import{Command as ee,Plugin as _}from"@ckeditor/ckeditor5-core";import{findAttributeRange as D,TwoStepCaretMovement as te,Input as Pe,inlineHighlight as Ce,Delete as Se,TextWatcher as De,getLastTextLine as Be}from"@ckeditor/ckeditor5-typing";import{ClipboardPipeline as Ne}from"@ckeditor/ckeditor5-clipboard";import{toMap as B,Collection as ie,first as ne,diff as Me,ObservableMixin as He,env as Re,keyCodes as Fe,FocusTracker as N,KeystrokeHandler as M}from"@ckeditor/ckeditor5-utils";import{ModelLivePosition as se,ClickObserver as Ue,Matcher as Oe}from"@ckeditor/ckeditor5-engine";import{IconPreviousArrow as H,IconNextArrow as ze,IconUnlink as je,IconPencil as Ke,IconSettings as Ye,IconLink as oe}from"@ckeditor/ckeditor5-icons";import{ButtonView as p,View as E,ViewCollection as R,FocusCycler as F,submitHandler as qe,FormHeaderView as U,ListView as O,ListItemView as z,LabeledFieldView as re,createLabeledInputText as le,FormRowView as ae,IconView as $e,ContextualBalloon as ce,ToolbarView as Ge,CssTransitionDisablerMixin as de,SwitchButtonView as We,MenuBarMenuListItemButtonView as Qe,clickOutsideHandler as Ze}from"@ckeditor/ckeditor5-ui";import{isWidget as Xe}from"@ckeditor/ckeditor5-widget";/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ue{_definitions=new Set;get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach(t=>this._definitions.add(t)):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",(t,i,n)=>{if(!n.consumable.test(i.item,"attribute:linkHref")||!(i.item.is("selection")||n.schema.isInline(i.item)))return;const s=n.writer,r=s.document.selection;for(const a of this._definitions){const l=s.createAttributeElement("a",a.attributes,{priority:5});a.classes&&s.addClass(a.classes,l);for(const c in a.styles)s.setStyle(c,a.styles[c],l);s.setCustomProperty("link",!0,l),a.callback(i.attributeNewValue)?i.item.is("selection")?s.wrap(r.getFirstRange(),l):s.wrap(n.mapper.toViewRange(i.range),l):s.unwrap(n.mapper.toViewRange(i.range),l)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",(t,i,{writer:n,mapper:s})=>{const r=s.toViewElement(i.item),a=Array.from(r.getChildren()).find(l=>l.is("element","a"));if(a)for(const l of this._definitions){const c=B(l.attributes);if(l.callback(i.attributeNewValue)){for(const[u,k]of c)u==="class"?n.addClass(k,a):n.setAttribute(u,k,a);l.classes&&n.addClass(l.classes,a);for(const u in l.styles)n.setStyle(u,l.styles[u],a)}else{for(const[u,k]of c)u==="class"?n.removeClass(k,a):n.removeAttribute(u,a);l.classes&&n.removeClass(l.classes,a);for(const u in l.styles)n.removeStyle(u,a)}}})}}}function ke(o){if(o==null)return"";if(typeof o=="string")return o;if(Array.isArray(o))return o.map(ke).join(",");const e=String(o);return e==="0"&&Object.is(Number(o),-0)?"-0":e}function Je(o){return o.substring(0,1).toUpperCase()+o.substring(1)}function et(o){return Je(ke(o))}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const tt=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,it="^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))",nt=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,st=/^((\w+:(\/{2,})?)|(\W))/i,ot=["https?","ftps?","mailto"],v="Ctrl+K";function j(o){return o.is("attributeElement")&&!!o.getCustomProperty("link")}function A(o,{writer:e}){const t=e.createAttributeElement("a",{href:o},{priority:5});return e.setCustomProperty("link",!0,t),t}function I(o,e=ot){const t=String(o),i=e.join("|"),n=new RegExp(`${it.replace("<protocols>",i)}`,"i");return rt(t,n)?t:"#"}function rt(o,e){return!!o.replace(tt,"").match(e)}function K(o,e){const t={"Open in a new tab":o("Open in a new tab"),Downloadable:o("Downloadable")};return e.forEach(i=>("label"in i&&t[i.label]&&(i.label=t[i.label]),i)),e}function Y(o){const e=[];if(o)for(const[t,i]of Object.entries(o)){const n=Object.assign({},i,{id:`link${et(t)}`});e.push(n)}return e}function y(o,e){return o?e.checkAttribute(o.name,"linkHref"):!1}function q(o){return nt.test(o)}function x(o,e){const t=q(o)?"mailto:":e,i=!!t&&!P(o);return o&&i?t+o:o}function P(o){return st.test(o)}function $(o){window.open(o,"_blank","noopener")}function T(o){let e="";for(const t of o.getItems()){if(!t.is("$text")&&!t.is("$textProxy"))return;e+=t.data}return e}var lt=Object.freeze({__proto__:null,LINK_KEYSTROKE:v,addLinkProtocolIfApplicable:x,createLinkElement:A,ensureSafeUrl:I,extractTextFromLinkRange:T,getLocalizedDecorators:K,isEmail:q,isLinkElement:j,isLinkableElement:y,linkHasProtocol:P,normalizeDecorators:Y,openLink:$});/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class he extends ee{manualDecorators=new ie;automaticDecorators=new ue;restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||ne(t.getSelectedBlocks());y(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const n of this.manualDecorators)n.value=this._getDecoratorStateFromModel(n.id)}execute(e,t={},i){const n=this.editor.model,s=n.document.selection,r=[],a=[];for(const l in t)t[l]?r.push(l):a.push(l);n.change(l=>{const c=d=>{l.setAttribute("linkHref",e,d),r.forEach(h=>l.setAttribute(h,!0,d)),a.forEach(h=>l.removeAttribute(h,d))},u=(d,h)=>{const f=T(d);if(!f)return d;let g=i;if(g||(g=h&&h==f?e:f),g!=f){const C=at(f,g);let m=0;for(const{offset:L,actual:S,expected:Q}of C){const Z=L+m,X=l.createRange(d.start.getShiftedBy(Z),d.start.getShiftedBy(Z+S.length)),Te=ct(X,d).getAttributes(),Ee=Array.from(Te).filter(([Ae])=>n.schema.getAttributeProperties(Ae).isFormatting),J=l.createText(Q,Ee);c(J),n.insertContent(J,X),m+=Q.length}return l.createRange(d.start,d.start.getShiftedBy(g.length))}},k=d=>{const{plugins:h}=this.editor;if(l.setSelection(d.end),h.has("TwoStepCaretMovement"))h.get("TwoStepCaretMovement")._handleForwardMovement();else for(const f of["linkHref",...r,...a])l.removeSelectionAttribute(f)};if(s.isCollapsed){const d=s.getFirstPosition();if(s.hasAttribute("linkHref")){const h=s.getAttribute("linkHref"),f=D(d,"linkHref",h,n),g=u(f,h);c(g||f),g&&k(g)}else if(e!==""){const h=B(s.getAttributes());h.set("linkHref",e),r.forEach(g=>{h.set(g,!0)});const f=n.insertContent(l.createText(i||e,h),d);k(f)}}else{const d=Array.from(s.getRanges()),h=n.schema.getValidRanges(d,"linkHref"),f=[];for(const m of s.getSelectedBlocks())n.schema.checkAttribute(m,"linkHref")&&f.push(l.createRangeOn(m));const g=f.slice();for(const m of h)this._isRangeToUpdate(m,f)&&g.push(m);const C=d.map(m=>({start:se.fromPosition(m.start,"toPrevious"),end:se.fromPosition(m.end,"toNext")}));for(let m of g){const L=(m.start.textNode||m.start.nodeAfter).getAttribute("linkHref");m=u(m,L)||m,c(m)}l.setSelection(C.map(m=>{const L=m.start.toPosition(),S=m.end.toPosition();return m.start.detach(),m.end.detach(),n.createRange(L,S)}))}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return y(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}function at(o,e){const t=Me(o,e),i={equal:0,insert:0,delete:0},n=[];let s="",r="";for(const a of[...t,null])a=="insert"?r+=e[i.equal+i.insert]:a=="delete"?s+=o[i.equal+i.delete]:(s.length||r.length)&&(n.push({offset:i.equal,actual:s,expected:r}),s="",r=""),a&&i[a]++;return n}function ct(o,e){if(!o.isCollapsed)return ne(o.getItems());const t=o.start;return t.textNode?t.textNode:!t.nodeBefore||t.isEqual(e.start)?t.nodeAfter:t.nodeBefore}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class me extends ee{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();y(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change(s=>{const r=i.isCollapsed?[D(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const a of r)if(s.removeAttribute("linkHref",a),n)for(const l of n.manualDecorators)s.removeAttribute(l.id,a)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class fe extends He(){id;defaultValue;label;attributes;classes;styles;constructor({id:e,label:t,attributes:i,classes:n,styles:s,defaultValue:r}){super(),this.id=e,this.set("value",void 0),this.defaultValue=r,this.label=t,this.attributes=i,this.classes=n,this.styles=s}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}function w(o,{insertAt:e}={}){if(!o||typeof document>"u")return;const t=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",window.litNonce&&i.setAttribute("nonce",window.litNonce),e==="top"&&t.firstChild?t.insertBefore(i,t.firstChild):t.appendChild(i),i.styleSheet?i.styleSheet.cssText=o:i.appendChild(document.createTextNode(o))}w(".ck .ck-link_selected{background:var(--ck-color-link-selected-background)}.ck .ck-link_selected span.image-inline{outline:var(--ck-widget-outline-thickness) solid var(--ck-color-link-selected-background)}.ck .ck-fake-link-selection{background:var(--ck-color-link-fake-selection)}.ck .ck-fake-link-selection_collapsed{border-right:1px solid var(--ck-color-base-text);height:100%;margin-right:-1px;outline:1px solid hsla(0,0%,100%,.5)}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const dt="ck-link_selected",ge="automatic",ut="manual",kt=/^(https?:)?\/\//;class V extends _{_linkOpeners=[];static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[te,Pe,Ne]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1,toolbar:["linkPreview","|","editLink","linkProperties","unlink"]})}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:A}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(s,r)=>A(I(s,t),r)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:s=>s.getAttribute("href")}}),e.commands.add("link",new he(e)),e.commands.add("unlink",new me(e));const i=K(e.t,Y(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(s=>s.mode===ge)),this._enableManualDecorators(i.filter(s=>s.mode===ut)),e.plugins.get(te).registerAttribute("linkHref"),Ce(e,"linkHref","a",dt),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_registerLinkOpener(e){this._linkOpeners.push(e)}_enableAutomaticDecorators(e){const t=this.editor,n=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:ge,callback:s=>!!s&&kt.test(s),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(s=>{t.model.schema.extend("$text",{allowAttributes:s.id});const r=new fe(s);n.add(r),t.conversion.for("downcast").attributeToElement({model:r.id,view:(a,{writer:l,schema:c},{item:u})=>{if((u.is("selection")||c.isInline(u))&&a){const k=l.createAttributeElement("a",r.attributes,{priority:5});r.classes&&l.addClass(r.classes,k);for(const d in r.styles)l.setStyle(d,r.styles[d],k);return l.setCustomProperty("link",!0,k),k}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...r._createPattern()},model:{key:r.id}})})}_enableLinkOpen(){const e=this.editor,i=e.editing.view.document,n=s=>{this._linkOpeners.some(r=>r(s))||$(s)};this.listenTo(i,"click",(s,r)=>{if(!(Re.isMac?r.domEvent.metaKey:r.domEvent.ctrlKey))return;let l=r.domTarget;if(l.tagName.toLowerCase()!="a"&&(l=l.closest("a")),!l)return;const c=l.getAttribute("href");c&&(s.stop(),r.preventDefault(),n(c))},{context:"$capture"}),this.listenTo(i,"keydown",(s,r)=>{const l=e.commands.get("link").value;l&&r.keyCode===Fe.enter&&r.altKey&&(s.stop(),n(l))})}_enableSelectionAttributesFixer(){const t=this.editor.model,i=t.document.selection;this.listenTo(i,"change:attribute",(n,{attributeKeys:s})=>{!s.includes("linkHref")||i.hasAttribute("linkHref")||t.change(r=>{ht(r,mt(t.schema))})})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(n,s)=>{t.change(r=>{const a=r.createRangeIn(s.content);for(const l of a.getItems())if(l.hasAttribute("linkHref")){const c=x(l.getAttribute("linkHref"),i);r.setAttribute("linkHref",c,l)}})})}}function ht(o,e){o.removeSelectionAttribute("linkHref");for(const t of e)o.removeSelectionAttribute(t)}function mt(o){return o.getDefinition("$text").allowAttributes.filter(t=>t.startsWith("link")||t==="htmlA")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class pe extends p{constructor(e){super(e);const t=this.bindTemplate;this.set({href:void 0,withText:!0}),this.extendTemplate({attributes:{class:["ck-link-toolbar__preview"],href:t.to("href"),target:"_blank",rel:"noopener noreferrer"},on:{click:t.to(i=>{if(this.href){const n=()=>i.preventDefault();this.fire("navigate",this.href,n)}})}}),this.template.tag="a"}}w('.ck-vertical-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck-vertical-form .ck-button:focus:after{display:none}@media screen and (max-width:600px){.ck.ck-responsive-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck.ck-responsive-form .ck-button:focus:after{display:none}}.ck-vertical-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form{padding:var(--ck-spacing-large)}.ck.ck-responsive-form:focus{outline:none}[dir=ltr] .ck.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-responsive-form>:not(:last-child){margin-left:var(--ck-spacing-standard)}@media screen and (max-width:600px){.ck.ck-responsive-form{padding:0;width:calc(var(--ck-input-width)*.8)}.ck.ck-responsive-form .ck-labeled-field-view{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-responsive-form .ck-labeled-field-view .ck-input-number,.ck.ck-responsive-form .ck-labeled-field-view .ck-input-text{min-width:0;width:100%}.ck.ck-responsive-form .ck-labeled-field-view .ck-labeled-field-view__error{white-space:normal}.ck.ck-responsive-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form>.ck-button:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){border-radius:0;margin-top:var(--ck-spacing-large);padding:var(--ck-spacing-standard)}.ck.ck-responsive-form>.ck-button:last-child:not(:focus),.ck.ck-responsive-form>.ck-button:nth-last-child(2):not(:focus){border-top:1px solid var(--ck-color-base-border)}[dir=ltr] .ck.ck-responsive-form>.ck-button:last-child,[dir=ltr] .ck.ck-responsive-form>.ck-button:nth-last-child(2),[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2){margin-left:0}[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child:last-of-type,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2):last-of-type{border-right:1px solid var(--ck-color-base-border)}}'),w(":root{--ck-form-default-width:340px}.ck.ck-form{padding:0 0 var(--ck-spacing-large)}.ck.ck-form.ck-form_default-width{width:var(--ck-form-default-width)}.ck.ck-form:focus{outline:none}.ck.ck-form .ck.ck-input-number,.ck.ck-form .ck.ck-input-text{min-width:100%;width:0}.ck.ck-form .ck.ck-dropdown{min-width:100%}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button .ck-button__label{width:100%}@media screen and (max-width:600px){.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit{align-items:stretch;flex-direction:column;padding:0}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit>.ck{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit .ck-button_with-text{justify-content:center}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_large-bottom-padding{padding-bottom:var(--ck-spacing-large)}}[dir=ltr] .ck.ck-form.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-form.ck-responsive-form>:not(:last-child){margin-left:0}"),w(".ck.ck-link-form .ck-link-form__providers-list{display:flex;flex-direction:column}.ck.ck-link-form .ck-link-form__providers-list .ck-link__button>.ck-button__label{flex-grow:1}.ck.ck-link-form .ck-link__items:empty{display:none}:root{--ck-link-panel-width:340px;--ck-link-provider-list-item-text-height:calc(var(--ck-line-height-base)*var(--ck-font-size-base));--ck-link-provider-list-item-height:calc(var(--ck-link-provider-list-item-text-height) + var(--ck-spacing-small) + var(--ck-spacing-small))}@media screen and (max-width:600px){:root{--ck-link-panel-width:300px}}.ck.ck-form.ck-link-form{padding-bottom:0;width:var(--ck-link-panel-width)}@media screen and (max-width:600px){.ck.ck-form.ck-link-form.ck-responsive-form .ck-labeled-field-view{margin:0}}.ck.ck-form.ck-link-form .ck-link-form__providers-list{border-top:1px solid var(--ck-color-base-border)}.ck.ck-form.ck-link-form .ck-link-form__providers-list:has(.ck-list__item:nth-child(n+5)){max-height:calc(var(--ck-link-provider-list-item-height)*4 + var(--ck-spacing-large) + 1px);overflow:auto}.ck.ck-form.ck-link-form .ck-link-form__providers-list .ck-link__button{border-radius:0;padding:var(--ck-spacing-small) var(--ck-spacing-large)}.ck.ck-form.ck-link-form .ck-link-form__providers-list .ck-link__button>.ck-button__label{overflow:hidden;text-overflow:ellipsis}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class be extends E{focusTracker=new N;keystrokes=new M;backButtonView;saveButtonView;displayedTextInputView;urlInputView;children;providersListChildren;_validators;_focusables=new R;_focusCycler;constructor(e,t){super(e),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.displayedTextInputView=this._createDisplayedTextInput(),this.urlInputView=this._createUrlInput(),this.providersListChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView()]),this._createFormChildren(),this.listenTo(this.providersListChildren,"add",()=>{this.stopListening(this.providersListChildren,"add"),this.children.add(this._createProvidersListView())}),this._focusCycler=new F({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-link-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),qe({view:this}),[this.urlInputView,this.saveButtonView,...this.providersListChildren,this.backButtonView,this.displayedTextInputView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createBackButton(){const e=this.locale.t,t=new p(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:H,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new p(this.locale);return t.set({label:e("Insert"),tooltip:!1,withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new U(this.locale,{label:e("Link")});return t.children.add(this.backButtonView,0),t}_createProvidersListView(){const e=new O(this.locale);return e.extendTemplate({attributes:{class:["ck-link-form__providers-list"]}}),e.items.bindTo(this.providersListChildren).using(t=>{const i=new z(this.locale);return i.children.add(t),i}),e}_createDisplayedTextInput(){const e=this.locale.t,t=new re(this.locale,le);return t.label=e("Displayed text"),t.class="ck-labeled-field-view_full-width",t}_createUrlInput(){const e=this.locale.t,t=new re(this.locale,le);return t.fieldView.inputMode="url",t.label=e("Link URL"),t.class="ck-labeled-field-view_full-width",t}_createFormChildren(){this.children.add(new ae(this.locale,{children:[this.displayedTextInputView],class:["ck-form__row_large-top-padding"]})),this.children.add(new ae(this.locale,{children:[this.urlInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding","ck-form__row_large-bottom-padding"]}))}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}w(".ck.ck-link-providers>.ck-link-providers__list{overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain}.ck.ck-link-providers>.ck-link-providers__list .ck-button>.ck-icon{flex-shrink:0}:root{--ck-link-providers-width:340px;--ck-link-list-view-max-height:240px;--ck-link-list-view-icon-size:calc(var(--ck-icon-size)*0.8)}@media screen and (max-width:600px){:root{--ck-link-providers-width:300px}}.ck.ck-link-providers{width:var(--ck-link-providers-width)}.ck.ck-link-providers .ck-form__header__label{overflow:hidden;text-overflow:ellipsis}.ck.ck-link-providers>.ck-link-providers__list{max-height:min(var(--ck-link-list-view-max-height),40vh)}.ck.ck-link-providers>.ck-link-providers__list .ck-button>.ck-icon{height:var(--ck-link-list-view-icon-size);width:var(--ck-link-list-view-icon-size)}.ck.ck-link-providers>.ck-link-providers__list .ck-button>.ck-button__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ck.ck-link-providers .ck-link__empty-list-info{font-style:italic;padding:calc(var(--ck-spacing-large)*2) var(--ck-spacing-medium);text-align:center}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class we extends E{focusTracker=new N;keystrokes=new M;backButtonView;listView;listChildren;emptyListInformation;children;_focusables=new R;_focusCycler;constructor(e){super(e),this.listChildren=this.createCollection(),this.backButtonView=this._createBackButton(),this.listView=this._createListView(),this.emptyListInformation=this._createEmptyLinksListItemView(),this.children=this.createCollection([this._createHeaderView(),this.emptyListInformation]),this.set("title",""),this.set("emptyListPlaceholder",""),this.set("hasItems",!1),this.listenTo(this.listChildren,"change",()=>{this.hasItems=this.listChildren.length>0}),this.on("change:hasItems",(t,i,n)=>{n?(this.children.remove(this.emptyListInformation),this.children.add(this.listView)):(this.children.remove(this.listView),this.children.add(this.emptyListInformation))}),this.keystrokes.set("Esc",(t,i)=>{this.fire("cancel"),i()}),this._focusCycler=new F({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-providers"],tabindex:"-1"},children:this.children})}render(){super.render(),[this.listView,this.backButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createListView(){const e=new O(this.locale);return e.extendTemplate({attributes:{class:["ck-link-providers__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new z(this.locale);return i.children.add(t),i}),e}_createBackButton(){const e=this.locale.t,t=new p(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:H,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=new U(this.locale);return e.bind("label").to(this,"title"),e.children.add(this.backButtonView,0),e}_createEmptyLinksListItemView(){const e=new E(this.locale);return e.setTemplate({tag:"p",attributes:{class:["ck","ck-link__empty-list-info"]},children:[{text:this.bindTemplate.to("emptyListPlaceholder")}]}),e}}w(":root{--ck-link-properties-width:340px}@media screen and (max-width:600px){:root{--ck-link-properties-width:300px}}.ck.ck-link-properties{width:var(--ck-link-properties-width)}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class _e extends E{focusTracker=new N;keystrokes=new M;backButtonView;children;listChildren;_focusables=new R;_focusCycler;constructor(e){super(e),this.backButtonView=this._createBackButton(),this.listChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView(),this._createListView()]),this._focusCycler=new F({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-properties"],tabindex:"-1"},children:this.children}),this.keystrokes.set("Esc",(t,i)=>{this.fire("back"),i()})}render(){super.render(),[...this.listChildren,this.backButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new p(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:H,tooltip:!0}),t.delegate("execute").to(this,"back"),t}_createHeaderView(){const e=this.locale.t,t=new U(this.locale,{label:e("Link properties")});return t.children.add(this.backButtonView,0),t}_createListView(){const e=new O(this.locale);return e.extendTemplate({attributes:{class:["ck-link__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new z(this.locale);return i.children.add(t),i}),e}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ve extends p{arrowView;constructor(e){super(e),this.set({withText:!0}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-link__button"]}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new $e;return e.content=ze,e}}w(".ck.ck-link-toolbar__preview{display:inline-block}.ck.ck-link-toolbar__preview .ck-button__label{overflow:hidden}:root{--ck-link-bookmark-icon-size:calc(var(--ck-icon-size)*0.7)}.ck.ck-toolbar.ck-link-toolbar>.ck-toolbar__items{flex-wrap:nowrap}a.ck.ck-button.ck-link-toolbar__preview{color:var(--ck-color-link-default);cursor:pointer;justify-content:center;padding:0 var(--ck-spacing-medium)}a.ck.ck-button.ck-link-toolbar__preview .ck.ck-button__label{max-width:var(--ck-input-width);text-overflow:ellipsis}a.ck.ck-button.ck-link-toolbar__preview,a.ck.ck-button.ck-link-toolbar__preview:active,a.ck.ck-button.ck-link-toolbar__preview:focus,a.ck.ck-button.ck-link-toolbar__preview:hover{background:none}a.ck.ck-button.ck-link-toolbar__preview:active{box-shadow:none}a.ck.ck-button.ck-link-toolbar__preview:focus,a.ck.ck-button.ck-link-toolbar__preview:hover{text-decoration:underline}a.ck.ck-button.ck-link-toolbar__preview.ck-button_with-text .ck.ck-icon.ck-button__icon{height:var(--ck-link-bookmark-icon-size);width:var(--ck-link-bookmark-icon-size)}[dir=ltr] a.ck.ck-button.ck-link-toolbar__preview.ck-button_with-text .ck.ck-icon.ck-button__icon{margin-left:var(--ck-spacing-small);margin-right:var(--ck-spacing-tiny)}[dir=rtl] a.ck.ck-button.ck-link-toolbar__preview.ck-button_with-text .ck.ck-icon.ck-button__icon{margin-left:var(--ck-spacing-tiny);margin-right:var(--ck-spacing-small)}a.ck.ck-button.ck-link-toolbar__preview:has(.ck-icon){padding-left:var(--ck-spacing-extra-tiny )}");/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const b="link-ui";class G extends _{toolbarView=null;formView=null;linkProviderItemsView=null;propertiesView=null;_balloon;_linksProviders=new ie;static get requires(){return[ce,V]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;this.set("selectedLinkableText",void 0),e.editing.view.addObserver(Ue),this._balloon=e.plugins.get(ce),this._registerComponents(),this._registerEditingOpeners(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:b,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:b,view:(i,{writer:n})=>{if(!i.markerRange.isCollapsed)return null;const s=n.createUIElement("span");return n.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],s),s}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:v},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.propertiesView&&this.propertiesView.destroy(),this.formView&&this.formView.destroy(),this.toolbarView&&this.toolbarView.destroy(),this.linkProviderItemsView&&this.linkProviderItemsView.destroy()}registerLinksListProvider(e){const t=this._linksProviders.filter(i=>(i.order||0)<=(e.order||0)).length;this._linksProviders.add(e,t)}_createViews(){const e=this.editor.commands.get("link");this.toolbarView=this._createToolbarView(),this.formView=this._createFormView(),e.manualDecorators.length&&(this.propertiesView=this._createPropertiesView()),this._enableUserBalloonInteractions()}_createToolbarView(){const e=this.editor,t=new Ge(e.locale),i=e.commands.get("link");t.class="ck-link-toolbar";let n=e.config.get("link.toolbar");return i.manualDecorators.length||(n=n.filter(s=>s!=="linkProperties")),t.fillFromConfig(n,e.ui.componentFactory),t.keystrokes.set("Esc",(s,r)=>{this._hideUI(),r()}),t.keystrokes.set(v,(s,r)=>{this._addFormView(),r()}),e.ui.addToolbar(t,{isContextual:!0,beforeFocus:()=>{this._getSelectedLinkElement()&&!this._isToolbarVisible&&this._showUI(!0)},afterBlur:()=>{this._hideUI(!1)}}),t}_createFormView(){const e=this.editor,t=e.locale.t,i=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),s=new(de(be))(e.locale,ft(e));return s.displayedTextInputView.bind("isEnabled").to(this,"selectedLinkableText",r=>r!==void 0),s.urlInputView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("label").to(i,"value",r=>t(r?"Update":"Insert")),this.listenTo(s,"submit",()=>{if(s.isValid()){const r=s.urlInputView.fieldView.element.value,a=x(r,n),l=s.displayedTextInputView.fieldView.element.value;e.execute("link",a,this._getDecoratorSwitchesState(),l!==this.selectedLinkableText?l:void 0),this._closeFormView()}}),this.listenTo(s.urlInputView,"change:errorText",()=>{e.ui.update()}),this.listenTo(s,"cancel",()=>{this._closeFormView()}),s.keystrokes.set("Esc",(r,a)=>{this._closeFormView(),a()}),s.providersListChildren.bindTo(this._linksProviders).using(r=>this._createLinksListProviderButton(r)),s}_createLinkProviderListView(e){return e.getListItems().map(({href:t,label:i,icon:n})=>{const s=new p;return s.set({label:i,icon:n,tooltip:!1,withText:!0}),s.on("execute",()=>{this.formView.resetFormStatus(),this.formView.urlInputView.fieldView.value=t,this.editor.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),s})}_createLinkProviderItemsView(e){const t=this.editor,i=t.locale.t,n=new we(t.locale),{emptyListPlaceholder:s,label:r}=e;return n.emptyListPlaceholder=s||i("No links available"),n.title=r,this.listenTo(n,"cancel",()=>{t.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),n}_createPropertiesView(){const e=this.editor,t=this.editor.commands.get("link"),i=new(de(_e))(e.locale);return this.listenTo(i,"back",()=>{e.editing.view.focus(),this._removePropertiesView()}),i.listChildren.bindTo(t.manualDecorators).using(n=>{const s=new We(e.locale);return s.set({label:n.label,withText:!0}),s.bind("isOn").toMany([n,t],"value",(r,a)=>a===void 0&&r===void 0?!!n.defaultValue:!!r),s.on("execute",()=>{n.set("value",!s.isOn),e.execute("link",t.value,this._getDecoratorSwitchesState())}),s}),i}_getDecoratorSwitchesState(){const e=this.editor.commands.get("link");return Array.from(e.manualDecorators).reduce((t,i)=>{const n=e.value===void 0&&i.value===void 0?i.defaultValue:i.value;return{...t,[i.id]:!!n}},{})}_registerEditingOpeners(){this.editor.plugins.get(V)._registerLinkOpener(t=>{const i=this._getLinkProviderLinkByHref(t);if(!i)return!1;const{item:n,provider:s}=i;return s.navigate?s.navigate(n):!1})}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("link",()=>{const t=this._createButton(p);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:link",()=>{const t=this._createButton(Qe);return t.set({role:"menuitemcheckbox"}),t}),e.ui.componentFactory.add("linkPreview",t=>{const i=new pe(t),n=e.config.get("link.allowedProtocols"),s=e.commands.get("link"),r=t.t;i.bind("isEnabled").to(s,"value",l=>!!l),i.bind("href").to(s,"value",l=>l&&I(l,n));const a=l=>{if(!l){i.label=void 0,i.icon=void 0,i.tooltip=r("Open link in new tab");return}const c=this._getLinkProviderLinkByHref(l);if(c){const{label:u,tooltip:k,icon:d}=c.item;i.label=u,i.tooltip=k||!1,i.icon=d}else i.label=l,i.icon=void 0,i.tooltip=r("Open link in new tab")};return a(s.value),this.listenTo(s,"change:value",(l,c,u)=>{a(u)}),this.listenTo(i,"navigate",(l,c,u)=>{const k=this._getLinkProviderLinkByHref(c);if(!k)return;const{provider:d,item:h}=k,{navigate:f}=d;f&&f(h)&&(l.stop(),u())}),i}),e.ui.componentFactory.add("unlink",t=>{const i=e.commands.get("unlink"),n=new p(t),s=t.t;return n.set({label:s("Unlink"),icon:je,tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{e.execute("unlink"),this._hideUI()}),n}),e.ui.componentFactory.add("editLink",t=>{const i=e.commands.get("link"),n=new p(t),s=t.t;return n.set({label:s("Edit link"),icon:Ke,tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{this._addFormView()}),n}),e.ui.componentFactory.add("linkProperties",t=>{const i=e.commands.get("link"),n=new p(t),s=t.t;return n.set({label:s("Link properties"),icon:Ye,tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled",i,"value",i,"manualDecorators",(r,a,l)=>r&&!!a&&l.length>0),this.listenTo(n,"execute",()=>{this._addPropertiesView()}),n})}_createLinksListProviderButton(e){const t=this.editor.locale,i=new ve(t);return i.set({label:e.label}),this.listenTo(i,"execute",()=>{this._showLinksProviderView(e)}),i}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),s=new e(t.locale),r=i.t;return s.set({label:r("Link"),icon:oe,keystroke:v,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",a=>!!a),this.listenTo(s,"execute",()=>{t.editing.view.scrollToTheSelection(),this._showUI(!0),this._getSelectedLinkElement()&&this._addFormView()}),s}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),e.keystrokes.set(v,(i,n)=>{n(),e.commands.get("link").isEnabled&&(e.editing.view.scrollToTheSelection(),this._showUI(!0))})}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",(e,t)=>{this._isToolbarVisible&&!this.toolbarView.focusTracker.isFocused&&(this.toolbarView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),Ze({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideUI(!1)}})}_addToolbarView(){this.toolbarView||this._createViews(),!this._isToolbarInPanel&&this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this.formView.backButtonView.isVisible=e.isEnabled&&!!e.value,this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.selectedLinkableText=this._getSelectedLinkableText(),this.formView.displayedTextInputView.fieldView.value=this.selectedLinkableText||"",this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_addPropertiesView(){this.propertiesView||this._createViews(),!this._arePropertiesInPanel&&(this.propertiesView.disableCssTransitions(),this._balloon.add({view:this.propertiesView,position:this._getBalloonPositionData()}),this.propertiesView.enableCssTransitions(),this.propertiesView.focus())}_showLinksProviderView(e){this.linkProviderItemsView&&this._removeLinksProviderView(),this.linkProviderItemsView=this._createLinkProviderItemsView(e),this._addLinkProviderItemsView(e)}_addLinkProviderItemsView(e){this.linkProviderItemsView.listChildren.clear(),this.linkProviderItemsView.listChildren.addMany(this._createLinkProviderListView(e)),this._balloon.add({view:this.linkProviderItemsView,position:this._getBalloonPositionData()}),this.linkProviderItemsView.focus()}_closeFormView(){const e=this.editor.commands.get("link");this.selectedLinkableText=void 0,e.value!==void 0?this._removeFormView():this._hideUI()}_removePropertiesView(){this._arePropertiesInPanel&&this._balloon.remove(this.propertiesView)}_removeLinksProviderView(){this._isLinksListInPanel&&this._balloon.remove(this.linkProviderItemsView)}_removeFormView(e=!0){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.displayedTextInputView.fieldView.reset(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._isToolbarVisible?this._addFormView():this._addToolbarView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addToolbarView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(e=!0){const t=this.editor;this._isUIInPanel&&(this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeLinksProviderView(),this._removePropertiesView(),this._removeFormView(e),this._isToolbarInPanel&&this._balloon.remove(this.toolbarView),this._hideFakeVisualSelection())}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=r();const s=()=>{const a=this._getSelectedLinkElement(),l=r();i&&!a||!i&&l!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=a,n=l};function r(){return t.selection.focus.getAncestors().reverse().find(a=>a.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _arePropertiesInPanel(){return!!this.propertiesView&&this._balloon.hasView(this.propertiesView)}get _isLinksListInPanel(){return!!this.linkProviderItemsView&&this._balloon.hasView(this.linkProviderItemsView)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isToolbarInPanel(){return!!this.toolbarView&&this._balloon.hasView(this.toolbarView)}get _isPropertiesVisible(){return!!this.propertiesView&&this._balloon.visibleView===this.propertiesView}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}get _isToolbarVisible(){return!!this.toolbarView&&this._balloon.visibleView===this.toolbarView}get _isUIInPanel(){return this._arePropertiesInPanel||this._isLinksListInPanel||this._isFormInPanel||this._isToolbarInPanel}get _isUIVisible(){return this._isPropertiesVisible||this._isLinksListInPanel||this._isFormVisible||this._isToolbarVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;if(this.editor.model.markers.has(b)){const n=this.editor.editing.mapper.markerNameToElements(b);if(n){const s=Array.from(n),r=e.createRange(e.createPositionBefore(s[0]),e.createPositionAfter(s[s.length-1]));return{target:e.domConverter.viewRangeToDom(r)}}}return{target:()=>{const n=this._getSelectedLinkElement();return n?e.domConverter.mapViewToDom(n):e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&Xe(i))return W(t.getFirstPosition());{const n=t.getFirstRange().getTrimmed(),s=W(n.start),r=W(n.end);return!s||s!=r?null:e.createRangeIn(s).getTrimmed().isEqual(n)?s:null}}_getSelectedLinkableText(){const e=this.editor.model,t=this.editor.editing,i=this._getSelectedLinkElement();if(!i)return T(e.document.selection.getFirstRange());const n=t.view.createRangeOn(i),s=t.mapper.toModelRange(n);return T(s)}_getLinkProviderLinkByHref(e){if(!e)return null;for(const t of this._linksProviders){const i=t.getItem?t.getItem(e):t.getListItems().find(n=>n.href===e);if(i)return{provider:t,item:i}}return null}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(b))t.updateMarker(b,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(b,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(b,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(b)&&e.change(t=>{t.removeMarker(b)})}}function W(o){return o.getAncestors().find(e=>j(e))||null}function ft(o){const e=o.t,t=o.config.get("link.allowCreatingEmptyLinks");return[i=>{if(!t&&!i.url.length)return e("Link URL must not be empty.")}]}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const gt=4,Ve=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}))|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i"),pt=2;class Le extends _{static get requires(){return[Se,V]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.model.document.selection;t.on("change:range",()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?D(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const n=this.editor.model,s=n.document.selection,r=s.getFirstPosition(),a=s.getLastPosition();let l=t.getJoined(this._expandLinkRange(n,r)||t);l&&(l=l.getJoined(this._expandLinkRange(n,a)||t)),l&&(l.start.isBefore(r)||l.end.isAfter(a))&&e.setSelection(l)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");n.on("inputTransformation",(r,a)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||a.method!=="paste"||i.rangeCount>1)return;const l=i.getFirstRange(),c=a.dataTransfer.getData("text/plain");if(!c)return;const u=c.match(Ve);u&&u[2]===c&&(t.change(k=>{this._selectEntireLinks(k,l),s.execute(c)}),r.stop())},{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new De(e.model,i=>{let n=i;if(!bt(n))return;n=n.slice(0,-1),"!.:,;?".includes(n[n.length-1])&&(n=n.slice(0,-1));const s=Ie(n);if(s)return{url:s,removedTrailingCharacters:i.length-n.length}});t.on("matched:data",(i,n)=>{const{batch:s,range:r,url:a,removedTrailingCharacters:l}=n;if(!s.isTyping)return;const c=r.end.getShiftedBy(-l),u=c.getShiftedBy(-a.length),k=e.model.createRange(u,c);this._applyAutoLink(a,k)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",()=>{const n=t.document.selection.getFirstPosition();let s;n.parent.previousSibling?.is("element")?s=t.createRangeIn(n.parent.previousSibling):s=t.createRange(t.createPositionAt(n.parent,0),n),this._checkAndApplyAutoLinkOnRange(s)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",()=>{const n=t.document.selection.getFirstPosition(),s=t.createRange(t.createPositionAt(n.parent,0),n.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(s)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=Be(e,t),s=Ie(i);if(s){const r=t.createRange(n.end.getShiftedBy(-s.length),n.end);this._applyAutoLink(s,r)}}_applyAutoLink(e,t){const i=this.editor.model,n=this.editor.config.get("link.defaultProtocol"),s=x(e,n);!this.isEnabled||!wt(t,i)||!P(s)||_t(t)||this._persistAutoLink(s,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange(s=>{s.setAttribute("linkHref",e,t),i.enqueueChange(()=>{n.requestUndoOnBackspace()})})}}function bt(o){return o.length>gt&&o[o.length-1]===" "&&o[o.length-2]!==" "}function Ie(o){const e=Ve.exec(o);return e?e[pt]:null}function wt(o,e){return e.schema.checkAttributeInSelection(e.createSelection(o),"linkHref")}function _t(o){const e=o.start.nodeAfter;return!!e&&e.hasAttribute("linkHref")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class vt extends _{static get requires(){return[V,G,Le]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ye extends _{static get requires(){return["ImageEditing","ImageUtils",V]}static get pluginName(){return"LinkImageEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(Vt(e)),e.conversion.for("downcast").add(Lt(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,i=e.commands.get("link").automaticDecorators;i.length&&e.conversion.for("downcast").add(i.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(It(i)),e.conversion.for("upcast").add(yt(e,i))}}function Vt(o){const e=o.plugins.has("ImageInlineEditing"),t=o.plugins.get("ImageUtils");return i=>{i.on("element:a",(n,s,r)=>{const a=s.viewItem,l=t.findViewImgElement(a);if(!l)return;const c=l.findAncestor(h=>t.isBlockImageView(h));if(e&&!c)return;const u={attributes:["href"]};if(!r.consumable.consume(a,u))return;const k=a.getAttribute("href");if(!k)return;let d=s.modelCursor.parent;if(!d.is("element","imageBlock")){const h=r.convertItem(l,s.modelCursor);s.modelRange=h.modelRange,s.modelCursor=h.modelCursor,d=s.modelCursor.nodeBefore}d&&d.is("element","imageBlock")&&r.writer.setAttribute("linkHref",k,d)},{priority:"high"})}}function Lt(o){const e=o.plugins.get("ImageUtils");return t=>{t.on("attribute:linkHref:imageBlock",(i,n,s)=>{if(!s.consumable.consume(n.item,i.name))return;const r=s.mapper.toViewElement(n.item),a=s.writer,l=Array.from(r.getChildren()).find(k=>k.is("element","a")),c=e.findViewImgElement(r),u=c.parent.is("element","picture")?c.parent:c;if(l)n.attributeNewValue?a.setAttribute("href",n.attributeNewValue,l):(a.move(a.createRangeOn(u),a.createPositionAt(r,0)),a.remove(l));else{const k=a.createContainerElement("a",{href:n.attributeNewValue});a.insert(a.createPositionAt(r,0),k),a.move(a.createRangeOn(u),a.createPositionAt(k,0))}},{priority:"high"})}}function It(o){return e=>{e.on(`attribute:${o.id}:imageBlock`,(t,i,n)=>{const s=n.mapper.toViewElement(i.item),r=Array.from(s.getChildren()).find(a=>a.is("element","a"));if(r){if(i.attributeOldValue){for(const a in o.attributes)n.writer.removeAttribute(a,r);o.classes&&n.writer.removeClass(o.classes,r);for(const a in o.styles)n.writer.removeStyle(a,r)}if(i.attributeNewValue){for(const[a,l]of B(o.attributes))n.writer.setAttribute(a,l,r);o.classes&&n.writer.addClass(o.classes,r);for(const a in o.styles)n.writer.setStyle(a,o.styles[a],r)}}})}}function yt(o,e){const t=o.plugins.has("ImageInlineEditing"),i=o.plugins.get("ImageUtils");return n=>{n.on("element:a",(s,r,a)=>{const l=r.viewItem,c=i.findViewImgElement(l);if(!c)return;const u=c.findAncestor(f=>i.isBlockImageView(f));if(t&&!u)return;const d=new Oe(e._createPattern()).match(l);if(!d||!a.consumable.consume(l,d.match))return;const h=r.modelCursor.nodeBefore||r.modelCursor.parent;a.writer.setAttribute(e.id,!0,h)},{priority:"high"})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class xe extends _{static get requires(){return[V,G,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(i,n)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(n.preventDefault(),i.stop())},{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",i=>{const n=new p(i),s=e.plugins.get("LinkUI"),r=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:oe,keystroke:v,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(r,"isEnabled"),n.bind("isOn").to(r,"value",a=>!!a),this.listenTo(n,"execute",()=>{this._isSelectedLinkedImage(e.model.document.selection)?s._addToolbarView():s._showUI(!0)}),n})}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}w('.ck.ck-editor__editable a span.image-inline:after,.ck.ck-editor__editable figure.image>a:after{display:block;position:absolute}:root{--ck-link-image-indicator-icon-size:20;--ck-link-image-indicator-icon-is-visible:clamp(0px,100% - 50px,1px)}.ck.ck-editor__editable a span.image-inline:after,.ck.ck-editor__editable figure.image>a:after{background-color:rgba(0,0,0,.4);background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTExLjA3NyAxNSAuOTkxLTEuNDE2YS43NS43NSAwIDEgMSAxLjIyOS44NmwtMS4xNDggMS42NGEuNzUuNzUgMCAwIDEtLjIxNy4yMDYgNS4yNTEgNS4yNTEgMCAwIDEtOC41MDMtNS45NTUuNy43IDAgMCAxIC4xMi0uMjc0bDEuMTQ3LTEuNjM5YS43NS43NSAwIDEgMSAxLjIyOC44Nkw0LjkzMyAxMC43bC4wMDYuMDAzYTMuNzUgMy43NSAwIDAgMCA2LjEzMiA0LjI5NHptNS40OTQtNS4zMzVhLjc1Ljc1IDAgMCAxLS4xMi4yNzRsLTEuMTQ3IDEuNjM5YS43NS43NSAwIDEgMS0xLjIyOC0uODZsLjg2LTEuMjNhMy43NSAzLjc1IDAgMCAwLTYuMTQ0LTQuMzAxbC0uODYgMS4yMjlhLjc1Ljc1IDAgMCAxLTEuMjI5LS44NmwxLjE0OC0xLjY0YS43NS43NSAwIDAgMSAuMjE3LS4yMDYgNS4yNTEgNS4yNTEgMCAwIDEgOC41MDMgNS45NTVtLTQuNTYzLTIuNTMyYS43NS43NSAwIDAgMSAuMTg0IDEuMDQ1bC0zLjE1NSA0LjUwNWEuNzUuNzUgMCAxIDEtMS4yMjktLjg2bDMuMTU1LTQuNTA2YS43NS43NSAwIDAgMSAxLjA0NS0uMTg0Ii8+PC9zdmc+");background-position:50%;background-repeat:no-repeat;background-size:14px;border-radius:100%;content:"";height:calc(var(--ck-link-image-indicator-icon-is-visible)*var(--ck-link-image-indicator-icon-size));overflow:hidden;right:min(var(--ck-spacing-medium),6%);top:min(var(--ck-spacing-medium),6%);width:calc(var(--ck-link-image-indicator-icon-is-visible)*var(--ck-link-image-indicator-icon-size))}');/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class xt extends _{static get requires(){return[ye,xe]}static get pluginName(){return"LinkImage"}static get isOfficialPlugin(){return!0}}export{Le as AutoLink,ue as AutomaticLinkDecorators,vt as Link,he as LinkCommand,V as LinkEditing,be as LinkFormView,xt as LinkImage,ye as LinkImageEditing,xe as LinkImageUI,fe as LinkManualDecorator,_e as LinkPropertiesView,we as LinkProviderItemsView,G as LinkUI,lt as LinkUtils,me as UnlinkCommand,v as _LINK_KEYSTROKE,ve as _LinkButtonView,pe as _LinkPreviewButtonView,A as _createLinkElement,I as _ensureSafeLinkUrl,T as _extractTextFromLinkRange,K as _getLocalizedLinkDecorators,P as _hasLinkProtocol,q as _isEmailLink,Y as _normalizeLinkDecorators,$ as _openLink,x as addLinkProtocolIfApplicable,I as ensureSafeUrl,j as isLinkElement,y as isLinkableElement};
