From: Louis Jeckel =t||n<0||d&&e-c>=o}function m(){var e=va();if(p(e))return g(e);s=setTimeout(m,function(e){var n=t-(e-l);return d?_a(n,o-(e-c)):n}(e))}function g(e){return s=void 0,h&&i?f(e):(i=r=void 0,a)}function k(){var e=va(),n=p(e);if(i=arguments,r=this,l=e,n){if(void 0===s)return v(l);if(d)return clearTimeout(s),s=setTimeout(m,t),f(l)}return void 0===s&&(s=setTimeout(m,t)),a}return t=ya(t)||0,ne(n)&&(u=!!n.leading,o=(d="maxWait"in n)?wa(ya(n.maxWait)||0,t):o,h="trailing"in n?!!n.trailing:h),k.cancel=function(){void 0!==s&&clearTimeout(s),c=0,i=l=r=s=void 0},k.flush=function(){return void 0===s?a:g(va())},k},Ca=function(e){C(n,e);var t=A(n);function n(e){var i;return w(this,n),i=t.call(this,e),i._fireSelectionChangeDoneDebounced=xa((function(e){return i.document.fire("selectionChangeDone",e)}),200),i}return x(n,[{key:"observe",value:function(){var e=this,t=this.document;t.on("keydown",(function(n,i){var r;t.selection.isFake&&((r=i.keyCode)==Br.arrowright||r==Br.arrowleft||r==Br.arrowup||r==Br.arrowdown)&&e.isEnabled&&(i.preventDefault(),e._handleSelectionMove(i.keyCode))}),{priority:"lowest"})}},{key:"destroy",value:function(){l(N(n.prototype),"destroy",this).call(this),this._fireSelectionChangeDoneDebounced.cancel()}},{key:"_handleSelectionMove",value:function(e){var t=this.document.selection,n=new Er(t.getRanges(),{backward:t.isBackward,fake:!1});e!=Br.arrowleft&&e!=Br.arrowup||n.setTo(n.getFirstPosition()),e!=Br.arrowright&&e!=Br.arrowdown||n.setTo(n.getLastPosition());var i={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}]),n}(Uo),Aa=function(e){C(n,e);var t=A(n);function n(e){var i;return w(this,n),i=t.call(this,e),i.mutationObserver=e.getObserver(ua),i.selection=i.document.selection,i.domConverter=e.domConverter,i._documents=new WeakSet,i._fireSelectionChangeDoneDebounced=xa((function(e){return i.document.fire("selectionChangeDone",e)}),200),i._clearInfiniteLoopInterval=setInterval((function(){return i._clearInfiniteLoop()}),1e3),i._loopbackCounter=0,i}return x(n,[{key:"observe",value:function(e){var t=this,n=e.ownerDocument;this._documents.has(n)||(this.listenTo(n,"selectionchange",(function(){t._handleSelectionChange(n)})),this._documents.add(n))}},{key:"destroy",value:function(){l(N(n.prototype),"destroy",this).call(this),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel()}},{key:"_handleSelectionChange",value:function(e){if(this.isEnabled){this.mutationObserver.flush();var t=e.defaultView.getSelection(),n=this.domConverter.domSelectionToView(t);if(0!=n.rangeCount){if(this.view.hasDomSelection=!0,!(this.selection.isEqual(n)&&this.domConverter.isDomSelectionCorrect(t)||++this._loopbackCounter>60))if(this.selection.isSimilar(n))this.view.forceRender();else{var i={oldSelection:this.selection,newSelection:n,domSelection:t};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}else this.view.hasDomSelection=!1}}},{key:"_clearInfiniteLoop",value:function(){this._loopbackCounter=0}}]),n}(Uo),Ta=function(e){C(n,e);var t=A(n);function n(e){var i;w(this,n),i=t.call(this,e),i.domEventType=["focus","blur"],i.useCapture=!0;var r=i.document;return r.on("focus",(function(){r.isFocused=!0,i._renderTimeoutId=setTimeout((function(){return e.forceRender()}),50)})),r.on("blur",(function(t,n){var i=r.selection.editableElement;null!==i&&i!==n.target||(r.isFocused=!1,e.forceRender())})),i}return x(n,[{key:"onDomEvent",value:function(e){this.fire(e.type,e)}},{key:"destroy",value:function(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),l(N(n.prototype),"destroy",this).call(this)}}]),n}(ha),Pa=function(e){C(n,e);var t=A(n);function n(e){var i;w(this,n),i=t.call(this,e),i.domEventType=["compositionstart","compositionupdate","compositionend"];var r=i.document;return r.on("compositionstart",(function(){r.isComposing=!0})),r.on("compositionend",(function(){r.isComposing=!1})),i}return x(n,[{key:"onDomEvent",value:function(e){this.fire(e.type,e)}}]),n}(ha),Ea=function(e){C(n,e);var t=A(n);function n(e){var i;return w(this,n),i=t.call(this,e),i.domEventType=["beforeinput"],i}return x(n,[{key:"onDomEvent",value:function(e){this.fire(e.type,e)}}]),n}(ha);function Sa(e){return"[object Range]"==Object.prototype.toString.apply(e)}function Oa(e){var t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}var Ma=["top","right","bottom","left","width","height"],Ia=function(){function e(t){w(this,e);var n=Sa(t);if(Object.defineProperty(this,"_source",{value:t._source||t,writable:!0,enumerable:!1}),Sn(t)||n)if(n){var i=e.getDomRangeRects(t);Na(this,e.getBoundingRect(i))}else Na(this,t.getBoundingClientRect());else if(jo(t)){var r=t.innerWidth,o=t.innerHeight;Na(this,{top:0,right:r,bottom:o,left:0,width:r,height:o})}else Na(this,t)}return x(e,[{key:"clone",value:function(){return new e(this)}},{key:"moveTo",value:function(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}},{key:"moveBy",value:function(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}},{key:"getIntersection",value:function(t){var n={top:Math.max(this.top,t.top),right:Math.min(this.right,t.right),bottom:Math.min(this.bottom,t.bottom),left:Math.max(this.left,t.left)};return n.width=n.right-n.left,n.height=n.bottom-n.top,n.width<0||n.height<0?null:new e(n)}},{key:"getIntersectionArea",value:function(e){var t=this.getIntersection(e);return t?t.getArea():0}},{key:"getArea",value:function(){return this.width*this.height}},{key:"getVisible",value:function(){var t=this._source,n=this.clone();if(!Ra(t))for(var i=t.parentNode||t.commonAncestorContainer;i&&!Ra(i);){var r=new e(i),o=n.getIntersection(r);if(!o)return null;o.getArea()s&&(s=this.boundaries.start.offset),a=t.offset-s}var l=t.offset-o.startOffset,c=new Ga(o,l-a,a);return t.offset-=a,this.position=t,Za("text",c,e,t,a)}return t.path.pop(),this.position=t,this._visitedParent=n.parent,Za("elementStart",n,e,t,1)}}]),e}();function Za(e,t,n,i,r){return{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,length:r}}}var Xa=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"toNone";if(w(this,e),!t.is("element")&&!t.is("documentFragment"))throw new jn.b("model-position-root-invalid: Position root invalid.",t);if(!(n instanceof Array)||0===n.length)throw new jn.b("model-position-path-incorrect-format: Position path must be an array with at least one item.",t,{path:n});t.is("rootElement")?n=n.slice():(n=[].concat(u(t.getPath()),u(n)),t=t.root),this.root=t,this.path=n,this.stickiness=i}return x(e,[{key:"compareWith",value:function(e){if(this.root!=e.root)return"different";var t=ii(this.path,e.path);switch(t){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[t]
").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).indexOf("
")>-1&&(r="
".concat(r,"
")),a=r),a=e._htmlDataProcessor.toView(a);var s=new Rn(e,"inputTransformation");e.fire(s,{content:a,dataTransfer:o}),s.stop.called&&t.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",(function(t,i){if(!i.content.isEmpty){var r=e.editor.data,o=e.editor.model,a=r.toModel(i.content,"$clipboardHolder");if(0==a.childCount)return;if(function(e){return!(e.childCount>1)&&0==u(e.getChild(0).getAttributeKeys()).length}(a)){var s=a.getChild(0);o.change((function(e){e.setAttributes(n.selection.getAttributes(),s)}))}o.insertContent(a),t.stop()}}),{priority:"low"}),this.listenTo(r,"copy",o,{priority:"low"}),this.listenTo(r,"cut",(function(e,n){t.isReadOnly?n.preventDefault():o(e,n)}),{priority:"low"}),this.listenTo(r,"clipboardOutput",(function(i,r){r.content.isEmpty||(r.dataTransfer.setData("text/html",e._htmlDataProcessor.toData(r.content)),r.dataTransfer.setData("text/plain",function e(t){var n="";if(t.is("$text")||t.is("$textProxy"))n=t.data;else if(t.is("element","img")&&t.hasAttribute("alt"))n=t.getAttribute("alt");else{var i,r=null,o=k(t.getChildren());try{for(o.s();!(i=o.n()).done;){var a=i.value,s=e(a);r&&(r.is("containerElement")||a.is("containerElement"))&&(hh.includes(r.name)||hh.includes(a.name)?n+="\n":n+="\n\n"),n+=s,r=a}}catch(l){o.e(l)}finally{o.f()}}return n}(r.content))),"cut"==r.method&&t.model.deleteContent(n.selection)}),{priority:"low"})}}],[{key:"pluginName",get:function(){return"Clipboard"}}]),n}(Vu),vh=function(){function e(){w(this,e),this._definitions=new Set}return x(e,[{key:"add",value:function(e){var t=this;Array.isArray(e)?e.forEach((function(e){return t._definitions.add(e)})):this._definitions.add(e)}},{key:"getDispatcher",value:function(){var e=this;return function(t){t.on("attribute:linkHref",(function(t,n,i){if(i.consumable.test(n.item,"attribute:linkHref")){var r,o=i.writer,a=o.document.selection,s=k(e._definitions);try{for(s.s();!(r=s.n()).done;){var l=r.value,c=o.createAttributeElement("a",l.attributes,{priority:5});o.setCustomProperty("link",!0,c),l.callback(n.attributeNewValue)?n.item.is("selection")?o.wrap(a.getFirstRange(),c):o.wrap(i.mapper.toViewRange(n.range),c):o.unwrap(i.mapper.toViewRange(n.range),c)}}catch(u){s.e(u)}finally{s.f()}}}),{priority:"high"})}}},{key:"getDispatcherForLinkedImage",value:function(){var e=this;return function(t){t.on("attribute:linkHref:image",(function(t,n,i){var r,o=i.mapper.toViewElement(n.item),a=Array.from(o.getChildren()).find((function(e){return"a"===e.name})),s=k(e._definitions);try{for(s.s();!(r=s.n()).done;){var l=r.value,c=li(l.attributes);if(l.callback(n.attributeNewValue)){var u,d=k(c);try{for(d.s();!(u=d.n()).done;){var h=v(u.value,2),f=h[0],p=h[1];"class"===f?i.writer.addClass(p,a):i.writer.setAttribute(f,p,a)}}catch(_){d.e(_)}finally{d.f()}}else{var m,g=k(c);try{for(g.s();!(m=g.n()).done;){var b=v(m.value,2),y=b[0],w=b[1];"class"===y?i.writer.removeClass(w,a):i.writer.removeAttribute(y,a)}}catch(_){g.e(_)}finally{g.f()}}}}catch(_){s.e(_)}finally{s.f()}}))}}},{key:"length",get:function(){return this._definitions.size}}]),e}(),ph=function(e,t,n){var i=e.length;return n=void 0===n?i:n,!t&&n>=i?e:Si(e,t,n)},mh=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]"),gh=function(e){return mh.test(e)},kh=function(e){return e.split("")},bh="[\\ud800-\\udfff]",yh="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",wh="\\ud83c[\\udffb-\\udfff]",_h="[^\\ud800-\\udfff]",xh="(?:\\ud83c[\\udde6-\\uddff]){2}",Ch="[\\ud800-\\udbff][\\udc00-\\udfff]",Ah="(?:"+yh+"|"+wh+")?",Th="[\\ufe0e\\ufe0f]?",Ph=Th+Ah+"(?:\\u200d(?:"+[_h,xh,Ch].join("|")+")"+Th+Ah+")*",Eh="(?:"+[_h+yh+"?",yh,xh,Ch,bh].join("|")+")",Sh=RegExp(wh+"(?="+wh+")|"+Eh+Ph,"g"),Oh=function(e){return e.match(Sh)||[]},Mh=function(e){return gh(e)?Oh(e):kh(e)},Ih=function(e){return function(t){t=Ci(t);var n=gh(t)?Mh(t):void 0,i=n?n[0]:t.charAt(0),r=n?ph(n,1).join(""):t.slice(1);return i[e]()+r}}("toUpperCase"),Nh=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Rh=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,Dh="Ctrl+K";function Lh(e,t){var n=t.writer,i=n.createAttributeElement("a",{href:e},{priority:5});return n.setCustomProperty("link",!0,i),i}function zh(e){return function(e){return e.replace(Nh,"").match(Rh)}(e=String(e))?e:"#"}function jh(e,t){return!!e&&e.is("element","image")&&t.checkAttribute("image","linkHref")}var Vh=function(e){C(n,e);var t=A(n);function n(e){var i;return w(this,n),i=t.call(this,e),i.manualDecorators=new Jn,i.automaticDecorators=new vh,i}return x(n,[{key:"restoreManualDecoratorStates",value:function(){var e,t=k(this.manualDecorators);try{for(t.s();!(e=t.n()).done;){var n=e.value;n.value=this._getDecoratorStateFromModel(n.id)}}catch(i){t.e(i)}finally{t.f()}}},{key:"refresh",value:function(){var e=this.editor.model,t=e.document,n=Hu(t.selection.getSelectedBlocks());jh(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"));var i,r=k(this.manualDecorators);try{for(r.s();!(i=r.n()).done;){var o=i.value;o.value=this._getDecoratorStateFromModel(o.id)}}catch(a){r.e(a)}finally{r.f()}}},{key:"execute",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.editor.model,r=i.document.selection,o=[],a=[];for(var s in n)n[s]?o.push(s):a.push(s);i.change((function(n){if(r.isCollapsed){var s=r.getFirstPosition();if(r.hasAttribute("linkHref")){var l=Qd(s,"linkHref",r.getAttribute("linkHref"),i);n.setAttribute("linkHref",e,l),o.forEach((function(e){n.setAttribute(e,!0,l)})),a.forEach((function(e){n.removeAttribute(e,l)})),n.setSelection(n.createPositionAfter(l.end.nodeBefore))}else if(""!==e){var c=li(r.getAttributes());c.set("linkHref",e),o.forEach((function(e){c.set(e,!0)}));var u=n.createText(e,c);i.insertContent(u,s),n.setSelection(n.createPositionAfter(u))}["linkHref"].concat(o,a).forEach((function(e){n.removeSelectionAttribute(e)}))}else{var d,h=i.schema.getValidRanges(r.getRanges(),"linkHref"),f=[],v=k(r.getSelectedBlocks());try{for(v.s();!(d=v.n()).done;){var p=d.value;i.schema.checkAttribute(p,"linkHref")&&f.push(n.createRangeOn(p))}}catch(C){v.e(C)}finally{v.f()}var m,g=f.slice(),b=k(h);try{for(b.s();!(m=b.n()).done;){var y=m.value;t._isRangeToUpdate(y,f)&&g.push(y)}}catch(C){b.e(C)}finally{b.f()}var w,_=k(g);try{var x=function(){var t=w.value;n.setAttribute("linkHref",e,t),o.forEach((function(e){n.setAttribute(e,!0,t)})),a.forEach((function(e){n.removeAttribute(e,t)}))};for(_.s();!(w=_.n()).done;)x()}catch(C){_.e(C)}finally{_.f()}}}))}},{key:"_getDecoratorStateFromModel",value:function(e){var t=this.editor.model,n=t.document,i=Hu(n.selection.getSelectedBlocks());return jh(i,t.schema)?i.getAttribute(e):n.selection.getAttribute(e)}},{key:"_isRangeToUpdate",value:function(e,t){var n,i=k(t);try{for(i.s();!(n=i.n()).done;){var r=n.value;if(r.containsRange(e))return!1}}catch(o){i.e(o)}finally{i.f()}return!0}}]),n}(Fu),Bh=function(e){C(n,e);var t=A(n);function n(){return w(this,n),t.apply(this,arguments)}return x(n,[{key:"refresh",value:function(){var e=this.editor.model,t=e.document,n=Hu(t.selection.getSelectedBlocks());jh(n,e.schema)?this.isEnabled=e.schema.checkAttribute(n,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref")}},{key:"execute",value:function(){var e=this.editor,t=this.editor.model,n=t.document.selection,i=e.commands.get("link");t.change((function(e){var r,o=n.isCollapsed?[Qd(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),t)]:n.getRanges(),a=k(o);try{for(a.s();!(r=a.n()).done;){var s=r.value;if(e.removeAttribute("linkHref",s),i){var l,c=k(i.manualDecorators);try{for(c.s();!(l=c.n()).done;){var u=l.value;e.removeAttribute(u.id,s)}}catch(d){c.e(d)}finally{c.f()}}}}catch(d){a.e(d)}finally{a.f()}}))}}]),n}(Fu),Fh=function e(t){var n=t.id,i=t.label,r=t.attributes,o=t.defaultValue;w(this,e),this.id=n,this.set("value"),this.defaultValue=o,this.label=i,this.attributes=r};Kn(Fh,vr),n(45);var Uh="automatic",Hh=/^(https?:)?\/\//,$h=function(e){C(n,e);var t=A(n);function n(e){var i;return w(this,n),i=t.call(this,e),e.config.define("link",{addTargetToExternalLinks:!1}),i}return x(n,null,[{key:"pluginName",get:function(){return"LinkEditing"}},{key:"requires",get:function(){return[qd,ch,fh]}}]),x(n,[{key:"init",value:function(){var e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:Lh}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:function(e,t){return Lh(zh(e),t)}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:function(e){return e.getAttribute("href")}}}),e.commands.add("link",new Vh(e)),e.commands.add("unlink",new Bh(e));var t=function(e,t){var n={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((function(e){return e.label&&n[e.label]&&(e.label=n[e.label]),e})),t}(e.t,function(e){var t=[];if(e)for(var n=0,i=Object.entries(e);n").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).indexOf("
")>-1&&(r=`
${r}
`),o=r),o=this._htmlDataProcessor.toView(o);const s=new gi(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:n}),s.stop.called&&e.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(e,i)=>{if(!i.content.isEmpty){const n=this.editor.data,o=this.editor.model,r=n.toModel(i.content,"$clipboardHolder");if(0==r.childCount)return;if(function(e){if(e.childCount>1)return!1;return 0==[...e.getChild(0).getAttributeKeys()].length}(r)){const e=r.getChild(0);o.change(i=>{i.setAttributes(t.selection.getAttributes(),e)})}o.insertContent(r),e.stop()}},{priority:"low"}),this.listenTo(n,"copy",o,{priority:"low"}),this.listenTo(n,"cut",(t,i)=>{e.isReadOnly?i.preventDefault():o(t,i)},{priority:"low"}),this.listenTo(n,"clipboardOutput",(i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this._htmlDataProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",function e(t){let i="";if(t.is("$text")||t.is("$textProxy"))i=t.data;else if(t.is("element","img")&&t.hasAttribute("alt"))i=t.getAttribute("alt");else{let n=null;for(const o of t.getChildren()){const t=e(o);n&&(n.is("containerElement")||o.is("containerElement"))&&($h.includes(n.name)||$h.includes(o.name)?i+="\n":i+="\n\n"),i+=t,n=o}}return i}(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}class Gh{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,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;const n=i.writer,o=n.document.selection;for(const e of this._definitions){const r=n.createAttributeElement("a",e.attributes,{priority:5});n.setCustomProperty("link",!0,r),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(o.getFirstRange(),r):n.wrap(i.mapper.toViewRange(t.range),r):n.unwrap(i.mapper.toViewRange(t.range),r)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:image",(e,t,i)=>{const n=i.mapper.toViewElement(t.item),o=Array.from(n.getChildren()).find(e=>"a"===e.name);for(const e of this._definitions){const n=Ui(e.attributes);if(e.callback(t.attributeNewValue))for(const[e,t]of n)"class"===e?i.writer.addClass(t,o):i.writer.setAttribute(e,t,o);else for(const[e,t]of n)"class"===e?i.writer.removeClass(t,o):i.writer.removeAttribute(e,o)}})}}}var Kh=function(e,t,i){var n=e.length;return i=void 0===i?n:i,!t&&i>=n?e:hn(e,t,i)},Jh=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Qh=function(e){return Jh.test(e)};var Zh=function(e){return e.split("")},Xh="[\\ud800-\\udfff]",eu="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",tu="\\ud83c[\\udffb-\\udfff]",iu="[^\\ud800-\\udfff]",nu="(?:\\ud83c[\\udde6-\\uddff]){2}",ou="[\\ud800-\\udbff][\\udc00-\\udfff]",ru="(?:"+eu+"|"+tu+")"+"?",su="[\\ufe0e\\ufe0f]?",au=su+ru+("(?:\\u200d(?:"+[iu,nu,ou].join("|")+")"+su+ru+")*"),cu="(?:"+[iu+eu+"?",eu,nu,ou,Xh].join("|")+")",lu=RegExp(tu+"(?="+tu+")|"+cu+au,"g");var du=function(e){return e.match(lu)||[]};var hu=function(e){return Qh(e)?du(e):Zh(e)};var uu=function(e){return function(t){t=sn(t);var i=Qh(t)?hu(t):void 0,n=i?i[0]:t.charAt(0),o=i?Kh(i,1).join(""):t.slice(1);return n[e]()+o}}("toUpperCase");const mu=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,fu=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,gu="Ctrl+K";function pu(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function bu(e){return function(e){return e.replace(mu,"").match(fu)}(e=String(e))?e:"#"}function wu(e,t){return!!e&&(e.is("element","image")&&t.checkAttribute("image","linkHref"))}class ku extends xd{constructor(e){super(e),this.manualDecorators=new Ii,this.automaticDecorators=new Gh}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document,i=Cd(t.selection.getSelectedBlocks());wu(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"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 i=this.editor.model,n=i.document.selection,o=[],r=[];for(const e in t)t[e]?o.push(e):r.push(e);i.change(t=>{if(n.isCollapsed){const s=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=Nh(s,"linkHref",n.getAttribute("linkHref"),i);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=Ui(n.getAttributes());r.set("linkHref",e),o.forEach(e=>{r.set(e,!0)});const a=t.createText(e,r);i.insertContent(a,s),t.setSelection(t.createPositionAfter(a))}["linkHref",...o,...r].forEach(e=>{t.removeSelectionAttribute(e)})}else{const s=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.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 i of c)t.setAttribute("linkHref",e,i),o.forEach(e=>{t.setAttribute(e,!0,i)}),r.forEach(e=>{t.removeAttribute(e,i)})}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document,n=Cd(i.selection.getSelectedBlocks());return wu(n,t.schema)?n.getAttribute(e):i.selection.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}class _u extends xd{refresh(){const e=this.editor.model,t=e.document,i=Cd(t.selection.getSelectedBlocks());wu(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change(e=>{const o=i.isCollapsed?[Nh(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:i.getRanges();for(const t of o)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)})}}class vu{constructor({id:e,label:t,attributes:i,defaultValue:n}){this.id=e,this.set("value"),this.defaultValue=n,this.label=t,this.attributes=i}}Mi(vu,Jn);i(45);const yu="automatic",xu=/^(https?:)?\/\//;class Au extends vd{static get pluginName(){return"LinkEditing"}static get requires(){return[Ph,Uh,Yh]}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:pu}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>pu(bu(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 ku(e)),e.commands.add("unlink",new _u(e));const t=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach(e=>(e.label&&i[e.label]&&(e.label=i[e.label]),e)),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:"link"+uu(i)});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter(e=>e.mode===yu)),this._enableManualDecorators(t.filter(e=>"manual"===e.mode));e.plugins.get(Ph).registerAttribute("linkHref"),function(e,t,i,n){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=Nh(s.getFirstPosition(),t,s.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(const e of l.getItems())e.is("element",i)&&!e.hasClass(n)&&(o.addClass(n,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(n,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,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:yu,callback:e=>xu.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach(e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),i.add(new vu(e)),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,{writer:n})=>{if(t){const t=i.get(e.id).attributes,o=n.createAttributeElement("a",t,{priority:5});return n.setCustomProperty("link",!0,o),o}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:i.get(e.id).attributes},model:{key:e.id}})})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor,t=e.model,i=t.document.selection,n=e.commands.get("link");this.listenTo(t,"insertContent",()=>{const e=i.anchor.nodeBefore,o=i.anchor.nodeAfter;i.hasAttribute("linkHref")&&e&&e.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change(e=>{Cu(e,n.manualDecorators)}))},{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.commands.get("link");e.editing.view.addObserver(Th);let i=!1;this.listenTo(e.editing.view.document,"mousedown",()=>{i=!0}),this.listenTo(e.editing.view.document,"selectionChange",()=>{if(!i)return;i=!1;const n=e.model.document.selection;if(!n.isCollapsed)return;if(!n.hasAttribute("linkHref"))return;const o=n.getFirstPosition(),r=Nh(o,"linkHref",n.getAttribute("linkHref"),e.model);(o.isTouching(r.start)||o.isTouching(r.end))&&e.model.change(e=>{Cu(e,t.manualDecorators)})})}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let i,n;this.listenTo(t.document,"delete",()=>{n=!0},{priority:"high"}),this.listenTo(e.model,"deleteContent",()=>{const t=e.model.document.selection;t.isCollapsed||(n?n=!1:Tu(e)&&function(e){const t=e.document.selection,i=t.getFirstPosition(),n=t.getLastPosition(),o=i.nodeAfter;if(!o)return!1;if(!o.is("$text"))return!1;if(!o.hasAttribute("linkHref"))return!1;const r=n.textNode||n.nodeBefore;if(o===r)return!0;return Nh(i,"linkHref",o.getAttribute("linkHref"),e).containsRange(e.createRange(i,n),!0)}(e.model)&&(i=t.getAttributes()))},{priority:"high"}),this.listenTo(e.model,"insertContent",(t,[o])=>{n=!1,Tu(e)&&i&&(e.model.change(e=>{for(const[t,n]of i)e.setAttribute(t,n,o)}),i=null)},{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view,o=e.commands.get("link");let r=!1,s=!1;this.listenTo(n.document,"delete",(e,t)=>{s=t.domEvent.keyCode===xo.backspace},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{r=!1;const e=i.getFirstPosition(),n=i.getAttribute("linkHref");if(!n)return;const o=Nh(e,"linkHref",n,t);r=o.containsPosition(e)||o.end.isEqual(e)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{s&&(s=!1,r||e.model.enqueueChange(e=>{Cu(e,o.manualDecorators)}))},{priority:"low"})}}function Cu(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i.id)}function Tu(e){return e.plugins.get("Input").isInput(e.model.change(e=>e.batch))}class Pu{constructor(e){this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}Mi(Pu,Jn);class Su extends Pu{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 Eu extends xd{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 ki.b('ckfinder-unknown-openerMethod: The openerMethod config option must by "popup" or "modal".',e);const i=this.editor.config.get("ckfinder.options")||{};i.chooseFiles=!0;const n=i.onInit;i.language||(i.language=e.locale.uiLanguage),i.onInit=t=>{n&&n(t),t.on("files:choose",i=>{const n=i.data.files.toArray(),o=n.filter(e=>!e.isImage()),r=n.filter(e=>e.isImage());for(const t of o)e.execute("link",t.getUrl());const s=[];for(const e of r){const i=e.getUrl();s.push(i||t.request("file:getProxyUrl",{file:e}))}s.length&&Mu(e,s)}),t.on("file:choose:resizedImage",t=>{const i=t.data.resizedUrl;if(i)Mu(e,[i]);else{const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("Could not obtain resized image URL."),{title:i("Selecting resized image failed"),namespace:"ckfinder"})}})},window.CKFinder[t](i)}}function Mu(e,t){if(e.commands.get("imageInsert").isEnabled)e.execute("imageInsert",{source:t});else{const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("Could not insert image at the current position."),{title:i("Inserting image failed"),namespace:"ckfinder"})}}class Iu extends vd{static get pluginName(){return"CKFinderEditing"}static get requires(){return[Su,Ah,Au]}init(){const e=this.editor;e.commands.add("ckfinder",new Eu(e))}}class Nu extends Pu{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Ii({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new ki.b("pendingactions-add-invalid-message: The message must be a string.",this);const t=Object.create(Jn);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 Ru{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((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}}Mi(Ru,Jn);class Ou extends vd{static get pluginName(){return"FileRepository"}static get requires(){return[Nu]}init(){this.loaders=new Ii,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 console.warn(Object(ki.a)("filerepository-no-upload-adapter: Upload adapter is not defined.")),null;const t=new zu(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 zu?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((e,i)=>{e===t&&this._loadersMap.delete(i)})}_updatePendingAction(){const e=this.editor.plugins.get(Nu);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}Mi(Ou,Jn);class zu{constructor(e,t){this.id=bi(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new Ru,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 ki.b("filerepository-read-wrong-status: You cannot call read if the status is different than idle.",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 ki.b("filerepository-upload-wrong-status: You cannot call upload if the status is different than idle.",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((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then(e=>{t.isFulfilled=!0,i(e)}).catch(e=>{t.isFulfilled=!0,n(e)})}),t}}Mi(zu,Jn);const Du="ckCsrfToken",Lu="abcdefghijklmnopqrstuvwxyz0123456789";function Vu(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const i of t){const t=i.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(Du);var t,i;return e&&40==e.length||(e=function(e){let t="";const i=new Uint8Array(e);window.crypto.getRandomValues(i);for(let e=0;e").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).indexOf("
")>-1&&(r=`
${r}
`),o=r),o=this._htmlDataProcessor.toView(o);const s=new gi(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:n}),s.stop.called&&e.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(e,i)=>{if(!i.content.isEmpty){const n=this.editor.data,o=this.editor.model,r=n.toModel(i.content,"$clipboardHolder");if(0==r.childCount)return;if(function(e){if(e.childCount>1)return!1;return 0==[...e.getChild(0).getAttributeKeys()].length}(r)){const e=r.getChild(0);o.change(i=>{i.setAttributes(t.selection.getAttributes(),e)})}o.insertContent(r),e.stop()}},{priority:"low"}),this.listenTo(n,"copy",o,{priority:"low"}),this.listenTo(n,"cut",(t,i)=>{e.isReadOnly?i.preventDefault():o(t,i)},{priority:"low"}),this.listenTo(n,"clipboardOutput",(i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this._htmlDataProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",function e(t){let i="";if(t.is("$text")||t.is("$textProxy"))i=t.data;else if(t.is("element","img")&&t.hasAttribute("alt"))i=t.getAttribute("alt");else{let n=null;for(const o of t.getChildren()){const t=e(o);n&&(n.is("containerElement")||o.is("containerElement"))&&(Yu.includes(n.name)||Yu.includes(o.name)?i+="\n":i+="\n\n"),i+=t,n=o}}return i}(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}class Ku{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,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;const n=i.writer,o=n.document.selection;for(const e of this._definitions){const r=n.createAttributeElement("a",e.attributes,{priority:5});n.setCustomProperty("link",!0,r),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(o.getFirstRange(),r):n.wrap(i.mapper.toViewRange(t.range),r):n.unwrap(i.mapper.toViewRange(t.range),r)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:image",(e,t,i)=>{const n=i.mapper.toViewElement(t.item),o=Array.from(n.getChildren()).find(e=>"a"===e.name);for(const e of this._definitions){const n=Ui(e.attributes);if(e.callback(t.attributeNewValue))for(const[e,t]of n)"class"===e?i.writer.addClass(t,o):i.writer.setAttribute(e,t,o);else for(const[e,t]of n)"class"===e?i.writer.removeClass(t,o):i.writer.removeAttribute(e,o)}})}}}var Ju=function(e,t,i){var n=e.length;return i=void 0===i?n:i,!t&&i>=n?e:un(e,t,i)},Qu=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Zu=function(e){return Qu.test(e)};var Xu=function(e){return e.split("")},eh="[\\ud800-\\udfff]",th="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",ih="\\ud83c[\\udffb-\\udfff]",nh="[^\\ud800-\\udfff]",oh="(?:\\ud83c[\\udde6-\\uddff]){2}",rh="[\\ud800-\\udbff][\\udc00-\\udfff]",sh="(?:"+th+"|"+ih+")"+"?",ah="[\\ufe0e\\ufe0f]?",ch=ah+sh+("(?:\\u200d(?:"+[nh,oh,rh].join("|")+")"+ah+sh+")*"),lh="(?:"+[nh+th+"?",th,oh,rh,eh].join("|")+")",dh=RegExp(ih+"(?="+ih+")|"+lh+ch,"g");var uh=function(e){return e.match(dh)||[]};var hh=function(e){return Zu(e)?uh(e):Xu(e)};var mh=function(e){return function(t){t=sn(t);var i=Zu(t)?hh(t):void 0,n=i?i[0]:t.charAt(0),o=i?Ju(i,1).join(""):t.slice(1);return n[e]()+o}}("toUpperCase");const fh=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,gh=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,ph="Ctrl+K";function bh(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function wh(e){return function(e){return e.replace(fh,"").match(gh)}(e=String(e))?e:"#"}function kh(e,t){return!!e&&(e.is("element","image")&&t.checkAttribute("image","linkHref"))}class _h extends xd{constructor(e){super(e),this.manualDecorators=new Ii,this.automaticDecorators=new Ku}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document,i=Cd(t.selection.getSelectedBlocks());kh(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"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 i=this.editor.model,n=i.document.selection,o=[],r=[];for(const e in t)t[e]?o.push(e):r.push(e);i.change(t=>{if(n.isCollapsed){const s=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=Ru(s,"linkHref",n.getAttribute("linkHref"),i);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=Ui(n.getAttributes());r.set("linkHref",e),o.forEach(e=>{r.set(e,!0)});const a=t.createText(e,r);i.insertContent(a,s),t.setSelection(t.createPositionAfter(a))}["linkHref",...o,...r].forEach(e=>{t.removeSelectionAttribute(e)})}else{const s=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.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 i of c)t.setAttribute("linkHref",e,i),o.forEach(e=>{t.setAttribute(e,!0,i)}),r.forEach(e=>{t.removeAttribute(e,i)})}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document,n=Cd(i.selection.getSelectedBlocks());return kh(n,t.schema)?n.getAttribute(e):i.selection.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}class vh extends xd{refresh(){const e=this.editor.model,t=e.document,i=Cd(t.selection.getSelectedBlocks());kh(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change(e=>{const o=i.isCollapsed?[Ru(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:i.getRanges();for(const t of o)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)})}}class yh{constructor({id:e,label:t,attributes:i,defaultValue:n}){this.id=e,this.set("value"),this.defaultValue=n,this.label=t,this.attributes=i}}Mi(yh,Jn);i(45);const xh="automatic",Ah=/^(https?:)?\/\//;class Ch extends vd{static get pluginName(){return"LinkEditing"}static get requires(){return[Su,Wu,Gu]}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:bh}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>bh(wh(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 _h(e)),e.commands.add("unlink",new vh(e));const t=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach(e=>(e.label&&i[e.label]&&(e.label=i[e.label]),e)),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:"link"+mh(i)});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter(e=>e.mode===xh)),this._enableManualDecorators(t.filter(e=>"manual"===e.mode));e.plugins.get(Su).registerAttribute("linkHref"),function(e,t,i,n){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=Ru(s.getFirstPosition(),t,s.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(const e of l.getItems())e.is("element",i)&&!e.hasClass(n)&&(o.addClass(n,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(n,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,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:xh,callback:e=>Ah.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach(e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),i.add(new yh(e)),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,{writer:n})=>{if(t){const t=i.get(e.id).attributes,o=n.createAttributeElement("a",t,{priority:5});return n.setCustomProperty("link",!0,o),o}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:i.get(e.id).attributes},model:{key:e.id}})})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor,t=e.model,i=t.document.selection,n=e.commands.get("link");this.listenTo(t,"insertContent",()=>{const e=i.anchor.nodeBefore,o=i.anchor.nodeAfter;i.hasAttribute("linkHref")&&e&&e.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change(e=>{Th(e,n.manualDecorators)}))},{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.commands.get("link");e.editing.view.addObserver(Pu);let i=!1;this.listenTo(e.editing.view.document,"mousedown",()=>{i=!0}),this.listenTo(e.editing.view.document,"selectionChange",()=>{if(!i)return;i=!1;const n=e.model.document.selection;if(!n.isCollapsed)return;if(!n.hasAttribute("linkHref"))return;const o=n.getFirstPosition(),r=Ru(o,"linkHref",n.getAttribute("linkHref"),e.model);(o.isTouching(r.start)||o.isTouching(r.end))&&e.model.change(e=>{Th(e,t.manualDecorators)})})}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let i,n;this.listenTo(t.document,"delete",()=>{n=!0},{priority:"high"}),this.listenTo(e.model,"deleteContent",()=>{const t=e.model.document.selection;t.isCollapsed||(n?n=!1:Ph(e)&&function(e){const t=e.document.selection,i=t.getFirstPosition(),n=t.getLastPosition(),o=i.nodeAfter;if(!o)return!1;if(!o.is("$text"))return!1;if(!o.hasAttribute("linkHref"))return!1;const r=n.textNode||n.nodeBefore;if(o===r)return!0;return Ru(i,"linkHref",o.getAttribute("linkHref"),e).containsRange(e.createRange(i,n),!0)}(e.model)&&(i=t.getAttributes()))},{priority:"high"}),this.listenTo(e.model,"insertContent",(t,[o])=>{n=!1,Ph(e)&&i&&(e.model.change(e=>{for(const[t,n]of i)e.setAttribute(t,n,o)}),i=null)},{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view,o=e.commands.get("link");let r=!1,s=!1;this.listenTo(n.document,"delete",(e,t)=>{s=t.domEvent.keyCode===xo.backspace},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{r=!1;const e=i.getFirstPosition(),n=i.getAttribute("linkHref");if(!n)return;const o=Ru(e,"linkHref",n,t);r=o.containsPosition(e)||o.end.isEqual(e)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{s&&(s=!1,r||e.model.enqueueChange(e=>{Th(e,o.manualDecorators)}))},{priority:"low"})}}function Th(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i.id)}function Ph(e){return e.plugins.get("Input").isInput(e.model.change(e=>e.batch))}class Sh{constructor(e){this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}Mi(Sh,Jn);class Eh extends Sh{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 Mh extends xd{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 ki.b('ckfinder-unknown-openerMethod: The openerMethod config option must by "popup" or "modal".',e);const i=this.editor.config.get("ckfinder.options")||{};i.chooseFiles=!0;const n=i.onInit;i.language||(i.language=e.locale.uiLanguage),i.onInit=t=>{n&&n(t),t.on("files:choose",i=>{const n=i.data.files.toArray(),o=n.filter(e=>!e.isImage()),r=n.filter(e=>e.isImage());for(const t of o)e.execute("link",t.getUrl());const s=[];for(const e of r){const i=e.getUrl();s.push(i||t.request("file:getProxyUrl",{file:e}))}s.length&&Ih(e,s)}),t.on("file:choose:resizedImage",t=>{const i=t.data.resizedUrl;if(i)Ih(e,[i]);else{const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("Could not obtain resized image URL."),{title:i("Selecting resized image failed"),namespace:"ckfinder"})}})},window.CKFinder[t](i)}}function Ih(e,t){if(e.commands.get("imageInsert").isEnabled)e.execute("imageInsert",{source:t});else{const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("Could not insert image at the current position."),{title:i("Inserting image failed"),namespace:"ckfinder"})}}class Nh extends vd{static get pluginName(){return"CKFinderEditing"}static get requires(){return[Eh,Cu,Ch]}init(){const e=this.editor;e.commands.add("ckfinder",new Mh(e))}}class Rh extends Sh{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Ii({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new ki.b("pendingactions-add-invalid-message: The message must be a string.",this);const t=Object.create(Jn);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 Oh{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((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}}Mi(Oh,Jn);class zh extends vd{static get pluginName(){return"FileRepository"}static get requires(){return[Rh]}init(){this.loaders=new Ii,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 console.warn(Object(ki.a)("filerepository-no-upload-adapter: Upload adapter is not defined.")),null;const t=new Dh(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 Dh?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((e,i)=>{e===t&&this._loadersMap.delete(i)})}_updatePendingAction(){const e=this.editor.plugins.get(Rh);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}Mi(zh,Jn);class Dh{constructor(e,t){this.id=bi(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new Oh,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 ki.b("filerepository-read-wrong-status: You cannot call read if the status is different than idle.",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 ki.b("filerepository-upload-wrong-status: You cannot call upload if the status is different than idle.",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((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then(e=>{t.isFulfilled=!0,i(e)}).catch(e=>{t.isFulfilled=!0,n(e)})}),t}}Mi(Dh,Jn);const Lh="ckCsrfToken",Vh="abcdefghijklmnopqrstuvwxyz0123456789";function jh(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const i of t){const t=i.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(Lh);var t,i;return e&&40==e.length||(e=function(e){let t="";const i=new Uint8Array(e);window.crypto.getRandomValues(i);for(let e=0;e