/*!
* @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 text alignment toolbar":"Horizontal text alignment toolbar",Huge:"Huge","Image toolbar":"Image toolbar","image widget":"image widget","Increase indent":"Increase indent","Insert code block":"Insert code block","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert image":"Insert image","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",Outset:"Outset",Padding:"Padding",Paragraph:"Paragraph","Plain text":"Plain text",Previous:"Previous",Purple:"Purple",Red:"Red",Redo:"Redo","Remove color":"Remove color","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","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(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,i){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(i,n,function(t){return e[t]}.bind(null,n));return i},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=122)}([function(e,t,o){"use strict";o.d(t,"b",(function(){return i})),o.d(t,"a",(function(){return n}));class i extends Error{constructor(e,t,o){e=n(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 i(e.message,t);throw o.stack=e.stack,o}}function n(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 i,n=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},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}
`),n=r),n=this._htmlDataProcessor.toView(n);const s=new lo(this,"inputTransformation");this.fire(s,{content:n,dataTransfer:i}),s.stop.called&&e.stop(),o.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(e,t)=>{if(!t.content.isEmpty){const o=this.editor.data,i=this.editor.model,n=o.toModel(t.content,"$clipboardHolder");if(0==n.childCount)return;i.insertContent(n),e.stop()}},{priority:"low"}),this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",(t,o)=>{e.isReadOnly?o.preventDefault():n(t,o)},{priority:"low"}),this.listenTo(i,"clipboardOutput",(o,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this._htmlDataProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",function e(t){let o="";if(t.is("text")||t.is("textProxy"))o=t.data;else if(t.is("img")&&t.hasAttribute("alt"))o=t.getAttribute("alt");else{let i=null;for(const n of t.getChildren()){const t=e(n);i&&(i.is("containerElement")||n.is("containerElement"))&&(Vu.includes(i.name)||Vu.includes(n.name)?o+="\n":o+="\n\n"),o+=t,i=n}}return o}(i.content))),"cut"==i.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}class Mu{constructor(e){this.document=e}createDocumentFragment(e){return new Pn(this.document,e)}createElement(e,t,o){return new Mi(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 i=o.getChildIndex(e);return this.removeChildren(i,1,o),this.insertChild(i,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 Mi(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 Zi._createAt(e,t)}createPositionAfter(e){return Zi._createAfter(e)}createPositionBefore(e){return Zi._createBefore(e)}createRange(e,t){return new en(e,t)}createRangeOn(e){return en._createOn(e)}createRangeIn(e){return en._createIn(e)}createSelection(e,t,o){return new nn(e,t,o)}}class Nu extends xd{refresh(){this.isEnabled=xh(this.editor.model)}execute(e){const t=this.editor,o=t.model,i=t.plugins.get(fd);o.change(t=>{const n=Array.isArray(e.file)?e.file:[e.file];for(const e of n)Bu(t,o,i,e)})}}function Bu(e,t,o,i){const n=o.createLoader(i);n&&yh(e,t,{uploadId:n.id})}class Fu extends Ml{static get requires(){return[fd,Eu,Ou]}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,i=e.conversion,n=e.plugins.get(fd),r=vu(e.config.get("image.upload.types"));o.extend("image",{allowAttributes:["uploadId","uploadStatus"]}),e.commands.add("imageUpload",new Nu(e)),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",(t,o)=>{if(i=o.dataTransfer,Array.from(i.types).includes("text/html")&&""!==i.getData("text/html"))return;var i;const n=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),n.length&&(t.stop(),e.model.enqueueChange("default",()=>{e.execute("imageUpload",{file:n})}))})}),this.listenTo(e.plugins.get(Ou),"inputTransformation",(t,o)=>{const i=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 i=t.getAttribute("src");fetch(i).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,i),n=o.replace("image/",""),r=new File([t],"image."+n,{type:o});e(r)}).catch(o)})),imageElement:e.item};var t});if(!i.length)return;const r=new Mu(e.editing.view.document);for(const e of i){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.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,i="$graveyard"==t.position.root.rootName;for(const t of zu(e,o)){const e=t.getAttribute("uploadId");if(!e)continue;const o=n.loaders.get(e);o&&(i?o.abort():"idle"==o.status&&this._readAndUpload(o,t))}}})}_readAndUpload(e,t){const o=this.editor,i=o.model,n=o.locale.t,r=o.plugins.get(fd),s=o.plugins.get(Eu);return i.enqueueChange("transparent",e=>{e.setAttribute("uploadStatus","reading",t)}),e.read().then(()=>{const n=e.upload();if(gn.isSafari){const e=Ch(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 i=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=i})}return i.enqueueChange("transparent",e=>{e.setAttribute("uploadStatus","uploading",t)}),n}).then(e=>{i.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:n("Upload failed"),namespace:"upload"}),a(),i.enqueueChange("transparent",e=>{e.remove(t)})});function a(){i.enqueueChange("transparent",e=>{e.removeAttribute("uploadId",t),e.removeAttribute("uploadStatus",t)}),r.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,o){let i=0;const n=Object.keys(e).filter(e=>{const t=parseInt(e,10);if(!isNaN(t))return i=Math.max(i,t),!0}).map(t=>`${e[t]} ${t}w`).join(", ");""!=n&&o.setAttribute("srcset",{data:n,width:i},t)}}function zu(e,t){return Array.from(e.model.createRangeOn(t)).filter(e=>e.item.is("image")).map(e=>e.item)}class Du{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 i=new os(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 os(e),i=t.split("-"),n={x:"right"==i[1]?o.right:o.left,y:"bottom"==i[0]?o.bottom:o.top};return n.x+=e.ownerDocument.defaultView.scrollX,n.y+=e.ownerDocument.defaultView.scrollY,n}(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=i.width,this.originalHeight=i.height,this.aspectRatio=i.width/i.height;const n=o.style.width;n&&n.match(/^\d+\.?\d*%$/)?this.originalWidthPercents=parseFloat(n):this.originalWidthPercents=function(e,t){const o=e.parentElement,i=parseFloat(o.ownerDocument.defaultView.getComputedStyle(o).width);return t.width/i*100}(o,i)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}Co(Du,Wi);class Lu{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"})}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change(o=>{const i=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,i)=>{o.style.display=i?"":"none"}),o.style.display=e.isEnabled?"":"none",o}));o.insert(o.createPositionAt(t,"end"),i),o.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=i})}begin(e){this.state=new Du(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||"%",i=("%"===o?t.widthPercents:t.width)+o;e.setStyle("width",i,this._options.viewElement)});const o=this._getHandleHost(),i=new os(o);t.handleHostWidth=Math.round(i.width),t.handleHostHeight=Math.round(i.height);const n=new os(o);t.width=Math.round(n.width),t.height=Math.round(n.height),this.redraw(i),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;var o;(o=t)&&o.ownerDocument&&o.ownerDocument.contains(o)&&this._options.editor.editing.view.change(o=>{const i=t.parentElement,n=this._getHandleHost(),r=e||new os(n);o.setStyle("width",r.width+"px",this._viewResizerWrapper),o.setStyle("height",r.height+"px",this._viewResizerWrapper);const s=n.offsetLeft,a=n.offsetTop,l=n.offsetHeight,c=n.offsetWidth;i.isSameNode(n)||(o.setStyle("left",s+"px",this._viewResizerWrapper),o.setStyle("top",a+"px",this._viewResizerWrapper),o.setStyle("height",l+"px",this._viewResizerWrapper),o.setStyle("width",c+"px",this._viewResizerWrapper))})}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:(i=e).pageX,y:i.pageY};var i;const n=!this._options.isCentered||this._options.isCentered(this),r={x:t._referenceCoordinates.x-(o.x+t.originalWidth),y:o.y-t.originalHeight-t._referenceCoordinates.y};n&&t.activeHandlePosition.endsWith("-right")&&(r.x=o.x-(t._referenceCoordinates.x+t.originalWidth)),n&&(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 i of t)e.appendChild(new Fl({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(o=i,"ck-widget__resizer__handle-"+o)}}).render());var o}_appendSizeUI(e){const t=new Hu;t.render(),this._sizeUI=t,e.appendChild(t.element)}}Co(Lu,Wi);class Hu extends oc{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,i)=>"px"===e.unit?`${t}×${o}`:i+"%"),this.bind("activeHandlePosition").to(t)}dismiss(){this.unbind(),this.isVisible=!1}}var ju=function(e,t,o){var i=!0,n=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return F(o)&&(i="leading"in o?!!o.leading:i,n="trailing"in o?!!o.trailing:n),Gr(e,t,{leading:i,maxWait:t,trailing:n})};o(74);class Wu extends Ml{static get pluginName(){return"WidgetResize"}init(){this.set("_visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map;const e=ir.window.document;this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0}),this._observer=Object.create(ur),this._observer.listenTo(e,"mousedown",this._mouseDownListener.bind(this)),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=ju(t,200);this.on("change:_visibleResizer",t),this.editor.ui.on("update",o),this._observer.listenTo(ir.window,"resize",o);const i=this.editor.editing.view.document.selection;i.on("change",()=>{const e=i.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 Lu(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){if(!Lu.isResizeHandle(t.target))return;const o=t.target;this._activeResizer=this._getResizerByHandle(o),this._activeResizer&&this._activeResizer.begin(o)}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}Co(Wu,Wi);class qu extends xd{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=vh(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();t.change(t=>{t.setAttribute("width",e.width,o)})}}o(76);class Uu{constructor(e,t,o){this.model=e,this.attribute=o,this._modelSelection=e.document.selection,this._overrideUid=null,this._isNextGravityRestorationSkipped=!1,t.listenTo(this._modelSelection,"change:range",(e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&$u(this._modelSelection.getFirstPosition(),o)||this._restoreGravity())})}handleForwardMovement(e,t){const o=this.attribute;if(!(this._isGravityOverridden||e.isAtStart&&this._hasSelectionAttribute))return Ju(e,o)&&this._hasSelectionAttribute?(this._preventCaretMovement(t),this._removeSelectionAttribute(),!0):Gu(e,o)||Ku(e,o)&&this._hasSelectionAttribute?(this._preventCaretMovement(t),this._overrideGravity(),!0):void 0}handleBackwardMovement(e,t){const o=this.attribute;return this._isGravityOverridden?Ju(e,o)&&this._hasSelectionAttribute?(this._preventCaretMovement(t),this._restoreGravity(),this._removeSelectionAttribute(),!0):(this._preventCaretMovement(t),this._restoreGravity(),e.isAtStart&&this._removeSelectionAttribute(),!0):Ju(e,o)&&!this._hasSelectionAttribute?(this._preventCaretMovement(t),this._setSelectionAttributeFromTheNodeBefore(e),!0):e.isAtEnd&&Ku(e,o)?this._hasSelectionAttribute?void(Yu(e,o)&&(this._skipNextAutomaticGravityRestoration(),this._overrideGravity())):(this._preventCaretMovement(t),this._setSelectionAttributeFromTheNodeBefore(e),!0):e.isAtStart?this._hasSelectionAttribute?(this._removeSelectionAttribute(),this._preventCaretMovement(t),!0):void 0:void(Yu(e,o)&&(this._skipNextAutomaticGravityRestoration(),this._overrideGravity()))}get _isGravityOverridden(){return!!this._overrideUid}get _hasSelectionAttribute(){return this._modelSelection.hasAttribute(this.attribute)}_overrideGravity(){this._overrideUid=this.model.change(e=>e.overrideSelectionGravity())}_restoreGravity(){this.model.change(e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null})}_preventCaretMovement(e){e.preventDefault()}_removeSelectionAttribute(){this.model.change(e=>{e.removeSelectionAttribute(this.attribute)})}_setSelectionAttributeFromTheNodeBefore(e){const t=this.attribute;this.model.change(o=>{o.setSelectionAttribute(this.attribute,e.nodeBefore.getAttribute(t))})}_skipNextAutomaticGravityRestoration(){this._isNextGravityRestorationSkipped=!0}}function $u(e,t){return Gu(e,t)||Ku(e,t)}function Gu(e,t){const{nodeBefore:o,nodeAfter:i}=e,n=!!o&&o.hasAttribute(t);return!!i&&i.hasAttribute(t)&&(!n||o.getAttribute(t)!==i.getAttribute(t))}function Ku(e,t){const{nodeBefore:o,nodeAfter:i}=e,n=!!o&&o.hasAttribute(t),r=!!i&&i.hasAttribute(t);return n&&(!r||o.getAttribute(t)!==i.getAttribute(t))}function Ju(e,t){const{nodeBefore:o,nodeAfter:i}=e,n=!!o&&o.hasAttribute(t);if(!!i&&i.hasAttribute(t)&&n)return i.getAttribute(t)!==o.getAttribute(t)}function Yu(e,t){return $u(e.getShiftedBy(-1),t)}function Qu(e,t,o){return o.createRange(Xu(e,t,!0,o),Xu(e,t,!1,o))}function Xu(e,t,o,i){let n=e.textNode||(o?e.nodeBefore:e.nodeAfter),r=null;for(;n&&n.getAttribute("linkHref")==t;)r=n,n=o?n.previousSibling:n.nextSibling;return r?i.createPositionAt(r,o?"before":"after"):e}class Zu extends xd{constructor(e){super(e),this.manualDecorators=new Ao}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document,o=Ld(t.selection.getSelectedBlocks());o&&o.is("image")&&e.schema.checkAttribute("image","linkHref")?(this.value=o.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(o,"linkHref")):(this.value=t.selection.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const o=this.editor.model,i=o.document.selection,n=[],r=[];for(const e in t)t[e]?n.push(e):r.push(e);o.change(t=>{if(i.isCollapsed){const s=i.getFirstPosition();if(i.hasAttribute("linkHref")){const a=Qu(s,i.getAttribute("linkHref"),o);t.setAttribute("linkHref",e,a),n.forEach(e=>{t.setAttribute(e,!0,a)}),r.forEach(e=>{t.removeAttribute(e,a)}),t.setSelection(t.createPositionAfter(a.end.nodeBefore))}else if(""!==e){const r=Fo(i.getAttributes());r.set("linkHref",e),n.forEach(e=>{r.set(e,!0)});const a=t.createText(e,r);o.insertContent(a,s),t.setSelection(t.createPositionAfter(a))}["linkHref",...n,...r].forEach(e=>{t.removeSelectionAttribute(e)})}else{const s=o.schema.getValidRanges(i.getRanges(),"linkHref"),a=[];for(const e of i.getSelectedBlocks())o.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of s)this._isRangeToUpdate(e,a)&&l.push(e);for(const o of l)t.setAttribute("linkHref",e,o),n.forEach(e=>{t.setAttribute(e,!0,o)}),r.forEach(e=>{t.removeAttribute(e,o)})}})}_getDecoratorStateFromModel(e){return this.editor.model.document.selection.getAttribute(e)}_isRangeToUpdate(e,t){for(const o of t)if(o.containsRange(e))return!1;return!0}}class eg extends xd{refresh(){const e=this.editor.model,t=e.document,o=Ld(t.selection.getSelectedBlocks());o&&o.is("image")&&e.schema.checkAttribute("image","linkHref")?this.isEnabled=e.schema.checkAttribute(o,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref")}execute(){const e=this.editor,t=this.editor.model,o=t.document.selection,i=e.commands.get("link");t.change(e=>{const n=o.isCollapsed?[Qu(o.getFirstPosition(),o.getAttribute("linkHref"),t)]:o.getRanges();for(const t of n)if(e.removeAttribute("linkHref",t),i)for(const o of i.manualDecorators)e.removeAttribute(o.id,t)})}}class tg{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach(e=>this._definitions.add(e)):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",(e,t,o)=>{if(!o.consumable.test(t.item,"attribute:linkHref"))return;const i=o.writer,n=i.document.selection;for(const e of this._definitions){const r=i.createAttributeElement("a",e.attributes,{priority:5});i.setCustomProperty("link",!0,r),e.callback(t.attributeNewValue)?t.item.is("selection")?i.wrap(n.getFirstRange(),r):i.wrap(o.mapper.toViewRange(t.range),r):i.unwrap(o.mapper.toViewRange(t.range),r)}},{priority:"high"})}}}class og{constructor({id:e,label:t,attributes:o,defaultValue:i}){this.id=e,this.set("value"),this.defaultValue=i,this.label=t,this.attributes=o}}Co(og,Wi);var ig=function(e,t,o){var i=e.length;return o=void 0===o?i:o,!t&&o>=i?e:ni(e,t,o)},ng=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var rg=function(e){return ng.test(e)};var sg=function(e){return e.split("")},ag="[\\ud800-\\udfff]",lg="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",cg="\\ud83c[\\udffb-\\udfff]",dg="[^\\ud800-\\udfff]",hg="(?:\\ud83c[\\udde6-\\uddff]){2}",ug="[\\ud800-\\udbff][\\udc00-\\udfff]",gg="(?:"+lg+"|"+cg+")"+"?",mg="[\\ufe0e\\ufe0f]?"+gg+("(?:\\u200d(?:"+[dg,hg,ug].join("|")+")[\\ufe0e\\ufe0f]?"+gg+")*"),fg="(?:"+[dg+lg+"?",lg,hg,ug,ag].join("|")+")",pg=RegExp(cg+"(?="+cg+")|"+fg+mg,"g");var bg=function(e){return e.match(pg)||[]};var wg=function(e){return rg(e)?bg(e):sg(e)};var kg=function(e){return function(t){t=Zo(t);var o=rg(t)?wg(t):void 0,i=o?o[0]:t.charAt(0),n=o?ig(o,1).join(""):t.slice(1);return i[e]()+n}}("toUpperCase");const _g=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,vg=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i;function yg(e,t){const o=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,o),o}function xg(e){return function(e){return e.replace(_g,"").match(vg)}(e=String(e))?e:"#"}o(78);const Cg=/^(https?:)?\/\//;class Ag extends Ml{static get pluginName(){return"LinkEditing"}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor,t=e.locale;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:yg}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>yg(xg(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new Zu(e)),e.commands.add("unlink",new eg(e));const o=function(e,t){const o={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach(e=>(e.label&&o[e.label]&&(e.label=o[e.label]),e)),t}(e.t,function(e){const t=[];if(e)for(const[o,i]of Object.entries(e)){const e=Object.assign({},i,{id:"link"+kg(o)});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(o.filter(e=>"automatic"===e.mode)),this._enableManualDecorators(o.filter(e=>"manual"===e.mode)),function({view:e,model:t,emitter:o,attribute:i,locale:n}){const r=new Uu(t,o,i),s=t.document.selection;o.listenTo(e.document,"keydown",(e,t)=>{if(!s.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const o=t.keyCode==pn.arrowright,i=t.keyCode==pn.arrowleft;if(!o&&!i)return;const a=s.getFirstPosition(),l=n.contentLanguageDirection;let c;c="ltr"===l&&o||"rtl"===l&&i?r.handleForwardMovement(a,t):r.handleBackwardMovement(a,t),c&&e.stop()},{priority:uo.get("high")+1})}({view:e.editing.view,model:e.model,emitter:this,attribute:"linkHref",locale:t}),this._setupLinkHighlight(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink()}_enableAutomaticDecorators(e){const t=this.editor,o=new tg;t.config.get("link.addTargetToExternalLinks")&&o.add({id:"linkIsExternal",mode:"automatic",callback:e=>Cg.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),o.add(e),o.length&&t.conversion.for("downcast").add(o.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,o=t.commands.get("link").manualDecorators;e.forEach(e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),o.add(new og(e)),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,i)=>{if(t){const t=o.get(e.id).attributes,n=i.createAttributeElement("a",t,{priority:5});return i.setCustomProperty("link",!0,n),n}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:o.get(e.id).attributes},model:{key:e.id}})})}_setupLinkHighlight(){const e=this.editor,t=e.editing.view,o=new Set;t.document.registerPostFixer(t=>{const i=e.model.document.selection;let n=!1;if(i.hasAttribute("linkHref")){const r=Qu(i.getFirstPosition(),i.getAttribute("linkHref"),e.model),s=e.editing.mapper.toViewRange(r);for(const e of s.getItems())e.is("a")&&!e.hasClass("ck-link_selected")&&(t.addClass("ck-link_selected",e),o.add(e),n=!0)}return n}),e.conversion.for("editingDowncast").add(e=>{function i(){t.change(e=>{for(const t of o.values())e.removeClass("ck-link_selected",t),o.delete(t)})}e.on("insert",i,{priority:"highest"}),e.on("remove",i,{priority:"highest"}),e.on("attribute",i,{priority:"highest"}),e.on("selection",i,{priority:"highest"})})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;e.on("insertContent",()=>{const o=t.anchor.nodeBefore,i=t.anchor.nodeAfter;t.hasAttribute("linkHref")&&o&&o.hasAttribute("linkHref")&&(i&&i.hasAttribute("linkHref")||e.change(t=>{[...e.document.selection.getAttributeKeys()].filter(e=>e.startsWith("link")).forEach(e=>t.removeSelectionAttribute(e))}))},{priority:"low"})}_enableClickingAfterLink(){const e=this.editor;e.editing.view.addObserver(Eh);let t=!1;this.listenTo(e.editing.view.document,"mousedown",()=>{t=!0}),this.listenTo(e.editing.view.document,"selectionChange",()=>{if(!t)return;t=!1;const o=e.model.document.selection;if(!o.isCollapsed)return;if(!o.hasAttribute("linkHref"))return;const i=o.getFirstPosition(),n=Qu(i,o.getAttribute("linkHref"),e.model);(i.isTouching(n.start)||i.isTouching(n.end))&&e.model.change(t=>{t.removeSelectionAttribute("linkHref");for(const o of e.commands.get("link").manualDecorators)t.removeSelectionAttribute(o.id)})})}}class Tg extends Br{constructor(e){super(e),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}o(80);class Pg extends oc{constructor(e,t,o){super(e);const i=e.t;this.focusTracker=new bc,this.keystrokes=new El,this.urlInputView=this._createUrlInput(o),this.saveButtonView=this._createButton(i("Save"),Uh,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),$h,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusables=new Bl,this._focusCycler=new yc({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const n=["ck","ck-link-form"];t.manualDecorators.length&&n.push("ck-link-form_layout-vertical"),this.setTemplate({tag:"form",attributes:{class:n,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce((e,t)=>(e[t.name]=t.isOn,e),{})}render(){super.render(),qh({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createUrlInput(e="https://"){const t=this.locale.t,o=new Lh(this.locale,jh);return o.label=t("Link URL"),o.fieldView.placeholder=e+"example.com",o}_createButton(e,t,o,i){const n=new pc(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.extendTemplate({attributes:{class:o}}),i&&n.delegate("execute").to(this,i),n}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const o of e.manualDecorators){const i=new Mc(this.locale);i.set({name:o.id,label:o.label,withText:!0}),i.bind("isOn").toMany([o,e],"value",(e,t)=>void 0===t&&void 0===e?o.defaultValue:e),i.on("execute",()=>{o.set("value",!i.isOn)}),t.add(i)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new oc;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map(e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}})),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}o(82);class Sg extends oc{constructor(e){super(e);const t=e.t;this.focusTracker=new bc,this.keystrokes=new El,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),'',"unlink"),this.editButtonView=this._createButton(t("Edit link"),'',"edit"),this.set("href"),this._focusables=new Bl,this._focusCycler=new yc({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createButton(e,t,o){const i=new pc(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.delegate("execute").to(this,o),i}_createPreviewButton(){const e=new pc(this.locale),t=this.bindTemplate,o=this.t;return e.set({withText:!0,tooltip:o("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",e=>e&&xg(e)),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",e=>e||o("This link has no URL")),e.bind("isEnabled").to(this,"href",e=>!!e),e.template.tag="a",e.template.eventListeners={},e}}const Eg=/^((\w+:(\/{2,})?)|(\W))/i,Rg=/[\w-]+@[\w-]+\.+[\w-]+/i;class Ig extends Ml{static get requires(){return[kc]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(Tg),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=e.plugins.get(kc),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),e.conversion.for("downcast").markerToHighlight({model:"link-ui",view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("downcast").markerToElement({model:"link-ui",view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const e=this.editor,t=new Sg(e.locale),o=e.commands.get("link"),i=e.commands.get("unlink");return t.bind("href").to(o,"value"),t.editButtonView.bind("isEnabled").to(o),t.unlinkButtonView.bind("isEnabled").to(i),this.listenTo(t,"edit",()=>{this._addFormView()}),this.listenTo(t,"unlink",()=>{e.execute("unlink"),this._hideUI()}),t.keystrokes.set("Esc",(e,t)=>{this._hideUI(),t()}),t.keystrokes.set("Ctrl+K",(e,t)=>{this._addFormView(),t()}),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),o=e.config.get("link.defaultProtocol"),i=new Pg(e.locale,t,o);return i.urlInputView.fieldView.bind("value").to(t,"value"),i.urlInputView.bind("isReadOnly").to(t,"isEnabled",e=>!e),i.saveButtonView.bind("isEnabled").to(t),this.listenTo(i,"submit",()=>{const{value:t}=i.urlInputView.fieldView.element,n=!!o&&!Eg.test(t),r=Rg.test(t),s=t&&n?(r?"mailto:":o)+t:t;e.execute("link",s,i.getDecoratorSwitchesState()),this._closeFormView()}),this.listenTo(i,"cancel",()=>{this._closeFormView()}),i.keystrokes.set("Esc",(e,t)=>{this._closeFormView(),t()}),i}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),o=e.t;e.keystrokes.set("Ctrl+K",(e,t)=>{t(),this._showUI(!0)}),e.ui.componentFactory.add("link",e=>{const i=new pc(e);return i.isEnabled=!0,i.label=o("Link"),i.icon='',i.keystroke="Ctrl+K",i.tooltip=!0,i.isToggleable=!0,i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",e=>!!e),this.listenTo(i,"execute",()=>this._showUI(!0)),i})}_enableUserBalloonInteractions(){const e=this.editor.editing.view.document;this.listenTo(e,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),this.editor.keystrokes.set("Tab",(e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),Nc({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const e=this.editor.commands.get("link");this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView(),this._showFakeVisualSelection()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let o=this._getSelectedLinkElement(),i=r();const n=()=>{const e=this._getSelectedLinkElement(),t=r();o&&!e||!o&&t!==i?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),o=e,i=t};function r(){return t.selection.focus.getAncestors().reverse().find(e=>e.is("element"))}this.listenTo(e.ui,"update",n),this.listenTo(this._balloon,"change:visibleView",n)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document,o=this._getSelectedLinkElement();return{target:o?e.domConverter.mapViewToDom(o):e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection;if(t.isCollapsed)return Vg(t.getFirstPosition());{const o=t.getFirstRange().getTrimmed(),i=Vg(o.start),n=Vg(o.end);return i&&i==n&&e.createRangeIn(i).getTrimmed().isEqual(o)?i:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{e.markers.has("link-ui")?t.updateMarker("link-ui",{range:e.document.selection.getFirstRange()}):t.addMarker("link-ui",{usingOperation:!1,affectsData:!1,range:e.document.selection.getFirstRange()})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has("link-ui")&&e.change(e=>{e.removeMarker("link-ui")})}}function Vg(e){return e.getAncestors().find(e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t})}class Og extends xd{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document,o=Array.from(t.selection.getSelectedBlocks()).filter(t=>Ng(t,e.schema)),i=!0===this.value;e.change(e=>{if(i){let t=o[o.length-1].nextSibling,i=Number.POSITIVE_INFINITY,n=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=o;)r>n.getAttribute("listIndent")&&(r=n.getAttribute("listIndent")),n.getAttribute("listIndent")==r&&e[t?"unshift":"push"](n),n=n[t?"previousSibling":"nextSibling"]}}function Ng(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class Bg extends xd{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let o=Array.from(t.selection.getSelectedBlocks());e.change(e=>{const t=o[o.length-1];let i=t.nextSibling;for(;i&&"listItem"==i.name&&i.getAttribute("listIndent")>t.getAttribute("listIndent");)o.push(i),i=i.nextSibling;this._indentBy<0&&(o=o.reverse());for(const t of o){const o=t.getAttribute("listIndent")+this._indentBy;o<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",o,t)}})}_checkEnabled(){const e=Ld(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),o=e.getAttribute("listType");let i=e.previousSibling;for(;i&&i.is("listItem")&&i.getAttribute("listIndent")>=t;){if(i.getAttribute("listIndent")==t)return i.getAttribute("listType")==o;i=i.previousSibling}return!1}return!0}}function Fg(e,t){const o=t.mapper,i=t.writer,n="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=Wg,t}(i),s=i.createContainerElement(n,null);return i.insert(i.createPositionAt(s,0),r),o.bindElements(e,r),r}function zg(e,t,o,i){const n=t.parent,r=o.mapper,s=o.writer;let a=r.toViewPosition(i.createPositionBefore(e));const l=Hg(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=r.toViewElement(l);a=s.breakContainer(s.createPositionAfter(e))}else a=c&&"listItem"==c.name?r.toViewPosition(i.createPositionAt(c,"end")):r.toViewPosition(i.createPositionBefore(e));if(a=Lg(a),s.insert(a,n),c&&"listItem"==c.name){const e=r.toViewElement(c),o=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of o)if(e.item.is("li")){const i=s.breakContainer(s.createPositionBefore(e.item)),n=e.item.parent,r=s.createPositionAt(t,"end");Dg(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(n),r),o.position=i}}else{const o=n.nextSibling;if(o&&(o.is("ul")||o.is("ol"))){let i=null;for(const t of o.getChildren()){const o=r.toModelElement(t);if(!(o&&o.getAttribute("listIndent")>e.getAttribute("listIndent")))break;i=t}i&&(s.breakContainer(s.createPositionAfter(i)),s.move(s.createRangeOn(i.parent),s.createPositionAt(t,"end")))}}Dg(s,n,n.nextSibling),Dg(s,n.previousSibling,n)}function Dg(e,t,o){return!t||!o||"ul"!=t.name&&"ol"!=t.name||t.name!=o.name||t.getAttribute("class")!==o.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function Lg(e){return e.getLastMatchingPosition(e=>e.item.is("uiElement"))}function Hg(e,t){const o=!!t.sameIndent,i=!!t.smallerIndent,n=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(o&&n==e||i&&n>e)return r;r=r.previousSibling}return null}function jg(e,t,o,i){e.ui.componentFactory.add(t,n=>{const r=e.commands.get(t),s=new pc(n);return s.set({label:o,icon:i,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",()=>{e.execute(t),e.editing.view.focus()}),s})}function Wg(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Fi.call(this)}function qg(e){return(t,o,i)=>{const n=i.consumable;if(!n.test(o.item,"insert")||!n.test(o.item,"attribute:listType")||!n.test(o.item,"attribute:listIndent"))return;n.consume(o.item,"insert"),n.consume(o.item,"attribute:listType"),n.consume(o.item,"attribute:listIndent");const r=o.item;zg(r,Fg(r,i),i,e)}}function Ug(e,t,o){if(!o.consumable.consume(t.item,"attribute:listType"))return;const i=o.mapper.toViewElement(t.item),n=o.writer;n.breakContainer(n.createPositionBefore(i)),n.breakContainer(n.createPositionAfter(i));const r=i.parent,s="numbered"==t.attributeNewValue?"ol":"ul";n.rename(s,r)}function $g(e,t,o){const i=o.mapper.toViewElement(t.item).parent,n=o.writer;Dg(n,i,i.nextSibling),Dg(n,i.previousSibling,i);for(const e of t.item.getChildren())o.consumable.consume(e,"insert")}function Gg(e,t,o){if("listItem"!=t.item.name){let e=o.mapper.toViewPosition(t.range.start);const i=o.writer,n=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=i.breakContainer(e),"li"==e.parent.name);){const t=e,o=i.createPositionAt(e.parent,"end");if(!t.isEqual(o)){const e=i.remove(i.createRange(t,o));n.push(e)}e=i.createPositionAfter(e.parent)}if(n.length>0){for(let t=0;t