/*!
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"%0 of %1","Align cell text to the bottom":"Align cell text to the bottom","Align cell text to the center":"Align cell text to the center","Align cell text to the left":"Align cell text to the left","Align cell text to the middle":"Align cell text to the middle","Align cell text to the right":"Align cell text to the right","Align cell text to the top":"Align cell text to the top","Align table to the left":"Align table to the left","Align table to the right":"Align table to the right",Alignment:"Alignment",Aquamarine:"Aquamarine",Background:"Background",Big:"Big",Black:"Black","Block quote":"Block quote",Blue:"Blue",Bold:"Bold",Border:"Border","Bulleted List":"Bulleted List",Cancel:"Cancel","Cannot upload file:":"Cannot upload file:","Cell properties":"Cell properties","Center table":"Center table","Centered image":"Centered image","Change image text alternative":"Change image text alternative","Choose heading":"Choose heading",Code:"Code",Color:"Color","Color picker":"Color picker",Column:"Column",Dashed:"Dashed","Decrease indent":"Decrease indent",Default:"Default","Delete column":"Delete column","Delete row":"Delete row","Dim grey":"Dim grey",Dimensions:"Dimensions","Document colors":"Document colors",Dotted:"Dotted",Double:"Double",Downloadable:"Downloadable","Dropdown toolbar":"Dropdown toolbar","Edit block":"Edit block","Edit link":"Edit link","Editor toolbar":"Editor toolbar","Enter image caption":"Enter image caption","Font Background Color":"Font Background Color","Font Color":"Font Color","Font Family":"Font Family","Font Size":"Font Size","Full size image":"Full size image",Green:"Green",Grey:"Grey",Groove:"Groove","Header column":"Header column","Header row":"Header row",Heading:"Heading","Heading 1":"Heading 1","Heading 2":"Heading 2","Heading 3":"Heading 3","Heading 4":"Heading 4","Heading 5":"Heading 5","Heading 6":"Heading 6",Height:"Height","Horizontal line":"Horizontal line","Horizontal text alignment toolbar":"Horizontal text alignment toolbar",Huge:"Huge","Image resize list":"Image resize list","Image toolbar":"Image toolbar","image widget":"image widget","Increase indent":"Increase indent",Insert:"Insert","Insert code block":"Insert code block","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert image":"Insert image","Insert image via URL":"Insert image via URL","Insert paragraph after block":"Insert paragraph after block","Insert paragraph before block":"Insert paragraph before block","Insert row above":"Insert row above","Insert row below":"Insert row below","Insert table":"Insert table",Inset:"Inset",Italic:"Italic","Justify cell text":"Justify cell text","Left aligned image":"Left aligned image","Light blue":"Light blue","Light green":"Light green","Light grey":"Light grey",Link:"Link","Link URL":"Link URL","Merge cell down":"Merge cell down","Merge cell left":"Merge cell left","Merge cell right":"Merge cell right","Merge cell up":"Merge cell up","Merge cells":"Merge cells",Next:"Next",None:"None","Numbered List":"Numbered List","Open in a new tab":"Open in a new tab","Open link in new tab":"Open link in new tab",Orange:"Orange",Original:"Original",Outset:"Outset",Padding:"Padding",Paragraph:"Paragraph","Paste the image source URL.":"Paste the image source URL.","Plain text":"Plain text",Previous:"Previous",Purple:"Purple",Red:"Red",Redo:"Redo","Remove color":"Remove color","Resize image":"Resize image","Resize image to %0":"Resize image to %0","Resize image to the original size":"Resize image to the original size","Rich Text Editor, %0":"Rich Text Editor, %0",Ridge:"Ridge","Right aligned image":"Right aligned image",Row:"Row",Save:"Save","Select all":"Select all","Select column":"Select column","Select row":"Select row","Show more items":"Show more items","Side image":"Side image",Small:"Small",Solid:"Solid","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Strikethrough:"Strikethrough",Style:"Style",Subscript:"Subscript",Superscript:"Superscript","Table alignment toolbar":"Table alignment toolbar","Table cell text alignment":"Table cell text alignment","Table properties":"Table properties","Table toolbar":"Table toolbar","Text alternative":"Text alternative",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".','The value is invalid. Try "10px" or "2em" or simply "2".':'The value is invalid. Try "10px" or "2em" or simply "2".',"This link has no URL":"This link has no URL",Tiny:"Tiny","To-do List":"To-do List",Turquoise:"Turquoise",Underline:"Underline",Undo:"Undo",Unlink:"Unlink",Update:"Update","Upload failed":"Upload failed","Upload in progress":"Upload in progress","Vertical text alignment toolbar":"Vertical text alignment toolbar",White:"White","Widget toolbar":"Widget toolbar",Width:"Width",Yellow:"Yellow"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BalloonEditor=t():e.BalloonEditor=t()}(window,(function(){return function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=128)}([function(e,t,o){"use strict";o.d(t,"b",(function(){return n})),o.d(t,"a",(function(){return i}));class n extends Error{constructor(e,t,o){e=i(e),o&&(e+=" "+JSON.stringify(o)),super(e),this.name="CKEditorError",this.context=t,this.data=o}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const o=new n(e.message,t);throw o.stack=e.stack,o}}function i(e){const t=e.match(/^([^:]+):/);return t?e+` Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-${t[1]}\n`:e}},function(e,t,o){"use strict";var n,i=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},r=function(){var e={};return function(t){if(void 0===e[t]){var o=document.querySelector(t);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}e[t]=o}return e[t]}}(),s=[];function a(e){for(var t=-1,o=0;o
").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).indexOf("
")>-1&&(r=`
${r}
`),i=r),i=this._htmlDataProcessor.toView(i);const s=new lo(this,"inputTransformation");this.fire(s,{content:i,dataTransfer:n}),s.stop.called&&e.stop(),o.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(e,o)=>{if(!o.content.isEmpty){const n=this.editor.data,i=this.editor.model,r=n.toModel(o.content,"$clipboardHolder");if(0==r.childCount)return;if(function(e){if(e.childCount>1)return!1;return 0==[...e.getChild(0).getAttributeKeys()].length}(r)){const e=r.getChild(0);i.change(o=>{o.setAttributes(t.selection.getAttributes(),e)})}i.insertContent(r),e.stop()}},{priority:"low"}),this.listenTo(n,"copy",i,{priority:"low"}),this.listenTo(n,"cut",(t,o)=>{e.isReadOnly?o.preventDefault():i(t,o)},{priority:"low"}),this.listenTo(n,"clipboardOutput",(o,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this._htmlDataProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",function e(t){let o="";if(t.is("$text")||t.is("$textProxy"))o=t.data;else if(t.is("element","img")&&t.hasAttribute("alt"))o=t.getAttribute("alt");else{let n=null;for(const i of t.getChildren()){const t=e(i);n&&(n.is("containerElement")||i.is("containerElement"))&&(tm.includes(n.name)||tm.includes(i.name)?o+="\n":o+="\n\n"),o+=t,n=i}}return o}(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}class nm{constructor(e){this.document=e}createDocumentFragment(e){return new Ei(this.document,e)}createElement(e,t,o){return new Nn(this.document,e,t,o)}createText(e){return new No(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,o){return o._insertChild(e,t)}removeChildren(e,t,o){return o._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const o=e.parent;if(o){const n=o.getChildIndex(e);return this.removeChildren(n,1,o),this.insertChild(n,t,o),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const o=t.getChildIndex(e);this.remove(e),this.insertChild(o,e.getChildren(),t)}}rename(e,t){const o=new Nn(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,o)?o:null}setAttribute(e,t,o){o._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,o){y(e)&&void 0===o&&(o=t),o._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,o){o._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return ei._createAt(e,t)}createPositionAfter(e){return ei._createAfter(e)}createPositionBefore(e){return ei._createBefore(e)}createRange(e,t){return new ti(e,t)}createRangeOn(e){return ti._createOn(e)}createRangeIn(e){return ti._createIn(e)}createSelection(e,t,o){return new ii(e,t,o)}}class im extends Vd{refresh(){const e=this.editor.model.document.selection.getSelectedElement(),t=e&&"image"===e.name||!1;this.isEnabled=Fh(this.editor.model)||t}execute(e){const t=this.editor,o=t.model,n=t.plugins.get(xd);o.change(t=>{const i=Array.isArray(e.file)?e.file:[e.file];for(const e of i)rm(t,o,n,e)})}}function rm(e,t,o,n){const i=o.createLoader(n);i&&Bh(e,t,{uploadId:i.id})}class sm extends jl{static get requires(){return[xd,Xu,om]}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,o=e.model.schema,n=e.conversion,i=e.plugins.get(xd),r=Wu(e.config.get("image.upload.types"));o.extend("image",{allowAttributes:["uploadId","uploadStatus"]}),e.commands.add("imageUpload",new im(e)),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",(t,o)=>{if(n=o.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const i=Array.from(o.dataTransfer.files).filter(e=>!!e&&r.test(e.type)),s=o.targetRanges.map(t=>e.editing.mapper.toModelRange(t));e.model.change(o=>{o.setSelection(s),i.length&&(t.stop(),e.model.enqueueChange("default",()=>{e.execute("imageUpload",{file:i})}))})}),this.listenTo(e.plugins.get(om),"inputTransformation",(t,o)=>{const n=Array.from(e.editing.view.createRangeIn(o.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=>{return{promise:(t=e.item,new Promise((e,o)=>{const n=t.getAttribute("src");fetch(n).then(e=>e.blob()).then(t=>{const o=function(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}(t,n),i=o.replace("image/",""),r=new File([t],"image."+i,{type:o});e(r)}).catch(o)})),imageElement:e.item};var t});if(!n.length)return;const r=new nm(e.editing.view.document);for(const e of n){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=i.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 o=t.differ.getChanges({includeChangesInGraveyard:!0});for(const t of o)if("insert"==t.type&&"$text"!=t.name){const o=t.position.nodeAfter,n="$graveyard"==t.position.root.rootName;for(const t of am(e,o)){const e=t.getAttribute("uploadId");if(!e)continue;const o=i.loaders.get(e);o&&(n?o.abort():"idle"==o.status&&this._readAndUpload(o,t))}}})}_readAndUpload(e,t){const o=this.editor,n=o.model,i=o.locale.t,r=o.plugins.get(xd),s=o.plugins.get(Xu);return n.enqueueChange("transparent",e=>{e.setAttribute("uploadStatus","reading",t)}),e.read().then(()=>{const i=e.upload();if(mi.isSafari){const e=Dh(o.editing.mapper.toViewElement(t));o.editing.view.once("render",()=>{if(!e.parent)return;const t=o.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)}),i}).then(e=>{n.enqueueChange("transparent",o=>{o.setAttributes({uploadStatus:"complete",src:e.default},t),this._parseAndSetSrcsetAttributeOnImage(e,t,o)}),a()}).catch(o=>{if("error"!==e.status&&"aborted"!==e.status)throw o;"error"==e.status&&o&&s.showWarning(o,{title:i("Upload failed"),namespace:"upload"}),a(),n.enqueueChange("transparent",e=>{e.remove(t)})});function a(){n.enqueueChange("transparent",e=>{e.removeAttribute("uploadId",t),e.removeAttribute("uploadStatus",t)}),r.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,o){let n=0;const i=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(", ");""!=i&&o.setAttribute("srcset",{data:i,width:n},t)}}function am(e,t){return Array.from(e.model.createRangeOn(t)).filter(e=>e.item.is("element","image")).map(e=>e.item)}class lm extends Vd{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=zh(e),e&&e.hasAttribute("width")?this.value={width:e.getAttribute("width"),height:null}:this.value=null}execute(e){const t=this.editor.model,o=t.document.selection.getSelectedElement();this.value={width:e.width,height:null},o&&t.change(t=>{t.setAttribute("width",e.width,o)})}}class cm extends jl{static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"imageResize:original",value:null,icon:"original"},{name:"imageResize:25",value:"25",icon:"small"},{name:"imageResize:50",value:"50",icon:"medium"},{name:"imageResize:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new lm(e);this._registerSchema(),this._registerConverters(),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,o)=>{if(!o.consumable.consume(t.item,e.name))return;const n=o.writer,i=o.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,i),n.addClass("image_resized",i)):(n.removeStyle("width",i),n.removeClass("image_resized",i))})),e.conversion.for("upcast").attributeToAttribute({view:{name:"figure",styles:{width:/.+/}},model:{key:"width",value:e=>e.getStyle("width")}})}}var dm='';const hm={small:'',medium:dm,large:'',original:''};class um extends jl{static get requires(){return[cm]}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"),o=e.commands.get("imageResize");this.bind("isEnabled").to(o);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:o,value:n,icon:i}=e,r=n?n+this._resizeUnit:null;t.ui.componentFactory.add(o,n=>{const s=new Cc(n),a=t.commands.get("imageResize"),l=this._getOptionLabelValue(e,!0);if(!hm[i])throw new mo.b('imageresizebuttons-missing-icon: The resize option "'+o+'" misses the "icon" property or the property value doesn\'t match any of the available icons.',t,e);return s.set({label:l,icon:hm[i],tooltip:l,isToggleable:!0}),s.bind("isEnabled").to(this),s.bind("isOn").to(a,"value",mm(r)),this.listenTo(s,"execute",()=>{t.execute("imageResize",{width:r})}),s})}_registerImageResizeDropdown(e){const t=this.editor,o=t.t,n=e.find(e=>!e.value);t.ui.componentFactory.add("imageResize",i=>{const r=t.commands.get("imageResize"),s=qc(i,Fc),a=s.buttonView;return a.set({tooltip:o("Resize image"),commandValue:n.value,icon:dm,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button"}),a.bind("label").to(r,"value",e=>e&&e.width?e.width:this._getOptionLabelValue(n)),s.bind("isOn").to(r),s.bind("isEnabled").to(this),$c(s,this._getResizeDropdownListItemDefinitions(e,r)),s.listView.ariaLabel=o("Image resize list"),this.listenTo(s,"execute",e=>{t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus()}),s})}_getOptionLabelValue(e,t){const o=this.editor.t;return e.label?e.label:t?e.value?o("Resize image to %0",e.value+this._resizeUnit):o("Resize image to the original size"):e.value?e.value+this._resizeUnit:o("Original")}_getResizeDropdownListItemDefinitions(e,t){const o=new Ao;return e.map(e=>{const n=e.value?e.value+this._resizeUnit:null,i={type:"button",model:new bh({commandName:"imageResize",commandValue:n,label:this._getOptionLabelValue(e),withText:!0,icon:null})};i.model.bind("isOn").to(t,"value",mm(n)),o.add(i)}),o}}function mm(e){return t=>null===e&&t===e||t&&t.width===e}class gm{constructor(e){this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}begin(e,t,o){const n=new is(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const o of t)if(e.classList.contains("ck-widget__resizer__handle-"+o))return o}(e),this._referenceCoordinates=function(e,t){const o=new is(e),n=t.split("-"),i={x:"right"==n[1]?o.right:o.left,y:"bottom"==n[0]?o.bottom:o.top};return i.x+=e.ownerDocument.defaultView.scrollX,i.y+=e.ownerDocument.defaultView.scrollY,i}(t,function(e){const t=e.split("-"),o={top:"bottom",bottom:"top",left:"right",right:"left"};return`${o[t[0]]}-${o[t[1]]}`}(this.activeHandlePosition)),this.originalWidth=n.width,this.originalHeight=n.height,this.aspectRatio=n.width/n.height;const i=o.style.width;i&&i.match(/^\d+\.?\d*%$/)?this.originalWidthPercents=parseFloat(i):this.originalWidthPercents=function(e,t){const o=e.parentElement,n=parseFloat(o.ownerDocument.defaultView.getComputedStyle(o).width);return t.width/n*100}(o,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}Co(gm,qn);class fm{constructor(e){this._options=e,this._domResizerWrapper=null,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())},{priority:"high"}),this.on("change:isEnabled",()=>{this.isEnabled&&this.redraw()})}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change(o=>{const n=o.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const o=this.toDomElement(t);return e._appendHandles(o),e._appendSizeUI(o),e._domResizerWrapper=o,e.on("change:isEnabled",(e,t,n)=>{o.style.display=n?"":"none"}),o.style.display=e.isEnabled?"":"none",o}));o.insert(o.createPositionAt(t,"end"),n),o.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n})}begin(e){this.state=new gm(this._options),this._sizeUI.bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change(e=>{const o=this._options.unit||"%",n=("%"===o?t.widthPercents:t.width)+o;e.setStyle("width",n,this._options.viewElement)});const o=this._getHandleHost(),n=new is(o);t.handleHostWidth=Math.round(n.width),t.handleHostHeight=Math.round(n.height);const i=new is(o);t.width=Math.round(i.width),t.height=Math.round(i.height),this.redraw(n),this.state.update(t)}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change(()=>{this._cleanup(),this._options.onCommit(t)})}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((o=t)&&o.ownerDocument&&o.ownerDocument.contains(o)))return;var o;const n=t.parentElement,i=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(n.isSameNode(i)){const t=e||new is(i);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[i.offsetWidth+"px",i.offsetHeight+"px",i.offsetLeft+"px",i.offsetTop+"px"];"same"!==Vo(s,a)&&this._options.editor.editing.view.change(e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeUI.dismiss(),this._sizeUI.isVisible=!1;this._options.editor.editing.view.change(e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,o={x:(n=e).pageX,y:n.pageY};var n;const i=!this._options.isCentered||this._options.isCentered(this),r={x:t._referenceCoordinates.x-(o.x+t.originalWidth),y:o.y-t.originalHeight-t._referenceCoordinates.y};i&&t.activeHandlePosition.endsWith("-right")&&(r.x=o.x-(t._referenceCoordinates.x+t.originalWidth)),i&&(r.x*=2);const s={width:Math.abs(t.originalWidth+r.x),height:Math.abs(t.originalHeight+r.y)};s.dominant=s.width/t.aspectRatio>s.height?"width":"height",s.max=s[s.dominant];const a={width:s.width,height:s.height};return"width"==s.dominant?a.height=a.width/t.aspectRatio:a.width=a.height*t.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new $l({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(o=n,"ck-widget__resizer__handle-"+o)}}).render());var o}_appendSizeUI(e){const t=new pm;t.render(),this._sizeUI=t,e.appendChild(t.element)}}Co(fm,qn);class pm extends dc{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("activeHandlePosition",e=>e?"ck-orientation-"+e:"")],style:{display:e.if("isVisible","none",e=>!e)}},children:[{text:e.to("label")}]})}bindToState(e,t){this.bind("isVisible").to(t,"proposedWidth",t,"proposedHeight",(e,t)=>null!==e&&null!==t),this.bind("label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",(t,o,n)=>"px"===e.unit?`${t}×${o}`:n+"%"),this.bind("activeHandlePosition").to(t)}dismiss(){this.unbind(),this.isVisible=!1}}var bm=function(e,t,o){var n=!0,i=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return B(o)&&(n="leading"in o?!!o.leading:n,i="trailing"in o?!!o.trailing:i),Jr(e,t,{leading:n,maxWait:t,trailing:i})};o(80);class wm extends jl{static get pluginName(){return"WidgetResize"}init(){this.set("_visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map;const e=rr.window.document;this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0}),this.editor.editing.view.addObserver(qh),this._observer=Object.create(gr),this.listenTo(this.editor.editing.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this));const t=()=>{this._visibleResizer&&this._visibleResizer.redraw()},o=bm(t,200);this.on("change:_visibleResizer",t),this.editor.ui.on("update",o),this._observer.listenTo(rr.window,"resize",o);const n=this.editor.editing.view.document.selection;n.on("change",()=>{const e=n.getSelectedElement();this._visibleResizer=this._getResizerByViewElement(e)||null})}destroy(){this._observer.stopListening();for(const e of this._resizers.values())e.destroy()}attachTo(e){const t=new fm(e),o=this.editor.plugins;if(t.attach(),o.has("WidgetToolbarRepository")){const e=o.get("WidgetToolbarRepository");t.on("begin",()=>{e.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{e.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{e.clearForceDisabled("resize")},{priority:"highest"})}return this._resizers.set(e.viewElement,t),t}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_getResizerByViewElement(e){return this._resizers.get(e)}_mouseDownListener(e,t){const o=t.domTarget;fm.isResizeHandle(o)&&(this._activeResizer=this._getResizerByHandle(o),this._activeResizer&&(this._activeResizer.begin(o),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}Co(wm,qn);class km extends jl{static get requires(){return[wm]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor,t=e.commands.get("imageResize");this.bind("isEnabled").to(t),e.editing.downcastDispatcher.on("insert:image",(t,o,n)=>{const i=n.mapper.toViewElement(o.item),r=e.plugins.get(wm).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:o.item,viewElement:i,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:e=>e,isCentered(){const e=o.item.getAttribute("imageStyle");return!e||"full"==e||"alignCenter"==e},onCommit(t){e.execute("imageResize",{width:t})}});r.on("updateSize",()=>{i.hasClass("image_resized")||e.editing.view.change(e=>{e.addClass("image_resized",i)})}),r.bind("isEnabled").to(this)},{priority:"low"})}}o(82);class _m{constructor(e,t=20){this.model=e,this.size=0,this.limit=t,this.isLocked=!1,this._changeCallback=(e,t)=>{"transparent"!=t.type&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch()),this._batch}input(e){this.size+=e,this.size>=this.limit&&this._reset(!0)}lock(){this.isLocked=!0}unlock(){this.isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e){this.isLocked&&!e||(this._batch=null,this.size=0)}}class vm extends Vd{constructor(e,t){super(e),this._buffer=new _m(e.model,t),this._batches=new WeakSet}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,o=t.document,n=e.text||"",i=n.length,r=e.range?t.createSelection(e.range):o.selection,s=e.resultRange;t.enqueueChange(this._buffer.batch,e=>{this._buffer.lock(),this._batches.add(this._buffer.batch),t.deleteContent(r),n&&t.insertContent(e.createText(n,o.selection.getAttributes()),r),s?e.setSelection(s):r.is("documentSelection")||e.setSelection(r),this._buffer.unlock(),this._buffer.input(i)})}}function ym(e){if(e.newChildren.length-e.oldChildren.length!=1)return;const t=function(e,t){const o=[];let n,i=0;return e.forEach(e=>{"equal"==e?(r(),i++):"insert"==e?(s("insert")?n.values.push(t[i]):(r(),n={type:"insert",index:i,values:[t[i]]}),i++):s("delete")?n.howMany++:(r(),n={type:"delete",index:i,howMany:1})}),r(),o;function r(){n&&(o.push(n),n=null)}function s(e){return n&&n.type==e}}(Qi(e.oldChildren,e.newChildren,xm),e.newChildren);if(t.length>1)return;const o=t[0];return o.values[0]&&o.values[0].is("$text")?o:void 0}function xm(e,t){return e&&e.is("$text")&&t&&t.is("$text")?e.data===t.data:e===t}class Cm{constructor(e){this.editor=e,this.editing=this.editor.editing}handle(e,t){if(function(e){if(0==e.length)return!1;for(const t of e)if("children"===t.type&&!ym(t))return!0;return!1}(e))this._handleContainerChildrenMutations(e,t);else for(const o of e)this._handleTextMutation(o,t),this._handleTextNodeInsertion(o)}_handleContainerChildrenMutations(e,t){const o=function(e){const t=e.map(e=>e.node).reduce((e,t)=>e.getCommonAncestor(t,{includeSelf:!0}));if(!t)return;return t.getAncestors({includeSelf:!0,parentFirst:!0}).find(e=>e.is("containerElement")||e.is("rootElement"))}(e);if(!o)return;const n=this.editor.editing.view.domConverter.mapViewToDom(o),i=new cr(this.editor.editing.view.document),r=this.editor.data.toModel(i.domToView(n)).getChild(0),s=this.editor.editing.mapper.toModelElement(o);if(!s)return;const a=Array.from(r.getChildren()),l=Array.from(s.getChildren()),c=a[a.length-1],d=l[l.length-1],h=c&&c.is("element","softBreak"),u=d&&!d.is("element","softBreak");h&&u&&a.pop();const m=this.editor.model.schema;if(!Am(a,m)||!Am(l,m))return;const g=a.map(e=>e.is("$text")?e.data:"@").join("").replace(/\u00A0/g," "),f=l.map(e=>e.is("$text")?e.data:"@").join("").replace(/\u00A0/g," ");if(f===g)return;const p=Qi(f,g),{firstChangeAt:b,insertions:w,deletions:k}=Tm(p);let _=null;t&&(_=this.editing.mapper.toModelRange(t.getFirstRange()));const v=g.substr(b,w),y=this.editor.model.createRange(this.editor.model.createPositionAt(s,b),this.editor.model.createPositionAt(s,b+k));this.editor.execute("input",{text:v,range:y,resultRange:_})}_handleTextMutation(e,t){if("text"!=e.type)return;const o=e.newText.replace(/\u00A0/g," "),n=e.oldText.replace(/\u00A0/g," ");if(n===o)return;const i=Qi(n,o),{firstChangeAt:r,insertions:s,deletions:a}=Tm(i);let l=null;t&&(l=this.editing.mapper.toModelRange(t.getFirstRange()));const c=this.editing.view.createPositionAt(e.node,r),d=this.editing.mapper.toModelPosition(c),h=this.editor.model.createRange(d,d.getShiftedBy(a)),u=o.substr(r,s);this.editor.execute("input",{text:u,range:h,resultRange:l})}_handleTextNodeInsertion(e){if("children"!=e.type)return;const t=ym(e),o=this.editing.view.createPositionAt(e.node,t.index),n=this.editing.mapper.toModelPosition(o),i=t.values[0].data;this.editor.execute("input",{text:i.replace(/\u00A0/g," "),range:this.editor.model.createRange(n)})}}function Am(e,t){return e.every(e=>t.isInline(e))}function Tm(e){let t=null,o=null;for(let n=0;n