@dialpad/dialtone 9.175.2 → 9.176.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.
@@ -1,21 +1,12 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("../../node_modules/@tiptap/vue-3.cjs"),T=require("@tiptap/core"),j=require("@tiptap/pm/state"),kt=require("@tiptap/pm/tables"),a=require("vue"),Et=require("@tiptap/extension-blockquote"),Ot=require("@tiptap/extension-code-block"),St=require("@tiptap/extension-code"),Lt=require("@tiptap/extension-document"),ve=require("@tiptap/extensions"),At=require("@tiptap/extension-hard-break"),Ge=require("@tiptap/extension-paragraph"),Dt=require("@tiptap/extension-bold"),xe=require("@tiptap/extension-list"),It=require("@tiptap/extension-italic"),Bt=require("@tiptap/extension-link"),Rt=require("@tiptap/extension-strike"),Mt=require("@tiptap/extension-underline"),Nt=require("@tiptap/extension-text"),Ht=require("@tiptap/extension-text-align"),pe=require("@tiptap/extension-table"),Je=require("@tiptap/extension-text-style"),Vt=require("@tiptap/suggestion"),Ze=require("regex-combined-emojis"),F=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),Qe=require("../emoji/emoji.cjs"),te=require("../../common/emoji/index.cjs"),$t=require("../list-item/list-item.cjs"),le=require("../stack/stack.cjs"),re=require("../../common/utils/index.cjs"),Pt=require("@tiptap/extension-image"),ke=require("@tiptap/extension-mention"),et=require("../link/link.cjs"),Ut=require("@dialpad/dialtone-icons/vue3"),tt=require("../../localization/index.cjs"),jt=require("../input/input.cjs"),zt=require("../popover/popover.cjs"),nt=require("../button/button.cjs"),qt=require("../badge/badge.cjs"),de=require("./rich-text-editor-constants.cjs"),Ft=require("../avatar/avatar.cjs"),Kt=require("@dialpad/dialtone-icons/vue3/hash"),Wt=require("@dialpad/dialtone-icons/vue3/lock"),Xt=require("deep-equal"),ot=["top","right","bottom","left"],Me=["start","end"],Ne=ot.reduce((e,t)=>e.concat(t,t+"-"+Me[0],t+"-"+Me[1]),[]),X=Math.min,I=Math.max,ue=Math.round,W=e=>({x:e,y:e}),Yt={left:"right",right:"left",bottom:"top",top:"bottom"},Gt={start:"end",end:"start"};function Te(e,t,o){return I(e,X(t,o))}function G(e,t){return typeof e=="function"?e(t):e}function $(e){return e.split("-")[0]}function U(e){return e.split("-")[1]}function it(e){return e==="x"?"y":"x"}function Ee(e){return e==="y"?"height":"width"}const Jt=new Set(["top","bottom"]);function K(e){return Jt.has($(e))?"y":"x"}function Oe(e){return it(K(e))}function st(e,t,o){o===void 0&&(o=!1);const n=U(e),i=Oe(e),s=Ee(i);let r=i==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=fe(r)),[r,fe(r)]}function Zt(e){const t=fe(e);return[he(e),t,he(t)]}function he(e){return e.replace(/start|end/g,t=>Gt[t])}const He=["left","right"],Ve=["right","left"],Qt=["top","bottom"],en=["bottom","top"];function tn(e,t,o){switch(e){case"top":case"bottom":return o?t?Ve:He:t?He:Ve;case"left":case"right":return t?Qt:en;default:return[]}}function nn(e,t,o,n){const i=U(e);let s=tn($(e),o==="start",n);return i&&(s=s.map(r=>r+"-"+i),t&&(s=s.concat(s.map(he)))),s}function fe(e){return e.replace(/left|right|bottom|top/g,t=>Yt[t])}function on(e){return{top:0,right:0,bottom:0,left:0,...e}}function Se(e){return typeof e!="number"?on(e):{top:e,right:e,bottom:e,left:e}}function oe(e){const{x:t,y:o,width:n,height:i}=e;return{width:n,height:i,top:o,left:t,right:t+n,bottom:o+i,x:t,y:o}}function $e(e,t,o){let{reference:n,floating:i}=e;const s=K(t),r=Oe(t),l=Ee(r),c=$(t),h=s==="y",u=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,f=n[l]/2-i[l]/2;let p;switch(c){case"top":p={x:u,y:n.y-i.height};break;case"bottom":p={x:u,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-i.width,y:d};break;default:p={x:n.x,y:n.y}}switch(U(t)){case"start":p[r]-=f*(o&&h?-1:1);break;case"end":p[r]+=f*(o&&h?-1:1);break}return p}async function sn(e,t){var o;t===void 0&&(t={});const{x:n,y:i,platform:s,rects:r,elements:l,strategy:c}=e,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=G(t,e),m=Se(p),w=l[f?d==="floating"?"reference":"floating":d],y=oe(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(w)))==null||o?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:h,rootBoundary:u,strategy:c})),v=d==="floating"?{x:n,y:i,width:r.floating.width,height:r.floating.height}:r.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),_=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},k=oe(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:x,strategy:c}):v);return{top:(y.top-k.top+m.top)/_.y,bottom:(k.bottom-y.bottom+m.bottom)/_.y,left:(y.left-k.left+m.left)/_.x,right:(k.right-y.right+m.right)/_.x}}const rn=async(e,t,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:s=[],platform:r}=o,l=s.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=$e(h,n,c),f=n,p={},m=0;for(let w=0;w<l.length;w++){var g;const{name:y,fn:v}=l[w],{x,y:_,data:k,reset:C}=await v({x:u,y:d,initialPlacement:n,placement:f,strategy:i,middlewareData:p,rects:h,platform:{...r,detectOverflow:(g=r.detectOverflow)!=null?g:sn},elements:{reference:e,floating:t}});u=x??u,d=_??d,p={...p,[y]:{...p[y],...k}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:u,y:d}=$e(h,f,c)),w=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},an=e=>({name:"arrow",options:e,async fn(t){const{x:o,y:n,placement:i,rects:s,platform:r,elements:l,middlewareData:c}=t,{element:h,padding:u=0}=G(e,t)||{};if(h==null)return{};const d=Se(u),f={x:o,y:n},p=Oe(i),m=Ee(p),g=await r.getDimensions(h),w=p==="y",y=w?"top":"left",v=w?"bottom":"right",x=w?"clientHeight":"clientWidth",_=s.reference[m]+s.reference[p]-f[p]-s.floating[m],k=f[p]-s.reference[p],C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let L=C?C[x]:0;(!L||!await(r.isElement==null?void 0:r.isElement(C)))&&(L=l.floating[x]||s.floating[m]);const H=_/2-k/2,A=L/2-g[m]/2-1,b=X(d[y],A),E=X(d[v],A),D=b,B=L-g[m]-E,O=L/2-g[m]/2+H,P=Te(D,O,B),V=!c.arrow&&U(i)!=null&&O!==P&&s.reference[m]/2-(O<D?b:E)-g[m]/2<0,R=V?O<D?O-D:O-B:0;return{[p]:f[p]+R,data:{[p]:P,centerOffset:O-P-R,...V&&{alignmentOffset:R}},reset:V}}});function ln(e,t,o){return(e?[...o.filter(i=>U(i)===e),...o.filter(i=>U(i)!==e)]:o.filter(i=>$(i)===i)).filter(i=>e?U(i)===e||(t?he(i)!==i:!1):!0)}const cn=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var o,n,i;const{rects:s,middlewareData:r,placement:l,platform:c,elements:h}=t,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Ne,autoAlignment:p=!0,...m}=G(e,t),g=d!==void 0||f===Ne?ln(d||null,p,f):f,w=await c.detectOverflow(t,m),y=((o=r.autoPlacement)==null?void 0:o.index)||0,v=g[y];if(v==null)return{};const x=st(v,s,await(c.isRTL==null?void 0:c.isRTL(h.floating)));if(l!==v)return{reset:{placement:g[0]}};const _=[w[$(v)],w[x[0]],w[x[1]]],k=[...((n=r.autoPlacement)==null?void 0:n.overflows)||[],{placement:v,overflows:_}],C=g[y+1];if(C)return{data:{index:y+1,overflows:k},reset:{placement:C}};const L=k.map(b=>{const E=U(b.placement);return[b.placement,E&&u?b.overflows.slice(0,2).reduce((D,B)=>D+B,0):b.overflows[0],b.overflows]}).sort((b,E)=>b[1]-E[1]),A=((i=L.filter(b=>b[2].slice(0,U(b[0])?2:3).every(E=>E<=0))[0])==null?void 0:i[0])||L[0][0];return A!==l?{data:{index:y+1,overflows:k},reset:{placement:A}}:{}}}},dn=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var o,n;const{placement:i,middlewareData:s,rects:r,initialPlacement:l,platform:c,elements:h}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...w}=G(e,t);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const y=$(i),v=K(l),x=$(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(h.floating)),k=f||(x||!g?[fe(l)]:Zt(l)),C=m!=="none";!f&&C&&k.push(...nn(l,g,m,_));const L=[l,...k],H=await c.detectOverflow(t,w),A=[];let b=((n=s.flip)==null?void 0:n.overflows)||[];if(u&&A.push(H[y]),d){const O=st(i,r,_);A.push(H[O[0]],H[O[1]])}if(b=[...b,{placement:i,overflows:A}],!A.every(O=>O<=0)){var E,D;const O=(((E=s.flip)==null?void 0:E.index)||0)+1,P=L[O];if(P&&(!(d==="alignment"?v!==K(P):!1)||b.every(M=>K(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:O,overflows:b},reset:{placement:P}};let V=(D=b.filter(R=>R.overflows[0]<=0).sort((R,M)=>R.overflows[1]-M.overflows[1])[0])==null?void 0:D.placement;if(!V)switch(p){case"bestFit":{var B;const R=(B=b.filter(M=>{if(C){const Z=K(M.placement);return Z===v||Z==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(Z=>Z>0).reduce((Z,Ct)=>Z+Ct,0)]).sort((M,Z)=>M[1]-Z[1])[0])==null?void 0:B[0];R&&(V=R);break}case"initialPlacement":V=l;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function Pe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ue(e){return ot.some(t=>e[t]>=0)}const un=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:o,platform:n}=t,{strategy:i="referenceHidden",...s}=G(e,t);switch(i){case"referenceHidden":{const r=await n.detectOverflow(t,{...s,elementContext:"reference"}),l=Pe(r,o.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ue(l)}}}case"escaped":{const r=await n.detectOverflow(t,{...s,altBoundary:!0}),l=Pe(r,o.floating);return{data:{escapedOffsets:l,escaped:Ue(l)}}}default:return{}}}}};function rt(e){const t=X(...e.map(s=>s.left)),o=X(...e.map(s=>s.top)),n=I(...e.map(s=>s.right)),i=I(...e.map(s=>s.bottom));return{x:t,y:o,width:n-t,height:i-o}}function hn(e){const t=e.slice().sort((i,s)=>i.y-s.y),o=[];let n=null;for(let i=0;i<t.length;i++){const s=t[i];!n||s.y-n.y>n.height/2?o.push([s]):o[o.length-1].push(s),n=s}return o.map(i=>oe(rt(i)))}const fn=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:o,elements:n,rects:i,platform:s,strategy:r}=t,{padding:l=2,x:c,y:h}=G(e,t),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(n.reference))||[]),d=hn(u),f=oe(rt(u)),p=Se(l);function m(){if(d.length===2&&d[0].left>d[1].right&&c!=null&&h!=null)return d.find(w=>c>w.left-p.left&&c<w.right+p.right&&h>w.top-p.top&&h<w.bottom+p.bottom)||f;if(d.length>=2){if(K(o)==="y"){const b=d[0],E=d[d.length-1],D=$(o)==="top",B=b.top,O=E.bottom,P=D?b.left:E.left,V=D?b.right:E.right,R=V-P,M=O-B;return{top:B,bottom:O,left:P,right:V,width:R,height:M,x:P,y:B}}const w=$(o)==="left",y=I(...d.map(b=>b.right)),v=X(...d.map(b=>b.left)),x=d.filter(b=>w?b.left===v:b.right===y),_=x[0].top,k=x[x.length-1].bottom,C=v,L=y,H=L-C,A=k-_;return{top:_,bottom:k,left:C,right:L,width:H,height:A,x:C,y:_}}return f}const g=await s.getElementRects({reference:{getBoundingClientRect:m},floating:n.floating,strategy:r});return i.reference.x!==g.reference.x||i.reference.y!==g.reference.y||i.reference.width!==g.reference.width||i.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},pn=new Set(["left","top"]);async function mn(e,t){const{placement:o,platform:n,elements:i}=e,s=await(n.isRTL==null?void 0:n.isRTL(i.floating)),r=$(o),l=U(o),c=K(o)==="y",h=pn.has(r)?-1:1,u=s&&c?-1:1,d=G(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof m=="number"&&(p=l==="end"?m*-1:m),c?{x:p*u,y:f*h}:{x:f*h,y:p*u}}const gn=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var o,n;const{x:i,y:s,placement:r,middlewareData:l}=t,c=await mn(t,e);return r===((o=l.offset)==null?void 0:o.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:r}}}}},wn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:o,y:n,placement:i,platform:s}=t,{mainAxis:r=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:v,y:x}=y;return{x:v,y:x}}},...h}=G(e,t),u={x:o,y:n},d=await s.detectOverflow(t,h),f=K($(i)),p=it(f);let m=u[p],g=u[f];if(r){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=m+d[y],_=m-d[v];m=Te(x,m,_)}if(l){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=g+d[y],_=g-d[v];g=Te(x,g,_)}const w=c.fn({...t,[p]:m,[f]:g});return{...w,data:{x:w.x-o,y:w.y-n,enabled:{[p]:r,[f]:l}}}}}},yn=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var o,n;const{placement:i,rects:s,platform:r,elements:l}=t,{apply:c=()=>{},...h}=G(e,t),u=await r.detectOverflow(t,h),d=$(i),f=U(i),p=K(i)==="y",{width:m,height:g}=s.floating;let w,y;d==="top"||d==="bottom"?(w=d,y=f===(await(r.isRTL==null?void 0:r.isRTL(l.floating))?"start":"end")?"left":"right"):(y=d,w=f==="end"?"top":"bottom");const v=g-u.top-u.bottom,x=m-u.left-u.right,_=X(g-u[w],v),k=X(m-u[y],x),C=!t.middlewareData.shift;let L=_,H=k;if((o=t.middlewareData.shift)!=null&&o.enabled.x&&(H=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(L=v),C&&!f){const b=I(u.left,0),E=I(u.right,0),D=I(u.top,0),B=I(u.bottom,0);p?H=m-2*(b!==0||E!==0?b+E:I(u.left,u.right)):L=g-2*(D!==0||B!==0?D+B:I(u.top,u.bottom))}await c({...t,availableWidth:H,availableHeight:L});const A=await r.getDimensions(l.floating);return m!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function me(){return typeof window<"u"}function se(e){return at(e)?(e.nodeName||"").toLowerCase():"#document"}function N(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function J(e){var t;return(t=(at(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function at(e){return me()?e instanceof Node||e instanceof N(e).Node:!1}function z(e){return me()?e instanceof Element||e instanceof N(e).Element:!1}function Y(e){return me()?e instanceof HTMLElement||e instanceof N(e).HTMLElement:!1}function je(e){return!me()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof N(e).ShadowRoot}const bn=new Set(["inline","contents"]);function ce(e){const{overflow:t,overflowX:o,overflowY:n,display:i}=q(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+o)&&!bn.has(i)}const vn=new Set(["table","td","th"]);function xn(e){return vn.has(se(e))}const _n=[":popover-open",":modal"];function ge(e){return _n.some(t=>{try{return e.matches(t)}catch{return!1}})}const Tn=["transform","translate","scale","rotate","perspective"],Cn=["transform","translate","scale","rotate","perspective","filter"],kn=["paint","layout","strict","content"];function Le(e){const t=Ae(),o=z(e)?q(e):e;return Tn.some(n=>o[n]?o[n]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!t&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!t&&(o.filter?o.filter!=="none":!1)||Cn.some(n=>(o.willChange||"").includes(n))||kn.some(n=>(o.contain||"").includes(n))}function En(e){let t=ee(e);for(;Y(t)&&!ie(t);){if(Le(t))return t;if(ge(t))return null;t=ee(t)}return null}function Ae(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const On=new Set(["html","body","#document"]);function ie(e){return On.has(se(e))}function q(e){return N(e).getComputedStyle(e)}function we(e){return z(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ee(e){if(se(e)==="html")return e;const t=e.assignedSlot||e.parentNode||je(e)&&e.host||J(e);return je(t)?t.host:t}function lt(e){const t=ee(e);return ie(t)?e.ownerDocument?e.ownerDocument.body:e.body:Y(t)&&ce(t)?t:lt(t)}function ct(e,t,o){var n;t===void 0&&(t=[]);const i=lt(e),s=i===((n=e.ownerDocument)==null?void 0:n.body),r=N(i);return s?t.concat(r,r.visualViewport||[],ce(i)?i:[],[]):t.concat(i,ct(i,[]))}function ze(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dt(e){const t=q(e);let o=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const i=Y(e),s=i?e.offsetWidth:o,r=i?e.offsetHeight:n,l=ue(o)!==s||ue(n)!==r;return l&&(o=s,n=r),{width:o,height:n,$:l}}function ut(e){return z(e)?e:e.contextElement}function ne(e){const t=ut(e);if(!Y(t))return W(1);const o=t.getBoundingClientRect(),{width:n,height:i,$:s}=dt(t);let r=(s?ue(o.width):o.width)/n,l=(s?ue(o.height):o.height)/i;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const Sn=W(0);function ht(e){const t=N(e);return!Ae()||!t.visualViewport?Sn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ln(e,t,o){return t===void 0&&(t=!1),!o||t&&o!==N(e)?!1:t}function ae(e,t,o,n){t===void 0&&(t=!1),o===void 0&&(o=!1);const i=e.getBoundingClientRect(),s=ut(e);let r=W(1);t&&(n?z(n)&&(r=ne(n)):r=ne(e));const l=Ln(s,o,n)?ht(s):W(0);let c=(i.left+l.x)/r.x,h=(i.top+l.y)/r.y,u=i.width/r.x,d=i.height/r.y;if(s){const f=N(s),p=n&&z(n)?N(n):n;let m=f,g=ze(m);for(;g&&n&&p!==m;){const w=ne(g),y=g.getBoundingClientRect(),v=q(g),x=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*w.x,_=y.top+(g.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,h*=w.y,u*=w.x,d*=w.y,c+=x,h+=_,m=N(g),g=ze(m)}}return oe({width:u,height:d,x:c,y:h})}function ye(e,t){const o=we(e).scrollLeft;return t?t.left+o:ae(J(e)).left+o}function ft(e,t){const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-ye(e,o),i=o.top+t.scrollTop;return{x:n,y:i}}function An(e){let{elements:t,rect:o,offsetParent:n,strategy:i}=e;const s=i==="fixed",r=J(n),l=t?ge(t.floating):!1;if(n===r||l&&s)return o;let c={scrollLeft:0,scrollTop:0},h=W(1);const u=W(0),d=Y(n);if((d||!d&&!s)&&((se(n)!=="body"||ce(r))&&(c=we(n)),Y(n))){const p=ae(n);h=ne(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop}const f=r&&!d&&!s?ft(r,c):W(0);return{width:o.width*h.x,height:o.height*h.y,x:o.x*h.x-c.scrollLeft*h.x+u.x+f.x,y:o.y*h.y-c.scrollTop*h.y+u.y+f.y}}function Dn(e){return Array.from(e.getClientRects())}function In(e){const t=J(e),o=we(e),n=e.ownerDocument.body,i=I(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=I(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let r=-o.scrollLeft+ye(e);const l=-o.scrollTop;return q(n).direction==="rtl"&&(r+=I(t.clientWidth,n.clientWidth)-i),{width:i,height:s,x:r,y:l}}const qe=25;function Bn(e,t){const o=N(e),n=J(e),i=o.visualViewport;let s=n.clientWidth,r=n.clientHeight,l=0,c=0;if(i){s=i.width,r=i.height;const u=Ae();(!u||u&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const h=ye(n);if(h<=0){const u=n.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(n.clientWidth-d.clientWidth-p);m<=qe&&(s-=m)}else h<=qe&&(s+=h);return{width:s,height:r,x:l,y:c}}const Rn=new Set(["absolute","fixed"]);function Mn(e,t){const o=ae(e,!0,t==="fixed"),n=o.top+e.clientTop,i=o.left+e.clientLeft,s=Y(e)?ne(e):W(1),r=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,h=n*s.y;return{width:r,height:l,x:c,y:h}}function Fe(e,t,o){let n;if(t==="viewport")n=Bn(e,o);else if(t==="document")n=In(J(e));else if(z(t))n=Mn(t,o);else{const i=ht(e);n={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return oe(n)}function pt(e,t){const o=ee(e);return o===t||!z(o)||ie(o)?!1:q(o).position==="fixed"||pt(o,t)}function Nn(e,t){const o=t.get(e);if(o)return o;let n=ct(e,[]).filter(l=>z(l)&&se(l)!=="body"),i=null;const s=q(e).position==="fixed";let r=s?ee(e):e;for(;z(r)&&!ie(r);){const l=q(r),c=Le(r);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&Rn.has(i.position)||ce(r)&&!c&&pt(e,r))?n=n.filter(u=>u!==r):i=l,r=ee(r)}return t.set(e,n),n}function Hn(e){let{element:t,boundary:o,rootBoundary:n,strategy:i}=e;const r=[...o==="clippingAncestors"?ge(t)?[]:Nn(t,this._c):[].concat(o),n],l=r[0],c=r.reduce((h,u)=>{const d=Fe(t,u,i);return h.top=I(d.top,h.top),h.right=X(d.right,h.right),h.bottom=X(d.bottom,h.bottom),h.left=I(d.left,h.left),h},Fe(t,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Vn(e){const{width:t,height:o}=dt(e);return{width:t,height:o}}function $n(e,t,o){const n=Y(t),i=J(t),s=o==="fixed",r=ae(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=W(0);function h(){c.x=ye(i)}if(n||!n&&!s)if((se(t)!=="body"||ce(i))&&(l=we(t)),n){const p=ae(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else i&&h();s&&!n&&i&&h();const u=i&&!n&&!s?ft(i,l):W(0),d=r.left+l.scrollLeft-c.x-u.x,f=r.top+l.scrollTop-c.y-u.y;return{x:d,y:f,width:r.width,height:r.height}}function _e(e){return q(e).position==="static"}function Ke(e,t){if(!Y(e)||q(e).position==="fixed")return null;if(t)return t(e);let o=e.offsetParent;return J(e)===o&&(o=o.ownerDocument.body),o}function mt(e,t){const o=N(e);if(ge(e))return o;if(!Y(e)){let i=ee(e);for(;i&&!ie(i);){if(z(i)&&!_e(i))return i;i=ee(i)}return o}let n=Ke(e,t);for(;n&&xn(n)&&_e(n);)n=Ke(n,t);return n&&ie(n)&&_e(n)&&!Le(n)?o:n||En(e)||o}const Pn=async function(e){const t=this.getOffsetParent||mt,o=this.getDimensions,n=await o(e.floating);return{reference:$n(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Un(e){return q(e).direction==="rtl"}const jn={convertOffsetParentRelativeRectToViewportRelativeRect:An,getDocumentElement:J,getClippingRect:Hn,getOffsetParent:mt,getElementRects:Pn,getClientRects:Dn,getDimensions:Vn,getScale:ne,isElement:z,isRTL:Un},De=gn,gt=cn,Ie=wn,Be=dn,wt=yn,yt=un,bt=an,vt=fn,Re=(e,t,o)=>{const n=new Map,i={platform:jn,...o},s={...i.platform,_c:n};return rn(e,t,{...i,platform:s})};function zn(e,t){const o=Math.min(e.top,t.top),n=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),r=Math.max(e.right,t.right)-i,l=n-o,c=i,h=o;return new DOMRect(c,h,r,l)}var qn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,shouldShow:s,appendTo:r,getReferencedVirtualElement:l,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:d,from:f,to:p})=>{const{doc:m,selection:g}=d,{empty:w}=g,y=!m.textBetween(f,p).length&&T.isTextSelection(d.selection),v=this.element.contains(document.activeElement);return!(!(u.hasFocus()||v)||w||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,d)=>{const f=!(d!=null&&d.selection.eq(u.state.selection)),p=!(d!=null&&d.doc.eq(u.state.doc));!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,f,p,d)},this.updateDelay))},this.updateHandler=(u,d,f,p)=>{const{composing:m}=u;if(m||!d&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta("bubbleMenu");d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"&&this.updateOptions(d.options)};var h;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(h=c==null?void 0:c.scrollTarget)!=null?h:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Be(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(bt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(wt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(gt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(yt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(vt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,o;const{selection:n}=this.editor.state,i=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(i)return i;if(!((o=(t=this.view)==null?void 0:t.dom)!=null&&o.parentNode))return;const s=T.posToDOMRect(this.view,n.from,n.to);let r={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(n instanceof j.NodeSelection){let l=this.view.nodeDOM(n.from);const c=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");c&&(l=c),l&&(r={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(n instanceof kt.CellSelection){const{$anchorCell:l,$headCell:c}=n,h=l?l.pos:c.pos,u=c?c.pos:l.pos,d=this.view.nodeDOM(h),f=this.view.nodeDOM(u);if(!d||!f)return;const p=d===f?d.getBoundingClientRect():zn(d.getBoundingClientRect(),f.getBoundingClientRect());r={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return r}updatePosition(){const e=this.virtualElement;e&&Re(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:o,strategy:n,middlewareData:i})=>{var s,r;if((s=i.hide)!=null&&s.referenceHidden||(r=i.hide)!=null&&r.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const{state:o}=e,n=o.selection.from!==o.selection.to;if(this.updateDelay>0&&n){this.handleDebouncedUpdate(e,t);return}const i=!(t!=null&&t.selection.eq(e.state.selection)),s=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,i,s,t)}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:o,oldState:e,from:s,to:r}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Fn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new qn({view:t,...e})}),Kn=a.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{editor:i,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}=e,f=n.value;f&&(f.style.visibility="hidden",f.style.position="absolute",f.remove(),a.nextTick(()=>{i.registerPlugin(Fn({editor:i,element:f,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}))}))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}}),Wn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,options:s,appendTo:r,shouldShow:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:h,state:u})=>{const{selection:d}=u,{$anchor:f,empty:p}=d,m=f.depth===1,g=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!h.hasFocus()||!p||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(h,u,d,f)=>{const{composing:p}=h;if(p||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var u;if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:h})=>{const u=h.getMeta("floatingMenu");u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"&&this.updateOptions(u.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(c=s==null?void 0:s.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return T.getText(e,{textSerializers:T.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Be(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(bt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(wt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(gt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(yt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(vt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:o,oldState:e,from:s,to:r})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=T.posToDOMRect(this.view,e.from,e.to);Re({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:n,y:i,strategy:s,middlewareData:r})=>{var l,c;if((l=r.hide)!=null&&l.referenceHidden||(c=r.hide)!=null&&c.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${n}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const o=!(t!=null&&t.selection.eq(e.state.selection)),n=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,o,n,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Xn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Wn({view:t,...e})});a.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{pluginKey:i,editor:s,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u}=e,d=n.value;d&&(d.style.visibility="hidden",d.style.position="absolute",d.remove(),s.registerPlugin(Xn({pluginKey:i,editor:s,element:d,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u})))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}});const Q=e=>({default:null,parseHTML:t=>t.getAttribute(e),renderHTML:t=>t[e]?{[e]:t[e]}:{}}),Yn=()=>{let e=Q("style");return e.renderHTML=t=>t.style?{style:Gn(t.style)}:{},e};function Gn(e){return e.replace(new RegExp("(?<![a-z-])width\\s*:\\s*([^;]+);?","gi"),(t,o)=>/^\s*0\s*[a-z%]*\s*(!important)?\s*$/i.test(o)?"width: 100%;":t)}const Jn=pe.Table.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),border:Q("border"),cellpadding:Q("cellpadding"),cellspacing:Q("cellspacing"),style:Yn()}},renderHTML({HTMLAttributes:e}){return["table",T.mergeAttributes(this.options.HTMLAttributes,e),["tbody",0]]}}),Zn=pe.TableRow.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),style:Q("style")}}}),xt={style:Q("style"),valign:Q("valign"),width:Q("width")},Qn=pe.TableCell.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),...xt}}}),eo=pe.TableHeader.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),...xt}}}),to=Je.TextStyle.extend({parseHTML(){var e;return[...((e=this.parent)==null?void 0:e.call(this))||[],{tag:"div",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1},{tag:"a",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1}]}}),no={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtEmoji:Qe.default},props:S.nodeViewProps};function oo(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block d-va-bottom d-lh0"},{default:a.withCtx(()=>[a.createVNode(r,{size:"500",code:e.node.attrs.code},null,8,["code"])]),_:1})}const io=F._(no,[["render",oo]]),so={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:$t.default},props:{items:{type:Array,required:!0},command:{type:Function,required:!0},itemComponent:{type:Object,required:!0},itemType:{type:String,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"?(this.downHandler(),!0):e.key==="Enter"||e.key==="Tab"?(this.selectHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length,this.scrollActiveElementIntoView()},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length,this.scrollActiveElementIntoView()},async scrollActiveElementIntoView(){await this.$nextTick();const e=this.$refs.suggestionList.querySelector(".d-list-item--highlighted");e&&e.scrollIntoView({behaviour:"smooth",block:"center"})},selectHandler(){this.selectItem(this.selectedIndex)},selectItem(e){const t=this.items[e];switch(this.itemType){case"emoji":this.command(t);return;case"mention":this.command({name:t.name,id:t.id,avatarSrc:t.avatarSrc,contactKey:t.contactKey});break;case"channel":this.command({name:t.name,id:t.id,locked:t.locked,channelKey:t.channelKey});break;case"slash-command":this.command({command:t.command});break}}}},ro={class:"d-popover__dialog d-suggestion-list__container"},ao={ref:"suggestionList",class:"d-suggestion-list"};function lo(e,t,o,n,i,s){const r=a.resolveComponent("dt-list-item");return a.openBlock(),a.createElementBlock("div",ro,[a.withDirectives(a.createElementVNode("ul",ao,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(o.items,(l,c)=>(a.openBlock(),a.createBlock(r,{key:l.id,class:a.normalizeClass(["d-suggestion-list__item",{"d-list-item--highlighted":c===i.selectedIndex}]),"navigation-type":"arrow-keys",onClick:h=>s.selectItem(c),onKeydown:a.withModifiers(s.onKeyDown,["prevent"])},{default:a.withCtx(()=>[(a.openBlock(),a.createBlock(a.resolveDynamicComponent(o.itemComponent),{item:l},null,8,["item"]))]),_:2},1032,["class","onClick","onKeydown"]))),128))],512),[[a.vShow,o.items.length]])])}const co=F._(so,[["render",lo]]),_t="top-start",Tt="650";function uo(){return{getBoundingClientRect:()=>({width:0,height:0,x:0,y:0,top:0,left:0,right:0,bottom:0})}}function We(e){return{getBoundingClientRect:e}}async function ho(e,t,o={}){if(!e||!(t!=null&&t.getBoundingClientRect))return;const{placement:n=_t,middleware:i=[De(0),Be(),Ie({padding:8})]}=o,{x:s,y:r}=await Re(t,e,{placement:n,middleware:i});Object.assign(e.style,{left:`${s}px`,top:`${r}px`})}function fo(e,t={}){const{zIndex:o=Tt}=t;e.style.position="absolute",e.style.zIndex=o,e.style.display="none"}function po(e){e&&(e.style.display="block")}function mo(e){e&&(e.style.display="none")}function go(e,t){return o=>{o.key==="Escape"&&t()&&e()}}function wo(e){document.addEventListener("keydown",e)}function yo(e){document.removeEventListener("keydown",e)}function bo(e,t,o,n){return new S.VueRenderer(e,{props:{itemComponent:a.markRaw(t),itemType:o,...n},editor:n.editor})}function vo(e){var t,o;e.escHandler&&yo(e.escHandler),(t=e.floatingEl)==null||t.remove(),(o=e.component)==null||o.destroy()}function be(e,t,o={}){const{listComponent:n=co,placement:i=_t,zIndex:s=Tt}=o;return()=>{let r=null,l=null,c=!1,h=uo(),u=null;function d(){ho(l,h,{placement:i})}function f(){l&&(po(l),c=!0,d())}function p(){l&&(mo(l),c=!1)}return{onStart:m=>{r=bo(n,e,t,m),m.clientRect&&(l=r.element,fo(l,{zIndex:s}),document.body.appendChild(l),h=We(m.clientRect),u=go(p,()=>c),wo(u),m.items.length>0&&f())},onUpdate(m){r==null||r.updateProps(m),m.items.length>0?f():p(),m.clientRect&&(h=We(m.clientRect),d())},onKeyDown(m){var g;if(c)return(g=r==null?void 0:r.ref)==null?void 0:g.onKeyDown(m)},onExit(){vo({escHandler:u,floatingEl:l,component:r}),u=null,l=null,r=null}}}}const xo={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:Qe.default,DtStack:le.default},props:{item:{type:Object,required:!0}}};function _o(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{size:"200",code:o.item.code},null,8,["code"]),a.createTextVNode(" "+a.toDisplayString(o.item.code),1)]),_:1})}const To=F._(xo,[["render",_o]]),Co=20,ko=(e,t,o)=>{var l,c;const n=(l=e.shortname)==null?void 0:l.replaceAll(":",""),i=(c=t.shortname)==null?void 0:c.replaceAll(":",""),s=n.startsWith(o),r=i.startsWith(o);return s&&!r?-1:!s&&r?1:n.localeCompare(i)},Eo={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(te.getEmojiData());return e=e.toLowerCase(),t.filter(n=>{var i;return[n.name,(i=n.shortname)==null?void 0:i.replaceAll(":",""),...n.keywords||[]].some(s=>s&&s.startsWith(e))}).splice(0,Co).sort((n,i)=>ko(n,i,e)).map(n=>({code:n.shortname}))},command:({editor:e,range:t,props:o})=>{var s,r;const n=e.view.state.selection.$to.nodeAfter;((s=n==null?void 0:n.text)==null?void 0:s.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:o}]).run(),(r=window.getSelection())==null||r.collapseToEnd()},render:be(To,"emoji")},Oo=/(:\w+:)$/,So=new RegExp(Ze.emojiPattern+"$"),Lo=e=>{if(e&&te.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},Ao=e=>[...e.matchAll(te.emojiShortCodeRegex)].filter(o=>te.codeToEmojiData(o[0])).map(o=>({index:o.index,text:o[0],match:o})),Do=T.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return S.VueNodeViewRenderer(io)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return te.stringToUnicode(te.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new T.InputRule({find:e=>{const t=e.match(Oo)||e.match(So);if(t)return Lo(t)},handler:({state:e,range:t,match:o})=>{const{tr:n}=e,i=t.from,s=t.to;n.replaceWith(i,s,this.type.create({code:o[0]}))}})]},addPasteRules(){return[T.nodePasteRule({find:Ao,type:this.type,getAttributes(e){return{code:e[0]}}}),T.nodePasteRule({find:te.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[Vt({char:":",pluginKey:new j.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Eo})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let o=!1;const{selection:n}=t,{empty:i,anchor:s}=n;return i?(t.doc.nodesBetween(s-1,s,(r,l)=>{if(r.type.name===this.name)return o=!0,e.insertText("",l,l+r.nodeSize),!1}),o):!1})}}});function Io(e,t,o=()=>!0){const n=[];t.lastIndex=0;let i;for(;i=t.exec(e);)o(e,i)&&n.push(i);return n}function Bo(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Ro(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function Mo(e,t){const o=e.slice(0,t+1).search(/\S+\s*$/),n=e.slice(t).search(/\s/);if(n<0){const i=e.slice(o);return{text:i,from:o,to:o+i.length}}return{text:e.slice(o,n+t),from:o,to:n+t}}function Ce(e,t,o,n){const i=Mo(e,t);if(n.lastIndex=0,!n.test(i.text))return i;const s=o==="left"?i.from-1:i.to+1;return s<=0||s>=e.length||s===t?i:Ce(e,s,o,n)}function No(e,t,o,n){const i=Math.max(e.from-1,0),s=Math.min(e.to+1,t.content.size),r=T.getMarksBetween(i,s,t);for(const l of r)l.mark.type===n&&o.removeMark(l.from,l.to,n)}const Xe=re.getPhoneNumberRegex(1,15);function Ye(e,t,o,n,i,s){if(!e)return;let r=o-t-1;r=r<0?0:r;const l=n-t,c=Ce(e,r,"left",Xe),h=Ce(e,l,"right",Xe),u=e.slice(c.from,h.to);Io(u,re.linkRegex,Bo).forEach(f=>{const p=Ro(f[0]),m=t+c.from+f.index+1,g=m+p.length;i.addMark(m,g,s.create())})}function Ho(e){let t=!1;return new j.Plugin({key:new j.PluginKey("autolink"),appendTransaction:(o,n,i)=>{const s=o.some(u=>u.docChanged)&&!n.doc.eq(i.doc);if(t&&!s)return;const{tr:r}=i,{textContent:l}=i.doc;t||Ye(l,0,0,l.length,r,e.type),t=!0;const c=T.combineTransactionSteps(n.doc,[...o]);return T.getChangedRanges(c).forEach(({oldRange:u,newRange:d})=>{No(d,i.doc,r,e.type),T.findChildrenInRange(i.doc,d,p=>p.isTextblock).forEach(({node:p,pos:m})=>{Ye(p.textContent,m,u.from,d.to,r,e.type)})}),r}})}const Vo={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},$o=T.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",T.mergeAttributes(this.options.HTMLAttributes,e,Vo)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Ho({type:this.type})]}}),Po=Pt.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),Uo=new Set(["address","article","aside","blockquote","dd","details","dialog","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","ol","p","pre","section","table","ul"]),jo=Ge.extend({parseHTML(){return[{tag:"div",getAttrs:e=>{for(const t of e.children)if(Uo.has(t.tagName.toLowerCase()))return!1;return null}}]},renderHTML({HTMLAttributes:e}){return["div",T.mergeAttributes(this.options.HTMLAttributes,e),0]}}),zo={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:et.default},props:S.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}},methods:{getMentionData(){return{name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,avatarSrc:this.$props.node.attrs.avatarSrc,contactKey:this.$props.node.attrs.contactKey}},handleClick(){this.$props.editor.emit("mention-click",this.getMentionData())},handleMouseEnter(e){this.$props.editor.emit("mention-hover",{...this.getMentionData(),event:e})},handleMouseLeave(e){this.$props.editor.emit("mention-leave",{...this.getMentionData(),event:e})}}};function qo(e,t,o,n,i,s){const r=a.resolveComponent("dt-link"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"]),onMouseenter:s.handleMouseEnter,onMouseleave:s.handleMouseLeave,onFocusin:s.handleMouseEnter,onFocusout:s.handleMouseLeave},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1},8,["onClick","onMouseenter","onMouseleave","onFocusin","onFocusout"])]),_:1})}const Fo=F._(zo,[["render",qo]]),Ko=ke.extend({addNodeView(){return S.VueNodeViewRenderer(Fo)},parseHTML(){return[{tag:"mention-component"}]},addAttributes(){return{name:{default:""},avatarSrc:{default:""},id:{default:""},contactKey:{default:""}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["mention-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new j.PluginKey("mentionSuggestion")}}),Wo={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:et.default,DtIconLock:Ut.DtIconLock,DtStack:le.default},props:S.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:"#"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,locked:this.$props.node.attrs.locked,channelKey:this.$props.node.attrs.channelKey};this.$props.editor.emit("channel-click",e)}}};function Xo(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-lock"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("dt-link"),h=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(h,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(c,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"])},{default:a.withCtx(()=>[a.createVNode(l,{direction:"row",gap:"0"},{default:a.withCtx(()=>[e.$props.node.attrs.locked?(a.openBlock(),a.createBlock(r,{key:0,size:"200"})):a.createCommentVNode("",!0),a.createElementVNode("span",null,a.toDisplayString(s.text),1)]),_:1})]),_:1},8,["onClick"])]),_:1})}const Yo=F._(Wo,[["render",Xo]]),Go=ke.extend({name:"channel",addNodeView(){return S.VueNodeViewRenderer(Yo)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1},channelKey:{default:""}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new j.PluginKey("channelSuggestion")}}),Jo={compatConfig:{MODE:3},name:"SlashCommandsComponent",components:{NodeViewWrapper:S.NodeViewWrapper},props:{...S.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var o,n,i;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(i=(n=(o=this.editor)==null?void 0:o.storage)==null?void 0:n["slash-commands"])==null?void 0:i.onSelectedCommand;t&&typeof t=="function"&&t(e)}};function Zo(e,t,o,n,i,s){const r=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(r,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1})}const Qo=F._(Jo,[["render",Zo]]),ei=(e,t)=>[...e.matchAll(t)].map(n=>{let i=n[2];return i.endsWith(" ")||(i+=" "),{index:n.index,text:i,match:n}}),ti=ke.extend({name:"slash-commands",group:"inline",inline:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onSelectedCommand:null}},addStorage(){return{onSelectedCommand:this.options.onSelectedCommand}},addNodeView(){return S.VueNodeViewRenderer(Qo)},parseHTML(){return[{tag:"command-component"}]},addAttributes(){return{command:{default:""},parametersExample:{default:""},description:{default:""}}},renderText({node:e}){return`/${e.attrs.command}`},renderHTML({HTMLAttributes:e}){return["command-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[T.nodeInputRule({find:t,type:this.type,getAttributes(n){return{command:n[2]}}})]},addPasteRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[T.nodePasteRule({find:n=>ei(n,t),type:this.type,getAttributes(n){return{command:n[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new j.PluginKey("slashCommandSuggestion")}}),ni=100,oi={name:"VariableComponent",components:{DtBadge:qt.default,DtButton:nt.default,DtPopover:zt.default,DtInput:jt.default,NodeViewWrapper:S.NodeViewWrapper},props:S.nodeViewProps,data(){return{i18n:new tt.DialtoneLocalization,MAX_VARIABLE_ALT_LENGTH:ni}},computed:{altText:{get(){var e,t;return((t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.altText)||""},set(e){this.updateAttributes({altText:e})}},variableId(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.id},placeholder(){var e;return((e=this.variableData)==null?void 0:e.placeholder)||""},variableItems(){var e,t;return((t=(e=this.extension)==null?void 0:e.options)==null?void 0:t.variableItems)||[]},variableData(){return this.variableItems.find(e=>e.id===this.variableId)},enableAltText(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.enableAltText},badgeLabel(){return`{} ${this.placeholder}`},placeholderText(){return`Replaces ${this.placeholder}`}}};function ii(e,t,o,n,i,s){const r=a.resolveComponent("dt-badge"),l=a.resolveComponent("dt-button"),c=a.resolveComponent("dt-input"),h=a.resolveComponent("dt-popover"),u=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(u,{class:"d-d-inline-block"},{default:a.withCtx(()=>[s.enableAltText?(a.openBlock(),a.createBlock(h,{key:0,padding:"small","navigation-type":"arrow-keys",placement:"top-start",modal:!1},{anchor:a.withCtx(({attrs:d})=>[a.createVNode(l,a.mergeProps(d,{kind:"unstyled"}),{default:a.withCtx(()=>[a.createVNode(r,{text:s.badgeLabel,contenteditable:"false"},null,8,["text"])]),_:1},16)]),content:a.withCtx(({close:d})=>[a.createVNode(c,{modelValue:s.altText,"onUpdate:modelValue":t[0]||(t[0]=f=>s.altText=f),"root-class":"d-p8 d-w332",label:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_LABEL"),placeholder:s.placeholderText,validate:{length:{description:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION"),message:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE"),max:i.MAX_VARIABLE_ALT_LENGTH,warn:i.MAX_VARIABLE_ALT_LENGTH,limitMaxLength:!0}},onKeyup:a.withKeys(f=>d(),["enter"])},null,8,["modelValue","label","placeholder","validate","onKeyup"])]),_:1})):(a.openBlock(),a.createBlock(r,{key:1,text:s.badgeLabel,contenteditable:"false"},null,8,["text"]))]),_:1})}const si=F._(oi,[["render",ii]]),ri=T.Node.create({name:"variable",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},variableItems:[]}},addNodeView(){return S.VueNodeViewRenderer(si)},addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-variable-id"),renderHTML:e=>e.id?{"data-variable-id":e.id}:{}},altText:{default:"",parseHTML:e=>e.getAttribute("data-alt-text"),renderHTML:e=>e.altText?{"data-alt-text":e.altText}:{}},enableAltText:{default:!0,parseHTML:e=>e.getAttribute("data-enable-alt-text")==="true",renderHTML:e=>({"data-enable-alt-text":String(e.enableAltText)})}}},parseHTML(){return[{tag:"variable"}]},renderText({node:e}){return e.attrs.altText},renderHTML({node:e,HTMLAttributes:t}){return["variable",T.mergeAttributes(this.options.HTMLAttributes,t,{"data-variable-id":e.attrs.id,"data-alt-text":e.attrs.altText,"data-enable-alt-text":String(e.attrs.enableAltText)})]},addCommands(){return{insertVariable:(e={})=>({commands:t})=>t.insertContent({type:this.name,attrs:{id:e.id||null,altText:e.altText||"",enableAltText:e.enableAltText}})}}}),ai={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:Ft.default,DtStack:le.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name},avatarSrc(){return this.item.avatarSrc},presence(){return this.item.presence},status(){return this.item.status},presenceText(){return this.item.presenceText},presenceFontColorClass(){return{active:"d-recipe-contact-row--active",busy:"d-recipe-contact-row--busy",away:"d-recipe-contact-row--away",offline:"d-recipe-contact-row--busy"}[this.presence]},showDetails(){return this.item.showDetails}}},li={class:"d-mention-suggestion__name"},ci={key:1,class:"d-mention-suggestion__divider"},di={key:2,class:"d-mention-suggestion__status"};function ui(e,t,o,n,i,s){const r=a.resolveComponent("dt-avatar"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",class:"d-mention-suggestion__container",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{"full-name":s.name,"image-src":s.avatarSrc,"image-alt":s.name,"show-presence":s.showDetails,presence:s.presence,size:"sm"},null,8,["full-name","image-src","image-alt","show-presence","presence"]),a.createVNode(l,{class:"d-mention-suggestion__details-container",gap:"100"},{default:a.withCtx(()=>[a.createElementVNode("span",li,a.toDisplayString(s.name),1),s.showDetails?(a.openBlock(),a.createBlock(l,{key:0,direction:"row",gap:"300",class:"d-label--sm-plain"},{default:a.withCtx(()=>[s.presenceText?(a.openBlock(),a.createElementBlock("span",{key:0,class:a.normalizeClass(["d-mention-suggestion__presence",[s.presenceFontColorClass]])},a.toDisplayString(s.presenceText),3)):a.createCommentVNode("",!0),s.status&&s.presenceText?(a.openBlock(),a.createElementBlock("div",ci," • ")):a.createCommentVNode("",!0),s.status?(a.openBlock(),a.createElementBlock("div",di,a.toDisplayString(s.status),1)):a.createCommentVNode("",!0)]),_:1})):a.createCommentVNode("",!0)]),_:1})]),_:1})}const hi=F._(ai,[["render",ui]]),fi={allowSpaces:!0,render:be(hi,"mention")},pi={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:le.default,DtIconHash:Kt,DtIconLock:Wt},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function mi(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-hash"),l=a.resolveComponent("dt-icon-lock"),c=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(c,{direction:"row",gap:"400"},{default:a.withCtx(()=>[o.item.locked?(a.openBlock(),a.createBlock(l,{key:1,size:"300"})):(a.openBlock(),a.createBlock(r,{key:0,size:"300"})),a.createElementVNode("span",null,a.toDisplayString(s.name),1)]),_:1})}const gi=F._(pi,[["render",mi]]),wi={allowSpaces:!0,render:be(gi,"channel")},yi={compatConfig:{MODE:3},name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}},bi={class:"d-body--md-compact"},vi={key:0},xi={class:"d-body--sm d-fc-tertiary"};function _i(e,t,o,n,i,s){return a.openBlock(),a.createElementBlock("div",null,[a.createElementVNode("div",bi,[a.createElementVNode("span",null,"/"+a.toDisplayString(s.command),1),s.parametersExample?(a.openBlock(),a.createElementBlock("span",vi,a.toDisplayString(s.parametersExample),1)):a.createCommentVNode("",!0)]),a.createElementVNode("div",xi,a.toDisplayString(s.description),1)])}const Ti=F._(yi,[["render",_i]]),Ci={allowSpaces:!0,startOfLine:!0,render:be(Ti,"slash-command")},ki={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:S.EditorContent,BubbleMenu:Kn,DtButton:nt.default,DtStack:le.default},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},preventTyping:{type:Boolean,default:!1},pasteRichText:{type:Boolean,default:!0},allowLineBreaks:{type:Boolean,default:!1},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e=="string"?de.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return de.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowBackgroundColor:{type:Boolean,default:!1},allowFontSize:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},allowLineHeight:{type:Boolean,default:!1},allowVariable:{type:Boolean,default:!1},variableItems:{type:Array,default:()=>[]},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},preserveWhitespace:{type:[Boolean,String],default:"full"},useDivTags:{type:Boolean,default:!1},allowTables:{type:Boolean,default:!1},allowImageResize:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","markdown-input","update:modelValue","blur","focus","enter","edit-link","selected","selected-command","mention-click","mention-hover","mention-leave","channel-click"],data(){return{editor:null,appendTo:()=>{var e;return(e=re.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},floatingOptions:{placement:"top-start"},i18n:new tt.DialtoneLocalization,jsonToMarkdownConverter:{convertToMarkdown(e){return this.processNode(e)},processNodeContent(e){return e.content?e.content.map(t=>this.processNode(t)).join(""):""},processNode(e){if(!e)return"";const o={doc:n=>this.processDocNode(n),paragraph:n=>this.processParagraphNode(n),text:n=>this.processTextNode(n),hardBreak:()=>this.processHardBreakNode(),blockquote:n=>this.processBlockquoteNode(n),bulletList:n=>this.processBulletListNode(n),orderedList:n=>this.processOrderedListNode(n),listItem:n=>this.processListItemNode(n),codeBlock:n=>this.processCodeBlockNode(n),mention:n=>this.processMentionNode(n),channel:n=>this.processChannelNode(n),"slash-commands":n=>this.processSlashCommandsNode(n),emoji:n=>this.processEmojiNode(n),variable:n=>this.processVariableNode(n)}[e.type];return o?o(e):this.processUnknownNode(e)},processDocNode(e){return this.processNodeContent(e)},processParagraphNode(e){const t=this.processNodeContent(e);return t?t+`
2
- `:`
3
- `},processTextNode(e){let t=e.text||"";return e.marks&&(t=this.applyMarks(t,e.marks)),t},processHardBreakNode(){return`
4
- `},processBlockquoteNode(e){return this.processNodeContent(e).split(`
5
- `).map(o=>o?`> ${o}`:">").join(`
6
- `)+`
7
- `},processBulletListNode(e){return this.processNodeContent(e)},processOrderedListNode(e){return e.content?e.content.map((t,o)=>this.processNode(t).replace(/^- /,`${o+1}. `)).join(""):""},processListItemNode(e){const t=this.processNodeContent(e);return t?`- ${t.replace(/\n$/,"")}
8
- `:""},processCodeBlockNode(e){return`\`\`\`
9
- ${this.processNodeContent(e)}
10
- \`\`\``},processMentionNode(e){var i,s,r;const t=((i=e.attrs)==null?void 0:i.name)||"",o=((s=e.attrs)==null?void 0:s.id)||"",n=((r=e.attrs)==null?void 0:r.contactKey)||"";return`<!-- @mention: {"id": "${o}", "contactKey": "${n}", "name": "${t}"} -->`},processChannelNode(e){var s,r,l,c;const t=((s=e.attrs)==null?void 0:s.name)||"",o=((r=e.attrs)==null?void 0:r.id)||"",n=((l=e.attrs)==null?void 0:l.locked.toString())||"",i=((c=e.attrs)==null?void 0:c.channelKey)||"";return`<!-- @channel: {"id": "${o}", "channelKey": "${i}", "name": "${t}", "locked": "${n}"} -->`},processSlashCommandsNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.command)||"",o=((i=e.attrs)==null?void 0:i.parameters)||"";return`/${t}${o?` ${o}`:""}`},processEmojiNode(e){var t;return((t=e.attrs)==null?void 0:t.code)||""},processVariableNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.id)||"",o=((i=e.attrs)==null?void 0:i.altText)||"";return`{{${t}=${o}}}`},processUnknownNode(e){return this.processNodeContent(e)},applyMarks(e,t){let o=e;return[...t].sort((i,s)=>{const r={link:0,bold:1,italic:2,strike:3,code:4};return(r[i.type]||5)-(r[s.type]||5)}).forEach(i=>{var s;switch(i.type){case"bold":o=`**${o}**`;break;case"italic":o=`*${o}*`;break;case"strike":o=`~~${o}~~`;break;case"code":o=`\`${o}\``;break;case"link":{const r=((s=i.attrs)==null?void 0:s.href)||"";o=`[${o}](${r})`;break}}}),o}}}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){const e=[Lt,Nt,ve.UndoRedo,At];e.push(this.useDivTags?jo:Ge),this.allowBold&&e.push(Dt),this.allowBlockquote&&e.push(Et),this.allowBulletList&&(e.push(xe.BulletList),e.push(xe.ListItem.extend({renderText({node:n}){return n.textContent}})),e.push(xe.OrderedList)),this.allowItalic&&e.push(It),this.allowStrike&&e.push(Rt),this.allowUnderline&&e.push(Mt),this.placeholder&&e.push(ve.Placeholder.configure({placeholder:this.placeholder}));const t=this,o=T.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:n})=>t.allowLineBreaks?!1:(n.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>t.allowBulletList&&i.splitListItem("listItem"),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(o),this.link&&e.push(Bt.extend({inclusive:!1,addKeyboardShortcuts(){return{"Mod-k":()=>(t.$emit("edit-link"),!0)}}}).configure({HTMLAttributes:{class:"d-link d-wb-break-all"},openOnClick:!1,autolink:!0,protocols:de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension($o,this.customLink)),this.mentionSuggestion){const n={...this.mentionSuggestion,...fi};e.push(Ko.configure({suggestion:n}))}if(this.channelSuggestion){const n={...this.channelSuggestion,...wi};e.push(Go.configure({suggestion:n}))}if(this.slashCommandSuggestion){const n={...this.slashCommandSuggestion,...Ci};e.push(ti.configure({suggestion:n,onSelectedCommand:i=>{this.$emit("selected-command",i)}}))}return this.allowVariable&&e.push(ri.configure({variableItems:this.variableItems})),e.push(Do),e.push(Ht.configure({types:["paragraph"]})),this.allowCode&&e.push(St),this.allowCodeblock&&e.push(Ot.extend({renderText({node:n}){return`\`\`\`
11
- ${n.textContent}
12
- \`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(Po.configure({resize:{enabled:this.allowImageResize,alwaysPreserveAspectRatio:!0}})),(this.allowFontFamily||this.allowFontColor||this.allowFontSize||this.allowBackgroundColor||this.allowLineHeight)&&(e.push(Je.TextStyleKit.configure({color:this.allowFontColor,backgroundColor:this.allowBackgroundColor,fontFamily:this.allowFontFamily,fontSize:this.allowFontSize,lineHeight:this.allowLineHeight})),e.push(to)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),this.allowTables&&e.push(Jn.configure({resizable:!0}),Zn,eo,Qn,ve.Gapcursor),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(e){this.processValue(e)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},mounted(){re.warnIfUnmounted(re.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new S.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,shouldRerenderOnTransaction:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const o=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&o.push("Enter"),!o.includes(t.key)},handlePaste:(e,t)=>{const o=t.clipboardData||window.clipboardData,n=o.getData("text/plain"),i=o.getData("text/html");return this.processPasteData(e,n,i)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var l,c,h;const{view:t,state:o}=e,{from:n,to:i}=t.state.selection,s=o.doc.textBetween(n,i,""),r=this.editor.state.doc.nodeAt(n);return r&&((h=(c=(l=r.marks)==null?void 0:l.at(0))==null?void 0:c.type)==null?void 0:h.name)==="link"?r.textContent:s},editLink(){const e=this.getSelectedLinkText(this.editor),t={href:this.editor.getAttributes("link").href,text:e};this.$emit("edit-link",t)},removeLink(){var e,t,o,n;(n=(o=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:o.unsetLink())==null||n.run()},openLink(){var t,o;(o=(t=this.editor)==null?void 0:t.chain())==null||o.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,o,n=de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,i){var l,c,h;if(!e){this.removeLink();return}n.find(u=>u.test(e))||(e=`${i}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const r=(h=(c=(l=this.editor)==null?void 0:l.view)==null?void 0:c.state)==null?void 0:h.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:r.from,to:r.from+t.length}).setLink({href:e,class:o.class}).run()},processValue(e,t=!0){if(!this.editor)return;const o=this.getOutput();if(!(t&&Xt(e,o))){if(typeof e=="string"&&this.outputFormat==="text"){const n=new RegExp(`(${Ze.emojiPattern})`,"g");e=e==null?void 0:e.replace(n,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,{emitUpdate:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace}})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const i=(this.pasteRichText?t:t.replace(/\r\n/g,`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("../../node_modules/@tiptap/vue-3.cjs"),T=require("@tiptap/core"),z=require("@tiptap/pm/state"),Et=require("@tiptap/pm/tables"),l=require("vue"),Ot=require("@tiptap/extension-blockquote"),St=require("@tiptap/extension-code-block"),Lt=require("@tiptap/extension-code"),At=require("@tiptap/extension-document"),ve=require("@tiptap/extensions"),Dt=require("@tiptap/extension-hard-break"),Je=require("@tiptap/extension-paragraph"),It=require("@tiptap/extension-bold"),xe=require("@tiptap/extension-list"),Rt=require("@tiptap/extension-italic"),Bt=require("@tiptap/extension-link"),Mt=require("@tiptap/extension-strike"),Ht=require("@tiptap/extension-underline"),Vt=require("@tiptap/extension-text"),Pt=require("@tiptap/extension-text-align"),pe=require("@tiptap/extension-table"),Ze=require("@tiptap/extension-text-style"),Nt=require("@tiptap/suggestion"),Qe=require("regex-combined-emojis"),q=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),et=require("../emoji/emoji.cjs"),te=require("../../common/emoji/index.cjs"),$t=require("../list-item/list-item.cjs"),ae=require("../stack/stack.cjs"),re=require("../../common/utils/index.cjs"),Ut=require("@tiptap/extension-image"),ke=require("@tiptap/extension-mention"),tt=require("../link/link.cjs"),zt=require("@dialpad/dialtone-icons/vue3"),nt=require("../../localization/index.cjs"),jt=require("../input/input.cjs"),Ft=require("../popover/popover.cjs"),it=require("../button/button.cjs"),qt=require("../badge/badge.cjs"),de=require("./rich-text-editor-constants.cjs"),Wt=require("../avatar/avatar.cjs"),Kt=require("@dialpad/dialtone-icons/vue3/hash"),Xt=require("@dialpad/dialtone-icons/vue3/lock"),Me=require("./markdownRenderer.cjs"),Yt=require("deep-equal"),ot=["top","right","bottom","left"],He=["start","end"],Ve=ot.reduce((e,t)=>e.concat(t,t+"-"+He[0],t+"-"+He[1]),[]),X=Math.min,I=Math.max,ue=Math.round,K=e=>({x:e,y:e}),Gt={left:"right",right:"left",bottom:"top",top:"bottom"},Jt={start:"end",end:"start"};function Te(e,t,n){return I(e,X(t,n))}function G(e,t){return typeof e=="function"?e(t):e}function N(e){return e.split("-")[0]}function U(e){return e.split("-")[1]}function st(e){return e==="x"?"y":"x"}function Ee(e){return e==="y"?"height":"width"}const Zt=new Set(["top","bottom"]);function W(e){return Zt.has(N(e))?"y":"x"}function Oe(e){return st(W(e))}function rt(e,t,n){n===void 0&&(n=!1);const i=U(e),o=Oe(e),s=Ee(o);let r=o==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=fe(r)),[r,fe(r)]}function Qt(e){const t=fe(e);return[he(e),t,he(t)]}function he(e){return e.replace(/start|end/g,t=>Jt[t])}const Pe=["left","right"],Ne=["right","left"],en=["top","bottom"],tn=["bottom","top"];function nn(e,t,n){switch(e){case"top":case"bottom":return n?t?Ne:Pe:t?Pe:Ne;case"left":case"right":return t?en:tn;default:return[]}}function on(e,t,n,i){const o=U(e);let s=nn(N(e),n==="start",i);return o&&(s=s.map(r=>r+"-"+o),t&&(s=s.concat(s.map(he)))),s}function fe(e){return e.replace(/left|right|bottom|top/g,t=>Gt[t])}function sn(e){return{top:0,right:0,bottom:0,left:0,...e}}function Se(e){return typeof e!="number"?sn(e):{top:e,right:e,bottom:e,left:e}}function ie(e){const{x:t,y:n,width:i,height:o}=e;return{width:i,height:o,top:n,left:t,right:t+i,bottom:n+o,x:t,y:n}}function $e(e,t,n){let{reference:i,floating:o}=e;const s=W(t),r=Oe(t),a=Ee(r),c=N(t),h=s==="y",u=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,f=i[a]/2-o[a]/2;let p;switch(c){case"top":p={x:u,y:i.y-o.height};break;case"bottom":p={x:u,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:d};break;case"left":p={x:i.x-o.width,y:d};break;default:p={x:i.x,y:i.y}}switch(U(t)){case"start":p[r]-=f*(n&&h?-1:1);break;case"end":p[r]+=f*(n&&h?-1:1);break}return p}async function rn(e,t){var n;t===void 0&&(t={});const{x:i,y:o,platform:s,rects:r,elements:a,strategy:c}=e,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=G(t,e),m=Se(p),w=a[f?d==="floating"?"reference":"floating":d],y=ie(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:h,rootBoundary:u,strategy:c})),v=d==="floating"?{x:i,y:o,width:r.floating.width,height:r.floating.height}:r.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),_=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},k=ie(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:c}):v);return{top:(y.top-k.top+m.top)/_.y,bottom:(k.bottom-y.bottom+m.bottom)/_.y,left:(y.left-k.left+m.left)/_.x,right:(k.right-y.right+m.right)/_.x}}const ln=async(e,t,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:s=[],platform:r}=n,a=s.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=$e(h,i,c),f=i,p={},m=0;for(let w=0;w<a.length;w++){var g;const{name:y,fn:v}=a[w],{x,y:_,data:k,reset:C}=await v({x:u,y:d,initialPlacement:i,placement:f,strategy:o,middlewareData:p,rects:h,platform:{...r,detectOverflow:(g=r.detectOverflow)!=null?g:rn},elements:{reference:e,floating:t}});u=x??u,d=_??d,p={...p,[y]:{...p[y],...k}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:d}=$e(h,f,c)),w=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:p}},an=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:i,placement:o,rects:s,platform:r,elements:a,middlewareData:c}=t,{element:h,padding:u=0}=G(e,t)||{};if(h==null)return{};const d=Se(u),f={x:n,y:i},p=Oe(o),m=Ee(p),g=await r.getDimensions(h),w=p==="y",y=w?"top":"left",v=w?"bottom":"right",x=w?"clientHeight":"clientWidth",_=s.reference[m]+s.reference[p]-f[p]-s.floating[m],k=f[p]-s.reference[p],C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let L=C?C[x]:0;(!L||!await(r.isElement==null?void 0:r.isElement(C)))&&(L=a.floating[x]||s.floating[m]);const V=_/2-k/2,A=L/2-g[m]/2-1,b=X(d[y],A),E=X(d[v],A),D=b,R=L-g[m]-E,O=L/2-g[m]/2+V,$=Te(D,O,R),P=!c.arrow&&U(o)!=null&&O!==$&&s.reference[m]/2-(O<D?b:E)-g[m]/2<0,B=P?O<D?O-D:O-R:0;return{[p]:f[p]+B,data:{[p]:$,centerOffset:O-$-B,...P&&{alignmentOffset:B}},reset:P}}});function cn(e,t,n){return(e?[...n.filter(o=>U(o)===e),...n.filter(o=>U(o)!==e)]:n.filter(o=>N(o)===o)).filter(o=>e?U(o)===e||(t?he(o)!==o:!1):!0)}const dn=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,i,o;const{rects:s,middlewareData:r,placement:a,platform:c,elements:h}=t,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Ve,autoAlignment:p=!0,...m}=G(e,t),g=d!==void 0||f===Ve?cn(d||null,p,f):f,w=await c.detectOverflow(t,m),y=((n=r.autoPlacement)==null?void 0:n.index)||0,v=g[y];if(v==null)return{};const x=rt(v,s,await(c.isRTL==null?void 0:c.isRTL(h.floating)));if(a!==v)return{reset:{placement:g[0]}};const _=[w[N(v)],w[x[0]],w[x[1]]],k=[...((i=r.autoPlacement)==null?void 0:i.overflows)||[],{placement:v,overflows:_}],C=g[y+1];if(C)return{data:{index:y+1,overflows:k},reset:{placement:C}};const L=k.map(b=>{const E=U(b.placement);return[b.placement,E&&u?b.overflows.slice(0,2).reduce((D,R)=>D+R,0):b.overflows[0],b.overflows]}).sort((b,E)=>b[1]-E[1]),A=((o=L.filter(b=>b[2].slice(0,U(b[0])?2:3).every(E=>E<=0))[0])==null?void 0:o[0])||L[0][0];return A!==a?{data:{index:y+1,overflows:k},reset:{placement:A}}:{}}}},un=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,i;const{placement:o,middlewareData:s,rects:r,initialPlacement:a,platform:c,elements:h}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...w}=G(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=N(o),v=W(a),x=N(a)===a,_=await(c.isRTL==null?void 0:c.isRTL(h.floating)),k=f||(x||!g?[fe(a)]:Qt(a)),C=m!=="none";!f&&C&&k.push(...on(a,g,m,_));const L=[a,...k],V=await c.detectOverflow(t,w),A=[];let b=((i=s.flip)==null?void 0:i.overflows)||[];if(u&&A.push(V[y]),d){const O=rt(o,r,_);A.push(V[O[0]],V[O[1]])}if(b=[...b,{placement:o,overflows:A}],!A.every(O=>O<=0)){var E,D;const O=(((E=s.flip)==null?void 0:E.index)||0)+1,$=L[O];if($&&(!(d==="alignment"?v!==W($):!1)||b.every(M=>W(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:O,overflows:b},reset:{placement:$}};let P=(D=b.filter(B=>B.overflows[0]<=0).sort((B,M)=>B.overflows[1]-M.overflows[1])[0])==null?void 0:D.placement;if(!P)switch(p){case"bestFit":{var R;const B=(R=b.filter(M=>{if(C){const Z=W(M.placement);return Z===v||Z==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(Z=>Z>0).reduce((Z,kt)=>Z+kt,0)]).sort((M,Z)=>M[1]-Z[1])[0])==null?void 0:R[0];B&&(P=B);break}case"initialPlacement":P=a;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function Ue(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ze(e){return ot.some(t=>e[t]>=0)}const hn=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:i}=t,{strategy:o="referenceHidden",...s}=G(e,t);switch(o){case"referenceHidden":{const r=await i.detectOverflow(t,{...s,elementContext:"reference"}),a=Ue(r,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:ze(a)}}}case"escaped":{const r=await i.detectOverflow(t,{...s,altBoundary:!0}),a=Ue(r,n.floating);return{data:{escapedOffsets:a,escaped:ze(a)}}}default:return{}}}}};function lt(e){const t=X(...e.map(s=>s.left)),n=X(...e.map(s=>s.top)),i=I(...e.map(s=>s.right)),o=I(...e.map(s=>s.bottom));return{x:t,y:n,width:i-t,height:o-n}}function fn(e){const t=e.slice().sort((o,s)=>o.y-s.y),n=[];let i=null;for(let o=0;o<t.length;o++){const s=t[o];!i||s.y-i.y>i.height/2?n.push([s]):n[n.length-1].push(s),i=s}return n.map(o=>ie(lt(o)))}const pn=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:n,elements:i,rects:o,platform:s,strategy:r}=t,{padding:a=2,x:c,y:h}=G(e,t),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(i.reference))||[]),d=fn(u),f=ie(lt(u)),p=Se(a);function m(){if(d.length===2&&d[0].left>d[1].right&&c!=null&&h!=null)return d.find(w=>c>w.left-p.left&&c<w.right+p.right&&h>w.top-p.top&&h<w.bottom+p.bottom)||f;if(d.length>=2){if(W(n)==="y"){const b=d[0],E=d[d.length-1],D=N(n)==="top",R=b.top,O=E.bottom,$=D?b.left:E.left,P=D?b.right:E.right,B=P-$,M=O-R;return{top:R,bottom:O,left:$,right:P,width:B,height:M,x:$,y:R}}const w=N(n)==="left",y=I(...d.map(b=>b.right)),v=X(...d.map(b=>b.left)),x=d.filter(b=>w?b.left===v:b.right===y),_=x[0].top,k=x[x.length-1].bottom,C=v,L=y,V=L-C,A=k-_;return{top:_,bottom:k,left:C,right:L,width:V,height:A,x:C,y:_}}return f}const g=await s.getElementRects({reference:{getBoundingClientRect:m},floating:i.floating,strategy:r});return o.reference.x!==g.reference.x||o.reference.y!==g.reference.y||o.reference.width!==g.reference.width||o.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},mn=new Set(["left","top"]);async function gn(e,t){const{placement:n,platform:i,elements:o}=e,s=await(i.isRTL==null?void 0:i.isRTL(o.floating)),r=N(n),a=U(n),c=W(n)==="y",h=mn.has(r)?-1:1,u=s&&c?-1:1,d=G(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),c?{x:p*u,y:f*h}:{x:f*h,y:p*u}}const wn=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;const{x:o,y:s,placement:r,middlewareData:a}=t,c=await gn(t,e);return r===((n=a.offset)==null?void 0:n.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:r}}}}},yn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:i,placement:o,platform:s}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:c={fn:y=>{let{x:v,y:x}=y;return{x:v,y:x}}},...h}=G(e,t),u={x:n,y:i},d=await s.detectOverflow(t,h),f=W(N(o)),p=st(f);let m=u[p],g=u[f];if(r){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=m+d[y],_=m-d[v];m=Te(x,m,_)}if(a){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=g+d[y],_=g-d[v];g=Te(x,g,_)}const w=c.fn({...t,[p]:m,[f]:g});return{...w,data:{x:w.x-n,y:w.y-i,enabled:{[p]:r,[f]:a}}}}}},bn=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,i;const{placement:o,rects:s,platform:r,elements:a}=t,{apply:c=()=>{},...h}=G(e,t),u=await r.detectOverflow(t,h),d=N(o),f=U(o),p=W(o)==="y",{width:m,height:g}=s.floating;let w,y;d==="top"||d==="bottom"?(w=d,y=f===(await(r.isRTL==null?void 0:r.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,w=f==="end"?"top":"bottom");const v=g-u.top-u.bottom,x=m-u.left-u.right,_=X(g-u[w],v),k=X(m-u[y],x),C=!t.middlewareData.shift;let L=_,V=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(V=x),(i=t.middlewareData.shift)!=null&&i.enabled.y&&(L=v),C&&!f){const b=I(u.left,0),E=I(u.right,0),D=I(u.top,0),R=I(u.bottom,0);p?V=m-2*(b!==0||E!==0?b+E:I(u.left,u.right)):L=g-2*(D!==0||R!==0?D+R:I(u.top,u.bottom))}await c({...t,availableWidth:V,availableHeight:L});const A=await r.getDimensions(a.floating);return m!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function me(){return typeof window<"u"}function se(e){return at(e)?(e.nodeName||"").toLowerCase():"#document"}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function J(e){var t;return(t=(at(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function at(e){return me()?e instanceof Node||e instanceof H(e).Node:!1}function j(e){return me()?e instanceof Element||e instanceof H(e).Element:!1}function Y(e){return me()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function je(e){return!me()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}const vn=new Set(["inline","contents"]);function ce(e){const{overflow:t,overflowX:n,overflowY:i,display:o}=F(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&!vn.has(o)}const xn=new Set(["table","td","th"]);function _n(e){return xn.has(se(e))}const Tn=[":popover-open",":modal"];function ge(e){return Tn.some(t=>{try{return e.matches(t)}catch{return!1}})}const Cn=["transform","translate","scale","rotate","perspective"],kn=["transform","translate","scale","rotate","perspective","filter"],En=["paint","layout","strict","content"];function Le(e){const t=Ae(),n=j(e)?F(e):e;return Cn.some(i=>n[i]?n[i]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||kn.some(i=>(n.willChange||"").includes(i))||En.some(i=>(n.contain||"").includes(i))}function On(e){let t=ee(e);for(;Y(t)&&!oe(t);){if(Le(t))return t;if(ge(t))return null;t=ee(t)}return null}function Ae(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Sn=new Set(["html","body","#document"]);function oe(e){return Sn.has(se(e))}function F(e){return H(e).getComputedStyle(e)}function we(e){return j(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ee(e){if(se(e)==="html")return e;const t=e.assignedSlot||e.parentNode||je(e)&&e.host||J(e);return je(t)?t.host:t}function ct(e){const t=ee(e);return oe(t)?e.ownerDocument?e.ownerDocument.body:e.body:Y(t)&&ce(t)?t:ct(t)}function dt(e,t,n){var i;t===void 0&&(t=[]);const o=ct(e),s=o===((i=e.ownerDocument)==null?void 0:i.body),r=H(o);return s?t.concat(r,r.visualViewport||[],ce(o)?o:[],[]):t.concat(o,dt(o,[]))}function Fe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ut(e){const t=F(e);let n=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const o=Y(e),s=o?e.offsetWidth:n,r=o?e.offsetHeight:i,a=ue(n)!==s||ue(i)!==r;return a&&(n=s,i=r),{width:n,height:i,$:a}}function ht(e){return j(e)?e:e.contextElement}function ne(e){const t=ht(e);if(!Y(t))return K(1);const n=t.getBoundingClientRect(),{width:i,height:o,$:s}=ut(t);let r=(s?ue(n.width):n.width)/i,a=(s?ue(n.height):n.height)/o;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}const Ln=K(0);function ft(e){const t=H(e);return!Ae()||!t.visualViewport?Ln:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function An(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==H(e)?!1:t}function le(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ht(e);let r=K(1);t&&(i?j(i)&&(r=ne(i)):r=ne(e));const a=An(s,n,i)?ft(s):K(0);let c=(o.left+a.x)/r.x,h=(o.top+a.y)/r.y,u=o.width/r.x,d=o.height/r.y;if(s){const f=H(s),p=i&&j(i)?H(i):i;let m=f,g=Fe(m);for(;g&&i&&p!==m;){const w=ne(g),y=g.getBoundingClientRect(),v=F(g),x=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*w.x,_=y.top+(g.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,h*=w.y,u*=w.x,d*=w.y,c+=x,h+=_,m=H(g),g=Fe(m)}}return ie({width:u,height:d,x:c,y:h})}function ye(e,t){const n=we(e).scrollLeft;return t?t.left+n:le(J(e)).left+n}function pt(e,t){const n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-ye(e,n),o=n.top+t.scrollTop;return{x:i,y:o}}function Dn(e){let{elements:t,rect:n,offsetParent:i,strategy:o}=e;const s=o==="fixed",r=J(i),a=t?ge(t.floating):!1;if(i===r||a&&s)return n;let c={scrollLeft:0,scrollTop:0},h=K(1);const u=K(0),d=Y(i);if((d||!d&&!s)&&((se(i)!=="body"||ce(r))&&(c=we(i)),Y(i))){const p=le(i);h=ne(i),u.x=p.x+i.clientLeft,u.y=p.y+i.clientTop}const f=r&&!d&&!s?pt(r,c):K(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-c.scrollLeft*h.x+u.x+f.x,y:n.y*h.y-c.scrollTop*h.y+u.y+f.y}}function In(e){return Array.from(e.getClientRects())}function Rn(e){const t=J(e),n=we(e),i=e.ownerDocument.body,o=I(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),s=I(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let r=-n.scrollLeft+ye(e);const a=-n.scrollTop;return F(i).direction==="rtl"&&(r+=I(t.clientWidth,i.clientWidth)-o),{width:o,height:s,x:r,y:a}}const qe=25;function Bn(e,t){const n=H(e),i=J(e),o=n.visualViewport;let s=i.clientWidth,r=i.clientHeight,a=0,c=0;if(o){s=o.width,r=o.height;const u=Ae();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const h=ye(i);if(h<=0){const u=i.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(i.clientWidth-d.clientWidth-p);m<=qe&&(s-=m)}else h<=qe&&(s+=h);return{width:s,height:r,x:a,y:c}}const Mn=new Set(["absolute","fixed"]);function Hn(e,t){const n=le(e,!0,t==="fixed"),i=n.top+e.clientTop,o=n.left+e.clientLeft,s=Y(e)?ne(e):K(1),r=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,h=i*s.y;return{width:r,height:a,x:c,y:h}}function We(e,t,n){let i;if(t==="viewport")i=Bn(e,n);else if(t==="document")i=Rn(J(e));else if(j(t))i=Hn(t,n);else{const o=ft(e);i={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ie(i)}function mt(e,t){const n=ee(e);return n===t||!j(n)||oe(n)?!1:F(n).position==="fixed"||mt(n,t)}function Vn(e,t){const n=t.get(e);if(n)return n;let i=dt(e,[]).filter(a=>j(a)&&se(a)!=="body"),o=null;const s=F(e).position==="fixed";let r=s?ee(e):e;for(;j(r)&&!oe(r);){const a=F(r),c=Le(r);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&Mn.has(o.position)||ce(r)&&!c&&mt(e,r))?i=i.filter(u=>u!==r):o=a,r=ee(r)}return t.set(e,i),i}function Pn(e){let{element:t,boundary:n,rootBoundary:i,strategy:o}=e;const r=[...n==="clippingAncestors"?ge(t)?[]:Vn(t,this._c):[].concat(n),i],a=r[0],c=r.reduce((h,u)=>{const d=We(t,u,o);return h.top=I(d.top,h.top),h.right=X(d.right,h.right),h.bottom=X(d.bottom,h.bottom),h.left=I(d.left,h.left),h},We(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Nn(e){const{width:t,height:n}=ut(e);return{width:t,height:n}}function $n(e,t,n){const i=Y(t),o=J(t),s=n==="fixed",r=le(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=K(0);function h(){c.x=ye(o)}if(i||!i&&!s)if((se(t)!=="body"||ce(o))&&(a=we(t)),i){const p=le(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else o&&h();s&&!i&&o&&h();const u=o&&!i&&!s?pt(o,a):K(0),d=r.left+a.scrollLeft-c.x-u.x,f=r.top+a.scrollTop-c.y-u.y;return{x:d,y:f,width:r.width,height:r.height}}function _e(e){return F(e).position==="static"}function Ke(e,t){if(!Y(e)||F(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return J(e)===n&&(n=n.ownerDocument.body),n}function gt(e,t){const n=H(e);if(ge(e))return n;if(!Y(e)){let o=ee(e);for(;o&&!oe(o);){if(j(o)&&!_e(o))return o;o=ee(o)}return n}let i=Ke(e,t);for(;i&&_n(i)&&_e(i);)i=Ke(i,t);return i&&oe(i)&&_e(i)&&!Le(i)?n:i||On(e)||n}const Un=async function(e){const t=this.getOffsetParent||gt,n=this.getDimensions,i=await n(e.floating);return{reference:$n(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function zn(e){return F(e).direction==="rtl"}const jn={convertOffsetParentRelativeRectToViewportRelativeRect:Dn,getDocumentElement:J,getClippingRect:Pn,getOffsetParent:gt,getElementRects:Un,getClientRects:In,getDimensions:Nn,getScale:ne,isElement:j,isRTL:zn},De=wn,wt=dn,Ie=yn,Re=un,yt=bn,bt=hn,vt=an,xt=pn,Be=(e,t,n)=>{const i=new Map,o={platform:jn,...n},s={...o.platform,_c:i};return ln(e,t,{...o,platform:s})};function Fn(e,t){const n=Math.min(e.top,t.top),i=Math.max(e.bottom,t.bottom),o=Math.min(e.left,t.left),r=Math.max(e.right,t.right)-o,a=i-n,c=o,h=n;return new DOMRect(c,h,r,a)}var qn=class{constructor({editor:e,element:t,view:n,updateDelay:i=250,resizeDelay:o=60,shouldShow:s,appendTo:r,getReferencedVirtualElement:a,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:d,from:f,to:p})=>{const{doc:m,selection:g}=d,{empty:w}=g,y=!m.textBetween(f,p).length&&T.isTextSelection(d.selection),v=this.element.contains(document.activeElement);return!(!(u.hasFocus()||v)||w||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,d)=>{const f=!(d!=null&&d.selection.eq(u.state.selection)),p=!(d!=null&&d.doc.eq(u.state.doc));!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,f,p,d)},this.updateDelay))},this.updateHandler=(u,d,f,p)=>{const{composing:m}=u;if(m||!d&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta("bubbleMenu");d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"&&this.updateOptions(d.options)};var h;this.editor=e,this.element=t,this.view=n,this.updateDelay=i,this.resizeDelay=o,this.appendTo=r,this.scrollTarget=(h=c==null?void 0:c.scrollTarget)!=null?h:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Re(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(vt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(yt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(wt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(bt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(xt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,n;const{selection:i}=this.editor.state,o=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(o)return o;if(!((n=(t=this.view)==null?void 0:t.dom)!=null&&n.parentNode))return;const s=T.posToDOMRect(this.view,i.from,i.to);let r={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(i instanceof z.NodeSelection){let a=this.view.nodeDOM(i.from);const c=a.dataset.nodeViewWrapper?a:a.querySelector("[data-node-view-wrapper]");c&&(a=c),a&&(r={getBoundingClientRect:()=>a.getBoundingClientRect(),getClientRects:()=>[a.getBoundingClientRect()]})}if(i instanceof Et.CellSelection){const{$anchorCell:a,$headCell:c}=i,h=a?a.pos:c.pos,u=c?c.pos:a.pos,d=this.view.nodeDOM(h),f=this.view.nodeDOM(u);if(!d||!f)return;const p=d===f?d.getBoundingClientRect():Fn(d.getBoundingClientRect(),f.getBoundingClientRect());r={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return r}updatePosition(){const e=this.virtualElement;e&&Be(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:n,strategy:i,middlewareData:o})=>{var s,r;if((s=o.hide)!=null&&s.referenceHidden||(r=o.hide)!=null&&r.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${t}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const{state:n}=e,i=n.selection.from!==n.selection.to;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const o=!(t!=null&&t.selection.eq(e.state.selection)),s=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,o,s,t)}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:o}=i,s=Math.min(...o.map(c=>c.$from.pos)),r=Math.max(...o.map(c=>c.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:s,to:r}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Wn=e=>new z.Plugin({key:typeof e.pluginKey=="string"?new z.PluginKey(e.pluginKey):e.pluginKey,view:t=>new qn({view:t,...e})}),Kn=l.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(e,{slots:t,attrs:n}){const i=l.ref(null);return l.onMounted(()=>{const{editor:o,options:s,pluginKey:r,resizeDelay:a,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}=e,f=i.value;f&&(f.style.visibility="hidden",f.style.position="absolute",f.remove(),l.nextTick(()=>{o.registerPlugin(Wn({editor:o,element:f,options:s,pluginKey:r,resizeDelay:a,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}))}))}),l.onBeforeUnmount(()=>{const{pluginKey:o,editor:s}=e;s.unregisterPlugin(o)}),()=>{var o;return l.h("div",{ref:i,...n},(o=t.default)==null?void 0:o.call(t))}}}),Xn=class{constructor({editor:e,element:t,view:n,updateDelay:i=250,resizeDelay:o=60,options:s,appendTo:r,shouldShow:a}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:h,state:u})=>{const{selection:d}=u,{$anchor:f,empty:p}=d,m=f.depth===1,g=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!h.hasFocus()||!p||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(h,u,d,f)=>{const{composing:p}=h;if(p||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var u;if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:h})=>{const u=h.getMeta("floatingMenu");u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"&&this.updateOptions(u.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=e,this.element=t,this.view=n,this.updateDelay=i,this.resizeDelay=o,this.appendTo=r,this.scrollTarget=(c=s==null?void 0:s.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return T.getText(e,{textSerializers:T.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Re(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(vt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(yt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(wt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(bt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(xt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:o}=i,s=Math.min(...o.map(c=>c.$from.pos)),r=Math.max(...o.map(c=>c.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:s,to:r})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=T.posToDOMRect(this.view,e.from,e.to);Be({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:o,strategy:s,middlewareData:r})=>{var a,c;if((a=r.hide)!=null&&a.referenceHidden||(c=r.hide)!=null&&c.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${i}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const n=!(t!=null&&t.selection.eq(e.state.selection)),i=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,n,i,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Yn=e=>new z.Plugin({key:typeof e.pluginKey=="string"?new z.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Xn({view:t,...e})});l.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(e,{slots:t,attrs:n}){const i=l.ref(null);return l.onMounted(()=>{const{pluginKey:o,editor:s,updateDelay:r,resizeDelay:a,options:c,appendTo:h,shouldShow:u}=e,d=i.value;d&&(d.style.visibility="hidden",d.style.position="absolute",d.remove(),s.registerPlugin(Yn({pluginKey:o,editor:s,element:d,updateDelay:r,resizeDelay:a,options:c,appendTo:h,shouldShow:u})))}),l.onBeforeUnmount(()=>{const{pluginKey:o,editor:s}=e;s.unregisterPlugin(o)}),()=>{var o;return l.h("div",{ref:i,...n},(o=t.default)==null?void 0:o.call(t))}}});const Q=e=>({default:null,parseHTML:t=>t.getAttribute(e),renderHTML:t=>t[e]?{[e]:t[e]}:{}}),Gn=()=>{let e=Q("style");return e.renderHTML=t=>t.style?{style:Jn(t.style)}:{},e};function Jn(e){return e.replace(new RegExp("(?<![a-z-])width\\s*:\\s*([^;]+);?","gi"),(t,n)=>/^\s*0\s*[a-z%]*\s*(!important)?\s*$/i.test(n)?"width: 100%;":t)}const Zn=pe.Table.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),border:Q("border"),cellpadding:Q("cellpadding"),cellspacing:Q("cellspacing"),style:Gn()}},renderHTML({HTMLAttributes:e}){return["table",T.mergeAttributes(this.options.HTMLAttributes,e),["tbody",0]]}}),Qn=pe.TableRow.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),style:Q("style")}}}),_t={style:Q("style"),valign:Q("valign"),width:Q("width")},ei=pe.TableCell.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),..._t}}}),ti=pe.TableHeader.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),..._t}}}),ni=Ze.TextStyle.extend({parseHTML(){var e;return[...((e=this.parent)==null?void 0:e.call(this))||[],{tag:"div",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1},{tag:"a",consuming:!1,getAttrs:t=>t.hasAttribute("style")?{}:!1}]}}),ii={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtEmoji:et.default},props:S.nodeViewProps};function oi(e,t,n,i,o,s){const r=l.resolveComponent("dt-emoji"),a=l.resolveComponent("node-view-wrapper");return l.openBlock(),l.createBlock(a,{class:"d-d-inline-block d-va-bottom d-lh0"},{default:l.withCtx(()=>[l.createVNode(r,{size:"500",code:e.node.attrs.code},null,8,["code"])]),_:1})}const si=q._(ii,[["render",oi]]),ri={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:$t.default},props:{items:{type:Array,required:!0},command:{type:Function,required:!0},itemComponent:{type:Object,required:!0},itemType:{type:String,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"?(this.downHandler(),!0):e.key==="Enter"||e.key==="Tab"?(this.selectHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length,this.scrollActiveElementIntoView()},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length,this.scrollActiveElementIntoView()},async scrollActiveElementIntoView(){await this.$nextTick();const e=this.$refs.suggestionList.querySelector(".d-list-item--highlighted");e&&e.scrollIntoView({behaviour:"smooth",block:"center"})},selectHandler(){this.selectItem(this.selectedIndex)},selectItem(e){const t=this.items[e];switch(this.itemType){case"emoji":this.command(t);return;case"mention":this.command({name:t.name,id:t.id,avatarSrc:t.avatarSrc,contactKey:t.contactKey});break;case"channel":this.command({name:t.name,id:t.id,locked:t.locked,channelKey:t.channelKey});break;case"slash-command":this.command({command:t.command});break}}}},li={class:"d-popover__dialog d-suggestion-list__container"},ai={ref:"suggestionList",class:"d-suggestion-list"};function ci(e,t,n,i,o,s){const r=l.resolveComponent("dt-list-item");return l.openBlock(),l.createElementBlock("div",li,[l.withDirectives(l.createElementVNode("ul",ai,[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(n.items,(a,c)=>(l.openBlock(),l.createBlock(r,{key:a.id,class:l.normalizeClass(["d-suggestion-list__item",{"d-list-item--highlighted":c===o.selectedIndex}]),"navigation-type":"arrow-keys",onClick:h=>s.selectItem(c),onKeydown:l.withModifiers(s.onKeyDown,["prevent"])},{default:l.withCtx(()=>[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(n.itemComponent),{item:a},null,8,["item"]))]),_:2},1032,["class","onClick","onKeydown"]))),128))],512),[[l.vShow,n.items.length]])])}const di=q._(ri,[["render",ci]]),Tt="top-start",Ct="650";function ui(){return{getBoundingClientRect:()=>({width:0,height:0,x:0,y:0,top:0,left:0,right:0,bottom:0})}}function Xe(e){return{getBoundingClientRect:e}}async function hi(e,t,n={}){if(!e||!(t!=null&&t.getBoundingClientRect))return;const{placement:i=Tt,middleware:o=[De(0),Re(),Ie({padding:8})]}=n,{x:s,y:r}=await Be(t,e,{placement:i,middleware:o});Object.assign(e.style,{left:`${s}px`,top:`${r}px`})}function fi(e,t={}){const{zIndex:n=Ct}=t;e.style.position="absolute",e.style.zIndex=n,e.style.display="none"}function pi(e){e&&(e.style.display="block")}function mi(e){e&&(e.style.display="none")}function gi(e,t){return n=>{n.key==="Escape"&&t()&&e()}}function wi(e){document.addEventListener("keydown",e)}function yi(e){document.removeEventListener("keydown",e)}function bi(e,t,n,i){return new S.VueRenderer(e,{props:{itemComponent:l.markRaw(t),itemType:n,...i},editor:i.editor})}function vi(e){var t,n;e.escHandler&&yi(e.escHandler),(t=e.floatingEl)==null||t.remove(),(n=e.component)==null||n.destroy()}function be(e,t,n={}){const{listComponent:i=di,placement:o=Tt,zIndex:s=Ct}=n;return()=>{let r=null,a=null,c=!1,h=ui(),u=null;function d(){hi(a,h,{placement:o})}function f(){a&&(pi(a),c=!0,d())}function p(){a&&(mi(a),c=!1)}return{onStart:m=>{r=bi(i,e,t,m),m.clientRect&&(a=r.element,fi(a,{zIndex:s}),document.body.appendChild(a),h=Xe(m.clientRect),u=gi(p,()=>c),wi(u),m.items.length>0&&f())},onUpdate(m){r==null||r.updateProps(m),m.items.length>0?f():p(),m.clientRect&&(h=Xe(m.clientRect),d())},onKeyDown(m){var g;if(c)return(g=r==null?void 0:r.ref)==null?void 0:g.onKeyDown(m)},onExit(){vi({escHandler:u,floatingEl:a,component:r}),u=null,a=null,r=null}}}}const xi={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:et.default,DtStack:ae.default},props:{item:{type:Object,required:!0}}};function _i(e,t,n,i,o,s){const r=l.resolveComponent("dt-emoji"),a=l.resolveComponent("dt-stack");return l.openBlock(),l.createBlock(a,{direction:"row",gap:"400"},{default:l.withCtx(()=>[l.createVNode(r,{size:"200",code:n.item.code},null,8,["code"]),l.createTextVNode(" "+l.toDisplayString(n.item.code),1)]),_:1})}const Ti=q._(xi,[["render",_i]]),Ci=20,ki=(e,t,n)=>{var a,c;const i=(a=e.shortname)==null?void 0:a.replaceAll(":",""),o=(c=t.shortname)==null?void 0:c.replaceAll(":",""),s=i.startsWith(n),r=o.startsWith(n);return s&&!r?-1:!s&&r?1:i.localeCompare(o)},Ei={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(te.getEmojiData());return e=e.toLowerCase(),t.filter(i=>{var o;return[i.name,(o=i.shortname)==null?void 0:o.replaceAll(":",""),...i.keywords||[]].some(s=>s&&s.startsWith(e))}).splice(0,Ci).sort((i,o)=>ki(i,o,e)).map(i=>({code:i.shortname}))},command:({editor:e,range:t,props:n})=>{var s,r;const i=e.view.state.selection.$to.nodeAfter;((s=i==null?void 0:i.text)==null?void 0:s.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:n}]).run(),(r=window.getSelection())==null||r.collapseToEnd()},render:be(Ti,"emoji")},Oi=/(:\w+:)$/,Si=new RegExp(Qe.emojiPattern+"$"),Li=e=>{if(e&&te.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},Ai=e=>[...e.matchAll(te.emojiShortCodeRegex)].filter(n=>te.codeToEmojiData(n[0])).map(n=>({index:n.index,text:n[0],match:n})),Di=T.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return S.VueNodeViewRenderer(si)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return te.stringToUnicode(te.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new T.InputRule({find:e=>{const t=e.match(Oi)||e.match(Si);if(t)return Li(t)},handler:({state:e,range:t,match:n})=>{const{tr:i}=e,o=t.from,s=t.to;i.replaceWith(o,s,this.type.create({code:n[0]}))}})]},addPasteRules(){return[T.nodePasteRule({find:Ai,type:this.type,getAttributes(e){return{code:e[0]}}}),T.nodePasteRule({find:te.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[Nt({char:":",pluginKey:new z.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Ei})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:i}=t,{empty:o,anchor:s}=i;return o?(t.doc.nodesBetween(s-1,s,(r,a)=>{if(r.type.name===this.name)return n=!0,e.insertText("",a,a+r.nodeSize),!1}),n):!1})}}});function Ii(e,t,n=()=>!0){const i=[];t.lastIndex=0;let o;for(;o=t.exec(e);)n(e,o)&&i.push(o);return i}function Ri(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Bi(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function Mi(e,t){const n=e.slice(0,t+1).search(/\S+\s*$/),i=e.slice(t).search(/\s/);if(i<0){const o=e.slice(n);return{text:o,from:n,to:n+o.length}}return{text:e.slice(n,i+t),from:n,to:i+t}}function Ce(e,t,n,i){const o=Mi(e,t);if(i.lastIndex=0,!i.test(o.text))return o;const s=n==="left"?o.from-1:o.to+1;return s<=0||s>=e.length||s===t?o:Ce(e,s,n,i)}function Hi(e,t,n,i){const o=Math.max(e.from-1,0),s=Math.min(e.to+1,t.content.size),r=T.getMarksBetween(o,s,t);for(const a of r)a.mark.type===i&&n.removeMark(a.from,a.to,i)}const Ye=re.getPhoneNumberRegex(1,15);function Ge(e,t,n,i,o,s){if(!e)return;let r=n-t-1;r=r<0?0:r;const a=i-t,c=Ce(e,r,"left",Ye),h=Ce(e,a,"right",Ye),u=e.slice(c.from,h.to);Ii(u,re.linkRegex,Ri).forEach(f=>{const p=Bi(f[0]),m=t+c.from+f.index+1,g=m+p.length;o.addMark(m,g,s.create())})}function Vi(e){let t=!1;return new z.Plugin({key:new z.PluginKey("autolink"),appendTransaction:(n,i,o)=>{const s=n.some(u=>u.docChanged)&&!i.doc.eq(o.doc);if(t&&!s)return;const{tr:r}=o,{textContent:a}=o.doc;t||Ge(a,0,0,a.length,r,e.type),t=!0;const c=T.combineTransactionSteps(i.doc,[...n]);return T.getChangedRanges(c).forEach(({oldRange:u,newRange:d})=>{Hi(d,o.doc,r,e.type),T.findChildrenInRange(o.doc,d,p=>p.isTextblock).forEach(({node:p,pos:m})=>{Ge(p.textContent,m,u.from,d.to,r,e.type)})}),r}})}const Pi={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},Ni=T.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",T.mergeAttributes(this.options.HTMLAttributes,e,Pi)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Vi({type:this.type})]}}),$i=Ut.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),Ui=new Set(["address","article","aside","blockquote","dd","details","dialog","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","ol","p","pre","section","table","ul"]),zi=Je.extend({parseHTML(){return[{tag:"div",getAttrs:e=>{for(const t of e.children)if(Ui.has(t.tagName.toLowerCase()))return!1;return null}}]},renderHTML({HTMLAttributes:e}){return["div",T.mergeAttributes(this.options.HTMLAttributes,e),0]}}),ji={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:tt.default},props:S.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}},methods:{getMentionData(){return{name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,avatarSrc:this.$props.node.attrs.avatarSrc,contactKey:this.$props.node.attrs.contactKey}},handleClick(){this.$props.editor.emit("mention-click",this.getMentionData())},handleMouseEnter(e){this.$props.editor.emit("mention-hover",{...this.getMentionData(),event:e})},handleMouseLeave(e){this.$props.editor.emit("mention-leave",{...this.getMentionData(),event:e})}}};function Fi(e,t,n,i,o,s){const r=l.resolveComponent("dt-link"),a=l.resolveComponent("node-view-wrapper");return l.openBlock(),l.createBlock(a,{class:"d-d-inline-block"},{default:l.withCtx(()=>[l.createVNode(r,{kind:"mention",onClick:l.withModifiers(s.handleClick,["prevent"]),onMouseenter:s.handleMouseEnter,onMouseleave:s.handleMouseLeave,onFocusin:s.handleMouseEnter,onFocusout:s.handleMouseLeave},{default:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(s.text),1)]),_:1},8,["onClick","onMouseenter","onMouseleave","onFocusin","onFocusout"])]),_:1})}const qi=q._(ji,[["render",Fi]]),Wi=ke.extend({addNodeView(){return S.VueNodeViewRenderer(qi)},parseHTML(){return[{tag:"mention-component"}]},addAttributes(){return{name:{default:""},avatarSrc:{default:""},id:{default:""},contactKey:{default:""}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["mention-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new z.PluginKey("mentionSuggestion")}}),Ki={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:tt.default,DtIconLock:zt.DtIconLock,DtStack:ae.default},props:S.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:"#"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,locked:this.$props.node.attrs.locked,channelKey:this.$props.node.attrs.channelKey};this.$props.editor.emit("channel-click",e)}}};function Xi(e,t,n,i,o,s){const r=l.resolveComponent("dt-icon-lock"),a=l.resolveComponent("dt-stack"),c=l.resolveComponent("dt-link"),h=l.resolveComponent("node-view-wrapper");return l.openBlock(),l.createBlock(h,{class:"d-d-inline-block"},{default:l.withCtx(()=>[l.createVNode(c,{kind:"mention",onClick:l.withModifiers(s.handleClick,["prevent"])},{default:l.withCtx(()=>[l.createVNode(a,{direction:"row",gap:"0"},{default:l.withCtx(()=>[e.$props.node.attrs.locked?(l.openBlock(),l.createBlock(r,{key:0,size:"200"})):l.createCommentVNode("",!0),l.createElementVNode("span",null,l.toDisplayString(s.text),1)]),_:1})]),_:1},8,["onClick"])]),_:1})}const Yi=q._(Ki,[["render",Xi]]),Gi=ke.extend({name:"channel",addNodeView(){return S.VueNodeViewRenderer(Yi)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1},channelKey:{default:""}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new z.PluginKey("channelSuggestion")}}),Ji={compatConfig:{MODE:3},name:"SlashCommandsComponent",components:{NodeViewWrapper:S.NodeViewWrapper},props:{...S.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var n,i,o;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(o=(i=(n=this.editor)==null?void 0:n.storage)==null?void 0:i["slash-commands"])==null?void 0:o.onSelectedCommand;t&&typeof t=="function"&&t(e)}};function Zi(e,t,n,i,o,s){const r=l.resolveComponent("node-view-wrapper");return l.openBlock(),l.createBlock(r,{class:"d-d-inline-block"},{default:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(s.text),1)]),_:1})}const Qi=q._(Ji,[["render",Zi]]),eo=(e,t)=>[...e.matchAll(t)].map(i=>{let o=i[2];return o.endsWith(" ")||(o+=" "),{index:i.index,text:o,match:i}}),to=ke.extend({name:"slash-commands",group:"inline",inline:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onSelectedCommand:null}},addStorage(){return{onSelectedCommand:this.options.onSelectedCommand}},addNodeView(){return S.VueNodeViewRenderer(Qi)},parseHTML(){return[{tag:"command-component"}]},addAttributes(){return{command:{default:""},parametersExample:{default:""},description:{default:""}}},renderText({node:e}){return`/${e.attrs.command}`},renderHTML({HTMLAttributes:e}){return["command-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var n;const e=(n=this.options.suggestion)==null?void 0:n.items({query:""}).map(i=>i.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[T.nodeInputRule({find:t,type:this.type,getAttributes(i){return{command:i[2]}}})]},addPasteRules(){var n;const e=(n=this.options.suggestion)==null?void 0:n.items({query:""}).map(i=>i.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[T.nodePasteRule({find:i=>eo(i,t),type:this.type,getAttributes(i){return{command:i[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new z.PluginKey("slashCommandSuggestion")}}),no=100,io={name:"VariableComponent",components:{DtBadge:qt.default,DtButton:it.default,DtPopover:Ft.default,DtInput:jt.default,NodeViewWrapper:S.NodeViewWrapper},props:S.nodeViewProps,data(){return{i18n:new nt.DialtoneLocalization,MAX_VARIABLE_ALT_LENGTH:no}},computed:{altText:{get(){var e,t;return((t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.altText)||""},set(e){this.updateAttributes({altText:e})}},variableId(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.id},placeholder(){var e;return((e=this.variableData)==null?void 0:e.placeholder)||""},variableItems(){var e,t;return((t=(e=this.extension)==null?void 0:e.options)==null?void 0:t.variableItems)||[]},variableData(){return this.variableItems.find(e=>e.id===this.variableId)},enableAltText(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.enableAltText},badgeLabel(){return`{} ${this.placeholder}`},placeholderText(){return`Replaces ${this.placeholder}`}}};function oo(e,t,n,i,o,s){const r=l.resolveComponent("dt-badge"),a=l.resolveComponent("dt-button"),c=l.resolveComponent("dt-input"),h=l.resolveComponent("dt-popover"),u=l.resolveComponent("node-view-wrapper");return l.openBlock(),l.createBlock(u,{class:"d-d-inline-block"},{default:l.withCtx(()=>[s.enableAltText?(l.openBlock(),l.createBlock(h,{key:0,padding:"small","navigation-type":"arrow-keys",placement:"top-start",modal:!1},{anchor:l.withCtx(({attrs:d})=>[l.createVNode(a,l.mergeProps(d,{kind:"unstyled"}),{default:l.withCtx(()=>[l.createVNode(r,{text:s.badgeLabel,contenteditable:"false"},null,8,["text"])]),_:1},16)]),content:l.withCtx(({close:d})=>[l.createVNode(c,{modelValue:s.altText,"onUpdate:modelValue":t[0]||(t[0]=f=>s.altText=f),"root-class":"d-p8 d-w332",label:o.i18n.$t("DIALTONE_EDITOR_VARIABLE_LABEL"),placeholder:s.placeholderText,validate:{length:{description:o.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION"),message:o.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE"),max:o.MAX_VARIABLE_ALT_LENGTH,warn:o.MAX_VARIABLE_ALT_LENGTH,limitMaxLength:!0}},onKeyup:l.withKeys(f=>d(),["enter"])},null,8,["modelValue","label","placeholder","validate","onKeyup"])]),_:1})):(l.openBlock(),l.createBlock(r,{key:1,text:s.badgeLabel,contenteditable:"false"},null,8,["text"]))]),_:1})}const so=q._(io,[["render",oo]]),ro=T.Node.create({name:"variable",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},variableItems:[]}},addNodeView(){return S.VueNodeViewRenderer(so)},addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-variable-id"),renderHTML:e=>e.id?{"data-variable-id":e.id}:{}},altText:{default:"",parseHTML:e=>e.getAttribute("data-alt-text"),renderHTML:e=>e.altText?{"data-alt-text":e.altText}:{}},enableAltText:{default:!0,parseHTML:e=>e.getAttribute("data-enable-alt-text")==="true",renderHTML:e=>({"data-enable-alt-text":String(e.enableAltText)})}}},parseHTML(){return[{tag:"variable"}]},renderText({node:e}){return e.attrs.altText},renderHTML({node:e,HTMLAttributes:t}){return["variable",T.mergeAttributes(this.options.HTMLAttributes,t,{"data-variable-id":e.attrs.id,"data-alt-text":e.attrs.altText,"data-enable-alt-text":String(e.attrs.enableAltText)})]},addCommands(){return{insertVariable:(e={})=>({commands:t})=>t.insertContent({type:this.name,attrs:{id:e.id||null,altText:e.altText||"",enableAltText:e.enableAltText}})}}}),lo={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:Wt.default,DtStack:ae.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name},avatarSrc(){return this.item.avatarSrc},presence(){return this.item.presence},status(){return this.item.status},presenceText(){return this.item.presenceText},presenceFontColorClass(){return{active:"d-recipe-contact-row--active",busy:"d-recipe-contact-row--busy",away:"d-recipe-contact-row--away",offline:"d-recipe-contact-row--busy"}[this.presence]},showDetails(){return this.item.showDetails}}},ao={class:"d-mention-suggestion__name"},co={key:1,class:"d-mention-suggestion__divider"},uo={key:2,class:"d-mention-suggestion__status"};function ho(e,t,n,i,o,s){const r=l.resolveComponent("dt-avatar"),a=l.resolveComponent("dt-stack");return l.openBlock(),l.createBlock(a,{direction:"row",class:"d-mention-suggestion__container",gap:"400"},{default:l.withCtx(()=>[l.createVNode(r,{"full-name":s.name,"image-src":s.avatarSrc,"image-alt":s.name,"show-presence":s.showDetails,presence:s.presence,size:"sm"},null,8,["full-name","image-src","image-alt","show-presence","presence"]),l.createVNode(a,{class:"d-mention-suggestion__details-container",gap:"100"},{default:l.withCtx(()=>[l.createElementVNode("span",ao,l.toDisplayString(s.name),1),s.showDetails?(l.openBlock(),l.createBlock(a,{key:0,direction:"row",gap:"300",class:"d-label--sm-plain"},{default:l.withCtx(()=>[s.presenceText?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["d-mention-suggestion__presence",[s.presenceFontColorClass]])},l.toDisplayString(s.presenceText),3)):l.createCommentVNode("",!0),s.status&&s.presenceText?(l.openBlock(),l.createElementBlock("div",co," • ")):l.createCommentVNode("",!0),s.status?(l.openBlock(),l.createElementBlock("div",uo,l.toDisplayString(s.status),1)):l.createCommentVNode("",!0)]),_:1})):l.createCommentVNode("",!0)]),_:1})]),_:1})}const fo=q._(lo,[["render",ho]]),po={allowSpaces:!0,render:be(fo,"mention")},mo={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:ae.default,DtIconHash:Kt,DtIconLock:Xt},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function go(e,t,n,i,o,s){const r=l.resolveComponent("dt-icon-hash"),a=l.resolveComponent("dt-icon-lock"),c=l.resolveComponent("dt-stack");return l.openBlock(),l.createBlock(c,{direction:"row",gap:"400"},{default:l.withCtx(()=>[n.item.locked?(l.openBlock(),l.createBlock(a,{key:1,size:"300"})):(l.openBlock(),l.createBlock(r,{key:0,size:"300"})),l.createElementVNode("span",null,l.toDisplayString(s.name),1)]),_:1})}const wo=q._(mo,[["render",go]]),yo={allowSpaces:!0,render:be(wo,"channel")},bo={compatConfig:{MODE:3},name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}},vo={class:"d-body--md-compact"},xo={key:0},_o={class:"d-body--sm d-fc-tertiary"};function To(e,t,n,i,o,s){return l.openBlock(),l.createElementBlock("div",null,[l.createElementVNode("div",vo,[l.createElementVNode("span",null,"/"+l.toDisplayString(s.command),1),s.parametersExample?(l.openBlock(),l.createElementBlock("span",xo,l.toDisplayString(s.parametersExample),1)):l.createCommentVNode("",!0)]),l.createElementVNode("div",_o,l.toDisplayString(s.description),1)])}const Co=q._(bo,[["render",To]]),ko={allowSpaces:!0,startOfLine:!0,render:be(Co,"slash-command")},Eo={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:S.EditorContent,BubbleMenu:Kn,DtButton:it.default,DtStack:ae.default},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},preventTyping:{type:Boolean,default:!1},pasteRichText:{type:Boolean,default:!0},allowLineBreaks:{type:Boolean,default:!1},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e=="string"?de.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return de.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowBackgroundColor:{type:Boolean,default:!1},allowFontSize:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},allowLineHeight:{type:Boolean,default:!1},allowVariable:{type:Boolean,default:!1},variableItems:{type:Array,default:()=>[]},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},preserveWhitespace:{type:[Boolean,String],default:"full"},useDivTags:{type:Boolean,default:!1},allowTables:{type:Boolean,default:!1},allowImageResize:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","markdown-input","update:modelValue","blur","focus","enter","edit-link","selected","selected-command","mention-click","mention-hover","mention-leave","channel-click"],data(){return{editor:null,appendTo:()=>{var e;return(e=re.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},floatingOptions:{placement:"top-start"},i18n:new nt.DialtoneLocalization}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){const e=[At,Vt,ve.UndoRedo,Dt];e.push(this.useDivTags?zi:Je),this.allowBold&&e.push(It),this.allowBlockquote&&e.push(Ot),this.allowBulletList&&(e.push(xe.BulletList),e.push(xe.ListItem.extend({renderText({node:i}){return i.textContent}})),e.push(xe.OrderedList)),this.allowItalic&&e.push(Rt),this.allowStrike&&e.push(Mt),this.allowUnderline&&e.push(Ht),this.placeholder&&e.push(ve.Placeholder.configure({placeholder:this.placeholder}));const t=this,n=T.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:i})=>t.allowLineBreaks?!1:(i.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>t.allowBulletList&&o.splitListItem("listItem"),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(n),this.link&&e.push(Bt.extend({inclusive:!1,addKeyboardShortcuts(){return{"Mod-k":()=>(t.$emit("edit-link"),!0)}}}).configure({HTMLAttributes:{class:"d-link d-wb-break-all"},openOnClick:!1,autolink:!0,protocols:de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension(Ni,this.customLink)),this.mentionSuggestion){const i={...this.mentionSuggestion,...po};e.push(Wi.configure({suggestion:i}))}if(this.channelSuggestion){const i={...this.channelSuggestion,...yo};e.push(Gi.configure({suggestion:i}))}if(this.slashCommandSuggestion){const i={...this.slashCommandSuggestion,...ko};e.push(to.configure({suggestion:i,onSelectedCommand:o=>{this.$emit("selected-command",o)}}))}return this.allowVariable&&e.push(ro.configure({variableItems:this.variableItems})),e.push(Di),e.push(Pt.configure({types:["paragraph"]})),this.allowCode&&e.push(Lt),this.allowCodeblock&&e.push(St.extend({renderText({node:i}){return`\`\`\`
2
+ ${i.textContent}
3
+ \`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push($i.configure({resize:{enabled:this.allowImageResize,alwaysPreserveAspectRatio:!0}})),(this.allowFontFamily||this.allowFontColor||this.allowFontSize||this.allowBackgroundColor||this.allowLineHeight)&&(e.push(Ze.TextStyleKit.configure({color:this.allowFontColor,backgroundColor:this.allowBackgroundColor,fontFamily:this.allowFontFamily,fontSize:this.allowFontSize,lineHeight:this.allowLineHeight})),e.push(ni)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),this.allowTables&&e.push(Zn.configure({resizable:!0}),Qn,ti,ei,ve.Gapcursor),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(e){this.processValue(e)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},mounted(){re.warnIfUnmounted(re.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new S.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,shouldRerenderOnTransaction:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const n=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&n.push("Enter"),!n.includes(t.key)},handlePaste:(e,t)=>{const n=t.clipboardData||window.clipboardData,i=n.getData("text/plain"),o=n.getData("text/html");return this.processPasteData(e,i,o)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var a,c,h;const{view:t,state:n}=e,{from:i,to:o}=t.state.selection,s=n.doc.textBetween(i,o,""),r=this.editor.state.doc.nodeAt(i);return r&&((h=(c=(a=r.marks)==null?void 0:a.at(0))==null?void 0:c.type)==null?void 0:h.name)==="link"?r.textContent:s},editLink(){const e=this.getSelectedLinkText(this.editor),t={href:this.editor.getAttributes("link").href,text:e};this.$emit("edit-link",t)},removeLink(){var e,t,n,i;(i=(n=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:n.unsetLink())==null||i.run()},openLink(){var t,n;(n=(t=this.editor)==null?void 0:t.chain())==null||n.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,n,i=de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,o){var a,c,h;if(!e){this.removeLink();return}i.find(u=>u.test(e))||(e=`${o}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const r=(h=(c=(a=this.editor)==null?void 0:a.view)==null?void 0:c.state)==null?void 0:h.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:r.from,to:r.from+t.length}).setLink({href:e,class:n.class}).run()},processValue(e,t=!0){if(!this.editor)return;const n=this.getOutput();if(!(t&&Yt(e,n))){if(typeof e=="string"&&this.outputFormat==="text"){const i=new RegExp(`(${Qe.emojiPattern})`,"g");e=e==null?void 0:e.replace(i,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,{emitUpdate:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace}})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const o=(this.pasteRichText?t:t.replace(/\r\n/g,`
13
4
  `).replace(/\n\n/g,`
14
- `)).replace(/[\r\n]+$/,"").split(/\r?\n/),s=[];for(let r=0;r<i.length;r++)r>0&&s.push({type:"hardBreak"}),i[r]&&s.push({type:"text",text:i[r]});this.editor.chain().focus().insertContent(s).run()},shouldPreserveLineBreaks(e,t){return this.pasteRichText?!t&&e&&this.hasBlankLines(e):!!e},processPasteData(e,t,o){if(this.shouldPreserveLineBreaks(t,o))return this.insertPlainTextWithHardBreaks(e,t),!0;if(this.shouldHandlePreformattedHTML(o)){const n=this.extractPreformattedText(o);if(n&&n.includes(`
15
- `))return this.insertPlainTextWithHardBreaks(e,n),!0}return!1},shouldHandlePreformattedHTML(e){return this.pasteRichText&&e&&this.containsPreformattedContent(e)},containsPreformattedContent(e){const t=document.createElement("div");t.innerHTML=e;const o=t.querySelectorAll("*");for(const n of o)if(this.hasPreWhitespace(n)&&this.hasLineBreaks(n))return!0;return!1},hasPreWhitespace(e){const t=e.getAttribute("style")||"",o=e.style.whiteSpace||"",n=o==="pre"||o==="pre-wrap",i=t.includes("white-space: pre");return n||i},hasLineBreaks(e){return e.textContent&&e.textContent.includes(`
5
+ `)).replace(/[\r\n]+$/,"").split(/\r?\n/),s=[];for(let r=0;r<o.length;r++)r>0&&s.push({type:"hardBreak"}),o[r]&&s.push({type:"text",text:o[r]});this.editor.chain().focus().insertContent(s).run()},shouldPreserveLineBreaks(e,t){return this.pasteRichText?!t&&e&&this.hasBlankLines(e):!!e},processPasteData(e,t,n){if(this.shouldPreserveLineBreaks(t,n))return this.insertPlainTextWithHardBreaks(e,t),!0;if(this.shouldHandlePreformattedHTML(n)){const i=this.extractPreformattedText(n);if(i&&i.includes(`
6
+ `))return this.insertPlainTextWithHardBreaks(e,i),!0}return!1},shouldHandlePreformattedHTML(e){return this.pasteRichText&&e&&this.containsPreformattedContent(e)},containsPreformattedContent(e){const t=document.createElement("div");t.innerHTML=e;const n=t.querySelectorAll("*");for(const i of n)if(this.hasPreWhitespace(i)&&this.hasLineBreaks(i))return!0;return!1},hasPreWhitespace(e){const t=e.getAttribute("style")||"",n=e.style.whiteSpace||"",i=n==="pre"||n==="pre-wrap",o=t.includes("white-space: pre");return i||o},hasLineBreaks(e){return e.textContent&&e.textContent.includes(`
16
7
  `)},hasBlankLines(e){return e.includes(`
17
8
 
18
- `)||/\n\s*\n/.test(e)},extractPreformattedText(e){const t=document.createElement("div");return t.innerHTML=e,this.walkAndExtractText(t)},walkAndExtractText(e){let t="";if(e.nodeType===Node.TEXT_NODE)t+=e.textContent;else if(e.nodeType===Node.ELEMENT_NODE)if(this.hasPreWhitespace(e))t+=e.textContent;else for(const o of e.childNodes)t+=this.walkAndExtractText(o);return t},triggerInputChangeEvents(){const e=this.getOutput();this.$emit("input",e),this.$emit("update:modelValue",e);const t=this.editor.getJSON();this.$emit("json-input",t);const o=this.editor.getHTML();this.$emit("html-input",o);const n=this.editor.getText({blockSeparator:`
19
- `});this.$emit("text-input",n);const i=this.jsonToMarkdownConverter.convertToMarkdown(t);this.$emit("markdown-input",i)},addEditorListeners(){this.editor.on("create",()=>{this.triggerInputChangeEvents()}),this.editor.on("update",()=>{this.triggerInputChangeEvents()}),this.editor.on("selectionUpdate",({editor:e})=>{this.$emit("selected",this.getSelectedLinkText(e))}),this.editor.on("focus",({event:e})=>{this.$emit("focus",e)}),this.editor.on("blur",({event:e})=>{this.$emit("blur",e)}),this.editor.on("mention-click",e=>{this.$emit("mention-click",e)}),this.editor.on("mention-hover",e=>{this.$emit("mention-hover",e)}),this.editor.on("mention-leave",e=>{this.$emit("mention-leave",e)}),this.editor.on("channel-click",e=>{this.$emit("channel-click",e)})},getOutput(){switch(this.outputFormat){case"json":return this.editor.getJSON();case"html":return this.editor.getHTML();case"markdown":return this.jsonToMarkdownConverter.convertToMarkdown(this.editor.getJSON());case"text":default:return this.editor.getText({blockSeparator:`
20
- `})}},getExtension(e,t){var o;return typeof t=="boolean"?e:(o=e.configure)==null?void 0:o.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},Ei={class:"d-popover__dialog"};function Oi(e,t,o,n,i,s){const r=a.resolveComponent("dt-button"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("bubble-menu"),h=a.resolveComponent("editor-content");return a.openBlock(),a.createElementBlock("div",null,[i.editor&&o.link&&!o.hideLinkBubbleMenu?(a.openBlock(),a.createBlock(c,{key:0,editor:i.editor,"should-show":s.bubbleMenuShouldShow,options:i.floatingOptions,"append-to":i.appendTo,style:{visibility:"visible"}},{default:a.withCtx(()=>[a.createElementVNode("div",Ei,[a.createVNode(l,{direction:"row",class:"d-rich-text-editor-bubble-menu__button-stack",gap:"0"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.editLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.openLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"danger",importance:"clear",onClick:s.removeLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")),1)]),_:1},8,["onClick"])]),_:1})])]),_:1},8,["editor","should-show","options","append-to"])):a.createCommentVNode("",!0),a.createVNode(h,a.mergeProps({ref:"editor",editor:i.editor,class:"d-rich-text-editor","data-qa":"dt-rich-text-editor"},s.attrs),null,16,["editor"])])}const Si=F._(ki,[["render",Oi]]);exports.default=Si;
9
+ `)||/\n\s*\n/.test(e)},extractPreformattedText(e){const t=document.createElement("div");return t.innerHTML=e,this.walkAndExtractText(t)},walkAndExtractText(e){let t="";if(e.nodeType===Node.TEXT_NODE)t+=e.textContent;else if(e.nodeType===Node.ELEMENT_NODE)if(this.hasPreWhitespace(e))t+=e.textContent;else for(const n of e.childNodes)t+=this.walkAndExtractText(n);return t},triggerInputChangeEvents(){const e=this.getOutput();this.$emit("input",e),this.$emit("update:modelValue",e);const t=this.editor.getJSON();this.$emit("json-input",t);const n=this.editor.getHTML();this.$emit("html-input",n);const i=this.editor.getText({blockSeparator:`
10
+ `});this.$emit("text-input",i);const o=Me.renderEditorToMarkdown(t,this.extensions);this.$emit("markdown-input",o)},addEditorListeners(){this.editor.on("create",()=>{this.triggerInputChangeEvents()}),this.editor.on("update",()=>{this.triggerInputChangeEvents()}),this.editor.on("selectionUpdate",({editor:e})=>{this.$emit("selected",this.getSelectedLinkText(e))}),this.editor.on("focus",({event:e})=>{this.$emit("focus",e)}),this.editor.on("blur",({event:e})=>{this.$emit("blur",e)}),this.editor.on("mention-click",e=>{this.$emit("mention-click",e)}),this.editor.on("mention-hover",e=>{this.$emit("mention-hover",e)}),this.editor.on("mention-leave",e=>{this.$emit("mention-leave",e)}),this.editor.on("channel-click",e=>{this.$emit("channel-click",e)})},getOutput(){switch(this.outputFormat){case"json":return this.editor.getJSON();case"html":return this.editor.getHTML();case"markdown":return Me.renderEditorToMarkdown(this.editor.getJSON(),this.extensions);case"text":default:return this.editor.getText({blockSeparator:`
11
+ `})}},getExtension(e,t){var n;return typeof t=="boolean"?e:(n=e.configure)==null?void 0:n.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},Oo={class:"d-popover__dialog"};function So(e,t,n,i,o,s){const r=l.resolveComponent("dt-button"),a=l.resolveComponent("dt-stack"),c=l.resolveComponent("bubble-menu"),h=l.resolveComponent("editor-content");return l.openBlock(),l.createElementBlock("div",null,[o.editor&&n.link&&!n.hideLinkBubbleMenu?(l.openBlock(),l.createBlock(c,{key:0,editor:o.editor,"should-show":s.bubbleMenuShouldShow,options:o.floatingOptions,"append-to":o.appendTo,style:{visibility:"visible"}},{default:l.withCtx(()=>[l.createElementVNode("div",Oo,[l.createVNode(a,{direction:"row",class:"d-rich-text-editor-bubble-menu__button-stack",gap:"0"},{default:l.withCtx(()=>[l.createVNode(r,{kind:"muted",importance:"clear",onClick:s.editLink},{default:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(o.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),l.createVNode(r,{kind:"muted",importance:"clear",onClick:s.openLink},{default:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(o.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),l.createVNode(r,{kind:"danger",importance:"clear",onClick:s.removeLink},{default:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(o.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")),1)]),_:1},8,["onClick"])]),_:1})])]),_:1},8,["editor","should-show","options","append-to"])):l.createCommentVNode("",!0),l.createVNode(h,l.mergeProps({ref:"editor",editor:o.editor,class:"d-rich-text-editor","data-qa":"dt-rich-text-editor"},s.attrs),null,16,["editor"])])}const Lo=q._(Eo,[["render",So]]);exports.default=Lo;
21
12
  //# sourceMappingURL=rich-text-editor.cjs.map