(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t))}(i.getData("text/html")):i.getData("text/plain")&&(((r=(r=i.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"").replace(/\r?\n/g,"
").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||r.includes("
"))&&(r=`
${r}
`),o=r),o=this.editor.data.htmlProcessor.toView(o);const s=new mn(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:i,asPlainText:t.asPlainText}),s.stop.called&&e.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,t)=>{if(!t.content.isEmpty){const n=this.editor.data,i=this.editor.model,o=n.toModel(t.content,"$clipboardHolder");if(0==o.childCount)return;i.change((e=>{const n=i.document.selection;if(t.asPlainText||function(e,t){if(e.childCount>1)return!1;const n=e.getChild(0);if(t.isObject(n))return!1;return 0==[...n.getAttributeKeys()].length}
+ */const mu=new WeakMap;function bu(e){const{view:t,element:n,text:i,isDirectHost:o=!0,keepOnFocus:r=!1}=e,s=t.document;mu.has(s)||(mu.set(s,new Map),s.registerPostFixer((e=>wu(s,e)))),mu.get(s).set(n,{text:i,isDirectHost:o,keepOnFocus:r,hostElement:o?n:null}),t.change((e=>wu(s,e)))}function ku(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function wu(e,t){const n=mu.get(e),i=[];let o=!1;for(const[e,r]of n)r.isDirectHost&&(i.push(e),_u(t,e,r)&&(o=!0));for(const[e,r]of n){if(r.isDirectHost)continue;const n=vu(e);n&&(i.includes(n)||(r.hostElement=n,_u(t,e,r)&&(o=!0)))}return o}function _u(e,t,n){const{text:i,isDirectHost:o,hostElement:r}=n;let s=!1;r.getAttribute("data-placeholder")!==i&&(e.setAttribute("data-placeholder",i,r),s=!0);return(o||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;if(Array.from(e.getChildren()).some((e=>!e.is("uiElement"))))return!1;if(t)return!0;const n=e.document;if(!n.isFocused)return!0;const i=n.selection.anchor;return i&&i.parent!==e}(r,n.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,r)&&(s=!0):ku(e,r)&&(s=!0),s}function vu(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement"))return t}return null}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(o,i.schema)){const t=Array.from(n.getAttributes()).filter((([e])=>i.schema.getAttributeProperties(e).isFormatting));n.isCollapsed||i.deleteContent(n,{doNotAutoparagraph:!0}),t.push(...n.getAttributes());const r=e.createRangeIn(o);for(const n of r.getItems())(n.is("$text")||n.is("$textProxy"))&&e.setAttributes(t,n)}i.insertContent(o)})),e.stop()}}),{priority:"low"}),this.listenTo(i,"copy",o,{priority:"low"}),this.listenTo(i,"cut",((t,n)=>{e.isReadOnly?n.preventDefault():o(t,n)}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((n,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",Bd(i.content))),"cut"==i.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}class Fd{constructor(e){this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"}),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}))}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",zd,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",zd),this.refresh())}execute(){}destroy(){this.stopListening()}}function zd(e){e.return=!1,e.stop()}
+ */const yu=new Map;function xu(e,t,n){let i=yu.get(e);i||(i=new Map,yu.set(e,i)),i.set(t,n)}function Au(e){return[e]}function Cu(e,t,n={}){const i=function(e,t){const n=yu.get(e);return n&&n.has(t)?n.get(t):Au}(e.constructor,t.constructor);try{return i(e=e.clone(),t,n)}catch(e){throw e}}function Tu(e,t,n){e=e.slice(),t=t.slice();const i=new Pu(n.document,n.useRelations,n.forceWeakRemove);i.setOriginalOperations(e),i.setOriginalOperations(t);const o=i.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:o};const r=new WeakMap;for(const t of e)r.set(t,0);const s={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length};let a=0;for(;a{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const i=e.range.getDifference(t.range).map((t=>new Mc(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&n.aIsStrong&&i.push(new Mc(o,t.key,t.newValue,e.newValue,0)),0==i.length?[new al(0)]:i}return[e]})),xu(Mc,Bc,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const n=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new Mc(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const i=Ru(t,e.key,e.oldValue);i&&n.unshift(i)}return n}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),xu(Mc,Lc,((e,t)=>{const n=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&n.push(fa._createFromPositionAndShift(t.graveyardPosition,1));const i=e.range._getTransformedByMergeOperation(t);return i.isCollapsed||n.push(i),n.map((t=>new Mc(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),xu(Mc,Vc,((e,t)=>function(e,t){const n=fa._createFromPositionAndShift(t.sourcePosition,t.howMany);let i=null,o=[];n.containsRange(e,!0)?i=e:e.start.hasSameParentAs(n.start)?(o=e.getDifference(n),i=e.getIntersection(n)):o=[e];const r=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const n=t.getMovedRangeStart(),i=e.start.hasSameParentAs(n);e=e._getTransformedByInsertion(n,t.howMany,i),r.push(...e)}i&&r.push(i._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return r}(e.range,t).map((t=>new Mc(t,e.key,e.oldValue,e.newValue,e.baseVersion))))),xu(Mc,jc,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const n=e.clone();return n.range=new fa(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,n]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),xu(Bc,Mc,((e,t)=>{const n=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const i=Ru(e,t.key,t.newValue);i&&n.push(i)}return n})),xu(Bc,Bc,((e,t,n)=>(e.position.isEqual(t.position)&&n.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),xu(Bc,Vc,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),xu(Bc,jc,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),xu(Bc,Lc,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),xu(Dc,Bc,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),xu(Dc,Dc,((e,t,n)=>{if(e.name==t.name){if(!n.aIsStrong)return[new al(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),xu(Dc,Lc,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),xu(Dc,Vc,((e,t,n)=>{if(e.oldRange&&(e.oldRange=fa._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(n.abRelation){const i=fa._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.start.path=n.abRelation.path,e.newRange.end=i.end,[e];if("right"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=i.start,e.newRange.end.path=n.abRelation.path,[e]}e.newRange=fa._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),xu(Dc,jc,((e,t,n)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(n.abRelation){const i=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&n.abRelation.wasStartBeforeMergedElement?e.newRange.start=la._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!n.abRelation.wasInLeftElement&&(e.newRange.start=la._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasInRightElement?e.newRange.end=la._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?e.newRange.end=la._createAt(t.insertionPosition):e.newRange.end=i.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),xu(Lc,Bc,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),xu(Lc,Lc,((e,t,n)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(n.bWasUndone){const n=t.graveyardPosition.path.slice();return n.push(0),e.sourcePosition=new la(t.graveyardPosition.root,n),e.howMany=0,[e]}return[new al(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!n.bWasUndone&&"splitAtSource"!=n.abRelation){const i="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=t.targetPosition._getTransformedByMergeOperation(t),i=e.targetPosition._getTransformedByMergeOperation(t);return[new Vc(n,e.howMany,i,0)]}return[new al(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&n.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),xu(Lc,Vc,((e,t,n)=>{const i=fa._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!n.bWasUndone&&!n.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.sourcePosition)?[new al(0)]:(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])})),xu(Lc,jc,((e,t,n)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const i=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(i||o||"mergeTargetNotMoved"==n.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==n.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==n.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),xu(Vc,Bc,((e,t)=>{const n=fa._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),xu(Vc,Vc,((e,t,n)=>{const i=fa._createFromPositionAndShift(e.sourcePosition,e.howMany),o=fa._createFromPositionAndShift(t.sourcePosition,t.howMany);let r,s=n.aIsStrong,a=!n.aIsStrong;if("insertBefore"==n.abRelation||"insertAfter"==n.baRelation?a=!0:"insertAfter"!=n.abRelation&&"insertBefore"!=n.baRelation||(a=!1),r=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Iu(e,t)&&Iu(t,e))return[t.getReversed()];if(i.containsPosition(t.targetPosition)&&i.containsRange(o,!0))return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Ou([i],r);if(o.containsPosition(e.targetPosition)&&o.containsRange(i,!0))return i.start=i.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),i.end=i.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),Ou([i],r);const c=mi(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Ou([i],r);"remove"!=e.type||"remove"==t.type||n.aWasUndone||n.forceWeakRemove?"remove"==e.type||"remove"!=t.type||n.bWasUndone||n.forceWeakRemove||(s=!1):s=!0;const l=[],d=i.getDifference(o);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const n="same"==mi(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),i=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,n);l.push(...i)}const u=i.getIntersection(o);return null!==u&&s&&(u.start=u.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),u.end=u.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===l.length?l.push(u):1==l.length?o.start.isBefore(i.start)||o.start.isEqual(i.start)?l.unshift(u):l.push(u):l.splice(1,0,u)),0===l.length?[new al(e.baseVersion)]:Ou(l,r)})),xu(Vc,jc,((e,t,n)=>{let i=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=n.abRelation||(i=e.targetPosition._getTransformedBySplitOperation(t));const o=fa._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=i,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new fa(t.splitPosition,o.end);e=e._getTransformedBySplitOperation(t);return Ou([new fa(o.start,t.splitPosition),e],i)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==n.abRelation&&(i=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==n.abRelation&&(i=e.targetPosition);const r=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const i=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&i&&!n.aWasUndone&&r.push(fa._createFromPositionAndShift(t.insertionPosition,1))}return Ou(r,i)})),xu(Vc,Lc,((e,t,n)=>{const i=fa._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(t.sourcePosition))if("remove"!=e.type||n.forceWeakRemove){if(1==e.howMany)return n.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new al(0)]}else if(!n.aWasUndone){const n=[];let i=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(n.push(new Vc(e.sourcePosition,e.howMany-1,e.targetPosition,0)),i=i._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),s=new Vc(i,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const c=new la(s.targetPosition.root,a);o=o._getTransformedByMove(i,r,1);const l=new Vc(o,t.howMany,c,0);return n.push(s),n.push(l),n}const o=fa._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=o.start,e.howMany=o.end.offset-o.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),xu(zc,Bc,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),xu(zc,Lc,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),xu(zc,Vc,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),xu(zc,zc,((e,t,n)=>{if(e.position.isEqual(t.position)){if(!n.aIsStrong)return[new al(0)];e.oldName=t.newName}return[e]})),xu(zc,jc,((e,t)=>{if("same"==mi(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new zc(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),xu(Fc,Fc,((e,t,n)=>{if(e.root===t.root&&e.key===t.key){if(!n.aIsStrong||e.newValue===t.newValue)return[new al(0)];e.oldValue=t.newValue}return[e]})),xu(jc,Bc,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!n.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const n=t.graveyardPosition.path.slice();n.push(0);const i=new la(t.graveyardPosition.root,n),o=jc.getInsertionPosition(new la(t.graveyardPosition.root,n)),r=new jc(i,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=jc.getInsertionPosition(e.splitPosition),e.graveyardPosition=r.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[r,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=jc.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),xu(jc,Vc,((e,t,n)=>{const i=fa._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);if(!n.bWasUndone&&o){const n=e.splitPosition._getTransformedByMoveOperation(t),i=e.graveyardPosition._getTransformedByMoveOperation(t),o=i.path.slice();o.push(0);const r=new la(i.root,o);return[new Vc(n,e.howMany,r,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==n.baRelation||"splitBefore"==n.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=jc.getInsertionPosition(e.splitPosition),[e];if(o&&n.abRelation&&n.abRelation.howMany){const{howMany:t,offset:i}=n.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(i),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=n,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new al(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new al(0)];if("splitBefore"==n.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const i="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=[];return t.howMany&&n.push(new Vc(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&n.push(new Vc(e.splitPosition,e.howMany,e.moveTargetPosition,0)),n}return[new al(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==n.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==n.baRelation){const n=t.insertionPosition.path.slice();n.push(0);const i=new la(t.insertionPosition.root,n);return[e,new Vc(e.insertionPosition,1,i,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{!function(e,t,n,i){const o=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(i.isLimit(s)||i.isLimit(a))return void(o||s!=a||e.deleteContent(n));if(o){const e=Ld(t.model.schema,n.getAttributes());$d(t,r.start),t.setSelectionAttribute(e)}else{const i=!(r.start.isAtStart&&r.end.isAtEnd),o=s==a;e.deleteContent(n,{leaveUnmerged:i}),i&&(o?$d(t,n.focus):t.setSelection(a,0))}}(this.editor.model,n,t.selection,e.schema),this.fire("afterExecute",{writer:n})}))}}function $d(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}
+ */class Nu extends ds{constructor(e){super(e),this.domEventType=["mousedown","mouseup"]}onDomEvent(e){this.fire(e.type,e)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Hd extends Pr{constructor(e){super(e);const t=this.document;t.on("keydown",((e,n)=>{if(this.isEnabled&&n.keyCode==Ao.enter){let i;t.once("enter",(e=>i=e),{priority:"highest"}),t.fire("enter",new Xr(t,n.domEvent,{isSoft:n.shiftKey})),i&&i.stop.called&&e.stop()}}))}observe(){}}
+ */class Vu{constructor(e){this.document=e}createDocumentFragment(e){return new Qo(this.document,e)}createElement(e,t,n){return new ao(this.document,e,t,n)}createText(e){return new wi(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const i=n.getChildIndex(e);return this.removeChildren(i,1,n),this.insertChild(i,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new ao(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){ct(e)&&void 0===n&&(n=t),n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return mo._createAt(e,t)}createPositionAfter(e){return mo._createAfter(e)}createPositionBefore(e){return mo._createBefore(e)}createRange(e,t){return new bo(e,t)}createRangeOn(e){return bo._createOn(e)}createRangeIn(e){return bo._createIn(e)}createSelection(e,t,n){return new _o(e,t,n)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class qd extends Rd{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(Hd),e.commands.add("enter",new jd(e)),this.listenTo(n,"enter",((n,i)=>{i.preventDefault(),i.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}
+ */new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple","currentcolor","transparent"]);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Wd extends Fd{execute(){const e=this.editor.model,t=e.document;e.change((n=>{!function(e,t,n){const i=n.isCollapsed,o=n.getFirstRange(),r=o.start.parent,s=o.end.parent,a=r==s;if(i){const i=Ld(e.schema,n.getAttributes());Ud(e,t,o.end),t.removeSelectionAttribute(n.getAttributeKeys()),t.setSelectionAttribute(i)}else{const i=!(o.start.isAtStart&&o.end.isAtEnd);e.deleteContent(n,{leaveUnmerged:i}),a?Ud(e,t,n.focus):i&&t.setSelection(s,0)}}(e,n,t.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const n=t.anchor;if(!n||!e.checkChild(n,"softBreak"))return!1;const i=t.getFirstRange(),o=i.start.parent,r=i.end.parent;if((Kd(o,e)||Kd(r,e))&&o!==r)return!1;return!0}(e.schema,t.selection)}}function Ud(e,t,n){const i=t.createElement("softBreak");e.insertContent(i,n),t.setSelection(i,"after")}function Kd(e,t){return!e.is("rootElement")&&(t.isLimit(e)||Kd(e.parent,t))}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Gd extends Rd{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,n=e.conversion,i=e.editing.view,o=i.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),i.addObserver(Hd),e.commands.add("shiftEnter",new Wd(e)),this.listenTo(o,"enter",((t,n)=>{n.preventDefault(),n.isSoft&&(e.execute("shiftEnter"),i.scrollToTheSelection())}),{priority:"low"})}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Jd extends Fd{execute(){const e=this.editor.model,t=e.document.selection;let n=e.schema.getLimitElement(t);if(t.containsEntireContent(n)||!Xd(e.schema,n))do{if(n=n.parent,!n)return}while(!Xd(e.schema,n));e.change((e=>{e.setSelection(n,"in")}))}}function Xd(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}
+ */
+class Bu extends Nl{constructor(e,t){super(e),this.view=t,this._toolbarConfig=zd(e.config.get("toolbar")),this._elementReplacer=new Rs}get element(){return this.view.element}init(e){const t=this.editor,n=this.view,i=t.editing.view,o=n.editable,r=i.document.getRoot();o.name=r.rootName,n.render();const s=o.element;this.setEditableElement(o.name,s),this.focusTracker.add(s),n.editable.bind("isFocused").to(this.focusTracker),i.attachDomRoot(s),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy(),super.destroy()}_initToolbar(){const e=this.editor,t=this.view,n=e.editing.view;t.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),t.stickyPanel.limiterElement=t.element,this._toolbarConfig.viewportTopOffset&&(t.stickyPanel.viewportTopOffset=this._toolbarConfig.viewportTopOffset),t.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),function({origin:e,originKeystrokeHandler:t,originFocusTracker:n,toolbar:i,beforeFocus:o,afterBlur:r}){n.add(i.element),t.set("Alt+F10",((e,t)=>{n.isFocused&&!i.focusTracker.isFocused&&(o&&o(),i.focus(),t())})),i.keystrokes.set("Esc",((t,n)=>{i.focusTracker.isFocused&&(e.focus(),r&&r(),n())}))}({origin:n,originFocusTracker:this.focusTracker,originKeystrokeHandler:e.keystrokes,toolbar:t.toolbar})}_initPlaceholder(){const e=this.editor,t=e.editing.view,n=t.document.getRoot(),i=e.sourceElement,o=e.config.get("placeholder")||i&&"textarea"===i.tagName.toLowerCase()&&i.getAttribute("placeholder");o&&bu({view:t,element:n,text:o,isDirectHost:!1,keepOnFocus:!0})}}n(61);
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class Du extends Xd{constructor(e,t,n={}){super(e),this.stickyPanel=new pu(e),this.toolbar=new Fd(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.editable=new Yd(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const Qd=Po("Ctrl+A");class Yd extends Rd{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new Jd(e)),this.listenTo(t,"keydown",((t,n)=>{To(n)===Qd&&(e.execute("selectAll"),n.preventDefault())}))}}
+ */class zu extends Il{constructor(e,t){super(t),ni(e)&&(this.sourceElement=e),this.model.document.createRoot();const n=!this.config.get("toolbar.shouldNotGroupWhenFull"),i=new Du(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:n});this.ui=new Bu(this,i),
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Zd extends Rd{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const n=e.commands.get("selectAll"),i=new gd(t),o=t.t;return i.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),i.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),i}))}}
+function(e){if(!O(e.updateSourceElement))throw new c.a("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(t&&"textarea"===t.tagName.toLowerCase()&&t.form){let n;const i=t.form,o=()=>e.updateSourceElement();O(i.submit)&&(n=i.submit,i.submit=()=>{o(),n.apply(i)}),i.addEventListener("submit",o),e.on("destroy",(()=>{i.removeEventListener("submit",o),n&&(i.submit=n)}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class eu extends Rd{static get requires(){return[Yd,Zd]}static get pluginName(){return"SelectAll"}}
+ */(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((n=>{const i=new this(e,t);n(i.initPlugins().then((()=>i.ui.init(ni(e)?e:null))).then((()=>{if(!ni(e)&&t.initialData)throw new c.a("editor-create-initial-data",null);const n=t.initialData||function(e){return ni(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class tu{constructor(e,t=20){this.model=e,this.size=0,this.limit=t,this.isLocked=!1,this._changeCallback=(e,t)=>{"transparent"!=t.type&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch()),this._batch}input(e){this.size+=e,this.size>=this.limit&&this._reset(!0)}lock(){this.isLocked=!0}unlock(){this.isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e){this.isLocked&&!e||(this._batch=null,this.size=0)}}
+ */(e);return i.data.init(n)})).then((()=>i.fire("ready"))).then((()=>i)))}))}}Xe(zu,Vl),Xe(zu,Bl);class Fu{constructor(e){this.files=function(e){const t=e.files?Array.from(e.files):[],n=e.items?Array.from(e.items):[];if(t.length)return t;return n.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class nu extends Fd{constructor(e,t){super(e),this._buffer=new tu(e.model,t),this._batches=new WeakSet}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,n=t.document,i=e.text||"",o=i.length,r=e.range?t.createSelection(e.range):n.selection,s=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock(),this._batches.add(this._buffer.batch),t.deleteContent(r),i&&t.insertContent(e.createText(i,n.selection.getAttributes()),r),s?e.setSelection(s):r.is("documentSelection")||e.setSelection(r),this._buffer.unlock(),this._buffer.input(o)}))}}
+ */(e),this._native=e}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}class Lu extends ds{constructor(e){super(e);const t=this.document;function n(e){return(n,i)=>{i.preventDefault();const r=i.dropRange?[i.dropRange]:null,s=new o(t,e);t.fire(s,{dataTransfer:i.dataTransfer,method:n.name,targetRanges:r,target:i.target}),s.stop.called&&i.stopPropagation()}}this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"],this.listenTo(t,"paste",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",n("dragging"),{priority:"low"})}onDomEvent(e){const t={dataTransfer:new Fu(e.clipboardData?e.clipboardData:e.dataTransfer)};"drop"!=e.type&&"dragover"!=e.type||(t.dropRange=function(e,t){const n=t.target.ownerDocument,i=t.clientX,o=t.clientY;let r;n.caretRangeFromPoint&&n.caretRangeFromPoint(i,o)?r=n.caretRangeFromPoint(i,o):t.rangeParent&&(r=n.createRange(),r.setStart(t.rangeParent,t.rangeOffset),r.collapse(!0));if(r)return e.domConverter.domRangeToView(r);return null}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const iu=[To("arrowUp"),To("arrowRight"),To("arrowDown"),To("arrowLeft"),9,16,17,18,19,20,27,33,34,35,36,45,91,93,144,145,173,174,175,176,177,178,179,255];for(let e=112;e<=135;e++)iu.push(e);function ou(e){return!!e.ctrlKey||iu.includes(e.keyCode)}
+ */(this.view,e)),this.fire(e.type,e,t)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function ru(e){if(e.newChildren.length-e.oldChildren.length!=1)return;const t=function(e,t){const n=[];let i,o=0;return e.forEach((e=>{"equal"==e?(r(),o++):"insert"==e?(s("insert")?i.values.push(t[o]):(r(),i={type:"insert",index:o,values:[t[o]]}),o++):s("delete")?i.howMany++:(r(),i={type:"delete",index:o,howMany:1})})),r(),n;function r(){i&&(n.push(i),i=null)}function s(e){return i&&i.type==e}}
+ */
+const ju=["figcaption","li"];function $u(e){let t="";if(e.is("$text")||e.is("$textProxy"))t=e.data;else if(e.is("element","img")&&e.hasAttribute("alt"))t=e.getAttribute("alt");else if(e.is("element","br"))t="\n";else{let n=null;for(const i of e.getChildren()){const e=$u(i);n&&(n.is("containerElement")||i.is("containerElement"))&&(ju.includes(n.name)||ju.includes(i.name)?t+="\n":t+="\n\n"),t+=e,n=i}}return t}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(ar(e.oldChildren,e.newChildren,su),e.newChildren);if(t.length>1)return;const n=t[0];return n.values[0]&&n.values[0].is("$text")?n:void 0}function su(e,t){return e&&e.is("$text")&&t&&t.is("$text")?e.data===t.data:e===t}
+ */class Hu extends Qe{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(Lu),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document;this.listenTo(i,"clipboardInput",(t=>{e.isReadOnly&&t.stop()}),{priority:"highest"}),this.listenTo(i,"clipboardInput",((e,t)=>{const i=t.dataTransfer;let r=t.content||"";var s;
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class au{constructor(e){this.editor=e,this.editing=this.editor.editing}handle(e,t){if(function(e){if(0==e.length)return!1;for(const t of e)if("children"===t.type&&!ru(t))return!0;return!1}(e))this._handleContainerChildrenMutations(e,t);else for(const n of e)this._handleTextMutation(n,t),this._handleTextNodeInsertion(n)}_handleContainerChildrenMutations(e,t){const n=function(e){const t=e.map((e=>e.node)).reduce(((e,t)=>e.getCommonAncestor(t,{includeSelf:!0})));if(!t)return;return t.getAncestors({includeSelf:!0,parentFirst:!0}).find((e=>e.is("containerElement")||e.is("rootElement")))}(e);if(!n)return;const i=this.editor.editing.view.domConverter.mapViewToDom(n),o=new wr(this.editor.editing.view.document),r=this.editor.data.toModel(o.domToView(i)).getChild(0),s=this.editor.editing.mapper.toModelElement(n);if(!s)return;const a=Array.from(r.getChildren()),c=Array.from(s.getChildren()),l=a[a.length-1],d=c[c.length-1],u=l&&l.is("element","softBreak"),h=d&&!d.is("element","softBreak");u&&h&&a.pop();const f=this.editor.model.schema;if(!cu(a,f)||!cu(c,f))return;const g=a.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," "),p=c.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," ");if(p===g)return;const m=ar(p,g),{firstChangeAt:b,insertions:k,deletions:w}=lu(m);let _=null;t&&(_=this.editing.mapper.toModelRange(t.getFirstRange()));const v=g.substr(b,k),y=this.editor.model.createRange(this.editor.model.createPositionAt(s,b),this.editor.model.createPositionAt(s,b+w));this.editor.execute("input",{text:v,range:y,resultRange:_})}_handleTextMutation(e,t){if("text"!=e.type)return;const n=e.newText.replace(/\u00A0/g," "),i=e.oldText.replace(/\u00A0/g," ");if(i===n)return;const o=ar(i,n),{firstChangeAt:r,insertions:s,deletions:a}=lu(o);let c=null;t&&(c=this.editing.mapper.toModelRange(t.getFirstRange()));const l=this.editing.view.createPositionAt(e.node,r),d=this.editing.mapper.toModelPosition(l),u=this.editor.model.createRange(d,d.getShiftedBy(a)),h=n.substr(r,s);this.editor.execute("input",{text:h,range:u,resultRange:c})}_handleTextNodeInsertion(e){if("children"!=e.type)return;const t=ru(e),n=this.editing.view.createPositionAt(e.node,t.index),i=this.editing.mapper.toModelPosition(n),o=t.values[0].data;this.editor.execute("input",{text:o.replace(/\u00A0/g," "),range:this.editor.model.createRange(i)})}}function cu(e,t){return e.every((e=>t.isInline(e)))}function lu(e){let t=null,n=null;for(let i=0;i(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t))}(i.getData("text/html")):i.getData("text/plain")&&(((s=(s=i.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"").replace(/\r?\n/g,"
").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||s.includes("
"))&&(s=`
${s}
`),r=s),r=this.editor.data.htmlProcessor.toView(r));const a=new o(this,"inputTransformation");this.fire(a,{content:r,dataTransfer:i,targetRanges:t.targetRanges,method:t.method}),a.stop.called&&e.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,n)=>{if(n.content.isEmpty)return;const i=this.editor.data.toModel(n.content,"$clipboardHolder");0!=i.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:i,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,n)=>{n.resultRange=t.insertContent(n.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,n=e.editing.view.document;function i(i,o){const r=o.dataTransfer;o.preventDefault();const s=e.data.toView(e.model.getSelectedContent(t.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:i.name})}this.listenTo(n,"copy",i,{priority:"low"}),this.listenTo(n,"cut",((t,n)=>{e.isReadOnly?n.preventDefault():i(t,n)}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",$u(i.content))),"cut"==i.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class du extends Rd{static get pluginName(){return"Input"}init(){const e=this.editor,t=new nu(e,e.config.get("typing.undoStep")||20);e.commands.add("input",t),function(e){let t=null;const n=e.model,i=e.editing.view,o=e.commands.get("input");function r(e){const r=n.document,a=i.document.isComposing,c=t&&t.isEqual(r.selection);t=null,o.isEnabled&&(ou(e)||r.selection.isCollapsed||a&&229===e.keyCode||!a&&229===e.keyCode&&c||s())}function s(){const e=o.buffer;e.lock();const t=e.batch;o._batches.add(t),n.enqueueChange(t,(()=>{n.deleteContent(n.document.selection)})),e.unlock()}yo.isAndroid?i.document.on("beforeinput",((e,t)=>r(t)),{priority:"lowest"}):i.document.on("keydown",((e,t)=>r(t)),{priority:"lowest"}),i.document.on("compositionstart",(function(){const e=n.document,t=1!==e.selection.rangeCount||e.selection.getFirstRange().isFlat;e.selection.isCollapsed||t||s()}),{priority:"lowest"}),i.document.on("compositionend",(()=>{t=n.createSelection(n.document.selection)}),{priority:"lowest"})}(e),function(e){e.editing.view.document.on("mutations",((t,n,i)=>{new au(e).handle(n,i)}))}(e)}isInput(e){return this.editor.commands.get("input")._batches.has(e)}}
+ */function*qu(e,t){for(const n of t)n&&e.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class uu extends Fd{constructor(e,t){super(e),this.direction=t,this._buffer=new tu(e.model,e.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,n=t.document;t.enqueueChange(this._buffer.batch,(i=>{this._buffer.lock();const o=i.createSelection(e.selection||n.selection),r=e.sequence||1,s=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(i);if(this._shouldReplaceFirstBlockWithParagraph(o,r))return void this.editor.execute("paragraph",{selection:o});if(o.isCollapsed)return;let a=0;o.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=ho(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(o,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),i.setSelection(o),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(i)))return!1;if(!t.schema.checkChild(i,"paragraph"))return!1;const o=i.getChild(0);return!o||"paragraph"!==o.name}_replaceEntireContentWithParagraph(e){const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n),o=e.createElement("paragraph");e.remove(e.createRangeIn(i)),e.insert(o,i),e.setSelection(o,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const n=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const i=e.getFirstPosition(),o=n.schema.getLimitElement(i),r=o.getChild(0);return i.parent==r&&(!!e.containsEntireContent(r)&&(!!n.schema.checkChild(o,"paragraph")&&"paragraph"!=r.name))}}
+ */class Wu extends Ze{execute(){const e=this.editor.model,t=e.document;e.change((n=>{!function(e,t,n,i){const o=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(i.isLimit(s)||i.isLimit(a))return void(o||s!=a||e.deleteContent(n));if(o){const e=qu(t.model.schema,n.getAttributes());Uu(t,r.start),t.setSelectionAttribute(e)}else{const i=!(r.start.isAtStart&&r.end.isAtEnd),o=s==a;e.deleteContent(n,{leaveUnmerged:i}),i&&(o?Uu(t,n.focus):t.setSelection(a,0))}}(this.editor.model,n,t.selection,e.schema),this.fire("afterExecute",{writer:n})}))}}function Uu(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class hu extends Pr{constructor(e){super(e);const t=e.document;let n=0;function i(e,n,i){let o;t.once("delete",(e=>o=e),{priority:Number.POSITIVE_INFINITY}),t.fire("delete",new Xr(t,n,i)),o&&o.stop.called&&e.stop()}t.on("keyup",((e,t)=>{t.keyCode!=Ao.delete&&t.keyCode!=Ao.backspace||(n=0)})),t.on("keydown",((e,t)=>{const o={};if(t.keyCode==Ao.delete)o.direction="forward",o.unit="character";else{if(t.keyCode!=Ao.backspace)return;o.direction="backward",o.unit="codePoint"}const r=yo.isMac?t.altKey:t.ctrlKey;o.unit=r?"word":o.unit,o.sequence=++n,i(e,t.domEvent,o)})),yo.isAndroid&&t.on("beforeinput",((t,n)=>{if("deleteContentBackward"!=n.domEvent.inputType)return;const o={unit:"codepoint",direction:"backward",sequence:1},r=n.domTarget.ownerDocument.defaultView.getSelection();r.anchorNode==r.focusNode&&r.anchorOffset+1!=r.focusOffset&&(o.selectionToRemove=e.domConverter.domSelectionToView(r)),i(t,n.domEvent,o)}))}observe(){}}
+ */class Ku extends Lr{constructor(e){super(e);const t=this.document;t.on("keydown",((e,n)=>{if(this.isEnabled&&n.keyCode==Fo.enter){const i=new yo(t,"enter",t.selection.getFirstRange());t.fire(i,new ls(t,n.domEvent,{isSoft:n.shiftKey})),i.stop.called&&e.stop()}}))}observe(){}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class fu extends Rd{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,n=t.document;if(t.addObserver(hu),e.commands.add("forwardDelete",new uu(e,"forward")),e.commands.add("delete",new uu(e,"backward")),this.listenTo(n,"delete",((n,i)=>{const o={unit:i.unit,sequence:i.sequence};if(i.selectionToRemove){const t=e.model.createSelection(),n=[];for(const t of i.selectionToRemove.getRanges())n.push(e.editing.mapper.toModelRange(t));t.setTo(n),o.selection=t}e.execute("forward"==i.direction?"forwardDelete":"delete",o),i.preventDefault(),t.scrollToTheSelection()})),yo.isAndroid){let e=null;this.listenTo(n,"delete",((t,n)=>{const i=n.domTarget.ownerDocument.defaultView.getSelection();e={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}}),{priority:"lowest"}),this.listenTo(n,"keyup",((t,n)=>{if(e){const t=n.domTarget.ownerDocument.defaultView.getSelection();t.collapse(e.anchorNode,e.anchorOffset),t.extend(e.focusNode,e.focusOffset),e=null}}))}}}
+ */class Gu extends Qe{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(Ku),e.commands.add("enter",new Wu(e)),this.listenTo(n,"enter",((n,i)=>{i.preventDefault(),i.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class gu extends Rd{static get requires(){return[du,fu]}static get pluginName(){return"Typing"}}
+ */class Ju{constructor(e,t=20){this.model=e,this.size=0,this.limit=t,this.isLocked=!1,this._changeCallback=(e,t)=>{"transparent"!=t.type&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch()),this._batch}input(e){this.size+=e,this.size>=this.limit&&this._reset(!0)}lock(){this.isLocked=!0}unlock(){this.isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e){this.isLocked&&!e||(this._batch=null,this.size=0)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const pu=new Map;function mu(e,t,n){let i=pu.get(e);i||(i=new Map,pu.set(e,i)),i.set(t,n)}function bu(e){return[e]}function ku(e,t,n={}){const i=function(e,t){const n=pu.get(e);return n&&n.has(t)?n.get(t):bu}(e.constructor,t.constructor);try{return i(e=e.clone(),t,n)}catch(e){throw e}}function wu(e,t,n){e=e.slice(),t=t.slice();const i=new _u(n.document,n.useRelations,n.forceWeakRemove);i.setOriginalOperations(e),i.setOriginalOperations(t);const o=i.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:o};const r=new WeakMap;for(const t of e)r.set(t,0);const s={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length};let a=0;for(;a{this._buffer.lock();const o=i.createSelection(e.selection||n.selection),r=e.sequence||1,s=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(i);if(this._shouldReplaceFirstBlockWithParagraph(o,r))return void this.editor.execute("paragraph",{selection:o});if(o.isCollapsed)return;let a=0;o.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=wo(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(o,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),i.setSelection(o),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(i)))return!1;if(!t.schema.checkChild(i,"paragraph"))return!1;const o=i.getChild(0);return!o||"paragraph"!==o.name}_replaceEntireContentWithParagraph(e){const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n),o=e.createElement("paragraph");e.remove(e.createRangeIn(i)),e.insert(o,i),e.setSelection(o,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const n=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const i=e.getFirstPosition(),o=n.schema.getLimitElement(i),r=o.getChild(0);return i.parent==r&&(!!e.containsEntireContent(r)&&(!!n.schema.checkChild(o,"paragraph")&&"paragraph"!=r.name))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */mu(cc,cc,((e,t,n)=>{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const i=e.range.getDifference(t.range).map((t=>new cc(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&n.aIsStrong&&i.push(new cc(o,t.key,t.newValue,e.newValue,0)),0==i.length?[new Bc(0)]:i}return[e]})),mu(cc,uc,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const n=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new cc(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const i=xu(t,e.key,e.oldValue);i&&n.unshift(i)}return n}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),mu(cc,pc,((e,t)=>{const n=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&n.push($s._createFromPositionAndShift(t.graveyardPosition,1));const i=e.range._getTransformedByMergeOperation(t);return i.isCollapsed||n.push(i),n.map((t=>new cc(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),mu(cc,dc,((e,t)=>function(e,t){const n=$s._createFromPositionAndShift(t.sourcePosition,t.howMany);let i=null,o=[];n.containsRange(e,!0)?i=e:e.start.hasSameParentAs(n.start)?(o=e.getDifference(n),i=e.getIntersection(n)):o=[e];const r=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const n=t.getMovedRangeStart(),i=e.start.hasSameParentAs(n);e=e._getTransformedByInsertion(n,t.howMany,i),r.push(...e)}i&&r.push(i._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return r}(e.range,t).map((t=>new cc(t,e.key,e.oldValue,e.newValue,e.baseVersion))))),mu(cc,mc,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const n=e.clone();return n.range=new $s(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,n]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),mu(uc,cc,((e,t)=>{const n=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const i=xu(e,t.key,t.newValue);i&&n.push(i)}return n})),mu(uc,uc,((e,t,n)=>(e.position.isEqual(t.position)&&n.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),mu(uc,dc,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),mu(uc,mc,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),mu(uc,pc,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),mu(hc,uc,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),mu(hc,hc,((e,t,n)=>{if(e.name==t.name){if(!n.aIsStrong)return[new Bc(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),mu(hc,pc,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),mu(hc,dc,((e,t,n)=>{if(e.oldRange&&(e.oldRange=$s._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(n.abRelation){const i=$s._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.start.path=n.abRelation.path,e.newRange.end=i.end,[e];if("right"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=i.start,e.newRange.end.path=n.abRelation.path,[e]}e.newRange=$s._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),mu(hc,mc,((e,t,n)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(n.abRelation){const i=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&n.abRelation.wasStartBeforeMergedElement?e.newRange.start=Fs._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!n.abRelation.wasInLeftElement&&(e.newRange.start=Fs._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasInRightElement?e.newRange.end=Fs._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?e.newRange.end=Fs._createAt(t.insertionPosition):e.newRange.end=i.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),mu(pc,uc,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),mu(pc,pc,((e,t,n)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(n.bWasUndone){const n=t.graveyardPosition.path.slice();return n.push(0),e.sourcePosition=new Fs(t.graveyardPosition.root,n),e.howMany=0,[e]}return[new Bc(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!n.bWasUndone&&"splitAtSource"!=n.abRelation){const i="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=t.targetPosition._getTransformedByMergeOperation(t),i=e.targetPosition._getTransformedByMergeOperation(t);return[new dc(n,e.howMany,i,0)]}return[new Bc(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&n.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),mu(pc,dc,((e,t,n)=>{const i=$s._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!n.bWasUndone&&!n.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.sourcePosition)?[new Bc(0)]:(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])})),mu(pc,mc,((e,t,n)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const i=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(i||o||"mergeTargetNotMoved"==n.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==n.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==n.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),mu(dc,uc,((e,t)=>{const n=$s._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),mu(dc,dc,((e,t,n)=>{const i=$s._createFromPositionAndShift(e.sourcePosition,e.howMany),o=$s._createFromPositionAndShift(t.sourcePosition,t.howMany);let r,s=n.aIsStrong,a=!n.aIsStrong;if("insertBefore"==n.abRelation||"insertAfter"==n.baRelation?a=!0:"insertAfter"!=n.abRelation&&"insertBefore"!=n.baRelation||(a=!1),r=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Cu(e,t)&&Cu(t,e))return[t.getReversed()];if(i.containsPosition(t.targetPosition)&&i.containsRange(o,!0))return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Au([i],r);if(o.containsPosition(e.targetPosition)&&o.containsRange(i,!0))return i.start=i.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),i.end=i.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),Au([i],r);const c=jn(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Au([i],r);"remove"!=e.type||"remove"==t.type||n.aWasUndone||n.forceWeakRemove?"remove"==e.type||"remove"!=t.type||n.bWasUndone||n.forceWeakRemove||(s=!1):s=!0;const l=[],d=i.getDifference(o);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const n="same"==jn(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),i=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,n);l.push(...i)}const u=i.getIntersection(o);return null!==u&&s&&(u.start=u.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),u.end=u.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===l.length?l.push(u):1==l.length?o.start.isBefore(i.start)||o.start.isEqual(i.start)?l.unshift(u):l.push(u):l.splice(1,0,u)),0===l.length?[new Bc(e.baseVersion)]:Au(l,r)})),mu(dc,mc,((e,t,n)=>{let i=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=n.abRelation||(i=e.targetPosition._getTransformedBySplitOperation(t));const o=$s._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=i,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new $s(t.splitPosition,o.end);e=e._getTransformedBySplitOperation(t);return Au([new $s(o.start,t.splitPosition),e],i)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==n.abRelation&&(i=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==n.abRelation&&(i=e.targetPosition);const r=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const i=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&i&&!n.aWasUndone&&r.push($s._createFromPositionAndShift(t.insertionPosition,1))}return Au(r,i)})),mu(dc,pc,((e,t,n)=>{const i=$s._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(t.sourcePosition))if("remove"!=e.type||n.forceWeakRemove){if(1==e.howMany)return n.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new Bc(0)]}else if(!n.aWasUndone){const n=[];let i=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(n.push(new dc(e.sourcePosition,e.howMany-1,e.targetPosition,0)),i=i._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),s=new dc(i,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const c=new Fs(s.targetPosition.root,a);o=o._getTransformedByMove(i,r,1);const l=new dc(o,t.howMany,c,0);return n.push(s),n.push(l),n}const o=$s._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=o.start,e.howMany=o.end.offset-o.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),mu(fc,uc,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),mu(fc,pc,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),mu(fc,dc,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),mu(fc,fc,((e,t,n)=>{if(e.position.isEqual(t.position)){if(!n.aIsStrong)return[new Bc(0)];e.oldName=t.newName}return[e]})),mu(fc,mc,((e,t)=>{if("same"==jn(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new fc(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),mu(gc,gc,((e,t,n)=>{if(e.root===t.root&&e.key===t.key){if(!n.aIsStrong||e.newValue===t.newValue)return[new Bc(0)];e.oldValue=t.newValue}return[e]})),mu(mc,uc,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!n.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const n=t.graveyardPosition.path.slice();n.push(0);const i=new Fs(t.graveyardPosition.root,n),o=mc.getInsertionPosition(new Fs(t.graveyardPosition.root,n)),r=new mc(i,0,null,0);return r.insertionPosition=o,e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=mc.getInsertionPosition(e.splitPosition),e.graveyardPosition=r.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[r,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=mc.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),mu(mc,dc,((e,t,n)=>{const i=$s._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);if(!n.bWasUndone&&o){const n=e.splitPosition._getTransformedByMoveOperation(t),i=e.graveyardPosition._getTransformedByMoveOperation(t),o=i.path.slice();o.push(0);const r=new Fs(i.root,o);return[new dc(n,e.howMany,r,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=n,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new Bc(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new Bc(0)];if("splitBefore"==n.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const i="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=[];return t.howMany&&n.push(new dc(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&n.push(new dc(e.splitPosition,e.howMany,e.moveTargetPosition,0)),n}return[new Bc(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==n.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==n.baRelation){const n=t.insertionPosition.path.slice();n.push(0);const i=new Fs(t.insertionPosition.root,n);return[e,new dc(e.insertionPosition,1,i,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offsetthis.clearStack()))}refresh(){this.isEnabled=this._stack.length>0}addBatch(e){const t=this.editor.model.document.selection,n={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,n){const i=this.editor.model,o=i.document,r=[],s=e.map((e=>e.getTransformedByOperations(n))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!Su(e,a)));t.length&&(Pu(t),r.push(t[0]))}r.length&&i.change((e=>{e.setSelection(r,{backward:t})}))}_undo(e,t){const n=this.editor.model,i=n.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,r=Array.from(i.history.getOperations(o)),s=wu([e.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const o of s)t.addOperation(o),n.applyOperation(o),i.history.setOperationAsUndone(e,o)}}}function Pu(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}
+ */class Qu extends Lr{constructor(e){super(e);const t=e.document;let n=0;function i(e,n,i){const o=new yo(t,"delete",t.selection.getFirstRange());t.fire(o,new ls(t,n,i)),o.stop.called&&e.stop()}t.on("keyup",((e,t)=>{t.keyCode!=Fo.delete&&t.keyCode!=Fo.backspace||(n=0)})),t.on("keydown",((e,t)=>{const o={};if(t.keyCode==Fo.delete)o.direction="forward",o.unit="character";else{if(t.keyCode!=Fo.backspace)return;o.direction="backward",o.unit="codePoint"}const r=Bo.isMac?t.altKey:t.ctrlKey;o.unit=r?"word":o.unit,o.sequence=++n,i(e,t.domEvent,o)})),Bo.isAndroid&&t.on("beforeinput",((t,n)=>{if("deleteContentBackward"!=n.domEvent.inputType)return;const o={unit:"codepoint",direction:"backward",sequence:1},r=n.domTarget.ownerDocument.defaultView.getSelection();r.anchorNode==r.focusNode&&r.anchorOffset+1!=r.focusOffset&&(o.selectionToRemove=e.domConverter.domSelectionToView(r)),i(t,n.domEvent,o)}))}observe(){}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Eu extends Tu{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,n=this._stack.splice(t,1)[0],i=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(i,(()=>{this._undo(n.batch,i);const e=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,e),this.fire("revert",n.batch,i)})),this.refresh()}}
+ */class Yu extends Qe{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(Qu);const i=new Xu(e,"forward");if(e.commands.add("deleteForward",i),e.commands.add("forwardDelete",i),e.commands.add("delete",new Xu(e,"backward")),this.listenTo(n,"delete",((n,i)=>{const o={unit:i.unit,sequence:i.sequence};if(i.selectionToRemove){const t=e.model.createSelection(),n=[];for(const t of i.selectionToRemove.getRanges())n.push(e.editing.mapper.toModelRange(t));t.setTo(n),o.selection=t}e.execute("forward"==i.direction?"deleteForward":"delete",o),i.preventDefault(),t.scrollToTheSelection()}),{priority:"low"}),Bo.isAndroid){let e=null;this.listenTo(n,"delete",((t,n)=>{const i=n.domTarget.ownerDocument.defaultView.getSelection();e={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}}),{priority:"lowest"}),this.listenTo(n,"keyup",((t,n)=>{if(e){const t=n.domTarget.ownerDocument.defaultView.getSelection();t.collapse(e.anchorNode,e.anchorOffset),t.extend(e.focusNode,e.focusOffset),e=null}}))}}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Ru extends Tu{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(t,(()=>{const n=e.batch.operations[e.batch.operations.length-1].baseVersion+1,i=this.editor.model.document.history.getOperations(n);this._restoreSelection(e.selection.ranges,e.selection.isBackward,i),this._undo(e.batch,t)})),this.refresh()}}
+ */class Zu{constructor(){this._stack=[]}add(e,t){const n=this._stack,i=n[0];this._insertDescriptor(e);const o=n[0];i===o||eh(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}remove(e,t){const n=this._stack,i=n[0];this._removeDescriptor(e);const o=n[0];i===o||eh(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e.id));if(eh(e,t[n]))return;n>-1&&t.splice(n,1);let i=0;for(;t[i]&&th(t[i],e);)i++;t.splice(i,0,e)}_removeDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e));n>-1&&t.splice(n,1)}}function eh(e,t){return e&&t&&e.priority==t.priority&&nh(e.classes)==nh(t.classes)}function th(e,t){return e.priority>t.priority||!(e.prioritynh(t.classes)}function nh(e){return Array.isArray(e)?e.sort().join(","):e}Xe(Zu,u);var ih='';
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Iu extends Rd{static get pluginName(){return"UndoEditing"}constructor(e){super(e),this._batchRegistry=new WeakSet}init(){const e=this.editor;this._undoCommand=new Eu(e),this._redoCommand=new Ru(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const n=t[0];if(!n.isDocumentOperation)return;const i=n.batch,o=this._redoCommand._createdBatches.has(i),r=this._undoCommand._createdBatches.has(i);this._batchRegistry.has(i)||"transparent"==i.type&&!o&&!r||(o?this._undoCommand.addBatch(i):r||(this._undoCommand.addBatch(i),this._redoCommand.clearStack()),this._batchRegistry.add(i))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,n)=>{this._redoCommand.addBatch(n)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}var Ou='',Mu='';
+ */const oh="ck-widget_selected";function rh(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function sh(e,t,n={}){if(!e.is("containerElement"))throw new c.a("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass("ck-widget",e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=ph,n.label&&function(e,t,n){n.setCustomProperty("widgetLabel",t,e)}(e,n.label,t),n.hasSelectionHandle&&function(e,t){const n=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),n=new vd;return n.set("content",ih),n.render(),t.appendChild(n.element),t}));t.insert(t.createPositionAt(e,0),n),t.addClass(["ck-widget_with-selection-handle"],e)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-class Nu extends Rd{init(){const e=this.editor,t=e.locale,n=e.t,i="ltr"==t.uiLanguageDirection?Ou:Mu,o="ltr"==t.uiLanguageDirection?Mu:Ou;this._addButton("undo",n("Undo"),"CTRL+Z",i),this._addButton("redo",n("Redo"),"CTRL+Y",o)}_addButton(e,t,n,i){const o=this.editor;o.ui.componentFactory.add(e,(r=>{const s=o.commands.get(e),a=new gd(r);return a.set({label:t,icon:i,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{o.execute(e),o.editing.view.focus()})),a}))}}
+ */(e,t),lh(e,t,ah,ch),e}function ah(e,t,n){if(t.classes&&n.addClass(li(t.classes),e),t.attributes)for(const i in t.attributes)n.setAttribute(i,t.attributes[i],e)}function ch(e,t,n){if(t.classes&&n.removeClass(li(t.classes),e),t.attributes)for(const i in t.attributes)n.removeAttribute(i,e)}function lh(e,t,n,i){const o=new Zu;o.on("change:top",((t,o)=>{o.oldDescriptor&&i(e,o.oldDescriptor,o.writer),o.newDescriptor&&n(e,o.newDescriptor,o.writer)})),t.setCustomProperty("addHighlight",((e,t,n)=>o.add(t,n)),e),t.setCustomProperty("removeHighlight",((e,t,n)=>o.remove(t,n)),e)}function dh(e){const t=e.getCustomProperty("widgetLabel");return t?"function"==typeof t?t():t:""}function uh(e,t){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((n,i,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((n,i,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),e}function hh(e,t){const n=e.getSelectedElement();if(n){const i=kh(e);if(i)return t.createPositionAt(n,i);if(t.schema.isBlock(n))return t.createPositionAfter(n)}const i=e.getSelectedBlocks().next().value;if(i){if(i.isEmpty)return t.createPositionAt(i,0);const n=t.createPositionAfter(i);return e.focus.isTouching(n)?n:t.createPositionBefore(i)}return e.focus}function fh(e,t){const n=e.getSelectedElement();return!!n&&t.isObject(n)}function gh(e,t){const n=new Vs(Sr.window),i=n.getIntersection(e),o=t.height+su.arrowVerticalOffset;if(e.top-o>n.top||e.bottom+o',"image/svg+xml").firstChild,xh="ck-widget__type-around_disabled";class Ah extends Qe{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Gu,Yu]}constructor(e){super(e),this._currentFakeCaretModelElement=null}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((n,i,o)=>{t.change((e=>{for(const n of t.document.roots)o?e.removeClass(xh,n):e.addClass(xh,n)})),o||e.model.change((e=>{e.removeSelectionAttribute(mh)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const n=this.editor,i=n.editing.view;n.execute("insertParagraph",{position:n.model.createPositionAt(e,t)}),i.focus(),i.scrollToTheSelection()}_listenToIfEnabled(e,t,n,i){this.listenTo(e,t,((...e)=>{this.isEnabled&&n(...e)}),i)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=kh(e);if(!t)return!1;const n=e.getSelectedElement();return this._insertParagraph(n,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,n=e.locale.t,i={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,n,o)=>{const r=o.mapper.toViewElement(n.item);bh(r,n.item,t)&&function(e,t,n){const i=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const n=this.toDomElement(e);return function(e,t){for(const n of vh){const i=new ed({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:t[n]},children:[e.ownerDocument.importNode(yh,!0)]});e.appendChild(i.render())}}(n,t),function(e){const t=new ed({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(n),n}));e.insert(e.createPositionAt(n,"end"),i)}(o.writer,i,r)}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,n=t.document.selection,i=t.schema,o=e.editing.view;function r(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[rh,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((t,n)=>{n.directChange&&e.model.change((e=>{e.removeSelectionAttribute(mh)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=n.getSelectedElement();if(t){if(bh(e.editing.mapper.toViewElement(t),t,i))return}e.model.change((e=>{e.removeSelectionAttribute(mh)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,n)=>{const o=n.writer;if(this._currentFakeCaretModelElement){const e=n.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(vh.map(r),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!bh(a,s,i))return;const c=kh(t.selection);c&&(o.addClass(r(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,n,i)=>{i||e.model.change((e=>{e.removeSelectionAttribute(mh)}))}))}_handleArrowKeyPress(e,t){const n=this.editor,i=n.model,o=i.document.selection,r=i.schema,s=n.editing.view,a=Wo(t.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;bh(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed&&(l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a)),l&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,n=kh(t.document.selection);return t.change((t=>{if(!n)return t.setSelectionAttribute(mh,e?"after":"before"),!0;if(!(n===(e?"after":"before")))return t.removeSelectionAttribute(mh),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,n=t.model,i=n.schema,o=t.plugins.get("Widget"),r=o._getObjectElementNextToSelection(e);return!!bh(t.editing.mapper.toViewElement(r),r,i)&&(n.change((t=>{o._setSelectionOverElement(r),t.setSelectionAttribute(mh,e?"before":"after")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((n,i)=>{const o=i.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const r=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),s=function(e,t){const n=e.closest(".ck-widget");return t.mapDomToView(n)}(o,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,r),i.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,n=e.editing.view;this._listenToIfEnabled(n.document,"enter",((n,i)=>{if("atTarget"!=n.eventPhase)return;const o=t.getSelectedElement(),r=e.editing.mapper.toViewElement(o),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:bh(r,o,s)&&(this._insertParagraph(o,i.isSoft?"before":"after"),a=!0),a&&(i.preventDefault(),n.stop())}),{context:rh})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view,t=[Fo.enter,Fo.delete,Fo.backspace];this._listenToIfEnabled(e.document,"keydown",((e,n)=>{t.includes(n.keyCode)||_h(n)||this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,n=e.model,i=n.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{if("atTarget"!=t.eventPhase)return;const r=kh(n.document.selection);if(!r)return;const s=o.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)e.execute("delete",{selection:n.createSelection(a,"on")});else{const t=i.getNearestSelectionRange(n.createPositionAt(a,r),s);if(t)if(t.isCollapsed){const o=n.createSelection(t.start);if(n.modifySelection(o,{direction:s}),o.focus.isEqual(t.start)){const e=function(e,t){let n=t;for(const i of t.getAncestors({parentFirst:!0})){if(i.childCount>1||e.isLimit(i))break;n=i}return n}(i,t.start.parent);n.deleteContent(n.createSelection(e,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(t),e.execute(c?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(t),e.execute(c?"deleteForward":"delete")}))}o.preventDefault(),t.stop()}),{context:rh})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[i,o])=>{if(o&&!o.is("documentSelection"))return;const r=kh(n);return r?(e.stop(),t.change((e=>{const o=n.getSelectedElement(),s=t.createPositionAt(o,r),a=e.createSelection(s),c=t.insertContent(i,a);return e.setSelection(a),c}))):void 0}),{priority:"high"})}}n(65);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-class Bu{constructor(e){this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}On(Bu,Yi);
+ */function Ch(e){const t=e.model;return(n,i)=>{const o=i.keyCode==Fo.arrowup,r=i.keyCode==Fo.arrowdown,s=i.shiftKey,a=t.document.selection;if(!o&&!r)return;const c=r;if(s&&function(e,t){return!e.isCollapsed&&e.isBackward==t}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */(a,c))return;const l=function(e,t,n){const i=e.model;if(n){const e=t.isCollapsed?t.focus:t.getLastPosition(),n=Th(i,e,"forward");if(!n)return null;const o=i.createRange(e,n),r=Ph(i.schema,o,"backward");return r&&e.isBefore(r)?i.createRange(e,r):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),n=Th(i,e,"backward");if(!n)return null;const o=i.createRange(n,e),r=Ph(i.schema,o,"forward");return r&&e.isAfter(r)?i.createRange(r,e):null}}(e,a,c);l&&!l.isCollapsed&&function(e,t,n){const i=e.model,o=e.view.domConverter;if(n){const e=i.createSelection(t.start);i.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=i.createRange(e.focus,t.end))}const r=e.mapper.toViewRange(t),s=o.viewRangeToDom(r),a=Vs.getDomRangeRects(s);let c;for(const e of a)if(void 0!==c){if(Math.round(e.top)>=c)return!1;c=Math.max(c,Math.round(e.bottom))}else c=Math.round(e.bottom);return!0}(e,l,c)&&(t.change((e=>{const n=c?l.end:l.start;if(s){const i=t.createSelection(a.anchor);i.setFocus(n),e.setSelection(i)}else e.setSelection(n)})),n.stop(),i.preventDefault(),i.stopPropagation())}}function Th(e,t,n){const i=e.schema,o=e.createRangeIn(t.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of o.getWalker({startPosition:t,direction:n})){if(i.isLimit(s)&&!i.isInline(s))return e;if(a==r&&i.isBlock(s))return null}return null}function Ph(e,t,n){const i="backward"==n?t.end:t.start;if(e.checkChild(i,"$text"))return i;for(const{nextPosition:i}of t.getWalker({direction:n}))if(e.checkChild(i,"$text"))return i}class Sh extends Qe{static get pluginName(){return"Widget"}static get requires(){return[Ah,Yu]}init(){const e=this.editor.editing.view,t=e.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((e,t,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const i=n.writer,o=i.document.selection,r=o.getSelectedElement();let s=null;for(const e of o.getRanges())for(const t of e){const e=t.item;rh(e)&&!Eh(e,s)&&(i.addClass(oh,e),this._previouslySelected.add(e),s=e,e==r&&i.setSelection(o.getRanges(),{fake:!0,label:dh(r)}))}}),{priority:"low"}),e.addObserver(Nu),this.listenTo(t,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(t,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[rh,"$text"]}),this.listenTo(t,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(t,"arrowKey",Ch(this.editor.editing),{context:"$text"}),this.listenTo(t,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const n=this.editor,i=n.editing.view,o=i.document;let r=t.target;if(function(e){for(;e;){if(e.is("editableElement")&&!e.is("rootElement"))return!0;if(rh(e))return!1;e=e.parent}return!1}(r)){if((Bo.isSafari||Bo.isGecko)&&t.domEvent.detail>=3){const e=n.editing.mapper,i=r.is("attributeElement")?r.findAncestor((e=>!e.is("attributeElement"))):r,o=e.toModelElement(i);t.preventDefault(),this.editor.model.change((e=>{e.setSelection(o,"in")}))}return}if(!rh(r)&&(r=r.findAncestor(rh),!r))return;Bo.isAndroid&&t.preventDefault(),o.isFocused||i.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(e,t){const n=t.keyCode,i=this.editor.model,o=i.schema,r=i.document.selection,s=r.getSelectedElement(),a=Wo(n,this.editor.locale.contentLanguageDirection);if(s&&o.isObject(s)){const n=a?r.getLastPosition():r.getFirstPosition(),s=o.getNearestSelectionRange(n,a?"forward":"backward");return void(s&&(i.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed)return;const c=this._getObjectElementNextToSelection(a);c&&o.isObject(c)&&(this._setSelectionOverElement(c),t.preventDefault(),e.stop())}_preventDefaultOnArrowKeyPress(e,t){const n=this.editor.model,i=n.schema,o=n.document.selection.getSelectedElement();o&&i.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){if(this.editor.isReadOnly)return;const t=this.editor.model.document.selection;if(!t.isCollapsed)return;const n=this._getObjectElementNextToSelection(e);return n?(this.editor.model.change((e=>{let i=t.anchor.parent;for(;i.isEmpty;){const t=i;i=t.parent,e.remove(t)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,n=t.schema,i=t.document.selection,o=t.createSelection(i);t.modifySelection(o,{direction:e?"forward":"backward"});const r=e?o.focus.nodeBefore:o.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(oh,t);this._previouslySelected.clear()}}function Eh(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}var Rh=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return w(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),As(e,t,{leading:i,maxWait:t,trailing:o})};n(67);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Du extends Bu{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Mn({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new _n.a("pendingactions-add-invalid-message",this);const t=Object.create(Yi);return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}
+class Ih extends Qe{static get pluginName(){return"DragDrop"}static get requires(){return[Hu,Sh]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=Rh((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=Nh((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=Nh((()=>this._clearDraggableAttributes()),40),t.addObserver(Lu),t.addObserver(Nu),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,n)=>{n||this._finalizeDragging(!1)})),Bo.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,n=t.document,i=e.editing.view,o=i.document;this.listenTo(o,"dragstart",((i,r)=>{const a=n.selection;if(r.target&&r.target.is("rootElement"))return void r.preventDefault();const c=r.target?Vh(r.target):null;if(c){const n=e.editing.mapper.toModelElement(c);this._draggedRange=Ta.fromRange(t.createRangeOn(n))}else if(!o.selection.isCollapsed){const e=o.selection.getSelectedElement();e&&rh(e)||(this._draggedRange=Ta.fromRange(a.getFirstRange()))}if(!this._draggedRange)return void r.preventDefault();this._draggingUid=s(),r.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",r.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const l=t.createSelection(this._draggedRange.toRange()),d=e.data.toView(t.getSelectedContent(l));o.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:d,method:i.name}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&i.focus()})),this.listenTo(o,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((t,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const i=Oh(e,n.targetRanges,n.target);this._draggedRange||(n.dataTransfer.dropEffect="copy"),Bo.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),i&&this._updateDropMarkerThrottled(i)}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const i=Oh(e,n.targetRanges,n.target);if(this._removeDropMarker(),!i)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==Mh(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(i,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(i)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Hu);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(n)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n="move"==Mh(t.dataTransfer),i=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(i&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,n=t.document;this.listenTo(n,"mousedown",((i,o)=>{if(Bo.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=Vh(o.target);if(Bo.isBlink&&!r&&!n.selection.isCollapsed){const e=n.selection.getSelectedElement();e&&rh(e)||(r=n.selection.editableElement)}r&&(t.change((e=>{e.setAttribute("draggable","true",r)})),this._draggableElement=e.editing.mapper.toModelElement(r))})),this.listenTo(n,"mouseup",(()=>{Bo.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_setupDropMarker(){const e=this.editor;e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:n})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.innerHTML="⁠⁠",t}))}})}_updateDropMarker(e){const t=this.editor,n=t.model.markers;t.model.change((t=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_finalizeDragging(e){const t=this.editor.model;this._removeDropMarker(),this._clearDraggableAttributes(),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&t.deleteContent(t.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function Oh(e,t,n){const i=e.model,o=e.editing.mapper;let r=null;const s=t?t[0].start:null;if(n.is("uiElement")&&(n=n.parent),r=function(e,t){const n=e.model,i=e.editing.mapper;if(rh(t))return n.createRangeOn(i.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>rh(e)||e.is("editableElement")));if(rh(e))return n.createRangeOn(i.toModelElement(e))}return null}(e,n),r)return r;const a=function(e,t){const n=e.editing.mapper,i=e.editing.view,o=n.toModelElement(t);if(o)return o;const r=i.createPositionBefore(t),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(e,n),c=s?o.toModelPosition(s):null;return c?(r=function(e,t,n){const i=e.model;if(!i.schema.checkChild(n,"$block"))return null;const o=i.createPositionAt(n,0),r=t.path.slice(0,o.path.length),s=i.createPositionFromPath(t.root,r).nodeAfter;if(s&&i.schema.isObject(s))return i.createRangeOn(s);return null}(e,c,a),r||(r=i.schema.getNearestSelectionRange(c,Bo.isGecko?"forward":"backward"),r||function(e,t){const n=e.model;for(;t;){if(n.schema.isObject(t))return n.createRangeOn(t);t=t.parent}}(e,c.parent))):function(e,t){const n=e.model,i=n.schema,o=n.createPositionAt(t,0);return i.getNearestSelectionRange(o,"forward")}(e,a)}function Mh(e){return Bo.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Nh(e,t){let n;function i(...o){i.cancel(),n=setTimeout((()=>e(...o)),t)}return i.cancel=()=>{clearTimeout(n)},i}function Vh(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(rh);if(rh(e))return e;const t=e.findAncestor((e=>rh(e)||e.is("editableElement")));return rh(t)?t:null}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Fu{constructor(){const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((n,i)=>{t.onload=()=>{const e=t.result;this._data=e,n(e)},t.onerror=()=>{i("error")},t.onabort=()=>{i("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}}On(Fu,Yi);
+ */class Bh extends Qe{static get pluginName(){return"PastePlainText"}static get requires(){return[Hu]}init(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document,o=t.document.selection;let r=!1;n.addObserver(Lu),this.listenTo(i,"keydown",((e,t)=>{r=t.shiftKey})),e.plugins.get(Hu).on("contentInsertion",((e,n)=>{(r||function(e,t){if(e.childCount>1)return!1;const n=e.getChild(0);if(t.isObject(n))return!1;return 0==[...n.getAttributeKeys()].length}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-class zu extends Rd{static get pluginName(){return"FileRepository"}static get requires(){return[Du]}init(){this.loaders=new Mn,this.loaders.on("add",(()=>this._updatePendingAction())),this.loaders.on("remove",(()=>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",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return Object(_n.c)("filerepository-no-upload-adapter"),null;const t=new Lu(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof Lu?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,n)=>{e===t&&this._loadersMap.delete(n)}))}_updatePendingAction(){const e=this.editor.plugins.get(Du);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,n=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(n(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else e.remove(this._pendingAction),this._pendingAction=null}}On(zu,Yi);class Lu{constructor(e,t){this.id=kn(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new Fu,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new _n.a("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new _n.a("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((n,i)=>{t.rejecter=i,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,n(e)})).catch((e=>{t.isFulfilled=!0,i(e)}))})),t}}On(Lu,Yi);
+ */(n.content,t.schema))&&t.change((e=>{const i=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),i.push(...o.getAttributes());const r=e.createRangeIn(n.content);for(const t of r.getItems())t.is("$textProxy")&&e.setAttributes(i,t)}))}))}}class Dh extends Qe{static get pluginName(){return"Clipboard"}static get requires(){return[Hu,Ih,Bh]}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const ju="ckCsrfToken",$u="abcdefghijklmnopqrstuvwxyz0123456789";function Hu(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const n of t){const t=n.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(ju);var t,n;return e&&40==e.length||(e=function(e){let t="";const n=new Uint8Array(e);window.crypto.getRandomValues(n);for(let e=0;e.5?i.toUpperCase():i}return t}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(40),t=ju,n=e,document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(n)+";path=/"),e}class qu extends Rd{static get requires(){return[zu]}static get pluginName(){return"CKFinderUploadAdapter"}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(zu).createUploadAdapter=t=>new Wu(t,e,this.editor.t))}}class Wu{constructor(e,t,n){this.loader=e,this.url=t,this.t=n}upload(){return this.loader.file.then((e=>new Promise(((t,n)=>{this._initRequest(),this._initListeners(t,n,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,n){const i=this.xhr,o=this.loader,r=(0,this.t)("Cannot upload file:")+` ${n.name}.`;i.addEventListener("error",(()=>t(r))),i.addEventListener("abort",(()=>t())),i.addEventListener("load",(()=>{const n=i.response;if(!n||!n.uploaded)return t(n&&n.error&&n.error.message?n.error.message:r);e({default:n.url})})),i.upload&&i.upload.addEventListener("progress",(e=>{e.lengthComputable&&(o.uploadTotal=e.total,o.uploaded=e.loaded)}))}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",Hu()),this.xhr.send(t)}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Uu(e){const t=e.next();return t.done?null:t.value}
+ */class zh extends Ze{execute(){const e=this.editor.model,t=e.document;e.change((n=>{!function(e,t,n){const i=n.isCollapsed,o=n.getFirstRange(),r=o.start.parent,s=o.end.parent,a=r==s;if(i){const i=qu(e.schema,n.getAttributes());Fh(e,t,o.end),t.removeSelectionAttribute(n.getAttributeKeys()),t.setSelectionAttribute(i)}else{const i=!(o.start.isAtStart&&o.end.isAtEnd);e.deleteContent(n,{leaveUnmerged:i}),a?Fh(e,t,n.focus):i&&t.setSelection(s,0)}}(e,n,t.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const n=t.anchor;if(!n||!e.checkChild(n,"softBreak"))return!1;const i=t.getFirstRange(),o=i.start.parent,r=i.end.parent;if((Lh(o,e)||Lh(r,e))&&o!==r)return!1;return!0}(e.schema,t.selection)}}function Fh(e,t,n){const i=t.createElement("softBreak");e.insertContent(i,n),t.setSelection(i,"after")}function Lh(e,t){return!e.is("rootElement")&&(t.isLimit(e)||Lh(e.parent,t))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Ku(e,t,n,i){let o,r=null;"function"==typeof i?o=i:(r=e.commands.get(i),o=()=>{e.execute(i)}),e.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!t.isEnabled)return;const c=Uu(e.model.document.selection.getRanges());if(!c.isCollapsed)return;if("transparent"==a.type)return;const l=Array.from(e.model.document.differ.getChanges()),d=l[0];if(1!=l.length||"insert"!==d.type||"$text"!=d.name||1!=d.length)return;const u=d.position.parent;if(u.is("element","codeBlock"))return;if(u.is("element","listItem")&&!["numberedList","bulletedList","todoList"].includes(i))return;if(r&&!0===r.value)return;const h=u.getChild(0),f=e.model.createRangeOn(h);if(!f.containsRange(c)&&!c.end.isEqual(f.end))return;const g=n.exec(h.data.substr(0,c.end.offset));g&&e.model.enqueueChange((t=>{const n=t.createPositionAt(u,0),i=t.createPositionAt(u,g[0].length),r=new ta(n,i);if(!1!==o({match:g})){t.remove(r);const n=e.model.document.selection.getFirstRange(),i=t.createRangeIn(u);!u.isEmpty||i.isEqual(n)||i.containsRange(n,!0)||t.remove(u)}r.detach()}))}))}
+ */class jh extends Qe{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,n=e.conversion,i=e.editing.view,o=i.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),i.addObserver(Ku),e.commands.add("shiftEnter",new zh(e)),this.listenTo(o,"enter",((t,n)=>{n.preventDefault(),n.isSoft&&(e.execute("shiftEnter"),i.scrollToTheSelection())}),{priority:"low"})}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Gu(e,t,n,i){let o,r;n instanceof RegExp?o=n:r=n,r=r||(e=>{let t;const n=[],i=[];for(;null!==(t=o.exec(e))&&!(t&&t.length<4);){let{index:e,1:o,2:r,3:s}=t;const a=o+r+s;e+=t[0].length-a.length;const c=[e,e+o.length],l=[e+o.length+r.length,e+o.length+r.length+s.length];n.push(c),n.push(l),i.push([e+o.length,e+o.length+r.length])}return{remove:n,format:i}}),e.model.document.on("change:data",((n,o)=>{if("transparent"==o.type||!t.isEnabled)return;const s=e.model,a=s.document.selection;if(!a.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const d=a.focus,u=d.parent,{text:h,range:f}=function(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>!i.is("$text")&&!i.is("$textProxy")||i.getAttribute("code")?(n=t.createPositionAfter(i),""):e+i.data),""),range:t.createRange(n,e.end)}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(s.createRange(s.createPositionAt(u,0),d),s),g=r(h),p=Ju(f.start,g.format,s),m=Ju(f.start,g.remove,s);p.length&&m.length&&s.enqueueChange((e=>{if(!1!==i(e,p))for(const t of m.reverse())e.remove(t)}))}))}function Ju(e,t,n){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>n.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}function Xu(e,t){return(n,i)=>{if(!e.commands.get(t).isEnabled)return!1;const o=e.model.schema.getValidRanges(i,t);for(const e of o)n.setAttribute(t,!0,e);n.removeSelectionAttribute(t)}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Qu extends Fd{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,n=t.document.selection,i=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(n.isCollapsed)i?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const t of o)i?e.setAttribute(this.attributeKey,i,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,this.attributeKey))return n.hasAttribute(this.attributeKey);return!1}}
+ */class $h extends Ze{execute(){const e=this.editor.model,t=e.document.selection;let n=e.schema.getLimitElement(t);if(t.containsEntireContent(n)||!Hh(e.schema,n))do{if(n=n.parent,!n)return}while(!Hh(e.schema,n));e.change((e=>{e.setSelection(n,"in")}))}}function Hh(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const Yu="bold";class Zu extends Rd{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Yu}),e.model.schema.setAttributeProperties(Yu,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Yu,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t?"bold"==t||Number(t)>=600?{name:!0,styles:["font-weight"]}:void 0:null}]}),e.commands.add(Yu,new Qu(e,Yu)),e.keystrokes.set("CTRL+B",Yu)}}
+ */const qh=$o("Ctrl+A");class Wh extends Qe{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new $h(e)),this.listenTo(t,"keydown",((t,n)=>{jo(n)===qh&&(e.execute("selectAll"),n.preventDefault())}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const eh="bold";class th extends Rd{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(eh,(n=>{const i=e.commands.get(eh),o=new gd(n);return o.set({label:t("Bold"),icon:'',keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(eh),e.editing.view.focus()})),o}))}}
+class Uh extends Qe{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const n=e.commands.get("selectAll"),i=new xd(t),o=t.t;return i.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),i.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),i}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
+ */class Kh extends Qe{static get requires(){return[Wh,Uh]}static get pluginName(){return"SelectAll"}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const nh="italic";class ih extends Rd{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:nh}),e.model.schema.setAttributeProperties(nh,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:nh,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(nh,new Qu(e,nh)),e.keystrokes.set("CTRL+I",nh)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const oh="italic";class rh extends Rd{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(oh,(n=>{const i=e.commands.get(oh),o=new gd(n);return o.set({label:t("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(oh),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
+ */class Gh extends Ze{constructor(e,t){super(e),this._buffer=new Ju(e.model,t),this._batches=new WeakSet}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,n=t.document,i=e.text||"",o=i.length,r=e.range?t.createSelection(e.range):n.selection,s=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock(),this._batches.add(this._buffer.batch),t.deleteContent(r),i&&t.insertContent(e.createText(i,n.selection.getAttributes()),r),s?e.setSelection(s):r.is("documentSelection")||e.setSelection(r),this._buffer.unlock(),this._buffer.input(o)}))}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */function Jh(e){if(e.newChildren.length-e.oldChildren.length!=1)return;const t=function(e,t){const n=[];let i,o=0;return e.forEach((e=>{"equal"==e?(r(),o++):"insert"==e?(s("insert")?i.values.push(t[o]):(r(),i={type:"insert",index:o,values:[t[o]]}),o++):s("delete")?i.howMany++:(r(),i={type:"delete",index:o,howMany:1})})),r(),n;function r(){i&&(n.push(i),i=null)}function s(e){return i&&i.type==e}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */(_r(e.oldChildren,e.newChildren,Xh),e.newChildren);if(t.length>1)return;const n=t[0];return n.values[0]&&n.values[0].is("$text")?n:void 0}function Xh(e,t){return e&&e.is("$text")&&t&&t.is("$text")?e.data===t.data:e===t}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class Qh{constructor(e){this.editor=e,this.editing=this.editor.editing}handle(e,t){if(function(e){if(0==e.length)return!1;for(const t of e)if("children"===t.type&&!Jh(t))return!0;return!1}(e))this._handleContainerChildrenMutations(e,t);else for(const n of e)this._handleTextMutation(n,t),this._handleTextNodeInsertion(n)}_handleContainerChildrenMutations(e,t){const n=function(e){const t=e.map((e=>e.node)).reduce(((e,t)=>e.getCommonAncestor(t,{includeSelf:!0})));if(!t)return;return t.getAncestors({includeSelf:!0,parentFirst:!0}).find((e=>e.is("containerElement")||e.is("rootElement")))}(e);if(!n)return;const i=this.editor.editing.view.domConverter.mapViewToDom(n),o=new Or(this.editor.editing.view.document),r=this.editor.data.toModel(o.domToView(i)).getChild(0),s=this.editor.editing.mapper.toModelElement(n);if(!s)return;const a=Array.from(r.getChildren()),c=Array.from(s.getChildren()),l=a[a.length-1],d=c[c.length-1],u=l&&l.is("element","softBreak"),h=d&&!d.is("element","softBreak");u&&h&&a.pop();const f=this.editor.model.schema;if(!Yh(a,f)||!Yh(c,f))return;const g=a.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," "),p=c.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," ");if(p===g)return;const m=_r(p,g),{firstChangeAt:b,insertions:k,deletions:w}=Zh(m);let _=null;t&&(_=this.editing.mapper.toModelRange(t.getFirstRange()));const v=g.substr(b,k),y=this.editor.model.createRange(this.editor.model.createPositionAt(s,b),this.editor.model.createPositionAt(s,b+w));this.editor.execute("input",{text:v,range:y,resultRange:_})}_handleTextMutation(e,t){if("text"!=e.type)return;const n=e.newText.replace(/\u00A0/g," "),i=e.oldText.replace(/\u00A0/g," ");if(i===n)return;const o=_r(i,n),{firstChangeAt:r,insertions:s,deletions:a}=Zh(o);let c=null;t&&(c=this.editing.mapper.toModelRange(t.getFirstRange()));const l=this.editing.view.createPositionAt(e.node,r),d=this.editing.mapper.toModelPosition(l),u=this.editor.model.createRange(d,d.getShiftedBy(a)),h=n.substr(r,s);this.editor.execute("input",{text:h,range:u,resultRange:c})}_handleTextNodeInsertion(e){if("children"!=e.type)return;const t=Jh(e),n=this.editing.view.createPositionAt(e.node,t.index),i=this.editing.mapper.toModelPosition(n),o=t.values[0].data;this.editor.execute("input",{text:o.replace(/\u00A0/g," "),range:this.editor.model.createRange(i)})}}function Yh(e,t){return e.every((e=>t.isInline(e)))}function Zh(e){let t=null,n=null;for(let i=0;i{n.deleteContent(n.document.selection)})),e.unlock()}Bo.isAndroid?i.document.on("beforeinput",((e,t)=>r(t)),{priority:"lowest"}):i.document.on("keydown",((e,t)=>r(t)),{priority:"lowest"}),i.document.on("compositionstart",(function(){const e=n.document,t=1!==e.selection.rangeCount||e.selection.getFirstRange().isFlat;e.selection.isCollapsed||t||s()}),{priority:"lowest"}),i.document.on("compositionend",(()=>{t=n.createSelection(n.document.selection)}),{priority:"lowest"})}(e),function(e){e.editing.view.document.on("mutations",((t,n,i)=>{new Qh(e).handle(n,i)}))}(e)}isInput(e){return this.editor.commands.get("input")._batches.has(e)}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class tf extends Qe{static get requires(){return[ef,Yu]}static get pluginName(){return"Typing"}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */function nf(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>i.is("$text")||i.is("$textProxy")?e+i.data:(n=t.createPositionAfter(i),"")),""),range:t.createRange(n,e.end)}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class of{constructor(e,t){this.model=e,this.testCallback=t,this.hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))})),this._startListening()}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:n})=>{n&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this.hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{"transparent"!=t.type&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const n=this.model,i=n.document.selection,o=n.createRange(n.createPositionAt(i.focus.parent,0),i.focus),{text:r,range:s}=nf(o,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this.hasMatch=!!a,a){const n=Object.assign(t,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${e}`,n)}}}Xe(of,qe);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const sh="underline";class ah extends Rd{static get pluginName(){return"UnderlineEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:sh}),e.model.schema.setAttributeProperties(sh,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:sh,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(sh,new Qu(e,sh)),e.keystrokes.set("CTRL+U","underline")}}
+class rf extends Qe{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,n=e.editing.view,i=e.locale,o=t.document.selection;this.listenTo(n.document,"arrowKey",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const n=t.keyCode==Fo.arrowright,r=t.keyCode==Fo.arrowleft;if(!n&&!r)return;const s=i.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&r?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(o,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&lf(o.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,n=this.editor.model.document.selection,i=n.getFirstPosition();return!this._isGravityOverridden&&((!i.isAtStart||!sf(n,t))&&(lf(i,t)?(cf(e),this._overrideGravity(),!0):void 0))}_handleBackwardMovement(e){const t=this.attributes,n=this.editor.model,i=n.document.selection,o=i.getFirstPosition();return this._isGravityOverridden?(cf(e),this._restoreGravity(),af(n,t,o),!0):o.isAtStart?!!sf(i,t)&&(cf(e),af(n,t,o),!0):function(e,t){return lf(e.getShiftedBy(-1),t)}(o,t)?o.isAtEnd&&!sf(i,t)&&lf(o,t)?(cf(e),af(n,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):void 0}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((e=>e.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function sf(e,t){for(const n of t)if(e.hasAttribute(n))return!0;return!1}function af(e,t,n){const i=n.nodeBefore;e.change((e=>{i?e.setSelectionAttribute(i.getAttributes()):e.removeSelectionAttribute(t)}))}function cf(e){e.preventDefault()}function lf(e,t){const{nodeBefore:n,nodeAfter:i}=e;for(const e of t){const t=n?n.getAttribute(e):void 0;if((i?i.getAttribute(e):void 0)!==t)return!0}return!1}var df=/[\\^$.*+?()[\]{}|]/g;RegExp(df.source);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const ch="underline";class lh extends Rd{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(ch,(n=>{const i=e.commands.get(ch),o=new gd(n);return o.set({label:t("Underline"),icon:'',keystroke:"CTRL+U",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(ch),e.editing.view.focus()})),o}))}}
+uf('"'),uf("'"),uf("'"),uf('"'),uf('"'),uf("'");function uf(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
+function hf(e,t,n,i){return i.createRange(ff(e,t,n,!0,i),ff(e,t,n,!1,i))}function ff(e,t,n,i,o){let r=e.textNode||(i?e.nodeBefore:e.nodeAfter),s=null;for(;r&&r.getAttribute(t)==n;)s=r,r=i?r.previousSibling:r.nextSibling;return s?o.createPositionAt(s,i?"before":"after"):e}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const dh="strikethrough";class uh extends Rd{static get pluginName(){return"StrikethroughEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:dh}),e.model.schema.setAttributeProperties(dh,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:dh,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(dh,new Qu(e,dh)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const hh="strikethrough";class fh extends Rd{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(hh,(n=>{const i=e.commands.get(hh),o=new gd(n);return o.set({label:t("Strikethrough"),icon:'',keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(hh),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1000,59 +1123,63 @@ const hh="strikethrough";class fh extends Rd{init(){const e=this.editor,t=e.t;e.
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-function gh(e){const t=e.t,n=e.config.get("codeBlock.languages");for(const e of n)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return n}function ph(e,t,n){const i={};for(const o of e)"class"===t?i[o[t].split(" ").shift()]=o[n]:i[o[t]]=o[n];return i}function mh(e){return e.data.match(/^(\s*)/)[0]}function bh(e,t){const n=e.createDocumentFragment(),i=t.split("\n").map((t=>e.createText(t))),o=i[i.length-1];for(const t of i)e.append(t,n),t!==o&&e.appendElement("softBreak",n);return n}function kh(e){const t=e.document.selection,n=[];if(t.isCollapsed)n.push(t.anchor);else{const i=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of i)if(t.is("$textProxy")&&t.parent.is("element","codeBlock")){const i=mh(t.textNode),{parent:o,startOffset:r}=t.textNode,s=e.createPositionAt(o,r+i.length);n.push(s)}}return n}function wh(e){const t=Uu(e.getSelectedBlocks());return t&&t.is("element","codeBlock")}
+class gf extends Ze{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(e.data,"set",(()=>this.clearStack()))}refresh(){this.isEnabled=this._stack.length>0}addBatch(e){const t=this.editor.model.document.selection,n={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,n){const i=this.editor.model,o=i.document,r=[],s=e.map((e=>e.getTransformedByOperations(n))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!mf(e,a)));t.length&&(pf(t),r.push(t[0]))}r.length&&i.change((e=>{e.setSelection(r,{backward:t})}))}_undo(e,t){const n=this.editor.model,i=n.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,r=Array.from(i.history.getOperations(o)),s=Tu([e.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const o of s)t.addOperation(o),n.applyOperation(o),i.history.setOperationAsUndone(e,o)}}}function pf(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class bf extends gf{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,n=this._stack.splice(t,1)[0],i=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(i,(()=>{this._undo(n.batch,i);const e=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,e),this.fire("revert",n.batch,i)})),this.refresh()}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class _h extends Fd{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,n=t.model,i=n.document.selection,o=gh(t)[0],r=Array.from(i.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue,a=e.language||o.language;n.change((e=>{s?this._applyCodeBlock(e,r,a):this._removeCodeBlock(e,r)}))}_getValue(){const e=Uu(this.editor.model.document.selection.getSelectedBlocks());return!!!(!e||!e.is("element","codeBlock"))&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=Uu(e.getSelectedBlocks());return!!n&&vh(t,n)}_applyCodeBlock(e,t,n){const i=this.editor.model.schema,o=t.filter((e=>vh(i,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",n,t),i.removeDisallowedAttributes([t],e);o.reverse().forEach(((t,n)=>{const i=o[n+1];t.previousSibling===i&&(e.appendElement("softBreak",i),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const n=t.filter((e=>e.is("element","codeBlock")));for(const t of n){const n=e.createRangeOn(t);for(const t of Array.from(n.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:n}=e.split(e.createPositionBefore(t));e.rename(n.nodeAfter,"paragraph"),e.removeAttribute("language",n.nodeAfter),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}function vh(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}
+ */class kf extends gf{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(t,(()=>{const n=e.batch.operations[e.batch.operations.length-1].baseVersion+1,i=this.editor.model.document.history.getOperations(n);this._restoreSelection(e.selection.ranges,e.selection.isBackward,i),this._undo(e.batch,t)})),this.refresh()}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class yh extends Fd{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const n=kh(e);for(const e of n)t.insertText(this._indentSequence,e)}))}_checkEnabled(){return!!this._indentSequence&&wh(this.editor.model.document.selection)}}
+ */class wf extends Qe{static get pluginName(){return"UndoEditing"}constructor(e){super(e),this._batchRegistry=new WeakSet}init(){const e=this.editor;this._undoCommand=new bf(e),this._redoCommand=new kf(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const n=t[0];if(!n.isDocumentOperation)return;const i=n.batch,o=this._redoCommand._createdBatches.has(i),r=this._undoCommand._createdBatches.has(i);this._batchRegistry.has(i)||"transparent"==i.type&&!o&&!r||(o?this._undoCommand.addBatch(i):r||(this._undoCommand.addBatch(i),this._redoCommand.clearStack()),this._batchRegistry.add(i))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,n)=>{this._redoCommand.addBatch(n)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}var _f='',vf='';
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class xh extends Fd{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const n=kh(e);for(const e of n){const n=Ch(this.editor.model,e,this._indentSequence);n&&t.remove(n)}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!wh(e.document.selection)&&kh(e).some((t=>Ch(e,t,this._indentSequence)))}}function Ch(e,t,n){const i=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}
+ */
+class yf extends Qe{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,n=e.t,i="ltr"==t.uiLanguageDirection?_f:vf,o="ltr"==t.uiLanguageDirection?vf:_f;this._addButton("undo",n("Undo"),"CTRL+Z",i),this._addButton("redo",n("Redo"),"CTRL+Y",o)}_addButton(e,t,n,i){const o=this.editor;o.ui.componentFactory.add(e,(r=>{const s=o.commands.get(e),a=new xd(r);return a.set({label:t,icon:i,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{o.execute(e),o.editing.view.focus()})),a}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(t);if(!i)return null;const o=mh(i),r=o.lastIndexOf(n);if(r+n.length!==o.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=i;return e.createRange(e.createPositionAt(s,a+r),e.createPositionAt(s,a+r+n.length))}function Ah(e,t,n=!1){const i=ph(t,"language","class"),o=ph(t,"language","label");return(t,r,s)=>{const{writer:a,mapper:c,consumable:l}=s;if(!l.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=c.toViewPosition(e.createPositionBefore(r.item)),h={};n&&(h["data-language"]=o[d],h.spellcheck="false");const f=a.createContainerElement("pre",h),g=a.createContainerElement("code",{class:i[d]||null});a.insert(a.createPositionAt(f,0),g),a.insert(u,f),c.bindElements(r.item,g)}}
+ */class xf extends Qe{static get requires(){return[wf,yf]}static get pluginName(){return"Undo"}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const Th="paragraph";class Ph extends Rd{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Gd]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,n=e.model,i=gh(e);e.commands.add("codeBlock",new _h(e)),e.commands.add("indentCodeBlock",new yh(e)),e.commands.add("outdentCodeBlock",new xh(e));const o=e=>(t,n)=>{this.editor.commands.get(e).isEnabled&&(this.editor.execute(e),n())};e.keystrokes.set("Tab",o("indentCodeBlock")),e.keystrokes.set("Shift+Tab",o("outdentCodeBlock")),t.register("codeBlock",{allowWhere:"$block",isBlock:!0,allowAttributes:["language"]}),t.extend("$text",{allowIn:"codeBlock"}),t.addAttributeCheck((e=>{if(e.endsWith("codeBlock $text"))return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",Ah(n,i,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Ah(n,i)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,n,i)=>{if("codeBlock"!==n.item.parent.name)return;const{writer:o,mapper:r,consumable:s}=i;if(!s.consume(n.item,"insert"))return;const a=r.toViewPosition(e.createPositionBefore(n.item));o.insert(a,o.createText("\n"))}}(n),{priority:"high"}),e.data.upcastDispatcher.on("element:pre",function(e,t){const n=ph(t,"class","language"),i=t[0].language;return(t,o,r)=>{const s=o.viewItem,a=s.getChild(0);if(!a||!a.is("element","code"))return;const{consumable:c,writer:l}=r;if(!c.test(s,{name:!0})||!c.test(a,{name:!0}))return;const d=l.createElement("codeBlock"),u=[...a.getClassNames()];u.length||u.push("");for(const e of u){const t=n[e];if(t){l.setAttribute("language",t,d);break}}d.hasAttribute("language")||l.setAttribute("language",i,d);const h=bh(l,[...e.createRangeIn(a)].filter((e=>"text"===e.type)).map((({item:e})=>e.data)).join(""));l.append(h,d),r.safeInsert(d,o.modelCursor)&&(c.consume(s,{name:!0}),c.consume(a,{name:!0}),r.updateConversionResult(d,o))}}(e.editing.view,i)),this.listenTo(e.editing.view.document,"clipboardInput",((e,t)=>{const i=n.document.selection;if(!i.anchor.parent.is("element","codeBlock"))return;const o=t.dataTransfer.getData("text/plain");n.change((t=>{n.insertContent(bh(t,o),i),e.stop()}))})),this.listenTo(n,"getSelectedContent",((e,[i])=>{const o=i.anchor;!i.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(i.focus)&&n.change((n=>{const r=e.return;if(r.childCount>1||i.containsEntireContent(o.parent)){const t=n.createElement("codeBlock",o.parent.getAttributes());n.append(r,t);const i=n.createDocumentFragment();n.append(t,i),e.return=i}else{const e=r.getChild(0);t.checkAttribute(e,"code")&&n.setAttribute("code",!0,e)}}))}))}afterInit(){const e=this.editor,t=e.commands,n=t.get("indent"),i=t.get("outdent");n&&n.registerChildCommand(t.get("indentCodeBlock")),i&&i.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,n)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const n=e.model.document,i=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeAfter;if(t||!n.selection.isCollapsed||!o.isAtStart)return!1;if(!r||!r.is("element","softBreak"))return!1;return e.model.change((t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,Th),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)})),i.scrollToTheSelection(),!0}(e,n.isSoft)||function(e,t){const n=e.model,i=n.document,o=e.editing.view,r=i.selection.getLastPosition(),s=r.nodeBefore;let a;if(t||!i.selection.isCollapsed||!r.isAtEnd||!s)return!1;if(s.is("element","softBreak"))a=n.createRangeOn(s);else{if(!s.is("$text")||s.data.match(/\S/)||!s.previousSibling||!s.previousSibling.is("element","softBreak"))return!1;a=n.createRange(n.createPositionBefore(s.previousSibling),n.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const n=i.selection.anchor.parent;t.rename(n,Th),e.model.schema.removeDisallowedAttributes([n],t)})),o.scrollToTheSelection(),!0}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(e,n.isSoft)||function(e){const t=e.model.document,n=t.selection.getLastPosition(),i=n.nodeBefore||n.textNode;let o;i&&i.is("$text")&&(o=mh(i));e.model.change((n=>{e.execute("shiftEnter"),o&&n.insertText(o,t.selection.anchor)}))}(e),n.preventDefault(),t.stop())}))}}class Sh{constructor(e,t){t&&Ki(this,t),e&&this.set(e)}}On(Sh,Yi);n(45);
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Eh extends Hl{constructor(e){super(e);const t=this.bindTemplate;this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(),this.arrowView=this._createArrowView(),this.keystrokes=new rl,this.focusTracker=new hl,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",t.if("isVisible","ck-hidden",(e=>!e)),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",((e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())})),this.keystrokes.set("arrowleft",((e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())}))}focus(){this.actionView.focus()}_createActionView(){const e=new gd;return e.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),e.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),e.delegate("execute").to(this),e}_createArrowView(){const e=new gd,t=e.bindTemplate;return e.icon=pd,e.extendTemplate({attributes:{class:"ck-splitbutton__arrow","aria-haspopup":!0,"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("isEnabled").to(this),e.delegate("execute").to(this,"open"),e}}n(47);
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Rh extends Rd{init(){const e=this.editor,t=e.t,n=e.ui.componentFactory,i=gh(e),o=i[0];n.add("codeBlock",(n=>{const r=e.commands.get("codeBlock"),s=yd(n,Eh),a=s.buttonView;return a.set({label:t("Insert code block"),tooltip:!0,icon:'',isToggleable:!0}),a.bind("isOn").to(r,"value",(e=>!!e)),a.on("execute",(()=>{e.execute("codeBlock",{language:o.language}),e.editing.view.focus()})),s.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),s.class="ck-code-block-dropdown",s.bind("isEnabled").to(r),xd(s,this._getLanguageListItemDefinitions(i)),s}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),n=new Mn;for(const i of e){const e={type:"button",model:new Sh({_codeBlockLanguage:i.language,label:i.label,withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),n.add(e)}return n}}
+class Af{constructor(){const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((n,i)=>{t.onload=()=>{const e=t.result;this._data=e,n(e)},t.onerror=()=>{i("error")},t.onabort=()=>{i("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}}Xe(Af,qe);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
+class Cf extends Qe{static get pluginName(){return"FileRepository"}static get requires(){return[Dl]}init(){this.loaders=new ai,this.loaders.on("add",(()=>this._updatePendingAction())),this.loaders.on("remove",(()=>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",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return Object(c.b)("filerepository-no-upload-adapter"),null;const t=new Tf(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof Tf?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,n)=>{e===t&&this._loadersMap.delete(n)}))}_updatePendingAction(){const e=this.editor.plugins.get(Dl);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,n=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(n(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else e.remove(this._pendingAction),this._pendingAction=null}}Xe(Cf,qe);class Tf{constructor(e,t){this.id=s(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new Af,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new c.a("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new c.a("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((n,i)=>{t.rejecter=i,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,n(e)})).catch((e=>{t.isFulfilled=!0,i(e)}))})),t}}Xe(Tf,qe);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Ih extends Fd{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.schema,i=t.document.selection,o=Array.from(i.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(r){const t=o.filter((e=>Oh(e)||Nh(n,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(Oh))}))}_getValue(){const e=Uu(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Oh(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=Uu(e.getSelectedBlocks());return!!n&&Nh(t,n)}_removeQuote(e,t){Mh(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const n=e.createPositionBefore(t.start.parent);return void e.move(t,n)}t.end.isAtEnd||e.split(t.end);const n=e.createPositionAfter(t.end.parent);e.move(t,n)}))}_applyQuote(e,t){const n=[];Mh(e,t).reverse().forEach((t=>{let i=Oh(t.start);i||(i=e.createElement("blockQuote"),e.wrap(t,i)),n.push(i)})),n.reverse().reduce(((t,n)=>t.nextSibling==n?(e.merge(e.createPositionAfter(t)),t):n))}}function Oh(e){return"blockQuote"==e.parent.name?e.parent:null}function Mh(e,t){let n,i=0;const o=[];for(;i{this._fileInputView.open()}))}focus(){this.buttonView.focus()}}class Sf extends Zl{constructor(e){super(e),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Vh extends Rd{static get pluginName(){return"BlockQuoteEditing"}init(){const e=this.editor,t=e.model.schema;e.commands.add("blockQuote",new Ih(e)),t.register("blockQuote",{allowWhere:"$block",allowContentOf:"$root"}),t.addChildCheck(((e,t)=>{if(e.endsWith("blockQuote")&&"blockQuote"==t.name)return!1})),e.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),e.model.document.registerPostFixer((n=>{const i=e.model.document.differ.getChanges();for(const e of i)if("insert"==e.type){const i=e.position.nodeAfter;if(!i)continue;if(i.is("element","blockQuote")&&i.isEmpty)return n.remove(i),!0;if(i.is("element","blockQuote")&&!t.checkChild(e.position,i))return n.unwrap(i),!0;if(i.is("element")){const e=n.createRangeIn(i);for(const i of e.getItems())if(i.is("element","blockQuote")&&!t.checkChild(n.createPositionBefore(i),i))return n.unwrap(i),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return n.remove(t),!0}return!1}));const n=this.editor.editing.view.document,i=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(n,"enter",((t,n)=>{if(!i.isCollapsed||!o.value)return;i.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{priority:wn.normal-10}),this.listenTo(n,"delete",((t,n)=>{if("backward"!=n.direction||!i.isCollapsed||!o.value)return;const r=i.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{priority:wn.high+5})}}n(49);
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Bh extends Rd{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(n=>{const i=e.commands.get("blockQuote"),o=new gd(n);return o.set({label:t("Block quote"),icon:'',tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1061,228 +1188,244 @@ class Bh extends Rd{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Dh extends Rd{static get pluginName(){return"CKFinderUI"}init(){const e=this.editor,t=e.ui.componentFactory,n=e.t;t.add("ckfinder",(t=>{const i=e.commands.get("ckfinder"),o=new gd(t);return o.set({label:n("Insert image or file"),icon:'',tooltip:!0}),o.bind("isEnabled").to(i),o.on("execute",(()=>{e.execute("ckfinder"),e.editing.view.focus()})),o}))}}
+const Ef="ckCsrfToken",Rf="abcdefghijklmnopqrstuvwxyz0123456789";function If(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const n of t){const t=n.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(Ef);var t,n;return e&&40==e.length||(e=function(e){let t="";const n=new Uint8Array(e);window.crypto.getRandomValues(n);for(let e=0;e.5?i.toUpperCase():i}return t}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Fh extends Pr{observe(e){this.listenTo(e,"load",((e,t)=>{const n=t.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(t)}),{useCapture:!0})}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}
+ */(40),t=Ef,n=e,document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(n)+";path=/"),e}class Of{constructor(e,t,n){this.loader=e,this.url=t,this.t=n}upload(){return this.loader.file.then((e=>new Promise(((t,n)=>{this._initRequest(),this._initListeners(t,n,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,n){const i=this.xhr,o=this.loader,r=(0,this.t)("Cannot upload file:")+` ${n.name}.`;i.addEventListener("error",(()=>t(r))),i.addEventListener("abort",(()=>t())),i.addEventListener("load",(()=>{const n=i.response;if(!n||!n.uploaded)return t(n&&n.error&&n.error.message?n.error.message:r);e({default:n.url})})),i.upload&&i.upload.addEventListener("progress",(e=>{e.lengthComputable&&(o.uploadTotal=e.total,o.uploaded=e.loaded)}))}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",If()),this.xhr.send(t)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class zh{constructor(){this._stack=[]}add(e,t){const n=this._stack,i=n[0];this._insertDescriptor(e);const o=n[0];i===o||Lh(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}remove(e,t){const n=this._stack,i=n[0];this._removeDescriptor(e);const o=n[0];i===o||Lh(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e.id));if(Lh(e,t[n]))return;n>-1&&t.splice(n,1);let i=0;for(;t[i]&&jh(t[i],e);)i++;t.splice(i,0,e)}_removeDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e));n>-1&&t.splice(n,1)}}function Lh(e,t){return e&&t&&e.priority==t.priority&&$h(e.classes)==$h(t.classes)}function jh(e,t){return e.priority>t.priority||!(e.priority$h(t.classes)}function $h(e){return Array.isArray(e)?e.sort().join(","):e}On(zh,xn);n(51);
+ */function Mf(e,t,n,i){let o,r=null;"function"==typeof i?o=i:(r=e.commands.get(i),o=()=>{e.execute(i)}),e.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!t.isEnabled)return;const c=js(e.model.document.selection.getRanges());if(!c.isCollapsed)return;if("transparent"==a.type)return;const l=Array.from(e.model.document.differ.getChanges()),d=l[0];if(1!=l.length||"insert"!==d.type||"$text"!=d.name||1!=d.length)return;const u=d.position.parent;if(u.is("element","codeBlock"))return;if(u.is("element","listItem")&&"function"!=typeof i&&!["numberedList","bulletedList","todoList"].includes(i))return;if(r&&!0===r.value)return;const h=u.getChild(0),f=e.model.createRangeOn(h);if(!f.containsRange(c)&&!c.end.isEqual(f.end))return;const g=n.exec(h.data.substr(0,c.end.offset));g&&e.model.enqueueChange((t=>{const n=t.createPositionAt(u,0),i=t.createPositionAt(u,g[0].length),r=new Ta(n,i);if(!1!==o({match:g})){t.remove(r);const n=e.model.document.selection.getFirstRange(),i=t.createRangeIn(u);!u.isEmpty||i.isEqual(n)||i.containsRange(n,!0)||t.remove(u)}r.detach()}))}))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */const Hh=Ql("px"),qh=pr.document.body;class Wh extends Hl{constructor(e){super(e);const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class"),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",(e=>`ck-balloon-panel_${e}`)),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Hh),left:t.to("left",Hh)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=Wh.defaultPositions,n=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast],limiter:qh,fitInViewport:!0},e),i=Wh._getOptimalPosition(n),o=parseInt(i.left),r=parseInt(i.top),s=i.name;Object.assign(this,{top:r,left:o,position:s})}pin(e){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this._startPinning(e),this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback)}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){this.attachTo(e);const t=Uh(e.target),n=e.limiter?Uh(e.limiter):qh;this.listenTo(pr.document,"scroll",((i,o)=>{const r=o.target,s=t&&r.contains(t),a=n&&r.contains(n);!s&&!a&&t&&n||this.attachTo(e)}),{useCapture:!0}),this.listenTo(pr.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(pr.document,"scroll"),this.stopListening(pr.window,"resize")}}function Uh(e){return un(e)?e:gs(e)?e.commonAncestorContainer:"function"==typeof e?Uh(e()):null}function Kh(e,t){return e.top-t.height-Wh.arrowVerticalOffset}function Gh(e){return e.bottom+Wh.arrowVerticalOffset}Wh.arrowHorizontalOffset=25,Wh.arrowVerticalOffset=10,Wh._getOptimalPosition=ad,Wh.defaultPositions={northWestArrowSouthWest:(e,t)=>({top:Kh(e,t),left:e.left-Wh.arrowHorizontalOffset,name:"arrow_sw"}),northWestArrowSouthMiddleWest:(e,t)=>({top:Kh(e,t),left:e.left-.25*t.width-Wh.arrowHorizontalOffset,name:"arrow_smw"}),northWestArrowSouth:(e,t)=>({top:Kh(e,t),left:e.left-t.width/2,name:"arrow_s"}),northWestArrowSouthMiddleEast:(e,t)=>({top:Kh(e,t),left:e.left-.75*t.width+Wh.arrowHorizontalOffset,name:"arrow_sme"}),northWestArrowSouthEast:(e,t)=>({top:Kh(e,t),left:e.left-t.width+Wh.arrowHorizontalOffset,name:"arrow_se"}),northArrowSouthWest:(e,t)=>({top:Kh(e,t),left:e.left+e.width/2-Wh.arrowHorizontalOffset,name:"arrow_sw"}),northArrowSouthMiddleWest:(e,t)=>({top:Kh(e,t),left:e.left+e.width/2-.25*t.width-Wh.arrowHorizontalOffset,name:"arrow_smw"}),northArrowSouth:(e,t)=>({top:Kh(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s"}),northArrowSouthMiddleEast:(e,t)=>({top:Kh(e,t),left:e.left+e.width/2-.75*t.width+Wh.arrowHorizontalOffset,name:"arrow_sme"}),northArrowSouthEast:(e,t)=>({top:Kh(e,t),left:e.left+e.width/2-t.width+Wh.arrowHorizontalOffset,name:"arrow_se"}),northEastArrowSouthWest:(e,t)=>({top:Kh(e,t),left:e.right-Wh.arrowHorizontalOffset,name:"arrow_sw"}),northEastArrowSouthMiddleWest:(e,t)=>({top:Kh(e,t),left:e.right-.25*t.width-Wh.arrowHorizontalOffset,name:"arrow_smw"}),northEastArrowSouth:(e,t)=>({top:Kh(e,t),left:e.right-t.width/2,name:"arrow_s"}),northEastArrowSouthMiddleEast:(e,t)=>({top:Kh(e,t),left:e.right-.75*t.width+Wh.arrowHorizontalOffset,name:"arrow_sme"}),northEastArrowSouthEast:(e,t)=>({top:Kh(e,t),left:e.right-t.width+Wh.arrowHorizontalOffset,name:"arrow_se"}),southWestArrowNorthWest:(e,t)=>({top:Gh(e),left:e.left-Wh.arrowHorizontalOffset,name:"arrow_nw"}),southWestArrowNorthMiddleWest:(e,t)=>({top:Gh(e),left:e.left-.25*t.width-Wh.arrowHorizontalOffset,name:"arrow_nmw"}),southWestArrowNorth:(e,t)=>({top:Gh(e),left:e.left-t.width/2,name:"arrow_n"}),southWestArrowNorthMiddleEast:(e,t)=>({top:Gh(e),left:e.left-.75*t.width+Wh.arrowHorizontalOffset,name:"arrow_nme"}),southWestArrowNorthEast:(e,t)=>({top:Gh(e),left:e.left-t.width+Wh.arrowHorizontalOffset,name:"arrow_ne"}),southArrowNorthWest:(e,t)=>({top:Gh(e),left:e.left+e.width/2-Wh.arrowHorizontalOffset,name:"arrow_nw"}),southArrowNorthMiddleWest:(e,t)=>({top:Gh(e),left:e.left+e.width/2-.25*t.width-Wh.arrowHorizontalOffset,name:"arrow_nmw"}),southArrowNorth:(e,t)=>({top:Gh(e),left:e.left+e.width/2-t.width/2,name:"arrow_n"}),southArrowNorthMiddleEast:(e,t)=>({top:Gh(e),left:e.left+e.width/2-.75*t.width+Wh.arrowHorizontalOffset,name:"arrow_nme"}),southArrowNorthEast:(e,t)=>({top:Gh(e),left:e.left+e.width/2-t.width+Wh.arrowHorizontalOffset,name:"arrow_ne"}),southEastArrowNorthWest:(e,t)=>({top:Gh(e),left:e.right-Wh.arrowHorizontalOffset,name:"arrow_nw"}),southEastArrowNorthMiddleWest:(e,t)=>({top:Gh(e),left:e.right-.25*t.width-Wh.arrowHorizontalOffset,name:"arrow_nmw"}),southEastArrowNorth:(e,t)=>({top:Gh(e),left:e.right-t.width/2,name:"arrow_n"}),southEastArrowNorthMiddleEast:(e,t)=>({top:Gh(e),left:e.right-.75*t.width+Wh.arrowHorizontalOffset,name:"arrow_nme"}),southEastArrowNorthEast:(e,t)=>({top:Gh(e),left:e.right-t.width+Wh.arrowHorizontalOffset,name:"arrow_ne"})};var Jh='';
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */function Nf(e,t,n,i){let o,r;n instanceof RegExp?o=n:r=n,r=r||(e=>{let t;const n=[],i=[];for(;null!==(t=o.exec(e))&&!(t&&t.length<4);){let{index:e,1:o,2:r,3:s}=t;const a=o+r+s;e+=t[0].length-a.length;const c=[e,e+o.length],l=[e+o.length+r.length,e+o.length+r.length+s.length];n.push(c),n.push(l),i.push([e+o.length,e+o.length+r.length])}return{remove:n,format:i}}),e.model.document.on("change:data",((n,o)=>{if("transparent"==o.type||!t.isEnabled)return;const s=e.model,a=s.document.selection;if(!a.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const d=a.focus,u=d.parent,{text:h,range:f}=function(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>!i.is("$text")&&!i.is("$textProxy")||i.getAttribute("code")?(n=t.createPositionAfter(i),""):e+i.data),""),range:t.createRange(n,e.end)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const Xh="widget-type-around";function Qh(e,t,n){return e&&ef(e)&&!n.isInline(t)}function Yh(e){return e.getAttribute(Xh)}
+ */(s.createRange(s.createPositionAt(u,0),d),s),g=r(h),p=Vf(f.start,g.format,s),m=Vf(f.start,g.remove,s);p.length&&m.length&&s.enqueueChange((e=>{if(!1!==i(e,p))for(const t of m.reverse())e.remove(t)}))}))}function Vf(e,t,n){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>n.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}function Bf(e,t){return(n,i)=>{if(!e.commands.get(t).isEnabled)return!1;const o=e.model.schema.getValidRanges(i,t);for(const e of o)n.setAttribute(t,!0,e);n.removeSelectionAttribute(t)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const Zh="ck-widget_selected";function ef(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function tf(e,t,n={}){if(!e.is("containerElement"))throw new _n.a("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass("ck-widget",e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=cf,n.label&&function(e,t,n){n.setCustomProperty("widgetLabel",t,e)}(e,n.label,t),n.hasSelectionHandle&&function(e,t){const n=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),n=new hd;return n.set("content",Jh),n.render(),t.appendChild(n.element),t}));t.insert(t.createPositionAt(e,0),n),t.addClass(["ck-widget_with-selection-handle"],e)}
+ */class Df extends Ze{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,n=t.document.selection,i=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(n.isCollapsed)i?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const t of o)i?e.setAttribute(this.attributeKey,i,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,this.attributeKey))return n.hasAttribute(this.attributeKey);return!1}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(e,t),nf(e,t,((e,t,n)=>n.addClass(Vn(t.classes),e)),((e,t,n)=>n.removeClass(Vn(t.classes),e))),e}function nf(e,t,n,i){const o=new zh;o.on("change:top",((t,o)=>{o.oldDescriptor&&i(e,o.oldDescriptor,o.writer),o.newDescriptor&&n(e,o.newDescriptor,o.writer)})),t.setCustomProperty("addHighlight",((e,t,n)=>o.add(t,n)),e),t.setCustomProperty("removeHighlight",((e,t,n)=>o.remove(t,n)),e)}function of(e){const t=e.getCustomProperty("widgetLabel");return t?"function"==typeof t?t():t:""}function rf(e,t){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((n,i,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((n,i,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),e}function sf(e,t){const n=e.getSelectedElement();if(n){const i=Yh(e);if(i)return t.createPositionAt(n,i);if(t.schema.isBlock(n))return t.createPositionAfter(n)}const i=e.getSelectedBlocks().next().value;if(i){if(i.isEmpty)return t.createPositionAt(i,0);const n=t.createPositionAfter(i);return e.focus.isTouching(n)?n:t.createPositionBefore(i)}return e.focus}function af(e,t){const n=new bs(pr.window),i=n.getIntersection(e),o=t.height+Wh.arrowVerticalOffset;if(e.top-o>n.top||e.bottom+o{const o=i.createElement("image",t),r=n||sf(e.document.selection,e);e.insertContent(o,r),o.parent&&i.setSelection(o,"on")}))}function hf(e){const t=e.schema,n=e.document.selection;return function(e,t,n){const i=function(e,t){const n=sf(e,t).parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}
+ */const zf="bold";class Ff extends Qe{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:zf}),e.model.schema.setAttributeProperties(zf,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:zf,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t?"bold"==t||Number(t)>=600?{name:!0,styles:["font-weight"]}:void 0:null}]}),e.commands.add(zf,new Df(e,zf)),e.keystrokes.set("CTRL+B",zf)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(e,n);return t.checkChild(i,"image")}(n,t,e)&&!function(e,t){const n=e.getSelectedElement();return n&&t.isObject(n)}(n,t)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","image")))}(n)}function ff(e){const t=[];for(const n of e.getChildren())t.push(n),n.is("element")&&t.push(...n.getChildren());return t.find((e=>e.is("element","img")))}function gf(e){return n=>{n.on(`attribute:${e}:image`,t)};function t(e,t,n){if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=ff(n.mapper.toViewElement(t.item));i.setAttribute(t.attributeKey,t.attributeNewValue||"",o)}}
+ */
+const Lf="bold";class jf extends Qe{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Lf,(n=>{const i=e.commands.get(Lf),o=new xd(n);return o.set({label:t("Bold"),icon:'',keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(Lf),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class pf extends Fd{refresh(){this.isEnabled=hf(this.editor.model)}execute(e){const t=this.editor.model;for(const n of Vn(e.source))uf(t,{src:n})}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class mf extends Rd{static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.model.schema,n=e.t,i=e.conversion;e.editing.view.addObserver(Fh),t.register("image",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["alt","src","srcset"]}),i.for("dataDowncast").elementToElement({model:"image",view:(e,{writer:t})=>bf(t)}),i.for("editingDowncast").elementToElement({model:"image",view:(e,{writer:t})=>function(e,t,n){return t.setCustomProperty("image",!0,e),tf(e,t,{label:function(){const t=ff(e).getAttribute("alt");return t?`${t} ${n}`:n}})}(bf(t),t,n("image widget"))}),i.for("downcast").add(gf("src")).add(gf("alt")).add(function(){return t=>{t.on("attribute:srcset:image",e)};function e(e,t,n){if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=ff(n.mapper.toViewElement(t.item));if(null===t.attributeNewValue){const e=t.attributeOldValue;e.data&&(i.removeAttribute("srcset",o),i.removeAttribute("sizes",o),e.width&&i.removeAttribute("width",o))}else{const e=t.attributeNewValue;e.data&&(i.setAttribute("srcset",e.data,o),i.setAttribute("sizes","100vw",o),e.width&&i.setAttribute("width",e.width,o))}}}()),i.for("upcast").elementToElement({view:{name:"img",attributes:{src:!0}},model:(e,{writer:t})=>t.createElement("image",{src:e.getAttribute("src")})}).attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}}).add(function(){return t=>{t.on("element:figure",e)};function e(e,t,n){if(!n.consumable.test(t.viewItem,{name:!0,classes:"image"}))return;const i=ff(t.viewItem);if(!i||!i.hasAttribute("src")||!n.consumable.test(i,{name:!0}))return;const o=Uu(n.convertItem(i,t.modelCursor).modelRange.getItems());o&&(n.convertChildren(t.viewItem,o),n.updateConversionResult(o,t))}}()),e.commands.add("imageInsert",new pf(e))}}function bf(e){const t=e.createEmptyElement("img"),n=e.createContainerElement("figure",{class:"image"});return e.insert(e.createPositionAt(n,0),t),n}
+ */
+const $f="italic";class Hf extends Qe{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:$f}),e.model.schema.setAttributeProperties($f,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:$f,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add($f,new Df(e,$f)),e.keystrokes.set("CTRL+I",$f)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class kf extends Qr{constructor(e){super(e),this.domEventType="mousedown"}onDomEvent(e){this.fire(e.type,e)}}
+ */
+const qf="italic";class Wf extends Qe{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(qf,(n=>{const i=e.commands.get(qf),o=new xd(n);return o.set({label:t("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(qf),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class wf extends Rd{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,n=e.editing.view,i=e.locale,o=t.document.selection;this.listenTo(n.document,"keydown",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const n=t.keyCode==Ao.arrowright,r=t.keyCode==Ao.arrowleft;if(!n&&!r)return;const s=i.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&r?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{priority:wn.get("high")+1}),this._isNextGravityRestorationSkipped=!1,this.listenTo(o,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&xf(o.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,n=this.editor.model.document.selection,i=n.getFirstPosition();return!this._isGravityOverridden&&((!i.isAtStart||!_f(n,t))&&(xf(i,t)?(yf(e),this._overrideGravity(),!0):void 0))}_handleBackwardMovement(e){const t=this.attributes,n=this.editor.model,i=n.document.selection,o=i.getFirstPosition();return this._isGravityOverridden?(yf(e),this._restoreGravity(),vf(n,t,o),!0):o.isAtStart?!!_f(i,t)&&(yf(e),vf(n,t,o),!0):function(e,t){return xf(e.getShiftedBy(-1),t)}(o,t)?o.isAtEnd&&!_f(i,t)&&xf(o,t)?(yf(e),vf(n,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):void 0}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((e=>e.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function _f(e,t){for(const n of t)if(e.hasAttribute(n))return!0;return!1}function vf(e,t,n){const i=n.nodeBefore;e.change((e=>{i?e.setSelectionAttribute(i.getAttributes()):e.removeSelectionAttribute(t)}))}function yf(e){e.preventDefault()}function xf(e,t){const{nodeBefore:n,nodeAfter:i}=e;for(const e of t){const t=n?n.getAttribute(e):void 0;if((i?i.getAttribute(e):void 0)!==t)return!0}return!1}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Cf(e,t,n,i){return i.createRange(Af(e,t,n,!0,i),Af(e,t,n,!1,i))}function Af(e,t,n,i,o){let r=e.textNode||(i?e.nodeBefore:e.nodeAfter),s=null;for(;r&&r.getAttribute(t)==n;)s=r,r=i?r.previousSibling:r.nextSibling;return s?o.createPositionAt(s,i?"before":"after"):e}
+ */
+const Uf="underline";class Kf extends Qe{static get pluginName(){return"UnderlineEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Uf}),e.model.schema.setAttributeProperties(Uf,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Uf,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(Uf,new Df(e,Uf)),e.keystrokes.set("CTRL+U","underline")}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
+const Gf="underline";class Jf extends Qe{static get pluginName(){return"UnderlineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Gf,(n=>{const i=e.commands.get(Gf),o=new xd(n);return o.set({label:t("Underline"),icon:'',keystroke:"CTRL+U",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(Gf),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Tf{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,n)=>{if(!n.consumable.test(t.item,"attribute:linkHref"))return;const i=n.writer,o=i.document.selection;for(const e of this._definitions){const r=i.createAttributeElement("a",e.attributes,{priority:5});i.setCustomProperty("link",!0,r),e.callback(t.attributeNewValue)?t.item.is("selection")?i.wrap(o.getFirstRange(),r):i.wrap(n.mapper.toViewRange(t.range),r):i.unwrap(n.mapper.toViewRange(t.range),r)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:image",((e,t,n)=>{const i=n.mapper.toViewElement(t.item),o=Array.from(i.getChildren()).find((e=>"a"===e.name));for(const e of this._definitions){const i=Un(e.attributes);if(e.callback(t.attributeNewValue))for(const[e,t]of i)"class"===e?n.writer.addClass(t,o):n.writer.setAttribute(e,t,o);else for(const[e,t]of i)"class"===e?n.writer.removeClass(t,o):n.writer.removeAttribute(e,o)}}))}}}var Pf=function(e,t,n){var i=e.length;return n=void 0===n?i:n,!t&&n>=i?e:fi(e,t,n)},Sf=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Ef=function(e){return Sf.test(e)};var Rf=function(e){return e.split("")},If="[\\ud800-\\udfff]",Of="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Mf="\\ud83c[\\udffb-\\udfff]",Nf="[^\\ud800-\\udfff]",Vf="(?:\\ud83c[\\udde6-\\uddff]){2}",Bf="[\\ud800-\\udbff][\\udc00-\\udfff]",Df="(?:"+Of+"|"+Mf+")"+"?",Ff="[\\ufe0e\\ufe0f]?",zf=Ff+Df+("(?:\\u200d(?:"+[Nf,Vf,Bf].join("|")+")"+Ff+Df+")*"),Lf="(?:"+[Nf+Of+"?",Of,Vf,Bf,If].join("|")+")",jf=RegExp(Mf+"(?="+Mf+")|"+Lf+zf,"g");var $f=function(e){return e.match(jf)||[]};var Hf=function(e){return Ef(e)?$f(e):Rf(e)};var qf=function(e){return function(t){t=ci(t);var n=Ef(t)?Hf(t):void 0,i=n?n[0]:t.charAt(0),o=n?Pf(n,1).join(""):t.slice(1);return i[e]()+o}}("toUpperCase");
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const Wf=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Uf=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,Kf=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,Gf=/^((\w+:(\/{2,})?)|(\W))/i,Jf="Ctrl+K";function Xf(e,{writer:t}){const n=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,n),n}function Qf(e){return function(e){return e.replace(Wf,"").match(Uf)}(e=String(e))?e:"#"}function Yf(e,t){return!!e&&(e.is("element","image")&&t.checkAttribute("image","linkHref"))}function Zf(e,t){const n=(i=e,Kf.test(i)?"mailto:":t);var i;const o=!!n&&!Gf.test(e);return e&&o?n+e:e}
+const Xf="strikethrough";class Qf extends Qe{static get pluginName(){return"StrikethroughEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Xf}),e.model.schema.setAttributeProperties(Xf,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Xf,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(Xf,new Df(e,Xf)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class eg extends Fd{constructor(e){super(e),this.manualDecorators=new Mn,this.automaticDecorators=new Tf}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document,n=Uu(t.selection.getSelectedBlocks());Yf(n,e.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(n,"linkHref")):(this.value=t.selection.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const n=this.editor.model,i=n.document.selection,o=[],r=[];for(const e in t)t[e]?o.push(e):r.push(e);n.change((t=>{if(i.isCollapsed){const s=i.getFirstPosition();if(i.hasAttribute("linkHref")){const a=Cf(s,"linkHref",i.getAttribute("linkHref"),n);t.setAttribute("linkHref",e,a),o.forEach((e=>{t.setAttribute(e,!0,a)})),r.forEach((e=>{t.removeAttribute(e,a)})),t.setSelection(t.createPositionAfter(a.end.nodeBefore))}else if(""!==e){const r=Un(i.getAttributes());r.set("linkHref",e),o.forEach((e=>{r.set(e,!0)}));const{end:a}=n.insertContent(t.createText(e,r),s);t.setSelection(a)}["linkHref",...o,...r].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const s=n.schema.getValidRanges(i.getRanges(),"linkHref"),a=[];for(const e of i.getSelectedBlocks())n.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const c=a.slice();for(const e of s)this._isRangeToUpdate(e,a)&&c.push(e);for(const n of c)t.setAttribute("linkHref",e,n),o.forEach((e=>{t.setAttribute(e,!0,n)})),r.forEach((e=>{t.removeAttribute(e,n)}))}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,n=t.document,i=Uu(n.selection.getSelectedBlocks());return Yf(i,t.schema)?i.getAttribute(e):n.selection.getAttribute(e)}_isRangeToUpdate(e,t){for(const n of t)if(n.containsRange(e))return!1;return!0}}
+ */
+const Yf="strikethrough";class Zf extends Qe{static get pluginName(){return"StrikethroughUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Yf,(n=>{const i=e.commands.get(Yf),o=new xd(n);return o.set({label:t("Strikethrough"),icon:'',keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(Yf),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class tg extends Fd{refresh(){const e=this.editor.model,t=e.document,n=Uu(t.selection.getSelectedBlocks());Yf(n,e.schema)?this.isEnabled=e.schema.checkAttribute(n,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref")}execute(){const e=this.editor,t=this.editor.model,n=t.document.selection,i=e.commands.get("link");t.change((e=>{const o=n.isCollapsed?[Cf(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),t)]:t.schema.getValidRanges(n.getRanges(),"linkHref");for(const t of o)if(e.removeAttribute("linkHref",t),i)for(const n of i.manualDecorators)e.removeAttribute(n.id,t)}))}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class ng{constructor({id:e,label:t,attributes:n,defaultValue:i}){this.id=e,this.set("value"),this.defaultValue=i,this.label=t,this.attributes=n}}On(ng,Yi);n(53);
+ */
+function eg(e){const t=e.t,n=e.config.get("codeBlock.languages");for(const e of n)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return n}function tg(e,t,n){const i={};for(const o of e)"class"===t?i[o[t].split(" ").shift()]=o[n]:i[o[t]]=o[n];return i}function ng(e){return e.data.match(/^(\s*)/)[0]}function ig(e){const t=e.document.selection,n=[];if(t.isCollapsed)n.push(t.anchor);else{const i=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of i)if(t.is("$textProxy")&&t.parent.is("element","codeBlock")){const i=ng(t.textNode),{parent:o,startOffset:r}=t.textNode,s=e.createPositionAt(o,r+i.length);n.push(s)}}return n}function og(e){const t=js(e.getSelectedBlocks());return t&&t.is("element","codeBlock")}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const ig="automatic",og=/^(https?:)?\/\//;class rg extends Rd{static get pluginName(){return"LinkEditing"}static get requires(){return[wf,du,Dd]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:Xf}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>Xf(Qf(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new eg(e)),e.commands.add("unlink",new tg(e));const t=function(e,t){const n={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>(e.label&&n[e.label]&&(e.label=n[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[n,i]of Object.entries(e)){const e=Object.assign({},i,{id:`link${qf(n)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter((e=>e.mode===ig))),this._enableManualDecorators(t.filter((e=>"manual"===e.mode)));e.plugins.get(wf).registerAttribute("linkHref"),function(e,t,n,i){const o=e.editing.view,r=new Set;o.document.registerPostFixer((o=>{const s=e.model.document.selection;let a=!1;if(s.hasAttribute(t)){const c=Cf(s.getFirstPosition(),t,s.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(const e of l.getItems())e.is("element",n)&&!e.hasClass(i)&&(o.addClass(i,e),r.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of r.values())e.removeClass(i,t),r.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}(e,"linkHref","a","ck-link_selected"),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(e){const t=this.editor,n=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:ig,callback:e=>og.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(e),n.length&&t.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,n=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),n.add(new ng(e)),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,{writer:i})=>{if(t){const t=n.get(e.id).attributes,o=i.createAttributeElement("a",t,{priority:5});return i.setCustomProperty("link",!0,o),o}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:n.get(e.id).attributes},model:{key:e.id}})}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor,t=e.model,n=t.document.selection,i=e.commands.get("link");this.listenTo(t,"insertContent",(()=>{const e=n.anchor.nodeBefore,o=n.anchor.nodeAfter;n.hasAttribute("linkHref")&&e&&e.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change((e=>{sg(e,i.manualDecorators)})))}),{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.commands.get("link");e.editing.view.addObserver(kf);let n=!1;this.listenTo(e.editing.view.document,"mousedown",(()=>{n=!0})),this.listenTo(e.editing.view.document,"selectionChange",(()=>{if(!n)return;n=!1;const i=e.model.document.selection;if(!i.isCollapsed)return;if(!i.hasAttribute("linkHref"))return;const o=i.getFirstPosition(),r=Cf(o,"linkHref",i.getAttribute("linkHref"),e.model);(o.isTouching(r.start)||o.isTouching(r.end))&&e.model.change((e=>{sg(e,t.manualDecorators)}))}))}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let n,i;this.listenTo(t.document,"delete",(()=>{i=!0}),{priority:"high"}),this.listenTo(e.model,"deleteContent",(()=>{const t=e.model.document.selection;t.isCollapsed||(i?i=!1:ag(e)&&function(e){const t=e.document.selection,n=t.getFirstPosition(),i=t.getLastPosition(),o=n.nodeAfter;if(!o)return!1;if(!o.is("$text"))return!1;if(!o.hasAttribute("linkHref"))return!1;const r=i.textNode||i.nodeBefore;if(o===r)return!0;return Cf(n,"linkHref",o.getAttribute("linkHref"),e).containsRange(e.createRange(n,i),!0)}(e.model)&&(n=t.getAttributes()))}),{priority:"high"}),this.listenTo(e.model,"insertContent",((t,[o])=>{i=!1,ag(e)&&n&&(e.model.change((e=>{for(const[t,i]of n)e.setAttribute(t,i,o)})),n=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,n=t.document.selection,i=e.editing.view,o=e.commands.get("link");let r=!1,s=!1;this.listenTo(i.document,"delete",((e,t)=>{s=t.domEvent.keyCode===Ao.backspace}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{r=!1;const e=n.getFirstPosition(),i=n.getAttribute("linkHref");if(!i)return;const o=Cf(e,"linkHref",i,t);r=o.containsPosition(e)||o.end.isEqual(e)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{s&&(s=!1,r||e.model.enqueueChange((e=>{sg(e,o.manualDecorators)})))}),{priority:"low"})}}function sg(e,t){e.removeSelectionAttribute("linkHref");for(const n of t)e.removeSelectionAttribute(n.id)}function ag(e){return e.plugins.get("Input").isInput(e.model.change((e=>e.batch)))}
+ */class rg extends Ze{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,n=t.model,i=n.document.selection,o=eg(t)[0],r=Array.from(i.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue,a=e.language||o.language;n.change((e=>{s?this._applyCodeBlock(e,r,a):this._removeCodeBlock(e,r)}))}_getValue(){const e=js(this.editor.model.document.selection.getSelectedBlocks());return!!!(!e||!e.is("element","codeBlock"))&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=js(e.getSelectedBlocks());return!!n&&sg(t,n)}_applyCodeBlock(e,t,n){const i=this.editor.model.schema,o=t.filter((e=>sg(i,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",n,t),i.removeDisallowedAttributes([t],e);o.reverse().forEach(((t,n)=>{const i=o[n+1];t.previousSibling===i&&(e.appendElement("softBreak",i),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const n=t.filter((e=>e.is("element","codeBlock")));for(const t of n){const n=e.createRangeOn(t);for(const t of Array.from(n.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:n}=e.split(e.createPositionBefore(t));e.rename(n.nodeAfter,"paragraph"),e.removeAttribute("language",n.nodeAfter),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}function sg(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class cg extends Bu{static get pluginName(){return"Notification"}init(){this.on("show:warning",((e,t)=>{window.alert(t.message)}),{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=`show:${e.type}`+(e.namespace?`:${e.namespace}`:"");this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}
+ */class ag extends Ze{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const n=ig(e);for(const e of n)t.insertText(this._indentSequence,e)}))}_checkEnabled(){return!!this._indentSequence&&og(this.editor.model.document.selection)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class lg extends Fd{constructor(e){super(e),this.stopListening(this.editor.model.document,"change"),this.listenTo(this.editor.model.document,"change",(()=>this.refresh()),{priority:"low"})}refresh(){const e=this.editor.commands.get("imageInsert"),t=this.editor.commands.get("link");this.isEnabled=e.isEnabled||t.isEnabled}execute(){const e=this.editor,t=this.editor.config.get("ckfinder.openerMethod")||"modal";if("popup"!=t&&"modal"!=t)throw new _n.a("ckfinder-unknown-openermethod",e);const n=this.editor.config.get("ckfinder.options")||{};n.chooseFiles=!0;const i=n.onInit;n.language||(n.language=e.locale.uiLanguage),n.onInit=t=>{i&&i(t),t.on("files:choose",(n=>{const i=n.data.files.toArray(),o=i.filter((e=>!e.isImage())),r=i.filter((e=>e.isImage()));for(const t of o)e.execute("link",t.getUrl());const s=[];for(const e of r){const n=e.getUrl();s.push(n||t.request("file:getProxyUrl",{file:e}))}s.length&&dg(e,s)})),t.on("file:choose:resizedImage",(t=>{const n=t.data.resizedUrl;if(n)dg(e,[n]);else{const t=e.plugins.get("Notification"),n=e.locale.t;t.showWarning(n("Could not obtain resized image URL."),{title:n("Selecting resized image failed"),namespace:"ckfinder"})}}))},window.CKFinder[t](n)}}function dg(e,t){if(e.commands.get("imageInsert").isEnabled)e.execute("imageInsert",{source:t});else{const t=e.plugins.get("Notification"),n=e.locale.t;t.showWarning(n("Could not insert image at the current position."),{title:n("Inserting image failed"),namespace:"ckfinder"})}}
+ */class cg extends Ze{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const n=ig(e);for(const e of n){const n=lg(this.editor.model,e,this._indentSequence);n&&t.remove(n)}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!og(e.document.selection)&&ig(e).some((t=>lg(e,t,this._indentSequence)))}}function lg(e,t,n){const i=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class ug extends Rd{static get pluginName(){return"CKFinderEditing"}static get requires(){return[cg,mf,rg]}init(){const e=this.editor;e.commands.add("ckfinder",new lg(e))}}
+ */(t);if(!i)return null;const o=ng(i),r=o.lastIndexOf(n);if(r+n.length!==o.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=i;return e.createRange(e.createPositionAt(s,a+r),e.createPositionAt(s,a+r+n.length))}function dg(e,t,n=!1){const i=tg(t,"language","class"),o=tg(t,"language","label");return(t,r,s)=>{const{writer:a,mapper:c,consumable:l}=s;if(!l.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=c.toViewPosition(e.createPositionBefore(r.item)),h={};n&&(h["data-language"]=o[d],h.spellcheck="false");const f=a.createContainerElement("pre",h),g=a.createContainerElement("code",{class:i[d]||null});a.insert(a.createPositionAt(f,0),g),a.insert(u,f),c.bindElements(r.item,g)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
+const ug="paragraph";class hg extends Qe{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[jh]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,n=e.model,i=eg(e);e.commands.add("codeBlock",new rg(e)),e.commands.add("indentCodeBlock",new ag(e)),e.commands.add("outdentCodeBlock",new cg(e));const o=e=>(t,n)=>{this.editor.commands.get(e).isEnabled&&(this.editor.execute(e),n())};e.keystrokes.set("Tab",o("indentCodeBlock")),e.keystrokes.set("Shift+Tab",o("outdentCodeBlock")),t.register("codeBlock",{allowWhere:"$block",isBlock:!0,allowAttributes:["language"]}),t.extend("$text",{allowIn:"codeBlock"}),t.addAttributeCheck((e=>{if(e.endsWith("codeBlock $text"))return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",dg(n,i,!0)),e.data.downcastDispatcher.on("insert:codeBlock",dg(n,i)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,n,i)=>{if("codeBlock"!==n.item.parent.name)return;const{writer:o,mapper:r,consumable:s}=i;if(!s.consume(n.item,"insert"))return;const a=r.toViewPosition(e.createPositionBefore(n.item));o.insert(a,o.createText("\n"))}}(n),{priority:"high"}),e.data.upcastDispatcher.on("element:pre",function(e,t){const n=tg(t,"class","language"),i=t[0].language;return(t,o,r)=>{const s=o.viewItem,a=s.getChild(0);if(!a||!a.is("element","code"))return;const{consumable:c,writer:l}=r;if(!c.test(s,{name:!0})||!c.test(a,{name:!0}))return;const d=l.createElement("codeBlock"),u=[...a.getClassNames()];u.length||u.push("");for(const e of u){const t=n[e];if(t){l.setAttribute("language",t,d);break}}d.hasAttribute("language")||l.setAttribute("language",i,d);const h=function(e,t){const n=e.createDocumentFragment(),i=t.split("\n").map((t=>e.createText(t))),o=i[i.length-1];for(const t of i)e.append(t,n),t!==o&&e.appendElement("softBreak",n);return n}(l,[...e.createRangeIn(a)].filter((e=>"text"===e.type)).map((({item:e})=>e.data)).join(""));l.append(h,d),r.safeInsert(d,o.modelCursor)&&(c.consume(s,{name:!0}),c.consume(a,{name:!0}),r.updateConversionResult(d,o))}}(e.editing.view,i)),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{let o=n.createRange(n.document.selection.anchor);if(i.targetRanges&&(o=e.editing.mapper.toModelRange(i.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=i.dataTransfer.getData("text/plain"),s=new Vu(e.editing.view.document);i.content=function(e,t){const n=e.createDocumentFragment(),i=t.split("\n"),o=i.reduce(((t,n,o)=>(t.push(n),o{const o=i.anchor;!i.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(i.focus)&&n.change((n=>{const r=e.return;if(r.childCount>1||i.containsEntireContent(o.parent)){const t=n.createElement("codeBlock",o.parent.getAttributes());n.append(r,t);const i=n.createDocumentFragment();n.append(t,i),e.return=i}else{const e=r.getChild(0);t.checkAttribute(e,"code")&&n.setAttribute("code",!0,e)}}))}))}afterInit(){const e=this.editor,t=e.commands,n=t.get("indent"),i=t.get("outdent");n&&n.registerChildCommand(t.get("indentCodeBlock")),i&&i.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,n)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const n=e.model.document,i=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeAfter;if(t||!n.selection.isCollapsed||!o.isAtStart)return!1;if(!r||!r.is("element","softBreak"))return!1;return e.model.change((t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,ug),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)})),i.scrollToTheSelection(),!0}(e,n.isSoft)||function(e,t){const n=e.model,i=n.document,o=e.editing.view,r=i.selection.getLastPosition(),s=r.nodeBefore;let a;if(t||!i.selection.isCollapsed||!r.isAtEnd||!s)return!1;if(s.is("element","softBreak"))a=n.createRangeOn(s);else{if(!s.is("$text")||s.data.match(/\S/)||!s.previousSibling||!s.previousSibling.is("element","softBreak"))return!1;a=n.createRange(n.createPositionBefore(s.previousSibling),n.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const n=i.selection.anchor.parent;t.rename(n,ug),e.model.schema.removeDisallowedAttributes([n],t)})),o.scrollToTheSelection(),!0}(e,n.isSoft)||function(e){const t=e.model.document,n=t.selection.getLastPosition(),i=n.nodeBefore||n.textNode;let o;i&&i.is("$text")&&(o=ng(i));e.model.change((n=>{e.execute("shiftEnter"),o&&n.insertText(o,t.selection.anchor)}))}(e),n.preventDefault(),t.stop())}),{context:"pre"})}}n(69);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const hg=/^data:(\S*?);base64,/;class fg{constructor(e,t,n){if(!e)throw new _n.a("fileuploader-missing-file",null);if(!t)throw new _n.a("fileuploader-missing-token",null);if(!n)throw new _n.a("fileuploader-missing-api-address",null);this.file=function(e){if("string"!=typeof e)return!1;const t=e.match(hg);return!(!t||!t.length)}
+class fg extends Qe{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,n=e.ui.componentFactory,i=eg(e),o=i[0];n.add("codeBlock",(n=>{const r=e.commands.get("codeBlock"),s=Ud(n,Ed),a=s.buttonView;return a.set({label:t("Insert code block"),tooltip:!0,icon:'',isToggleable:!0}),a.bind("isOn").to(r,"value",(e=>!!e)),a.on("execute",(()=>{e.execute("codeBlock",{language:o.language}),e.editing.view.focus()})),s.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),s.class="ck-code-block-dropdown",s.bind("isEnabled").to(r),Kd(s,this._getLanguageListItemDefinitions(i)),s}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),n=new ai;for(const i of e){const e={type:"button",model:new iu({_codeBlockLanguage:i.language,label:i.label,withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),n.add(e)}return n}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(e)?function(e,t=512){try{const n=e.match(hg)[1],i=atob(e.replace(hg,"")),o=[];for(let e=0;ee(n))),this}onError(e){return this.once("error",((t,n)=>e(n))),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this,t=this.xhr;function n(t){return()=>e.fire("error",t)}t.addEventListener("error",n("Network Error")),t.addEventListener("abort",n("Abort")),t.upload&&t.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.fire("progress",{total:e.total,uploaded:e.loaded})})),t.addEventListener("load",(()=>{const e=t.status,n=t.response;if(e<200||e>299)return this.fire("error",n.message||n.error)}))}_sendRequest(){const e=new FormData,t=this.xhr;return e.append("file",this.file),new Promise(((n,i)=>{t.addEventListener("load",(()=>{const e=t.status,o=t.response;return e<200||e>299?o.message?i(new _n.a("fileuploader-uploading-data-failed",this,{message:o.message})):i(o.error):n(o)})),t.addEventListener("error",(()=>i(new Error("Network Error")))),t.addEventListener("abort",(()=>i(new Error("Abort")))),t.send(e)}))}}On(fg,xn);
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const gg={autoRefresh:!0},pg=36e5;class mg{constructor(e,t=gg){if(!e)throw new _n.a("token-missing-token-url",this);t.initValue&&this._validateTokenValue(t.initValue),this.set("value",t.initValue),this._refresh="function"==typeof e?e:()=>{return t=e,new Promise(((e,n)=>{const i=new XMLHttpRequest;i.open("GET",t),i.addEventListener("load",(()=>{const t=i.status,o=i.response;return t<200||t>299?n(new _n.a("token-cannot-download-new-token",null)):e(o)})),i.addEventListener("error",(()=>n(new Error("Network Error")))),i.addEventListener("abort",(()=>n(new Error("Abort")))),i.send()}));var t},this._options=Object.assign({},gg,t)}init(){return new Promise(((e,t)=>{this.value?(this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)):this.refreshToken().then(e).catch(t)}))}refreshToken(){return this._refresh().then((e=>{this._validateTokenValue(e),this.set("value",e),this._options.autoRefresh&&this._registerRefreshTokenTimeout()})).then((()=>this))}destroy(){clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const t="string"==typeof e,n=!/^".*"$/.test(e),i=t&&3===e.split(".").length;if(!n||!i)throw new _n.a("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(){const e=this._getTokenRefreshTimeoutTime();clearTimeout(this._tokenRefreshTimeout),this._tokenRefreshTimeout=setTimeout((()=>{this.refreshToken()}),e)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));if(!t)return pg;return Math.floor((1e3*t-Date.now())/2)}catch(e){return pg}}static create(e,t=gg){return new mg(e,t).init()}}On(mg,Yi);var bg=mg;
+class gg extends Ze{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.schema,i=t.document.selection,o=Array.from(i.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(r){const t=o.filter((e=>pg(e)||bg(n,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(pg))}))}_getValue(){const e=js(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!pg(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=js(e.getSelectedBlocks());return!!n&&bg(t,n)}_removeQuote(e,t){mg(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const n=e.createPositionBefore(t.start.parent);return void e.move(t,n)}t.end.isAtEnd||e.split(t.end);const n=e.createPositionAfter(t.end.parent);e.move(t,n)}))}_applyQuote(e,t){const n=[];mg(e,t).reverse().forEach((t=>{let i=pg(t.start);i||(i=e.createElement("blockQuote"),e.wrap(t,i)),n.push(i)})),n.reverse().reduce(((t,n)=>t.nextSibling==n?(e.merge(e.createPositionAfter(t)),t):n))}}function pg(e){return"blockQuote"==e.parent.name?e.parent:null}function mg(e,t){let n,i=0;const o=[];for(;i{if(e.endsWith("blockQuote")&&"blockQuote"==t.name)return!1})),e.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),e.model.document.registerPostFixer((n=>{const i=e.model.document.differ.getChanges();for(const e of i)if("insert"==e.type){const i=e.position.nodeAfter;if(!i)continue;if(i.is("element","blockQuote")&&i.isEmpty)return n.remove(i),!0;if(i.is("element","blockQuote")&&!t.checkChild(e.position,i))return n.unwrap(i),!0;if(i.is("element")){const e=n.createRangeIn(i);for(const i of e.getItems())if(i.is("element","blockQuote")&&!t.checkChild(n.createPositionBefore(i),i))return n.unwrap(i),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return n.remove(t),!0}return!1}));const n=this.editor.editing.view.document,i=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(n,"enter",((t,n)=>{if(!i.isCollapsed||!o.value)return;i.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((t,n)=>{if("backward"!=n.direction||!i.isCollapsed||!o.value)return;const r=i.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"})}}n(71);
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class wg extends Qe{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(n=>{const i=e.commands.get("blockQuote"),o=new xd(n);return o.set({label:t("Block quote"),icon:Kl,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class wg extends Rd{static get requires(){return[zu,kg]}init(){const e=this.editor,t=e.plugins.get(kg),n=t.token,i=t.uploadUrl;n&&(this._uploadGateway=new wg._UploadGateway(n,i),e.plugins.get(zu).createUploadAdapter=e=>new _g(this._uploadGateway,e))}}class _g{constructor(e,t){this.uploadGateway=e,this.loader=t}upload(){return this.loader.file.then((e=>(this.fileUploader=this.uploadGateway.upload(e),this.fileUploader.on("progress",((e,t)=>{this.loader.uploadTotal=t.total,this.loader.uploaded=t.uploaded})),this.fileUploader.send())))}abort(){this.fileUploader.abort()}}wg._UploadGateway=class{constructor(e,t){if(!e)throw new _n.a("uploadgateway-missing-token",null);if(!t)throw new _n.a("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=t}upload(e){return new fg(e,this._token,this._apiAddress)}};n(55);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const vg=["before","after"],yg=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,xg="ck-widget__type-around_disabled";class Cg extends Rd{static get pluginName(){return"WidgetTypeAround"}constructor(e){super(e),this._currentFakeCaretModelElement=null}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((n,i,o)=>{t.change((e=>{for(const n of t.document.roots)o?e.removeClass(xg,n):e.addClass(xg,n)})),o||e.model.change((e=>{e.removeSelectionAttribute(Xh)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const n=this.editor,i=n.editing.view;n.execute("insertParagraph",{position:n.model.createPositionAt(e,t)}),i.focus(),i.scrollToTheSelection()}_listenToIfEnabled(e,t,n,i){this.listenTo(e,t,((...e)=>{this.isEnabled&&n(...e)}),i)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Yh(e);if(!t)return!1;const n=e.getSelectedElement();return this._insertParagraph(n,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,n=e.locale.t,i={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,n,o)=>{const r=o.mapper.toViewElement(n.item);Qh(r,n.item,t)&&function(e,t,n){const i=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const n=this.toDomElement(e);return function(e,t){for(const n of vg){const i=new xl({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:t[n]},children:[e.ownerDocument.importNode(yg,!0)]});e.appendChild(i.render())}}(n,t),function(e){const t=new xl({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(n),n}));e.insert(e.createPositionAt(n,"end"),i)}(o.writer,i,r)}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,n=t.document.selection,i=t.schema,o=e.editing.view;function r(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"keydown",((e,t)=>{Eo(t.keyCode)&&this._handleArrowKeyPress(e,t)}),{priority:wn.get("high")+10}),this._listenToIfEnabled(n,"change:range",((t,n)=>{n.directChange&&e.model.change((e=>{e.removeSelectionAttribute(Xh)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=n.getSelectedElement();if(t){if(Qh(e.editing.mapper.toViewElement(t),t,i))return}e.model.change((e=>{e.removeSelectionAttribute(Xh)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,n)=>{const o=n.writer;if(this._currentFakeCaretModelElement){const e=n.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(vg.map(r),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!Qh(a,s,i))return;const c=Yh(t.selection);c&&(o.addClass(r(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,n,i)=>{i||e.model.change((e=>{e.removeSelectionAttribute(Xh)}))}))}_handleArrowKeyPress(e,t){const n=this.editor,i=n.model,o=i.document.selection,r=i.schema,s=n.editing.view,a=Io(t.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;Qh(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed&&(l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a)),l&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,n=Yh(t.document.selection);return t.change((t=>{if(!n)return t.setSelectionAttribute(Xh,e?"after":"before"),!0;if(!(n===(e?"after":"before")))return t.removeSelectionAttribute(Xh),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,n=t.model,i=n.schema,o=t.plugins.get("Widget"),r=o._getObjectElementNextToSelection(e);return!!Qh(t.editing.mapper.toViewElement(r),r,i)&&(n.change((t=>{o._setSelectionOverElement(r),t.setSelectionAttribute(Xh,e?"before":"after")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((n,i)=>{const o=i.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const r=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),s=function(e,t){const n=e.closest(".ck-widget");return t.mapDomToView(n)}(o,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,r),i.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"enter",((n,i)=>{const o=t.document.selection.getSelectedElement(),r=e.editing.mapper.toModelElement(o),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:Qh(o,r,s)&&(this._insertParagraph(r,i.isSoft?"before":"after"),a=!0),a&&(i.preventDefault(),n.stop())}))}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view,t=[Ao.enter,Ao.delete,Ao.backspace];this._listenToIfEnabled(e.document,"keydown",((e,n)=>{t.includes(n.keyCode)||ou(n)||this._insertParagraphAccordingToFakeCaretPosition()}),{priority:wn.get("high")+1})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,n=e.model,i=n.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{const r=Yh(n.document.selection);if(!r)return;const s=o.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)e.execute("delete",{selection:n.createSelection(a,"on")});else{const t=i.getNearestSelectionRange(n.createPositionAt(a,r),s);if(t)if(t.isCollapsed){const o=n.createSelection(t.start);if(n.modifySelection(o,{direction:s}),o.focus.isEqual(t.start)){const e=function(e,t){let n=t;for(const i of t.getAncestors({parentFirst:!0})){if(i.childCount>1||e.isLimit(i))break;n=i}return n}(i,t.start.parent);n.deleteContent(n.createSelection(e,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(t),e.execute(c?"forwardDelete":"delete")}))}else n.change((n=>{n.setSelection(t),e.execute(c?"forwardDelete":"delete")}))}o.preventDefault(),t.stop()}),{priority:wn.get("high")+1})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[i,o])=>{if(o&&!o.is("documentSelection"))return;const r=Yh(n);return r?(e.stop(),t.change((e=>{const o=n.getSelectedElement(),s=t.createPositionAt(o,r),a=e.createSelection(s),c=t.insertContent(i,a);return e.setSelection(a),c}))):void 0}),{priority:"high"})}}n(57);
+class _g extends Qe{static get pluginName(){return"CKFinderUI"}init(){const e=this.editor,t=e.ui.componentFactory,n=e.t;t.add("ckfinder",(t=>{const i=e.commands.get("ckfinder"),o=new xd(t);return o.set({label:n("Insert image or file"),icon:'',tooltip:!0}),o.bind("isEnabled").to(i),o.on("execute",(()=>{e.execute("ckfinder"),e.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Ag(e){const t=e.model;return(n,i)=>{const o=i.keyCode==Ao.arrowup,r=i.keyCode==Ao.arrowdown,s=i.shiftKey,a=t.document.selection;if(!o&&!r)return;const c=r;if(s&&function(e,t){return!e.isCollapsed&&e.isBackward==t}
+ */class vg extends Ze{constructor(e){super(e),this.stopListening(this.editor.model.document,"change"),this.listenTo(this.editor.model.document,"change",(()=>this.refresh()),{priority:"low"})}refresh(){const e=this.editor.commands.get("insertImage"),t=this.editor.commands.get("link");this.isEnabled=e.isEnabled||t.isEnabled}execute(){const e=this.editor,t=this.editor.config.get("ckfinder.openerMethod")||"modal";if("popup"!=t&&"modal"!=t)throw new c.a("ckfinder-unknown-openermethod",e);const n=this.editor.config.get("ckfinder.options")||{};n.chooseFiles=!0;const i=n.onInit;n.language||(n.language=e.locale.uiLanguage),n.onInit=t=>{i&&i(t),t.on("files:choose",(n=>{const i=n.data.files.toArray(),o=i.filter((e=>!e.isImage())),r=i.filter((e=>e.isImage()));for(const t of o)e.execute("link",t.getUrl());const s=[];for(const e of r){const n=e.getUrl();s.push(n||t.request("file:getProxyUrl",{file:e}))}s.length&&yg(e,s)})),t.on("file:choose:resizedImage",(t=>{const n=t.data.resizedUrl;if(n)yg(e,[n]);else{const t=e.plugins.get("Notification"),n=e.locale.t;t.showWarning(n("Could not obtain resized image URL."),{title:n("Selecting resized image failed"),namespace:"ckfinder"})}}))},window.CKFinder[t](n)}}function yg(e,t){if(e.commands.get("insertImage").isEnabled)e.execute("insertImage",{source:t});else{const t=e.plugins.get("Notification"),n=e.locale.t;t.showWarning(n("Could not insert image at the current position."),{title:n("Inserting image failed"),namespace:"ckfinder"})}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(a,c))return;const l=function(e,t,n){const i=e.model;if(n){const e=t.isCollapsed?t.focus:t.getLastPosition(),n=Tg(i,e,"forward");if(!n)return null;const o=i.createRange(e,n),r=Pg(i.schema,o,"backward");return r&&e.isBefore(r)?i.createRange(e,r):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),n=Tg(i,e,"backward");if(!n)return null;const o=i.createRange(n,e),r=Pg(i.schema,o,"forward");return r&&e.isAfter(r)?i.createRange(r,e):null}}(e,a,c);l&&!l.isCollapsed&&function(e,t,n){const i=e.model,o=e.view.domConverter;if(n){const e=i.createSelection(t.start);i.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=i.createRange(e.focus,t.end))}const r=e.mapper.toViewRange(t),s=o.viewRangeToDom(r),a=bs.getDomRangeRects(s);let c;for(const e of a)if(void 0!==c){if(Math.round(e.top)>=c)return!1;c=Math.max(c,Math.round(e.bottom))}else c=Math.round(e.bottom);return!0}(e,l,c)&&(t.change((e=>{const n=c?l.end:l.start;if(s){const i=t.createSelection(a.anchor);i.setFocus(n),e.setSelection(i)}else e.setSelection(n)})),n.stop(),i.preventDefault(),i.stopPropagation())}}function Tg(e,t,n){const i=e.schema,o=e.createRangeIn(t.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of o.getWalker({startPosition:t,direction:n})){if(i.isLimit(s)&&!i.isInline(s))return e;if(a==r&&i.isBlock(s))return null}return null}function Pg(e,t,n){const i="backward"==n?t.end:t.start;if(e.checkChild(i,"$text"))return i;for(const{nextPosition:i}of t.getWalker({direction:n}))if(e.checkChild(i,"$text"))return i}class Sg extends Rd{static get pluginName(){return"Widget"}static get requires(){return[Cg]}init(){const e=this.editor.editing.view,t=e.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((e,t,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const i=n.writer,o=i.document.selection,r=o.getSelectedElement();let s=null;for(const e of o.getRanges())for(const t of e){const e=t.item;ef(e)&&!Eg(e,s)&&(i.addClass(Zh,e),this._previouslySelected.add(e),s=e,e==r&&i.setSelection(o.getRanges(),{fake:!0,label:of(r)}))}}),{priority:"low"}),e.addObserver(kf),this.listenTo(t,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(t,"keydown",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{priority:"high"}),this.listenTo(t,"keydown",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{priority:wn.get("high")-20}),this.listenTo(t,"keydown",Ag(this.editor.editing)),this.listenTo(t,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{priority:"high"})}_onMousedown(e,t){const n=this.editor,i=n.editing.view,o=i.document;let r=t.target;if(function(e){for(;e;){if(e.is("editableElement")&&!e.is("rootElement"))return!0;if(ef(e))return!1;e=e.parent}return!1}(r)){if((yo.isSafari||yo.isGecko)&&t.domEvent.detail>=3){const e=n.editing.mapper,i=r.is("attributeElement")?r.findAncestor((e=>!e.is("attributeElement"))):r,o=e.toModelElement(i);t.preventDefault(),this.editor.model.change((e=>{e.setSelection(o,"in")}))}return}if(!ef(r)&&(r=r.findAncestor(ef),!r))return;t.preventDefault(),o.isFocused||i.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(e,t){const n=t.keyCode;if(!Eo(n))return;const i=this.editor.model,o=i.schema,r=i.document.selection,s=r.getSelectedElement(),a=Io(n,this.editor.locale.contentLanguageDirection);if(s&&o.isObject(s)){const n=a?r.getLastPosition():r.getFirstPosition(),s=o.getNearestSelectionRange(n,a?"forward":"backward");return void(s&&(i.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed)return;const c=this._getObjectElementNextToSelection(a);c&&o.isObject(c)&&(this._setSelectionOverElement(c),t.preventDefault(),e.stop())}_preventDefaultOnArrowKeyPress(e,t){if(!Eo(t.keyCode))return;const n=this.editor.model,i=n.schema,o=n.document.selection.getSelectedElement();o&&i.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){if(this.editor.isReadOnly)return;const t=this.editor.model.document.selection;if(!t.isCollapsed)return;const n=this._getObjectElementNextToSelection(e);return n?(this.editor.model.change((e=>{let i=t.anchor.parent;for(;i.isEmpty;){const t=i;i=t.parent,e.remove(t)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,n=t.schema,i=t.document.selection,o=t.createSelection(i);t.modifySelection(o,{direction:e?"forward":"backward"});const r=e?o.focus.nodeBefore:o.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Zh,t);this._previouslySelected.clear()}}function Eg(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}
+ */class xg extends Qe{static get pluginName(){return"CKFinderEditing"}static get requires(){return[nu,"ImageEditing","LinkEditing"]}init(){const e=this.editor;e.commands.add("ckfinder",new vg(e))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Rg extends Fd{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=df(e),df(e)&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor.model,n=t.document.selection.getSelectedElement();t.change((t=>{t.setAttribute("alt",e.newValue,n)}))}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Ig extends Rd{static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new Rg(this.editor))}}n(59);
+ */
+const Ag={autoRefresh:!0},Cg=36e5;class Tg{constructor(e,t=Ag){if(!e)throw new c.a("token-missing-token-url",this);t.initValue&&this._validateTokenValue(t.initValue),this.set("value",t.initValue),this._refresh="function"==typeof e?e:()=>{return t=e,new Promise(((e,n)=>{const i=new XMLHttpRequest;i.open("GET",t),i.addEventListener("load",(()=>{const t=i.status,o=i.response;return t<200||t>299?n(new c.a("token-cannot-download-new-token",null)):e(o)})),i.addEventListener("error",(()=>n(new Error("Network Error")))),i.addEventListener("abort",(()=>n(new Error("Abort")))),i.send()}));var t},this._options=Object.assign({},Ag,t)}init(){return new Promise(((e,t)=>{this.value?(this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)):this.refreshToken().then(e).catch(t)}))}refreshToken(){return this._refresh().then((e=>{this._validateTokenValue(e),this.set("value",e),this._options.autoRefresh&&this._registerRefreshTokenTimeout()})).then((()=>this))}destroy(){clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const t="string"==typeof e,n=!/^".*"$/.test(e),i=t&&3===e.split(".").length;if(!n||!i)throw new c.a("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(){const e=this._getTokenRefreshTimeoutTime();clearTimeout(this._tokenRefreshTimeout),this._tokenRefreshTimeout=setTimeout((()=>{this.refreshToken()}),e)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));if(!t)return Cg;return Math.floor((1e3*t-Date.now())/2)}catch(e){return Cg}}static create(e,t=Ag){return new Tg(e,t).init()}}Xe(Tg,qe);var Pg=Tg;
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Og extends Hl{constructor(e,t){super(e);const n=`ck-labeled-field-view-${kn()}`,i=`ck-labeled-field-view-status-${kn()}`;this.fieldView=t(this,n,i),this.set("label"),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class"),this.set("placeholder"),this.labelView=this._createLabelView(n),this.statusView=this._createStatusView(i),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const o=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",o.to("class"),o.if("isEnabled","ck-disabled",(e=>!e)),o.if("isEmpty","ck-labeled-field-view_empty"),o.if("isFocused","ck-labeled-field-view_focused"),o.if("placeholder","ck-labeled-field-view_placeholder"),o.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:[this.fieldView,this.labelView]},this.statusView]})}_createLabelView(e){const t=new Kl(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Hl(this.locale),n=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",(e=>!e))],id:e,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),t}focus(){this.fieldView.focus()}}n(61);
+ */const Sg=/^data:(\S*?);base64,/;class Eg{constructor(e,t,n){if(!e)throw new c.a("fileuploader-missing-file",null);if(!t)throw new c.a("fileuploader-missing-token",null);if(!n)throw new c.a("fileuploader-missing-api-address",null);this.file=function(e){if("string"!=typeof e)return!1;const t=e.match(Sg);return!(!t||!t.length)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Mg extends Hl{constructor(e){super(e),this.set("value"),this.set("id"),this.set("placeholder"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById"),this.focusTracker=new hl,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{type:"text",class:["ck","ck-input","ck-input-text",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById")},on:{input:t.to("input"),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((e,t,n)=>{this._setDomElementValue(n),this._updateIsEmpty()}))}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}
+ */(e)?function(e,t=512){try{const n=e.match(Sg)[1],i=atob(e.replace(Sg,"")),o=[];for(let e=0;ee(n))),this}onError(e){return this.once("error",((t,n)=>e(n))),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this,t=this.xhr;function n(t){return()=>e.fire("error",t)}t.addEventListener("error",n("Network Error")),t.addEventListener("abort",n("Abort")),t.upload&&t.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.fire("progress",{total:e.total,uploaded:e.loaded})})),t.addEventListener("load",(()=>{const e=t.status,n=t.response;if(e<200||e>299)return this.fire("error",n.message||n.error)}))}_sendRequest(){const e=new FormData,t=this.xhr;return e.append("file",this.file),new Promise(((n,i)=>{t.addEventListener("load",(()=>{const e=t.status,o=t.response;return e<200||e>299?o.message?i(new c.a("fileuploader-uploading-data-failed",this,{message:o.message})):i(o.error):n(o)})),t.addEventListener("error",(()=>i(new Error("Network Error")))),t.addEventListener("abort",(()=>i(new Error("Abort")))),t.send(e)}))}}Xe(Eg,u);class Rg{constructor(e,t){if(!e)throw new c.a("uploadgateway-missing-token",null);if(!t)throw new c.a("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=t}upload(e){return new Eg(e,this._token,this._apiAddress)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-function Ng(e,t,n){const i=new Mg(e.locale);return i.set({id:t,ariaDescribedById:n}),i.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),i.bind("hasError").to(e,"errorText",(e=>!!e)),i.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(i),i}
+ */class Ig extends pi{static get pluginName(){return"CloudServicesCore"}createToken(e,t){return new Pg(e,t)}createUploadGateway(e,t){return new Rg(e,t)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-function Vg(e){e.set("_isCssTransitionsDisabled",!1),e.disableCssTransitions=()=>{e._isCssTransitionsDisabled=!0},e.enableCssTransitions=()=>{e._isCssTransitionsDisabled=!1},e.extendTemplate({attributes:{class:[e.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Bg({view:e}){e.listenTo(e.element,"submit",((t,n)=>{n.preventDefault(),e.fire("submit")}),{useCapture:!0})}var Dg='',Fg='';n(63),n(11);
+ */
+class Og extends Qe{static get pluginName(){return"CloudServicesUploadAdapter"}static get requires(){return["CloudServices",Cf]}init(){const e=this.editor,t=e.plugins.get("CloudServices"),n=t.token,i=t.uploadUrl;n&&(this._uploadGateway=e.plugins.get("CloudServicesCore").createUploadGateway(n,i),e.plugins.get(Cf).createUploadAdapter=e=>new Mg(this._uploadGateway,e))}}class Mg{constructor(e,t){this.uploadGateway=e,this.loader=t}upload(){return this.loader.file.then((e=>(this.fileUploader=this.uploadGateway.upload(e),this.fileUploader.on("progress",((e,t)=>{this.loader.uploadTotal=t.total,this.loader.uploaded=t.uploaded})),this.fileUploader.send())))}abort(){this.fileUploader.abort()}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class zg extends Hl{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new hl,this.keystrokes=new rl,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Dg,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),Fg,"ck-button-cancel","cancel"),this._focusables=new yl,this._focusCycler=new ed({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]}),Vg(this)}render(){super.render(),this.keystrokes.listenTo(this.element),Bg({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}_createButton(e,t,n,i){const o=new gd(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createLabeledInputView(){const e=this.locale.t,t=new Og(this.locale,Ng);return t.label=e("Text alternative"),t}}n(66),n(68);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const Lg=Ql("px");class jg extends Rd{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.set("visibleView",null),this.view=new Wh(e.locale),e.ui.view.body.add(this.view),e.ui.focusTracker.add(this.view.element),this._viewToStack=new Map,this._idToStack=new Map,this.set("_numberOfStacks",0),this.set("_singleViewMode",!1),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this.hasView(e.view))throw new _n.a("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const n=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),n.set(e.view,e),this._viewToStack.set(e.view,n),n===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new _n.a("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(1===t.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),1===t.size?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new _n.a("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find((t=>t[1]===e))[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new $g(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>1)),e.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((e,n)=>{if(n<2)return"";const i=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[i,n])})),e.buttonNextView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),e.buttonPrevView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),e}_createFakePanelsView(){const e=new Hg(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>=2?Math.min(e-1,2):0)),e.listenTo(this.view,"change:top",(()=>e.updatePosition())),e.listenTo(this.view,"change:left",(()=>e.updatePosition())),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:n=!0,singleViewMode:i=!1}){this.view.class=t,this.view.withArrow=n,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),i&&(this._singleViewMode=!0)}_getBalloonPosition(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&!e.limiter&&(e=Object.assign({},e,{limiter:this.positionLimiter})),e}}class $g extends Hl{constructor(e){super(e);const t=e.t,n=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new hl,this.buttonPrevView=this._createButtonView(t("Previous"),''),this.buttonNextView=this._createButtonView(t("Next"),''),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",n.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const n=new gd(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n}}class Hg extends Hl{constructor(e,t){super(e);const n=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",n.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:n.to("top",Lg),left:n.to("left",Lg),width:n.to("width",Lg),height:n.to("height",Lg)}},children:this.content}),this.on("change:numberOfPanels",((e,t,n,i)=>{n>i?this._addPanels(n-i):this._removePanels(i-n),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new Hl;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:n,height:i}=new bs(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:n,height:i})}}}function qg(e){const t=e.editing.view,n=Wh.defaultPositions;return{target:t.domConverter.viewToDom(t.document.selection.getSelectedElement()),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast]}}
+class Ng extends Ze{refresh(){const e=this.editor.model,t=js(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Vg(t,e.schema)}execute(e={}){const t=this.editor.model,n=t.document;t.change((i=>{const o=(e.selection||n.selection).getSelectedBlocks();for(const e of o)!e.is("element","paragraph")&&Vg(e,t.schema)&&i.rename(e,"paragraph")}))}}function Vg(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class Bg extends Ze{execute(e){const t=this.editor.model;let n=e.position;t.change((e=>{const i=e.createElement("paragraph");if(!t.schema.checkChild(n.parent,i)){const o=t.schema.findAllowedParent(n,i);if(!o)return;n=e.split(n,o).position}t.insertContent(i,n),e.setSelection(i,"in")}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Wg extends Rd{static get requires(){return[jg]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(n=>{const i=e.commands.get("imageTextAlternative"),o=new gd(n);return o.set({label:t("Change image text alternative"),icon:'',tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled"),this.listenTo(o,"execute",(()=>{this._showForm()})),o}))}_createForm(){const e=this.editor,t=e.editing.view.document;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new zg(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{lf(t.selection)?this._isVisible&&
+ */class Dg extends Qe{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Ng(e)),e.commands.add("insertParagraph",new Bg(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Dg.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Dg.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-function(e){const t=e.plugins.get("ContextualBalloon");if(lf(e.editing.view.document.selection)){const n=qg(e);t.updatePosition(n)}}(e):this._hideForm(!0)})),vd({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;const e=this.editor,t=e.commands.get("imageTextAlternative"),n=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:qg(e)}),n.fieldView.value=n.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Ug extends Rd{static get requires(){return[Ig,Wg]}static get pluginName(){return"ImageTextAlternative"}}n(70);
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Kg extends Rd{static get requires(){return[mf,Sg,Ug]}static get pluginName(){return"Image"}}
+ */
+class zg extends Ze{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=js(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>Fg(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,n=t.document,i=e.value;t.change((e=>{const o=Array.from(n.selection.getSelectedBlocks()).filter((e=>Fg(e,i,t.schema)));for(const t of o)t.is("element",i)||e.rename(t,i)}))}}function Fg(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Gg extends Hl{constructor(e){super(e),this.buttonView=new gd(e),this._fileInputView=new Jg(e),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 Jg extends Hl{constructor(e){super(e),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}
+ */const Lg="paragraph";class jg extends Qe{static get pluginName(){return"HeadingEditing"}constructor(e){super(e),e.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[Dg]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const i of t)i.model!==Lg&&(e.model.schema.register(i.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(i),n.push(i.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new zg(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,i)=>{const o=e.model.document.selection.getFirstPosition().parent;n.some((e=>o.is("element",e.model)))&&!o.is("element",Lg)&&0===o.childCount&&i.writer.rename(o,Lg)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:a.get("low")+1})}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Xg(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function Qg(e){return new Promise(((t,n)=>{const i=e.getAttribute("src");fetch(i).then((e=>e.blob())).then((e=>{const n=Yg(e,i),o=n.replace("image/",""),r=new File([e],`image.${o}`,{type:n});t(r)})).catch((e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise(((t,n)=>{const i=pr.document.createElement("img");i.addEventListener("load",(()=>{const e=pr.document.createElement("canvas");e.width=i.width,e.height=i.height;e.getContext("2d").drawImage(i,0,0),e.toBlob((e=>e?t(e):n()))})),i.addEventListener("error",(()=>n())),i.src=e}))}(e).then((t=>{const n=Yg(t,e),i=n.replace("image/","");return new File([t],`image.${i}`,{type:n})}))}(i).then(t).catch(n):n(e)))}))}function Yg(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}
+ */n(13);
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class $g extends Qe{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,n=function(e){const t=e.t,n={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=n[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),i=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},s=new ai,a=e.commands.get("heading"),c=e.commands.get("paragraph"),l=[a];for(const e of n){const t={type:"button",model:new iu({label:e.title,class:e.class,withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(c,"value"),t.model.set("commandName","paragraph"),l.push(c)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),s.add(t),r[e.model]=e.title}const d=Ud(t);return Kd(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:o}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",c,"value",((e,t)=>{const n=e||t&&"paragraph";return r[n]?r[n]:i})),this.listenTo(d,"execute",(t=>{e.execute(t.source.commandName,t.source.commandValue?{value:t.source.commandValue}:void 0),e.editing.view.focus()})),d}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Zg extends Rd{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageUpload",(n=>{const i=new Gg(n),o=e.commands.get("imageUpload"),r=e.config.get("image.upload.types"),s=Xg(r);return i.set({acceptedType:r.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0}),i.buttonView.set({label:t("Insert image"),icon:'',tooltip:!0}),i.buttonView.bind("isEnabled").to(o),i.on("done",((t,n)=>{const i=Array.from(n).filter((e=>s.test(e.type)));i.length&&e.execute("imageUpload",{file:i})})),i}))}}n(72),n(74),n(76);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class ep extends Rd{constructor(e){super(e),this.placeholder="data:image/svg+xml;utf8,"+encodeURIComponent('')}init(){this.editor.editing.downcastDispatcher.on("attribute:uploadStatus:image",((...e)=>this.uploadStatusChange(...e)))}uploadStatusChange(e,t,n){const i=this.editor,o=t.item,r=o.getAttribute("uploadId");if(!n.consumable.consume(t.item,e.name))return;const s=i.plugins.get(zu),a=r?t.attributeNewValue:null,c=this.placeholder,l=i.editing.mapper.toViewElement(o),d=n.writer;if("reading"==a)return tp(l,d),void np(c,l,d);if("uploading"==a){const e=s.loaders.get(r);return tp(l,d),void(e?(ip(l,d),function(e,t,n,i){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),n.on("change:uploadedPercent",((e,t,n)=>{i.change((e=>{e.setStyle("width",n+"%",o)}))}))}(l,d,e,i.editing.view),function(e,t,n){if(n.data){const i=ff(e);t.setAttribute("src",n.data,i)}}
+class Hg extends Qe{static get requires(){return[uu]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!rh(t))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(l,d,e)):np(c,l,d))}"complete"==a&&s.loaders.get(r)&&function(e,t,n){const i=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),i),setTimeout((()=>{n.change((e=>e.remove(e.createRangeOn(i))))}),3e3)}(l,d,i.editing.view),function(e,t){rp(e,t,"progressBar")}(l,d),ip(l,d),function(e,t){t.removeClass("ck-appear",e)}(l,d)}}function tp(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function np(e,t,n){t.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",t);const i=ff(t);i.getAttribute("src")!==e&&n.setAttribute("src",e,i),op(t,"placeholder")||n.insert(n.createPositionAfter(i),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function ip(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),rp(e,t,"placeholder")}function op(e,t){for(const n of e.getChildren())if(n.getCustomProperty(t))return n}function rp(e,t,n){const i=op(e,n);i&&t.remove(t.createRangeOn(i))}class sp{constructor(e){this.document=e}createDocumentFragment(e){return new Fo(this.document,e)}createElement(e,t,n){return new Hi(this.document,e,t,n)}createText(e){return new qn(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const i=n.getChildIndex(e);return this.removeChildren(i,1,n),this.insertChild(i,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new Hi(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){y(e)&&void 0===n&&(n=t),n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return co._createAt(e,t)}createPositionAfter(e){return co._createAfter(e)}createPositionBefore(e){return co._createBefore(e)}createRange(e,t){return new lo(e,t)}createRangeOn(e){return lo._createOn(e)}createRangeIn(e){return lo._createIn(e)}createSelection(e,t,n){return new fo(e,t,n)}}
+ */)(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:n,getRelatedElement:i,balloonClassName:o="ck-toolbar-container"}){if(!n.length)return void Object(c.b)("widget-toolbar-no-items",{toolbarId:e});const r=this.editor,s=r.t,a=new Fd(r.locale);if(a.ariaLabel=t||s("Widget toolbar"),this._toolbarDefinitions.has(e))throw new c.a("widget-toolbar-duplicated",this,{toolbarId:e});a.fillFromConfig(n,r.ui.componentFactory),this._toolbarDefinitions.set(e,{view:a,getRelatedElement:i,balloonClassName:o})}_updateToolbarsVisibility(){let e=0,t=null,n=null;for(const i of this._toolbarDefinitions.values()){const o=i.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const r=o.getAncestors().length;r>e&&(e=r,t=o,n=i)}else this._isToolbarVisible(i)&&this._hideToolbar(i);else this._isToolbarInBalloon(i)&&this._hideToolbar(i)}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?qg(this.editor,t):this._isToolbarInBalloon(e)||(this._balloon.add({view:e.view,position:Wg(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);qg(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function qg(e,t){const n=e.plugins.get("ContextualBalloon"),i=Wg(e,t);n.updatePosition(i)}function Wg(e,t){const n=e.editing.view,i=su.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,gh]}}class Ug{constructor(e){this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}begin(e,t,n){const i=new Vs(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)if(e.classList.contains(Kg(n)))return n}(e),this._referenceCoordinates=function(e,t){const n=new Vs(e),i=t.split("-"),o={x:"right"==i[1]?n.right:n.left,y:"bottom"==i[0]?n.bottom:n.top};return o.x+=e.ownerDocument.defaultView.scrollX,o.y+=e.ownerDocument.defaultView.scrollY,o}(t,function(e){const t=e.split("-"),n={top:"bottom",bottom:"top",left:"right",right:"left"};return`${n[t[0]]}-${n[t[1]]}`}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class ap extends Fd{refresh(){const e=this.editor.model.document.selection.getSelectedElement(),t=e&&"image"===e.name||!1;this.isEnabled=hf(this.editor.model)||t}execute(e){const t=this.editor,n=t.model,i=t.plugins.get(zu);for(const t of Vn(e.file))cp(n,i,t)}}function cp(e,t,n){const i=t.createLoader(n);i&&uf(e,{uploadId:i.id})}
+ */(this.activeHandlePosition)),this.originalWidth=i.width,this.originalHeight=i.height,this.aspectRatio=i.width/i.height;const o=n.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this.originalWidthPercents=parseFloat(o):this.originalWidthPercents=function(e,t){const n=e.parentElement,i=parseFloat(n.ownerDocument.defaultView.getComputedStyle(n).width);return t.width/i*100}(n,i)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function Kg(e){return`ck-widget__resizer__handle-${e}`}Xe(Ug,qe);class Gg{constructor(e){this._options=e,this._domResizerWrapper=null,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())}),{priority:"high"}),this.on("change:isEnabled",(()=>{this.isEnabled&&this.redraw()}))}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change((n=>{const i=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const n=this.toDomElement(t);return e._appendHandles(n),e._appendSizeUI(n),e._domResizerWrapper=n,e.on("change:isEnabled",((e,t,i)=>{n.style.display=i?"":"none"})),n.style.display=e.isEnabled?"":"none",n}));n.insert(n.createPositionAt(t,"end"),i),n.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=i}))}begin(e){this.state=new Ug(this._options),this._sizeUI.bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change((e=>{const n=this._options.unit||"%",i=("%"===n?t.widthPercents:t.width)+n;e.setStyle("width",i,this._options.viewElement)}));const n=this._getHandleHost(),i=new Vs(n);t.handleHostWidth=Math.round(i.width),t.handleHostHeight=Math.round(i.height);const o=new Vs(n);t.width=Math.round(o.width),t.height=Math.round(o.height),this.redraw(i),this.state.update(t)}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(t)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((n=t)&&n.ownerDocument&&n.ownerDocument.contains(n)))return;var n;const i=t.parentElement,o=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(i.isSameNode(o)){const t=e||new Vs(o);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];"same"!==mi(s,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)}))}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeUI.dismiss(),this._sizeUI.isVisible=!1;this._options.editor.editing.view.change((e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(e){const t=this.state,n={x:(i=e).pageX,y:i.pageY};var i;const o=!this._options.isCentered||this._options.isCentered(this),r={x:t._referenceCoordinates.x-(n.x+t.originalWidth),y:n.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(r.x=n.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(r.x*=2);const s={width:Math.abs(t.originalWidth+r.x),height:Math.abs(t.originalHeight+r.y)};s.dominant=s.width/t.aspectRatio>s.height?"width":"height",s.max=s[s.dominant];const a={width:s.width,height:s.height};return"width"==s.dominant?a.height=a.width/t.aspectRatio:a.width=a.height*t.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)e.appendChild(new ed({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(n=i,`ck-widget__resizer__handle-${n}`)}}).render());var n}_appendSizeUI(e){const t=new Jg;t.render(),this._sizeUI=t,e.appendChild(t.element)}}Xe(Gg,qe);class Jg extends Zl{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("activeHandlePosition",(e=>e?`ck-orientation-${e}`:""))],style:{display:e.if("isVisible","none",(e=>!e))}},children:[{text:e.to("label")}]})}bindToState(e,t){this.bind("isVisible").to(t,"proposedWidth",t,"proposedHeight",((e,t)=>null!==e&&null!==t)),this.bind("label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",((t,n,i)=>"px"===e.unit?`${t}×${n}`:`${i}%`)),this.bind("activeHandlePosition").to(t)}dismiss(){this.unbind(),this.isVisible=!1}}n(74);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class lp extends Rd{static get requires(){return[zu,cg,Dd]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}})}init(){const e=this.editor,t=e.model.document,n=e.model.schema,i=e.conversion,o=e.plugins.get(zu),r=Xg(e.config.get("image.upload.types"));n.extend("image",{allowAttributes:["uploadId","uploadStatus"]}),e.commands.add("imageUpload",new ap(e)),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{if(i=n.dataTransfer,Array.from(i.types).includes("text/html")&&""!==i.getData("text/html"))return;var i;const o=Array.from(n.dataTransfer.files).filter((e=>!!e&&r.test(e.type))),s=n.targetRanges.map((t=>e.editing.mapper.toModelRange(t)));e.model.change((n=>{n.setSelection(s),o.length&&(t.stop(),e.model.enqueueChange("default",(()=>{e.execute("imageUpload",{file:o})})))}))})),this.listenTo(e.plugins.get(Dd),"inputTransformation",((t,n)=>{const i=Array.from(e.editing.view.createRangeIn(n.content)).filter((e=>{return!(!(t=e.item).is("element","img")||!t.getAttribute("src"))&&(t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||t.getAttribute("src").match(/^blob:/g))&&!e.item.getAttribute("uploadProcessed");var t})).map((e=>({promise:Qg(e.item),imageElement:e.item})));if(!i.length)return;const r=new sp(e.editing.view.document);for(const e of i){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=o.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const n=t.differ.getChanges({includeChangesInGraveyard:!0});for(const t of n)if("insert"==t.type&&"$text"!=t.name){const n=t.position.nodeAfter,i="$graveyard"==t.position.root.rootName;for(const t of dp(e,n)){const e=t.getAttribute("uploadId");if(!e)continue;const n=o.loaders.get(e);n&&(i?n.abort():"idle"==n.status&&this._readAndUpload(n,t))}}}))}_readAndUpload(e,t){const n=this.editor,i=n.model,o=n.locale.t,r=n.plugins.get(zu),s=n.plugins.get(cg);return i.enqueueChange("transparent",(e=>{e.setAttribute("uploadStatus","reading",t)})),e.read().then((()=>{const o=e.upload();if(yo.isSafari){const e=ff(n.editing.mapper.toViewElement(t));n.editing.view.once("render",(()=>{if(!e.parent)return;const t=n.editing.view.domConverter.mapViewToDom(e.parent);if(!t)return;const i=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=i}))}return i.enqueueChange("transparent",(e=>{e.setAttribute("uploadStatus","uploading",t)})),o})).then((e=>{i.enqueueChange("transparent",(n=>{n.setAttributes({uploadStatus:"complete",src:e.default},t),this._parseAndSetSrcsetAttributeOnImage(e,t,n)})),a()})).catch((n=>{if("error"!==e.status&&"aborted"!==e.status)throw n;"error"==e.status&&n&&s.showWarning(n,{title:o("Upload failed"),namespace:"upload"}),a(),i.enqueueChange("transparent",(e=>{e.remove(t)}))}));function a(){i.enqueueChange("transparent",(e=>{e.removeAttribute("uploadId",t),e.removeAttribute("uploadStatus",t)})),r.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,n){let i=0;const o=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return i=Math.max(i,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");""!=o&&n.setAttribute("srcset",{data:o,width:i},t)}}function dp(e,t){return Array.from(e.model.createRangeOn(t)).filter((e=>e.item.is("element","image"))).map((e=>e.item))}
+ */Xe(class extends Qe{static get pluginName(){return"WidgetResize"}init(){this.set("visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map;const e=Sr.window.document;this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0}),this.editor.editing.view.addObserver(Nu),this._observer=Object.create(Dr),this.listenTo(this.editor.editing.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this));const t=()=>{this.visibleResizer&&this.visibleResizer.redraw()},n=Rh(t,200);this.on("change:visibleResizer",t),this.editor.ui.on("update",n),this._observer.listenTo(Sr.window,"resize",n);const i=this.editor.editing.view.document.selection;i.on("change",(()=>{const e=i.getSelectedElement();this.visibleResizer=this.getResizerByViewElement(e)||null}))}destroy(){this._observer.stopListening();for(const e of this._resizers.values())e.destroy()}attachTo(e){const t=new Gg(e),n=this.editor.plugins;if(t.attach(),n.has("WidgetToolbarRepository")){const e=n.get("WidgetToolbarRepository");t.on("begin",(()=>{e.forceDisabled("resize")}),{priority:"lowest"}),t.on("cancel",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"}),t.on("commit",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(e.viewElement,t);const i=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(i)==t&&(this.visibleResizer=t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const n=t.domTarget;Gg.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n),this._activeResizer&&(this._activeResizer.begin(n),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}},qe);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class up extends Rd{static get pluginName(){return"ImageUpload"}static get requires(){return[lp,Zg,ep]}}
+ */
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1291,45 +1434,61 @@ class ep extends Rd{constructor(e){super(e),this.placeholder="data:image/svg+xml
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class hp extends Fd{refresh(){const e=this.editor.model,t=Uu(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&fp(t,e.schema)}execute(e={}){const t=this.editor.model,n=t.document;t.change((i=>{const o=(e.selection||n.selection).getSelectedBlocks();for(const e of o)!e.is("element","paragraph")&&fp(e,t.schema)&&i.rename(e,"paragraph")}))}}function fp(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}
+class Xg extends Lr{observe(e){this.listenTo(e,"load",((e,t)=>{const n=t.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(t)}),{useCapture:!0})}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */function Qg(e){return!!e.getCustomProperty("image")&&rh(e)}function Yg(e){const t=e.getSelectedElement();return t&&Qg(t)?t:null}function Zg(e){return!!e&&e.is("element","image")}function ep(e,t={},n=null){e.change((i=>{const o=i.createElement("image",t),r=n||hh(e.document.selection,e);e.insertContent(o,r),o.parent&&i.setSelection(o,"on")}))}function tp(e){const t=e.schema,n=e.document.selection;return function(e,t,n){const i=function(e,t){const n=hh(e,t).parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */(e,n);return t.checkChild(i,"image")}(n,t,e)&&!fh(n,t)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","image")))}(n)}function np(e){const t=[];for(const n of e.getChildren())t.push(n),n.is("element")&&t.push(...n.getChildren());return t.find((e=>e.is("element","img")))}function ip(e){return n=>{n.on(`attribute:${e}:image`,t)};function t(e,t,n){if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=np(n.mapper.toViewElement(t.item));i.setAttribute(t.attributeKey,t.attributeNewValue||"",o)}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class op extends Ze{refresh(){this.isEnabled=tp(this.editor.model)}execute(e){const t=this.editor.model;for(const n of li(e.source))ep(t,{src:n})}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class gp extends Fd{execute(e){const t=this.editor.model;let n=e.position;t.change((e=>{const i=e.createElement("paragraph");if(!t.schema.checkChild(n.parent,i)){const o=t.schema.findAllowedParent(n,i);if(!o)return;n=e.split(n,o).position}t.insertContent(i,n),e.setSelection(i,"in")}))}}
+ */class rp extends Qe{static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.model.schema,n=e.t,i=e.conversion;e.editing.view.addObserver(Xg),t.register("image",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["alt","src","srcset"]}),i.for("dataDowncast").elementToElement({model:"image",view:(e,{writer:t})=>sp(t)}),i.for("editingDowncast").elementToElement({model:"image",view:(e,{writer:t})=>function(e,t,n){return t.setCustomProperty("image",!0,e),sh(e,t,{label:function(){const t=np(e).getAttribute("alt");return t?`${t} ${n}`:n}})}(sp(t),t,n("image widget"))}),i.for("downcast").add(ip("src")).add(ip("alt")).add(function(){return t=>{t.on("attribute:srcset:image",e)};function e(e,t,n){if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=np(n.mapper.toViewElement(t.item));if(null===t.attributeNewValue){const e=t.attributeOldValue;e.data&&(i.removeAttribute("srcset",o),i.removeAttribute("sizes",o),e.width&&i.removeAttribute("width",o))}else{const e=t.attributeNewValue;e.data&&(i.setAttribute("srcset",e.data,o),i.setAttribute("sizes","100vw",o),e.width&&i.setAttribute("width",e.width,o))}}}()),i.for("upcast").elementToElement({view:{name:"img",attributes:{src:!0}},model:(e,{writer:t})=>t.createElement("image",{src:e.getAttribute("src")})}).attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}}).add(function(){return t=>{t.on("element:figure",e)};function e(e,t,n){if(!n.consumable.test(t.viewItem,{name:!0,classes:"image"}))return;const i=np(t.viewItem);if(!i||!i.hasAttribute("src")||!n.consumable.test(i,{name:!0}))return;const o=js(n.convertItem(i,t.modelCursor).modelRange.getItems());o&&(n.convertChildren(t.viewItem,o),n.updateConversionResult(o,t))}}());const o=new op(e);e.commands.add("insertImage",o),e.commands.add("imageInsert",o)}}function sp(e){const t=e.createEmptyElement("img"),n=e.createContainerElement("figure",{class:"image"});return e.insert(e.createPositionAt(n,0),t),n}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class pp extends Rd{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new hp(e)),e.commands.add("insertParagraph",new gp(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>pp.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}pp.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);
+ */class ap extends Ze{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=Zg(e),Zg(e)&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor.model,n=t.document.selection.getSelectedElement();t.change((t=>{t.setAttribute("alt",e.newValue,n)}))}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class cp extends Qe{static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new ap(this.editor))}}n(76),n(11);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class mp extends Fd{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=Uu(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>bp(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,n=t.document,i=e.value;t.change((e=>{const o=Array.from(n.selection.getSelectedBlocks()).filter((e=>bp(e,i,t.schema)));for(const t of o)t.is("element",i)||e.rename(t,i)}))}}function bp(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}
+class lp extends Zl{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new $s,this.keystrokes=new Hs,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Fl,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),zl,"ck-button-cancel","cancel"),this._focusables=new Yl,this._focusCycler=new Cd({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]}),Xl(this)}render(){super.render(),this.keystrokes.listenTo(this.element),Ql({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}_createButton(e,t,n,i){const o=new xd(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createLabeledInputView(){const e=this.locale.t,t=new eu(this.locale,tu);return t.label=e("Text alternative"),t}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */const kp="paragraph";class wp extends Rd{static get pluginName(){return"HeadingEditing"}constructor(e){super(e),e.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[pp]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const i of t)i.model!==kp&&(e.model.schema.register(i.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(i),n.push(i.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new mp(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,i)=>{const o=e.model.document.selection.getFirstPosition().parent;n.some((e=>o.is("element",e.model)))&&!o.is("element",kp)&&0===o.childCount&&i.writer.rename(o,kp)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:wn.get("low")+1})}}
+ */function dp(e){const t=e.editing.view,n=su.defaultPositions;return{target:t.domConverter.viewToDom(t.document.selection.getSelectedElement()),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast]}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */n(13);
+ */class up extends Qe{static get requires(){return[uu]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(n=>{const i=e.commands.get("imageTextAlternative"),o=new xd(n);return o.set({label:t("Change image text alternative"),icon:Ll,tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled"),this.listenTo(o,"execute",(()=>{this._showForm()})),o}))}_createForm(){const e=this.editor,t=e.editing.view.document;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new lp(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{Yg(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(Yg(e.editing.view.document.selection)){const n=dp(e);t.updatePosition(n)}}(e):this._hideForm(!0)})),Jl({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;const e=this.editor,t=e.commands.get("imageTextAlternative"),n=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:dp(e)}),n.fieldView.value=n.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class _p extends Rd{init(){const e=this.editor,t=e.t,n=function(e){const t=e.t,n={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=n[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),i=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},s=new Mn,a=e.commands.get("heading"),c=e.commands.get("paragraph"),l=[a];for(const e of n){const t={type:"button",model:new Sh({label:e.title,class:e.class,withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(c,"value"),t.model.set("commandName","paragraph"),l.push(c)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),s.add(t),r[e.model]=e.title}const d=yd(t);return xd(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:o}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",c,"value",((e,t)=>{const n=e||t&&"paragraph";return r[n]?r[n]:i})),this.listenTo(d,"execute",(t=>{e.execute(t.source.commandName,t.source.commandValue?{value:t.source.commandValue}:void 0),e.editing.view.focus()})),d}))}}
+ */class hp extends Qe{static get requires(){return[cp,up]}static get pluginName(){return"ImageTextAlternative"}}n(79);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function vp(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}function yp(e){const t=e.parent;return"figcaption"==e.name&&t&&"figure"==t.name&&t.hasClass("image")?{name:!0}:null}
+ */function fp(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}function gp(e){const t=e.parent;return"figcaption"==e.name&&t&&"figure"==t.name&&t.hasClass("image")?{name:!0}:null}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class xp extends Rd{static get pluginName(){return"ImageCaptionEditing"}init(){const e=this.editor,t=e.editing.view,n=e.model.schema,i=e.data,o=e.editing,r=e.t;n.register("caption",{allowIn:"image",allowContentOf:"$block",isLimit:!0}),e.model.document.registerPostFixer((e=>this._insertMissingModelCaptionElement(e))),e.conversion.for("upcast").elementToElement({view:yp,model:"caption"});i.downcastDispatcher.on("insert:caption",Cp((e=>e.createContainerElement("figcaption")),!1));const s=
+ */class pp extends Qe{static get pluginName(){return"ImageCaptionEditing"}init(){const e=this.editor,t=e.editing.view,n=e.model.schema,i=e.data,o=e.editing,r=e.t;n.register("caption",{allowIn:"image",allowContentOf:"$block",isLimit:!0}),e.model.document.registerPostFixer((e=>this._insertMissingModelCaptionElement(e))),e.conversion.for("upcast").elementToElement({view:gp,model:"caption"});i.downcastDispatcher.on("insert:caption",mp((e=>e.createContainerElement("figcaption")),!1));const s=
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-function(e,t){return n=>{const i=n.createEditableElement("figcaption");return n.setCustomProperty("imageCaption",!0,i),ml({view:e,element:i,text:t}),rf(i,n)}}(t,r("Enter image caption"));o.downcastDispatcher.on("insert:caption",Cp(s)),o.downcastDispatcher.on("insert",this._fixCaptionVisibility((e=>e.item)),{priority:"high"}),o.downcastDispatcher.on("remove",this._fixCaptionVisibility((e=>e.position.parent)),{priority:"high"}),t.document.registerPostFixer((e=>this._updateCaptionVisibility(e)))}_updateCaptionVisibility(e){const t=this.editor.editing.mapper,n=this._lastSelectedCaption;let i;const o=this.editor.model.document.selection,r=o.getSelectedElement();if(r&&r.is("element","image")){const e=vp(r);i=t.toViewElement(e)}const s=Ap(o.getFirstPosition().parent);if(s&&(i=t.toViewElement(s)),i&&!this.editor.isReadOnly)return n?(n===i||(Tp(n,e),this._lastSelectedCaption=i),Pp(i,e)):(this._lastSelectedCaption=i,Pp(i,e));if(n){const t=Tp(n,e);return this._lastSelectedCaption=null,t}return!1}_fixCaptionVisibility(e){return(t,n,i)=>{const o=Ap(e(n)),r=this.editor.editing.mapper,s=i.writer;if(o){const e=r.toViewElement(o);e&&(o.childCount?s.removeClass("ck-hidden",e):s.addClass("ck-hidden",e))}}}_insertMissingModelCaptionElement(e){const t=this.editor.model,n=t.document.differ.getChanges(),i=[];for(const e of n)if("insert"==e.type&&"$text"!=e.name){const n=e.position.nodeAfter;if(n.is("element","image")&&!vp(n)&&i.push(n),!n.is("element","image")&&n.childCount)for(const e of t.createRangeIn(n).getItems())e.is("element","image")&&!vp(e)&&i.push(e)}for(const t of i)e.appendElement("caption",t);return!!i.length}}function Cp(e,t=!0){return(n,i,o)=>{const r=i.item;if((r.childCount||t)&&df(r.parent)){if(!o.consumable.consume(i.item,"insert"))return;const t=o.mapper.toViewElement(i.range.start.parent),n=e(o.writer),s=o.writer;r.childCount||s.addClass("ck-hidden",n),function(e,t,n,i){const o=i.writer.createPositionAt(n,"end");i.writer.insert(o,e),i.mapper.bindElements(t,e)}(n,i.item,t,o)}}}function Ap(e){const t=e.getAncestors({includeSelf:!0}).find((e=>"caption"==e.name));return t&&t.parent&&"image"==t.parent.name?t:null}function Tp(e,t){return!e.childCount&&!e.hasClass("ck-hidden")&&(t.addClass("ck-hidden",e),!0)}function Pp(e,t){return!!e.hasClass("ck-hidden")&&(t.removeClass("ck-hidden",e),!0)}n(79);
+function(e,t){return n=>{const i=n.createEditableElement("figcaption");return n.setCustomProperty("imageCaption",!0,i),bu({view:e,element:i,text:t}),uh(i,n)}}(t,r("Enter image caption"));o.downcastDispatcher.on("insert:caption",mp(s)),o.downcastDispatcher.on("insert",this._fixCaptionVisibility((e=>e.item)),{priority:"high"}),o.downcastDispatcher.on("remove",this._fixCaptionVisibility((e=>e.position.parent)),{priority:"high"}),t.document.registerPostFixer((e=>this._updateCaptionVisibility(e)))}_updateCaptionVisibility(e){const t=this.editor.editing.mapper,n=this._lastSelectedCaption;let i;const o=this.editor.model.document.selection,r=o.getSelectedElement();if(r&&r.is("element","image")){const e=fp(r);i=t.toViewElement(e)}const s=bp(o.getFirstPosition().parent);if(s&&(i=t.toViewElement(s)),i&&!this.editor.isReadOnly)return n?(n===i||(kp(n,e),this._lastSelectedCaption=i),wp(i,e)):(this._lastSelectedCaption=i,wp(i,e));if(n){const t=kp(n,e);return this._lastSelectedCaption=null,t}return!1}_fixCaptionVisibility(e){return(t,n,i)=>{const o=bp(e(n)),r=this.editor.editing.mapper,s=i.writer;if(o){const e=r.toViewElement(o);e&&(o.childCount?s.removeClass("ck-hidden",e):s.addClass("ck-hidden",e))}}}_insertMissingModelCaptionElement(e){const t=this.editor.model,n=t.document.differ.getChanges(),i=[];for(const e of n)if("insert"==e.type&&"$text"!=e.name){const n=e.position.nodeAfter;if(n.is("element","image")&&!fp(n)&&i.push(n),!n.is("element","image")&&n.childCount)for(const e of t.createRangeIn(n).getItems())e.is("element","image")&&!fp(e)&&i.push(e)}for(const t of i)e.appendElement("caption",t);return!!i.length}}function mp(e,t=!0){return(n,i,o)=>{const r=i.item;if((r.childCount||t)&&Zg(r.parent)){if(!o.consumable.consume(i.item,"insert"))return;const t=o.mapper.toViewElement(i.range.start.parent),n=e(o.writer),s=o.writer;r.childCount||s.addClass("ck-hidden",n),function(e,t,n,i){const o=i.writer.createPositionAt(n,"end");i.writer.insert(o,e),i.mapper.bindElements(t,e)}(n,i.item,t,o)}}}function bp(e){const t=e.getAncestors({includeSelf:!0}).find((e=>"caption"==e.name));return t&&t.parent&&"image"==t.parent.name?t:null}function kp(e,t){return!e.childCount&&!e.hasClass("ck-hidden")&&(t.addClass("ck-hidden",e),!0)}function wp(e,t){return!!e.hasClass("ck-hidden")&&(t.removeClass("ck-hidden",e),!0)}n(81);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1338,99 +1497,127 @@ function(e,t){return n=>{const i=n.createEditableElement("figcaption");return n.
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Sp extends Fd{constructor(e,t){super(e),this.defaultStyle=!1,this.styles=t.reduce(((e,t)=>(e[t.name]=t,t.isDefault&&(this.defaultStyle=t.name),e)),{})}refresh(){const e=this.editor.model.document.selection.getSelectedElement();if(this.isEnabled=df(e),e)if(e.hasAttribute("imageStyle")){const t=e.getAttribute("imageStyle");this.value=!!this.styles[t]&&t}else this.value=this.defaultStyle;else this.value=!1}execute(e){const t=e.value,n=this.editor.model,i=n.document.selection.getSelectedElement();n.change((e=>{this.styles[t].isDefault?e.removeAttribute("imageStyle",i):e.setAttribute("imageStyle",t,i)}))}}
+class _p extends Ze{constructor(e,t){super(e),this.defaultStyle=!1,this.styles=t.reduce(((e,t)=>(e[t.name]=t,t.isDefault&&(this.defaultStyle=t.name),e)),{})}refresh(){const e=this.editor.model.document.selection.getSelectedElement();if(this.isEnabled=Zg(e),e)if(e.hasAttribute("imageStyle")){const t=e.getAttribute("imageStyle");this.value=!!this.styles[t]&&t}else this.value=this.defaultStyle;else this.value=!1}execute(e){const t=e.value,n=this.editor.model,i=n.document.selection.getSelectedElement();n.change((e=>{this.styles[t].isDefault?e.removeAttribute("imageStyle",i):e.setAttribute("imageStyle",t,i)}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Ep(e,t){for(const n of t)if(n.name===e)return n}var Rp='',Ip='',Op='',Mp='';
+ */function vp(e,t){for(const n of t)if(n.name===e)return n}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-const Np={full:{name:"full",title:"Full size image",icon:Rp,isDefault:!0},side:{name:"side",title:"Side image",icon:Mp,className:"image-style-side"},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:Ip,className:"image-style-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:Op,className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:Mp,className:"image-style-align-right"}},Vp={full:Rp,left:Ip,right:Mp,center:Op};function Bp(e=[]){return e.map(Dp)}function Dp(e){if("string"==typeof e){const t=e;Np[t]?e=Object.assign({},Np[t]):(Object(_n.c)("image-style-not-found",{name:t}),e={name:t})}else if(Np[e.name]){const t=Np[e.name],n=Object.assign({},e);for(const i in t)Object.prototype.hasOwnProperty.call(e,i)||(n[i]=t[i]);e=n}return"string"==typeof e.icon&&Vp[e.icon]&&(e.icon=Vp[e.icon]),e}
+ */const yp={full:{name:"full",title:"Full size image",icon:Wl,isDefault:!0},side:{name:"side",title:"Side image",icon:ql,className:"image-style-side"},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:$l,className:"image-style-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:Hl,className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:ql,className:"image-style-align-right"}},xp={full:Wl,left:$l,right:ql,center:Hl};function Ap(e=[]){return e.map(Cp)}function Cp(e){if("string"==typeof e){const t=e;yp[t]?e=Object.assign({},yp[t]):(Object(c.b)("image-style-not-found",{name:t}),e={name:t})}else if(yp[e.name]){const t=yp[e.name],n=Object.assign({},e);for(const i in t)Object.prototype.hasOwnProperty.call(e,i)||(n[i]=t[i]);e=n}return"string"==typeof e.icon&&xp[e.icon]&&(e.icon=xp[e.icon]),e}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Fp extends Rd{static get pluginName(){return"ImageStyleEditing"}init(){const e=this.editor,t=e.model.schema,n=e.data,i=e.editing;e.config.define("image.styles",["full","side"]);const o=Bp(e.config.get("image.styles"));t.extend("image",{allowAttributes:"imageStyle"});const r=function(e){return(t,n,i)=>{if(!i.consumable.consume(n.item,t.name))return;const o=Ep(n.attributeNewValue,e),r=Ep(n.attributeOldValue,e),s=i.mapper.toViewElement(n.item),a=i.writer;r&&a.removeClass(r.className,s),o&&a.addClass(o.className,s)}}(o);i.downcastDispatcher.on("attribute:imageStyle:image",r),n.downcastDispatcher.on("attribute:imageStyle:image",r),n.upcastDispatcher.on("element:figure",function(e){const t=e.filter((e=>!e.isDefault));return(e,n,i)=>{if(!n.modelRange)return;const o=n.viewItem,r=Uu(n.modelRange.getItems());if(!r||i.schema.checkAttribute(r,"imageStyle"))for(const e of t)i.consumable.consume(o,{classes:e.className})&&i.writer.setAttribute("imageStyle",e.name,r)}}(o),{priority:"low"}),e.commands.add("imageStyle",new Sp(e,o))}}n(81);
+ */class Tp extends Qe{static get pluginName(){return"ImageStyleEditing"}init(){const e=this.editor,t=e.model.schema,n=e.data,i=e.editing;e.config.define("image.styles",["full","side"]);const o=Ap(e.config.get("image.styles"));t.extend("image",{allowAttributes:"imageStyle"});const r=function(e){return(t,n,i)=>{if(!i.consumable.consume(n.item,t.name))return;const o=vp(n.attributeNewValue,e),r=vp(n.attributeOldValue,e),s=i.mapper.toViewElement(n.item),a=i.writer;r&&a.removeClass(r.className,s),o&&a.addClass(o.className,s)}}(o);i.downcastDispatcher.on("attribute:imageStyle:image",r),n.downcastDispatcher.on("attribute:imageStyle:image",r),n.upcastDispatcher.on("element:figure",function(e){const t=e.filter((e=>!e.isDefault));return(e,n,i)=>{if(!n.modelRange)return;const o=n.viewItem,r=js(n.modelRange.getItems());if(!r||i.schema.checkAttribute(r,"imageStyle"))for(const e of t)i.consumable.consume(o,{classes:e.className})&&i.writer.setAttribute("imageStyle",e.name,r)}}(o),{priority:"low"}),e.commands.add("imageStyle",new _p(e,o))}}n(83);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class zp extends Rd{static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=function(e,t){for(const n of e)t[n.title]&&(n.title=t[n.title]);return e}
+ */class Pp extends Qe{static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=function(e,t){for(const n of e)t[n.title]&&(n.title=t[n.title]);return e}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(Bp(this.editor.config.get("image.styles")),this.localizedDefaultStylesTitles);for(const t of e)this._createButton(t)}_createButton(e){const t=this.editor,n=`imageStyle:${e.name}`;t.ui.componentFactory.add(n,(n=>{const i=t.commands.get("imageStyle"),o=new gd(n);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(i,"isEnabled"),o.bind("isOn").to(i,"value",(t=>t===e.name)),this.listenTo(o,"execute",(()=>{t.execute("imageStyle",{value:e.name}),t.editing.view.focus()})),o}))}}
+ */(Ap(this.editor.config.get("image.styles")),this.localizedDefaultStylesTitles);for(const t of e)this._createButton(t)}_createButton(e){const t=this.editor,n=`imageStyle:${e.name}`;t.ui.componentFactory.add(n,(n=>{const i=t.commands.get("imageStyle"),o=new xd(n);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(i,"isEnabled"),o.bind("isOn").to(i,"value",(t=>t===e.name)),this.listenTo(o,"execute",(()=>{t.execute("imageStyle",{value:e.name}),t.editing.view.focus()})),o}))}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Lp extends Rd{static get requires(){return[jg]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!ef(t))}
+function Sp(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function Ep(e){return new Promise(((t,n)=>{const i=e.getAttribute("src");fetch(i).then((e=>e.blob())).then((e=>{const n=Rp(e,i),o=n.replace("image/",""),r=new File([e],`image.${o}`,{type:n});t(r)})).catch((e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise(((t,n)=>{const i=Sr.document.createElement("img");i.addEventListener("load",(()=>{const e=Sr.document.createElement("canvas");e.width=i.width,e.height=i.height;e.getContext("2d").drawImage(i,0,0),e.toBlob((e=>e?t(e):n()))})),i.addEventListener("error",(()=>n())),i.src=e}))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */)(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:n,getRelatedElement:i,balloonClassName:o="ck-toolbar-container"}){if(!n.length)return void Object(_n.c)("widget-toolbar-no-items",{toolbarId:e});const r=this.editor,s=r.t,a=new Cd(r.locale);if(a.ariaLabel=t||s("Widget toolbar"),this._toolbarDefinitions.has(e))throw new _n.a("widget-toolbar-duplicated",this,{toolbarId:e});a.fillFromConfig(n,r.ui.componentFactory),this._toolbarDefinitions.set(e,{view:a,getRelatedElement:i,balloonClassName:o})}_updateToolbarsVisibility(){let e=0,t=null,n=null;for(const i of this._toolbarDefinitions.values()){const o=i.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const r=o.getAncestors().length;r>e&&(e=r,t=o,n=i)}else this._isToolbarVisible(i)&&this._hideToolbar(i);else this._isToolbarInBalloon(i)&&this._hideToolbar(i)}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?jp(this.editor,t):this._isToolbarInBalloon(e)||(this._balloon.add({view:e.view,position:$p(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);jp(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function jp(e,t){const n=e.plugins.get("ContextualBalloon"),i=$p(e,t);n.updatePosition(i)}function $p(e,t){const n=e.editing.view,i=Wh.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,af]}}
+ */(e).then((t=>{const n=Rp(t,e),i=n.replace("image/","");return new File([t],`image.${i}`,{type:n})}))}(i).then(t).catch(n):n(e)))}))}function Rp(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class Ip extends Qe{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,n=n=>{const i=new Pf(n),o=e.commands.get("uploadImage"),r=e.config.get("image.upload.types"),s=Sp(r);return i.set({acceptedType:r.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0}),i.buttonView.set({label:t("Insert image"),icon:jl,tooltip:!0}),i.buttonView.bind("isEnabled").to(o),i.on("done",((t,n)=>{const i=Array.from(n).filter((e=>s.test(e.type)));i.length&&e.execute("uploadImage",{file:i})})),i};e.ui.componentFactory.add("uploadImage",n),e.ui.componentFactory.add("imageUpload",n)}}n(85),n(87),n(89);
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Hp extends Qr{constructor(e){super(e),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}n(83);
+class Op extends Qe{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.placeholder="data:image/svg+xml;utf8,"+encodeURIComponent('')}init(){this.editor.editing.downcastDispatcher.on("attribute:uploadStatus:image",((...e)=>this.uploadStatusChange(...e)))}uploadStatusChange(e,t,n){const i=this.editor,o=t.item,r=o.getAttribute("uploadId");if(!n.consumable.consume(t.item,e.name))return;const s=i.plugins.get(Cf),a=r?t.attributeNewValue:null,c=this.placeholder,l=i.editing.mapper.toViewElement(o),d=n.writer;if("reading"==a)return Mp(l,d),void Np(c,l,d);if("uploading"==a){const e=s.loaders.get(r);return Mp(l,d),void(e?(Vp(l,d),function(e,t,n,i){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),n.on("change:uploadedPercent",((e,t,n)=>{i.change((e=>{e.setStyle("width",n+"%",o)}))}))}(l,d,e,i.editing.view),function(e,t,n){if(n.data){const i=np(e);t.setAttribute("src",n.data,i)}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class qp extends Hl{constructor(e,t){super(e);const n=e.t;this.focusTracker=new hl,this.keystrokes=new rl,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Dg,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Fg,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusables=new yl,this._focusCycler=new ed({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const i=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&i.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:i,tabindex:"-1"},children:this.children}),Vg(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),Bg({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new Og(this.locale,Ng);return t.label=e("Link URL"),t}_createButton(e,t,n,i){const o=new gd(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const n of e.manualDecorators){const i=new _d(this.locale);i.set({name:n.id,label:n.label,withText:!0}),i.bind("isOn").toMany([n,e],"value",((e,t)=>void 0===t&&void 0===e?n.defaultValue:e)),i.on("execute",(()=>{n.set("value",!i.isOn)})),t.add(i)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Hl;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}n(85);
+ */(l,d,e)):Np(c,l,d))}"complete"==a&&s.loaders.get(r)&&function(e,t,n){const i=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),i),setTimeout((()=>{n.change((e=>e.remove(e.createRangeOn(i))))}),3e3)}(l,d,i.editing.view),function(e,t){Dp(e,t,"progressBar")}(l,d),Vp(l,d),function(e,t){t.removeClass("ck-appear",e)}(l,d)}}function Mp(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function Np(e,t,n){t.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",t);const i=np(t);i.getAttribute("src")!==e&&n.setAttribute("src",e,i),Bp(t,"placeholder")||n.insert(n.createPositionAfter(i),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function Vp(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),Dp(e,t,"placeholder")}function Bp(e,t){for(const n of e.getChildren())if(n.getCustomProperty(t))return n}function Dp(e,t,n){const i=Bp(e,n);i&&t.remove(t.createRangeOn(i))}class zp extends Ze{refresh(){const e=this.editor.model.document.selection.getSelectedElement(),t=e&&"image"===e.name||!1;this.isEnabled=tp(this.editor.model)||t}execute(e){const t=this.editor,n=t.model,i=t.plugins.get(Cf);for(const t of li(e.file))Fp(n,i,t)}}function Fp(e,t,n){const i=t.createLoader(n);i&&ep(e,{uploadId:i.id})}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class Lp extends Qe{static get requires(){return[Cf,nu,Hu]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}})}init(){const e=this.editor,t=e.model.document,n=e.model.schema,i=e.conversion,o=e.plugins.get(Cf),r=Sp(e.config.get("image.upload.types"));n.extend("image",{allowAttributes:["uploadId","uploadStatus"]});const s=new zp(e);e.commands.add("uploadImage",s),e.commands.add("imageUpload",s),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{if(i=n.dataTransfer,Array.from(i.types).includes("text/html")&&""!==i.getData("text/html"))return;var i;const o=Array.from(n.dataTransfer.files).filter((e=>!!e&&r.test(e.type)));o.length&&(t.stop(),e.model.change((t=>{n.targetRanges&&t.setSelection(n.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.model.enqueueChange("default",(()=>{e.execute("uploadImage",{file:o})}))})))})),this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",((t,n)=>{const i=Array.from(e.editing.view.createRangeIn(n.content)).filter((e=>{return!(!(t=e.item).is("element","img")||!t.getAttribute("src"))&&(t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||t.getAttribute("src").match(/^blob:/g))&&!e.item.getAttribute("uploadProcessed");var t})).map((e=>({promise:Ep(e.item),imageElement:e.item})));if(!i.length)return;const r=new Vu(e.editing.view.document);for(const e of i){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=o.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const n=t.differ.getChanges({includeChangesInGraveyard:!0});for(const t of n)if("insert"==t.type&&"$text"!=t.name){const n=t.position.nodeAfter,i="$graveyard"==t.position.root.rootName;for(const t of jp(e,n)){const e=t.getAttribute("uploadId");if(!e)continue;const n=o.loaders.get(e);n&&(i?n.abort():"idle"==n.status&&this._readAndUpload(n,t))}}}))}_readAndUpload(e,t){const n=this.editor,i=n.model,o=n.locale.t,r=n.plugins.get(Cf),s=n.plugins.get(nu);return i.enqueueChange("transparent",(e=>{e.setAttribute("uploadStatus","reading",t)})),e.read().then((()=>{const o=e.upload();if(Bo.isSafari){const e=np(n.editing.mapper.toViewElement(t));n.editing.view.once("render",(()=>{if(!e.parent)return;const t=n.editing.view.domConverter.mapViewToDom(e.parent);if(!t)return;const i=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=i}))}return i.enqueueChange("transparent",(e=>{e.setAttribute("uploadStatus","uploading",t)})),o})).then((e=>{i.enqueueChange("transparent",(n=>{n.setAttributes({uploadStatus:"complete",src:e.default},t),this._parseAndSetSrcsetAttributeOnImage(e,t,n)})),a()})).catch((n=>{if("error"!==e.status&&"aborted"!==e.status)throw n;"error"==e.status&&n&&s.showWarning(n,{title:o("Upload failed"),namespace:"upload"}),a(),i.enqueueChange("transparent",(e=>{e.remove(t)}))}));function a(){i.enqueueChange("transparent",(e=>{e.removeAttribute("uploadId",t),e.removeAttribute("uploadStatus",t)})),r.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,n){let i=0;const o=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return i=Math.max(i,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");""!=o&&n.setAttribute("srcset",{data:o,width:i},t)}}function jp(e,t){return Array.from(e.model.createRangeOn(t)).filter((e=>e.item.is("element","image"))).map((e=>e.item))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Wp extends Hl{constructor(e){super(e);const t=e.t;this.focusTracker=new hl,this.keystrokes=new rl,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),'',"unlink"),this.editButtonView=this._createButton(t("Edit link"),'',"edit"),this.set("href"),this._focusables=new yl,this._focusCycler=new ed({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();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createButton(e,t,n){const i=new gd(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.delegate("execute").to(this,n),i}_createPreviewButton(){const e=new gd(this.locale),t=this.bindTemplate,n=this.t;return e.set({withText:!0,tooltip:n("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&Qf(e))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||n("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+class $p{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,n)=>{if(!n.consumable.test(t.item,"attribute:linkHref"))return;const i=n.writer,o=i.document.selection;for(const e of this._definitions){const r=i.createAttributeElement("a",e.attributes,{priority:5});i.setCustomProperty("link",!0,r),e.callback(t.attributeNewValue)?t.item.is("selection")?i.wrap(o.getFirstRange(),r):i.wrap(n.mapper.toViewRange(t.range),r):i.unwrap(n.mapper.toViewRange(t.range),r)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:image",((e,t,n)=>{const i=n.mapper.toViewElement(t.item),o=Array.from(i.getChildren()).find((e=>"a"===e.name));for(const e of this._definitions){const i=vi(e.attributes);if(e.callback(t.attributeNewValue))for(const[e,t]of i)"class"===e?n.writer.addClass(t,o):n.writer.setAttribute(e,t,o);else for(const[e,t]of i)"class"===e?n.writer.removeClass(t,o):n.writer.removeAttribute(e,o)}}))}}}var Hp=function(e,t,n){var i=e.length;return n=void 0===n?i:n,!t&&n>=i?e:$i(e,t,n)},qp=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Wp=function(e){return qp.test(e)};var Up=function(e){return e.split("")},Kp="[\\ud800-\\udfff]",Gp="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Jp="\\ud83c[\\udffb-\\udfff]",Xp="[^\\ud800-\\udfff]",Qp="(?:\\ud83c[\\udde6-\\uddff]){2}",Yp="[\\ud800-\\udbff][\\udc00-\\udfff]",Zp="(?:"+Gp+"|"+Jp+")"+"?",em="[\\ufe0e\\ufe0f]?",tm=em+Zp+("(?:\\u200d(?:"+[Xp,Qp,Yp].join("|")+")"+em+Zp+")*"),nm="(?:"+[Xp+Gp+"?",Gp,Qp,Yp,Kp].join("|")+")",im=RegExp(Jp+"(?="+Jp+")|"+nm+tm,"g");var om=function(e){return e.match(im)||[]};var rm=function(e){return Wp(e)?om(e):Up(e)};var sm=function(e){return function(t){t=Di(t);var n=Wp(t)?rm(t):void 0,i=n?n[0]:t.charAt(0),o=n?Hp(n,1).join(""):t.slice(1);return i[e]()+o}}("toUpperCase");
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const Up="link-ui";class Kp extends Rd{static get requires(){return[jg]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(Hp),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=e.plugins.get(jg),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),e.conversion.for("editingDowncast").markerToHighlight({model:Up,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Up,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const e=this.editor,t=new Wp(e.locale),n=e.commands.get("link"),i=e.commands.get("unlink");return t.bind("href").to(n,"value"),t.editButtonView.bind("isEnabled").to(n),t.unlinkButtonView.bind("isEnabled").to(i),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(Jf,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),i=new qp(e.locale,t);return i.urlInputView.fieldView.bind("value").to(t,"value"),i.urlInputView.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),i.saveButtonView.bind("isEnabled").to(t),this.listenTo(i,"submit",(()=>{const{value:t}=i.urlInputView.fieldView.element,o=Zf(t,n);e.execute("link",o,i.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(i,"cancel",(()=>{this._closeFormView()})),i.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),i}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),n=e.t;e.keystrokes.set(Jf,((e,n)=>{n(),t.isEnabled&&this._showUI(!0)})),e.ui.componentFactory.add("link",(e=>{const i=new gd(e);return i.isEnabled=!0,i.label=n("Link"),i.icon='',i.keystroke=Jf,i.tooltip=!0,i.isToggleable=!0,i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(e=>!!e)),this.listenTo(i,"execute",(()=>this._showUI(!0))),i}))}_enableUserBalloonInteractions(){const e=this.editor.editing.view.document;this.listenTo(e,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),vd({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let n=this._getSelectedLinkElement(),i=r();const o=()=>{const e=this._getSelectedLinkElement(),t=r();n&&!e||!n&&t!==i?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=e,i=t};function r(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,n=e.document;let i=null;if(t.markers.has(Up)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(Up)),n=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));i=e.domConverter.viewRangeToDom(n)}else{const t=this._getSelectedLinkElement(),o=n.selection.getFirstRange();i=t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(o)}return{target:i}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection;if(t.isCollapsed)return Gp(t.getFirstPosition());{const n=t.getFirstRange().getTrimmed(),i=Gp(n.start),o=Gp(n.end);return i&&i==o&&e.createRangeIn(i).getTrimmed().isEqual(n)?i:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const n=e.document.selection.getFirstRange();if(e.markers.has(Up))t.updateMarker(Up,{range:n});else if(n.start.isAtEnd){const i=n.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:n});t.addMarker(Up,{usingOperation:!1,affectsData:!1,range:t.createRange(i,n.end)})}else t.addMarker(Up,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Up)&&e.change((e=>{e.removeMarker(Up)}))}}function Gp(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))}
+const am=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,cm=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,lm=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,dm=/^((\w+:(\/{2,})?)|(\W))/i,um="Ctrl+K";function hm(e,{writer:t}){const n=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,n),n}function fm(e){return function(e){return e.replace(am,"").match(cm)}(e=String(e))?e:"#"}function gm(e,t){return!!e&&(e.is("element","image")&&t.checkAttribute("image","linkHref"))}function pm(e,t){const n=(i=e,lm.test(i)?"mailto:":t);var i;const o=!!n&&!dm.test(e);return e&&o?n+e:e}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Jp(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>i.is("$text")||i.is("$textProxy")?e+i.data:(n=t.createPositionAfter(i),"")),""),range:t.createRange(n,e.end)}}
+ */class mm extends Ze{constructor(e){super(e),this.manualDecorators=new ai,this.automaticDecorators=new $p}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document,n=js(t.selection.getSelectedBlocks());gm(n,e.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(n,"linkHref")):(this.value=t.selection.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const n=this.editor.model,i=n.document.selection,o=[],r=[];for(const e in t)t[e]?o.push(e):r.push(e);n.change((t=>{if(i.isCollapsed){const s=i.getFirstPosition();if(i.hasAttribute("linkHref")){const a=hf(s,"linkHref",i.getAttribute("linkHref"),n);t.setAttribute("linkHref",e,a),o.forEach((e=>{t.setAttribute(e,!0,a)})),r.forEach((e=>{t.removeAttribute(e,a)})),t.setSelection(t.createPositionAfter(a.end.nodeBefore))}else if(""!==e){const r=vi(i.getAttributes());r.set("linkHref",e),o.forEach((e=>{r.set(e,!0)}));const{end:a}=n.insertContent(t.createText(e,r),s);t.setSelection(a)}["linkHref",...o,...r].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const s=n.schema.getValidRanges(i.getRanges(),"linkHref"),a=[];for(const e of i.getSelectedBlocks())n.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const c=a.slice();for(const e of s)this._isRangeToUpdate(e,a)&&c.push(e);for(const n of c)t.setAttribute("linkHref",e,n),o.forEach((e=>{t.setAttribute(e,!0,n)})),r.forEach((e=>{t.removeAttribute(e,n)}))}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,n=t.document,i=js(n.selection.getSelectedBlocks());return gm(i,t.schema)?i.getAttribute(e):n.selection.getAttribute(e)}_isRangeToUpdate(e,t){for(const n of t)if(n.containsRange(e))return!1;return!0}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class Xp{constructor(e,t){this.model=e,this.testCallback=t,this.hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))})),this._startListening()}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:n})=>{n&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this.hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{"transparent"!=t.type&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const n=this.model,i=n.document.selection,o=n.createRange(n.createPositionAt(i.focus.parent,0),i.focus),{text:r,range:s}=Jp(o,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this.hasMatch=!!a,a){const n=Object.assign(t,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${e}`,n)}}}On(Xp,Yi);
+ */class bm extends Ze{refresh(){const e=this.editor.model,t=e.document,n=js(t.selection.getSelectedBlocks());gm(n,e.schema)?this.isEnabled=e.schema.checkAttribute(n,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref")}execute(){const e=this.editor,t=this.editor.model,n=t.document.selection,i=e.commands.get("link");t.change((e=>{const o=n.isCollapsed?[hf(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),t)]:t.schema.getValidRanges(n.getRanges(),"linkHref");for(const t of o)if(e.removeAttribute("linkHref",t),i)for(const n of i.manualDecorators)e.removeAttribute(n.id,t)}))}}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class km{constructor({id:e,label:t,attributes:n,defaultValue:i}){this.id=e,this.set("value"),this.defaultValue=i,this.label=t,this.attributes=n}}Xe(km,qe);n(91);
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */const wm="automatic",_m=/^(https?:)?\/\//;class vm extends Qe{static get pluginName(){return"LinkEditing"}static get requires(){return[rf,ef,Hu]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:hm}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>hm(fm(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new mm(e)),e.commands.add("unlink",new bm(e));const t=function(e,t){const n={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>(e.label&&n[e.label]&&(e.label=n[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[n,i]of Object.entries(e)){const e=Object.assign({},i,{id:`link${sm(n)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter((e=>e.mode===wm))),this._enableManualDecorators(t.filter((e=>"manual"===e.mode)));e.plugins.get(rf).registerAttribute("linkHref"),function(e,t,n,i){const o=e.editing.view,r=new Set;o.document.registerPostFixer((o=>{const s=e.model.document.selection;let a=!1;if(s.hasAttribute(t)){const c=hf(s.getFirstPosition(),t,s.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(const e of l.getItems())e.is("element",n)&&!e.hasClass(i)&&(o.addClass(i,e),r.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of r.values())e.removeClass(i,t),r.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}(e,"linkHref","a","ck-link_selected"),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(e){const t=this.editor,n=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:wm,callback:e=>_m.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(e),n.length&&t.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,n=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),n.add(new km(e)),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,{writer:i})=>{if(t){const t=n.get(e.id).attributes,o=i.createAttributeElement("a",t,{priority:5});return i.setCustomProperty("link",!0,o),o}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:n.get(e.id).attributes},model:{key:e.id}})}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor,t=e.model,n=t.document.selection,i=e.commands.get("link");this.listenTo(t,"insertContent",(()=>{const e=n.anchor.nodeBefore,o=n.anchor.nodeAfter;n.hasAttribute("linkHref")&&e&&e.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change((e=>{ym(e,i.manualDecorators)})))}),{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.commands.get("link");e.editing.view.addObserver(Nu);let n=!1;this.listenTo(e.editing.view.document,"mousedown",(()=>{n=!0})),this.listenTo(e.editing.view.document,"selectionChange",(()=>{if(!n)return;n=!1;const i=e.model.document.selection;if(!i.isCollapsed)return;if(!i.hasAttribute("linkHref"))return;const o=i.getFirstPosition(),r=hf(o,"linkHref",i.getAttribute("linkHref"),e.model);(o.isTouching(r.start)||o.isTouching(r.end))&&e.model.change((e=>{ym(e,t.manualDecorators)}))}))}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let n,i;this.listenTo(t.document,"delete",(()=>{i=!0}),{priority:"high"}),this.listenTo(e.model,"deleteContent",(()=>{const t=e.model.document.selection;t.isCollapsed||(i?i=!1:xm(e)&&function(e){const t=e.document.selection,n=t.getFirstPosition(),i=t.getLastPosition(),o=n.nodeAfter;if(!o)return!1;if(!o.is("$text"))return!1;if(!o.hasAttribute("linkHref"))return!1;const r=i.textNode||i.nodeBefore;if(o===r)return!0;return hf(n,"linkHref",o.getAttribute("linkHref"),e).containsRange(e.createRange(n,i),!0)}(e.model)&&(n=t.getAttributes()))}),{priority:"high"}),this.listenTo(e.model,"insertContent",((t,[o])=>{i=!1,xm(e)&&n&&(e.model.change((e=>{for(const[t,i]of n)e.setAttribute(t,i,o)})),n=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,n=t.document.selection,i=e.editing.view,o=e.commands.get("link");let r=!1,s=!1;this.listenTo(i.document,"delete",((e,t)=>{s=t.domEvent.keyCode===Fo.backspace}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{r=!1;const e=n.getFirstPosition(),i=n.getAttribute("linkHref");if(!i)return;const o=hf(e,"linkHref",i,t);r=o.containsPosition(e)||o.end.isEqual(e)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{s&&(s=!1,r||e.model.enqueueChange((e=>{ym(e,o.manualDecorators)})))}),{priority:"low"})}}function ym(e,t){e.removeSelectionAttribute("linkHref");for(const n of t)e.removeSelectionAttribute(n.id)}function xm(e){return e.plugins.get("Input").isInput(e.model.change((e=>e.batch)))}n(93);
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */class Am extends Zl{constructor(e,t){super(e);const n=e.t;this.focusTracker=new $s,this.keystrokes=new Hs,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Fl,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),zl,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusables=new Yl,this._focusCycler=new Cd({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const i=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&i.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:i,tabindex:"-1"},children:this.children}),Xl(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),Ql({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new eu(this.locale,tu);return t.label=e("Link URL"),t}_createButton(e,t,n,i){const o=new xd(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const n of e.manualDecorators){const i=new Ad(this.locale);i.set({name:n.id,label:n.label,withText:!0}),i.bind("isOn").toMany([n,e],"value",((e,t)=>void 0===t&&void 0===e?n.defaultValue:e)),i.on("execute",(()=>{n.set("value",!i.isOn)})),t.add(i)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Zl;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}n(95);
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+class Cm extends Zl{constructor(e){super(e);const t=e.t;this.focusTracker=new $s,this.keystrokes=new Hs,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),'',"unlink"),this.editButtonView=this._createButton(t("Edit link"),Ul,"edit"),this.set("href"),this._focusables=new Yl,this._focusCycler=new Cd({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();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createButton(e,t,n){const i=new xd(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.delegate("execute").to(this,n),i}_createPreviewButton(){const e=new xd(this.locale),t=this.bindTemplate,n=this.t;return e.set({withText:!0,tooltip:n("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&fm(e))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||n("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-const Qp=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.))+(?:[a-z\\u00a1-\\uffff]{2,})))$","i");class Yp extends Rd{static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new Xp(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=Zp(e.substr(0,e.length-1));return t?{url:t}:void 0})),n=e.plugins.get("Input");t.on("matched:data",((t,i)=>{const{batch:o,range:r,url:s}=i;if(!n.isInput(o))return;const a=r.end.getShiftedBy(-1),c=a.getShiftedBy(-s.length),l=e.model.createRange(c,a);this._applyAutoLink(s,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("enter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const n=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("shiftEnter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),n=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:n,range:i}=Jp(e,t),o=Zp(n);if(o){const e=t.createRange(i.end.getShiftedBy(-o.length),i.end);this._applyAutoLink(o,e)}}_applyAutoLink(e,t){const n=this.editor.model;this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}
+const Tm="link-ui";class Pm extends Qe{static get requires(){return[uu]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(Mu),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=e.plugins.get(uu),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),e.conversion.for("editingDowncast").markerToHighlight({model:Tm,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Tm,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const e=this.editor,t=new Cm(e.locale),n=e.commands.get("link"),i=e.commands.get("unlink");return t.bind("href").to(n,"value"),t.editButtonView.bind("isEnabled").to(n),t.unlinkButtonView.bind("isEnabled").to(i),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(um,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),i=new Am(e.locale,t);return i.urlInputView.fieldView.bind("value").to(t,"value"),i.urlInputView.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),i.saveButtonView.bind("isEnabled").to(t),this.listenTo(i,"submit",(()=>{const{value:t}=i.urlInputView.fieldView.element,o=pm(t,n);e.execute("link",o,i.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(i,"cancel",(()=>{this._closeFormView()})),i.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),i}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),n=e.t;e.keystrokes.set(um,((e,n)=>{n(),t.isEnabled&&this._showUI(!0)})),e.ui.componentFactory.add("link",(e=>{const i=new xd(e);return i.isEnabled=!0,i.label=n("Link"),i.icon='',i.keystroke=um,i.tooltip=!0,i.isToggleable=!0,i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(e=>!!e)),this.listenTo(i,"execute",(()=>this._showUI(!0))),i}))}_enableUserBalloonInteractions(){const e=this.editor.editing.view.document;this.listenTo(e,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),Jl({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let n=this._getSelectedLinkElement(),i=r();const o=()=>{const e=this._getSelectedLinkElement(),t=r();n&&!e||!n&&t!==i?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=e,i=t};function r(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,n=e.document;let i=null;if(t.markers.has(Tm)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(Tm)),n=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));i=e.domConverter.viewRangeToDom(n)}else{const t=this._getSelectedLinkElement(),o=n.selection.getFirstRange();i=t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(o)}return{target:i}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection;if(t.isCollapsed)return Sm(t.getFirstPosition());{const n=t.getFirstRange().getTrimmed(),i=Sm(n.start),o=Sm(n.end);return i&&i==o&&e.createRangeIn(i).getTrimmed().isEqual(n)?i:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const n=e.document.selection.getFirstRange();if(e.markers.has(Tm))t.updateMarker(Tm,{range:n});else if(n.start.isAtEnd){const i=n.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:n});t.addMarker(Tm,{usingOperation:!1,affectsData:!1,range:t.createRange(i,n.end)})}else t.addMarker(Tm,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Tm)&&e.change((e=>{e.removeMarker(Tm)}))}}function Sm(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(t,n)&&n.enqueueChange((n=>{const i=this.editor.config.get("link.defaultProtocol"),o=Zf(e,i);n.setAttribute("linkHref",o,t)}))}}function Zp(e){const t=Qp.exec(e);return t?t[2]:null}
+ */const Em=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");class Rm extends Qe{static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new of(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=Im(e.substr(0,e.length-1));return t?{url:t}:void 0})),n=e.plugins.get("Input");t.on("matched:data",((t,i)=>{const{batch:o,range:r,url:s}=i;if(!n.isInput(o))return;const a=r.end.getShiftedBy(-1),c=a.getShiftedBy(-s.length),l=e.model.createRange(c,a);this._applyAutoLink(s,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("enter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const n=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("shiftEnter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),n=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:n,range:i}=nf(e,t),o=Im(n);if(o){const e=t.createRange(i.end.getShiftedBy(-o.length),i.end);this._applyAutoLink(o,e)}}_applyAutoLink(e,t){const n=this.editor.model;this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}
+/**
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */(t,n)&&n.enqueueChange((n=>{const i=this.editor.config.get("link.defaultProtocol"),o=pm(e,i);n.setAttribute("linkHref",o,t)}))}}function Im(e){const t=Em.exec(e);return t?t[2]:null}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class em extends Fd{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document,n=Array.from(t.selection.getSelectedBlocks()).filter((t=>nm(t,e.schema))),i=!0===this.value;e.change((e=>{if(i){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=n;)r>o.getAttribute("listIndent")&&(r=o.getAttribute("listIndent")),o.getAttribute("listIndent")==r&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function nm(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}
+class Om extends Ze{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document,n=Array.from(t.selection.getSelectedBlocks()).filter((t=>Nm(t,e.schema))),i=!0===this.value;e.change((e=>{if(i){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=n;)r>o.getAttribute("listIndent")&&(r=o.getAttribute("listIndent")),o.getAttribute("listIndent")==r&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function Nm(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */class im extends Fd{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let n=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=n[n.length-1];let i=t.nextSibling;for(;i&&"listItem"==i.name&&i.getAttribute("listIndent")>t.getAttribute("listIndent");)n.push(i),i=i.nextSibling;this._indentBy<0&&(n=n.reverse());for(const t of n){const n=t.getAttribute("listIndent")+this._indentBy;n<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",n,t)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const e=Uu(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),n=e.getAttribute("listType");let i=e.previousSibling;for(;i&&i.is("element","listItem")&&i.getAttribute("listIndent")>=t;){if(i.getAttribute("listIndent")==t)return i.getAttribute("listType")==n;i=i.previousSibling}return!1}return!0}}
+ */class Vm extends Ze{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let n=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=n[n.length-1];let i=t.nextSibling;for(;i&&"listItem"==i.name&&i.getAttribute("listIndent")>t.getAttribute("listIndent");)n.push(i),i=i.nextSibling;this._indentBy<0&&(n=n.reverse());for(const t of n){const n=t.getAttribute("listIndent")+this._indentBy;n<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",n,t)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const e=js(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),n=e.getAttribute("listType");let i=e.previousSibling;for(;i&&i.is("element","listItem")&&i.getAttribute("listIndent")>=t;){if(i.getAttribute("listIndent")==t)return i.getAttribute("listType")==n;i=i.previousSibling}return!1}return!0}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function om(e,t){const n=t.mapper,i=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=dm,t}(i),s=i.createContainerElement(o,null);return i.insert(i.createPositionAt(s,0),r),n.bindElements(e,r),r}function rm(e,t,n,i){const o=t.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(i.createPositionBefore(e));const c=cm(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),l=e.previousSibling;if(c&&c.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(e))}else if(l&&"listItem"==l.name){a=r.toViewPosition(i.createPositionAt(l,"end"));const e=r.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?s.createPositionBefore(t):s.createPositionAt(e,"end")}else a=r.toViewPosition(i.createPositionBefore(e));if(a=am(a),s.insert(a,o),l&&"listItem"==l.name){const e=r.toViewElement(l),n=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of n)if(e.item.is("element","li")){const i=s.breakContainer(s.createPositionBefore(e.item)),o=e.item.parent,r=s.createPositionAt(t,"end");sm(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(o),r),n.position=i}}else{const n=o.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let i=null;for(const t of n.getChildren()){const n=r.toModelElement(t);if(!(n&&n.getAttribute("listIndent")>e.getAttribute("listIndent")))break;i=t}i&&(s.breakContainer(s.createPositionAfter(i)),s.move(s.createRangeOn(i.parent),s.createPositionAt(t,"end")))}}sm(s,o,o.nextSibling),sm(s,o.previousSibling,o)}function sm(e,t,n){return!t||!n||"ul"!=t.name&&"ol"!=t.name||t.name!=n.name||t.getAttribute("class")!==n.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function am(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function cm(e,t){const n=!!t.sameIndent,i=!!t.smallerIndent,o=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(n&&o==e||i&&o>e)return r;r="forward"===t.direction?r.nextSibling:r.previousSibling}return null}function lm(e,t,n,i){e.ui.componentFactory.add(t,(o=>{const r=e.commands.get(t),s=new gd(o);return s.set({label:n,icon:i,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function dm(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Ui.call(this)}
+ */function Bm(e,t){const n=t.mapper,i=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=$m,t}(i),s=i.createContainerElement(o,null);return i.insert(i.createPositionAt(s,0),r),n.bindElements(e,r),r}function Dm(e,t,n,i){const o=t.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(i.createPositionBefore(e));const c=Lm(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),l=e.previousSibling;if(c&&c.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(e))}else if(l&&"listItem"==l.name){a=r.toViewPosition(i.createPositionAt(l,"end"));const e=r.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?s.createPositionBefore(t):s.createPositionAt(e,"end")}else a=r.toViewPosition(i.createPositionBefore(e));if(a=Fm(a),s.insert(a,o),l&&"listItem"==l.name){const e=r.toViewElement(l),n=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of n)if(e.item.is("element","li")){const i=s.breakContainer(s.createPositionBefore(e.item)),o=e.item.parent,r=s.createPositionAt(t,"end");zm(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(o),r),n.position=i}}else{const n=o.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let i=null;for(const t of n.getChildren()){const n=r.toModelElement(t);if(!(n&&n.getAttribute("listIndent")>e.getAttribute("listIndent")))break;i=t}i&&(s.breakContainer(s.createPositionAfter(i)),s.move(s.createRangeOn(i.parent),s.createPositionAt(t,"end")))}}zm(s,o,o.nextSibling),zm(s,o.previousSibling,o)}function zm(e,t,n){return!t||!n||"ul"!=t.name&&"ol"!=t.name||t.name!=n.name||t.getAttribute("class")!==n.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function Fm(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function Lm(e,t){const n=!!t.sameIndent,i=!!t.smallerIndent,o=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(n&&o==e||i&&o>e)return r;r="forward"===t.direction?r.nextSibling:r.previousSibling}return null}function jm(e,t,n,i){e.ui.componentFactory.add(t,(o=>{const r=e.commands.get(t),s=new xd(o);return s.set({label:n,icon:i,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function $m(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:uo.call(this)}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function um(e){return(t,n,i)=>{const o=i.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;o.consume(n.item,"insert"),o.consume(n.item,"attribute:listType"),o.consume(n.item,"attribute:listIndent");const r=n.item;rm(r,om(r,i),i,e)}}function hm(e,t,n){if(!n.consumable.consume(t.item,"attribute:listType"))return;const i=n.mapper.toViewElement(t.item),o=n.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const r=i.parent,s="numbered"==t.attributeNewValue?"ol":"ul";o.rename(s,r)}function fm(e,t,n){const i=n.mapper.toViewElement(t.item).parent,o=n.writer;sm(o,i,i.nextSibling),sm(o,i.previousSibling,i);for(const e of t.item.getChildren())n.consumable.consume(e,"insert")}function gm(e,t,n){if("listItem"!=t.item.name){let e=n.mapper.toViewPosition(t.range.start);const i=n.writer,o=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=i.breakContainer(e),"li"==e.parent.name);){const t=e,n=i.createPositionAt(e.parent,"end");if(!t.isEqual(n)){const e=i.remove(i.createRange(t,n));o.push(e)}e=i.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=sm(i,n,n.nextSibling);t&&t.parent==n&&e.offset--}}sm(i,e.nodeBefore,e.nodeAfter)}}}function pm(e,t,n){const i=n.mapper.toViewPosition(t.position),o=i.nodeBefore,r=i.nodeAfter;sm(n.writer,o,r)}function mm(e,t,n){if(n.consumable.consume(t.viewItem,{name:!0})){const e=n.writer,i=e.createElement("listItem"),o=function(e){let t=0,n=e.parent;for(;n;){if(n.is("element","li"))t++;else{const e=n.previousSibling;e&&e.is("element","li")&&t++}n=n.parent}return t}
+ */function Hm(e){return(t,n,i)=>{const o=i.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;o.consume(n.item,"insert"),o.consume(n.item,"attribute:listType"),o.consume(n.item,"attribute:listIndent");const r=n.item;Dm(r,Bm(r,i),i,e)}}function qm(e,t,n){if(!n.consumable.consume(t.item,"attribute:listType"))return;const i=n.mapper.toViewElement(t.item),o=n.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const r=i.parent,s="numbered"==t.attributeNewValue?"ol":"ul";o.rename(s,r)}function Wm(e,t,n){const i=n.mapper.toViewElement(t.item).parent,o=n.writer;zm(o,i,i.nextSibling),zm(o,i.previousSibling,i);for(const e of t.item.getChildren())n.consumable.consume(e,"insert")}function Um(e,t,n){if("listItem"!=t.item.name){let e=n.mapper.toViewPosition(t.range.start);const i=n.writer,o=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=i.breakContainer(e),"li"==e.parent.name);){const t=e,n=i.createPositionAt(e.parent,"end");if(!t.isEqual(n)){const e=i.remove(i.createRange(t,n));o.push(e)}e=i.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=zm(i,n,n.nextSibling);t&&t.parent==n&&e.offset--}}zm(i,e.nodeBefore,e.nodeAfter)}}}function Km(e,t,n){const i=n.mapper.toViewPosition(t.position),o=i.nodeBefore,r=i.nodeAfter;zm(n.writer,o,r)}function Gm(e,t,n){if(n.consumable.consume(t.viewItem,{name:!0})){const e=n.writer,i=e.createElement("listItem"),o=function(e){let t=0,n=e.parent;for(;n;){if(n.is("element","li"))t++;else{const e=n.previousSibling;e&&e.is("element","li")&&t++}n=n.parent}return t}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */(t.viewItem);e.setAttribute("listIndent",o,i);const r=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",r,i),!n.safeInsert(i,t.modelCursor))return;const s=function(e,t,n){const{writer:i,schema:o}=n;let r=i.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const t=n.convertItem(s,i.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!o.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:vm(t.modelCursor),r=i.createPositionAfter(e))}return r}(i,t.viewItem.getChildren(),n);t.modelRange=e.createRange(t.modelCursor,s),n.updateConversionResult(i,t)}}function bm(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||xm(t))&&t._remove()}}}function km(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let n=!1,i=!0;for(const t of e)n&&!xm(t)&&t._remove(),t.is("$text")?(i&&(t._data=t.data.replace(/^\s+/,"")),t.nextSibling&&!xm(t.nextSibling)||(t._data=t.data.replace(/\s+$/,""))):xm(t)&&(n=!0),i=!1}}function wm(e){return(t,n)=>{if(n.isPhantom)return;const i=n.modelPosition.nodeBefore;if(i&&i.is("element","listItem")){const t=n.mapper.toViewElement(i),o=t.getAncestors().find(xm),r=e.createPositionAt(t,0).getWalker();for(const e of r){if("elementStart"==e.type&&e.item.is("element","li")){n.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){n.viewPosition=e.nextPosition;break}}}}}function _m(e,[t,n]){let i,o=t.is("documentFragment")?t.getChild(0):t;if(i=n?this.createSelection(n):this.document.selection,o&&o.is("element","listItem")){const e=i.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}}function vm(e){const t=new Bs({startPosition:e});let n;do{n=t.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function ym(e,t,n,i,o,r){const s=cm(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e,foo:"b"}),a=o.mapper,c=o.writer,l=s?s.getAttribute("listIndent"):null;let d;if(s)if(l==e){const e=a.toViewElement(s).parent;d=c.createPositionAfter(e)}else{const e=r.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=n;d=am(d);for(const e of[...i.getChildren()])xm(e)&&(d=c.move(c.createRangeOn(e),d).end,sm(c,e,e.nextSibling),sm(c,e.previousSibling,e))}function xm(e){return e.is("element","ol")||e.is("element","ul")}class Cm extends Rd{static get pluginName(){return"ListEditing"}static get requires(){return[pp]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,n=e.editing;var i;e.model.document.registerPostFixer((t=>function(e,t){const n=e.document.differ.getChanges(),i=new Map;let o=!1;for(const i of n)if("insert"==i.type&&"listItem"==i.name)r(i.position);else if("insert"==i.type&&"listItem"!=i.name){if("$text"!=i.name){const n=i.position.nodeAfter;n.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",n),o=!0),n.hasAttribute("listType")&&(t.removeAttribute("listType",n),o=!0),n.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",n),o=!0);for(const t of Array.from(e.createRangeIn(n)).filter((e=>e.item.is("element","listItem"))))r(t.previousPosition)}r(i.position.getShiftedBy(i.length))}else"remove"==i.type&&"listItem"==i.name?r(i.position):("attribute"==i.type&&"listIndent"==i.attributeKey||"attribute"==i.type&&"listType"==i.attributeKey)&&r(i.range.start);for(const e of i.values())s(e),a(e);return o;function r(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(i.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,i.has(e))return;i.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&i.set(t,t)}}function s(e){let n=0,i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(r>n){let s;null===i?(i=r-n,s=n):(i>r&&(i=r),s=r-i),t.setAttribute("listIndent",s,e),o=!0}else i=null,n=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let n=[],i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(i&&i.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const i=n[r];e.getAttribute("listType")!=i&&(t.setAttribute("listType",i,e),o=!0)}else n[r]=e.getAttribute("listType");i=e,e=e.nextSibling}}}(e.model,t))),n.mapper.registerViewToModelLength("li",Am),t.mapper.registerViewToModelLength("li",Am),n.mapper.on("modelToViewPosition",wm(n.view)),n.mapper.on("viewToModelPosition",(i=e.model,(e,t)=>{const n=t.viewPosition,o=n.parent,r=t.mapper;if("ul"==o.name||"ol"==o.name){if(n.isAtEnd){const e=r.toModelElement(n.nodeBefore),o=r.getModelLength(n.nodeBefore);t.modelPosition=i.createPositionBefore(e).getShiftedBy(o)}else{const e=r.toModelElement(n.nodeAfter);t.modelPosition=i.createPositionBefore(e)}e.stop()}else if("li"==o.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(o);let a=1,c=n.nodeBefore;for(;c&&xm(c);)a+=r.getModelLength(c),c=c.previousSibling;t.modelPosition=i.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",wm(n.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",gm,{priority:"high"}),t.on("insert:listItem",um(e.model)),t.on("attribute:listType:listItem",hm,{priority:"high"}),t.on("attribute:listType:listItem",fm,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,n,i)=>{if(!i.consumable.consume(n.item,"attribute:listIndent"))return;const o=i.mapper.toViewElement(n.item),r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s);r.remove(c),a&&a.nextSibling&&sm(r,a,a.nextSibling),ym(n.attributeOldValue+1,n.range.start,c.start,o,i,e),rm(n.item,o,i,e);for(const e of n.item.getChildren())i.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,n,i)=>{const o=i.mapper.toViewPosition(n.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s),l=r.remove(c);a&&a.nextSibling&&sm(r,a,a.nextSibling),ym(i.mapper.toModelElement(o).getAttribute("listIndent")+1,n.position,c.start,o,i,e);for(const e of r.createRangeIn(l).getItems())i.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",pm,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",gm,{priority:"high"}),t.on("insert:listItem",um(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",bm,{priority:"high"}),e.on("element:ol",bm,{priority:"high"}),e.on("element:li",km,{priority:"high"}),e.on("element:li",mm)})),e.model.on("insertContent",_m,{priority:"high"}),e.commands.add("numberedList",new em(e,"numbered")),e.commands.add("bulletedList",new em(e,"bulleted")),e.commands.add("indentList",new im(e,"forward")),e.commands.add("outdentList",new im(e,"backward"));const o=n.view.document;this.listenTo(o,"enter",((e,t)=>{const n=this.editor.model.document,i=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==i.name&&i.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())})),this.listenTo(o,"delete",((e,t)=>{if("backward"!==t.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const i=n.getFirstPosition();if(!i.isAtStart)return;const o=i.parent;if("listItem"!==o.name)return;o.previousSibling&&"listItem"===o.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{priority:wn.high+10});const r=e=>(t,n)=>{this.editor.commands.get(e).isEnabled&&(this.editor.execute(e),n())};e.keystrokes.set("Tab",r("indentList")),e.keystrokes.set("Shift+Tab",r("outdentList"))}afterInit(){const e=this.editor.commands,t=e.get("indent"),n=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),n&&n.registerChildCommand(e.get("outdentList"))}}function Am(e){let t=1;for(const n of e.getChildren())if("ul"==n.name||"ol"==n.name)for(const e of n.getChildren())t+=Am(e);return t}
+ */(t.viewItem);e.setAttribute("listIndent",o,i);const r=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",r,i),!n.safeInsert(i,t.modelCursor))return;const s=function(e,t,n){const{writer:i,schema:o}=n;let r=i.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const t=n.convertItem(s,i.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!o.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:Zm(t.modelCursor),r=i.createPositionAfter(e))}return r}(i,t.viewItem.getChildren(),n);t.modelRange=e.createRange(t.modelCursor,s),n.updateConversionResult(i,t)}}function Jm(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||tb(t))&&t._remove()}}}function Xm(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let n=!1,i=!0;for(const t of e)n&&!tb(t)&&t._remove(),t.is("$text")?(i&&(t._data=t.data.trimStart()),t.nextSibling&&!tb(t.nextSibling)||(t._data=t.data.trimEnd())):tb(t)&&(n=!0),i=!1}}function Qm(e){return(t,n)=>{if(n.isPhantom)return;const i=n.modelPosition.nodeBefore;if(i&&i.is("element","listItem")){const t=n.mapper.toViewElement(i),o=t.getAncestors().find(tb),r=e.createPositionAt(t,0).getWalker();for(const e of r){if("elementStart"==e.type&&e.item.is("element","li")){n.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){n.viewPosition=e.nextPosition;break}}}}}function Ym(e,[t,n]){let i,o=t.is("documentFragment")?t.getChild(0):t;if(i=n?this.createSelection(n):this.document.selection,o&&o.is("element","listItem")){const e=i.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}}function Zm(e){const t=new aa({startPosition:e});let n;do{n=t.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function eb(e,t,n,i,o,r){const s=Lm(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e,foo:"b"}),a=o.mapper,c=o.writer,l=s?s.getAttribute("listIndent"):null;let d;if(s)if(l==e){const e=a.toViewElement(s).parent;d=c.createPositionAfter(e)}else{const e=r.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=n;d=Fm(d);for(const e of[...i.getChildren()])tb(e)&&(d=c.move(c.createRangeOn(e),d).end,zm(c,e,e.nextSibling),zm(c,e.previousSibling,e))}function tb(e){return e.is("element","ol")||e.is("element","ul")}class nb extends Qe{static get pluginName(){return"ListEditing"}static get requires(){return[Gu,Yu]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,n=e.editing;var i;e.model.document.registerPostFixer((t=>function(e,t){const n=e.document.differ.getChanges(),i=new Map;let o=!1;for(const i of n)if("insert"==i.type&&"listItem"==i.name)r(i.position);else if("insert"==i.type&&"listItem"!=i.name){if("$text"!=i.name){const n=i.position.nodeAfter;n.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",n),o=!0),n.hasAttribute("listType")&&(t.removeAttribute("listType",n),o=!0),n.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",n),o=!0);for(const t of Array.from(e.createRangeIn(n)).filter((e=>e.item.is("element","listItem"))))r(t.previousPosition)}r(i.position.getShiftedBy(i.length))}else"remove"==i.type&&"listItem"==i.name?r(i.position):("attribute"==i.type&&"listIndent"==i.attributeKey||"attribute"==i.type&&"listType"==i.attributeKey)&&r(i.range.start);for(const e of i.values())s(e),a(e);return o;function r(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(i.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,i.has(e))return;i.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&i.set(t,t)}}function s(e){let n=0,i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(r>n){let s;null===i?(i=r-n,s=n):(i>r&&(i=r),s=r-i),t.setAttribute("listIndent",s,e),o=!0}else i=null,n=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let n=[],i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(i&&i.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const i=n[r];e.getAttribute("listType")!=i&&(t.setAttribute("listType",i,e),o=!0)}else n[r]=e.getAttribute("listType");i=e,e=e.nextSibling}}}(e.model,t))),n.mapper.registerViewToModelLength("li",ib),t.mapper.registerViewToModelLength("li",ib),n.mapper.on("modelToViewPosition",Qm(n.view)),n.mapper.on("viewToModelPosition",(i=e.model,(e,t)=>{const n=t.viewPosition,o=n.parent,r=t.mapper;if("ul"==o.name||"ol"==o.name){if(n.isAtEnd){const e=r.toModelElement(n.nodeBefore),o=r.getModelLength(n.nodeBefore);t.modelPosition=i.createPositionBefore(e).getShiftedBy(o)}else{const e=r.toModelElement(n.nodeAfter);t.modelPosition=i.createPositionBefore(e)}e.stop()}else if("li"==o.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(o);let a=1,c=n.nodeBefore;for(;c&&tb(c);)a+=r.getModelLength(c),c=c.previousSibling;t.modelPosition=i.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",Qm(n.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",Um,{priority:"high"}),t.on("insert:listItem",Hm(e.model)),t.on("attribute:listType:listItem",qm,{priority:"high"}),t.on("attribute:listType:listItem",Wm,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,n,i)=>{if(!i.consumable.consume(n.item,"attribute:listIndent"))return;const o=i.mapper.toViewElement(n.item),r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s);r.remove(c),a&&a.nextSibling&&zm(r,a,a.nextSibling),eb(n.attributeOldValue+1,n.range.start,c.start,o,i,e),Dm(n.item,o,i,e);for(const e of n.item.getChildren())i.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,n,i)=>{const o=i.mapper.toViewPosition(n.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s),l=r.remove(c);a&&a.nextSibling&&zm(r,a,a.nextSibling),eb(i.mapper.toModelElement(o).getAttribute("listIndent")+1,n.position,c.start,o,i,e);for(const e of r.createRangeIn(l).getItems())i.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",Km,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",Um,{priority:"high"}),t.on("insert:listItem",Hm(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",Jm,{priority:"high"}),e.on("element:ol",Jm,{priority:"high"}),e.on("element:li",Xm,{priority:"high"}),e.on("element:li",Gm)})),e.model.on("insertContent",Ym,{priority:"high"}),e.commands.add("numberedList",new Om(e,"numbered")),e.commands.add("bulletedList",new Om(e,"bulleted")),e.commands.add("indentList",new Vm(e,"forward")),e.commands.add("outdentList",new Vm(e,"backward"));const o=n.view.document;this.listenTo(o,"enter",((e,t)=>{const n=this.editor.model.document,i=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==i.name&&i.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(o,"delete",((e,t)=>{if("backward"!==t.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const i=n.getFirstPosition();if(!i.isAtStart)return;const o=i.parent;if("listItem"!==o.name)return;o.previousSibling&&"listItem"===o.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"});const r=e=>(t,n)=>{this.editor.commands.get(e).isEnabled&&(this.editor.execute(e),n())};e.keystrokes.set("Tab",r("indentList")),e.keystrokes.set("Shift+Tab",r("outdentList"))}afterInit(){const e=this.editor.commands,t=e.get("indent"),n=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),n&&n.registerChildCommand(e.get("outdentList"))}}function ib(e){let t=1;for(const n of e.getChildren())if("ul"==n.name||"ol"==n.name)for(const e of n.getChildren())t+=ib(e);return t}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-class Tm extends Rd{init(){const e=this.editor.t;lm(this.editor,"numberedList",e("Numbered List"),''),lm(this.editor,"bulletedList",e("Bulleted List"),'')}}
+class ob extends Qe{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;jm(this.editor,"numberedList",e("Numbered List"),''),jm(this.editor,"bulletedList",e("Bulleted List"),'')}}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1439,11 +1626,11 @@ class Tm extends Rd{init(){const e=this.editor.t;lm(this.editor,"numberedList",e
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
-function Pm(e,t){if(!e.childCount)return;const n=new sp(e.document),i=function(e,t){const n=t.createRangeIn(e),i=new Kn({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of n)if("elementStart"===e.type&&i.match(e.item)){const t=Rm(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,n);if(!i.length)return;let o=null,r=1;i.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const n=t.element.previousSibling;if(!n)return!0;return i=n,!(i.is("element","ol")||i.is("element","ul"));var i}(i[s-1],e),c=a?null:i[s-1],l=(u=e,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(o=null,r=1),!o||0!==l){const i=function(e,t){const n=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]*);/gi,o=n.exec(t);let r="decimal",s="ol";if(o&&o[1]){const t=i.exec(o[1]);if(t&&t[1]&&(r=t[1].trim(),s="bullet"!==r&&"image"!==r?"ol":"ul"),"bullet"===r){const t=function(e){const t=function(e){if(e.getChild(0).is("$text"))return null;const t=e.getChild(0).getChild(0);if(t.is("$text"))return t;return t.getChild(0)}(e);if(!t)return null;const n=t._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(e.element);t&&(r=t)}}return{type:s,style:Sm(r)}}(e,t);if(o){if(e.indent>r){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=Em(i,t,n),r+=1}else if(e.indent{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const n=t.element.previousSibling;if(!n)return!0;return i=n,!(i.is("element","ol")||i.is("element","ul"));var i}(i[s-1],e),c=a?null:i[s-1],l=(u=e,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(o=null,r=1),!o||0!==l){const i=function(e,t){const n=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,o=n.exec(t);let r="decimal",s="ol";if(o&&o[1]){const t=i.exec(o[1]);if(t&&t[1]&&(r=t[1].trim(),s="bullet"!==r&&"image"!==r?"ol":"ul"),"bullet"===r){const t=function(e){const t=function(e){if(e.getChild(0).is("$text"))return null;const t=e.getChild(0).getChild(0);if(t.is("$text"))return t;return t.getChild(0)}(e);if(!t)return null;const n=t._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(e.element);t&&(r=t)}}return{type:s,style:sb(r)}}(e,t);if(o){if(e.indent>r){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=ab(i,t,n),r+=1}else if(e.indent(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join(" ").substr(0,t.length)))}
+ */function ub(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join(" ").substr(0,t.length)))}
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */function Nm(e,t){const n=new DOMParser,i=function(e){return Mm(Mm(e)).replace(/([\s]*?)[\r\n]+(\s*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>(\s*[\r\n]\s*)<")}(function(e){const t=/<\/body>(.*?)(<\/html>|$)/,n=e.match(t);n&&n[1]&&(e=e.slice(0,n.index)+e.slice(n.index).replace(n[1],""));return e}
+ */function hb(e,t){const n=new DOMParser,i=function(e){return ub(ub(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="