@vonage/vivid 5.30.0 → 5.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/bundled/definition25.cjs +4 -4
  2. package/bundled/definition25.js +4 -4
  3. package/bundled/text-field.cjs +1 -1
  4. package/bundled/text-field.js +1 -1
  5. package/bundled/vivid-element.cjs +1 -1
  6. package/bundled/vivid-element.js +27 -1
  7. package/custom-elements.json +4413 -4437
  8. package/lib/rich-text-editor/rte/feature.d.ts +0 -1
  9. package/lib/rich-text-editor/rte/features/base.d.ts +9 -0
  10. package/lib/rich-text-editor/rte/features/bold.d.ts +5 -1
  11. package/lib/rich-text-editor/rte/features/font-size-picker.d.ts +5 -1
  12. package/lib/rich-text-editor/rte/features/hard-break.d.ts +4 -0
  13. package/lib/rich-text-editor/rte/features/inline-image.d.ts +4 -0
  14. package/lib/rich-text-editor/rte/features/italic.d.ts +5 -1
  15. package/lib/rich-text-editor/rte/features/link.d.ts +5 -1
  16. package/lib/rich-text-editor/rte/features/list.d.ts +6 -0
  17. package/lib/rich-text-editor/rte/features/monospace.d.ts +5 -1
  18. package/lib/rich-text-editor/rte/features/strikethrough.d.ts +5 -1
  19. package/lib/rich-text-editor/rte/features/text-color-picker.d.ts +4 -1
  20. package/lib/rich-text-editor/rte/features/underline.d.ts +5 -1
  21. package/lib/rich-text-editor/rte/public-interface.d.ts +1 -1
  22. package/number-field/index.cjs +1 -1
  23. package/number-field/index.js +1 -1
  24. package/package.json +6 -6
  25. package/rich-text-editor/index.cjs +1 -1
  26. package/rich-text-editor/index.js +176 -160
  27. package/shared/foundation/vivid-element/vivid-element.browser-spec.d.ts +1 -0
  28. package/shared/foundation/vivid-element/vivid-element.d.ts +8 -8
  29. package/unbundled/definition2.cjs +4 -4
  30. package/unbundled/definition2.js +4 -4
  31. package/unbundled/definition55.cjs +1 -1
  32. package/unbundled/definition55.js +1 -1
  33. package/unbundled/definition63.cjs +73 -46
  34. package/unbundled/definition63.js +73 -46
  35. package/unbundled/text-field.cjs +1 -1
  36. package/unbundled/text-field.js +1 -1
  37. package/unbundled/vivid-element.cjs +54 -1
  38. package/unbundled/vivid-element.js +55 -2
  39. package/vivid.api.json +12 -12
@@ -40,4 +40,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
40
40
  `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=_.u.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=di(n),cn&&fi(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||_.l.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!$r.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=pi(ai(s,+u[1],+u[2]),u[4]);else if(s=_.v.maxOpen(ei(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=ai(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var $r=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function ei(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&ni(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=ri(a[a.length-1],i.length));let n=ti(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return _.d.from(a)}return e}function ti(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,_.d.from(e));return e}function ni(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=ni(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(_.d.from(ti(n,e,i+1))))}}function ri(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,ri(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(_.d.empty,!0);return e.copy(n.append(r))}function ii(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=ii(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(_.d.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function ai(e,t,n){return t<e.openStart&&(e=new _.v(ii(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new _.v(ii(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var oi={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},si=null;function ci(){return si||=document.implementation.createHTMLDocument(`title`)}var li=null;function ui(e){let t=window.trustedTypes;return t?(li||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),li.createHTML(e)):e}function di(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ci().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&oi[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=ui(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function fi(e){let t=e.querySelectorAll(I?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function pi(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=_.d.from(t.create(r[e+1],i)),a++,o++}return new _.v(i,a,o)}var R={},z={},mi={touchstart:!0,touchmove:!0},hi=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function gi(e){for(let t in R){let n=R[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{xi(e,t)&&!bi(e,t)&&(e.editable||!(t.type in z))&&n(e,t)},mi[t]?{passive:!0}:void 0)}L&&e.dom.addEventListener(`input`,()=>null),yi(e)}function _i(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function vi(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function yi(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>bi(e,t))})}function bi(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function xi(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Si(e,t){!bi(e,t)&&R[t.type]&&(e.editable||!(t.type in z))&&R[t.type](e,t)}z.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Ii(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(sn&&I&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),rn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Wt(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Xr(e,n)?n.preventDefault():_i(e,`key`)}},z.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},z.keypress=(e,t)=>{let n=t;if(Ii(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||an&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof D)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Ci(e){return{left:e.clientX,top:e.clientY}}function wi(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Ti(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Ei(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Di(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&k.isSelectable(r)?(Ei(e,new k(n),`pointer`),!0):!1}function Oi(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof k&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(k.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(Ei(e,k.create(e.state.doc,i),`pointer`),!0)}function ki(e,t,n,r,i){return Ti(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Oi(e,n):Di(e,n))}function Ai(e,t,n,r){return Ti(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function ji(e,t,n,r){return Ti(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Mi(e,n,r)}function Mi(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Ei(e,D.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Ei(e,D.create(r,a+1,a+1+n.content.size),`pointer`);else if(k.isSelectable(n))Ei(e,k.create(r,a),`pointer`);else continue;return!0}}function Ni(e){return Ui(e)}var Pi=an?`metaKey`:`ctrlKey`;R.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ni(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&wi(n,e.input.lastClick)&&!n[Pi]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(Ci(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Fi(e,o,n,!!r)):(a==`doubleClick`?Ai:ji)(e,o.pos,o.inside,n)?n.preventDefault():_i(e,`pointer`))};var Fi=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Pi],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof k&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&en&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),_i(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>yr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ci(e))),this.updateAllowDefault(e),this.allowDefault||!t?_i(this.view,`pointer`):ki(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||L&&this.mightDrag&&!this.mightDrag.node.isAtom||I&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ei(this.view,E.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):_i(this.view,`pointer`)}move(e){this.updateAllowDefault(e),_i(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};R.touchstart=e=>{e.input.lastTouch=Date.now(),Ni(e),_i(e,`pointer`)},R.touchmove=e=>{e.input.lastTouch=Date.now(),_i(e,`pointer`)},R.contextmenu=e=>Ni(e);function Ii(e,t){return e.composing?!0:L&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Li=sn?5e3:-1;z.compositionstart=z.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof D&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||I&&on&&Ri(e)))e.markCursor=e.state.storedMarks||n.marks(),Ui(e,!0),e.markCursor=null;else if(Ui(e,!t.selection.empty),en&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}zi(e,Li)};function Ri(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}z.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,zi(e,20))};function zi(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Ui(e),t))}function Bi(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Hi());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Vi(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=zt(t.focusNode,t.focusOffset),r=Bt(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Hi(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Ui(e,t=!1){if(!(sn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Bi(e),t||e.docView&&e.docView.dirty){let n=_r(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Wi(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Gi=F&&$t<15||rn&&ln<604;R.copy=z.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Gi?null:n.clipboardData,{dom:o,text:s}=Zr(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Wi(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Ki(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function qi(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ji(e,r.value,null,i,t):Ji(e,r.textContent,r.innerHTML,i,t)},50)}function Ji(e,t,n,r,i){let a=Qr(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||_.v.empty)))return!0;if(!a)return!1;let o=Ki(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function Yi(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}z.paste=(e,t)=>{let n=t;if(e.composing&&!sn)return;let r=Gi?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Ji(e,Yi(r),r.getData(`text/html`),i,n)?n.preventDefault():qi(e,n)};var Xi=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Zi=an?`altKey`:`ctrlKey`;function Qi(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[Zi]:!n}R.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Ci(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof k?i.to-1:i.to))){if(r&&r.mightDrag)o=k.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=k.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Zr(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!I||nn>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Gi?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Gi||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Xi(l,Qi(e,n),o)},R.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},z.dragover=z.dragenter=(e,t)=>t.preventDefault(),z.drop=(e,t)=>{try{$i(e,t,e.dragging)}finally{e.dragging=null}};function $i(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Ci(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Qr(e,Yi(t.dataTransfer),Gi?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Qi(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||_.v.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Ge(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&k.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new k(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Or(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}R.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&yr(e)},20))},R.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},R.beforeinput=(e,t)=>{if(I&&sn&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Wt(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in z)R[e]=z[e];function ea(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ta=class e{constructor(e,t){this.toDOM=e,this.spec=t||aa,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new B(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&ea(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},na=class e{constructor(e,t){this.attrs=e,this.spec=t||aa}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new B(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&ea(this.attrs,t.attrs)&&ea(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},ra=class e{constructor(e,t){this.attrs=e,this.spec=t||aa}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new B(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&ea(this.attrs,t.attrs)&&ea(this.spec,t.spec)}destroy(){}},B=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new ta(n,r))}static inline(t,n,r,i){return new e(t,n,new na(r,i))}static node(t,n,r,i){return new e(t,n,new ra(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof na}get widget(){return this.type instanceof ta}},ia=[],aa={},V=class e{constructor(e,t){this.local=e.length?e:ia,this.children=t.length?t:ia}static create(e,t){return t.length?fa(t,e,0,aa):H}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==H||e.maps.length==0?this:this.mapInner(e,t,0,0,n||aa)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?sa(this.children,o||[],t,n,r,i,a):o?new e(o.sort(pa),ia):H}add(t,n){return n.length?this==H?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=ua(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,fa(s,e,o+1,aa)),a+=3}});let o=ca(a?da(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(pa):this.local,i||this.children)}remove(e){return e.length==0||this==H?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==H?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):H}forChild(t,n){if(this==H)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof na){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(pa),ia);return r?new oa([t,r]):t}return r||H}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return ma(this.localsInner(e))}localsInner(e){if(this==H)return ia;if(e.inlineContent||!this.local.some(na.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof na||t.push(this.local[e]);return t}forEachSet(e){e(this)}};V.empty=new V([],[]),V.removeOverlap=ma;var H=V.empty,oa=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,aa));return e.from(r)}forChild(t,n){if(n.isLeaf)return V.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=H&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length){if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}}return t?ma(n?t:t.sort(pa)):ia}static from(t){switch(t.length){case 0:return H;case 1:return t[0];default:return new e(t.every(e=>e instanceof V)?t:t.reduce((e,t)=>e.concat(t instanceof V?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function sa(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==H?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=fa(la(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new V(t.sort(pa),s)}function ca(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new B(i.from+t,i.to+t,i.type))}return n}function la(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function ua(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function da(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function fa(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=ua(e,t,o+n);if(s){a=!0;let e=fa(s,t,n+o+1,r);e!=H&&i.push(o,o+t.nodeSize,e)}});let o=ca(a?da(e):e,-n).sort(pa);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new V(o,i):H}function pa(e,t){return e.from-t.from||e.to-t.to}function ma(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from)a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),ha(t,i+1,a.copy(r.to,a.to)));else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),ha(t,i,r.copy(a.from,r.to)));break}}}return t}function ha(e,t,n){for(;t<e.length&&pa(n,e[t])>0;)t++;e.splice(t,0,n)}function ga(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=H&&t.push(r)}),e.cursorWrapper&&t.push(V.create(e.state.doc,[e.cursorWrapper.deco])),oa.from(t)}var _a={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},va=F&&$t<=11,ya=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},ba=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ya,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);F&&$t<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():L&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),va&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,_a)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(kr(this.view)){if(this.suppressingSelectionUpdates)return yr(this.view);if(F&&$t<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&P(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Nt(n))t.add(n);for(let r=e.anchorNode;r;r=Nt(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&kr(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(en&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Ea(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ut(n)&&(c=_r(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,yr(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Ca(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Da(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||yr(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(F&&$t<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?M(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?M(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}return e.type==`attributes`?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},xa=new WeakMap,Sa=!1;function Ca(e){if(!xa.has(e)&&(xa.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=en,Sa)return;console.warn(`ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.`),Sa=!0}}function wa(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return P(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Ta(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return wa(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?wa(e,n):null}function Ea(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Da(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Oa(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],Ut(c)||l.push({node:c.focusNode,offset:c.focusOffset})),I&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||_.l.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace!=`pre`||`full`,findPositions:l,ruleFromNode:ka,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function ka(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(L&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(e.parentNode.lastChild==e||L&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Aa=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function ja(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=_r(e,t);if(n&&!e.state.selection.eq(n)){if(I&&sn&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Wt(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Oa(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=Ia(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(rn&&e.input.lastIOSEnter>Date.now()-225||sn)&&i.some(e=>e.nodeType==1&&!Aa.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Wt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof D&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Ma(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof D&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),F&&$t<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),ee=u.resolve(m.start),te=h.sameParent(g)&&h.parent.inlineContent&&ee.end()>=m.endA;if((rn&&e.input.lastIOSEnter>Date.now()-225&&(!te||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!te&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Wt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Pa(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Wt(8,`Backspace`)))){sn&&I&&e.domObserver.suppressSelectionUpdates();return}I&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),sn&&!te&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Wt(13,`Enter`))})},20));let _=m.start,v=m.endA,ne=t=>{let n=t||e.state.tr.replace(_,v,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Ma(e,n.doc,l.sel);t&&!(I&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==_||t.head==n.mapping.map(v)-1)||F&&t.empty&&t.head==_)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},re;if(te){if(h.pos==g.pos){F&&$t<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>yr(e),20));let t=ne(e.state.tr.delete(_,v)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(re=Na(h.parent.content.cut(h.parentOffset,g.parentOffset),ee.parent.content.cut(ee.parentOffset,m.endA-ee.start())))){let t=ne(e.state.tr);re.type==`add`?t.addMark(_,v,re.mark):t.removeMark(_,v,re.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>ne(e.state.tr.insertText(t,_,v));e.someProp(`handleTextInput`,r=>r(e,_,v,t,n))||e.dispatch(n())}else e.dispatch(ne())}else e.dispatch(ne())}function Ma(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Or(e,t.resolve(n.anchor),t.resolve(n.head))}function Na(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(_.d.from(l).eq(e))return{mark:s,type:o}}function Pa(e,t,n,r,i){if(n-t<=i.pos-r.pos||Fa(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Fa(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Fa(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Fa(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Ia(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&La(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&La(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function La(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Ra=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new hi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ga),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Va(this),Ba(this),this.nodeViews=Ua(this),this.docView=Zn(this.state.doc,za(this),ga(this),this.dom,this),this.domObserver=new ba(this,(e,t,n,r)=>ja(this,e,t,n,r)),this.domObserver.start(),gi(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&yi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ga),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Bi(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Ua(this);Wa(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&yi(this),this.editable=Va(this),Ba(this);let o=ga(this),s=za(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&mn(this);if(i){this.domObserver.stop();let t=l&&(F||I)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Ha(n.selection,e.selection);if(l){let n=I?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Vi(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Zn(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&jr(this))?yr(this,t):(Er(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&gn(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(e.nodeType==1?e:e.parentNode)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof k){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&pn(this,t.getBoundingClientRect(),e)}else pn(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Xi(e.slice,e.move,r<0?void 0:k.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(F){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&yn(this.dom),yr(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Dn(this,e)}coordsAtPos(e,t=1){return jn(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Vn(this,t||this.state,e)}pasteHTML(e,t){return Ji(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Ji(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Zr(this,e)}destroy(){this.docView&&(vi(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ga(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ft())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Si(this,e)}domSelectionRange(){let e=this.domSelection();return e?L&&this.root.nodeType===11&&Gt(this.dom.ownerDocument)==this.dom&&Ta(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Ra.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function za(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[B.node(0,e.state.doc.content.size,t)]}function Ba(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:B.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Va(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Ha(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Ua(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Wa(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Ga(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var Ka={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},qa={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Ja=typeof navigator<`u`&&/Mac/.test(navigator.platform),Ya=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),U=0;U<10;U++)Ka[48+U]=Ka[96+U]=String(U);for(var U=1;U<=24;U++)Ka[U+111]=`F`+U;for(var U=65;U<=90;U++)Ka[U]=String.fromCharCode(U+32),qa[U]=String.fromCharCode(U);for(var Xa in Ka)qa.hasOwnProperty(Xa)||(qa[Xa]=Ka[Xa]);function Za(e){var t=!(Ja&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ya&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?qa:Ka)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var Qa=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),$a=typeof navigator<`u`&&/Win/.test(navigator.platform);function eo(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))Qa?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function to(e){let t=Object.create(null);for(let n in e)t[eo(n)]=e[n];return t}function no(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function W(e){return new j({props:{handleKeyDown:ro(e)}})}function ro(e){let t=to(e);return function(e,n){let r=Za(n),i,a=t[no(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[no(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!($a&&n.ctrlKey&&n.altKey)&&(i=Ka[n.keyCode])&&i!=r){let r=t[no(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var io=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function ao(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var oo=(e,t,n)=>{let r=ao(e,n);if(!r)return!1;let i=lo(r);if(!i){let n=r.blockRange(),i=n&&Ae(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(wo(e,i,t,-1))return!0;if(r.parent.content.size==0&&(so(a,`end`)||k.isSelectable(a)))for(let n=r.depth;;n--){let o=Ke(e.doc,r.before(n),r.after(n),_.v.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(so(a,`end`)?E.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):k.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1};function so(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var co=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=lo(r)}let o=a&&a.nodeBefore;return!o||!k.isSelectable(o)?!1:(t&&t(e.tr.setSelection(k.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function lo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function uo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var fo=(e,t,n)=>{let r=uo(e,n);if(!r)return!1;let i=mo(r);if(!i)return!1;let a=i.nodeAfter;if(wo(e,i,t,1))return!0;if(r.parent.content.size==0&&(so(a,`start`)||k.isSelectable(a))){let n=Ke(e.doc,r.before(),r.after(),_.v.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(so(a,`start`)?E.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):k.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},po=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=mo(r)}let o=a&&a.nodeAfter;return!o||!k.isSelectable(o)?!1:(t&&t(e.tr.setSelection(k.create(e.doc,a.pos)).scrollIntoView()),!0)};function mo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var ho=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
41
41
  `).scrollIntoView()),!0)};function go(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var _o=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=go(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(E.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},vo=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof A||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=go(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(D.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},yo=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Re(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ae(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function bo(e){return(t,n)=>{if(t.selection instanceof k&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Re(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof D||t.selection instanceof A)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=go(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Re(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Re(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var xo=bo(),So=(e,t)=>(t&&t(e.tr.setSelection(new A(e.doc))),!0);function Co(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Be(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function wo(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Co(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=_.d.empty;for(let e=o.length-1;e>=0;e--)s=_.d.from(o[e].create(null,s));s=_.d.from(i.copy(s));let c=e.tr.step(new w(t.pos-1,r,t.pos,r,new _.v(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Be(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:E.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ae(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&so(a,`start`,!0)&&so(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=_.d.empty;for(let e=o.length-1;e>=0;e--)r=_.d.from(o[e].copy(r));n(e.tr.step(new w(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new _.v(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function To(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(D.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var Eo=To(-1),Do=To(1);function Oo(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function ko(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new pt(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new pt(r,i))}return t}function Ao(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!Oo(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=ko(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function jo(e,t){return n=>{if(!n.isGeneric)return e(n);let r=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<r.length;e++)r[e]=t.map(r[e]);t.forEach((e,t,n,i)=>r.push(n,i))}let i=[];for(let e=0;e<r.length;e+=2){let a=r[e],o=r[e+1],s=n.doc.resolve(a),c=s.sharedDepth(o),l=s.node(c);for(let e=s.indexAfter(c),n=s.after(c+1);n<=o;++e){let r=l.maybeChild(e);if(!r)break;if(e&&i.indexOf(n)==-1){let a=l.child(e-1);a.type==r.type&&t(a,r)&&i.push(n)}n+=r.nodeSize}}i.sort((e,t)=>e-t);for(let e=i.length-1;e>=0;e--)Be(n.doc,i[e])&&n.join(i[e]);e(n)}}function Mo(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,i)=>e(t,r&&jo(r,n),i)}function No(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var Po=No(io,oo,co),Fo=No(io,fo,po),Io={Enter:No(ho,vo,yo,xo),"Mod-Enter":_o,Backspace:Po,"Mod-Backspace":Po,"Shift-Backspace":Po,Delete:Fo,"Mod-Delete":Fo,"Mod-a":So},Lo={"Ctrl-h":Io.Backspace,"Alt-Backspace":Io[`Mod-Backspace`],"Ctrl-d":Io.Delete,"Ctrl-Alt-Backspace":Io[`Mod-Delete`],"Alt-Delete":Io[`Mod-Delete`],"Alt-d":Io[`Mod-Delete`],"Ctrl-a":Eo,"Ctrl-e":Do};for(let e in Io)Lo[e]=Io[e];var Ro=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?Lo:Io,zo=`.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;position:relative}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection{caret-color:#0000}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";pointer-events:none;border:2px solid #8cf;position:absolute;inset:-2px -2px -2px -32px}img.ProseMirror-separator{border:none!important;margin:0!important;display:inline!important}`;function Bo(e={}){return new j({view(t){return new Vo(t,e)}})}var Vo=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Ge(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},G=class e extends E{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):E.near(r)}content(){return _.v.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Ho(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Wo(e)||!Go(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!k.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};G.prototype.visible=!1,G.findFrom=G.findGapCursorFrom,E.jsonID(`gapcursor`,G);var Ho=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return G.valid(t)?new G(t):E.near(t)}};function Uo(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Wo(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Uo(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Go(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Uo(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Ko(){return new j({props:{decorations:Zo,createSelectionBetween(e,t,n){return t.pos==n.pos&&G.valid(n)?new G(n):null},handleClick:Yo,handleKeyDown:qo,handleDOMEvents:{beforeinput:Xo}}})}var qo=ro({ArrowLeft:Jo(`horiz`,-1),ArrowRight:Jo(`horiz`,1),ArrowUp:Jo(`vert`,-1),ArrowDown:Jo(`vert`,1)});function Jo(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof D){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=G.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new G(c))),!0):!1}}function Yo(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!G.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&k.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new G(r))),!0)}function Xo(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof G))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=_.d.empty;for(let e=r.length-1;e>=0;e--)i=_.d.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new _.v(i,0,0));return a.setSelection(D.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Zo(e){if(!(e.selection instanceof G))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,V.create(e.doc,[B.widget(e.selection.head,t,{key:`gapcursor`})])}function Qo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}}var $o=`[data-class=ui-select]{min-inline-size:120px;margin-block:-4px}.ui-divider{block-size:20px}.ui-button-group{gap:4px;display:flex}.ui-tooltip,.ui-menu{--_popup-display:contents;display:contents}.ui-tooltip-wrapper{display:contents}`,es=class{constructor(e){this.plugin=new j({state:{init:()=>e,apply:(e,t)=>{let n=e.getMeta(this.plugin);return n===void 0?t:n}}})}getValue(e){return this.plugin.getState(e.state)}setValue(e,t){e.dispatchTransaction(e.tr.setMeta(this.plugin,t))}},ts=`.ProseMirror{box-sizing:border-box;padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none;flex:1 0 0}.ProseMirror-selectednode{--focus-stroke-gap-color:transparent;--focus-border-radius:2px;outline:none;position:relative}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in sRGB, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px));border-radius:var(--focus-border-radius,inherit);block-size:calc(100% + var(--focus-block-size-addition,4px));content:"";inline-size:calc(100% + var(--focus-block-size-addition,4px));display:block;position:absolute;inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}.editor--disabled .ProseMirror{color:var(--_appearance-color-text,var(--vvd-color-neutral-300));cursor:not-allowed}`,ns=class extends _.r{constructor(...e){super(...e),this.name=`RteForeignHtmlFeature`}getPlugins(e){return[this.contribution(new j({props:{transformPastedHTML:t=>e.foreignHtmlParser[_.c].transform(t),clipboardParser:e.foreignHtmlParser[_.c].parser,clipboardSerializer:e.foreignHtmlSerializer[_.c].serializer}}))]}},rs=e=>{if(e.parentOffset!==e.parent.content.size)return null;let t=e.nodeBefore;return t&&t.isInline&&t.isAtom&&!t.isText?{}:null},is=e=>{let t=e.nodeAfter;return t&&t.isInline&&t.isAtom&&!t.isText?{afterCursor:!0}:null};function as(e){let t=document.createElement(`span`);t.textContent=`​`;for(let[n,r]of Object.entries(e))t.style.setProperty(n,r);return t}var ss=class extends _.r{constructor(...e){super(...e),this.name=`RteCursorFix`}getPlugins(e){let t=[rs,is];for(let n of Object.values(e.schema.marks)){let e=n.spec;e.cursorFix&&t.push(e.cursorFix)}return[this.contribution(new j({props:{decorations:e=>{let{$cursor:n}=e.selection;if(!n)return null;let r=[],i={},a=!1,o=!1;for(let r of t){let t=r(n,e);t&&(t.style&&Object.assign(i,t.style),t.afterCursor?o=!0:a=!0)}return a&&r.push(B.widget(n.pos,()=>as(i),{side:-1})),o&&r.push(B.widget(n.pos,()=>as(i),{side:1})),r.length===0?null:V.create(e.doc,r)}}}))]}};_.a(ss);var cs=new j({state:{init(){return null},apply(e,t){return e.getMeta(cs)||t}}}),ls=class extends _.r{constructor(...e){super(...e),this.name=`RteCore`,this.disabled=new es(!1),this.scrollThreshold=void 0,this.scrollMargin=void 0}getStyles(){return[this.contribution(zo),this.contribution(ts),this.contribution($o)]}getPlugins(e){let t=bo((t,n,r)=>{if(!n)return{type:t.type,attrs:t.attrs};let i=Qo(r.node(r.depth-1).contentMatchAt(r.indexAfter(r.depth-1)));return i?{type:i,attrs:e.textblockAttrs.extractFromNode(t)}:null}),n=No(ho,vo,yo,(e,n)=>t(e,n&&(t=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&t.ensureMarks(r),n(t)})));return[this.contribution(this.disabled.plugin),this.contribution(new j({props:{editable:()=>!this.disabled.getValue(e),handleDOMEvents:{click:(t,n)=>this.disabled.getValue(e)?(n.preventDefault(),!0):!1}},view:t=>{let n=t.dom.getRootNode().querySelector(`.popovers`),r=()=>{let r=this.disabled.getValue(e);n.classList.toggle(`popovers--disabled`,r),t.dom.parentElement.classList.toggle(`editor--disabled`,r),e.onDisabledChanged?.(r)};return r(),{update:()=>{r()}}}})),this.contribution(W({...Ro,Enter:n,"Shift-Enter":n})),this.contribution(Bo()),this.contribution(Ko()),this.contribution(cs)]}getFeatures(){return[this,new ns,new ss]}};_.a(ls);function us(e,t){this.v=e,this.k=t}function ds(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function fs(e){if(Array.isArray(e))return e}function ps(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ms(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
42
42
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hs(e,t){return fs(e)||ps(e,t)||gs(e,t)||ms()}function gs(e,t){if(e){if(typeof e==`string`)return ds(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ds(e,t):void 0}}function _s(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof us;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}_s.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},_s.prototype.next=function(e){return this._invoke(`next`,e)},_s.prototype.throw=function(e){return this._invoke(`throw`,e)},_s.prototype.return=function(e){return this._invoke(`return`,e)};var vs=Object.entries,ys=Object.setPrototypeOf,bs=Object.isFrozen,xs=Object.getPrototypeOf,Ss=Object.getOwnPropertyDescriptor,K=Object.freeze,q=Object.seal,Cs=Object.create,ws=typeof Reflect<`u`&&Reflect,Ts=ws.apply,Es=ws.construct;K||=function(e){return e},q||=function(e){return e},Ts||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},Es||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var Ds=X(Array.prototype.forEach);Array.prototype.indexOf;var Os=X(Array.prototype.lastIndexOf),ks=X(Array.prototype.pop),As=X(Array.prototype.push);Array.prototype.slice;var js=X(Array.prototype.splice),Ms=Array.isArray,Ns=X(String.prototype.toLowerCase),Ps=X(String.prototype.toString),Fs=X(String.prototype.match),Is=X(String.prototype.replace),Ls=X(String.prototype.indexOf),Rs=X(String.prototype.trim),zs=X(Number.prototype.toString),Bs=X(Boolean.prototype.toString),Vs=typeof BigInt>`u`?null:X(BigInt.prototype.toString),Hs=typeof Symbol>`u`?null:X(Symbol.prototype.toString),J=X(Object.prototype.hasOwnProperty),Us=X(Object.prototype.toString),Y=X(RegExp.prototype.test),Ws=Gs(TypeError);function X(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Ts(e,t,r)}}function Gs(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return Es(e,n)}}function Z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ns;if(ys&&ys(e,null),!Ms(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(bs(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ks(e){for(let t=0;t<e.length;t++)J(e,t)||(e[t]=null);return e}function qs(e){let t=Cs(null);for(let r of vs(e)){var n=hs(r,2);let i=n[0],a=n[1];J(e,i)&&(t[i]=Ms(a)?Ks(a):a&&typeof a==`object`&&a.constructor===Object?qs(a):a)}return t}function Js(e){switch(typeof e){case`string`:return e;case`number`:return zs(e);case`boolean`:return Bs(e);case`bigint`:return Vs?Vs(e):`0`;case`symbol`:return Hs?Hs(e):`Symbol()`;case`undefined`:return Us(e);case`function`:case`object`:{if(e===null)return Us(e);let t=e,n=Ys(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Us(e)}return Us(e)}default:return Us(e)}}function Ys(e,t){for(;e!==null;){let n=Ss(e,t);if(n){if(n.get)return X(n.get);if(typeof n.value==`function`)return X(n.value)}e=xs(e)}function n(){return null}return n}function Xs(e){try{return Y(e,``),!0}catch{return!1}}var Zs=K(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Qs=K(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),$s=K([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),ec=K([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),tc=K(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),nc=K([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),rc=K([`#text`]),ic=K(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),ac=K(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),oc=K(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),sc=K([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),cc=q(/{{[\w\W]*|^[\w\W]*}}/g),lc=q(/<%[\w\W]*|^[\w\W]*%>/g),uc=q(/\${[\w\W]*/g),dc=q(/^data-[\-\w.\u00B7-\uFFFF]+$/),fc=q(/^aria-[\-\w]+$/),pc=q(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),mc=q(/^(?:\w+script|data):/i),hc=q(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),gc=q(/^html$/i),_c=q(/^[a-z][.\w]*(-[.\w]+)+$/i),vc=q(/<[/\w!]/g),yc=q(/<[/\w]/g),bc=q(/<\/no(script|embed|frames)/i),xc=q(/\/>/i),Sc={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Cc=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],wc=K(Z({},Cc)),Tc=function(){let e={};return Ds(Cc,t=>{e[t]=q(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),K(e)}(),Ec=function(){return typeof window>`u`?null:window},Dc=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Oc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},kc=function(e,t,n,r){return J(e,t)&&Ms(e[t])?Z(r.base?qs(r.base):{},e[t],r.transform):n},Ac=function(e,t,n){let r=J(e,t)?e[t]:void 0;return r&&typeof r==`object`?qs(r):n()};function jc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ec(),t=e=>jc(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==Sc.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Ys(d,`cloneNode`),p=Ys(d,`remove`),m=Ys(d,`removeAttributeNode`),h=Ys(d,`nextSibling`),g=Ys(d,`childNodes`),ee=Ys(d,`parentNode`),te=Ys(d,`shadowRoot`),_=Ys(d,`attributes`),v=o&&o.prototype?Ys(o.prototype,`nodeType`):null,ne=o&&o.prototype?Ys(o.prototype,`nodeName`):null,re=o&&o.prototype?Ys(o.prototype,`ownerDocument`):null,ie=function(e){return v?v(e):e.nodeType},ae=function(e){return ne?ne(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let y,oe=``,b,se=!1,ce=0,le=function(){if(ce>0)throw Ws(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ue=function(e){le(),ce++;try{return y.createHTML(e)}finally{ce--}},de=function(e){le(),ce++;try{return y.createScriptURL(e)}finally{ce--}},fe=function(){return se||=(b=Dc(u,i),!0),b},pe=n,me=pe.implementation,he=pe.createNodeIterator,ge=pe.createDocumentFragment,_e=pe.getElementsByTagName,ve=r.importNode,x=Oc();t.isSupported=typeof vs==`function`&&typeof ee==`function`&&me&&me.createHTMLDocument!==void 0;let ye=cc,S=lc,C=uc,be=dc,xe=fc,Se=mc,Ce=hc,we=_c,Te=pc,w=null,Ee=Z({},[...Zs,...Qs,...$s,...tc,...rc]),T=null,De=Z({},[...ic,...ac,...oc,...sc]),Oe=Object.seal(Cs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ke=null,Ae=null,je=Object.seal(Cs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Me=!0,Ne=!0,Pe=!1,Fe=!0,Ie=!1,Le=!0,Re=!1,ze=!1,Be=null,Ve=null,He=!1,Ue=!1,We=!1,Ge=!1,Ke=!0,qe=!1,Je=`user-content-`,Ye=!0,Xe=!1,Ze={},Qe=null,$e=Z({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),et=null,tt=Z({},[`audio`,`video`,`img`,`source`,`image`,`track`]),nt=null,rt=Z({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),it=`http://www.w3.org/1998/Math/MathML`,at=`http://www.w3.org/2000/svg`,ot=`http://www.w3.org/1999/xhtml`,st=ot,ct=!1,lt=null,ut=Z({},[it,at,ot],Ps),dt=K([`mi`,`mo`,`mn`,`ms`,`mtext`]),ft=Z({},dt),E=K([`annotation-xml`]),pt=Z({},E),mt=Z({},[`title`,`style`,`font`,`a`,`script`]),ht=null,D=[`application/xhtml+xml`,`text/html`],O=null,k=null,gt=n.createElement(`form`),A=function(e){return e instanceof RegExp||e instanceof Function},_t=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(k&&k===e)return;(!e||typeof e!=`object`)&&(e={}),e=qs(e),ht=D.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,O=ht===`application/xhtml+xml`?Ps:Ns,w=kc(e,`ALLOWED_TAGS`,Ee,{transform:O}),T=kc(e,`ALLOWED_ATTR`,De,{transform:O}),lt=kc(e,`ALLOWED_NAMESPACES`,ut,{transform:Ps}),nt=kc(e,`ADD_URI_SAFE_ATTR`,rt,{transform:O,base:rt}),et=kc(e,`ADD_DATA_URI_TAGS`,tt,{transform:O,base:tt}),Qe=kc(e,`FORBID_CONTENTS`,$e,{transform:O}),ke=kc(e,`FORBID_TAGS`,qs({}),{transform:O}),Ae=kc(e,`FORBID_ATTR`,qs({}),{transform:O}),Ze=J(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?qs(e.USE_PROFILES):e.USE_PROFILES:!1,Me=e.ALLOW_ARIA_ATTR!==!1,Ne=e.ALLOW_DATA_ATTR!==!1,Pe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Fe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ie=e.SAFE_FOR_TEMPLATES||!1,Le=e.SAFE_FOR_XML!==!1,Re=e.WHOLE_DOCUMENT||!1,Ue=e.RETURN_DOM||!1,We=e.RETURN_DOM_FRAGMENT||!1,Ge=e.RETURN_TRUSTED_TYPE||!1,He=e.FORCE_BODY||!1,Ke=e.SANITIZE_DOM!==!1,qe=e.SANITIZE_NAMED_PROPS||!1,Ye=e.KEEP_CONTENT!==!1,Xe=e.IN_PLACE||!1,Te=Xs(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:pc,st=typeof e.NAMESPACE==`string`?e.NAMESPACE:ot,ft=Ac(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>Z({},dt)),pt=Ac(e,`HTML_INTEGRATION_POINTS`,()=>Z({},E));let t=Ac(e,`CUSTOM_ELEMENT_HANDLING`,()=>Cs(null));if(Oe=Cs(null),J(t,`tagNameCheck`)&&A(t.tagNameCheck)&&(Oe.tagNameCheck=t.tagNameCheck),J(t,`attributeNameCheck`)&&A(t.attributeNameCheck)&&(Oe.attributeNameCheck=t.attributeNameCheck),J(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Oe.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),q(Oe),Ie&&(Ne=!1),We&&(Ue=!0),Ze&&(w=Z({},rc),T=Cs(null),Ze.html===!0&&(Z(w,Zs),Z(T,ic)),Ze.svg===!0&&(Z(w,Qs),Z(T,ac),Z(T,sc)),Ze.svgFilters===!0&&(Z(w,$s),Z(T,ac),Z(T,sc)),Ze.mathMl===!0&&(Z(w,tc),Z(T,oc),Z(T,sc))),je.tagCheck=null,je.attributeCheck=null,J(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?je.tagCheck=e.ADD_TAGS:Ms(e.ADD_TAGS)&&(w===Ee&&(w=qs(w)),Z(w,e.ADD_TAGS,O))),J(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?je.attributeCheck=e.ADD_ATTR:Ms(e.ADD_ATTR)&&(T===De&&(T=qs(T)),Z(T,e.ADD_ATTR,O))),J(e,`ADD_FORBID_CONTENTS`)&&Ms(e.ADD_FORBID_CONTENTS)&&(Qe===$e&&(Qe=qs(Qe)),Z(Qe,e.ADD_FORBID_CONTENTS,O)),Ye&&(w[`#text`]=!0),Re&&Z(w,[`html`,`head`,`body`]),w.table&&(Z(w,[`tbody`]),delete ke.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ws(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ws(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=y;y=e.TRUSTED_TYPES_POLICY;try{oe=ue(``)}catch(e){throw y=t,e}}else e.TRUSTED_TYPES_POLICY===null?(y=void 0,oe=``):(y===void 0&&(y=fe()),y&&typeof oe==`string`&&(oe=ue(``)));K&&K(e),k=e},vt=Z({},[...Qs,...$s,...ec]),yt=Z({},[...tc,...nc]),bt=function(e,t,n){return t.namespaceURI===ot?e===`svg`:t.namespaceURI===it?e===`svg`&&(n===`annotation-xml`||ft[n]):!!vt[e]},xt=function(e,t,n){return t.namespaceURI===ot?e===`math`:t.namespaceURI===at?e===`math`&&pt[n]:!!yt[e]},St=function(e,t,n){return t.namespaceURI===at&&!pt[n]||t.namespaceURI===it&&!ft[n]?!1:!yt[e]&&(mt[e]||!vt[e])},Ct=function(e){let t=ee(e);(!t||!t.tagName)&&(t={namespaceURI:st,tagName:`template`});let n=Ns(e.tagName),r=Ns(t.tagName);return lt[e.namespaceURI]?e.namespaceURI===at?bt(n,t,r):e.namespaceURI===it?xt(n,t,r):e.namespaceURI===ot?St(n,t,r):!!(ht===`application/xhtml+xml`&&lt[e.namespaceURI]):!1},wt=function(e){As(t.removed,{element:e});try{ee(e).removeChild(e)}catch{if(p(e),!ee(e))throw Ws(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Tt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Et=function(e){kt(e);let t=g(e);if(t){let e=[];Ds(t,t=>{As(e,t)}),Ds(e,e=>{try{p(e)}catch{}})}let n=_(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&Tt(e,r,i)}},Dt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}As(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ue||We)try{wt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Ot=function(e){let t=_(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||T[O(i)]||Tt(e,r,i)}},kt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();ie(e)===Sc.element&&Ot(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},j=function(e,t){return Le?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},At=function(e){if(!Le)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=ie(e);if(n===Sc.processingInstruction||n===Sc.comment&&Y(yc,e.data)){try{p(e)}catch{}continue}if(n===Sc.element){let t=e,n=O(ae(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&j(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},jt=function(e){let t=null,r=null;if(He)e=`<remove></remove>`+e;else{let t=Fs(e,/^[\r\n\t ]+/);r=t&&t[0]}ht===`application/xhtml+xml`&&st===ot&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=y?ue(e):e;if(st===ot)try{t=new l().parseFromString(i,ht)}catch{}if(!t||!t.documentElement){t=me.createDocument(st,`template`,null);try{t.documentElement.innerHTML=ct?oe:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),st===ot?_e.call(t,Re?`html`:`body`)[0]:Re?t.documentElement:a},Mt=function(e){let t=re?re(e):e.ownerDocument;return he.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},M=function(e){return e=Is(e,ye,` `),e=Is(e,S,` `),e=Is(e,C,` `),e},Nt=function(e){e.normalize();let t=re?re(e):e.ownerDocument,n=he.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=M(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&Ds(i,e=>{N(e.content)&&Nt(e.content)})},Pt=function(e){let t=ne?ne(e):null;return typeof t!=`string`||O(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==_(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==v(e)||e.childNodes!==g(e)},N=function(e){if(!v||typeof e!=`object`||!e)return!1;try{return v(e)===Sc.documentFragment}catch{return!1}},Ft=function(e){if(!v||typeof e!=`object`||!e)return!1;try{return typeof v(e)==`number`}catch{return!1}};function P(e,n,r){e.length!==0&&Ds(e,e=>{e.call(t,n,r,k)})}let It=function(e,t){return!!(Le&&e.hasChildNodes()&&!Ft(e.firstElementChild)&&Y(vc,e.textContent)&&Y(vc,e.innerHTML)||Le&&e.namespaceURI===ot&&wc[t]&&(Ft(e.firstElementChild)||typeof e.textContent==`string`&&Y(Tc[t],e.textContent))||e.nodeType===Sc.processingInstruction||Le&&e.nodeType===Sc.comment&&Y(yc,e.data))},Lt=function(e,t){if(e instanceof RegExp)return Y(e,t);if(e instanceof Function){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return!!e(t,...r)}return!1},Rt=function(e,t,n){if(!ke[t]&&Wt(t)&&Lt(Oe.tagNameCheck,t))return!1;if(Ye&&!Qe[t]){let t=ee(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return wt(e),!0},zt=function(e,t,n,r){return e.length===0?t:t===n||t===r?qs(t):t},Bt=function(e,t){return e===t||ee(e)!==null?!1:(Xe&&kt(e),!0)},Vt=function(e,n){if(P(x.beforeSanitizeElements,e,null),Bt(e,n))return!0;if(Pt(e))return wt(e),!0;let r=O(ae(e));if(w=zt(x.uponSanitizeElement,w,Ee,Be),P(x.uponSanitizeElement,e,{tagName:r,allowedTags:w}),Bt(e,n))return!0;if(It(e,r))return wt(e),!0;if(ke[r]||!(je.tagCheck instanceof Function&&je.tagCheck(r))&&!w[r]){let t=Rt(e,r,n);return t===!1&&(P(x.afterSanitizeElements,e,null),Bt(e,n))?!0:t}if(ie(e)===Sc.element&&!Ct(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Y(bc,e.innerHTML))return wt(e),!0;if(Ie&&e.nodeType===Sc.text){let n=M(e.textContent);e.textContent!==n&&(As(t.removed,{element:e.cloneNode()}),e.textContent=n)}return P(x.afterSanitizeElements,e,null),Bt(e,n)},Ht=function(e,t,r){if(Ae[t]||j(t,e)||Ke&&(t===`id`||t===`name`)&&(r in n||r in gt))return!1;let i=T[t]||je.attributeCheck instanceof Function&&je.attributeCheck(t,e);return Ne&&Y(be,t)||Me&&Y(xe,t)?!0:i?nt[t]||Y(Te,Is(r,Ce,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Ls(r,`data:`)===0&&et[e]||Pe&&!Y(Se,Is(r,Ce,``))?!0:!r:Wt(e)&&Lt(Oe.tagNameCheck,e)&&Lt(Oe.attributeNameCheck,t,e)||t===`is`&&Oe.allowCustomizedBuiltInElements&&Lt(Oe.tagNameCheck,r)},Ut=Z({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Wt=function(e){return!Ut[Ns(e)]&&Y(we,e)},Gt=function(e,t,n,r){if(y&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ue(r);case`TrustedScriptURL`:return de(r)}return r},Kt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Pt(e)||(wt(e),!1)}catch{return Dt(t,e),!1}},qt=function(e,n){if(P(x.beforeSanitizeAttributes,e,null),Bt(e,n))return;let r=e.attributes;if(!r||Pt(e))return;T=zt(x.uponSanitizeAttribute,T,De,Ve);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0},a=r.length,o=O(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=O(s),d=l,f=s===`value`?d:Rs(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,P(x.uponSanitizeAttribute,e,i),f=i.attrValue,qe&&(u===`id`||u===`name`)&&Ls(f,Je)!==0&&(Dt(s,e,n),f=Je+f,p=!0),Le&&Y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)||u===`attributename`&&Fs(f,`href`)?Dt(s,e,n):i.forceKeepAttr||(i.keepAttr?!Fe&&Y(xc,f)?Dt(s,e,n):(Ie&&(f=M(f)),Ht(o,u,f)?(f=Gt(o,u,c,f),f!==d&&Kt(e,s,c,f)&&p&&ks(t.removed)):Dt(s,e,n)):Dt(s,e,n))}P(x.afterSanitizeAttributes,e,null),Bt(e,n)},Jt=function(e){let t=null,n=Mt(e);for(P(x.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(P(x.uponSanitizeShadowNode,t,null),Vt(t,e),qt(t,e),N(t.content)&&Jt(t.content),ie(t)===Sc.element){let e=te(t);N(e)&&(Yt(e),Jt(e))}P(x.afterSanitizeShadowDOM,e,null)},Yt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Jt(e.shadow);continue}let n=e.node,r=ie(n)===Sc.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=ne?ne(n):null;if(typeof e==`string`&&O(e)===`template`){let e=n.content;N(e)&&t.push({node:e,shadow:null})}}if(r){let e=te(n);N(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(ct=!e,ct&&(e=`<!-->`),typeof e!=`string`&&!Ft(e)&&(e=Js(e),typeof e!=`string`))throw Ws(`dirty is not a string, aborting`);if(!t.isSupported)return e;ze?(w=Be,T=Ve):_t(n),(x.uponSanitizeElement.length>0||x.uponSanitizeAttribute.length>0)&&(w=qs(w)),x.uponSanitizeAttribute.length>0&&(T=qs(T)),t.removed=[];let c=Xe&&typeof e!=`string`&&Ft(e);if(c){At(e);let t=ae(e);if(typeof t==`string`){let n=O(t);if(!w[n]||ke[n])throw Et(e),Ws(`root node is forbidden and cannot be sanitized in-place`)}if(Pt(e))throw Et(e),Ws(`root node is clobbered and cannot be sanitized in-place`);try{Yt(e)}catch(t){throw Et(e),t}}else if(Ft(e))i=jt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Sc.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Yt(i);else{if(!Ue&&!Ie&&!Re&&e.indexOf(`<`)===-1)return y&&Ge?ue(e):e;if(i=jt(e),!i)return Ue?null:Ge?oe:``}i&&He&&wt(i.firstChild);let l=c?e:i;try{let e=Mt(l);for(;o=e.nextNode();)Vt(o,l),qt(o,l),N(o.content)&&Jt(o.content)}catch(n){throw c&&(Et(e),Ds(t.removed,e=>{e.element&&kt(e.element)})),n}if(c){let n=!1;if(Ds(t.removed,t=>{t.element&&(t.element===e&&(n=!0),kt(t.element))}),n)throw Ws(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Ie&&Nt(e),e}if(Ue){if(Ie&&Nt(i),We)for(s=ge.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(T.shadowroot||T.shadowrootmode)&&(s=ve.call(r,s,!0)),s}let u=Re?i.outerHTML:i.innerHTML;return Re&&w[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Y(gc,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
43
- `+u),Ie&&(u=M(u)),y&&Ge?ue(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_t(e),ze=!0,Be=w,Ve=T},t.clearConfig=function(){k=null,ze=!1,Be=null,Ve=null,y=b,oe=``},t.isValidAttribute=function(e,t,n){k||_t({});let r=O(e),i=O(t);return Ht(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&J(x,e)&&As(x[e],t)},t.removeHook=function(e,t){if(J(x,e)){if(t!==void 0){let n=Os(x[e],t);return n===-1?void 0:js(x[e],n,1)[0]}return ks(x[e])}},t.removeHooks=function(e){J(x,e)&&(x[e]=[])},t.removeAllHooks=function(){x=Oc()},t}var Mc=jc(),Nc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Pc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Fc=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,Ic={ALLOWED_URI_REGEXP:Pc},Lc=e=>{if(!Nc.test(e.replace(Fc,``)))return``;let t=document.createElement(`a`);return t.setAttribute(`href`,e),Mc.sanitize(t,{RETURN_DOM:!0,...Ic}).querySelector(`a`).getAttribute(`href`)??``},Rc=e=>Lc(e)!==``,zc=/^(?:[/?#]|\.{1,2}\/)/,Bc=e=>{let t=e.trim();if(!t||!Rc(t))return!1;if(zc.test(t))return!0;try{return new URL(t),!0}catch{return!1}},Vc=e=>{let t=document.createElement(`img`);return t.setAttribute(`src`,e),Mc.sanitize(t,{RETURN_DOM:!0,...Ic}).querySelector(`img`).getAttribute(`src`)??``},Hc=e=>e.replace(/[;!].*/,``),Uc=e=>({...e}),Wc=e=>({nodes:Object.fromEntries(Object.keys(e.nodes).map(t=>[t,(e.nodes[t].spec.parseDOM??[]).map(Uc)])),marks:Object.fromEntries(Object.keys(e.marks).map(t=>[t,(e.marks[t].spec.parseDOM??[]).map(Uc)]))}),Gc=class{constructor(e,t){this[_.c]=new Kc(e[_.c],t)}parseDocument(e,t){return this[_.c].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[_.c].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){let n=Mc.sanitize(e,{RETURN_DOM:!0,...Ic}),r=document.createDocumentFragment();return r.appendChild(n),t?.modifyDom?.(r),r}},Kc=class{constructor(e,t){let n=Wc(e.schema);t?.modifyParseRules?.(n),this.parser=qc(e.schema,n)}transform(e){return Mc.sanitize(e)}},qc=(e,{marks:t,nodes:n})=>{let r=[],i=e=>e.priority??50;function a(e){let t=0;for(;t<r.length;t++){let n=r[t];if(i(n)<i(e))break}r.splice(t,0,e)}for(let e in t)t[e]?.forEach(t=>{a(t=Uc(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)});for(let e in n)n[e]?.forEach(t=>{a(t=Uc(t)),t.node||t.ignore||t.mark||(t.node=e)});return r.push({tag:`br`,closeParent:!0}),new _.l(e,r)},Jc=class{constructor(e,t){this[_.c]=new Yc(e[_.c],t)}serializeDocument(e,t){return this[_.c].serializeFragment(e.content,t)}serializeFragment(e,t){return this[_.c].serializeFragment(e,t)}},Yc=class e{constructor(t,n){this.config=t;let r=e.domSerializersFromSchema(t.schema);Object.assign(r.nodes,n?.serializers?.nodes??{}),Object.assign(r.marks,n?.serializers?.marks??{}),this.serializer=new _.u(r.nodes,r.marks)}static domSerializersFromSchema(e){let t={nodes:{},marks:{}};for(let n in e.marks){let r=e.marks[n].spec.toDOM;r&&(t.marks[n]=r)}for(let n in e.nodes){let r=e.nodes[n].spec.serializeToDOM??e.nodes[n].spec.toDOM;r&&(t.nodes[n]=r)}return t.nodes.text=e=>document.createTextNode(e.text),t}serializeFragment(e,t){let n=_.d.fromJSON(this.config.schema,e),r=this.serializer.serializeFragment(n),i=document.createDocumentFragment();i.appendChild(r),t?.modifyDom?.(i);let a=document.createElement(`div`);return a.appendChild(i),a.innerHTML}},Xc=(e,t)=>{let n=e.topNodeType.createAndFill(null,t?_.d.fromJSON(e,t.content):null);if(!n)throw Error(`Document could not be parsed`);return n.check(),n},Zc=class{constructor(e,t){this.options=t,this.feature=(e,t)=>this[_.c].getPublicInterface(e,t),this[_.c]=new Qc(this,e,t)}getDocument(){return this[_.c].state.doc.toJSON()}reset(e){this[_.c].reset(e)}replaceSelection(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[_.c];r.replaceSelection(new _.v(_.d.fromJSON(i,e),0,0)),r.doc.check();let o=r.doc.resolve(r.mapping.map(n.selection.from,-1)),s=r.doc.resolve(r.selection.to),[c,l]=t?.cursorPlacement===`start`?[o,s]:[s,o];t?.selectContent?r.setSelection(n.selection instanceof A?new A(r.doc):D.between(l,c)):r.setSelection(D.between(c,c)),a(r)}replaceDocument(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[_.c];r.replaceWith(0,n.doc.content.size,Xc(i,e)),t?.selectContent?r.setSelection(new A(r.doc)):t?.cursorPlacement===`end`?r.setSelection(D.atEnd(r.doc)):r.setSelection(D.atStart(r.doc)),a(r)}scrollIntoView(){let e=this[_.c];e.view&&e.dispatchTransaction(e.tr.scrollIntoView())}},Qc=class{getFeature(e){let t=this.config.featureMap.get(e);if(!t)throw Error(`Feature not found: ${e}`);return t}getPublicInterface(e,t){let n=this.config.featureFacadesMap.get(e);if(!n||n.length===0)throw Error(`Feature not found`);if(n[0].featureId!==void 0){if(t===void 0)throw Error(`No featureId provided for multi-instance feature.`);let e=n.find(e=>e.featureId===t);if(!e)throw Error(`Feature with id "${t}" not found`);return e.getPublicInterface(this)}if(t!==void 0)throw Error(`Feature does not support featureId`);return n[0].getPublicInterface(this)}constructor(e,n,r){this.options=r,this.view=null,this.onDisabledChanged=null,this.dispatchTransaction=e=>{let t=this.state;return this.state=this.state.apply(e),this.view?.updateState(this.state),t.doc!==this.state.doc&&this.options?.onChange?.(),this.state},this.facade=e;let i=n[_.c];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=r?.foreignHtmlParser??new Gc(n),this.foreignHtmlSerializer=r?.foreignHtmlSerializer??new Jc(n),this.styles=new t.w(_.s(i.features.flatMap(e=>e.getStyles()))),this.initState(r?.initialDocument)}initState(e){this.state=Ot.create({doc:Xc(this.schema,e),schema:this.config.schema,plugins:_.s(this.config.features.flatMap(e=>e.getPlugins(this)))})}reset(e){let t=cs.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){let t=this.config.featureMap.get(`RteCore`);this.view=new Ra({mount:e},{state:this.state,dispatchTransaction:this.dispatchTransaction,...t?.scrollThreshold!==void 0&&{scrollThreshold:t.scrollThreshold},...t?.scrollMargin!==void 0&&{scrollMargin:t.scrollMargin}})}destroyViewIfNeeded(){this.view&&=(this.view.destroy(),null)}createComponent(e){return document.createElement(this.hostState().ctx.tagFor(e,!0))}getLocale(){return this.hostState().locale}get tr(){return this.state.tr}hostState(){let e=cs.getState(this.state);if(!e)throw Error(`No host state available`);return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(cs,e))}},$c=class{constructor(e){this.specs=e,this.attrs={};for(let t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join(`; `)}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}},el=class{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(e=>e.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}},tl=(e,t)=>{let n=t.config[_.c].schema,r=e=>n.marks[e.type].rank,i=(e,t)=>{if(e.type!==t.type)return!1;let n=e.attrs,r=t.attrs;if(n===r)return!0;if(!n||!r)return!1;let i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(n[e]!==r[e])return!1;return!0},a=e=>{let n=[],o=[],s=[n];for(let n of e){let e=[...n.marks??[]].sort((e,t)=>r(e)-r(t)),c=0,l=0;for(;c<o.length&&l<e.length&&i(o[c],e[l]);)c++,l++;for(;o.length>c;)o.pop(),s.pop();for(;l<e.length;){let n=e[l],r=[];s[s.length-1].push({type:`mark`,mark:n,children:{type:`fragment`,content:r,[_.c]:t},[_.c]:t}),o.push(n),s.push(r),l++}s[s.length-1].push({type:`node`,node:n,children:a(n.content??[]),[_.c]:t})}return{type:`fragment`,content:n,[_.c]:t}};return{type:`node`,node:e,children:a(e.content),[_.c]:t}},nl=class{constructor(e){this[_.c]=new rl(e)}instantiateEditor(e){return new Zc(this,e)}instantiateView(e,t){return tl(e,{config:this,options:{...t}})}},rl=class{constructor(e){let t=e=>e.flatMap(e=>e.getFeatures().flatMap(n=>n===e?e:t([n])));this.features=t(e.map(_.o)),this.featureMap=new Map;for(let e of this.features){if(this.featureMap.has(e.name))throw Error(`Duplicate feature: ${e.name}`);this.featureMap.set(e.name,e)}this.featureFacadesMap=new Map;for(let t of e){let e=t.constructor,n=_.o(t),r=this.featureFacadesMap.get(e);r?r.push(n):this.featureFacadesMap.set(e,[n])}if(!this.featureMap.has(`RteBase`))throw Error(`RteBase feature is required`);if(this.featureMap.has(`RteLinkFeature`)&&!this.featureMap.has(`RteToolbarFeature`))throw Error(`RteToolbarFeature is required for RteLinkFeature`);this.textblockAttrs=new $c(_.s(this.features.flatMap(e=>e.getTextblockAttrs()))),this.textblockMarks=new el(_.s(this.features.flatMap(e=>e.getTextblockMarks())));let n=_.s(this.features.flatMap(e=>e.getSchema(this.textblockAttrs,this.textblockMarks))),r={nodes:{},marks:{}};for(let e of n)Object.assign(r.nodes,e.nodes??{}),Object.assign(r.marks,e.marks??{});for(let e of this.textblockMarks.getReferencedNodeNames())if(!(e in r.nodes))throw Error(`Unknown node "${e}"`);this.schema=new _._(r)}},il=e=>{let t=[],n;return e.forEach(e=>{if(e.isInline)n||(n=[],t.push(n)),n.push(e);else if(n=void 0,e.isTextblock){let n=[];e.content.forEach(e=>n.push(e)),t.push(n)}else t.push(...il(e.content))}),t},al=(e,t)=>{let n=il(e.content);if(n.length<=1)return e;let r=t.nodes.hardBreak,i=r?[r.create()]:[],a=n.flatMap((e,t)=>t===0?e:[...i,...e]);return new _.v(_.d.fromArray(a),0,0)},ol=200,Q=function(){};Q.prototype.append=function(e){return e.length?(e=Q.from(e),!this.length&&e||e.length<ol&&this.leafAppend(e)||this.length<ol&&e.leafPrepend(this)||this.appendInner(e)):this},Q.prototype.prepend=function(e){return e.length?Q.from(e).append(this):this},Q.prototype.appendInner=function(e){return new cl(this,e)},Q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Q.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Q.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Q.from=function(e){return e instanceof Q?e:e&&e.length?new sl(e):Q.empty};var sl=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=ol)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=ol)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Q);Q.empty=new sl([]);var cl=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Q),ll=500,ul=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new fl(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new fl(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new fl(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>ml&&(s=dl(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new x;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new fl(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new fl(i,o,l))}else r.push(new fl(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new fl(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>ll&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new fl(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(Q.from(i.reverse()),a)}};ul.empty=new ul(Q.empty,0);function dl(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var fl=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},pl=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},ml=20;function hl(e,t,n,r){let i=n.getMeta(wl),a;if(i)return i.historyState;n.getMeta(Tl)&&(e=new pl(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(wl))return o.getMeta(wl).redo?new pl(e.done.addTransform(n,void 0,r,Sl(t)),e.undone,_l(n.mapping.maps),e.prevTime,e.prevComposition):new pl(e.done,e.undone.addTransform(n,void 0,r,Sl(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!gl(n,e.prevRanges)),s=o?vl(e.prevRanges,n.mapping):_l(n.mapping.maps);return new pl(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Sl(t)),ul.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new pl(e.done.rebased(n,a),e.undone.rebased(n,a),vl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new pl(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),vl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function gl(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function _l(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function vl(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function yl(e,t,n){let r=Sl(t),i=wl.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new pl(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(wl,{redo:n,historyState:c})}var bl=!1,xl=null;function Sl(e){let t=e.plugins;if(xl!=t){bl=!1,xl=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){bl=!0;break}}return bl}function Cl(e){return e.setMeta(Tl,!0)}var wl=new Mt(`history`),Tl=new Mt(`closeHistory`);function El(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new j({key:wl,state:{init(){return new pl(ul.empty,ul.empty,null,0,-1)},apply(t,n,r){return hl(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Ol:n==`historyRedo`?kl:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Dl(e,t){return(n,r)=>{let i=wl.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=yl(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Ol=Dl(!1,!0),kl=Dl(!0,!0),Al=e=>typeof e==`function`,jl=(e,t,n)=>[e,t,n],Ml=class{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return Al(e)?e(this):e}bindProp(e,t){if(e!==void 0){if(Al(e)){let n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}}updateBindings(){for(let e of this.bindings)e()}shouldReturnFocusToEditor(){return this.evalProp(this.props.shouldReturnFocusToEditor)}bindToEl(e,t={},n=[],r=[]){for(let n in t)this.bindProp(t[n],t=>{e[n]=t});for(let[t,r,i]of n)r&&e.addEventListener(t,i(r));for(let t of r)e.appendChild(t)}},Nl=(e,t)=>{let n=document.createElement(`div`);return e.bindToEl(n,{className:t.className,slot:t.slot},[],t.children),n},Pl=(e,t)=>{let n=document.createElement(`a`);return e.bindToEl(n,{href:t.href,target:t.target,rel:t.rel,className:t.className},[],t.children),n},Fl=new WeakMap,Il=(e,t)=>{let n=e.rte.createComponent(l.r);n.setAttribute(`exportparts`,`vvd-theme-alternate`),e.bindToEl(n,{className:`ui-tooltip`,text:t.label,placement:e.props.popupPlacement}),e.bindProp(t.enabled,e=>{e||(n.open=!1),n.anchor=e?t.anchor:void 0});let r=Nl(e,{className:`ui-tooltip-wrapper`,slot:t.slot,children:[t.anchor,n]});return Fl.set(r,t.anchor),r},$=(e,t)=>{let n=()=>e.evalProp(t.variant)??`toolbar`,r=()=>n()===`toolbar`?`super-condensed`:`condensed`,i=()=>n()===`popover-primary`?`outlined`:`ghost-light`,a=()=>n()===`toolbar-menu`||n()===`popover`?`filled`:i(),o=()=>e.evalProp(t.active)?a():i(),c=()=>e.evalProp(t.connotation)??(n()===`toolbar-menu`&&e.evalProp(t.active)?`cta`:void 0),l=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),u=!!(t.icon??t.dynamicIcon),d=()=>{let n=e.evalProp(t.dynamicIcon);return n===void 0?e.evalProp(t.icon):`${n}-${e.evalProp(t.active)?`solid`:`line`}`},f=e.rte.createComponent(s.i);return e.bindToEl(f,{size:r,appearance:o,disabled:l,icon:d,autofocus:t.autofocus,connotation:c,[u?`ariaLabel`:`label`]:t.label,pressed:()=>!!e.evalProp(t.active),ariaPressed:t.active===void 0?void 0:()=>e.evalProp(t.active)?`true`:`false`},[jl(`click`,t.onClick,t=>()=>{!t()&&e.shouldReturnFocusToEditor()&&e.view.focus()})]),Il(e,{enabled:()=>u&&!e.evalProp(t.noTooltip)&&!l(),label:t.label,anchor:f,slot:t.slot})},Ll=(e,t)=>{let n=e.rte.createComponent(ne.r);e.bindToEl(n,{className:`ui-menu`,autoDismiss:!0,ariaLabel:t.label,anchor:Fl.get(t.trigger)??t.trigger,placement:e.props.popupPlacement,offset:()=>e.evalProp(e.props.menuOffset)??null},[],t.children);let r=document.createDocumentFragment();return r.appendChild(t.trigger),r.appendChild(n),r},Rl=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(v.i);return e.bindToEl(r,{text:t.text,checked:t.checked,disabled:n,controlType:`radio`,checkedAppearance:`tick-only`},[jl(`change`,t.onSelect,n=>()=>{r.checked&&!r.disabled&&e.evalProp(t.checked)!==r.checked&&(n(),e.shouldReturnFocusToEditor()&&e.view.focus())})]),r},zl=(e,t)=>Nl(e,{slot:t.slot,className:`ui-button-group`,children:t.children});function Bl(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}var Vl=(e,t)=>$(e,{label:t.label,dynamicIcon:t.dynamicIcon,active:()=>Bl(e.view.state,t.markType),disabled:()=>!Ao(t.markType)(e.view.state),onClick:()=>{Ao(t.markType)(e.view.state,e.view.dispatch)}}),Hl=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(f.t);return e.bindToEl(r,{value:t.value,text:t.text,disabled:n}),r},Ul=(e,t)=>{let n=()=>!!e.evalProp(e.props.disabled),r=e.rte.createComponent(g.r);r.setAttribute(`data-class`,`ui-select`),e.bindToEl(r,{placeholder:` `,ariaLabel:t.label,appearance:`ghost`,disabled:n},[jl(`change`,t.onSelect,t=>()=>{let n=r.value;n&&(t(n),e.shouldReturnFocusToEditor()&&e.view.focus())})],t.children),queueMicrotask(()=>{e.bindProp(t.value,e=>r.value=e)});let i=!1;return r.addEventListener(`vwc-popup:open`,()=>{i=!0,e.updateBindings()}),r.addEventListener(`vwc-popup:close`,()=>{i=!1,e.updateBindings()}),Il(e,{enabled:()=>!i&&!n(),label:t.label,anchor:r})},Wl=e=>{let t=e.rte.createComponent(te.t);return e.bindToEl(t,{className:`ui-divider`,orientation:`vertical`}),t},Gl=(e,t)=>{let n=e.rte.createComponent(d.r);return e.bindToEl(n,{label:t.label,value:t.value,placeholder:t.placeholder,slot:t.slot,autofocus:t.autofocus,type:t.type,helperText:t.helperText},[jl(`input`,t.onInput,e=>()=>{e(n.value)})]),n},Kl=(e,t)=>{let n=document.createTextNode(``);return e.bindToEl(n,{textContent:t.text}),n},ql=(e,t)=>{let n=document.createElement(`slot`);n.name=t.name;let r=null,i=[];function a(){for(let{el:e,type:t,handler:n}of i)e.removeEventListener(t,n);i.length=0,r=null}for(let[n,i]of Object.entries(t.assignedProps))e.bindProp(i,e=>{r&&(r[n]=e)});function o(n){for(let[r,i]of Object.entries(t.assignedProps))n[r]=e.evalProp(i);for(let[r,a]of Object.entries(t.assignedEvents)){let t=t=>{a(t),e.shouldReturnFocusToEditor()&&e.view.focus()};n.addEventListener(r,t),i.push({el:n,type:r,handler:t})}}let s=()=>{let e=n.assignedElements({flatten:!0})[0];e!==r&&(a(),e&&(r=e,o(e)))};return n.addEventListener(`slotchange`,s),queueMicrotask(s),n},Jl=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteHistoryFeature`}getPlugins(){return[this.contribution(El()),this.contribution(W({"Mod-z":Ol,"Ctrl-y":kl,"Cmd-Z":kl}))]}getToolbarItems(){return this.config.showToolbarButtons?[this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.undo,icon:`undo-line`,disabled:e=>!Ol(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;Ol(t,n)}})},1),this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.redo,icon:`redo-line`,disabled:e=>!kl(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;kl(t,n)}})},2)]:[]}},Yl=`h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:16px;line-height:20px}.heading-step-1{font:var(--vvd-typography-heading-4);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:28px}.heading-step-2{font:var(--vvd-typography-heading-3);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:36px}.heading-step-3{font:var(--vvd-typography-heading-2);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:32px 16px;line-height:42px}`,Xl=class extends _.r{constructor(e){super(),this.enabledBlocks=e,this.name=`RteBasicTextBlocks`}getStyles(){return[this.contribution(Yl)]}getSchema(e,t){let n={};this.enabledBlocks.paragraph&&(n.paragraph={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:`p`,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(`paragraph`).join(` `),toDOM(t){return[`p`,{part:`node--paragraph`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[`p`,...e.getDOMAttrs(t),0]}});let r=0;for(let i of[3,2,1]){let a=`heading${i}`,o=`h${i}`;if(!this.enabledBlocks[a])continue;r++;let s=r;n[a]={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:o,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(a).join(` `),defining:!0,toDOM(t){return[o,{class:`heading-step-${s}`,part:`node--${a}`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[o,...e.getDOMAttrs(t),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){let t={};this.enabledBlocks.paragraph&&(t[`Mod-Alt-0`]=this.setBlockType(e,`paragraph`));for(let n of[1,2,3]){let r=`heading${n}`;this.enabledBlocks[r]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,r))}return[this.contribution(W(t))]}getCurrentBlockType(e){let{$from:t,$to:n}=e.selection,r=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1);return r!==(n.depth===0?e.doc.childBefore(n.pos).node:n.node(1))||!(r.type.name in this.enabledBlocks)?null:r.type.name}setBlockType(e,t){return(n,r)=>{let{from:i,to:a}=n.selection,o=n.tr,s=!1;return n.doc.nodesBetween(i,a,(r,i)=>(r.type.name in this.enabledBlocks&&(s=!0,o.setBlockType(i,i+r.nodeSize,n.schema.nodes[t],t=>e.textblockAttrs.extractFromNode(t))),!1)),s?(r?.(o),!0):!1}}},Zl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Ql(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Ql(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var $l=500;function eu({rules:e}){let t=new j({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return tu(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&tu(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function tu(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-$l),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}var nu=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new Zl(/--$/,`—`,{inCodeMark:!1}),new Zl(/\.\.\.$/,`…`,{inCodeMark:!1}),new Zl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new Zl(/"$/,`”`,{inCodeMark:!1}),new Zl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new Zl(/'$/,`’`,{inCodeMark:!1});var ru=e=>e.parent.textBetween(0,e.parentOffset,void 0,``),iu=class extends _.r{constructor(...e){super(...e),this.name=`RteInputRulesFeature`}getPlugins(e){let t=_.s(e.config.features.flatMap(t=>t.getInputRules(e)));if(t.length===0)return[];let n=[],r=t.map(e=>e.rule);n.push(this.contribution(eu({rules:r}))),n.push(this.contribution(W({Backspace:nu}),_.i.high));let i=t.filter(e=>e.enterHandler).map(e=>e.enterHandler);return i.length>0&&n.push(this.contribution(W({Enter:(e,t)=>{let{$cursor:n}=e.selection;if(!n)return!1;let r=ru(n);for(let{regex:a,handler:o}of i){let i=a.exec(r);if(!i)continue;let s=n.pos-n.parentOffset+i.index,c=o(e,i,s,s+i[0].length);c&&t?.(c);break}return!1}}),_.i.highest)),n}},au=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteBase`}getSchema(){return[this.contribution({nodes:{doc:{content:this.config?.singleBlock?`block`:`block+`},text:{group:`inline`}}})]}getPlugins(e){return this.config?.singleBlock?[this.contribution(new j({props:{transformPasted:(e,t)=>al(e,t.state.schema)}}))]:[]}getFeatures(){return[this,new ls,new Jl({showToolbarButtons:this.config?.historyToolbarButtons??!0}),new Xl({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new iu]}getPublicInterface(e){let t=e.getFeature(`RteCore`);return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)},get scrollThreshold(){return t.scrollThreshold},set scrollThreshold(n){t.scrollThreshold=n,e.view?.setProps({scrollThreshold:n})},get scrollMargin(){return t.scrollMargin},set scrollMargin(n){t.scrollMargin=n,e.view?.setProps({scrollMargin:n})}}}},ou=_.a(au),su=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteTextBlockPickerFeature`}getToolbarItems(e){let t=e.getFeature(`RteBasicTextBlocks`);return[this.contribution({section:`font`,render:n=>Ul(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:e=>t.getCurrentBlockType(e.view.state)??``,onSelect:r=>{let{state:i,dispatch:a}=n.view;t.setBlockType(e,r)(i,a)},children:this.config.options.map(r=>Hl(n,{text:r.label,value:r.node,disabled:()=>!t.setBlockType(e,r.node)(n.view.state)}))})},1)]}},cu=_.a(su),lu=`.toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}`,uu=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteToolbarFeature`,this.hidden=new es(!1)}getStyles(){return[this.contribution(lu)]}getPlugins(e){let t=[`history`,`font`,`text-style`,`textblock`,`insert`],n=new Map(t.map(e=>[e,[]]));for(let t of _.s(e.features.flatMap(t=>t.getToolbarItems(e))))n.get(t.section).push(t);let r=e.getFeature(`RteCore`);return[this.contribution(this.hidden.plugin),this.contribution(new j({view:i=>{let a=!1,o=new Ml(i,e,{popupPlacement:this.config?.popupDirection===`outward`?`bottom`:`top`,menuOffset:8,disabled:()=>r.disabled.getValue(e),shouldReturnFocusToEditor:()=>a}),s=i.dom.getRootNode().querySelector(`.toolbar`),c=-1/0,l=()=>{i.hasFocus()&&(a=!0),c=Date.now()},u=()=>{Date.now()-c>250&&(a=!1)},d=e=>{s.contains(e.relatedTarget)||(a=!1)};s.addEventListener(`mousedown`,l,{capture:!0}),s.addEventListener(`focusin`,u),s.addEventListener(`focusout`,d),o.bindProp(()=>this.hidden.getValue(e),e=>{s.classList.toggle(`toolbar--hidden`,e)});let f=!1;for(let e of t){let t=n.get(e);t.length&&f&&(s.appendChild(Wl(o)),f=!1);for(let e of t)s.appendChild(e.render(o)),f=!0}return{update(){o.updateBindings()},destroy(){s.innerHTML=``,s.removeEventListener(`mousedown`,l,{capture:!0}),s.removeEventListener(`focusin`,u),s.removeEventListener(`focusout`,d),a=!1}}}}))]}getPublicInterface(e){let t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}},du=_.a(uu),fu=`.placeholder{display:contents}.placeholder:before{color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size,inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none;position:absolute}.editor--disabled .placeholder:before{color:var(--vvd-color-neutral-300)}`,pu=class extends _.r{constructor(e){super(),this.config=e,this.name=`RtePlaceholderFeature`}getStyles(){return[this.contribution(fu)]}getPlugins(){let e=new j({props:{decorations:e=>{if(e.doc.nodeSize===4){let t=e.schema.marks.fontSize?.isInSet(e.storedMarks??[])?.attrs.size;return V.create(e.doc,[B.widget(1,()=>{let e=document.createElement(`span`);return e.className=`placeholder`,e.dataset.placeholder=this.config.text,t&&e.style.setProperty(`--placeholder-font-size`,t),e})])}return null}}});return[this.contribution(e)]}},mu=_.a(pu),hu=class extends _.r{constructor(...e){super(...e),this.name=`RteHardBreakFeature`}getSchema(){return[this.contribution({nodes:{hardBreak:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}}}})]}getPlugins(e){return[this.contribution(W({"Shift-Enter":(e,t)=>{let n=e.storedMarks||e.selection.$from.marks(),r=e.tr.replaceSelectionWith(e.schema.nodes.hardBreak.create(),!0).scrollIntoView();return n.length&&r.setStoredMarks(n),t?.(r),!0}}),_.i.high)]}},gu=_.a(hu),_u=Symbol(`mixedFontSize`),vu=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteFontSizePickerFeature`,this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(let t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`fontSize`,onNodeName:e.node})):[this.contribution({markName:`fontSize`})]}getSchema(){return[this.contribution({marks:{fontSize:{attrs:{size:{validate:`string`}},parseDOM:[{tag:`span[style*='font-size']`,getAttrs:e=>{let t=e.getAttribute(`style`).match(/font-size:\s*([^;]+)/)?.[1]?.trim();if(!t)return!1;let n=this.config?.parseSizeFromHtml?this.config.parseSizeFromHtml(t):t;return n===null||this.config?.restrictToOptions&&!this.fontSizes.some(e=>e.size===n)?!1:{size:n}}}],toDOM:e=>[`span`,{style:`font-size: ${Hc(e.attrs.size)};`},0],cursorFix:(e,t)=>{let n=t.storedMarks;if(!n)return null;let r=n.find(e=>e.type.name===`fontSize`);if(r)return{style:{"font-size":r.attrs.size}};if(n.length===0){let t=this.defaultFontSizeForNode?.[e.parent.type.name];if(t)return{style:{"font-size":t}}}return null}}}})]}getPlugins(){return[this.contribution(W({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:`font`,render:t=>Ll(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:$(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:`text-size-line`}),children:this.fontSizes.map(e=>Rl(t,{text:e.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===e.size,disabled:()=>!this.setFontSize(e.size)(t.view.state),onSelect:()=>{let{state:n,dispatch:r}=t.view;this.setFontSize(e.size)(n,r)}}))})},2)]}getFontSizeFromSelection(e){let{from:t,to:n,$from:r,empty:i}=e.selection,{fontSize:a}=e.schema.marks;if(i){let t=this.defaultFontSizeForNode?.[r.parent.type.name]??null;return a.isInSet(e.storedMarks||r.marks())?.attrs.size??t}let o=null,s=e=>{o===null?o=e??null:e!==o&&(o=_u)};return e.doc.nodesBetween(t,n,(e,t,n)=>o===_u?!1:e.isLeaf?(s(a.isInSet(e.marks)?.attrs.size??(n&&this.defaultFontSizeForNode?.[n.type.name])),!0):(e.type.allowsMarkType(a)&&e.childCount===0&&s(this.defaultFontSizeForNode?.[e.type.name]),!0)),o}setFontSize(e){return(t,n)=>{let{from:r,to:i,empty:a,$from:o}=t.selection,{fontSize:s}=t.schema.marks;if(!Ao(s,{size:e})(t))return!1;let c=t.tr;if(a){let n=(t.storedMarks||[]).filter(e=>e.type!==s);e!==this.defaultFontSizeForNode?.[o.parent.type.name]&&n.push(s.create({size:e})),c.setStoredMarks(n)}else c.addMark(r,i,s.create({size:e})),c.doc.nodesBetween(r,i,(e,t,n)=>{if(!e.isInline)return;let r=s.isInSet(e.marks),i=this.defaultFontSizeForNode?.[n.type.name];r&&r.attrs.size===i&&c.step(new Se(t,t+e.nodeSize,r))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{let r=this.getFontSizeFromSelection(t);if(r===null||r===_u)return!1;let i=this.fontSizes.findIndex(e=>e.size===r)+e;return i<0||i>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[i].size)(t,n)}}},yu=_.a(vu),bu=[`p`,0],xu=[`blockquote`,0],Su=[`hr`],Cu=[`pre`,[`code`,0]],wu=[`br`],Tu={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return bu}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return xu}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return Su}},heading:{attrs:{level:{default:1,validate:`number`}},content:`inline*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}},{tag:`h4`,attrs:{level:4}},{tag:`h5`,attrs:{level:5}},{tag:`h6`,attrs:{level:6}}],toDOM(e){return[`h`+ +e.attrs.level,0]}},code_block:{content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`}],toDOM(){return Cu}},text:{group:`inline`},image:{inline:!0,attrs:{src:{validate:`string`},alt:{default:null,validate:`string|null`},title:{default:null,validate:`string|null`}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){let{src:t,alt:n,title:r}=e.attrs;return[`img`,{src:t,alt:n,title:r}]}},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return wu}}},Eu=[`em`,0],Du=[`strong`,0],Ou=[`code`,0],ku={link:{attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){let{href:t,title:n}=e.attrs;return[`a`,{href:t,title:n},0]}},em:{parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name==`em`}],toDOM(){return Eu}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return Du}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return Ou}}};new _._({nodes:Tu,marks:ku});var Au=class extends _.r{constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}},ju=class extends Au{constructor(...e){super(...e),this.name=`RteBoldFeature`,this.markName=`bold`}getSchema(){return[this.contribution({marks:{bold:ku.strong}})]}getPlugins(e){return[this.contribution(W({"Mod-b":Ao(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.bold,dynamicIcon:`bold`,markType:e.schema.marks.bold})},1)]}},Mu=_.a(ju),Nu=class extends Au{constructor(...e){super(...e),this.name=`RteItalicFeature`,this.markName=`italic`}getSchema(){return[this.contribution({marks:{italic:ku.em}})]}getPlugins(e){return[this.contribution(W({"Mod-i":Ao(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.italic,dynamicIcon:`italic`,markType:e.schema.marks.italic})},2)]}},Pu=_.a(Nu),Fu=class extends Au{constructor(...e){super(...e),this.name=`RteUnderlineFeature`,this.markName=`underline`}getSchema(){return[this.contribution({marks:{underline:{parseDOM:[{tag:`u`}],toDOM(){return[`u`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Mod-u":Ao(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.underline,dynamicIcon:`underline`,markType:e.schema.marks.underline})},3)]}},Iu=_.a(Fu),Lu=class extends Au{constructor(...e){super(...e),this.name=`RteStrikethroughFeature`,this.markName=`strikethrough`}getSchema(){return[this.contribution({marks:{strikethrough:{parseDOM:[{tag:`s`},{tag:`del`}],toDOM(){return[`s`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Alt-Shift-5":Ao(e.schema.marks.strikethrough),"Cmd-Shift-X":Ao(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,dynamicIcon:`strikethrough`,markType:e.schema.marks.strikethrough})},4)]}},Ru=_.a(Lu),zu=`tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}`,Bu=class extends Au{constructor(...e){super(...e),this.name=`RteMonospaceFeature`,this.markName=`monospace`}getStyles(){return[this.contribution(zu)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:`tt`},{tag:`code`}],toDOM(){return[`tt`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Mod-M":Ao(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,dynamicIcon:`monospace`,markType:e.schema.marks.monospace})},5)]}},Vu=_.a(Bu),Hu=e=>{let t=document.createElement(`div`);return t.style.color=e,t.style.color||null};function Uu(e,t,n){for(let r=0;r<t.length;r++){let{$from:i,$to:a}=t[r],o=i.depth==0&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,a.pos,e=>!o&&(o=e.inlineContent&&e.type.allowsMarkType(n),!0)),o)return!0}return!1}var Wu=Symbol(`mixedColor`),Gu=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteTextColorPicker`,e?.onBlocks){this.defaultColorForNode={};for(let t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`textColor`,onNodeName:e.node})):[this.contribution({markName:`textColor`})]}getSchema(){let e=e=>{let t=this.config?.parseColorFromHtml?this.config.parseColorFromHtml(e):e;return t!==null&&{color:t}};return[this.contribution({marks:{textColor:{attrs:{color:{validate:`string`}},parseDOM:[{tag:`span[data-text-color]`,getAttrs:t=>e(t.getAttribute(`data-text-color`))},{style:`color`,getAttrs:t=>e(t)}],toDOM(e){let{color:t}=e.attrs;return[`span`,{style:`color: ${Hc(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:`text-style`,render:e=>{let t=$(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor(`any`)(e.view.state),icon:`textcolor-line`}),n=t.firstElementChild;return Nl(e,{children:[t,ql(e,{name:`text-color-picker`,assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||``},assignedEvents:{change:t=>{let n=t.currentTarget.value;this.setColor(n)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){let{selection:t}=e,{textColor:n}=e.schema.marks,{from:r,to:i,$from:a,empty:o}=t;if(o){let t=this.defaultColorForNode?.[a.parent.type.name]??null;return n.isInSet(e.storedMarks||a.marks())?.attrs.color??t}let s=null,c=e=>{s===null?s=e??null:e!==s&&(s=Wu)};return e.doc.nodesBetween(r,i,(e,t,r)=>s===Wu?!1:e.isLeaf?(c(n.isInSet(e.marks)?.attrs.color??(r&&this.defaultColorForNode?.[r.type.name])),!0):(e.type.allowsMarkType(n)&&e.childCount===0&&c(this.defaultColorForNode?.[e.type.name]),!0)),s===Wu?null:s}setColor(e){return(t,n)=>{let{textColor:r}=t.schema.marks,{from:i,to:a,empty:o,$from:s}=t.selection;if(!Uu(t.doc,t.selection.ranges,r))return!1;let c=t.tr;if(o){let n=(t.storedMarks||[]).filter(e=>e.type!==r);e!==this.defaultColorForNode?.[s.parent.type.name]&&n.push(r.create({color:e})),c.setStoredMarks(n)}else c.addMark(i,a,r.create({color:e})),c.doc.nodesBetween(i,a,(e,t,n)=>{if(!e.isInline)return;let i=r.isInSet(e.marks),a=this.defaultColorForNode?.[n.type.name];i&&i.attrs.color===a&&c.step(new Se(t,t+e.nodeSize,i))});return n?.(c.scrollIntoView()),!0}}},Ku=Object.assign(_.a(Gu),{normalizeCssColor:Hu}),qu=`.rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}`,Ju=e=>e.parentOffset===0,Yu=e=>e.nodeSize===2,Xu=e=>e.depth-1,Zu=e=>e.depth-2,Qu=e=>e.parent,$u=e=>e.node(Xu(e)),ed=e=>e.depth>2,td=(e,t)=>e.index(t)===0,nd=(e,t)=>e.index(t)===e.node(t).childCount-1,rd=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r-1)},id=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r+1)},ad=e=>{let{$from:t,$to:n}=e;if(e instanceof A){let r=D.between(e.$from,e.$to);t=r.$from,n=r.$to}return{$from:t,$to:n}},od=(e,t)=>e.sameParent(t)?e.node(-1):e.node(e.sharedDepth(t.pos)),sd=e=>{let{$cursor:t}=e.selection;return t?.parent.type===e.schema.nodes.listItem?t:null},cd=(e,t,n,r)=>{let i,a=!0;return e.doc.nodesBetween(t.pos,n.pos,t=>{t.type.isInGroup(`list`)&&(i=t.type),t.type===e.schema.nodes.listItem&&i!==r&&(a=!1)}),a},ld=(e,t,n)=>ed(t)?(ud(t,n),!0):dd(e,t,n),ud=(e,t)=>{let n=new _.h(e.doc.resolve(e.before()),e.doc.resolve(e.after()),e.depth-1);t.lift(n,e.depth-2)},dd=(e,t,n)=>{let r=$u(t),i=t.index(Zu(t)),a=Qo(t.node(Zu(t)).contentMatchAt(i+1));if(!a)return!1;let o=td(t,Xu(t)),s=nd(t,Xu(t));return n.step(new w(t.before()-+!!o,t.after()+ +!!s,t.start(),t.end(),new _.v((o?_.d.empty:_.d.from(r.copy(_.d.empty))).append(_.d.from(a.create(e.textblockAttrs.extractFromNode(Qu(t))))).append(s?_.d.empty:_.d.from(r.copy(_.d.empty))),+!o,+!s),+!o+1)),!0},fd=(e,t,n,r)=>{n.parent.type===e.schema.nodes.listItem?pd(t,n,r):md(e,t,n,r)},pd=(e,t,n)=>{let r=rd(t,Xu(t))?.type===e,i=id(t,Xu(t))?.type===e,a=+!!r,o=+!!i;n.step(new w(t.before()-+!!r,t.after()+ +!!i,t.before(),t.after(),new _.v(_.d.from(e.create(null,[])),a,o),1-a))},md=(e,t,n,r)=>{r.step(new w(n.before(),n.after(),n.start(),n.end(),new _.v(_.d.from(t.create(null,[e.schema.nodes.listItem.create(e.textblockAttrs.extractFromNode(n.parent))])),0,0),2))},hd=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteListFeature`,!e.bulletList&&!e.numberedList)throw Error(`RteListFeature requires at least one of bulletList or numberedList to be enabled`)}getStyles(){return[this.contribution(qu)]}getSchema(e){return[this.contribution({nodes:{listItem:{content:`inline*`,attrs:e.attrs,defining:!0,parseDOM:[{tag:`li`,getAttrs:t=>e.fromDOM(t)}],toDOM(t){return[`li`,...e.getDOMAttrs(t),0]}},...this.config.bulletList?{bulletList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}}}:{},...this.config.numberedList?{numberedList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ol`}],toDOM(){return[`ol`,0]}}}:{}}})]}getPlugins(e){return this.rte=e,[this.contribution(W({Enter:(e,t)=>{let n=sd(e);if(n&&Yu(Qu(n))){let r=e.tr;return ld(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Backspace:(e,t)=>{let n=sd(e);if(n&&Ju(n)){if(td(n,Xu(n))&&rd(n,Zu(n))?.type===$u(n).type)return!1;let r=e.tr;return ld(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Tab:(e,t)=>{let n=sd(e);if(n&&Ju(n)){let r=e.tr;return pd($u(n).type,n,r),t?.(r.scrollIntoView()),!0}return!1},"Shift-Tab":(e,t)=>{let n=sd(e);if(n&&Ju(n)&&ed(n)){let r=e.tr;return ud(n,r),t?.(r.scrollIntoView()),!0}return!1},...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),_.i.high)]}getToolbarItems(e){let t=[];return this.config.bulletList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.bulletList,dynamicIcon:`bullet-list-2`,active:()=>this.isSelectionInList(e.schema.nodes.bulletList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.bulletList)(n,r)}})},1)),this.config.numberedList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.numberedList,dynamicIcon:`list-numbered`,active:()=>this.isSelectionInList(e.schema.nodes.numberedList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.numberedList)(n,r)}})},2)),t}toggleList(e){return Mo((t,n)=>{let{$from:r,$to:i}=ad(t.selection);if(od(r,i).type.isInGroup(`list`)){if(cd(t,r,i,e)){let e=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(n,r)=>{if(n.type===t.schema.nodes.listItem){let t=e.doc.resolve(e.mapping.map(r+1));ld(this.rte,t,e)}}),n?.(e.scrollIntoView()),!0}{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{t.type.isInGroup(`list`)&&t.type!==e&&a.setNodeMarkup(n,e,t.attrs)}),n?.(a.scrollIntoView()),!0}}{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{if(!t.isTextblock)return;let r=a.doc.resolve(a.mapping.map(n+1));fd(this.rte,e,r,a)}),n?.(a.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){let{$from:n,$to:r}=ad(t.selection);return od(n,r).type.isInGroup(`list`)?cd(t,n,r,e):!1}},gd=_.a(hd),_d=[{value:`left`,icon:`align-left`,label:`left`},{value:`center`,icon:`align-center`,label:`center`},{value:`right`,icon:`align-right`,label:`right`}],vd=e=>_d.find(t=>t.value===e)?.value??`left`,yd=class extends _.r{constructor(...e){super(...e),this.name=`RteAlignmentFeature`}getTextblockAttrs(){return[this.contribution({name:`textAlign`,default:`left`,fromDOM(e){return vd(e.style.textAlign)},toStyles(e){return[`text-align: ${vd(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(W({"Mod-L":this.setAlignment(`left`),"Mod-E":this.setAlignment(`center`),"Mod-R":this.setAlignment(`right`)}))]}getToolbarItems(){return[this.contribution({section:`textblock`,render:e=>Ll(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:$(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{let t=this.getAlignmentFromSelection(e.view.state);return`${_d.find(e=>e.value===t)?.icon??`align-left`}-line`}}),children:[zl(e,{slot:`header`,children:_d.map((t,n)=>$(e,{dynamicIcon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],noTooltip:!0,variant:`toolbar-menu`,autofocus:()=>{let r=this.getAlignmentFromSelection(e.view.state);return(r===`mixed`||r===null)&&n===0||t.value===r},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{let{state:n,dispatch:r}=e.view;this.setAlignment(t.value)(n,r)}}))})]})},3)]}getAlignmentFromSelection(e){let{selection:t}=e,{from:n,to:r}=t,i=null;return e.doc.nodesBetween(n,r,e=>{i!==`mixed`&&e.type.isTextblock&&(i?i!==e.attrs.textAlign&&(i=`mixed`):i=e.attrs.textAlign)}),i}setAlignment(e){return(t,n)=>{let{tr:r,selection:i}=t,{from:a,to:o}=i;return t.doc.nodesBetween(a,o,(t,n)=>{t.type.isTextblock&&r.setNodeMarkup(n,t.type,{...t.attrs,textAlign:e})}),t.storedMarks&&r.setStoredMarks(t.storedMarks),n?.(r.scrollIntoView()),!0}}},bd=_.a(yd),xd=`.link-popover{flex-direction:column;gap:8px;inline-size:450px;padding:16px;display:flex}.link-popover-header{justify-content:space-between;align-items:center;display:flex}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{flex-direction:column;gap:16px;display:flex}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{justify-content:end;gap:8px;display:flex}.link-toolbar-menu{flex-direction:column;gap:16px;inline-size:368px;padding:8px;display:flex}`,Sd=`(?:https?://|www\\.)[^\\s<]+`;function Cd(e,t,n,r){if(e.doc.rangeHasMark(n,n+1,e.schema.marks.link))return null;let i=t.replace(/[.,;:!?) ]+$/,``),a=i.startsWith(`www.`)?`https://${i}`:i,o=e.schema.marks.link.create({href:a}),s=n+i.length,c=t.slice(i.length),l=e.tr.addMark(n,s,o);return c&&l.replaceWith(s,r,e.schema.text(c)),l}var wd=class extends _.r{constructor(...e){super(...e),this.name=`RteLinkFeature`,this.removeLink=(e,t)=>{let n=e.tr,r=this.getCurrentLink(e);return n.removeMark(r.start,r.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(xd)]}getSchema(){return[this.contribution({marks:{link:{attrs:{href:{validate:`string`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`)}}}],toDOM(e){let{href:t}=e.attrs;return[`a`,{href:Lc(t)},0]}}}},_.i.high)]}getTextblockMarks(){return[this.contribution({markName:`link`})]}getInputRules(){let e=RegExp(`${Sd}$`);return[this.contribution({rule:new Zl(RegExp(`${Sd} $`),(e,t,n,r)=>Cd(e,t[0],n,r)),enterHandler:{regex:e,handler:(e,t,n,r)=>Cd(e,t[0],n,r)}})]}getPlugins(e){let t=()=>(this.toolbarMenu.open=!0,!0),n;return[this.contribution(new j({props:{decorations:e=>{let t=this.getCurrentLink(e);if(t){let n=B.inline(t.start,t.end,{id:`current-link`});return V.create(e.doc,[n])}return null}},view:t=>{let r=new Ml(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});n=e.createComponent(b),n.anchorId=`current-link`;let i=Nl(r,{className:`link-popover`,children:[Nl(r,{className:`link-popover-header`,children:[Nl(r,{className:`link-popover-label`,children:[Kl(r,{text:()=>this.getCurrentLink(r.view.state)?.text||``})]}),$(r,{icon:`close-line`,label:()=>r.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{n.dismiss()}})]}),Nl(r,{className:`link-popover-content`,children:[Pl(r,{className:`link`,href:()=>this.getCurrentLink(r.view.state)?.href||``,target:`_blank`,rel:`noopener`,children:[Kl(r,{text:()=>this.getCurrentLink(r.view.state)?.href||``})]}),Nl(r,{className:`link-action-bar`,children:[$(r,{icon:`delete-line`,label:()=>r.rte.getLocale().richTextEditor.delete,connotation:`alert`,variant:`popover`,noTooltip:!0,onClick:()=>{let{state:e,dispatch:t}=r.view;this.removeLink(e,t)}}),$(r,{icon:`edit-line`,label:()=>r.rte.getLocale().richTextEditor.edit,variant:`popover`,noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,n.requestOpenState(!1),!0)})]})]})]});return n.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(n),{update:e=>{let t=e.state;r.updateBindings();let i=this.getCurrentLink(t);n.requestOpenState(!!i)},destroy:()=>{n.remove()}}}})),this.contribution(W({Escape:e=>this.getCurrentLink(e)?(n?.dismiss(),!0):!1,"Mod-k":t}))]}getToolbarItems(e){let t=e=>{let{from:t,to:n}=e.selection;return t===n?``:e.doc.textBetween(t,n,` `)};return[this.contribution({section:`insert`,render:n=>{let r=Gl(n,{label:()=>n.rte.getLocale().richTextEditor.linkText,placeholder:()=>n.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:`header`,autofocus:!0,value:()=>this.getCurrentLink(n.view.state)?.text||t(n.view.state)||``,onInput:()=>{s()}}),i=Gl(n,{label:()=>n.rte.getLocale().richTextEditor.linkUrl,type:`url`,placeholder:()=>n.rte.getLocale().richTextEditor.linkUrlPlaceholder,helperText:()=>n.rte.getLocale().richTextEditor.linkUrlHelperText,slot:`header`,value:()=>this.getCurrentLink(n.view.state)?.href||``,onInput:()=>{s()}}),a=()=>!(r.value.length&&Bc(i.value)),o=$(n,{label:()=>n.rte.getLocale().richTextEditor.apply,variant:`popover-primary`,disabled:a,onClick:()=>{let{state:t,dispatch:a}=n.view;this.insertLink(e,i.value,r.value)(t,a),this.toolbarMenu.open=!1}}),s=()=>{o.querySelector(`[data-vvd-component="button"]`).disabled=a()},c=Ll(n,{label:()=>n.rte.getLocale().richTextEditor.hyperlink,trigger:$(n,{label:()=>n.rte.getLocale().richTextEditor.hyperlink,icon:`link-line`}),children:[Nl(n,{className:`link-toolbar-menu`,slot:`header`,children:[r,i,Nl(n,{className:`link-action-bar`,slot:`header`,children:[$(n,{label:()=>n.rte.getLocale().richTextEditor.cancel,variant:`popover`,onClick:()=>{this.toolbarMenu.open=!1}}),o]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){let t=e.selection;if(!(t instanceof D))return null;let n=e.schema.marks.link,{$from:r,$to:i}=t,a=e.selection.empty?r.marks():r.nodeAfter?.marks??[],o=n.isInSet(a)?.attrs.href;if(!o)return null;let s=e=>n.isInSet(e.marks)?.attrs.href===o,c=null,l=[];e.doc.nodesBetween(r.start(),i.end(),(e,t)=>{if(!e.isText)return!0;let n=t+e.nodeSize;return s(e)?c?c.end=n:(c={start:t,end:n},l.push(c)):c=null,!1});let u=l.find(e=>e.start<=t.from&&e.end>=t.to);return u?{text:e.doc.textBetween(u.start,u.end,` `),href:o,start:u.start,end:u.end}:null}insertLink(e,t,n){return(r,i)=>{let{from:a,to:o}=r.selection,s=r.tr,c=this.getCurrentLink(r);return c&&(a=c.start,o=c.end),s.insertText(n,a,o),s.addMark(a,a+n.length,e.schema.marks.link.create({href:t})),i?.(s.scrollIntoView()),!0}}},Td=_.a(wd),Ed=`.inline-image-wrapper{vertical-align:text-bottom;display:inline-block}.inline-image{block-size:auto;display:block}.inline-image-popover{align-items:center;gap:4px;padding:8px;display:flex}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}`,Dd=e=>e!==null&&!!e.next,Od=1,kd=()=>Od++,Ad=class{constructor(e,t,n,r){this.view=t,this.getPos=n,this.config=r,this.content=null,this.dom=document.createElement(`div`),this.dom.className=`inline-image-wrapper`,this.imageUrl=e.attrs.imageUrl,this.img=document.createElement(`img`),this.initializeImg(e);let i=this.config.resolveUrl?this.config.resolveUrl(this.imageUrl):this.imageUrl,a=Dd(i)?null:i;this.handleResolvedUrl(a),Dd(i)&&this.handleResolvedUrlGenerator(i)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),b.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){let t=e[Symbol.asyncIterator](),n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e==`string`)this.renderImg(e);else if(e?.type===`placeholder`){let t=`inline-image-placeholder-${kd()}`,n=document.createElement(`slot`);n.className=`inline-image-placeholder`,n.name=t;let r=e.create?.(t),i=this.view.dom.getRootNode().host;_.t(i,`inline-image-placeholder`,t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{_.t(i,`inline-image-placeholder`,t,_.n),r?.()}})}else this.setContent(null)}initializeImg(e){this.img.className=`inline-image`,this.update(e),this.img.addEventListener(`load`,()=>{let e=this.getPos();if(e){let{state:t,dispatch:n}=this.view,r=t.doc.nodeAt(e);if(!r||r.attrs.naturalWidth===this.img.naturalWidth&&r.attrs.naturalHeight===this.img.naturalHeight)return;let i=t.tr;i.setNodeAttribute(e,`naturalWidth`,this.img.naturalWidth),i.setNodeAttribute(e,`naturalHeight`,this.img.naturalHeight),i.setMeta(`addToHistory`,!1),n(i)}})}renderImg(e){this.img.src=Vc(e),this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}},jd=class extends _.r{constructor(e={}){super(),this.config=e,this.name=`RteInlineImageFeature`}getStyles(){return[this.contribution(Ed)]}getSchema(){return[this.contribution({nodes:{inlineImage:{inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{imageUrl:{validate:`string`},alt:{validate:`string`,default:``},size:{validate:`string|null`,default:null},naturalWidth:{validate:`number|null`,default:null},naturalHeight:{validate:`number|null`,default:null}},parseDOM:[{tag:`img[src],img[data-src]`,getAttrs:e=>{let t=e=>{let t=parseInt(e??``,10);return isNaN(t)?null:t},n=e.getAttribute(`data-src`)??e.getAttribute(`src`),r=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(n):n;return r!==null&&{imageUrl:r,alt:e.getAttribute(`alt`)||``,size:this.config.parseSizeFromHtml?this.config.parseSizeFromHtml(e):e.style.maxWidth||null,naturalWidth:t(e.getAttribute(`width`)),naturalHeight:t(e.getAttribute(`height`))}}}],toDOM:e=>{let{imageUrl:t,alt:n,size:r,naturalWidth:i,naturalHeight:a}=e.attrs,o=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(t):t;if(o===null)return document.createTextNode(``);let s={src:Vc(o),"data-src":o,alt:n};return r&&(s.style=`max-width: ${Hc(r)}; height: auto;`),i&&(s.width=i),a&&(s.height=a),[`img`,s]}}}})]}getPlugins(e){let t;return[this.contribution(new j({props:{nodeViews:{inlineImage:(e,t,n)=>new Ad(e,t,n,this.config)}},view:n=>{let r=new Ml(n,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});t=e.createComponent(b),t.kind=`imageOptions`,t.offset=4;let i=Nl(r,{className:`inline-image-popover`,children:[$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.small,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`small`,onClick:()=>{this.setSelectedImageSize(`small`)(r.view.state,r.view.dispatch)}}),Wl(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.fit,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`fit`,onClick:()=>{this.setSelectedImageSize(`fit`)(r.view.state,r.view.dispatch)}}),Wl(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.original,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`original`,onClick:()=>{this.setSelectedImageSize(`original`)(r.view.state,r.view.dispatch)}})]});return t.appendChild(i),n.dom.getRootNode().querySelector(`.popovers`).appendChild(t),{update:e=>{r.updateBindings();let n=this.getSelectedInlineImage(e.state);n?(t.anchorEl=e.nodeDOM(n.pos),t.requestOpenState(!0)):(t.anchorEl=void 0,t.requestOpenState(!1))},destroy:()=>{t.remove()}}}})),this.contribution(W({Escape:e=>this.getSelectedInlineImage(e)?(t?.dismiss(),!0):!1}))]}calculateSmallWidth(e){return`${Math.min(300,e/2)}px`}getSelectedInlineImage(e){let t=e.selection;return t instanceof k&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{let r=this.getSelectedInlineImage(t);if(!r)return!1;let{naturalWidth:i}=r.node.attrs;if(e===`small`&&i===null)return!1;let a=t.tr;return a.setNodeAttribute(r.pos,`size`,e===`small`?this.calculateSmallWidth(i):e===`fit`?`100%`:null),n?.(a.scrollIntoView()),!0}}getSelectedImageSize(e){let t=this.getSelectedInlineImage(e);if(!t)return null;let{size:n,naturalWidth:r}=t.node.attrs;return r!==null&&n===this.calculateSmallWidth(r)?`small`:n===`100%`?`fit`:n===null?`original`:null}},Md=_.a(jd),Nd=async e=>{try{return{type:`ok`,result:await e}}catch(e){return{type:`error`,error:e}}},Pd=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteFileHandlerFeature`}getPlugins(e){let t=new j({state:{init(){return V.empty},apply(e,n){n=n.map(e.mapping,e.doc);let r=e.getMeta(t);if(r&&r.add){let t=document.createElement(`placeholder`),i=B.widget(r.add.pos,t,{id:r.add.id,relaxedSide:!0});n=n.add(e.doc,[i])}else r&&r.remove&&(n=n.remove(n.find(void 0,void 0,e=>e.id==r.remove.id)));return n}},props:{decorations(e){return this.getState(e)}}}),n=(e,n)=>{let r=u.n();return e.setMeta(t,{add:{id:r,pos:n}}),{getPos:e=>{let n=t.getState(e).find(void 0,void 0,e=>e.id==r);return n.length?n[0].from:null},remove:e=>{e.setMeta(t,{remove:{id:r}})}}},r=(t,n,r)=>{if(r.type===`selection`){let r=_.v.fromJSON(e.schema,{content:n});t.replaceSelection(r)}else{let i=_.d.fromJSON(e.schema,n);t.insert(r.pos,i)}},i=(e,t)=>{let n=this.config.handleFiles(e);n!==null&&(n instanceof Promise?o(n,t):a(n,t))},a=(t,n)=>{let i=e.state.tr;r(i,t,n),e.dispatchTransaction(i)},o=async(t,i)=>{let a=e.state.tr;i.type===`selection`&&!a.selection.empty&&a.deleteSelection();let o=i.type===`selection`?a.selection.from:i.pos,s=n(a,o);e.dispatchTransaction(a);let c=await Nd(t),l=s.getPos(e.state),u=e.state.tr;s.remove(u),l!==null&&c.type===`ok`&&r(u,c.result,{type:`pos`,pos:l}),e.dispatchTransaction(u),c.type===`error`&&console.error(`Error in handleFiles handler:`,c.error)};return[this.contribution(t),this.contribution(new j({props:{handlePaste:(e,t)=>{let n=Array.from(t.clipboardData.files);return n.length?(i(n,{type:`selection`}),!0):!1},handleDrop:(e,t)=>{let n=Array.from(t.dataTransfer.files);if(!n.length)return!1;let r=e.posAtCoords({left:t.clientX,top:t.clientY}).pos;if(e.dragging&&e.dragging.slice){let t=Ge(e.state.doc,r,e.dragging.slice);t!=null&&(r=t)}return i(n,{type:`pos`,pos:r}),!0}}}))]}},Fd=_.a(Pd),Id=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteDebugFeature`}getPlugins(){let e=new WeakMap,t=!1,n=n=>{e.get(n)===void 0&&(t=this.config.onViewportDragOver?.(n)??!1)},r=e=>{this.config.onViewportDrop?.(e),this.config.onViewportDragFinish?.()},i=()=>{this.config.onViewportDragFinish?.()},a=!1,o=()=>{a=!0,window.setTimeout(()=>a=!1,0)},s=()=>{a||this.config.onViewportDragFinish?.()};return[this.contribution(new j({view:e=>{let t=e.root.host.editorViewportElement;return t.addEventListener(`dragover`,n),t.addEventListener(`drop`,r),t.addEventListener(`dragend`,i),t.addEventListener(`dragenter`,o),t.addEventListener(`dragleave`,s),{destroy(){t.removeEventListener(`dragover`,n),t.removeEventListener(`drop`,r),t.removeEventListener(`dragend`,i),t.removeEventListener(`dragenter`,o),t.removeEventListener(`dragleave`,s)}}}})),this.contribution(new j({props:{handleDOMEvents:{dragover:(n,r)=>{let i=this.config.onViewportDragOver?.(r)??!1;return e.set(r,i),t=i,i?(r.stopImmediatePropagation(),r.preventDefault(),!0):!1},drop:()=>t}}}),_.i.high)]}},Ld=_.a(Id),Rd=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:`insert`,render:e=>$(e,{label:this.options.label,icon:this.options.icon,onClick:()=>{this.executeAction(e)}})},2+(this.options.order??0)/(2**53-1))]}executeAction(e){let{action:t}=this.options;switch(t.type){case`insert-text`:{let{state:n,dispatch:r}=e.view,{from:i,to:a}=n.selection;r(n.tr.insertText(t.text,i,a));break}}}},zd=_.a(Rd),Bd=e=>typeof e==`object`&&!!e&&`next`in e,Vd=/^[a-zA-Z0-9-]+$/,Hd=e=>e==null?{text:``,variant:[]}:typeof e==`string`?{text:e,variant:[]}:{text:e.text,variant:(e.variant??[]).filter(e=>Vd.test(e)?!0:(console.warn(`[rich-text-editor] Ignoring invalid atom variant "${e}".`),!1))},Ud=(e,t)=>[`node--${e}`,...t.map(e=>`atom-variant--${e}`)].join(` `),Wd=class{constructor(e,t,n){this.atomName=n,this.dom=document.createElement(`span`),this.dom.className=`atom-wrapper`;let r=t.resolveValue?t.resolveValue(e.attrs.value):e.attrs.value;Bd(r)?(this.render(null),this.handleResolvedGenerator(r)):this.render(r)}render(e){let{text:t,variant:n}=Hd(e);this.dom.textContent!==t&&(this.dom.textContent=t);let r=Ud(this.atomName,n);this.dom.getAttribute(`part`)!==r&&this.dom.setAttribute(`part`,r)}async handleResolvedGenerator(e){let t=e[Symbol.asyncIterator]();try{let e;do e=await t.next(),this.render(e.value??null);while(!e.done)}catch(e){this.render(null),console.warn(`[rich-text-editor] Error while resolving atom value:`,e)}}},Gd=class extends _.r{constructor(e,t={}){super(),this.atomName=e,this.config=t,this.name=`RteAtomFeature[${e}]`}getSchema(){let e={inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{value:{validate:`string`}},parseDOM:[{tag:`span[data-atom-type="${this.atomName}"][data-value]`,getAttrs:e=>({value:e.getAttribute(`data-value`)})}],toDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createDocumentFragment():[`span`,{part:Ud(this.atomName,[])},t]},serializeToDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createTextNode(``):[`span`,{"data-atom-type":this.atomName,"data-value":e.attrs.value},t]}};return[this.contribution({nodes:{[this.atomName]:e}})]}getPlugins(e){return[this.contribution(new j({props:{nodeViews:{[this.atomName]:e=>new Wd(e,this.config,this.atomName)}}}))]}},Kd=_.a(Gd),qd=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteInputRuleFeature[${e}]`}getInputRules(e){let t=`(?:${this.options.pattern.source})`,n=(t,n,r,i)=>{let a=this.options.handler(n);return a?t.tr.replaceWith(r,i,_.d.fromJSON(e.schema,a)):null},r={rule:new Zl(this.options.matchAfterWhitespace?RegExp(`${t} $`):RegExp(`${t}$`),n)};return this.options.matchAfterWhitespace&&(r.enterHandler={regex:RegExp(`${t}$`),handler:n}),[this.contribution(r)]}},Jd=_.a(qd);function Yd(e,t){return(n,r)=>e(t)}var Xd=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteKeyboardShortcutsFeature[${e}]`}getPlugins(e){let t={};for(let[n,r]of Object.entries(this.options.shortcuts))t[n]=Yd(r,e.facade);return[this.contribution(W(t),_.i.high)]}},Zd=_.a(Xd),Qd=`.suggest-popover{flex-direction:column;gap:2px;max-block-size:408px;min-inline-size:128px;max-inline-size:248px;padding:4px;display:flex}.suggest-loading-widget{vertical-align:middle;white-space:normal;align-items:center;margin-inline-start:2px;display:inline-flex}.suggest-empty-message{color:var(--vvd-color-neutral-300);font:var(--vvd-typography-base);text-align:center;justify-content:center;align-items:center;min-block-size:40px;display:flex}`,$d=e=>`suggestions`in e,ef=e=>!(!e?.suggestions||e.dismissed),tf=e=>ef(e)&&e.suggestions.items.length>0;function nf(e,t){let{$cursor:n}=e.selection;if(!n)return null;let r=ru(n),i=t.exec(r);if(!i)return null;let a=n.pos-n.parentOffset;return{text:i[0],groups:[...i],start:a+i.index,end:a+i.index+i[0].length}}var rf=(e,t,n)=>{let{state:r}=e;e.dispatch(Cl(r.tr));let i=e.state.tr;i.replaceWith(t.start,t.end,_.d.fromJSON(e.state.schema,n));let a=i.mapping.map(t.end);i.setSelection(D.create(i.doc,a)),e.dispatch(i.scrollIntoView())},af=class extends _.r{selectSuggestion(e,t,n){let r=this.options.select(n);rf(e,t.match,r),e.focus()}async startLoadingSuggestions(e,t){let n=++this.loadGeneration,r=await this.options.load(e);n===this.loadGeneration&&t({type:`load`,generation:n,entries:r})}constructor(e,t){super(),this.featureId=e,this.options=t,this.pluginKey=new Mt(`suggest`),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}getStyles(){return[this.contribution(Qd)]}getPlugins(e){let t=t=>e.state.tr.setMeta(this.pluginKey,t),n=n=>e.dispatchTransaction(t(n)),r=new j({key:this.pluginKey,state:{init:()=>null,apply:(t,r,i,o)=>{let s=nf(o,this.options.pattern);if(!s||!r&&!t.docChanged)return null;if(r?.dismissed)return r;let c=n=>n?r?.loadingDecoration.find().length??0?r.loadingDecoration.map(t.mapping,t.doc):V.create(t.doc,[B.widget(s.end,()=>{let t=document.createElement(`span`);t.className=`suggest-loading-widget`;let n=e.createComponent(a.r);return n.size=-6,t.appendChild(n),t},{ignoreSelection:!0,side:1})]):V.empty,l=t.getMeta(this.pluginKey);if(r&&l)switch(l.type){case`load`:{let e=l.entries.filter(e=>!$d(e)||e.suggestions.length>0);return{...r,suggestions:{generation:l.generation,entries:e,items:e.flatMap(e=>$d(e)?e.suggestions:[e]),selectedIndex:0,visibleFocus:!1},loadingDecoration:c(!1)}}case`navigate`:{if(!r.suggestions?.items.length)return r;if(!r.suggestions.visibleFocus)return{...r,suggestions:{...r.suggestions,visibleFocus:!0}};let e=Math.max(0,Math.min(r.suggestions.items.length-1,r.suggestions.selectedIndex+(l.action===`up`?-1:1)));return{...r,suggestions:{...r.suggestions,selectedIndex:e}}}case`dismiss`:return{...r,dismissed:!0,loadingDecoration:V.empty}}if(!r)return this.startLoadingSuggestions(s.groups,n),{match:s,loadingDecoration:c(!0)};let u=s.groups[0]!==r.match.groups[0];return u&&this.startLoadingSuggestions(s.groups,n),{...r,match:s,suggestions:r.suggestions?{...r.suggestions,visibleFocus:!1}:void 0,loadingDecoration:c(u)}}},props:{decorations:e=>{let t=this.pluginKey.getState(e);return t?t.loadingDecoration.add(e.doc,[B.inline(t.match.start,t.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:t=>{let n=new Ml(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0}),r=e.createComponent(b);r.anchorId=`suggest-anchor-${this.featureId}`,r.kind=`autocomplete`,r.offset=4;let i=Nl(n,{className:`suggest-popover`,children:[]});r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r);let a=`${this.featureId}-suggestions-empty`,o=t.dom.getRootNode().host,s=!1,c=e=>{!s&&e&&_.t(o,`suggestions-empty-state`,a,{id:this.featureId}),s&&!e&&_.t(o,`suggestions-empty-state`,a,_.n),s=e},l=r=>{i.innerHTML=``;let o=r.suggestions,s=o.items.length===0;if(c(s),s){let t=document.createElement(`slot`);t.name=a,t.textContent=e.getLocale().richTextEditor.suggestNoResults,i.appendChild(Nl(n,{className:`suggest-empty-message`,children:[t]}));return}let l=(n,i,a)=>{let s=e.createComponent(f.t);if(s.text=n.text,s.textSecondary=n.textSecondary,s.icon=n.icon,i===o.selectedIndex){s.selected=!0,o.visibleFocus&&(s._highlighted=!0);let e=a??s;queueMicrotask(()=>{e.scrollIntoView({block:`nearest`})})}return s.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this.selectSuggestion(t,r,n)}),s},u=0;for(let t of o.entries){if(!$d(t)){i.appendChild(l(t,u++));continue}let n=e.createComponent(m.t),r=document.createElement(`span`);r.slot=`label`,r.textContent=t.label,n.appendChild(r);for(let[e,r]of t.suggestions.entries())n.appendChild(l(r,u++,e===0?n:void 0));i.appendChild(n)}};return{update:e=>{n.updateBindings();let t=this.pluginKey.getState(e.state),i=ef(t);r.requestOpenState(i),i?l(t):c(!1)},destroy:()=>{c(!1),r.remove()}}}});return[this.contribution(r),this.contribution(W({ArrowUp:(e,n)=>tf(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`up`})),!0):!1,ArrowDown:(e,n)=>tf(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`down`})),!0):!1,Enter:(e,t,n)=>{let r=this.pluginKey.getState(e);if(!tf(r))return!1;let i=r.suggestions.items[r.suggestions.selectedIndex];return n&&this.selectSuggestion(n,r,i),!0},Escape:(e,n)=>ef(this.pluginKey.getState(e))?(n?.(t({type:`dismiss`})),!0):!1}),_.i.high)]}},of=_.a(af),sf=e=>e.textBetween(0,e.content.size,void 0,` `).length,cf=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteCharacterCountFeature`}getPlugins(){let e=this.config?.limit;return e===void 0?[]:[this.contribution(new j({filterTransaction:(t,n)=>{if(!t.docChanged)return!0;let r=sf(n.doc),i=sf(t.doc);if(i<=e)return!0;if(r>e)return i<=r;if(!t.getMeta(`paste`))return!1;let a=t.selection.$head.pos,o=a-(i-e),s=a;return t.deleteRange(o,s),sf(t.doc)<=e}}))]}getPublicInterface(e){let t=this.config?.limit;return{get characters(){return sf(e.state.doc)},get limit(){return t}}}},lf=_.a(cf),uf=t.u(`rich-text-editor`,ie,ae,[ee.t,g.n,p.t,h.t,s.t,l.n,ne.t,v.t,d.n,se,a.t],{styles:re,shadowOptions:{delegatesFocus:!0}});t.d(uf)(),exports.RteAlignmentFeature=bd,exports.RteAtomFeature=Kd,exports.RteBase=ou,exports.RteBoldFeature=Mu,exports.RteCharacterCountFeature=lf,exports.RteConfig=nl,exports.RteDropHandlerFeature=Ld,exports.RteFileHandlerFeature=Fd,exports.RteFontSizePickerFeature=yu,exports.RteHardBreakFeature=gu,exports.RteHtmlParser=Gc,exports.RteHtmlSerializer=Jc,exports.RteInlineImageFeature=Md,exports.RteInputRuleFeature=Jd,exports.RteItalicFeature=Pu,exports.RteKeyboardShortcutsFeature=Zd,exports.RteLinkFeature=Td,exports.RteListFeature=gd,exports.RteMonospaceFeature=Vu,exports.RtePlaceholderFeature=mu,exports.RteStrikethroughFeature=Ru,exports.RteSuggestFeature=of,exports.RteTextBlockPickerFeature=cu,exports.RteTextColorPickerFeature=Ku,exports.RteToolbarButtonFeature=zd,exports.RteToolbarFeature=du,exports.RteUnderlineFeature=Iu;
43
+ `+u),Ie&&(u=M(u)),y&&Ge?ue(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_t(e),ze=!0,Be=w,Ve=T},t.clearConfig=function(){k=null,ze=!1,Be=null,Ve=null,y=b,oe=``},t.isValidAttribute=function(e,t,n){k||_t({});let r=O(e),i=O(t);return Ht(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&J(x,e)&&As(x[e],t)},t.removeHook=function(e,t){if(J(x,e)){if(t!==void 0){let n=Os(x[e],t);return n===-1?void 0:js(x[e],n,1)[0]}return ks(x[e])}},t.removeHooks=function(e){J(x,e)&&(x[e]=[])},t.removeAllHooks=function(){x=Oc()},t}var Mc=jc(),Nc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Pc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Fc=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,Ic={ALLOWED_URI_REGEXP:Pc},Lc=e=>{if(!Nc.test(e.replace(Fc,``)))return``;let t=document.createElement(`a`);return t.setAttribute(`href`,e),Mc.sanitize(t,{RETURN_DOM:!0,...Ic}).querySelector(`a`).getAttribute(`href`)??``},Rc=e=>Lc(e)!==``,zc=/^(?:[/?#]|\.{1,2}\/)/,Bc=e=>{let t=e.trim();if(!t||!Rc(t))return!1;if(zc.test(t))return!0;try{return new URL(t),!0}catch{return!1}},Vc=e=>{let t=document.createElement(`img`);return t.setAttribute(`src`,e),Mc.sanitize(t,{RETURN_DOM:!0,...Ic}).querySelector(`img`).getAttribute(`src`)??``},Hc=e=>e.replace(/[;!].*/,``),Uc=e=>({...e}),Wc=e=>({nodes:Object.fromEntries(Object.keys(e.nodes).map(t=>[t,(e.nodes[t].spec.parseDOM??[]).map(Uc)])),marks:Object.fromEntries(Object.keys(e.marks).map(t=>[t,(e.marks[t].spec.parseDOM??[]).map(Uc)]))}),Gc=class{constructor(e,t){this[_.c]=new Kc(e[_.c],t)}parseDocument(e,t){return this[_.c].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[_.c].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){let n=Mc.sanitize(e,{RETURN_DOM:!0,...Ic}),r=document.createDocumentFragment();return r.appendChild(n),t?.modifyDom?.(r),r}},Kc=class{constructor(e,t){let n=Wc(e.schema);t?.modifyParseRules?.(n),this.parser=qc(e.schema,n)}transform(e){return Mc.sanitize(e)}},qc=(e,{marks:t,nodes:n})=>{let r=[],i=e=>e.priority??50;function a(e){let t=0;for(;t<r.length;t++){let n=r[t];if(i(n)<i(e))break}r.splice(t,0,e)}for(let e in t)t[e]?.forEach(t=>{a(t=Uc(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)});for(let e in n)n[e]?.forEach(t=>{a(t=Uc(t)),t.node||t.ignore||t.mark||(t.node=e)});return r.push({tag:`br`,closeParent:!0}),new _.l(e,r)},Jc=class{constructor(e,t){this[_.c]=new Yc(e[_.c],t)}serializeDocument(e,t){return this[_.c].serializeFragment(e.content,t)}serializeFragment(e,t){return this[_.c].serializeFragment(e,t)}},Yc=class e{constructor(t,n){this.config=t;let r=e.domSerializersFromSchema(t.schema);Object.assign(r.nodes,n?.serializers?.nodes??{}),Object.assign(r.marks,n?.serializers?.marks??{}),this.serializer=new _.u(r.nodes,r.marks)}static domSerializersFromSchema(e){let t={nodes:{},marks:{}};for(let n in e.marks){let r=e.marks[n].spec.toDOM;r&&(t.marks[n]=r)}for(let n in e.nodes){let r=e.nodes[n].spec.serializeToDOM??e.nodes[n].spec.toDOM;r&&(t.nodes[n]=r)}return t.nodes.text=e=>document.createTextNode(e.text),t}serializeFragment(e,t){let n=_.d.fromJSON(this.config.schema,e),r=this.serializer.serializeFragment(n),i=document.createDocumentFragment();i.appendChild(r),t?.modifyDom?.(i);let a=document.createElement(`div`);return a.appendChild(i),a.innerHTML}},Xc=(e,t)=>{let n=e.topNodeType.createAndFill(null,t?_.d.fromJSON(e,t.content):null);if(!n)throw Error(`Document could not be parsed`);return n.check(),n},Zc=class{constructor(e,t){this.options=t,this.feature=(e,t)=>this[_.c].getPublicInterface(e,t),this[_.c]=new Qc(this,e,t)}getDocument(){return this[_.c].state.doc.toJSON()}reset(e){this[_.c].reset(e)}replaceSelection(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[_.c];r.replaceSelection(new _.v(_.d.fromJSON(i,e),0,0)),r.doc.check();let o=r.doc.resolve(r.mapping.map(n.selection.from,-1)),s=r.doc.resolve(r.selection.to),[c,l]=t?.cursorPlacement===`start`?[o,s]:[s,o];t?.selectContent?r.setSelection(n.selection instanceof A?new A(r.doc):D.between(l,c)):r.setSelection(D.between(c,c)),a(r)}replaceDocument(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[_.c];r.replaceWith(0,n.doc.content.size,Xc(i,e)),t?.selectContent?r.setSelection(new A(r.doc)):t?.cursorPlacement===`end`?r.setSelection(D.atEnd(r.doc)):r.setSelection(D.atStart(r.doc)),a(r)}scrollIntoView(){let e=this[_.c];e.view&&e.dispatchTransaction(e.tr.scrollIntoView())}},Qc=class{getFeature(e){let t=this.config.featureMap.get(e);if(!t)throw Error(`Feature not found: ${e}`);return t}getPublicInterface(e,t){let n=this.config.featureFacadesMap.get(e);if(!n||n.length===0)throw Error(`Feature not found`);if(n[0].featureId!==void 0){if(t===void 0)throw Error(`No featureId provided for multi-instance feature.`);let e=n.find(e=>e.featureId===t);if(!e)throw Error(`Feature with id "${t}" not found`);return e.getPublicInterface(this)}if(t!==void 0)throw Error(`Feature does not support featureId`);return n[0].getPublicInterface(this)}constructor(e,n,r){this.options=r,this.view=null,this.onDisabledChanged=null,this.dispatchTransaction=e=>{let t=this.state;return this.state=this.state.apply(e),this.view?.updateState(this.state),t.doc!==this.state.doc&&this.options?.onChange?.(),this.state},this.facade=e;let i=n[_.c];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=r?.foreignHtmlParser??new Gc(n),this.foreignHtmlSerializer=r?.foreignHtmlSerializer??new Jc(n),this.styles=new t.w(_.s(i.features.flatMap(e=>e.getStyles()))),this.initState(r?.initialDocument)}initState(e){this.state=Ot.create({doc:Xc(this.schema,e),schema:this.config.schema,plugins:_.s(this.config.features.flatMap(e=>e.getPlugins(this)))})}reset(e){let t=cs.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){let t=this.config.featureMap.get(`RteCore`);this.view=new Ra({mount:e},{state:this.state,dispatchTransaction:this.dispatchTransaction,...t?.scrollThreshold!==void 0&&{scrollThreshold:t.scrollThreshold},...t?.scrollMargin!==void 0&&{scrollMargin:t.scrollMargin}})}destroyViewIfNeeded(){this.view&&=(this.view.destroy(),null)}createComponent(e){return document.createElement(this.hostState().ctx.tagFor(e,!0))}getLocale(){return this.hostState().locale}get tr(){return this.state.tr}hostState(){let e=cs.getState(this.state);if(!e)throw Error(`No host state available`);return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(cs,e))}},$c=class{constructor(e){this.specs=e,this.attrs={};for(let t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join(`; `)}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}},el=class{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(e=>e.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}},tl=(e,t)=>{let n=t.config[_.c].schema,r=e=>n.marks[e.type].rank,i=(e,t)=>{if(e.type!==t.type)return!1;let n=e.attrs,r=t.attrs;if(n===r)return!0;if(!n||!r)return!1;let i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(n[e]!==r[e])return!1;return!0},a=e=>{let n=[],o=[],s=[n];for(let n of e){let e=[...n.marks??[]].sort((e,t)=>r(e)-r(t)),c=0,l=0;for(;c<o.length&&l<e.length&&i(o[c],e[l]);)c++,l++;for(;o.length>c;)o.pop(),s.pop();for(;l<e.length;){let n=e[l],r=[];s[s.length-1].push({type:`mark`,mark:n,children:{type:`fragment`,content:r,[_.c]:t},[_.c]:t}),o.push(n),s.push(r),l++}s[s.length-1].push({type:`node`,node:n,children:a(n.content??[]),[_.c]:t})}return{type:`fragment`,content:n,[_.c]:t}};return{type:`node`,node:e,children:a(e.content),[_.c]:t}},nl=class{constructor(e){this[_.c]=new rl(e)}instantiateEditor(e){return new Zc(this,e)}instantiateView(e,t){return tl(e,{config:this,options:{...t}})}},rl=class{constructor(e){let t=e=>e.flatMap(e=>e.getFeatures().flatMap(n=>n===e?e:t([n])));this.features=t(e.map(_.o)),this.featureMap=new Map;for(let e of this.features){if(this.featureMap.has(e.name))throw Error(`Duplicate feature: ${e.name}`);this.featureMap.set(e.name,e)}this.featureFacadesMap=new Map;for(let t of e){let e=t.constructor,n=_.o(t),r=this.featureFacadesMap.get(e);r?r.push(n):this.featureFacadesMap.set(e,[n])}if(!this.featureMap.has(`RteBase`))throw Error(`RteBase feature is required`);if(this.featureMap.has(`RteLinkFeature`)&&!this.featureMap.has(`RteToolbarFeature`))throw Error(`RteToolbarFeature is required for RteLinkFeature`);this.textblockAttrs=new $c(_.s(this.features.flatMap(e=>e.getTextblockAttrs()))),this.textblockMarks=new el(_.s(this.features.flatMap(e=>e.getTextblockMarks())));let n=_.s(this.features.flatMap(e=>e.getSchema(this.textblockAttrs,this.textblockMarks))),r={nodes:{},marks:{}};for(let e of n)Object.assign(r.nodes,e.nodes??{}),Object.assign(r.marks,e.marks??{});for(let e of this.textblockMarks.getReferencedNodeNames())if(!(e in r.nodes))throw Error(`Unknown node "${e}"`);this.schema=new _._(r)}},il=e=>{let t=[],n;return e.forEach(e=>{if(e.isInline)n||(n=[],t.push(n)),n.push(e);else if(n=void 0,e.isTextblock){let n=[];e.content.forEach(e=>n.push(e)),t.push(n)}else t.push(...il(e.content))}),t},al=(e,t)=>{let n=il(e.content);if(n.length<=1)return e;let r=t.nodes.hardBreak,i=r?[r.create()]:[],a=n.flatMap((e,t)=>t===0?e:[...i,...e]);return new _.v(_.d.fromArray(a),0,0)},ol=200,Q=function(){};Q.prototype.append=function(e){return e.length?(e=Q.from(e),!this.length&&e||e.length<ol&&this.leafAppend(e)||this.length<ol&&e.leafPrepend(this)||this.appendInner(e)):this},Q.prototype.prepend=function(e){return e.length?Q.from(e).append(this):this},Q.prototype.appendInner=function(e){return new cl(this,e)},Q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Q.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Q.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Q.from=function(e){return e instanceof Q?e:e&&e.length?new sl(e):Q.empty};var sl=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=ol)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=ol)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Q);Q.empty=new sl([]);var cl=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Q),ll=500,ul=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new fl(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new fl(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new fl(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>ml&&(s=dl(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new x;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new fl(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new fl(i,o,l))}else r.push(new fl(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new fl(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>ll&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new fl(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(Q.from(i.reverse()),a)}};ul.empty=new ul(Q.empty,0);function dl(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var fl=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},pl=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},ml=20;function hl(e,t,n,r){let i=n.getMeta(wl),a;if(i)return i.historyState;n.getMeta(Tl)&&(e=new pl(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(wl))return o.getMeta(wl).redo?new pl(e.done.addTransform(n,void 0,r,Sl(t)),e.undone,_l(n.mapping.maps),e.prevTime,e.prevComposition):new pl(e.done,e.undone.addTransform(n,void 0,r,Sl(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!gl(n,e.prevRanges)),s=o?vl(e.prevRanges,n.mapping):_l(n.mapping.maps);return new pl(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Sl(t)),ul.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new pl(e.done.rebased(n,a),e.undone.rebased(n,a),vl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new pl(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),vl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function gl(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function _l(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function vl(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function yl(e,t,n){let r=Sl(t),i=wl.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new pl(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(wl,{redo:n,historyState:c})}var bl=!1,xl=null;function Sl(e){let t=e.plugins;if(xl!=t){bl=!1,xl=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){bl=!0;break}}return bl}function Cl(e){return e.setMeta(Tl,!0)}var wl=new Mt(`history`),Tl=new Mt(`closeHistory`);function El(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new j({key:wl,state:{init(){return new pl(ul.empty,ul.empty,null,0,-1)},apply(t,n,r){return hl(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Ol:n==`historyRedo`?kl:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Dl(e,t){return(n,r)=>{let i=wl.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=yl(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Ol=Dl(!1,!0),kl=Dl(!0,!0),Al=e=>typeof e==`function`,jl=(e,t,n)=>[e,t,n],Ml=class{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return Al(e)?e(this):e}bindProp(e,t){if(e!==void 0){if(Al(e)){let n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}}updateBindings(){for(let e of this.bindings)e()}shouldReturnFocusToEditor(){return this.evalProp(this.props.shouldReturnFocusToEditor)}bindToEl(e,t={},n=[],r=[]){for(let n in t)this.bindProp(t[n],t=>{e[n]=t});for(let[t,r,i]of n)r&&e.addEventListener(t,i(r));for(let t of r)e.appendChild(t)}},Nl=(e,t)=>{let n=document.createElement(`div`);return e.bindToEl(n,{className:t.className,slot:t.slot},[],t.children),n},Pl=(e,t)=>{let n=document.createElement(`a`);return e.bindToEl(n,{href:t.href,target:t.target,rel:t.rel,className:t.className},[],t.children),n},Fl=new WeakMap,Il=(e,t)=>{let n=e.rte.createComponent(l.r);n.setAttribute(`exportparts`,`vvd-theme-alternate`),e.bindToEl(n,{className:`ui-tooltip`,text:t.label,placement:e.props.popupPlacement}),e.bindProp(t.enabled,e=>{e||(n.open=!1),n.anchor=e?t.anchor:void 0});let r=Nl(e,{className:`ui-tooltip-wrapper`,slot:t.slot,children:[t.anchor,n]});return Fl.set(r,t.anchor),r},$=(e,t)=>{let n=()=>e.evalProp(t.variant)??`toolbar`,r=()=>n()===`toolbar`?`super-condensed`:`condensed`,i=()=>n()===`popover-primary`?`outlined`:`ghost-light`,a=()=>n()===`toolbar-menu`||n()===`popover`?`filled`:i(),o=()=>e.evalProp(t.active)?a():i(),c=()=>e.evalProp(t.connotation)??(n()===`toolbar-menu`&&e.evalProp(t.active)?`cta`:void 0),l=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),u=!!(t.icon??t.dynamicIcon),d=()=>{let n=e.evalProp(t.dynamicIcon);return n===void 0?e.evalProp(t.icon):`${n}-${e.evalProp(t.active)?`solid`:`line`}`},f=e.rte.createComponent(s.i);return e.bindToEl(f,{size:r,appearance:o,disabled:l,icon:d,autofocus:t.autofocus,connotation:c,[u?`ariaLabel`:`label`]:t.label,pressed:()=>!!e.evalProp(t.active),ariaPressed:t.active===void 0?void 0:()=>e.evalProp(t.active)?`true`:`false`},[jl(`click`,t.onClick,t=>()=>{!t()&&e.shouldReturnFocusToEditor()&&e.view.focus()})]),Il(e,{enabled:()=>u&&!e.evalProp(t.noTooltip)&&!l(),label:t.label,anchor:f,slot:t.slot})},Ll=(e,t)=>{let n=e.rte.createComponent(ne.r);e.bindToEl(n,{className:`ui-menu`,autoDismiss:!0,ariaLabel:t.label,anchor:Fl.get(t.trigger)??t.trigger,placement:e.props.popupPlacement,offset:()=>e.evalProp(e.props.menuOffset)??null},[],t.children);let r=document.createDocumentFragment();return r.appendChild(t.trigger),r.appendChild(n),r},Rl=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(v.i);return e.bindToEl(r,{text:t.text,checked:t.checked,disabled:n,controlType:`radio`,checkedAppearance:`tick-only`},[jl(`change`,t.onSelect,n=>()=>{r.checked&&!r.disabled&&e.evalProp(t.checked)!==r.checked&&(n(),e.shouldReturnFocusToEditor()&&e.view.focus())})]),r},zl=(e,t)=>Nl(e,{slot:t.slot,className:`ui-button-group`,children:t.children});function Bl(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}var Vl=(e,t)=>$(e,{label:t.label,dynamicIcon:t.dynamicIcon,active:()=>Bl(e.view.state,t.markType),disabled:()=>!Ao(t.markType)(e.view.state),onClick:()=>{Ao(t.markType)(e.view.state,e.view.dispatch)}}),Hl=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(f.t);return e.bindToEl(r,{value:t.value,text:t.text,disabled:n}),r},Ul=(e,t)=>{let n=()=>!!e.evalProp(e.props.disabled),r=e.rte.createComponent(g.r);r.setAttribute(`data-class`,`ui-select`),e.bindToEl(r,{placeholder:` `,ariaLabel:t.label,appearance:`ghost`,disabled:n},[jl(`change`,t.onSelect,t=>()=>{let n=r.value;n&&(t(n),e.shouldReturnFocusToEditor()&&e.view.focus())})],t.children),queueMicrotask(()=>{e.bindProp(t.value,e=>r.value=e)});let i=!1;return r.addEventListener(`vwc-popup:open`,()=>{i=!0,e.updateBindings()}),r.addEventListener(`vwc-popup:close`,()=>{i=!1,e.updateBindings()}),Il(e,{enabled:()=>!i&&!n(),label:t.label,anchor:r})},Wl=e=>{let t=e.rte.createComponent(te.t);return e.bindToEl(t,{className:`ui-divider`,orientation:`vertical`}),t},Gl=(e,t)=>{let n=e.rte.createComponent(d.r);return e.bindToEl(n,{label:t.label,value:t.value,placeholder:t.placeholder,slot:t.slot,autofocus:t.autofocus,type:t.type,helperText:t.helperText},[jl(`input`,t.onInput,e=>()=>{e(n.value)})]),n},Kl=(e,t)=>{let n=document.createTextNode(``);return e.bindToEl(n,{textContent:t.text}),n},ql=(e,t)=>{let n=document.createElement(`slot`);n.name=t.name;let r=null,i=[];function a(){for(let{el:e,type:t,handler:n}of i)e.removeEventListener(t,n);i.length=0,r=null}for(let[n,i]of Object.entries(t.assignedProps))e.bindProp(i,e=>{r&&(r[n]=e)});function o(n){for(let[r,i]of Object.entries(t.assignedProps))n[r]=e.evalProp(i);for(let[r,a]of Object.entries(t.assignedEvents)){let t=t=>{a(t),e.shouldReturnFocusToEditor()&&e.view.focus()};n.addEventListener(r,t),i.push({el:n,type:r,handler:t})}}let s=()=>{let e=n.assignedElements({flatten:!0})[0];e!==r&&(a(),e&&(r=e,o(e)))};return n.addEventListener(`slotchange`,s),queueMicrotask(s),n},Jl=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteHistoryFeature`}getPlugins(){return[this.contribution(El()),this.contribution(W({"Mod-z":Ol,"Ctrl-y":kl,"Cmd-Z":kl}))]}getToolbarItems(){return this.config.showToolbarButtons?[this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.undo,icon:`undo-line`,disabled:e=>!Ol(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;Ol(t,n)}})},1),this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.redo,icon:`redo-line`,disabled:e=>!kl(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;kl(t,n)}})},2)]:[]}},Yl=`h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:16px;line-height:20px}.heading-step-1{font:var(--vvd-typography-heading-4);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:28px}.heading-step-2{font:var(--vvd-typography-heading-3);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:36px}.heading-step-3{font:var(--vvd-typography-heading-2);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:32px 16px;line-height:42px}`,Xl=class extends _.r{constructor(e){super(),this.enabledBlocks=e,this.name=`RteBasicTextBlocks`}getStyles(){return[this.contribution(Yl)]}getSchema(e,t){let n={};this.enabledBlocks.paragraph&&(n.paragraph={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:`p`,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(`paragraph`).join(` `),toDOM(t){return[`p`,{part:`node--paragraph`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[`p`,...e.getDOMAttrs(t),0]}});let r=0;for(let i of[3,2,1]){let a=`heading${i}`,o=`h${i}`;if(!this.enabledBlocks[a])continue;r++;let s=r;n[a]={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:o,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(a).join(` `),defining:!0,toDOM(t){return[o,{class:`heading-step-${s}`,part:`node--${a}`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[o,...e.getDOMAttrs(t),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){let t={};this.enabledBlocks.paragraph&&(t[`Mod-Alt-0`]=this.setBlockType(e,`paragraph`));for(let n of[1,2,3]){let r=`heading${n}`;this.enabledBlocks[r]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,r))}return[this.contribution(W(t))]}getCurrentBlockType(e){let{$from:t,$to:n}=e.selection,r=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1);return r!==(n.depth===0?e.doc.childBefore(n.pos).node:n.node(1))||!(r.type.name in this.enabledBlocks)?null:r.type.name}setBlockType(e,t){return(n,r)=>{let{from:i,to:a}=n.selection,o=n.tr,s=!1;return n.doc.nodesBetween(i,a,(r,i)=>(r.type.name in this.enabledBlocks&&(s=!0,o.setBlockType(i,i+r.nodeSize,n.schema.nodes[t],t=>e.textblockAttrs.extractFromNode(t))),!1)),s?(r?.(o),!0):!1}}},Zl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Ql(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Ql(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var $l=500;function eu({rules:e}){let t=new j({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return tu(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&tu(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function tu(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-$l),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}var nu=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new Zl(/--$/,`—`,{inCodeMark:!1}),new Zl(/\.\.\.$/,`…`,{inCodeMark:!1}),new Zl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new Zl(/"$/,`”`,{inCodeMark:!1}),new Zl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new Zl(/'$/,`’`,{inCodeMark:!1});var ru=e=>e.parent.textBetween(0,e.parentOffset,void 0,``),iu=class extends _.r{constructor(...e){super(...e),this.name=`RteInputRulesFeature`}getPlugins(e){let t=_.s(e.config.features.flatMap(t=>t.getInputRules(e)));if(t.length===0)return[];let n=[],r=t.map(e=>e.rule);n.push(this.contribution(eu({rules:r}))),n.push(this.contribution(W({Backspace:nu}),_.i.high));let i=t.filter(e=>e.enterHandler).map(e=>e.enterHandler);return i.length>0&&n.push(this.contribution(W({Enter:(e,t)=>{let{$cursor:n}=e.selection;if(!n)return!1;let r=ru(n);for(let{regex:a,handler:o}of i){let i=a.exec(r);if(!i)continue;let s=n.pos-n.parentOffset+i.index,c=o(e,i,s,s+i[0].length);c&&t?.(c);break}return!1}}),_.i.highest)),n}},au={doc:`doc`,text:`text`,paragraph:`paragraph`,heading1:`heading1`,heading2:`heading2`,heading3:`heading3`},ou=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteBase`}getSchema(){return[this.contribution({nodes:{[au.doc]:{content:this.config?.singleBlock?`block`:`block+`},[au.text]:{group:`inline`}}})]}getPlugins(e){return this.config?.singleBlock?[this.contribution(new j({props:{transformPasted:(e,t)=>al(e,t.state.schema)}}))]:[]}getFeatures(){return[this,new ls,new Jl({showToolbarButtons:this.config?.historyToolbarButtons??!0}),new Xl({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new iu]}getPublicInterface(e){let t=e.getFeature(`RteCore`);return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)},get scrollThreshold(){return t.scrollThreshold},set scrollThreshold(n){t.scrollThreshold=n,e.view?.setProps({scrollThreshold:n})},get scrollMargin(){return t.scrollMargin},set scrollMargin(n){t.scrollMargin=n,e.view?.setProps({scrollMargin:n})}}}},su=Object.assign(_.a(ou),{nodes:au}),cu=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteTextBlockPickerFeature`}getToolbarItems(e){let t=e.getFeature(`RteBasicTextBlocks`);return[this.contribution({section:`font`,render:n=>Ul(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:e=>t.getCurrentBlockType(e.view.state)??``,onSelect:r=>{let{state:i,dispatch:a}=n.view;t.setBlockType(e,r)(i,a)},children:this.config.options.map(r=>Hl(n,{text:r.label,value:r.node,disabled:()=>!t.setBlockType(e,r.node)(n.view.state)}))})},1)]}},lu=_.a(cu),uu=`.toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}`,du=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteToolbarFeature`,this.hidden=new es(!1)}getStyles(){return[this.contribution(uu)]}getPlugins(e){let t=[`history`,`font`,`text-style`,`textblock`,`insert`],n=new Map(t.map(e=>[e,[]]));for(let t of _.s(e.features.flatMap(t=>t.getToolbarItems(e))))n.get(t.section).push(t);let r=e.getFeature(`RteCore`);return[this.contribution(this.hidden.plugin),this.contribution(new j({view:i=>{let a=!1,o=new Ml(i,e,{popupPlacement:this.config?.popupDirection===`outward`?`bottom`:`top`,menuOffset:8,disabled:()=>r.disabled.getValue(e),shouldReturnFocusToEditor:()=>a}),s=i.dom.getRootNode().querySelector(`.toolbar`),c=-1/0,l=()=>{i.hasFocus()&&(a=!0),c=Date.now()},u=()=>{Date.now()-c>250&&(a=!1)},d=e=>{s.contains(e.relatedTarget)||(a=!1)};s.addEventListener(`mousedown`,l,{capture:!0}),s.addEventListener(`focusin`,u),s.addEventListener(`focusout`,d),o.bindProp(()=>this.hidden.getValue(e),e=>{s.classList.toggle(`toolbar--hidden`,e)});let f=!1;for(let e of t){let t=n.get(e);t.length&&f&&(s.appendChild(Wl(o)),f=!1);for(let e of t)s.appendChild(e.render(o)),f=!0}return{update(){o.updateBindings()},destroy(){s.innerHTML=``,s.removeEventListener(`mousedown`,l,{capture:!0}),s.removeEventListener(`focusin`,u),s.removeEventListener(`focusout`,d),a=!1}}}}))]}getPublicInterface(e){let t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}},fu=_.a(du),pu=`.placeholder{display:contents}.placeholder:before{color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size,inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none;position:absolute}.editor--disabled .placeholder:before{color:var(--vvd-color-neutral-300)}`,mu=class extends _.r{constructor(e){super(),this.config=e,this.name=`RtePlaceholderFeature`}getStyles(){return[this.contribution(pu)]}getPlugins(){let e=new j({props:{decorations:e=>{if(e.doc.nodeSize===4){let t=e.schema.marks.fontSize?.isInSet(e.storedMarks??[])?.attrs.size;return V.create(e.doc,[B.widget(1,()=>{let e=document.createElement(`span`);return e.className=`placeholder`,e.dataset.placeholder=this.config.text,t&&e.style.setProperty(`--placeholder-font-size`,t),e})])}return null}}});return[this.contribution(e)]}},hu=_.a(mu),gu={hardBreak:`hardBreak`},_u=class extends _.r{constructor(...e){super(...e),this.name=`RteHardBreakFeature`}getSchema(){return[this.contribution({nodes:{[gu.hardBreak]:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}}}})]}getPlugins(e){return[this.contribution(W({"Shift-Enter":(e,t)=>{let n=e.storedMarks||e.selection.$from.marks(),r=e.tr.replaceSelectionWith(e.schema.nodes.hardBreak.create(),!0).scrollIntoView();return n.length&&r.setStoredMarks(n),t?.(r),!0}}),_.i.high)]}},vu=Object.assign(_.a(_u),{nodes:gu}),yu=Symbol(`mixedFontSize`),bu={fontSize:`fontSize`},xu=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteFontSizePickerFeature`,this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(let t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:bu.fontSize,onNodeName:e.node})):[this.contribution({markName:bu.fontSize})]}getSchema(){let e={attrs:{size:{validate:`string`}},parseDOM:[{tag:`span[style*='font-size']`,getAttrs:e=>{let t=e.getAttribute(`style`).match(/font-size:\s*([^;]+)/)?.[1]?.trim();if(!t)return!1;let n=this.config?.parseSizeFromHtml?this.config.parseSizeFromHtml(t):t;return n===null||this.config?.restrictToOptions&&!this.fontSizes.some(e=>e.size===n)?!1:{size:n}}}],toDOM:e=>[`span`,{style:`font-size: ${Hc(e.attrs.size)};`},0],cursorFix:(e,t)=>{let n=t.storedMarks;if(!n)return null;let r=n.find(e=>e.type.name===`fontSize`);if(r)return{style:{"font-size":r.attrs.size}};if(n.length===0){let t=this.defaultFontSizeForNode?.[e.parent.type.name];if(t)return{style:{"font-size":t}}}return null}};return[this.contribution({marks:{[bu.fontSize]:e}})]}getPlugins(){return[this.contribution(W({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:`font`,render:t=>Ll(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:$(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:`text-size-line`}),children:this.fontSizes.map(e=>Rl(t,{text:e.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===e.size,disabled:()=>!this.setFontSize(e.size)(t.view.state),onSelect:()=>{let{state:n,dispatch:r}=t.view;this.setFontSize(e.size)(n,r)}}))})},2)]}getFontSizeFromSelection(e){let{from:t,to:n,$from:r,empty:i}=e.selection,{fontSize:a}=e.schema.marks;if(i){let t=this.defaultFontSizeForNode?.[r.parent.type.name]??null;return a.isInSet(e.storedMarks||r.marks())?.attrs.size??t}let o=null,s=e=>{o===null?o=e??null:e!==o&&(o=yu)};return e.doc.nodesBetween(t,n,(e,t,n)=>o===yu?!1:e.isLeaf?(s(a.isInSet(e.marks)?.attrs.size??(n&&this.defaultFontSizeForNode?.[n.type.name])),!0):(e.type.allowsMarkType(a)&&e.childCount===0&&s(this.defaultFontSizeForNode?.[e.type.name]),!0)),o}setFontSize(e){return(t,n)=>{let{from:r,to:i,empty:a,$from:o}=t.selection,{fontSize:s}=t.schema.marks;if(!Ao(s,{size:e})(t))return!1;let c=t.tr;if(a){let n=(t.storedMarks||[]).filter(e=>e.type!==s);e!==this.defaultFontSizeForNode?.[o.parent.type.name]&&n.push(s.create({size:e})),c.setStoredMarks(n)}else c.addMark(r,i,s.create({size:e})),c.doc.nodesBetween(r,i,(e,t,n)=>{if(!e.isInline)return;let r=s.isInSet(e.marks),i=this.defaultFontSizeForNode?.[n.type.name];r&&r.attrs.size===i&&c.step(new Se(t,t+e.nodeSize,r))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{let r=this.getFontSizeFromSelection(t);if(r===null||r===yu)return!1;let i=this.fontSizes.findIndex(e=>e.size===r)+e;return i<0||i>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[i].size)(t,n)}}},Su=Object.assign(_.a(xu),{marks:bu}),Cu=[`p`,0],wu=[`blockquote`,0],Tu=[`hr`],Eu=[`pre`,[`code`,0]],Du=[`br`],Ou={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return Cu}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return wu}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return Tu}},heading:{attrs:{level:{default:1,validate:`number`}},content:`inline*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}},{tag:`h4`,attrs:{level:4}},{tag:`h5`,attrs:{level:5}},{tag:`h6`,attrs:{level:6}}],toDOM(e){return[`h`+ +e.attrs.level,0]}},code_block:{content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`}],toDOM(){return Eu}},text:{group:`inline`},image:{inline:!0,attrs:{src:{validate:`string`},alt:{default:null,validate:`string|null`},title:{default:null,validate:`string|null`}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){let{src:t,alt:n,title:r}=e.attrs;return[`img`,{src:t,alt:n,title:r}]}},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return Du}}},ku=[`em`,0],Au=[`strong`,0],ju=[`code`,0],Mu={link:{attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){let{href:t,title:n}=e.attrs;return[`a`,{href:t,title:n},0]}},em:{parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name==`em`}],toDOM(){return ku}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return Au}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return ju}}};new _._({nodes:Ou,marks:Mu});var Nu=class extends _.r{constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}},Pu={bold:`bold`},Fu=class extends Nu{constructor(...e){super(...e),this.name=`RteBoldFeature`,this.markName=Pu.bold}getSchema(){return[this.contribution({marks:{[Pu.bold]:Mu.strong}})]}getPlugins(e){return[this.contribution(W({"Mod-b":Ao(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.bold,dynamicIcon:`bold`,markType:e.schema.marks.bold})},1)]}},Iu=Object.assign(_.a(Fu),{marks:Pu}),Lu={italic:`italic`},Ru=class extends Nu{constructor(...e){super(...e),this.name=`RteItalicFeature`,this.markName=Lu.italic}getSchema(){return[this.contribution({marks:{[Lu.italic]:Mu.em}})]}getPlugins(e){return[this.contribution(W({"Mod-i":Ao(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.italic,dynamicIcon:`italic`,markType:e.schema.marks.italic})},2)]}},zu=Object.assign(_.a(Ru),{marks:Lu}),Bu={underline:`underline`},Vu=class extends Nu{constructor(...e){super(...e),this.name=`RteUnderlineFeature`,this.markName=Bu.underline}getSchema(){return[this.contribution({marks:{[Bu.underline]:{parseDOM:[{tag:`u`}],toDOM(){return[`u`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Mod-u":Ao(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.underline,dynamicIcon:`underline`,markType:e.schema.marks.underline})},3)]}},Hu=Object.assign(_.a(Vu),{marks:Bu}),Uu={strikethrough:`strikethrough`},Wu=class extends Nu{constructor(...e){super(...e),this.name=`RteStrikethroughFeature`,this.markName=Uu.strikethrough}getSchema(){return[this.contribution({marks:{[Uu.strikethrough]:{parseDOM:[{tag:`s`},{tag:`del`}],toDOM(){return[`s`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Alt-Shift-5":Ao(e.schema.marks.strikethrough),"Cmd-Shift-X":Ao(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,dynamicIcon:`strikethrough`,markType:e.schema.marks.strikethrough})},4)]}},Gu=Object.assign(_.a(Wu),{marks:Uu}),Ku=`tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}`,qu={monospace:`monospace`},Ju=class extends Nu{constructor(...e){super(...e),this.name=`RteMonospaceFeature`,this.markName=qu.monospace}getStyles(){return[this.contribution(Ku)]}getSchema(){return[this.contribution({marks:{[qu.monospace]:{parseDOM:[{tag:`tt`},{tag:`code`}],toDOM(){return[`tt`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Mod-M":Ao(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Vl(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,dynamicIcon:`monospace`,markType:e.schema.marks.monospace})},5)]}},Yu=Object.assign(_.a(Ju),{marks:qu}),Xu=e=>{let t=document.createElement(`div`);return t.style.color=e,t.style.color||null};function Zu(e,t,n){for(let r=0;r<t.length;r++){let{$from:i,$to:a}=t[r],o=i.depth==0&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,a.pos,e=>!o&&(o=e.inlineContent&&e.type.allowsMarkType(n),!0)),o)return!0}return!1}var Qu=Symbol(`mixedColor`),$u={textColor:`textColor`},ed=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteTextColorPicker`,e?.onBlocks){this.defaultColorForNode={};for(let t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:$u.textColor,onNodeName:e.node})):[this.contribution({markName:$u.textColor})]}getSchema(){let e=e=>{let t=this.config?.parseColorFromHtml?this.config.parseColorFromHtml(e):e;return t!==null&&{color:t}};return[this.contribution({marks:{[$u.textColor]:{attrs:{color:{validate:`string`}},parseDOM:[{tag:`span[data-text-color]`,getAttrs:t=>e(t.getAttribute(`data-text-color`))},{style:`color`,getAttrs:t=>e(t)}],toDOM(e){let{color:t}=e.attrs;return[`span`,{style:`color: ${Hc(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:`text-style`,render:e=>{let t=$(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor(`any`)(e.view.state),icon:`textcolor-line`}),n=t.firstElementChild;return Nl(e,{children:[t,ql(e,{name:`text-color-picker`,assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||``},assignedEvents:{change:t=>{let n=t.currentTarget.value;this.setColor(n)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){let{selection:t}=e,{textColor:n}=e.schema.marks,{from:r,to:i,$from:a,empty:o}=t;if(o){let t=this.defaultColorForNode?.[a.parent.type.name]??null;return n.isInSet(e.storedMarks||a.marks())?.attrs.color??t}let s=null,c=e=>{s===null?s=e??null:e!==s&&(s=Qu)};return e.doc.nodesBetween(r,i,(e,t,r)=>s===Qu?!1:e.isLeaf?(c(n.isInSet(e.marks)?.attrs.color??(r&&this.defaultColorForNode?.[r.type.name])),!0):(e.type.allowsMarkType(n)&&e.childCount===0&&c(this.defaultColorForNode?.[e.type.name]),!0)),s===Qu?null:s}setColor(e){return(t,n)=>{let{textColor:r}=t.schema.marks,{from:i,to:a,empty:o,$from:s}=t.selection;if(!Zu(t.doc,t.selection.ranges,r))return!1;let c=t.tr;if(o){let n=(t.storedMarks||[]).filter(e=>e.type!==r);e!==this.defaultColorForNode?.[s.parent.type.name]&&n.push(r.create({color:e})),c.setStoredMarks(n)}else c.addMark(i,a,r.create({color:e})),c.doc.nodesBetween(i,a,(e,t,n)=>{if(!e.isInline)return;let i=r.isInSet(e.marks),a=this.defaultColorForNode?.[n.type.name];i&&i.attrs.color===a&&c.step(new Se(t,t+e.nodeSize,i))});return n?.(c.scrollIntoView()),!0}}},td=Object.assign(_.a(ed),{marks:$u,normalizeCssColor:Xu}),nd=`.rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}`,rd=e=>e.parentOffset===0,id=e=>e.nodeSize===2,ad=e=>e.depth-1,od=e=>e.depth-2,sd=e=>e.parent,cd=e=>e.node(ad(e)),ld=e=>e.depth>2,ud=(e,t)=>e.index(t)===0,dd=(e,t)=>e.index(t)===e.node(t).childCount-1,fd=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r-1)},pd=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r+1)},md=e=>{let{$from:t,$to:n}=e;if(e instanceof A){let r=D.between(e.$from,e.$to);t=r.$from,n=r.$to}return{$from:t,$to:n}},hd=(e,t)=>e.sameParent(t)?e.node(-1):e.node(e.sharedDepth(t.pos)),gd=e=>{let{$cursor:t}=e.selection;return t?.parent.type===e.schema.nodes.listItem?t:null},_d=(e,t,n,r)=>{let i,a=!0;return e.doc.nodesBetween(t.pos,n.pos,t=>{t.type.isInGroup(`list`)&&(i=t.type),t.type===e.schema.nodes.listItem&&i!==r&&(a=!1)}),a},vd=(e,t,n)=>ld(t)?(yd(t,n),!0):bd(e,t,n),yd=(e,t)=>{let n=new _.h(e.doc.resolve(e.before()),e.doc.resolve(e.after()),e.depth-1);t.lift(n,e.depth-2)},bd=(e,t,n)=>{let r=cd(t),i=t.index(od(t)),a=Qo(t.node(od(t)).contentMatchAt(i+1));if(!a)return!1;let o=ud(t,ad(t)),s=dd(t,ad(t));return n.step(new w(t.before()-+!!o,t.after()+ +!!s,t.start(),t.end(),new _.v((o?_.d.empty:_.d.from(r.copy(_.d.empty))).append(_.d.from(a.create(e.textblockAttrs.extractFromNode(sd(t))))).append(s?_.d.empty:_.d.from(r.copy(_.d.empty))),+!o,+!s),+!o+1)),!0},xd=(e,t,n,r)=>{n.parent.type===e.schema.nodes.listItem?Sd(t,n,r):Cd(e,t,n,r)},Sd=(e,t,n)=>{let r=fd(t,ad(t))?.type===e,i=pd(t,ad(t))?.type===e,a=+!!r,o=+!!i;n.step(new w(t.before()-+!!r,t.after()+ +!!i,t.before(),t.after(),new _.v(_.d.from(e.create(null,[])),a,o),1-a))},Cd=(e,t,n,r)=>{r.step(new w(n.before(),n.after(),n.start(),n.end(),new _.v(_.d.from(t.create(null,[e.schema.nodes.listItem.create(e.textblockAttrs.extractFromNode(n.parent))])),0,0),2))},wd={listItem:`listItem`,bulletList:`bulletList`,numberedList:`numberedList`},Td=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteListFeature`,!e.bulletList&&!e.numberedList)throw Error(`RteListFeature requires at least one of bulletList or numberedList to be enabled`)}getStyles(){return[this.contribution(nd)]}getSchema(e){return[this.contribution({nodes:{[wd.listItem]:{content:`inline*`,attrs:e.attrs,defining:!0,parseDOM:[{tag:`li`,getAttrs:t=>e.fromDOM(t)}],toDOM(t){return[`li`,...e.getDOMAttrs(t),0]}},...this.config.bulletList?{[wd.bulletList]:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}}}:{},...this.config.numberedList?{[wd.numberedList]:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ol`}],toDOM(){return[`ol`,0]}}}:{}}})]}getPlugins(e){return this.rte=e,[this.contribution(W({Enter:(e,t)=>{let n=gd(e);if(n&&id(sd(n))){let r=e.tr;return vd(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Backspace:(e,t)=>{let n=gd(e);if(n&&rd(n)){if(ud(n,ad(n))&&fd(n,od(n))?.type===cd(n).type)return!1;let r=e.tr;return vd(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Tab:(e,t)=>{let n=gd(e);if(n&&rd(n)){let r=e.tr;return Sd(cd(n).type,n,r),t?.(r.scrollIntoView()),!0}return!1},"Shift-Tab":(e,t)=>{let n=gd(e);if(n&&rd(n)&&ld(n)){let r=e.tr;return yd(n,r),t?.(r.scrollIntoView()),!0}return!1},...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),_.i.high)]}getToolbarItems(e){let t=[];return this.config.bulletList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.bulletList,dynamicIcon:`bullet-list-2`,active:()=>this.isSelectionInList(e.schema.nodes.bulletList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.bulletList)(n,r)}})},1)),this.config.numberedList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.numberedList,dynamicIcon:`list-numbered`,active:()=>this.isSelectionInList(e.schema.nodes.numberedList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.numberedList)(n,r)}})},2)),t}toggleList(e){return Mo((t,n)=>{let{$from:r,$to:i}=md(t.selection);if(hd(r,i).type.isInGroup(`list`)){if(_d(t,r,i,e)){let e=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(n,r)=>{if(n.type===t.schema.nodes.listItem){let t=e.doc.resolve(e.mapping.map(r+1));vd(this.rte,t,e)}}),n?.(e.scrollIntoView()),!0}{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{t.type.isInGroup(`list`)&&t.type!==e&&a.setNodeMarkup(n,e,t.attrs)}),n?.(a.scrollIntoView()),!0}}{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{if(!t.isTextblock)return;let r=a.doc.resolve(a.mapping.map(n+1));xd(this.rte,e,r,a)}),n?.(a.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){let{$from:n,$to:r}=md(t.selection);return hd(n,r).type.isInGroup(`list`)?_d(t,n,r,e):!1}},Ed=Object.assign(_.a(Td),{nodes:wd}),Dd=[{value:`left`,icon:`align-left`,label:`left`},{value:`center`,icon:`align-center`,label:`center`},{value:`right`,icon:`align-right`,label:`right`}],Od=e=>Dd.find(t=>t.value===e)?.value??`left`,kd=class extends _.r{constructor(...e){super(...e),this.name=`RteAlignmentFeature`}getTextblockAttrs(){return[this.contribution({name:`textAlign`,default:`left`,fromDOM(e){return Od(e.style.textAlign)},toStyles(e){return[`text-align: ${Od(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(W({"Mod-L":this.setAlignment(`left`),"Mod-E":this.setAlignment(`center`),"Mod-R":this.setAlignment(`right`)}))]}getToolbarItems(){return[this.contribution({section:`textblock`,render:e=>Ll(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:$(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{let t=this.getAlignmentFromSelection(e.view.state);return`${Dd.find(e=>e.value===t)?.icon??`align-left`}-line`}}),children:[zl(e,{slot:`header`,children:Dd.map((t,n)=>$(e,{dynamicIcon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],noTooltip:!0,variant:`toolbar-menu`,autofocus:()=>{let r=this.getAlignmentFromSelection(e.view.state);return(r===`mixed`||r===null)&&n===0||t.value===r},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{let{state:n,dispatch:r}=e.view;this.setAlignment(t.value)(n,r)}}))})]})},3)]}getAlignmentFromSelection(e){let{selection:t}=e,{from:n,to:r}=t,i=null;return e.doc.nodesBetween(n,r,e=>{i!==`mixed`&&e.type.isTextblock&&(i?i!==e.attrs.textAlign&&(i=`mixed`):i=e.attrs.textAlign)}),i}setAlignment(e){return(t,n)=>{let{tr:r,selection:i}=t,{from:a,to:o}=i;return t.doc.nodesBetween(a,o,(t,n)=>{t.type.isTextblock&&r.setNodeMarkup(n,t.type,{...t.attrs,textAlign:e})}),t.storedMarks&&r.setStoredMarks(t.storedMarks),n?.(r.scrollIntoView()),!0}}},Ad=_.a(kd),jd=`.link-popover{flex-direction:column;gap:8px;inline-size:450px;padding:16px;display:flex}.link-popover-header{justify-content:space-between;align-items:center;display:flex}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{flex-direction:column;gap:16px;display:flex}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{justify-content:end;gap:8px;display:flex}.link-toolbar-menu{flex-direction:column;gap:16px;inline-size:368px;padding:8px;display:flex}`,Md=`(?:https?://|www\\.)[^\\s<]+`;function Nd(e,t,n,r){if(e.doc.rangeHasMark(n,n+1,e.schema.marks.link))return null;let i=t.replace(/[.,;:!?) ]+$/,``),a=i.startsWith(`www.`)?`https://${i}`:i,o=e.schema.marks.link.create({href:a}),s=n+i.length,c=t.slice(i.length),l=e.tr.addMark(n,s,o);return c&&l.replaceWith(s,r,e.schema.text(c)),l}var Pd={link:`link`},Fd=class extends _.r{constructor(...e){super(...e),this.name=`RteLinkFeature`,this.removeLink=(e,t)=>{let n=e.tr,r=this.getCurrentLink(e);return n.removeMark(r.start,r.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(jd)]}getSchema(){return[this.contribution({marks:{[Pd.link]:{attrs:{href:{validate:`string`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`)}}}],toDOM(e){let{href:t}=e.attrs;return[`a`,{href:Lc(t)},0]}}}},_.i.high)]}getTextblockMarks(){return[this.contribution({markName:Pd.link})]}getInputRules(){let e=RegExp(`${Md}$`);return[this.contribution({rule:new Zl(RegExp(`${Md} $`),(e,t,n,r)=>Nd(e,t[0],n,r)),enterHandler:{regex:e,handler:(e,t,n,r)=>Nd(e,t[0],n,r)}})]}getPlugins(e){let t=()=>(this.toolbarMenu.open=!0,!0),n;return[this.contribution(new j({props:{decorations:e=>{let t=this.getCurrentLink(e);if(t){let n=B.inline(t.start,t.end,{id:`current-link`});return V.create(e.doc,[n])}return null}},view:t=>{let r=new Ml(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});n=e.createComponent(b),n.anchorId=`current-link`;let i=Nl(r,{className:`link-popover`,children:[Nl(r,{className:`link-popover-header`,children:[Nl(r,{className:`link-popover-label`,children:[Kl(r,{text:()=>this.getCurrentLink(r.view.state)?.text||``})]}),$(r,{icon:`close-line`,label:()=>r.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{n.dismiss()}})]}),Nl(r,{className:`link-popover-content`,children:[Pl(r,{className:`link`,href:()=>this.getCurrentLink(r.view.state)?.href||``,target:`_blank`,rel:`noopener`,children:[Kl(r,{text:()=>this.getCurrentLink(r.view.state)?.href||``})]}),Nl(r,{className:`link-action-bar`,children:[$(r,{icon:`delete-line`,label:()=>r.rte.getLocale().richTextEditor.delete,connotation:`alert`,variant:`popover`,noTooltip:!0,onClick:()=>{let{state:e,dispatch:t}=r.view;this.removeLink(e,t)}}),$(r,{icon:`edit-line`,label:()=>r.rte.getLocale().richTextEditor.edit,variant:`popover`,noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,n.requestOpenState(!1),!0)})]})]})]});return n.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(n),{update:e=>{let t=e.state;r.updateBindings();let i=this.getCurrentLink(t);n.requestOpenState(!!i)},destroy:()=>{n.remove()}}}})),this.contribution(W({Escape:e=>this.getCurrentLink(e)?(n?.dismiss(),!0):!1,"Mod-k":t}))]}getToolbarItems(e){let t=e=>{let{from:t,to:n}=e.selection;return t===n?``:e.doc.textBetween(t,n,` `)};return[this.contribution({section:`insert`,render:n=>{let r=Gl(n,{label:()=>n.rte.getLocale().richTextEditor.linkText,placeholder:()=>n.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:`header`,autofocus:!0,value:()=>this.getCurrentLink(n.view.state)?.text||t(n.view.state)||``,onInput:()=>{s()}}),i=Gl(n,{label:()=>n.rte.getLocale().richTextEditor.linkUrl,type:`url`,placeholder:()=>n.rte.getLocale().richTextEditor.linkUrlPlaceholder,helperText:()=>n.rte.getLocale().richTextEditor.linkUrlHelperText,slot:`header`,value:()=>this.getCurrentLink(n.view.state)?.href||``,onInput:()=>{s()}}),a=()=>!(r.value.length&&Bc(i.value)),o=$(n,{label:()=>n.rte.getLocale().richTextEditor.apply,variant:`popover-primary`,disabled:a,onClick:()=>{let{state:t,dispatch:a}=n.view;this.insertLink(e,i.value,r.value)(t,a),this.toolbarMenu.open=!1}}),s=()=>{o.querySelector(`[data-vvd-component="button"]`).disabled=a()},c=Ll(n,{label:()=>n.rte.getLocale().richTextEditor.hyperlink,trigger:$(n,{label:()=>n.rte.getLocale().richTextEditor.hyperlink,icon:`link-line`}),children:[Nl(n,{className:`link-toolbar-menu`,slot:`header`,children:[r,i,Nl(n,{className:`link-action-bar`,slot:`header`,children:[$(n,{label:()=>n.rte.getLocale().richTextEditor.cancel,variant:`popover`,onClick:()=>{this.toolbarMenu.open=!1}}),o]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){let t=e.selection;if(!(t instanceof D))return null;let n=e.schema.marks.link,{$from:r,$to:i}=t,a=e.selection.empty?r.marks():r.nodeAfter?.marks??[],o=n.isInSet(a)?.attrs.href;if(!o)return null;let s=e=>n.isInSet(e.marks)?.attrs.href===o,c=null,l=[];e.doc.nodesBetween(r.start(),i.end(),(e,t)=>{if(!e.isText)return!0;let n=t+e.nodeSize;return s(e)?c?c.end=n:(c={start:t,end:n},l.push(c)):c=null,!1});let u=l.find(e=>e.start<=t.from&&e.end>=t.to);return u?{text:e.doc.textBetween(u.start,u.end,` `),href:o,start:u.start,end:u.end}:null}insertLink(e,t,n){return(r,i)=>{let{from:a,to:o}=r.selection,s=r.tr,c=this.getCurrentLink(r);return c&&(a=c.start,o=c.end),s.insertText(n,a,o),s.addMark(a,a+n.length,e.schema.marks.link.create({href:t})),i?.(s.scrollIntoView()),!0}}},Id=Object.assign(_.a(Fd),{marks:Pd}),Ld=`.inline-image-wrapper{vertical-align:text-bottom;display:inline-block}.inline-image{block-size:auto;display:block}.inline-image-popover{align-items:center;gap:4px;padding:8px;display:flex}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}`,Rd=e=>e!==null&&!!e.next,zd=1,Bd=()=>zd++,Vd=class{constructor(e,t,n,r){this.view=t,this.getPos=n,this.config=r,this.content=null,this.dom=document.createElement(`div`),this.dom.className=`inline-image-wrapper`,this.imageUrl=e.attrs.imageUrl,this.img=document.createElement(`img`),this.initializeImg(e);let i=this.config.resolveUrl?this.config.resolveUrl(this.imageUrl):this.imageUrl,a=Rd(i)?null:i;this.handleResolvedUrl(a),Rd(i)&&this.handleResolvedUrlGenerator(i)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),b.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){let t=e[Symbol.asyncIterator](),n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e==`string`)this.renderImg(e);else if(e?.type===`placeholder`){let t=`inline-image-placeholder-${Bd()}`,n=document.createElement(`slot`);n.className=`inline-image-placeholder`,n.name=t;let r=e.create?.(t),i=this.view.dom.getRootNode().host;_.t(i,`inline-image-placeholder`,t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{_.t(i,`inline-image-placeholder`,t,_.n),r?.()}})}else this.setContent(null)}initializeImg(e){this.img.className=`inline-image`,this.update(e),this.img.addEventListener(`load`,()=>{let e=this.getPos();if(e){let{state:t,dispatch:n}=this.view,r=t.doc.nodeAt(e);if(!r||r.attrs.naturalWidth===this.img.naturalWidth&&r.attrs.naturalHeight===this.img.naturalHeight)return;let i=t.tr;i.setNodeAttribute(e,`naturalWidth`,this.img.naturalWidth),i.setNodeAttribute(e,`naturalHeight`,this.img.naturalHeight),i.setMeta(`addToHistory`,!1),n(i)}})}renderImg(e){this.img.src=Vc(e),this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}},Hd={inlineImage:`inlineImage`},Ud=class extends _.r{constructor(e={}){super(),this.config=e,this.name=`RteInlineImageFeature`}getStyles(){return[this.contribution(Ld)]}getSchema(){let e={inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{imageUrl:{validate:`string`},alt:{validate:`string`,default:``},size:{validate:`string|null`,default:null},naturalWidth:{validate:`number|null`,default:null},naturalHeight:{validate:`number|null`,default:null}},parseDOM:[{tag:`img[src],img[data-src]`,getAttrs:e=>{let t=e=>{let t=parseInt(e??``,10);return isNaN(t)?null:t},n=e.getAttribute(`data-src`)??e.getAttribute(`src`),r=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(n):n;return r!==null&&{imageUrl:r,alt:e.getAttribute(`alt`)||``,size:this.config.parseSizeFromHtml?this.config.parseSizeFromHtml(e):e.style.maxWidth||null,naturalWidth:t(e.getAttribute(`width`)),naturalHeight:t(e.getAttribute(`height`))}}}],toDOM:e=>{let{imageUrl:t,alt:n,size:r,naturalWidth:i,naturalHeight:a}=e.attrs,o=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(t):t;if(o===null)return document.createTextNode(``);let s={src:Vc(o),"data-src":o,alt:n};return r&&(s.style=`max-width: ${Hc(r)}; height: auto;`),i&&(s.width=i),a&&(s.height=a),[`img`,s]}};return[this.contribution({nodes:{[Hd.inlineImage]:e}})]}getPlugins(e){let t;return[this.contribution(new j({props:{nodeViews:{inlineImage:(e,t,n)=>new Vd(e,t,n,this.config)}},view:n=>{let r=new Ml(n,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});t=e.createComponent(b),t.kind=`imageOptions`,t.offset=4;let i=Nl(r,{className:`inline-image-popover`,children:[$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.small,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`small`,onClick:()=>{this.setSelectedImageSize(`small`)(r.view.state,r.view.dispatch)}}),Wl(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.fit,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`fit`,onClick:()=>{this.setSelectedImageSize(`fit`)(r.view.state,r.view.dispatch)}}),Wl(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.original,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`original`,onClick:()=>{this.setSelectedImageSize(`original`)(r.view.state,r.view.dispatch)}})]});return t.appendChild(i),n.dom.getRootNode().querySelector(`.popovers`).appendChild(t),{update:e=>{r.updateBindings();let n=this.getSelectedInlineImage(e.state);n?(t.anchorEl=e.nodeDOM(n.pos),t.requestOpenState(!0)):(t.anchorEl=void 0,t.requestOpenState(!1))},destroy:()=>{t.remove()}}}})),this.contribution(W({Escape:e=>this.getSelectedInlineImage(e)?(t?.dismiss(),!0):!1}))]}calculateSmallWidth(e){return`${Math.min(300,e/2)}px`}getSelectedInlineImage(e){let t=e.selection;return t instanceof k&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{let r=this.getSelectedInlineImage(t);if(!r)return!1;let{naturalWidth:i}=r.node.attrs;if(e===`small`&&i===null)return!1;let a=t.tr;return a.setNodeAttribute(r.pos,`size`,e===`small`?this.calculateSmallWidth(i):e===`fit`?`100%`:null),n?.(a.scrollIntoView()),!0}}getSelectedImageSize(e){let t=this.getSelectedInlineImage(e);if(!t)return null;let{size:n,naturalWidth:r}=t.node.attrs;return r!==null&&n===this.calculateSmallWidth(r)?`small`:n===`100%`?`fit`:n===null?`original`:null}},Wd=Object.assign(_.a(Ud),{nodes:Hd}),Gd=async e=>{try{return{type:`ok`,result:await e}}catch(e){return{type:`error`,error:e}}},Kd=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteFileHandlerFeature`}getPlugins(e){let t=new j({state:{init(){return V.empty},apply(e,n){n=n.map(e.mapping,e.doc);let r=e.getMeta(t);if(r&&r.add){let t=document.createElement(`placeholder`),i=B.widget(r.add.pos,t,{id:r.add.id,relaxedSide:!0});n=n.add(e.doc,[i])}else r&&r.remove&&(n=n.remove(n.find(void 0,void 0,e=>e.id==r.remove.id)));return n}},props:{decorations(e){return this.getState(e)}}}),n=(e,n)=>{let r=u.n();return e.setMeta(t,{add:{id:r,pos:n}}),{getPos:e=>{let n=t.getState(e).find(void 0,void 0,e=>e.id==r);return n.length?n[0].from:null},remove:e=>{e.setMeta(t,{remove:{id:r}})}}},r=(t,n,r)=>{if(r.type===`selection`){let r=_.v.fromJSON(e.schema,{content:n});t.replaceSelection(r)}else{let i=_.d.fromJSON(e.schema,n);t.insert(r.pos,i)}},i=(e,t)=>{let n=this.config.handleFiles(e);n!==null&&(n instanceof Promise?o(n,t):a(n,t))},a=(t,n)=>{let i=e.state.tr;r(i,t,n),e.dispatchTransaction(i)},o=async(t,i)=>{let a=e.state.tr;i.type===`selection`&&!a.selection.empty&&a.deleteSelection();let o=i.type===`selection`?a.selection.from:i.pos,s=n(a,o);e.dispatchTransaction(a);let c=await Gd(t),l=s.getPos(e.state),u=e.state.tr;s.remove(u),l!==null&&c.type===`ok`&&r(u,c.result,{type:`pos`,pos:l}),e.dispatchTransaction(u),c.type===`error`&&console.error(`Error in handleFiles handler:`,c.error)};return[this.contribution(t),this.contribution(new j({props:{handlePaste:(e,t)=>{let n=Array.from(t.clipboardData.files);return n.length?(i(n,{type:`selection`}),!0):!1},handleDrop:(e,t)=>{let n=Array.from(t.dataTransfer.files);if(!n.length)return!1;let r=e.posAtCoords({left:t.clientX,top:t.clientY}).pos;if(e.dragging&&e.dragging.slice){let t=Ge(e.state.doc,r,e.dragging.slice);t!=null&&(r=t)}return i(n,{type:`pos`,pos:r}),!0}}}))]}},qd=_.a(Kd),Jd=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteDebugFeature`}getPlugins(){let e=new WeakMap,t=!1,n=n=>{e.get(n)===void 0&&(t=this.config.onViewportDragOver?.(n)??!1)},r=e=>{this.config.onViewportDrop?.(e),this.config.onViewportDragFinish?.()},i=()=>{this.config.onViewportDragFinish?.()},a=!1,o=()=>{a=!0,window.setTimeout(()=>a=!1,0)},s=()=>{a||this.config.onViewportDragFinish?.()};return[this.contribution(new j({view:e=>{let t=e.root.host.editorViewportElement;return t.addEventListener(`dragover`,n),t.addEventListener(`drop`,r),t.addEventListener(`dragend`,i),t.addEventListener(`dragenter`,o),t.addEventListener(`dragleave`,s),{destroy(){t.removeEventListener(`dragover`,n),t.removeEventListener(`drop`,r),t.removeEventListener(`dragend`,i),t.removeEventListener(`dragenter`,o),t.removeEventListener(`dragleave`,s)}}}})),this.contribution(new j({props:{handleDOMEvents:{dragover:(n,r)=>{let i=this.config.onViewportDragOver?.(r)??!1;return e.set(r,i),t=i,i?(r.stopImmediatePropagation(),r.preventDefault(),!0):!1},drop:()=>t}}}),_.i.high)]}},Yd=_.a(Jd),Xd=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:`insert`,render:e=>$(e,{label:this.options.label,icon:this.options.icon,onClick:()=>{this.executeAction(e)}})},2+(this.options.order??0)/(2**53-1))]}executeAction(e){let{action:t}=this.options;switch(t.type){case`insert-text`:{let{state:n,dispatch:r}=e.view,{from:i,to:a}=n.selection;r(n.tr.insertText(t.text,i,a));break}}}},Zd=_.a(Xd),Qd=e=>typeof e==`object`&&!!e&&`next`in e,$d=/^[a-zA-Z0-9-]+$/,ef=e=>e==null?{text:``,variant:[]}:typeof e==`string`?{text:e,variant:[]}:{text:e.text,variant:(e.variant??[]).filter(e=>$d.test(e)?!0:(console.warn(`[rich-text-editor] Ignoring invalid atom variant "${e}".`),!1))},tf=(e,t)=>[`node--${e}`,...t.map(e=>`atom-variant--${e}`)].join(` `),nf=class{constructor(e,t,n){this.atomName=n,this.dom=document.createElement(`span`),this.dom.className=`atom-wrapper`;let r=t.resolveValue?t.resolveValue(e.attrs.value):e.attrs.value;Qd(r)?(this.render(null),this.handleResolvedGenerator(r)):this.render(r)}render(e){let{text:t,variant:n}=ef(e);this.dom.textContent!==t&&(this.dom.textContent=t);let r=tf(this.atomName,n);this.dom.getAttribute(`part`)!==r&&this.dom.setAttribute(`part`,r)}async handleResolvedGenerator(e){let t=e[Symbol.asyncIterator]();try{let e;do e=await t.next(),this.render(e.value??null);while(!e.done)}catch(e){this.render(null),console.warn(`[rich-text-editor] Error while resolving atom value:`,e)}}},rf=class extends _.r{constructor(e,t={}){super(),this.atomName=e,this.config=t,this.name=`RteAtomFeature[${e}]`}getSchema(){let e={inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{value:{validate:`string`}},parseDOM:[{tag:`span[data-atom-type="${this.atomName}"][data-value]`,getAttrs:e=>({value:e.getAttribute(`data-value`)})}],toDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createDocumentFragment():[`span`,{part:tf(this.atomName,[])},t]},serializeToDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createTextNode(``):[`span`,{"data-atom-type":this.atomName,"data-value":e.attrs.value},t]}};return[this.contribution({nodes:{[this.atomName]:e}})]}getPlugins(e){return[this.contribution(new j({props:{nodeViews:{[this.atomName]:e=>new nf(e,this.config,this.atomName)}}}))]}},af=_.a(rf),of=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteInputRuleFeature[${e}]`}getInputRules(e){let t=`(?:${this.options.pattern.source})`,n=(t,n,r,i)=>{let a=this.options.handler(n);return a?t.tr.replaceWith(r,i,_.d.fromJSON(e.schema,a)):null},r={rule:new Zl(this.options.matchAfterWhitespace?RegExp(`${t} $`):RegExp(`${t}$`),n)};return this.options.matchAfterWhitespace&&(r.enterHandler={regex:RegExp(`${t}$`),handler:n}),[this.contribution(r)]}},sf=_.a(of);function cf(e,t){return(n,r)=>e(t)}var lf=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteKeyboardShortcutsFeature[${e}]`}getPlugins(e){let t={};for(let[n,r]of Object.entries(this.options.shortcuts))t[n]=cf(r,e.facade);return[this.contribution(W(t),_.i.high)]}},uf=_.a(lf),df=`.suggest-popover{flex-direction:column;gap:2px;max-block-size:408px;min-inline-size:128px;max-inline-size:248px;padding:4px;display:flex}.suggest-loading-widget{vertical-align:middle;white-space:normal;align-items:center;margin-inline-start:2px;display:inline-flex}.suggest-empty-message{color:var(--vvd-color-neutral-300);font:var(--vvd-typography-base);text-align:center;justify-content:center;align-items:center;min-block-size:40px;display:flex}`,ff=e=>`suggestions`in e,pf=e=>!(!e?.suggestions||e.dismissed),mf=e=>pf(e)&&e.suggestions.items.length>0;function hf(e,t){let{$cursor:n}=e.selection;if(!n)return null;let r=ru(n),i=t.exec(r);if(!i)return null;let a=n.pos-n.parentOffset;return{text:i[0],groups:[...i],start:a+i.index,end:a+i.index+i[0].length}}var gf=(e,t,n)=>{let{state:r}=e;e.dispatch(Cl(r.tr));let i=e.state.tr;i.replaceWith(t.start,t.end,_.d.fromJSON(e.state.schema,n));let a=i.mapping.map(t.end);i.setSelection(D.create(i.doc,a)),e.dispatch(i.scrollIntoView())},_f=class extends _.r{selectSuggestion(e,t,n){let r=this.options.select(n);gf(e,t.match,r),e.focus()}async startLoadingSuggestions(e,t){let n=++this.loadGeneration,r=await this.options.load(e);n===this.loadGeneration&&t({type:`load`,generation:n,entries:r})}constructor(e,t){super(),this.featureId=e,this.options=t,this.pluginKey=new Mt(`suggest`),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}getStyles(){return[this.contribution(df)]}getPlugins(e){let t=t=>e.state.tr.setMeta(this.pluginKey,t),n=n=>e.dispatchTransaction(t(n)),r=new j({key:this.pluginKey,state:{init:()=>null,apply:(t,r,i,o)=>{let s=hf(o,this.options.pattern);if(!s||!r&&!t.docChanged)return null;if(r?.dismissed)return r;let c=n=>n?r?.loadingDecoration.find().length??0?r.loadingDecoration.map(t.mapping,t.doc):V.create(t.doc,[B.widget(s.end,()=>{let t=document.createElement(`span`);t.className=`suggest-loading-widget`;let n=e.createComponent(a.r);return n.size=-6,t.appendChild(n),t},{ignoreSelection:!0,side:1})]):V.empty,l=t.getMeta(this.pluginKey);if(r&&l)switch(l.type){case`load`:{let e=l.entries.filter(e=>!ff(e)||e.suggestions.length>0);return{...r,suggestions:{generation:l.generation,entries:e,items:e.flatMap(e=>ff(e)?e.suggestions:[e]),selectedIndex:0,visibleFocus:!1},loadingDecoration:c(!1)}}case`navigate`:{if(!r.suggestions?.items.length)return r;if(!r.suggestions.visibleFocus)return{...r,suggestions:{...r.suggestions,visibleFocus:!0}};let e=Math.max(0,Math.min(r.suggestions.items.length-1,r.suggestions.selectedIndex+(l.action===`up`?-1:1)));return{...r,suggestions:{...r.suggestions,selectedIndex:e}}}case`dismiss`:return{...r,dismissed:!0,loadingDecoration:V.empty}}if(!r)return this.startLoadingSuggestions(s.groups,n),{match:s,loadingDecoration:c(!0)};let u=s.groups[0]!==r.match.groups[0];return u&&this.startLoadingSuggestions(s.groups,n),{...r,match:s,suggestions:r.suggestions?{...r.suggestions,visibleFocus:!1}:void 0,loadingDecoration:c(u)}}},props:{decorations:e=>{let t=this.pluginKey.getState(e);return t?t.loadingDecoration.add(e.doc,[B.inline(t.match.start,t.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:t=>{let n=new Ml(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0}),r=e.createComponent(b);r.anchorId=`suggest-anchor-${this.featureId}`,r.kind=`autocomplete`,r.offset=4;let i=Nl(n,{className:`suggest-popover`,children:[]});r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r);let a=`${this.featureId}-suggestions-empty`,o=t.dom.getRootNode().host,s=!1,c=e=>{!s&&e&&_.t(o,`suggestions-empty-state`,a,{id:this.featureId}),s&&!e&&_.t(o,`suggestions-empty-state`,a,_.n),s=e},l=r=>{i.innerHTML=``;let o=r.suggestions,s=o.items.length===0;if(c(s),s){let t=document.createElement(`slot`);t.name=a,t.textContent=e.getLocale().richTextEditor.suggestNoResults,i.appendChild(Nl(n,{className:`suggest-empty-message`,children:[t]}));return}let l=(n,i,a)=>{let s=e.createComponent(f.t);if(s.text=n.text,s.textSecondary=n.textSecondary,s.icon=n.icon,i===o.selectedIndex){s.selected=!0,o.visibleFocus&&(s._highlighted=!0);let e=a??s;queueMicrotask(()=>{e.scrollIntoView({block:`nearest`})})}return s.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this.selectSuggestion(t,r,n)}),s},u=0;for(let t of o.entries){if(!ff(t)){i.appendChild(l(t,u++));continue}let n=e.createComponent(m.t),r=document.createElement(`span`);r.slot=`label`,r.textContent=t.label,n.appendChild(r);for(let[e,r]of t.suggestions.entries())n.appendChild(l(r,u++,e===0?n:void 0));i.appendChild(n)}};return{update:e=>{n.updateBindings();let t=this.pluginKey.getState(e.state),i=pf(t);r.requestOpenState(i),i?l(t):c(!1)},destroy:()=>{c(!1),r.remove()}}}});return[this.contribution(r),this.contribution(W({ArrowUp:(e,n)=>mf(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`up`})),!0):!1,ArrowDown:(e,n)=>mf(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`down`})),!0):!1,Enter:(e,t,n)=>{let r=this.pluginKey.getState(e);if(!mf(r))return!1;let i=r.suggestions.items[r.suggestions.selectedIndex];return n&&this.selectSuggestion(n,r,i),!0},Escape:(e,n)=>pf(this.pluginKey.getState(e))?(n?.(t({type:`dismiss`})),!0):!1}),_.i.high)]}},vf=_.a(_f),yf=e=>e.textBetween(0,e.content.size,void 0,` `).length,bf=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteCharacterCountFeature`}getPlugins(){let e=this.config?.limit;return e===void 0?[]:[this.contribution(new j({filterTransaction:(t,n)=>{if(!t.docChanged)return!0;let r=yf(n.doc),i=yf(t.doc);if(i<=e)return!0;if(r>e)return i<=r;if(!t.getMeta(`paste`))return!1;let a=t.selection.$head.pos,o=a-(i-e),s=a;return t.deleteRange(o,s),yf(t.doc)<=e}}))]}getPublicInterface(e){let t=this.config?.limit;return{get characters(){return yf(e.state.doc)},get limit(){return t}}}},xf=_.a(bf),Sf=t.u(`rich-text-editor`,ie,ae,[ee.t,g.n,p.t,h.t,s.t,l.n,ne.t,v.t,d.n,se,a.t],{styles:re,shadowOptions:{delegatesFocus:!0}});t.d(Sf)(),exports.RteAlignmentFeature=Ad,exports.RteAtomFeature=af,exports.RteBase=su,exports.RteBoldFeature=Iu,exports.RteCharacterCountFeature=xf,exports.RteConfig=nl,exports.RteDropHandlerFeature=Yd,exports.RteFileHandlerFeature=qd,exports.RteFontSizePickerFeature=Su,exports.RteHardBreakFeature=vu,exports.RteHtmlParser=Gc,exports.RteHtmlSerializer=Jc,exports.RteInlineImageFeature=Wd,exports.RteInputRuleFeature=sf,exports.RteItalicFeature=zu,exports.RteKeyboardShortcutsFeature=uf,exports.RteLinkFeature=Id,exports.RteListFeature=Ed,exports.RteMonospaceFeature=Yu,exports.RtePlaceholderFeature=hu,exports.RteStrikethroughFeature=Gu,exports.RteSuggestFeature=vf,exports.RteTextBlockPickerFeature=lu,exports.RteTextColorPickerFeature=td,exports.RteToolbarButtonFeature=Zd,exports.RteToolbarFeature=fu,exports.RteUnderlineFeature=Hu;