text: /*!
   * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
   * For licensing, see LICENSE.md.
   */
  window.CKEditor5=window.CKEditor5||{},window.CKEditor5.image=function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=32)}([function(e,t,i){e.exports=i(7)("./src/core.js")},function(e,t,i){e.exports=i(7)("./src/ui.js")},function(e,t,i){e.exports=i(7)("./src/utils.js")},function(e,t,i){e.exports=i(7)("./src/widget.js")},function(e,t,i){"use strict";var n,o=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},a=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),r=[];function s(e){for(var t=-1,i=0;i<r.length;i++)if(r[i].identifier===e){t=i;break}return t}function c(e,t){for(var i={},n=[],o=0;o<e.length;o++){var a=e[o],c=t.base?a[0]+t.base:a[0],l=i[c]||0,d="".concat(c," ").concat(l);i[c]=l+1;var u=s(d),m={css:a[1],media:a[2],sourceMap:a[3]};-1!==u?(r[u].references++,r[u].updater(m)):r.push({identifier:d,updater:f(m,t),references:1}),n.push(d)}return n}function l(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var o=i.nc;o&&(n.nonce=o)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var r=a(e.insert||"head");if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function m(e,t,i,n){var o=i?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=u(t,o);else{var a=document.createTextNode(o),r=e.childNodes;r[t]&&e.removeChild(r[t]),r.length?e.insertBefore(a,r[t]):e.appendChild(a)}}function g(e,t,i){var n=i.css,o=i.media,a=i.sourceMap;if(o?e.setAttribute("media",o):e.removeAttribute("media"),a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var p=null,h=0;function f(e,t){var i,n,o;if(t.singleton){var a=h++;i=p||(p=l(t)),n=m.bind(null,i,a,!1),o=m.bind(null,i,a,!0)}else i=l(t),n=g.bind(null,i,t),o=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else o()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=o());var i=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<i.length;n++){var o=s(i[n]);r[o].references--}for(var a=c(e,t),l=0;l<i.length;l++){var d=s(i[l]);0===r[d].references&&(r[d].updater(),r.splice(d,1))}i=a}}}},function(e,t,i){e.exports=i(7)("./src/engine.js")},function(e,t,i){e.exports=i(7)("./src/upload.js")},function(e,t){e.exports=CKEditor5.dll},function(e,t,i){e.exports=i(7)("./src/clipboard.js")},function(e,t,i){e.exports=i(7)("./src/undo.js")},function(e,t,i){var n=i(4),o=i(11);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=".ck.ck-text-alternative-form{display:flex;flex-direction:row;flex-wrap:nowrap}.ck.ck-text-alternative-form .ck-labeled-field-view{display:inline-block}.ck.ck-text-alternative-form .ck-label{display:none}@media screen and (max-width:600px){.ck.ck-text-alternative-form{flex-wrap:wrap}.ck.ck-text-alternative-form .ck-labeled-field-view{flex-basis:100%}.ck.ck-text-alternative-form .ck-button{flex-basis:50%}}"},function(e,t,i){var n=i(4),o=i(13);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports='.ck-vertical-form .ck-button:after{content:"";width:0;position:absolute;right:-1px;top:var(--ck-spacing-small);bottom:var(--ck-spacing-small);z-index:1}@media screen and (max-width:600px){.ck.ck-responsive-form .ck-button:after{content:"";width:0;position:absolute;right:-1px;top:var(--ck-spacing-small);bottom:var(--ck-spacing-small);z-index:1}}.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-text-width)*0.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-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:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){padding:var(--ck-spacing-standard);margin-top:var(--ck-spacing-large);border-radius:0;border:0;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}.ck.ck-responsive-form>.ck-button:nth-last-child(2):after,[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)}}'},function(e,t,i){var n=i(4),o=i(15);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=".ck-content .image{display:table;clear:both;text-align:center;margin:1em auto}.ck-content .image img{display:block;margin:0 auto;max-width:100%;min-width:50px}.ck.ck-editor__editable .image>figcaption.ck-placeholder:before{position:static}"},function(e,t,i){var n=i(4),o=i(17);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=".ck-content .image>figcaption{display:table-caption;caption-side:bottom;word-break:break-word;color:#333;background-color:#f7f7f7;padding:.6em;font-size:.75em;outline-offset:-1px}"},function(e,t,i){var n=i(4),o=i(19);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=".ck.ck-editor__editable .image{position:relative}.ck.ck-editor__editable .image .ck-progress-bar{position:absolute;top:0;left:0}.ck.ck-editor__editable .image.ck-appear{animation:fadeIn .7s}.ck.ck-editor__editable .image .ck-progress-bar{height:2px;width:0;background:var(--ck-color-upload-bar-background);transition:width .1s}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}"},function(e,t,i){var n=i(4),o=i(21);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports='.ck-image-upload-complete-icon{display:block;position:absolute;top:10px;right:10px;border-radius:50%}.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:20px;--ck-image-upload-icon-width:2px}.ck-image-upload-complete-icon{width:var(--ck-image-upload-icon-size);height:var(--ck-image-upload-icon-size);opacity:0;background:var(--ck-color-image-upload-icon-background);animation-name:ck-upload-complete-icon-show,ck-upload-complete-icon-hide;animation-fill-mode:forwards,forwards;animation-duration:.5s,.5s;font-size:var(--ck-image-upload-icon-size);animation-delay:0ms,3s}.ck-image-upload-complete-icon:after{left:25%;top:50%;opacity:0;height:0;width:0;transform:scaleX(-1) rotate(135deg);transform-origin:left top;border-top:var(--ck-image-upload-icon-width) solid var(--ck-color-image-upload-icon);border-right:var(--ck-image-upload-icon-width) solid var(--ck-color-image-upload-icon);animation-name:ck-upload-complete-icon-check;animation-duration:.5s;animation-delay:.5s;animation-fill-mode:forwards;box-sizing:border-box}@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%{opacity:1;width:0;height:0}33%{width:.3em;height:0}to{opacity:1;width:.3em;height:.45em}}'},function(e,t,i){var n=i(4),o=i(23);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports='.ck .ck-upload-placeholder-loader{position:absolute;display:flex;align-items:center;justify-content:center;top:0;left:0}.ck .ck-upload-placeholder-loader:before{content:"";position:relative}:root{--ck-color-upload-placeholder-loader:#b3b3b3;--ck-upload-placeholder-loader-size:32px}.ck .ck-image-upload-placeholder{width:100%;margin:0}.ck .ck-upload-placeholder-loader{width:100%;height:100%}.ck .ck-upload-placeholder-loader:before{width:var(--ck-upload-placeholder-loader-size);height:var(--ck-upload-placeholder-loader-size);border-radius:50%;border-top:3px solid var(--ck-color-upload-placeholder-loader);border-right:2px solid transparent;animation:ck-upload-placeholder-loader 1s linear infinite}@keyframes ck-upload-placeholder-loader{to{transform:rotate(1turn)}}'},function(e,t,i){var n=i(4),o=i(25);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=".ck.ck-image-insert-form:focus{outline:none}.ck.ck-form__row{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between}.ck.ck-form__row>:not(.ck-label){flex-grow:1}.ck.ck-form__row.ck-image-insert-form__action-row{margin-top:var(--ck-spacing-standard)}.ck.ck-form__row.ck-image-insert-form__action-row .ck-button-cancel,.ck.ck-form__row.ck-image-insert-form__action-row .ck-button-save{justify-content:center}.ck.ck-form__row.ck-image-insert-form__action-row .ck-button .ck-button__label{color:var(--ck-color-text)}"},function(e,t,i){var n=i(4),o=i(27);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=".ck.ck-image-insert__panel{padding:var(--ck-spacing-large)}.ck.ck-image-insert__ck-finder-button{display:block;width:100%;margin:var(--ck-spacing-standard) auto;border:1px solid #ccc;border-radius:var(--ck-border-radius)}.ck.ck-splitbutton>.ck-file-dialog-button.ck-button{padding:0;margin:0;border:none}"},function(e,t,i){var n=i(4),o=i(29);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=".ck-content .image.image_resized{max-width:100%;display:block;box-sizing:border-box}.ck-content .image.image_resized img{width:100%}.ck-content .image.image_resized>figcaption{display:block}[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}"},function(e,t,i){var n=i(4),o=i(31);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,a);e.exports=o.locals||{}},function(e,t){e.exports=":root{--ck-image-style-spacing:1.5em}.ck-content .image-style-side{float:right;margin-left:var(--ck-image-style-spacing);max-width:50%}.ck-content .image-style-align-left{float:left;margin-right:var(--ck-image-style-spacing)}.ck-content .image-style-align-center{margin-left:auto;margin-right:auto}.ck-content .image-style-align-right{float:right;margin-left:var(--ck-image-style-spacing)}"},function(e,t,i){"use strict";i.r(t),i.d(t,"AutoImage",(function(){return f})),i.d(t,"Image",(function(){return A})),i.d(t,"ImageEditing",(function(){return v})),i.d(t,"ImageCaption",(function(){return F})),i.d(t,"ImageCaptionEditing",(function(){return j})),i.d(t,"ImageInsert",(function(){return oe})),i.d(t,"ImageInsertUI",(function(){return ne})),i.d(t,"ImageResize",(function(){return ue})),i.d(t,"ImageResizeButtons",(function(){return ce})),i.d(t,"ImageResizeEditing",(function(){return re})),i.d(t,"ImageResizeHandles",(function(){return de})),i.d(t,"ImageStyle",(function(){return ve})),i.d(t,"ImageStyleEditing",(function(){return we})),i.d(t,"ImageStyleUI",(function(){return ke})),i.d(t,"ImageTextAlternative",(function(){return E})),i.d(t,"ImageTextAlternativeEditing",(function(){return x})),i.d(t,"ImageTextAlternativeUI",(function(){return V})),i.d(t,"ImageToolbar",(function(){return ye})),i.d(t,"ImageUpload",(function(){return Z})),i.d(t,"ImageUploadEditing",(function(){return Q})),i.d(t,"ImageUploadProgress",(function(){return q})),i.d(t,"ImageUploadUI",(function(){return M}));var n=i(0),o=i(8),a=i(5),r=i(9),s=i(2),c=i(3);function l(e){return!!e.getCustomProperty("image")&&Object(c.isWidget)(e)}function d(e){const t=e.getSelectedElement();return t&&l(t)?t:null}function u(e){return!!e&&e.is("element","image")}function m(e,t={},i=null){e.change(n=>{const o=n.createElement("image",t),a=i||Object(c.findOptimalInsertionPosition)(e.document.selection,e);e.insertContent(o,a),o.parent&&n.setSelection(o,"on")})}function g(e){const t=e.schema,i=e.document.selection;return function(e,t,i){const n=function(e,t){const i=Object(c.findOptimalInsertionPosition)(e,t).parent;if(i.isEmpty&&!i.is("element","$root"))return i.parent;return i}(e,i);return t.checkChild(n,"image")}(i,t,e)&&!Object(c.checkSelectionOnObject)(i,t)&&function(e){return[...e.focus.getAncestors()].every(e=>!e.is("element","image"))}(i)}function p(e){const t=[];for(const i of e.getChildren())t.push(i),i.is("element")&&t.push(...i.getChildren());return t.find(e=>e.is("element","img"))}const h=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 f extends n.Plugin{static get requires(){return[o.Clipboard,r.Undo]}static get pluginName(){return"AutoImage"}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document;this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",()=>{const e=t.selection.getFirstRange(),i=a.LivePosition.fromPosition(e.start);i.stickiness="toPrevious";const n=a.LivePosition.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",()=>{this._embedImageBetweenPositions(i,n),i.detach(),n.detach()},{priority:"high"})}),e.commands.get("undo").on("execute",()=>{this._timeoutId&&(s.global.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedImageBetweenPositions(e,t){const i=this.editor,n=new a.LiveRange(e,t),o=n.getWalker({ignoreElementEnd:!0});let r="";for(const e of o)e.item.is("$textProxy")&&(r+=e.item.data);r=r.trim(),r.match(h)?(this._positionToInsert=a.LivePosition.fromPosition(e),this._timeoutId=s.global.window.setTimeout(()=>{i.commands.get("insertImage").isEnabled?i.model.change(e=>{let t;this._timeoutId=null,e.remove(n),n.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert.toPosition()),m(i.model,{src:r},t),this._positionToInsert.detach(),this._positionToInsert=null}):n.detach()},100)):n.detach()}}class b extends a.Observer{observe(e){this.listenTo(e,"load",(e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)},{useCapture:!0})}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}function w(e){return i=>{i.on(`attribute:${e}:image`,t)};function t(e,t,i){if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=p(i.mapper.toViewElement(t.item));n.setAttribute(t.attributeKey,t.attributeNewValue||"",o)}}class k extends n.Command{refresh(){this.isEnabled=g(this.editor.model)}execute(e){const t=this.editor.model;for(const i of Object(s.toArray)(e.source))m(t,{src:i})}}class v extends n.Plugin{static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;e.editing.view.addObserver(b),t.register("image",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["alt","src","srcset"]}),n.for("dataDowncast").elementToElement({model:"image",view:(e,{writer:t})=>y(t)}),n.for("editingDowncast").elementToElement({model:"image",view:(e,{writer:t})=>function(e,t,i){return t.setCustomProperty("image",!0,e),Object(c.toWidget)(e,t,{label:function(){const t=p(e).getAttribute("alt");return t?`${t} ${i}`:i}})}(y(t),t,i("image widget"))}),n.for("downcast").add(w("src")).add(w("alt")).add(function(){return t=>{t.on("attribute:srcset:image",e)};function e(e,t,i){if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=p(i.mapper.toViewElement(t.item));if(null===t.attributeNewValue){const e=t.attributeOldValue;e.data&&(n.removeAttribute("srcset",o),n.removeAttribute("sizes",o),e.width&&n.removeAttribute("width",o))}else{const e=t.attributeNewValue;e.data&&(n.setAttribute("srcset",e.data,o),n.setAttribute("sizes","100vw",o),e.width&&n.setAttribute("width",e.width,o))}}}()),n.for("upcast").elementToElement({view:{name:"img",attributes:{src:!0}},model:(e,{writer:t})=>t.createElement("image",{src:e.getAttribute("src")})}).attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}}).add(function(){return t=>{t.on("element:figure",e)};function e(e,t,i){if(!i.consumable.test(t.viewItem,{name:!0,classes:"image"}))return;const n=p(t.viewItem);if(!n||!n.hasAttribute("src")||!i.consumable.test(n,{name:!0}))return;const o=i.convertItem(n,t.modelCursor),a=Object(s.first)(o.modelRange.getItems());a&&(i.convertChildren(t.viewItem,a),i.updateConversionResult(a,t))}}());const o=new k(e);e.commands.add("insertImage",o),e.commands.add("imageInsert",o)}}function y(e){const t=e.createEmptyElement("img"),i=e.createContainerElement("figure",{class:"image"});return e.insert(e.createPositionAt(i,0),t),i}class _ extends n.Command{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=u(e),u(e)&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor.model,i=t.document.selection.getSelectedElement();t.change(t=>{t.setAttribute("alt",e.newValue,i)})}}class x extends n.Plugin{static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new _(this.editor))}}var I=i(1);i(10),i(12);class C extends I.View{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),n.icons.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),n.icons.cancel,"ck-button-cancel","cancel"),this._focusables=new I.ViewCollection,this._focusCycler=new I.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]}),Object(I.injectCssTransitionDisabler)(this)}render(){super.render(),this.keystrokes.listenTo(this.element),Object(I.submitHandler)({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)})}_createButton(e,t,i,n){const o=new I.ButtonView(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createLabeledInputView(){const e=this.locale.t,t=new I.LabeledFieldView(this.locale,I.createLabeledInputText);return t.label=e("Text alternative"),t}}function T(e){const t=e.editing.view,i=I.BalloonPanelView.defaultPositions;return{target:t.domConverter.viewToDom(t.document.selection.getSelectedElement()),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast]}}class V extends n.Plugin{static get requires(){return[I.ContextualBalloon]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",i=>{const o=e.commands.get("imageTextAlternative"),a=new I.ButtonView(i);return a.set({label:t("Change image text alternative"),icon:n.icons.lowVision,tooltip:!0}),a.bind("isEnabled").to(o,"isEnabled"),this.listenTo(a,"execute",()=>{this._showForm()}),a})}_createForm(){const e=this.editor,t=e.editing.view.document;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new C(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._form.keystrokes.set("Esc",(e,t)=>{this._hideForm(!0),t()}),this.listenTo(e.ui,"update",()=>{d(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(d(e.editing.view.document.selection)){const i=T(e);t.updatePosition(i)}}(e):this._hideForm(!0)}),Object(I.clickOutsideHandler)({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;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:T(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e){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.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}class E extends n.Plugin{static get requires(){return[x,V]}static get pluginName(){return"ImageTextAlternative"}}i(14);class A extends n.Plugin{static get requires(){return[v,c.Widget,E]}static get pluginName(){return"Image"}isImageWidget(e){return l(e)}}function S(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}function z(e){const t=e.parent;return"figcaption"==e.name&&t&&"figure"==t.name&&t.hasClass("image")?{name:!0}:null}class j extends n.Plugin{static get pluginName(){return"ImageCaptionEditing"}init(){const e=this.editor,t=e.editing.view,i=e.model.schema,n=e.data,o=e.editing,r=e.t;i.isRegistered("caption")?i.extend("caption",{allowIn:"image"}):i.register("caption",{allowIn:"image",allowContentOf:"$block",isLimit:!0}),e.model.document.registerPostFixer(e=>this._insertMissingModelCaptionElement(e)),e.conversion.for("upcast").elementToElement({view:z,model:"caption"});n.downcastDispatcher.on("insert:caption",P(e=>e.createContainerElement("figcaption"),!1));const s=function(e,t){return i=>{const n=i.createEditableElement("figcaption");return i.setCustomProperty("imageCaption",!0,n),Object(a.enablePlaceholder)({view:e,element:n,text:t}),Object(c.toWidgetEditable)(n,i)}}(t,r("Enter image caption"));o.downcastDispatcher.on("insert:caption",P(s)),o.downcastDispatcher.on("insert",this._fixCaptionVisibility(e=>e.item),{priority:"high"}),o.downcastDispatcher.on("remove",this._fixCaptionVisibility(e=>e.position.parent),{priority:"high"}),t.document.registerPostFixer(e=>this._updateCaptionVisibility(e))}_updateCaptionVisibility(e){const t=this.editor.editing.mapper,i=this._lastSelectedCaption;let n;const o=this.editor.model.document.selection,a=o.getSelectedElement();if(a&&a.is("element","image")){const e=S(a);n=t.toViewElement(e)}const r=R(o.getFirstPosition().parent);if(r&&(n=t.toViewElement(r)),n&&!this.editor.isReadOnly)return i?(i===n||(O(i,e),this._lastSelectedCaption=n),B(n,e)):(this._lastSelectedCaption=n,B(n,e));if(i){const t=O(i,e);return this._lastSelectedCaption=null,t}return!1}_fixCaptionVisibility(e){return(t,i,n)=>{const o=R(e(i)),a=this.editor.editing.mapper,r=n.writer;if(o){const e=a.toViewElement(o);e&&(o.childCount?r.removeClass("ck-hidden",e):r.addClass("ck-hidden",e))}}}_insertMissingModelCaptionElement(e){const t=this.editor.model,i=t.document.differ.getChanges(),n=[];for(const e of i)if("insert"==e.type&&"$text"!=e.name){const i=e.position.nodeAfter;if(i.is("element","image")&&!S(i)&&n.push(i),!i.is("element","image")&&i.childCount)for(const e of t.createRangeIn(i).getItems())e.is("element","image")&&!S(e)&&n.push(e)}for(const t of n)e.appendElement("caption",t);return!!n.length}}function P(e,t=!0){return(i,n,o)=>{const a=n.item;if((a.childCount||t)&&u(a.parent)){if(!o.consumable.consume(n.item,"insert"))return;const t=o.mapper.toViewElement(n.range.start.parent),i=e(o.writer),r=o.writer;a.childCount||r.addClass("ck-hidden",i),function(e,t,i,n){const o=n.writer.createPositionAt(i,"end");n.writer.insert(o,e),n.mapper.bindElements(t,e)}(i,n.item,t,o)}}}function R(e){const t=e.getAncestors({includeSelf:!0}).find(e=>"caption"==e.name);return t&&t.parent&&"image"==t.parent.name?t:null}function O(e,t){return!e.childCount&&!e.hasClass("ck-hidden")&&(t.addClass("ck-hidden",e),!0)}function B(e,t){return!!e.hasClass("ck-hidden")&&(t.removeClass("ck-hidden",e),!0)}i(16);class F extends n.Plugin{static get requires(){return[j]}static get pluginName(){return"ImageCaption"}}var N=i(6);function U(e){const t=e.map(e=>e.replace("+","\\+"));return new RegExp(`^image\\/(${t.join("|")})$`)}function L(e){return new Promise((t,i)=>{const n=e.getAttribute("src");fetch(n).then(e=>e.blob()).then(e=>{const i=D(e,n),o=i.replace("image/",""),a=new File([e],"image."+o,{type:i});t(a)}).catch(e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise((t,i)=>{const n=s.global.document.createElement("img");n.addEventListener("load",()=>{const e=s.global.document.createElement("canvas");e.width=n.width,e.height=n.height;e.getContext("2d").drawImage(n,0,0),e.toBlob(e=>e?t(e):i())}),n.addEventListener("error",()=>i()),n.src=e})}(e).then(t=>{const i=D(t,e),n=i.replace("image/","");return new File([t],"image."+n,{type:i})})}(n).then(t).catch(i):i(e))})}function D(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class M extends n.Plugin{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=i=>{const o=new N.FileDialogButtonView(i),a=e.commands.get("uploadImage"),r=e.config.get("image.upload.types"),s=U(r);return o.set({acceptedType:r.map(e=>"image/"+e).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:t("Insert image"),icon:n.icons.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(a),o.on("done",(t,i)=>{const n=Array.from(i).filter(e=>s.test(e.type));n.length&&e.execute("uploadImage",{file:n})}),o};e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i)}}i(18),i(20),i(22);class q extends n.Plugin{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.placeholder="data:image/svg+xml;utf8,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 700 250"><rect rx="4"/></svg>')}init(){this.editor.editing.downcastDispatcher.on("attribute:uploadStatus:image",(...e)=>this.uploadStatusChange(...e))}uploadStatusChange(e,t,i){const n=this.editor,o=t.item,a=o.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get(N.FileRepository),s=a?t.attributeNewValue:null,c=this.placeholder,l=n.editing.mapper.toViewElement(o),d=i.writer;if("reading"==s)return W(l,d),void $(c,l,d);if("uploading"==s){const e=r.loaders.get(a);return W(l,d),void(e?(H(l,d),function(e,t,i,n){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),i.on("change:uploadedPercent",(e,t,i)=>{n.change(e=>{e.setStyle("width",i+"%",o)})})}(l,d,e,n.editing.view),function(e,t,i){if(i.data){const n=p(e);t.setAttribute("src",i.data,n)}}(l,d,e)):$(c,l,d))}"complete"==s&&r.loaders.get(a)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout(()=>{i.change(e=>e.remove(e.createRangeOn(n)))},3e3)}(l,d,n.editing.view),function(e,t){G(e,t,"progressBar")}(l,d),H(l,d),function(e,t){t.removeClass("ck-appear",e)}(l,d)}}function W(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function $(e,t,i){t.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",t);const n=p(t);n.getAttribute("src")!==e&&i.setAttribute("src",e,n),K(t,"placeholder")||i.insert(i.createPositionAfter(n),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(i))}function H(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),G(e,t,"placeholder")}function K(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function G(e,t,i){const n=K(e,i);n&&t.remove(t.createRangeOn(n))}class J extends n.Command{refresh(){const e=this.editor.model.document.selection.getSelectedElement(),t=e&&"image"===e.name||!1;this.isEnabled=g(this.editor.model)||t}execute(e){const t=this.editor,i=t.model,n=t.plugins.get(N.FileRepository);for(const t of Object(s.toArray)(e.file))X(i,n,t)}}function X(e,t,i){const n=t.createLoader(i);n&&m(e,{uploadId:n.id})}class Q extends n.Plugin{static get requires(){return[N.FileRepository,I.Notification,o.ClipboardPipeline]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}})}init(){const e=this.editor,t=e.model.document,i=e.model.schema,n=e.conversion,o=e.plugins.get(N.FileRepository),r=U(e.config.get("image.upload.types"));i.extend("image",{allowAttributes:["uploadId","uploadStatus"]});const s=new J(e);e.commands.add("uploadImage",s),e.commands.add("imageUpload",s),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",(t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const o=Array.from(i.dataTransfer.files).filter(e=>!!e&&r.test(e.type));o.length&&(t.stop(),e.model.change(t=>{i.targetRanges&&t.setSelection(i.targetRanges.map(t=>e.editing.mapper.toModelRange(t))),e.model.enqueueChange("default",()=>{e.execute("uploadImage",{file:o})})}))}),this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",(t,i)=>{const n=Array.from(e.editing.view.createRangeIn(i.content)).filter(e=>{return!(!(t=e.item).is("element","img")||!t.getAttribute("src"))&&(t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||t.getAttribute("src").match(/^blob:/g))&&!e.item.getAttribute("uploadProcessed");var t}).map(e=>({promise:L(e.item),imageElement:e.item}));if(!n.length)return;const r=new a.UpcastWriter(e.editing.view.document);for(const e of n){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=o.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}}),e.editing.view.document.on("dragover",(e,t)=>{t.preventDefault()}),t.on("change",()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0});for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,n="$graveyard"==t.position.root.rootName;for(const t of Y(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=o.loaders.get(e);i&&(n?i.abort():"idle"==i.status&&this._readAndUpload(i,t))}}}),this.on("uploadComplete",(e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change(e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e)})},{priority:"low"})}_readAndUpload(e,t){const i=this.editor,n=i.model,o=i.locale.t,a=i.plugins.get(N.FileRepository),r=i.plugins.get(I.Notification);return n.enqueueChange("transparent",e=>{e.setAttribute("uploadStatus","reading",t)}),e.read().then(()=>{const o=e.upload();if(s.env.isSafari){const e=p(i.editing.mapper.toViewElement(t));i.editing.view.once("render",()=>{if(!e.parent)return;const t=i.editing.view.domConverter.mapViewToDom(e.parent);if(!t)return;const n=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=n})}return n.enqueueChange("transparent",e=>{e.setAttribute("uploadStatus","uploading",t)}),o}).then(e=>{n.enqueueChange("transparent",i=>{i.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:e,imageElement:t})}),c()}).catch(i=>{if("error"!==e.status&&"aborted"!==e.status)throw i;"error"==e.status&&i&&r.showWarning(i,{title:o("Upload failed"),namespace:"upload"}),c(),n.enqueueChange("transparent",e=>{e.remove(t)})});function c(){n.enqueueChange("transparent",e=>{e.removeAttribute("uploadId",t),e.removeAttribute("uploadStatus",t)}),a.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const o=Object.keys(e).filter(e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0}).map(t=>`${e[t]} ${t}w`).join(", ");""!=o&&i.setAttribute("srcset",{data:o,width:n},t)}}function Y(e,t){return Array.from(e.model.createRangeOn(t)).filter(e=>e.item.is("element","image")).map(e=>e.item)}class Z extends n.Plugin{static get pluginName(){return"ImageUpload"}static get requires(){return[Q,M,q]}}i(24);class ee extends I.View{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach(e=>this.children.add(e)),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")],role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}i(26);class te extends I.View{constructor(e,t){super(e);const{insertButtonView:i,cancelButtonView:n}=this._createActionButtons(e);if(this.insertButtonView=i,this.cancelButtonView=n,this.dropdownView=this._createDropdownView(e),this.set("imageURLInputValue",""),this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this._focusables=new I.ViewCollection,this._focusCycler=new I.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.set("_integrations",new s.Collection),t)for(const[e,i]of Object.entries(t))"insertImageViaUrl"===e&&(i.fieldView.bind("value").to(this,"imageURLInputValue",e=>e||""),i.fieldView.on("input",()=>{this.imageURLInputValue=i.fieldView.element.value.trim()})),i.name=e,this._integrations.add(i);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:"-1"},children:[...this._integrations,new ee(e,{children:[this.insertButtonView,this.cancelButtonView],class:"ck-image-insert-form__action-row"})]})}render(){super.render(),Object(I.submitHandler)({view:this});const e=[...this._integrations,this.insertButtonView,this.cancelButtonView];e.forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element);const t=e=>e.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t),this.listenTo(e[0].element,"selectstart",(e,t)=>{t.stopPropagation()},{priority:"high"})}getIntegration(e){return this._integrations.find(t=>t.name===e)}_createDropdownView(e){const t=e.t,i=Object(I.createDropdown)(e,I.SplitButtonView),o=i.buttonView,a=i.panelView;return o.set({label:t("Insert image"),icon:n.icons.image,tooltip:!0}),a.extendTemplate({attributes:{class:"ck-image-insert__panel"}}),i}_createActionButtons(e){const t=e.t,i=new I.ButtonView(e),o=new I.ButtonView(e);return i.set({label:t("Insert"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0,isEnabled:this.imageURLInputValue}),o.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",withText:!0}),i.bind("isEnabled").to(this,"imageURLInputValue",e=>!!e),i.delegate("execute").to(this,"submit"),o.delegate("execute").to(this,"cancel"),{insertButtonView:i,cancelButtonView:o}}focus(){this._focusCycler.focusFirst()}}function ie(e){const t=e.t,i=new I.LabeledFieldView(e,I.createLabeledInputText);return i.set({label:t("Insert image via URL")}),i.fieldView.placeholder="https://example.com/image.png",i}class ne extends n.Plugin{static get pluginName(){return"ImageInsertUI"}init(){const e=this.editor,t=e=>this._createDropdownView(e);e.ui.componentFactory.add("insertImage",t),e.ui.componentFactory.add("imageInsert",t)}_createDropdownView(e){const t=this.editor,i=new te(e,function(e){const t=e.config.get("image.insert.integrations"),i=e.plugins.get("ImageInsertUI"),n={insertImageViaUrl:ie(e.locale)};if(!t)return n;if(t.find(e=>"openCKFinder"===e)&&e.ui.componentFactory.has("ckfinder")){const t=e.ui.componentFactory.create("ckfinder");t.set({withText:!0,class:"ck-image-insert__ck-finder-button"}),t.delegate("execute").to(i,"cancel"),n.openCKFinder=t}return t.reduce((t,i)=>(n[i]?t[i]=n[i]:e.ui.componentFactory.has(i)&&(t[i]=e.ui.componentFactory.create(i)),t),{})}(t)),n=t.commands.get("uploadImage"),o=i.dropdownView,a=o.buttonView;return a.actionView=t.ui.componentFactory.create("uploadImage"),a.actionView.extendTemplate({attributes:{class:"ck ck-button ck-splitbutton__action"}}),this._setUpDropdown(o,i,n)}_setUpDropdown(e,t,i){const n=this.editor,o=n.t,a=t.insertButtonView,r=t.getIntegration("insertImageViaUrl"),s=e.panelView;function c(){n.editing.view.focus(),e.isOpen=!1}return e.bind("isEnabled").to(i),e.buttonView.once("open",()=>{s.children.add(t)}),e.on("change:isOpen",()=>{const i=n.model.document.selection.getSelectedElement();e.isOpen&&(t.focus(),u(i)?(t.imageURLInputValue=i.getAttribute("src"),a.label=o("Update"),r.label=o("Update image URL")):(t.imageURLInputValue="",a.label=o("Insert"),r.label=o("Insert image via URL")))},{priority:"low"}),t.delegate("submit","cancel").to(e),this.delegate("cancel").to(e),e.on("submit",()=>{c(),function(){const e=n.model.document.selection.getSelectedElement();u(e)?n.model.change(i=>{i.setAttribute("src",t.imageURLInputValue,e),i.removeAttribute("srcset",e),i.removeAttribute("sizes",e)}):n.execute("insertImage",{source:t.imageURLInputValue})}()}),e.on("cancel",()=>{c()}),e}}class oe extends n.Plugin{static get pluginName(){return"ImageInsert"}static get requires(){return[Z,ne]}}class ae extends n.Command{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=u(e),e&&e.hasAttribute("width")?this.value={width:e.getAttribute("width"),height:null}:this.value=null}execute(e){const t=this.editor.model,i=t.document.selection.getSelectedElement();this.value={width:e.width,height:null},i&&t.change(t=>{t.setAttribute("width",e.width,i)})}}class re extends n.Plugin{static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{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 ae(e);this._registerSchema(),this._registerConverters(),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}_registerSchema(){this.editor.model.schema.extend("image",{allowAttributes:"width"}),this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0})}_registerConverters(){const e=this.editor;e.conversion.for("downcast").add(e=>e.on("attribute:width:image",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,o),n.addClass("image_resized",o)):(n.removeStyle("width",o),n.removeClass("image_resized",o))})),e.conversion.for("upcast").attributeToAttribute({view:{name:"figure",styles:{width:/.+/}},model:{key:"width",value:e=>e.getStyle("width")}})}}const se={small:n.icons.objectSizeSmall,medium:n.icons.objectSizeMedium,large:n.icons.objectSizeLarge,original:n.icons.objectSizeFull};class ce extends n.Plugin{static get requires(){return[re]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:o}=e,a=n?n+this._resizeUnit:null;t.ui.componentFactory.add(i,i=>{const n=new I.ButtonView(i),r=t.commands.get("resizeImage"),c=this._getOptionLabelValue(e,!0);if(!se[o])throw new s.CKEditorError("imageresizebuttons-missing-icon",t,e);return n.set({label:c,icon:se[o],tooltip:c,isToggleable:!0}),n.bind("isEnabled").to(this),n.bind("isOn").to(r,"value",le(a)),this.listenTo(n,"execute",()=>{t.execute("resizeImage",{width:a})}),n})}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find(e=>!e.value),o=o=>{const a=t.commands.get("resizeImage"),r=Object(I.createDropdown)(o,I.DropdownButtonView),s=r.buttonView;return s.set({tooltip:i("Resize image"),commandValue:n.value,icon:se.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button"}),s.bind("label").to(a,"value",e=>e&&e.width?e.width:this._getOptionLabelValue(n)),r.bind("isOn").to(a),r.bind("isEnabled").to(this),Object(I.addListToDropdown)(r,this._getResizeDropdownListItemDefinitions(e,a)),r.listView.ariaLabel=i("Image resize list"),this.listenTo(r,"execute",e=>{t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus()}),r};t.ui.componentFactory.add("resizeImage",o),t.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(e,t){const i=this.editor.t;return e.label?e.label:t?e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const i=new s.Collection;return e.map(e=>{const n=e.value?e.value+this._resizeUnit:null,o={type:"button",model:new I.Model({commandName:"resizeImage",commandValue:n,label:this._getOptionLabelValue(e),withText:!0,icon:null})};o.model.bind("isOn").to(t,"value",le(n)),i.add(o)}),i}}function le(e){return t=>null===e&&t===e||t&&t.width===e}class de extends n.Plugin{static get requires(){return[c.WidgetResize]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view;t.addObserver(b),this.listenTo(t.document,"imageLoaded",(i,n)=>{if(!n.target.matches("figure.image.ck-widget > img, figure.image.ck-widget > a > img"))return;const o=e.editing.view.domConverter.domToView(n.target).findAncestor("figure");let a=this.editor.plugins.get(c.WidgetResize).getResizerByViewElement(o);if(a)return void a.redraw();const r=e.editing.mapper.toModelElement(o);a=e.plugins.get(c.WidgetResize).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:r,viewElement:o,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:e=>e,isCentered(){const e=r.getAttribute("imageStyle");return!e||"full"==e||"alignCenter"==e},onCommit(t){e.execute("resizeImage",{width:t})}}),a.on("updateSize",()=>{o.hasClass("image_resized")||t.change(e=>{e.addClass("image_resized",o)})}),a.bind("isEnabled").to(this)})}}i(28);class ue extends n.Plugin{static get requires(){return[re,de,ce]}static get pluginName(){return"ImageResize"}}class me extends n.Command{constructor(e,t){super(e),this.defaultStyle=!1,this.styles=t.reduce((e,t)=>(e[t.name]=t,t.isDefault&&(this.defaultStyle=t.name),e),{})}refresh(){const e=this.editor.model.document.selection.getSelectedElement();if(this.isEnabled=u(e),e)if(e.hasAttribute("imageStyle")){const t=e.getAttribute("imageStyle");this.value=!!this.styles[t]&&t}else this.value=this.defaultStyle;else this.value=!1}execute(e){const t=e.value,i=this.editor.model,n=i.document.selection.getSelectedElement();i.change(e=>{this.styles[t].isDefault?e.removeAttribute("imageStyle",n):e.setAttribute("imageStyle",t,n)})}}function ge(e,t){for(const i of t)if(i.name===e)return i}const pe={full:{name:"full",title:"Full size image",icon:n.icons.objectFullWidth,isDefault:!0},side:{name:"side",title:"Side image",icon:n.icons.objectRight,className:"image-style-side"},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:n.icons.objectLeft,className:"image-style-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:n.icons.objectCenter,className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:n.icons.objectRight,className:"image-style-align-right"}},he={full:n.icons.objectFullWidth,left:n.icons.objectLeft,right:n.icons.objectRight,center:n.icons.objectCenter};function fe(e=[]){return e.map(be)}function be(e){if("string"==typeof e){const t=e;pe[t]?e=Object.assign({},pe[t]):(Object(s.logWarning)("image-style-not-found",{name:t}),e={name:t})}else if(pe[e.name]){const t=pe[e.name],i=Object.assign({},e);for(const n in t)Object.prototype.hasOwnProperty.call(e,n)||(i[n]=t[n]);e=i}return"string"==typeof e.icon&&he[e.icon]&&(e.icon=he[e.icon]),e}class we extends n.Plugin{static get pluginName(){return"ImageStyleEditing"}init(){const e=this.editor,t=e.model.schema,i=e.data,n=e.editing;e.config.define("image.styles",["full","side"]);const o=fe(e.config.get("image.styles"));t.extend("image",{allowAttributes:"imageStyle"});const a=function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=ge(i.attributeNewValue,e),a=ge(i.attributeOldValue,e),r=n.mapper.toViewElement(i.item),s=n.writer;a&&s.removeClass(a.className,r),o&&s.addClass(o.className,r)}}(o);n.downcastDispatcher.on("attribute:imageStyle:image",a),i.downcastDispatcher.on("attribute:imageStyle:image",a),i.upcastDispatcher.on("element:figure",function(e){const t=e.filter(e=>!e.isDefault);return(e,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,a=Object(s.first)(i.modelRange.getItems());if(!a||n.schema.checkAttribute(a,"imageStyle"))for(const e of t)n.consumable.consume(o,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,a)}}(o),{priority:"low"}),e.commands.add("imageStyle",new me(e,o))}}i(30);class ke extends n.Plugin{static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"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=function(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}(fe(this.editor.config.get("image.styles")),this.localizedDefaultStylesTitles);for(const t of e)this._createButton(t)}_createButton(e){const t=this.editor,i="imageStyle:"+e.name;t.ui.componentFactory.add(i,i=>{const n=t.commands.get("imageStyle"),o=new I.ButtonView(i);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",t=>t===e.name),this.listenTo(o,"execute",()=>{t.execute("imageStyle",{value:e.name}),t.editing.view.focus()}),o})}}class ve extends n.Plugin{static get requires(){return[we,ke]}static get pluginName(){return"ImageStyle"}}class ye extends n.Plugin{static get requires(){return[c.WidgetToolbarRepository]}static get pluginName(){return"ImageToolbar"}afterInit(){const e=this.editor,t=e.t;e.plugins.get(c.WidgetToolbarRepository).register("image",{ariaLabel:t("Image toolbar"),items:e.config.get("image.toolbar")||[],getRelatedElement:d})}}}]);