{this.focusTracker.add(t.ui.getEditableElement());this.focusTracker.add(this.toolbarView.element)}));t.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this.show(true),afterBlur:()=>this.hide(),isContextual:true});this._resizeObserver=null;this._balloon=t.plugins.get(ContextualBalloon);this._fireSelectionChangeDebounced=debounce((()=>this.fire("_selectionChangeDebounced")),200);this.decorate("show")}static get pluginName(){return"BalloonToolbar"}static get requires(){return[ContextualBalloon]}init(){const t=this.editor;const e=t.model.document.selection;this.listenTo(this.focusTracker,"change:isFocused",((t,e,n)=>{const o=this._balloon.visibleView===this.toolbarView;if(!n&&o){this.hide()}else if(n){this.show()}}));this.listenTo(e,"change:range",((t,n)=>{if(n.directChange||e.isCollapsed){this.hide()}this._fireSelectionChangeDebounced()}));this.listenTo(this,"_selectionChangeDebounced",(()=>{if(this.editor.editing.view.document.isFocused){this.show()}}));if(!this._balloonConfig.shouldNotGroupWhenFull){this.listenTo(t,"ready",(()=>{const e=t.ui.view.editable.element;this._resizeObserver=new ResizeObserver(e,(()=>{this.toolbarView.maxWidth=Xy(new Rect(e).width*.9)}))}))}this.listenTo(this.toolbarView,"groupedItemsUpdate",(()=>{this._updatePosition()}))}afterInit(){const t=this.editor.ui.componentFactory;this.toolbarView.fillFromConfig(this._balloonConfig,t)}_createToolbarView(){const t=this.editor.locale.t;const e=!this._balloonConfig.shouldNotGroupWhenFull;const n=new ToolbarView(this.editor.locale,{shouldGroupWhenFull:e,isFloating:true});n.ariaLabel=t("Editor contextual toolbar");n.render();return n}show(t=false){const e=this.editor;const n=e.model.document.selection;const o=e.model.schema;if(this._balloon.hasView(this.toolbarView)){return}if(n.isCollapsed&&!t){return}if(ex(n,o)){return}if(Array.from(this.toolbarView.items).every((t=>t.isEnabled!==undefined&&!t.isEnabled))){return}this.listenTo(this.editor.ui,"update",(()=>{this._updatePosition()}));this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"})}hide(){if(this._balloon.hasView(this.toolbarView)){this.stopListening(this.editor.ui,"update");this._balloon.remove(this.toolbarView)}}_getBalloonPositionData(){const t=this.editor;const e=t.editing.view;const n=e.document;const o=n.selection;const i=n.selection.isBackward;return{target:()=>{const t=i?o.getFirstRange():o.getLastRange();const n=Rect.getDomRangeRects(e.domConverter.viewRangeToDom(t));if(i){return n[0]}else{if(n.length>1&&n[n.length-1].width===0){n.pop()}return n[n.length-1]}},positions:this._getBalloonPositions(i)}}_updatePosition(){this._balloon.updatePosition(this._getBalloonPositionData())}destroy(){super.destroy();this.stopListening();this._fireSelectionChangeDebounced.cancel();this.toolbarView.destroy();this.focusTracker.destroy();if(this._resizeObserver){this._resizeObserver.destroy()}}_getBalloonPositions(t){const e=env.isSafari&&env.isiOS;const n=e?generatePositions({heightOffset:Math.max(BalloonPanelView.arrowHeightOffset,Math.round(20/global.window.visualViewport.scale))}):BalloonPanelView.defaultPositions;return t?[n.northWestArrowSouth,n.northWestArrowSouthWest,n.northWestArrowSouthEast,n.northWestArrowSouthMiddleEast,n.northWestArrowSouthMiddleWest,n.southWestArrowNorth,n.southWestArrowNorthWest,n.southWestArrowNorthEast,n.southWestArrowNorthMiddleWest,n.southWestArrowNorthMiddleEast]:[n.southEastArrowNorth,n.southEastArrowNorthEast,n.southEastArrowNorthWest,n.southEastArrowNorthMiddleEast,n.southEastArrowNorthMiddleWest,n.northEastArrowSouth,n.northEastArrowSouthEast,n.northEastArrowSouthWest,n.northEastArrowSouthMiddleEast,n.northEastArrowSouthMiddleWest]}}function ex(t,e){if(t.rangeCount===1){return false}return[...t.getRanges()].every((t=>{const n=t.getContainedElement();return n&&e.isSelectable(n)}))}var nx=n(706);var ox={injectType:"singletonStyleTag",attributes:{"data-cke":true}};ox.insert="head";ox.singleton=true;var ix=Vu()(nx.Z,ox);const rx=nx.Z.locals||{};const sx=pA("px");class ax extends(null&&ButtonView){constructor(t){super(t);const e=this.bindTemplate;this.isVisible=false;this.isToggleable=true;this.set("top",0);this.set("left",0);this.extendTemplate({attributes:{class:"ck-block-toolbar-button",style:{top:e.to("top",(t=>sx(t))),left:e.to("left",(t=>sx(t)))}}})}}const cx=pA("px");class lx extends(null&&Plugin){constructor(t){super(t);this._blockToolbarConfig=normalizeToolbarConfig(this.editor.config.get("blockToolbar"));this.toolbarView=this._createToolbarView();this.panelView=this._createPanelView();this.buttonView=this._createButtonView();this._resizeObserver=null;clickOutsideHandler({emitter:this.panelView,contextElements:[this.panelView.element,this.buttonView.element],activator:()=>this.panelView.isVisible,callback:()=>this._hidePanel()})}static get pluginName(){return"BlockToolbar"}init(){const t=this.editor;this.listenTo(t.model.document.selection,"change:range",((t,e)=>{if(e.directChange){this._hidePanel()}}));this.listenTo(t.ui,"update",(()=>this._updateButton()));this.listenTo(t,"change:isReadOnly",(()=>this._updateButton()),{priority:"low"});this.listenTo(t.ui.focusTracker,"change:isFocused",(()=>this._updateButton()));this.listenTo(this.buttonView,"change:isVisible",((t,e,n)=>{if(n){this.buttonView.listenTo(window,"resize",(()=>this._updateButton()))}else{this.buttonView.stopListening(window,"resize");this._hidePanel()}}));t.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this._showPanel(),afterBlur:()=>this._hidePanel()})}afterInit(){const t=this.editor.ui.componentFactory;const e=this._blockToolbarConfig;this.toolbarView.fillFromConfig(e,t);for(const t of this.toolbarView.items){t.on("execute",(()=>this._hidePanel(true)),{priority:"high"})}if(!e.shouldNotGroupWhenFull){this.listenTo(this.editor,"ready",(()=>{const t=this.editor.ui.view.editable.element;this._resizeObserver=new ResizeObserver(t,(()=>{this.toolbarView.maxWidth=this._getToolbarMaxWidth()}))}))}}destroy(){super.destroy();this.panelView.destroy();this.buttonView.destroy();this.toolbarView.destroy();if(this._resizeObserver){this._resizeObserver.destroy()}}_createToolbarView(){const t=this.editor.locale.t;const e=!this._blockToolbarConfig.shouldNotGroupWhenFull;const n=new ToolbarView(this.editor.locale,{shouldGroupWhenFull:e,isFloating:true});n.ariaLabel=t("Editor block content toolbar");n.focusTracker.on("change:isFocused",((t,e,n)=>{if(!n){this._hidePanel()}}));return n}_createPanelView(){const t=this.editor;const e=new BalloonPanelView(t.locale);e.content.add(this.toolbarView);e.class="ck-toolbar-container";t.ui.view.body.add(e);t.ui.focusTracker.add(e.element);this.toolbarView.keystrokes.set("Esc",((t,e)=>{this._hidePanel(true);e()}));return e}_createButtonView(){const t=this.editor;const e=t.t;const n=new BlockButtonView(t.locale);const o=n.bindTemplate;n.set({label:e("Edit block"),icon:pilcrow,withText:false});n.extendTemplate({on:{mousedown:o.to((t=>{if(env.isSafari&&this.panelView.isVisible){this.toolbarView.focus()}t.preventDefault()}))}});n.bind("isOn").to(this.panelView,"isVisible");n.bind("tooltip").to(this.panelView,"isVisible",(t=>!t));this.listenTo(n,"execute",(()=>{if(!this.panelView.isVisible){this._showPanel()}else{this._hidePanel(true)}}));t.ui.view.body.add(n);t.ui.focusTracker.add(n.element);return n}_updateButton(){const t=this.editor;const e=t.model;const n=t.editing.view;if(!t.ui.focusTracker.isFocused){this._hideButton();return}if(t.isReadOnly){this._hideButton();return}const o=Array.from(e.document.selection.getSelectedBlocks())[0];if(!o||Array.from(this.toolbarView.items).every((t=>!t.isEnabled))){this._hideButton();return}const i=n.domConverter.mapViewToDom(t.editing.mapper.toViewElement(o));this.buttonView.isVisible=true;this._attachButtonToElement(i);if(this.panelView.isVisible){this._showPanel()}}_hideButton(){this.buttonView.isVisible=false}_showPanel(){if(!this.buttonView.isVisible){return}const t=this.panelView.isVisible;this.panelView.show();this.toolbarView.maxWidth=this._getToolbarMaxWidth();this.panelView.pin({target:this.buttonView.element,limiter:this.editor.ui.getEditableElement()});if(!t){this.toolbarView.items.get(0).focus()}}_hidePanel(t){this.panelView.isVisible=false;if(t){this.editor.editing.view.focus()}}_attachButtonToElement(t){const e=window.getComputedStyle(t);const n=new Rect(this.editor.ui.getEditableElement());const o=parseInt(e.paddingTop,10);const i=parseInt(e.lineHeight,10)||parseInt(e.fontSize,10)*1.2;const r=getOptimalPosition({element:this.buttonView.element,target:t,positions:[(t,e)=>{let r;if(this.editor.locale.uiLanguageDirection==="ltr"){r=n.left-e.width}else{r=n.right}return{top:t.top+o+(i-e.height)/2,left:r}}]});this.buttonView.top=r.top;this.buttonView.left=r.left}_getToolbarMaxWidth(){const t=this.editor.ui.view.editable.element;const e=new Rect(t);const n=new Rect(this.buttonView.element);const o=this.editor.locale.uiLanguageDirection==="rtl";const i=o?n.left-e.right+n.width:e.left-n.left;return cx(e.width+i)}}class dx extends RA{constructor(t,e){super(t);this.view=e;this._toolbarConfig=fC(t.config.get("toolbar"));this._elementReplacer=new tg}get element(){return this.view.element}init(t){const e=this.editor;const n=this.view;const o=e.editing.view;const i=n.editable;const r=o.document.getRoot();i.name=r.rootName;n.render();const s=i.element;this.setEditableElement(i.name,s);n.editable.bind("isFocused").to(this.focusTracker);o.attachDomRoot(s);if(t){this._elementReplacer.replace(t,this.element)}this._initPlaceholder();this._initToolbar();this.fire("ready")}destroy(){super.destroy();const t=this.view;const e=this.editor.editing.view;this._elementReplacer.restore();e.detachDomRoot(t.editable.name);t.destroy()}_initToolbar(){const t=this.view;t.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused");t.stickyPanel.limiterElement=t.element;t.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:t})=>t));t.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory);this.addToolbar(t.toolbar)}_initPlaceholder(){const t=this.editor;const e=t.editing.view;const n=e.document.getRoot();const o=t.sourceElement;const i=t.config.get("placeholder")||o&&o.tagName.toLowerCase()==="textarea"&&o.getAttribute("placeholder");if(i){Zb({view:e,element:n,text:i,isDirectHost:false,keepOnFocus:true})}}}var ux=n(638);var hx={injectType:"singletonStyleTag",attributes:{"data-cke":true}};hx.insert="head";hx.singleton=true;var fx=Vu()(ux.Z,hx);const gx=ux.Z.locals||{};class px extends sy{constructor(t,e,n={}){super(t);this.stickyPanel=new Qy(t);this.toolbar=new _C(t,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull});this.editable=new cy(t,e)}render(){super.render();this.stickyPanel.content.add(this.toolbar);this.top.add(this.stickyPanel);this.main.add(this.editable)}}class mx extends y_{constructor(t,e={}){if(!ba(t)&&e.initialData!==undefined){throw new u("editor-create-initial-data",null)}super(e);if(this.config.get("initialData")===undefined){this.config.set("initialData",kx(t))}if(ba(t)){this.sourceElement=t}this.model.document.createRoot();const n=!this.config.get("toolbar.shouldNotGroupWhenFull");const o=new px(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:n});this.ui=new dx(this,o);zA(this)}destroy(){if(this.sourceElement){this.updateSourceElement()}this.ui.destroy();return super.destroy()}static create(t,e={}){return new Promise((n=>{const o=new this(t,e);n(o.initPlugins().then((()=>o.ui.init(ba(t)?t:null))).then((()=>o.data.init(o.config.get("initialData")))).then((()=>o.fire("ready"))).then((()=>o)))}))}}Xf(mx,FA);Xf(mx,NA);function kx(t){return ba(t)?rg(t):t}class bx extends ot{constructor(t,e){super(t);this.attributeKey=e}refresh(){const t=this.editor.model;const e=t.document;this.value=this._getValueFromFirstAllowedNode();this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model;const n=e.document;const o=n.selection;const i=t.forceValue===undefined?!this.value:t.forceValue;e.change((t=>{if(o.isCollapsed){if(i){t.setSelectionAttribute(this.attributeKey,true)}else{t.removeSelectionAttribute(this.attributeKey)}}else{const n=e.schema.getValidRanges(o.getRanges(),this.attributeKey);for(const e of n){if(i){t.setAttribute(this.attributeKey,i,e)}else{t.removeAttribute(this.attributeKey,e)}}}}))}_getValueFromFirstAllowedNode(){const t=this.editor.model;const e=t.schema;const n=t.document.selection;if(n.isCollapsed){return n.hasAttribute(this.attributeKey)}for(const t of n.getRanges()){for(const n of t.getItems()){if(e.checkAttribute(n,this.attributeKey)){return n.hasAttribute(this.attributeKey)}}}return false}}const wx="bold";class _x extends et{static get pluginName(){return"BoldEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:wx});t.model.schema.setAttributeProperties(wx,{isFormatting:true,copyOnEnter:true});t.conversion.attributeToElement({model:wx,view:"strong",upcastAlso:["b",t=>{const e=t.getStyle("font-weight");if(!e){return null}if(e=="bold"||Number(e)>=600){return{name:true,styles:["font-weight"]}}}]});t.commands.add(wx,new bx(t,wx));t.keystrokes.set("CTRL+B",wx)}}const Ax="bold";class vx extends et{static get pluginName(){return"BoldUI"}init(){const t=this.editor;const e=t.t;t.ui.componentFactory.add(Ax,(n=>{const o=t.commands.get(Ax);const i=new Fv(n);i.set({label:e("Bold"),icon:vv.bold,keystroke:"CTRL+B",tooltip:true,isToggleable:true});i.bind("isOn","isEnabled").to(o,"value","isEnabled");this.listenTo(i,"execute",(()=>{t.execute(Ax);t.editing.view.focus()}));return i}))}}class Cx extends et{static get requires(){return[_x,vx]}static get pluginName(){return"Bold"}}class yx extends vh{constructor(t){super(t);const e=this.document;this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];this.listenTo(e,"paste",n("clipboardInput"),{priority:"low"});this.listenTo(e,"drop",n("clipboardInput"),{priority:"low"});this.listenTo(e,"dragover",n("dragging"),{priority:"low"});function n(t){return(n,o)=>{o.preventDefault();const r=o.dropRange?[o.dropRange]:null;const s=new i(e,t);e.fire(s,{dataTransfer:o.dataTransfer,method:n.name,targetRanges:r,target:o.target});if(s.stop.called){o.stopPropagation()}}}}onDomEvent(t){const e={dataTransfer:new Jf("clipboardData"in t?t.clipboardData:t.dataTransfer)};if(t.type=="drop"||t.type=="dragover"){e.dropRange=xx(this.view,t)}this.fire(t.type,t,e)}}function xx(t,e){const n=e.target.ownerDocument;const o=e.clientX;const i=e.clientY;let r;if(n.caretRangeFromPoint&&n.caretRangeFromPoint(o,i)){r=n.caretRangeFromPoint(o,i)}else if(e.rangeParent){r=n.createRange();r.setStart(e.rangeParent,e.rangeOffset);r.collapse(true)}if(r){return t.domConverter.domRangeToView(r)}return null}function Ex(t){t=t.replace(//g,">").replace(/\r?\n\r?\n/g,"").replace(/\r?\n/g,"
").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ");if(t.includes("
")||t.includes("
")){t=`
${t}
`}return t}function Sx(t){return t.replace(/(\s+)<\/span>/g,((t,e)=>{if(e.length==1){return" "}return e})).replace(//g,"")}const Dx=["figcaption","li"];function Tx(t){let e="";if(t.is("$text")||t.is("$textProxy")){e=t.data}else if(t.is("element","img")&&t.hasAttribute("alt")){e=t.getAttribute("alt")}else if(t.is("element","br")){e="\n"}else{let n=null;for(const o of t.getChildren()){const t=Tx(o);if(n&&(n.is("containerElement")||o.is("containerElement"))){if(Dx.includes(n.name)||Dx.includes(o.name)){e+="\n"}else{e+="\n\n"}}e+=t;n=o}}return e}class Bx extends et{static get pluginName(){return"ClipboardPipeline"}init(){const t=this.editor;const e=t.editing.view;e.addObserver(yx);this._setupPasteDrop();this._setupCopyCut()}_setupPasteDrop(){const t=this.editor;const e=t.model;const n=t.editing.view;const o=n.document;this.listenTo(o,"clipboardInput",(e=>{if(t.isReadOnly){e.stop()}}),{priority:"highest"});this.listenTo(o,"clipboardInput",((t,e)=>{const o=e.dataTransfer;let r;if(e.content){r=e.content}else{let t="";if(o.getData("text/html")){t=Sx(o.getData("text/html"))}else if(o.getData("text/plain")){t=Ex(o.getData("text/plain"))}r=this.editor.data.htmlProcessor.toView(t)}const s=new i(this,"inputTransformation");this.fire(s,{content:r,dataTransfer:o,targetRanges:e.targetRanges,method:e.method});if(s.stop.called){t.stop()}n.scrollToTheSelection()}),{priority:"low"});this.listenTo(this,"inputTransformation",((t,n)=>{if(n.content.isEmpty){return}const o=this.editor.data;const i=o.toModel(n.content,"$clipboardHolder");if(i.childCount==0){return}t.stop();e.change((()=>{this.fire("contentInsertion",{content:i,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})}))}),{priority:"low"});this.listenTo(this,"contentInsertion",((t,n)=>{n.resultRange=e.insertContent(n.content)}),{priority:"low"})}_setupCopyCut(){const t=this.editor;const e=t.model.document;const n=t.editing.view;const o=n.document;const i=(n,i)=>{const r=i.dataTransfer;i.preventDefault();const s=t.data.toView(t.model.getSelectedContent(e.selection));o.fire("clipboardOutput",{dataTransfer:r,content:s,method:n.name})};this.listenTo(o,"copy",i,{priority:"low"});this.listenTo(o,"cut",((e,n)=>{if(t.isReadOnly){n.preventDefault()}else{i(e,n)}}),{priority:"low"});this.listenTo(o,"clipboardOutput",((n,o)=>{if(!o.content.isEmpty){o.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(o.content));o.dataTransfer.setData("text/plain",Tx(o.content))}if(o.method=="cut"){t.model.deleteContent(e.selection)}}),{priority:"low"})}}function*Px(t,e){for(const n of e){if(n&&t.getAttributeProperties(n[0]).copyOnEnter){yield n}}}class Ix extends ot{execute(){const t=this.editor.model;const e=t.document;t.change((n=>{Rx(this.editor.model,n,e.selection,t.schema);this.fire("afterExecute",{writer:n})}))}}function Rx(t,e,n,o){const i=n.isCollapsed;const r=n.getFirstRange();const s=r.start.parent;const a=r.end.parent;if(o.isLimit(s)||o.isLimit(a)){if(!i&&s==a){t.deleteContent(n)}return}if(i){const t=Px(e.model.schema,n.getAttributes());Ox(e,r.start);e.setSelectionAttribute(t)}else{const o=!(r.start.isAtStart&&r.end.isAtEnd);const i=s==a;t.deleteContent(n,{leaveUnmerged:o});if(o){if(i){Ox(e,n.focus)}else{e.setSelection(a,0)}}}}function Ox(t,e){t.split(e);t.setSelection(e.parent.nextSibling,0)}const zx={insertParagraph:{isSoft:false},insertLineBreak:{isSoft:true}};class Mx extends bh{constructor(t){super(t);const e=this.document;e.on("beforeinput",((n,o)=>{if(!this.isEnabled){return}const i=o.domEvent;const r=zx[o.inputType];if(!r){return}const s=new ld(e,"enter",o.targetRanges[0]);e.fire(s,new Ah(t,i,{isSoft:r.isSoft}));if(s.stop.called){n.stop()}}))}observe(){}}class Fx extends et{static get pluginName(){return"Enter"}init(){const t=this.editor;const e=t.editing.view;const n=e.document;e.addObserver(Mx);t.commands.add("enter",new Ix(t));this.listenTo(n,"enter",((o,i)=>{if(!n.isComposing){i.preventDefault()}if(i.isSoft){return}t.execute("enter");e.scrollToTheSelection()}),{priority:"low"})}}class Vx{constructor(t,e=20){this._batch=null;this.model=t;this._size=0;this.limit=e;this._isLocked=false;this._changeCallback=(t,e)=>{if(e.isLocal&&e.isUndoable&&e!==this._batch){this._reset(true)}};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(){if(!this._batch){this._batch=this.model.createBatch({isTyping:true})}return this._batch}get size(){return this._size}input(t){this._size+=t;if(this._size>=this.limit){this._reset(true)}}get isLocked(){return this._isLocked}lock(){this._isLocked=true}unlock(){this._isLocked=false}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(t=false){if(!this.isLocked||t){this._batch=null;this._size=0}}}class Nx extends ot{constructor(t,e){super(t);this.direction=e;this._buffer=new Vx(t.model,t.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(t={}){const e=this.editor.model;const n=e.document;e.enqueueChange(this._buffer.batch,(o=>{this._buffer.lock();const i=o.createSelection(t.selection||n.selection);const r=t.sequence||1;const s=i.isCollapsed;if(i.isCollapsed){e.modifySelection(i,{direction:this.direction,unit:t.unit,treatEmojiAsSingleUnit:true})}if(this._shouldEntireContentBeReplacedWithParagraph(r)){this._replaceEntireContentWithParagraph(o);return}if(this._shouldReplaceFirstBlockWithParagraph(i,r)){this.editor.execute("paragraph",{selection:i});return}if(i.isCollapsed){return}let a=0;i.getFirstRange().getMinimalFlatRanges().forEach((t=>{a+=sd(t.getWalker({singleCharacters:true,ignoreElementEnd:true,shallow:true}))}));e.deleteContent(i,{doNotResetEntireContent:s,direction:this.direction});this._buffer.input(a);o.setSelection(i);this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(t){if(t>1){return false}const e=this.editor.model;const n=e.document;const o=n.selection;const i=e.schema.getLimitElement(o);const r=o.isCollapsed&&o.containsEntireContent(i);if(!r){return false}if(!e.schema.checkChild(i,"paragraph")){return false}const s=i.getChild(0);if(s&&s.is("element","paragraph")){return false}return true}_replaceEntireContentWithParagraph(t){const e=this.editor.model;const n=e.document;const o=n.selection;const i=e.schema.getLimitElement(o);const r=t.createElement("paragraph");t.remove(t.createRangeIn(i));t.insert(r,i);t.setSelection(r,0)}_shouldReplaceFirstBlockWithParagraph(t,e){const n=this.editor.model;if(e>1||this.direction!="backward"){return false}if(!t.isCollapsed){return false}const o=t.getFirstPosition();const i=n.schema.getLimitElement(o);const r=i.getChild(0);if(o.parent!=r){return false}if(!t.containsEntireContent(r)){return false}if(!n.schema.checkChild(i,"paragraph")){return false}if(r.name=="paragraph"){return false}return true}}const Lx="character";const Hx="word";const jx="codePoint";const Wx="selection";const qx="backward";const Ux="forward";const $x={deleteContent:{unit:Wx,direction:qx},deleteContentBackward:{unit:jx,direction:qx},deleteWordBackward:{unit:Hx,direction:qx},deleteHardLineBackward:{unit:Wx,direction:qx},deleteSoftLineBackward:{unit:Wx,direction:qx},deleteContentForward:{unit:Lx,direction:Ux},deleteWordForward:{unit:Hx,direction:Ux},deleteHardLineForward:{unit:Wx,direction:Ux},deleteSoftLineForward:{unit:Wx,direction:Ux}};class Kx extends bh{constructor(t){super(t);const e=t.document;let n=0;e.on("keydown",(()=>{n++}));e.on("keyup",(()=>{n=0}));e.on("beforeinput",((o,i)=>{if(!this.isEnabled){return}const{targetRanges:r,domEvent:s,inputType:a}=i;const c=$x[a];if(!c){return}const l={direction:c.direction,unit:c.unit,sequence:n};if(l.unit==Wx){l.selectionToRemove=t.createSelection(r[0])}if(Sd.isAndroid&&a==="deleteContentBackward"){l.sequence=1;if(r.length==1&&(r[0].start.parent!=r[0].end.parent||r[0].start.offset+1!=r[0].end.offset)){l.unit=Wx;l.selectionToRemove=t.createSelection(r)}}const d=new ld(e,"delete",r[0]);e.fire(d,new Ah(t,s,l));if(d.stop.called){o.stop()}}));if(Sd.isBlink){Gx(this)}}observe(){}}function Gx(t){const e=t.view;const n=e.document;let o=null;let i=false;n.on("keydown",((t,{keyCode:e})=>{o=e;i=false}));n.on("keyup",((a,{keyCode:c,domEvent:l})=>{const d=n.selection;const u=t.isEnabled&&c==o&&r(c)&&!d.isCollapsed&&!i;o=null;if(u){const t=d.getFirstRange();const o=new ld(n,"delete",t);const i={unit:Wx,direction:s(c),selectionToRemove:d};n.fire(o,new Ah(e,l,i))}}));n.on("beforeinput",((t,{inputType:e})=>{const n=$x[e];const a=r(o)&&n&&n.direction==s(o);if(a){i=true}}));n.on("beforeinput",((t,{inputType:e,data:n})=>{const i=o==Vd["delete"]&&e=="insertText"&&n=="";if(i){t.stop()}}),{priority:"high"});function r(t){return t==Vd.backspace||t==Vd["delete"]}function s(t){return t==Vd.backspace?qx:Ux}}class Zx extends et{static get pluginName(){return"Delete"}init(){const t=this.editor;const e=t.editing.view;const n=e.document;const o=t.model.document;e.addObserver(Kx);this._undoOnBackspace=false;const i=new Nx(t,"forward");t.commands.add("deleteForward",i);t.commands.add("forwardDelete",i);t.commands.add("delete",new Nx(t,"backward"));this.listenTo(n,"delete",((o,i)=>{if(!n.isComposing){i.preventDefault()}const{direction:r,sequence:s,selectionToRemove:a,unit:c}=i;const l=r==="forward"?"deleteForward":"delete";const d={sequence:s};if(c=="selection"){const e=Array.from(a.getRanges()).map((e=>t.editing.mapper.toModelRange(e)));d.selection=t.model.createSelection(e)}else{d.unit=c}t.execute(l,d);e.scrollToTheSelection()}),{priority:"low"});if(this.editor.plugins.has("UndoEditing")){this.listenTo(n,"delete",((e,n)=>{if(this._undoOnBackspace&&n.direction=="backward"&&n.sequence==1&&n.unit=="codePoint"){this._undoOnBackspace=false;t.execute("undo");n.preventDefault();e.stop()}}),{context:"$capture"});this.listenTo(o,"change",(()=>{this._undoOnBackspace=false}))}}requestUndoOnBackspace(){if(this.editor.plugins.has("UndoEditing")){this._undoOnBackspace=true}}}class Jx extends y{constructor(){super();this._stack=[]}add(t,e){const n=this._stack;const o=n[0];this._insertDescriptor(t);const i=n[0];if(o!==i&&!Yx(o,i)){this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}}remove(t,e){const n=this._stack;const o=n[0];this._removeDescriptor(t);const i=n[0];if(o!==i&&!Yx(o,i)){this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}}_insertDescriptor(t){const e=this._stack;const n=e.findIndex((e=>e.id===t.id));if(Yx(t,e[n])){return}if(n>-1){e.splice(n,1)}let o=0;while(e[o]&&Qx(e[o],t)){o++}e.splice(o,0,t)}_removeDescriptor(t){const e=this._stack;const n=e.findIndex((e=>e.id===t));if(n>-1){e.splice(n,1)}}}function Yx(t,e){return t&&e&&t.priority==e.priority&&Xx(t.classes)==Xx(e.classes)}function Qx(t,e){if(t.priority>e.priority){return true}else if(t.priorityXx(e.classes)}function Xx(t){return Array.isArray(t)?t.sort().join(","):t}const tE='';const eE="ck-widget";const nE="ck-widget_selected";function oE(t){if(!t.is("element")){return false}return!!t.getCustomProperty("widget")}function iE(t,e,n={}){if(!t.is("containerElement")){throw new u("widget-to-widget-wrong-element-type",null,{element:t})}e.setAttribute("contenteditable","false",t);e.addClass(eE,t);e.setCustomProperty("widget",true,t);t.getFillerOffset=fE;if(n.label){cE(t,n.label,e)}if(n.hasSelectionHandle){gE(t,e)}aE(t,e);return t}function rE(t,e,n){if(e.classes){n.addClass(xa(e.classes),t)}if(e.attributes){for(const o in e.attributes){n.setAttribute(o,e.attributes[o],t)}}}function sE(t,e,n){if(e.classes){n.removeClass(xa(e.classes),t)}if(e.attributes){for(const o in e.attributes){n.removeAttribute(o,t)}}}function aE(t,e,n=rE,o=sE){const i=new Jx;i.on("change:top",((e,i)=>{if(i.oldDescriptor){o(t,i.oldDescriptor,i.writer)}if(i.newDescriptor){n(t,i.newDescriptor,i.writer)}}));const r=(t,e,n)=>i.add(e,n);const s=(t,e,n)=>i.remove(e,n);e.setCustomProperty("addHighlight",r,t);e.setCustomProperty("removeHighlight",s,t)}function cE(t,e,n){n.setCustomProperty("widgetLabel",e,t)}function lE(t){const e=t.getCustomProperty("widgetLabel");if(!e){return""}return typeof e=="function"?e():e}function dE(t,e,n={}){e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t);e.setAttribute("role","textbox",t);if(n.label){e.setAttribute("aria-label",n.label,t)}e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t);t.on("change:isReadOnly",((n,o,i)=>{e.setAttribute("contenteditable",i?"false":"true",t)}));t.on("change:isFocused",((n,o,i)=>{if(i){e.addClass("ck-editor__nested-editable_focused",t)}else{e.removeClass("ck-editor__nested-editable_focused",t)}}));aE(t,e);return t}function uE(t,e){const n=t.getSelectedElement();if(n){const o=_E(t);if(o){return e.createRange(e.createPositionAt(n,o))}}return u_(t,e)}function hE(t,e){return(n,o)=>{const{mapper:i,viewPosition:r}=o;const s=i.findMappedViewAncestor(r);if(!e(s)){return}const a=i.toModelElement(s);o.modelPosition=t.createPositionAt(a,r.isAtStart?"before":"after")}}function fE(){return null}function gE(t,e){const n=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(t){const e=this.toDomElement(t);const n=new Iv;n.set("content",tE);n.render();e.appendChild(n.element);return e}));e.insert(e.createPositionAt(t,0),n);e.addClass(["ck-widget_with-selection-handle"],t)}const pE="widget-type-around";function mE(t,e,n){return!!t&&oE(t)&&!n.isInline(e)}function kE(t){return t.closest(".ck-widget__type-around__button")}function bE(t){return t.classList.contains("ck-widget__type-around__button_before")?"before":"after"}function wE(t,e){const n=t.closest(".ck-widget");return e.mapDomToView(n)}function _E(t){return t.getAttribute(pE)}const AE='';var vE=n(137);var CE={injectType:"singletonStyleTag",attributes:{"data-cke":true}};CE.insert="head";CE.singleton=true;var yE=Vu()(vE.Z,CE);const xE=vE.Z.locals||{};const EE=["before","after"];const SE=(new DOMParser).parseFromString(AE,"image/svg+xml").firstChild;const DE="ck-widget__type-around_disabled";class TE extends et{constructor(t){super(t);this._currentFakeCaretModelElement=null}static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Fx,Zx]}init(){const t=this.editor;const e=t.editing.view;this.on("change:isEnabled",((n,o,i)=>{e.change((t=>{for(const n of e.document.roots){if(i){t.removeClass(DE,n)}else{t.addClass(DE,n)}}}));if(!i){t.model.change((t=>{t.removeSelectionAttribute(pE)}))}}));this._enableTypeAroundUIInjection();this._enableInsertingParagraphsOnButtonClick();this._enableInsertingParagraphsOnEnterKeypress();this._enableInsertingParagraphsOnTypingKeystroke();this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows();this._enableDeleteIntegration();this._enableInsertContentIntegration();this._enableInsertObjectIntegration();this._enableDeleteContentIntegration()}destroy(){super.destroy();this._currentFakeCaretModelElement=null}_insertParagraph(t,e){const n=this.editor;const o=n.editing.view;const i=n.model.schema.getAttributesWithProperty(t,"copyOnReplace",true);n.execute("insertParagraph",{position:n.model.createPositionAt(t,e),attributes:i});o.focus();o.scrollToTheSelection()}_listenToIfEnabled(t,e,n,o){this.listenTo(t,e,((...t)=>{if(this.isEnabled){n(...t)}}),o)}_insertParagraphAccordingToFakeCaretPosition(){const t=this.editor;const e=t.model;const n=e.document.selection;const o=_E(n);if(!o){return false}const i=n.getSelectedElement();this._insertParagraph(i,o);return true}_enableTypeAroundUIInjection(){const t=this.editor;const e=t.model.schema;const n=t.locale.t;const o={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",((t,n,i)=>{const r=i.mapper.toViewElement(n.item);if(mE(r,n.item,e)){BE(i.writer,o,r)}}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const t=this.editor;const e=t.model;const n=e.document.selection;const o=e.schema;const i=t.editing.view;this._listenToIfEnabled(i.document,"arrowKey",((t,e)=>{this._handleArrowKeyPress(t,e)}),{context:[oE,"$text"],priority:"high"});this._listenToIfEnabled(n,"change:range",((e,n)=>{if(!n.directChange){return}t.model.change((t=>{t.removeSelectionAttribute(pE)}))}));this._listenToIfEnabled(e.document,"change:data",(()=>{const e=n.getSelectedElement();if(e){const n=t.editing.mapper.toViewElement(e);if(mE(n,e,o)){return}}t.model.change((t=>{t.removeSelectionAttribute(pE)}))}));this._listenToIfEnabled(t.editing.downcastDispatcher,"selection",((t,e,n)=>{const i=n.writer;if(this._currentFakeCaretModelElement){const t=n.mapper.toViewElement(this._currentFakeCaretModelElement);if(t){i.removeClass(EE.map(r),t);this._currentFakeCaretModelElement=null}}const s=e.selection.getSelectedElement();if(!s){return}const a=n.mapper.toViewElement(s);if(!mE(a,s,o)){return}const c=_E(e.selection);if(!c){return}i.addClass(r(c),a);this._currentFakeCaretModelElement=s}));this._listenToIfEnabled(t.ui.focusTracker,"change:isFocused",((e,n,o)=>{if(!o){t.model.change((t=>{t.removeSelectionAttribute(pE)}))}}));function r(t){return`ck-widget_type-around_show-fake-caret_${t}`}}_handleArrowKeyPress(t,e){const n=this.editor;const o=n.model;const i=o.document.selection;const r=o.schema;const s=n.editing.view;const a=e.keyCode;const c=$d(a,n.locale.contentLanguageDirection);const l=s.document.selection.getSelectedElement();const d=n.editing.mapper.toModelElement(l);let u;if(mE(l,d,r)){u=this._handleArrowKeyPressOnSelectedWidget(c)}else if(i.isCollapsed){u=this._handleArrowKeyPressWhenSelectionNextToAWidget(c)}else if(!e.shiftKey){u=this._handleArrowKeyPressWhenNonCollapsedSelection(c)}if(u){e.preventDefault();t.stop()}}_handleArrowKeyPressOnSelectedWidget(t){const e=this.editor;const n=e.model;const o=n.document.selection;const i=_E(o);return n.change((e=>{if(i){const n=i===(t?"after":"before");if(!n){e.removeSelectionAttribute(pE);return true}}else{e.setSelectionAttribute(pE,t?"after":"before");return true}return false}))}_handleArrowKeyPressWhenSelectionNextToAWidget(t){const e=this.editor;const n=e.model;const o=n.schema;const i=e.plugins.get("Widget");const r=i._getObjectElementNextToSelection(t);const s=e.editing.mapper.toViewElement(r);if(mE(s,r,o)){n.change((e=>{i._setSelectionOverElement(r);e.setSelectionAttribute(pE,t?"before":"after")}));return true}return false}_handleArrowKeyPressWhenNonCollapsedSelection(t){const e=this.editor;const n=e.model;const o=n.schema;const i=e.editing.mapper;const r=n.document.selection;const s=t?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;const a=i.toViewElement(s);if(mE(a,s,o)){n.change((e=>{e.setSelection(s,"on");e.setSelectionAttribute(pE,t?"after":"before")}));return true}return false}_enableInsertingParagraphsOnButtonClick(){const t=this.editor;const e=t.editing.view;this._listenToIfEnabled(e.document,"mousedown",((n,o)=>{const i=kE(o.domTarget);if(!i){return}const r=bE(i);const s=wE(i,e.domConverter);const a=t.editing.mapper.toModelElement(s);this._insertParagraph(a,r);o.preventDefault();n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const t=this.editor;const e=t.model.document.selection;const n=t.editing.view;this._listenToIfEnabled(n.document,"enter",((n,o)=>{if(n.eventPhase!="atTarget"){return}const i=e.getSelectedElement();const r=t.editing.mapper.toViewElement(i);const s=t.model.schema;let a;if(this._insertParagraphAccordingToFakeCaretPosition()){a=true}else if(mE(r,i,s)){this._insertParagraph(i,o.isSoft?"before":"after");a=true}if(a){o.preventDefault();n.stop()}}),{context:oE})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor;const e=t.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,n)=>{if(this._insertParagraphAccordingToFakeCaretPosition()){n.selection=e.selection}}),{priority:"high"});if(Sd.isAndroid){this._listenToIfEnabled(e,"keydown",((t,e)=>{if(e.keyCode==229){this._insertParagraphAccordingToFakeCaretPosition()}}))}else{this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}}_enableDeleteIntegration(){const t=this.editor;const e=t.editing.view;const n=t.model;const o=n.schema;this._listenToIfEnabled(e.document,"delete",((e,i)=>{if(e.eventPhase!="atTarget"){return}const r=_E(n.document.selection);if(!r){return}const s=i.direction;const a=n.document.selection.getSelectedElement();const c=r==="before";const l=s=="forward";const d=c===l;if(d){t.execute("delete",{selection:n.createSelection(a,"on")})}else{const e=o.getNearestSelectionRange(n.createPositionAt(a,r),s);if(e){if(!e.isCollapsed){n.change((n=>{n.setSelection(e);t.execute(l?"deleteForward":"delete")}))}else{const i=n.createSelection(e.start);n.modifySelection(i,{direction:s});if(!i.focus.isEqual(e.start)){n.change((n=>{n.setSelection(e);t.execute(l?"deleteForward":"delete")}))}else{const t=RE(o,e.start.parent);n.deleteContent(n.createSelection(t,"on"),{doNotAutoparagraph:true})}}}}i.preventDefault();e.stop()}),{context:oE})}_enableInsertContentIntegration(){const t=this.editor;const e=this.editor.model;const n=e.document.selection;this._listenToIfEnabled(t.model,"insertContent",((t,[o,i])=>{if(i&&!i.is("documentSelection")){return}const r=_E(n);if(!r){return}t.stop();return e.change((t=>{const i=n.getSelectedElement();const s=e.createPositionAt(i,r);const a=t.createSelection(s);const c=e.insertContent(o,a);t.setSelection(a);return c}))}),{priority:"high"})}_enableInsertObjectIntegration(){const t=this.editor;const e=this.editor.model;const n=e.document.selection;this._listenToIfEnabled(t.model,"insertObject",((t,e)=>{const[,o,,i={}]=e;if(o&&!o.is("documentSelection")){return}const r=_E(n);if(!r){return}i.findOptimalPosition=r;e[3]=i}),{priority:"high"})}_enableDeleteContentIntegration(){const t=this.editor;const e=this.editor.model;const n=e.document.selection;this._listenToIfEnabled(t.model,"deleteContent",((t,[e])=>{if(e&&!e.is("documentSelection")){return}const o=_E(n);if(o){t.stop()}}),{priority:"high"})}}function BE(t,e,n){const o=t.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(t){const n=this.toDomElement(t);PE(n,e);IE(n);return n}));t.insert(t.createPositionAt(n,"end"),o)}function PE(t,e){for(const n of EE){const o=new B_({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:e[n]},children:[t.ownerDocument.importNode(SE,true)]});t.appendChild(o.render())}}function IE(t){const e=new B_({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});t.appendChild(e.render())}function RE(t,e){let n=e;for(const o of e.getAncestors({parentFirst:true})){if(o.childCount>1||t.isLimit(o)){break}n=o}return n}function OE(t){const e=t.model;return(n,o)=>{const i=o.keyCode==Vd.arrowup;const r=o.keyCode==Vd.arrowdown;const s=o.shiftKey;const a=e.document.selection;if(!i&&!r){return}const c=r;if(s&&NE(a,c)){return}const l=zE(t,a,c);if(!l){return}if(l.isCollapsed){if(a.isCollapsed){return}else if(s){return}}if(l.isCollapsed||VE(t,l,c)){e.change((t=>{const n=c?l.end:l.start;if(s){const o=e.createSelection(a.anchor);o.setFocus(n);t.setSelection(o)}else{t.setSelection(n)}}));n.stop();o.preventDefault();o.stopPropagation()}}}function zE(t,e,n){const o=t.model;if(n){const t=e.isCollapsed?e.focus:e.getLastPosition();const n=ME(o,t,"forward");if(!n){return null}const i=o.createRange(t,n);const r=FE(o.schema,i,"backward");if(r){return o.createRange(t,r)}return null}else{const t=e.isCollapsed?e.focus:e.getFirstPosition();const n=ME(o,t,"backward");if(!n){return null}const i=o.createRange(n,t);const r=FE(o.schema,i,"forward");if(r){return o.createRange(r,t)}return null}}function ME(t,e,n){const o=t.schema;const i=t.createRangeIn(e.root);const r=n=="forward"?"elementStart":"elementEnd";for(const{previousPosition:t,item:s,type:a}of i.getWalker({startPosition:e,direction:n})){if(o.isLimit(s)&&!o.isInline(s)){return t}if(a==r&&o.isBlock(s)){return null}}return null}function FE(t,e,n){const o=n=="backward"?e.end:e.start;if(t.checkChild(o,"$text")){return o}for(const{nextPosition:o}of e.getWalker({direction:n})){if(t.checkChild(o,"$text")){return o}}return null}function VE(t,e,n){const o=t.model;const i=t.view.domConverter;if(n){const t=o.createSelection(e.start);o.modifySelection(t);if(!t.focus.isAtEnd&&!e.start.isEqual(t.focus)){e=o.createRange(t.focus,e.end)}}const r=t.mapper.toViewRange(e);const s=i.viewRangeToDom(r);const a=mg.getDomRangeRects(s);let c;for(const t of a){if(c===undefined){c=Math.round(t.bottom);continue}if(Math.round(t.top)>=c){return false}c=Math.max(c,Math.round(t.bottom))}return true}function NE(t,e){return!t.isCollapsed&&t.isBackward==e}var LE=n(507);var HE={injectType:"singletonStyleTag",attributes:{"data-cke":true}};HE.insert="head";HE.singleton=true;var jE=Vu()(LE.Z,HE);const WE=LE.Z.locals||{};class qE extends et{static get pluginName(){return"Widget"}static get requires(){return[TE,Zx]}init(){const t=this.editor;const e=t.editing.view;const n=e.document;this._previouslySelected=new Set;this.editor.editing.downcastDispatcher.on("selection",((e,n,o)=>{const i=o.writer;const r=n.selection;if(r.isCollapsed){return}const s=r.getSelectedElement();if(!s){return}const a=t.editing.mapper.toViewElement(s);if(!oE(a)){return}if(!o.consumable.consume(r,"selection")){return}i.setSelection(i.createRangeOn(a),{fake:true,label:lE(a)})}));this.editor.editing.downcastDispatcher.on("selection",((t,e,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const o=n.writer;const i=o.document.selection;let r=null;for(const t of i.getRanges()){for(const e of t){const t=e.item;if(oE(t)&&!$E(t,r)){o.addClass(nE,t);this._previouslySelected.add(t);r=t}}}}),{priority:"low"});e.addObserver(kw);this.listenTo(n,"mousedown",((...t)=>this._onMousedown(...t)));this.listenTo(n,"arrowKey",((...t)=>{this._handleSelectionChangeOnArrowKeyPress(...t)}),{context:[oE,"$text"]});this.listenTo(n,"arrowKey",((...t)=>{this._preventDefaultOnArrowKeyPress(...t)}),{context:"$root"});this.listenTo(n,"arrowKey",OE(this.editor.editing),{context:"$text"});this.listenTo(n,"delete",((t,e)=>{if(this._handleDelete(e.direction=="forward")){e.preventDefault();t.stop()}}),{context:"$root"})}_onMousedown(t,e){const n=this.editor;const o=n.editing.view;const i=o.document;let r=e.target;if(UE(r)){if((Sd.isSafari||Sd.isGecko)&&e.domEvent.detail>=3){const t=n.editing.mapper;const o=r.is("attributeElement")?r.findAncestor((t=>!t.is("attributeElement"))):r;const i=t.toModelElement(o);e.preventDefault();this.editor.model.change((t=>{t.setSelection(i,"in")}))}return}if(!oE(r)){r=r.findAncestor(oE);if(!r){return}}if(Sd.isAndroid){e.preventDefault()}if(!i.isFocused){o.focus()}const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(t,e){const n=e.keyCode;const o=this.editor.model;const i=o.schema;const r=o.document.selection;const s=r.getSelectedElement();const a=qd(n,this.editor.locale.contentLanguageDirection);const c=a=="down"||a=="right";const l=a=="up"||a=="down";if(s&&i.isObject(s)){const n=c?r.getLastPosition():r.getFirstPosition();const s=i.getNearestSelectionRange(n,c?"forward":"backward");if(s){o.change((t=>{t.setSelection(s)}));e.preventDefault();t.stop()}return}if(!r.isCollapsed&&!e.shiftKey){const n=r.getFirstPosition();const s=r.getLastPosition();const a=n.nodeAfter;const l=s.nodeBefore;if(a&&i.isObject(a)||l&&i.isObject(l)){o.change((t=>{t.setSelection(c?s:n)}));e.preventDefault();t.stop()}return}if(!r.isCollapsed){return}const d=this._getObjectElementNextToSelection(c);if(d&&i.isObject(d)){if(i.isInline(d)&&l){return}this._setSelectionOverElement(d);e.preventDefault();t.stop()}}_preventDefaultOnArrowKeyPress(t,e){const n=this.editor.model;const o=n.schema;const i=n.document.selection.getSelectedElement();if(i&&o.isObject(i)){e.preventDefault();t.stop()}}_handleDelete(t){if(this.editor.isReadOnly){return}const e=this.editor.model.document;const n=e.selection;if(!n.isCollapsed){return}const o=this._getObjectElementNextToSelection(t);if(o){this.editor.model.change((t=>{let e=n.anchor.parent;while(e.isEmpty){const n=e;e=n.parent;t.remove(n)}this._setSelectionOverElement(o)}));return true}}_setSelectionOverElement(t){this.editor.model.change((e=>{e.setSelection(e.createRangeOn(t))}))}_getObjectElementNextToSelection(t){const e=this.editor.model;const n=e.schema;const o=e.document.selection;const i=e.createSelection(o);e.modifySelection(i,{direction:t?"forward":"backward"});if(i.isEqual(o)){return null}const r=t?i.focus.nodeBefore:i.focus.nodeAfter;if(!!r&&n.isObject(r)){return r}return null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected){t.removeClass(nE,e)}this._previouslySelected.clear()}}function UE(t){let e=t;while(e){if(e.is("editableElement")&&!e.is("rootElement")){return true}if(oE(e)){return false}e=e.parent}return false}function $E(t,e){if(!e){return false}return Array.from(t.getAncestors()).includes(e)}var KE="Expected a function";function GE(t,e,n){var o=true,i=true;if(typeof t!="function"){throw new TypeError(KE)}if(F(n)){o="leading"in n?!!n.leading:o;i="trailing"in n?!!n.trailing:i}return Wh(t,e,{leading:o,maxWait:e,trailing:i})}const ZE=GE;var JE=n(390);var YE={injectType:"singletonStyleTag",attributes:{"data-cke":true}};YE.insert="head";YE.singleton=true;var QE=Vu()(JE.Z,YE);const XE=JE.Z.locals||{};class tS extends et{static get pluginName(){return"DragDrop"}static get requires(){return[Bx,qE]}init(){const t=this.editor;const e=t.editing.view;this._draggedRange=null;this._draggingUid="";this._draggableElement=null;this._updateDropMarkerThrottled=ZE((t=>this._updateDropMarker(t)),40);this._removeDropMarkerDelayed=cS((()=>this._removeDropMarker()),40);this._clearDraggableAttributesDelayed=cS((()=>this._clearDraggableAttributes()),40);e.addObserver(yx);e.addObserver(kw);this._setupDragging();this._setupContentInsertionIntegration();this._setupClipboardInputIntegration();this._setupDropMarker();this._setupDraggableAttributeHandling();this.listenTo(t,"change:isReadOnly",((t,e,n)=>{if(n){this.forceDisabled("readOnlyMode")}else{this.clearForceDisabled("readOnlyMode")}}));this.on("change:isEnabled",((t,e,n)=>{if(!n){this._finalizeDragging(false)}}));if(Sd.isAndroid){this.forceDisabled("noAndroidSupport")}}destroy(){if(this._draggedRange){this._draggedRange.detach();this._draggedRange=null}this._updateDropMarkerThrottled.cancel();this._removeDropMarkerDelayed.cancel();this._clearDraggableAttributesDelayed.cancel();return super.destroy()}_setupDragging(){const t=this.editor;const e=t.model;const n=e.document;const o=t.editing.view;const i=o.document;this.listenTo(i,"dragstart",((o,r)=>{const a=n.selection;if(r.target&&r.target.is("editableElement")){r.preventDefault();return}const c=r.target?lS(r.target):null;if(c){const n=t.editing.mapper.toModelElement(c);this._draggedRange=dp.fromRange(e.createRangeOn(n));if(t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}}else if(!i.selection.isCollapsed){const t=i.selection.getSelectedElement();if(!t||!oE(t)){this._draggedRange=dp.fromRange(a.getFirstRange())}}if(!this._draggedRange){r.preventDefault();return}this._draggingUid=s();r.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy";r.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const l=e.createSelection(this._draggedRange.toRange());const d=t.data.toView(e.getSelectedContent(l));i.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:d,method:"dragstart"});if(!this.isEnabled){this._draggedRange.detach();this._draggedRange=null;this._draggingUid=""}}),{priority:"low"});this.listenTo(i,"dragend",((t,e)=>{this._finalizeDragging(!e.dataTransfer.isCanceled&&e.dataTransfer.dropEffect=="move")}),{priority:"low"});this.listenTo(i,"dragenter",(()=>{if(!this.isEnabled){return}o.focus()}));this.listenTo(i,"dragleave",(()=>{this._removeDropMarkerDelayed()}));this.listenTo(i,"dragging",((e,n)=>{if(!this.isEnabled){n.dataTransfer.dropEffect="none";return}this._removeDropMarkerDelayed.cancel();const o=eS(t,n.targetRanges,n.target);if(!this._draggedRange){n.dataTransfer.dropEffect="copy"}if(!Sd.isGecko){if(n.dataTransfer.effectAllowed=="copy"){n.dataTransfer.dropEffect="copy"}else if(["all","copyMove"].includes(n.dataTransfer.effectAllowed)){n.dataTransfer.dropEffect="move"}}if(o){this._updateDropMarkerThrottled(o)}}),{priority:"low"})}_setupClipboardInputIntegration(){const t=this.editor;const e=t.editing.view;const n=e.document;this.listenTo(n,"clipboardInput",((e,n)=>{if(n.method!="drop"){return}const o=eS(t,n.targetRanges,n.target);this._removeDropMarker();if(!o){this._finalizeDragging(false);e.stop();return}if(this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")){this._draggedRange.detach();this._draggedRange=null;this._draggingUid=""}const i=aS(n.dataTransfer)=="move";if(i&&this._draggedRange&&this._draggedRange.containsRange(o,true)){this._finalizeDragging(false);e.stop();return}n.targetRanges=[t.editing.mapper.toViewRange(o)]}),{priority:"high"})}_setupContentInsertionIntegration(){const t=this.editor.plugins.get(Bx);t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||e.method!=="drop"){return}const n=e.targetRanges.map((t=>this.editor.editing.mapper.toModelRange(t)));this.editor.model.change((t=>t.setSelection(n)))}),{priority:"high"});t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||e.method!=="drop"){return}const n=aS(e.dataTransfer)=="move";const o=!e.resultRange||!e.resultRange.isCollapsed;this._finalizeDragging(o&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const t=this.editor;const e=t.editing.view;const n=e.document;this.listenTo(n,"mousedown",((o,i)=>{if(Sd.isAndroid||!i){return}this._clearDraggableAttributesDelayed.cancel();let r=lS(i.target);if(Sd.isBlink&&!t.isReadOnly&&!r&&!n.selection.isCollapsed){const t=n.selection.getSelectedElement();if(!t||!oE(t)){r=n.selection.editableElement}}if(r){e.change((t=>{t.setAttribute("draggable","true",r)}));this._draggableElement=t.editing.mapper.toModelElement(r)}}));this.listenTo(n,"mouseup",(()=>{if(!Sd.isAndroid){this._clearDraggableAttributesDelayed()}}))}_clearDraggableAttributes(){const t=this.editor.editing;t.view.change((e=>{if(this._draggableElement&&this._draggableElement.root.rootName!="$graveyard"){e.removeAttribute("draggable",t.mapper.toViewElement(this._draggableElement))}this._draggableElement=null}))}_setupDropMarker(){const t=this.editor;t.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}});t.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(e,{writer:n})=>{const o=t.model.schema.checkChild(e.markerRange.start,"$text");if(!o){return}return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(t){const e=this.toDomElement(t);e.append("",t.createElement("span"),"");return e}))}})}_updateDropMarker(t){const e=this.editor;const n=e.model.markers;e.model.change((e=>{if(n.has("drop-target")){if(!n.get("drop-target").getRange().isEqual(t)){e.updateMarker("drop-target",{range:t})}}else{e.addMarker("drop-target",{range:t,usingOperation:false,affectsData:false})}}))}_removeDropMarker(){const t=this.editor.model;this._removeDropMarkerDelayed.cancel();this._updateDropMarkerThrottled.cancel();if(t.markers.has("drop-target")){t.change((t=>{t.removeMarker("drop-target")}))}}_finalizeDragging(t){const e=this.editor;const n=e.model;this._removeDropMarker();this._clearDraggableAttributes();if(e.plugins.has("WidgetToolbarRepository")){e.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="";if(!this._draggedRange){return}if(t&&this.isEnabled){n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:true})}this._draggedRange.detach();this._draggedRange=null}}function eS(t,e,n){const o=t.model;const i=t.editing.mapper;let r=null;const s=e?e[0].start:null;if(n.is("uiElement")){n=n.parent}r=nS(t,n);if(r){return r}const a=sS(t,n);const c=s?i.toModelPosition(s):null;if(!c){return oS(t,a)}r=iS(t,c,a);if(r){return r}r=o.schema.getNearestSelectionRange(c,Sd.isGecko?"forward":"backward");if(r){return r}return rS(t,c.parent)}function nS(t,e){const n=t.model;const o=t.editing.mapper;if(oE(e)){return n.createRangeOn(o.toModelElement(e))}if(!e.is("editableElement")){const t=e.findAncestor((t=>oE(t)||t.is("editableElement")));if(oE(t)){return n.createRangeOn(o.toModelElement(t))}}return null}function oS(t,e){const n=t.model;const o=n.schema;const i=n.createPositionAt(e,0);return o.getNearestSelectionRange(i,"forward")}function iS(t,e,n){const o=t.model;if(!o.schema.checkChild(n,"$block")){return null}const i=o.createPositionAt(n,0);const r=e.path.slice(0,i.path.length);const s=o.createPositionFromPath(e.root,r);const a=s.nodeAfter;if(a&&o.schema.isObject(a)){return o.createRangeOn(a)}return null}function rS(t,e){const n=t.model;let o=e;while(o){if(n.schema.isObject(o)){return n.createRangeOn(o)}o=o.parent}return null}function sS(t,e){const n=t.editing.mapper;const o=t.editing.view;const i=n.toModelElement(e);if(i){return i}const r=o.createPositionBefore(e);const s=n.findMappedViewAncestor(r);return n.toModelElement(s)}function aS(t){if(Sd.isGecko){return t.dropEffect}return["all","copyMove"].includes(t.effectAllowed)?"move":"copy"}function cS(t,e){let n;function o(...i){o.cancel();n=setTimeout((()=>t(...i)),e)}o.cancel=()=>{clearTimeout(n)};return o}function lS(t){if(t.is("editableElement")){return null}if(t.hasClass("ck-widget__selection-handle")){return t.findAncestor(oE)}if(oE(t)){return t}const e=t.findAncestor((t=>oE(t)||t.is("editableElement")));if(oE(e)){return e}return null}class dS extends et{static get pluginName(){return"PastePlainText"}static get requires(){return[Bx]}init(){const t=this.editor;const e=t.model;const n=t.editing.view;const o=n.document;const i=e.document.selection;let r=false;n.addObserver(yx);this.listenTo(o,"keydown",((t,e)=>{r=e.shiftKey}));t.plugins.get(Bx).on("contentInsertion",((t,n)=>{if(!r&&!uS(n.content,e.schema)){return}e.change((t=>{const o=Array.from(i.getAttributes()).filter((([t])=>e.schema.getAttributeProperties(t).isFormatting));if(!i.isCollapsed){e.deleteContent(i,{doNotAutoparagraph:true})}o.push(...i.getAttributes());const r=t.createRangeIn(n.content);for(const e of r.getItems()){if(e.is("$textProxy")){t.setAttributes(o,e)}}}))}))}}function uS(t,e){if(t.childCount>1){return false}const n=t.getChild(0);if(e.isObject(n)){return false}return Array.from(n.getAttributeKeys()).length==0}class hS extends et{static get pluginName(){return"Clipboard"}static get requires(){return[Bx,tS,dS]}}class fS extends ot{execute(){const t=this.editor.model;const e=t.document;t.change((n=>{pS(t,n,e.selection);this.fire("afterExecute",{writer:n})}))}refresh(){const t=this.editor.model;const e=t.document;this.isEnabled=gS(t.schema,e.selection)}}function gS(t,e){if(e.rangeCount>1){return false}const n=e.anchor;if(!n||!t.checkChild(n,"softBreak")){return false}const o=e.getFirstRange();const i=o.start.parent;const r=o.end.parent;if((kS(i,t)||kS(r,t))&&i!==r){return false}return true}function pS(t,e,n){const o=n.isCollapsed;const i=n.getFirstRange();const r=i.start.parent;const s=i.end.parent;const a=r==s;if(o){const o=Px(t.schema,n.getAttributes());mS(t,e,i.end);e.removeSelectionAttribute(n.getAttributeKeys());e.setSelectionAttribute(o)}else{const o=!(i.start.isAtStart&&i.end.isAtEnd);t.deleteContent(n,{leaveUnmerged:o});if(a){mS(t,e,n.focus)}else{if(o){e.setSelection(s,0)}}}}function mS(t,e,n){const o=e.createElement("softBreak");t.insertContent(o,n);e.setSelection(o,"after")}function kS(t,e){if(t.is("rootElement")){return false}return e.isLimit(t)||kS(t.parent,e)}class bS extends et{static get pluginName(){return"ShiftEnter"}init(){const t=this.editor;const e=t.model.schema;const n=t.conversion;const o=t.editing.view;const i=o.document;e.register("softBreak",{allowWhere:"$text",isInline:true});n.for("upcast").elementToElement({model:"softBreak",view:"br"});n.for("downcast").elementToElement({model:"softBreak",view:(t,{writer:e})=>e.createEmptyElement("br")});o.addObserver(Mx);t.commands.add("shiftEnter",new fS(t));this.listenTo(i,"enter",((e,n)=>{if(!i.isComposing){n.preventDefault()}if(!n.isSoft){return}t.execute("shiftEnter");o.scrollToTheSelection()}),{priority:"low"})}}class wS extends ot{constructor(t){super(t);this.affectsData=false}execute(){const t=this.editor.model;const e=t.document.selection;let n=t.schema.getLimitElement(e);if(e.containsEntireContent(n)||!_S(t.schema,n)){do{n=n.parent;if(!n){return}}while(!_S(t.schema,n))}t.change((t=>{t.setSelection(n,"in")}))}}function _S(t,e){return t.isLimit(e)&&(t.checkChild(e,"$text")||t.checkChild(e,"paragraph"))}const AS=Hd("Ctrl+A");class vS extends et{static get pluginName(){return"SelectAllEditing"}init(){const t=this.editor;const e=t.editing.view;const n=e.document;t.commands.add("selectAll",new wS(t));this.listenTo(n,"keydown",((e,n)=>{if(Ld(n)===AS){t.execute("selectAll");n.preventDefault()}}))}}const CS='';class yS extends et{static get pluginName(){return"SelectAllUI"}init(){const t=this.editor;t.ui.componentFactory.add("selectAll",(e=>{const n=t.commands.get("selectAll");const o=new Fv(e);const i=e.t;o.set({label:i("Select all"),icon:CS,keystroke:"Ctrl+A",tooltip:true});o.bind("isEnabled").to(n,"isEnabled");this.listenTo(o,"execute",(()=>{t.execute("selectAll");t.editing.view.focus()}));return o}))}}class xS extends et{static get requires(){return[vS,yS]}static get pluginName(){return"SelectAll"}}class ES extends ot{constructor(t,e){super(t);this._buffer=new Vx(t.model,e)}get buffer(){return this._buffer}destroy(){super.destroy();this._buffer.destroy()}execute(t={}){const e=this.editor.model;const n=e.document;const o=t.text||"";const i=o.length;let r=n.selection;if(t.selection){r=t.selection}else if(t.range){r=e.createSelection(t.range)}const s=t.resultRange;e.enqueueChange(this._buffer.batch,(t=>{this._buffer.lock();e.deleteContent(r);if(o){e.insertContent(t.createText(o,n.selection.getAttributes()),r)}if(s){t.setSelection(s)}else if(!r.is("documentSelection")){t.setSelection(r)}this._buffer.unlock();this._buffer.input(i)}))}}const SS=["insertText","insertReplacementText"];class DS extends bh{constructor(t){super(t);if(Sd.isAndroid){SS.push("insertCompositionText")}const e=t.document;e.on("beforeinput",((n,o)=>{if(!this.isEnabled){return}const{data:r,targetRanges:s,inputType:a,domEvent:c}=o;if(!SS.includes(a)){return}const l=new i(e,"insertText");e.fire(l,new Ah(t,c,{text:r,selection:t.createSelection(s)}));if(l.stop.called){n.stop()}}));e.on("compositionend",((n,{data:o,domEvent:i})=>{if(!this.isEnabled||Sd.isAndroid){return}if(!o){return}e.fire("insertText",new Ah(t,i,{text:o,selection:e.selection}))}),{priority:"lowest"})}observe(){}}class TS extends et{static get pluginName(){return"Input"}init(){const t=this.editor;const e=t.model;const n=t.editing.view;const o=e.document.selection;n.addObserver(DS);const i=new ES(t,t.config.get("typing.undoStep")||20);t.commands.add("insertText",i);t.commands.add("input",i);this.listenTo(n.document,"insertText",((o,i)=>{if(!n.document.isComposing){i.preventDefault()}const{text:r,selection:s,resultRange:a}=i;const c=Array.from(s.getRanges()).map((e=>t.editing.mapper.toModelRange(e)));let l=r;if(Sd.isAndroid){const t=Array.from(c[0].getItems()).reduce(((t,e)=>t+(e.is("$textProxy")?e.data:"")),"");if(t){if(t.length<=l.length){if(l.startsWith(t)){l=l.substring(t.length);c[0].start=c[0].start.getShiftedBy(t.length)}}else{if(t.startsWith(l)){c[0].start=c[0].start.getShiftedBy(l.length);l=""}}}}const d={text:l,selection:e.createSelection(c)};if(a){d.resultRange=t.editing.mapper.toModelRange(a)}t.execute("insertText",d)}));if(Sd.isAndroid){this.listenTo(n.document,"keydown",((t,r)=>{if(o.isCollapsed||r.keyCode!=229||!n.document.isComposing){return}BS(e,i)}))}else{this.listenTo(n.document,"compositionstart",(()=>{if(o.isCollapsed){return}BS(e,i)}))}}}function BS(t,e){if(!e.isEnabled){return}const n=e.buffer;n.lock();t.enqueueChange(n.batch,(()=>{t.deleteContent(t.document.selection)}));n.unlock()}class PS extends et{static get requires(){return[TS,Zx]}static get pluginName(){return"Typing"}}function IS(t,e){let n=t.start;const o=Array.from(t.getItems()).reduce(((t,o)=>{if(!(o.is("$text")||o.is("$textProxy"))){n=e.createPositionAfter(o);return""}return t+o.data}),"");return{text:o,range:e.createRange(n,t.end)}}class RS extends q{constructor(t,e){super();this.model=t;this.testCallback=e;this._hasMatch=false;this.set("isEnabled",true);this.on("change:isEnabled",(()=>{if(this.isEnabled){this._startListening()}else{this.stopListening(t.document.selection);this.stopListening(t.document)}}));this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const t=this.model;const e=t.document;this.listenTo(e.selection,"change:range",((t,{directChange:n})=>{if(!n){return}if(!e.selection.isCollapsed){if(this.hasMatch){this.fire("unmatched");this._hasMatch=false}return}this._evaluateTextBeforeSelection("selection")}));this.listenTo(e,"change:data",((t,e)=>{if(e.isUndo||!e.isLocal){return}this._evaluateTextBeforeSelection("data",{batch:e})}))}_evaluateTextBeforeSelection(t,e={}){const n=this.model;const o=n.document;const i=o.selection;const r=n.createRange(n.createPositionAt(i.focus.parent,0),i.focus);const{text:s,range:a}=IS(r,n);const c=this.testCallback(s);if(!c&&this.hasMatch){this.fire("unmatched")}this._hasMatch=!!c;if(c){const n=Object.assign(e,{text:s,range:a});if(typeof c=="object"){Object.assign(n,c)}this.fire(`matched:${t}`,n)}}}class OS extends et{constructor(t){super(t);this.attributes=new Set;this._overrideUid=null}static get pluginName(){return"TwoStepCaretMovement"}init(){const t=this.editor;const e=t.model;const n=t.editing.view;const o=t.locale;const i=e.document.selection;this.listenTo(n.document,"arrowKey",((t,e)=>{if(!i.isCollapsed){return}if(e.shiftKey||e.altKey||e.ctrlKey){return}const n=e.keyCode==Vd.arrowright;const r=e.keyCode==Vd.arrowleft;if(!n&&!r){return}const s=o.contentLanguageDirection;let a=false;if(s==="ltr"&&n||s==="rtl"&&r){a=this._handleForwardMovement(e)}else{a=this._handleBackwardMovement(e)}if(a===true){t.stop()}}),{context:"$text",priority:"highest"});this._isNextGravityRestorationSkipped=false;this.listenTo(i,"change:range",((t,e)=>{if(this._isNextGravityRestorationSkipped){this._isNextGravityRestorationSkipped=false;return}if(!this._isGravityOverridden){return}if(!e.directChange&&NS(i.getFirstPosition(),this.attributes)){return}this._restoreGravity()}))}registerAttribute(t){this.attributes.add(t)}_handleForwardMovement(t){const e=this.attributes;const n=this.editor.model;const o=n.document.selection;const i=o.getFirstPosition();if(this._isGravityOverridden){return false}if(i.isAtStart&&zS(o,e)){return false}if(NS(i,e)){FS(t);this._overrideGravity();return true}return false}_handleBackwardMovement(t){const e=this.attributes;const n=this.editor.model;const o=n.document.selection;const i=o.getFirstPosition();if(this._isGravityOverridden){FS(t);this._restoreGravity();MS(n,e,i);return true}else{if(i.isAtStart){if(zS(o,e)){FS(t);MS(n,e,i);return true}return false}if(VS(i,e)){if(i.isAtEnd&&!zS(o,e)&&NS(i,e)){FS(t);MS(n,e,i);return true}this._isNextGravityRestorationSkipped=true;this._overrideGravity();return false}}return false}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((t=>t.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((t=>{t.restoreSelectionGravity(this._overrideUid);this._overrideUid=null}))}}function zS(t,e){for(const n of e){if(t.hasAttribute(n)){return true}}return false}function MS(t,e,n){const o=n.nodeBefore;t.change((t=>{if(o){t.setSelectionAttribute(o.getAttributes())}else{t.removeSelectionAttribute(e)}}))}function FS(t){t.preventDefault()}function VS(t,e){const n=t.getShiftedBy(-1);return NS(n,e)}function NS(t,e){const{nodeBefore:n,nodeAfter:o}=t;for(const t of e){const e=n?n.getAttribute(t):undefined;const i=o?o.getAttribute(t):undefined;if(i!==e){return true}}return false}const LS={copyright:{from:"(c)",to:"©"},registeredTrademark:{from:"(r)",to:"®"},trademark:{from:"(tm)",to:"™"},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,"½",null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,"⅓",null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,"⅔",null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,"¼",null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,"¾",null]},lessThanOrEqual:{from:"<=",to:"≤"},greaterThanOrEqual:{from:">=",to:"≥"},notEqual:{from:"!=",to:"≠"},arrowLeft:{from:"<-",to:"←"},arrowRight:{from:"->",to:"→"},horizontalEllipsis:{from:"...",to:"…"},enDash:{from:/(^| )(--)( )$/,to:[null,"–",null]},emDash:{from:/(^| )(---)( )$/,to:[null,"—",null]},quotesPrimary:{from:KS('"'),to:[null,"“",null,"”"]},quotesSecondary:{from:KS("'"),to:[null,"‘",null,"’"]},quotesPrimaryEnGb:{from:KS("'"),to:[null,"‘",null,"’"]},quotesSecondaryEnGb:{from:KS('"'),to:[null,"“",null,"”"]},quotesPrimaryPl:{from:KS('"'),to:[null,"„",null,"”"]},quotesSecondaryPl:{from:KS("'"),to:[null,"‚",null,"’"]}};const HS={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]};const jS=null&&["symbols","mathematical","typography","quotes"];class WS extends(null&&Plugin){static get requires(){return["Delete","Input"]}static get pluginName(){return"TextTransformation"}constructor(t){super(t);t.config.define("typing",{transformations:{include:jS}})}init(){const t=this.editor.model;const e=t.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}));this._enableTransformationWatchers()}_enableTransformationWatchers(){const t=this.editor;const e=t.model;const n=t.plugins.get("Delete");const o=GS(t.config.get("typing.transformations"));const i=t=>{for(const e of o){const n=e.from;const o=n.test(t);if(o){return{normalizedTransformation:e}}}};const r=new TextWatcher(t.model,i);r.on("matched:data",((t,o)=>{if(!o.batch.isTyping){return}const{from:i,to:r}=o.normalizedTransformation;const s=i.exec(o.text);const a=r(s.slice(1));const c=o.range;let l=s.index;e.enqueueChange((t=>{for(let n=1;n{n.requestUndoOnBackspace()}))}))}));r.bind("isEnabled").to(this)}}function qS(t){if(typeof t=="string"){return new RegExp(`(${escapeRegExp(t)})$`)}return t}function US(t){if(typeof t=="string"){return()=>[t]}else if(t instanceof Array){return()=>t}return t}function $S(t){const e=t.textNode?t.textNode:t.nodeAfter;return e.getAttributes()}function KS(t){return new RegExp(`(^|\\s)(${t})([^${t}]*)(${t})$`)}function GS(t){const e=t.extra||[];const n=t.remove||[];const o=t=>!n.includes(t);const i=t.include.concat(e).filter(o);return ZS(i).filter(o).map((t=>typeof t=="string"&&LS[t]?LS[t]:t)).filter((t=>typeof t==="object")).map((t=>({from:qS(t.from),to:US(t.to)})))}function ZS(t){const e=new Set;for(const n of t){if(typeof n=="string"&&HS[n]){for(const t of HS[n]){e.add(t)}}else{e.add(n)}}return Array.from(e)}function JS(t,e,n,o){return o.createRange(YS(t,e,n,true,o),YS(t,e,n,false,o))}function YS(t,e,n,o,i){let r=t.textNode||(o?t.nodeBefore:t.nodeAfter);let s=null;while(r&&r.getAttribute(e)==n){s=r;r=o?r.previousSibling:r.nextSibling}return s?i.createPositionAt(s,o?"before":"after"):t}function QS(t,e,n,o){const i=t.editing.view;const r=new Set;i.document.registerPostFixer((i=>{const s=t.model.document.selection;let a=false;if(s.hasAttribute(e)){const c=JS(s.getFirstPosition(),e,s.getAttribute(e),t.model);const l=t.editing.mapper.toViewRange(c);for(const t of l.getItems()){if(t.is("element",n)&&!t.hasClass(o)){i.addClass(o,t);r.add(t);a=true}}}return a}));t.conversion.for("editingDowncast").add((t=>{t.on("insert",e,{priority:"highest"});t.on("remove",e,{priority:"highest"});t.on("attribute",e,{priority:"highest"});t.on("selection",e,{priority:"highest"});function e(){i.change((t=>{for(const e of r.values()){t.removeClass(o,e);r.delete(e)}}))}}))}class XS extends ot{constructor(t){super(t);this._stack=[];this._createdBatches=new WeakSet;this.refresh();this.listenTo(t.data,"set",((t,e)=>{e[1]={...e[1]};const n=e[1];if(!n.batchType){n.batchType={isUndoable:false}}}),{priority:"high"});this.listenTo(t.data,"set",((t,e)=>{const n=e[1];if(!n.batchType.isUndoable){this.clearStack()}}))}refresh(){this.isEnabled=this._stack.length>0}addBatch(t){const e=this.editor.model.document.selection;const n={ranges:e.hasOwnRange?Array.from(e.getRanges()):[],isBackward:e.isBackward};this._stack.push({batch:t,selection:n});this.refresh()}clearStack(){this._stack=[];this.refresh()}_restoreSelection(t,e,n){const o=this.editor.model;const i=o.document;const r=[];const s=t.map((t=>t.getTransformedByOperations(n)));const a=s.flat();for(const t of s){const e=t.filter((t=>t.root!=i.graveyard)).filter((t=>!eD(t,a)));if(!e.length){continue}tD(e);r.push(e[0])}if(r.length){o.change((t=>{t.setSelection(r,{backward:e})}))}}_undo(t,e){const n=this.editor.model;const o=n.document;this._createdBatches.add(e);const i=t.operations.slice().filter((t=>t.isDocumentOperation));i.reverse();for(const t of i){const i=t.baseVersion+1;const r=Array.from(o.history.getOperations(i));const s=cw([t.getReversed()],r,{useRelations:true,document:this.editor.model.document,padWithNoOps:false,forceWeakRemove:true});const a=s.operationsA;for(const i of a){e.addOperation(i);n.applyOperation(i);o.history.setOperationAsUndone(t,i)}}}}function tD(t){t.sort(((t,e)=>t.start.isBefore(e.start)?-1:1));for(let e=1;ee!==t&&e.containsRange(t,true)))}class nD extends XS{execute(t=null){const e=t?this._stack.findIndex((e=>e.batch==t)):this._stack.length-1;const n=this._stack.splice(e,1)[0];const o=this.editor.model.createBatch({isUndo:true});this.editor.model.enqueueChange(o,(()=>{this._undo(n.batch,o);const t=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,t);this.fire("revert",n.batch,o)}));this.refresh()}}class oD extends XS{execute(){const t=this._stack.pop();const e=this.editor.model.createBatch({isUndo:true});this.editor.model.enqueueChange(e,(()=>{const n=t.batch.operations[t.batch.operations.length-1];const o=n.baseVersion+1;const i=this.editor.model.document.history.getOperations(o);this._restoreSelection(t.selection.ranges,t.selection.isBackward,i);this._undo(t.batch,e)}));this.refresh()}}class iD extends et{constructor(t){super(t);this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const t=this.editor;this._undoCommand=new nD(t);this._redoCommand=new oD(t);t.commands.add("undo",this._undoCommand);t.commands.add("redo",this._redoCommand);this.listenTo(t.model,"applyOperation",((t,e)=>{const n=e[0];if(!n.isDocumentOperation){return}const o=n.batch;const i=this._redoCommand._createdBatches.has(o);const r=this._undoCommand._createdBatches.has(o);const s=this._batchRegistry.has(o);if(s){return}this._batchRegistry.add(o);if(!o.isUndoable){return}if(i){this._undoCommand.addBatch(o)}else if(!r){this._undoCommand.addBatch(o);this._redoCommand.clearStack()}}),{priority:"highest"});this.listenTo(this._undoCommand,"revert",((t,e,n)=>{this._redoCommand.addBatch(n)}));t.keystrokes.set("CTRL+Z","undo");t.keystrokes.set("CTRL+Y","redo");t.keystrokes.set("CTRL+SHIFT+Z","redo")}}const rD='';const sD='';class aD extends et{static get pluginName(){return"UndoUI"}init(){const t=this.editor;const e=t.locale;const n=t.t;const o=e.uiLanguageDirection=="ltr"?rD:sD;const i=e.uiLanguageDirection=="ltr"?sD:rD;this._addButton("undo",n("Undo"),"CTRL+Z",o);this._addButton("redo",n("Redo"),"CTRL+Y",i)}_addButton(t,e,n,o){const i=this.editor;i.ui.componentFactory.add(t,(r=>{const s=i.commands.get(t);const a=new Fv(r);a.set({label:e,icon:o,keystroke:n,tooltip:true});a.bind("isEnabled").to(s,"isEnabled");this.listenTo(a,"execute",(()=>{i.execute(t);i.editing.view.focus()}));return a}))}}class cD extends et{static get requires(){return[iD,aD]}static get pluginName(){return"Undo"}}class lD extends et{static get requires(){return[hS,Fx,xS,bS,PS,cD]}static get pluginName(){return"Essentials"}}class dD extends ot{refresh(){const t=this.editor.model;const e=t.document;const n=cg(e.selection.getSelectedBlocks());this.value=!!n&&n.is("element","paragraph");this.isEnabled=!!n&&uD(n,t.schema)}execute(t={}){const e=this.editor.model;const n=e.document;e.change((o=>{const i=(t.selection||n.selection).getSelectedBlocks();for(const t of i){if(!t.is("element","paragraph")&&uD(t,e.schema)){o.rename(t,"paragraph")}}}))}}function uD(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}class hD extends ot{execute(t){const e=this.editor.model;const n=t.attributes;let o=t.position;e.change((t=>{const i=t.createElement("paragraph");if(n){e.schema.setAllowedAttributes(i,n,t)}if(!e.schema.checkChild(o.parent,i)){const n=e.schema.findAllowedParent(o,i);if(!n){return}o=t.split(o,n).position}e.insertContent(i,o);t.setSelection(i,"in")}))}}class fD extends et{static get pluginName(){return"Paragraph"}init(){const t=this.editor;const e=t.model;t.commands.add("paragraph",new dD(t));t.commands.add("insertParagraph",new hD(t));e.schema.register("paragraph",{inheritAllFrom:"$block"});t.conversion.elementToElement({model:"paragraph",view:"p"});t.conversion.for("upcast").elementToElement({model:(t,{writer:e})=>{if(!fD.paragraphLikeElements.has(t.name)){return null}if(t.isEmpty){return null}return e.createElement("paragraph")},view:/.+/,converterPriority:"low"})}}fD.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class gD extends(null&&Plugin){init(){const t=this.editor;const e=t.t;t.ui.componentFactory.add("paragraph",(n=>{const o=new ButtonView(n);const i=t.commands.get("paragraph");o.label=e("Paragraph");o.icon=icon;o.tooltip=true;o.isToggleable=true;o.bind("isEnabled").to(i);o.bind("isOn").to(i,"value");o.on("execute",(()=>{t.execute("paragraph")}));return o}))}}class pD extends ot{constructor(t,e){super(t);this.modelElements=e}refresh(){const t=cg(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name;this.isEnabled=!!t&&this.modelElements.some((e=>mD(t,e,this.editor.model.schema)))}execute(t){const e=this.editor.model;const n=e.document;const o=t.value;e.change((t=>{const i=Array.from(n.selection.getSelectedBlocks()).filter((t=>mD(t,o,e.schema)));for(const e of i){if(!e.is("element",o)){t.rename(e,o)}}}))}}function mD(t,e,n){return n.checkChild(t.parent,e)&&!n.isObject(t)}const kD="paragraph";class bD extends et{static get pluginName(){return"HeadingEditing"}constructor(t){super(t);t.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[fD]}init(){const t=this.editor;const e=t.config.get("heading.options");const n=[];for(const o of e){if(o.model!==kD){t.model.schema.register(o.model,{inheritAllFrom:"$block"});t.conversion.elementToElement(o);n.push(o.model)}}this._addDefaultH1Conversion(t);t.commands.add("heading",new pD(t,n))}afterInit(){const t=this.editor;const e=t.commands.get("enter");const n=t.config.get("heading.options");if(e){this.listenTo(e,"afterExecute",((e,o)=>{const i=t.model.document.selection.getFirstPosition().parent;const r=n.some((t=>i.is("element",t.model)));if(r&&!i.is("element",kD)&&i.childCount===0){o.writer.rename(i,kD)}}))}}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:c.get("low")+1})}}function wD(t){const e=t.t;const n={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return t.config.get("heading.options").map((t=>{const e=n[t.title];if(e&&e!=t.title){t.title=e}return t}))}var _D=n(230);var AD={injectType:"singletonStyleTag",attributes:{"data-cke":true}};AD.insert="head";AD.singleton=true;var vD=Vu()(_D.Z,AD);const CD=_D.Z.locals||{};class yD extends et{static get pluginName(){return"HeadingUI"}init(){const t=this.editor;const e=t.t;const n=wD(t);const o=e("Choose heading");const i=e("Heading");t.ui.componentFactory.add("heading",(e=>{const r={};const s=new Ca;const a=t.commands.get("heading");const c=t.commands.get("paragraph");const l=[a];for(const t of n){const e={type:"button",model:new Iy({label:t.title,class:t.class,withText:true})};if(t.model==="paragraph"){e.model.bind("isOn").to(c,"value");e.model.set("commandName","paragraph");l.push(c)}else{e.model.bind("isOn").to(a,"value",(e=>e===t.model));e.model.set({commandName:"heading",commandValue:t.model})}s.add(e);r[t.model]=t.title}const d=NC(e);HC(d,s);d.buttonView.set({isOn:false,withText:true,tooltip:i});d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}});d.bind("isEnabled").toMany(l,"isEnabled",((...t)=>t.some((t=>t))));d.buttonView.bind("label").to(a,"value",c,"value",((t,e)=>{const n=t||e&&"paragraph";return r[n]?r[n]:o}));this.listenTo(d,"execute",(e=>{t.execute(e.source.commandName,e.source.commandValue?{value:e.source.commandValue}:undefined);t.editing.view.focus()}));return d}))}}class xD extends et{static get requires(){return[bD,yD]}static get pluginName(){return"Heading"}}class ED extends et{static get requires(){return[qy]}static get pluginName(){return"WidgetToolbarRepository"}init(){const t=this.editor;if(t.plugins.has("BalloonToolbar")){const e=t.plugins.get("BalloonToolbar");this.listenTo(e,"show",(e=>{if(TD(t.editing.view.document.selection)){e.stop()}}),{priority:"high"})}this._toolbarDefinitions=new Map;this._balloon=this.editor.plugins.get("ContextualBalloon");this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()}));this.listenTo(t.ui,"update",(()=>{this._updateToolbarsVisibility()}));this.listenTo(t.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const t of this._toolbarDefinitions.values()){t.view.destroy()}}register(t,{ariaLabel:e,items:n,getRelatedElement:o,balloonClassName:i="ck-toolbar-container"}){if(!n.length){h("widget-toolbar-no-items",{toolbarId:t});return}const r=this.editor;const s=r.t;const a=new _C(r.locale);a.ariaLabel=e||s("Widget toolbar");if(this._toolbarDefinitions.has(t)){throw new u("widget-toolbar-duplicated",this,{toolbarId:t})}a.fillFromConfig(n,r.ui.componentFactory);const c={view:a,getRelatedElement:o,balloonClassName:i};r.ui.addToolbar(a,{isContextual:true,beforeFocus:()=>{const t=o(r.editing.view.document.selection);if(t){this._showToolbar(c,t)}},afterBlur:()=>{this._hideToolbar(c)}});this._toolbarDefinitions.set(t,c)}_updateToolbarsVisibility(){let t=0;let e=null;let n=null;for(const o of this._toolbarDefinitions.values()){const i=o.getRelatedElement(this.editor.editing.view.document.selection);if(!this.isEnabled||!i){if(this._isToolbarInBalloon(o)){this._hideToolbar(o)}}else if(!this.editor.ui.focusTracker.isFocused){if(this._isToolbarVisible(o)){this._hideToolbar(o)}}else{const r=i.getAncestors().length;if(r>t){t=r;e=i;n=o}}}if(n){this._showToolbar(n,e)}}_hideToolbar(t){this._balloon.remove(t.view);this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){if(this._isToolbarVisible(t)){SD(this.editor,e)}else if(!this._isToolbarInBalloon(t)){this._balloon.add({view:t.view,position:DD(this.editor,e),balloonClassName:t.balloonClassName});this.listenTo(this._balloon,"change:visibleView",(()=>{for(const t of this._toolbarDefinitions.values()){if(this._isToolbarVisible(t)){const e=t.getRelatedElement(this.editor.editing.view.document.selection);SD(this.editor,e)}}}))}}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function SD(t,e){const n=t.plugins.get("ContextualBalloon");const o=DD(t,e);n.updatePosition(o)}function DD(t,e){const n=t.editing.view;const o=vA.defaultPositions;return{target:n.domConverter.mapViewToDom(e),positions:[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}function TD(t){const e=t.getSelectedElement();return!!(e&&oE(e))}class BD extends(null&&Observable){constructor(t){super();this.set("activeHandlePosition",null);this.set("proposedWidthPercents",null);this.set("proposedWidth",null);this.set("proposedHeight",null);this.set("proposedHandleHostWidth",null);this.set("proposedHandleHostHeight",null);this._options=t;this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(t,e,n){const o=new Rect(e);this.activeHandlePosition=OD(t);this._referenceCoordinates=ID(e,zD(this.activeHandlePosition));this._originalWidth=o.width;this._originalHeight=o.height;this._aspectRatio=o.width/o.height;const i=n.style.width;if(i&&i.match(/^\d+(\.\d*)?%$/)){this._originalWidthPercents=parseFloat(i)}else{this._originalWidthPercents=PD(n,o)}}update(t){this.proposedWidth=t.width;this.proposedHeight=t.height;this.proposedWidthPercents=t.widthPercents;this.proposedHandleHostWidth=t.handleHostWidth;this.proposedHandleHostHeight=t.handleHostHeight}}function PD(t,e){const n=t.parentElement;const o=parseFloat(n.ownerDocument.defaultView.getComputedStyle(n).width);return e.width/o*100}function ID(t,e){const n=new Rect(t);const o=e.split("-");const i={x:o[1]=="right"?n.right:n.left,y:o[0]=="bottom"?n.bottom:n.top};i.x+=t.ownerDocument.defaultView.scrollX;i.y+=t.ownerDocument.defaultView.scrollY;return i}function RD(t){return`ck-widget__resizer__handle-${t}`}function OD(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const n of e){if(t.classList.contains(RD(n))){return n}}}function zD(t){const e=t.split("-");const n={top:"bottom",bottom:"top",left:"right",right:"left"};return`${n[e[0]]}-${n[e[1]]}`}class MD extends(null&&View){constructor(){super();const t=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",t.to("_viewPosition",(t=>t?`ck-orientation-${t}`:""))],style:{display:t.if("_isVisible","none",(t=>!t))}},children:[{text:t.to("_label")}]})}_bindToState(t,e){this.bind("_isVisible").to(e,"proposedWidth",e,"proposedHeight",((t,e)=>t!==null&&e!==null));this.bind("_label").to(e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",e,"proposedWidthPercents",((e,n,o)=>{if(t.unit==="px"){return`${e}×${n}`}else{return`${o}%`}}));this.bind("_viewPosition").to(e,"activeHandlePosition",e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",((t,e,n)=>e<50||n<50?"above-center":t))}_dismiss(){this.unbind();this._isVisible=false}}class FD extends(null&&Observable){constructor(t){super();this._options=t;this._viewResizerWrapper=null;this.set("isEnabled",true);this.set("isSelected",false);this.bind("isVisible").to(this,"isEnabled",this,"isSelected",((t,e)=>t&&e));this.decorate("begin");this.decorate("cancel");this.decorate("commit");this.decorate("updateSize");this.on("commit",(t=>{if(!this.state.proposedWidth&&!this.state.proposedWidthPercents){this._cleanup();t.stop()}}),{priority:"high"})}get state(){return this._state}show(){const t=this._options.editor.editing.view;t.change((t=>{t.removeClass("ck-hidden",this._viewResizerWrapper)}))}hide(){const t=this._options.editor.editing.view;t.change((t=>{t.addClass("ck-hidden",this._viewResizerWrapper)}))}attach(){const t=this;const e=this._options.viewElement;const n=this._options.editor.editing.view;n.change((n=>{const o=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(e){const n=this.toDomElement(e);t._appendHandles(n);t._appendSizeUI(n);return n}));n.insert(n.createPositionAt(e,"end"),o);n.addClass("ck-widget_with-resizer",e);this._viewResizerWrapper=o;if(!this.isVisible){this.hide()}}));this.on("change:isVisible",(()=>{if(this.isVisible){this.show();this.redraw()}else{this.hide()}}))}begin(t){this._state=new ResizeState(this._options);this._sizeView._bindToState(this._options,this.state);this._initialViewWidth=this._options.viewElement.getStyle("width");this.state.begin(t,this._getHandleHost(),this._getResizeHost())}updateSize(t){const e=this._proposeNewSize(t);const n=this._options.editor.editing.view;n.change((t=>{const n=this._options.unit||"%";const o=(n==="%"?e.widthPercents:e.width)+n;t.setStyle("width",o,this._options.viewElement)}));const o=this._getHandleHost();const i=new Rect(o);const r=Math.round(i.width);const s=Math.round(i.height);const a=new Rect(o);e.width=Math.round(a.width);e.height=Math.round(a.height);this.redraw(i);this.state.update({...e,handleHostWidth:r,handleHostHeight:s})}commit(){const t=this._options.unit||"%";const e=(t==="%"?this.state.proposedWidthPercents:this.state.proposedWidth)+t;this._options.editor.editing.view.change((()=>{this._cleanup();this._options.onCommit(e)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(t){const e=this._domResizerWrapper;if(!LD(e)){return}const n=e.parentElement;const o=this._getHandleHost();const i=this._viewResizerWrapper;const r=[i.getStyle("width"),i.getStyle("height"),i.getStyle("left"),i.getStyle("top")];let s;if(n.isSameNode(o)){const e=t||new Rect(o);s=[e.width+"px",e.height+"px",undefined,undefined]}else{s=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"]}if(compareArrays(r,s)!=="same"){this._options.editor.editing.view.change((t=>{t.setStyle({width:s[0],height:s[1],left:s[2],top:s[3]},i)}))}}containsHandle(t){return this._domResizerWrapper.contains(t)}static isResizeHandle(t){return t.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();const t=this._options.editor.editing.view;t.change((t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(t){const e=this.state;const n=ND(t);const o=this._options.isCentered?this._options.isCentered(this):true;const i={x:e._referenceCoordinates.x-(n.x+e.originalWidth),y:n.y-e.originalHeight-e._referenceCoordinates.y};if(o&&e.activeHandlePosition.endsWith("-right")){i.x=n.x-(e._referenceCoordinates.x+e.originalWidth)}if(o){i.x*=2}let r=Math.abs(e.originalWidth+i.x);let s=Math.abs(e.originalHeight+i.y);const a=r/e.aspectRatio>s?"width":"height";if(a=="width"){s=r/e.aspectRatio}else{r=s*e.aspectRatio}return{width:Math.round(r),height:Math.round(s),widthPercents:Math.min(Math.round(e.originalWidthPercents/e.originalWidth*r*100)/100,100)}}_getResizeHost(){const t=this._domResizerWrapper.parentElement;return this._options.getResizeHost(t)}_getHandleHost(){const t=this._domResizerWrapper.parentElement;return this._options.getHandleHost(t)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const n of e){t.appendChild(new Template({tag:"div",attributes:{class:`ck-widget__resizer__handle ${VD(n)}`}}).render())}}_appendSizeUI(t){this._sizeView=new SizeView;this._sizeView.render();t.appendChild(this._sizeView.element)}}function VD(t){return`ck-widget__resizer__handle-${t}`}function ND(t){return{x:t.pageX,y:t.pageY}}function LD(t){return t&&t.ownerDocument&&t.ownerDocument.contains(t)}var HD=n(263);var jD={injectType:"singletonStyleTag",attributes:{"data-cke":true}};jD.insert="head";jD.singleton=true;var WD=Vu()(HD.Z,jD);const qD=HD.Z.locals||{};class UD extends(null&&Plugin){static get pluginName(){return"WidgetResize"}init(){const t=this.editor.editing;const e=global.window.document;this.set("selectedResizer",null);this.set("_activeResizer",null);this._resizers=new Map;t.view.addObserver(MouseObserver);this._observer=new DomEmitter;this.listenTo(t.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"});this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this));this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this));this._redrawSelectedResizerThrottled=throttle((()=>this.redrawSelectedResizer()),200);this.editor.ui.on("update",this._redrawSelectedResizerThrottled);this.editor.model.document.on("change",(()=>{for(const[t,e]of this._resizers){if(!t.isAttached()){this._resizers.delete(t);e.destroy()}}}),{priority:"lowest"});this._observer.listenTo(global.window,"resize",this._redrawSelectedResizerThrottled);const n=this.editor.editing.view.document.selection;n.on("change",(()=>{const t=n.getSelectedElement();const e=this.getResizerByViewElement(t)||null;if(e){this.select(e)}else{this.deselect()}}))}redrawSelectedResizer(){if(this.selectedResizer&&this.selectedResizer.isVisible){this.selectedResizer.redraw()}}destroy(){super.destroy();this._observer.stopListening();for(const t of this._resizers.values()){t.destroy()}this._redrawSelectedResizerThrottled.cancel()}select(t){this.deselect();this.selectedResizer=t;this.selectedResizer.isSelected=true}deselect(){if(this.selectedResizer){this.selectedResizer.isSelected=false}this.selectedResizer=null}attachTo(t){const e=new Resizer(t);const n=this.editor.plugins;e.attach();if(n.has("WidgetToolbarRepository")){const t=n.get("WidgetToolbarRepository");e.on("begin",(()=>{t.forceDisabled("resize")}),{priority:"lowest"});e.on("cancel",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"});e.on("commit",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(t.viewElement,e);const o=this.editor.editing.view.document.selection;const i=o.getSelectedElement();if(this.getResizerByViewElement(i)==e){this.select(e)}return e}getResizerByViewElement(t){return this._resizers.get(t)}_getResizerByHandle(t){for(const e of this._resizers.values()){if(e.containsHandle(t)){return e}}}_mouseDownListener(t,e){const n=e.domTarget;if(!Resizer.isResizeHandle(n)){return}this._activeResizer=this._getResizerByHandle(n)||null;if(this._activeResizer){this._activeResizer.begin(n);t.stop();e.preventDefault()}}_mouseMoveListener(t,e){if(this._activeResizer){this._activeResizer.updateSize(e)}}_mouseUpListener(){if(this._activeResizer){this._activeResizer.commit();this._activeResizer=null}}}class $D extends ot{refresh(){const t=this.editor;const e=t.plugins.get("ImageUtils");const n=e.getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!n;if(this.isEnabled&&n.hasAttribute("alt")){this.value=n.getAttribute("alt")}else{this.value=false}}execute(t){const e=this.editor;const n=e.plugins.get("ImageUtils");const o=e.model;const i=n.getClosestSelectedImageElement(o.document.selection);o.change((e=>{e.setAttribute("alt",t.newValue,i)}))}}function KD(t){return t.createContainerElement("span",{class:"image-inline"},t.createEmptyElement("img"))}function GD(t){return t.createContainerElement("figure",{class:"image"},[t.createEmptyElement("img"),t.createSlot()])}function ZD(t,e){const n=t.plugins.get("ImageUtils");const o=t.plugins.has("ImageInlineEditing")&&t.plugins.has("ImageBlockEditing");return t=>{if(!n.isInlineImageView(t)){return null}if(!o){return i(t)}const r=t.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline";if(r!==e){return null}return i(t)};function i(t){const e={name:true};if(t.hasAttribute("src")){e.attributes=["src"]}return e}}function JD(t,e){const n=cg(e.getSelectedBlocks());if(!n||t.isObject(n)){return"imageBlock"}if(n.isEmpty&&n.name!="listItem"){return"imageBlock"}return"imageInline"}class YD extends et{static get pluginName(){return"ImageUtils"}isImage(t){return this.isInlineImage(t)||this.isBlockImage(t)}isInlineImageView(t){return!!t&&t.is("element","img")}isBlockImageView(t){return!!t&&t.is("element","figure")&&t.hasClass("image")}insertImage(t={},e=null,n=null){const o=this.editor;const i=o.model;const r=i.document.selection;n=eT(o,e||r,n);t={...Object.fromEntries(r.getAttributes()),...t};for(const e in t){if(!i.schema.checkAttribute(n,e)){delete t[e]}}return i.change((o=>{const r=o.createElement(n,t);i.insertObject(r,e,null,{setSelection:"on",findOptimalPosition:!e&&n!="imageInline"});if(r.parent){return r}return null}))}getClosestSelectedImageWidget(t){const e=t.getFirstPosition();if(!e){return null}const n=t.getSelectedElement();if(n&&this.isImageWidget(n)){return n}let o=e.parent;while(o){if(o.is("element")&&this.isImageWidget(o)){return o}o=o.parent}return null}getClosestSelectedImageElement(t){const e=t.getSelectedElement();return this.isImage(e)?e:t.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const t=this.editor.model;const e=t.document.selection;return QD(this.editor,e)&&XD(e)}toImageWidget(t,e,n){e.setCustomProperty("image",true,t);const o=()=>{const e=this.findViewImgElement(t);const o=e.getAttribute("alt");return o?`${o} ${n}`:n};return iE(t,e,{label:o})}isImageWidget(t){return!!t.getCustomProperty("image")&&oE(t)}isBlockImage(t){return!!t&&t.is("element","imageBlock")}isInlineImage(t){return!!t&&t.is("element","imageInline")}findViewImgElement(t){if(this.isInlineImageView(t)){return t}const e=this.editor.editing.view;for(const{item:n}of e.createRangeIn(t)){if(this.isInlineImageView(n)){return n}}}}function QD(t,e){const n=eT(t,e);if(n=="imageBlock"){const n=tT(e,t.model);if(t.model.schema.checkChild(n,"imageBlock")){return true}}else if(t.model.schema.checkChild(e.focus,"imageInline")){return true}return false}function XD(t){return[...t.focus.getAncestors()].every((t=>!t.is("element","imageBlock")))}function tT(t,e){const n=uE(t,e);const o=n.start.parent;if(o.isEmpty&&!o.is("element","$root")){return o.parent}return o}function eT(t,e,n){const o=t.model.schema;const i=t.config.get("image.insert.type");if(!t.plugins.has("ImageBlockEditing")){return"imageInline"}if(!t.plugins.has("ImageInlineEditing")){return"imageBlock"}if(n){return n}if(i==="inline"){return"imageInline"}if(i==="block"){return"imageBlock"}if(e.is("selection")){return JD(o,e)}return o.checkChild(e,"imageInline")?"imageInline":"imageBlock"}class nT extends et{static get requires(){return[YD]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new $D(this.editor))}}var oT=n(831);var iT={injectType:"singletonStyleTag",attributes:{"data-cke":true}};iT.insert="head";iT.singleton=true;var rT=Vu()(oT.Z,iT);const sT=oT.Z.locals||{};var aT=n(590);var cT={injectType:"singletonStyleTag",attributes:{"data-cke":true}};cT.insert="head";cT.singleton=true;var lT=Vu()(aT.Z,cT);const dT=aT.Z.locals||{};class uT extends aA{constructor(t){super(t);const e=this.locale.t;this.focusTracker=new lg;this.keystrokes=new dg;this.labeledInput=this._createLabeledInputView();this.saveButtonView=this._createButton(e("Save"),vv.check,"ck-button-save");this.saveButtonView.type="submit";this.cancelButtonView=this._createButton(e("Cancel"),vv.cancel,"ck-button-cancel","cancel");this._focusables=new S_;this._focusCycler=new cC({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]});yv(this)}render(){super.render();this.keystrokes.listenTo(this.element);xv({view:this});[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t);this.focusTracker.add(t.element)}))}destroy(){super.destroy();this.focusTracker.destroy();this.keystrokes.destroy()}_createButton(t,e,n,o){const i=new Fv(this.locale);i.set({label:t,icon:e,tooltip:true});i.extendTemplate({attributes:{class:n}});if(o){i.delegate("execute").to(this,o)}return i}_createLabeledInputView(){const t=this.locale.t;const e=new Sy(this.locale,Dy);e.label=t("Text alternative");return e}}function hT(t){const e=t.plugins.get("ContextualBalloon");if(t.plugins.get("ImageUtils").getClosestSelectedImageWidget(t.editing.view.document.selection)){const n=fT(t);e.updatePosition(n)}}function fT(t){const e=t.editing.view;const n=vA.defaultPositions;const o=t.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(o.getClosestSelectedImageWidget(e.document.selection)),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class gT extends et{static get requires(){return[qy]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton();this._createForm()}destroy(){super.destroy();this._form.destroy()}_createButton(){const t=this.editor;const e=t.t;t.ui.componentFactory.add("imageTextAlternative",(n=>{const o=t.commands.get("imageTextAlternative");const i=new Fv(n);i.set({label:e("Change image text alternative"),icon:vv.lowVision,tooltip:true});i.bind("isEnabled").to(o,"isEnabled");i.bind("isOn").to(o,"value",(t=>!!t));this.listenTo(i,"execute",(()=>{this._showForm()}));return i}))}_createForm(){const t=this.editor;const e=t.editing.view;const n=e.document;const o=t.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon");this._form=new uT(t.locale);this._form.render();this.listenTo(this._form,"submit",(()=>{t.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value});this._hideForm(true)}));this.listenTo(this._form,"cancel",(()=>{this._hideForm(true)}));this._form.keystrokes.set("Esc",((t,e)=>{this._hideForm(true);e()}));this.listenTo(t.ui,"update",(()=>{if(!o.getClosestSelectedImageWidget(n.selection)){this._hideForm(true)}else if(this._isVisible){hT(t)}}));Cv({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible){return}const t=this.editor;const e=t.commands.get("imageTextAlternative");const n=this._form.labeledInput;this._form.disableCssTransitions();if(!this._isInBalloon){this._balloon.add({view:this._form,position:fT(t)})}n.fieldView.value=n.fieldView.element.value=e.value||"";this._form.labeledInput.fieldView.select();this._form.enableCssTransitions()}_hideForm(t){if(!this._isInBalloon){return}if(this._form.focusTracker.isFocused){this._form.saveButtonView.focus()}this._balloon.remove(this._form);if(t){this.editor.editing.view.focus()}}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}class pT extends et{static get requires(){return[nT,gT]}static get pluginName(){return"ImageTextAlternative"}}function mT(t){return t=>{t.on("element:figure",e)};function e(e,n,o){if(!o.consumable.test(n.viewItem,{name:true,classes:"image"})){return}const i=t.findViewImgElement(n.viewItem);if(!i||!o.consumable.test(i,{name:true})){return}o.consumable.consume(n.viewItem,{name:true,classes:"image"});const r=o.convertItem(i,n.modelCursor);const s=cg(r.modelRange.getItems());if(!s){o.consumable.revert(n.viewItem,{name:true,classes:"image"});return}o.convertChildren(n.viewItem,s);o.updateConversionResult(s,n)}}function kT(t){const e=["srcset","media","type","sizes"];return t=>{t.on("element:picture",n)};function n(n,o,i){const r=o.viewItem;if(!i.consumable.test(r,{name:true})){return}const s=new Map;for(const t of r.getChildren()){if(t.is("element","source")){const n={};for(const o of e){if(t.hasAttribute(o)){if(i.consumable.test(t,{attributes:o})){n[o]=t.getAttribute(o)}}}if(Object.keys(n).length){s.set(t,n)}}}const a=t.findViewImgElement(r);if(!a){return}let c=o.modelCursor.parent;if(!c.is("element","imageBlock")){const t=i.convertItem(a,o.modelCursor);o.modelRange=t.modelRange;o.modelCursor=t.modelCursor;c=first(t.modelRange.getItems())}i.consumable.consume(r,{name:true});for(const[t,e]of s){i.consumable.consume(t,{attributes:Object.keys(e)})}if(s.size){i.writer.setAttribute("sources",Array.from(s.values()),c)}i.convertChildren(r,c)}}function bT(t,e){return t=>{t.on(`attribute:srcset:${e}`,n)};function n(e,n,o){if(!o.consumable.consume(n.item,e.name)){return}const i=o.writer;const r=o.mapper.toViewElement(n.item);const s=t.findViewImgElement(r);if(n.attributeNewValue===null){const t=n.attributeOldValue;if(t.data){i.removeAttribute("srcset",s);i.removeAttribute("sizes",s);if(t.width){i.removeAttribute("width",s)}}}else{const t=n.attributeNewValue;if(t.data){i.setAttribute("srcset",t.data,s);i.setAttribute("sizes","100vw",s);if(t.width){i.setAttribute("width",t.width,s)}}}}}function wT(t){return t=>{t.on("attribute:sources:imageBlock",e);t.on("attribute:sources:imageInline",e)};function e(e,n,o){if(!o.consumable.consume(n.item,e.name)){return}const i=o.writer;const r=o.mapper.toViewElement(n.item);const s=t.findViewImgElement(r);if(n.attributeNewValue&&n.attributeNewValue.length){const t=i.createContainerElement("picture",null,n.attributeNewValue.map((t=>i.createEmptyElement("source",t))));const e=[];let o=s.parent;while(o&&o.is("attributeElement")){const t=o.parent;i.unwrap(i.createRangeOn(s),o);e.unshift(o);o=t}i.insert(i.createPositionBefore(s),t);i.move(i.createRangeOn(s),i.createPositionAt(t,"end"));for(const n of e){i.wrap(i.createRangeOn(t),n)}}else if(s.parent.is("element","picture")){const t=s.parent;i.move(i.createRangeOn(s),i.createPositionBefore(t));i.remove(t)}}}function _T(t,e,n){return t=>{t.on(`attribute:${n}:${e}`,o)};function o(e,n,o){if(!o.consumable.consume(n.item,e.name)){return}const i=o.writer;const r=o.mapper.toViewElement(n.item);const s=t.findViewImgElement(r);i.setAttribute(n.attributeKey,n.attributeNewValue||"",s)}}class AT extends bh{observe(t){this.listenTo(t,"load",((t,e)=>{const n=e.target;if(this.checkShouldIgnoreEventFromTarget(n)){return}if(n.tagName=="IMG"){this._fireEvents(e)}}),{useCapture:true})}_fireEvents(t){if(this.isEnabled){this.document.fire("layoutChanged");this.document.fire("imageLoaded",t)}}}class vT extends ot{constructor(t){super(t);const e=t.config.get("image.insert.type");if(!t.plugins.has("ImageBlockEditing")){if(e==="block"){h("image-block-plugin-required")}}if(!t.plugins.has("ImageInlineEditing")){if(e==="inline"){h("image-inline-plugin-required")}}}refresh(){this.isEnabled=this.editor.plugins.get("ImageUtils").isImageAllowed()}execute(t){const e=xa(t.source);const n=this.editor.model.document.selection;const o=this.editor.plugins.get("ImageUtils");const i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if(typeof t==="string"){t={src:t}}if(e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);o.insertImage({...t,...i},e)}else{o.insertImage({...t,...i})}}))}}class CT extends et{static get requires(){return[YD]}static get pluginName(){return"ImageEditing"}init(){const t=this.editor;const e=t.conversion;t.editing.view.addObserver(AT);e.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:t=>{const e={data:t.getAttribute("srcset")};if(t.hasAttribute("width")){e.width=t.getAttribute("width")}return e}}});const n=new vT(t);t.commands.add("insertImage",n);t.commands.add("imageInsert",n)}}class yT extends ot{constructor(t,e){super(t);this._modelElementName=e}refresh(){const t=this.editor;const e=t.plugins.get("ImageUtils");const n=e.getClosestSelectedImageElement(this.editor.model.document.selection);if(this._modelElementName==="imageBlock"){this.isEnabled=e.isInlineImage(n)}else{this.isEnabled=e.isBlockImage(n)}}execute(){const t=this.editor;const e=this.editor.model;const n=t.plugins.get("ImageUtils");const o=n.getClosestSelectedImageElement(e.document.selection);const i=Object.fromEntries(o.getAttributes());if(!i.src&&!i.uploadId){return null}return e.change((t=>{const r=Array.from(e.markers).filter((t=>t.getRange().containsItem(o)));const s=n.insertImage(i,e.createSelection(o,"on"),this._modelElementName);if(!s){return null}const a=t.createRangeOn(s);for(const e of r){const n=e.getRange();const o=n.root.rootName!="$graveyard"?n.getJoined(a,true):a;t.updateMarker(e,{range:o})}return{oldElement:o,newElement:s}}))}}class xT extends et{static get requires(){return[CT,YD,Bx]}static get pluginName(){return"ImageBlockEditing"}init(){const t=this.editor;const e=t.model.schema;e.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]});this._setupConversion();if(t.plugins.has("ImageInlineEditing")){t.commands.add("imageTypeBlock",new yT(this.editor,"imageBlock"));this._setupClipboardIntegration()}}_setupConversion(){const t=this.editor;const e=t.t;const n=t.conversion;const o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:e})=>GD(e)});n.for("editingDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:n})=>o.toImageWidget(GD(n),n,e("image widget"))});n.for("downcast").add(_T(o,"imageBlock","src")).add(_T(o,"imageBlock","alt")).add(bT(o,"imageBlock"));n.for("upcast").elementToElement({view:ZD(t,"imageBlock"),model:(t,{writer:e})=>e.createElement("imageBlock",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)}).add(mT(o))}_setupClipboardIntegration(){const t=this.editor;const e=t.model;const n=t.editing.view;const o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isInlineImageView)){return}if(r.targetRanges){a=t.editing.mapper.toModelRange(r.targetRanges[0])}else{a=e.document.selection.getFirstRange()}const c=e.createSelection(a);if(JD(e.schema,c)==="imageBlock"){const t=new bw(n.document);const e=s.map((e=>t.createElement("figure",{class:"image"},e)));r.content=t.createDocumentFragment(e)}}))}}var ET=n(48);var ST={injectType:"singletonStyleTag",attributes:{"data-cke":true}};ST.insert="head";ST.singleton=true;var DT=Vu()(ET.Z,ST);const TT=ET.Z.locals||{};class BT extends et{static get requires(){return[xT,qE,pT]}static get pluginName(){return"ImageBlock"}}class PT extends et{static get requires(){return[CT,YD,Bx]}static get pluginName(){return"ImageInlineEditing"}init(){const t=this.editor;const e=t.model.schema;e.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]});e.addChildCheck(((t,e)=>{if(t.endsWith("caption")&&e.name==="imageInline"){return false}}));this._setupConversion();if(t.plugins.has("ImageBlockEditing")){t.commands.add("imageTypeInline",new yT(this.editor,"imageInline"));this._setupClipboardIntegration()}}_setupConversion(){const t=this.editor;const e=t.t;const n=t.conversion;const o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageInline",view:(t,{writer:e})=>e.createEmptyElement("img")});n.for("editingDowncast").elementToStructure({model:"imageInline",view:(t,{writer:n})=>o.toImageWidget(KD(n),n,e("image widget"))});n.for("downcast").add(_T(o,"imageInline","src")).add(_T(o,"imageInline","alt")).add(bT(o,"imageInline"));n.for("upcast").elementToElement({view:ZD(t,"imageInline"),model:(t,{writer:e})=>e.createElement("imageInline",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)})}_setupClipboardIntegration(){const t=this.editor;const e=t.model;const n=t.editing.view;const o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isBlockImageView)){return}if(r.targetRanges){a=t.editing.mapper.toModelRange(r.targetRanges[0])}else{a=e.document.selection.getFirstRange()}const c=e.createSelection(a);if(JD(e.schema,c)==="imageInline"){const t=new bw(n.document);const e=s.map((e=>{if(e.childCount===1){Array.from(e.getAttributes()).forEach((n=>t.setAttribute(...n,o.findViewImgElement(e))));return e.getChild(0)}else{return e}}));r.content=t.createDocumentFragment(e)}}))}}class IT extends et{static get requires(){return[PT,qE,pT]}static get pluginName(){return"ImageInline"}}class RT extends et{static get requires(){return[BT,IT]}static get pluginName(){return"Image"}}class OT extends q{constructor(){super();const t=new window.FileReader;this._reader=t;this._data=undefined;this.set("loaded",0);t.onprogress=t=>{this.loaded=t.loaded}}get error(){return this._reader.error}get data(){return this._data}read(t){const e=this._reader;this.total=t.size;return new Promise(((n,o)=>{e.onload=()=>{const t=e.result;this._data=t;n(t)};e.onerror=()=>{o("error")};e.onabort=()=>{o("aborted")};this._reader.readAsDataURL(t)}))}abort(){this._reader.abort()}}class zT extends et{static get pluginName(){return"FileRepository"}static get requires(){return[HA]}init(){this.loaders=new Ca;this.loaders.on("change",(()=>this._updatePendingAction()));this._loadersMap=new Map;this._pendingAction=null;this.set("uploaded",0);this.set("uploadTotal",null);this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((t,e)=>e?t/e*100:0))}getLoader(t){return this._loadersMap.get(t)||null}createLoader(t){if(!this.createUploadAdapter){h("filerepository-no-upload-adapter");return null}const e=new MT(Promise.resolve(t),this.createUploadAdapter);this.loaders.add(e);this._loadersMap.set(t,e);if(t instanceof Promise){e.file.then((t=>{this._loadersMap.set(t,e)})).catch((()=>{}))}e.on("change:uploaded",(()=>{let t=0;for(const e of this.loaders){t+=e.uploaded}this.uploaded=t}));e.on("change:uploadTotal",(()=>{let t=0;for(const e of this.loaders){if(e.uploadTotal){t+=e.uploadTotal}}this.uploadTotal=t}));return e}destroyLoader(t){const e=t instanceof MT?t:this.getLoader(t);e._destroy();this.loaders.remove(e);this._loadersMap.forEach(((t,n)=>{if(t===e){this._loadersMap.delete(n)}}))}_updatePendingAction(){const t=this.editor.plugins.get(HA);if(this.loaders.length){if(!this._pendingAction){const e=this.editor.t;const n=t=>`${e("Upload in progress")} ${parseInt(t)}%.`;this._pendingAction=t.add(n(this.uploadedPercent));this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else{t.remove(this._pendingAction);this._pendingAction=null}}}class MT extends q{constructor(t,e){super();this.id=s();this._filePromiseWrapper=this._createFilePromiseWrapper(t);this._adapter=e(this);this._reader=new OT;this.set("status","idle");this.set("uploaded",0);this.set("uploadTotal",null);this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((t,e)=>e?t/e*100:0));this.set("uploadResponse",null)}get file(){if(!this._filePromiseWrapper){return Promise.resolve(null)}else{return this._filePromiseWrapper.promise.then((t=>this._filePromiseWrapper?t:null))}}get data(){return this._reader.data}read(){if(this.status!="idle"){throw new u("filerepository-read-wrong-status",this)}this.status="reading";return this.file.then((t=>this._reader.read(t))).then((t=>{if(this.status!=="reading"){throw this.status}this.status="idle";return t})).catch((t=>{if(t==="aborted"){this.status="aborted";throw"aborted"}this.status="error";throw this._reader.error?this._reader.error:t}))}upload(){if(this.status!="idle"){throw new u("filerepository-upload-wrong-status",this)}this.status="uploading";return this.file.then((()=>this._adapter.upload())).then((t=>{this.uploadResponse=t;this.status="idle";return t})).catch((t=>{if(this.status==="aborted"){throw"aborted"}this.status="error";throw t}))}abort(){const t=this.status;this.status="aborted";if(!this._filePromiseWrapper.isFulfilled){this._filePromiseWrapper.promise.catch((()=>{}));this._filePromiseWrapper.rejecter("aborted")}else if(t=="reading"){this._reader.abort()}else if(t=="uploading"&&this._adapter.abort){this._adapter.abort()}this._destroy()}_destroy(){this._filePromiseWrapper=undefined;this._reader=undefined;this._adapter=undefined;this.uploadResponse=undefined}_createFilePromiseWrapper(t){const e={};e.promise=new Promise(((n,o)=>{e.rejecter=o;e.isFulfilled=false;t.then((t=>{e.isFulfilled=true;n(t)})).catch((t=>{e.isFulfilled=true;o(t)}))}));return e}}class FT extends aA{constructor(t){super(t);this.buttonView=new Fv(t);this._fileInputView=new VT(t);this._fileInputView.bind("acceptedType").to(this);this._fileInputView.bind("allowMultipleFiles").to(this);this._fileInputView.delegate("done").to(this);this.setTemplate({tag:"span",attributes:{class:"ck-file-dialog-button"},children:[this.buttonView,this._fileInputView]});this.buttonView.on("execute",(()=>{this._fileInputView.open()}))}focus(){this.buttonView.focus()}}class VT extends aA{constructor(t){super(t);this.set("acceptedType",undefined);this.set("allowMultipleFiles",false);const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:e.to("acceptedType"),multiple:e.to("allowMultipleFiles")},on:{change:e.to((()=>{if(this.element&&this.element.files&&this.element.files.length){this.fire("done",this.element.files)}this.element.value=""}))}})}open(){this.element.click()}}class NT extends(null&&Plugin){static get requires(){return[FileRepository]}static get pluginName(){return"Base64UploadAdapter"}init(){this.editor.plugins.get(FileRepository).createUploadAdapter=t=>new LT(t)}}class LT{constructor(t){this.loader=t}upload(){return new Promise(((t,e)=>{const n=this.reader=new window.FileReader;n.addEventListener("load",(()=>{t({default:n.result})}));n.addEventListener("error",(t=>{e(t)}));n.addEventListener("abort",(()=>{e()}));this.loader.file.then((t=>{n.readAsDataURL(t)}))}))}abort(){this.reader.abort()}}class HT extends(null&&Plugin){static get requires(){return[FileRepository]}static get pluginName(){return"SimpleUploadAdapter"}init(){const t=this.editor.config.get("simpleUpload");if(!t){return}if(!t.uploadUrl){logWarning("simple-upload-adapter-missing-uploadurl");return}this.editor.plugins.get(FileRepository).createUploadAdapter=e=>new jT(e,t)}}class jT{constructor(t,e){this.loader=t;this.options=e}upload(){return this.loader.file.then((t=>new Promise(((e,n)=>{this._initRequest();this._initListeners(e,n,t);this._sendRequest(t)}))))}abort(){if(this.xhr){this.xhr.abort()}}_initRequest(){const t=this.xhr=new XMLHttpRequest;t.open("POST",this.options.uploadUrl,true);t.responseType="json"}_initListeners(t,e,n){const o=this.xhr;const i=this.loader;const r=`Couldn't upload file: ${n.name}.`;o.addEventListener("error",(()=>e(r)));o.addEventListener("abort",(()=>e()));o.addEventListener("load",(()=>{const n=o.response;if(!n||n.error){return e(n&&n.error&&n.error.message?n.error.message:r)}const i=n.url?{default:n.url}:n.urls;t({...n,urls:i})}));if(o.upload){o.upload.addEventListener("progress",(t=>{if(t.lengthComputable){i.uploadTotal=t.total;i.uploaded=t.loaded}}))}}_sendRequest(t){const e=this.options.headers||{};const n=this.options.withCredentials||false;for(const t of Object.keys(e)){this.xhr.setRequestHeader(t,e[t])}this.xhr.withCredentials=n;const o=new FormData;o.append("upload",t);this.xhr.send(o)}}function WT(t){const e=t.map((t=>t.replace("+","\\+")));return new RegExp(`^image\\/(${e.join("|")})$`)}function qT(t){return new Promise(((e,n)=>{const o=t.getAttribute("src");fetch(o).then((t=>t.blob())).then((t=>{const n=$T(t,o);const i=n.replace("image/","");const r=`image.${i}`;const s=new File([t],r,{type:n});e(s)})).catch((t=>t&&t.name==="TypeError"?KT(o).then(e).catch(n):n(t)))}))}function UT(t,e){if(!t.isInlineImageView(e)||!e.getAttribute("src")){return false}return e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||e.getAttribute("src").match(/^blob:/g)}function $T(t,e){if(t.type){return t.type}else if(e.match(/data:(image\/\w+);base64/)){return e.match(/data:(image\/\w+);base64/)[1].toLowerCase()}else{return"image/jpeg"}}function KT(t){return GT(t).then((e=>{const n=$T(e,t);const o=n.replace("image/","");const i=`image.${o}`;return new File([e],i,{type:n})}))}function GT(t){return new Promise(((e,n)=>{const o=Sa.document.createElement("img");o.addEventListener("load",(()=>{const t=Sa.document.createElement("canvas");t.width=o.width;t.height=o.height;const i=t.getContext("2d");i.drawImage(o,0,0);t.toBlob((t=>t?e(t):n()))}));o.addEventListener("error",(()=>n()));o.src=t}))}class ZT extends et{static get pluginName(){return"ImageUploadUI"}init(){const t=this.editor;const e=t.t;const n=n=>{const o=new FT(n);const i=t.commands.get("uploadImage");const r=t.config.get("image.upload.types");const s=WT(r);o.set({acceptedType:r.map((t=>`image/${t}`)).join(","),allowMultipleFiles:true});o.buttonView.set({label:e("Insert image"),icon:vv.image,tooltip:true});o.buttonView.bind("isEnabled").to(i);o.on("done",((e,n)=>{const o=Array.from(n).filter((t=>s.test(t.type)));if(o.length){t.execute("uploadImage",{file:o});t.editing.view.focus()}}));return o};t.ui.componentFactory.add("uploadImage",n);t.ui.componentFactory.add("imageUpload",n)}}var JT=n(870);var YT={injectType:"singletonStyleTag",attributes:{"data-cke":true}};YT.insert="head";YT.singleton=true;var QT=Vu()(JT.Z,YT);const XT=JT.Z.locals||{};var tB=n(899);var eB={injectType:"singletonStyleTag",attributes:{"data-cke":true}};eB.insert="head";eB.singleton=true;var nB=Vu()(tB.Z,eB);const oB=tB.Z.locals||{};var iB=n(825);var rB={injectType:"singletonStyleTag",attributes:{"data-cke":true}};rB.insert="head";rB.singleton=true;var sB=Vu()(iB.Z,rB);const aB=iB.Z.locals||{};class cB extends et{static get pluginName(){return"ImageUploadProgress"}constructor(t){super(t);this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const t=this.editor;if(t.plugins.has("ImageBlockEditing")){t.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",((...t)=>this.uploadStatusChange(...t)))}if(t.plugins.has("ImageInlineEditing")){t.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",((...t)=>this.uploadStatusChange(...t)))}}uploadStatusChange(t,e,n){const o=this.editor;const i=e.item;const r=i.getAttribute("uploadId");if(!n.consumable.consume(e.item,t.name)){return}const s=o.plugins.get("ImageUtils");const a=o.plugins.get(zT);const c=r?e.attributeNewValue:null;const l=this.placeholder;const d=o.editing.mapper.toViewElement(i);const u=n.writer;if(c=="reading"){lB(d,u);uB(s,l,d,u);return}if(c=="uploading"){const t=a.loaders.get(r);lB(d,u);if(!t){uB(s,l,d,u)}else{hB(d,u);fB(d,u,t,o.editing.view);_B(s,d,u,t)}return}if(c=="complete"&&a.loaders.get(r)){pB(d,u,o.editing.view)}gB(d,u);hB(d,u);dB(d,u)}}function lB(t,e){if(!t.hasClass("ck-appear")){e.addClass("ck-appear",t)}}function dB(t,e){e.removeClass("ck-appear",t)}function uB(t,e,n,o){if(!n.hasClass("ck-image-upload-placeholder")){o.addClass("ck-image-upload-placeholder",n)}const i=t.findViewImgElement(n);if(i.getAttribute("src")!==e){o.setAttribute("src",e,i)}if(!bB(n,"placeholder")){o.insert(o.createPositionAfter(i),kB(o))}}function hB(t,e){if(t.hasClass("ck-image-upload-placeholder")){e.removeClass("ck-image-upload-placeholder",t)}wB(t,e,"placeholder")}function fB(t,e,n,o){const i=mB(e);e.insert(e.createPositionAt(t,"end"),i);n.on("change:uploadedPercent",((t,e,n)=>{o.change((t=>{t.setStyle("width",n+"%",i)}))}))}function gB(t,e){wB(t,e,"progressBar")}function pB(t,e,n){const o=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),o);setTimeout((()=>{n.change((t=>t.remove(t.createRangeOn(o))))}),3e3)}function mB(t){const e=t.createUIElement("div",{class:"ck-progress-bar"});t.setCustomProperty("progressBar",true,e);return e}function kB(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});t.setCustomProperty("placeholder",true,e);return e}function bB(t,e){for(const n of t.getChildren()){if(n.getCustomProperty(e)){return n}}}function wB(t,e,n){const o=bB(t,n);if(o){e.remove(e.createRangeOn(o))}}function _B(t,e,n,o){if(o.data){const i=t.findViewImgElement(e);n.setAttribute("src",o.data,i)}}class AB extends ot{refresh(){const t=this.editor;const e=t.plugins.get("ImageUtils");const n=t.model.document.selection.getSelectedElement();this.isEnabled=e.isImageAllowed()||e.isImage(n)}execute(t){const e=xa(t.file);const n=this.editor.model.document.selection;const o=this.editor.plugins.get("ImageUtils");const i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if(e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);this._uploadImage(t,i,e)}else{this._uploadImage(t,i)}}))}_uploadImage(t,e,n){const o=this.editor;const i=o.plugins.get(zT);const r=i.createLoader(t);const s=o.plugins.get("ImageUtils");if(!r){return}s.insertImage({...e,uploadId:r.id},n)}}class vB extends et{static get requires(){return[zT,Py,Bx,YD]}static get pluginName(){return"ImageUploadEditing"}constructor(t){super(t);t.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}});this._uploadImageElements=new Map}init(){const t=this.editor;const e=t.model.document;const n=t.conversion;const o=t.plugins.get(zT);const i=t.plugins.get("ImageUtils");const r=WT(t.config.get("image.upload.types"));const s=new AB(t);t.commands.add("uploadImage",s);t.commands.add("imageUpload",s);n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"});this.listenTo(t.editing.view.document,"clipboardInput",((e,n)=>{if(CB(n.dataTransfer)){return}const o=Array.from(n.dataTransfer.files).filter((t=>{if(!t){return false}return r.test(t.type)}));if(!o.length){return}e.stop();t.model.change((e=>{if(n.targetRanges){e.setSelection(n.targetRanges.map((e=>t.editing.mapper.toModelRange(e))))}t.model.enqueueChange((()=>{t.execute("uploadImage",{file:o})}))}))}));this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((e,n)=>{const r=Array.from(t.editing.view.createRangeIn(n.content)).filter((t=>UT(i,t.item)&&!t.item.getAttribute("uploadProcessed"))).map((t=>({promise:qT(t.item),imageElement:t.item})));if(!r.length){return}const s=new bw(t.editing.view.document);for(const t of r){s.setAttribute("uploadProcessed",true,t.imageElement);const e=o.createLoader(t.promise);if(e){s.setAttribute("src","",t.imageElement);s.setAttribute("uploadId",e.id,t.imageElement)}}}));t.editing.view.document.on("dragover",((t,e)=>{e.preventDefault()}));e.on("change",(()=>{const n=e.differ.getChanges({includeChangesInGraveyard:true}).reverse();const i=new Set;for(const e of n){if(e.type=="insert"&&e.name!="$text"){const n=e.position.nodeAfter;const r=e.position.root.rootName=="$graveyard";for(const e of yB(t,n)){const t=e.getAttribute("uploadId");if(!t){continue}const n=o.loaders.get(t);if(!n){continue}if(r){if(!i.has(t)){n.abort()}}else{i.add(t);this._uploadImageElements.set(t,e);if(n.status=="idle"){this._readAndUpload(n)}}}}}}));this.on("uploadComplete",((t,{imageElement:e,data:n})=>{const o=n.urls?n.urls:n;this.editor.model.change((t=>{t.setAttribute("src",o.default,e);this._parseAndSetSrcsetAttributeOnImage(o,e,t)}))}),{priority:"low"})}afterInit(){const t=this.editor.model.schema;if(this.editor.plugins.has("ImageBlockEditing")){t.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]})}if(this.editor.plugins.has("ImageInlineEditing")){t.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}}_readAndUpload(t){const e=this.editor;const n=e.model;const o=e.locale.t;const i=e.plugins.get(zT);const r=e.plugins.get(Py);const s=e.plugins.get("ImageUtils");const a=this._uploadImageElements;n.enqueueChange({isUndoable:false},(e=>{e.setAttribute("uploadStatus","reading",a.get(t.id))}));return t.read().then((()=>{const o=t.upload();const i=a.get(t.id);if(Sd.isSafari){const t=e.editing.mapper.toViewElement(i);const n=s.findViewImgElement(t);e.editing.view.once("render",(()=>{if(!n.parent){return}const t=e.editing.view.domConverter.mapViewToDom(n.parent);if(!t){return}const o=t.style.display;t.style.display="none";t._ckHack=t.offsetHeight;t.style.display=o}))}n.enqueueChange({isUndoable:false},(t=>{t.setAttribute("uploadStatus","uploading",i)}));return o})).then((e=>{n.enqueueChange({isUndoable:false},(n=>{const o=a.get(t.id);n.setAttribute("uploadStatus","complete",o);this.fire("uploadComplete",{data:e,imageElement:o})}));c()})).catch((e=>{if(t.status!=="error"&&t.status!=="aborted"){throw e}if(t.status=="error"&&e){r.showWarning(e,{title:o("Upload failed"),namespace:"upload"})}n.enqueueChange({isUndoable:false},(e=>{e.remove(a.get(t.id))}));c()}));function c(){n.enqueueChange({isUndoable:false},(e=>{const n=a.get(t.id);e.removeAttribute("uploadId",n);e.removeAttribute("uploadStatus",n);a.delete(t.id)}));i.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,n){let o=0;const i=Object.keys(t).filter((t=>{const e=parseInt(t,10);if(!isNaN(e)){o=Math.max(o,e);return true}})).map((e=>`${t[e]} ${e}w`)).join(", ");if(i!=""){n.setAttribute("srcset",{data:i,width:o},e)}}}function CB(t){return Array.from(t.types).includes("text/html")&&t.getData("text/html")!==""}function yB(t,e){const n=t.plugins.get("ImageUtils");return Array.from(t.model.createRangeOn(e)).filter((t=>n.isImage(t.item))).map((t=>t.item))}class xB extends et{static get pluginName(){return"ImageUpload"}static get requires(){return[vB,ZT,cB]}}var EB=n(364);var SB={injectType:"singletonStyleTag",attributes:{"data-cke":true}};SB.insert="head";SB.singleton=true;var DB=Vu()(EB.Z,SB);const TB=EB.Z.locals||{};class BB extends aA{constructor(t,e={}){super(t);const n=this.bindTemplate;this.set("class",e.class||null);this.children=this.createCollection();if(e.children){e.children.forEach((t=>this.children.add(t)))}this.set("_role",null);this.set("_ariaLabelledBy",null);if(e.labelView){this.set({_role:"group",_ariaLabelledBy:e.labelView.id})}this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",n.to("class")],role:n.to("_role"),"aria-labelledby":n.to("_ariaLabelledBy")},children:this.children})}}var PB=n(292);var IB={injectType:"singletonStyleTag",attributes:{"data-cke":true}};IB.insert="head";IB.singleton=true;var RB=Vu()(PB.Z,IB);const OB=PB.Z.locals||{};class zB extends aA{constructor(t,e){super(t);const{insertButtonView:n,cancelButtonView:o}=this._createActionButtons(t);this.insertButtonView=n;this.cancelButtonView=o;this.set("imageURLInputValue","");this.focusTracker=new lg;this.keystrokes=new dg;this._focusables=new S_;this._focusCycler=new cC({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});this.set("_integrations",new Ca);if(e){for(const[t,n]of Object.entries(e)){if(t==="insertImageViaUrl"){n.fieldView.bind("value").to(this,"imageURLInputValue",(t=>t||""));n.fieldView.on("input",(()=>{this.imageURLInputValue=n.fieldView.element.value.trim()}))}n.name=t;this._integrations.add(n)}}this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:"-1"},children:[...this._integrations,new BB(t,{children:[this.insertButtonView,this.cancelButtonView],class:"ck-image-insert-form__action-row"})]})}render(){super.render();xv({view:this});const t=[...this._integrations,this.insertButtonView,this.cancelButtonView];t.forEach((t=>{this._focusables.add(t);this.focusTracker.add(t.element)}));this.keystrokes.listenTo(this.element);const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e);this.keystrokes.set("arrowleft",e);this.keystrokes.set("arrowup",e);this.keystrokes.set("arrowdown",e);this.listenTo(t[0].element,"selectstart",((t,e)=>{e.stopPropagation()}),{priority:"high"})}destroy(){super.destroy();this.focusTracker.destroy();this.keystrokes.destroy()}getIntegration(t){return this._integrations.find((e=>e.name===t))}_createActionButtons(t){const e=t.t;const n=new Fv(t);const o=new Fv(t);n.set({label:e("Insert"),icon:vv.check,class:"ck-button-save",type:"submit",withText:true,isEnabled:this.imageURLInputValue});o.set({label:e("Cancel"),icon:vv.cancel,class:"ck-button-cancel",withText:true});n.bind("isEnabled").to(this,"imageURLInputValue",(t=>!!t));n.delegate("execute").to(this,"submit");o.delegate("execute").to(this,"cancel");return{insertButtonView:n,cancelButtonView:o}}focus(){this._focusCycler.focusFirst()}}function MB(t){const e=t.config.get("image.insert.integrations");const n=t.plugins.get("ImageInsertUI");const o={insertImageViaUrl:FB(t.locale)};if(!e){return o}if(e.find((t=>t==="openCKFinder"))&&t.ui.componentFactory.has("ckfinder")){const e=t.ui.componentFactory.create("ckfinder");e.set({withText:true,class:"ck-image-insert__ck-finder-button"});e.delegate("execute").to(n,"cancel");o.openCKFinder=e}return e.reduce(((e,n)=>{if(o[n]){e[n]=o[n]}else if(t.ui.componentFactory.has(n)){e[n]=t.ui.componentFactory.create(n)}return e}),{})}function FB(t){const e=t.t;const n=new Sy(t,Dy);n.set({label:e("Insert image via URL")});n.fieldView.placeholder="https://example.com/image.png";return n}class VB extends et{static get pluginName(){return"ImageInsertUI"}init(){const t=this.editor;const e=t=>this._createDropdownView(t);t.ui.componentFactory.add("insertImage",e);t.ui.componentFactory.add("imageInsert",e)}_createDropdownView(t){const e=this.editor;const n=t.t;const o=e.commands.get("uploadImage");const i=e.commands.get("insertImage");this.dropdownView=NC(t,o?eC:undefined);const r=this.dropdownView.buttonView;const s=this.dropdownView.panelView;r.set({label:n("Insert image"),icon:vv.image,tooltip:true});s.extendTemplate({attributes:{class:"ck-image-insert__panel"}});if(o){const t=this.dropdownView.buttonView;t.actionView=e.ui.componentFactory.create("uploadImage");t.actionView.extendTemplate({attributes:{class:"ck ck-button ck-splitbutton__action"}})}return this._setUpDropdown(o||i)}_setUpDropdown(t){const e=this.editor;const n=e.t;const o=new zB(e.locale,MB(e));const i=o.insertButtonView;const r=o.getIntegration("insertImageViaUrl");const s=this.dropdownView;const a=s.panelView;const c=this.editor.plugins.get("ImageUtils");s.bind("isEnabled").to(t);s.once("change:isOpen",(()=>{a.children.add(o)}));s.on("change:isOpen",(()=>{const t=e.model.document.selection.getSelectedElement();if(s.isOpen){if(c.isImage(t)){o.imageURLInputValue=t.getAttribute("src");i.label=n("Update");r.label=n("Update image URL")}else{o.imageURLInputValue="";i.label=n("Insert");r.label=n("Insert image via URL")}}}),{priority:"low"});o.delegate("submit","cancel").to(s);this.delegate("cancel").to(s);s.on("submit",(()=>{d();l()}));s.on("cancel",(()=>{d()}));function l(){const t=e.model.document.selection.getSelectedElement();if(c.isImage(t)){e.model.change((e=>{e.setAttribute("src",o.imageURLInputValue,t);e.removeAttribute("srcset",t);e.removeAttribute("sizes",t)}))}else{e.execute("insertImage",{source:o.imageURLInputValue})}}function d(){e.editing.view.focus();s.isOpen=false}return s}}class NB extends et{static get pluginName(){return"ImageInsertViaUrl"}static get requires(){return[VB]}}class LB extends et{static get pluginName(){return"ImageInsert"}static get requires(){return[xB,NB,VB]}}class HB extends et{static get pluginName(){return"IndentEditing"}init(){const t=this.editor;t.commands.add("indent",new rt(t));t.commands.add("outdent",new rt(t))}}const jB='';const WB='';class qB extends et{static get pluginName(){return"IndentUI"}init(){const t=this.editor;const e=t.locale;const n=t.t;const o=e.uiLanguageDirection=="ltr"?jB:WB;const i=e.uiLanguageDirection=="ltr"?WB:jB;this._defineButton("indent",n("Increase indent"),o);this._defineButton("outdent",n("Decrease indent"),i)}_defineButton(t,e,n){const o=this.editor;o.ui.componentFactory.add(t,(i=>{const r=o.commands.get(t);const s=new Fv(i);s.set({label:e,icon:n,tooltip:true});s.bind("isOn","isEnabled").to(r,"value","isEnabled");this.listenTo(s,"execute",(()=>{o.execute(t);o.editing.view.focus()}));return s}))}}class UB extends et{static get pluginName(){return"Indent"}static get requires(){return[HB,qB]}}const $B="italic";class KB extends et{static get pluginName(){return"ItalicEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:$B});t.model.schema.setAttributeProperties($B,{isFormatting:true,copyOnEnter:true});t.conversion.attributeToElement({model:$B,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]});t.commands.add($B,new bx(t,$B));t.keystrokes.set("CTRL+I",$B)}}const GB='';const ZB="italic";class JB extends et{static get pluginName(){return"ItalicUI"}init(){const t=this.editor;const e=t.t;t.ui.componentFactory.add(ZB,(n=>{const o=t.commands.get(ZB);const i=new Fv(n);i.set({label:e("Italic"),icon:GB,keystroke:"CTRL+I",tooltip:true,isToggleable:true});i.bind("isOn","isEnabled").to(o,"value","isEnabled");this.listenTo(i,"execute",(()=>{t.execute(ZB);t.editing.view.focus()}));return i}))}}class YB extends et{static get requires(){return[KB,JB]}static get pluginName(){return"Italic"}}class QB{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(t){if(Array.isArray(t)){t.forEach((t=>this._definitions.add(t)))}else{this._definitions.add(t)}}getDispatcher(){return t=>{t.on("attribute:linkHref",((t,e,n)=>{if(!n.consumable.test(e.item,"attribute:linkHref")){return}if(!(e.item.is("selection")||n.schema.isInline(e.item))){return}const o=n.writer;const i=o.document.selection;for(const t of this._definitions){const r=o.createAttributeElement("a",t.attributes,{priority:5});if(t.classes){o.addClass(t.classes,r)}for(const e in t.styles){o.setStyle(e,t.styles[e],r)}o.setCustomProperty("link",true,r);if(t.callback(e.attributeNewValue)){if(e.item.is("selection")){o.wrap(i.getFirstRange(),r)}else{o.wrap(n.mapper.toViewRange(e.range),r)}}else{o.unwrap(n.mapper.toViewRange(e.range),r)}}}),{priority:"high"})}}getDispatcherForLinkedImage(){return t=>{t.on("attribute:linkHref:imageBlock",((t,e,{writer:n,mapper:o})=>{const i=o.toViewElement(e.item);const r=Array.from(i.getChildren()).find((t=>t.name==="a"));for(const t of this._definitions){const o=Ga(t.attributes);if(t.callback(e.attributeNewValue)){for(const[t,e]of o){if(t==="class"){n.addClass(e,r)}else{n.setAttribute(t,e,r)}}if(t.classes){n.addClass(t.classes,r)}for(const e in t.styles){n.setStyle(e,t.styles[e],r)}}else{for(const[t,e]of o){if(t==="class"){n.removeClass(e,r)}else{n.removeAttribute(t,r)}}if(t.classes){n.removeClass(t.classes,r)}for(const e in t.styles){n.removeStyle(e,r)}}}}))}}}function XB(t,e,n){var o=t.length;n=n===undefined?o:n;return!e&&n>=o?t:Hc(t,e,n)}const tP=XB;var eP="\\ud800-\\udfff",nP="\\u0300-\\u036f",oP="\\ufe20-\\ufe2f",iP="\\u20d0-\\u20ff",rP=nP+oP+iP,sP="\\ufe0e\\ufe0f";var aP="\\u200d";var cP=RegExp("["+aP+eP+rP+sP+"]");function lP(t){return cP.test(t)}const dP=lP;function uP(t){return t.split("")}const hP=uP;var fP="\\ud800-\\udfff",gP="\\u0300-\\u036f",pP="\\ufe20-\\ufe2f",mP="\\u20d0-\\u20ff",kP=gP+pP+mP,bP="\\ufe0e\\ufe0f";var wP="["+fP+"]",_P="["+kP+"]",AP="\\ud83c[\\udffb-\\udfff]",vP="(?:"+_P+"|"+AP+")",CP="[^"+fP+"]",yP="(?:\\ud83c[\\udde6-\\uddff]){2}",xP="[\\ud800-\\udbff][\\udc00-\\udfff]",EP="\\u200d";var SP=vP+"?",DP="["+bP+"]?",TP="(?:"+EP+"(?:"+[CP,yP,xP].join("|")+")"+DP+SP+")*",BP=DP+SP+TP,PP="(?:"+[CP+_P+"?",_P,yP,xP,wP].join("|")+")";var IP=RegExp(AP+"(?="+AP+")|"+PP+BP,"g");function RP(t){return t.match(IP)||[]}const OP=RP;function zP(t){return dP(t)?OP(t):hP(t)}const MP=zP;function FP(t){return function(e){e=Bc(e);var n=dP(e)?MP(e):undefined;var o=n?n[0]:e.charAt(0);var i=n?tP(n,1).join(""):e.slice(1);return o[t]()+i}}const VP=FP;var NP=VP("toUpperCase");const LP=NP;const HP=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g;const jP=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i;const WP=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i;const qP=/^((\w+:(\/{2,})?)|(\W))/i;const UP="Ctrl+K";function $P(t){return t.is("attributeElement")&&!!t.getCustomProperty("link")}function KP(t,{writer:e}){const n=e.createAttributeElement("a",{href:t},{priority:5});e.setCustomProperty("link",true,n);return n}function GP(t){t=String(t);return ZP(t)?t:"#"}function ZP(t){const e=t.replace(HP,"");return e.match(jP)}function JP(t,e){const n={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};e.forEach((t=>{if(t.label&&n[t.label]){t.label=n[t.label]}return t}));return e}function YP(t){const e=[];if(t){for(const[n,o]of Object.entries(t)){const t=Object.assign({},o,{id:`link${LP(n)}`});e.push(t)}}return e}function QP(t,e){if(!t){return false}return e.checkAttribute(t.name,"linkHref")}function XP(t){return WP.test(t)}function tI(t,e){const n=XP(t)?"mailto:":e;const o=!!n&&!eI(t);return t&&o?n+t:t}function eI(t){return qP.test(t)}function nI(t){window.open(t,"_blank","noopener")}class oI extends ot{constructor(t){super(t);this.manualDecorators=new Ca;this.automaticDecorators=new QB}restoreManualDecoratorStates(){for(const t of this.manualDecorators){t.value=this._getDecoratorStateFromModel(t.id)}}refresh(){const t=this.editor.model;const e=t.document.selection;const n=e.getSelectedElement()||cg(e.getSelectedBlocks());if(QP(n,t.schema)){this.value=n.getAttribute("linkHref");this.isEnabled=t.schema.checkAttribute(n,"linkHref")}else{this.value=e.getAttribute("linkHref");this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref")}for(const t of this.manualDecorators){t.value=this._getDecoratorStateFromModel(t.id)}}execute(t,e={}){const n=this.editor.model;const o=n.document.selection;const i=[];const r=[];for(const t in e){if(e[t]){i.push(t)}else{r.push(t)}}n.change((e=>{if(o.isCollapsed){const s=o.getFirstPosition();if(o.hasAttribute("linkHref")){const a=JS(s,"linkHref",o.getAttribute("linkHref"),n);e.setAttribute("linkHref",t,a);i.forEach((t=>{e.setAttribute(t,true,a)}));r.forEach((t=>{e.removeAttribute(t,a)}));e.setSelection(e.createPositionAfter(a.end.nodeBefore))}else if(t!==""){const r=Ga(o.getAttributes());r.set("linkHref",t);i.forEach((t=>{r.set(t,true)}));const{end:a}=n.insertContent(e.createText(t,r),s);e.setSelection(a)}["linkHref",...i,...r].forEach((t=>{e.removeSelectionAttribute(t)}))}else{const s=n.schema.getValidRanges(o.getRanges(),"linkHref");const a=[];for(const t of o.getSelectedBlocks()){if(n.schema.checkAttribute(t,"linkHref")){a.push(e.createRangeOn(t))}}const c=a.slice();for(const t of s){if(this._isRangeToUpdate(t,a)){c.push(t)}}for(const n of c){e.setAttribute("linkHref",t,n);i.forEach((t=>{e.setAttribute(t,true,n)}));r.forEach((t=>{e.removeAttribute(t,n)}))}}}))}_getDecoratorStateFromModel(t){const e=this.editor.model;const n=e.document.selection;const o=n.getSelectedElement();if(QP(o,e.schema)){return o.getAttribute(t)}return n.getAttribute(t)}_isRangeToUpdate(t,e){for(const n of e){if(n.containsRange(t)){return false}}return true}}class iI extends ot{refresh(){const t=this.editor.model;const e=t.document.selection;const n=e.getSelectedElement();if(QP(n,t.schema)){this.isEnabled=t.schema.checkAttribute(n,"linkHref")}else{this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref")}}execute(){const t=this.editor;const e=this.editor.model;const n=e.document.selection;const o=t.commands.get("link");e.change((t=>{const i=n.isCollapsed?[JS(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),e)]:e.schema.getValidRanges(n.getRanges(),"linkHref");for(const e of i){t.removeAttribute("linkHref",e);if(o){for(const n of o.manualDecorators){t.removeAttribute(n.id,e)}}}}))}}class rI{constructor({id:t,label:e,attributes:n,classes:o,styles:i,defaultValue:r}){this.id=t;this.set("value");this.defaultValue=r;this.label=e;this.attributes=n;this.classes=o;this.styles=i}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}Xf(rI,W);var sI=n(399);var aI={injectType:"singletonStyleTag",attributes:{"data-cke":true}};aI.insert="head";aI.singleton=true;var cI=Vu()(sI.Z,aI);const lI=sI.Z.locals||{};const dI="ck-link_selected";const uI="automatic";const hI="manual";const fI=/^(https?:)?\/\//;class gI extends et{static get pluginName(){return"LinkEditing"}static get requires(){return[OS,TS,Bx]}constructor(t){super(t);t.config.define("link",{addTargetToExternalLinks:false})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"linkHref"});t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:KP});t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,e)=>KP(GP(t),e)});t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:true}},model:{key:"linkHref",value:t=>t.getAttribute("href")}});t.commands.add("link",new oI(t));t.commands.add("unlink",new iI(t));const e=JP(t.t,YP(t.config.get("link.decorators")));this._enableAutomaticDecorators(e.filter((t=>t.mode===uI)));this._enableManualDecorators(e.filter((t=>t.mode===hI)));const n=t.plugins.get(OS);n.registerAttribute("linkHref");QS(t,"linkHref","a",dI);this._enableLinkOpen();this._enableInsertContentSelectionAttributesFixer();this._enableClickingAfterLink();this._enableTypingOverLink();this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(t){const e=this.editor;const n=e.commands.get("link");const o=n.automaticDecorators;if(e.config.get("link.addTargetToExternalLinks")){o.add({id:"linkIsExternal",mode:uI,callback:t=>fI.test(t),attributes:{target:"_blank",rel:"noopener noreferrer"}})}o.add(t);if(o.length){e.conversion.for("downcast").add(o.getDispatcher())}}_enableManualDecorators(t){if(!t.length){return}const e=this.editor;const n=e.commands.get("link");const o=n.manualDecorators;t.forEach((t=>{e.model.schema.extend("$text",{allowAttributes:t.id});t=new rI(t);o.add(t);e.conversion.for("downcast").attributeToElement({model:t.id,view:(e,{writer:n,schema:o},{item:i})=>{if(!(i.is("selection")||o.isInline(i))){return}if(e){const e=n.createAttributeElement("a",t.attributes,{priority:5});if(t.classes){n.addClass(t.classes,e)}for(const o in t.styles){n.setStyle(o,t.styles[o],e)}n.setCustomProperty("link",true,e);return e}}});e.conversion.for("upcast").elementToAttribute({view:{name:"a",...t._createPattern()},model:{key:t.id}})}))}_enableLinkOpen(){const t=this.editor;const e=t.editing.view;const n=e.document;this.listenTo(n,"click",((t,e)=>{const n=Sd.isMac?e.domEvent.metaKey:e.domEvent.ctrlKey;if(!n){return}let o=e.domTarget;if(o.tagName.toLowerCase()!="a"){o=o.closest("a")}if(!o){return}const i=o.getAttribute("href");if(!i){return}t.stop();e.preventDefault();nI(i)}),{context:"$capture"});this.listenTo(n,"keydown",((e,n)=>{const o=t.commands.get("link").value;const i=o&&n.keyCode===Vd.enter&&n.altKey;if(!i){return}e.stop();nI(o)}))}_enableInsertContentSelectionAttributesFixer(){const t=this.editor;const e=t.model;const n=e.document.selection;this.listenTo(e,"insertContent",(()=>{const t=n.anchor.nodeBefore;const o=n.anchor.nodeAfter;if(!n.hasAttribute("linkHref")){return}if(!t){return}if(!t.hasAttribute("linkHref")){return}if(o&&o.hasAttribute("linkHref")){return}e.change((t=>{pI(t,bI(e.schema))}))}),{priority:"low"})}_enableClickingAfterLink(){const t=this.editor;const e=t.model;t.editing.view.addObserver(kw);let n=false;this.listenTo(t.editing.view.document,"mousedown",(()=>{n=true}));this.listenTo(t.editing.view.document,"selectionChange",(()=>{if(!n){return}n=false;const t=e.document.selection;if(!t.isCollapsed){return}if(!t.hasAttribute("linkHref")){return}const o=t.getFirstPosition();const i=JS(o,"linkHref",t.getAttribute("linkHref"),e);if(o.isTouching(i.start)||o.isTouching(i.end)){e.change((t=>{pI(t,bI(e.schema))}))}}))}_enableTypingOverLink(){const t=this.editor;const e=t.editing.view;let n;let o;this.listenTo(e.document,"delete",(()=>{o=true}),{priority:"high"});this.listenTo(t.model,"deleteContent",(()=>{const e=t.model.document.selection;if(e.isCollapsed){return}if(o){o=false;return}if(!kI(t)){return}if(mI(t.model)){n=e.getAttributes()}}),{priority:"high"});this.listenTo(t.model,"insertContent",((e,[i])=>{o=false;if(!kI(t)){return}if(!n){return}t.model.change((t=>{for(const[e,o]of n){t.setAttribute(e,o,i)}}));n=null}),{priority:"high"})}_handleDeleteContentAfterLink(){const t=this.editor;const e=t.model;const n=e.document.selection;const o=t.editing.view;let i=false;let r=false;this.listenTo(o.document,"delete",((t,e)=>{r=e.direction==="backward"}),{priority:"high"});this.listenTo(e,"deleteContent",(()=>{i=false;const t=n.getFirstPosition();const o=n.getAttribute("linkHref");if(!o){return}const r=JS(t,"linkHref",o,e);i=r.containsPosition(t)||r.end.isEqual(t)}),{priority:"high"});this.listenTo(e,"deleteContent",(()=>{if(!r){return}r=false;if(i){return}t.model.enqueueChange((t=>{pI(t,bI(e.schema))}))}),{priority:"low"})}}function pI(t,e){t.removeSelectionAttribute("linkHref");for(const n of e){t.removeSelectionAttribute(n)}}function mI(t){const e=t.document.selection;const n=e.getFirstPosition();const o=e.getLastPosition();const i=n.nodeAfter;if(!i){return false}if(!i.is("$text")){return false}if(!i.hasAttribute("linkHref")){return false}const r=o.textNode||o.nodeBefore;if(i===r){return true}const s=JS(n,"linkHref",i.getAttribute("linkHref"),t);return s.containsRange(t.createRange(n,o),true)}function kI(t){const e=t.model.change((t=>t.batch));return e.isTyping}function bI(t){const e=t.getDefinition("$text").allowAttributes;return e.filter((t=>t.startsWith("link")))}var wI=n(827);var _I={injectType:"singletonStyleTag",attributes:{"data-cke":true}};_I.insert="head";_I.singleton=true;var AI=Vu()(wI.Z,_I);const vI=wI.Z.locals||{};class CI extends aA{constructor(t,e){super(t);const n=t.t;this.focusTracker=new lg;this.keystrokes=new dg;this.urlInputView=this._createUrlInput();this.saveButtonView=this._createButton(n("Save"),vv.check,"ck-button-save");this.saveButtonView.type="submit";this.cancelButtonView=this._createButton(n("Cancel"),vv.cancel,"ck-button-cancel","cancel");this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e);this.children=this._createFormChildren(e.manualDecorators);this._focusables=new S_;this._focusCycler=new cC({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];if(e.manualDecorators.length){o.push("ck-link-form_layout-vertical","ck-vertical-form")}this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children});yv(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((t,e)=>{t[e.name]=e.isOn;return t}),{})}render(){super.render();xv({view:this});const t=[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView];t.forEach((t=>{this._focusables.add(t);this.focusTracker.add(t.element)}));this.keystrokes.listenTo(this.element)}destroy(){super.destroy();this.focusTracker.destroy();this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const t=this.locale.t;const e=new Sy(this.locale,Dy);e.label=t("Link URL");return e}_createButton(t,e,n,o){const i=new Fv(this.locale);i.set({label:t,icon:e,tooltip:true});i.extendTemplate({attributes:{class:n}});if(o){i.delegate("execute").to(this,o)}return i}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const n of t.manualDecorators){const o=new jv(this.locale);o.set({name:n.id,label:n.label,withText:true});o.bind("isOn").toMany([n,t],"value",((t,e)=>e===undefined&&t===undefined?n.defaultValue:t));o.on("execute",(()=>{n.set("value",!o.isOn)}));e.add(o)}return e}_createFormChildren(t){const e=this.createCollection();e.add(this.urlInputView);if(t.length){const t=new aA;t.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((t=>({tag:"li",children:[t],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}});e.add(t)}e.add(this.saveButtonView);e.add(this.cancelButtonView);return e}}var yI=n(465);var xI={injectType:"singletonStyleTag",attributes:{"data-cke":true}};xI.insert="head";xI.singleton=true;var EI=Vu()(yI.Z,xI);const SI=yI.Z.locals||{};const DI='';class TI extends aA{constructor(t){super(t);const e=t.t;this.focusTracker=new lg;this.keystrokes=new dg;this.previewButtonView=this._createPreviewButton();this.unlinkButtonView=this._createButton(e("Unlink"),DI,"unlink");this.editButtonView=this._createButton(e("Edit link"),vv.pencil,"edit");this.set("href");this._focusables=new S_;this._focusCycler=new cC({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render();const t=[this.previewButtonView,this.editButtonView,this.unlinkButtonView];t.forEach((t=>{this._focusables.add(t);this.focusTracker.add(t.element)}));this.keystrokes.listenTo(this.element)}destroy(){super.destroy();this.focusTracker.destroy();this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(t,e,n){const o=new Fv(this.locale);o.set({label:t,icon:e,tooltip:true});o.delegate("execute").to(this,n);return o}_createPreviewButton(){const t=new Fv(this.locale);const e=this.bindTemplate;const n=this.t;t.set({withText:true,tooltip:n("Open link in new tab")});t.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:e.to("href",(t=>t&&GP(t))),target:"_blank",rel:"noopener noreferrer"}});t.bind("label").to(this,"href",(t=>t||n("This link has no URL")));t.bind("isEnabled").to(this,"href",(t=>!!t));t.template.tag="a";t.template.eventListeners={};return t}}const BI='';const PI="link-ui";class II extends et{static get requires(){return[qy]}static get pluginName(){return"LinkUI"}init(){const t=this.editor;t.editing.view.addObserver(mw);this.actionsView=this._createActionsView();this.formView=this._createFormView();this._balloon=t.plugins.get(qy);this._createToolbarLinkButton();this._enableUserBalloonInteractions();t.conversion.for("editingDowncast").markerToHighlight({model:PI,view:{classes:["ck-fake-link-selection"]}});t.conversion.for("editingDowncast").markerToElement({model:PI,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy();this.formView.destroy()}_createActionsView(){const t=this.editor;const e=new TI(t.locale);const n=t.commands.get("link");const o=t.commands.get("unlink");e.bind("href").to(n,"value");e.editButtonView.bind("isEnabled").to(n);e.unlinkButtonView.bind("isEnabled").to(o);this.listenTo(e,"edit",(()=>{this._addFormView()}));this.listenTo(e,"unlink",(()=>{t.execute("unlink");this._hideUI()}));e.keystrokes.set("Esc",((t,e)=>{this._hideUI();e()}));e.keystrokes.set(UP,((t,e)=>{this._addFormView();e()}));return e}_createFormView(){const t=this.editor;const e=t.commands.get("link");const n=t.config.get("link.defaultProtocol");const o=new CI(t.locale,e);o.urlInputView.fieldView.bind("value").to(e,"value");o.urlInputView.bind("isReadOnly").to(e,"isEnabled",(t=>!t));o.saveButtonView.bind("isEnabled").to(e);this.listenTo(o,"submit",(()=>{const{value:e}=o.urlInputView.fieldView.element;const i=tI(e,n);t.execute("link",i,o.getDecoratorSwitchesState());this._closeFormView()}));this.listenTo(o,"cancel",(()=>{this._closeFormView()}));o.keystrokes.set("Esc",((t,e)=>{this._closeFormView();e()}));return o}_createToolbarLinkButton(){const t=this.editor;const e=t.commands.get("link");const n=t.t;t.keystrokes.set(UP,((t,n)=>{n();if(e.isEnabled){this._showUI(true)}}));t.ui.componentFactory.add("link",(t=>{const o=new Fv(t);o.isEnabled=true;o.label=n("Link");o.icon=BI;o.keystroke=UP;o.tooltip=true;o.isToggleable=true;o.bind("isEnabled").to(e,"isEnabled");o.bind("isOn").to(e,"value",(t=>!!t));this.listenTo(o,"execute",(()=>this._showUI(true)));return o}))}_enableUserBalloonInteractions(){const t=this.editor.editing.view.document;this.listenTo(t,"click",(()=>{const t=this._getSelectedLinkElement();if(t){this._showUI()}}));this.editor.keystrokes.set("Tab",((t,e)=>{if(this._areActionsVisible&&!this.actionsView.focusTracker.isFocused){this.actionsView.focus();e()}}),{priority:"high"});this.editor.keystrokes.set("Esc",((t,e)=>{if(this._isUIVisible){this._hideUI();e()}}));Cv({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){if(this._areActionsInPanel){return}this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel){return}const t=this.editor;const e=t.commands.get("link");this.formView.disableCssTransitions();this._balloon.add({view:this.formView,position:this._getBalloonPositionData()});if(this._balloon.visibleView===this.formView){this.formView.urlInputView.fieldView.select()}this.formView.enableCssTransitions();this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const t=this.editor.commands.get("link");t.restoreManualDecoratorStates();if(t.value!==undefined){this._removeFormView()}else{this._hideUI()}}_removeFormView(){if(this._isFormInPanel){this.formView.saveButtonView.focus();this._balloon.remove(this.formView);this.editor.editing.view.focus();this._hideFakeVisualSelection()}}_showUI(t=false){if(!this._getSelectedLinkElement()){this._showFakeVisualSelection();this._addActionsView();if(t){this._balloon.showStack("main")}this._addFormView()}else{if(this._areActionsVisible){this._addFormView()}else{this._addActionsView()}if(t){this._balloon.showStack("main")}}this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel){return}const t=this.editor;this.stopListening(t.ui,"update");this.stopListening(this._balloon,"change:visibleView");t.editing.view.focus();this._removeFormView();this._balloon.remove(this.actionsView);this._hideFakeVisualSelection()}_startUpdatingUI(){const t=this.editor;const e=t.editing.view.document;let n=this._getSelectedLinkElement();let o=r();const i=()=>{const t=this._getSelectedLinkElement();const e=r();if(n&&!t||!n&&e!==o){this._hideUI()}else if(this._isUIVisible){this._balloon.updatePosition(this._getBalloonPositionData())}n=t;o=e};function r(){return e.selection.focus.getAncestors().reverse().find((t=>t.is("element")))}this.listenTo(t.ui,"update",i);this.listenTo(this._balloon,"change:visibleView",i)}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(){const t=this._balloon.visibleView;return t==this.formView||this._areActionsVisible}_getBalloonPositionData(){const t=this.editor.editing.view;const e=this.editor.model;const n=t.document;let o=null;if(e.markers.has(PI)){const e=Array.from(this.editor.editing.mapper.markerNameToElements(PI));const n=t.createRange(t.createPositionBefore(e[0]),t.createPositionAfter(e[e.length-1]));o=t.domConverter.viewRangeToDom(n)}else{o=()=>{const e=this._getSelectedLinkElement();return e?t.domConverter.mapViewToDom(e):t.domConverter.viewRangeToDom(n.selection.getFirstRange())}}return{target:o}}_getSelectedLinkElement(){const t=this.editor.editing.view;const e=t.document.selection;const n=e.getSelectedElement();if(e.isCollapsed||n&&oE(n)){return RI(e.getFirstPosition())}else{const n=e.getFirstRange().getTrimmed();const o=RI(n.start);const i=RI(n.end);if(!o||o!=i){return null}if(t.createRangeIn(o).getTrimmed().isEqual(n)){return o}else{return null}}}_showFakeVisualSelection(){const t=this.editor.model;t.change((e=>{const n=t.document.selection.getFirstRange();if(t.markers.has(PI)){e.updateMarker(PI,{range:n})}else{if(n.start.isAtEnd){const o=n.start.getLastMatchingPosition((({item:e})=>!t.schema.isContent(e)),{boundaries:n});e.addMarker(PI,{usingOperation:false,affectsData:false,range:e.createRange(o,n.end)})}else{e.addMarker(PI,{usingOperation:false,affectsData:false,range:n})}}}))}_hideFakeVisualSelection(){const t=this.editor.model;if(t.markers.has(PI)){t.change((t=>{t.removeMarker(PI)}))}}}function RI(t){return t.getAncestors().find((t=>$P(t)))}const OI=4;const zI=new RegExp("(^|\\s)"+"("+"("+"(?:(?:(?:https?|ftp):)?\\/\\/)"+"(?:\\S+(?::\\S*)?@)?"+"(?:"+"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])"+"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}"+"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))"+"|"+"("+"((?!www\\.)|(www\\.))"+"(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+"+"(?:[a-z\\u00a1-\\uffff]{2,63})"+")"+")"+"(?::\\d{2,5})?"+"(?:[/?#]\\S*)?"+")"+"|"+"("+"(www.|(\\S+@))"+"((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+"+"(?:[a-z\\u00a1-\\uffff]{2,63})"+")"+")$","i");const MI=2;class FI extends et{static get requires(){return[Zx]}static get pluginName(){return"AutoLink"}init(){const t=this.editor;const e=t.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}));this._enableTypingHandling()}afterInit(){this._enableEnterHandling();this._enableShiftEnterHandling()}_enableTypingHandling(){const t=this.editor;const e=new RS(t.model,(t=>{if(!VI(t)){return}const e=NI(t.substr(0,t.length-1));if(e){return{url:e}}}));e.on("matched:data",((e,n)=>{const{batch:o,range:i,url:r}=n;if(!o.isTyping){return}const s=i.end.getShiftedBy(-1);const a=s.getShiftedBy(-r.length);const c=t.model.createRange(a,s);this._applyAutoLink(r,c)}));e.bind("isEnabled").to(this)}_enableEnterHandling(){const t=this.editor;const e=t.model;const n=t.commands.get("enter");if(!n){return}n.on("execute",(()=>{const t=e.document.selection.getFirstPosition();if(!t.parent.previousSibling){return}const n=e.createRangeIn(t.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const t=this.editor;const e=t.model;const n=t.commands.get("shiftEnter");if(!n){return}n.on("execute",(()=>{const t=e.document.selection.getFirstPosition();const n=e.createRange(e.createPositionAt(t.parent,0),t.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(t){const e=this.editor.model;const{text:n,range:o}=IS(t,e);const i=NI(n);if(i){const t=e.createRange(o.end.getShiftedBy(-i.length),o.end);this._applyAutoLink(i,t)}}_applyAutoLink(t,e){const n=this.editor.model;const o=this.editor.config.get("link.defaultProtocol");const i=tI(t,o);if(!this.isEnabled||!LI(e,n)||!eI(i)||HI(e)){return}this._persistAutoLink(i,e)}_persistAutoLink(t,e){const n=this.editor.model;const o=this.editor.plugins.get("Delete");n.enqueueChange((i=>{i.setAttribute("linkHref",t,e);n.enqueueChange((()=>{o.requestUndoOnBackspace()}))}))}}function VI(t){return t.length>OI&&t[t.length-1]===" "&&t[t.length-2]!==" "}function NI(t){const e=zI.exec(t);return e?e[MI]:null}function LI(t,e){return e.schema.checkAttributeInSelection(e.createSelection(t),"linkHref")}function HI(t){const e=t.start.nodeAfter;return e&&e.hasAttribute("linkHref")}class jI extends et{static get requires(){return[gI,II,FI]}static get pluginName(){return"Link"}}class WI extends ot{constructor(t,e){super(t);this.type=e}refresh(){this.value=this._getValue();this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model;const n=e.document;const o=Array.from(n.selection.getSelectedBlocks()).filter((t=>UI(t,e.schema)));const i=t.forceValue!==undefined?!t.forceValue:this.value;e.change((t=>{if(i){let e=o[o.length-1].nextSibling;let n=Number.POSITIVE_INFINITY;let i=[];while(e&&e.name=="listItem"&&e.getAttribute("listIndent")!==0){const t=e.getAttribute("listIndent");if(t=n){if(r>i.getAttribute("listIndent")){r=i.getAttribute("listIndent")}if(i.getAttribute("listIndent")==r){t[e?"unshift":"push"](i)}i=i[e?"previousSibling":"nextSibling"]}}}function UI(t,e){return e.checkChild(t.parent,"listItem")&&!e.isObject(t)}class $I extends ot{constructor(t,e){super(t);this._indentBy=e=="forward"?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model;const e=t.document;let n=Array.from(e.selection.getSelectedBlocks());t.change((t=>{const e=n[n.length-1];let o=e.nextSibling;while(o&&o.name=="listItem"&&o.getAttribute("listIndent")>e.getAttribute("listIndent")){n.push(o);o=o.nextSibling}if(this._indentBy<0){n=n.reverse()}for(const e of n){const n=e.getAttribute("listIndent")+this._indentBy;if(n<0){t.rename(e,"paragraph")}else{t.setAttribute("listIndent",n,e)}}this.fire("_executeCleanup",n)}))}_checkEnabled(){const t=cg(this.editor.model.document.selection.getSelectedBlocks());if(!t||!t.is("element","listItem")){return false}if(this._indentBy>0){const e=t.getAttribute("listIndent");const n=t.getAttribute("listType");let o=t.previousSibling;while(o&&o.is("element","listItem")&&o.getAttribute("listIndent")>=e){if(o.getAttribute("listIndent")==e){return o.getAttribute("listType")==n}o=o.previousSibling}return false}return true}}function KI(t){const e=t.createContainerElement("li");e.getFillerOffset=sR;return e}function GI(t,e){const n=e.mapper;const o=e.writer;const i=t.getAttribute("listType")=="numbered"?"ol":"ul";const r=KI(o);const s=o.createContainerElement(i,null);o.insert(o.createPositionAt(s,0),r);n.bindElements(t,r);return r}function ZI(t,e,n,o){const i=e.parent;const r=n.mapper;const s=n.writer;let a=r.toViewPosition(o.createPositionBefore(t));const c=QI(t.previousSibling,{sameIndent:true,smallerIndent:true,listIndent:t.getAttribute("listIndent")});const l=t.previousSibling;if(c&&c.getAttribute("listIndent")==t.getAttribute("listIndent")){const t=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(t))}else{if(l&&l.name=="listItem"){a=r.toViewPosition(o.createPositionAt(l,"end"));const t=r.findMappedViewAncestor(a);const e=tR(t);if(e){a=s.createPositionBefore(e)}else{a=s.createPositionAt(t,"end")}}else{a=r.toViewPosition(o.createPositionBefore(t))}}a=YI(a);s.insert(a,i);if(l&&l.name=="listItem"){const t=r.toViewElement(l);const n=s.createRange(s.createPositionAt(t,0),a);const o=n.getWalker({ignoreElementEnd:true});for(const t of o){if(t.item.is("element","li")){const n=s.breakContainer(s.createPositionBefore(t.item));const i=t.item.parent;const r=s.createPositionAt(e,"end");JI(s,r.nodeBefore,r.nodeAfter);s.move(s.createRangeOn(i),r);o.position=n}}}else{const n=i.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let o=null;for(const e of n.getChildren()){const n=r.toModelElement(e);if(n&&n.getAttribute("listIndent")>t.getAttribute("listIndent")){o=e}else{break}}if(o){s.breakContainer(s.createPositionAfter(o));s.move(s.createRangeOn(o.parent),s.createPositionAt(e,"end"))}}}JI(s,i,i.nextSibling);JI(s,i.previousSibling,i)}function JI(t,e,n){if(!e||!n||e.name!="ul"&&e.name!="ol"){return null}if(e.name!=n.name||e.getAttribute("class")!==n.getAttribute("class")){return null}return t.mergeContainers(t.createPositionAfter(e))}function YI(t){return t.getLastMatchingPosition((t=>t.item.is("uiElement")))}function QI(t,e){const n=!!e.sameIndent;const o=!!e.smallerIndent;const i=e.listIndent;let r=t;while(r&&r.name=="listItem"){const t=r.getAttribute("listIndent");if(n&&i==t||o&&i>t){return r}if(e.direction==="forward"){r=r.nextSibling}else{r=r.previousSibling}}return null}function XI(t,e,n,o){t.ui.componentFactory.add(e,(i=>{const r=t.commands.get(e);const s=new Fv(i);s.set({label:n,icon:o,tooltip:true,isToggleable:true});s.bind("isOn","isEnabled").to(r,"value","isEnabled");s.on("execute",(()=>{t.execute(e);t.editing.view.focus()}));return s}))}function tR(t){for(const e of t.getChildren()){if(e.name=="ul"||e.name=="ol"){return e}}return null}function eR(t,e){const n=[];const o=t.parent;const i={ignoreElementEnd:false,startPosition:t,shallow:true,direction:e};const r=o.getAttribute("listIndent");const s=[...new TreeWalker(i)].filter((t=>t.item.is("element"))).map((t=>t.item));for(const t of s){if(!t.is("element","listItem")){break}if(t.getAttribute("listIndent")r){continue}if(t.getAttribute("listType")!==o.getAttribute("listType")){break}if(t.getAttribute("listStyle")!==o.getAttribute("listStyle")){break}if(t.getAttribute("listReversed")!==o.getAttribute("listReversed")){break}if(t.getAttribute("listStart")!==o.getAttribute("listStart")){break}if(e==="backward"){n.unshift(t)}else{n.push(t)}}return n}function nR(t){const e=t.document;let n=[...e.selection.getSelectedBlocks()].filter((t=>t.is("element","listItem"))).map((e=>{const n=t.change((t=>t.createPositionAt(e,0)));return[...eR(n,"backward"),...eR(n,"forward")]})).flat();n=[...new Set(n)];return n}const oR=null&&["disc","circle","square"];const iR=null&&["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function rR(t){if(oR.includes(t)){return"bulleted"}if(iR.includes(t)){return"numbered"}return null}function sR(){const t=!this.isEmpty&&(this.getChild(0).name=="ul"||this.getChild(0).name=="ol");if(this.isEmpty||t){return 0}return Ql.call(this)}function aR(t){return(e,n,o)=>{const i=o.consumable;if(!i.test(n.item,"insert")||!i.test(n.item,"attribute:listType")||!i.test(n.item,"attribute:listIndent")){return}i.consume(n.item,"insert");i.consume(n.item,"attribute:listType");i.consume(n.item,"attribute:listIndent");const r=n.item;const s=GI(r,o);ZI(r,s,o,t)}}function cR(t){return(e,n,o)=>{const i=o.mapper.toViewPosition(n.position);const r=i.getLastMatchingPosition((t=>!t.item.is("element","li")));const s=r.nodeAfter;const a=o.writer;a.breakContainer(a.createPositionBefore(s));a.breakContainer(a.createPositionAfter(s));const c=s.parent;const l=c.previousSibling;const d=a.createRangeOn(c);const u=a.remove(d);if(l&&l.nextSibling){JI(a,l,l.nextSibling)}const h=o.mapper.toModelElement(s);CR(h.getAttribute("listIndent")+1,n.position,d.start,s,o,t);for(const t of a.createRangeIn(u).getItems()){o.mapper.unbindViewElement(t)}e.stop()}}function lR(t,e,n){if(!n.consumable.test(e.item,t.name)){return}const o=n.mapper.toViewElement(e.item);const i=n.writer;i.breakContainer(i.createPositionBefore(o));i.breakContainer(i.createPositionAfter(o));const r=o.parent;const s=e.attributeNewValue=="numbered"?"ol":"ul";i.rename(s,r)}function dR(t,e,n){n.consumable.consume(e.item,t.name);const o=n.mapper.toViewElement(e.item);const i=o.parent;const r=n.writer;JI(r,i,i.nextSibling);JI(r,i.previousSibling,i)}function uR(t){return(e,n,o)=>{if(!o.consumable.consume(n.item,"attribute:listIndent")){return}const i=o.mapper.toViewElement(n.item);const r=o.writer;r.breakContainer(r.createPositionBefore(i));r.breakContainer(r.createPositionAfter(i));const s=i.parent;const a=s.previousSibling;const c=r.createRangeOn(s);r.remove(c);if(a&&a.nextSibling){JI(r,a,a.nextSibling)}CR(n.attributeOldValue+1,n.range.start,c.start,i,o,t);ZI(n.item,i,o,t);for(const t of n.item.getChildren()){o.consumable.consume(t,"insert")}}}function hR(t,e,n){if(!n.consumable.test(e.item,t.name)){return}if(e.item.name!="listItem"){let t=n.mapper.toViewPosition(e.range.start);const o=n.writer;const i=[];while(t.parent.name=="ul"||t.parent.name=="ol"){t=o.breakContainer(t);if(t.parent.name!="li"){break}const e=t;const n=o.createPositionAt(t.parent,"end");if(!e.isEqual(n)){const t=o.remove(o.createRange(e,n));i.push(t)}t=o.createPositionAfter(t.parent)}if(i.length>0){for(let e=0;e0){const e=JI(o,n,n.nextSibling);if(e&&e.parent==n){t.offset--}}}JI(o,t.nodeBefore,t.nodeAfter)}}}function fR(t,e,n){const o=n.mapper.toViewPosition(e.position);const i=o.nodeBefore;const r=o.nodeAfter;JI(n.writer,i,r)}function gR(t,e,n){if(n.consumable.consume(e.viewItem,{name:true})){const t=n.writer;const o=t.createElement("listItem");const i=xR(e.viewItem);t.setAttribute("listIndent",i,o);const r=e.viewItem.parent&&e.viewItem.parent.name=="ol"?"numbered":"bulleted";t.setAttribute("listType",r,o);if(!n.safeInsert(o,e.modelCursor)){return}const s=AR(o,e.viewItem.getChildren(),n);e.modelRange=t.createRange(e.modelCursor,s);n.updateConversionResult(o,e)}}function pR(t,e,n){if(n.consumable.test(e.viewItem,{name:true})){const t=Array.from(e.viewItem.getChildren());for(const e of t){const t=!(e.is("element","li")||yR(e));if(t){e._remove()}}}}function mR(t,e,n){if(n.consumable.test(e.viewItem,{name:true})){if(e.viewItem.childCount===0){return}const t=[...e.viewItem.getChildren()];let n=false;for(const e of t){if(n&&!yR(e)){e._remove()}if(yR(e)){n=true}}}}function kR(t){return(e,n)=>{if(n.isPhantom){return}const o=n.modelPosition.nodeBefore;if(o&&o.is("element","listItem")){const e=n.mapper.toViewElement(o);const i=e.getAncestors().find(yR);const r=t.createPositionAt(e,0).getWalker();for(const t of r){if(t.type=="elementStart"&&t.item.is("element","li")){n.viewPosition=t.previousPosition;break}else if(t.type=="elementEnd"&&t.item==i){n.viewPosition=t.nextPosition;break}}}}}function bR(t){return(e,n)=>{const o=n.viewPosition;const i=o.parent;const r=n.mapper;if(i.name=="ul"||i.name=="ol"){if(!o.isAtEnd){const e=r.toModelElement(o.nodeAfter);n.modelPosition=t.createPositionBefore(e)}else{const e=r.toModelElement(o.nodeBefore);const i=r.getModelLength(o.nodeBefore);n.modelPosition=t.createPositionBefore(e).getShiftedBy(i)}e.stop()}else if(i.name=="li"&&o.nodeBefore&&(o.nodeBefore.name=="ul"||o.nodeBefore.name=="ol")){const s=r.toModelElement(i);let a=1;let c=o.nodeBefore;while(c&&yR(c)){a+=r.getModelLength(c);c=c.previousSibling}n.modelPosition=t.createPositionBefore(s).getShiftedBy(a);e.stop()}}}function wR(t,e){const n=t.document.differ.getChanges();const o=new Map;let i=false;for(const o of n){if(o.type=="insert"&&o.name=="listItem"){r(o.position)}else if(o.type=="insert"&&o.name!="listItem"){if(o.name!="$text"){const n=o.position.nodeAfter;if(n.hasAttribute("listIndent")){e.removeAttribute("listIndent",n);i=true}if(n.hasAttribute("listType")){e.removeAttribute("listType",n);i=true}if(n.hasAttribute("listStyle")){e.removeAttribute("listStyle",n);i=true}if(n.hasAttribute("listReversed")){e.removeAttribute("listReversed",n);i=true}if(n.hasAttribute("listStart")){e.removeAttribute("listStart",n);i=true}for(const e of Array.from(t.createRangeIn(n)).filter((t=>t.item.is("element","listItem")))){r(e.previousPosition)}}const n=o.position.getShiftedBy(o.length);r(n)}else if(o.type=="remove"&&o.name=="listItem"){r(o.position)}else if(o.type=="attribute"&&o.attributeKey=="listIndent"){r(o.range.start)}else if(o.type=="attribute"&&o.attributeKey=="listType"){r(o.range.start)}}for(const t of o.values()){s(t);a(t)}return i;function r(t){const e=t.nodeBefore;if(!e||!e.is("element","listItem")){const e=t.nodeAfter;if(e&&e.is("element","listItem")){o.set(e,e)}}else{let t=e;if(o.has(t)){return}for(let e=t.previousSibling;e&&e.is("element","listItem");e=t.previousSibling){t=e;if(o.has(t)){return}}o.set(e,t)}}function s(t){let n=0;let o=null;while(t&&t.is("element","listItem")){const r=t.getAttribute("listIndent");if(r>n){let s;if(o===null){o=r-n;s=n}else{if(o>r){o=r}s=r-o}e.setAttribute("listIndent",s,t);i=true}else{o=null;n=t.getAttribute("listIndent")+1}t=t.nextSibling}}function a(t){let n=[];let o=null;while(t&&t.is("element","listItem")){const r=t.getAttribute("listIndent");if(o&&o.getAttribute("listIndent")>r){n=n.slice(0,r+1)}if(r!=0){if(n[r]){const o=n[r];if(t.getAttribute("listType")!=o){e.setAttribute("listType",o,t);i=true}}else{n[r]=t.getAttribute("listType")}}o=t;t=t.nextSibling}}}function _R(t,[e,n,o]){let i=e.is("documentFragment")?e.getChild(0):e;let r;if(!n){r=this.document.selection}else{r=this.createSelection(n,o)}if(i&&i.is("element","listItem")){const t=r.getFirstPosition();let e=null;if(t.parent.is("element","listItem")){e=t.parent}else if(t.nodeBefore&&t.nodeBefore.is("element","listItem")){e=t.nodeBefore}if(e){const t=e.getAttribute("listIndent");if(t>0){while(i&&i.is("element","listItem")){i._setAttribute("listIndent",i.getAttribute("listIndent")+t);i=i.nextSibling}}}}}function AR(t,e,n){const{writer:o,schema:i}=n;let r=o.createPositionAfter(t);for(const s of e){if(s.name=="ul"||s.name=="ol"){r=n.convertItem(s,r).modelCursor}else{const e=n.convertItem(s,o.createPositionAt(t,"end"));const a=e.modelRange.start.nodeAfter;const c=a&&a.is("element")&&!i.checkChild(t,a.name);if(c){if(e.modelCursor.parent.is("element","listItem")){t=e.modelCursor.parent}else{t=vR(e.modelCursor)}r=o.createPositionAfter(t)}}}return r}function vR(t){const e=new Hg({startPosition:t});let n;do{n=e.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function CR(t,e,n,o,i,r){const s=QI(e.nodeBefore,{sameIndent:true,smallerIndent:true,listIndent:t,foo:"b"});const a=i.mapper;const c=i.writer;const l=s?s.getAttribute("listIndent"):null;let d;if(!s){d=n}else if(l==t){const t=a.toViewElement(s).parent;d=c.createPositionAfter(t)}else{const t=r.createPositionAt(s,"end");d=a.toViewPosition(t)}d=YI(d);for(const t of[...o.getChildren()]){if(yR(t)){d=c.move(c.createRangeOn(t),d).end;JI(c,t,t.nextSibling);JI(c,t.previousSibling,t)}}}function yR(t){return t.is("element","ol")||t.is("element","ul")}function xR(t){let e=0;let n=t.parent;while(n){if(n.is("element","li")){e++}else{const t=n.previousSibling;if(t&&t.is("element","li")){e++}}n=n.parent}return e}class ER extends et{static get pluginName(){return"ListEditing"}static get requires(){return[Fx,Zx]}init(){const t=this.editor;t.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const e=t.data;const n=t.editing;t.model.document.registerPostFixer((e=>wR(t.model,e)));n.mapper.registerViewToModelLength("li",SR);e.mapper.registerViewToModelLength("li",SR);n.mapper.on("modelToViewPosition",kR(n.view));n.mapper.on("viewToModelPosition",bR(t.model));e.mapper.on("modelToViewPosition",kR(n.view));t.conversion.for("editingDowncast").add((e=>{e.on("insert",hR,{priority:"high"});e.on("insert:listItem",aR(t.model));e.on("attribute:listType:listItem",lR,{priority:"high"});e.on("attribute:listType:listItem",dR,{priority:"low"});e.on("attribute:listIndent:listItem",uR(t.model));e.on("remove:listItem",cR(t.model));e.on("remove",fR,{priority:"low"})}));t.conversion.for("dataDowncast").add((e=>{e.on("insert",hR,{priority:"high"});e.on("insert:listItem",aR(t.model))}));t.conversion.for("upcast").add((t=>{t.on("element:ul",pR,{priority:"high"});t.on("element:ol",pR,{priority:"high"});t.on("element:li",mR,{priority:"high"});t.on("element:li",gR)}));t.model.on("insertContent",_R,{priority:"high"});t.commands.add("numberedList",new WI(t,"numbered"));t.commands.add("bulletedList",new WI(t,"bulleted"));t.commands.add("indentList",new $I(t,"forward"));t.commands.add("outdentList",new $I(t,"backward"));const o=n.view.document;this.listenTo(o,"enter",((t,e)=>{const n=this.editor.model.document;const o=n.selection.getLastPosition().parent;if(n.selection.isCollapsed&&o.name=="listItem"&&o.isEmpty){this.editor.execute("outdentList");e.preventDefault();t.stop()}}),{context:"li"});this.listenTo(o,"delete",((t,e)=>{if(e.direction!=="backward"){return}const n=this.editor.model.document.selection;if(!n.isCollapsed){return}const o=n.getFirstPosition();if(!o.isAtStart){return}const i=o.parent;if(i.name!=="listItem"){return}const r=i.previousSibling&&i.previousSibling.name==="listItem";if(r){return}this.editor.execute("outdentList");e.preventDefault();t.stop()}),{context:"li"});this.listenTo(t.editing.view.document,"tab",((e,n)=>{const o=n.shiftKey?"outdentList":"indentList";const i=this.editor.commands.get(o);if(i.isEnabled){t.execute(o);n.stopPropagation();n.preventDefault();e.stop()}}),{context:"li"})}afterInit(){const t=this.editor.commands;const e=t.get("indent");const n=t.get("outdent");if(e){e.registerChildCommand(t.get("indentList"))}if(n){n.registerChildCommand(t.get("outdentList"))}}}function SR(t){let e=1;for(const n of t.getChildren()){if(n.name=="ul"||n.name=="ol"){for(const t of n.getChildren()){e+=SR(t)}}}return e}const DR='';const TR='';class BR extends et{static get pluginName(){return"ListUI"}init(){const t=this.editor.t;XI(this.editor,"numberedList",t("Numbered List"),DR);XI(this.editor,"bulletedList",t("Bulleted List"),TR)}}class PR extends et{static get requires(){return[ER,BR]}static get pluginName(){return"List"}}function IR(t){const e=[{name:"address",isVoid:false},{name:"article",isVoid:false},{name:"aside",isVoid:false},{name:"blockquote",isVoid:false},{name:"br",isVoid:true},{name:"details",isVoid:false},{name:"dialog",isVoid:false},{name:"dd",isVoid:false},{name:"div",isVoid:false},{name:"dl",isVoid:false},{name:"dt",isVoid:false},{name:"fieldset",isVoid:false},{name:"figcaption",isVoid:false},{name:"figure",isVoid:false},{name:"footer",isVoid:false},{name:"form",isVoid:false},{name:"h1",isVoid:false},{name:"h2",isVoid:false},{name:"h3",isVoid:false},{name:"h4",isVoid:false},{name:"h5",isVoid:false},{name:"h6",isVoid:false},{name:"header",isVoid:false},{name:"hgroup",isVoid:false},{name:"hr",isVoid:true},{name:"input",isVoid:true},{name:"li",isVoid:false},{name:"main",isVoid:false},{name:"nav",isVoid:false},{name:"ol",isVoid:false},{name:"p",isVoid:false},{name:"section",isVoid:false},{name:"table",isVoid:false},{name:"tbody",isVoid:false},{name:"td",isVoid:false},{name:"textarea",isVoid:false},{name:"th",isVoid:false},{name:"thead",isVoid:false},{name:"tr",isVoid:false},{name:"ul",isVoid:false}];const n=e.map((t=>t.name)).join("|");const o=t.replace(new RegExp(`?(${n})( .*?)?>`,"g"),"\n$&\n").split("\n");let i=0;return o.filter((t=>t.length)).map((t=>{if(RR(t,e)){return zR(t,i++)}if(OR(t,e)){return zR(t,--i)}return zR(t,i)})).join("\n")}function RR(t,e){return e.some((e=>{if(e.isVoid){return false}if(!new RegExp(`<${e.name}( .*?)?>`).test(t)){return false}return true}))}function OR(t,e){return e.some((e=>new RegExp(`${e.name}>`).test(t)))}function zR(t,e,n=" "){return`${n.repeat(Math.max(0,e))}${t}`}var MR=n(671);var FR={injectType:"singletonStyleTag",attributes:{"data-cke":true}};FR.insert="head";FR.singleton=true;var VR=Vu()(MR.Z,FR);const NR=MR.Z.locals||{};const LR='';const HR="SourceEditingMode";class jR extends et{static get pluginName(){return"SourceEditing"}static get requires(){return[HA]}constructor(t){super(t);this.set("isSourceEditingMode",false);this._elementReplacer=new tg;this._replacedRoots=new Map;this._dataFromRoots=new Map}init(){const t=this.editor;const e=t.t;t.ui.componentFactory.add("sourceEditing",(n=>{const o=new Fv(n);o.set({label:e("Source"),icon:LR,tooltip:true,withText:true,class:"ck-source-editing-button"});o.bind("isOn").to(this,"isSourceEditingMode");o.bind("isEnabled").to(this,"isEnabled",t,"isReadOnly",t.plugins.get(HA),"hasAny",((t,e,n)=>{if(!t){return false}if(e){return false}if(n){return false}return true}));this.listenTo(o,"execute",(()=>{this.isSourceEditingMode=!this.isSourceEditingMode}));return o}));if(this._isAllowedToHandleSourceEditingMode()){this.on("change:isSourceEditingMode",((t,e,n)=>{if(n){this._showSourceEditing();this._disableCommands()}else{this._hideSourceEditing();this._enableCommands()}}));this.on("change:isEnabled",((t,e,n)=>this._handleReadOnlyMode(!n)));this.listenTo(t,"change:isReadOnly",((t,e,n)=>this._handleReadOnlyMode(n)))}t.data.on("get",(()=>{if(this.isSourceEditingMode){this._updateEditorData()}}),{priority:"high"})}afterInit(){const t=this.editor;const e=["RealTimeCollaborativeEditing","CommentsEditing","TrackChangesEditing","RevisionHistory"];if(e.some((e=>t.plugins.has(e)))){console.warn("You initialized the editor with the source editing feature and at least one of the collaboration features. "+"Please be advised that the source editing feature may not work, and be careful when editing document source "+"that contains markers created by the collaboration features.")}if(t.plugins.has("RestrictedEditingModeEditing")){console.warn("You initialized the editor with the source editing feature and restricted editing feature. "+"Please be advised that the source editing feature may not work, and be careful when editing document source "+"that contains markers created by the restricted editing feature.")}}_showSourceEditing(){const t=this.editor;const e=t.editing.view;const n=t.model;n.change((t=>{t.setSelection(null);t.removeSelectionAttribute(n.document.selection.getAttributeKeys())}));for(const[n,o]of e.domRoots){const i=WR(t.data.get({rootName:n}));const r=ig(o.ownerDocument,"textarea",{rows:"1","aria-label":"Source code editing area"});const s=ig(o.ownerDocument,"div",{class:"ck-source-editing-area","data-value":i},[r]);r.value=i;r.setSelectionRange(0,0);r.addEventListener("input",(()=>{s.dataset.value=r.value}));e.change((t=>{const o=e.document.getRoot(n);t.addClass("ck-hidden",o)}));t.ui.setEditableElement("sourceEditing:"+n,r);this._replacedRoots.set(n,s);this._elementReplacer.replace(o,s);this._dataFromRoots.set(n,i)}this._focusSourceEditing()}_hideSourceEditing(){const t=this.editor;const e=t.editing.view;this._updateEditorData();e.change((t=>{for(const[n]of this._replacedRoots){t.removeClass("ck-hidden",e.document.getRoot(n))}}));this._elementReplacer.restore();this._replacedRoots.clear();this._dataFromRoots.clear();e.focus()}_updateEditorData(){const t=this.editor;const e={};for(const[t,n]of this._replacedRoots){const o=this._dataFromRoots.get(t);const i=n.dataset.value;if(o!==i){e[t]=i}}if(Object.keys(e).length){t.data.set(e,{batchType:{isUndoable:true}})}}_focusSourceEditing(){const t=this.editor;const[e]=this._replacedRoots.values();const n=e.querySelector("textarea");t.editing.view.document.isFocused=false;n.focus()}_disableCommands(){const t=this.editor;for(const e of t.commands.commands()){e.forceDisabled(HR)}}_enableCommands(){const t=this.editor;for(const e of t.commands.commands()){e.clearForceDisabled(HR)}}_handleReadOnlyMode(t){if(!this.isSourceEditingMode){return}for(const[,e]of this._replacedRoots){e.querySelector("textarea").readOnly=t}}_isAllowedToHandleSourceEditingMode(){const t=this.editor;const e=t.ui.view.editable;return e&&!e._hasExternalElement}}function WR(t){if(!qR(t)){return t}return IR(t)}function qR(t){return t.startsWith("<")}function UR(t,e,n,o,i=1){if(e>i){o.setAttribute(t,e,n)}else{o.removeAttribute(t,n)}}function $R(t,e,n={}){const o=t.createElement("tableCell",n);t.insertElement("paragraph",o);t.insert(o,e);return o}function KR(t,e){const n=e.parent.parent;const o=parseInt(n.getAttribute("headingColumns")||0);const{column:i}=t.getCellLocation(e);return!!o&&i{t.on("element:figure",((t,e,n)=>{if(!n.consumable.test(e.viewItem,{name:true,classes:"table"})){return}const o=XR(e.viewItem);if(!o||!n.consumable.test(o,{name:true})){return}n.consumable.consume(e.viewItem,{name:true,classes:"table"});const i=n.convertItem(o,e.modelCursor);const r=cg(i.modelRange.getItems());if(!r){n.consumable.revert(e.viewItem,{name:true,classes:"table"});return}n.convertChildren(e.viewItem,n.writer.createPositionAt(r,"end"));n.updateConversionResult(r,e)}))}}function JR(){return t=>{t.on("element:table",((t,e,n)=>{const o=e.viewItem;if(!n.consumable.test(o,{name:true})){return}const{rows:i,headingRows:r,headingColumns:s}=tO(o);const a={};if(s){a.headingColumns=s}if(r){a.headingRows=r}const c=n.writer.createElement("table",a);if(!n.safeInsert(c,e.modelCursor)){return}n.consumable.consume(o,{name:true});i.forEach((t=>n.convertItem(t,n.writer.createPositionAt(c,"end"))));n.convertChildren(o,n.writer.createPositionAt(c,"end"));if(c.isEmpty){const t=n.writer.createElement("tableRow");n.writer.insert(t,n.writer.createPositionAt(c,"end"));$R(n.writer,n.writer.createPositionAt(t,"end"))}n.updateConversionResult(c,e)}))}}function YR(){return t=>{t.on("element:tr",((t,e)=>{if(e.viewItem.isEmpty&&e.modelCursor.index==0){t.stop()}}),{priority:"high"})}}function QR(t){return e=>{e.on(`element:${t}`,((t,e,n)=>{if(!e.modelRange){return}if(e.viewItem.isEmpty){const t=e.modelRange.start.nodeAfter;const o=n.writer.createPositionAt(t,0);n.writer.insertElement("paragraph",o)}}),{priority:"low"})}}function XR(t){for(const e of t.getChildren()){if(e.is("element","table")){return e}}}function tO(t){const e={headingRows:0,headingColumns:0};const n=[];const o=[];let i;for(const r of Array.from(t.getChildren())){if(r.name==="tbody"||r.name==="thead"||r.name==="tfoot"){if(r.name==="thead"&&!i){i=r}const t=Array.from(r.getChildren()).filter((t=>t.is("element","tr")));for(const r of t){if(r.parent.name==="thead"&&r.parent===i){e.headingRows++;n.push(r)}else{o.push(r);const t=eO(r,e,i);if(t>e.headingColumns){e.headingColumns=t}}}}}e.rows=[...n,...o];return e}function eO(t){let e=0;let n=0;const o=Array.from(t.getChildren()).filter((t=>t.name==="th"||t.name==="td"));while(n1||i>1){this._recordSpans(n,i,o)}if(!this._shouldSkipSlot()){e=this._formatOutValue(n)}this._nextCellAtColumn=this._column+o}this._column++;if(this._column==this._nextCellAtColumn){this._cellIndex++}return e||this.next()}skipRow(t){this._skipRows.add(t)}_advanceToNextRow(){this._row++;this._rowIndex++;this._column=0;this._cellIndex=0;this._nextCellAtColumn=-1;return this.next()}_isOverEndRow(){return this._endRow!==undefined&&this._row>this._endRow}_isOverEndColumn(){return this._endColumn!==undefined&&this._column>this._endColumn}_formatOutValue(t,e=this._row,n=this._column){return{done:false,value:new oO(this,t,e,n)}}_shouldSkipSlot(){const t=this._skipRows.has(this._row);const e=this._rowthis._endColumn;return t||e||n||o}_getSpanned(){const t=this._spannedCells.get(this._row);if(!t){return null}return t.get(this._column)||null}_recordSpans(t,e,n){const o={cell:t,row:this._row,column:this._column};for(let t=this._row;t{const i=n.getAttribute("headingRows")||0;const r=[];if(i>0){r.push(o.createContainerElement("thead",null,o.createSlot((t=>t.is("element","tableRow")&&t.indext.is("element","tableRow")&&t.index>=i))))}const s=o.createContainerElement("figure",{class:"table"},[o.createContainerElement("table",null,r),o.createSlot((t=>!t.is("element","tableRow")))]);return e.asWidget?lO(s,o):s}}function rO(){return(t,{writer:e})=>t.isEmpty?e.createEmptyElement("tr"):e.createContainerElement("tr")}function sO(t={}){return(e,{writer:n})=>{const o=e.parent;const i=o.parent;const r=i.getChildIndex(o);const s=new nO(i,{row:r});const a=i.getAttribute("headingRows")||0;const c=i.getAttribute("headingColumns")||0;for(const o of s){if(o.cell==e){const e=o.row{if(!e.parent.is("element","tableCell")){return}if(!cO(e)){return}if(t.asWidget){return n.createContainerElement("span",{class:"ck-table-bogus-paragraph"})}else{o.consume(e,"insert");i.bindElements(e,i.toViewElement(e.parent))}}}function cO(t){const e=t.parent;const n=e.childCount==1;return n&&!dO(t)}function lO(t,e){e.setCustomProperty("table",true,t);return iE(t,e,{hasSelectionHandle:true})}function dO(t){return!![...t.getAttributeKeys()].length}class uO extends ot{refresh(){const t=this.editor.model;const e=t.document.selection;const n=t.schema;this.isEnabled=hO(e,n)}execute(t={}){const e=this.editor.model;const n=this.editor.plugins.get("TableUtils");const o=this.editor.config.get("table");const i=o.defaultHeadings.rows;const r=o.defaultHeadings.columns;if(t.headingRows===undefined&&i){t.headingRows=i}if(t.headingColumns===undefined&&r){t.headingColumns=r}e.change((o=>{const i=n.createTable(o,t);e.insertObject(i,null,null,{findOptimalPosition:"auto"});o.setSelection(o.createPositionAt(i.getNodeByPath([0,0,0]),0))}))}}function hO(t,e){const n=t.getFirstPosition().parent;const o=n===n.root?n:n.parent;return e.checkChild(o,"table")}class fO extends ot{constructor(t,e={}){super(t);this.order=e.order||"below"}refresh(){const t=this.editor.model.document.selection;const e=this.editor.plugins.get("TableUtils");const n=!!e.getSelectionAffectedTableCells(t).length;this.isEnabled=n}execute(){const t=this.editor;const e=t.model.document.selection;const n=t.plugins.get("TableUtils");const o=this.order==="above";const i=n.getSelectionAffectedTableCells(e);const r=n.getRowIndexes(i);const s=o?r.first:r.last;const a=i[0].findAncestor("table");n.insertRows(a,{at:o?s:s+1,copyStructureFromAbove:!o})}}class gO extends ot{constructor(t,e={}){super(t);this.order=e.order||"right"}refresh(){const t=this.editor.model.document.selection;const e=this.editor.plugins.get("TableUtils");const n=!!e.getSelectionAffectedTableCells(t).length;this.isEnabled=n}execute(){const t=this.editor;const e=t.model.document.selection;const n=t.plugins.get("TableUtils");const o=this.order==="left";const i=n.getSelectionAffectedTableCells(e);const r=n.getColumnIndexes(i);const s=o?r.first:r.last;const a=i[0].findAncestor("table");n.insertColumns(a,{columns:1,at:o?s:s+1})}}class pO extends ot{constructor(t,e={}){super(t);this.direction=e.direction||"horizontally"}refresh(){const t=this.editor.plugins.get("TableUtils");const e=t.getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length===1}execute(){const t=this.editor.plugins.get("TableUtils");const e=t.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];const n=this.direction==="horizontally";if(n){t.splitCellHorizontally(e,2)}else{t.splitCellVertically(e,2)}}}function mO(t,e,n){const{startRow:o,startColumn:i,endRow:r,endColumn:s}=e;const a=n.createElement("table");const c=r-o+1;for(let t=0;t1){c.rowspan=l}const d=parseInt(t.getAttribute("colspan")||1);if(d>1){c.colspan=d}const u=r;const h=u+a;const f=[...new nO(i,{startRow:u,endRow:h,includeAllSlots:true})];let g=null;let p;for(const e of f){const{row:o,column:i,cell:r}=e;if(r===t&&p===undefined){p=i}if(p!==undefined&&p===i&&o===h){g=$R(n,e.getPositionBefore(),c)}}UR("rowspan",a,t,n);return g}function wO(t,e){const n=[];const o=new nO(t);for(const t of o){const{column:o,cellWidth:i}=t;const r=o+i-1;if(o1){s.colspan=a}const c=parseInt(t.getAttribute("rowspan")||1);if(c>1){s.rowspan=c}const l=$R(o,o.createPositionAfter(t),s);UR("colspan",r,t,o);return l}function AO(t,e,n,o,i,r){const s=parseInt(t.getAttribute("colspan")||1);const a=parseInt(t.getAttribute("rowspan")||1);const c=n+s-1;if(c>i){const e=i-n+1;UR("colspan",e,t,r,1)}const l=e+a-1;if(l>o){const n=o-e+1;UR("rowspan",n,t,r,1)}}function vO(t,e,n,o,i){const r=parseInt(e.getAttribute("headingRows")||0);if(r>0){const e=r-n;UR("headingRows",e,t,i,0)}const s=parseInt(e.getAttribute("headingColumns")||0);if(s>0){const e=s-o;UR("headingColumns",e,t,i,0)}}function CO(t,e){const n=e.getColumns(t);const o=new Array(n).fill(0);for(const{column:e}of new nO(t)){o[e]++}const i=o.reduce(((t,e,n)=>e?t:[...t,n]),[]);if(i.length>0){const n=i[i.length-1];e.removeColumns(t,{at:n});return true}return false}function yO(t,e){const n=[];const o=e.getRows(t);for(let e=0;e0){const o=n[n.length-1];e.removeRows(t,{at:o});return true}return false}function xO(t,e){const n=CO(t,e);if(!n){yO(t,e)}}function EO(t,e){const n=Array.from(new nO(t,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));const o=n.every((({cellHeight:t})=>t===1));if(o){return e.lastRow}const i=n[0].cellHeight-1;return e.lastRow+i}function SO(t,e){const n=Array.from(new nO(t,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));const o=n.every((({cellWidth:t})=>t===1));if(o){return e.lastColumn}const i=n[0].cellWidth-1;return e.lastColumn+i}class DO extends ot{constructor(t,e){super(t);this.direction=e.direction;this.isHorizontal=this.direction=="right"||this.direction=="left"}refresh(){const t=this._getMergeableCell();this.value=t;this.isEnabled=!!t}execute(){const t=this.editor.model;const e=t.document;const n=this.editor.plugins.get("TableUtils");const o=n.getTableCellsContainingSelection(e.selection)[0];const i=this.value;const r=this.direction;t.change((t=>{const e=r=="right"||r=="down";const n=e?o:i;const s=e?i:o;const a=s.parent;PO(s,n,t);const c=this.isHorizontal?"colspan":"rowspan";const l=parseInt(o.getAttribute(c)||1);const d=parseInt(i.getAttribute(c)||1);t.setAttribute(c,l+d,n);t.setSelection(t.createRangeIn(n));const u=this.editor.plugins.get("TableUtils");const h=a.findAncestor("table");xO(h,u)}))}_getMergeableCell(){const t=this.editor.model;const e=t.document;const n=this.editor.plugins.get("TableUtils");const o=n.getTableCellsContainingSelection(e.selection)[0];if(!o){return}const i=this.isHorizontal?TO(o,this.direction,n):BO(o,this.direction,n);if(!i){return}const r=this.isHorizontal?"rowspan":"colspan";const s=parseInt(o.getAttribute(r)||1);const a=parseInt(i.getAttribute(r)||1);if(a===s){return i}}}function TO(t,e,n){const o=t.parent;const i=o.parent;const r=e=="right"?t.nextSibling:t.previousSibling;const s=(i.getAttribute("headingColumns")||0)>0;if(!r){return}const a=e=="right"?t:r;const c=e=="right"?r:t;const{column:l}=n.getCellLocation(a);const{column:d}=n.getCellLocation(c);const u=parseInt(a.getAttribute("colspan")||1);const h=KR(n,a,i);const f=KR(n,c,i);if(s&&h!=f){return}const g=l+u===d;return g?r:undefined}function BO(t,e,n){const o=t.parent;const i=o.parent;const r=i.getChildIndex(o);if(e=="down"&&r===n.getRows(i)-1||e=="up"&&r===0){return}const s=parseInt(t.getAttribute("rowspan")||1);const a=i.getAttribute("headingRows")||0;const c=e=="down"&&r+s===a;const l=e=="up"&&r===a;if(a&&(c||l)){return}const d=parseInt(t.getAttribute("rowspan")||1);const u=e=="down"?r+d:r;const h=[...new nO(i,{endRow:u})];const f=h.find((e=>e.cell===t));const g=f.column;const p=h.find((({row:t,cellHeight:n,column:o})=>{if(o!==g){return false}if(e=="down"){return t===u}else{return u===t+n}}));return p&&p.cell}function PO(t,e,n){if(!IO(t)){if(IO(e)){n.remove(n.createRangeIn(e))}n.move(n.createRangeIn(t),n.createPositionAt(e,"end"))}n.remove(t)}function IO(t){return t.childCount==1&&t.getChild(0).is("element","paragraph")&&t.getChild(0).isEmpty}class RO extends ot{refresh(){const t=this.editor.plugins.get("TableUtils");const e=t.getSelectionAffectedTableCells(this.editor.model.document.selection);const n=e[0];if(n){const o=n.findAncestor("table");const i=this.editor.plugins.get("TableUtils").getRows(o);const r=i-1;const s=t.getRowIndexes(e);const a=s.first===0&&s.last===r;this.isEnabled=!a}else{this.isEnabled=false}}execute(){const t=this.editor.model;const e=this.editor.plugins.get("TableUtils");const n=e.getSelectionAffectedTableCells(t.document.selection);const o=e.getRowIndexes(n);const i=n[0];const r=i.findAncestor("table");const s=e.getCellLocation(i).column;t.change((t=>{const n=o.last-o.first+1;e.removeRows(r,{at:o.first,rows:n});const i=OO(r,o.first,s,e.getRows(r));t.setSelection(t.createPositionAt(i,0))}))}}function OO(t,e,n,o){const i=t.getChild(Math.min(e,o-1));let r=i.getChild(0);let s=0;for(const t of i.getChildren()){if(s>n){return r}r=t;s+=parseInt(t.getAttribute("colspan")||1)}return r}class zO extends ot{refresh(){const t=this.editor.plugins.get("TableUtils");const e=t.getSelectionAffectedTableCells(this.editor.model.document.selection);const n=e[0];if(n){const o=n.findAncestor("table");const i=t.getColumns(o);const{first:r,last:s}=t.getColumnIndexes(e);this.isEnabled=s-rt.cell===e)).column,last:i.find((t=>t.cell===n)).column};const s=MO(i,e,n,r);this.editor.model.change((t=>{const e=r.last-r.first+1;this.editor.plugins.get("TableUtils").removeColumns(o,{at:r.first,columns:e});t.setSelection(t.createPositionAt(s,0))}))}}function MO(t,e,n,o){const i=parseInt(n.getAttribute("colspan")||1);if(i>1){return n}else if(e.previousSibling||n.nextSibling){return n.nextSibling||e.previousSibling}else{if(o.first){return t.reverse().find((({column:t})=>tt>o.last)).cell}}}function FO(t,e){const n=e.getSelectionAffectedTableCells(t);const o=n[0];const i=n.pop();const r=[o,i];return o.isBefore(i)?r:r.reverse()}class VO extends ot{refresh(){const t=this.editor.plugins.get("TableUtils");const e=this.editor.model;const n=t.getSelectionAffectedTableCells(e.document.selection);const o=n.length>0;this.isEnabled=o;this.value=o&&n.every((t=>this._isInHeading(t,t.parent.parent)))}execute(t={}){if(t.forceValue===this.value){return}const e=this.editor.plugins.get("TableUtils");const n=this.editor.model;const o=e.getSelectionAffectedTableCells(n.document.selection);const i=o[0].findAncestor("table");const{first:r,last:s}=e.getRowIndexes(o);const a=this.value?r:s+1;const c=i.getAttribute("headingRows")||0;n.change((t=>{if(a){const e=a>c?c:0;const n=kO(i,a,e);for(const{cell:e}of n){bO(e,a,t)}}UR("headingRows",a,i,t,0)}))}_isInHeading(t,e){const n=parseInt(e.getAttribute("headingRows")||0);return!!n&&t.parent.index0;this.isEnabled=o;this.value=o&&n.every((t=>KR(e,t)))}execute(t={}){if(t.forceValue===this.value){return}const e=this.editor.plugins.get("TableUtils");const n=this.editor.model;const o=e.getSelectionAffectedTableCells(n.document.selection);const i=o[0].findAncestor("table");const{first:r,last:s}=e.getColumnIndexes(o);const a=this.value?r:s+1;n.change((t=>{if(a){const e=wO(i,a);for(const{cell:n,column:o}of e){_O(n,o,a,t)}}UR("headingColumns",a,i,t,0)}))}}class LO extends et{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns");this.decorate("insertRows")}getCellLocation(t){const e=t.parent;const n=e.parent;const o=n.getChildIndex(e);const i=new nO(n,{row:o});for(const{cell:e,row:n,column:o}of i){if(e===t){return{row:n,column:o}}}}createTable(t,e){const n=t.createElement("table");const o=parseInt(e.rows)||2;const i=parseInt(e.columns)||2;HO(t,n,0,o,i);if(e.headingRows){UR("headingRows",Math.min(e.headingRows,o),n,t,0)}if(e.headingColumns){UR("headingColumns",Math.min(e.headingColumns,i),n,t,0)}return n}insertRows(t,e={}){const n=this.editor.model;const o=e.at||0;const i=e.rows||1;const r=e.copyStructureFromAbove!==undefined;const s=e.copyStructureFromAbove?o-1:o;const a=this.getRows(t);const c=this.getColumns(t);if(o>a){throw new u("tableutils-insertrows-insert-out-of-range",this,{options:e})}n.change((e=>{const n=t.getAttribute("headingRows")||0;if(n>o){UR("headingRows",n+i,t,e,0)}if(!r&&(o===0||o===a)){HO(e,t,o,i,c);return}const l=r?Math.max(o,s):o;const d=new nO(t,{endRow:l});const u=new Array(c).fill(1);for(const{row:t,column:n,cellHeight:a,cellWidth:c,cell:l}of d){const d=t+a-1;const h=t0){$R(e,i,o>1?{colspan:o}:null)}t+=Math.abs(o)-1}}}))}insertColumns(t,e={}){const n=this.editor.model;const o=e.at||0;const i=e.columns||1;n.change((e=>{const n=t.getAttribute("headingColumns");if(oi-1){throw new u("tableutils-removerows-row-index-out-of-range",this,{table:t,options:e})}n.change((e=>{const{cellsToMove:n,cellsToTrim:o}=$O(t,r,s);if(n.size){const o=s+1;KO(t,o,n,e)}for(let n=s;n>=r;n--){e.remove(t.getChild(n))}for(const{rowspan:t,cell:n}of o){UR("rowspan",t,n,e)}UO(t,r,s,e);if(!CO(t,this)){yO(t,this)}}))}removeColumns(t,e){const n=this.editor.model;const o=e.at;const i=e.columns||1;const r=e.at+i-1;n.change((e=>{qO(t,{first:o,last:r},e);for(let n=r;n>=o;n--){for(const{cell:o,column:i,cellWidth:r}of[...new nO(t)]){if(i<=n&&r>1&&i+r>n){UR("colspan",r-1,o,e)}else if(i===n){e.remove(o)}}}if(!yO(t,this)){CO(t,this)}}))}splitCellVertically(t,e=2){const n=this.editor.model;const o=t.parent;const i=o.parent;const r=parseInt(t.getAttribute("rowspan")||1);const s=parseInt(t.getAttribute("colspan")||1);n.change((n=>{if(s>1){const{newCellsSpan:o,updatedSpan:i}=WO(s,e);UR("colspan",i,t,n);const a={};if(o>1){a.colspan=o}if(r>1){a.rowspan=r}const c=s>e?e-1:s-1;jO(c,n,n.createPositionAfter(t),a)}if(se===t));const l=a.filter((({cell:e,cellWidth:n,column:o})=>{const i=e!==t&&o===c;const r=oc;return i||r}));for(const{cell:t,cellWidth:e}of l){n.setAttribute("colspan",e+o,t)}const d={};if(r>1){d.rowspan=r}jO(o,n,n.createPositionAfter(t),d);const u=i.getAttribute("headingColumns")||0;if(u>c){UR("headingColumns",u+o,i,n)}}}))}splitCellHorizontally(t,e=2){const n=this.editor.model;const o=t.parent;const i=o.parent;const r=i.getChildIndex(o);const s=parseInt(t.getAttribute("rowspan")||1);const a=parseInt(t.getAttribute("colspan")||1);n.change((n=>{if(s>1){const o=[...new nO(i,{startRow:r,endRow:r+s-1,includeAllSlots:true})];const{newCellsSpan:c,updatedSpan:l}=WO(s,e);UR("rowspan",l,t,n);const{column:d}=o.find((({cell:e})=>e===t));const u={};if(c>1){u.rowspan=c}if(a>1){u.colspan=a}for(const t of o){const{column:e,row:o}=t;const i=o>=r+l;const s=e===d;const a=(o+r+l)%c===0;if(i&&s&&a){jO(1,n,t.getPositionBefore(),u)}}}if(sr){const t=i+o;n.setAttribute("rowspan",t,e)}}const l={};if(a>1){l.colspan=a}HO(n,i,r+1,o,1,l);const d=i.getAttribute("headingRows")||0;if(d>r){UR("headingRows",d+o,i,n)}}}))}getColumns(t){const e=t.getChild(0);return[...e.getChildren()].reduce(((t,e)=>{const n=parseInt(e.getAttribute("colspan")||1);return t+n}),0)}getRows(t){return Array.from(t.getChildren()).reduce(((t,e)=>e.is("element","tableRow")?t+1:t),0)}createTableWalker(t,e={}){return new nO(t,e)}getSelectedTableCells(t){const e=[];for(const n of this.sortRanges(t.getRanges())){const t=n.getContainedElement();if(t&&t.is("element","tableCell")){e.push(t)}}return e}getTableCellsContainingSelection(t){const e=[];for(const n of t.getRanges()){const t=n.start.findAncestor("tableCell");if(t){e.push(t)}}return e}getSelectionAffectedTableCells(t){const e=this.getSelectedTableCells(t);if(e.length){return e}return this.getTableCellsContainingSelection(t)}getRowIndexes(t){const e=t.map((t=>t.parent.index));return this._getFirstLastIndexesObject(e)}getColumnIndexes(t){const e=t[0].findAncestor("table");const n=[...new nO(e)];const o=n.filter((e=>t.includes(e.cell))).map((t=>t.column));return this._getFirstLastIndexesObject(o)}isSelectionRectangular(t){if(t.length<2||!this._areCellInTheSameTableSection(t)){return false}const e=new Set;const n=new Set;let o=0;for(const i of t){const{row:t,column:r}=this.getCellLocation(i);const s=parseInt(i.getAttribute("rowspan")||1);const a=parseInt(i.getAttribute("colspan")||1);e.add(t);n.add(r);if(s>1){e.add(t+s-1)}if(a>1){n.add(r+a-1)}o+=s*a}const i=ZO(e,n);return i==o}sortRanges(t){return Array.from(t).sort(GO)}_getFirstLastIndexesObject(t){const e=t.sort(((t,e)=>t-e));const n=e[0];const o=e[e.length-1];return{first:n,last:o}}_areCellInTheSameTableSection(t){const e=t[0].findAncestor("table");const n=this.getRowIndexes(t);const o=parseInt(e.getAttribute("headingRows")||0);if(!this._areIndexesInSameSection(n,o)){return false}const i=parseInt(e.getAttribute("headingColumns")||0);const r=this.getColumnIndexes(t);return this._areIndexesInSameSection(r,i)}_areIndexesInSameSection({first:t,last:e},n){const o=t=e&&r<=n&&t>n;if(l){const t=n-r+1;const e=a-t;o.set(s,{cell:c,rowspan:e})}const d=r=e;if(d){let o;if(t>=n){o=n-e+1}else{o=t-e+1}i.push({cell:c,rowspan:a-o})}}return{cellsToMove:o,cellsToTrim:i}}function KO(t,e,n,o){const i=new nO(t,{includeAllSlots:true,row:e});const r=[...i];const s=t.getChild(e);let a;for(const{column:t,cell:e,isAnchor:i}of r){if(n.has(t)){const{cell:e,rowspan:i}=n.get(t);const r=a?o.createPositionAfter(a):o.createPositionAt(s,0);o.move(o.createRangeOn(e),r);UR("rowspan",i,e,o);a=e}else if(i){a=e}}}function GO(t,e){const n=t.start;const o=e.start;return n.isBefore(o)?-1:1}function ZO(t,e){const n=Array.from(t.values());const o=Array.from(e.values());const i=Math.max(...n);const r=Math.min(...n);const s=Math.max(...o);const a=Math.min(...o);return(i-r+1)*(s-a+1)}class JO extends ot{refresh(){const t=this.editor.plugins.get(LO);const e=t.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=t.isSelectionRectangular(e,this.editor.plugins.get(LO))}execute(){const t=this.editor.model;const e=this.editor.plugins.get(LO);t.change((n=>{const o=e.getSelectedTableCells(t.document.selection);const i=o.shift();const{mergeWidth:r,mergeHeight:s}=XO(i,o,e);UR("colspan",r,i,n);UR("rowspan",s,i,n);for(const t of o){YO(t,i,n)}const a=i.findAncestor("table");xO(a,e);n.setSelection(i,"in")}))}}function YO(t,e,n){if(!QO(t)){if(QO(e)){n.remove(n.createRangeIn(e))}n.move(n.createRangeIn(t),n.createPositionAt(e,"end"))}n.remove(t)}function QO(t){return t.childCount==1&&t.getChild(0).is("element","paragraph")&&t.getChild(0).isEmpty}function XO(t,e,n){let o=0;let i=0;for(const t of e){const{row:e,column:r}=n.getCellLocation(t);o=tz(t,r,o,"colspan");i=tz(t,e,i,"rowspan")}const{row:r,column:s}=n.getCellLocation(t);const a=o-s;const c=i-r;return{mergeWidth:a,mergeHeight:c}}function tz(t,e,n,o){const i=parseInt(t.getAttribute(o)||1);return Math.max(n,e+i)}class ez extends ot{constructor(t){super(t);this.affectsData=false}refresh(){const t=this.editor.plugins.get("TableUtils");const e=t.getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const t=this.editor.model;const e=this.editor.plugins.get("TableUtils");const n=e.getSelectionAffectedTableCells(t.document.selection);const o=e.getRowIndexes(n);const i=n[0].findAncestor("table");const r=[];for(let e=o.first;e<=o.last;e++){for(const n of i.getChild(e).getChildren()){r.push(t.createRangeOn(n))}}t.change((t=>{t.setSelection(r)}))}}class nz extends ot{constructor(t){super(t);this.affectsData=false}refresh(){const t=this.editor.plugins.get("TableUtils");const e=t.getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const t=this.editor.plugins.get("TableUtils");const e=this.editor.model;const n=t.getSelectionAffectedTableCells(e.document.selection);const o=n[0];const i=n.pop();const r=o.findAncestor("table");const s=t.getCellLocation(o);const a=t.getCellLocation(i);const c=Math.min(s.column,a.column);const l=Math.max(s.column,a.column);const d=[];for(const t of new nO(r,{startColumn:c,endColumn:l})){d.push(e.createRangeOn(t.cell))}e.change((t=>{t.setSelection(d)}))}}function oz(t){t.document.registerPostFixer((e=>iz(e,t)))}function iz(t,e){const n=e.document.differ.getChanges();let o=false;const i=new Set;for(const e of n){let n;if(e.name=="table"&&e.type=="insert"){n=e.position.nodeAfter}if(e.name=="tableRow"||e.name=="tableCell"){n=e.position.findAncestor("table")}if(lz(e)){n=e.range.start.findAncestor("table")}if(n&&!i.has(n)){o=rz(n,t)||o;o=sz(n,t)||o;i.add(n)}}return o}function rz(t,e){let n=false;const o=az(t);if(o.length){n=true;for(const t of o){UR("rowspan",t.rowspan,t.cell,e,1)}}return n}function sz(t,e){let n=false;const o=cz(t);const i=[];for(const[e,n]of o.entries()){if(!n&&t.getChild(e).is("element","tableRow")){i.push(e)}}if(i.length){n=true;for(const n of i.reverse()){e.remove(t.getChild(n));o.splice(n,1)}}const r=o.filter(((e,n)=>t.getChild(n).is("element","tableRow")));const s=r[0];const a=r.every((t=>t===s));if(!a){const o=r.reduce(((t,e)=>e>t?e:t),0);for(const[i,s]of r.entries()){const r=o-s;if(r){for(let n=0;ne.is("element","tableRow")?t+1:t),0);const o=[];for(const{row:i,cell:r,cellHeight:s}of new nO(t)){if(s<2){continue}const t=ia){const t=a-i;o.push({cell:r,rowspan:t})}}return o}function cz(t){const e=new Array(t.childCount).fill(0);for(const{rowIndex:n}of new nO(t,{includeAllSlots:true})){e[n]++}return e}function lz(t){const e=t.type==="attribute";const n=t.attributeKey;return e&&(n==="headingRows"||n==="colspan"||n==="rowspan")}function dz(t){t.document.registerPostFixer((e=>uz(e,t)))}function uz(t,e){const n=e.document.differ.getChanges();let o=false;for(const e of n){if(e.type=="insert"&&e.name=="table"){o=hz(e.position.nodeAfter,t)||o}if(e.type=="insert"&&e.name=="tableRow"){o=fz(e.position.nodeAfter,t)||o}if(e.type=="insert"&&e.name=="tableCell"){o=gz(e.position.nodeAfter,t)||o}if(pz(e)){o=gz(e.position.parent,t)||o}}return o}function hz(t,e){let n=false;for(const o of t.getChildren()){if(o.is("element","tableRow")){n=fz(o,e)||n}}return n}function fz(t,e){let n=false;for(const o of t.getChildren()){n=gz(o,e)||n}return n}function gz(t,e){if(t.childCount==0){e.insertElement("paragraph",t);return true}const n=Array.from(t.getChildren()).filter((t=>t.is("$text")));for(const t of n){e.wrap(e.createRangeOn(t),"paragraph")}return!!n.length}function pz(t){if(!t.position||!t.position.parent.is("element","tableCell")){return false}return t.type=="insert"&&t.name=="$text"||t.type=="remove"}function mz(t,e){const n=t.document.differ;for(const t of n.getChanges()){let n;let o=false;if(t.type=="attribute"){const e=t.range.start.nodeAfter;if(!e||!e.is("element","table")){continue}if(t.attributeKey!="headingRows"&&t.attributeKey!="headingColumns"){continue}n=e;o=t.attributeKey=="headingRows"}else if(t.name=="tableRow"||t.name=="tableCell"){n=t.position.findAncestor("table");o=t.name=="tableRow"}if(!n){continue}const i=n.getAttribute("headingRows")||0;const r=n.getAttribute("headingColumns")||0;const s=new nO(n);for(const t of s){const n=t.rowbz(t,e.mapper)));for(const t of n){e.reconvertItem(t)}}}function bz(t,e){if(!t.is("element","paragraph")){return false}const n=e.toViewElement(t);if(!n){return false}return cO(t)!==n.is("element","span")}var wz=n(777);var _z={injectType:"singletonStyleTag",attributes:{"data-cke":true}};_z.insert="head";_z.singleton=true;var Az=Vu()(wz.Z,_z);const vz=wz.Z.locals||{};class Cz extends et{static get pluginName(){return"TableEditing"}static get requires(){return[LO]}init(){const t=this.editor;const e=t.model;const n=e.schema;const o=t.conversion;const i=t.plugins.get(LO);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]});n.register("tableRow",{allowIn:"table",isLimit:true});n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:true,isSelectable:true});o.for("upcast").add(ZR());o.for("upcast").add(JR());o.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:iO(i,{asWidget:true})});o.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:iO(i)});o.for("upcast").elementToElement({model:"tableRow",view:"tr"});o.for("upcast").add(YR());o.for("downcast").elementToElement({model:"tableRow",view:rO()});o.for("upcast").elementToElement({model:"tableCell",view:"td"});o.for("upcast").elementToElement({model:"tableCell",view:"th"});o.for("upcast").add(QR("td"));o.for("upcast").add(QR("th"));o.for("editingDowncast").elementToElement({model:"tableCell",view:sO({asWidget:true})});o.for("dataDowncast").elementToElement({model:"tableCell",view:sO()});o.for("editingDowncast").elementToElement({model:"paragraph",view:aO({asWidget:true}),converterPriority:"high"});o.for("dataDowncast").elementToElement({model:"paragraph",view:aO(),converterPriority:"high"});o.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"});o.for("upcast").attributeToAttribute({model:{key:"colspan",value:xz("colspan")},view:"colspan"});o.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"});o.for("upcast").attributeToAttribute({model:{key:"rowspan",value:xz("rowspan")},view:"rowspan"});t.data.mapper.on("modelToViewPosition",yz());t.config.define("table.defaultHeadings.rows",0);t.config.define("table.defaultHeadings.columns",0);t.commands.add("insertTable",new uO(t));t.commands.add("insertTableRowAbove",new fO(t,{order:"above"}));t.commands.add("insertTableRowBelow",new fO(t,{order:"below"}));t.commands.add("insertTableColumnLeft",new gO(t,{order:"left"}));t.commands.add("insertTableColumnRight",new gO(t,{order:"right"}));t.commands.add("removeTableRow",new RO(t));t.commands.add("removeTableColumn",new zO(t));t.commands.add("splitTableCellVertically",new pO(t,{direction:"vertically"}));t.commands.add("splitTableCellHorizontally",new pO(t,{direction:"horizontally"}));t.commands.add("mergeTableCells",new JO(t));t.commands.add("mergeTableCellRight",new DO(t,{direction:"right"}));t.commands.add("mergeTableCellLeft",new DO(t,{direction:"left"}));t.commands.add("mergeTableCellDown",new DO(t,{direction:"down"}));t.commands.add("mergeTableCellUp",new DO(t,{direction:"up"}));t.commands.add("setTableColumnHeader",new NO(t));t.commands.add("setTableRowHeader",new VO(t));t.commands.add("selectTableRow",new ez(t));t.commands.add("selectTableColumn",new nz(t));oz(e);dz(e);this.listenTo(e.document,"change:data",(()=>{mz(e,t.editing);kz(e,t.editing)}))}}function yz(){return(t,e)=>{const n=e.modelPosition.parent;const o=e.modelPosition.nodeBefore;if(!n.is("element","tableCell")){return}if(!o||!o.is("element","paragraph")){return}const i=e.mapper.toViewElement(o);const r=e.mapper.toViewElement(n);if(i===r){e.viewPosition=e.mapper.findPositionIn(r,o.maxOffset)}}}function xz(t){return e=>{const n=parseInt(e.getAttribute(t));if(Number.isNaN(n)||n<=0){return null}return n}}var Ez=n(85);var Sz={injectType:"singletonStyleTag",attributes:{"data-cke":true}};Sz.insert="head";Sz.singleton=true;var Dz=Vu()(Ez.Z,Sz);const Tz=Ez.Z.locals||{};class Bz extends aA{constructor(t){super(t);const e=this.bindTemplate;this.items=this._createGridCollection();this.keystrokes=new dg;this.focusTracker=new lg;this.set("rows",0);this.set("columns",0);this.bind("label").to(this,"columns",this,"rows",((t,e)=>`${e} × ${t}`));this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":e.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":true},children:[{text:e.to("label")}]}],on:{mousedown:e.to((t=>{t.preventDefault()})),click:e.to((()=>{this.fire("execute")}))}});this.on("boxover",((t,e)=>{const{row:n,column:o}=e.target.dataset;this.items.get((parseInt(n,10)-1)*10+(parseInt(o,10)-1)).focus()}));this.focusTracker.on("change:focusedElement",((t,e,n)=>{if(!n){return}const{row:o,column:i}=n.dataset;this.set({rows:parseInt(o),columns:parseInt(i)})}));this.on("change:columns",(()=>this._highlightGridBoxes()));this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render();Ev({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10});for(const t of this.items){this.focusTracker.add(t.element)}this.keystrokes.listenTo(this.element)}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const t=this.rows;const e=this.columns;this.items.map(((n,o)=>{const i=Math.floor(o/10);const r=o%10;const s=i{const o=t.commands.get("insertTable");const i=NC(n);i.bind("isEnabled").to(o);i.buttonView.set({icon:Pz,label:e("Insert table"),tooltip:true});let r;i.on("change:isOpen",(()=>{if(r){return}r=new Bz(n);i.panelView.children.add(r);r.delegate("execute").to(i);i.on("execute",(()=>{t.execute("insertTable",{rows:r.rows,columns:r.columns});t.editing.view.focus()}))}));return i}));t.ui.componentFactory.add("tableColumn",(t=>{const n=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:e("Header column"),bindIsOn:true}},{type:"separator"},{type:"button",model:{commandName:o?"insertTableColumnLeft":"insertTableColumnRight",label:e("Insert column left")}},{type:"button",model:{commandName:o?"insertTableColumnRight":"insertTableColumnLeft",label:e("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:e("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:e("Select column")}}];return this._prepareDropdown(e("Column"),Iz,n,t)}));t.ui.componentFactory.add("tableRow",(t=>{const n=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:e("Header row"),bindIsOn:true}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:e("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:e("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:e("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:e("Select row")}}];return this._prepareDropdown(e("Row"),Rz,n,t)}));t.ui.componentFactory.add("mergeTableCells",(t=>{const n=[{type:"button",model:{commandName:"mergeTableCellUp",label:e("Merge cell up")}},{type:"button",model:{commandName:o?"mergeTableCellRight":"mergeTableCellLeft",label:e("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:e("Merge cell down")}},{type:"button",model:{commandName:o?"mergeTableCellLeft":"mergeTableCellRight",label:e("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:e("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:e("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(e("Merge cells"),Oz,n,t)}))}_prepareDropdown(t,e,n,o){const i=this.editor;const r=NC(o);const s=this._fillDropdownWithListOptions(r,n);r.buttonView.set({label:t,icon:e,tooltip:true});r.bind("isEnabled").toMany(s,"isEnabled",((...t)=>t.some((t=>t))));this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName);if(!(t.source instanceof jv)){i.editing.view.focus()}}));return r}_prepareMergeSplitButtonDropdown(t,e,n,o){const i=this.editor;const r=NC(o,eC);const s="mergeTableCells";const a=i.commands.get(s);const c=this._fillDropdownWithListOptions(r,n);r.buttonView.set({label:t,icon:e,tooltip:true,isEnabled:true});r.bind("isEnabled").toMany([a,...c],"isEnabled",((...t)=>t.some((t=>t))));this.listenTo(r.buttonView,"execute",(()=>{i.execute(s);i.editing.view.focus()}));this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName);i.editing.view.focus()}));return r}_fillDropdownWithListOptions(t,e){const n=this.editor;const o=[];const i=new Ca;for(const t of e){Mz(t,n,o,i)}HC(t,i,n.ui.componentFactory);return o}}function Mz(t,e,n,o){const i=t.model=new Iy(t.model);const{commandName:r,bindIsOn:s}=t.model;if(t.type==="button"||t.type==="switchbutton"){const t=e.commands.get(r);n.push(t);i.set({commandName:r});i.bind("isEnabled").to(t);if(s){i.bind("isOn").to(t,"value")}}i.set({withText:true});o.add(t)}var Fz=n(593);var Vz={injectType:"singletonStyleTag",attributes:{"data-cke":true}};Vz.insert="head";Vz.singleton=true;var Nz=Vu()(Fz.Z,Vz);const Lz=Fz.Z.locals||{};class Hz extends et{static get pluginName(){return"TableSelection"}static get requires(){return[LO,LO]}init(){const t=this.editor;const e=t.model;const n=t.editing.view;this.listenTo(e,"deleteContent",((t,e)=>this._handleDeleteContent(t,e)),{priority:"high"});this.listenTo(n.document,"insertText",((t,e)=>this._handleInsertTextEvent(t,e)),{priority:"high"});this._defineSelectionConverter();this._enablePluginDisabling()}getSelectedTableCells(){const t=this.editor.plugins.get(LO);const e=this.editor.model.document.selection;const n=t.getSelectedTableCells(e);if(n.length==0){return null}return n}getSelectionAsFragment(){const t=this.editor.plugins.get(LO);const e=this.getSelectedTableCells();if(!e){return null}return this.editor.model.change((n=>{const o=n.createDocumentFragment();const{first:i,last:r}=t.getColumnIndexes(e);const{first:s,last:a}=t.getRowIndexes(e);const c=e[0].findAncestor("table");let l=a;let d=r;if(t.isSelectionRectangular(e)){const t={firstColumn:i,lastColumn:r,firstRow:s,lastRow:a};l=EO(c,t);d=SO(c,t)}const u={startRow:s,startColumn:i,endRow:l,endColumn:d};const h=mO(c,u,n);n.insert(h,o,0);return o}))}setCellSelection(t,e){const n=this._getCellsToSelect(t,e);this.editor.model.change((t=>{t.setSelection(n.cells.map((e=>t.createRangeOn(e))),{backward:n.backward})}))}getFocusCell(){const t=this.editor.model.document.selection;const e=[...t.getRanges()].pop();const n=e.getContainedElement();if(n&&n.is("element","tableCell")){return n}return null}getAnchorCell(){const t=this.editor.model.document.selection;const e=cg(t.getRanges());const n=e.getContainedElement();if(n&&n.is("element","tableCell")){return n}return null}_defineSelectionConverter(){const t=this.editor;const e=new Set;t.conversion.for("editingDowncast").add((t=>t.on("selection",((t,o,i)=>{const r=i.writer;n(r);const s=this.getSelectedTableCells();if(!s){return}for(const t of s){const n=i.mapper.toViewElement(t);r.addClass("ck-editor__editable_selected",n);e.add(n)}const a=i.mapper.toViewElement(s[s.length-1]);r.setSelection(a,0)}),{priority:"lowest"})));function n(t){for(const n of e){t.removeClass("ck-editor__editable_selected",n)}e.clear()}}_enablePluginDisabling(){const t=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const e=this.getSelectedTableCells();if(!e){return}t.model.change((n=>{const o=n.createPositionAt(e[0],0);const i=t.model.schema.getNearestSelectionRange(o);n.setSelection(i)}))}}))}_handleDeleteContent(t,e){const n=this.editor.plugins.get(LO);const[o,i]=e;const r=this.editor.model;const s=!i||i.direction=="backward";const a=n.getSelectedTableCells(o);if(!a.length){return}t.stop();r.change((t=>{const e=a[s?a.length-1:0];r.change((t=>{for(const e of a){r.deleteContent(t.createSelection(e,"in"))}}));const n=r.schema.getNearestSelectionRange(t.createPositionAt(e,0));if(o.is("documentSelection")){t.setSelection(n)}else{o.setTo(n)}}))}_handleInsertTextEvent(t,e){const n=this.editor;const o=n.model;const i=o.document.selection;const r=this.getSelectedTableCells(i);if(!r){return}const s=n.editing.view;const a=n.editing.mapper;const c=r.map((t=>s.createRangeOn(a.toViewElement(t))));e.selection=s.createSelection(c)}_getCellsToSelect(t,e){const n=this.editor.plugins.get("TableUtils");const o=n.getCellLocation(t);const i=n.getCellLocation(e);const r=Math.min(o.row,i.row);const s=Math.max(o.row,i.row);const a=Math.min(o.column,i.column);const c=Math.max(o.column,i.column);const l=new Array(s-r+1).fill(null).map((()=>[]));const d={startRow:r,endRow:s,startColumn:a,endColumn:c};for(const{row:e,cell:n}of new nO(t.findAncestor("table"),d)){l[e-r].push(n)}const u=i.rowt.reverse()))}return{cells:l.flat(),backward:u||h}}}class jz extends et{static get pluginName(){return"TableClipboard"}static get requires(){return[Hz,LO]}init(){const t=this.editor;const e=t.editing.view.document;this.listenTo(e,"copy",((t,e)=>this._onCopyCut(t,e)));this.listenTo(e,"cut",((t,e)=>this._onCopyCut(t,e)));this.listenTo(t.model,"insertContent",((t,e)=>this._onInsertContent(t,...e)),{priority:"high"});this.decorate("_replaceTableSlotCell")}_onCopyCut(t,e){const n=this.editor.plugins.get(Hz);if(!n.getSelectedTableCells()){return}if(t.name=="cut"&&this.editor.isReadOnly){return}e.preventDefault();t.stop();const o=this.editor.data;const i=this.editor.editing.view.document;const r=o.toView(n.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:e.dataTransfer,content:r,method:t.name})}_onInsertContent(t,e,n){if(n&&!n.is("documentSelection")){return}const o=this.editor.model;const i=this.editor.plugins.get(LO);let r=Wz(e,o);if(!r){return}const s=i.getSelectionAffectedTableCells(o.document.selection);if(!s.length){xO(r,i);return}t.stop();o.change((t=>{const e={width:i.getColumns(r),height:i.getRows(r)};const n=qz(s,e,t,i);const o=n.lastRow-n.firstRow+1;const a=n.lastColumn-n.firstColumn+1;const c={startRow:0,startColumn:0,endRow:Math.min(o,e.height)-1,endColumn:Math.min(a,e.width)-1};r=mO(r,c,t);const l=s[0].findAncestor("table");const d=this._replaceSelectedCellsWithPasted(r,e,l,n,t);if(this.editor.plugins.get("TableSelection").isEnabled){const e=i.sortRanges(d.map((e=>t.createRangeOn(e))));t.setSelection(e)}else{t.setSelection(d[0],0)}}))}_replaceSelectedCellsWithPasted(t,e,n,o,i){const{width:r,height:s}=e;const a=$z(t,r,s);const c=[...new nO(n,{startRow:o.firstRow,endRow:o.lastRow,startColumn:o.firstColumn,endColumn:o.lastColumn,includeAllSlots:true})];const l=[];let d;for(const t of c){const{row:e,column:n}=t;if(n===o.firstColumn){d=t.getPositionBefore()}const c=e-o.firstRow;const u=n-o.firstColumn;const h=a[c%s][u%r];const f=h?i.cloneElement(h):null;const g=this._replaceTableSlotCell(t,f,d,i);if(!g){continue}AO(g,e,n,o.lastRow,o.lastColumn,i);l.push(g);d=i.createPositionAfter(g)}const u=parseInt(n.getAttribute("headingRows")||0);const h=parseInt(n.getAttribute("headingColumns")||0);const f=o.firstRowi){o.insertColumns(t,{at:i,columns:n-i})}if(e>r){o.insertRows(t,{at:r,rows:e-r})}}function $z(t,e,n){const o=new Array(n).fill(null).map((()=>new Array(e).fill(null)));for(const{column:e,row:n,cell:i}of new nO(t)){o[n][e]=i}return o}function Kz(t,e,n){const{firstRow:o,lastRow:i,firstColumn:r,lastColumn:s}=e;const a={first:o,last:i};const c={first:r,last:s};Zz(t,r,a,n);Zz(t,s+1,a,n);Gz(t,o,c,n);Gz(t,i+1,c,n,o)}function Gz(t,e,n,o,i=0){if(e<1){return}const r=kO(t,e,i);const s=r.filter((({column:t,cellWidth:e})=>Jz(t,e,n)));return s.map((({cell:t})=>bO(t,e,o)))}function Zz(t,e,n,o){if(e<1){return}const i=wO(t,e);const r=i.filter((({row:t,cellHeight:e})=>Jz(t,e,n)));return r.map((({cell:t,column:n})=>_O(t,n,e,o)))}function Jz(t,e,n){const o=t+e-1;const{first:i,last:r}=n;const s=t>=i&&t<=r;const a=t=i;return s||a}class Yz extends et{static get pluginName(){return"TableKeyboard"}static get requires(){return[Hz,LO]}init(){const t=this.editor.editing.view;const e=t.document;this.listenTo(e,"arrowKey",((...t)=>this._onArrowKey(...t)),{context:"table"});this.listenTo(e,"tab",((...t)=>this._handleTabOnSelectedTable(...t)),{context:"figure"});this.listenTo(e,"tab",((...t)=>this._handleTab(...t)),{context:["th","td"]})}_handleTabOnSelectedTable(t,e){const n=this.editor;const o=n.model.document.selection;const i=o.getSelectedElement();if(!i||!i.is("element","table")){return}e.preventDefault();e.stopPropagation();t.stop();n.model.change((t=>{t.setSelection(t.createRangeIn(i.getChild(0).getChild(0)))}))}_handleTab(t,e){const n=this.editor;const o=this.editor.plugins.get(LO);const i=n.model.document.selection;const r=!e.shiftKey;let s=o.getTableCellsContainingSelection(i)[0];if(!s){s=this.editor.plugins.get("TableSelection").getFocusCell()}if(!s){return}e.preventDefault();e.stopPropagation();t.stop();const a=s.parent;const c=a.parent;const l=c.getChildIndex(a);const d=a.getChildIndex(s);const u=d===0;if(!r&&u&&l===0){n.model.change((t=>{t.setSelection(t.createRangeOn(c))}));return}const h=d===a.childCount-1;const f=l===o.getRows(c)-1;if(r&&f&&h){n.execute("insertTableRowBelow");if(l===o.getRows(c)-1){n.model.change((t=>{t.setSelection(t.createRangeOn(c))}));return}}let g;if(r&&h){const t=c.getChild(l+1);g=t.getChild(0)}else if(!r&&u){const t=c.getChild(l-1);g=t.getChild(t.childCount-1)}else{g=a.getChild(d+(r?1:-1))}n.model.change((t=>{t.setSelection(t.createRangeIn(g))}))}_onArrowKey(t,e){const n=this.editor;const o=e.keyCode;const i=qd(o,n.locale.contentLanguageDirection);const r=this._handleArrowKeys(i,e.shiftKey);if(r){e.preventDefault();e.stopPropagation();t.stop()}}_handleArrowKeys(t,e){const n=this.editor.plugins.get(LO);const o=this.editor.model;const i=o.document.selection;const r=["right","down"].includes(t);const s=n.getSelectedTableCells(i);if(s.length){let n;if(e){n=this.editor.plugins.get("TableSelection").getFocusCell()}else{n=r?s[s.length-1]:s[0]}this._navigateFromCellInDirection(n,t,e);return true}const a=i.focus.findAncestor("tableCell");if(!a){return false}if(!i.isCollapsed){if(e){if(i.isBackward==r&&!i.containsEntireContent(a)){return false}}else{const t=i.getSelectedElement();if(!t||!o.schema.isObject(t)){return false}}}if(this._isSelectionAtCellEdge(i,a,r)){this._navigateFromCellInDirection(a,t,e);return true}return false}_isSelectionAtCellEdge(t,e,n){const o=this.editor.model;const i=this.editor.model.schema;const r=n?t.getLastPosition():t.getFirstPosition();if(!i.getLimitElement(r).is("element","tableCell")){const t=o.createPositionAt(e,n?"end":0);return t.isTouching(r)}const s=o.createSelection(r);o.modifySelection(s,{direction:n?"forward":"backward"});return r.isEqual(s.focus)}_navigateFromCellInDirection(t,e,n=false){const o=this.editor.model;const i=t.findAncestor("table");const r=[...new nO(i,{includeAllSlots:true})];const{row:s,column:a}=r[r.length-1];const c=r.find((({cell:e})=>e==t));let{row:l,column:d}=c;switch(e){case"left":d--;break;case"up":l--;break;case"right":d+=c.cellWidth;break;case"down":l+=c.cellHeight;break}const u=l<0||l>s;const h=d<0&&l<=0;const f=d>a&&l>=s;if(u||h||f){o.change((t=>{t.setSelection(t.createRangeOn(i))}));return}if(d<0){d=n?0:a;l--}else if(d>a){d=n?a:0;l++}const g=r.find((t=>t.row==l&&t.column==d)).cell;const p=["right","down"].includes(e);const m=this.editor.plugins.get("TableSelection");if(n&&m.isEnabled){const e=m.getAnchorCell()||t;m.setCellSelection(e,g)}else{const t=o.createPositionAt(g,p?0:"end");o.change((e=>{e.setSelection(t)}))}}}class Qz extends vh{constructor(t){super(t);this.domEventType=["mousemove","mouseleave"]}onDomEvent(t){this.fire(t.type,t)}}class Xz extends et{static get pluginName(){return"TableMouse"}static get requires(){return[Hz,LO]}init(){const t=this.editor;t.editing.view.addObserver(Qz);this._enableShiftClickSelection();this._enableMouseDragSelection()}_enableShiftClickSelection(){const t=this.editor;const e=t.plugins.get(LO);let n=false;const o=t.plugins.get(Hz);this.listenTo(t.editing.view.document,"mousedown",((i,r)=>{const s=t.model.document.selection;if(!this.isEnabled||!o.isEnabled){return}if(!r.domEvent.shiftKey){return}const a=o.getAnchorCell()||e.getTableCellsContainingSelection(s)[0];if(!a){return}const c=this._getModelTableCellFromDomEvent(r);if(c&&tM(a,c)){n=true;o.setCellSelection(a,c);r.preventDefault()}}));this.listenTo(t.editing.view.document,"mouseup",(()=>{n=false}));this.listenTo(t.editing.view.document,"selectionChange",(t=>{if(n){t.stop()}}),{priority:"highest"})}_enableMouseDragSelection(){const t=this.editor;let e,n;let o=false;let i=false;const r=t.plugins.get(Hz);this.listenTo(t.editing.view.document,"mousedown",((t,n)=>{if(!this.isEnabled||!r.isEnabled){return}if(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey){return}e=this._getModelTableCellFromDomEvent(n)}));this.listenTo(t.editing.view.document,"mousemove",((t,s)=>{if(!s.domEvent.buttons){return}if(!e){return}const a=this._getModelTableCellFromDomEvent(s);if(a&&tM(e,a)){n=a;if(!o&&n!=e){o=true}}if(!o){return}i=true;r.setCellSelection(e,n);s.preventDefault()}));this.listenTo(t.editing.view.document,"mouseup",(()=>{o=false;i=false;e=null;n=null}));this.listenTo(t.editing.view.document,"selectionChange",(t=>{if(i){t.stop()}}),{priority:"highest"})}_getModelTableCellFromDomEvent(t){const e=t.target;const n=this.editor.editing.view.createPositionAt(e,0);const o=this.editor.editing.mapper.toModelPosition(n);const i=o.parent;return i.findAncestor("tableCell",{includeSelf:true})}}function tM(t,e){return t.parent.parent==e.parent.parent}var eM=n(104);var nM={injectType:"singletonStyleTag",attributes:{"data-cke":true}};nM.insert="head";nM.singleton=true;var oM=Vu()(eM.Z,nM);const iM=eM.Z.locals||{};class rM extends et{static get requires(){return[Cz,zz,Hz,Xz,Yz,jz,qE]}static get pluginName(){return"Table"}}function sM(t){const e=t.getSelectedElement();if(e&&cM(e)){return e}return null}function aM(t){const e=t.getFirstPosition();if(!e){return null}let n=e.parent;while(n){if(n.is("element")&&cM(n)){return n}n=n.parent}return null}function cM(t){return!!t.getCustomProperty("table")&&oE(t)}class lM extends et{static get requires(){return[ED]}static get pluginName(){return"TableToolbar"}afterInit(){const t=this.editor;const e=t.t;const n=t.plugins.get(ED);const o=t.config.get("table.contentToolbar");const i=t.config.get("table.tableToolbar");if(o){n.register("tableContent",{ariaLabel:e("Table toolbar"),items:o,getRelatedElement:aM})}if(i){n.register("table",{ariaLabel:e("Table toolbar"),items:i,getRelatedElement:sM})}}}class dM extends mx{}dM.builtinPlugins=[Cx,lD,xD,RT,LB,xB,UB,YB,jI,PR,fD,jR,rM,lM];dM.defaultConfig={toolbar:{items:["undo","redo","heading","|","bold","italic","link","bulletedList","numberedList","|","outdent","indent","|","imageInsert","insertTable","sourceEditing"]},language:"en",table:{contentToolbar:["tableColumn","tableRow","mergeTableCells"]}};const uM=dM})();o=o["default"];return o})()));
//# sourceMappingURL=ckeditor.js.map