@frontify/fondue 12.0.0-beta.281 → 12.0.0-beta.283

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.
package/dist/index.umd.js CHANGED
@@ -35,7 +35,7 @@ ${i2("Ctrl+B")}`),key:l,type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:
35
35
  color: var(--box-neutral-inverse-color-hover);
36
36
  `]},ym0={renderAfterEditable:Zm0};class mV extends n0{constructor(l){super(Am0,{button:Im0,showIn:[h0.BOTTOM,h0.TOP],...l})}plugins(){return[w.createComboboxPlugin(),w.createEmojiPlugin(ym0)]}}const xm0="soft-break-plugin";class LV extends n0{constructor(l){super(xm0,{...l})}plugins(){return[w.createSoftBreakPlugin()]}}const Hm0="italic-plugin",h5="tw-italic",dV=({attributes:e,children:l})=>t.createElement("span",{...e,className:h5},l);class uV extends l0{constructor(l=w.MARK_ITALIC,a=dV){super(l,a)}}const bm0=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.MarkToolbarButton,{tooltip:V0(`Italic
37
37
  ${i2("Ctrl+I")}`),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(Ce,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"})),km0=[{validNodeName:["EM","I"]},{validStyle:{fontStyle:"italic"}}];class wV extends n0{constructor(l){super(Hm0,{button:bm0,markupElement:new uV,...l})}plugins(){return[w.createItalicPlugin({deserializeHtml:{rules:[...km0,{validNodeName:["SPAN"],validClassName:h5}]},options:{hotkey:["mod+i","ctrl+i"]}})]}}const zm0=e=>!!e.match(/^(https?:\/\/|mailto:|tel:).+/),pm0=w.createComponentAs(e=>{var a;const l=w.useFloatingLinkInsert({...e,floatingOptions:{strategy:"fixed"}});return((a=l.style)==null?void 0:a.display)==="none"?null:w.createElementAs("div",l)}),Vm0=w.createComponentAs(e=>{var a;const l=Bm0({...e,floatingOptions:{strategy:"fixed"}});return((a=l.style)==null?void 0:a.display)==="none"?null:w.createElementAs("div",l)});w.FloatingLink.EditRoot=Vm0,w.FloatingLink.InsertRoot=pm0;const f5=w.FloatingLink,F1="link-plugin",Tm0=()=>{const e=w.useFloatingLinkUrlInput({}),{styles:l}=C1();return t.createElement("div",{"data-test-id":"floating-link-edit",className:"tw-bg-white tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]"},t.createElement("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between"},t.createElement("span",{style:l[F1],className:"tw-pointer-events-none"},e.defaultValue),t.createElement("span",{className:"tw-flex tw-gap-2"},t.createElement("span",{role:"button",tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1"},t.createElement(f5.EditButton,null,t.createElement(ce,null))),t.createElement("span",{role:"button",tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1"},t.createElement(f5.UnlinkButton,null,t.createElement(Me,null))))))},j3=(e,l)=>{const a=w.getAboveNode(e,{match:{type:w.ELEMENT_LINK}});return Array.isArray(a)?l(a[0]):""},jm0=e=>j3(e,l=>{var a,o;return((o=(a=l.chosenLink)==null?void 0:a.searchResult)==null?void 0:o.link)||""}),Dm0=e=>j3(e,l=>l.url||""),hV=e=>{var l,a;return e.url||((a=(l=e.chosenLink)==null?void 0:l.searchResult)==null?void 0:a.link)||""},Fm0=e=>j3(e,hV),Bm0=({floatingOptions:e,...l})=>{const a=w.useEditorRef(),o=w.usePlateSelectors().keyEditor(),i=w.useFloatingLinkSelectors().mode(),c=w.useFloatingLinkSelectors().isOpen(a.id),{triggerFloatingLinkHotkeys:s="command+k, ctrl+k"}=w.getPluginOptions(a,w.ELEMENT_LINK),m=t.useCallback(()=>{const h=w.getAboveNode(a,{match:{type:w.getPluginType(a,w.ELEMENT_LINK)}});if(h){const[,g]=h;return w.getRangeBoundingClientRect(a,{anchor:w.getStartPoint(a,g),focus:w.getEndPoint(a,g)})}return w.getDefaultBoundingClientRect()},[a]),L=c&&i==="edit",{update:d,style:u,floating:f}=w.useVirtualFloatingLink({editorId:a.id,open:L,getBoundingClientRect:m,...e});return t.useEffect(()=>{const h=Fm0(a);if(h&&w.floatingLinkActions.url(h),a.selection&&w.someNode(a,{match:{type:w.getPluginType(a,w.ELEMENT_LINK)}})){w.floatingLinkActions.show("edit",a.id),d();return}w.floatingLinkSelectors.mode()==="edit"&&w.floatingLinkActions.hide()},[a,o,d]),w.useHotkeys(s,h=>{h.preventDefault(),w.floatingLinkSelectors.mode()==="edit"&&w.triggerFloatingLinkEdit(a)},{enableOnContentEditable:!0},[]),w.useFloatingLinkEnter(),w.useFloatingLinkEscape(),{style:{...u,zIndex:1},...l,ref:w.useComposedRef(l.ref,f)}},Om0=({state:e,onTextChange:l,onUrlChange:a,onToggleTab:o,onCancel:i,onSave:c,isValidUrlOrEmpty:s,hasValues:m,testId:L,children:d})=>t.createElement("div",{"data-test-id":L,className:"tw-bg-white tw-rounded tw-shadow tw-p-7 tw-min-w-[400px] tw-overflow-y-auto"},t.createElement(q2,{label:{children:"Text",htmlFor:"linkText",required:!0}},t.createElement(v1,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:l})),d,t.createElement("div",{className:"tw-pt-5"},t.createElement(q2,{label:{children:"URL",htmlFor:"url",required:!0}},t.createElement(v1,{id:"url",value:e.url,placeholder:"https://example.com",focusOnMount:!0,onChange:a})),!s()&&t.createElement("div",{className:"tw-text-red-65 tw-mt-3"},"Please enter a valid URL.")),t.createElement("div",{className:"tw-pt-5"},t.createElement(f1,{value:"new-tab",label:"Open in new tab",state:e.newTab,onChange:o})),t.createElement("div",{className:"tw-mt-3"},t.createElement("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10"},t.createElement(z0,{onClick:i,size:i0.Medium,style:$.Default,emphasis:f0.Default},"Cancel"),t.createElement(z0,{onClick:c,size:i0.Medium,icon:t.createElement(X5,null),disabled:!s()||!m},"Save")))),Pm0={url:"",text:"",newTab:M0.Unchecked},Um0=()=>{const[e,l]=t.useReducer((a,o)=>{const{type:i,payload:c}=o;switch(i){case"NEW_TAB":return{...a,newTab:M0.Checked};case"SAME_TAB":return{...a,newTab:M0.Unchecked};case"URL":case"TEXT":case"INIT":return{...a,...c};default:return a}},Pm0);return[e,l]},Qm0=()=>{const e=w.useEditorRef(),[l,a]=Um0();t.useEffect(()=>{const u=jm0(e),f=Dm0(e);a({type:"INIT",payload:{text:w.floatingLinkSelectors.text(),newTab:w.floatingLinkSelectors.newTab()?M0.Checked:M0.Unchecked,url:u&&f===""?u:w.floatingLinkSelectors.url()}})},[a,e]);const o=u=>{a({type:"TEXT",payload:{text:u}})},i=u=>{a({type:"URL",payload:{url:u}})},c=u=>{a(u?{type:"NEW_TAB"}:{type:"SAME_TAB"})},s=()=>{w.floatingLinkActions.hide()},m=u=>{!d()||!L||(w.floatingLinkActions.text(l.text),w.floatingLinkActions.url(l.url),w.floatingLinkActions.newTab(l.newTab===M0.Checked),w.submitFloatingLink(e)&&(u==null||u.preventDefault()))},L=l.url!==""&&l.text!=="",d=()=>{const{isUrl:u}=w.getPluginOptions(e,w.ELEMENT_LINK);return!l.url||u&&u(l.url)};return w.useHotkeys("enter",m,{enableOnFormTags:["INPUT"]},[]),{state:l,onTextChange:o,onUrlChange:i,onToggleTab:c,onCancel:s,onSave:m,hasValues:L,isValidUrlOrEmpty:d}},Ym0=()=>t.createElement(Om0,{...Qm0(),testId:"floating-link-insert"}),Gm0=({readOnly:e})=>{const l=w.useFloatingLinkSelectors().isEditing();if(e)return null;const a=t.createElement(Ym0,null),o=l?a:t.createElement(Tm0,null);return t.createElement(t.Fragment,null,t.createElement(f5.InsertRoot,null,a),t.createElement(f5.EditRoot,null,o))},Wm0=({id:e,editorId:l})=>{const a=w.usePlateEditorState(w.useEventPlateId(l)),o=!!w.isRangeInSameBlock(a,{at:a.selection}),i=I0(o);return t.createElement(Z0,{id:e},t.createElement(w.LinkToolbarButton,{tooltip:V0(o?`Link
38
- ${i2("Ctrl+K")}`:"Links can only be set for a single text block."),icon:t.createElement(y0,{icon:t.createElement(ne,null)}),classNames:i,styles:x0,actionHandler:"onMouseDown"}))},qm0=e=>({...w.useElementProps({...e,elementToAttributes:a=>({href:hV(a),target:a.target||"_blank"})}),onMouseOver:a=>{a.stopPropagation()}}),Km0=e=>{const l=qm0(e),{attributes:a,children:o}=e,{styles:i}=C1();return t.createElement("a",{...a,href:l.href,target:l.target,style:i[F1]},o)};class $m0 extends l0{constructor(l=w.ELEMENT_LINK,a=Km0){super(l,a)}}const fV=w.createPluginFactory({...w.createLinkPlugin(),renderAfterEditable:Gm0,options:{isUrl:zm0,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k"}});class vV extends n0{constructor({styles:a=p0[F1],...o}={}){super(F1,{button:Wm0,markupElement:new $m0,...o});W(this,"styles",{});this.styles=a}plugins(){return[fV()]}}const D3="tw-border-b tw-border-dashed tw-border-line-x-strong tw-pb-5",gV=`${D3} tw-break-after-column tw-break-inside-avoid-column`,O0=e=>{const l=e.breakAfterColumn;return A([l==="active"&&gV,l==="inactive"&&D3])},F3=e=>A([O0(e),e.align?z3[e.align]:"tw-justify-start","tw-grid tw-grid-cols-[min-content_repeat(3,_auto)]"]),AV=({attributes:e,children:l,element:a})=>t.createElement("p",{className:F3(a),...e},t.createElement("span",{className:"tw-w-auto tw-min-w-[10px]"},l));class CV extends l0{constructor(l=w.ELEMENT_LIC,a=AV){super(l,a)}}const EV="text-style-plugin",v5="list-plugin",Xm0=(e,{options:{validLiChildrenTypes:l,isSoftBreak:a}})=>{const{insertBreak:o,deleteBackward:i,deleteForward:c,deleteFragment:s}=e;return a?e.insertSoftBreak=()=>{w.insertBreakList(e)||o()}:e.insertBreak=()=>{w.insertBreakList(e)||o()},e.deleteBackward=m=>{w.deleteBackwardList(e,m)||i(m)},e.deleteForward=m=>{w.deleteForwardList(e)||c(m)},e.deleteFragment=m=>{w.deleteFragmentList(e)||s(m)},e.insertFragment=w.insertFragmentList(e),e.normalizeNode=w.normalizeList(e,{validLiChildrenTypes:l}),e},c2="textStyle",MV=w.createPluginFactory({key:c2,isLeaf:!0});class B3 extends n0{constructor(a){super(v5,{leafMarkupElements:[new CV,new pV],...a});W(this,"isSoftBreak");this.isSoftBreak=(a==null?void 0:a.isSoftBreak)??!1}plugins(){return[w.createListPlugin({withOverrides:Xm0,options:{isSoftBreak:this.isSoftBreak}}),MV()]}}const Jm0=e=>w.getAboveNode(e,{match:{type:w.ELEMENT_LI},mode:"lowest"})||w.someNode(e,{match:{type:J0},mode:"lowest"}),_m0=({editor:e,type:l,children:a})=>{const o=e!=null&&e.selection?w.getMark(e,c2)===l.id:w.someNode(e,{match:{type:l}});return t.createElement("button",{"data-test-id":"textstyle-option",type:"button",className:A(["tw-block tw-w-full tw-text-left tw-px-3 tw-py-2 tw-outline-none tw-cursor-pointer tw-truncate hover:tw-bg-box-neutral-hover hover:w-text-box-neutral-inverse-hover tw-max-h-20 tw-max-w-[15rem] tw-min-h-[2.25rem]",o?"tw-text-box-neutral-inverse tw-bg-box-neutral":"tw-text-text"]),onMouseDown:i=>{i.preventDefault(),i.stopPropagation(),!(!e||!e.selection)&&(w.setMarks(e,{[c2]:l.id}),Jm0(e)||w.toggleNodeType(e,{activeType:l.id,inactiveType:l.id}))}},a)},Rm0=({label:e,open:l,onClick:a},o)=>t.createElement("button",{ref:o,"data-test-id":"textstyle-dropdown-trigger",type:"button",className:"tw-cursor-pointer tw-h-8 tw-w-full",onMouseDown:i=>{i.preventDefault(),i.stopPropagation(),a()}},t.createElement("div",{className:A(["tw-relative tw-inline-flex tw-flex-row tw-items-center tw-justify-between tw-overflow-hidden tw-text-text tw-rounded tw-gap-1 tw-px-2 hover:tw-text-box-selected-inverse hover:tw-bg-box-selected tw-h-6 tw-w-28",l&&"tw-text-box-selected-inverse tw-bg-box-selected"])},t.createElement("span",{className:"tw-text-xs tw-truncate"},e),t.createElement("div",{className:A(["tw-transition-transform",l&&"tw-rotate-180"])},t.createElement($5,null)))),eL0=t.forwardRef(Rm0),tL0=e=>Array.isArray(e.children)?(e.children.find(a=>w.isText(a))??{})[c2]:w.ELEMENT_PARAGRAPH,lL0=[w.ELEMENT_LI,w.ELEMENT_UL,w.ELEMENT_OL],nL0=e=>!e||!e.selection?[]:Array.from(w.getNodeEntries(e,{unhang:!0,at:e.selection,reverse:!0})).reduce((a,[o])=>{if(!w.isNode(o))return a;const i=o.type===w.ELEMENT_LIC||o.type===J0?tL0(o):o.textStyle;return i&&!a.includes(i)&&!lL0.includes(i)&&a.push(i),a},[]),rL0=6,aL0=10,oL0={name:"vertical-positioning",phase:"read",fn:({state:e,name:l})=>{if(e.modifiersData[l]._skip)return;const{position:a,maxHeight:o}=r3(e.elements.reference,e.rects.popper.height,rL0+aL0,0);a==="top"&&(e.placement="top-start"),e.styles.popper={maxHeight:`${o}px`},e.reset=!0,e.modifiersData[l]._skip=!0},enabled:!0},g5="Mixed";var j=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e.p="p",e))(j||{});const iL0=e=>{const[l,a]=t.useState(!1),[o,i]=t.useState(null),[c,s]=t.useState(null),m=w.usePlateEditorState(e),L=nL0(m);let d=g5;L.length===1?d=L[0]:L.length===0&&(d="p");const u=t.useCallback(()=>{a(h=>!h)},[a]),f=N1.usePopper(o,c,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,6]}},{name:"flip",enabled:!1},oL0]});return t.useEffect(()=>{const h=g=>{if(l){const v=g.target;if(c&&c.contains(v)||o&&o.contains(v))return;a(!1)}};return document.addEventListener("pointerdown",h),()=>{document.removeEventListener("pointerdown",h)}},[l,c,a,o]),{state:{isOpen:l,toggle:u,editor:m},dropdownProps:{...f.attributes.popper,style:f.styles.popper},key:d,dropdownRef:s,triggerRef:i}},cL0=({editorId:e,textStyles:l=[]})=>{var f;const{state:{editor:a,toggle:o,isOpen:i},dropdownProps:c,triggerRef:s,dropdownRef:m,key:L}=iL0(e);let d=g5;const u=l.find(h=>{var g;return h.id===L&&((g=h.props)==null?void 0:g.label)});return u&&(d=((f=u.props)==null?void 0:f.label)||g5),t.createElement(t.Fragment,null,t.createElement(eL0,{label:d,open:i,onClick:o,ref:s}),i&&t.createElement("div",{className:"tw-divide-y tw-divide-line tw-bg-base tw-shadow-md tw-border tw-border-line tw-z-[1000] tw-overflow-auto tw-min-h-[40px]",ref:m,...c},l.map(h=>{var g;return t.createElement(_m0,{editor:a,type:h,key:h.id},t.createElement("span",{style:h.styles??{}},(g=h.props)==null?void 0:g.label))})))},sL0=({editorId:e,id:l,textStyles:a})=>t.createElement(Z0,{id:l},t.createElement(cL0,{editorId:e,textStyles:a})),mL0=(e,l)=>a=>t.createElement(e,{...a,textStyles:l}),LL0="textstyle-custom1-plugin";class dL0 extends n0{constructor({styles:a=p0.custom1,...o}={}){super(j.custom1,{label:"Custom 1",markupElement:new uL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[wL0(this.styles)]}}class uL0 extends l0{constructor(l=LL0,a=IV){super(l,a)}}const IV=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},wL0=e=>w.createPluginFactory({key:j.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:j.custom1}]}})({component:l=>t.createElement(IV,{...l,styles:e})}),hL0="textstyle-custom2-plugin";class fL0 extends n0{constructor({styles:a=p0.custom2,...o}={}){super(j.custom2,{label:"Custom 2",markupElement:new vL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[gL0(this.styles)]}}class vL0 extends l0{constructor(l=hL0,a=ZV){super(l,a)}}const ZV=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},gL0=e=>w.createPluginFactory({key:j.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:j.custom2}]}})({component:l=>t.createElement(ZV,{...l,styles:e})}),AL0="textstyle-custom3-plugin";class CL0 extends n0{constructor({styles:a=p0.custom3,...o}={}){super(j.custom3,{label:"Custom 3",markupElement:new EL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[ML0(this.styles)]}}class EL0 extends l0{constructor(l=AL0,a=NV){super(l,a)}}const NV=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},ML0=e=>w.createPluginFactory({key:j.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:j.custom3}]}})({component:l=>t.createElement(NV,{...l,styles:e})}),IL0="textstyle-heading1-plugin";class ZL0 extends n0{constructor({styles:a=p0.heading1,...o}={}){super(j.heading1,{label:"Heading 1",markupElement:new NL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[SL0(this.styles)]}}class NL0 extends l0{constructor(l=IL0,a=O3){super(l,a)}}const O3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h1",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},SL0=e=>w.createPluginFactory({key:j.heading1,isElement:!0,component:O3,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:l=>t.createElement(O3,{...l,styles:e})}),yL0="textstyle-heading2-plugin";class xL0 extends n0{constructor({styles:a=p0.heading2,...o}={}){super(j.heading2,{label:"Heading 2",markupElement:new HL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[bL0(this.styles)]}}class HL0 extends l0{constructor(l=yL0,a=P3){super(l,a)}}const P3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h2",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},bL0=e=>w.createPluginFactory({key:j.heading2,isElement:!0,component:P3,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:l=>t.createElement(P3,{...l,styles:e})}),kL0="textstyle-heading3-plugin";class zL0 extends n0{constructor({styles:a=p0.heading3,...o}={}){super(j.heading3,{label:"Heading 3",markupElement:new pL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[VL0(this.styles)]}}class pL0 extends l0{constructor(l=kL0,a=U3){super(l,a)}}const U3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h3",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},VL0=e=>w.createPluginFactory({key:j.heading3,isElement:!0,component:U3,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:l=>t.createElement(U3,{...l,styles:e})}),TL0="textstyle-heading4-plugin";class jL0 extends n0{constructor({styles:a=p0.heading4,...o}={}){super(j.heading4,{label:"Heading 4",markupElement:new DL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[FL0(this.styles)]}}class DL0 extends l0{constructor(l=TL0,a=Q3){super(l,a)}}const Q3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h4",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},FL0=e=>w.createPluginFactory({key:j.heading4,isElement:!0,component:Q3,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:l=>t.createElement(Q3,{...l,styles:e})}),BL0="textstyle-imageCaption-plugin";class OL0 extends n0{constructor({styles:a=p0.imageCaption,...o}={}){super(j.imageCaption,{label:"Image Caption",markupElement:new PL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[UL0(this.styles)]}}class PL0 extends l0{constructor(l=BL0,a=Y3){super(l,a)}}const Y3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},UL0=e=>w.createPluginFactory({key:j.imageCaption,isElement:!0,component:Y3,deserializeHtml:{rules:[{validClassName:j.imageCaption}]}})({component:l=>t.createElement(Y3,{...l,styles:e})}),QL0="textstyle-imageTitle-plugin";class YL0 extends n0{constructor({styles:a=p0.imageTitle,...o}={}){super(j.imageTitle,{label:"Image Title",markupElement:new GL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[WL0(this.styles)]}}class GL0 extends l0{constructor(l=QL0,a=G3){super(l,a)}}const G3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},WL0=e=>w.createPluginFactory({key:j.imageTitle,isElement:!0,component:G3,deserializeHtml:{rules:[{validClassName:j.imageTitle}]}})({component:l=>t.createElement(G3,{...l,styles:e})});class SV extends n0{constructor({styles:a=p0.p,...o}={}){super(j.p,{markupElement:new xV,label:"Body Text",...o});W(this,"styles",{});this.styles=a}plugins(){return[HV(this.styles)]}}const yV="tw-m-0 tw-px-0 tw-py-0",A5=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align,c=A([i&&B0[i],yV,O0(e)]);return t.createElement("p",{...l,className:c,style:o},a)};class xV extends l0{constructor(l=j.p,a=A5){super(l,a)}}const HV=e=>w.createPluginFactory({...w.createParagraphPlugin(),key:j.p,isElement:!0,component:A5})({component:l=>t.createElement(A5,{...l,styles:e})}),qL0="textstyle-quote-plugin";class KL0 extends n0{constructor({styles:a=p0.quote,...o}={}){super(j.quote,{label:"Quote",markupElement:new $L0,...o});W(this,"styles",{});this.styles=a}plugins(){return[bV(this.styles)]}}class $L0 extends l0{constructor(l=qL0,a=C5){super(l,a)}}const C5=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("blockquote",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},bV=e=>w.createPluginFactory({key:j.quote,isElement:!0,component:C5,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:l=>t.createElement(C5,{...l,styles:e})});class kV extends n0{constructor({...a}){super(EV,{button:mL0(sL0,a.textStyles),...a});W(this,"textStyles");this.textStyles=a.textStyles}plugins(){return this.textStyles.map(a=>a.plugins()).flat()}}const W3="[&>p]:before:tw-flex [&>p]:before:tw-justify-end [&>p]:before:tw-w-[1.2em] !tw-no-underline",zV=({attributes:e,children:l,element:a})=>{const{styles:o}=C1();return t.createElement("li",{style:q3(a,o),...e,className:W3},l)};class pV extends l0{constructor(l=w.ELEMENT_LI,a=zV){super(l,a)}}const q3=(e,l)=>({...l[VV(e)??j.p],counterIncrement:"count"}),VV=e=>{let l;if(e.type==="a")l=e.children[0].textStyle;else if(e.children)for(const a of e.children){const o=VV(a);o&&(!l||o.startsWith(l))&&(l=o)}else l=e.textStyle;return l},XL0=["[&>li>p]:before:tw-content-[counter(count,decimal)_'._']","[&>li>p]:before:tw-content-[counter(count,_lower-alpha)_'._']","[&>li>p]:before:tw-content-[counter(count,lower-roman)_'._']"],JL0=(e,l)=>{const a=w.findNodePath(e,l);if(!a)return 0;const o=w.getNodeAncestors(e,a);return Array.from(o).filter(i=>i[0].type===w.ELEMENT_LI).length},K3=e=>`tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px] [&>li>p]:before:tw-pr-1 ${XL0[e%3]}`,$3={counterReset:"count"},TV=({attributes:e,children:l,element:a})=>{const o=w.usePlateEditorRef(),i=JL0(o,a);return t.createElement("ol",{className:K3(i),...e,style:$3},l)};class jV extends l0{constructor(l=w.ELEMENT_OL,a=TV){super(l,a)}}const DV=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.ListToolbarButton,{tooltip:V0("Ordered list"),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(oe,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"}));class FV extends B3{constructor(l){super({id:v5,button:DV,markupElement:new jV,...l})}}const X3="[&>li>p]:before:tw-content-['•'] [&>li>p]:before:tw-px-2 tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px]",BV=({attributes:e,children:l})=>t.createElement("ul",{className:X3,...e},l);class OV extends l0{constructor(l=w.ELEMENT_UL,a=BV){super(l,a)}}const PV=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.ListToolbarButton,{tooltip:V0("Bullet list"),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(re,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"}));class UV extends B3{constructor(l){super({id:v5,button:PV,markupElement:new OV,...l})}}class _L0{constructor(){W(this,"toolbarButtons",{[h0.BOTTOM]:[],[h0.FLOATING]:[],[h0.TOP]:[]})}createGroupOfButtons(l){const a=[],o=[],i=[];for(const{markupElement:c,button:s,id:m,showIn:L}of l){if(!s)continue;const d={id:(c==null?void 0:c.getId())||m,button:s};L.includes(h0.BOTTOM)&&a.push(d),L.includes(h0.TOP)&&o.push(d),L.includes(h0.FLOATING)&&i.push(d)}a.length>0&&this.toolbarButtons[h0.BOTTOM].push(a),o.length>0&&this.toolbarButtons[h0.TOP].push(o),i.length>0&&this.toolbarButtons[h0.FLOATING].push(i)}at(l){return this.toolbarButtons[l]}}class QV{constructor(l){W(this,"platePlugins",new Map);W(this,"markupElements",{});W(this,"inlineElements",[]);W(this,"toolbarButtons",new _L0);W(this,"styles",{});this.props=l}setPlugin(...l){for(const a of l){const o=Array.isArray(a)?a:[a];for(const i of o)this.addElement(i.markupElement),this.addElement(i.markupInputElement),this.addLeafElements(i.leafMarkupElements),this.addPlugin(i),this.addInline(i.inline()),i.styles&&this.addStyles(i.styles,i.id),i.textStyles&&this.addTextStylesOfSubPlugins(i.textStyles);this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(o)}return this}addTextStylesOfSubPlugins(l){for(const a of l)a.styles&&this.addStyles(a.styles,a.id)}addLeafElements(l){if(l===void 0)return;const a=Array.isArray(l)?l:[l];for(const o of a)this.addElement(o)}addElement(l){if(l===void 0)return;const a=l.getId(),o=l.getNode();o&&!this.markupElements[a]&&(this.markupElements[a]=o)}addPlugin(l){l.id&&!this.platePlugins.has(l.id)&&this.platePlugins.set(l.id,l.plugins())}addInline(l){l&&this.inlineElements.push(l)}addStyles(l,a){this.styles[a]=l}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const a of this.platePlugins.values())for(const o of a){const{key:i,component:c}=o;c&&(l[i]=c)}return l}get plugins(){const l=[];for(const a of this.platePlugins.values())l.push(...a);return l}get buttons(){return this.toolbarButtons}get inline(){return this.inlineElements}get hasToolbar(){var l;return!((l=this.props)!=null&&l.noToolbar)}get getStyles(){return this.styles}}const YV="reset-formatting-plugin",GV="reset-formatting",RL0=e=>{!e||!e.selection||(w.removeMark(e,{key:[w.MARK_BOLD,w.MARK_ITALIC,w.MARK_CODE,w.MARK_UNDERLINE,w.MARK_STRIKETHROUGH]}),w.unwrapList(e,{}),w.setElements(e,{type:w.ELEMENT_PARAGRAPH,align:void 0}))},ed0=w.withPlateProvider(({id:e,...l})=>{const a=w.usePlateEditorState(w.useEventPlateId(e));return t.createElement(w.ToolbarButton,{tooltip:V0("Clear formatting"),onMouseDown:()=>{RL0(a)},...l})}),td0=({id:e})=>t.createElement(Z0,{id:e},t.createElement(ed0,{icon:t.createElement(y0,{icon:t.createElement(ee,null)}),classNames:I0(),styles:x0})),WV=w.createPluginFactory({key:GV,isElement:!1});class qV extends n0{constructor(l){super(YV,{button:td0,...l})}plugins(){return[WV()]}}const ld0="strikethrough-plugin",J3="!tw-line-through",KV=({attributes:e,children:l})=>t.createElement("span",{...e,className:J3},l);class $V extends l0{constructor(l=w.MARK_STRIKETHROUGH,a=KV){super(l,a)}}const nd0=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.MarkToolbarButton,{tooltip:V0("Strikethrough"),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(PH,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"}));class XV extends n0{constructor(l){super(ld0,{button:nd0,markupElement:new $V,...l})}plugins(){return[w.createStrikethroughPlugin()]}}const rd0="underline-plugin",E5="tw-underline",JV=({attributes:e,children:l})=>t.createElement("span",{...e,className:E5},l);class _V extends l0{constructor(l=w.MARK_UNDERLINE,a=JV){super(l,a)}}const ad0=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.MarkToolbarButton,{tooltip:V0(`Underline
38
+ ${i2("Ctrl+K")}`:"Links can only be set for a single text block."),icon:t.createElement(y0,{icon:t.createElement(ne,null)}),classNames:i,styles:x0,actionHandler:"onMouseDown"}))},qm0=e=>({...w.useElementProps({...e,elementToAttributes:a=>({href:hV(a),target:a.target||"_blank"})}),onMouseOver:a=>{a.stopPropagation()}}),Km0=e=>{const l=qm0(e),{attributes:a,children:o}=e,{styles:i}=C1();return t.createElement("a",{...a,href:l.href,target:l.target,style:i[F1]},o)};class $m0 extends l0{constructor(l=w.ELEMENT_LINK,a=Km0){super(l,a)}}const fV=w.createPluginFactory({...w.createLinkPlugin(),renderAfterEditable:Gm0,options:{isUrl:zm0,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k"}});class vV extends n0{constructor({styles:a=p0[F1],...o}={}){super(F1,{button:Wm0,markupElement:new $m0,...o});W(this,"styles",{});this.styles=a}plugins(){return[fV()]}}const D3="tw-border-b tw-border-dashed tw-border-line-x-strong tw-pb-5",gV=`${D3} tw-break-after-column tw-break-inside-avoid-column`,O0=e=>{const l=e.breakAfterColumn;return A([l==="active"&&gV,l==="inactive"&&D3])},F3=e=>A([O0(e),e.align?z3[e.align]:"tw-justify-start","tw-grid tw-grid-cols-[min-content_repeat(3,_auto)]"]),AV=({attributes:e,children:l,element:a})=>t.createElement("p",{className:F3(a),...e},t.createElement("span",{className:"tw-w-auto tw-min-w-[10px]"},l));class CV extends l0{constructor(l=w.ELEMENT_LIC,a=AV){super(l,a)}}const EV="text-style-plugin",v5="list-plugin",Xm0=(e,{options:{validLiChildrenTypes:l,isSoftBreak:a}})=>{const{insertBreak:o,deleteBackward:i,deleteForward:c,deleteFragment:s}=e;return a?e.insertSoftBreak=()=>{w.insertBreakList(e)||o()}:e.insertBreak=()=>{w.insertBreakList(e)||o()},e.deleteBackward=m=>{w.deleteBackwardList(e,m)||i(m)},e.deleteForward=m=>{w.deleteForwardList(e)||c(m)},e.deleteFragment=m=>{w.deleteFragmentList(e)||s(m)},e.insertFragment=w.insertFragmentList(e),e.normalizeNode=w.normalizeList(e,{validLiChildrenTypes:l}),e},c2="textStyle",MV=w.createPluginFactory({key:c2,isLeaf:!0});class B3 extends n0{constructor(a){super(v5,{leafMarkupElements:[new CV,new pV],...a});W(this,"isSoftBreak");this.isSoftBreak=(a==null?void 0:a.isSoftBreak)??!1}plugins(){return[w.createListPlugin({withOverrides:Xm0,options:{isSoftBreak:this.isSoftBreak}}),MV()]}}const Jm0=e=>w.getAboveNode(e,{match:{type:w.ELEMENT_LI},mode:"lowest"})||w.someNode(e,{match:{type:J0},mode:"lowest"}),_m0=({editor:e,type:l,children:a})=>{const o=e!=null&&e.selection?w.getMark(e,c2)===l.id:w.someNode(e,{match:{type:l}});return t.createElement("button",{"data-test-id":"textstyle-option",type:"button",className:A(["tw-block tw-w-full tw-text-left tw-px-3 tw-py-2 tw-outline-none tw-cursor-pointer tw-truncate hover:tw-bg-box-neutral-hover hover:w-text-box-neutral-inverse-hover tw-max-h-20 tw-max-w-[15rem] tw-min-h-[2.25rem]",o?"tw-text-box-neutral-inverse tw-bg-box-neutral":"tw-text-text"]),onMouseDown:i=>{i.preventDefault(),i.stopPropagation(),!(!e||!e.selection)&&(w.setMarks(e,{[c2]:l.id}),Jm0(e)||w.toggleNodeType(e,{activeType:l.id,inactiveType:l.id}))}},a)},Rm0=({label:e,open:l,onClick:a},o)=>t.createElement("button",{ref:o,"data-test-id":"textstyle-dropdown-trigger",type:"button",className:"tw-cursor-pointer tw-h-8 tw-w-full",onMouseDown:i=>{i.preventDefault(),i.stopPropagation(),a()}},t.createElement("div",{className:A(["tw-relative tw-inline-flex tw-flex-row tw-items-center tw-justify-between tw-overflow-hidden tw-text-text tw-rounded tw-gap-1 tw-px-2 hover:tw-text-box-selected-inverse hover:tw-bg-box-selected tw-h-6 tw-w-28",l&&"tw-text-box-selected-inverse tw-bg-box-selected"])},t.createElement("span",{className:"tw-text-xs tw-truncate"},e),t.createElement("div",{className:A(["tw-transition-transform",l&&"tw-rotate-180"])},t.createElement($5,null)))),eL0=t.forwardRef(Rm0),tL0=e=>Array.isArray(e.children)?(e.children.find(a=>w.isText(a))??{})[c2]:w.ELEMENT_PARAGRAPH,lL0=[w.ELEMENT_LI,w.ELEMENT_UL,w.ELEMENT_OL],nL0=e=>!e||!e.selection?[]:Array.from(w.getNodeEntries(e,{unhang:!0,at:e.selection,reverse:!0})).reduce((a,[o])=>{if(!w.isNode(o))return a;const i=o.type===w.ELEMENT_LIC||o.type===J0?tL0(o):o.textStyle;return i&&!a.includes(i)&&!lL0.includes(i)&&a.push(i),a},[]),rL0=6,aL0=10,oL0={name:"vertical-positioning",phase:"read",fn:({state:e,name:l})=>{if(e.modifiersData[l]._skip)return;const{position:a,maxHeight:o}=r3(e.elements.reference,e.rects.popper.height,rL0+aL0,0);a==="top"&&(e.placement="top-start"),e.styles.popper={maxHeight:`${o}px`},e.reset=!0,e.modifiersData[l]._skip=!0},enabled:!0},g5="Mixed";var j=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e.p="p",e))(j||{});const iL0=e=>{const[l,a]=t.useState(!1),[o,i]=t.useState(null),[c,s]=t.useState(null),m=w.usePlateEditorState(e),L=nL0(m);let d=g5;L.length===1?d=L[0]:L.length===0&&(d="p");const u=t.useCallback(()=>{a(h=>!h)},[a]),f=N1.usePopper(o,c,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,6]}},{name:"flip",enabled:!1},oL0]});return t.useEffect(()=>{const h=g=>{if(l){const v=g.target;if(c&&c.contains(v)||o&&o.contains(v))return;a(!1)}};return document.addEventListener("pointerdown",h),()=>{document.removeEventListener("pointerdown",h)}},[l,c,a,o]),{state:{isOpen:l,toggle:u,editor:m},dropdownProps:{...f.attributes.popper,style:f.styles.popper},key:d,dropdownRef:s,triggerRef:i}},cL0=({editorId:e,textStyles:l=[]})=>{var f;const{state:{editor:a,toggle:o,isOpen:i},dropdownProps:c,triggerRef:s,dropdownRef:m,key:L}=iL0(e);let d=g5;const u=l.find(h=>{var g;return h.id===L&&((g=h.props)==null?void 0:g.label)});return u&&(d=((f=u.props)==null?void 0:f.label)||g5),t.createElement(t.Fragment,null,t.createElement(eL0,{label:d,open:i,onClick:o,ref:s}),i&&t.createElement("div",{className:"tw-divide-y tw-divide-line tw-bg-base tw-shadow-md tw-border tw-border-line tw-z-[1000] tw-overflow-auto tw-min-h-[40px]",ref:m,...c},l.map(h=>{var g;return t.createElement(_m0,{editor:a,type:h,key:h.id},t.createElement("span",{style:h.styles??{}},(g=h.props)==null?void 0:g.label))})))},sL0=({editorId:e,id:l,textStyles:a})=>t.createElement(Z0,{id:l},t.createElement(cL0,{editorId:e,textStyles:a})),mL0=(e,l)=>a=>t.createElement(e,{...a,textStyles:l}),LL0="textstyle-custom1-plugin";class dL0 extends n0{constructor({styles:a=p0.custom1,...o}={}){super(j.custom1,{label:"Custom 1",markupElement:new uL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[wL0(this.styles)]}}class uL0 extends l0{constructor(l=LL0,a=IV){super(l,a)}}const IV=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},wL0=e=>w.createPluginFactory({key:j.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:j.custom1}]}})({component:l=>t.createElement(IV,{...l,styles:e})}),hL0="textstyle-custom2-plugin";class fL0 extends n0{constructor({styles:a=p0.custom2,...o}={}){super(j.custom2,{label:"Custom 2",markupElement:new vL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[gL0(this.styles)]}}class vL0 extends l0{constructor(l=hL0,a=ZV){super(l,a)}}const ZV=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},gL0=e=>w.createPluginFactory({key:j.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:j.custom2}]}})({component:l=>t.createElement(ZV,{...l,styles:e})}),AL0="textstyle-custom3-plugin";class CL0 extends n0{constructor({styles:a=p0.custom3,...o}={}){super(j.custom3,{label:"Custom 3",markupElement:new EL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[ML0(this.styles)]}}class EL0 extends l0{constructor(l=AL0,a=NV){super(l,a)}}const NV=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},ML0=e=>w.createPluginFactory({key:j.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:j.custom3}]}})({component:l=>t.createElement(NV,{...l,styles:e})}),IL0="textstyle-heading1-plugin";class ZL0 extends n0{constructor({styles:a=p0.heading1,...o}={}){super(j.heading1,{label:"Heading 1",markupElement:new NL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[SL0(this.styles)]}}class NL0 extends l0{constructor(l=IL0,a=O3){super(l,a)}}const O3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h1",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},SL0=e=>w.createPluginFactory({key:j.heading1,isElement:!0,component:O3,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:l=>t.createElement(O3,{...l,styles:e})}),yL0="textstyle-heading2-plugin";class xL0 extends n0{constructor({styles:a=p0.heading2,...o}={}){super(j.heading2,{label:"Heading 2",markupElement:new HL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[bL0(this.styles)]}}class HL0 extends l0{constructor(l=yL0,a=P3){super(l,a)}}const P3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h2",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},bL0=e=>w.createPluginFactory({key:j.heading2,isElement:!0,component:P3,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:l=>t.createElement(P3,{...l,styles:e})}),kL0="textstyle-heading3-plugin";class zL0 extends n0{constructor({styles:a=p0.heading3,...o}={}){super(j.heading3,{label:"Heading 3",markupElement:new pL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[VL0(this.styles)]}}class pL0 extends l0{constructor(l=kL0,a=U3){super(l,a)}}const U3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h3",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},VL0=e=>w.createPluginFactory({key:j.heading3,isElement:!0,component:U3,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:l=>t.createElement(U3,{...l,styles:e})}),TL0="textstyle-heading4-plugin";class jL0 extends n0{constructor({styles:a=p0.heading4,...o}={}){super(j.heading4,{label:"Heading 4",markupElement:new DL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[FL0(this.styles)]}}class DL0 extends l0{constructor(l=TL0,a=Q3){super(l,a)}}const Q3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("h4",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},FL0=e=>w.createPluginFactory({key:j.heading4,isElement:!0,component:Q3,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:l=>t.createElement(Q3,{...l,styles:e})}),BL0="textstyle-imageCaption-plugin";class OL0 extends n0{constructor({styles:a=p0.imageCaption,...o}={}){super(j.imageCaption,{label:"Image Caption",markupElement:new PL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[UL0(this.styles)]}}class PL0 extends l0{constructor(l=BL0,a=Y3){super(l,a)}}const Y3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},UL0=e=>w.createPluginFactory({key:j.imageCaption,isElement:!0,component:Y3,deserializeHtml:{rules:[{validClassName:j.imageCaption}]}})({component:l=>t.createElement(Y3,{...l,styles:e})}),QL0="textstyle-imageTitle-plugin";class YL0 extends n0{constructor({styles:a=p0.imageTitle,...o}={}){super(j.imageTitle,{label:"Image Title",markupElement:new GL0,...o});W(this,"styles",{});this.styles=a}plugins(){return[WL0(this.styles)]}}class GL0 extends l0{constructor(l=QL0,a=G3){super(l,a)}}const G3=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("p",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},WL0=e=>w.createPluginFactory({key:j.imageTitle,isElement:!0,component:G3,deserializeHtml:{rules:[{validClassName:j.imageTitle}]}})({component:l=>t.createElement(G3,{...l,styles:e})});class SV extends n0{constructor({styles:a=p0.p,...o}={}){super(j.p,{markupElement:new xV,label:"Body Text",...o});W(this,"styles",{});this.styles=a}plugins(){return[HV(this.styles)]}}const yV="tw-m-0 tw-px-0 tw-py-0",A5=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align,c=A([i&&B0[i],yV,O0(e)]);return t.createElement("p",{...l,className:c,style:o},a)};class xV extends l0{constructor(l=j.p,a=A5){super(l,a)}}const HV=e=>w.createPluginFactory({...w.createParagraphPlugin(),key:j.p,isElement:!0,component:A5})({component:l=>t.createElement(A5,{...l,styles:e})}),qL0="textstyle-quote-plugin";class KL0 extends n0{constructor({styles:a=p0.quote,...o}={}){super(j.quote,{label:"Quote",markupElement:new $L0,...o});W(this,"styles",{});this.styles=a}plugins(){return[bV(this.styles)]}}class $L0 extends l0{constructor(l=qL0,a=C5){super(l,a)}}const C5=({element:e,attributes:l,children:a,styles:o})=>{const i=e.align;return t.createElement("blockquote",{...l,className:A([i&&B0[i],O0(e)]),style:o},a)},bV=e=>w.createPluginFactory({key:j.quote,isElement:!0,component:C5,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:l=>t.createElement(C5,{...l,styles:e})});class kV extends n0{constructor({...a}){super(EV,{button:mL0(sL0,a.textStyles),...a});W(this,"textStyles");this.textStyles=a.textStyles}plugins(){return this.textStyles.map(a=>a.plugins()).flat()}}const W3="[&>p]:before:tw-flex [&>p]:before:tw-justify-end [&>p]:before:tw-w-[1.2em] !tw-no-underline",zV=({attributes:e,children:l,element:a})=>{const{styles:o}=C1();return t.createElement("li",{style:q3(a,o),...e,className:W3},l)};class pV extends l0{constructor(l=w.ELEMENT_LI,a=zV){super(l,a)}}const q3=(e,l)=>({...l[VV(e)??j.p],counterIncrement:"count"}),VV=e=>{let l;if(e.type==="a")l=e.children[0].textStyle;else if(e.children)for(const a of e.children){const o=VV(a);o&&(!l||o.startsWith(l))&&(l=o)}else l=e.textStyle;return l},XL0=["[&>li>p]:before:tw-content-[counter(count,decimal)_'._']","[&>li>p]:before:tw-content-[counter(count,_lower-alpha)_'._']","[&>li>p]:before:tw-content-[counter(count,lower-roman)_'._']"],JL0=(e,l)=>{const a=w.findNodePath(e,l);if(!a)return 0;const o=w.getNodeAncestors(e,a);return Array.from(o).filter(i=>i[0].type===w.ELEMENT_LI).length},K3=e=>`tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px] [&>li>p]:before:tw-pr-1 [&>li>p]:before:tw-tabular-nums ${XL0[e%3]}`,$3={counterReset:"count"},TV=({attributes:e,children:l,element:a})=>{const o=w.usePlateEditorRef(),i=JL0(o,a);return t.createElement("ol",{className:K3(i),...e,style:$3},l)};class jV extends l0{constructor(l=w.ELEMENT_OL,a=TV){super(l,a)}}const DV=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.ListToolbarButton,{tooltip:V0("Ordered list"),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(oe,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"}));class FV extends B3{constructor(l){super({id:v5,button:DV,markupElement:new jV,...l})}}const X3="[&>li>p]:before:tw-content-['•'] [&>li>p]:before:tw-px-2 tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px]",BV=({attributes:e,children:l})=>t.createElement("ul",{className:X3,...e},l);class OV extends l0{constructor(l=w.ELEMENT_UL,a=BV){super(l,a)}}const PV=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.ListToolbarButton,{tooltip:V0("Bullet list"),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(re,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"}));class UV extends B3{constructor(l){super({id:v5,button:PV,markupElement:new OV,...l})}}class _L0{constructor(){W(this,"toolbarButtons",{[h0.BOTTOM]:[],[h0.FLOATING]:[],[h0.TOP]:[]})}createGroupOfButtons(l){const a=[],o=[],i=[];for(const{markupElement:c,button:s,id:m,showIn:L}of l){if(!s)continue;const d={id:(c==null?void 0:c.getId())||m,button:s};L.includes(h0.BOTTOM)&&a.push(d),L.includes(h0.TOP)&&o.push(d),L.includes(h0.FLOATING)&&i.push(d)}a.length>0&&this.toolbarButtons[h0.BOTTOM].push(a),o.length>0&&this.toolbarButtons[h0.TOP].push(o),i.length>0&&this.toolbarButtons[h0.FLOATING].push(i)}at(l){return this.toolbarButtons[l]}}class QV{constructor(l){W(this,"platePlugins",new Map);W(this,"markupElements",{});W(this,"inlineElements",[]);W(this,"toolbarButtons",new _L0);W(this,"styles",{});this.props=l}setPlugin(...l){for(const a of l){const o=Array.isArray(a)?a:[a];for(const i of o)this.addElement(i.markupElement),this.addElement(i.markupInputElement),this.addLeafElements(i.leafMarkupElements),this.addPlugin(i),this.addInline(i.inline()),i.styles&&this.addStyles(i.styles,i.id),i.textStyles&&this.addTextStylesOfSubPlugins(i.textStyles);this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(o)}return this}addTextStylesOfSubPlugins(l){for(const a of l)a.styles&&this.addStyles(a.styles,a.id)}addLeafElements(l){if(l===void 0)return;const a=Array.isArray(l)?l:[l];for(const o of a)this.addElement(o)}addElement(l){if(l===void 0)return;const a=l.getId(),o=l.getNode();o&&!this.markupElements[a]&&(this.markupElements[a]=o)}addPlugin(l){l.id&&!this.platePlugins.has(l.id)&&this.platePlugins.set(l.id,l.plugins())}addInline(l){l&&this.inlineElements.push(l)}addStyles(l,a){this.styles[a]=l}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const a of this.platePlugins.values())for(const o of a){const{key:i,component:c}=o;c&&(l[i]=c)}return l}get plugins(){const l=[];for(const a of this.platePlugins.values())l.push(...a);return l}get buttons(){return this.toolbarButtons}get inline(){return this.inlineElements}get hasToolbar(){var l;return!((l=this.props)!=null&&l.noToolbar)}get getStyles(){return this.styles}}const YV="reset-formatting-plugin",GV="reset-formatting",RL0=e=>{!e||!e.selection||(w.removeMark(e,{key:[w.MARK_BOLD,w.MARK_ITALIC,w.MARK_CODE,w.MARK_UNDERLINE,w.MARK_STRIKETHROUGH]}),w.unwrapList(e,{}),w.setElements(e,{type:w.ELEMENT_PARAGRAPH,align:void 0}))},ed0=w.withPlateProvider(({id:e,...l})=>{const a=w.usePlateEditorState(w.useEventPlateId(e));return t.createElement(w.ToolbarButton,{tooltip:V0("Clear formatting"),onMouseDown:()=>{RL0(a)},...l})}),td0=({id:e})=>t.createElement(Z0,{id:e},t.createElement(ed0,{icon:t.createElement(y0,{icon:t.createElement(ee,null)}),classNames:I0(),styles:x0})),WV=w.createPluginFactory({key:GV,isElement:!1});class qV extends n0{constructor(l){super(YV,{button:td0,...l})}plugins(){return[WV()]}}const ld0="strikethrough-plugin",J3="!tw-line-through",KV=({attributes:e,children:l})=>t.createElement("span",{...e,className:J3},l);class $V extends l0{constructor(l=w.MARK_STRIKETHROUGH,a=KV){super(l,a)}}const nd0=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.MarkToolbarButton,{tooltip:V0("Strikethrough"),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(PH,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"}));class XV extends n0{constructor(l){super(ld0,{button:nd0,markupElement:new $V,...l})}plugins(){return[w.createStrikethroughPlugin()]}}const rd0="underline-plugin",E5="tw-underline",JV=({attributes:e,children:l})=>t.createElement("span",{...e,className:E5},l);class _V extends l0{constructor(l=w.MARK_UNDERLINE,a=JV){super(l,a)}}const ad0=({editor:e,id:l})=>t.createElement(Z0,{id:l},t.createElement(w.MarkToolbarButton,{tooltip:V0(`Underline
39
39
  ${i2("Ctrl+U")}`),type:w.getPluginType(e,l),icon:t.createElement(y0,{icon:t.createElement(Ee,null)}),classNames:I0(),styles:x0,actionHandler:"onMouseDown"})),od0=[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}];class RV extends n0{constructor(l){super(rd0,{button:ad0,markupElement:new _V,...l})}plugins(){return[w.createUnderlinePlugin({deserializeHtml:{rules:[...od0,{validNodeName:["SPAN"],validClassName:E5}]},options:{hotkey:["mod+u","ctrl+u"]}})]}}const eT=e=>Array.from(w.getNodeEntries(e,{at:[],match:l=>!!l.breakAfterColumn})).length,s2=(e,{key:l=B1,value:a,at:o})=>{const i=c=>w.isBlock(e,c);a?w.setElements(e,{[l]:a},{mode:"lowest",match:i,at:o}):w.unsetNodes(e,l,{match:i,mode:"lowest",at:o})},id0=(e,l,a)=>{s2(e,{at:l,value:a})},_3=(e,l)=>{const a=Array.from(w.getNodeEntries(e,{at:[],match:o=>!!o.breakAfterColumn}));for(const[o,[,i]]of a.entries())id0(e,i,o<l-1?"active":"inactive")},tT=(e,l,a)=>{if(a.preventDefault(),a.stopPropagation(),!!(e!=null&&e.selection)&&w.someNode(e,{match:i=>!!i.breakAfterColumn}))s2(e,{value:void 0});else{const i=eT(e),c=Math.max(l-i-1,0);if(c===0)return;const s=Array.from(w.getNodeEntries(e,{at:e.selection,match:m=>w.isBlock(e,m),mode:"lowest"})).slice(-c);for(const m of s)s2(e,{value:"active",at:m[1]})}_3(e,l)},cd0=(e,{options:{hotkey:l}})=>a=>{var o;if(!a.defaultPrevented&&l&&AD(l,a)){const i=e.plugins.find(s=>s.key===B1),c=((o=i==null?void 0:i.options)==null?void 0:o.columns)??1;tT(e,c,a)}},sd0=({id:e,...l})=>{var L,d;const a=w.usePlateEditorState(w.useEventPlateId(e)),o=!!(a!=null&&a.selection)&&w.someNode(a,{match:u=>!!u.breakAfterColumn}),i=(d=(L=a==null?void 0:a.pluginsByKey.breakAfterColumn)==null?void 0:L.options)==null?void 0:d.columns,c=Number(i)||1,s=md0(a,c,o),m=I0(s);return t.createElement(w.ToolbarButton,{active:o,tooltip:V0(s?`Column Break
40
40
  Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:u=>tT(a,c,u),...l,classNames:m})},md0=(e,l,a)=>eT(e)+1<l||a,lT=({id:e})=>t.createElement(Z0,{id:e},t.createElement(sd0,{icon:t.createElement(y0,{icon:t.createElement(ge,null)}),classNames:I0(),styles:x0})),Ld0=(e,l)=>{const a=w.getStartPoint(e,l);setTimeout(()=>{w.select(e,{anchor:a,focus:a})})},dd0=e=>{var a;const l=e.plugins.find(o=>o.key===B1);return((a=l==null?void 0:l.options)==null?void 0:a.columns)??1},ud0=e=>{const{apply:l}=e,a=dd0(e);e.apply=o=>{switch(o.type){case"split_node":o.properties={...o.properties,breakAfterColumn:void 0};break;case"merge_node":const i=w.getPointBefore(e,o.path);if(!i)break;const c=w.getParentNode(e,i.path);if(s2(e,{at:i,value:void 0}),_3(e,a),c!=null&&c[0].breakAfterColumn)return Ld0(e,o.path),e;break}l(o)},setTimeout(()=>_3(e,a))},B1="breakAfterColumn",R3="normal";class wd0 extends n0{constructor(a){super("break-after-plugin",{button:lT,...a});W(this,"columns");W(this,"gap");this.columns=(a==null?void 0:a.columns)??1,this.gap=(a==null?void 0:a.gap)??R3}plugins(){return[nT(this.columns,this.gap)]}}const nT=(e,l)=>w.createPluginFactory({key:B1,handlers:{onKeyDown:cd0},useHooks:ud0,options:{columns:e,gap:l,hotkey:["shift+ctrl+enter"]}})(),hd0=12,fd0=26,vd0=124,gd0=e=>e.map((l,a)=>({group:l,buttonGroupWidth:l.reduce((o,i)=>i.id===EV?vd0:fd0+o,hd0),index:a})),Ad0=(e,l)=>l.reduce((a,{group:o,buttonGroupWidth:i,index:c})=>{const s=Math.max(0,a.length-1);return a[s]=a[s]??[],(a[s]??[{actions:[],buttonGroupWidth:0}]).reduce((L,{buttonGroupWidth:d})=>L+d,0)+i<=e?a[s].push({group:o,buttonGroupWidth:i,index:c}):a.push([{group:o,buttonGroupWidth:i,index:c}]),a.filter(L=>L.length)},[]),Cd0=({index:e,children:l})=>t.createElement("div",{"data-test-id":`toolbar-group-${e}`,className:"tw-flex tw-items-center tw-h-9 tw-p-2"},l),Ed0=({toolbarButtons:e,editorId:l,toolbarWidth:a})=>{const o=w.usePlateEditorRef(l),{editorWidth:i}=Kp(),{position:c}=C1(),s=a||i||0,m=gd0(e.at(c)),L=Ad0(s,m),d=dT[c];return t.createElement(d.ToolbarWrapper,{editorWidth:i,toolbarWidth:a,toolbarButtonGroups:L},L.map((u,f)=>t.createElement("div",{className:"tw-divide-x tw-divide-line tw-flex tw-w-full tw-flex-wrap",key:f},u.map(({group:h,index:g})=>t.createElement(Cd0,{index:g,key:g},h.map((v,E)=>t.createElement(v.button,{editor:o,editorId:l,id:v.id,key:E.toString()})))))))},rT=e=>w.createPlugins(e.plugins,{components:w.createPlateUI(e.elements)}),e7=(e,l)=>({create:()=>rT(l),toolbar:a=>l.hasToolbar?t.createElement(Ed0,{toolbarButtons:l.buttons,editorId:e,toolbarWidth:a}):null,inline:()=>t.createElement(t.Fragment,null,l.inline.map((a,o)=>t.createElement(a,{key:o}))),styles:()=>l.getStyles}),Md0="mention-plugin",Id0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),t7=(e,l)=>`${e}:${l}`,l7=e=>{const l=new Map;for(const a of e){const o=t7(a.data.category,a.data.id),i=a.text;l.set(o,i)}return l},aT=(e,l,a)=>e.get(l)??a;var _0=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(_0||{});const n7=({attributes:e,element:l,nodeProps:a,children:o})=>t.createElement("span",{...e,"data-slate-value":l==null?void 0:l.value,"data-slate-key":l==null?void 0:l.key,"data-slate-category":l==null?void 0:l.category,contentEditable:!1,style:{lineHeight:"10px",padding:"1px",margin:"0 1px",fontWeight:"bold",verticalAlign:"baseline",display:"inline-block",borderRadius:"2px",backgroundColor:"rgb(227, 232, 246)",color:"rgb(130, 95, 255)"},...a},o),Zd0=({children:e,...l})=>t.createElement(n7,{...l},t.createElement("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"}},t.createElement(N2,null)),e),Nd0=({children:e,...l})=>t.createElement(n7,{...l},"@",e),Sd0=({children:e,...l})=>t.createElement(n7,{...l},e),yd0=({category:e,children:l,...a})=>{const o={[_0.USER]:Sd0,[_0.GROUP]:Zd0,[_0.ALL]:Nd0},i=o[e]??o[_0.USER];return t.createElement(i,{...a},l)},r7=e=>l=>{const{element:a,children:o}=l,i=t7(a==null?void 0:a.category,String(a==null?void 0:a.id));return t.createElement(yd0,{category:a==null?void 0:a.category,...l},aT(e,i,String(a==null?void 0:a.id)),o)};class oT extends l0{constructor(l=w.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=r7(l7(l)),this}}const xd0=({image:e,category:l,text:a,id:o})=>{if(e)return t.createElement("img",{src:e,alt:`${o}-${l}-${a}`});switch(l){case _0.GROUP:return t.createElement(N2,null);case _0.ALL:return t.createElement(de,null);default:return t.createElement(se,null)}},Hd0=({item:e})=>{const{data:{image:l,category:a},key:o,text:i}=e;return t.createElement("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]"},t.createElement("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-mr-2.5 tw-bg-base-alt tw-border tw-border-line-weak tw-w-[22px] tw-h-[22px] tw-shrink-0 tw-overflow-hidden group-hover:tw-border-base group-aria-selected:tw-border-base"},t.createElement(xd0,{image:l,category:a,text:i,id:o})),t.createElement("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis"},i))},iT=[`
41
41
  color: var(--text-color-weak);
@@ -68,7 +68,7 @@ Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:u=>tT(a,
68
68
  font-weight: bold;
69
69
  line-height: 10px;
70
70
  border-radius: 2px;
71
- `]},Td0=e=>t.createElement(w.MentionInputElement,{...e,styles:Vd0});class jd0 extends l0{constructor(l=w.ELEMENT_MENTION_INPUT,a=Td0){super(l,a)}}class Dd0 extends n0{constructor(l){super(Md0,{markupElement:new oT().setNodeWithMentionable(l.mentionableItems),markupInputElement:new jd0,...l})}inline(){var l;return zd0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[w.createComboboxPlugin(),w.createMentionPlugin(pd0)]}}const Fd0="blur-on-break-plugin",Bd0=["input","select","textarea","button","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]","[tabindex]"].join(':not([hidden]):not([tabindex="-1"]):not([disabled]),'),cT=(e,l)=>{if(!document.activeElement)return;e.preventDefault();const a=Array.from(document.querySelectorAll(Bd0)).filter(s=>Od0(s)),o=a.indexOf(document.activeElement),i=(l?o+1:o-1+a.length)%a.length,c=a[i];c&&c.focus()},Od0=e=>{let l=e;for(;l;){const a=window.getComputedStyle(l);if(a.display==="none"||a.visibility==="hidden")return!1;l=l.parentElement}return!0},sT=()=>{var e;(e=document.activeElement)==null||e.blur()},Pd0=(e,{options:{onBreak:l=()=>{}}})=>a=>{w.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),sT(),typeof l=="function"&&l(e.children))},Ud0="blurOnBreak",Qd0=w.createPluginFactory({key:Ud0,handlers:{onKeyDown:Pd0}});class Yd0 extends n0{constructor(a){super(Fd0,{...a});W(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[Qd0({options:{onBreak:this.onBreak}})]}}const O1=new QV;O1.setPlugin(new LV).setPlugin(new kV({textStyles:[new SV]})).setPlugin([new aV,new wV,new RV,new XV,new vV,new cV],[new Rp,new _p,new tV,new eV,new UV,new Jp,new FV,new qV,new mV]);class m2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=x1(),a=O1){const o=e7(l,a);return this.editor=w.createPlateEditor({id:l,plugins:o.create()}),this}}W(m2,"editor"),W(m2,"editorId",x1());const Gd0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],mT=[{type:w.ELEMENT_PARAGRAPH,children:[{text:""}]}],L2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const o=m2.init(`${e}_parseRawValue`,a).getInstance();let i=mT;if(!l)return i;try{i=JSON.parse(l)}catch{const c=l.trim().replaceAll(/>\s+</g,"><"),s=w.deserializeHtml(o,{element:c});i=Gd0(s)}return o.children=i,w.normalizeEditor(o,{force:!0}),o.children},M5=e=>e&&typeof e=="object"&&!Array.isArray(e),LT=(e,l)=>{if(!M5(e)||!M5(l))return{};const a=Object.assign({},e);for(const o of Object.keys(l)){if(o in e&&M5(l[o])){a[o]=LT(e[o],l[o]);continue}Object.assign(a,{[o]:l[o]})}return a},Wd0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,qd0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,Kd0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,$d0=e=>qd0(e)&&Kd0(e.children[0]),Xd0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(Wd0(l)&&$d0(l))return!0}return!1},Jd0=({children:e,editorWidth:l,toolbarButtonGroups:a=[],toolbarWidth:o})=>{const[i,c]=t.useState(),s=t.useRef();t.useEffect(()=>{if(o)c(o);else{const L=Up(a);L>0&&c(L+a.length+Pp)}},[l,o,a]),t.useEffect(()=>{const L=()=>{const d=window.getSelection(),u=(d==null?void 0:d.rangeCount)??0,f=u>0&&(d==null?void 0:d.getRangeAt(0).startOffset),h=u>0&&(d==null?void 0:d.getRangeAt(0).endOffset);!(!!d&&f!==h&&u>0)&&s.current&&s.current()};return document.addEventListener("selectionchange",L),()=>document.removeEventListener("selectionchange",L)},[]);const m=(L,d,u)=>{s.current=w.autoUpdate(L,d,u)};return t.createElement(w.BalloonToolbar,{floatingOptions:{middleware:[w.flip(),w.shift()],whileElementsMounted:m},styles:{root:{border:"none",background:"#ffffff",width:i}}},t.createElement("div",{"data-selector":"toolbar-floating","data-test-id":"toolbar-floating",className:"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap"},e))},dT={[h0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:Ks0},[h0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:Jd0},[h0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:$s0}},_d0=(e,l)=>{const a=dT[e].PlateWrapperClassNames;return A([a,l&&"tw-border tw-border-line-strong tw-rounded"])},Rd0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},eu0=({value:e})=>{const l=w.usePlateEditorRef();return t.useEffect(()=>{e&&(Rd0(l),w.insertNodes(l,e))},[l,e]),null},tu0=({hideExternalFloatingModals:e})=>{const l=w.useEditorRef(),a=w.useFloatingLinkSelectors().isOpen(l.id),o=t.useCallback(()=>{a&&w.floatingLinkActions.reset(),e&&e(l.id)},[a,e,l]),i=t.useCallback(()=>{l.collapse(),o()},[l,o]);return t.useEffect(()=>{const c=s=>{const m=`[data-editor-id='${l.id}']`,L="[data-selector='toolbar-floating']",d="[data-is-underlay]",u=document.querySelector(m),f=document.querySelector(L),h=document.querySelector(d),g=s.target,v=h==null?void 0:h.contains(g),E=u==null?void 0:u.contains(g),C=f==null?void 0:f.contains(g);C&&o(),!E&&!C&&!v&&i()};return document.addEventListener("pointerdown",c),document.addEventListener("focusin",c),()=>{document.removeEventListener("focusin",c),document.removeEventListener("pointerdown",c)}},[i,o,l.id]),null},lu0={position:"relative",height:"0"},uT=({id:e,value:l,placeholder:a="",readonly:o=!1,onTextChange:i,onBlur:c,padding:s=k3.None,position:m=h0.FLOATING,plugins:L=O1,updateValueOnChange:d=!1,onValueChanged:u,border:f=!0,toolbarWidth:h,hideExternalFloatingModals:g})=>{var H,I;const v=E0(e),{localValue:E,onChange:C,memoizedValue:M,config:Z}=Rs0({editorId:v,initialValue:l,onTextChange:i,plugins:L,onValueChanged:u}),N=L.plugins.find(b=>b.key===B1),x=((H=N==null?void 0:N.options)==null?void 0:H.columns)??1,k=((I=N==null?void 0:N.options)==null?void 0:I.gap)??R3,S={placeholder:a,renderPlaceholder:({children:b,attributes:y})=>{const V={...y,style:{...y.style,...lu0}};return t.createElement("span",{...V},b)},readOnly:o,onBlur:()=>c&&c(JSON.stringify(E.current)),className:`${s}`,style:{columns:x,columnGap:k,outline:"none"},onKeyDown:b=>{b.code==="Tab"&&cT(b,!b.shiftKey)},scrollSelectionIntoView:()=>{}};return t.createElement(Gp,{value:{styles:Z.styles(),position:m,border:f,editorId:v}},t.createElement(w.Plate,{id:v,onChange:C,editableProps:S,plugins:Z.create(),initialValue:M},!S.readOnly&&Z.toolbar(h),Z.inline(),d&&t.createElement(eu0,{value:L2({editorId:v,raw:l,plugins:L})}),m===h0.FLOATING&&t.createElement(tu0,{hideExternalFloatingModals:g})))};uT.displayName="FondueRichTextEditor";const wT=e=>e.split("").reverse().join(""),P1=(e,l)=>{const a=e.trim(),o=a,i=`${l}${o}${wT(l)}`;if(o.length===e.length)return i;const c=l+o+wT(l);return e.replace(a,c)},nu0=(e,l)=>{const a=`
71
+ `]},Td0=e=>t.createElement(w.MentionInputElement,{...e,styles:Vd0});class jd0 extends l0{constructor(l=w.ELEMENT_MENTION_INPUT,a=Td0){super(l,a)}}class Dd0 extends n0{constructor(l){super(Md0,{markupElement:new oT().setNodeWithMentionable(l.mentionableItems),markupInputElement:new jd0,...l})}inline(){var l;return zd0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[w.createComboboxPlugin(),w.createMentionPlugin(pd0)]}}const Fd0="blur-on-break-plugin",Bd0=["input","select","textarea","button","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]","[tabindex]"].join(':not([hidden]):not([tabindex="-1"]):not([disabled]),'),cT=(e,l)=>{if(!document.activeElement)return;e.preventDefault();const a=Array.from(document.querySelectorAll(Bd0)).filter(s=>Od0(s)),o=a.indexOf(document.activeElement),i=(l?o+1:o-1+a.length)%a.length,c=a[i];c&&c.focus()},Od0=e=>{let l=e;for(;l;){const a=window.getComputedStyle(l);if(a.display==="none"||a.visibility==="hidden")return!1;l=l.parentElement}return!0},sT=()=>{var e;(e=document.activeElement)==null||e.blur()},Pd0=(e,{options:{onBreak:l=()=>{}}})=>a=>{w.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),sT(),typeof l=="function"&&l(e.children))},Ud0="blurOnBreak",Qd0=w.createPluginFactory({key:Ud0,handlers:{onKeyDown:Pd0}});class Yd0 extends n0{constructor(a){super(Fd0,{...a});W(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[Qd0({options:{onBreak:this.onBreak}})]}}const O1=new QV;O1.setPlugin(new LV).setPlugin(new kV({textStyles:[new SV]})).setPlugin([new aV,new wV,new RV,new XV,new vV,new cV],[new Rp,new _p,new tV,new eV,new UV,new Jp,new FV,new qV,new mV]);class m2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=x1(),a=O1){const o=e7(l,a);return this.editor=w.createPlateEditor({id:l,plugins:o.create()}),this}}W(m2,"editor"),W(m2,"editorId",x1());const Gd0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],mT=[{type:w.ELEMENT_PARAGRAPH,children:[{text:""}]}],L2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const o=m2.init(`${e}_parseRawValue`,a).getInstance();let i=mT;if(!l)return i;try{i=JSON.parse(l)}catch{const c=l.trim().replaceAll(/>\s+</g,"><"),s=w.deserializeHtml(o,{element:c});i=Gd0(s)}return o.children=i,w.normalizeEditor(o,{force:!0}),o.children},M5=e=>e&&typeof e=="object"&&!Array.isArray(e),LT=(e,l)=>{if(!M5(e)||!M5(l))return{};const a=Object.assign({},e);for(const o of Object.keys(l)){if(o in e&&M5(l[o])){a[o]=LT(e[o],l[o]);continue}Object.assign(a,{[o]:l[o]})}return a},Wd0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,qd0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,Kd0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,$d0=e=>qd0(e)&&Kd0(e.children[0]),Xd0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(Wd0(l)&&$d0(l))return!0}return!1},Jd0=({children:e,editorWidth:l,toolbarButtonGroups:a=[],toolbarWidth:o})=>{const[i,c]=t.useState(),s=t.useRef();t.useEffect(()=>{if(o)c(o);else{const L=Up(a);L>0&&c(L+a.length+Pp)}},[l,o,a]),t.useEffect(()=>{const L=()=>{const d=window.getSelection(),u=(d==null?void 0:d.rangeCount)??0,f=u>0&&(d==null?void 0:d.getRangeAt(0).startOffset),h=u>0&&(d==null?void 0:d.getRangeAt(0).endOffset);!(!!d&&f!==h&&u>0)&&s.current&&s.current()};return document.addEventListener("selectionchange",L),()=>document.removeEventListener("selectionchange",L)},[]);const m=(L,d,u)=>{s.current=w.autoUpdate(L,d,u)};return t.createElement(w.BalloonToolbar,{floatingOptions:{middleware:[w.flip(),w.shift()],whileElementsMounted:m},styles:{root:{border:"none",background:"#ffffff",width:i,transitionDuration:"0s"}}},t.createElement("div",{"data-selector":"toolbar-floating","data-test-id":"toolbar-floating",className:"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap"},e))},dT={[h0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:Ks0},[h0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:Jd0},[h0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:$s0}},_d0=(e,l)=>{const a=dT[e].PlateWrapperClassNames;return A([a,l&&"tw-border tw-border-line-strong tw-rounded"])},Rd0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},eu0=({value:e})=>{const l=w.usePlateEditorRef();return t.useEffect(()=>{e&&(Rd0(l),w.insertNodes(l,e))},[l,e]),null},tu0=({hideExternalFloatingModals:e})=>{const l=w.useEditorRef(),a=w.useFloatingLinkSelectors().isOpen(l.id),o=t.useCallback(()=>{a&&w.floatingLinkActions.reset(),e&&e(l.id)},[a,e,l]),i=t.useCallback(()=>{l.collapse(),o()},[l,o]);return t.useEffect(()=>{const c=s=>{const m=`[data-editor-id='${l.id}']`,L="[data-selector='toolbar-floating']",d="[data-is-underlay]",u=document.querySelector(m),f=document.querySelector(L),h=document.querySelector(d),g=s.target,v=h==null?void 0:h.contains(g),E=u==null?void 0:u.contains(g),C=f==null?void 0:f.contains(g);C&&o(),!E&&!C&&!v&&i()};return document.addEventListener("pointerdown",c),document.addEventListener("focusin",c),()=>{document.removeEventListener("focusin",c),document.removeEventListener("pointerdown",c)}},[i,o,l.id]),null},lu0={position:"relative",height:"0"},uT=({id:e,value:l,placeholder:a="",readonly:o=!1,onTextChange:i,onBlur:c,padding:s=k3.None,position:m=h0.FLOATING,plugins:L=O1,updateValueOnChange:d=!1,onValueChanged:u,border:f=!0,toolbarWidth:h,hideExternalFloatingModals:g})=>{var H,I;const v=E0(e),{localValue:E,onChange:C,memoizedValue:M,config:Z}=Rs0({editorId:v,initialValue:l,onTextChange:i,plugins:L,onValueChanged:u}),N=L.plugins.find(b=>b.key===B1),x=((H=N==null?void 0:N.options)==null?void 0:H.columns)??1,k=((I=N==null?void 0:N.options)==null?void 0:I.gap)??R3,S={placeholder:a,renderPlaceholder:({children:b,attributes:y})=>{const V={...y,style:{...y.style,...lu0}};return t.createElement("span",{...V},b)},readOnly:o,onBlur:()=>c&&c(JSON.stringify(E.current)),className:`${s}`,style:{columns:x,columnGap:k,outline:"none"},onKeyDown:b=>{b.code==="Tab"&&cT(b,!b.shiftKey)},scrollSelectionIntoView:()=>{}};return t.createElement(Gp,{value:{styles:Z.styles(),position:m,border:f,editorId:v}},t.createElement(w.Plate,{id:v,onChange:C,editableProps:S,plugins:Z.create(),initialValue:M},!S.readOnly&&Z.toolbar(h),Z.inline(),d&&t.createElement(eu0,{value:L2({editorId:v,raw:l,plugins:L})}),m===h0.FLOATING&&t.createElement(tu0,{hideExternalFloatingModals:g})))};uT.displayName="FondueRichTextEditor";const wT=e=>e.split("").reverse().join(""),P1=(e,l)=>{const a=e.trim(),o=a,i=`${l}${o}${wT(l)}`;if(o.length===e.length)return i;const c=l+o+wT(l);return e.replace(a,c)},nu0=(e,l)=>{const a=`
72
72
  `;return(l.strikethrough||l.bold||l.italic)&&new RegExp(a,"g").test(e)&&(e=e.replaceAll(a,`\\
73
73
  `)),e},ru0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=P1(e,"~~***"):l.bold&&l.italic?e=P1(e,"***"):(l.bold&&(e=P1(e,"**")),l.italic&&(e=P1(e,"_")),l.strikethrough&&(e=P1(e,"~~")),l.code&&(e=P1(e,"`"))),e=nu0(e,l),e),U1=e=>!("type"in e),au0={paragraph:"paragraph",blockQuote:"block_quote",codeBlock:"code_block",link:"link",ulList:"ul_list",olList:"ol_list",listItem:"list_item",listItemChild:"lic",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"},emphasisMark:"italic",strongMark:"bold",deleteMark:"strikethrough",inlineCodeMark:"code",thematicBreak:"thematic_break",image:"image",mention:"mention"},I5={Blank:"_blank",Self:"_self"},ou0=e=>`@[${e.category}:${e.id}]`,iu0=e=>`${e}
74
74
  `,cu0=(e,l,a,o)=>{const i=a&&a.parentType===e.olList,c=a.children.length===1&&U1(a.children[0]);let s="";for(let m=0;o>m;m++)i?s+=" ":s+=" ";return`${s}${i?"1.":"-"} ${l}${c?`