From 43d8affcc8567e769614b3013e8d049778278e36 Mon Sep 17 00:00:00 2001
From: Elian Doran
Date: Sun, 2 Mar 2025 21:17:04 +0200
Subject: [PATCH 001/219] feat(i18n): translate unknown content widget message
---
src/public/app/widgets/type_widgets/content_widget.ts | 3 ++-
src/public/translations/en/translation.json | 3 +++
src/public/translations/ro/translation.json | 3 +++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/public/app/widgets/type_widgets/content_widget.ts b/src/public/app/widgets/type_widgets/content_widget.ts
index 0e9f3ca22..617967248 100644
--- a/src/public/app/widgets/type_widgets/content_widget.ts
+++ b/src/public/app/widgets/type_widgets/content_widget.ts
@@ -39,6 +39,7 @@ import EditorOptions from "./options/text_notes/editor.js";
import ShareSettingsOptions from "./options/other/share_settings.js";
import type FNote from "../../entities/fnote.js";
import type NoteContextAwareWidget from "../note_context_aware_widget.js";
+import { t } from "i18next";
const TPL = `
`;
export default class LanguageOptions extends OptionsWidget {
+ private $languagesContainer!: JQuery;
+
doRender() {
this.$widget = $(TPL);
+ this.$languagesContainer = this.$widget.find(".options-languages");
+ }
+
+ async optionsLoaded(options: OptionMap) {
+ const availableLocales = await server.get("options/locales");
+
+ this.$languagesContainer.empty();
+ for (const locale of availableLocales) {
+ const checkbox = $(`
").replace(/\r?\n/g,"
").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||r.includes("
"))&&(r=`
${r}
`),t=r),o=this.editor.data.htmlProcessor.toView(t)}var r;const s=new mi(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:i,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 i=this.editor.data.toModel(n.content,"$clipboardHolder");0!=i.childCount&&(t.stop(),e.change((()=>{this.fire("contentInsertion",{content:i,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((t,e)=>{e.resultRange=o._pasteFragmentWithMarkers(e.content)}),{priority:"low"})}_setupCopyCut(){const t=this.editor,e=t.model.document,n=t.editing.view.document,i=(t,n)=>{const i=n.dataTransfer;n.preventDefault(),this._fireOutputTransformationEvent(i,e.selection,t.name)};this.listenTo(n,"copy",i,{priority:"low"}),this.listenTo(n,"cut",((e,n)=>{t.model.canEditAt(t.model.document.selection)?i(e,n):n.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((e,i)=>{const o=t.data.toView(i.content);n.fire("clipboardOutput",{dataTransfer:i.dataTransfer,content:o,method:i.method})}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",WA(i.content))),"cut"==i.method&&t.model.deleteContent(e.selection)}),{priority:"low"})}}class c_ extends(Di()){_stack=[];add(t,e){const n=this._stack,i=n[0];this._insertDescriptor(t);const o=n[0];i===o||d_(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:e})}remove(t,e){const n=this._stack,i=n[0];this._removeDescriptor(t);const o=n[0];i===o||d_(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:e})}_insertDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t.id));if(d_(t,e[n]))return;n>-1&&e.splice(n,1);let i=0;for(;e[i]&&h_(e[i],t);)i++;e.splice(i,0,t)}_removeDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t));n>-1&&e.splice(n,1)}}function d_(t,e){return t&&e&&t.priority==e.priority&&u_(t.classes)==u_(e.classes)}function h_(t,e){return t.priority>e.priority||!(t.priorityu_(e.classes)}function u_(t){return Array.isArray(t)?t.sort().join(","):t}const m_='',g_="ck-widget_selected";function p_(t){return!!t.is("element")&&!!t.getCustomProperty("widget")}function f_(t,e,n={}){if(!t.is("containerElement"))throw new ki("widget-to-widget-wrong-element-type",null,{element:t});return e.setAttribute("contenteditable","false",t),e.addClass("ck-widget",t),e.setCustomProperty("widget",!0,t),t.getFillerOffset=v_,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 pm;return n.set("content",m_),n.render(),e.appendChild(n.element),e}));e.insert(e.createPositionAt(t,0),n),e.addClass(["ck-widget_with-selection-handle"],t)}(t,e),w_(t,e),t}function b_(t,e,n){if(e.classes&&n.addClass(tr(e.classes),t),e.attributes)for(const i in e.attributes)n.setAttribute(i,e.attributes[i],t)}function k_(t,e,n){if(e.classes&&n.removeClass(tr(e.classes),t),e.attributes)for(const i in e.attributes)n.removeAttribute(i,t)}function w_(t,e,n=b_,i=k_){const o=new c_;o.on("change:top",((e,o)=>{o.oldDescriptor&&i(t,o.oldDescriptor,o.writer),o.newDescriptor&&n(t,o.newDescriptor,o.writer)}));e.setCustomProperty("addHighlight",((t,e,n)=>o.add(e,n)),t),e.setCustomProperty("removeHighlight",((t,e,n)=>o.remove(e,n)),t)}function A_(t,e,n={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t),e.setAttribute("role","textbox",t),e.setAttribute("tabindex","-1",t),n.label&&e.setAttribute("aria-label",n.label,t),e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t),t.on("change:isReadOnly",((n,i,o)=>{e.setAttribute("contenteditable",o?"false":"true",t)})),t.on("change:isFocused",((n,i,o)=>{o?e.addClass("ck-editor__nested-editable_focused",t):e.removeClass("ck-editor__nested-editable_focused",t)})),w_(t,e),t}function __(t,e){const n=t.getSelectedElement();if(n){const i=B_(t);if(i)return e.createRange(e.createPositionAt(n,i))}return e.schema.findOptimalInsertionRange(t)}function C_(t,e){return(n,i)=>{const{mapper:o,viewPosition:r}=i,s=o.findMappedViewAncestor(r);if(!e(s))return;const a=o.toModelElement(s);i.modelPosition=t.createPositionAt(a,r.isAtStart?"before":"after")}}function v_(){return null}function y_(t){const e=t=>{const{width:e,paddingLeft:n,paddingRight:i}=t.ownerDocument.defaultView.getComputedStyle(t);return parseFloat(e)-(parseFloat(n)||0)-(parseFloat(i)||0)},n=t.parentElement;if(!n)return 0;let i=e(n);let o=0,r=n;for(;isNaN(i);){if(r=r.parentElement,++o>5)return 0;i=e(r)}return i}const x_="widget-type-around";function E_(t,e,n){return!!t&&p_(t)&&!n.isInline(e)}function B_(t){return t.getAttribute(x_)}var D_=n(8508),S_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(D_.A,S_);D_.A.locals;const T_=["before","after"],I_=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,P_="ck-widget__type-around_disabled";class V_ extends Lr{_currentFakeCaretModelElement=null;static get pluginName(){return"WidgetTypeAround"}static get requires(){return[pA,sw]}init(){const t=this.editor,e=t.editing.view;this.on("change:isEnabled",((n,i,o)=>{e.change((t=>{for(const n of e.document.roots)o?t.removeClass(P_,n):t.addClass(P_,n)})),o||t.model.change((t=>{t.removeSelectionAttribute(x_)}))})),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,i=n.editing.view,o=n.model.schema.getAttributesWithProperty(t,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(t,e),attributes:o}),i.focus(),i.scrollToTheSelection()}_listenToIfEnabled(t,e,n,i){this.listenTo(t,e,((...t)=>{this.isEnabled&&n(...t)}),i)}_insertParagraphAccordingToFakeCaretPosition(){const t=this.editor.model.document.selection,e=B_(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,i={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",((t,o,r)=>{const s=r.mapper.toViewElement(o.item);if(s&&E_(s,o.item,e)){!function(t,e,n){const i=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 T_){const i=new Ou({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(I_,!0)]});t.appendChild(i.render())}}(n,e),function(t){const e=new Ou({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});t.appendChild(e.render())}(n),n}));t.insert(t.createPositionAt(n,"end"),i)}(r.writer,i,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,i=e.schema,o=t.editing.view;function r(t){return`ck-widget_type-around_show-fake-caret_${t}`}this._listenToIfEnabled(o.document,"arrowKey",((t,e)=>{this._handleArrowKeyPress(t,e)}),{context:[p_,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((e,n)=>{n.directChange&&t.model.change((t=>{t.removeSelectionAttribute(x_)}))})),this._listenToIfEnabled(e.document,"change:data",(()=>{const e=n.getSelectedElement();if(e){if(E_(t.editing.mapper.toViewElement(e),e,i))return}t.model.change((t=>{t.removeSelectionAttribute(x_)}))})),this._listenToIfEnabled(t.editing.downcastDispatcher,"selection",((t,e,n)=>{const o=n.writer;if(this._currentFakeCaretModelElement){const t=n.mapper.toViewElement(this._currentFakeCaretModelElement);t&&(o.removeClass(T_.map(r),t),this._currentFakeCaretModelElement=null)}const s=e.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!E_(a,s,i))return;const l=B_(e.selection);l&&(o.addClass(r(l),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(t.ui.focusTracker,"change:isFocused",((e,n,i)=>{i||t.model.change((t=>{t.removeSelectionAttribute(x_)}))}))}_handleArrowKeyPress(t,e){const n=this.editor,i=n.model,o=i.document.selection,r=i.schema,s=n.editing.view,a=function(t,e){const n=Qo(t,e);return"down"===n||"right"===n}(e.keyCode,n.locale.contentLanguageDirection),l=s.document.selection.getSelectedElement();let c;E_(l,n.editing.mapper.toModelElement(l),r)?c=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):e.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(e.preventDefault(),t.stop())}_handleArrowKeyPressOnSelectedWidget(t){const e=this.editor.model,n=B_(e.document.selection);return e.change((e=>{if(!n)return e.setSelectionAttribute(x_,t?"after":"before"),!0;if(!(n===(t?"after":"before")))return e.removeSelectionAttribute(x_),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(t){const e=this.editor,n=e.model,i=n.schema,o=e.plugins.get("Widget"),r=o._getObjectElementNextToSelection(t);return!!E_(e.editing.mapper.toViewElement(r),r,i)&&(n.change((e=>{o._setSelectionOverElement(r),e.setSelectionAttribute(x_,t?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(t){const e=this.editor,n=e.model,i=n.schema,o=e.editing.mapper,r=n.document.selection,s=t?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!E_(o.toViewElement(s),s,i)&&(n.change((e=>{e.setSelection(s,"on"),e.setSelectionAttribute(x_,t?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const t=this.editor,e=t.editing.view;this._listenToIfEnabled(e.document,"mousedown",((n,i)=>{const o=i.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const r=function(t){return t.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),s=function(t,e){const n=t.closest(".ck-widget");return e.mapDomToView(n)}(o,e.domConverter),a=t.editing.mapper.toModelElement(s);this._insertParagraph(a,r),i.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const t=this.editor,e=t.model.document.selection,n=t.editing.view;this._listenToIfEnabled(n.document,"enter",((n,i)=>{if("atTarget"!=n.eventPhase)return;const o=e.getSelectedElement(),r=t.editing.mapper.toViewElement(o),s=t.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:E_(r,o,s)&&(this._insertParagraph(o,i.isSoft?"before":"after"),a=!0),a&&(i.preventDefault(),n.stop())}),{context:p_})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view.document;this._listenToIfEnabled(t,"insertText",((e,n)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(n.selection=t.selection)}),{priority:"high"}),Xn.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,i=n.schema;this._listenToIfEnabled(e.document,"delete",((e,o)=>{if("atTarget"!=e.eventPhase)return;const r=B_(n.document.selection);if(!r)return;const s=o.direction,a=n.document.selection.getSelectedElement(),l="forward"==s;if("before"===r===l)t.execute("delete",{selection:n.createSelection(a,"on")});else{const e=i.getNearestSelectionRange(n.createPositionAt(a,r),s);if(e)if(e.isCollapsed){const o=n.createSelection(e.start);if(n.modifySelection(o,{direction:s}),o.focus.isEqual(e.start)){const t=function(t,e){let n=e;for(const i of e.getAncestors({parentFirst:!0})){if(i.childCount>1||t.isLimit(i))break;n=i}return n}(i,e.start.parent);n.deleteContent(n.createSelection(t,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(e),t.execute(l?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(e),t.execute(l?"deleteForward":"delete")}))}o.preventDefault(),e.stop()}),{context:p_})}_enableInsertContentIntegration(){const t=this.editor,e=this.editor.model,n=e.document.selection;this._listenToIfEnabled(t.model,"insertContent",((t,[i,o])=>{if(o&&!o.is("documentSelection"))return;const r=B_(n);return r?(t.stop(),e.change((t=>{const o=n.getSelectedElement(),s=e.createPositionAt(o,r),a=t.createSelection(s),l=e.insertContent(i,a);return t.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"insertObject",((t,n)=>{const[,i,o={}]=n;if(i&&!i.is("documentSelection"))return;const r=B_(e);r&&(o.findOptimalPosition=r,n[3]=o)}),{priority:"high"})}_enableDeleteContentIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"deleteContent",((t,[n])=>{if(n&&!n.is("documentSelection"))return;B_(e)&&t.stop()}),{priority:"high"})}}function F_(t){const e=t.model;return(n,i)=>{const o=i.keyCode==Go.arrowup,r=i.keyCode==Go.arrowdown,s=i.shiftKey,a=e.document.selection;if(!o&&!r)return;const l=r;if(s&&function(t,e){return!t.isCollapsed&&t.isBackward==e}(a,l))return;const c=function(t,e,n){const i=t.model;if(n){const t=e.isCollapsed?e.focus:e.getLastPosition(),n=R_(i,t,"forward");if(!n)return null;const o=i.createRange(t,n),r=L_(i.schema,o,"backward");return r?i.createRange(t,r):null}{const t=e.isCollapsed?e.focus:e.getFirstPosition(),n=R_(i,t,"backward");if(!n)return null;const o=i.createRange(n,t),r=L_(i.schema,o,"forward");return r?i.createRange(r,t):null}}(t,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(s)return}(c.isCollapsed||function(t,e,n){const i=t.model,o=t.view.domConverter;if(n){const t=i.createSelection(e.start);i.modifySelection(t),t.focus.isAtEnd||e.start.isEqual(t.focus)||(e=i.createRange(t.focus,e.end))}const r=t.mapper.toViewRange(e),s=o.viewRangeToDom(r),a=bo.getDomRangeRects(s);let l;for(const t of a)if(void 0!==l){if(Math.round(t.top)>=l)return!1;l=Math.max(l,Math.round(t.bottom))}else l=Math.round(t.bottom);return!0}(t,c,l))&&(e.change((t=>{const n=l?c.end:c.start;if(s){const i=e.createSelection(a.anchor);i.setFocus(n),t.setSelection(i)}else t.setSelection(n)})),n.stop(),i.preventDefault(),i.stopPropagation())}}}function R_(t,e,n){const i=t.schema,o=t.createRangeIn(e.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:t,item:s,type:a}of o.getWalker({startPosition:e,direction:n})){if(i.isLimit(s)&&!i.isInline(s))return t;if(a==r&&i.isBlock(s))return null}return null}function L_(t,e,n){const i="backward"==n?e.end:e.start;if(t.checkChild(i,"$text"))return i;for(const{nextPosition:i}of e.getWalker({direction:n}))if(t.checkChild(i,"$text"))return i;return null}var z_=n(695),M_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(z_.A,M_);z_.A.locals;class O_ extends Lr{_previouslySelected=new Set;static get pluginName(){return"Widget"}static get requires(){return[V_,sw]}init(){const t=this.editor,e=t.editing.view,n=e.document,i=t.t;this.editor.editing.downcastDispatcher.on("selection",((e,n,i)=>{const o=i.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=t.editing.mapper.toViewElement(s);var l;p_(a)&&(i.consumable.consume(r,"selection")&&o.setSelection(o.createRangeOn(a),{fake:!0,label:(l=a,l.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 i=n.writer,o=i.document.selection;let r=null;for(const t of o.getRanges())for(const e of t){const t=e.item;p_(t)&&!N_(t,r)&&(i.addClass(g_,t),this._previouslySelected.add(t),r=t)}}),{priority:"low"}),e.addObserver(Hh),this.listenTo(n,"mousedown",((...t)=>this._onMousedown(...t))),this.listenTo(n,"arrowKey",((...t)=>{this._handleSelectionChangeOnArrowKeyPress(...t)}),{context:[p_,"$text"]}),this.listenTo(n,"arrowKey",((...t)=>{this._preventDefaultOnArrowKeyPress(...t)}),{context:"$root"}),this.listenTo(n,"arrowKey",F_(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((t,e)=>{this._handleDelete("forward"==e.direction)&&(e.preventDefault(),t.stop())}),{context:"$root"}),this.listenTo(n,"tab",((t,e)=>{"atTarget"==t.eventPhase&&(e.shiftKey||this._selectFirstNestedEditable()&&(e.preventDefault(),t.stop()))}),{context:p_,priority:"low"}),this.listenTo(n,"tab",((t,e)=>{e.shiftKey&&this._selectAncestorWidget()&&(e.preventDefault(),t.stop())}),{priority:"low"}),this.listenTo(n,"keydown",((t,e)=>{e.keystroke==Go.esc&&this._selectAncestorWidget()&&(e.preventDefault(),t.stop())}),{priority:"low"}),t.accessibility.addKeystrokeInfoGroup({id:"widget",label:i("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:i("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:i("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:i("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:i("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:i("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(t,e){const n=this.editor,i=n.editing.view,o=i.document;let r=e.target;if(!r)return;if(e.domEvent.detail>=3)return void(this._selectBlockContent(r)&&e.preventDefault());if(!p_(r)){const t=function(t){let e=t;for(;e;){if(e.is("editableElement")||p_(e))return e;e=e.parent}return null}(r);if(!t)return;if(p_(t))r=t;else{const t=function(t,e){const n=uo(e.domEvent);let i=null;i=n?t.domConverter.domRangeToView(n):t.createRange(t.createPositionAt(e.target,0));if(!i)return null;const o=i.start;if(!o.parent)return null;let r=o.parent;o.parent.is("editableElement")&&(o.isAtEnd&&o.nodeBefore?r=o.nodeBefore:o.isAtStart&&o.nodeAfter&&(r=o.nodeAfter));if(r.is("$text"))return r.parent;return r}(i,e);if(!t||!p_(t))return;r=t}}Xn.isAndroid&&e.preventDefault(),o.isFocused||i.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_selectBlockContent(t){const e=this.editor,n=e.model,i=e.editing.mapper,o=n.schema,r=i.findMappedViewAncestor(this.editor.editing.view.createPositionAt(t,0)),s=function(t,e){for(const n of t.getAncestors({includeSelf:!0,parentFirst:!0})){if(e.checkChild(n,"$text"))return n;if(e.isLimit(n)&&!e.isObject(n))break}return null}(i.toModelElement(r),n.schema);return!!s&&(n.change((t=>{const e=o.isLimit(s)?null:function(t,e){const n=new Wl({startPosition:t});for(const{item:t}of n){if(e.isLimit(t)||!t.is("element"))return null;if(e.checkChild(t,"$text"))return t}return null}(t.createPositionAfter(s),o),n=t.createPositionAt(s,0),i=e?t.createPositionAt(e,0):t.createPositionAt(s,"end");t.setSelection(t.createRange(n,i))})),!0)}_handleSelectionChangeOnArrowKeyPress(t,e){const n=e.keyCode,i=this.editor.model,o=i.schema,r=i.document.selection,s=r.getSelectedElement(),a=Qo(n,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(s&&o.isObject(s)){const n=l?r.getLastPosition():r.getFirstPosition(),s=o.getNearestSelectionRange(n,l?"forward":"backward");return void(s&&(i.change((t=>{t.setSelection(s)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed&&!e.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,c=s.nodeBefore;return void((a&&o.isObject(a)||c&&o.isObject(c))&&(i.change((t=>{t.setSelection(l?s:n)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(l);if(d&&o.isObject(d)){if(o.isInline(d)&&c)return;this._setSelectionOverElement(d),e.preventDefault(),t.stop()}}_preventDefaultOnArrowKeyPress(t,e){const n=this.editor.model,i=n.schema,o=n.document.selection.getSelectedElement();o&&i.isObject(o)&&(e.preventDefault(),t.stop())}_handleDelete(t){const e=this.editor.model.document.selection;if(!this.editor.model.canEditAt(e))return;if(!e.isCollapsed)return;const n=this._getObjectElementNextToSelection(t);return n?(this.editor.model.change((t=>{let i=e.anchor.parent;for(;i.isEmpty;){const e=i;i=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,i=e.document.selection,o=e.createSelection(i);if(e.modifySelection(o,{direction:t?"forward":"backward"}),o.isEqual(i))return null;const r=t?o.focus.nodeBefore:o.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass(g_,e);this._previouslySelected.clear()}_selectFirstNestedEditable(){const t=this.editor,e=this.editor.editing.view.document;for(const n of e.selection.getFirstRange().getItems())if(n.is("editableElement")){const e=t.editing.mapper.toModelElement(n);if(!e)continue;const i=t.model.createPositionAt(e,0),o=t.model.schema.getNearestSelectionRange(i,"forward");return t.model.change((t=>{t.setSelection(o)})),!0}return!1}_selectAncestorWidget(){const t=this.editor,e=t.editing.mapper,n=t.editing.view.document.selection.getFirstPosition().parent,i=(n.is("$text")?n.parent:n).findAncestor(p_);if(!i)return!1;const o=e.toModelElement(i);return!!o&&(t.model.change((t=>{t.setSelection(o,"on")})),!0)}}function N_(t,e){return!!e&&Array.from(t.getAncestors()).includes(e)}class H_ extends Lr{_toolbarDefinitions=new Map;_balloon;static get requires(){return[yb]}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||!p_(e))})(t.editing.view.document.selection)&&e.stop()}),{priority:"high"})}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:i,balloonClassName:o="ck-toolbar-container"}){if(!n.length)return void wi("widget-toolbar-no-items",{toolbarId:t});const r=this.editor,s=r.t,a=new bp(r.locale);if(a.ariaLabel=e||s("Widget toolbar"),this._toolbarDefinitions.has(t))throw new ki("widget-toolbar-duplicated",this,{toolbarId:t});const l={view:a,getRelatedElement:i,balloonClassName:o,itemsConfig:n,initialized:!1};r.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const t=i(r.editing.view.document.selection);t&&this._showToolbar(l,t)},afterBlur:()=>{this._hideToolbar(l)}}),this._toolbarDefinitions.set(t,l)}_updateToolbarsVisibility(){let t=0,e=null,n=null;for(const i of this._toolbarDefinitions.values()){const o=i.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const r=o.getAncestors().length;r>t&&(t=r,e=o,n=i)}else this._isToolbarVisible(i)&&this._hideToolbar(i);else this._isToolbarInBalloon(i)&&this._hideToolbar(i)}n&&this._showToolbar(n,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?j_(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:q_(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);j_(this.editor,e)}})))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function j_(t,e){const n=t.plugins.get("ContextualBalloon"),i=q_(t,e);n.updatePosition(i)}function q_(t,e){const n=t.editing.view,i=rp.defaultPositions;return{target:n.domConverter.mapViewToDom(e),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class W_ extends(ji()){_referenceCoordinates;_options;_originalWidth;_originalHeight;_originalWidthPercents;_aspectRatio;constructor(t){super(),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=t,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(t,e,n){const i=new bo(e);this.activeHandlePosition=function(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const n of e)if(t.classList.contains(U_(n)))return n}(t),this._referenceCoordinates=function(t,e){const n=new bo(t),i=e.split("-"),o={x:"right"==i[1]?n.right:n.left,y:"bottom"==i[0]?n.bottom:n.top};return o.x+=t.ownerDocument.defaultView.scrollX,o.y+=t.ownerDocument.defaultView.scrollY,o}(e,function(t){const e=t.split("-"),n={top:"bottom",bottom:"top",left:"right",right:"left"};return`${n[e[0]]}-${n[e[1]]}`}(this.activeHandlePosition)),this._originalWidth=i.width,this._originalHeight=i.height,this._aspectRatio=i.width/i.height;const o=n.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(o):this._originalWidthPercents=function(t,e=new bo(t)){const n=y_(t);return n?e.width/n*100:0}(n,i)}update(t){this.proposedWidth=t.width,this.proposedHeight=t.height,this.proposedWidthPercents=t.widthPercents,this.proposedHandleHostWidth=t.handleHostWidth,this.proposedHandleHostHeight=t.handleHostHeight}}function U_(t){return`ck-widget__resizer__handle-${t}`}class $_ extends lm{constructor(){super();const t=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",t.to("_viewPosition",(t=>t?`ck-orientation-${t}`:""))],style:{display:t.if("_isVisible","none",(t=>!t))}},children:[{text:t.to("_label")}]})}_bindToState(t,e){this.bind("_isVisible").to(e,"proposedWidth",e,"proposedHeight",((t,e)=>null!==t&&null!==e)),this.bind("_label").to(e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",e,"proposedWidthPercents",((e,n,i)=>"px"===t.unit?`${e}×${n}`:`${i}%`)),this.bind("_viewPosition").to(e,"activeHandlePosition",e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",((t,e,n)=>e<50||n<50?"above-center":t))}_dismiss(){this.unbind(),this._isVisible=!1}}class G_ extends(ji()){_state;_sizeView;_options;_viewResizerWrapper=null;_initialViewWidth;constructor(t){super(),this._options=t,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",((t,e)=>t&&e)),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(t=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),t.stop())}),{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change((t=>{t.removeClass("ck-hidden",this._viewResizerWrapper)}))}hide(){this._options.editor.editing.view.change((t=>{t.addClass("ck-hidden",this._viewResizerWrapper)}))}attach(){const t=this,e=this._options.viewElement;this._options.editor.editing.view.change((n=>{const i=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(e){const n=this.toDomElement(e);return t._appendHandles(n),t._appendSizeUI(n),n}));n.insert(n.createPositionAt(e,"end"),i),n.addClass("ck-widget_with-resizer",e),this._viewResizerWrapper=i,this.isVisible||this.hide()})),this.on("change:isVisible",(()=>{this.isVisible?(this.show(),this.redraw()):this.hide()}))}begin(t){this._state=new W_(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(t,this._getHandleHost(),this._getResizeHost())}updateSize(t){const e=this._proposeNewSize(t);this._options.editor.editing.view.change((t=>{const n=this._options.unit||"%",i=("%"===n?e.widthPercents:e.width)+n;t.setStyle("width",i,this._options.viewElement)}));const n=this._getHandleHost(),i=new bo(n),o=Math.round(i.width),r=Math.round(i.height),s=new bo(n);e.width=Math.round(s.width),e.height=Math.round(s.height),this.redraw(i),this.state.update({...e,handleHostWidth:o,handleHostHeight:r})}commit(){const t=this._options.unit||"%",e=("%"===t?this.state.proposedWidthPercents:this.state.proposedWidth)+t;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(e)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(t){const e=this._domResizerWrapper;if(!((n=e)&&n.ownerDocument&&n.ownerDocument.contains(n)))return;var n;const i=e.parentElement,o=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(i.isSameNode(o)){const e=t||new bo(o);a=[e.width+"px",e.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];"same"!==Zi(s,a)&&this._options.editor.editing.view.change((t=>{t.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)}))}containsHandle(t){return this._domResizerWrapper.contains(t)}static isResizeHandle(t){return t.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(t){const e=this.state,n={x:(i=t).pageX,y:i.pageY};var i;const o=!this._options.isCentered||this._options.isCentered(this),r={x:e._referenceCoordinates.x-(n.x+e.originalWidth),y:n.y-e.originalHeight-e._referenceCoordinates.y};o&&e.activeHandlePosition.endsWith("-right")&&(r.x=n.x-(e._referenceCoordinates.x+e.originalWidth)),o&&(r.x*=2);let s=Math.abs(e.originalWidth+r.x),a=Math.abs(e.originalHeight+r.y);return"width"==(s/e.aspectRatio>a?"width":"height")?a=s/e.aspectRatio:s=a*e.aspectRatio,{width:Math.round(s),height:Math.round(a),widthPercents:Math.min(Math.round(e.originalWidthPercents/e.originalWidth*s*100)/100,100)}}_getResizeHost(){const t=this._domResizerWrapper.parentElement;return this._options.getResizeHost(t)}_getHandleHost(){const t=this._domResizerWrapper.parentElement;return this._options.getHandleHost(t)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const i of e)t.appendChild(new Ou({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(n=i,`ck-widget__resizer__handle-${n}`)}}).render());var n}_appendSizeUI(t){this._sizeView=new $_,this._sizeView.render(),t.appendChild(this._sizeView.element)}}var K_=n(4095),Z_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(K_.A,Z_);K_.A.locals;class Y_ extends Lr{_resizers=new Map;_observer;_redrawSelectedResizerThrottled;static get pluginName(){return"WidgetResize"}init(){const t=this.editor.editing,e=Yn.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),t.view.addObserver(Hh),this._observer=new(ro()),this.listenTo(t.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=R((()=>this.redrawSelectedResizer()),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[t,e]of this._resizers)t.isAttached()||(this._resizers.delete(t),e.destroy())}),{priority:"lowest"}),this._observer.listenTo(Yn.window,"resize",this._redrawSelectedResizerThrottled);const n=this.editor.editing.view.document.selection;n.on("change",(()=>{const t=n.getSelectedElement(),e=this.getResizerByViewElement(t)||null;e?this.select(e):this.deselect()}))}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(const t of this._resizers.values())t.destroy();this._redrawSelectedResizerThrottled.cancel()}select(t){this.deselect(),this.selectedResizer=t,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(t){const e=new G_(t),n=this.editor.plugins;if(e.attach(),n.has("WidgetToolbarRepository")){const t=n.get("WidgetToolbarRepository");e.on("begin",(()=>{t.forceDisabled("resize")}),{priority:"lowest"}),e.on("cancel",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"}),e.on("commit",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(t.viewElement,e);const i=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(i)==e&&this.select(e),e}getResizerByViewElement(t){return this._resizers.get(t)}_getResizerByHandle(t){for(const e of this._resizers.values())if(e.containsHandle(t))return e}_mouseDownListener(t,e){const n=e.domTarget;G_.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n)||null,this._activeResizer&&(this._activeResizer.begin(n),t.stop(),e.preventDefault()))}_mouseMoveListener(t,e){this._activeResizer&&this._activeResizer.updateSize(e)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}const J_=yo("px");class Q_ extends lm{constructor(){super();const t=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",t.if("isVisible","ck-hidden",(t=>!t))],style:{left:t.to("left",(t=>J_(t))),top:t.to("top",(t=>J_(t))),width:t.to("width",(t=>J_(t)))}}})}}class X_ extends Lr{removeDropMarkerDelayed=Tr((()=>this.removeDropMarker()),40);_updateDropMarkerThrottled=R((t=>this._updateDropMarker(t)),40);_reconvertMarkerThrottled=R((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0);_dropTargetLineView=new Q_;_domEmitter=new(ro());_scrollables=new Map;static get pluginName(){return"DragDropTarget"}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:t}of this._scrollables.values())t.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(t,e,n,i,o,r){this.removeDropMarkerDelayed.cancel();const s=tC(this.editor,t,e,n,i,o,r);if(s)return r&&r.containsRange(s)?this.removeDropMarker():void this._updateDropMarkerThrottled(s)}getFinalDropRange(t,e,n,i,o,r){const s=tC(this.editor,t,e,n,i,o,r);return this.removeDropMarker(),s}removeDropMarker(){const t=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,t.markers.has("drop-target")&&t.change((t=>{t.removeMarker("drop-target")}))}_setupDropMarker(){const t=this.editor;t.ui.view.body.add(this._dropTargetLineView),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 this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(n);e.markerRange.isCollapsed?this._updateDropTargetLine(e.markerRange):this._dropTargetLineView.isVisible=!1}})}_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})}))}_createDropTargetPosition(t){return t.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(t){const e=this.toDomElement(t);return e.append("",t.createElement("span"),""),e}))}_updateDropTargetLine(t){const e=this.editor.editing,n=t.start.nodeBefore,i=t.start.nodeAfter,o=t.start.parent,r=n?e.mapper.toViewElement(n):null,s=r?e.view.domConverter.mapViewToDom(r):null,a=i?e.mapper.toViewElement(i):null,l=a?e.view.domConverter.mapViewToDom(a):null,c=e.mapper.toViewElement(o);if(!c)return;const d=e.view.domConverter.mapViewToDom(c),h=this._getScrollableRect(c),{scrollX:u,scrollY:m}=Yn.window,g=s?new bo(s):null,p=l?new bo(l):null,f=new bo(d).excludeScrollbarsAndBorders(),b=g?g.bottom:f.top,k=p?p.top:f.bottom,w=Yn.window.getComputedStyle(d),A=b<=k?(b+k)/2:k;if(h.topa.schema.checkChild(r,t)))){if(a.schema.checkChild(r,"$text"))return a.createRange(r);if(e)return nC(t,oC(t,e.parent),i,o)}}}else if(a.schema.isInline(c))return nC(t,c,i,o);if(a.schema.isBlock(c))return nC(t,c,i,o);if(a.schema.checkChild(c,"$block")){const e=Array.from(c.getChildren()).filter((e=>e.is("element")&&!eC(t,e)));let n=0,r=e.length;if(0==r)return a.createRange(a.createPositionAt(c,"end"));for(;n{n?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),Xn.isAndroid&&this.forceDisabled("noAndroidSupport"),t.plugins.has("BlockToolbar")){const e=t.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(e,"dragstart",((t,e)=>this._handleBlockDragStart(e))),this._domEmitter.listenTo(Yn.document,"dragover",((t,e)=>this._handleBlockDragging(e))),this._domEmitter.listenTo(Yn.document,"drop",((t,e)=>this._handleBlockDragging(e))),this._domEmitter.listenTo(Yn.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&e.setAttribute("draggable","true"),this.on("change:isEnabled",((t,n,i)=>{e.setAttribute("draggable",i?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(t){if(!this.isEnabled)return;const e=this.editor.model,n=e.document.selection,i=this.editor.editing.view,o=Array.from(n.getSelectedBlocks()),r=e.createRange(e.createPositionBefore(o[0]),e.createPositionAfter(o[o.length-1]));e.change((t=>t.setSelection(r))),this._isBlockDragging=!0,i.focus(),i.getObserver(HA).onDomEvent(t)}_handleBlockDragging(t){if(!this.isEnabled||!this._isBlockDragging)return;const e=t.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),n=t.clientY,i=document.elementFromPoint(e,n),o=this.editor.editing.view;i&&i.closest(".ck-editor__editable")&&o.getObserver(HA).onDomEvent({...t,type:t.type,dataTransfer:t.dataTransfer,target:i,clientX:e,clientY:n,preventDefault:()=>t.preventDefault(),stopPropagation:()=>t.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}var sC=n(7793),aC={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(sC.A,aC);sC.A.locals;class lC extends Lr{_draggedRange;_draggingUid;_draggableElement;_clearDraggableAttributesDelayed=Tr((()=>this._clearDraggableAttributes()),40);_blockMode=!1;_domEmitter=new(ro());_previewContainer;static get pluginName(){return"DragDrop"}static get requires(){return[l_,O_,X_,rC]}init(){const t=this.editor,e=t.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,e.addObserver(HA),e.addObserver(Hh),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),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)})),Xn.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const t=this.editor,e=t.model,n=t.editing.view,i=n.document,o=t.plugins.get(X_);this.listenTo(i,"dragstart",((t,n)=>{if(n.target&&n.target.is("editableElement"))return void n.preventDefault();if(this._prepareDraggedRange(n.target),!this._draggedRange)return void n.preventDefault();this._draggingUid=pi(),n.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",n.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const i=e.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(n.dataTransfer,i,"dragstart");const{dataTransfer:o,domTarget:r,domEvent:s}=n,{clientX:a}=s;this._updatePreview({dataTransfer:o,domTarget:r,clientX:a}),n.stopPropagation(),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._domEmitter.listenTo(Yn.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(i,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(i,"dragleave",(()=>{o.removeDropMarkerDelayed()})),this.listenTo(i,"dragging",((t,e)=>{if(!this.isEnabled)return void(e.dataTransfer.dropEffect="none");const{clientX:n,clientY:i}=e.domEvent;o.updateDropMarker(e.target,e.targetRanges,n,i,this._blockMode,this._draggedRange),this._draggedRange||(e.dataTransfer.dropEffect="copy"),Xn.isGecko||("copy"==e.dataTransfer.effectAllowed?e.dataTransfer.dropEffect="copy":["all","copyMove"].includes(e.dataTransfer.effectAllowed)&&(e.dataTransfer.dropEffect="move")),t.stop()}),{priority:"low"})}_setupClipboardInputIntegration(){const t=this.editor,e=t.editing.view.document,n=t.plugins.get(X_);this.listenTo(e,"clipboardInput",((e,i)=>{if("drop"!=i.method)return;const{clientX:o,clientY:r}=i.domEvent,s=n.getFinalDropRange(i.target,i.targetRanges,o,r,this._blockMode,this._draggedRange);if(!s)return this._finalizeDragging(!1),void e.stop();this._draggedRange&&this._draggingUid!=i.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==cC(i.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(s,!0))return this._finalizeDragging(!1),void e.stop();i.targetRanges=[t.editing.mapper.toViewRange(s)]}),{priority:"high"})}_setupContentInsertionIntegration(){const t=this.editor.plugins.get(l_);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"==cC(e.dataTransfer),i=!e.resultRange||!e.resultRange.isCollapsed;this._finalizeDragging(i&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const t=this.editor,e=t.editing.view,n=e.document;this.listenTo(n,"mousedown",((i,o)=>{if(Xn.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=dC(o.target);if(Xn.isBlink&&!t.isReadOnly&&!r&&!n.selection.isCollapsed){const t=n.selection.getSelectedElement();t&&p_(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",(()=>{Xn.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}))}_finalizeDragging(t){const e=this.editor,n=e.model;if(e.plugins.get(X_).removeDropMarker(),this._clearDraggableAttributes(),e.plugins.has("WidgetToolbarRepository")){e.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(t&&this.isEnabled&&n.change((t=>{const e=n.createSelection(this._draggedRange);n.deleteContent(e,{doNotAutoparagraph:!0});const i=e.getFirstPosition().parent;i.isEmpty&&!n.schema.checkChild(i,"$text")&&n.schema.checkChild(i,"paragraph")&&t.insertElement("paragraph",i,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(t){const e=this.editor,n=e.model,i=n.document.selection,o=t?dC(t):null;if(o){const t=e.editing.mapper.toModelElement(o);if(this._draggedRange=uc.fromRange(n.createRangeOn(t)),this._blockMode=n.schema.isBlock(t),e.plugins.has("WidgetToolbarRepository")){e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(i.isCollapsed&&!i.getFirstPosition().parent.isEmpty)return;const r=Array.from(i.getSelectedBlocks()),s=i.getFirstRange();if(0==r.length)return void(this._draggedRange=uc.fromRange(s));const a=hC(n,r);if(r.length>1)this._draggedRange=uc.fromRange(a),this._blockMode=!0;else if(1==r.length){const t=s.start.isTouching(a.start)&&s.end.isTouching(a.end);this._draggedRange=uc.fromRange(t?a:s),this._blockMode=t}n.change((t=>t.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:t,domTarget:e,clientX:n}){const i=this.editor.editing.view,o=i.document.selection.editableElement,r=i.domConverter.mapViewToDom(o),s=Yn.window.getComputedStyle(r);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=Qi(Yn.document,"div",{style:"position: fixed; left: -999999px;"}),Yn.document.body.appendChild(this._previewContainer));const a=new bo(r);if(r.contains(e))return;const l=parseFloat(s.paddingLeft),c=Qi(Yn.document,"div");c.className="ck ck-content",c.style.width=s.width,c.style.paddingLeft=`${a.left-n+l}px`,Xn.isiOS&&(c.style.backgroundColor="white"),i.domConverter.setContentOf(c,t.getData("text/html")),t.setDragImage(c,0,0),this._previewContainer.appendChild(c)}}function cC(t){return Xn.isGecko?t.dropEffect:["all","copyMove"].includes(t.effectAllowed)?"move":"copy"}function dC(t){if(t.is("editableElement"))return null;if(t.hasClass("ck-widget__selection-handle"))return t.findAncestor(p_);if(p_(t))return t;const e=t.findAncestor((t=>p_(t)||t.is("editableElement")));return p_(e)?e:null}function hC(t,e){const n=e[0],i=e[e.length-1],o=n.getCommonAncestor(i),r=t.createPositionBefore(n),s=t.createPositionAfter(i);if(o&&o.is("element")&&!t.schema.isLimit(o)){const e=t.createRangeOn(o),n=r.isTouching(e.start),i=s.isTouching(e.end);if(n&&i)return hC(t,[o])}return t.createRange(r,s)}class uC extends Lr{static get pluginName(){return"PastePlainText"}static get requires(){return[l_]}init(){const t=this.editor,e=t.model,n=t.editing.view,i=e.document.selection;n.addObserver(HA),t.plugins.get(l_).on("contentInsertion",((t,n)=>{(function(t,e){let n=e.createRangeIn(t);if(1==t.childCount){const i=t.getChild(0);i.is("element")&&e.schema.isBlock(i)&&!e.schema.isObject(i)&&!e.schema.isLimit(i)&&(n=e.createRangeIn(i))}for(const t of n.getItems()){if(!e.schema.isInline(t))return!1;if(Array.from(t.getAttributeKeys()).find((t=>e.schema.getAttributeProperties(t).isFormatting)))return!1}return!0})(n.content,e)&&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 n of r.getItems())for(const i of o)e.schema.checkAttribute(n,i[0])&&t.setAttribute(i[0],i[1],n)}))}))}}class mC extends Lr{static get pluginName(){return"Clipboard"}static get requires(){return[a_,l_,lC,uC]}init(){const t=this.editor,e=this.editor.t;t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Copy selected content"),keystroke:"CTRL+C"},{label:e("Paste content"),keystroke:"CTRL+V"},{label:e("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}class gC extends Mr{_stack=[];_createdBatches=new WeakSet;constructor(t){super(t),this.refresh(),this._isEnabledBasedOnSelection=!1,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}get createdBatches(){return this._createdBatches}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 i=this.editor.model,o=i.document,r=[],s=t.map((t=>t.getTransformedByOperations(n))),a=s.flat();for(const t of s){const e=t.filter((t=>t.root!=o.graveyard)).filter((t=>!fC(t,a)));e.length&&(pC(e),r.push(e[0]))}r.length&&i.change((t=>{t.setSelection(r,{backward:e})}))}_undo(t,e){const n=this.editor.model,i=n.document;this._createdBatches.add(e);const o=t.operations.slice().filter((t=>t.isDocumentOperation));o.reverse();for(const t of o){const o=t.baseVersion+1,r=Array.from(i.history.getOperations(o)),s=Gd([t.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let o of s){const r=o.affectedSelectable;r&&!n.canEditAt(r)&&(o=new zd(o.baseVersion)),e.addOperation(o),n.applyOperation(o),i.history.setOperationAsUndone(t,o)}}}}function pC(t){t.sort(((t,e)=>t.start.isBefore(e.start)?-1:1));for(let e=1;ee!==t&&e.containsRange(t,!0)))}class bC extends gC{execute(t=null){const e=t?this._stack.findIndex((e=>e.batch==t)):this._stack.length-1,n=this._stack.splice(e,1)[0],i=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(i,(()=>{this._undo(n.batch,i);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,i),this.refresh()}}class kC extends gC{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,i=this.editor.model.document.history.getOperations(n);this._restoreSelection(t.selection.ranges,t.selection.isBackward,i),this._undo(t.batch,e)})),this.refresh()}}class wC extends Lr{_undoCommand;_redoCommand;_batchRegistry=new WeakSet;static get pluginName(){return"UndoEditing"}init(){const t=this.editor,e=t.t;this._undoCommand=new bC(t),this._redoCommand=new kC(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 i=n.batch,o=this._redoCommand.createdBatches.has(i),r=this._undoCommand.createdBatches.has(i);this._batchRegistry.has(i)||(this._batchRegistry.add(i),i.isUndoable&&(o?this._undoCommand.addBatch(i):r||(this._undoCommand.addBatch(i),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"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Undo"),keystroke:"CTRL+Z"},{label:e("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class AC extends Lr{static get pluginName(){return"UndoUI"}init(){const t=this.editor,e=t.locale,n=t.t,i="ltr"==e.uiLanguageDirection?zu.undo:zu.redo,o="ltr"==e.uiLanguageDirection?zu.redo:zu.undo;this._addButtonsToFactory("undo",n("Undo"),"CTRL+Z",i),this._addButtonsToFactory("redo",n("Redo"),"CTRL+Y",o)}_addButtonsToFactory(t,e,n,i){const o=this.editor;o.ui.componentFactory.add(t,(()=>{const o=this._createButton(wm,t,e,n,i);return o.set({tooltip:!0}),o})),o.ui.componentFactory.add("menuBar:"+t,(()=>this._createButton(Ym,t,e,n,i)))}_createButton(t,e,n,i,o){const r=this.editor,s=r.locale,a=r.commands.get(e),l=new t(s);return l.set({label:n,icon:o,keystroke:i}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",(()=>{r.execute(e),r.editing.view.focus()})),l}}class _C extends Lr{static get requires(){return[wC,AC]}static get pluginName(){return"Undo"}}function CC(t){return t.createContainerElement("figure",{class:"image"},[t.createEmptyElement("img"),t.createSlot("children")])}function vC(t,e){const n=t.plugins.get("ImageUtils"),i=t.plugins.has("ImageInlineEditing")&&t.plugins.has("ImageBlockEditing");return t=>{if(!n.isInlineImageView(t))return null;if(!i)return o(t);return("block"==t.getStyle("display")||t.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline")!==e?null:o(t)};function o(t){const e={name:!0};return t.hasAttribute("src")&&(e.attributes=["src"]),e}}function yC(t,e){const n=Er(e.getSelectedBlocks());return!n||t.isObject(n)||n.isEmpty&&"listItem"!=n.name?"imageBlock":"imageInline"}function xC(t){return t&&t.endsWith("px")?parseInt(t):null}function EC(t){const e=xC(t.getStyle("width")),n=xC(t.getStyle("height"));return!(!e||!n)}const BC=/^(image|image-inline)$/;class DC extends Lr{_domEmitter=new(ro());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,i={}){const o=this.editor,r=o.model,s=r.document.selection,a=SC(o,e||s,n);t={...Object.fromEntries(s.getAttributes()),...t};for(const e in t)r.schema.checkAttribute(a,e)||delete t[e];return r.change((n=>{const{setImageSizes:o=!0}=i,s=n.createElement(a,t);return r.insertObject(s,e,null,{setSelection:"on",findOptimalPosition:e||"imageInline"==a?void 0:"auto"}),s.parent?(o&&this.setImageNaturalSizeAttributes(s),s):null}))}setImageNaturalSizeAttributes(t){const e=t.getAttribute("src");e&&(t.getAttribute("width")||t.getAttribute("height")||this.editor.model.change((n=>{const i=new Yn.window.Image;this._domEmitter.listenTo(i,"load",(()=>{t.getAttribute("width")||t.getAttribute("height")||this.editor.model.enqueueChange(n.batch,(e=>{e.setAttribute("width",i.naturalWidth,t),e.setAttribute("height",i.naturalHeight,t)})),this._domEmitter.stopListening(i,"load")})),i.src=e})))}getClosestSelectedImageWidget(t){const e=t.getFirstPosition();if(!e)return null;const n=t.getSelectedElement();if(n&&this.isImageWidget(n))return n;let i=e.parent;for(;i;){if(i.is("element")&&this.isImageWidget(i))return i;i=i.parent}return null}getClosestSelectedImageElement(t){const e=t.getSelectedElement();return this.isImage(e)?e:t.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(t){return t.findAncestor({classes:BC})}isImageAllowed(){const t=this.editor.model.document.selection;return function(t,e){const n=SC(t,e,null);if("imageBlock"==n){const n=function(t,e){const n=__(t,e),i=n.start.parent;if(i.isEmpty&&!i.is("element","$root"))return i.parent;return i}(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){e.setCustomProperty("image",!0,t);return f_(t,e,{label:()=>{const e=this.findViewImgElement(t).getAttribute("alt");return e?`${e} ${n}`:n}})}isImageWidget(t){return!!t.getCustomProperty("image")&&p_(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}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function SC(t,e,n){const i=t.model.schema,o=t.config.get("image.insert.type");return t.plugins.has("ImageBlockEditing")?t.plugins.has("ImageInlineEditing")?n||("inline"===o?"imageInline":"auto"!==o?"imageBlock":e.is("selection")?yC(i,e):i.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class TC extends Mr{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"),i=e.model,o=n.getClosestSelectedImageElement(i.document.selection);i.change((e=>{e.setAttribute("alt",t.newValue,o)}))}}class IC extends Lr{static get requires(){return[DC]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new TC(this.editor))}}var PC=n(4062),VC={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(PC.A,VC);PC.A.locals;class FC extends lm{focusTracker;keystrokes;labeledInput;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(t){super(t);const e=this.locale.t;this.focusTracker=new Br,this.keystrokes=new Dr,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(e("Save"),zu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(e("Cancel"),zu.cancel,"ck-button-cancel","cancel"),this._focusables=new Mu,this._focusCycler=new ym({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),hm({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,i){const o=new wm(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createLabeledInputView(){const t=this.locale.t,e=new Sg(this.locale,Rp);return e.label=t("Text alternative"),e}}function RC(t){const e=t.editing.view,n=rp.defaultPositions,i=t.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(i.getClosestSelectedImageWidget(e.document.selection)),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class LC extends Lr{_balloon;_form;static get requires(){return[yb]}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 i=t.commands.get("imageTextAlternative"),o=new wm(n);return o.set({label:e("Change image text alternative"),icon:zu.textAlternative,tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled"),o.bind("isOn").to(i,"value",(t=>!!t)),this.listenTo(o,"execute",(()=>{this._showForm()})),o}))}_createForm(){const t=this.editor,e=t.editing.view.document,n=t.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(dm(FC))(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",(()=>{n.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=RC(t);e.updatePosition(n)}}(t):this._hideForm(!0)})),cm({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:RC(t)}),n.fieldView.value=n.fieldView.element.value=e.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(t=!1){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 zC extends Lr{static get requires(){return[IC,LC]}static get pluginName(){return"ImageTextAlternative"}}function MC(t,e){const n=(e,n,i)=>{if(!i.consumable.consume(n.item,e.name))return;const o=i.writer,r=i.mapper.toViewElement(n.item),s=t.findViewImgElement(r);null===n.attributeNewValue?(o.removeAttribute("srcset",s),o.removeAttribute("sizes",s)):n.attributeNewValue&&(o.setAttribute("srcset",n.attributeNewValue,s),o.setAttribute("sizes","100vw",s))};return t=>{t.on(`attribute:srcset:${e}`,n)}}function OC(t,e,n){const i=(e,n,i)=>{if(!i.consumable.consume(n.item,e.name))return;const o=i.writer,r=i.mapper.toViewElement(n.item),s=t.findViewImgElement(r);o.setAttribute(n.attributeKey,n.attributeNewValue||"",s)};return t=>{t.on(`attribute:${n}:${e}`,i)}}class NC extends Xa{observe(t){this.listenTo(t,"load",((t,e)=>{const n=e.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(e)}),{useCapture:!0})}stopObserving(t){this.stopListening(t)}_fireEvents(t){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",t))}}class HC extends Mr{constructor(t){super(t);const e=t.config.get("image.insert.type");t.plugins.has("ImageBlockEditing")||"block"===e&&wi("image-block-plugin-required"),t.plugins.has("ImageInlineEditing")||"inline"===e&&wi("image-inline-plugin-required")}refresh(){const t=this.editor.plugins.get("ImageUtils");this.isEnabled=t.isImageAllowed()}execute(t){const e=tr(t.source),n=this.editor.model.document.selection,i=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(n.getAttributes());e.forEach(((e,r)=>{const s=n.getSelectedElement();if("string"==typeof e&&(e={src:e}),r&&s&&i.isImage(s)){const n=this.editor.model.createPositionAfter(s);i.insertImage({...e,...o},n,t.imageType)}else i.insertImage({...e,...o},null,t.imageType)}))}}class jC extends Mr{constructor(t){super(t),this.decorate("cleanupImage")}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(),n=this.editor.plugins.get("ImageUtils");this.editor.model.change((i=>{i.setAttribute("src",t.source,e),this.cleanupImage(i,e),n.setImageNaturalSizeAttributes(e)}))}cleanupImage(t,e){t.removeAttribute("srcset",e),t.removeAttribute("sizes",e),t.removeAttribute("sources",e),t.removeAttribute("width",e),t.removeAttribute("height",e),t.removeAttribute("alt",e)}}class qC extends Lr{static get requires(){return[DC]}static get pluginName(){return"ImageEditing"}init(){const t=this.editor,e=t.conversion;t.editing.view.addObserver(NC),e.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const n=new HC(t),i=new jC(t);t.commands.add("insertImage",n),t.commands.add("replaceImageSource",i),t.commands.add("imageInsert",n)}}class WC extends Lr{static get requires(){return[DC]}static get pluginName(){return"ImageSizeAttributes"}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(t){const e=this.editor,n=e.plugins.get("ImageUtils"),i="imageBlock"===t?"figure":"img";function o(e,i,o,r){e.on(`attribute:${i}:${t}`,((e,i,s)=>{if(!s.consumable.consume(i.item,e.name))return;const a=s.writer,l=s.mapper.toViewElement(i.item),c=n.findViewImgElement(l);if(null!==i.attributeNewValue?a.setAttribute(o,i.attributeNewValue,c):a.removeAttribute(o,c),i.item.hasAttribute("sources"))return;const d=i.item.hasAttribute("resizedWidth");if("imageInline"===t&&!d&&!r)return;const h=i.item.getAttribute("width"),u=i.item.getAttribute("height");h&&u&&a.setStyle("aspect-ratio",`${h}/${u}`,c)}))}e.conversion.for("upcast").attributeToAttribute({view:{name:i,styles:{width:/.+/}},model:{key:"width",value:t=>EC(t)?xC(t.getStyle("width")):null}}).attributeToAttribute({view:{name:i,key:"width"},model:"width"}).attributeToAttribute({view:{name:i,styles:{height:/.+/}},model:{key:"height",value:t=>EC(t)?xC(t.getStyle("height")):null}}).attributeToAttribute({view:{name:i,key:"height"},model:"height"}),e.conversion.for("editingDowncast").add((t=>{o(t,"width","width",!0),o(t,"height","height",!0)})),e.conversion.for("dataDowncast").add((t=>{o(t,"width","width",!1),o(t,"height","height",!1)}))}}class UC extends Mr{_modelElementName;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(t={}){const e=this.editor,n=this.editor.model,i=e.plugins.get("ImageUtils"),o=i.getClosestSelectedImageElement(n.document.selection),r=Object.fromEntries(o.getAttributes());return r.src||r.uploadId?n.change((e=>{const{setImageSizes:s=!0}=t,a=Array.from(n.markers).filter((t=>t.getRange().containsItem(o))),l=i.insertImage(r,n.createSelection(o,"on"),this._modelElementName,{setImageSizes:s});if(!l)return null;const c=e.createRangeOn(l);for(const t of a){const n=t.getRange(),i="$graveyard"!=n.root.rootName?n.getJoined(c,!0):c;e.updateMarker(t,{range:i})}return{oldElement:o,newElement:l}})):null}}var $C=n(7378),GC={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()($C.A,GC);$C.A.locals;class KC extends Lr{static get requires(){return[DC]}static get pluginName(){return"ImagePlaceholder"}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const t=this.editor.model.schema;t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["placeholder"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const t=this.editor,e=t.conversion,n=t.plugins.get("ImageUtils");e.for("editingDowncast").add((t=>{t.on("attribute:placeholder",((t,e,i)=>{if(!i.consumable.test(e.item,t.name))return;if(!e.item.is("element","imageBlock")&&!e.item.is("element","imageInline"))return;i.consumable.consume(e.item,t.name);const o=i.writer,r=i.mapper.toViewElement(e.item),s=n.findViewImgElement(r);e.attributeNewValue?(o.addClass("image_placeholder",s),o.setStyle("background-image",`url(${e.attributeNewValue})`,s),o.setCustomProperty("editingPipeline:doNotReuseOnce",!0,s)):(o.removeClass("image_placeholder",s),o.removeStyle("background-image",s))}))}))}_setupLoadListener(){const t=this.editor,e=t.model,n=t.editing,i=n.view,o=t.plugins.get("ImageUtils");i.addObserver(NC),this.listenTo(i.document,"imageLoaded",((t,r)=>{const s=i.domConverter.mapDomToView(r.target);if(!s)return;const a=o.getImageWidgetFromImageView(s);if(!a)return;const l=n.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&e.enqueueChange({isUndoable:!1},(t=>{t.removeAttribute("placeholder",l)}))}))}}class ZC extends Lr{static get requires(){return[qC,WC,DC,KC,l_]}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 UC(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,i=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:e})=>CC(e)}),n.for("editingDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:n})=>i.toImageWidget(CC(n),n,e("image widget"))}),n.for("downcast").add(OC(i,"imageBlock","src")).add(OC(i,"imageBlock","alt")).add(MC(i,"imageBlock")),n.for("upcast").elementToElement({view:vC(t,"imageBlock"),model:(t,{writer:e})=>e.createElement("imageBlock",t.hasAttribute("src")?{src:t.getAttribute("src")}:void 0)}).add(function(t){const e=(e,n,i)=>{if(!i.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const o=t.findViewImgElement(n.viewItem);if(!o||!i.consumable.test(o,{name:!0}))return;i.consumable.consume(n.viewItem,{name:!0,classes:"image"});const r=Er(i.convertItem(o,n.modelCursor).modelRange.getItems());r?(i.convertChildren(n.viewItem,r),i.updateConversionResult(r,n)):i.consumable.revert(n.viewItem,{name:!0,classes:"image"})};return t=>{t.on("element:figure",e)}}(i))}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,i=t.plugins.get("ImageUtils"),o=t.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(i.isInlineImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const l=e.createSelection(a);if("imageBlock"===yC(e.schema,l)){const t=new jh(n.document),e=s.map((e=>t.createElement("figure",{class:"image"},e)));r.content=t.createDocumentFragment(e)}})),this.listenTo(o,"contentInsertion",((t,n)=>{"paste"===n.method&&e.change((t=>{const e=t.createRangeIn(n.content);for(const t of e.getItems())t.is("element","imageBlock")&&i.setImageNaturalSizeAttributes(t)}))}))}}var YC=n(3350),JC={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(YC.A,JC);YC.A.locals;class QC extends lm{focusTracker;keystrokes;_focusables;_focusCycler;children;constructor(t,e=[]){super(t),this.focusTracker=new Br,this.keystrokes=new Dr,this._focusables=new Mu,this.children=this.createCollection(),this._focusCycler=new ym({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const t of e)this.children.add(t),this._focusables.add(t),t instanceof mg&&this._focusables.addMany(t.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),hm({view:this});for(const t of this._focusables)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)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class XC extends Lr{static get pluginName(){return"ImageInsertUI"}static get requires(){return[DC]}dropdownView;_integrations=new Map;constructor(t){super(t),t.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const t=this.editor,e=t.model.document.selection,n=t.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(t.model.document,"change",(()=>{this.isImageSelected=n.isImage(e.getSelectedElement())}));const i=t=>this._createToolbarComponent(t);t.ui.componentFactory.add("insertImage",i),t.ui.componentFactory.add("imageInsert",i),t.ui.componentFactory.add("menuBar:insertImage",(t=>this._createMenuBarComponent(t)))}registerIntegration({name:t,observable:e,buttonViewCreator:n,formViewCreator:i,menuBarButtonViewCreator:o,requiresForm:r=!1}){this._integrations.has(t)&&wi("image-insert-integration-exists",{name:t}),this._integrations.set(t,{observable:e,buttonViewCreator:n,menuBarButtonViewCreator:o,formViewCreator:i,requiresForm:r})}_createToolbarComponent(t){const e=this.editor,n=t.t,i=this._prepareIntegrations();if(!i.length)return null;let o;const r=i[0];if(1==i.length){if(!r.requiresForm)return r.buttonViewCreator(!0);o=r.buttonViewCreator(!0)}else{const e=r.buttonViewCreator(!1);o=new vp(t,e),o.tooltip=!0,o.bind("label").to(this,"isImageSelected",(t=>n(t?"Replace image":"Insert image")))}const s=this.dropdownView=Dp(t,o),a=i.map((({observable:t})=>"function"==typeof t?t():t));return s.bind("isEnabled").toMany(a,"isEnabled",((...t)=>t.some((t=>t)))),s.once("change:isOpen",(()=>{const t=i.map((({formViewCreator:t})=>t(1==i.length))),n=new QC(e.locale,t);s.panelView.children.add(n)})),s}_createMenuBarComponent(t){const e=t.t,n=this._prepareIntegrations();if(!n.length)return null;let i;const o=n[0];if(1==n.length)i=o.menuBarButtonViewCreator(!0);else{i=new ok(t);const o=new rk(t);i.panelView.children.add(o),i.buttonView.set({icon:zu.image,label:e("Image")});for(const e of n){const n=new Kf(t,i),r=e.menuBarButtonViewCreator(!1);n.children.add(r),o.items.add(n)}}return i}_prepareIntegrations(){const t=this.editor.config.get("image.insert.integrations"),e=[];if(!t.length)return wi("image-insert-integrations-not-specified"),e;for(const n of t)this._integrations.has(n)?e.push(this._integrations.get(n)):["upload","assetManager","url"].includes(n)||wi("image-insert-unknown-integration",{item:n});return e.length||wi("image-insert-integrations-not-registered"),e}}var tv=n(265),ev={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(tv.A,ev);tv.A.locals;class nv extends Lr{static get requires(){return[ZC,O_,zC,XC]}static get pluginName(){return"ImageBlock"}}class iv extends Lr{static get requires(){return[qC,WC,DC,KC,l_]}static get pluginName(){return"ImageInlineEditing"}init(){const t=this.editor;t.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),t.plugins.has("ImageBlockEditing")&&(t.commands.add("imageTypeInline",new UC(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,i=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})=>i.toImageWidget(function(t){return t.createContainerElement("span",{class:"image-inline"},t.createEmptyElement("img"))}(n),n,e("image widget"))}),n.for("downcast").add(OC(i,"imageInline","src")).add(OC(i,"imageInline","alt")).add(MC(i,"imageInline")),n.for("upcast").elementToElement({view:vC(t,"imageInline"),model:(t,{writer:e})=>e.createElement("imageInline",t.hasAttribute("src")?{src:t.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,i=t.plugins.get("ImageUtils"),o=t.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(i.isBlockImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const l=e.createSelection(a);if("imageInline"===yC(e.schema,l)){const t=new jh(n.document),e=s.map((e=>1===e.childCount?(Array.from(e.getAttributes()).forEach((n=>t.setAttribute(...n,i.findViewImgElement(e)))),e.getChild(0)):e));r.content=t.createDocumentFragment(e)}})),this.listenTo(o,"contentInsertion",((t,n)=>{"paste"===n.method&&e.change((t=>{const e=t.createRangeIn(n.content);for(const t of e.getItems())t.is("element","imageInline")&&i.setImageNaturalSizeAttributes(t)}))}))}}class ov extends Lr{static get requires(){return[iv,O_,zC,XC]}static get pluginName(){return"ImageInline"}}class rv extends Lr{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[DC]}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 sv extends Mr{refresh(){const t=this.editor,e=t.plugins.get("ImageCaptionUtils"),n=t.plugins.get("ImageUtils");if(!t.plugins.has(ZC))return this.isEnabled=!1,void(this.value=!1);const i=t.model.document.selection,o=i.getSelectedElement();if(!o){const t=e.getCaptionFromModelSelection(i);return this.isEnabled=!!t,void(this.value=!!t)}this.isEnabled=n.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,i=this.editor.plugins.get("ImageCaptionEditing"),o=this.editor.plugins.get("ImageUtils");let r=n.getSelectedElement();const s=i._getSavedCaption(r);o.isInlineImage(r)&&(this.editor.execute("imageTypeBlock"),r=n.getSelectedElement());const a=s||t.createElement("caption");t.append(a,r),e&&t.setSelection(a,"in")}_hideImageCaption(t){const e=this.editor,n=e.model.document.selection,i=e.plugins.get("ImageCaptionEditing"),o=e.plugins.get("ImageCaptionUtils");let r,s=n.getSelectedElement();s?r=o.getCaptionFromImageModelElement(s):(r=o.getCaptionFromModelSelection(n),s=r.parent),i._saveCaption(s,r),t.setSelection(s,"on"),t.remove(r)}}class av extends Lr{static get requires(){return[DC,rv]}static get pluginName(){return"ImageCaptionEditing"}_savedCaptionsMap;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 sv(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils"),i=t.plugins.get("ImageCaptionUtils"),o=t.t;t.conversion.for("upcast").elementToElement({view:t=>i.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:i})=>{if(!n.isBlockImage(t.parent))return null;const r=i.createEditableElement("figcaption");i.setCustomProperty("imageCaption",!0,r),r.placeholder=o("Enter image caption"),Jr({view:e,element:r,keepOnFocus:!0});const s=t.parent.getAttribute("alt");return A_(r,i,{label:s?o("Caption for image: %0",[s]):o("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.plugins.get("ImageCaptionUtils"),i=t.commands.get("imageTypeInline"),o=t.commands.get("imageTypeBlock"),r=t=>{if(!t.return)return;const{oldElement:i,newElement:o}=t.return;if(!i)return;if(e.isBlockImage(i)){const t=n.getCaptionFromImageModelElement(i);if(t)return void this._saveCaption(o,t)}const r=this._getSavedCaption(i);r&&this._saveCaption(o,r)};i&&this.listenTo(i,"execute",r,{priority:"low"}),o&&this.listenTo(o,"execute",r,{priority:"low"})}_getSavedCaption(t){const e=this._savedCaptionsMap.get(t);return e?ql.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"),i=t.plugins.get("ImageCaptionUtils");e.document.on("change:data",(()=>{const o=e.document.differ.getChanges();for(const e of o){if("alt"!==e.attributeKey)continue;const o=e.range.start.nodeAfter;if(n.isBlockImage(o)){const e=i.getCaptionFromImageModelElement(o);if(!e)return;t.editing.reconvertItem(e)}}}))}}class lv extends Lr{static get requires(){return[rv]}static get pluginName(){return"ImageCaptionUI"}init(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageCaptionUtils"),i=t.t;t.ui.componentFactory.add("toggleImageCaption",(o=>{const r=t.commands.get("toggleImageCaption"),s=new wm(o);return s.set({icon:zu.caption,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.bind("label").to(r,"value",(t=>i(t?"Toggle caption off":"Toggle caption on"))),this.listenTo(s,"execute",(()=>{t.execute("toggleImageCaption",{focusCaptionOnShow:!0});const i=n.getCaptionFromModelSelection(t.model.document.selection);if(i){const n=t.editing.mapper.toViewElement(i);e.scrollToTheSelection(),e.change((t=>{t.addClass("image__caption_highlighted",n)}))}t.editing.view.focus()})),s}))}}var cv=n(5247),dv={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(cv.A,dv);cv.A.locals;function hv(t){const e=t.map((t=>t.replace("+","\\+")));return new RegExp(`^image\\/(${e.join("|")})$`)}function uv(t){return new Promise(((e,n)=>{const i=t.getAttribute("src");fetch(i).then((t=>t.blob())).then((t=>{const n=mv(t,i),o=n.replace("image/",""),r=new File([t],`image.${o}`,{type:n});e(r)})).catch((t=>t&&"TypeError"===t.name?function(t){return function(t){return new Promise(((e,n)=>{const i=Yn.document.createElement("img");i.addEventListener("load",(()=>{const t=Yn.document.createElement("canvas");t.width=i.width,t.height=i.height;t.getContext("2d").drawImage(i,0,0),t.toBlob((t=>t?e(t):n()))})),i.addEventListener("error",(()=>n())),i.src=t}))}(t).then((e=>{const n=mv(e,t),i=n.replace("image/","");return new File([e],`image.${i}`,{type:n})}))}(i).then(e).catch(n):n(t)))}))}function mv(t,e){return t.type?t.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class gv extends Lr{static get pluginName(){return"ImageUploadUI"}init(){const t=this.editor;t.ui.componentFactory.add("uploadImage",(()=>this._createToolbarButton())),t.ui.componentFactory.add("imageUpload",(()=>this._createToolbarButton())),t.ui.componentFactory.add("menuBar:uploadImage",(()=>this._createMenuBarButton("standalone"))),t.plugins.has("ImageInsertUI")&&t.plugins.get("ImageInsertUI").registerIntegration({name:"upload",observable:()=>t.commands.get("uploadImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:t=>this._createMenuBarButton(t?"insertOnly":"insertNested")})}_createButton(t){const e=this.editor,n=e.locale,i=e.commands.get("uploadImage"),o=e.config.get("image.upload.types"),r=hv(o),s=new t(e.locale),a=n.t;return s.set({acceptedType:o.map((t=>`image/${t}`)).join(","),allowMultipleFiles:!0,label:a("Upload from computer"),icon:zu.imageUpload}),s.bind("isEnabled").to(i),s.on("done",((t,n)=>{const i=Array.from(n).filter((t=>r.test(t.type)));i.length&&(e.execute("uploadImage",{file:i}),e.editing.view.focus())})),s}_createToolbarButton(){const t=this.editor.locale.t,e=this.editor.plugins.get("ImageInsertUI"),n=this.editor.commands.get("uploadImage"),i=this._createButton(sg);return i.tooltip=!0,i.bind("label").to(e,"isImageSelected",n,"isAccessAllowed",((e,n)=>t(n?e?"Replace image from computer":"Upload image from computer":"You have no image upload permissions."))),i}_createDropdownButton(){const t=this.editor.locale.t,e=this.editor.plugins.get("ImageInsertUI"),n=this._createButton(sg);return n.withText=!0,n.bind("label").to(e,"isImageSelected",(e=>t(e?"Replace from computer":"Upload from computer"))),n.on("execute",(()=>{e.dropdownView.isOpen=!1})),n}_createMenuBarButton(t){const e=this.editor.locale.t,n=this._createButton(ak);switch(n.withText=!0,t){case"standalone":n.label=e("Image from computer");break;case"insertOnly":n.label=e("Image");break;case"insertNested":n.label=e("From computer")}return n}}var pv=n(2267),fv={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(pv.A,fv);pv.A.locals;var bv=n(7693),kv={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(bv.A,kv);bv.A.locals;var wv=n(1559),Av={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(wv.A,Av);wv.A.locals;class _v extends Lr{static get pluginName(){return"ImageUploadProgress"}placeholder;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",this.uploadStatusChange),t.plugins.has("ImageInlineEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}uploadStatusChange=(t,e,n)=>{const i=this.editor,o=e.item,r=o.getAttribute("uploadId");if(!n.consumable.consume(e.item,t.name))return;const s=i.plugins.get("ImageUtils"),a=i.plugins.get(Mk),l=r?e.attributeNewValue:null,c=this.placeholder,d=i.editing.mapper.toViewElement(o),h=n.writer;if("reading"==l)return Cv(d,h),void vv(s,c,d,h);if("uploading"==l){const t=a.loaders.get(r);return Cv(d,h),void(t?(yv(d,h),function(t,e,n,i){const o=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"),o),n.on("change:uploadedPercent",((t,e,n)=>{i.change((t=>{t.setStyle("width",n+"%",o)}))}))}(d,h,t,i.editing.view),function(t,e,n,i){if(i.data){const o=t.findViewImgElement(e);n.setAttribute("src",i.data,o)}}(s,d,h,t)):vv(s,c,d,h))}"complete"==l&&a.loaders.get(r)&&function(t,e,n){const i=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),i),setTimeout((()=>{n.change((t=>t.remove(t.createRangeOn(i))))}),3e3)}(d,h,i.editing.view),function(t,e){Ev(t,e,"progressBar")}(d,h),yv(d,h),function(t,e){e.removeClass("ck-appear",t)}(d,h)}}function Cv(t,e){t.hasClass("ck-appear")||e.addClass("ck-appear",t)}function vv(t,e,n,i){n.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",n);const o=t.findViewImgElement(n);o.getAttribute("src")!==e&&i.setAttribute("src",e,o),xv(n,"placeholder")||i.insert(i.createPositionAfter(o),function(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});return t.setCustomProperty("placeholder",!0,e),e}(i))}function yv(t,e){t.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",t),Ev(t,e,"placeholder")}function xv(t,e){for(const n of t.getChildren())if(n.getCustomProperty(e))return n}function Ev(t,e,n){const i=xv(t,n);i&&e.remove(e.createRangeOn(i))}class Bv extends Mr{constructor(t){super(t),this.set("isAccessAllowed",!0)}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=tr(t.file),n=this.editor.model.document.selection,i=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if(e&&r&&i.isImage(r)){const e=this.editor.model.createPositionAfter(r);this._uploadImage(t,o,e)}else this._uploadImage(t,o)}))}_uploadImage(t,e,n){const i=this.editor,o=i.plugins.get(Mk).createLoader(t),r=i.plugins.get("ImageUtils");o&&r.insertImage({...e,uploadId:o.id},n)}}class Dv extends Lr{static get requires(){return[Mk,bb,l_,DC]}static get pluginName(){return"ImageUploadEditing"}_uploadImageElements;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,i=t.plugins.get(Mk),o=t.plugins.get("ImageUtils"),r=t.plugins.get("ClipboardPipeline"),s=hv(t.config.get("image.upload.types")),a=new Bv(t);t.commands.add("uploadImage",a),t.commands.add("imageUpload",a),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(t.editing.view.document,"clipboardInput",((e,n)=>{if(i=n.dataTransfer,Array.from(i.types).includes("text/html")&&""!==i.getData("text/html"))return;var i;const o=Array.from(n.dataTransfer.files).filter((t=>!!t&&s.test(t.type)));if(!o.length)return;e.stop(),t.model.change((e=>{n.targetRanges&&e.setSelection(n.targetRanges.map((e=>t.editing.mapper.toModelRange(e)))),t.execute("uploadImage",{file:o})}));if(!t.commands.get("uploadImage").isAccessAllowed){const e=t.plugins.get("Notification"),n=t.locale.t;e.showWarning(n("You have no image upload permissions."),{namespace:"image"})}})),this.listenTo(r,"inputTransformation",((e,n)=>{const r=Array.from(t.editing.view.createRangeIn(n.content)).map((t=>t.item)).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))}(o,t)&&!t.getAttribute("uploadProcessed"))).map((t=>({promise:uv(t),imageElement:t})));if(!r.length)return;const s=new jh(t.editing.view.document);for(const t of r){s.setAttribute("uploadProcessed",!0,t.imageElement);const e=i.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(),o=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 Sv(t,n)){const t=e.getAttribute("uploadId");if(!t)continue;const n=i.loaders.get(t);n&&(r?o.has(t)||n.abort():(o.add(t),this._uploadImageElements.set(t,e),"idle"==n.status&&this._readAndUpload(n)))}}})),this.on("uploadComplete",((t,{imageElement:e,data:n})=>{const i=n.urls?n.urls:n;this.editor.model.change((t=>{t.setAttribute("src",i.default,e),this._parseAndSetSrcsetAttributeOnImage(i,e,t),o.setImageNaturalSizeAttributes(e)}))}),{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,i=e.locale.t,o=e.plugins.get(Mk),r=e.plugins.get(bb),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(),r=a.get(t.id);if(Xn.isSafari){const t=e.editing.mapper.toViewElement(r),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 i=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=i}))}return e.ui&&e.ui.ariaLiveAnnouncer.announce(i("Uploading image")),n.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","uploading",r)})),o})).then((o=>{n.enqueueChange({isUndoable:!1},(n=>{const r=a.get(t.id);n.setAttribute("uploadStatus","complete",r),e.ui&&e.ui.ariaLiveAnnouncer.announce(i("Image upload complete")),this.fire("uploadComplete",{data:o,imageElement:r})})),l()})).catch((o=>{if(e.ui&&e.ui.ariaLiveAnnouncer.announce(i("Error during image upload")),"error"!==t.status&&"aborted"!==t.status)throw o;"error"==t.status&&o&&r.showWarning(o,{title:i("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},(e=>{e.remove(a.get(t.id))})),l()}));function l(){n.enqueueChange({isUndoable:!1},(e=>{const n=a.get(t.id);e.removeAttribute("uploadId",n),e.removeAttribute("uploadStatus",n),a.delete(t.id)})),o.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,n){let i=0;const o=Object.keys(t).filter((t=>{const e=parseInt(t,10);if(!isNaN(e))return i=Math.max(i,e),!0})).map((e=>`${t[e]} ${e}w`)).join(", ");if(""!=o){const t={srcset:o};e.hasAttribute("width")||e.hasAttribute("height")||(t.width=i),n.setAttributes(t,e)}}}function Sv(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))}const Tv=function(t,e){return function(n,i){if(null==n)return n;if(!Be(n))return t(n,i);for(var o=n.length,r=e?o:-1,s=Object(n);(e?r--:++r{e.setAttribute("resizedWidth",t.width,o),e.removeAttribute("resizedHeight",o),i.setImageNaturalSizeAttributes(o)}))}}class Fv extends Lr{static get requires(){return[DC]}static get pluginName(){return"ImageResizeEditing"}constructor(t){super(t),t.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const t=this.editor,e=new Vv(t);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),t.commands.add("resizeImage",e),t.commands.add("imageResize",e)}afterInit(){this._registerSchema()}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]})}_registerConverters(t){const e=this.editor,n=e.plugins.get("ImageUtils");e.conversion.for("downcast").add((e=>e.on(`attribute:resizedWidth:${t}`,((t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const i=n.writer,o=n.mapper.toViewElement(e.item);null!==e.attributeNewValue?(i.setStyle("width",e.attributeNewValue,o),i.addClass("image_resized",o)):(i.removeStyle("width",o),i.removeClass("image_resized",o))})))),e.conversion.for("dataDowncast").attributeToAttribute({model:{name:t,key:"resizedHeight"},view:t=>({key:"style",value:{height:t}})}),e.conversion.for("editingDowncast").add((e=>e.on(`attribute:resizedHeight:${t}`,((e,i,o)=>{if(!o.consumable.consume(i.item,e.name))return;const r=o.writer,s=o.mapper.toViewElement(i.item),a="imageInline"===t?n.findViewImgElement(s):s;null!==i.attributeNewValue?r.setStyle("height",i.attributeNewValue,a):r.removeStyle("height",a)})))),e.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===t?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:t=>EC(t)?null:t.getStyle("width")}}),e.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===t?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:t=>EC(t)?null:t.getStyle("height")}})}}const Rv=(()=>({small:zu.objectSizeSmall,medium:zu.objectSizeMedium,large:zu.objectSizeLarge,custom:zu.objectSizeCustom,original:zu.objectSizeFull}))();class Lv extends Lr{static get requires(){return[Fv]}static get pluginName(){return"ImageResizeButtons"}_resizeUnit;constructor(t){super(t),this._resizeUnit=t.config.get("image.resizeUnit")}init(){const t=this.editor,e=t.config.get("image.resizeOptions"),n=t.commands.get("resizeImage");this.bind("isEnabled").to(n);for(const t of e)this._registerImageResizeButton(t);this._registerImageResizeDropdown(e)}_registerImageResizeButton(t){const e=this.editor,{name:n,value:i,icon:o}=t;e.ui.componentFactory.add(n,(n=>{const r=new wm(n),s=e.commands.get("resizeImage"),a=this._getOptionLabelValue(t,!0);if(!Rv[o])throw new ki("imageresizebuttons-missing-icon",e,t);if(r.set({label:a,icon:Rv[o],tooltip:a,isToggleable:!0}),r.bind("isEnabled").to(this),e.plugins.has("ImageCustomResizeUI")&&zv(t)){const t=e.plugins.get("ImageCustomResizeUI");this.listenTo(r,"execute",(()=>{t._showForm(this._resizeUnit)}))}else{const t=i?i+this._resizeUnit:null;r.bind("isOn").to(s,"value",Mv(t)),this.listenTo(r,"execute",(()=>{e.execute("resizeImage",{width:t})}))}return r}))}_registerImageResizeDropdown(t){const e=this.editor,n=e.t,i=t.find((t=>!t.value)),o=o=>{const r=e.commands.get("resizeImage"),s=Dp(o,jg),a=s.buttonView,l=n("Resize image");return a.set({tooltip:l,commandValue:i.value,icon:Rv.medium,isToggleable:!0,label:this._getOptionLabelValue(i),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(r,"value",(t=>t&&t.width?t.width:this._getOptionLabelValue(i))),s.bind("isEnabled").to(this),Ip(s,(()=>this._getResizeDropdownListItemDefinitions(t,r)),{ariaLabel:n("Image resize list"),role:"menu"}),this.listenTo(s,"execute",(t=>{"onClick"in t.source?t.source.onClick():(e.execute(t.source.commandName,{width:t.source.commandValue}),e.editing.view.focus())})),s};e.ui.componentFactory.add("resizeImage",o),e.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(t,e=!1){const n=this.editor.t;return t.label?t.label:e?zv(t)?n("Custom image size"):t.value?n("Resize image to %0",t.value+this._resizeUnit):n("Resize image to the original size"):zv(t)?n("Custom"):t.value?t.value+this._resizeUnit:n("Original")}_getResizeDropdownListItemDefinitions(t,e){const{editor:n}=this,i=new xr,o=t.map((t=>zv(t)?{...t,valueWithUnits:"custom"}:t.value?{...t,valueWithUnits:`${t.value}${this._resizeUnit}`}:{...t,valueWithUnits:null}));for(const t of o){let r=null;if(n.plugins.has("ImageCustomResizeUI")&&zv(t)){const i=n.plugins.get("ImageCustomResizeUI");r={type:"button",model:new kb({label:this._getOptionLabelValue(t),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{i._showForm(this._resizeUnit)}})};const s=Pv(o,"valueWithUnits");r.model.bind("isOn").to(e,"value",Ov(s))}else r={type:"button",model:new kb({commandName:"resizeImage",commandValue:t.valueWithUnits,label:this._getOptionLabelValue(t),role:"menuitemradio",withText:!0,icon:null})},r.model.bind("isOn").to(e,"value",Mv(t.valueWithUnits));r.model.bind("isEnabled").to(e,"isEnabled"),i.add(r)}return i}}function zv(t){return"custom"===t.value}function Mv(t){return e=>null===t&&e===t||null!==e&&e.width===t}function Ov(t){return e=>!t.some((t=>Mv(t)(e)))}const Nv="image_resized";class Hv extends Lr{static get requires(){return[Y_,DC]}static get pluginName(){return"ImageResizeHandles"}init(){const t=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(t),this._setupResizerCreator()}_setupResizerCreator(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils");e.addObserver(NC),this.listenTo(e.document,"imageLoaded",((i,o)=>{if(!o.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const r=t.editing.view.domConverter,s=r.domToView(o.target),a=n.getImageWidgetFromImageView(s);let l=this.editor.plugins.get(Y_).getResizerByViewElement(a);if(l)return void l.redraw();const c=t.editing.mapper,d=c.toModelElement(a);l=t.plugins.get(Y_).attachTo({unit:t.config.get("image.resizeUnit"),modelElement:d,viewElement:a,editor:t,getHandleHost:t=>t.querySelector("img"),getResizeHost:()=>r.mapViewToDom(c.toViewElement(d)),isCentered:()=>"alignCenter"==d.getAttribute("imageStyle"),onCommit(n){e.change((t=>{t.removeClass(Nv,a)})),t.execute("resizeImage",{width:n})}}),l.on("updateSize",(()=>{a.hasClass(Nv)||e.change((t=>{t.addClass(Nv,a)}));const t="imageInline"===d.name?s:a;t.getStyle("height")&&e.change((e=>{e.removeStyle("height",t)}))})),l.bind("isEnabled").to(this)}))}}function jv(t){if(!t)return null;const[,e,n]=t.trim().match(/([.,\d]+)(%|px)$/)||[],i=Number.parseFloat(e);return Number.isNaN(i)?null:{value:i,unit:n}}function qv(t,e,n){return"px"===n?{value:e.value,unit:"px"}:{value:e.value/t*100,unit:"%"}}function Wv(t){const{editing:e}=t,n=t.plugins.get("ImageUtils").getClosestSelectedImageElement(t.model.document.selection);if(!n)return null;const i=e.mapper.toViewElement(n);return{model:n,view:i,dom:e.view.domConverter.mapViewToDom(i)}}var Uv=n(4642),$v={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(Uv.A,$v);Uv.A.locals;class Gv extends lm{focusTracker;keystrokes;unit;labeledInput;saveButtonView;cancelButtonView;_focusables;_focusCycler;_validators;constructor(t,e,n){super(t);const i=this.locale.t;this.focusTracker=new Br,this.keystrokes=new Dr,this.unit=e,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(i("Save"),zu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),zu.cancel,"ck-button-cancel","cancel"),this._focusables=new Mu,this._validators=n,this._focusCycler=new ym({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),hm({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,i){const o=new wm(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createLabeledInputView(){const t=this.locale.t,e=new Sg(this.locale,Lp);return e.label=t("Resize image (in %0)",this.unit),e.fieldView.set({step:.1}),e}isValid(){this.resetFormStatus();for(const t of this._validators){const e=t(this);if(e)return this.labeledInput.errorText=e,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:t}=this.labeledInput.fieldView;return t?t.value:null}get parsedSize(){const{rawSize:t}=this;if(null===t)return null;const e=Number.parseFloat(t);return Number.isNaN(e)?null:e}get sizeWithUnits(){const{parsedSize:t,unit:e}=this;return null===t?null:`${t}${e}`}}class Kv extends Lr{_balloon;_form;static get requires(){return[yb]}static get pluginName(){return"ImageCustomResizeUI"}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(t){const e=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(dm(Gv))(e.locale,t,function(t){const e=t.t;return[t=>""===t.rawSize.trim()?e("The value must not be empty."):null===t.parsedSize?e("The value should be a plain number."):void 0]}(e)),this._form.render(),this.listenTo(this._form,"submit",(()=>{this._form.isValid()&&(e.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))})),this.listenTo(this._form.labeledInput,"change:errorText",(()=>{e.ui.update()})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((t,e)=>{this._hideForm(!0),e()})),cm({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(t){if(this._isVisible)return;this._form||this._createForm(t);const e=this.editor,n=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:RC(e)});const i=function(t,e){const n=Wv(t);if(!n)return null;const i=jv(n.model.getAttribute("resizedWidth")||null);return i?i.unit===e?i:qv(y_(n.dom),{unit:"px",value:new bo(n.dom).width},e):null}(e,t),o=i?i.value.toFixed(1):"",r=function(t,e){const n=Wv(t);if(!n)return null;const i=y_(n.dom),o=jv(window.getComputedStyle(n.dom).minWidth)||{value:1,unit:"px"};return{unit:e,lower:Math.max(.1,qv(i,o,e).value),upper:"px"===e?i:100}}(e,t);n.fieldView.value=n.fieldView.element.value=o,r&&Object.assign(n.fieldView,{min:r.lower.toFixed(1),max:Math.ceil(r.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(t=!1){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)}}var Zv=n(3469),Yv={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(Zv.A,Yv);Zv.A.locals;class Jv extends Mr{_defaultStyles;_styles;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,i=e.plugins.get("ImageUtils");n.change((e=>{const o=t.value,{setImageSizes:r=!0}=t;let s=i.getClosestSelectedImageElement(n.document.selection);o&&this.shouldConvertImageType(o,s)&&(this.editor.execute(i.isBlockImage(s)?"imageTypeInline":"imageTypeBlock",{setImageSizes:r}),s=i.getClosestSelectedImageElement(n.document.selection)),!o||this._styles.get(o).isDefault?e.removeAttribute("imageStyle",s):e.setAttribute("imageStyle",o,s),r&&i.setImageNaturalSizeAttributes(s)}))}shouldConvertImageType(t,e){return!this._styles.get(t).modelElements.includes(e.name)}}const Qv={get inline(){return{name:"inline",title:"In line",icon:zu.objectInline,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:zu.objectLeft,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:zu.objectBlockLeft,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:zu.objectCenter,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:zu.objectRight,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:zu.objectBlockRight,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:zu.objectCenter,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:zu.objectRight,modelElements:["imageBlock"],className:"image-style-side"}}},Xv=(()=>({full:zu.objectFullWidth,left:zu.objectBlockLeft,right:zu.objectBlockRight,center:zu.objectCenter,inlineLeft:zu.objectLeft,inlineRight:zu.objectRight,inline:zu.objectInline}))(),ty=[{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 ey(t){wi("image-style-configuration-definition-invalid",t)}const ny={normalizeStyles:function(t){return(t.configuredStyles.options||[]).map((t=>function(t){t="string"==typeof t?Qv[t]?{...Qv[t]}:{name:t}:function(t,e){const n={...e};for(const i in t)Object.prototype.hasOwnProperty.call(e,i)||(n[i]=t[i]);return n}(Qv[t.name],t);"string"==typeof t.icon&&(t.icon=Xv[t.icon]||t.icon);return t}(t))).filter((e=>function(t,{isBlockPluginLoaded:e,isInlinePluginLoaded:n}){const{modelElements:i,name:o}=t;if(!(i&&i.length&&o))return ey({style:t}),!1;{const o=[e?"imageBlock":null,n?"imageInline":null];if(!i.some((t=>o.includes(t))))return wi("image-style-missing-dependency",{style:t,missingPlugins:i.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")?[...ty]:[]},warnInvalidStyle:ey,DEFAULT_OPTIONS:Qv,DEFAULT_ICONS:Xv,DEFAULT_DROPDOWN_DEFINITIONS:ty};function iy(t,e){for(const n of e)if(n.name===t)return n}class oy extends Lr{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[DC]}normalizedStyles;init(){const{normalizeStyles:t,getDefaultStylesConfiguration:e}=ny,n=this.editor,i=n.plugins.has("ImageBlockEditing"),o=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",e(i,o)),this.normalizedStyles=t({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:i,isInlinePluginLoaded:o}),this._setupConversion(i,o),this._setupPostFixer(),n.commands.add("imageStyle",new Jv(n,this.normalizedStyles))}_setupConversion(t,e){const n=this.editor,i=n.model.schema,o=(r=this.normalizedStyles,(t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const i=iy(e.attributeNewValue,r),o=iy(e.attributeOldValue,r),s=n.mapper.toViewElement(e.item),a=n.writer;o&&a.removeClass(o.className,s),i&&a.addClass(i.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,i)=>{if(!n.modelRange)return;const o=n.viewItem,r=Er(n.modelRange.getItems());if(r&&i.schema.checkAttribute(r,"imageStyle"))for(const t of e[r.name])i.consumable.consume(o,{classes:t.className})&&i.writer.setAttribute("imageStyle",t.name,r)}}(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",o),n.data.downcastDispatcher.on("attribute:imageStyle",o),t&&(i.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",s,{priority:"low"})),e&&(i.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(DC),i=new Map(this.normalizedStyles.map((t=>[t.name,t])));e.registerPostFixer((t=>{let o=!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=i.get(s);a&&a.modelElements.includes(e.name)||(t.removeAttribute("imageStyle",e),o=!0)}return o}))}}var ry=n(6386),sy={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(ry.A,sy);ry.A.locals;class ay extends Lr{static get requires(){return[oy]}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=ly(t.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const t of n)this._createButton(t);const i=ly([...e.filter(s),...ny.getDefaultDropdownDefinitions(t)],this.localizedDefaultStylesTitles);for(const t of i)this._createDropdown(t,n)}_createDropdown(t,e){const n=this.editor.ui.componentFactory;n.add(t.name,(i=>{let o;const{defaultItem:r,items:s,title:a}=t,l=s.filter((t=>e.find((({name:e})=>cy(e)===t)))).map((t=>{const e=n.create(t);return t===r&&(o=e),e}));s.length!==l.length&&ny.warnInvalidStyle({dropdown:t});const c=Dp(i,vp),d=c.buttonView,h=d.arrowView;return Sp(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:dy(a,o.label),class:null,tooltip:!0}),h.unbind("label"),h.set({label:a}),d.bind("icon").toMany(l,"isOn",((...t)=>{const e=t.findIndex(lr);return e<0?o.icon:l[e].icon})),d.bind("label").toMany(l,"isOn",((...t)=>{const e=t.findIndex(lr);return dy(a,e<0?o.label:l[e].label)})),d.bind("isOn").toMany(l,"isOn",((...t)=>t.some(lr))),d.bind("class").toMany(l,"isOn",((...t)=>t.some(lr)?"ck-splitbutton_flatten":void 0)),d.on("execute",(()=>{l.some((({isOn:t})=>t))?c.isOpen=!c.isOpen:o.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...t)=>t.some(lr))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(t){const e=t.name;this.editor.ui.componentFactory.add(cy(e),(n=>{const i=this.editor.commands.get("imageStyle"),o=new wm(n);return o.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(i,"isEnabled"),o.bind("isOn").to(i,"value",(t=>t===e)),o.on("execute",this._executeCommand.bind(this,e)),o}))}_executeCommand(t){this.editor.execute("imageStyle",{value:t}),this.editor.editing.view.focus()}}function ly(t,e){for(const n of t)e[n.title]&&(n.title=e[n.title]);return t}function cy(t){return`imageStyle:${t}`}function dy(t,e){return(t?t+": ":"")+e}class hy{_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 i=n.writer,o=i.document.selection;for(const t of this._definitions){const r=i.createAttributeElement("a",t.attributes,{priority:5});t.classes&&i.addClass(t.classes,r);for(const e in t.styles)i.setStyle(e,t.styles[e],r);i.setCustomProperty("link",!0,r),t.callback(e.attributeNewValue)?e.item.is("selection")?i.wrap(o.getFirstRange(),r):i.wrap(n.mapper.toViewRange(e.range),r):i.unwrap(n.mapper.toViewRange(e.range),r)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return t=>{t.on("attribute:linkHref:imageBlock",((t,e,{writer:n,mapper:i})=>{const o=i.toViewElement(e.item),r=Array.from(o.getChildren()).find((t=>t.is("element","a")));for(const t of this._definitions){const i=Sr(t.attributes);if(t.callback(e.attributeNewValue)){for(const[t,e]of i)"class"===t?n.addClass(e,r):n.setAttribute(t,e,r);t.classes&&n.addClass(t.classes,r);for(const e in t.styles)n.setStyle(e,t.styles[e],r)}else{for(const[t,e]of i)"class"===t?n.removeClass(e,r):n.removeAttribute(t,r);t.classes&&n.removeClass(t.classes,r);for(const e in t.styles)n.removeStyle(e,r)}}}))}}}const uy=function(t,e,n){var i=t.length;return n=void 0===n?i:n,!e&&n>=i?t:Ss(t,e,n)};var my=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const gy=function(t){return my.test(t)};const py=function(t){return t.split("")};var fy="\\ud800-\\udfff",by="["+fy+"]",ky="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",wy="\\ud83c[\\udffb-\\udfff]",Ay="[^"+fy+"]",_y="(?:\\ud83c[\\udde6-\\uddff]){2}",Cy="[\\ud800-\\udbff][\\udc00-\\udfff]",vy="(?:"+ky+"|"+wy+")"+"?",yy="[\\ufe0e\\ufe0f]?",xy=yy+vy+("(?:\\u200d(?:"+[Ay,_y,Cy].join("|")+")"+yy+vy+")*"),Ey="(?:"+[Ay+ky+"?",ky,_y,Cy,by].join("|")+")",By=RegExp(wy+"(?="+wy+")|"+Ey+xy,"g");const Dy=function(t){return t.match(By)||[]};const Sy=function(t){return gy(t)?Dy(t):py(t)};const Ty=function(t){return function(e){e=ys(e);var n=gy(e)?Sy(e):void 0,i=n?n[0]:e.charAt(0),o=n?uy(n,1).join(""):e.slice(1);return i[t]()+o}}("toUpperCase"),Iy=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Py=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,Vy=/^((\w+:(\/{2,})?)|(\W))/i,Fy=["https?","ftps?","mailto"],Ry="Ctrl+K";function Ly(t,{writer:e}){const n=e.createAttributeElement("a",{href:t},{priority:5});return e.setCustomProperty("link",!0,n),n}function zy(t,e=Fy){const n=String(t),i=e.join("|");return function(t,e){const n=t.replace(Iy,"");return!!n.match(e)}(n,new RegExp(`${"^(?:(?:):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("",i)}`,"i"))?n:"#"}function My(t,e){return!!t&&e.checkAttribute(t.name,"linkHref")}function Oy(t,e){const n=(i=t,Py.test(i)?"mailto:":e);var i;const o=!!n&&!Ny(t);return t&&o?n+t:t}function Ny(t){return Vy.test(t)}function Hy(t){window.open(t,"_blank","noopener")}class jy extends Mr{manualDecorators=new xr;automaticDecorators=new hy;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()||Er(e.getSelectedBlocks());My(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 t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}execute(t,e={}){const n=this.editor.model,i=n.document.selection,o=[],r=[];for(const t in e)e[t]?o.push(t):r.push(t);n.change((e=>{if(i.isCollapsed){const s=i.getFirstPosition();if(i.hasAttribute("linkHref")){const a=qy(i);let l=yw(s,"linkHref",i.getAttribute("linkHref"),n);i.getAttribute("linkHref")===a&&(l=this._updateLinkContent(n,e,l,t)),e.setAttribute("linkHref",t,l),o.forEach((t=>{e.setAttribute(t,!0,l)})),r.forEach((t=>{e.removeAttribute(t,l)})),e.setSelection(e.createPositionAfter(l.end.nodeBefore))}else if(""!==t){const r=Sr(i.getAttributes());r.set("linkHref",t),o.forEach((t=>{r.set(t,!0)}));const{end:a}=n.insertContent(e.createText(t,r),s);e.setSelection(a)}["linkHref",...o,...r].forEach((t=>{e.removeSelectionAttribute(t)}))}else{const s=n.schema.getValidRanges(i.getRanges(),"linkHref"),a=[];for(const t of i.getSelectedBlocks())n.schema.checkAttribute(t,"linkHref")&&a.push(e.createRangeOn(t));const l=a.slice();for(const t of s)this._isRangeToUpdate(t,a)&&l.push(t);for(const s of l){let a=s;if(1===l.length){const o=qy(i);i.getAttribute("linkHref")===o&&(a=this._updateLinkContent(n,e,s,t),e.setSelection(e.createSelection(a)))}e.setAttribute("linkHref",t,a),o.forEach((t=>{e.setAttribute(t,!0,a)})),r.forEach((t=>{e.removeAttribute(t,a)}))}}}))}_getDecoratorStateFromModel(t){const e=this.editor.model,n=e.document.selection,i=n.getSelectedElement();return My(i,e.schema)?i.getAttribute(t):n.getAttribute(t)}_isRangeToUpdate(t,e){for(const n of e)if(n.containsRange(t))return!1;return!0}_updateLinkContent(t,e,n,i){const o=e.createText(i,{linkHref:i});return t.insertContent(o,n)}}function qy(t){if(t.isCollapsed){const e=t.getFirstPosition();return e.textNode&&e.textNode.data}{const e=Array.from(t.getFirstRange().getItems());if(e.length>1)return null;const n=e[0];return n.is("$text")||n.is("$textProxy")?n.data:null}}class Wy extends Mr{refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement();My(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,i=t.commands.get("link");e.change((t=>{const o=n.isCollapsed?[yw(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),e)]:e.schema.getValidRanges(n.getRanges(),"linkHref");for(const e of o)if(t.removeAttribute("linkHref",e),i)for(const n of i.manualDecorators)t.removeAttribute(n.id,e)}))}}class Uy extends(ji()){id;defaultValue;label;attributes;classes;styles;constructor({id:t,label:e,attributes:n,classes:i,styles:o,defaultValue:r}){super(),this.id=t,this.set("value",void 0),this.defaultValue=r,this.label=e,this.attributes=n,this.classes=i,this.styles=o}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}var $y=n(7719),Gy={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()($y.A,Gy);$y.A.locals;const Ky="automatic",Zy=/^(https?:)?\/\//;class Yy extends Lr{static get pluginName(){return"LinkEditing"}static get requires(){return[dw,Zk,l_]}constructor(t){super(t),t.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1})}init(){const t=this.editor,e=this.editor.config.get("link.allowedProtocols");t.model.schema.extend("$text",{allowAttributes:"linkHref"}),t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:Ly}),t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,n)=>Ly(zy(t,e),n)}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:t=>t.getAttribute("href")}}),t.commands.add("link",new jy(t)),t.commands.add("unlink",new Wy(t));const n=function(t,e){const n={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};return e.forEach((t=>("label"in t&&n[t.label]&&(t.label=n[t.label]),t))),e}(t.t,function(t){const e=[];if(t)for(const[n,i]of Object.entries(t)){const t=Object.assign({},i,{id:`link${Ty(n)}`});e.push(t)}return e}(t.config.get("link.decorators")));this._enableAutomaticDecorators(n.filter((t=>t.mode===Ky))),this._enableManualDecorators(n.filter((t=>"manual"===t.mode)));t.plugins.get(dw).registerAttribute("linkHref"),Ew(t,"linkHref","a","ck-link_selected"),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_enableAutomaticDecorators(t){const e=this.editor,n=e.commands.get("link").automaticDecorators;e.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:Ky,callback:t=>!!t&&Zy.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});const i=new Uy(t);n.add(i),e.conversion.for("downcast").attributeToElement({model:i.id,view:(t,{writer:e,schema:n},{item:o})=>{if((o.is("selection")||n.isInline(o))&&t){const t=e.createAttributeElement("a",i.attributes,{priority:5});i.classes&&e.addClass(i.classes,t);for(const n in i.styles)e.setStyle(n,i.styles[n],t);return e.setCustomProperty("link",!0,t),t}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",...i._createPattern()},model:{key:i.id}})}))}_enableLinkOpen(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"click",((t,e)=>{if(!(Xn.isMac?e.domEvent.metaKey:e.domEvent.ctrlKey))return;let n=e.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const i=n.getAttribute("href");i&&(t.stop(),e.preventDefault(),Hy(i))}),{context:"$capture"}),this.listenTo(e,"keydown",((e,n)=>{const i=t.commands.get("link").value;!!i&&n.keyCode===Go.enter&&n.altKey&&(e.stop(),Hy(i))}))}_enableSelectionAttributesFixer(){const t=this.editor.model,e=t.document.selection;this.listenTo(e,"change:attribute",((n,{attributeKeys:i})=>{i.includes("linkHref")&&!e.hasAttribute("linkHref")&&t.change((e=>{var n;!function(t,e){t.removeSelectionAttribute("linkHref");for(const n of e)t.removeSelectionAttribute(n)}(e,(n=t.schema,n.getDefinition("$text").allowAttributes.filter((t=>t.startsWith("link")))))}))}))}_enableClipboardIntegration(){const t=this.editor,e=t.model,n=this.editor.config.get("link.defaultProtocol");n&&this.listenTo(t.plugins.get("ClipboardPipeline"),"contentInsertion",((t,i)=>{e.change((t=>{const e=t.createRangeIn(i.content);for(const i of e.getItems())if(i.hasAttribute("linkHref")){const e=Oy(i.getAttribute("linkHref"),n);t.setAttribute("linkHref",e,i)}}))}))}}var Jy=n(3817),Qy={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(Jy.A,Qy);Jy.A.locals;class Xy extends lm{focusTracker=new Br;keystrokes=new Dr;urlInputView;saveButtonView;cancelButtonView;_manualDecoratorSwitches;children;_validators;_focusables=new Mu;_focusCycler;constructor(t,e,n){super(t);const i=t.t;this._validators=n,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),zu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),zu.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e.manualDecorators),this._focusCycler=new ym({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})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((t,e)=>(t[e.name]=e.isOn,t)),{})}render(){super.render(),hm({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()}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}_createUrlInput(){const t=this.locale.t,e=new Sg(this.locale,Rp);return e.fieldView.inputMode="url",e.label=t("Link URL"),e}_createButton(t,e,n,i){const o=new wm(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const n of t.manualDecorators){const i=new rg(this.locale);i.set({name:n.id,label:n.label,withText:!0}),i.bind("isOn").toMany([n,t],"value",((t,e)=>void 0===e&&void 0===t?!!n.defaultValue:!!t)),i.on("execute",(()=>{n.set("value",!i.isOn)})),e.add(i)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new lm;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}get url(){const{element:t}=this.urlInputView.fieldView;return t?t.value.trim():null}}var tx=n(8762),ex={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(tx.A,ex);tx.A.locals;class nx extends lm{focusTracker=new Br;keystrokes=new Dr;previewButtonView;unlinkButtonView;editButtonView;_focusables=new Mu;_focusCycler;_linkConfig;constructor(t,e={}){super(t);const n=t.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(n("Unlink"),'',"unlink"),this.editButtonView=this._createButton(n("Edit link"),zu.pencil,"edit"),this.set("href",void 0),this._linkConfig=e,this._focusCycler=new ym({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 i=new wm(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.delegate("execute").to(this,n),i}_createPreviewButton(){const t=new wm(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&&zy(t,this._linkConfig.allowedProtocols))),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 ix="link-ui";class ox extends Lr{actionsView=null;formView=null;_balloon;static get requires(){return[yb]}static get pluginName(){return"LinkUI"}init(){const t=this.editor,e=this.editor.t;t.editing.view.addObserver(Nh),this._balloon=t.plugins.get(yb),this._createToolbarLinkButton(),this._enableBalloonActivators(),t.conversion.for("editingDowncast").markerToHighlight({model:ix,view:{classes:["ck-fake-link-selection"]}}),t.conversion.for("editingDowncast").markerToElement({model:ix,view:(t,{writer:e})=>{if(!t.markerRange.isCollapsed)return null;const n=e.createUIElement("span");return e.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],n),n}}),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Create link"),keystroke:Ry},{label:e("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const t=this.editor,e=new nx(t.locale,t.config.get("link")),n=t.commands.get("link"),i=t.commands.get("unlink");return e.bind("href").to(n,"value"),e.editButtonView.bind("isEnabled").to(n),e.unlinkButtonView.bind("isEnabled").to(i),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(Ry,((t,e)=>{this._addFormView(),e()})),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),n=t.config.get("link.defaultProtocol"),i=new(dm(Xy))(t.locale,e,function(t){const e=t.t,n=t.config.get("link.allowCreatingEmptyLinks");return[t=>{if(!n&&!t.url.length)return e("Link URL must not be empty.")}]}(t));return i.urlInputView.fieldView.bind("value").to(e,"value"),i.urlInputView.bind("isEnabled").to(e,"isEnabled"),i.saveButtonView.bind("isEnabled").to(e,"isEnabled"),this.listenTo(i,"submit",(()=>{if(i.isValid()){const{value:e}=i.urlInputView.fieldView.element,o=Oy(e,n);t.execute("link",o,i.getDecoratorSwitchesState()),this._closeFormView()}})),this.listenTo(i.urlInputView,"change:errorText",(()=>{t.ui.update()})),this.listenTo(i,"cancel",(()=>{this._closeFormView()})),i.keystrokes.set("Esc",((t,e)=>{this._closeFormView(),e()})),i}_createToolbarLinkButton(){const t=this.editor;t.ui.componentFactory.add("link",(()=>{const t=this._createButton(wm);return t.set({tooltip:!0}),t})),t.ui.componentFactory.add("menuBar:link",(()=>{const t=this._createButton(Ym);return t.set({role:"menuitemcheckbox"}),t}))}_createButton(t){const e=this.editor,n=e.locale,i=e.commands.get("link"),o=new t(e.locale),r=n.t;return o.set({label:r("Link"),icon:'',keystroke:Ry,isToggleable:!0}),o.bind("isEnabled").to(i,"isEnabled"),o.bind("isOn").to(i,"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(Ry,((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())})),cm({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.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.urlInputView.fieldView.value=t.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_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.formView.urlInputView.fieldView.reset(),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(),i=r();const o=()=>{const t=this._getSelectedLinkElement(),e=r();n&&!t||!n&&e!==i?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=t,i=e};function r(){return e.selection.focus.getAncestors().reverse().find((t=>t.is("element")))}this.listenTo(t.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const t=this._balloon.visibleView;return!!this.formView&&t==this.formView||this._areActionsVisible}_getBalloonPositionData(){const t=this.editor.editing.view,e=this.editor.model,n=t.document;let i;if(e.markers.has(ix)){const e=Array.from(this.editor.editing.mapper.markerNameToElements(ix)),n=t.createRange(t.createPositionBefore(e[0]),t.createPositionAfter(e[e.length-1]));i=t.domConverter.viewRangeToDom(n)}else i=()=>{const e=this._getSelectedLinkElement();return e?t.domConverter.mapViewToDom(e):t.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:i}}_getSelectedLinkElement(){const t=this.editor.editing.view,e=t.document.selection,n=e.getSelectedElement();if(e.isCollapsed||n&&p_(n))return rx(e.getFirstPosition());{const n=e.getFirstRange().getTrimmed(),i=rx(n.start),o=rx(n.end);return i&&i==o&&t.createRangeIn(i).getTrimmed().isEqual(n)?i:null}}_showFakeVisualSelection(){const t=this.editor.model;t.change((e=>{const n=t.document.selection.getFirstRange();if(t.markers.has(ix))e.updateMarker(ix,{range:n});else if(n.start.isAtEnd){const i=n.start.getLastMatchingPosition((({item:e})=>!t.schema.isContent(e)),{boundaries:n});e.addMarker(ix,{usingOperation:!1,affectsData:!1,range:e.createRange(i,n.end)})}else e.addMarker(ix,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const t=this.editor.model;t.markers.has(ix)&&t.change((t=>{t.removeMarker(ix)}))}}function rx(t){return t.getAncestors().find((t=>{return(e=t).is("attributeElement")&&!!e.getCustomProperty("link");var e}))||null}const sx=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class ax extends Lr{static get requires(){return[sw,Yy]}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(),this._enablePasteLinking()}_expandLinkRange(t,e){return e.textNode&&e.textNode.hasAttribute("linkHref")?yw(e,"linkHref",e.textNode.getAttribute("linkHref"),t):null}_selectEntireLinks(t,e){const n=this.editor.model,i=n.document.selection,o=i.getFirstPosition(),r=i.getLastPosition();let s=e.getJoined(this._expandLinkRange(n,o)||e);s&&(s=s.getJoined(this._expandLinkRange(n,r)||e)),s&&(s.start.isBefore(o)||s.end.isAfter(r))&&t.setSelection(s)}_enablePasteLinking(){const t=this.editor,e=t.model,n=e.document.selection,i=t.plugins.get("ClipboardPipeline"),o=t.commands.get("link");i.on("inputTransformation",((t,i)=>{if(!this.isEnabled||!o.isEnabled||n.isCollapsed||"paste"!==i.method)return;if(n.rangeCount>1)return;const r=n.getFirstRange(),s=i.dataTransfer.getData("text/plain");if(!s)return;const a=s.match(sx);a&&a[2]===s&&(e.change((t=>{this._selectEntireLinks(t,r),o.execute(s)})),t.stop())}),{priority:"high"})}_enableTypingHandling(){const t=this.editor,e=new cw(t.model,(t=>{if(!function(t){return t.length>4&&" "===t[t.length-1]&&" "!==t[t.length-2]}(t))return;const e=lx(t.substr(0,t.length-1));return e?{url:e}:void 0}));e.on("matched:data",((e,n)=>{const{batch:i,range:o,url:r}=n;if(!i.isTyping)return;const s=o.end.getShiftedBy(-1),a=s.getShiftedBy(-r.length),l=t.model.createRange(a,s);this._applyAutoLink(r,l)})),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:i}=lw(t,e),o=lx(n);if(o){const t=e.createRange(i.end.getShiftedBy(-o.length),i.end);this._applyAutoLink(o,t)}}_applyAutoLink(t,e){const n=this.editor.model,i=Oy(t,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(t,e){return e.schema.checkAttributeInSelection(e.createSelection(t),"linkHref")}(e,n)&&Ny(i)&&!function(t){const e=t.start.nodeAfter;return!!e&&e.hasAttribute("linkHref")}(e)&&this._persistAutoLink(i,e)}_persistAutoLink(t,e){const n=this.editor.model,i=this.editor.plugins.get("Delete");n.enqueueChange((o=>{o.setAttribute("linkHref",t,e),n.enqueueChange((()=>{i.requestUndoOnBackspace()}))}))}}function lx(t){const e=sx.exec(t);return e?e[2]:null}var cx=n(4808),dx={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(cx.A,dx);cx.A.locals;class hx{_startElement;_referenceIndent;_isForward;_includeSelf;_sameAttributes;_sameIndent;_lowerIndent;_higherIndent;constructor(t,e){this._startElement=t,this._referenceIndent=t.getAttribute("listIndent"),this._isForward="forward"==e.direction,this._includeSelf=!!e.includeSelf,this._sameAttributes=tr(e.sameAttributes||[]),this._sameIndent=!!e.sameIndent,this._lowerIndent=!!e.lowerIndent,this._higherIndent=!!e.higherIndent}static first(t,e){return Er(new this(t,e)[Symbol.iterator]())}*[Symbol.iterator](){const t=[];for(const{node:e}of ux(this._getStartNode(),this._isForward?"forward":"backward")){const n=e.getAttribute("listIndent");if(nthis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){t.push(e);continue}}else{if(!this._sameIndent){if(this._higherIndent){t.length&&(yield*t,t.length=0);break}continue}if(this._sameAttributes.some((t=>e.getAttribute(t)!==this._startElement.getAttribute(t))))break}t.length&&(yield*t,t.length=0),yield e}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}function*ux(t,e="forward"){const n="forward"==e,i=[];let o=null;for(;px(t);){let e=null;if(o){const n=t.getAttribute("listIndent"),r=o.getAttribute("listIndent");n>r?i[r]=o:nt.getAttribute("listItemId")!=e))}function Dx(t){return Array.from(t).filter((t=>"$graveyard"!==t.root.rootName)).sort(((t,e)=>t.index-e.index))}function Sx(t){const e=t.document.selection.getSelectedElement();return e&&t.schema.isObject(e)&&t.schema.isBlock(e)?e:null}function Tx(t,e){return e.checkChild(t.parent,"listItem")&&e.checkChild(t,"$text")&&!e.isObject(t)}function Ix(t){return"numbered"==t||"customNumbered"==t}function Px(t,e,n){return bx(e,{direction:"forward"}).pop().index>t.index?yx(t,e,n):[]}class Vx extends Mr{_direction;constructor(t,e){super(t),this._direction=e}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=Fx(t.document.selection);t.change((t=>{const n=[];Bx(e)&&!wx(e[0])?("forward"==this._direction&&n.push(...xx(e,t)),n.push(...vx(e[0],t))):"forward"==this._direction?n.push(...xx(e,t,{expand:!0})):n.push(...function(t,e){const n=_x(t=tr(t)),i=new Set,o=Math.min(...n.map((t=>t.getAttribute("listIndent")))),r=new Map;for(const t of n)r.set(t,hx.first(t,{lowerIndent:!0}));for(const t of n){if(i.has(t))continue;i.add(t);const n=t.getAttribute("listIndent")-1;if(n<0)Ex(t,e);else{if(t.getAttribute("listIndent")==o){const n=Px(t,r.get(t),e);for(const t of n)i.add(t);if(n.length)continue}e.setAttribute("listIndent",n,t)}}return Dx(i)}(e,t));for(const e of n){if(!e.hasAttribute("listType"))continue;const n=hx.first(e,{sameIndent:!0});n&&t.setAttribute("listType",n.getAttribute("listType"),e)}this._fireAfterExecute(n)}))}_fireAfterExecute(t){this.fire("afterExecute",Dx(new Set(t)))}_checkEnabled(){let t=Fx(this.editor.model.document.selection),e=t[0];if(!e)return!1;if("backward"==this._direction)return!0;if(Bx(t)&&!wx(t[0]))return!0;t=_x(t),e=t[0];const n=hx.first(e,{sameIndent:!0});return!!n&&n.getAttribute("listType")==e.getAttribute("listType")}}function Fx(t){const e=Array.from(t.getSelectedBlocks()),n=e.findIndex((t=>!px(t)));return-1!=n&&(e.length=n),e}class Rx extends Mr{type;_listWalkerOptions;constructor(t,e,n={}){super(t),this.type=e,this._listWalkerOptions=n.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document,i=Sx(e),o=Array.from(n.selection.getSelectedBlocks()).filter((t=>e.schema.checkAttribute(t,"listType")||Tx(t,e.schema))),r=void 0!==t.forceValue?!t.forceValue:this.value;e.change((s=>{if(r){const t=o[o.length-1],e=bx(t,{direction:"forward"}),n=[];e.length>1&&n.push(...vx(e[1],s)),n.push(...Ex(o,s)),n.push(...function(t,e){const n=[];let i=Number.POSITIVE_INFINITY;for(const{node:o}of ux(t.nextSibling,"forward")){const t=o.getAttribute("listIndent");if(0==t)break;t{const{firstElement:r,lastElement:s}=this._getMergeSubjectElements(n,t),a=r.getAttribute("listIndent")||0,l=s.getAttribute("listIndent"),c=s.getAttribute("listItemId");if(a!=l){const t=(d=s,Array.from(new hx(d,{direction:"forward",higherIndent:!0})));i.push(...xx([s,...t],o,{indentBy:a-l,expand:a{const e=vx(this._getStartBlock(),t);this._fireAfterExecute(e)}))}_fireAfterExecute(t){this.fire("afterExecute",Dx(new Set(t)))}_checkEnabled(){const t=this.editor.model.document.selection,e=this._getStartBlock();return t.isCollapsed&&px(e)&&!wx(e)}_getStartBlock(){const t=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?t:t.nextSibling}}class Mx extends Lr{static get pluginName(){return"ListUtils"}expandListBlocksToCompleteList(t){return Cx(t)}isFirstBlockOfListItem(t){return wx(t)}isListItemBlock(t){return px(t)}expandListBlocksToCompleteItems(t,e={}){return _x(t,e)}isNumberedListType(t){return Ix(t)}}function Ox(t){return t.is("element","ol")||t.is("element","ul")}function Nx(t){return t.is("element","li")}function Hx(t,e,n,i=Wx(n,e)){return t.createAttributeElement(qx(n),null,{priority:2*e/100-100,id:i})}function jx(t,e,n){return t.createAttributeElement("li",null,{priority:(2*e+1)/100-100,id:n})}function qx(t){return"numbered"==t||"customNumbered"==t?"ol":"ul"}function Wx(t,e){return`list-${t}-${e}`}function Ux(t,e){const n=t.nodeBefore;if(px(n)){let t=n;for(const{node:n}of ux(t,"backward"))if(t=n,e.has(t))return;e.set(n,t)}else{const n=t.nodeAfter;px(n)&&e.set(n,n)}}function $x(){return(t,e,n)=>{const{writer:i,schema:o}=n;if(!e.modelRange)return;const r=Array.from(e.modelRange.getItems({shallow:!0})).filter((t=>o.checkAttribute(t,"listItemId")));if(!r.length)return;const s=gx.next(),a=function(t){let e=0,n=t.parent;for(;n;){if(Nx(n))e++;else{const t=n.previousSibling;t&&Nx(t)&&e++}n=n.parent}return e}(e.viewItem);let l=e.viewItem.parent&&e.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=r[0].getAttribute("listType");c&&(l=c);const d={listItemId:s,listIndent:a,listType:l};for(const t of r)t.hasAttribute("listItemId")||i.setAttributes(d,t);r.length>1&&r[1].getAttribute("listItemId")!=d.listItemId&&n.keepEmptyElement(r[0])}}function Gx(t,e,n,{dataPipeline:i}={}){const o=function(t){return(e,n)=>{const i=[];for(const n of t)e.hasAttribute(n)&&i.push(`attribute:${n}`);return!!i.every((t=>!1!==n.test(e,t)))&&(i.forEach((t=>n.consume(e,t))),!0)}}(t);return(r,s,a)=>{const{writer:l,mapper:c,consumable:d}=a,h=s.item;if(!t.includes(s.attributeKey))return;if(!o(h,d))return;const u=function(t,e,n){const i=n.createRangeOn(t),o=e.toViewRange(i).getTrimmed();return o.end.nodeBefore}(h,c,n);Zx(u,l,c),function(t,e){let n=t.parent;for(;n.is("attributeElement")&&["ul","ol","li"].includes(n.name);){const i=n.parent;e.unwrap(e.createRangeOn(t),n),n=i}}(u,l);const m=function(t,e,n,i,{dataPipeline:o}){let r=i.createRangeOn(e);if(!wx(t))return r;for(const s of n){if("itemMarker"!=s.scope)continue;const n=s.createElement(i,t,{dataPipeline:o});if(!n)continue;if(i.setCustomProperty("listItemMarker",!0,n),s.canInjectMarkerIntoElement&&s.canInjectMarkerIntoElement(t)?i.insert(i.createPositionAt(e,0),n):(i.insert(r.start,n),r=i.createRange(i.createPositionBefore(n),i.createPositionAfter(e))),!s.createWrapperElement||!s.canWrapElement)continue;const a=s.createWrapperElement(i,t,{dataPipeline:o});i.setCustomProperty("listItemWrapper",!0,a),s.canWrapElement(t)?r=i.wrap(r,a):(r=i.wrap(i.createRangeOn(n),a),r=i.createRange(r.start,i.createPositionAfter(e)))}return r}(h,u,e,l,{dataPipeline:i});!function(t,e,n,i){if(!t.hasAttribute("listIndent"))return;const o=t.getAttribute("listIndent");let r=t;for(let t=o;t>=0;t--){const o=jx(i,t,r.getAttribute("listItemId")),s=Hx(i,t,r.getAttribute("listType"));for(const t of n)"list"!=t.scope&&"item"!=t.scope||!r.hasAttribute(t.attributeName)||t.setAttributeOnDowncast(i,r.getAttribute(t.attributeName),"list"==t.scope?s:o);if(e=i.wrap(e,o),e=i.wrap(e,s),0==t)break;if(r=hx.first(r,{lowerIndent:!0}),!r)break}}(h,m,e,l)}}function Kx(t,{dataPipeline:e}={}){return(n,{writer:i})=>{if(!Yx(n,t))return null;if(!e)return i.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=i.createContainerElement("p");return i.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function Zx(t,e,n){for(;t.parent.is("attributeElement")&&t.parent.getCustomProperty("listItemWrapper");)e.unwrap(e.createRangeOn(t),t.parent);const i=[];o(e.createPositionBefore(t).getWalker({direction:"backward"})),o(e.createRangeIn(t).getWalker());for(const t of i)e.remove(t);function o(t){for(const{item:e}of t){if(e.is("element")&&n.toModelElement(e))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&i.push(e)}}}function Yx(t,e,n=fx(t)){if(!px(t))return!1;for(const n of t.getAttributeKeys())if(!n.startsWith("selection:")&&!e.includes(n))return!1;return n.length<2}var Jx=n(1232),Qx={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(Jx.A,Qx);Jx.A.locals;var Xx=n(6903),tE={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(Xx.A,tE);Xx.A.locals;const eE=["listType","listIndent","listItemId"];class nE extends Lr{_downcastStrategies=[];static get pluginName(){return"ListEditing"}static get requires(){return[pA,sw,Mx,l_]}constructor(t){super(t),t.config.define("list.multiBlock",!0)}init(){const t=this.editor,e=t.model,n=t.config.get("list.multiBlock");if(t.plugins.has("LegacyListEditing"))throw new ki("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});e.schema.register("$listItem",{allowAttributes:eE}),n?(e.schema.extend("$container",{allowAttributesOf:"$listItem"}),e.schema.extend("$block",{allowAttributesOf:"$listItem"}),e.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):e.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const t of eE)e.schema.setAttributeProperties(t,{copyOnReplace:!0});t.commands.add("numberedList",new Rx(t,"numbered")),t.commands.add("bulletedList",new Rx(t,"bulleted")),t.commands.add("customNumberedList",new Rx(t,"customNumbered",{multiLevel:!0})),t.commands.add("customBulletedList",new Rx(t,"customBulleted",{multiLevel:!0})),t.commands.add("indentList",new Vx(t,"forward")),t.commands.add("outdentList",new Vx(t,"backward")),t.commands.add("splitListItemBefore",new zx(t,"before")),t.commands.add("splitListItemAfter",new zx(t,"after")),n&&(t.commands.add("mergeListItemBackward",new Lx(t,"backward")),t.commands.add("mergeListItemForward",new Lx(t,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const t=this.editor.commands,e=t.get("indent"),n=t.get("outdent");e&&e.registerChildCommand(t.get("indentList"),{priority:"high"}),n&&n.registerChildCommand(t.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(t){this._downcastStrategies.push(t)}getListAttributeNames(){return[...eE,...this._downcastStrategies.map((t=>t.attributeName))]}_setupDeleteIntegration(){const t=this.editor,e=t.commands.get("mergeListItemBackward"),n=t.commands.get("mergeListItemForward");this.listenTo(t.editing.view.document,"delete",((i,o)=>{const r=t.model.document.selection;Sx(t.model)||t.model.change((()=>{const s=r.getFirstPosition();if(r.isCollapsed&&"backward"==o.direction){if(!s.isAtStart)return;const n=s.parent;if(!px(n))return;if(hx.first(n,{sameAttributes:"listType",sameIndent:!0})||0!==n.getAttribute("listIndent")){if(!e||!e.isEnabled)return;e.execute({shouldMergeOnBlocksContentLevel:iE(t.model,"backward")})}else Ax(n)||t.execute("splitListItemAfter"),t.execute("outdentList");o.preventDefault(),i.stop()}else{if(r.isCollapsed&&!r.getLastPosition().isAtEnd)return;if(!n||!n.isEnabled)return;n.execute({shouldMergeOnBlocksContentLevel:iE(t.model,"forward")}),o.preventDefault(),i.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const t=this.editor,e=t.model,n=t.commands,i=n.get("enter");this.listenTo(t.editing.view.document,"enter",((n,i)=>{const o=e.document,r=o.selection.getFirstPosition().parent;if(o.selection.isCollapsed&&px(r)&&r.isEmpty&&!i.isSoft){const e=wx(r),o=Ax(r);e&&o?(t.execute("outdentList"),i.preventDefault(),n.stop()):e&&!o?(t.execute("splitListItemAfter"),i.preventDefault(),n.stop()):o&&(t.execute("splitListItemBefore"),i.preventDefault(),n.stop())}}),{context:"li"}),this.listenTo(i,"afterExecute",(()=>{const e=n.get("splitListItemBefore");if(e.refresh(),!e.isEnabled)return;2===fx(t.model.document.selection.getLastPosition().parent).length&&e.execute()}))}_setupTabIntegration(){const t=this.editor;this.listenTo(t.editing.view.document,"tab",((e,n)=>{const i=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(i).isEnabled&&(t.execute(i),n.stopPropagation(),n.preventDefault(),e.stop())}),{context:"li"})}_setupConversion(){const t=this.editor,e=t.model,n=this.getListAttributeNames(),i=t.config.get("list.multiBlock"),o=i?"paragraph":"listItem";t.conversion.for("upcast").elementToElement({view:"li",model:(t,{writer:e})=>e.createElement(o,{listType:""})}).elementToElement({view:"p",model:(t,{writer:e})=>t.parent&&t.parent.is("element","li")?e.createElement(o,{listType:""}):null,converterPriority:"high"}).add((t=>{t.on("element:li",$x())})),i||t.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),t.conversion.for("editingDowncast").elementToElement({model:o,view:Kx(n),converterPriority:"high"}).add((t=>{var i;t.on("attribute",Gx(n,this._downcastStrategies,e)),t.on("remove",(i=e.schema,(t,e,n)=>{const{writer:o,mapper:r}=n,s=t.name.split(":")[1];if(!i.checkAttribute(s,"listItemId"))return;const a=r.toViewPosition(e.position),l=e.position.getShiftedBy(e.length),c=r.toViewPosition(l,{isPhantom:!0}),d=o.createRange(a,c).getTrimmed().end.nodeBefore;d&&Zx(d,o,r)}))})),t.conversion.for("dataDowncast").elementToElement({model:o,view:Kx(n,{dataPipeline:!0}),converterPriority:"high"}).add((t=>{t.on("attribute",Gx(n,this._downcastStrategies,e,{dataPipeline:!0}))}));const r=(s=this._downcastStrategies,a=t.editing.view,(t,e)=>{if(e.modelPosition.offset>0)return;const n=e.modelPosition.parent;if(!px(n))return;if(!s.some((t=>"itemMarker"==t.scope&&t.canInjectMarkerIntoElement&&t.canInjectMarkerIntoElement(n))))return;const i=e.mapper.toViewElement(n),o=a.createRangeIn(i),r=o.getWalker();let l=o.start;for(const{item:t}of r){if(t.is("element")&&e.mapper.toModelElement(t)||t.is("$textProxy"))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&(l=a.createPositionAfter(t),r.skip((({previousPosition:t})=>!t.isEqual(l))))}e.viewPosition=l});var s,a;t.editing.mapper.on("modelToViewPosition",r),t.data.mapper.on("modelToViewPosition",r),this.listenTo(e.document,"change:data",function(t,e,n,i){return()=>{const i=t.document.differ.getChanges(),s=[],a=new Map,l=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name)Ux(t.position,a),t.attributes.has("listItemId")?l.add(t.position.nodeAfter):Ux(t.position.getShiftedBy(t.length),a);else if("remove"==t.type&&t.attributes.has("listItemId"))Ux(t.position,a);else if("attribute"==t.type){const e=t.range.start.nodeAfter;n.includes(t.attributeKey)?(Ux(t.range.start,a),null===t.attributeNewValue?(Ux(t.range.start.getShiftedBy(1),a),r(e)&&s.push(e)):l.add(e)):px(e)&&r(e)&&s.push(e)}for(const t of a.values())s.push(...o(t,l));for(const t of new Set(s))e.reconvertItem(t)};function o(t,e){const i=[],o=new Set,a=[];for(const{node:l,previous:c}of ux(t,"forward")){if(o.has(l))continue;const t=l.getAttribute("listIndent");c&&tn.includes(t))));const d=bx(l,{direction:"forward"});for(const t of d)o.add(t),(r(t,d)||s(t,a,e))&&i.push(t)}return i}function r(t,o){const r=e.mapper.toViewElement(t);if(!r)return!1;if(i.fire("checkElement",{modelElement:t,viewElement:r}))return!0;if(!t.is("element","paragraph")&&!t.is("element","listItem"))return!1;const s=Yx(t,n,o);return!(!s||!r.is("element","p"))||!(s||!r.is("element","span"))}function s(t,n,o){if(o.has(t))return!1;const r=e.mapper.toViewElement(t);let s=n.length-1;for(let t=r.parent;!t.is("editableElement");t=t.parent){const e=Nx(t),o=Ox(t);if(!o&&!e)continue;const r="checkAttributes:"+(e?"item":"list");if(i.fire(r,{viewElement:t,modelAttributes:n[s]}))break;if(o&&(s--,s<0))return!1}return!0}}(e,t.editing,n,this),{priority:"high"}),this.on("checkAttributes:item",((t,{viewElement:e,modelAttributes:n})=>{e.id!=n.listItemId&&(t.return=!0,t.stop())})),this.on("checkAttributes:list",((t,{viewElement:e,modelAttributes:n})=>{e.name==qx(n.listType)&&e.id==Wx(n.listType,n.listIndent)||(t.return=!0,t.stop())}))}_setupModelPostFixing(){const t=this.editor.model,e=this.getListAttributeNames();t.document.registerPostFixer((n=>function(t,e,n,i){const o=t.document.differ.getChanges(),r=new Map,s=i.editor.config.get("list.multiBlock");let a=!1;for(const i of o){if("insert"==i.type&&"$text"!=i.name){const o=i.position.nodeAfter;if(!t.schema.checkAttribute(o,"listItemId"))for(const t of Array.from(o.getAttributeKeys()))n.includes(t)&&(e.removeAttribute(t,o),a=!0);Ux(i.position,r),i.attributes.has("listItemId")||Ux(i.position.getShiftedBy(i.length),r);for(const{item:e,previousPosition:n}of t.createRangeIn(o))px(e)&&Ux(n,r)}else"remove"==i.type?Ux(i.position,r):"attribute"==i.type&&n.includes(i.attributeKey)&&(Ux(i.range.start,r),null===i.attributeNewValue&&Ux(i.range.start.getShiftedBy(1),r));if(!s&&"attribute"==i.type&&eE.includes(i.attributeKey)){const t=i.range.start.nodeAfter;null===i.attributeNewValue&&t&&t.is("element","listItem")?(e.rename(t,"paragraph"),a=!0):null===i.attributeOldValue&&t&&t.is("element")&&"listItem"!=t.name&&(e.rename(t,"listItem"),a=!0)}}const l=new Set;for(const t of r.values())a=i.fire("postFixer",{listNodes:new mx(t),listHead:t,writer:e,seenIds:l})||a;return a}(t,n,e,this))),this.on("postFixer",((t,{listNodes:e,writer:n})=>{t.return=function(t,e){let n=0,i=-1,o=null,r=!1;for(const{node:s}of t){const t=s.getAttribute("listIndent");if(t>n){let a;null===o?(o=t-n,a=n):(o>t&&(o=t),a=t-o),a>i+1&&(a=i+1),e.setAttribute("listIndent",a,s),r=!0,i=a}else o=null,n=t+1,i=t}return r}(e,n)||t.return}),{priority:"high"}),this.on("postFixer",((t,{listNodes:e,writer:n,seenIds:i})=>{t.return=function(t,e,n){const i=new Set;let o=!1;for(const{node:r}of t){if(i.has(r))continue;let t=r.getAttribute("listType"),s=r.getAttribute("listItemId");if(e.has(s)&&(s=gx.next()),e.add(s),r.is("element","listItem"))r.getAttribute("listItemId")!=s&&(n.setAttribute("listItemId",s,r),o=!0);else for(const e of bx(r,{direction:"forward"}))i.add(e),e.getAttribute("listType")!=t&&(s=gx.next(),t=e.getAttribute("listType")),e.getAttribute("listItemId")!=s&&(n.setAttribute("listItemId",s,e),o=!0)}return o}(e,i,n)||t.return}),{priority:"high"})}_setupClipboardIntegration(){const t=this.editor.model,e=this.editor.plugins.get("ClipboardPipeline");this.listenTo(t,"insertContent",function(t){return(e,[n,i])=>{const o=n.is("documentFragment")?Array.from(n.getChildren()):[n];if(!o.length)return;const r=(i?t.createSelection(i):t.document.selection).getFirstPosition();let s;if(px(r.parent))s=r.parent;else{if(!px(r.nodeBefore))return;s=r.nodeBefore}t.change((t=>{const e=s.getAttribute("listType"),n=s.getAttribute("listIndent"),i=o[0].getAttribute("listIndent")||0,r=Math.max(n-i,0);for(const n of o){const i=px(n);s.is("element","listItem")&&n.is("element","paragraph")&&t.rename(n,"listItem"),t.setAttributes({listIndent:(i?n.getAttribute("listIndent"):0)+r,listItemId:i?n.getAttribute("listItemId"):gx.next(),listType:e},n)}}))}}(t),{priority:"high"}),this.listenTo(e,"outputTransformation",((e,n)=>{t.change((t=>{const e=Array.from(n.content.getChildren()),i=e[e.length-1];if(e.length>1&&i.is("element")&&i.isEmpty){e.slice(0,-1).every(px)&&t.remove(i)}if("copy"==n.method||"cut"==n.method){const e=Array.from(n.content.getChildren());Bx(e)&&Ex(e,t)}}))}))}_setupAccessibilityIntegration(){const t=this.editor,e=t.t;t.accessibility.addKeystrokeInfoGroup({id:"list",label:e("Keystrokes that can be used in a list"),keystrokes:[{label:e("Increase list item indent"),keystroke:"Tab"},{label:e("Decrease list item indent"),keystroke:"Shift+Tab"}]})}}function iE(t,e){const n=t.document.selection;if(!n.isCollapsed)return!Sx(t);if("forward"===e)return!0;const i=n.getFirstPosition().parent,o=i.previousSibling;return!t.schema.isObject(o)&&(!!o.isEmpty||Bx([i,o]))}function oE(t,e,n,i){t.ui.componentFactory.add(e,(()=>{const o=rE(wm,t,e,n,i);return o.set({tooltip:!0,isToggleable:!0}),o})),t.ui.componentFactory.add(`menuBar:${e}`,(()=>{const o=rE(Ym,t,e,n,i);return o.set({role:"menuitemcheckbox",isToggleable:!0}),o}))}function rE(t,e,n,i,o){const r=e.commands.get(n),s=new t(e.locale);return s.set({label:i,icon:o}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(n),e.editing.view.focus()})),s}class sE extends Lr{static get pluginName(){return"ListUI"}init(){const t=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||oE(this.editor,"numberedList",t("Numbered List"),zu.numberedList),this.editor.ui.componentFactory.has("bulletedList")||oE(this.editor,"bulletedList",t("Bulleted List"),zu.bulletedList)}}class aE extends Lr{static get requires(){return[nE,sE]}static get pluginName(){return"List"}}class lE extends Mr{refresh(){const t=this._getValue();this.value=t,this.isEnabled=null!=t}execute({startIndex:t=1}={}){const e=this.editor.model,n=e.document;let i=Array.from(n.selection.getSelectedBlocks()).filter((t=>px(t)&&Ix(t.getAttribute("listType"))));i=Cx(i),e.change((e=>{for(const n of i)e.setAttribute("listStart",t>=0?t:1,n)}))}_getValue(){const t=Er(this.editor.model.document.selection.getSelectedBlocks());return t&&px(t)&&Ix(t.getAttribute("listType"))?t.getAttribute("listStart"):null}}const cE={},dE={},hE={},uE=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:t,typeAttribute:e,listType:n}of uE)cE[t]=n,dE[t]=e,e&&(hE[e]=t);function mE(){return uE.map((t=>t.listStyle))}function gE(t){return cE[t]||null}function pE(t){return hE[t]||null}function fE(t){return dE[t]||null}class bE extends Mr{defaultType;_supportedTypes;constructor(t,e,n){super(t),this.defaultType=e,this._supportedTypes=n}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document;e.change((e=>{this._tryToConvertItemsToList(t);let i=Array.from(n.selection.getSelectedBlocks()).filter((t=>t.hasAttribute("listType")));if(i.length){i=Cx(i);for(const n of i)e.setAttribute("listStyle",t.type||this.defaultType,n)}}))}isStyleTypeSupported(t){return!this._supportedTypes||this._supportedTypes.includes(t)}_getValue(){const t=Er(this.editor.model.document.selection.getSelectedBlocks());return px(t)?t.getAttribute("listStyle"):null}_checkEnabled(){const t=this.editor,e=t.commands.get("numberedList"),n=t.commands.get("bulletedList");return e.isEnabled||n.isEnabled}_tryToConvertItemsToList(t){if(!t.type)return;const e=gE(t.type);if(!e)return;const n=this.editor,i=`${e}List`;n.commands.get(i).value||n.execute(i)}}class kE extends Mr{refresh(){const t=this._getValue();this.value=t,this.isEnabled=null!=t}execute(t={}){const e=this.editor.model,n=e.document;let i=Array.from(n.selection.getSelectedBlocks()).filter((t=>px(t)&&"numbered"==t.getAttribute("listType")));i=Cx(i),e.change((e=>{for(const n of i)e.setAttribute("listReversed",!!t.reversed,n)}))}_getValue(){const t=Er(this.editor.model.document.selection.getSelectedBlocks());return px(t)&&"numbered"==t.getAttribute("listType")?t.getAttribute("listReversed"):null}}function wE(t){return(e,n,i)=>{const{writer:o,schema:r,consumable:s}=i;if(!1===s.test(n.viewItem,t.viewConsumables))return;n.modelRange||Object.assign(n,i.convertChildren(n.viewItem,n.modelCursor));let a=!1;for(const e of n.modelRange.getItems({shallow:!0}))r.checkAttribute(e,t.attributeName)&&t.appliesToListItem(e)&&(e.hasAttribute(t.attributeName)||(o.setAttribute(t.attributeName,t.getAttributeOnUpcast(n.viewItem),e),a=!0));a&&s.consume(n.viewItem,t.viewConsumables)}}class AE extends Lr{static get pluginName(){return"ListPropertiesUtils"}getAllSupportedStyleTypes(){return mE()}getListTypeFromListStyleType(t){return gE(t)}getListStyleTypeFromTypeAttribute(t){return pE(t)}getTypeAttributeFromListStyleType(t){return fE(t)}}function _E(t){const{startIndex:e,reversed:n,styles:i}=t;return{styles:CE(i),startIndex:e||!1,reversed:n||!1}}function CE(t){const e={listTypes:["bulleted","numbered"],useAttribute:!1};return!0===t||(t?Array.isArray(t)||"string"==typeof t?e.listTypes=tr(t):(e.listTypes=t.listTypes?tr(t.listTypes):e.listTypes,e.useAttribute=!!t.useAttribute):e.listTypes=[]),e}const vE="default";class yE extends Lr{static get requires(){return[nE,AE]}static get pluginName(){return"ListPropertiesEditing"}constructor(t){super(t),t.config.define("list.properties",{styles:!0,startIndex:!1,reversed:!1})}init(){const t=this.editor,e=t.model,n=t.plugins.get(nE),i=function(t){const e=[],n=_E(t);if(t.styles){const t=n.styles.useAttribute;e.push({attributeName:"listStyle",defaultValue:vE,viewConsumables:{styles:"list-style-type"},addCommand(e){let n=mE();t&&(n=n.filter((t=>!!fE(t)))),e.commands.add("listStyle",new bE(e,vE,n))},appliesToListItem:t=>"numbered"==t.getAttribute("listType")||"bulleted"==t.getAttribute("listType"),hasValidAttribute(t){if(!this.appliesToListItem(t))return!t.hasAttribute("listStyle");if(!t.hasAttribute("listStyle"))return!1;const e=t.getAttribute("listStyle");return e==vE||gE(e)==t.getAttribute("listType")},setAttributeOnDowncast(e,n,i){if(n&&n!==vE){if(!t)return void e.setStyle("list-style-type",n,i);{const t=fE(n);if(t)return void e.setAttribute("type",t,i)}}e.removeStyle("list-style-type",i),e.removeAttribute("type",i)},getAttributeOnUpcast(t){const e=t.getStyle("list-style-type");if(e)return e;const n=t.getAttribute("type");return n?pE(n):vE}})}t.reversed&&e.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(t){t.commands.add("listReversed",new kE(t))},appliesToListItem:t=>"numbered"==t.getAttribute("listType"),hasValidAttribute(t){return this.appliesToListItem(t)==t.hasAttribute("listReversed")},setAttributeOnDowncast(t,e,n){e?t.setAttribute("reversed","reversed",n):t.removeAttribute("reversed",n)},getAttributeOnUpcast:t=>t.hasAttribute("reversed")});t.startIndex&&e.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(t){t.commands.add("listStart",new lE(t))},appliesToListItem:t=>Ix(t.getAttribute("listType")),hasValidAttribute(t){return this.appliesToListItem(t)==t.hasAttribute("listStart")},setAttributeOnDowncast(t,e,n){0==e||e>1?t.setAttribute("start",e,n):t.removeAttribute("start",n)},getAttributeOnUpcast(t){const e=t.getAttribute("start");return e>=0?e:1}});return e}(t.config.get("list.properties"));for(const o of i)o.addCommand(t),e.schema.extend("$listItem",{allowAttributes:o.attributeName}),n.registerDowncastStrategy({scope:"list",attributeName:o.attributeName,setAttributeOnDowncast(t,e,n){o.setAttributeOnDowncast(t,e,n)}});t.conversion.for("upcast").add((t=>{for(const e of i)t.on("element:ol",wE(e)),t.on("element:ul",wE(e))})),n.on("checkAttributes:list",((t,{viewElement:e,modelAttributes:n})=>{for(const o of i)o.getAttributeOnUpcast(e)!=n[o.attributeName]&&(t.return=!0,t.stop())})),this.listenTo(t.commands.get("indentList"),"afterExecute",((t,n)=>{e.change((t=>{for(const e of n)for(const n of i)n.appliesToListItem(e)&&t.setAttribute(n.attributeName,n.defaultValue,e)}))})),n.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:o}of e)for(const e of i)e.hasValidAttribute(o)||(e.appliesToListItem(o)?n.setAttribute(e.attributeName,e.defaultValue,o):n.removeAttribute(e.attributeName,o),t.return=!0)})),n.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:o,previousNodeInList:r}of e)if(r&&r.getAttribute("listType")==o.getAttribute("listType"))for(const e of i){const{attributeName:i}=e;if(!e.appliesToListItem(o))continue;const s=r.getAttribute(i);o.getAttribute(i)!=s&&(n.setAttribute(i,s,o),t.return=!0)}}))}}var xE=n(9968),EE={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(xE.A,EE);xE.A.locals;class BE extends lm{children;stylesView=null;additionalPropertiesCollapsibleView=null;startIndexFieldView=null;reversedSwitchButtonView=null;focusTracker=new Br;keystrokes=new Dr;focusables=new Mu;focusCycler;constructor(t,{enabledProperties:e,styleButtonViews:n,styleGridAriaLabel:i}){super(t);const o=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new ym({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),n&&n.length?(this.stylesView=this._createStylesView(n,i),this.children.add(this.stylesView)):o.push("ck-list-properties_without-styles"),(e.startIndex||e.reversed)&&(this._addNumberedListPropertyViews(e),o.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:o},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const t of this.stylesView.children)this.stylesView.focusTracker.add(t.element);um({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>Yn.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const 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.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(t,e){const n=new lm(this.locale);return n.children=n.createCollection(),n.children.addMany(t),n.setTemplate({tag:"div",attributes:{"aria-label":e,class:["ck","ck-list-styles-list"]},children:n.children}),n.children.delegate("execute").to(this),n.focus=function(){this.children.first.focus()},n.focusTracker=new Br,n.keystrokes=new Dr,n.render(),n.keystrokes.listenTo(n.element),n}_addNumberedListPropertyViews(t){const e=this.locale.t,n=[];t.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),n.push(this.startIndexFieldView)),t.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),n.push(this.reversedSwitchButtonView)),this.stylesView?(this.additionalPropertiesCollapsibleView=new mg(this.locale,n),this.additionalPropertiesCollapsibleView.set({label:e("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(n,"isEnabled",((...t)=>t.some((t=>t)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((t,e,n)=>{n||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(n)}_createStartIndexField(){const t=this.locale.t,e=new Sg(this.locale,Lp);return e.set({label:t("Start at"),class:"ck-numbered-list-properties__start-index"}),e.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),e.fieldView.on("input",(()=>{const n=e.fieldView.element,i=n.valueAsNumber;Number.isNaN(i)?e.errorText=t("Invalid start index value."):n.checkValidity()?this.fire("listStart",{startIndex:i}):e.errorText=t("Start index must be greater than 0.")})),e}_createReversedSwitchButton(){const t=this.locale.t,e=new rg(this.locale);return e.set({withText:!0,label:t("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),e.delegate("execute").to(this,"listReversed"),e}}var DE=n(7141),SE={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(DE.A,SE);DE.A.locals;class TE extends Lr{static get pluginName(){return"ListPropertiesUI"}init(){const t=this.editor,e=t.locale.t,n=t.config.get("list.properties"),i=_E(n),o=i.styles.listTypes;if(o.includes("bulleted")){const n=[{label:e("Toggle the disc list style"),tooltip:e("Disc"),type:"disc",icon:''},{label:e("Toggle the circle list style"),tooltip:e("Circle"),type:"circle",icon:''},{label:e("Toggle the square list style"),tooltip:e("Square"),type:"square",icon:''}],o=e("Bulleted List"),r=e("Bulleted list styles toolbar"),s="bulletedList";t.ui.componentFactory.add(s,IE({editor:t,normalizedConfig:i,parentCommandName:s,buttonLabel:o,buttonIcon:zu.bulletedList,styleGridAriaLabel:r,styleDefinitions:n})),t.ui.componentFactory.add(`menuBar:${s}`,VE({editor:t,normalizedConfig:i,parentCommandName:s,buttonLabel:o,styleGridAriaLabel:r,styleDefinitions:n}))}if(o.includes("numbered")||n.startIndex||n.reversed){const n=[{label:e("Toggle the decimal list style"),tooltip:e("Decimal"),type:"decimal",icon:''},{label:e("Toggle the decimal with leading zero list style"),tooltip:e("Decimal with leading zero"),type:"decimal-leading-zero",icon:''},{label:e("Toggle the lower–roman list style"),tooltip:e("Lower–roman"),type:"lower-roman",icon:''},{label:e("Toggle the upper–roman list style"),tooltip:e("Upper-roman"),type:"upper-roman",icon:''},{label:e("Toggle the lower–latin list style"),tooltip:e("Lower-latin"),type:"lower-latin",icon:''},{label:e("Toggle the upper–latin list style"),tooltip:e("Upper-latin"),type:"upper-latin",icon:''}],r=e("Numbered List"),s=e("Numbered list styles toolbar"),a="numberedList";t.ui.componentFactory.add(a,IE({editor:t,normalizedConfig:i,parentCommandName:a,buttonLabel:r,buttonIcon:zu.numberedList,styleGridAriaLabel:s,styleDefinitions:n})),o.includes("numbered")&&t.ui.componentFactory.add(`menuBar:${a}`,VE({editor:t,normalizedConfig:i,parentCommandName:a,buttonLabel:r,styleGridAriaLabel:s,styleDefinitions:n}))}}}function IE({editor:t,normalizedConfig:e,parentCommandName:n,buttonLabel:i,buttonIcon:o,styleGridAriaLabel:r,styleDefinitions:s}){const a=t.commands.get(n);return l=>{const c=Dp(l,vp),d=c.buttonView;return c.bind("isEnabled").to(a),c.class="ck-list-styles-dropdown",d.on("execute",(()=>{t.execute(n),t.editing.view.focus()})),d.set({label:i,icon:o,tooltip:!0,isToggleable:!0}),d.bind("isOn").to(a,"value",(t=>!!t)),c.once("change:isOpen",(()=>{const i=function({editor:t,normalizedConfig:e,dropdownView:n,parentCommandName:i,styleDefinitions:o,styleGridAriaLabel:r}){const s=t.locale,a={...e,..."numberedList"!=i?{startIndex:!1,reversed:!1}:null},l=i.replace("List","");let c=null;if(e.styles.listTypes.includes(l)){const e=t.commands.get("listStyle"),n=PE({editor:t,parentCommandName:i,listStyleCommand:e}),r=FE(e);c=o.filter(r).map(n)}const d=new BE(s,{styleGridAriaLabel:r,enabledProperties:a,styleButtonViews:c});e.styles.listTypes.includes(l)&&Vp(n,(()=>d.stylesView.children.find((t=>t.isOn))));if(a.startIndex){const e=t.commands.get("listStart");d.startIndexFieldView.bind("isEnabled").to(e),d.startIndexFieldView.fieldView.bind("value").to(e),d.on("listStart",((e,n)=>t.execute("listStart",n)))}if(a.reversed){const e=t.commands.get("listReversed");d.reversedSwitchButtonView.bind("isEnabled").to(e),d.reversedSwitchButtonView.bind("isOn").to(e,"value",(t=>!!t)),d.on("listReversed",(()=>{const n=e.value;t.execute("listReversed",{reversed:!n})}))}return d.delegate("execute").to(n),d}({editor:t,normalizedConfig:e,dropdownView:c,parentCommandName:n,styleGridAriaLabel:r,styleDefinitions:s});c.panelView.children.add(i)})),c.on("execute",(()=>{t.editing.view.focus()})),c}}function PE({editor:t,listStyleCommand:e,parentCommandName:n}){const i=t.locale,o=t.commands.get(n);return({label:r,type:s,icon:a,tooltip:l})=>{const c=new wm(i);return c.set({label:r,icon:a,tooltip:l}),e.on("change:value",(()=>{c.isOn=e.value===s})),c.on("execute",(()=>{o.value?e.value===s?t.execute(n):e.value!==s&&t.execute("listStyle",{type:s}):t.model.change((()=>{t.execute("listStyle",{type:s})}))})),c}}function VE({editor:t,normalizedConfig:e,parentCommandName:n,buttonLabel:i,styleGridAriaLabel:o,styleDefinitions:r}){return s=>{const a=new ok(s),l=t.commands.get(n),c=t.commands.get("listStyle"),d=FE(c),h=PE({editor:t,parentCommandName:n,listStyleCommand:c}),u=r.filter(d).map(h),m=new BE(s,{styleGridAriaLabel:o,enabledProperties:{...e,startIndex:!1,reversed:!1},styleButtonViews:u});return m.delegate("execute").to(a),a.buttonView.set({label:i,icon:zu[n]}),a.panelView.children.add(m),a.bind("isEnabled").to(l,"isEnabled"),a.on("execute",(()=>{t.editing.view.focus()})),a}}function FE(t){return"function"==typeof t.isStyleTypeSupported?e=>t.isStyleTypeSupported(e.type):()=>!0}class RE extends Lr{static get requires(){return[yE,TE]}static get pluginName(){return"ListProperties"}}class LE extends Mr{constructor(t){super(t),this.on("execute",(()=>{this.refresh()}),{priority:"highest"})}refresh(){const t=this._getSelectedItems();this.value=this._getValue(t),this.isEnabled=!!t.length}execute(t={}){this.editor.model.change((e=>{const n=this._getSelectedItems(),i=void 0===t.forceValue?!this._getValue(n):t.forceValue;for(const t of n)i?e.setAttribute("todoListChecked",!0,t):e.removeAttribute("todoListChecked",t)}))}_getValue(t){return t.every((t=>t.getAttribute("todoListChecked")))}_getSelectedItems(){const t=this.editor.model,e=t.schema,n=t.document.selection.getFirstRange(),i=n.start.parent,o=[];e.checkAttribute(i,"todoListChecked")&&o.push(...fx(i));for(const t of n.getItems({shallow:!0}))e.checkAttribute(t,"todoListChecked")&&!o.includes(t)&&o.push(...fx(t));return o}}class zE extends nl{domEventType=["change"];onDomEvent(t){if(t.target){const e=this.view.domConverter.mapDomToView(t.target);e&&e.is("element","input")&&"checkbox"==e.getAttribute("type")&&e.findAncestor({classes:"todo-list__label"})&&this.fire("todoCheckboxChange",t)}}}const ME=Yo("Ctrl+Enter");class OE extends Lr{static get pluginName(){return"TodoListEditing"}static get requires(){return[nE]}init(){const t=this.editor,e=t.model,n=t.editing,i=t.plugins.get(nE),o=t.config.get("list.multiBlock")?"paragraph":"listItem";t.commands.add("todoList",new Rx(t,"todo")),t.commands.add("checkTodoList",new LE(t)),n.view.addObserver(zE),e.schema.extend("$listItem",{allowAttributes:"todoListChecked"}),e.schema.addAttributeCheck((t=>{const e=t.last;if(!e.getAttribute("listItemId")||"todo"!=e.getAttribute("listType"))return!1}),"todoListChecked"),t.conversion.for("upcast").add((t=>{t.on("element:input",((t,e,n)=>{const i=e.modelCursor,o=i.parent,r=e.viewItem;if(!n.consumable.test(r,{name:!0}))return;if("checkbox"!=r.getAttribute("type")||!i.isAtStart||!o.hasAttribute("listType"))return;n.consumable.consume(r,{name:!0});const s=n.writer;s.setAttribute("listType","todo",o),e.viewItem.hasAttribute("checked")&&s.setAttribute("todoListChecked",!0,o),e.modelRange=s.createRange(i)})),t.on("element:li",((t,e,n)=>{const{writer:i,schema:o}=n;if(!e.modelRange)return;const r=Array.from(e.modelRange.getItems({shallow:!0})).filter((t=>"todo"===t.getAttribute("listType")&&o.checkAttribute(t,"listItemId"))).reduce(((t,e)=>{const n=e.getAttribute("listItemId");return t.has(n)||t.set(n,fx(e)),t}),new Map);for(const[,t]of r.entries())if(t.some((t=>t.getAttribute("todoListChecked"))))for(const e of t)i.setAttribute("todoListChecked",!0,e)}),{priority:"low"}),t.on("element:label",NE({name:"label",classes:"todo-list__label"})),t.on("element:label",NE({name:"label",classes:["todo-list__label","todo-list__label_without-description"]})),t.on("element:span",NE({name:"span",classes:"todo-list__label__description"})),t.on("element:ul",function(t){const e=new as(t);return(t,n,i)=>{const o=e.match(n.viewItem);if(!o)return;const r=o.match;r.name=!1,i.consumable.consume(n.viewItem,r)}}({name:"ul",classes:"todo-list"}))})),t.conversion.for("downcast").elementToElement({model:o,view:(t,{writer:e})=>{if(HE(t,i.getListAttributeNames()))return e.createContainerElement("span",{class:"todo-list__label__description"})},converterPriority:"highest"}),i.registerDowncastStrategy({scope:"list",attributeName:"listType",setAttributeOnDowncast(t,e,n){"todo"==e?t.addClass("todo-list",n):t.removeClass("todo-list",n)}}),i.registerDowncastStrategy({scope:"itemMarker",attributeName:"todoListChecked",createElement(t,e,{dataPipeline:n}){if("todo"!=e.getAttribute("listType"))return null;const i=t.createUIElement("input",{type:"checkbox",...e.getAttribute("todoListChecked")?{checked:"checked"}:null,...n?{disabled:"disabled"}:{tabindex:"-1"}});if(n)return i;const o=t.createContainerElement("span",{contenteditable:"false"},i);return o.getFillerOffset=()=>null,o},canWrapElement:t=>HE(t,i.getListAttributeNames()),createWrapperElement(t,e,{dataPipeline:n}){const o=["todo-list__label"];return HE(e,i.getListAttributeNames())||o.push("todo-list__label_without-description"),t.createAttributeElement(n?"label":"span",{class:o.join(" ")})}}),i.on("checkElement",((t,{modelElement:e,viewElement:n})=>{const o=HE(e,i.getListAttributeNames());n.hasClass("todo-list__label__description")!=o&&(t.return=!0,t.stop())})),i.on("checkElement",((e,{modelElement:n,viewElement:i})=>{const o="todo"==n.getAttribute("listType")&&wx(n);let r=!1;const s=t.editing.view.createPositionBefore(i).getWalker({direction:"backward"});for(const{item:e}of s){if(e.is("element")&&t.editing.mapper.toModelElement(e))break;e.is("element","input")&&"checkbox"==e.getAttribute("type")&&(r=!0)}r!=o&&(e.return=!0,e.stop())})),i.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:i,previousNodeInList:o}of e){if(!o)continue;if(o.getAttribute("listItemId")!=i.getAttribute("listItemId"))continue;const e=o.hasAttribute("todoListChecked"),r=i.hasAttribute("todoListChecked");r&&!e?(n.removeAttribute("todoListChecked",i),t.return=!0):!r&&e&&(n.setAttribute("todoListChecked",!0,i),t.return=!0)}})),e.document.registerPostFixer((t=>{const n=e.document.differ.getChanges();let i=!1;for(const e of n)if("attribute"==e.type&&"listType"==e.attributeKey){const n=e.range.start.nodeAfter;"todo"==e.attributeOldValue&&n.hasAttribute("todoListChecked")&&(t.removeAttribute("todoListChecked",n),i=!0)}else if("insert"==e.type&&"$text"!=e.name)for(const{item:n}of t.createRangeOn(e.position.nodeAfter))n.is("element")&&"todo"!=n.getAttribute("listType")&&n.hasAttribute("todoListChecked")&&(t.removeAttribute("todoListChecked",n),i=!0);return i})),this.listenTo(n.view.document,"keydown",((e,n)=>{Zo(n)===ME&&(t.execute("checkTodoList"),e.stop())}),{priority:"high"}),this.listenTo(n.view.document,"todoCheckboxChange",((t,e)=>{const i=e.target;if(!i||!i.is("element","input"))return;const o=n.view.createPositionAfter(i),r=n.mapper.toModelPosition(o).parent;r&&px(r)&&"todo"==r.getAttribute("listType")&&this._handleCheckmarkChange(r)})),this.listenTo(n.view.document,"arrowKey",function(t,e){return(n,i)=>{const o=Qo(i.keyCode,e.contentLanguageDirection),r=t.schema,s=t.document.selection;if(!s.isCollapsed)return;const a=s.getFirstPosition(),l=a.parent;if("right"==o&&a.isAtEnd){const e=r.getNearestSelectionRange(t.createPositionAfter(l),"forward");if(!e)return;const o=e.start.parent;o&&px(o)&&"todo"==o.getAttribute("listType")&&(t.change((t=>t.setSelection(e))),i.preventDefault(),i.stopPropagation(),n.stop())}else if("left"==o&&a.isAtStart&&px(l)&&"todo"==l.getAttribute("listType")){const e=r.getNearestSelectionRange(t.createPositionBefore(l),"backward");if(!e)return;t.change((t=>t.setSelection(e))),i.preventDefault(),i.stopPropagation(),n.stop()}}}(e,t.locale),{context:"$text"}),this.listenTo(n.mapper,"viewToModelPosition",((t,n)=>{const i=n.viewPosition.parent,o=i.is("attributeElement","li")&&0==n.viewPosition.offset,r=jE(i)&&n.viewPosition.offset<=1,s=i.is("element","span")&&"false"==i.getAttribute("contenteditable")&&jE(i.parent);if(!o&&!r&&!s)return;const a=n.modelPosition.nodeAfter;a&&"todo"==a.getAttribute("listType")&&(n.modelPosition=e.createPositionAt(a,0))}),{priority:"low"}),this._initAriaAnnouncements()}_handleCheckmarkChange(t){const e=this.editor,n=e.model,i=Array.from(n.document.selection.getRanges());n.change((n=>{n.setSelection(t,"end"),e.execute("checkTodoList"),n.setSelection(i)}))}_initAriaAnnouncements(){const{model:t,ui:e,t:n}=this.editor;let i=null;e&&t.document.selection.on("change:range",(()=>{const o=t.document.selection.focus.parent,r=qE(i),s=qE(o);r&&!s?e.ariaLiveAnnouncer.announce(n("Leaving a to-do list")):!r&&s&&e.ariaLiveAnnouncer.announce(n("Entering a to-do list")),i=o}))}}function NE(t){const e=new as(t);return(t,n,i)=>{const o=e.match(n.viewItem);o&&i.consumable.consume(n.viewItem,o.match)&&Object.assign(n,i.convertChildren(n.viewItem,n.modelCursor))}}function HE(t,e){return(t.is("element","paragraph")||t.is("element","listItem"))&&"todo"==t.getAttribute("listType")&&wx(t)&&function(t,e){for(const n of t.getAttributeKeys())if(!n.startsWith("selection:")&&!e.includes(n))return!1;return!0}(t,e)}function jE(t){return!!t&&t.is("attributeElement")&&t.hasClass("todo-list__label")}function qE(t){return!!t&&(!(!t.is("element","paragraph")&&!t.is("element","listItem"))&&"todo"==t.getAttribute("listType"))}class WE extends Lr{static get pluginName(){return"TodoListUI"}init(){const t=this.editor.t;oE(this.editor,"todoList",t("To-do List"),zu.todoList)}}var UE=n(8991),$E={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};$r()(UE.A,$E);UE.A.locals;class GE extends Lr{static get requires(){return[OE,WE]}static get pluginName(){return"TodoList"}}function KE(t){return void 0!==t&&t.endsWith("px")}function ZE(t){return t.toFixed(2).replace(/\.?0+$/,"")+"px"}function YE(t,e,n){if(!t.childCount)return;const i=new jh(t.document),o=function(t,e){const n=e.createRangeIn(t),i=[],o=new Set;for(const t of n.getItems()){if(!t.is("element")||!t.name.match(/^(p|h\d+|li|div)$/))continue;let e=oB(t);if(void 0===e||0!=parseFloat(e)||Array.from(t.getClassNames()).find((t=>t.startsWith("MsoList")))||(e=void 0),t.hasStyle("mso-list")||void 0!==e&&o.has(e)){const n=nB(t);i.push({element:t,id:n.id,order:n.order,indent:n.indent,marginLeft:e}),void 0!==e&&o.add(e)}else o.clear()}return i}(t,i);if(!o.length)return;const r={},s=[];for(const t of o)if(void 0!==t.indent){JE(t)||(s.length=0);const o=`${t.id}:${t.indent}`,a=Math.min(t.indent-1,s.length);if(as.length-1||s[a].listElement.name!=l.type){0==a&&"ol"==l.type&&void 0!==t.id&&r[o]&&(l.startIndex=r[o]);const e=eB(l,i,n);if(KE(t.marginLeft)&&(0==a||KE(s[a-1].marginLeft))){let n=t.marginLeft;a>0&&(n=ZE(parseFloat(n)-parseFloat(s[a-1].marginLeft))),i.setStyle("padding-left",n,e)}if(0==s.length){const n=t.element.parent,o=n.getChildIndex(t.element)+1;i.insertChild(o,e,n)}else{const t=s[a-1].listItemElements;i.appendChild(e,t[t.length-1])}s[a]={...t,listElement:e,listItemElements:[]},0==a&&void 0!==t.id&&(r[o]=l.startIndex||1)}}const l="li"==t.element.name?t.element:i.createElement("li");i.appendChild(l,s[a].listElement),s[a].listItemElements.push(l),0==a&&void 0!==t.id&&r[o]++,t.element!=l&&i.appendChild(t.element,l),iB(t.element,i),i.removeStyle("text-indent",t.element),i.removeStyle("margin-left",t.element)}else{const e=s.find((e=>e.marginLeft==t.marginLeft));if(e){const n=e.listItemElements;i.appendChild(t.element,n[n.length-1]),i.removeStyle("margin-left",t.element)}else s.length=0}}function JE(t){const e=t.element.previousSibling;return QE(e||t.element.parent)}function QE(t){return t.is("element","ol")||t.is("element","ul")}function XE(t,e){const n=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=new RegExp(`@list\\s+l${t.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),s=new RegExp(`@list l${t.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=r.exec(e),l=s.exec(e),c=a&&!l,d=n.exec(e);let h="decimal",u="ol",m=null;if(d&&d[1]){const e=i.exec(d[1]);if(e&&e[1]&&(h=e[1].trim(),u="bullet"!==h&&"image"!==h?"ol":"ul"),"bullet"===h){const e=function(t){if("li"==t.name&&"ul"==t.parent.name&&t.parent.hasAttribute("type"))return t.parent.getAttribute("type");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);if(t)return t.is("$text")?t:t.getChild(0)}return null}(t);if(!e)return null;const n=e._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(t.element);e&&(h=e)}else{const t=o.exec(d[1]);t&&t[1]&&(m=parseInt(t[1]))}c&&(u="ol")}return{type:u,startIndex:m,style:tB(h),isLegalStyleList:c}}function tB(t){if(t.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(t){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return t;default:return null}}function eB(t,e,n){const i=e.createElement(t.type);return t.style&&e.setStyle("list-style-type",t.style,i),t.startIndex&&t.startIndex>1&&e.setAttribute("start",t.startIndex,i),t.isLegalStyleList&&n&&e.addClass("legal-list",i),i}function nB(t){const e=t.getStyle("mso-list");if(void 0===e)return{};const n=e.match(/(^|\s{1,100})l(\d+)/i),i=e.match(/\s{0,100}lfo(\d+)/i),o=e.match(/\s{0,100}level(\d+)/i);return n&&i&&o?{id:n[2],order:i[1],indent:parseInt(o[1])}:{indent:1}}function iB(t,e){const n=new as({name:"span",styles:{"mso-list":"Ignore"}}),i=e.createRangeIn(t);for(const t of i)"elementStart"===t.type&&n.match(t.item)&&e.remove(t.item)}function oB(t){const e=t.getStyle("margin-left");return void 0===e||e.endsWith("px")?e:function(t){const e=parseFloat(t);return t.endsWith("pt")?ZE(96*e/72):t.endsWith("pc")?ZE(12*e*96/72):t.endsWith("in")?ZE(96*e):t.endsWith("cm")?ZE(96*e/2.54):t.endsWith("mm")?ZE(e/10*96/2.54):t}(e)}function rB(t,e){if(!t.childCount)return;const n=new jh(t.document),i=function(t,e){const n=e.createRangeIn(t),i=new as({name:/v:(.+)/}),o=[];for(const t of n){if("elementStart"!=t.type)continue;const e=t.item,n=e.previousSibling,r=n&&n.is("element")?n.name:null,s=["Chart"],a=i.match(e),l=e.getAttribute("o:gfxdata"),c="v:shapetype"===r,d=l&&s.some((t=>e.getAttribute("id").includes(t)));a&&l&&!c&&!d&&o.push(t.item.getAttribute("id"))}return o}(t,n);!function(t,e,n){const i=n.createRangeIn(e),o=new as({name:"img"}),r=[];for(const e of i)if(e.item.is("element")&&o.match(e.item)){const n=e.item,i=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];i.length&&i.every((e=>t.indexOf(e)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const t of r)n.remove(t)}(i,t,n),function(t,e,n){const i=n.createRangeIn(e),o=[];for(const e of i)if("elementStart"==e.type&&e.item.is("element","v:shape")){const n=e.item.getAttribute("id");if(t.includes(n))continue;r(e.item.parent.getChildren(),n)||o.push(e.item)}for(const t of o){const e={src:s(t)};t.hasAttribute("alt")&&(e.alt=t.getAttribute("alt"));const i=n.createElement("img",e);n.insertChild(t.index+1,i,t.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")}}(i,t,n),function(t,e){const n=e.createRangeIn(t),i=new as({name:/v:(.+)/}),o=[];for(const t of n)"elementStart"==t.type&&i.match(t.item)&&o.push(t.item);for(const t of o)e.remove(t)}(t,n);const o=function(t,e){const n=e.createRangeIn(t),i=new as({name:"img"}),o=[];for(const t of n)t.item.is("element")&&i.match(t.item)&&t.item.getAttribute("src").startsWith("file://")&&o.push(t.item);return o}(t,n);o.length&&function(t,e,n){if(t.length===e.length)for(let i=0;iString.fromCharCode(parseInt(t,16)))).join(""))}const aB=//i,lB=/xmlns:o="urn:schemas-microsoft-com/i;class cB{document;hasMultiLevelListPlugin;constructor(t,e=!1){this.document=t,this.hasMultiLevelListPlugin=e}isActive(t){return aB.test(t)||lB.test(t)}execute(t){const{body:e,stylesString:n}=t._parsedData;YE(e,n,this.hasMultiLevelListPlugin),rB(e,t.dataTransfer.getData("text/rtf")),function(t){const e=[],n=new jh(t.document);for(const{item:i}of n.createRangeIn(t))if(i.is("element")){for(const t of i.getClassNames())/\bmso/gi.exec(t)&&n.removeClass(t,i);for(const t of i.getStyleNames())/\bmso/gi.exec(t)&&n.removeStyle(t,i);(i.is("element","w:sdt")||i.is("element","w:sdtpr")&&i.isEmpty||i.is("element","o:p")&&i.isEmpty)&&e.push(i)}for(const t of e){const e=t.parent,i=e.getChildIndex(t);n.insertChild(i,t.getChildren(),e),n.remove(t)}}(e),t.content=e}}function dB(t,e,n,{blockElements:i,inlineObjectElements:o}){let r=n.createPositionAt(t,"forward"==e?"after":"before");return r=r.getLastMatchingPosition((({item:t})=>t.is("element")&&!i.includes(t.name)&&!o.includes(t.name)),{direction:e}),"forward"==e?r.nodeAfter:r.nodeBefore}function hB(t,e){return!!t&&t.is("element")&&e.includes(t.name)}const uB=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class mB{document;constructor(t){this.document=t}isActive(t){return uB.test(t)}execute(t){const e=new jh(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 i=t.getChildIndex(n);e.remove(n),e.insertChild(i,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 sa(e.document.stylesProcessor),i=new Za(n,{renderingMode:"data"}),o=i.blockElements,r=i.inlineObjectElements,s=[];for(const n of e.createRangeIn(t)){const t=n.item;if(t.is("element","br")){const n=dB(t,"forward",e,{blockElements:o,inlineObjectElements:r}),i=dB(t,"backward",e,{blockElements:o,inlineObjectElements:r}),a=hB(n,o);(hB(i,o)||a)&&s.push(t)}}for(const t of s)t.hasClass("Apple-interchange-newline")?e.remove(t):e.replace(t,e.createElement("p"))}(n,e),t.content=n}}const gB=/(\s+)<\/span>/g,((t,e)=>1===e.length?" ":Array(e.length+1).join(" ").substr(0,e.length)))}function bB(t,e){const n=new DOMParser,i=function(t){return fB(fB(t)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(t){const e="