import{Plugin as p,Command as _}from"@ckeditor/ckeditor5-core";import{Clipboard as Lt,ClipboardPipeline as q}from"@ckeditor/ckeditor5-clipboard";import{ModelLivePosition as $,ModelLiveRange as Mt,Observer as Wt,ViewUpcastWriter as j,enableViewPlaceholder as qt,ModelElement as $t}from"@ckeditor/ckeditor5-engine";import{Undo as jt}from"@ckeditor/ckeditor5-undo";import{Delete as Ht}from"@ckeditor/ckeditor5-typing";import{first as z,DomEmitterMixin as Gt,global as R,FocusTracker as H,KeystrokeHandler as P,logWarning as v,toArray as Ie,env as Kt,CKEditorError as Jt,Collection as Xt,Rect as Zt}from"@ckeditor/ckeditor5-utils";import{toWidget as Yt,isWidget as Qt,findOptimalInsertionRange as ei,Widget as we,toWidgetEditable as ti,WidgetResize as G,calculateResizeHostAncestorWidth as _e,WidgetToolbarRepository as ve}from"@ckeditor/ckeditor5-widget";import{View as O,FormRowView as ye,ViewCollection as K,FocusCycler as J,submitHandler as N,ButtonView as I,FormHeaderView as Ee,LabeledFieldView as X,createLabeledInputText as Ce,BalloonPanelView as ii,ContextualBalloon as xe,CssTransitionDisablerMixin as Se,clickOutsideHandler as Ue,CollapsibleView as ni,SplitButtonView as Ve,createDropdown as Z,MenuBarMenuView as oi,MenuBarMenuListView as si,MenuBarMenuListItemView as ai,FileDialogButtonView as Be,MenuBarMenuListItemFileDialogButtonView as ri,Notification as Ae,Dialog as li,MenuBarMenuListItemButtonView as ci,UIModel as Te,DropdownButtonView as mi,addListToDropdown as gi,createLabeledInputNumber as ui,addToolbarToDropdown as di}from"@ckeditor/ckeditor5-ui";import{IconPreviousArrow as ze,IconTextAlternative as hi,IconImage as pi,IconCaption as fi,IconImageUpload as bi,IconImageUrl as ki,IconObjectSizeFull as Ii,IconObjectSizeCustom as wi,IconObjectSizeLarge as _i,IconObjectSizeMedium as vi,IconObjectSizeSmall as yi,IconObjectInline as Re,IconObjectInlineRight as Y,IconObjectInlineLeft as Pe,IconObjectCenter as Q,IconObjectRight as Oe,IconObjectLeft as Ne,IconObjectFullWidth as Ei}from"@ckeditor/ckeditor5-icons";import{FileRepository as y}from"@ckeditor/ckeditor5-upload";/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Fe(a){return a.createContainerElement("span",{class:"image-inline"},a.createEmptyElement("img"))}function ee(a){return a.createContainerElement("figure",{class:"image"},[a.createEmptyElement("img"),a.createSlot("children")])}function te(a,e){const t=a.plugins.get("ImageUtils"),i=a.plugins.has("ImageInlineEditing")&&a.plugins.has("ImageBlockEditing");return s=>t.isInlineImageView(s)?i&&(s.getStyle("display")=="block"||s.findAncestor(t.isBlockImageView)?"imageBlock":"imageInline")!==e?null:n(s):null;function n(s){const o={name:!0};return s.hasAttribute("src")&&(o.attributes=["src"]),o}}function F(a,e){const t=z(e.getSelectedBlocks());return!t||a.isObject(t)||t.isEmpty&&t.name!="listItem"?"imageBlock":"imageInline"}function x(a){return a&&a.endsWith("px")?parseInt(a):null}function S(a){const e=x(a.getStyle("width")),t=x(a.getStyle("height"));return!!(e&&t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Ci=/^(image|image-inline)$/;class f extends p{_domEmitter=new(Gt());static get pluginName(){return"ImageUtils"}static get isOfficialPlugin(){return!0}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,n={}){const s=this.editor,o=s.model,r=o.document.selection,l=De(s,t||r,i);e={...Object.fromEntries(r.getAttributes()),...e};for(const c in e)o.schema.checkAttribute(l,c)||delete e[c];return o.change(c=>{const{setImageSizes:m=!0}=n,g=c.createElement(l,e);return o.insertObject(g,t,null,{setSelection:"on",findOptimalPosition:!t&&l!="imageInline"?"auto":void 0}),g.parent?(m&&this.setImageNaturalSizeAttributes(g),g):null})}setImageNaturalSizeAttributes(e){const t=e.getAttribute("src");t&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change(i=>{const n=new R.window.Image;this._domEmitter.listenTo(n,"load",()=>{!e.getAttribute("width")&&!e.getAttribute("height")&&this.editor.model.enqueueChange(i.batch,s=>{s.setAttribute("width",n.naturalWidth,e),s.setAttribute("height",n.naturalHeight,e)}),this._domEmitter.stopListening(n,"load")}),n.src=t}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:Ci})}isImageAllowed(){const t=this.editor.model.document.selection;return xi(this.editor,t)&&Si(t)}toImageWidget(e,t,i){return t.setCustomProperty("image",!0,e),Yt(e,t,{label:()=>{const o=this.findViewImgElement(e).getAttribute("alt");return o?`${o} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&Qt(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function xi(a,e){if(De(a,e,null)=="imageBlock"){const i=Ui(e,a.model);if(a.model.schema.checkChild(i,"imageBlock"))return!0}else if(a.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}function Si(a){return[...a.focus.getAncestors()].every(e=>!e.is("element","imageBlock"))}function Ui(a,e){const i=ei(a,e).start.parent;return i.isEmpty&&!i.is("element","$root")?i.parent:i}function De(a,e,t){const i=a.model.schema,n=a.config.get("image.insert.type");return a.plugins.has("ImageBlockEditing")?a.plugins.has("ImageInlineEditing")?t||(n==="inline"?"imageInline":n!=="auto"?"imageBlock":e.is("selection")?F(i,e):i.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Vi=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 Bi extends p{static get requires(){return[Lt,f,jt,Ht]}static get pluginName(){return"AutoImage"}static get isOfficialPlugin(){return!0}_timeoutId;_positionToInsert;constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document,i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",()=>{const n=t.selection.getFirstRange(),s=$.fromPosition(n.start);s.stickiness="toPrevious";const o=$.fromPosition(n.end);o.stickiness="toNext",t.once("change:data",()=>{this._embedImageBetweenPositions(s,o),s.detach(),o.detach()},{priority:"high"})}),e.commands.get("undo").on("execute",()=>{this._timeoutId&&(R.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedImageBetweenPositions(e,t){const i=this.editor,n=new Mt(e,t),s=n.getWalker({ignoreElementEnd:!0}),o=Object.fromEntries(i.model.document.selection.getAttributes()),r=this.editor.plugins.get("ImageUtils");let l="";for(const c of s)c.item.is("$textProxy")&&(l+=c.item.data);if(l=l.trim(),!l.match(Vi)){n.detach();return}this._positionToInsert=$.fromPosition(e),this._timeoutId=setTimeout(()=>{if(!i.commands.get("insertImage").isEnabled){n.detach();return}i.model.change(g=>{this._timeoutId=null,g.remove(n),n.detach();let u;this._positionToInsert.root.rootName!=="$graveyard"&&(u=this._positionToInsert.toPosition()),r.insertImage({...o,src:l},u),this._positionToInsert.detach(),this._positionToInsert=null}),i.plugins.get("Delete").requestUndoOnBackspace()},100)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Le extends _{refresh(){const i=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!i,this.isEnabled&&i.hasAttribute("alt")?this.value=i.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,s=i.getClosestSelectedImageElement(n.document.selection);n.change(o=>{o.setAttribute("alt",e.newValue,s)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Me extends p{static get requires(){return[f]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new Le(this.editor))}}function k(a,{insertAt:e}={}){if(!a||typeof document>"u")return;const t=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",window.litNonce&&i.setAttribute("nonce",window.litNonce),e==="top"&&t.firstChild?t.insertBefore(i,t.firstChild):t.appendChild(i),i.styleSheet?i.styleSheet.cssText=a:i.appendChild(document.createTextNode(a))}k(":root{--ck-text-alternative-form-width:340px}@media screen and (max-width:600px){:root{--ck-text-alternative-form-width:300px}}.ck.ck-text-alternative-form.ck-responsive-form{width:var(--ck-text-alternative-form-width)}"),k('.ck-vertical-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck-vertical-form .ck-button:focus:after{display:none}@media screen and (max-width:600px){.ck.ck-responsive-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck.ck-responsive-form .ck-button:focus:after{display:none}}.ck-vertical-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form{padding:var(--ck-spacing-large)}.ck.ck-responsive-form:focus{outline:none}[dir=ltr] .ck.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-responsive-form>:not(:last-child){margin-left:var(--ck-spacing-standard)}@media screen and (max-width:600px){.ck.ck-responsive-form{padding:0;width:calc(var(--ck-input-width)*.8)}.ck.ck-responsive-form .ck-labeled-field-view{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-responsive-form .ck-labeled-field-view .ck-input-number,.ck.ck-responsive-form .ck-labeled-field-view .ck-input-text{min-width:0;width:100%}.ck.ck-responsive-form .ck-labeled-field-view .ck-labeled-field-view__error{white-space:normal}.ck.ck-responsive-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form>.ck-button:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){border-radius:0;margin-top:var(--ck-spacing-large);padding:var(--ck-spacing-standard)}.ck.ck-responsive-form>.ck-button:last-child:not(:focus),.ck.ck-responsive-form>.ck-button:nth-last-child(2):not(:focus){border-top:1px solid var(--ck-color-base-border)}[dir=ltr] .ck.ck-responsive-form>.ck-button:last-child,[dir=ltr] .ck.ck-responsive-form>.ck-button:nth-last-child(2),[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2){margin-left:0}[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child:last-of-type,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2):last-of-type{border-right:1px solid var(--ck-color-base-border)}}'),k(":root{--ck-form-default-width:340px}.ck.ck-form{padding:0 0 var(--ck-spacing-large)}.ck.ck-form.ck-form_default-width{width:var(--ck-form-default-width)}.ck.ck-form:focus{outline:none}.ck.ck-form .ck.ck-input-number,.ck.ck-form .ck.ck-input-text{min-width:100%;width:0}.ck.ck-form .ck.ck-dropdown{min-width:100%}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button .ck-button__label{width:100%}@media screen and (max-width:600px){.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit{align-items:stretch;flex-direction:column;padding:0}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit>.ck{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit .ck-button_with-text{justify-content:center}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_large-bottom-padding{padding-bottom:var(--ck-spacing-large)}}[dir=ltr] .ck.ck-form.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-form.ck-responsive-form>:not(:last-child){margin-left:0}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class We extends O{focusTracker;keystrokes;labeledInput;backButtonView;saveButtonView;children;_focusables;_focusCycler;constructor(e){super(e),this.focusTracker=new H,this.keystrokes=new P,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new ye(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new K,this.keystrokes.set("Esc",(t,i)=>{this.fire("cancel"),i()}),this._focusCycler=new J({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),N({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].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()}_createBackButton(){const e=this.locale.t,t=new I(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:ze,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new I(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Ee(this.locale,{label:e("Text Alternative")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new X(this.locale,Ce);return t.label=e("Text alternative"),t.class="ck-labeled-field-view_full-width",t}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function qe(a){const e=a.plugins.get("ContextualBalloon");if(a.plugins.get("ImageUtils").getClosestSelectedImageWidget(a.editing.view.document.selection)){const i=D(a);e.updatePosition(i)}}function D(a){const e=a.editing.view,t=ii.defaultPositions,i=a.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(i.getClosestSelectedImageWidget(e.document.selection)),positions:[t.northArrowSouth,t.northArrowSouthWest,t.northArrowSouthEast,t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast,t.viewportStickyNorth]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class $e extends p{_balloon;_form;static get requires(){return[xe]}static get pluginName(){return"ImageTextAlternativeUI"}static get isOfficialPlugin(){return!0}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",i=>{const n=e.commands.get("imageTextAlternative"),s=new I(i);return s.set({label:t("Change image text alternative"),icon:hi,tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",o=>!!o),this.listenTo(s,"execute",()=>{this._showForm()}),s})}_createForm(){const e=this.editor,i=e.editing.view.document,n=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(Se(We))(e.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),this.listenTo(e.ui,"update",()=>{n.getClosestSelectedImageWidget(i.selection)?this._isVisible&&qe(e):this._hideForm(!0)}),Ue({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:D(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ie extends p{static get requires(){return[Me,$e]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function je(a){const e=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=a.findViewImgElement(i.viewItem);if(!s||!n.consumable.test(s,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const o=n.convertItem(s,i.modelCursor),r=z(o.modelRange.getItems());if(!r){n.consumable.revert(i.viewItem,{name:!0,classes:"image"});return}n.convertChildren(i.viewItem,r),n.updateConversionResult(r,i)};return t=>{t.on("element:figure",e)}}function He(a){const e=["srcset","media","type","sizes"],t=(i,n,s)=>{const o=n.viewItem;if(!s.consumable.test(o,{name:!0}))return;const r=new Map;for(const m of o.getChildren())if(m.is("element","source")){const g={};for(const u of e)m.hasAttribute(u)&&s.consumable.test(m,{attributes:u})&&(g[u]=m.getAttribute(u));Object.keys(g).length&&r.set(m,g)}const l=a.findViewImgElement(o);if(!l)return;let c=n.modelCursor.parent;if(!c.is("element","imageBlock")){const m=s.convertItem(l,n.modelCursor);n.modelRange=m.modelRange,n.modelCursor=m.modelCursor,c=z(m.modelRange.getItems())}s.consumable.consume(o,{name:!0});for(const[m,g]of r)s.consumable.consume(m,{attributes:Object.keys(g)});r.size&&s.writer.setAttribute("sources",Array.from(r.values()),c),s.convertChildren(o,c)};return i=>{i.on("element:picture",t)}}function ne(a,e){const t=(i,n,s)=>{if(!s.consumable.consume(n.item,i.name))return;const o=s.writer,r=s.mapper.toViewElement(n.item),l=a.findViewImgElement(r);n.attributeNewValue===null?(o.removeAttribute("srcset",l),o.removeAttribute("sizes",l)):n.attributeNewValue&&(o.setAttribute("srcset",n.attributeNewValue,l),o.setAttribute("sizes","100vw",l))};return i=>{i.on(`attribute:srcset:${e}`,t)}}function Ge(a){const e=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=a.findViewImgElement(o),l=i.attributeNewValue;if(l&&l.length){const c=[];let m=r.parent;for(;m&&m.is("attributeElement");){const d=m.parent;s.unwrap(s.createRangeOn(r),m),c.unshift(m),m=d}const g=r.parent.is("element","picture"),u=g?r.parent:s.createContainerElement("picture",null);g||s.insert(s.createPositionBefore(r),u),s.remove(s.createRangeIn(u)),s.insert(s.createPositionAt(u,"end"),l.map(d=>s.createEmptyElement("source",d))),s.move(s.createRangeOn(r),s.createPositionAt(u,"end"));for(const d of c)s.wrap(s.createRangeOn(u),d)}else if(r.parent.is("element","picture")){const c=r.parent;s.move(s.createRangeOn(r),s.createPositionBefore(c)),s.remove(c)}};return t=>{t.on("attribute:sources:imageBlock",e),t.on("attribute:sources:imageInline",e)}}function U(a,e,t){const i=(n,s,o)=>{if(!o.consumable.consume(s.item,n.name))return;const r=o.writer,l=o.mapper.toViewElement(s.item),c=a.findViewImgElement(l);r.setAttribute(s.attributeKey,s.attributeNewValue||"",c)};return n=>{n.on(`attribute:${t}:${e}`,i)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class L extends Wt{observe(e){this.listenTo(e,"load",(t,i)=>{const n=i.target;this.checkShouldIgnoreEventFromTarget(n)||n.tagName=="IMG"&&this._fireEvents(i)},{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ke extends _{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||t==="block"&&v("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||t==="inline"&&v("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=Ie(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((o,r)=>{const l=i.getSelectedElement();if(typeof o=="string"&&(o={src:o}),r&&l&&n.isImage(l)){const c=this.editor.model.createPositionAfter(l);n.insertImage({...o,...s},c,e.imageType)}else e.breakBlock?n.insertImage({...o,...s},i.getFirstPosition(),e.imageType):n.insertImage({...o,...s},null,e.imageType)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Je extends _{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const t=this.editor.plugins.get("ImageUtils"),i=this.editor.model.document.selection.getSelectedElement();this.isEnabled=t.isImage(i),this.value=this.isEnabled?i.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change(n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,t),i.setImageNaturalSizeAttributes(t)})}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class M extends p{static get requires(){return[f]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(L),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new Ke(e),n=new Je(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class oe extends p{static get requires(){return[f]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=e==="imageBlock"?"figure":"img";t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:o=>S(o)?x(o.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:o=>S(o)?x(o.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add(o=>{s(o,"width","width",!0,!0),s(o,"height","height",!0,!0)}),t.conversion.for("dataDowncast").add(o=>{s(o,"width","width",!1),s(o,"height","height",!1)}),t.conversion.for("upcast").add(o=>{o.on("element:img",(r,l,c)=>{const m=l.viewItem.getAttribute("width"),g=l.viewItem.getAttribute("height");m&&g&&c.consumable.consume(l.viewItem,{styles:["aspect-ratio"]})})});function s(o,r,l,c,m=!1){o.on(`attribute:${r}:${e}`,(g,u,d)=>{if(!d.consumable.consume(u.item,g.name))return;const h=d.writer,b=d.mapper.toViewElement(u.item),w=i.findViewImgElement(b);u.attributeNewValue!==null?h.setAttribute(l,u.attributeNewValue,w):h.removeAttribute(l,w);const C=u.item.getAttribute("width"),T=u.item.getAttribute("height"),ke=C&&T;if(ke&&m&&h.setAttribute("loading","lazy",w),u.item.hasAttribute("sources"))return;const Dt=u.item.hasAttribute("resizedWidth");e==="imageInline"&&!Dt&&!c||ke&&h.setStyle("aspect-ratio",`${C}/${T}`,w)})}}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class se extends _{_modelElementName;constructor(e,t){super(e),this._modelElementName=t}refresh(){const t=this.editor.plugins.get("ImageUtils"),i=t.getClosestSelectedImageElement(this.editor.model.document.selection);this._modelElementName==="imageBlock"?this.isEnabled=t.isInlineImage(i):this.isEnabled=t.isBlockImage(i)}execute(e={}){const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection),o=Object.fromEntries(s.getAttributes());return!o.src&&!o.uploadId?null:i.change(r=>{const{setImageSizes:l=!0}=e,c=Array.from(i.markers).filter(u=>u.getRange().containsItem(s)),m=n.insertImage(o,i.createSelection(s,"on"),this._modelElementName,{setImageSizes:l});if(!m)return null;const g=r.createRangeOn(m);for(const u of c){const d=u.getRange(),h=d.root.rootName!="$graveyard"?d.getJoined(g,!0):g;r.updateMarker(u,{range:h})}return{oldElement:s,newElement:m}})}}k(".ck.ck-editor__editable img.image_placeholder{background-size:100% 100%}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ae extends p{static get requires(){return[f]}static get pluginName(){return"ImagePlaceholder"}static get isOfficialPlugin(){return!0}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add(n=>{n.on("attribute:placeholder",(s,o,r)=>{if(!r.consumable.test(o.item,s.name)||!o.item.is("element","imageBlock")&&!o.item.is("element","imageInline"))return;r.consumable.consume(o.item,s.name);const l=r.writer,c=r.mapper.toViewElement(o.item),m=i.findViewImgElement(c);o.attributeNewValue?(l.addClass("image_placeholder",m),l.setStyle("background-image",`url(${o.attributeNewValue})`,m),l.setCustomProperty("editingPipeline:doNotReuseOnce",!0,m)):(l.removeClass("image_placeholder",m),l.removeStyle("background-image",m))})})}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,s=e.plugins.get("ImageUtils");n.addObserver(L),this.listenTo(n.document,"imageLoaded",(o,r)=>{const l=n.domConverter.mapDomToView(r.target);if(!l)return;const c=s.getImageWidgetFromImageView(l);if(!c)return;const m=i.mapper.toModelElement(c);!m||!m.hasAttribute("placeholder")||t.enqueueChange({isUndoable:!1},g=>{g.removeAttribute("placeholder",m)})})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class re extends p{static get requires(){return[M,oe,f,ae,q]}static get pluginName(){return"ImageBlockEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new se(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(s,{writer:o})=>ee(o)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(s,{writer:o})=>n.toImageWidget(ee(o),o,t("image widget"))}),i.for("downcast").add(U(n,"imageBlock","src")).add(U(n,"imageBlock","alt")).add(ne(n,"imageBlock")),i.for("upcast").elementToElement({view:te(e,"imageBlock"),model:(s,{writer:o})=>o.createElement("imageBlock",s.hasAttribute("src")?{src:s.getAttribute("src")}:void 0)}).add(je(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(o,r)=>{const l=Array.from(r.content.getChildren());let c;if(!l.every(n.isInlineImageView))return;r.targetRanges?c=e.editing.mapper.toModelRange(r.targetRanges[0]):c=t.document.selection.getFirstRange();const m=t.createSelection(c);if(F(t.schema,m)==="imageBlock"){const g=new j(i.document),u=l.map(d=>g.createElement("figure",{class:"image"},d));r.content=g.createDocumentFragment(u)}}),this.listenTo(s,"contentInsertion",(o,r)=>{r.method==="paste"&&t.change(l=>{const c=l.createRangeIn(r.content);for(const m of c.getItems())m.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(m)})})}}k(".ck.ck-image-insert-url{padding:var(--ck-spacing-large) var(--ck-spacing-large) 0;width:400px}.ck.ck-image-insert-url .ck-image-insert-url__action-row{display:grid;grid-template-columns:repeat(2,1fr)}:root{--ck-image-insert-insert-by-url-width:250px}.ck.ck-image-insert-url{--ck-input-width:100%}.ck.ck-image-insert-url .ck-image-insert-url__action-row{grid-column-gap:var(--ck-spacing-large);margin-top:var(--ck-spacing-large)}.ck.ck-image-insert-url .ck-image-insert-url__action-row .ck-button-cancel,.ck.ck-image-insert-url .ck-image-insert-url__action-row .ck-button-save{justify-content:center;min-width:auto}.ck.ck-image-insert-url .ck-image-insert-url__action-row .ck-button .ck-button__label{color:var(--ck-color-text)}.ck.ck-image-insert-form>.ck.ck-button{display:block;width:100%}[dir=ltr] .ck.ck-image-insert-form>.ck.ck-button{text-align:left}[dir=rtl] .ck.ck-image-insert-form>.ck.ck-button{text-align:right}.ck.ck-image-insert-form>.ck.ck-collapsible{min-width:var(--ck-image-insert-insert-by-url-width)}.ck.ck-image-insert-form>.ck.ck-collapsible:not(:first-child){border-top:1px solid var(--ck-color-base-border)}.ck.ck-image-insert-form>.ck.ck-collapsible:not(:last-child){border-bottom:1px solid var(--ck-color-base-border)}.ck.ck-image-insert-form>.ck.ck-image-insert-url{min-width:var(--ck-image-insert-insert-by-url-width);padding:var(--ck-spacing-large)}.ck.ck-image-insert-form:focus{outline:none}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Xe extends O{focusTracker;keystrokes;_focusables;_focusCycler;children;constructor(e,t=[]){super(e),this.focusTracker=new H,this.keystrokes=new P,this._focusables=new K,this.children=this.createCollection(),this._focusCycler=new J({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const i of t)this.children.add(i),this._focusables.add(i),i instanceof ni&&this._focusables.addMany(i.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),N({view:this});for(const t of this._focusables)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element);const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class E extends p{static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[f]}dropdownView;_integrations=new Map;constructor(e){super(e),e.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",()=>{this.isImageSelected=i.isImage(t.getSelectedElement())});const n=o=>this._createToolbarComponent(o),s=o=>this._createMenuBarComponent(o);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n),e.ui.componentFactory.add("menuBar:insertImage",s)}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:n,menuBarButtonViewCreator:s,requiresForm:o=!1,override:r=!1}){this._integrations.has(e)&&!r&&v("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,menuBarButtonViewCreator:s,formViewCreator:n,requiresForm:o})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let s;const o=n[0];if(n.length==1){if(!o.requiresForm)return o.buttonViewCreator(!0);s=o.buttonViewCreator(!0)}else{const c=o.buttonViewCreator(!1);s=new Ve(e,c),s.tooltip=!0,s.bind("label").to(this,"isImageSelected",m=>i(m?"Replace image":"Insert image"))}const r=this.dropdownView=Z(e,s),l=n.map(({observable:c})=>typeof c=="function"?c():c);return r.bind("isEnabled").toMany(l,"isEnabled",(...c)=>c.some(m=>m)),r.once("change:isOpen",()=>{const c=n.flatMap(({formViewCreator:g})=>g(n.length==1)),m=new Xe(t.locale,c);r.panelView.children.add(m)}),r}_createMenuBarComponent(e){const t=e.t,i=this._prepareIntegrations();if(!i.length)return null;const n=i.flatMap(({menuBarButtonViewCreator:r})=>r(i.length==1)),s=new oi(e),o=new si(e);s.panelView.children.add(o),s.buttonView.set({icon:pi,label:t("Image")});for(const r of n){const l=new ai(e,s);l.children.add(r),o.items.add(l),r.delegate("execute").to(s)}return s}_prepareIntegrations(){const t=this.editor.config.get("image.insert.integrations"),i=[];if(!t.length)return v("image-insert-integrations-not-specified"),i;for(const n of t){if(!this._integrations.has(n)){["upload","assetManager","url"].includes(n)||v("image-insert-unknown-integration",{item:n});continue}i.push(this._integrations.get(n))}return i.length||v("image-insert-integrations-not-registered"),i}}k(".ck-content .image{clear:both;display:table;margin:.9em auto;min-width:50px;text-align:center}.ck-content .image img{display:block;height:auto;margin:0 auto;max-width:100%;min-width:100%}.ck-content .image-inline{align-items:flex-start;display:inline-flex;max-width:100%}.ck-content .image-inline picture{display:flex}.ck-content .image-inline img,.ck-content .image-inline picture{flex-grow:1;flex-shrink:1;max-width:100%}.ck.ck-editor__editable .image>figcaption.ck-placeholder:before{overflow:hidden;padding-left:inherit;padding-right:inherit;text-overflow:ellipsis;white-space:nowrap}.ck.ck-editor__editable .image{z-index:1}.ck.ck-editor__editable .image.ck-widget_selected{z-index:2}.ck.ck-editor__editable .image-inline{z-index:1}.ck.ck-editor__editable .image-inline.ck-widget_selected{z-index:2}.ck.ck-editor__editable .image-inline.ck-widget_selected ::selection{display:none}.ck.ck-editor__editable .image-inline img{height:auto}.ck.ck-editor__editable td .image-inline img,.ck.ck-editor__editable th .image-inline img{max-width:none}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ze extends p{static get requires(){return[re,we,ie,E]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ye extends p{static get requires(){return[M,oe,f,ae,q]}static get pluginName(){return"ImageInlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new se(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(s,{writer:o})=>o.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(s,{writer:o})=>n.toImageWidget(Fe(o),o,t("image widget"))}),i.for("downcast").add(U(n,"imageInline","src")).add(U(n,"imageInline","alt")).add(ne(n,"imageInline")),i.for("upcast").elementToElement({view:te(e,"imageInline"),model:(s,{writer:o})=>o.createElement("imageInline",s.hasAttribute("src")?{src:s.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(o,r)=>{const l=Array.from(r.content.getChildren());let c;if(!l.every(n.isBlockImageView))return;r.targetRanges?c=e.editing.mapper.toModelRange(r.targetRanges[0]):c=t.document.selection.getFirstRange();const m=t.createSelection(c);if(F(t.schema,m)==="imageInline"){const g=new j(i.document),u=l.map(d=>d.childCount===1?(Array.from(d.getAttributes()).forEach(h=>g.setAttribute(...h,n.findViewImgElement(d))),d.getChild(0)):d);r.content=g.createDocumentFragment(u)}}),this.listenTo(s,"contentInsertion",(o,r)=>{r.method==="paste"&&t.change(l=>{const c=l.createRangeIn(r.content);for(const m of c.getItems())m.is("element","imageInline")&&n.setImageNaturalSizeAttributes(m)})})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Qe extends p{static get requires(){return[Ye,we,ie,E]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ai extends p{static get requires(){return[Ze,Qe]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class le extends p{static get pluginName(){return"ImageCaptionUtils"}static get isOfficialPlugin(){return!0}static get requires(){return[f]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return e.name=="figcaption"&&t.isBlockImageView(e.parent)?{name:!0}:null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class et extends _{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(re)){this.isEnabled=!1,this.value=!1;return}const n=e.model.document.selection,s=n.getSelectedElement();if(!s){const o=t.getCaptionFromModelSelection(n);this.isEnabled=!!o,this.value=!!o;return}this.isEnabled=i.isImage(s),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(s):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change(i=>{this.value?this._hideImageCaption(i):this._showImageCaption(i,t)})}_showImageCaption(e,t){const n=this.editor.model.document.selection,s=this.editor.plugins.get("ImageCaptionEditing"),o=this.editor.plugins.get("ImageUtils");let r=n.getSelectedElement();const l=s._getSavedCaption(r);o.isInlineImage(r)&&(this.editor.execute("imageTypeBlock"),r=n.getSelectedElement());const c=l||e.createElement("caption");e.append(c,r),t&&e.setSelection(c,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),s=t.plugins.get("ImageCaptionUtils");let o=i.getSelectedElement(),r;o?r=s.getCaptionFromImageModelElement(o):(r=s.getCaptionFromModelSelection(i),o=r.parent),n._saveCaption(o,r),e.setSelection(o,"on"),e.remove(r)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class tt extends p{static get requires(){return[f,le]}static get pluginName(){return"ImageCaptionEditing"}static get isOfficialPlugin(){return!0}_savedCaptionsMap;constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new et(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),s=e.t;e.conversion.for("upcast").elementToElement({view:o=>n.matchImageCaptionViewElement(o),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(o,{writer:r})=>i.isBlockImage(o.parent)?r.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(o,{writer:r})=>{if(!i.isBlockImage(o.parent))return null;const l=r.createEditableElement("figcaption");r.setCustomProperty("imageCaption",!0,l),l.placeholder=s("Enter image caption"),qt({view:t,element:l,keepOnFocus:!0});const c=o.parent.getAttribute("alt"),m=c?s("Caption for image: %0",[c]):s("Caption for the image");return ti(l,r,{label:m})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),s=e.commands.get("imageTypeBlock"),o=r=>{if(!r.return)return;const{oldElement:l,newElement:c}=r.return;/* istanbul ignore if: paranoid check -- @preserve */if(!l)return;if(t.isBlockImage(l)){const g=i.getCaptionFromImageModelElement(l);if(g){this._saveCaption(c,g);return}}const m=this._getSavedCaption(l);m&&this._saveCaption(c,m)};n&&this.listenTo(n,"execute",o,{priority:"low"}),s&&this.listenTo(s,"execute",o,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?$t.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",()=>{const s=t.document.differ.getChanges();for(const o of s){if(o.attributeKey!=="alt")continue;const r=o.range.start.nodeAfter;if(i.isBlockImage(r)){const l=n.getCaptionFromImageModelElement(r);if(!l)return;e.editing.reconvertItem(l)}}})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class it extends p{static get requires(){return[le]}static get pluginName(){return"ImageCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),n=e.t;e.ui.componentFactory.add("toggleImageCaption",s=>{const o=e.commands.get("toggleImageCaption"),r=new I(s);return r.set({icon:fi,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.bind("label").to(o,"value",l=>n(l?"Toggle caption off":"Toggle caption on")),this.listenTo(r,"execute",()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const l=i.getCaptionFromModelSelection(e.model.document.selection);if(l){const c=e.editing.mapper.toViewElement(l);t.scrollToTheSelection(),t.change(m=>{m.addClass("image__caption_highlighted",c)})}e.editing.view.focus()}),r})}}k(":root{--ck-content-color-image-caption-background:#f7f7f7;--ck-content-color-image-caption-text:#333;--ck-color-image-caption-highlighted-background:#fd0}.ck-content .image>figcaption{background-color:var(--ck-content-color-image-caption-background);break-before:avoid;caption-side:bottom;color:var(--ck-content-color-image-caption-text);display:table-caption;font-size:.75em;outline-offset:-1px;overflow-wrap:anywhere;padding:.6em;word-break:normal}@media (forced-colors:active){.ck-content .image>figcaption{background-color:unset;color:unset}}@media (forced-colors:none){.ck.ck-editor__editable .image>figcaption.image__caption_highlighted{animation:ck-image-caption-highlight .6s ease-out}}@media (prefers-reduced-motion:reduce){.ck.ck-editor__editable .image>figcaption.image__caption_highlighted{animation:none}}@keyframes ck-image-caption-highlight{0%{background-color:var(--ck-color-image-caption-highlighted-background)}to{background-color:var(--ck-content-color-image-caption-background)}}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ti extends p{static get requires(){return[tt,it]}static get pluginName(){return"ImageCaption"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ce(a){const e=a.map(t=>t.replace("+","\\+"));return new RegExp(`^image\\/(${e.join("|")})$`)}function nt(a){return new Promise((e,t)=>{const i=a.getAttribute("src");fetch(i).then(n=>n.blob()).then(n=>{const s=st(n,i),r=`image.${s.replace("image/","")}`,l=new File([n],r,{type:s});e(l)}).catch(n=>n&&n.name==="TypeError"?zi(i).then(e).catch(t):t(n))})}function ot(a,e){return!a.isInlineImageView(e)||!e.getAttribute("src")?!1:!!e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||!!e.getAttribute("src").match(/^blob:/g)}function st(a,e){return a.type?a.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}function zi(a){return Ri(a).then(e=>{const t=st(e,a),n=`image.${t.replace("image/","")}`;return new File([e],n,{type:t})})}function Ri(a){return new Promise((e,t)=>{const i=R.document.createElement("img");i.addEventListener("load",()=>{const n=R.document.createElement("canvas");n.width=i.width,n.height=i.height,n.getContext("2d").drawImage(i,0,0),n.toBlob(o=>o?e(o):t())}),i.addEventListener("error",()=>t()),i.src=a})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class at extends p{static get pluginName(){return"ImageUploadUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("uploadImage",()=>this._createToolbarButton()),e.ui.componentFactory.add("imageUpload",()=>this._createToolbarButton()),e.ui.componentFactory.add("menuBar:uploadImage",()=>this._createMenuBarButton("standalone")),e.plugins.has("ImageInsertUI")&&e.plugins.get("ImageInsertUI").registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:t=>this._createMenuBarButton(t?"insertOnly":"insertNested")})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),s=t.config.get("image.upload.types"),o=ce(s),r=new e(t.locale),l=i.t;return r.set({acceptedType:s.map(c=>`image/${c}`).join(","),allowMultipleFiles:!0,label:l("Upload from computer"),icon:bi}),r.bind("isEnabled").to(n),r.on("done",(c,m)=>{const g=Array.from(m).filter(u=>o.test(u.type));g.length&&(t.execute("uploadImage",{file:g}),t.editing.view.focus())}),r}_createToolbarButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this.editor.commands.get("uploadImage"),n=this._createButton(Be);return n.tooltip=!0,n.bind("label").to(t,"isImageSelected",i,"isAccessAllowed",(s,o)=>e(o?s?"Replace image from computer":"Upload image from computer":"You have no image upload permissions.")),n}_createDropdownButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this._createButton(Be);return i.withText=!0,i.bind("label").to(t,"isImageSelected",n=>e(n?"Replace from computer":"Upload from computer")),i.on("execute",()=>{t.dropdownView.isOpen=!1}),i}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createButton(ri);switch(i.withText=!0,e){case"standalone":i.label=t("Image from computer");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("From computer");break}return i}}k(".ck.ck-editor__editable .image,.ck.ck-editor__editable .image-inline{position:relative}.ck.ck-editor__editable .image .ck-progress-bar,.ck.ck-editor__editable .image-inline .ck-progress-bar{left:0;position:absolute;top:0}.ck.ck-editor__editable .image-inline.ck-appear,.ck.ck-editor__editable .image.ck-appear{animation:fadeIn .7s}@media (prefers-reduced-motion:reduce){.ck.ck-editor__editable .image-inline.ck-appear,.ck.ck-editor__editable .image.ck-appear{animation:none;opacity:1}}.ck.ck-editor__editable .image .ck-progress-bar,.ck.ck-editor__editable .image-inline .ck-progress-bar{background:var(--ck-color-upload-bar-background);height:2px;transition:width .1s;width:0}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}"),k('.ck-image-upload-complete-icon{border-radius:50%;display:block;position:absolute;right:min(var(--ck-spacing-medium),6%);top:min(var(--ck-spacing-medium),6%);z-index:1}.ck-image-upload-complete-icon:after{content:"";position:absolute}:root{--ck-color-image-upload-icon:#fff;--ck-color-image-upload-icon-background:#008a00;--ck-image-upload-icon-size:20;--ck-image-upload-icon-width:2px;--ck-image-upload-icon-is-visible:clamp(0px,100% - 50px,1px)}.ck-image-upload-complete-icon{animation-delay:0s,3s;animation-duration:.5s,.5s;animation-fill-mode:forwards,forwards;animation-name:ck-upload-complete-icon-show,ck-upload-complete-icon-hide;background:var(--ck-color-image-upload-icon-background);font-size:calc(1px*var(--ck-image-upload-icon-size));height:calc(var(--ck-image-upload-icon-is-visible)*var(--ck-image-upload-icon-size));opacity:0;overflow:hidden;width:calc(var(--ck-image-upload-icon-is-visible)*var(--ck-image-upload-icon-size))}.ck-image-upload-complete-icon:after{animation-delay:.5s;animation-duration:.5s;animation-fill-mode:forwards;animation-name:ck-upload-complete-icon-check;border-right:var(--ck-image-upload-icon-width) solid var(--ck-color-image-upload-icon);border-top:var(--ck-image-upload-icon-width) solid var(--ck-color-image-upload-icon);box-sizing:border-box;height:0;left:25%;opacity:0;top:50%;transform:scaleX(-1) rotate(135deg);transform-origin:left top;width:0}@media (prefers-reduced-motion:reduce){.ck-image-upload-complete-icon{animation-duration:0s}.ck-image-upload-complete-icon:after{animation:none;height:.45em;opacity:1;width:.3em}}@keyframes ck-upload-complete-icon-show{0%{opacity:0}to{opacity:1}}@keyframes ck-upload-complete-icon-hide{0%{opacity:1}to{opacity:0}}@keyframes ck-upload-complete-icon-check{0%{height:0;opacity:1;width:0}33%{height:0;width:.3em}to{height:.45em;opacity:1;width:.3em}}'),k('.ck .ck-upload-placeholder-loader{align-items:center;display:flex;justify-content:center;left:0;position:absolute;top:0}.ck .ck-upload-placeholder-loader:before{content:"";position:relative}:root{--ck-color-upload-placeholder-loader:#b3b3b3;--ck-upload-placeholder-loader-size:32px;--ck-upload-placeholder-image-aspect-ratio:2.8}.ck .ck-image-upload-placeholder{margin:0;width:100%}.ck .ck-image-upload-placeholder.image-inline{width:calc(var(--ck-upload-placeholder-loader-size)*2*var(--ck-upload-placeholder-image-aspect-ratio))}.ck .ck-image-upload-placeholder img{aspect-ratio:var(--ck-upload-placeholder-image-aspect-ratio)}.ck .ck-upload-placeholder-loader{height:100%;width:100%}.ck .ck-upload-placeholder-loader:before{animation:ck-upload-placeholder-loader 1s linear infinite;border-radius:50%;border-right:2px solid transparent;border-top:3px solid var(--ck-color-upload-placeholder-loader);height:var(--ck-upload-placeholder-loader-size);width:var(--ck-upload-placeholder-loader-size)}@keyframes ck-upload-placeholder-loader{to{transform:rotate(1turn)}}');/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class rt extends p{static get pluginName(){return"ImageUploadProgress"}static get isOfficialPlugin(){return!0}placeholder;constructor(e){super(e),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}uploadStatusChange=(e,t,i)=>{const n=this.editor,s=t.item,o=s.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),l=n.plugins.get(y),c=o?t.attributeNewValue:null,m=this.placeholder,g=n.editing.mapper.toViewElement(s),u=i.writer;if(c=="reading"){lt(g,u),ct(r,m,g,u);return}if(c=="uploading"){const d=l.loaders.get(o);lt(g,u),d?(mt(g,u),Oi(g,u,d,n.editing.view),Mi(r,g,u,d)):ct(r,m,g,u);return}c=="complete"&&l.loaders.get(o)&&Fi(g,u,n.editing.view),Ni(g,u),mt(g,u),Pi(g,u)}}function lt(a,e){a.hasClass("ck-appear")||e.addClass("ck-appear",a)}function Pi(a,e){e.removeClass("ck-appear",a)}function ct(a,e,t,i){t.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",t);const n=a.findViewImgElement(t);n.getAttribute("src")!==e&&i.setAttribute("src",e,n),gt(t,"placeholder")||i.insert(i.createPositionAfter(n),Li(i))}function mt(a,e){a.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",a),ut(a,e,"placeholder")}function Oi(a,e,t,i){const n=Di(e);e.insert(e.createPositionAt(a,"end"),n),t.on("change:uploadedPercent",(s,o,r)=>{i.change(l=>{l.setStyle("width",r+"%",n)})})}function Ni(a,e){ut(a,e,"progressBar")}function Fi(a,e,t){const i=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(a,"end"),i),setTimeout(()=>{t.change(n=>n.remove(n.createRangeOn(i)))},3e3)}function Di(a){const e=a.createUIElement("div",{class:"ck-progress-bar"});return a.setCustomProperty("progressBar",!0,e),e}function Li(a){const e=a.createUIElement("div",{class:"ck-upload-placeholder-loader"});return a.setCustomProperty("placeholder",!0,e),e}function gt(a,e){for(const t of a.getChildren())if(t.getCustomProperty(e))return t}function ut(a,e,t){const i=gt(a,t);i&&e.remove(e.createRangeOn(i))}function Mi(a,e,t,i){if(i.data){const n=a.findViewImgElement(e);t.setAttribute("src",i.data,n)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class dt extends _{constructor(e){super(e),this.set("isAccessAllowed",!0)}refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=Ie(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((o,r)=>{const l=i.getSelectedElement();if(r&&l&&n.isImage(l)){const c=this.editor.model.createPositionAfter(l);this._uploadImage(o,s,c)}else this._uploadImage(o,s)})}_uploadImage(e,t,i){const n=this.editor,o=n.plugins.get(y).createLoader(e),r=n.plugins.get("ImageUtils");o&&r.insertImage({...t,uploadId:o.id},i)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ht extends p{static get requires(){return[y,Ae,q,f]}static get pluginName(){return"ImageUploadEditing"}static get isOfficialPlugin(){return!0}_uploadImageElements;_uploadedImages=new Map;constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(y),s=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline"),r=ce(e.config.get("image.upload.types")),l=new dt(e);e.commands.add("uploadImage",l),e.commands.add("imageUpload",l),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}).add(c=>c.on("element:img",(m,g,u)=>{if(!u.consumable.test(g.viewItem,{attributes:["data-ck-upload-id"]}))return;const d=g.viewItem.getAttribute("data-ck-upload-id");if(!d)return;const[h]=Array.from(g.modelRange.getItems({shallow:!0})),b=n.loaders.get(d);h&&(u.writer.setAttribute("uploadId",d,h),u.consumable.consume(g.viewItem,{attributes:["data-ck-upload-id"]}),b&&b.data&&u.writer.setAttribute("uploadStatus",b.status,h))},{priority:"low"})),this.listenTo(e.editing.view.document,"clipboardInput",(c,m)=>{if(pt(m.dataTransfer))return;const g=Array.from(m.dataTransfer.files).filter(d=>d?r.test(d.type):!1);if(!g.length)return;if(c.stop(),e.model.change(d=>{m.targetRanges&&d.setSelection(m.targetRanges.map(h=>e.editing.mapper.toModelRange(h))),e.execute("uploadImage",{file:g})}),!e.commands.get("uploadImage").isAccessAllowed){const d=e.plugins.get("Notification"),h=e.locale.t;d.showWarning(h("You have no image upload permissions."),{namespace:"image"})}}),this.listenTo(o,"inputTransformation",(c,m)=>{const g=Array.from(e.editing.view.createRangeIn(m.content)).map(d=>d.item).filter(d=>ot(s,d)&&!d.getAttribute("uploadProcessed")).map(d=>({promise:nt(d),imageElement:d}));if(!g.length)return;const u=new j(e.editing.view.document);for(const d of g){u.setAttribute("uploadProcessed",!0,d.imageElement);const h=n.createLoader(d.promise);h&&(u.setAttribute("src","",d.imageElement),u.setAttribute("uploadId",h.id,d.imageElement))}}),e.editing.view.document.on("dragover",(c,m)=>{m.preventDefault()}),t.on("change",()=>{const c=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),m=new Set;for(const g of c)if(g.type=="insert"&&g.name!="$text"){const u=g.position.nodeAfter,d=g.position.root.rootName=="$graveyard";for(const h of Wi(e,u)){const b=h.getAttribute("uploadId");if(!b)continue;const w=n.loaders.get(b);if(!w){!d&&this._uploadedImages.has(b)&&e.model.enqueueChange({isUndoable:!1},C=>{C.setAttribute("uploadStatus","complete",h),this.fire("uploadComplete",{data:this._uploadedImages.get(b),imageElement:h})});continue}d?m.has(b)||Array.from(this._uploadImageElements.get(b)).every(T=>T.root.rootName=="$graveyard")&&w.abort():(m.add(b),this._uploadImageElements.has(b)?this._uploadImageElements.get(b).add(h):this._uploadImageElements.set(b,new Set([h])),w.status=="idle"&&this._readAndUpload(w))}}}),this.on("uploadComplete",(c,{imageElement:m,data:g})=>{const u=g.urls?g.urls:g;this.editor.model.change(d=>{d.setAttribute("src",u.default,m),this._parseAndSetSrcsetAttributeOnImage(u,m,d),s.setImageNaturalSizeAttributes(m)})},{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageBlock")),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageInline"))}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,s=t.plugins.get(y),o=t.plugins.get(Ae),r=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},m=>{const g=l.get(e.id);for(const u of g)m.setAttribute("uploadStatus","reading",u)}),e.read().then(()=>{const m=e.upload();t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Uploading image"));for(const g of l.get(e.id)){/* istanbul ignore next -- @preserve */if(Kt.isSafari){const u=t.editing.mapper.toViewElement(g),d=r.findViewImgElement(u);t.editing.view.once("render",()=>{if(!d.parent)return;const h=t.editing.view.domConverter.mapViewToDom(d.parent);if(!h)return;const b=h.style.display;h.style.display="none",h._ckHack=h.offsetHeight,h.style.display=b})}i.enqueueChange({isUndoable:!1},u=>{u.setAttribute("uploadStatus","uploading",g)})}return m}).then(m=>{i.enqueueChange({isUndoable:!1},g=>{for(const u of l.get(e.id))g.setAttribute("uploadStatus","complete",u),this.fire("uploadComplete",{data:m,imageElement:u});t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Image upload complete")),this._uploadedImages.set(e.id,m)}),c()}).catch(m=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Error during image upload")),e.status!=="error"&&e.status!=="aborted")throw m;e.status=="error"&&m&&o.showWarning(m,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},g=>{for(const u of l.get(e.id))u.root.rootName!=="$graveyard"&&g.remove(u)}),c()});function c(){i.enqueueChange({isUndoable:!1},m=>{for(const g of l.get(e.id))m.removeAttribute("uploadId",g),m.removeAttribute("uploadStatus",g);l.delete(e.id)}),s.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const s=Object.keys(e).filter(o=>{const r=parseInt(o,10);if(!isNaN(r))return n=Math.max(n,r),!0}).map(o=>`${e[o]} ${o}w`).join(", ");if(s!=""){const o={srcset:s};!t.hasAttribute("width")&&!t.hasAttribute("height")&&(o.width=n),i.setAttributes(o,t)}}_registerConverters(e){const{conversion:t,plugins:i}=this.editor,n=i.get(y),s=i.get(f);t.for("dataDowncast").add(o=>{o.on(`attribute:uploadId:${e}`,(r,l,c)=>{if(!c.consumable.test(l.item,r.name))return;const m=n.loaders.get(l.attributeNewValue);if(!m||!m.data)return null;const g=c.mapper.toViewElement(l.item),u=s.findViewImgElement(g);u&&(c.consumable.consume(l.item,r.name),c.writer.setAttribute("data-ck-upload-id",m.id,u))})})}}function pt(a){return Array.from(a.types).includes("text/html")&&a.getData("text/html")!==""}function Wi(a,e){const t=a.plugins.get("ImageUtils");return Array.from(a.model.createRangeOn(e)).filter(i=>t.isImage(i.item)).map(i=>i.item)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ft extends p{static get pluginName(){return"ImageUpload"}static get isOfficialPlugin(){return!0}static get requires(){return[ht,at,rt]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bt extends O{urlInputView;keystrokes;constructor(e){super(e),this.set("imageURLInputValue",""),this.set("isImageSelected",!1),this.set("isEnabled",!0),this.keystrokes=new P,this.urlInputView=this._createUrlInputView(),this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-url"],tabindex:"-1"},children:[this.urlInputView,{tag:"div",attributes:{class:["ck","ck-image-insert-url__action-row"]}}]})}render(){super.render(),N({view:this}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy()}_createUrlInputView(){const e=this.locale,t=e.t,i=new X(e,Ce);return i.bind("label").to(this,"isImageSelected",n=>t(n?"Update image URL":"Insert image via URL")),i.bind("isEnabled").to(this),i.fieldView.inputMode="url",i.fieldView.placeholder="https://example.com/image.png",i.fieldView.bind("value").to(this,"imageURLInputValue",n=>n||""),i.fieldView.on("input",()=>{this.imageURLInputValue=i.fieldView.element.value.trim()}),i}focus(){this.urlInputView.focus()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class kt extends p{_imageInsertUI;_formView;static get pluginName(){return"ImageInsertViaUrlUI"}static get isOfficialPlugin(){return!0}static get requires(){return[E,li]}init(){this.editor.ui.componentFactory.add("insertImageViaUrl",()=>this._createToolbarButton()),this.editor.ui.componentFactory.add("menuBar:insertImageViaUrl",()=>this._createMenuBarButton("standalone"))}afterInit(){this._imageInsertUI=this.editor.plugins.get("ImageInsertUI"),this._imageInsertUI.registerIntegration({name:"url",observable:()=>this.editor.commands.get("insertImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:e=>this._createMenuBarButton(e?"insertOnly":"insertNested")})}_createInsertUrlButton(e){const t=new e(this.editor.locale);return t.icon=ki,t.on("execute",()=>{this._showModal()}),t}_createToolbarButton(){const e=this.editor.locale.t,t=this._createInsertUrlButton(I);return t.tooltip=!0,t.bind("label").to(this._imageInsertUI,"isImageSelected",i=>e(i?"Update image URL":"Insert image via URL")),t}_createDropdownButton(){const e=this.editor.locale.t,t=this._createInsertUrlButton(I);return t.withText=!0,t.bind("label").to(this._imageInsertUI,"isImageSelected",i=>e(i?"Update image URL":"Insert via URL")),t}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createInsertUrlButton(ci);switch(i.withText=!0,e){case"standalone":i.label=t("Image via URL");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("Via URL");break}return i}_createInsertUrlView(){const e=this.editor,t=e.locale,i=e.commands.get("replaceImageSource"),n=e.commands.get("insertImage"),s=new bt(t);return s.bind("isImageSelected").to(this._imageInsertUI),s.bind("isEnabled").toMany([n,i],"isEnabled",(...o)=>o.some(r=>r)),s}_showModal(){const e=this.editor,i=e.locale.t,n=e.plugins.get("Dialog");this._formView||(this._formView=this._createInsertUrlView(),this._formView.on("submit",()=>this._handleSave()));const s=e.commands.get("replaceImageSource");this._formView.imageURLInputValue=s.value||"",n.show({id:"insertImageViaUrl",title:i("Image via URL"),isModal:!0,content:this._formView,actionButtons:[{label:i("Cancel"),withText:!0,onExecute:()=>n.hide()},{label:this._imageInsertUI.isImageSelected?i("Save"):i("Insert"),class:"ck-button-action",withText:!0,onExecute:()=>this._handleSave()}]})}_handleSave(){this.editor.commands.get("replaceImageSource").isEnabled?this.editor.execute("replaceImageSource",{source:this._formView.imageURLInputValue}):this.editor.execute("insertImage",{source:this._formView.imageURLInputValue}),this.editor.plugins.get("Dialog").hide()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class It extends p{static get pluginName(){return"ImageInsertViaUrl"}static get isOfficialPlugin(){return!0}static get requires(){return[kt,E]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class qi extends p{static get pluginName(){return"ImageInsert"}static get isOfficialPlugin(){return!0}static get requires(){return[ft,It,E]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class wt extends _{refresh(){const e=this.editor,i=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!i,!i||!i.hasAttribute("resizedWidth")?this.value=null:this.value={width:i.getAttribute("resizedWidth"),height:null}}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},s&&i.change(o=>{o.setAttribute("resizedWidth",e.width,s),o.removeAttribute("resizedHeight",s),n.setImageNaturalSizeAttributes(s)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class me extends p{static get requires(){return[f]}static get pluginName(){return"ImageResizeEditing"}static get licenseFeatureCode(){return"IR"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new wt(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0})),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0}))}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add(n=>n.on(`attribute:resizedWidth:${e}`,(s,o,r)=>{if(!r.consumable.consume(o.item,s.name))return;const l=r.writer,c=r.mapper.toViewElement(o.item);o.attributeNewValue!==null?(l.setStyle("width",o.attributeNewValue,c),l.addClass("image_resized",c)):(l.removeStyle("width",c),l.removeClass("image_resized",c))})),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:n=>({key:"style",value:{height:n}})}),t.conversion.for("editingDowncast").add(n=>n.on(`attribute:resizedHeight:${e}`,(s,o,r)=>{if(!r.consumable.consume(o.item,s.name))return;const l=r.writer,c=r.mapper.toViewElement(o.item),m=e==="imageInline"?i.findViewImgElement(c):c;o.attributeNewValue!==null?l.setStyle("height",o.attributeNewValue,m):l.removeStyle("height",m)})),t.conversion.for("upcast").attributeToAttribute({view:{name:e==="imageBlock"?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:n=>S(n)?null:n.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:e==="imageBlock"?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:n=>S(n)?null:n.getStyle("height")}}),t.conversion.for("upcast").add(n=>{n.on(`element:${e==="imageBlock"?"figure":"img"}`,(s,o,r)=>{r.consumable.consume(o.viewItem,{classes:["image_resized"]})})})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const ge={small:yi,medium:vi,large:_i,custom:wi,original:Ii};class _t extends p{static get requires(){return[me]}static get pluginName(){return"ImageResizeButtons"}static get isOfficialPlugin(){return!0}_resizeUnit;constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const n of t)this._registerImageResizeButton(n);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:s}=e;t.ui.componentFactory.add(i,o=>{const r=new I(o),l=t.commands.get("resizeImage"),c=this._getOptionLabelValue(e,!0);if(!ge[s])throw new Jt("imageresizebuttons-missing-icon",t,e);if(r.set({label:c,icon:ge[s],tooltip:c,isToggleable:!0}),r.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&V(e)){const m=t.plugins.get("ImageCustomResizeUI");this.listenTo(r,"execute",()=>{m._showForm(this._resizeUnit)})}else{const m=n?n+this._resizeUnit:null;r.bind("isOn").to(l,"value",l,"isEnabled",ue(m)),this.listenTo(r,"execute",()=>{t.execute("resizeImage",{width:m})})}return r})}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find(o=>!o.value),s=o=>{const r=t.commands.get("resizeImage"),l=Z(o,mi),c=l.buttonView,m=i("Resize image");return c.set({tooltip:m,commandValue:n.value,icon:ge.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:m,ariaLabelledBy:void 0}),c.bind("label").to(r,"value",g=>g&&g.width?g.width:this._getOptionLabelValue(n)),l.bind("isEnabled").to(this),gi(l,()=>this._getResizeDropdownListItemDefinitions(e,r),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(l,"execute",g=>{"onClick"in g.source?g.source.onClick():(t.execute(g.source.commandName,{width:g.source.commandValue}),t.editing.view.focus())}),l};t.ui.componentFactory.add("resizeImage",s),t.ui.componentFactory.add("imageResize",s)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?V(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):V(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,n=new Xt,s=e.map(o=>V(o)?{...o,valueWithUnits:"custom"}:o.value?{...o,valueWithUnits:`${o.value}${this._resizeUnit}`}:{...o,valueWithUnits:null});for(const o of s){let r=null;if(i.plugins.has("ImageCustomResizeUI")&&V(o)){const l=i.plugins.get("ImageCustomResizeUI");r={type:"button",model:new Te({label:this._getOptionLabelValue(o),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{l._showForm(this._resizeUnit)}})};const c=Object.values(s).map(m=>m.valueWithUnits);r.model.bind("isOn").to(t,"value",t,"isEnabled",$i(c))}else r={type:"button",model:new Te({commandName:"resizeImage",commandValue:o.valueWithUnits,label:this._getOptionLabelValue(o),role:"menuitemradio",withText:!0,icon:null})},r.model.bind("isOn").to(t,"value",t,"isEnabled",ue(o.valueWithUnits));r.model.bind("isEnabled").to(t,"isEnabled"),n.add(r)}return n}}function V(a){return a.value==="custom"}function ue(a){return(e,t)=>{const i=e;return i===void 0||!t?!1:a===null&&i===a?!0:i!==null&&i.width===a}}function $i(a){return(e,t)=>!a.some(i=>ue(i)(e,t))}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const ji="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",de="image_resized";class vt extends p{static get requires(){return[G,f]}static get pluginName(){return"ImageResizeHandles"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(L),this.listenTo(t.document,"imageLoaded",(n,s)=>{if(!s.target.matches(ji))return;const o=e.editing.view.domConverter,r=o.domToView(s.target),l=i.getImageWidgetFromImageView(r);let c=this.editor.plugins.get(G).getResizerByViewElement(l);if(c){c.redraw();return}const m=e.editing.mapper,g=m.toModelElement(l);c=e.plugins.get(G).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:g,viewElement:l,editor:e,getHandleHost(u){return u.querySelector("img")},getResizeHost(){return o.mapViewToDom(m.toViewElement(g))},isCentered(){return g.getAttribute("imageStyle")=="alignCenter"},onCommit(u){t.change(d=>{d.removeClass(de,l)}),e.execute("resizeImage",{width:u})}}),c.on("updateSize",()=>{l.hasClass(de)||t.change(d=>{d.addClass(de,l)});const u=g.name==="imageInline"?r:l;u.getStyle("height")&&t.change(d=>{d.removeStyle("height",u)})}),c.bind("isEnabled").to(this)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function he(a){if(!a)return null;const[,e,t]=a.trim().match(/([.,\d]+)(%|px)$/)||[],i=Number.parseFloat(e);return Number.isNaN(i)?null:{value:i,unit:t}}function pe(a,e,t){return t==="px"?{value:e.value,unit:"px"}:{value:e.value/a*100,unit:"%"}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function fe(a){const{editing:e}=a,i=a.plugins.get("ImageUtils").getClosestSelectedImageElement(a.model.document.selection);if(!i)return null;const n=e.mapper.toViewElement(i),s=e.view.domConverter.mapViewToDom(n);return{model:i,view:n,dom:s}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function yt(a,e){const t=fe(a);if(!t)return null;const i=he(t.model.getAttribute("resizedWidth")||null);if(!i)return null;if(i.unit===e)return i;const n=_e(t.dom),s={value:new Zt(t.dom).width};return pe(n,s,e)}k(":root{--ck-image-custom-resize-form-width:340px}@media screen and (max-width:600px){:root{--ck-image-custom-resize-form-width:300px}}.ck.ck-image-custom-resize-form.ck-responsive-form{width:var(--ck-image-custom-resize-form-width)}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Et extends O{focusTracker;keystrokes;unit;backButtonView;saveButtonView;labeledInput;children;_focusables;_focusCycler;_validators;constructor(e,t,i){super(e),this.focusTracker=new H,this.keystrokes=new P,this.unit=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new ye(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new K,this._validators=i,this.keystrokes.set("Esc",(n,s)=>{this.fire("cancel"),s()}),this._focusCycler=new J({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),N({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].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()}_createBackButton(){const e=this.locale.t,t=new I(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:ze,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new I(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Ee(this.locale,{label:e("Image Resize")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new X(this.locale,ui);return t.label=e("Resize image (in %0)",this.unit),t.class="ck-labeled-field-view_full-width",t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(e===null)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return e===null?null:`${e}${t}`}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ct(a,e){const t=fe(a);if(!t)return null;const i=_e(t.dom),n=he(window.getComputedStyle(t.dom).minWidth)||{value:1},s=Math.max(.1,pe(i,n,e).value);return{unit:e,lower:s,upper:e==="px"?i:100}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class xt extends p{_balloon;_form;static get requires(){return[xe]}static get pluginName(){return"ImageCustomResizeUI"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(Se(Et))(t.locale,e,Hi(t)),this._form.render(),this.listenTo(this._form,"submit",()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))}),this.listenTo(this._form.labeledInput,"change:errorText",()=>{t.ui.update()}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),Ue({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:D(t)});const n=yt(t,e),s=n?n.value.toFixed(1):"",o=Ct(t,e);i.fieldView.value=i.fieldView.element.value=s,o&&Object.assign(i.fieldView,{min:o.lower.toFixed(1),max:Math.ceil(o.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}function Hi(a){const e=a.t;return[t=>{if(t.rawSize.trim()==="")return e("The value must not be empty.");if(t.parsedSize===null)return e("The value should be a plain number.")}]}k(".ck-content img.image_resized{height:auto}.ck-content .image.image_resized{box-sizing:border-box;display:block;max-width:100%}.ck-content .image.image_resized img{width:100%}.ck-content .image.image_resized>figcaption{display:block}.ck.ck-editor__editable td .image-inline.image_resized img,.ck.ck-editor__editable th .image-inline.image_resized img{max-width:100%}[dir=ltr] .ck.ck-button.ck-button_with-text.ck-resize-image-button .ck-button__icon{margin-right:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-button.ck-button_with-text.ck-resize-image-button .ck-button__icon{margin-left:var(--ck-spacing-standard)}.ck.ck-dropdown .ck-button.ck-resize-image-button .ck-button__label{width:4em}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Gi extends p{static get requires(){return[me,vt,xt,_t]}static get pluginName(){return"ImageResize"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class St extends _{_defaultStyles;_styles;constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map(i=>{if(i.isDefault)for(const n of i.modelElements)this._defaultStyles[n]=i.name;return[i.name,i]}))}refresh(){const i=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!i,this.isEnabled?i.hasAttribute("imageStyle")?this.value=i.getAttribute("imageStyle"):this.value=this._defaultStyles[i.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change(s=>{const o=e.value,{setImageSizes:r=!0}=e;let l=n.getClosestSelectedImageElement(i.document.selection);o&&this.shouldConvertImageType(o,l)&&(this.editor.execute(n.isBlockImage(l)?"imageTypeInline":"imageTypeBlock",{setImageSizes:r}),l=n.getClosestSelectedImageElement(i.document.selection)),!o||this._styles.get(o).isDefault?s.removeAttribute("imageStyle",l):s.setAttribute("imageStyle",o,l),r&&n.setImageNaturalSizeAttributes(l)})}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const W={get inline(){return{name:"inline",title:"In line",icon:Re,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:Pe,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:Ne,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:Q,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:Y,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:Oe,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:Q,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:Y,modelElements:["imageBlock"],className:"image-style-side"}}},Ut={full:Ei,left:Ne,right:Oe,center:Q,inlineLeft:Pe,inlineRight:Y,inline:Re},Vt=[{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 Ki(a){return(a.configuredStyles.options||[]).map(i=>Zi(i)).filter(i=>Yi(i,a))}function Ji(a,e){return a&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:a?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}}function Xi(a){return a.has("ImageBlockEditing")&&a.has("ImageInlineEditing")?[...Vt]:[]}function Zi(a){return typeof a=="string"?W[a]?a={...W[a]}:a={name:a}:a=Qi(W[a.name],a),typeof a.icon=="string"&&(a.icon=Ut[a.icon]||a.icon),a}function Yi(a,{isBlockPluginLoaded:e,isInlinePluginLoaded:t}){const{modelElements:i,name:n}=a;if(!i||!i.length||!n)return Bt({style:a}),!1;{const s=[e?"imageBlock":null,t?"imageInline":null];if(!i.some(o=>s.includes(o)))return v("image-style-missing-dependency",{style:a,missingPlugins:i.map(o=>o==="imageBlock"?"ImageBlockEditing":"ImageInlineEditing")}),!1}return!0}function Qi(a,e){const t={...e};for(const i in a)Object.prototype.hasOwnProperty.call(e,i)||(t[i]=a[i]);return t}function Bt(a){v("image-style-configuration-definition-invalid",a)}const B={normalizeStyles:Ki,getDefaultStylesConfiguration:Ji,getDefaultDropdownDefinitions:Xi,warnInvalidStyle:Bt};/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function At(a){return(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=zt(t.attributeNewValue,a),s=zt(t.attributeOldValue,a),o=i.mapper.toViewElement(t.item),r=i.writer;s&&r.removeClass(s.className,o),n&&r.addClass(n.className,o)}}function Tt(a){const e={imageInline:a.filter(t=>!t.isDefault&&t.modelElements.includes("imageInline")),imageBlock:a.filter(t=>!t.isDefault&&t.modelElements.includes("imageBlock"))};return(t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=z(i.modelRange.getItems());if(o&&n.schema.checkAttribute(o,"imageStyle"))for(const r of e[o.name])n.consumable.consume(s,{classes:r.className})&&n.writer.setAttribute("imageStyle",r.name,o)}}function zt(a,e){for(const t of e)if(t.name===a)return t}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class be extends p{static get pluginName(){return"ImageStyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[f]}normalizedStyles;init(){const e=this.editor,t=e.plugins.has("ImageBlockEditing"),i=e.plugins.has("ImageInlineEditing");e.config.define("image.styles",B.getDefaultStylesConfiguration(t,i)),this.normalizedStyles=B.normalizeStyles({configuredStyles:e.config.get("image.styles"),isBlockPluginLoaded:t,isInlinePluginLoaded:i}),this._setupConversion(t,i),this._setupPostFixer(),e.commands.add("imageStyle",new St(e,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,s=At(this.normalizedStyles),o=Tt(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",s),i.data.downcastDispatcher.on("attribute:imageStyle",s),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:figure",o,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:img",o,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(f),n=new Map(this.normalizedStyles.map(s=>[s.name,s]));t.registerPostFixer(s=>{let o=!1;for(const r of t.differ.getChanges())if(r.type=="insert"||r.type=="attribute"&&r.attributeKey=="imageStyle"){let l=r.type=="insert"?r.position.nodeAfter:r.range.start.nodeAfter;if(l&&l.is("element","paragraph")&&l.childCount>0&&(l=l.getChild(0)),!i.isImage(l))continue;const c=l.getAttribute("imageStyle");if(!c)continue;const m=n.get(c);(!m||!m.modelElements.includes(l.name))&&(s.removeAttribute("imageStyle",l),o=!0)}return o})}}function Rt(a){return a!==null&&(typeof a=="object"||typeof a=="function")}function A(a){return a}k(":root{--ck-content-image-style-spacing:1.5em;--ck-content-inline-image-style-spacing:calc(var(--ck-content-image-style-spacing)/2)}.ck-content .image.image-style-block-align-left,.ck-content .image.image-style-block-align-right{max-width:calc(100% - var(--ck-content-image-style-spacing))}.ck-content .image.image-style-align-left,.ck-content .image.image-style-align-right{clear:none}.ck-content .image.image-style-side{float:right;margin-left:var(--ck-content-image-style-spacing);max-width:50%}.ck-content .image.image-style-align-left{float:left;margin-right:var(--ck-content-image-style-spacing)}.ck-content .image.image-style-align-right{float:right;margin-left:var(--ck-content-image-style-spacing)}.ck-content .image.image-style-block-align-right{margin-left:auto;margin-right:0}.ck-content .image.image-style-block-align-left{margin-left:0;margin-right:auto}.ck-content .image-style-align-center{margin-left:auto;margin-right:auto}.ck-content .image-style-align-left{float:left;margin-right:var(--ck-content-image-style-spacing)}.ck-content .image-style-align-right{float:right;margin-left:var(--ck-content-image-style-spacing)}.ck-content p+.image.image-style-align-left,.ck-content p+.image.image-style-align-right,.ck-content p+.image.image-style-side{margin-top:0}.ck-content .image-inline.image-style-align-left,.ck-content .image-inline.image-style-align-right{margin-bottom:var(--ck-content-inline-image-style-spacing);margin-top:var(--ck-content-inline-image-style-spacing)}.ck-content .image-inline.image-style-align-left{margin-right:var(--ck-content-inline-image-style-spacing)}.ck-content .image-inline.image-style-align-right{margin-left:var(--ck-content-inline-image-style-spacing)}.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open>.ck-splitbutton__action:not(.ck-disabled),.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open>.ck-splitbutton__arrow:not(.ck-disabled),.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open>.ck-splitbutton__arrow:not(.ck-disabled):not(:hover),.ck.ck-splitbutton.ck-splitbutton_flatten:hover>.ck-splitbutton__action:not(.ck-disabled),.ck.ck-splitbutton.ck-splitbutton_flatten:hover>.ck-splitbutton__arrow:not(.ck-disabled),.ck.ck-splitbutton.ck-splitbutton_flatten:hover>.ck-splitbutton__arrow:not(.ck-disabled):not(:hover){background-color:var(--ck-color-button-on-background)}.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open>.ck-splitbutton__action:not(.ck-disabled):after,.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open>.ck-splitbutton__arrow:not(.ck-disabled):after,.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open>.ck-splitbutton__arrow:not(.ck-disabled):not(:hover):after,.ck.ck-splitbutton.ck-splitbutton_flatten:hover>.ck-splitbutton__action:not(.ck-disabled):after,.ck.ck-splitbutton.ck-splitbutton_flatten:hover>.ck-splitbutton__arrow:not(.ck-disabled):after,.ck.ck-splitbutton.ck-splitbutton_flatten:hover>.ck-splitbutton__arrow:not(.ck-disabled):not(:hover):after{display:none}.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open:hover>.ck-splitbutton__action:not(.ck-disabled),.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open:hover>.ck-splitbutton__arrow:not(.ck-disabled),.ck.ck-splitbutton.ck-splitbutton_flatten.ck-splitbutton_open:hover>.ck-splitbutton__arrow:not(.ck-disabled):not(:hover){background-color:var(--ck-color-button-on-hover-background)}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Pt extends p{static get requires(){return[be]}static get pluginName(){return"ImageStyleUI"}static get isOfficialPlugin(){return!0}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=e.get("ImageStyleEditing"),n=Ot(i.normalizedStyles,this.localizedDefaultStylesTitles);for(const o of n)this._createButton(o);const s=Ot([...t.filter(Rt),...B.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const o of s)this._createDropdown(o,n)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,n=>{let s;const{defaultItem:o,items:r,title:l}=e,c=r.filter(d=>t.find(({name:h})=>Nt(h)===d)).map(d=>{const h=i.create(d);return d===o&&(s=h),h});r.length!==c.length&&B.warnInvalidStyle({dropdown:e});const m=Z(n,Ve),g=m.buttonView,u=g.arrowView;return di(m,c,{enableActiveItemFocusOnDropdownOpen:!0}),g.set({label:Ft(l,s.label),class:null,tooltip:!0}),u.unbind("label"),u.set({label:l}),g.bind("icon").toMany(c,"isOn",(...d)=>{const h=d.findIndex(A);return h<0?s.icon:c[h].icon}),g.bind("label").toMany(c,"isOn",(...d)=>{const h=d.findIndex(A);return Ft(l,h<0?s.label:c[h].label)}),g.bind("isOn").toMany(c,"isOn",(...d)=>d.some(A)),g.bind("class").toMany(c,"isOn",(...d)=>d.some(A)?"ck-splitbutton_flatten":void 0),g.on("execute",()=>{c.some(({isOn:d})=>d)?m.isOpen=!m.isOpen:s.fire("execute")}),m.bind("isEnabled").toMany(c,"isEnabled",(...d)=>d.some(A)),this.listenTo(m,"execute",()=>{this.editor.editing.view.focus()}),m})}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(Nt(t),i=>{const n=this.editor.commands.get("imageStyle"),s=new I(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",o=>o===t),s.on("execute",this._executeCommand.bind(this,t)),s})}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function Ot(a,e){for(const t of a)e[t.title]&&(t.title=e[t.title]);return a}function Nt(a){return`imageStyle:${a}`}function Ft(a,e){return(a?a+": ":"")+e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class en extends p{static get requires(){return[be,Pt]}static get pluginName(){return"ImageStyle"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class tn extends p{static get requires(){return[ve,f]}static get pluginName(){return"ImageToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(ve),n=e.plugins.get("ImageUtils");i.register("image",{ariaLabel:t("Image toolbar"),items:nn(e.config.get("image.toolbar")||[]),getRelatedElement:s=>n.getClosestSelectedImageWidget(s)})}}function nn(a){return a.map(e=>Rt(e)?e.name:e)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class on extends p{static get requires(){return[M,f]}static get pluginName(){return"PictureEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:["sources"]}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:["sources"]}),this._setupConversion(),this._setupImageUploadEditingIntegration()}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("upcast").add(He(i)),t.for("downcast").add(Ge(i))}_setupImageUploadEditingIntegration(){const e=this.editor;if(!e.plugins.has("ImageUploadEditing"))return;const t=e.plugins.get("ImageUploadEditing");this.listenTo(t,"uploadComplete",(i,{imageElement:n,data:s})=>{const o=s.sources;o&&e.model.change(r=>{r.setAttributes({sources:o},n)})})}}export{Bi as AutoImage,Ai as Image,Ze as ImageBlock,re as ImageBlockEditing,Ti as ImageCaption,tt as ImageCaptionEditing,it as ImageCaptionUI,le as ImageCaptionUtils,xt as ImageCustomResizeUI,M as ImageEditing,Qe as ImageInline,Ye as ImageInlineEditing,qi as ImageInsert,E as ImageInsertUI,It as ImageInsertViaUrl,kt as ImageInsertViaUrlUI,L as ImageLoadObserver,ae as ImagePlaceholder,Gi as ImageResize,_t as ImageResizeButtons,me as ImageResizeEditing,vt as ImageResizeHandles,oe as ImageSizeAttributes,en as ImageStyle,St as ImageStyleCommand,be as ImageStyleEditing,Pt as ImageStyleUI,ie as ImageTextAlternative,Le as ImageTextAlternativeCommand,Me as ImageTextAlternativeEditing,$e as ImageTextAlternativeUI,tn as ImageToolbar,se as ImageTypeCommand,ft as ImageUpload,ht as ImageUploadEditing,rt as ImageUploadProgress,at as ImageUploadUI,f as ImageUtils,Ke as InsertImageCommand,on as PictureEditing,Je as ReplaceImageSourceCommand,wt as ResizeImageCommand,et as ToggleImageCaptionCommand,dt as UploadImageCommand,Vt as _IMAGE_DEFAULT_DROPDOWN_DEFINITIONS,Ut as _IMAGE_DEFAULT_ICONS,W as _IMAGE_DEFAULT_OPTIONS,Et as _ImageCustomResizeFormView,Xe as _ImageInsertFormView,bt as _ImageInsertUrlView,B as _ImageStyleUtils,We as _ImageTextAlternativeFormView,S as _checkIfImageWidthAndHeightStylesAreBothSet,ee as _createBlockImageViewElement,Fe as _createInlineImageViewElement,F as _determineImageTypeForInsertionAtSelection,U as _downcastImageAttribute,Ge as _downcastImageSourcesAttribute,ne as _downcastImageSrcsetAttribute,nt as _fetchLocalImage,D as _getImageBalloonPositionData,x as _getImageSizeValueIfInPx,te as _getImageViewElementMatcher,fe as _getSelectedImageEditorNodes,Ct as _getSelectedImagePossibleResizeRange,yt as _getSelectedImageWidthInUnits,ot as _isLocalImage,At as _modelToViewImageStyleAttribute,qe as _repositionImageContextualBalloon,pe as _tryCastImageDimensionsToUnit,he as _tryParseImageDimensionWithUnit,je as _upcastImageFigure,He as _upcastImagePicture,Tt as _viewToModelImageStyleAttribute,ce as createImageTypeRegExp,pt as isHtmlInDataTransfer};
