@payloadcms/richtext-lexical 3.85.1 → 3.85.2

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,4 +1,4 @@
1
- "use client";import{a as Ce,c as ht,d as gt,e as xt}from"./chunk-XFA5M7FY.js";import{a as Xe}from"./chunk-DBWINSQN.js";import{a as Ct,b as ze}from"./chunk-QJ5EETIB.js";import{a as xe}from"./chunk-INBEEENE.js";import{a as Lc}from"./chunk-F26IQ5RE.js";import{b as Xt,c as zt,d as le,e as gn,f as Uo,g as Wo,h as yc,i as Rc,k as Ic,m as vc,p as Mc}from"./chunk-FTT5KJ6W.js";import{a as Nc,b as U}from"./chunk-BZZVLW4U.js";function X(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{c as Fc}from"react/compiler-runtime";import{useLexicalComposerContext as Pc}from"@lexical/react/LexicalComposerContext";import{$isDecoratorBlockNode as be}from"@lexical/react/LexicalDecoratorBlockNode";import{$findMatchingParent as Bc}from"@lexical/utils";import{$getSelection as jc,$isElementNode as ue,$isNodeSelection as Hc,$isRangeSelection as bt,COMMAND_PRIORITY_LOW as Uc,FORMAT_ELEMENT_COMMAND as kt}from"lexical";import{useEffect as Wc}from"react";import{jsx as Go,jsxs as Dc}from"react/jsx-runtime";import"react";var xn=()=>Dc("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Go("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Go("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Go("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Vo,jsxs as $c}from"react/jsx-runtime";import"react";var Cn=()=>$c("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Vo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Vo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Vo("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Jo,jsxs as Oc}from"react/jsx-runtime";import"react";var Zt=()=>Oc("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Jo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Jo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Jo("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Ko,jsxs as Ac}from"react/jsx-runtime";import"react";var bn=()=>Ac("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ko("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ko("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ko("path",{d:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var M=t=>o=>{let r={clientFeatureProps:o};if(typeof t=="function")r.feature=({config:n,featureClientImportMap:l,featureClientSchemaMap:s,featureProviderMap:i,field:d,resolvedFeatures:c,schemaPath:u,unSanitizedEditorConfig:a})=>{let m=t({config:n,featureClientImportMap:l,featureClientSchemaMap:s,featureProviderMap:i,field:d,props:o,resolvedFeatures:c,schemaPath:u,unSanitizedEditorConfig:a});return m.sanitizedClientFeatureProps===null&&(m.sanitizedClientFeatureProps=o),m};else{let n={...t};n.sanitizedClientFeatureProps=o,r.feature=n}return r};var kn=t=>({type:"dropdown",ChildComponent:Zt,items:t,key:"align",order:30});var ve=t=>ue(t)?t.getFormatType():t.__format,_n=[kn([{ChildComponent:Zt,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="left")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"left")},order:1},{ChildComponent:xn,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="center")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"center")},order:2},{ChildComponent:bn,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="right")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"right")},order:3},{ChildComponent:Cn,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="justify")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"justify")},order:4}])],Gc=()=>{let t=Fc(3),[e]=Pc(),o,r;return t[0]!==e?(o=()=>e.registerCommand(kt,Kc,Uc),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Wc(o,r),null},Vc=M({plugins:[{Component:Gc,position:"normal"}],toolbarFixed:{groups:_n},toolbarInline:{groups:_n}});function Jc(t){return(ue(t)||be(t))&&!t.isInline()}function Kc(t){let e=jc();if(!bt(e)&&!Hc(e))return!1;let o=e.getNodes();for(let r of o){let n=Bc(r,Jc);n!==null&&n.setFormat(t)}return!0}import{$createQuoteNode as yn,$isQuoteNode as Nn,QuoteNode as Zc}from"@lexical/rich-text";import{$setBlocksType as Rn}from"@lexical/selection";import{$getSelection as In,$isRangeSelection as Yc}from"lexical";import{jsx as Tn}from"react/jsx-runtime";import"react";var Xo=()=>Tn("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Tn("path",{d:"M13.5353 10.5725C13.5353 9.47709 11.0456 9.99991 11.0456 7.85883C11.0456 6.46464 12.1162 5.61816 13.361 5.61816C14.805 5.61816 16 6.86298 16 8.92937C16 11.2945 14.4564 13.7841 11.1203 14.3816L10.8216 13.1368C12.888 12.4895 13.5353 11.4937 13.5353 10.5725ZM6.71369 10.5725C6.71369 9.47709 4.22407 9.99991 4.22407 7.85883C4.22407 6.46464 5.29461 5.61816 6.53942 5.61816C7.9834 5.61816 9.17842 6.86298 9.17842 8.92937C9.17842 11.2945 7.63485 13.7841 4.29876 14.3816L4 13.1368C6.06639 12.4895 6.71369 11.4937 6.71369 10.5725Z",fill:"currentColor"})});import{jsx as wn}from"react/jsx-runtime";import"react";var _t=()=>wn("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:wn("path",{d:"M11.708 14.5H7.79785V13.9414H8.01367C9.00391 13.9414 9.15625 13.9033 9.15625 13.6113V6.70508H8.07715C6.82031 6.70508 6.73145 7.08594 6.28711 8.67285H5.80469L5.91895 6.12109H13.5869L13.7012 8.67285H13.2188C12.7744 7.08594 12.6855 6.70508 11.4287 6.70508H10.3496V13.6113C10.3496 13.9033 10.502 13.9414 11.4922 13.9414H11.708V14.5Z",fill:"currentColor"})});var ee=t=>({type:"dropdown",ChildComponent:_t,items:t,key:"text",order:25});import{$createQuoteNode as Xc,$isQuoteNode as Sn,QuoteNode as zc}from"@lexical/rich-text";var En={type:"element",dependencies:[zc],export:(t,e)=>{if(!Sn(t))return null;let o=e(t).split(`
1
+ "use client";import{a as Ce,c as ht,d as gt,e as xt}from"./chunk-XFA5M7FY.js";import{a as Xe}from"./chunk-DBWINSQN.js";import{a as Ct,b as ze}from"./chunk-QJ5EETIB.js";import{a as xe}from"./chunk-INBEEENE.js";import{a as Lc}from"./chunk-F26IQ5RE.js";import{b as Xt,c as zt,d as le,e as gn,f as Uo,g as Wo,h as yc,i as Rc,k as Ic,m as vc,p as Mc}from"./chunk-QAW5QKEM.js";import{a as Nc,b as U}from"./chunk-BZZVLW4U.js";function X(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{c as Fc}from"react/compiler-runtime";import{useLexicalComposerContext as Pc}from"@lexical/react/LexicalComposerContext";import{$isDecoratorBlockNode as be}from"@lexical/react/LexicalDecoratorBlockNode";import{$findMatchingParent as Bc}from"@lexical/utils";import{$getSelection as jc,$isElementNode as ue,$isNodeSelection as Hc,$isRangeSelection as bt,COMMAND_PRIORITY_LOW as Uc,FORMAT_ELEMENT_COMMAND as kt}from"lexical";import{useEffect as Wc}from"react";import{jsx as Go,jsxs as Dc}from"react/jsx-runtime";import"react";var xn=()=>Dc("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Go("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Go("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Go("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Vo,jsxs as $c}from"react/jsx-runtime";import"react";var Cn=()=>$c("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Vo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Vo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Vo("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Jo,jsxs as Oc}from"react/jsx-runtime";import"react";var Zt=()=>Oc("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Jo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Jo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Jo("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Ko,jsxs as Ac}from"react/jsx-runtime";import"react";var bn=()=>Ac("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ko("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ko("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ko("path",{d:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var M=t=>o=>{let r={clientFeatureProps:o};if(typeof t=="function")r.feature=({config:n,featureClientImportMap:l,featureClientSchemaMap:s,featureProviderMap:i,field:d,resolvedFeatures:c,schemaPath:u,unSanitizedEditorConfig:a})=>{let m=t({config:n,featureClientImportMap:l,featureClientSchemaMap:s,featureProviderMap:i,field:d,props:o,resolvedFeatures:c,schemaPath:u,unSanitizedEditorConfig:a});return m.sanitizedClientFeatureProps===null&&(m.sanitizedClientFeatureProps=o),m};else{let n={...t};n.sanitizedClientFeatureProps=o,r.feature=n}return r};var kn=t=>({type:"dropdown",ChildComponent:Zt,items:t,key:"align",order:30});var ve=t=>ue(t)?t.getFormatType():t.__format,_n=[kn([{ChildComponent:Zt,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="left")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"left")},order:1},{ChildComponent:xn,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="center")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"center")},order:2},{ChildComponent:bn,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="right")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"right")},order:3},{ChildComponent:Cn,isActive:({selection:t})=>{if(!bt(t))return!1;for(let e of t.getNodes()){if((ue(e)||be(e))&&ve(e)==="justify")continue;let o=e.getParent();if(!((ue(o)||be(o))&&ve(o)==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(kt,"justify")},order:4}])],Gc=()=>{let t=Fc(3),[e]=Pc(),o,r;return t[0]!==e?(o=()=>e.registerCommand(kt,Kc,Uc),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Wc(o,r),null},Vc=M({plugins:[{Component:Gc,position:"normal"}],toolbarFixed:{groups:_n},toolbarInline:{groups:_n}});function Jc(t){return(ue(t)||be(t))&&!t.isInline()}function Kc(t){let e=jc();if(!bt(e)&&!Hc(e))return!1;let o=e.getNodes();for(let r of o){let n=Bc(r,Jc);n!==null&&n.setFormat(t)}return!0}import{$createQuoteNode as yn,$isQuoteNode as Nn,QuoteNode as Zc}from"@lexical/rich-text";import{$setBlocksType as Rn}from"@lexical/selection";import{$getSelection as In,$isRangeSelection as Yc}from"lexical";import{jsx as Tn}from"react/jsx-runtime";import"react";var Xo=()=>Tn("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Tn("path",{d:"M13.5353 10.5725C13.5353 9.47709 11.0456 9.99991 11.0456 7.85883C11.0456 6.46464 12.1162 5.61816 13.361 5.61816C14.805 5.61816 16 6.86298 16 8.92937C16 11.2945 14.4564 13.7841 11.1203 14.3816L10.8216 13.1368C12.888 12.4895 13.5353 11.4937 13.5353 10.5725ZM6.71369 10.5725C6.71369 9.47709 4.22407 9.99991 4.22407 7.85883C4.22407 6.46464 5.29461 5.61816 6.53942 5.61816C7.9834 5.61816 9.17842 6.86298 9.17842 8.92937C9.17842 11.2945 7.63485 13.7841 4.29876 14.3816L4 13.1368C6.06639 12.4895 6.71369 11.4937 6.71369 10.5725Z",fill:"currentColor"})});import{jsx as wn}from"react/jsx-runtime";import"react";var _t=()=>wn("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:wn("path",{d:"M11.708 14.5H7.79785V13.9414H8.01367C9.00391 13.9414 9.15625 13.9033 9.15625 13.6113V6.70508H8.07715C6.82031 6.70508 6.73145 7.08594 6.28711 8.67285H5.80469L5.91895 6.12109H13.5869L13.7012 8.67285H13.2188C12.7744 7.08594 12.6855 6.70508 11.4287 6.70508H10.3496V13.6113C10.3496 13.9033 10.502 13.9414 11.4922 13.9414H11.708V14.5Z",fill:"currentColor"})});var ee=t=>({type:"dropdown",ChildComponent:_t,items:t,key:"text",order:25});import{$createQuoteNode as Xc,$isQuoteNode as Sn,QuoteNode as zc}from"@lexical/rich-text";var En={type:"element",dependencies:[zc],export:(t,e)=>{if(!Sn(t))return null;let o=e(t).split(`
2
2
  `),r=[];for(let n of o)r.push("> "+n);return r.join(`
3
3
  `)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let l=t.getPreviousSibling();if(Sn(l)){l.splice(l.getChildrenSize(),0,[...e]),l.select(0,0),t.remove();return}}let n=Xc();n.append(...e),t.replace(n),n.select(0,0)}};var Ln=[ee([{ChildComponent:Xo,isActive:({selection:t})=>{if(!Yc(t))return!1;for(let e of t.getNodes())if(!Nn(e)&&!Nn(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=In();Rn(e,()=>yn())})},order:20}])],qc=M({markdownTransformers:[En],nodes:[Zc],slashMenu:{groups:[X([{Icon:Xo,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=In();Rn(e,()=>yn())})}}])]},toolbarFixed:{groups:Ln},toolbarInline:{groups:Ln}});import{getTranslation as io}from"@payloadcms/translations";import{jsx as zo,jsxs as Qc}from"react/jsx-runtime";import"react";var Yt=()=>Qc("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[zo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),zo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),zo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as vn}from"react/jsx-runtime";import"react";var qt=()=>vn("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:vn("path",{clipRule:"evenodd",d:"M5.33333 6.5C5.11232 6.5 4.90036 6.5878 4.74408 6.74408C4.5878 6.90036 4.5 7.11232 4.5 7.33333V12.1667C4.5 12.3877 4.5878 12.5996 4.74408 12.7559C4.90036 12.9122 5.11232 13 5.33333 13H14.6667C14.8877 13 15.0996 12.9122 15.2559 12.7559C15.4122 12.5996 15.5 12.3877 15.5 12.1667V11.6667C15.5 11.3905 15.7239 11.1667 16 11.1667C16.2761 11.1667 16.5 11.3905 16.5 11.6667V12.1667C16.5 12.6529 16.3068 13.1192 15.963 13.463C15.6192 13.8068 15.1529 14 14.6667 14H5.33333C4.8471 14 4.38079 13.8068 4.03697 13.463C3.69315 13.1192 3.5 12.6529 3.5 12.1667V7.33333C3.5 6.8471 3.69315 6.38079 4.03697 6.03697C4.38079 5.69315 4.8471 5.5 5.33333 5.5H10.3333C10.6095 5.5 10.8333 5.72386 10.8333 6C10.8333 6.27614 10.6095 6.5 10.3333 6.5H5.33333ZM13 6.5C12.7239 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.7239 5.5 13 5.5H16C16.2761 5.5 16.5 5.72386 16.5 6V9C16.5 9.27614 16.2761 9.5 16 9.5C15.7239 9.5 15.5 9.27614 15.5 9V7.20711L13.3536 9.35355C13.1583 9.54882 12.8417 9.54882 12.6464 9.35355C12.4512 9.15829 12.4512 8.84171 12.6464 8.64645L14.7929 6.5H13ZM6.16699 8.33325C6.16699 8.05711 6.39085 7.83325 6.66699 7.83325H11.0003C11.2765 7.83325 11.5003 8.05711 11.5003 8.33325C11.5003 8.60939 11.2765 8.83325 11.0003 8.83325H6.66699C6.39085 8.83325 6.16699 8.60939 6.16699 8.33325ZM6.16699 10.9999C6.16699 10.7238 6.39085 10.4999 6.66699 10.4999H13.3337C13.6098 10.4999 13.8337 10.7238 13.8337 10.9999C13.8337 11.2761 13.6098 11.4999 13.3337 11.4999H6.66699C6.39085 11.4999 6.16699 11.2761 6.16699 10.9999Z",fill:"currentColor",fillRule:"evenodd"})});import{jsx as eu}from"react/jsx-runtime";import"react";function Qt(t,e){let{admin:o,imageAltText:r,imageURL:n}=t,l=o?.images,s,i;if(l?.icon?(s=typeof l.icon=="string"?l.icon:l.icon.url,i=typeof l.icon=="string"?void 0:l.icon.alt):l?.thumbnail?(s=typeof l.thumbnail=="string"?l.thumbnail:l.thumbnail.url,i=typeof l.thumbnail=="string"?void 0:l.thumbnail.alt):(s=n,i=r),!s)return e;let d=i??"Block Image";return()=>eu("img",{alt:d,className:"lexical-block-custom-image",src:s,style:{maxHeight:20,maxWidth:20}})}import{$parseSerializedNode as Un}from"lexical";import{JSOX as Zo}from"jsox";function eo({propsString:t}){let e={},o="",r=!0;for(let n=0;n<t.length;n++){let l=t[n];if(r)l==="="||l===" "?o&&(l===" "?(e[o]=!0,o=""):r=!1):o+=l;else{let s=tu(t,n);e[o]=s.value,n=s.newIndex,o="",r=!0}}return o&&(e[o]=!0),e}function tu(t,e){let o=t[e];return o==='"'?Mn(t,e):o==="'"?Mn(t,e,!0):o==="{"?ru(t,e):o==="["?ou(t,e):lu(t,e)}function ou(t,e){let o=1,r="",n=e+1;for(;n<t.length&&o>0;)t[n]==="["?o++:t[n]==="]"&&o--,o>0&&(r+=t[n]),n++;return{newIndex:n,value:Zo.parse(`[${r}]`)}}function Mn(t,e,o=!1){let r="",n=e+1;for(;n<t.length&&(t[n]!==(o?"'":'"')||t[n-1]==="\\");)r+=t[n],n++;return{newIndex:n,value:r}}function ru(t,e){let o=1,r="",n=e+1;for(;n<t.length&&o>0;)t[n]==="{"?o++:t[n]==="}"&&o--,o>0&&(r+=t[n]),n++;return{newIndex:n,value:nu(r)}}function nu(t){return t[0]!=="{"?Zo.parse(t):Zo.parse(t.replace(/(\w+):/g,'"$1":'))}function lu(t,e){let o="",r=e;for(;r<t.length&&t[r]!==" ";)o+=t[r],r++;return{newIndex:r-1,value:o}}function Tt({props:t}){let e=[];for(let[o,r]of Object.entries(t))typeof r=="string"?e.push(`${o}="${iu(r)}"`):typeof r=="number"?e.push(`${o}={${r}}`):typeof r=="boolean"?r&&e.push(`${o}`):r!==null&&typeof r=="object"&&(Array.isArray(r)?e.push(`${o}={[${r.map(n=>JSON.stringify(n,Dn)).join(", ")}]}`):e.push(`${o}={${JSON.stringify(r,Dn)}}`));return e.join(" ")}function iu(t){return t.replace(/"/g,"&quot;")}function Dn(t,e){return typeof e=="string"?e.replace(/'/g,"\\'"):e}function to({isEndOptional:t,lines:e,regexpEndRegex:o,startLineIndex:r,startMatch:n,trimChildren:l}){let s="",i="",d=e.slice(r),c=!1,u=0,a=0,m=null,p=!1,h=0,f=d[0].slice(0,n.index),g=0,k=r;e:for(let[R,T]of d.entries()){let C=l?T.trim():T,x=0;if(l)for(let _=0;_<T.length&&T[_]===" ";_++)x++;let b=0;for(R===0&&(b=(n.index??0)+n[0].length-x);b<C.length;){let _=C[b],D=C[b+1];if(c){if(_==="`"&&h++,h%2===0)if(_==="<"&&D==="/"){if(u--,u<0){i[i.length-1]===`
4
4
  `&&(i=i.slice(0,-1)),k=R;for(let I=b;I<C.length;I++)if(C[I]===">"){g=I+1;break}break e}}else if(_==="/"&&D===">"){if(u--,u<0){i[i.length-1]===`
@@ -57,7 +57,7 @@ ${e.map(Cd).join(`
57
57
 
58
58
  `,Ts="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",ws="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",y0=new RegExp("^[^"+ws+"]*["+Ts+"]"),R0=new RegExp("^[^"+Ts+"]*["+ws+"]"),I0={bold:A.IS_BOLD,code:A.IS_CODE,highlight:A.IS_HIGHLIGHT,italic:A.IS_ITALIC,strikethrough:A.IS_STRIKETHROUGH,subscript:A.IS_SUBSCRIPT,superscript:A.IS_SUPERSCRIPT,underline:A.IS_UNDERLINE},v0={directionless:A.IS_DIRECTIONLESS,unmergeable:A.IS_UNMERGEABLE},M0={center:A.IS_ALIGN_CENTER,end:A.IS_ALIGN_END,justify:A.IS_ALIGN_JUSTIFY,left:A.IS_ALIGN_LEFT,right:A.IS_ALIGN_RIGHT,start:A.IS_ALIGN_START},D0={[A.IS_ALIGN_CENTER]:"center",[A.IS_ALIGN_END]:"end",[A.IS_ALIGN_JUSTIFY]:"justify",[A.IS_ALIGN_LEFT]:"left",[A.IS_ALIGN_RIGHT]:"right",[A.IS_ALIGN_START]:"start"},$0={normal:A.IS_NORMAL,segmented:A.IS_SEGMENTED,token:A.IS_TOKEN},O0={[A.IS_NORMAL]:"normal",[A.IS_SEGMENTED]:"segmented",[A.IS_TOKEN]:"token"};var Ss={text:({node:t})=>{let e=t.text;return t.format&A.IS_BOLD&&(e=Ue("strong",{children:e})),t.format&A.IS_ITALIC&&(e=Ue("em",{children:e})),t.format&A.IS_STRIKETHROUGH&&(e=Ue("span",{style:{textDecoration:"line-through"},children:e})),t.format&A.IS_UNDERLINE&&(e=Ue("span",{style:{textDecoration:"underline"},children:e})),t.format&A.IS_CODE&&(e=Ue("code",{children:e})),t.format&A.IS_SUBSCRIPT&&(e=Ue("sub",{children:e})),t.format&A.IS_SUPERSCRIPT&&(e=Ue("sup",{children:e})),e}};import{jsx as Ot}from"react/jsx-runtime";var Es={upload:({node:t})=>{let e=t;if(typeof e.value!="object")return null;let o=e.value,r=e.fields?.alt||o?.alt||"",n=o.url;if(!o.mimeType.startsWith("image"))return Ot("a",{href:n,rel:"noopener noreferrer",children:o.filename});if(!o.sizes||!Object.keys(o.sizes).length)return Ot("img",{alt:r,height:o.height,src:n,width:o.width});let l=[];for(let s in o.sizes){let i=o.sizes[s];if(!i||!i.width||!i.height||!i.mimeType||!i.filesize||!i.filename||!i.url)continue;let d=i?.url;l.push(Ot("source",{media:`(max-width: ${i.width}px)`,srcSet:d,type:i.mimeType},s))}return l.push(Ot("img",{alt:r,height:o?.height,src:n,width:o?.width},"image")),Ot("picture",{children:l})}};var it={...bs,...Ss,...hs,...ms,..._s,...ps,...fs,...Cs,...xs({}),...Es,...ks};import{jsx as bo,Fragment as A0}from"react/jsx-runtime";import Co from"react";function Ns(t){if(!!!t?.root?.children?.length)return!1;let o=!1;if(t?.root?.children?.length===1&&t?.root?.children[0]?.type==="paragraph"){let r=t?.root?.children[0];if(!r?.children||r?.children?.length===0)o=!0;else if(r?.children?.length===1){let n=r?.children[0];n?.type==="text"&&(n?.text?.length||(o=!0))}}return!o}function F0(t){return e=>{let o={...e,isEditor:!1,isJSXConverter:!0};if(t.Component)return t.Component(o);if(t.html){let r=typeof t.html=="function"?t.html(o):t.html;return bo("span",{dangerouslySetInnerHTML:{__html:r}})}return null}}function Ls(t){return e=>{if(t.Component){let o={...e,isEditor:!1,isJSXConverter:!0};return t.Component(o)}if(t.Block){let o=e.node,r={childIndex:e.childIndex,converters:e.converters,formData:o.fields??{},isEditor:!1,isJSXConverter:!0,node:o,nodesToJSX:e.nodesToJSX,parent:e.parent};return Co.createElement(t.Block,r)}if(t.html){let o={...e,isEditor:!1,isJSXConverter:!0},r=typeof t.html=="function"?t.html(o):t.html;return bo("span",{dangerouslySetInnerHTML:{__html:r}})}return null}}function P0(t){let e={};for(let[o,r]of Object.entries(t)){if(!r||typeof r!="object")continue;if(o==="blocks"){e.blocks={};for(let[l,s]of Object.entries(r)){let i=s;(i.Component||i.Block||i.html)&&(e.blocks[l]=Ls(i))}continue}if(o==="inlineBlocks"){e.inlineBlocks={};for(let[l,s]of Object.entries(r)){let i=s;(i.Component||i.Block||i.html)&&(e.inlineBlocks[l]=Ls(i))}continue}let n=r;(n.Component||n.html)&&(e[o]=F0(n))}return e}function ys({converters:t,data:e,disableIndent:o,disableTextAlign:r,nodeMap:n}){if(Ns(e)){let l=n?P0(n):void 0,s=l?{...t,...l,blocks:{...t.blocks,...l.blocks},inlineBlocks:{...t.inlineBlocks,...l.inlineBlocks}}:t;return Rs({converters:s,disableIndent:o,disableTextAlign:r,nodes:e.root.children,parent:e.root})}return bo(A0,{})}function Rs({converters:t,disableIndent:e,disableTextAlign:o,nodes:r,parent:n}){let l=t.unknown;return r.map((i,d)=>{let c;i.type==="block"?(c=t?.blocks?.[i?.fields?.blockType],!c&&!l&&console.error(`Lexical => JSX converter: Blocks converter: found ${i?.fields?.blockType} block, but no converter is provided`)):i.type==="inlineBlock"?(c=t?.inlineBlocks?.[i?.fields?.blockType],!c&&!l&&console.error(`Lexical => JSX converter: Inline Blocks converter: found ${i?.fields?.blockType} inline block, but no converter is provided`)):c=t[i.type];try{!c&&l&&(c=l);let u;c?u=typeof c=="function"?c({childIndex:d,converters:t,node:i,nodesToJSX:p=>Rs({converters:p.converters??t,disableIndent:p.disableIndent??e,disableTextAlign:p.disableTextAlign??o,nodes:p.nodes,parent:p.parent??{...i,parent:n}}),parent:n}):c:u=bo("span",{children:"unknown node"},d);let a={};if(!o&&(!Array.isArray(o)||!o?.includes(i.type))&&"format"in i&&i.format)switch(i.format){case"center":a.textAlign="center";break;case"end":a.textAlign="right";break;case"justify":a.textAlign="justify";break;case"left":break;case"right":a.textAlign="right";break;case"start":a.textAlign="left";break}if(!e&&(!Array.isArray(e)||!e?.includes(i.type))&&"indent"in i&&i.indent&&i.type!=="listitem"&&(a.paddingInlineStart=`${Number(i.indent)*40}px`),Co.isValidElement(u)){if(a.textAlign||a.paddingInlineStart){let m={...a,...u?.props?.style??{}};return Co.cloneElement(u,{key:d,style:m})}return Co.cloneElement(u,{key:d})}return u}catch(u){return console.error("Error converting lexical node to JSX:",u,"node:",i),null}}).filter(Boolean)}function Rr({className:t,converters:e,data:o,disableContainer:r,disableIndent:n,disableTextAlign:l,nodeMap:s}){if(!o)return null;let i={};e?typeof e=="function"?i=e({defaultConverters:it}):i=e:i=it;let d=o&&!Array.isArray(o)&&typeof o=="object"&&"root"in o&&ys({converters:i,data:o,disableIndent:n,disableTextAlign:l,nodeMap:s});return r?Is(B0,{children:d}):Is("div",{className:t??"payload-richtext",children:d})}function Ms(){let t=j0(7),[e]=H0(),o;t[0]!==e?(o=()=>e.getEditorState().toJSON(),t[0]=e,t[1]=o):o=t[1];let[r,n]=W0(o),l,s;t[2]!==e?(l=()=>e.registerUpdateListener(d=>{let{editorState:c}=d;n(c.toJSON())}),s=[e],t[2]=e,t[3]=l,t[4]=s):(l=t[3],s=t[4]),U0(l,s);let i;return t[5]!==r?(i=vs("div",{className:"debug-jsx-converter",children:vs(Rr,{converters:it,data:r})}),t[5]=r,t[6]=i):i=t[6],i}var G0=M({plugins:[{Component:Ms,position:"bottom"}]});var j={amber:{50:"oklch(0.987 0.022 95.277)",100:"oklch(0.962 0.059 95.617)",200:"oklch(0.924 0.12 95.746)",300:"oklch(0.879 0.169 91.605)",400:"oklch(0.828 0.189 84.429)",500:"oklch(0.769 0.188 70.08)",600:"oklch(0.666 0.179 58.318)",700:"oklch(0.555 0.163 48.998)",800:"oklch(0.473 0.137 46.201)",900:"oklch(0.414 0.112 45.904)",950:"oklch(0.279 0.077 45.635)"},black:"#000",blue:{50:"oklch(0.97 0.014 254.604)",100:"oklch(0.932 0.032 255.585)",200:"oklch(0.882 0.059 254.128)",300:"oklch(0.809 0.105 251.813)",400:"oklch(0.707 0.165 254.624)",500:"oklch(0.623 0.214 259.815)",600:"oklch(0.546 0.245 262.881)",700:"oklch(0.488 0.243 264.376)",800:"oklch(0.424 0.199 265.638)",900:"oklch(0.379 0.146 265.522)",950:"oklch(0.282 0.091 267.935)"},current:"currentColor",cyan:{50:"oklch(0.984 0.019 200.873)",100:"oklch(0.956 0.045 203.388)",200:"oklch(0.917 0.08 205.041)",300:"oklch(0.865 0.127 207.078)",400:"oklch(0.789 0.154 211.53)",500:"oklch(0.715 0.143 215.221)",600:"oklch(0.609 0.126 221.723)",700:"oklch(0.52 0.105 223.128)",800:"oklch(0.45 0.085 224.283)",900:"oklch(0.398 0.07 227.392)",950:"oklch(0.302 0.056 229.695)"},emerald:{50:"oklch(0.979 0.021 166.113)",100:"oklch(0.95 0.052 163.051)",200:"oklch(0.905 0.093 164.15)",300:"oklch(0.845 0.143 164.978)",400:"oklch(0.765 0.177 163.223)",500:"oklch(0.696 0.17 162.48)",600:"oklch(0.596 0.145 163.225)",700:"oklch(0.508 0.118 165.612)",800:"oklch(0.432 0.095 166.913)",900:"oklch(0.378 0.077 168.94)",950:"oklch(0.262 0.051 172.552)"},fuchsia:{50:"oklch(0.977 0.017 320.058)",100:"oklch(0.952 0.037 318.852)",200:"oklch(0.903 0.076 319.62)",300:"oklch(0.833 0.145 321.434)",400:"oklch(0.74 0.238 322.16)",500:"oklch(0.667 0.295 322.15)",600:"oklch(0.591 0.293 322.896)",700:"oklch(0.518 0.253 323.949)",800:"oklch(0.452 0.211 324.591)",900:"oklch(0.401 0.17 325.612)",950:"oklch(0.293 0.136 325.661)"},gray:{50:"oklch(0.985 0.002 247.839)",100:"oklch(0.967 0.003 264.542)",200:"oklch(0.928 0.006 264.531)",300:"oklch(0.872 0.01 258.338)",400:"oklch(0.707 0.022 261.325)",500:"oklch(0.551 0.027 264.364)",600:"oklch(0.446 0.03 256.802)",700:"oklch(0.373 0.034 259.733)",800:"oklch(0.278 0.033 256.848)",900:"oklch(0.21 0.034 264.665)",950:"oklch(0.13 0.028 261.692)"},green:{50:"oklch(0.982 0.018 155.826)",100:"oklch(0.962 0.044 156.743)",200:"oklch(0.925 0.084 155.995)",300:"oklch(0.871 0.15 154.449)",400:"oklch(0.792 0.209 151.711)",500:"oklch(0.723 0.219 149.579)",600:"oklch(0.627 0.194 149.214)",700:"oklch(0.527 0.154 150.069)",800:"oklch(0.448 0.119 151.328)",900:"oklch(0.393 0.095 152.535)",950:"oklch(0.266 0.065 152.934)"},indigo:{50:"oklch(0.962 0.018 272.314)",100:"oklch(0.93 0.034 272.788)",200:"oklch(0.87 0.065 274.039)",300:"oklch(0.785 0.115 274.713)",400:"oklch(0.673 0.182 276.935)",500:"oklch(0.585 0.233 277.117)",600:"oklch(0.511 0.262 276.966)",700:"oklch(0.457 0.24 277.023)",800:"oklch(0.398 0.195 277.366)",900:"oklch(0.359 0.144 278.697)",950:"oklch(0.257 0.09 281.288)"},inherit:"inherit",lime:{50:"oklch(0.986 0.031 120.757)",100:"oklch(0.967 0.067 122.328)",200:"oklch(0.938 0.127 124.321)",300:"oklch(0.897 0.196 126.665)",400:"oklch(0.841 0.238 128.85)",500:"oklch(0.768 0.233 130.85)",600:"oklch(0.648 0.2 131.684)",700:"oklch(0.532 0.157 131.589)",800:"oklch(0.453 0.124 130.933)",900:"oklch(0.405 0.101 131.063)",950:"oklch(0.274 0.072 132.109)"},neutral:{50:"oklch(0.985 0 0)",100:"oklch(0.97 0 0)",200:"oklch(0.922 0 0)",300:"oklch(0.87 0 0)",400:"oklch(0.708 0 0)",500:"oklch(0.556 0 0)",600:"oklch(0.439 0 0)",700:"oklch(0.371 0 0)",800:"oklch(0.269 0 0)",900:"oklch(0.205 0 0)",950:"oklch(0.145 0 0)"},orange:{50:"oklch(0.98 0.016 73.684)",100:"oklch(0.954 0.038 75.164)",200:"oklch(0.901 0.076 70.697)",300:"oklch(0.837 0.128 66.29)",400:"oklch(0.75 0.183 55.934)",500:"oklch(0.705 0.213 47.604)",600:"oklch(0.646 0.222 41.116)",700:"oklch(0.553 0.195 38.402)",800:"oklch(0.47 0.157 37.304)",900:"oklch(0.408 0.123 38.172)",950:"oklch(0.266 0.079 36.259)"},pink:{50:"oklch(0.971 0.014 343.198)",100:"oklch(0.948 0.028 342.258)",200:"oklch(0.899 0.061 343.231)",300:"oklch(0.823 0.12 346.018)",400:"oklch(0.718 0.202 349.761)",500:"oklch(0.656 0.241 354.308)",600:"oklch(0.592 0.249 0.584)",700:"oklch(0.525 0.223 3.958)",800:"oklch(0.459 0.187 3.815)",900:"oklch(0.408 0.153 2.432)",950:"oklch(0.284 0.109 3.907)"},purple:{50:"oklch(0.977 0.014 308.299)",100:"oklch(0.946 0.033 307.174)",200:"oklch(0.902 0.063 306.703)",300:"oklch(0.827 0.119 306.383)",400:"oklch(0.714 0.203 305.504)",500:"oklch(0.627 0.265 303.9)",600:"oklch(0.558 0.288 302.321)",700:"oklch(0.496 0.265 301.924)",800:"oklch(0.438 0.218 303.724)",900:"oklch(0.381 0.176 304.987)",950:"oklch(0.291 0.149 302.717)"},red:{50:"oklch(0.971 0.013 17.38)",100:"oklch(0.936 0.032 17.717)",200:"oklch(0.885 0.062 18.334)",300:"oklch(0.808 0.114 19.571)",400:"oklch(0.704 0.191 22.216)",500:"oklch(0.637 0.237 25.331)",600:"oklch(0.577 0.245 27.325)",700:"oklch(0.505 0.213 27.518)",800:"oklch(0.444 0.177 26.899)",900:"oklch(0.396 0.141 25.723)",950:"oklch(0.258 0.092 26.042)"},rose:{50:"oklch(0.969 0.015 12.422)",100:"oklch(0.941 0.03 12.58)",200:"oklch(0.892 0.058 10.001)",300:"oklch(0.81 0.117 11.638)",400:"oklch(0.712 0.194 13.428)",500:"oklch(0.645 0.246 16.439)",600:"oklch(0.586 0.253 17.585)",700:"oklch(0.514 0.222 16.935)",800:"oklch(0.455 0.188 13.697)",900:"oklch(0.41 0.159 10.272)",950:"oklch(0.271 0.105 12.094)"},sky:{50:"oklch(0.977 0.013 236.62)",100:"oklch(0.951 0.026 236.824)",200:"oklch(0.901 0.058 230.902)",300:"oklch(0.828 0.111 230.318)",400:"oklch(0.746 0.16 232.661)",500:"oklch(0.685 0.169 237.323)",600:"oklch(0.588 0.158 241.966)",700:"oklch(0.5 0.134 242.749)",800:"oklch(0.443 0.11 240.79)",900:"oklch(0.391 0.09 240.876)",950:"oklch(0.293 0.066 243.157)"},slate:{50:"oklch(0.984 0.003 247.858)",100:"oklch(0.968 0.007 247.896)",200:"oklch(0.929 0.013 255.508)",300:"oklch(0.869 0.022 252.894)",400:"oklch(0.704 0.04 256.788)",500:"oklch(0.554 0.046 257.417)",600:"oklch(0.446 0.043 257.281)",700:"oklch(0.372 0.044 257.287)",800:"oklch(0.279 0.041 260.031)",900:"oklch(0.208 0.042 265.755)",950:"oklch(0.129 0.042 264.695)"},stone:{50:"oklch(0.985 0.001 106.423)",100:"oklch(0.97 0.001 106.424)",200:"oklch(0.923 0.003 48.717)",300:"oklch(0.869 0.005 56.366)",400:"oklch(0.709 0.01 56.259)",500:"oklch(0.553 0.013 58.071)",600:"oklch(0.444 0.011 73.639)",700:"oklch(0.374 0.01 67.558)",800:"oklch(0.268 0.007 34.298)",900:"oklch(0.216 0.006 56.043)",950:"oklch(0.147 0.004 49.25)"},teal:{50:"oklch(0.984 0.014 180.72)",100:"oklch(0.953 0.051 180.801)",200:"oklch(0.91 0.096 180.426)",300:"oklch(0.855 0.138 181.071)",400:"oklch(0.777 0.152 181.912)",500:"oklch(0.704 0.14 182.503)",600:"oklch(0.6 0.118 184.704)",700:"oklch(0.511 0.096 186.391)",800:"oklch(0.437 0.078 188.216)",900:"oklch(0.386 0.063 188.416)",950:"oklch(0.277 0.046 192.524)"},transparent:"transparent",violet:{50:"oklch(0.969 0.016 293.756)",100:"oklch(0.943 0.029 294.588)",200:"oklch(0.894 0.057 293.283)",300:"oklch(0.811 0.111 293.571)",400:"oklch(0.702 0.183 293.541)",500:"oklch(0.606 0.25 292.717)",600:"oklch(0.541 0.281 293.009)",700:"oklch(0.491 0.27 292.581)",800:"oklch(0.432 0.232 292.759)",900:"oklch(0.38 0.189 293.745)",950:"oklch(0.283 0.141 291.089)"},white:"#fff",yellow:{50:"oklch(0.987 0.026 102.212)",100:"oklch(0.973 0.071 103.193)",200:"oklch(0.945 0.129 101.54)",300:"oklch(0.905 0.182 98.111)",400:"oklch(0.852 0.199 91.936)",500:"oklch(0.795 0.184 86.047)",600:"oklch(0.681 0.162 75.834)",700:"oklch(0.554 0.135 66.442)",800:"oklch(0.476 0.114 61.907)",900:"oklch(0.421 0.095 57.708)",950:"oklch(0.286 0.066 53.813)"},zinc:{50:"oklch(0.985 0 0)",100:"oklch(0.967 0.001 286.375)",200:"oklch(0.92 0.004 286.32)",300:"oklch(0.871 0.006 286.286)",400:"oklch(0.705 0.015 286.067)",500:"oklch(0.552 0.016 285.938)",600:"oklch(0.442 0.017 285.786)",700:"oklch(0.37 0.013 285.805)",800:"oklch(0.274 0.006 286.033)",900:"oklch(0.21 0.006 285.885)",950:"oklch(0.141 0.005 285.823)"}},V0={text:{"text-red":{css:{color:`light-dark(${j.red[600]}, ${j.red[400]})`},label:"Red"},"text-orange":{css:{color:`light-dark(${j.orange[600]}, ${j.orange[400]})`},label:"Orange"},"text-yellow":{css:{color:`light-dark(${j.yellow[700]}, ${j.yellow[300]})`},label:"Yellow"},"text-green":{css:{color:`light-dark(${j.green[700]}, ${j.green[400]})`},label:"Green"},"text-blue":{css:{color:`light-dark(${j.blue[600]}, ${j.blue[400]})`},label:"Blue"},"text-purple":{css:{color:`light-dark(${j.purple[600]}, ${j.purple[400]})`},label:"Purple"},"text-pink":{css:{color:`light-dark(${j.pink[600]}, ${j.pink[400]})`},label:"Pink"}},background:{"bg-red":{css:{"background-color":`light-dark(${j.red[400]}, ${j.red[600]})`},label:"Red"},"bg-orange":{css:{"background-color":`light-dark(${j.orange[400]}, ${j.orange[600]})`},label:"Orange"},"bg-yellow":{css:{"background-color":`light-dark(${j.yellow[300]}, ${j.yellow[700]})`},label:"Yellow"},"bg-green":{css:{"background-color":`light-dark(${j.green[400]}, ${j.green[700]})`},label:"Green"},"bg-blue":{css:{"background-color":`light-dark(${j.blue[400]}, ${j.blue[600]})`},label:"Blue"},"bg-purple":{css:{"background-color":`light-dark(${j.purple[400]}, ${j.purple[600]})`},label:"Purple"},"bg-pink":{css:{"background-color":`light-dark(${j.pink[400]}, ${j.pink[600]})`},label:"Pink"}}};import{$isNodeSelection as D1}from"lexical";import{jsx as At,jsxs as J0}from"react/jsx-runtime";import"react";var Ir=()=>J0("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[At("g",{clipPath:"url(#clip0_4397_10817)",children:At("path",{d:"M7.75 12.25L15.25 4.75M15.25 4.75H11.5M15.25 4.75V8.5M13 11.5V13.75C13 14.5784 12.3284 15.25 11.5 15.25H6.25C5.42157 15.25 4.75 14.5784 4.75 13.75V8.5C4.75 7.67157 5.42157 7 6.25 7H8.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})}),At("defs",{children:At("clipPath",{id:"clip0_4397_10817",children:At("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{jsx as Y0}from"react/jsx-runtime";import{$applyNodeReplacement as q0}from"lexical";import*as $s from"react";import{DecoratorBlockNode as K0}from"@lexical/react/LexicalDecoratorBlockNode.js";import{addClassNamesToElement as X0}from"@lexical/utils";import{$applyNodeReplacement as z0}from"lexical";function Z0(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:Ds({relationTo:o,value:e})}:null}var Ft=class extends K0{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"relationship"}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:Z0,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=Ds(o);return r.setFormat(e.format),r}static isInline(){return!1}createDOM(e){let o=document.createElement("div");return X0(o,e?.theme?.relationship),o}decorate(e,o){return null}exportDOM(){let e=document.createElement("div");e.setAttribute("data-lexical-relationship-id",String(typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value)),e.setAttribute("data-lexical-relationship-relationTo",this.__data?.relationTo);let o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"relationship",version:2}}getData(){return this.getLatest().__data}getTextContent(){return`${this.__data?.relationTo} relation to ${typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value}`}setData(e){let o=this.getWritable();o.__data=e}};function Ds(t){return z0(new Ft({data:t}))}var Q0=$s.lazy(()=>import("./RelationshipComponent-BG3DPV3T.js").then(t=>({default:t.RelationshipComponent})));function e1(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:We({relationTo:o,value:e})}:null}var Ne=class extends Ft{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:e1,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=We(o);return r.setFormat(e.format),r}decorate(e,o){return Y0(Q0,{className:o.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function We(t){return q0(new Ne({data:t}))}function vr(t){return t instanceof Ne}import{c as _1}from"react/compiler-runtime";import{jsx as T1}from"react/jsx-runtime";import{useLexicalComposerContext as w1}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as S1}from"@lexical/utils";import{$getPreviousSelection as E1,$getSelection as N1,$isParagraphNode as L1,$isRangeSelection as y1,COMMAND_PRIORITY_EDITOR as R1,createCommand as I1}from"lexical";import{useEffect as v1}from"react";import{c as Fs}from"react/compiler-runtime";import{jsx as Mr}from"react/jsx-runtime";import{useLexicalComposerContext as Ps}from"@lexical/react/LexicalComposerContext.js";import{toast as m1}from"@payloadcms/ui";import{$getNodeByKey as p1,COMMAND_PRIORITY_EDITOR as Bs}from"lexical";import{useEffect as js,useState as f1}from"react";import{c as t1}from"react/compiler-runtime";import{jsx as o1}from"react/jsx-runtime";import{useLexicalComposerContext as r1}from"@lexical/react/LexicalComposerContext";import{useListDrawer as n1,useModal as l1}from"@payloadcms/ui";import{$getNodeByKey as Os,$getPreviousSelection as i1,$getRoot as s1,$getSelection as a1,$isRangeSelection as c1,$setSelection as u1}from"lexical";import{useEffect as d1,useState as As}from"react";var Pt=t=>{let e=t1(23),[o]=r1(),[r,n]=As(null),[l,s]=As(!1),[i,d,c]=n1(t),{closeDrawer:u,drawerSlug:a,isDrawerOpen:m,openDrawer:p}=c,{modalState:h}=l1(),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let I=a1()??i1();n(I)},e[0]=f):f=e[0];let g=f,k;e[1]!==o||e[2]!==r?(k=()=>{r&&o.update(()=>{if(c1(r)){let{anchor:I,focus:y}=r;Os(I.key)&&Os(y.key)&&u1(r.clone())}else s1().selectEnd()},{discrete:!0,skipTransforms:!0})},e[1]=o,e[2]=r,e[3]=k):k=e[3];let N=k,R;e[4]!==u?(R=()=>{u()},e[4]=u,e[5]=R):R=e[5];let T=R,C,x;e[6]!==a||e[7]!==h||e[8]!==N||e[9]!==l?(C=()=>{if(!l)return;let I=h[a];I&&!I?.isOpen&&(s(!1),setTimeout(()=>{N()},1))},x=[h,a,N,l],e[6]=a,e[7]=h,e[8]=N,e[9]=l,e[10]=C,e[11]=x):(C=e[10],x=e[11]),d1(C,x);let b;e[12]!==d?(b=I=>o1(d,{...I,onClick:()=>{g()}}),e[12]=d,e[13]=b):b=e[13];let _;e[14]!==p?(_=()=>{g(),p(),s(!0)},e[14]=p,e[15]=_):_=e[15];let D;return e[16]!==i||e[17]!==T||e[18]!==m||e[19]!==a||e[20]!==b||e[21]!==_?(D={closeListDrawer:T,isListDrawerOpen:m,ListDrawer:i,listDrawerSlug:a,ListDrawerToggler:b,openListDrawer:_},e[16]=i,e[17]=T,e[18]=m,e[19]=a,e[20]=b,e[21]=_,e[22]=D):D=e[22],D};var h1=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=p1(o);n&&n.replace(We({relationTo:e,value:r}))}):t.dispatchCommand(Dr,{relationTo:e,value:r})},g1=t=>{let e=Fs(14),{enabledCollectionSlugs:o}=t,[r]=Ps(),[n,l]=f1(null),s=o?.[0],i;e[0]!==o||e[1]!==s?(i={collectionSlugs:o,selectedCollection:s},e[0]=o,e[1]=s,e[2]=i):i=e[2];let{closeListDrawer:d,ListDrawer:c,openListDrawer:u}=Pt(i),a,m;e[3]!==r||e[4]!==u?(a=()=>r.registerCommand(Xe,g=>(l(g?.replace?g?.replace.nodeKey:null),u(),!0),Bs),m=[r,u],e[3]=r,e[4]=u,e[5]=a,e[6]=m):(a=e[5],m=e[6]),js(a,m);let p;e[7]!==d||e[8]!==r||e[9]!==n?(p=g=>{let{collectionSlug:k,doc:N}=g;h1({editor:r,relationTo:k,replaceNodeKey:n,value:N.id}),d()},e[7]=d,e[8]=r,e[9]=n,e[10]=p):p=e[10];let h=p,f;return e[11]!==c||e[12]!==h?(f=Mr(c,{onSelect:h}),e[11]=c,e[12]=h,e[13]=f):f=e[13],f},x1=()=>{let t=Fs(3),[e]=Ps(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Xe,C1,Bs),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),js(o,r),null},Hs=({enabledCollectionSlugs:t})=>t?.length?Mr(g1,{enabledCollectionSlugs:t}):Mr(x1,{});function C1(){return m1.error("No relationship collections enabled"),!0}import{useConfig as b1,useEntityVisibility as k1}from"@payloadcms/ui";import*as Us from"react";var ko=t=>{let{collectionSlugsBlacklist:e,collectionSlugsWhitelist:o,uploads:r=!1}=t||{},{config:{collections:n}}=b1(),{visibleEntities:l}=k1();return Us.useMemo(()=>{let i=[],d=[],c=o?new Set(o):null,u=e?new Set(e):null;for(let a of n){let{slug:m,admin:{enableRichTextRelationship:p},upload:h}=a;if(l?.collections.includes(m)){if(r){if(!p||!h)continue}else if(h||!p)continue;c&&!c.has(m)||u&&u.has(m)||(i.push(m),d.push(a))}}return{enabledCollections:d,enabledCollectionSlugs:i}},[n,l,r,o,e])};var Dr=I1("INSERT_RELATIONSHIP_COMMAND"),Ws=t=>{let e=_1(8),{clientProps:o}=t,[r]=w1(),n=o?.disabledCollections,l=o?.enabledCollections,s;e[0]!==n||e[1]!==l?(s={collectionSlugsBlacklist:n,collectionSlugsWhitelist:l},e[0]=n,e[1]=l,e[2]=s):s=e[2];let{enabledCollectionSlugs:i}=ko(s),d,c;e[3]!==r?(d=()=>{if(!r.hasNodes([Ne]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand(Dr,M1,R1)},c=[r],e[3]=r,e[4]=d,e[5]=c):(d=e[4],c=e[5]),v1(d,c);let u;return e[6]!==i?(u=T1(Hs,{enabledCollectionSlugs:i}),e[6]=i,e[7]=u):u=e[7],u};function M1(t){let e=N1()||E1();if(y1(e)){let o=We(t),{focus:r}=e,n=r.getNode();S1(o),L1(n)&&!n.__first&&n.remove()}return!0}var $1=M({nodes:[Ne],plugins:[{Component:Ws,position:"normal"}],slashMenu:{groups:[X([{Icon:Ir,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xe,{replace:!1})}}])]},toolbarFixed:{groups:[ke([{ChildComponent:Ir,isActive:({selection:t})=>{if(!D1(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return vr(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xe,{replace:!1})}}])]}});import{c as lh}from"react/compiler-runtime";import{jsx as me,jsxs as ih}from"react/jsx-runtime";import{useLexicalComposerContext as sh}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as qs}from"@lexical/react/useLexicalEditable";import{useScrollInfo as ah,useThrottledEffect as ch,useTranslation as uh}from"@payloadcms/ui";import*as So from"react";import{useMemo as Fr}from"react";import{c as O1}from"react/compiler-runtime";import{jsx as A1}from"react/jsx-runtime";import{$addUpdateTag as F1}from"lexical";import"react";var Gs="toolbar-popup__button",Bt=t=>{let e=O1(14),{active:o,children:r,editor:n,enabled:l,item:s}=t,i=o===void 0?!1:o,d=l===void 0?!0:l,c=d?"":"disabled",u=i?"active":"",a=s.key?`${Gs}-${s.key}`:"",m;e[0]!==c||e[1]!==u||e[2]!==a?(m=[Gs,c,u,a].filter(Boolean),e[0]=c,e[1]=u,e[2]=a,e[3]=m):m=e[3];let p=m.join(" "),h;e[4]!==i||e[5]!==n||e[6]!==d||e[7]!==s?(h=()=>{d&&n.focus(()=>{n.update(P1),s.onSelect?.({editor:n,isActive:i})})},e[4]=i,e[5]=n,e[6]=d,e[7]=s,e[8]=h):h=e[8];let f=h,g=B1,k;return e[9]!==r||e[10]!==p||e[11]!==f||e[12]!==s.key?(k=A1("button",{className:p,"data-button-key":s.key,onClick:f,onMouseDown:g,type:"button",children:r}),e[9]=r,e[10]=p,e[11]=f,e[12]=s.key,e[13]=k):k=e[13],k};function P1(){F1("toolbar")}function B1(t){t.preventDefault()}import{c as J1}from"react/compiler-runtime";import{jsx as st}from"react/jsx-runtime";import K1,{useMemo as X1}from"react";import{useTranslation as z1}from"@payloadcms/ui";import{jsx as Me,jsxs as Vs}from"react/jsx-runtime";import{Button as j1}from"@payloadcms/ui";import{$addUpdateTag as H1,isDOMNode as U1}from"lexical";import _o,{useCallback as W1,useEffect as To,useMemo as Ks,useRef as $r,useState as Or}from"react";import{createPortal as G1}from"react-dom";var Js="toolbar-popup__dropdown-item",Xs=_o.createContext(null);function zs({active:t,children:e,editor:o,enabled:r,Icon:n,item:l,itemKey:s,tooltip:i}){let d=Ks(()=>[Js,r===!1?"disabled":"",t?"active":"",l?.key?`${Js}-${l.key}`:""].filter(Boolean).join(" "),[r,t,l.key]),c=$r(null),u=_o.use(Xs);if(u===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:a}=u;return To(()=>{c?.current!=null&&a(c)},[c,a]),Me(j1,{"aria-label":i,buttonStyle:"none",className:d,disabled:r===!1,extraButtonProps:{"data-item-key":s},icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{H1("toolbar")}),l.onSelect?.({editor:o,isActive:t})})},onMouseDown:m=>{m.preventDefault()},ref:c,tooltip:i,type:"button",children:e})}function V1({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,l]=Or(),[s,i]=Or(),d=W1(a=>{l(m=>m!=null?[...m,a]:[a])},[l]),c=a=>{if(n==null)return;let{key:m}=a;["ArrowDown","ArrowUp","Escape","Tab"].includes(m)&&a.preventDefault(),m==="Escape"||m==="Tab"?r():m==="ArrowUp"?i(p=>{if(p==null)return n[0];let h=n.indexOf(p)-1;return n[h===-1?n.length-1:h]}):m==="ArrowDown"&&i(p=>p==null?n[0]:n[n.indexOf(p)+1])},u=Ks(()=>({registerItem:d}),[d]);return To(()=>{n!=null&&s==null&&i(n[0]),s!=null&&s?.current!=null&&s.current.focus()},[n,s]),Me(Xs,{value:u,children:Me("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:c,ref:e,children:t})})}function Zs({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,dropdownKey:n,Icon:l,itemsContainerClassNames:s,label:i,stopCloseOnClickSelf:d}){let c=$r(null),u=$r(null),[a,m]=Or(!1),p=()=>{m(!1),u?.current!=null&&u.current.focus()};To(()=>{let f=u.current,g=c.current;if(a&&f!==null&&g!==null){let{left:k,top:N}=f.getBoundingClientRect(),R=window.scrollY||document.documentElement.scrollTop;g.style.top=`${N+R+f.offsetHeight+5}px`,g.style.left=`${Math.min(k-5,window.innerWidth-g.offsetWidth-20)}px`}},[c,u,a]),To(()=>{let f=u.current;if(f!==null&&a){let g=k=>{let N=k.target;U1(N)&&(d&&c.current&&c.current.contains(N)||f.contains(N)||m(!1))};return document.addEventListener("click",g),()=>{document.removeEventListener("click",g)}}},[c,u,a,d]);let h=G1(Me(V1,{dropDownRef:c,itemsContainerClassNames:s,onClose:p,children:o}),document.body);return Vs(_o.Fragment,{children:[Vs("button",{"aria-label":t,className:e+(a?" active":""),"data-dropdown-key":n,disabled:r,onClick:f=>{f.preventDefault(),m(!a)},onMouseDown:f=>{f.preventDefault()},ref:u,type:"button",children:[l&&Me(l,{}),i&&Me("span",{className:"toolbar-popup__dropdown-label",children:i}),Me("i",{className:"toolbar-popup__dropdown-caret"})]}),a&&Me(_o.Fragment,{children:h})]})}var Ar="toolbar-popup__dropdown",Z1=t=>{let e=J1(14),{active:o,anchorElem:r,editor:n,enabled:l,item:s}=t,{i18n:i}=z1(),{fieldProps:d}=U(),{featureClientSchemaMap:c,schemaPath:u}=d;if(s.Component){let m;return e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==s?(m=s?.Component&&st(s.Component,{active:o,anchorElem:r,editor:n,enabled:l,item:s},s.key),e[0]=o,e[1]=r,e[2]=n,e[3]=l,e[4]=s,e[5]=m):m=e[5],m}let a;if(e[6]!==o||e[7]!==n||e[8]!==l||e[9]!==c||e[10]!==i||e[11]!==s||e[12]!==u){let m=s.key,p;s.label&&(m=typeof s.label=="function"?s.label({featureClientSchemaMap:c,i18n:i,schemaPath:u}):s.label),m.length>25?p=m.substring(0,25)+"...":p=m,a=st(zs,{active:o,editor:n,enabled:l,Icon:s?.ChildComponent?st(s.ChildComponent,{}):void 0,item:s,itemKey:s.key,tooltip:m,children:st("span",{className:"text",children:p})},s.key),e[6]=o,e[7]=n,e[8]=l,e[9]=c,e[10]=i,e[11]=s,e[12]=u,e[13]=a}else a=e[13];return a},Y1=K1.memo(Z1),jt=({anchorElem:t,classNames:e,editor:o,group:r,groupState:n,Icon:l,itemsContainerClassNames:s,label:i})=>{let{items:d,key:c}=r,u=X1(()=>d?.length?d.map(a=>st(Y1,{active:n.activeItemKeys.includes(a.key),anchorElem:t,editor:o,enabled:n.enabledItemKeys.includes(a.key),item:a},a.key)):null,[d,n.activeItemKeys,n.enabledItemKeys,t,o]);return st(Zs,{buttonAriaLabel:`${c} dropdown`,buttonClassName:[Ar,`${Ar}-${c}`,...e||[]].filter(Boolean).join(" "),disabled:!n.enabledGroup,dropdownKey:c,Icon:l,itemsContainerClassNames:[`${Ar}-items`,...s||[]],label:i,children:u},c)};import{mergeRegister as q1}from"@lexical/utils";import{$getSelection as Q1}from"lexical";import{useCallback as eh,useDeferredValue as th,useEffect as oh,useRef as Ys,useState as rh}from"react";function nh(t){let e=new Map,o=new Map;if(!t?.length)return{groupStates:o,itemStates:e};for(let r of t){let n=[];for(let l of r.items)e.set(l.key,{active:!1,enabled:!0}),n.push(l.key);o.set(r.key,{activeItemKeys:[],activeItems:[],enabledGroup:!0,enabledItemKeys:n})}return{groupStates:o,itemStates:e}}function wo(t,e){let[o,r]=rh(()=>nh(e)),n=th(o),l=U(),s=Ys(l);s.current=l;let i=Ys(e);i.current=e;let d=gn(),c=eh(()=>{t.getEditorState().read(()=>{let u=Q1();if(!u)return;let a=i.current;if(!a?.length)return;let m=s.current,p=new Map,h=new Map;for(let f of a){let g=[],k=[],N=[],R=f.type==="dropdown"?f.maxActiveItems??1:void 0;for(let C of f.items){let x=C.isActive?(!R||g.length<R)&&C.isActive({editor:t,editorConfigContext:m,selection:u}):!1,b=C.isEnabled?C.isEnabled({editor:t,editorConfigContext:m,selection:u}):!0;x&&(g.push(C.key),k.push(C)),b&&N.push(C.key),p.set(C.key,{active:x,enabled:b})}let T=f.type==="dropdown"&&f.isEnabled?f.isEnabled({editor:t,editorConfigContext:m,selection:u}):!0;h.set(f.key,{activeItemKeys:g,activeItems:k,enabledGroup:T,enabledItemKeys:N})}r({groupStates:h,itemStates:p})})},[t]);return oh(()=>{d(c);let u=()=>d(c),a=q1(t.registerUpdateListener(u));return document.addEventListener("mouseup",u),()=>{a(),document.removeEventListener("mouseup",u)}},[t,d,c]),n}function dh({active:t,anchorElem:e,editor:o,enabled:r,item:n}){return n.Component?n?.Component&&me(n.Component,{anchorElem:e,editor:o,item:n},n.key):n.ChildComponent?me(Bt,{active:t,editor:o,enabled:r,item:n,children:me(n.ChildComponent,{})},n.key):null}function mh({anchorElem:t,editor:e,editorConfig:o,group:r,index:n,toolbarStates:l}){let{i18n:s}=uh(),{fieldProps:{featureClientSchemaMap:i,schemaPath:d}}=U(),c=l.groupStates.get(r.key),u=Fr(()=>{if(r.type!=="dropdown")return;let m=c?.activeItems?.[0];return m?m.ChildComponent:r.ChildComponent},[r,c?.activeItems]),a=Fr(()=>{if(r.type!=="dropdown")return;let m=c?.activeItems;if(!m?.length)return;if(m.length>1)return s.t("lexical:general:toolbarItemsActive",{count:m.length});let p=m[0],h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:i,i18n:s,schemaPath:d}):p.label),h.length>25&&(h=h.substring(0,25)+"..."),h},[r,c?.activeItems,s,i,d]);return ih("div",{className:`fixed-toolbar__group fixed-toolbar__group-${r.key}`,"data-toolbar-group-key":r.key,children:[r.type==="dropdown"&&r.items.length&&c?me(jt,{anchorElem:t,editor:e,group:r,groupState:c,Icon:u,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a}):null,r.type==="buttons"&&r.items.length?r.items.map(m=>{let p=l.itemStates.get(m.key);return me(dh,{active:p?.active??!1,anchorElem:t,editor:e,enabled:p?.enabled??!0,item:m},m.key)}):null,n<o.features.toolbarFixed?.groups.length-1&&me("div",{className:"divider"})]},r.key)}function ph({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let l=So.useRef(null),s=qs(),{y:i}=ah(),d=wo(o,r?.features?.toolbarFixed?.groups),c=Fr(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let a=n.editorContainerRef.current.previousElementSibling;for(;a;){if(a.classList.contains("fixed-toolbar"))return a;a=a.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return ch(()=>{if(!c)return;let u=l.current;if(!u)return;let a=u.getBoundingClientRect(),m=c.getBoundingClientRect();if(!(a.bottom<m.top||a.top>m.bottom))u.classList.remove("fixed-toolbar"),u.classList.add("fixed-toolbar","fixed-toolbar--overlapping"),c.classList.remove("fixed-toolbar"),c.classList.add("fixed-toolbar","fixed-toolbar--hide");else{if(!u.classList.contains("fixed-toolbar--overlapping"))return;u.classList.remove("fixed-toolbar--overlapping"),u.classList.add("fixed-toolbar"),c.classList.remove("fixed-toolbar--hide"),c.classList.add("fixed-toolbar")}},50,[l,c,i]),me("div",{className:"fixed-toolbar",onFocus:u=>{u.stopPropagation()},ref:l,children:s&&me(So.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((u,a)=>me(mh,{anchorElem:t,editor:o,editorConfig:r,group:u,index:a,toolbarStates:d},u.key))})})}var Qs=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return Qs(t.parentEditor)}return!1},ea=t=>{let e=lh(6),{clientProps:o}=t,[r]=sh(),n=U();if(!qs())return null;let{editorConfig:s}=n,i=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,d=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||s,c,u;if(e[0]!==o||e[1]!==i||e[2]!==d||e[3]!==n){u=Symbol.for("react.early_return_sentinel");e:{let a=Qs(n);if(o?.disableIfParentHasFixedToolbar&&a){u=null;break e}if(!d?.features?.toolbarFixed?.groups?.length){u=null;break e}c=me(ph,{anchorElem:document.body,clientProps:o,editor:i,editorConfig:d,parentWithFixedToolbar:a})}e[0]=o,e[1]=i,e[2]=d,e[3]=n,e[4]=c,e[5]=u}else c=e[4],u=e[5];return u!==Symbol.for("react.early_return_sentinel")?u:c};var fh=M({plugins:[{Component:ea,position:"aboveContainer"}]});import{c as hh}from"react/compiler-runtime";import{jsx as Le,jsxs as ra}from"react/jsx-runtime";import{useLexicalComposerContext as gh}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as xh}from"@lexical/react/useLexicalEditable";import{mergeRegister as na}from"@lexical/utils";import{$getSelection as la,$isRangeSelection as ta,$isTextNode as Ch,COMMAND_PRIORITY_LOW as bh,getDOMSelection as ia,SELECTION_CHANGE_COMMAND as kh}from"lexical";import{useCallback as No,useEffect as Ht,useMemo as _h,useRef as oa,useState as Th}from"react";import"react";import{createPortal as wh}from"react-dom";function Pr(t,e){let o=t.getRangeAt(0),r;if(t.anchorNode===e){let n=e;for(;n.firstElementChild!=null;)n=n.firstElementChild;r=n.getBoundingClientRect()}else r=o.getBoundingClientRect();return r}function Eo(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:l=32,horizontalPosition:s="left",specialHandlingForCaret:i=!1,targetRect:d,verticalGap:c=10}=t,u=o.parentElement;if(d===null||u==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let a=n.getBoundingClientRect(),m=o.getBoundingClientRect(),p=u.getBoundingClientRect(),h=d.top-a.height-c,f=d.left-l;s==="center"&&(f=d.left+d.width/2-a.width/2);let g=0;return!e&&h<p.top&&!i&&(g=a.height+d.height+c*2,h+=g),s==="center"?f+a.width>p.right?f=p.right-a.width-l:f<p.left&&(f=p.left+l):f+a.width>p.right&&(f=p.right-a.width-l),f-=m.left,n.style.opacity="1",i&&r!==0?(h-=m.bottom-r+a.height-3,n.style.transform=`translate(${f}px, ${h}px) rotate(180deg)`):(h-=m.top,n.style.transform=`translate(${f}px, ${h}px)`),g}function Sh({active:t,anchorElem:e,editor:o,enabled:r,item:n}){return n.Component?n?.Component&&Le(n.Component,{anchorElem:e,editor:o,item:n},n.key):n.ChildComponent?Le(Bt,{active:t,editor:o,enabled:r,item:n,children:Le(n.ChildComponent,{})},n.key):null}function Eh({anchorElem:t,editor:e,group:o,index:r,toolbarStates:n}){let{editorConfig:l}=U(),s=n.groupStates.get(o.key),i=_h(()=>o.type!=="dropdown"?void 0:s?.activeItems?.[0]?.ChildComponent??o.ChildComponent,[o,s?.activeItems]);return ra("div",{className:`inline-toolbar-popup__group inline-toolbar-popup__group-${o.key}`,"data-toolbar-group-key":o.key,children:[o.type==="dropdown"&&o.items.length&&s?Le(jt,{anchorElem:t,editor:e,group:o,groupState:s,Icon:i}):null,o.type==="buttons"&&o.items.length?o.items.map(d=>{let c=n.itemStates.get(d.key);return Le(Sh,{active:c?.active??!1,anchorElem:t,editor:e,enabled:c?.enabled??!0,item:d},d.key)}):null,r<l.features.toolbarInline?.groups.length-1&&Le("div",{className:"divider"})]},o.key)}function Nh({anchorElem:t,editor:e}){let o=oa(null),r=oa(null),{editorConfig:n}=U(),l=wo(e,n?.features?.toolbarInline?.groups),s=No(()=>{if(o?.current){let u=o.current.style.opacity==="0",a=o.current.style.pointerEvents==="none";u||(o.current.style.opacity="0"),a||(o.current.style.pointerEvents="none")}},[o]),i=No(u=>{if(o?.current&&(u.buttons===1||u.buttons===3)){let a=o.current.style.opacity==="0",m=o.current.style.pointerEvents==="none";if(!a||!m){let p=u.clientX,h=u.clientY,f=document.elementFromPoint(p,h);o.current.contains(f)||s()}}},[s]),d=No(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);Ht(()=>(document.addEventListener("mousemove",i),document.addEventListener("mouseup",d),()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",d)}),[o,i,d]);let c=No(()=>{let u=la(),a=ia(e._window);if(o.current===null)return;let m=t.querySelector(":scope > .link-editor"),p=m!==null&&"style"in m&&m?.style?.opacity==="1",h=e.getRootElement();if(u!==null&&a!==null&&!a.isCollapsed&&h!==null&&h.contains(a.anchorNode)){let f=Pr(a,h),g=Eo({alwaysDisplayOnTop:p,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&Eo({anchorElem:o.current,anchorFlippedOffset:g,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else s()},[e,s,t]);return Ht(()=>{let u=t.parentElement,a=()=>{e.getEditorState().read(()=>{c()})};return window.addEventListener("resize",a),u&&u.addEventListener("scroll",a),()=>{window.removeEventListener("resize",a),u&&u.removeEventListener("scroll",a)}},[e,c,t]),Ht(()=>(e.getEditorState().read(()=>{c()}),na(e.registerUpdateListener(({editorState:u})=>{u.read(()=>{c()})}),e.registerCommand(kh,()=>(c(),!1),bh))),[e,c]),ra("div",{className:"inline-toolbar-popup",ref:o,children:[Le("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((u,a)=>Le(Eh,{anchorElem:t,editor:e,group:u,index:a,toolbarStates:l},u.key))]})}function Lh(t,e){let o=hh(12),[r,n]=Th(!1),l=xh(),s;o[0]!==t?(s=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let p=la(),h=ia(t._window),f=t.getRootElement();if(h!==null&&(!ta(p)||f===null||!f.contains(h.anchorNode))){n(!1);return}if(!ta(p))return;if(p.getTextContent()!==""){let k=p.getNodes(),N=!1;for(let R of k)if(Ch(R)){n(!0),N=!0;break}N||n(!1)}else n(!1);let g=p.getTextContent().replace(/\n/g,"");if(!p.isCollapsed()&&g===""){n(!1);return}})},o[0]=t,o[1]=s):s=o[1];let i=s,d,c;o[2]!==i?(d=()=>(document.addEventListener("selectionchange",i),document.addEventListener("mouseup",i),()=>{document.removeEventListener("selectionchange",i),document.removeEventListener("mouseup",i)}),c=[i],o[2]=i,o[3]=d,o[4]=c):(d=o[3],c=o[4]),Ht(d,c);let u,a;if(o[5]!==t||o[6]!==i?(u=()=>na(t.registerUpdateListener(()=>{i()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),a=[t,i],o[5]=t,o[6]=i,o[7]=u,o[8]=a):(u=o[7],a=o[8]),Ht(u,a),!r||!l)return null;let m;return o[9]!==e||o[10]!==t?(m=wh(Le(Nh,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=m):m=o[11],m}var sa=t=>{let{anchorElem:e}=t,[o]=gh();return Lh(o,e)};var yh=M({plugins:[{Component:sa,position:"floatingAnchorElem"}]});import{TableCellNode as xx,TableNode as Cx,TableRowNode as bx}from"@lexical/table";import{jsx as aa}from"react/jsx-runtime";import"react";var Br=()=>aa("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:aa("path",{clipRule:"evenodd",d:"M5.33333 4.5C4.8731 4.5 4.5 4.8731 4.5 5.33333V7.5H9.5V4.5H5.33333ZM5.33333 3.5C4.32081 3.5 3.5 4.32081 3.5 5.33333V14.6667C3.5 15.6792 4.32081 16.5 5.33333 16.5H14.6667C15.6792 16.5 16.5 15.6792 16.5 14.6667V5.33333C16.5 4.32081 15.6792 3.5 14.6667 3.5H5.33333ZM10.5 4.5V7.5H15.5V5.33333C15.5 4.8731 15.1269 4.5 14.6667 4.5H10.5ZM15.5 8.5H10.5V11.5H15.5V8.5ZM15.5 12.5H10.5V15.5H14.6667C15.1269 15.5 15.5 15.1269 15.5 14.6667V12.5ZM9.5 15.5V12.5H4.5V14.6667C4.5 15.1269 4.8731 15.5 5.33333 15.5H9.5ZM4.5 11.5H9.5V8.5H4.5V11.5Z",fill:"currentColor",fillRule:"evenodd"})});import{$createTableCellNode as Rh,$createTableNode as Ih,$createTableRowNode as vh,$isTableCellNode as ca,$isTableNode as jr,$isTableRowNode as Hr,TableCellHeaderStates as Lo,TableCellNode as Mh,TableNode as Dh,TableRowNode as $h}from"@lexical/table";import{$isParagraphNode as Oh,$isTextNode as Ah}from"lexical";var da=/^\|(.+)\|\s?$/,Fh=/^(\| ?:?-*:? ?)+\|\s?$/,ma=({allTransformers:t})=>({type:"element",dependencies:[Dh,$h,Mh],export:e=>{if(!jr(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!Hr(r))continue;let l=!1;for(let s of r.getChildren())ca(s)&&(n.push(zt(t,s).replace(/\n/g,"\\n").trim()),s.__headerState===Lo.ROW&&(l=!0));o.push(`| ${n.join(" | ")} |`),l&&o.push(`| ${n.map(s=>"---").join(" | ")} |`)}return o.join(`
59
59
  `)},regExp:da,replace:(e,o,r)=>{let n=r[0];if(!n)return;if(Fh.test(n)){let a=e.getPreviousSibling();if(!a||!jr(a))return;let m=a.getChildren(),p=m[m.length-1];if(!p||!Hr(p))return;p.getChildren().forEach(h=>{ca(h)&&h.setHeaderStyles(Lo.ROW,Lo.ROW)}),e.remove();return}let l=ua(n,t);if(l==null)return;let s=[l],i=e.getPreviousSibling(),d=l.length;for(;i&&!(!Oh(i)||i.getChildrenSize()!==1);){let a=i.getFirstChild();if(!Ah(a))break;let m=ua(a.getTextContent(),t);if(m==null)break;d=Math.max(d,m.length),s.unshift(m);let p=i.getPreviousSibling();i.remove(),i=p}let c=Ih();for(let a of s){let m=vh();c.append(m);for(let p=0;p<d;p++)m.append(p<a.length?a[p]:pa("",t))}let u=e.getPreviousSibling();jr(u)&&Ph(u)===d?(u.append(...c.getChildren()),e.remove()):e.replace(c),c.selectEnd()}});function Ph(t){let e=t.getFirstChild();return Hr(e)?e.getChildrenSize():0}var pa=(t,e)=>{t=t.replace(/\\n/g,`
60
- `);let o=Rh(Lo.NO_STATUS);return Xt(t,e,o),o},ua=(t,e)=>{let o=t.match(da);return!o||!o[1]?null:o[1].split("|").map(r=>pa(r,e))};import{c as jh}from"react/compiler-runtime";import{jsx as B,jsxs as ye}from"react/jsx-runtime";import{useLexicalComposerContext as Ca}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Hh}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as ha,$deleteTableColumnAtSelection as Uh,$deleteTableRowAtSelection as Wh,$getNodeTriplet as Gh,$getTableCellNodeFromLexicalNode as ga,$getTableColumnIndexFromTableCellNode as Vh,$getTableNodeFromLexicalNodeOrThrow as $e,$getTableRowIndexFromTableCellNode as Jh,$insertTableColumnAtSelection as Kh,$insertTableRowAtSelection as Xh,$isTableCellNode as ba,$isTableSelection as Ut,$mergeCells as zh,$unmergeCell as Zh,getTableElement as Wr,getTableObserverFromTableElement as Gr,TableCellHeaderStates as De,TableCellNode as Yh}from"@lexical/table";import{mergeRegister as qh}from"@lexical/utils";import{useScrollInfo as Qh}from"@payloadcms/ui";import{$getSelection as Ro,$isElementNode as eg,$isRangeSelection as Vr,$isTextNode as tg,$setSelection as og,COMMAND_PRIORITY_CRITICAL as rg,getDOMSelection as ng,isDOMNode as lg,SELECTION_CHANGE_COMMAND as ig}from"lexical";import*as Jr from"react";import{useCallback as ce,useEffect as at,useRef as yo,useState as ct}from"react";import{createPortal as ka}from"react-dom";import{jsx as Ur,jsxs as Bh}from"react/jsx-runtime";import"react";var fa=()=>Bh("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Ur("path",{d:"M5 11C5.55228 11 6 10.5523 6 10C6 9.44772 5.55228 9 5 9C4.44772 9 4 9.44772 4 10C4 10.5523 4.44772 11 5 11Z",fill:"currentColor"}),Ur("path",{d:"M10 11C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9C9.44772 9 9 9.44772 9 10C9 10.5523 9.44772 11 10 11Z",fill:"currentColor"}),Ur("path",{d:"M15 11C15.5523 11 16 10.5523 16 10C16 9.44772 15.5523 9 15 9C14.4477 9 14 9.44772 14 10C14 10.5523 14.4477 11 15 11Z",fill:"currentColor"})]});function xa(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function sg(){let t=Ro();if(Vr(t)&&!t.isCollapsed()||Ut(t)&&!t.anchor.is(t.focus)||!Vr(t)&&!Ut(t))return!1;let[e]=Gh(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function ag(t){let e=t.getLastDescendant();tg(e)?e.select():eg(e)?e.selectEnd():e!==null&&e.selectNext()}function cg({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[l]=Ca(),s=yo(null),[i,d]=ct(n),[c,u]=ct({columns:1,rows:1}),[a,m]=ct(!1),[p,h]=ct(!1),{y:f}=Qh();at(()=>l.registerMutationListener(Yh,w=>{w.get(i.getKey())==="updated"&&l.getEditorState().read(()=>{d(i.getLatest())})},{skipInitialization:!0}),[l,i]),at(()=>{l.getEditorState().read(()=>{let w=Ro();if(Ut(w)){let L=xa(w);u(xa(w)),m(L.columns>1||L.rows>1)}h(sg())})},[l]),at(()=>{let w=e.current,L=s.current,E=l.getRootElement();if(w!=null&&L!=null&&E!=null){let v=E.getBoundingClientRect(),$=w.getBoundingClientRect();L.style.opacity="1";let O=L.getBoundingClientRect(),F=5,P=$.right+F;if(P+O.width>window.innerWidth||P+O.width>v.right){let K=$.left-O.width-F;P=(K<0?F:K)+window.pageXOffset}L.style.left=`${P+window.pageXOffset}px`;let Z=$.top;if(Z+O.height>window.innerHeight){let K=$.bottom-O.height;Z=K<0?F:K}L.style.top=`${Z}px`}},[e,s,l,f]),at(()=>{function w(L){s.current!=null&&e.current!=null&&lg(L.target)&&!s.current.contains(L.target)&&!e.current.contains(L.target)&&r(!1)}return window.addEventListener("click",w),()=>window.removeEventListener("click",w)},[r,e]);let g=ce(()=>{l.update(()=>{if(i.isAttached()){let w=$e(i),L=Wr(w,l.getElementByKey(w.getKey()));if(L===null)throw new Error("Expected to find tableElement in DOM");let E=Gr(L);E!==null&&E.$clearHighlight(),w.markDirty(),d(i.getLatest())}og(null)})},[l,i]),k=()=>{l.update(()=>{let w=Ro();if(!Ut(w))return;let E=w.getNodes().filter(ba),v=zh(E);v&&(ag(v),o())})},N=()=>{l.update(()=>{Zh()})},R=ce(w=>{l.update(()=>{for(let L=0;L<c.rows;L++)Xh(w);o()})},[l,o,c.rows]),T=ce(w=>{l.update(()=>{for(let L=0;L<c.columns;L++)Kh(w);o()})},[l,o,c.columns]),C=ce(()=>{l.update(()=>{Wh(),o()})},[l,o]),x=ce(()=>{l.update(()=>{$e(i).remove(),g(),o()})},[l,i,g,o]),b=ce(()=>{l.update(()=>{Uh(),o()})},[l,o]),_=ce(()=>{l.update(()=>{let w=$e(i),L=Jh(i),[E]=ha(w,null,null),v=new Set,$=i.getHeaderStyles()^De.ROW;if(E[L])for(let O=0;O<E[L].length;O++){let F=E[L][O];F?.cell&&(v.has(F.cell)||(v.add(F.cell),F.cell.setHeaderStyles($,De.ROW)))}g(),o()})},[l,i,g,o]),D=ce(()=>{l.update(()=>{let w=$e(i),L=Vh(i),[E]=ha(w,null,null),v=new Set,$=i.getHeaderStyles()^De.COLUMN;if(E)for(let O=0;O<E.length;O++){let F=E?.[O]?.[L];F?.cell&&(v.has(F.cell)||(v.add(F.cell),F.cell.setHeaderStyles($,De.COLUMN)))}g(),o()})},[l,i,g,o]),I=ce(()=>{l.update(()=>{if(i.isAttached()){let w=$e(i);w&&w.setRowStriping(!w.getRowStriping())}g(),o()})},[l,i,g,o]),y=ce(()=>{l.update(()=>{if(i.isAttached()){let w=$e(i);w&&w.setFrozenColumns(w.getFrozenColumns()===0?1:0)}g(),o()})},[l,i,g,o]),S=null;return t&&(a?S=B("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>k(),type:"button",children:B("span",{className:"text",children:"Merge cells"})}):p&&(S=B("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>N(),type:"button",children:B("span",{className:"text",children:"Unmerge cells"})}))),ka(ye("div",{className:"table-action-menu-dropdown",onClick:w=>{w.stopPropagation()},ref:s,children:[S?ye(Jr.Fragment,{children:[S,B("hr",{})]}):null,B("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>I(),type:"button",children:B("span",{className:"text",children:"Toggle Row Striping"})}),B("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>y(),type:"button",children:B("span",{className:"text",children:"Toggle First Column Freeze"})}),B("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>R(!1),type:"button",children:ye("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),B("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>R(!0),type:"button",children:ye("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>T(!1),type:"button",children:ye("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),B("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>T(!0),type:"button",children:ye("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>b(),type:"button",children:B("span",{className:"text",children:"Delete column"})}),B("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>C(),type:"button",children:B("span",{className:"text",children:"Delete row"})}),B("button",{className:"item","data-test-id":"table-delete",onClick:()=>x(),type:"button",children:B("span",{className:"text",children:"Delete table"})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-row-header",onClick:()=>_(),type:"button",children:ye("span",{className:"text",children:[(i.__headerState&De.ROW)===De.ROW?"Remove":"Add"," ","row header"]})}),B("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:ye("span",{className:"text",children:[(i.__headerState&De.COLUMN)===De.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function ug({anchorElem:t,cellMerge:e}){let[o]=Ca(),r=yo(null),n=yo(null),[l,s]=ct(!1),[i,d]=ct(null),c=ce(()=>{let a=r.current,m=Ro(),p=ng(o._window),h=document.activeElement;function f(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),d(null)}if(m==null||a==null)return f();let g=o.getRootElement(),k=null,N=null;if(Vr(m)&&g!==null&&p!==null&&g.contains(p.anchorNode)){let T=ga(m.anchor.getNode());if(T==null||(N=o.getElementByKey(T.getKey()),N==null||!T.isAttached()))return f();let C=$e(T),x=Wr(C,o.getElementByKey(C.getKey()));if(x===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");k=Gr(x),d(T)}else if(Ut(m)){let T=ga(m.anchor.getNode());if(!ba(T))throw new Error("TableSelection anchorNode must be a TableCellNode");let C=$e(T),x=Wr(C,o.getElementByKey(C.getKey()));if(x===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");k=Gr(x),N=o.getElementByKey(T.getKey())}else if(!h)return f();if(k===null||N===null)return f();let R=!k||!k.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",R),a.classList.toggle("table-cell-action-button-container--inactive",!R),R){let T=N.getBoundingClientRect(),C=t.getBoundingClientRect(),x=T.top-C.top,b=T.right-C.left;a.style.transform=`translate(${b}px, ${x}px)`}},[o,t]);at(()=>{let a,m=()=>{a=void 0,o.getEditorState().read(c)},p=()=>(a===void 0&&(a=setTimeout(m,0)),!1);return qh(o.registerUpdateListener(p),o.registerCommand(ig,p,rg),o.registerRootListener((h,f)=>{f&&f.removeEventListener("pointerup",p),h&&(h.addEventListener("pointerup",p),p())}),()=>clearTimeout(a))});let u=yo(i);return at(()=>{u.current!==i&&s(!1),u.current=i},[u,i]),B("div",{className:"table-cell-action-button-container",ref:r,children:i!=null&&ye(Jr.Fragment,{children:[B("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),s(!l)},ref:n,type:"button",children:B(fa,{})}),l&&B(cg,{cellMerge:e,contextRef:n,onClose:()=>s(!1),setIsMenuOpen:s,tableCellNode:i})]})})}var _a=t=>{let e=jh(3),{anchorElem:o}=t,r=Hh(),n;return e[0]!==o||e[1]!==r?(n=ka(r?B(ug,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as dg}from"react/compiler-runtime";import{jsx as vo,jsxs as mg}from"react/jsx-runtime";import{useLexicalComposerContext as pg}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as fg}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as hg,$getTableNodeFromLexicalNodeOrThrow as Kr,$getTableRowIndexFromTableCellNode as gg,$isTableCellNode as Ta,$isTableRowNode as xg,getDOMCellFromTarget as Cg,getTableElement as bg,TableNode as wa}from"@lexical/table";import{calculateZoomLevel as Sa,mergeRegister as kg}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Xr,isHTMLElement as _g,SKIP_SCROLL_INTO_VIEW_TAG as Ea}from"lexical";import*as La from"react";import{useCallback as Wt,useEffect as zr,useRef as Io,useState as ut}from"react";import{createPortal as Tg}from"react-dom";var wg=33,Na=92;function Sg({editor:t}){let e=Io(null),o=Io(null),r=Io(null),[n,l]=ut(!1),s=U(),i=Io(null),[d,c]=ut(null),[u,a]=ut(null),[m,p]=ut(!1),[h,f]=ut(null),g=Wt(()=>{a(null),e.current=null,f(null),i.current=null,r.current=null},[]),k=y=>(y.buttons&1)===1;zr(()=>{let y=new Set;return kg(t.registerMutationListener(wa,S=>{for(let[w,L]of S)L==="destroyed"?y.delete(w):y.add(w);l(y.size>0)}),t.registerNodeTransform(wa,S=>{if(S.getColWidths())return S;let w=S.getColumnCount(),L=Na;return S.setColWidths(Array(w).fill(L)),S}))},[t]),zr(()=>{if(!n)return;let y=E=>{let v=E.target;if(_g(v)){if(h){c({x:E.clientX,y:E.clientY});return}if(p(k(E)),!(o.current&&o.current.contains(v))&&e.current!==v){e.current=v;let $=Cg(v);$&&u!==$?t.getEditorState().read(()=>{let O=Xr($.elem);if(!O)throw new Error("TableCellResizer: Table cell node not found.");let F=Kr(O),P=bg(F,t.getElementByKey(F.getKey()));if(!P)throw new Error("TableCellResizer: Table element not found.");e.current=v,r.current=P.getBoundingClientRect(),a($)},{editor:t}):$==null&&g()}}},S=E=>{p(!0)},w=E=>{p(!1)},L=t.registerRootListener((E,v)=>{v?.removeEventListener("mousemove",y),v?.removeEventListener("mousedown",S),v?.removeEventListener("mouseup",w),E?.addEventListener("mousemove",y),E?.addEventListener("mousedown",S),E?.addEventListener("mouseup",w)});return()=>{L()}},[u,h,t,n,g]);let N=y=>y==="bottom",R=Wt(y=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Xr(u.elem);if(!Ta(S))throw new Error("TableCellResizer: Table cell node not found.");let w=Kr(S),L=gg(S),E=w.getChildren(),$=S.getColSpan()===w.getColumnCount()?L:L+S.getRowSpan()-1;if($>=E.length||$<0)throw new Error("Expected table cell to be inside of table row.");let O=E[$];if(!xg(O))throw new Error("Expected table row");let F=O.getHeight();if(F===void 0){let Z=O.getChildren();F=Math.min(...Z.map(K=>T(K,t)??1/0))}let P=Math.max(F+y,wg);O.setHeight(P)},{tag:Ea})},[u,t]),T=(y,S)=>S.getElementByKey(y.getKey())?.clientHeight,C=(y,S)=>{let w;return S.forEach(L=>{L.forEach((E,v)=>{E.cell===y&&(w=v)})}),w},x=Wt(y=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Xr(u.elem);if(!Ta(S))throw new Error("TableCellResizer: Table cell node not found.");let w=Kr(S),[L]=hg(w,null,null),E=C(S,L);if(E===void 0)throw new Error("TableCellResizer: Table column not found.");let v=w.getColWidths();if(!v)return;let $=v[E];if($===void 0)return;let O=[...v],F=Math.max($+y,Na);O[E]=F,w.setColWidths(O)},{tag:Ea})},[u,t]),b=Wt(y=>{let S=w=>{if(w.preventDefault(),w.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:L,y:E}=i.current;if(u===null)return;let v=Sa(w.target);if(N(y)){let $=(w.clientY-E)/v;R($)}else{let $=(w.clientX-L)/v;x($)}g(),document.removeEventListener("mouseup",S)}};return S},[u,g,x,R]),_=Wt(y=>S=>{if(S.preventDefault(),S.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");i.current={x:S.clientX,y:S.clientY},c(i.current),f(y),document.addEventListener("mouseup",b(y))},[u,b]),[D,I]=ut({bottom:null,left:null,right:null,top:null});return zr(()=>{if(u){let{height:y,left:S,top:w,width:L}=u.elem.getBoundingClientRect(),E=Sa(u.elem),v=10,$={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${v}px`,left:`${window.scrollX+S}px`,top:`${window.scrollY+w+y-v/2}px`,width:`${L}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${y}px`,left:`${window.scrollX+S+L-v/2}px`,top:`${window.scrollY+w}px`,width:`${v}px`}},O=r.current;h&&d&&O&&(N(h)?($[h].left=`${window.scrollX+O.left}px`,$[h].top=`${window.scrollY+d.y/E}px`,$[h].height="3px",$[h].width=`${O.width}px`):($[h].top=`${window.scrollY+O.top}px`,$[h].left=`${window.scrollX+d.x/E}px`,$[h].width="3px",$[h].height=`${O.height}px`),$[h].backgroundColor="#adf"),I($)}else I({bottom:null,left:null,right:null,top:null})},[u,h,d]),vo("div",{ref:o,children:u!=null&&!m&&mg(La.Fragment,{children:[vo("div",{className:`${s.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:_("right"),style:D.right||void 0}),vo("div",{className:`${s.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:_("bottom"),style:D.bottom||void 0})]})})}var ya=()=>{let t=dg(3),[e]=pg(),o=fg(),r;return t[0]!==e||t[1]!==o?(r=o?Tg(vo(Sg,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],r};import{c as Mg}from"react/compiler-runtime";import{jsx as Zr,jsxs as Dg,Fragment as $g}from"react/jsx-runtime";import{useLexicalComposerContext as Og}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Aa}from"@lexical/react/useLexicalEditable";import{$getTableAndElementByKey as Ag,$getTableColumnIndexFromTableCellNode as Fg,$getTableRowIndexFromTableCellNode as Pg,$insertTableColumnAtSelection as Bg,$insertTableRowAtSelection as jg,$isTableCellNode as Hg,$isTableNode as va,getTableElement as Ug,TableNode as Wg}from"@lexical/table";import{$findMatchingParent as Gg,mergeRegister as Vg}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Ma,isHTMLElement as Jg}from"lexical";import{useEffect as Da,useMemo as Kg,useRef as $a,useState as Mo}from"react";import"react";import{createPortal as Xg}from"react-dom";import{c as Rg}from"react/compiler-runtime";import{useEffect as Ig,useRef as vg}from"react";var Eg="Expected a function",Ng=Math.max,Lg=Math.min;function yg(t,e,o){let r,n,l=0,s,i=!1,d=!1,c,u,a,m=!0;if(typeof t!="function")throw new TypeError(Eg);e=e||0,typeof o=="object"&&(i=!!o.leading,d="maxWait"in o,c=d?Ng(o.maxWait||0,e):c,m="trailing"in o?!!o.trailing:m);function p(x){let b=r,_=s;return r=s=void 0,l=x,u=t.apply(_,b),u}function h(x){return l=x,a=setTimeout(k,e),i?p(x):u}function f(x){let b=x-n,_=x-l,D=e-b;return d?Lg(D,c-_):D}function g(x){let b=x-n,_=x-l;return n===void 0||b>=e||b<0||d&&_>=c}function k(){let x=Date.now();if(g(x))return N(x);a=setTimeout(k,f(x))}function N(x){return a=void 0,m&&r?p(x):(r=s=void 0,u)}function R(){a!==void 0&&clearTimeout(a),l=0,r=n=s=a=void 0}function T(){return a===void 0?u:N(Date.now())}function C(){let x=Date.now(),b=g(x);if(r=arguments,s=this,n=x,b){if(a===void 0)return h(n);if(d)return clearTimeout(a),a=setTimeout(k,e),p(n)}return a===void 0&&(a=setTimeout(k,e)),u}return C.cancel=R,C.flush=T,C}var Ra=yg;function Ia(t,e,o){let r=Rg(6),n=vg(null),l,s;r[0]!==t||r[1]!==o||r[2]!==e?(l=()=>(n.current=Ra(t,e,{maxWait:o}),()=>{n.current?.cancel()}),s=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=l,r[4]=s):(l=r[3],s=r[4]),Ig(l,s);let i;return r[5]===Symbol.for("react.memo_cache_sentinel")?(i=(...c)=>{let u=c;n.current&&n.current(...u)},r[5]=i):i=r[5],i}var Oa=20;function zg({anchorElem:t}){let[e]=Og(),o=Aa(),r=U(),[n,l]=Mo(!1),[s,i]=Mo(!1),[d,c]=Mo(!1),[u,a]=Mo({}),m=$a(new Set),p=$a(null),h=Ia(k=>{let{isOutside:N,tableDOMNode:R}=Zg(k,r.editorConfig?.lexical);if(N){l(!1),i(!1);return}if(!R)return;p.current=R;let T=null,C=null,x=null;if(e.getEditorState().read(()=>{let $=Ma(R);if(Hg($)){let O=Gg($,F=>va(F));if(!va(O))return;if(x=Ug(O,e.getElementByKey(O.getKey())),x){let F=O.getChildrenSize(),P=O.getChildAtIndex(0)?.getChildrenSize(),Z=Pg($),K=Fg($);Z===F-1?T=$:K===P-1&&(C=$)}}},{editor:e}),!x)return;let b=x.parentElement;if(!b)return;let{bottom:_,height:D,left:I,right:y,width:S,y:w}=x.getBoundingClientRect(),L=!1;b&&b.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(L=b.scrollWidth>b.clientWidth);let{left:E,y:v}=t.getBoundingClientRect();T?(i(!1),l(!0),a({height:Oa,left:L&&b?b.offsetLeft:I-E,top:_-v+5,width:L&&b?b.offsetWidth:S})):C&&(i(!0),l(!1),a({height:D,left:y-E+5,top:w-v,width:Oa}))},50,250),f=Kg(()=>new ResizeObserver(()=>{l(!1),i(!1)}),[]);Da(()=>{if(d)return document.addEventListener("mousemove",h),()=>{l(!1),i(!1),document.removeEventListener("mousemove",h)}},[d,h]),Da(()=>Vg(e.registerMutationListener(Wg,k=>{e.getEditorState().read(()=>{let N=!1;for(let[R,T]of k)switch(T){case"created":{m.current.add(R),N=!0;break}case"destroyed":{m.current.delete(R),N=!0;break}default:break}if(N){f.disconnect();for(let R of m.current){let{tableElement:T}=Ag(R);f.observe(T)}c(m.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let g=k=>{e.update(()=>{p.current&&(Ma(p.current)?.selectEnd(),k?(jg(),l(!1)):(Bg(),i(!1)))})};return o?Dg($g,{children:[n&&Zr("button",{"aria-label":"Add Row",className:r.editorConfig.lexical.theme.tableAddRows,onClick:()=>g(!0),style:{...u},type:"button"}),s&&Zr("button",{"aria-label":"Add Column",className:r.editorConfig.lexical.theme.tableAddColumns,onClick:()=>g(!1),style:{...u},type:"button"})]}):null}function Zg(t,e){let o=t.target;if(Jg(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Fa(t){let e=Mg(2),{anchorElem:o}=t,r=o===void 0?document.body:o;if(!Aa())return null;let l;return e[0]!==r?(l=Xg(Zr(zg,{anchorElem:r}),r),e[0]=r,e[1]=l):l=e[1],l}import{c as Yg}from"react/compiler-runtime";import{jsx as Yr,jsxs as qg}from"react/jsx-runtime";import{useLexicalComposerContext as Qg}from"@lexical/react/LexicalComposerContext";import{TablePlugin as ex}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as tx,TableCellNode as ox,TableNode as rx,TableRowNode as nx}from"@lexical/table";import{mergeRegister as lx}from"@lexical/utils";import{formatDrawerSlug as ix,useEditDepth as sx}from"@payloadcms/ui";import{$getSelection as ax,$isRangeSelection as cx,COMMAND_PRIORITY_EDITOR as ux,createCommand as dx}from"lexical";import{createContext as mx,use as px,useEffect as fx,useMemo as hx,useState as gx}from"react";import*as Pa from"react";var Do=dx("OPEN_EMBED_DRAWER_COMMAND"),Ba=mx({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function ja({children:t}){let[e,o]=gx({cellEditorConfig:null,cellEditorPlugins:null});return Yr(Ba,{value:hx(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Ha=()=>{let t=Yg(16),[e]=Qg(),o=px(Ba),r=sx(),{fieldProps:n,uuid:l}=U(),{schemaPath:s}=n,i="lexical-table-create-"+l,d;t[0]!==r||t[1]!==i?(d=ix({slug:i,depth:r}),t[0]=r,t[1]=i,t[2]=d):d=t[2];let c=d,{toggleDrawer:u}=xe(c,!0),a;t[3]!==e||t[4]!==u?(a=()=>{if(!e.hasNodes([rx,nx,ox]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return lx(e.registerCommand(Do,()=>{let f=null;return e.getEditorState().read(()=>{let g=ax();cx(g)&&(f=g)}),f&&u(),!0},ux))},t[3]=e,t[4]=u,t[5]=a):a=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==u?(m=[o,e,u],t[6]=o,t[7]=e,t[8]=u,t[9]=m):m=t[9],fx(a,m);let p;t[10]!==e?(p=(f,g)=>{!g.columns||!g.rows||e.dispatchCommand(tx,{columns:String(g.columns),rows:String(g.rows)})},t[10]=e,t[11]=p):p=t[11];let h;return t[12]!==c||t[13]!==s||t[14]!==p?(h=qg(Pa.Fragment,{children:[Yr(Ct,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:s,schemaPathSuffix:"fields"}),Yr(ex,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=s,t[14]=p,t[15]=h):h=t[15],h};var kx=M({markdownTransformers:[ma],nodes:[Cx,xx,bx],plugins:[{Component:Ha,position:"normal"},{Component:ya,position:"normal"},{Component:_a,position:"floatingAnchorElem"},{Component:Fa,position:"floatingAnchorElem"}],providers:[ja],slashMenu:{groups:[X([{Icon:Br,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Do,{})}}])]},toolbarFixed:{groups:[ke([{ChildComponent:Br,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Do,{})}}])]}});import{$isNodeSelection as oC}from"lexical";import{jsx as qr,jsxs as _x}from"react/jsx-runtime";import"react";var Qr=()=>_x("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[qr("path",{d:"M14.6667 4H5.33333C4.59695 4 4 4.59695 4 5.33333V14.6667C4 15.403 4.59695 16 5.33333 16H14.6667C15.403 16 16 15.403 16 14.6667V5.33333C16 4.59695 15.403 4 14.6667 4Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),qr("path",{d:"M7.99984 9.33366C8.73622 9.33366 9.33317 8.73671 9.33317 8.00033C9.33317 7.26395 8.73622 6.66699 7.99984 6.66699C7.26346 6.66699 6.6665 7.26395 6.6665 8.00033C6.6665 8.73671 7.26346 9.33366 7.99984 9.33366Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),qr("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ja}from"react/jsx-runtime";import Ka from"bson-objectid";import{$applyNodeReplacement as Lx}from"lexical";import*as Xa from"react";import Tx from"bson-objectid";function $o(t,e){if(t.hasAttribute("data-lexical-pending-upload-form-id")){let r=t.getAttribute("data-lexical-pending-upload-form-id");if(r!=null)return{node:e({data:{pending:{formID:r,src:t.getAttribute("src")||""}}})}}if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let r=t.getAttribute("data-lexical-upload-id"),n=t.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:e({data:{fields:{},relationTo:n,value:r}})}}return{node:e({data:{pending:{formID:new Tx.default().toHexString(),src:t.getAttribute("src")||""}}})}}import{DecoratorBlockNode as wx}from"@lexical/react/LexicalDecoratorBlockNode.js";import{addClassNamesToElement as Sx}from"@lexical/utils";import Wa from"bson-objectid";import{$applyNodeReplacement as Ex}from"lexical";var Gt=class extends wx{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:o=>$o(o,Ua),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Wa.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=Ua({data:o});return r.setFormat(e.format),r}static isInline(){return!1}createDOM(e){let o=document.createElement("div");return Sx(o,e?.theme?.upload),o}decorate(){return null}exportDOM(){let e=document.createElement("img"),o=this.__data;return o.pending?(e.setAttribute("data-lexical-pending-upload-form-id",String(o?.pending?.formID)),e.setAttribute("src",o?.pending?.src||"")):(e.setAttribute("data-lexical-upload-id",String(o?.value)),e.setAttribute("data-lexical-upload-relation-to",o?.relationTo)),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function Ua({data:t}){return t?.id||(t.id=new Wa.default().toHexString()),Ex(new Gt({data:t}))}import{jsx as Ga}from"react/jsx-runtime";import{ShimmerEffect as Nx}from"@payloadcms/ui";var Va=()=>Ga("div",{className:"lexical-upload",children:Ga(Nx,{height:"95px",width:"203px"})});var yx=Xa.lazy(()=>import("./component-XIHC3W6W.js").then(t=>({default:t.UploadComponent}))),pe=class extends Gt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:o=>$o(o,fe),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Ka.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=fe({data:o});return r.setFormat(e.format),r}decorate(e,o){return this.__data.pending?Ja(Va,{}):Ja(yx,{className:o?.theme?.upload??"LexicalEditorTheme__upload",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function fe({data:t}){return t?.id||(t.id=new Ka.default().toHexString()),Lx(new pe({data:t}))}function dt(t){return t instanceof pe}import{c as Ax}from"react/compiler-runtime";import{jsx as Fx}from"react/jsx-runtime";import{useLexicalComposerContext as Px}from"@lexical/react/LexicalComposerContext.js";import{$dfsIterator as lc,$insertNodeToNearestRoot as on,mergeRegister as Bx}from"@lexical/utils";import{useBulkUpload as jx,useEffectEvent as Hx,useModal as Ux}from"@payloadcms/ui";import rn from"bson-objectid";import{$createRangeSelection as Wx,$getPreviousSelection as ec,$getSelection as tc,$isParagraphNode as nn,$isRangeSelection as oc,$setSelection as Gx,COMMAND_PRIORITY_EDITOR as Vx,COMMAND_PRIORITY_LOW as rc,createCommand as Jx,DROP_COMMAND as Kx,getDOMSelectionFromTarget as Xx,isHTMLElement as nc,PASTE_COMMAND as zx}from"lexical";import{useEffect as Zx}from"react";import{c as za}from"react/compiler-runtime";import{jsx as en}from"react/jsx-runtime";import{useLexicalComposerContext as Za}from"@lexical/react/LexicalComposerContext.js";import{toast as Rx}from"@payloadcms/ui";import{$getNodeByKey as Ix,COMMAND_PRIORITY_EDITOR as Ya}from"lexical";import{useEffect as qa,useState as vx}from"react";var Mx=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Ix(o);n&&n.replace(fe({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(tn,{fields:null,relationTo:e,value:r})},Dx=t=>{let e=za(13),{enabledCollectionSlugs:o}=t,[r]=Za(),[n,l]=vx(null),s;e[0]!==o?(s={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=s):s=e[1];let{closeListDrawer:i,ListDrawer:d,openListDrawer:c}=Pt(s),u,a;e[2]!==r||e[3]!==c?(u=()=>r.registerCommand(ze,f=>(l(f?.replace?f?.replace.nodeKey:null),c(),!0),Ya),a=[r,c],e[2]=r,e[3]=c,e[4]=u,e[5]=a):(u=e[4],a=e[5]),qa(u,a);let m;e[6]!==i||e[7]!==r||e[8]!==n?(m=f=>{let{collectionSlug:g,doc:k}=f;i(),Mx({editor:r,relationTo:g,replaceNodeKey:n,value:k.id})},e[6]=i,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,h;return e[10]!==d||e[11]!==p?(h=en(d,{onSelect:p}),e[10]=d,e[11]=p,e[12]=h):h=e[12],h},$x=()=>{let t=za(3),[e]=Za(),o,r;return t[0]!==e?(o=()=>e.registerCommand(ze,Ox,Ya),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),qa(o,r),null},Qa=({enabledCollectionSlugs:t})=>t?.length?en(Dx,{enabledCollectionSlugs:t}):en($x,{});function Ox(){return Rx.error("No upload collections enabled"),!0}function Yx(t){let e=t.target;return!!(nc(e)&&!e.closest("code, span.editor-image")&&nc(e.parentElement)&&e.parentElement.closest("div.ContentEditable__root"))}function qx(t){let e,o=Xx(t.target);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&o!==null)o.collapse(t.rangeParent,t.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var tn=Jx("INSERT_UPLOAD_COMMAND"),ic=t=>{let e=Ax(21),{clientProps:o}=t,[r]=Px(),n=o?.disabledCollections,l=o?.enabledCollections,s;e[0]!==n||e[1]!==l?(s={collectionSlugsBlacklist:n,collectionSlugsWhitelist:l,uploads:!0},e[0]=n,e[1]=l,e[2]=s):s=e[2];let{enabledCollectionSlugs:i}=ko(s),{drawerSlug:d,setCollectionSlug:c,setInitialForms:u,setOnCancel:a,setOnSuccess:m,setSelectableCollections:p}=jx(),{isModalOpen:h,openModal:f}=Ux(),g;e[3]!==d||e[4]!==r||e[5]!==i||e[6]!==h||e[7]!==f||e[8]!==c||e[9]!==u||e[10]!==a||e[11]!==m||e[12]!==p?(g=C=>{let{files:x}=C;if(x?.length!==0&&(u(b=>[...b??[],...x.map(Qx)]),!h(d))){if(!i.length||!i[0])return;c(i[0]),p(i),a(()=>{r.update(eC)}),m(b=>{let _=new Map(b.map(tC));r.update(()=>{for(let D of lc()){let I=D.node;if(dt(I)){let y=I.getData();if(y?.pending){let S=_.get(y.pending?.formID);S&&I.replace(fe({data:{id:new rn.default().toHexString(),fields:{},relationTo:S.collectionSlug,value:S.doc.id}}))}}}})}),f(d)}},e[3]=d,e[4]=r,e[5]=i,e[6]=h,e[7]=f,e[8]=c,e[9]=u,e[10]=a,e[11]=m,e[12]=p,e[13]=g):g=e[13];let k=Hx(g),N;e[14]!==r||e[15]!==k?(N=()=>{if(!r.hasNodes([pe]))throw new Error("UploadPlugin: UploadNode not registered on editor");return Bx(r.registerNodeTransform(pe,C=>{let x=C.getData();if(!x?.pending)return;(async function(){let D=null,I=x?.pending?.src,y=x?.pending?.formID;if(I?.startsWith("data:")){let S=I.match(/data:(image\/[a-zA-Z]+);base64,/),w=S?S[1]:"image/png",L=I.replace(/^data:image\/[a-zA-Z]+;base64,/,""),E=atob(L),v=new Array(E.length);for(let F=0;F<E.length;F++)v[F]=E.charCodeAt(F);let $=new Uint8Array(v);D={alt:void 0,file:new File([$],"pasted-image."+w?.split("/",2)[1],{type:w}),formID:y}}else if(I?.startsWith("http")||I?.startsWith("https")){let w=await(await fetch(I)).blob(),L=I.split("/").pop()||"pasted-image"+w.type.split("/",2)[1];D={alt:void 0,file:new File([w],L,{type:w.type}),formID:y}}D&&k({files:[D]})})()}),r.registerCommand(tn,C=>(r.update(()=>{let x=tc()||ec();if(oc(x)){let b=fe({data:{id:C.id,fields:C.fields,relationTo:C.relationTo,value:C.value}}),{focus:_}=x,D=_.getNode();on(b),nn(D)&&!D.__first&&D.remove()}}),!0),Vx),r.registerCommand(zx,C=>{if(!(C instanceof ClipboardEvent))return!1;let x=C.clipboardData;if(!x?.types?.length||x?.types?.includes("text/html"))return!1;let b=[];return x?.files?.length&&Array.from(x.files).forEach(_=>{b.push({alt:"",file:_,formID:new rn.default().toHexString()})}),b.length?(r.update(()=>{let _=tc()||ec();if(oc(_))for(let D of b){let I=fe({data:{pending:{formID:D.formID,src:URL.createObjectURL(D.file)}}}),{focus:y}=_,S=y.getNode();on(I),nn(S)&&!S.__first&&S.remove()}}),k({files:b}),!0):!1},rc),r.registerCommand(Kx,C=>{if(!(C instanceof DragEvent))return!1;let x=C.dataTransfer;if(!x?.types?.length)return!1;let b=[];return x?.files?.length&&Array.from(x.files).forEach(_=>{b.push({alt:"",file:_,formID:new rn.default().toHexString()})}),b.length?(C.preventDefault(),C.stopPropagation(),r.update(()=>{if(Yx(C)){let _=qx(C),D=Wx();_!=null&&D.applyDOMRange(_),Gx(D);for(let I of b){let y=fe({data:{pending:{formID:I.formID,src:URL.createObjectURL(I.file)}}}),{focus:S}=D,w=S.getNode();on(y),nn(w)&&!w.__first&&w.remove()}}}),k({files:b}),!0):!1},rc))},e[14]=r,e[15]=k,e[16]=N):N=e[16];let R;e[17]!==r?(R=[r],e[17]=r,e[18]=R):R=e[18],Zx(N,R);let T;return e[19]!==i?(T=Fx(Qa,{enabledCollectionSlugs:i}),e[19]=i,e[20]=T):T=e[20],T};function Qx(t){return{file:t.file,formID:t.formID}}function eC(){for(let t of lc()){let e=t.node;dt(e)&&e.getData()?.pending&&e.remove()}}function tC(t){return[t.formID,t]}var rC=M({nodes:[pe],plugins:[{Component:ic,position:"normal"}],slashMenu:{groups:[X([{Icon:Qr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(ze,{replace:!1})}}])]},toolbarFixed:{groups:[ke([{ChildComponent:Qr,isActive:({selection:t})=>{if(!oC(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return dt(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(ze,{replace:!1})}}])]}});import{c as lC}from"react/compiler-runtime";import{jsx as Oo}from"react/jsx-runtime";import{createElement as iC}from"react";import{ShimmerEffect as sC,useConfig as aC}from"@payloadcms/ui";import{lazy as cC,Suspense as uC,useEffect as dC,useState as mC}from"react";var sc={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",inlineBlock:"LexicalEditorTheme__inlineBlock",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",placeholder:"LexicalEditorTheme__placeholder",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"LexicalEditorTheme__upload"};var ln={namespace:"lexical",theme:sc};function ac({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:l}){let s=new Map;for(let c of l.features){if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");s.set(c.clientFeatureProps.featureKey,c)}l.features=l.features.sort((c,u)=>c.clientFeatureProps.order-u.clientFeatureProps.order);let i=new Map,d=0;for(let c of l.features){let u=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:s,field:r,resolvedFeatures:i,schemaPath:n,unSanitizedEditorConfig:l}):c.feature;u.key=c.clientFeatureProps.featureKey,u.order=d,i.set(c.clientFeatureProps.featureKey,u),d++}return i}import{deepMerge as nC}from"payload/shared";var cc=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,l)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+l,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let l=e.toolbarInline.groups.find(s=>s.key===n.key);l?e.toolbarInline.groups=e.toolbarInline.groups.filter(s=>s.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarInline?.groups.push(l)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let l=e.toolbarFixed.groups.find(s=>s.key===n.key);l?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(s=>s.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarFixed?.groups.push(l)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let l=e.slashMenu.groups.find(s=>s.key===n.key);l?e.slashMenu.groups=e.slashMenu.groups.filter(s=>s.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.slashMenu.groups.push(l)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?nC(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);return e};function sn(t,e,o,r){return{admin:o,features:cc(t),lexical:e,resolvedFeatureMap:t,view:r}}var pC=cC(()=>import("./Field-KR4W3EZZ.js").then(t=>({default:t.RichText}))),fC=t=>Oo(Uo,{inheritable:!0,views:t.views,children:Oo(hC,{...t})}),hC=t=>{let e=lC(23),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:l,field:s,lexicalEditorConfig:i,schemaPath:d,views:c}=t,u;e[0]!==o?(u=o===void 0?{}:o,e[0]=o,e[1]=u):u=e[1];let a=u,m;e[2]!==n?(m=n===void 0?{}:n,e[2]=n,e[3]=m):m=e[3];let p=m,h=i===void 0?ln:i,{currentView:f}=Wo(),g=c?.[f]?.admin??a,k=c?.[f]?.lexical,N;e[4]!==h||e[5]!==k?(N=typeof k=="function"?k(h):k??h,e[4]=h,e[5]=k,e[6]=N):N=e[6];let R=N,{config:T}=aC(),[C,x]=mC(null),b,_;e[7]!==r||e[8]!==T||e[9]!==f||e[10]!==g||e[11]!==R||e[12]!==p||e[13]!==l||e[14]!==s||e[15]!==C||e[16]!==d||e[17]!==c?(b=()=>{if(C&&C.view===f)return;let I=c?.[f],y=I?.filterFeatures?I.filterFeatures(r):r,S=[];for(let L of Object.values(y))L.clientFeatureProvider&&S.push(L.clientFeatureProvider(L.clientFeatureProps));let w=ac({config:T,featureClientImportMap:p,featureClientSchemaMap:l,field:s,schemaPath:d??s.name,unSanitizedEditorConfig:{features:S,lexical:R}});x(sn(w,R,g,f))},_=[g,r,T,p,l,s,C,R,d,f,c],e[7]=r,e[8]=T,e[9]=f,e[10]=g,e[11]=R,e[12]=p,e[13]=l,e[14]=s,e[15]=C,e[16]=d,e[17]=c,e[18]=b,e[19]=_):(b=e[18],_=e[19]),dC(b,_);let D;return e[20]!==C||e[21]!==t?(D=Oo(uC,{fallback:Oo(sC,{height:"35vh"}),children:C&&iC(pC,{...t,editorConfig:C,key:C.view})}),e[20]=C,e[21]=t,e[22]=D):D=e[22],D};function gC(t){return t instanceof HTMLElement}function xC(...t){return t.filter(Boolean).join(" ")}var Ao=new WeakMap;function uc(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function Fo(t,e){let o=Ao.get(t);if(o===void 0){let r=new Set,n=s=>{o!==void 0&&(o.start=uc(s))},l=s=>{if(o===void 0)return;let{start:i}=o;if(i===null)return;let d=uc(s);for(let c of r)d!==null&&c([d[0]-i[0],d[1]-i[1]],s)};t.addEventListener("touchstart",n),t.addEventListener("touchend",l),o={handleTouchend:l,handleTouchstart:n,listeners:r,start:null},Ao.set(t,o)}return o.listeners.add(e),()=>{CC(t,e)}}function CC(t,e){let o=Ao.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(Ao.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function bC(t,e){return Fo(t,(o,r)=>{let[n,l]=o;n<0&&-n>Math.abs(l)&&e(n,r)})}function kC(t,e){return Fo(t,(o,r)=>{let[n,l]=o;n>0&&n>Math.abs(l)&&e(n,r)})}function _C(t,e){return Fo(t,(o,r)=>{let[n,l]=o;l<0&&-l>Math.abs(n)&&e(n,r)})}function TC(t,e){return Fo(t,(o,r)=>{let[n,l]=o;l>0&&l>Math.abs(n)&&e(n,r)})}import{c as wC}from"react/compiler-runtime";import{jsx as SC}from"react/jsx-runtime";import"react";var EC=()=>{let t=wC(2),{EditButton:e}=Ce(),o;return t[0]!==e?(o=e?SC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as NC}from"react/compiler-runtime";import{jsx as LC}from"react/jsx-runtime";import"react";var yC=()=>{let t=NC(2),{RemoveButton:e}=Ce(),o;return t[0]!==e?(o=e?LC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as RC}from"react/compiler-runtime";import{jsx as IC}from"react/jsx-runtime";import"react";var vC=()=>{let t=RC(2),{Label:e}=Ce(),o;return t[0]!==e?(o=e?IC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as MC}from"react/compiler-runtime";import{jsx as DC}from"react/jsx-runtime";import"react";var $C=t=>{let e=MC(3),{children:o}=t,{InlineBlockContainer:r}=Ce(),n;return e[0]!==r||e[1]!==o?(n=r?DC(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{jsx as OC}from"react/jsx-runtime";import"react";var AC=t=>{let{children:e,...o}=t,{BlockCollapsible:r}=ie();return r?OC(r,{...o,children:e}):null};import{c as FC}from"react/compiler-runtime";import{jsx as PC}from"react/jsx-runtime";import"react";var BC=()=>{let t=FC(2),{EditButton:e}=ie(),o;return t[0]!==e?(o=e?PC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as jC}from"react/compiler-runtime";import{jsx as HC}from"react/jsx-runtime";import"react";var UC=()=>{let t=jC(2),{RemoveButton:e}=ie(),o;return t[0]!==e?(o=e?HC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as WC}from"qs-esm";var GC=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:l,collectionSlug:s,select:i})=>{let d=WC({depth:e??0,draft:o??!1,locale:r,select:i},{addQueryPrefix:!0});return await fetch(`${t}/${s}/${l}${d}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(u=>u.json())};var dc={customEndRegex:{optional:!0,regExp:/[ \t]*```$/},customStartRegex:/^[ \t]*```(\w+)?/,doNotTrimChildren:!0,export:({fields:t})=>!t.code.includes(`
60
+ `);let o=Rh(Lo.NO_STATUS);return Xt(t,e,o),o},ua=(t,e)=>{let o=t.match(da);return!o||!o[1]?null:o[1].split("|").map(r=>pa(r,e))};import{c as jh}from"react/compiler-runtime";import{jsx as B,jsxs as ye}from"react/jsx-runtime";import{useLexicalComposerContext as Ca}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Hh}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as ha,$deleteTableColumnAtSelection as Uh,$deleteTableRowAtSelection as Wh,$getNodeTriplet as Gh,$getTableCellNodeFromLexicalNode as ga,$getTableColumnIndexFromTableCellNode as Vh,$getTableNodeFromLexicalNodeOrThrow as $e,$getTableRowIndexFromTableCellNode as Jh,$insertTableColumnAtSelection as Kh,$insertTableRowAtSelection as Xh,$isTableCellNode as ba,$isTableSelection as Ut,$mergeCells as zh,$unmergeCell as Zh,getTableElement as Wr,getTableObserverFromTableElement as Gr,TableCellHeaderStates as De,TableCellNode as Yh}from"@lexical/table";import{mergeRegister as qh}from"@lexical/utils";import{useScrollInfo as Qh}from"@payloadcms/ui";import{$getSelection as Ro,$isElementNode as eg,$isRangeSelection as Vr,$isTextNode as tg,$setSelection as og,COMMAND_PRIORITY_CRITICAL as rg,getDOMSelection as ng,isDOMNode as lg,SELECTION_CHANGE_COMMAND as ig}from"lexical";import*as Jr from"react";import{useCallback as ce,useEffect as at,useRef as yo,useState as ct}from"react";import{createPortal as ka}from"react-dom";import{jsx as Ur,jsxs as Bh}from"react/jsx-runtime";import"react";var fa=()=>Bh("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Ur("path",{d:"M5 11C5.55228 11 6 10.5523 6 10C6 9.44772 5.55228 9 5 9C4.44772 9 4 9.44772 4 10C4 10.5523 4.44772 11 5 11Z",fill:"currentColor"}),Ur("path",{d:"M10 11C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9C9.44772 9 9 9.44772 9 10C9 10.5523 9.44772 11 10 11Z",fill:"currentColor"}),Ur("path",{d:"M15 11C15.5523 11 16 10.5523 16 10C16 9.44772 15.5523 9 15 9C14.4477 9 14 9.44772 14 10C14 10.5523 14.4477 11 15 11Z",fill:"currentColor"})]});function xa(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function sg(){let t=Ro();if(Vr(t)&&!t.isCollapsed()||Ut(t)&&!t.anchor.is(t.focus)||!Vr(t)&&!Ut(t))return!1;let[e]=Gh(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function ag(t){let e=t.getLastDescendant();tg(e)?e.select():eg(e)?e.selectEnd():e!==null&&e.selectNext()}function cg({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[l]=Ca(),s=yo(null),[i,d]=ct(n),[c,u]=ct({columns:1,rows:1}),[a,m]=ct(!1),[p,h]=ct(!1),{y:f}=Qh();at(()=>l.registerMutationListener(Yh,w=>{w.get(i.getKey())==="updated"&&l.getEditorState().read(()=>{d(i.getLatest())})},{skipInitialization:!0}),[l,i]),at(()=>{l.getEditorState().read(()=>{let w=Ro();if(Ut(w)){let L=xa(w);u(xa(w)),m(L.columns>1||L.rows>1)}h(sg())})},[l]),at(()=>{let w=e.current,L=s.current,E=l.getRootElement();if(w!=null&&L!=null&&E!=null){let v=E.getBoundingClientRect(),$=w.getBoundingClientRect();L.style.opacity="1";let O=L.getBoundingClientRect(),F=5,P=$.right+F;if(P+O.width>window.innerWidth||P+O.width>v.right){let K=$.left-O.width-F;P=(K<0?F:K)+window.pageXOffset}L.style.left=`${P+window.pageXOffset}px`;let Z=$.top;if(Z+O.height>window.innerHeight){let K=$.bottom-O.height;Z=K<0?F:K}L.style.top=`${Z}px`}},[e,s,l,f]),at(()=>{function w(L){s.current!=null&&e.current!=null&&lg(L.target)&&!s.current.contains(L.target)&&!e.current.contains(L.target)&&r(!1)}return window.addEventListener("click",w),()=>window.removeEventListener("click",w)},[r,e]);let g=ce(()=>{l.update(()=>{if(i.isAttached()){let w=$e(i),L=Wr(w,l.getElementByKey(w.getKey()));if(L===null)throw new Error("Expected to find tableElement in DOM");let E=Gr(L);E!==null&&E.$clearHighlight(),w.markDirty(),d(i.getLatest())}og(null)})},[l,i]),k=()=>{l.update(()=>{let w=Ro();if(!Ut(w))return;let E=w.getNodes().filter(ba),v=zh(E);v&&(ag(v),o())})},N=()=>{l.update(()=>{Zh()})},R=ce(w=>{l.update(()=>{for(let L=0;L<c.rows;L++)Xh(w);o()})},[l,o,c.rows]),T=ce(w=>{l.update(()=>{for(let L=0;L<c.columns;L++)Kh(w);o()})},[l,o,c.columns]),C=ce(()=>{l.update(()=>{Wh(),o()})},[l,o]),x=ce(()=>{l.update(()=>{$e(i).remove(),g(),o()})},[l,i,g,o]),b=ce(()=>{l.update(()=>{Uh(),o()})},[l,o]),_=ce(()=>{l.update(()=>{let w=$e(i),L=Jh(i),[E]=ha(w,null,null),v=new Set,$=i.getHeaderStyles()^De.ROW;if(E[L])for(let O=0;O<E[L].length;O++){let F=E[L][O];F?.cell&&(v.has(F.cell)||(v.add(F.cell),F.cell.setHeaderStyles($,De.ROW)))}g(),o()})},[l,i,g,o]),D=ce(()=>{l.update(()=>{let w=$e(i),L=Vh(i),[E]=ha(w,null,null),v=new Set,$=i.getHeaderStyles()^De.COLUMN;if(E)for(let O=0;O<E.length;O++){let F=E?.[O]?.[L];F?.cell&&(v.has(F.cell)||(v.add(F.cell),F.cell.setHeaderStyles($,De.COLUMN)))}g(),o()})},[l,i,g,o]),I=ce(()=>{l.update(()=>{if(i.isAttached()){let w=$e(i);w&&w.setRowStriping(!w.getRowStriping())}g(),o()})},[l,i,g,o]),y=ce(()=>{l.update(()=>{if(i.isAttached()){let w=$e(i);w&&w.setFrozenColumns(w.getFrozenColumns()===0?1:0)}g(),o()})},[l,i,g,o]),S=null;return t&&(a?S=B("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>k(),type:"button",children:B("span",{className:"text",children:"Merge cells"})}):p&&(S=B("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>N(),type:"button",children:B("span",{className:"text",children:"Unmerge cells"})}))),ka(ye("div",{className:"table-action-menu-dropdown",onClick:w=>{w.stopPropagation()},ref:s,children:[S?ye(Jr.Fragment,{children:[S,B("hr",{})]}):null,B("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>I(),type:"button",children:B("span",{className:"text",children:"Toggle Row Striping"})}),B("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>y(),type:"button",children:B("span",{className:"text",children:"Toggle First Column Freeze"})}),B("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>R(!1),type:"button",children:ye("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),B("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>R(!0),type:"button",children:ye("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>T(!1),type:"button",children:ye("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),B("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>T(!0),type:"button",children:ye("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>b(),type:"button",children:B("span",{className:"text",children:"Delete column"})}),B("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>C(),type:"button",children:B("span",{className:"text",children:"Delete row"})}),B("button",{className:"item","data-test-id":"table-delete",onClick:()=>x(),type:"button",children:B("span",{className:"text",children:"Delete table"})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-row-header",onClick:()=>_(),type:"button",children:ye("span",{className:"text",children:[(i.__headerState&De.ROW)===De.ROW?"Remove":"Add"," ","row header"]})}),B("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:ye("span",{className:"text",children:[(i.__headerState&De.COLUMN)===De.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function ug({anchorElem:t,cellMerge:e}){let[o]=Ca(),r=yo(null),n=yo(null),[l,s]=ct(!1),[i,d]=ct(null),c=ce(()=>{let a=r.current,m=Ro(),p=ng(o._window),h=document.activeElement;function f(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),d(null)}if(m==null||a==null)return f();let g=o.getRootElement(),k=null,N=null;if(Vr(m)&&g!==null&&p!==null&&g.contains(p.anchorNode)){let T=ga(m.anchor.getNode());if(T==null||(N=o.getElementByKey(T.getKey()),N==null||!T.isAttached()))return f();let C=$e(T),x=Wr(C,o.getElementByKey(C.getKey()));if(x===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");k=Gr(x),d(T)}else if(Ut(m)){let T=ga(m.anchor.getNode());if(!ba(T))throw new Error("TableSelection anchorNode must be a TableCellNode");let C=$e(T),x=Wr(C,o.getElementByKey(C.getKey()));if(x===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");k=Gr(x),N=o.getElementByKey(T.getKey())}else if(!h)return f();if(k===null||N===null)return f();let R=!k||!k.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",R),a.classList.toggle("table-cell-action-button-container--inactive",!R),R){let T=N.getBoundingClientRect(),C=t.getBoundingClientRect(),x=T.top-C.top,b=T.right-C.left;a.style.transform=`translate(${b}px, ${x}px)`}},[o,t]);at(()=>{let a,m=()=>{a=void 0,o.getEditorState().read(c)},p=()=>(a===void 0&&(a=setTimeout(m,0)),!1);return qh(o.registerUpdateListener(p),o.registerCommand(ig,p,rg),o.registerRootListener((h,f)=>{f&&f.removeEventListener("pointerup",p),h&&(h.addEventListener("pointerup",p),p())}),()=>clearTimeout(a))});let u=yo(i);return at(()=>{u.current!==i&&s(!1),u.current=i},[u,i]),B("div",{className:"table-cell-action-button-container",ref:r,children:i!=null&&ye(Jr.Fragment,{children:[B("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),s(!l)},ref:n,type:"button",children:B(fa,{})}),l&&B(cg,{cellMerge:e,contextRef:n,onClose:()=>s(!1),setIsMenuOpen:s,tableCellNode:i})]})})}var _a=t=>{let e=jh(3),{anchorElem:o}=t,r=Hh(),n;return e[0]!==o||e[1]!==r?(n=ka(r?B(ug,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as dg}from"react/compiler-runtime";import{jsx as vo,jsxs as mg}from"react/jsx-runtime";import{useLexicalComposerContext as pg}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as fg}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as hg,$getTableNodeFromLexicalNodeOrThrow as Kr,$getTableRowIndexFromTableCellNode as gg,$isTableCellNode as Ta,$isTableRowNode as xg,getDOMCellFromTarget as Cg,getTableElement as bg,TableNode as wa}from"@lexical/table";import{calculateZoomLevel as Sa,mergeRegister as kg}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Xr,isHTMLElement as _g,SKIP_SCROLL_INTO_VIEW_TAG as Ea}from"lexical";import*as La from"react";import{useCallback as Wt,useEffect as zr,useRef as Io,useState as ut}from"react";import{createPortal as Tg}from"react-dom";var wg=33,Na=92;function Sg({editor:t}){let e=Io(null),o=Io(null),r=Io(null),[n,l]=ut(!1),s=U(),i=Io(null),[d,c]=ut(null),[u,a]=ut(null),[m,p]=ut(!1),[h,f]=ut(null),g=Wt(()=>{a(null),e.current=null,f(null),i.current=null,r.current=null},[]),k=y=>(y.buttons&1)===1;zr(()=>{let y=new Set;return kg(t.registerMutationListener(wa,S=>{for(let[w,L]of S)L==="destroyed"?y.delete(w):y.add(w);l(y.size>0)}),t.registerNodeTransform(wa,S=>{if(S.getColWidths())return S;let w=S.getColumnCount(),L=Na;return S.setColWidths(Array(w).fill(L)),S}))},[t]),zr(()=>{if(!n)return;let y=E=>{let v=E.target;if(_g(v)){if(h){c({x:E.clientX,y:E.clientY});return}if(p(k(E)),!(o.current&&o.current.contains(v))&&e.current!==v){e.current=v;let $=Cg(v);$&&u!==$?t.getEditorState().read(()=>{let O=Xr($.elem);if(!O)throw new Error("TableCellResizer: Table cell node not found.");let F=Kr(O),P=bg(F,t.getElementByKey(F.getKey()));if(!P)throw new Error("TableCellResizer: Table element not found.");e.current=v,r.current=P.getBoundingClientRect(),a($)},{editor:t}):$==null&&g()}}},S=E=>{p(!0)},w=E=>{p(!1)},L=t.registerRootListener((E,v)=>{v?.removeEventListener("mousemove",y),v?.removeEventListener("mousedown",S),v?.removeEventListener("mouseup",w),E?.addEventListener("mousemove",y),E?.addEventListener("mousedown",S),E?.addEventListener("mouseup",w)});return()=>{L()}},[u,h,t,n,g]);let N=y=>y==="bottom",R=Wt(y=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Xr(u.elem);if(!Ta(S))throw new Error("TableCellResizer: Table cell node not found.");let w=Kr(S),L=gg(S),E=w.getChildren(),$=S.getColSpan()===w.getColumnCount()?L:L+S.getRowSpan()-1;if($>=E.length||$<0)throw new Error("Expected table cell to be inside of table row.");let O=E[$];if(!xg(O))throw new Error("Expected table row");let F=O.getHeight();if(F===void 0){let Z=O.getChildren();F=Math.min(...Z.map(K=>T(K,t)??1/0))}let P=Math.max(F+y,wg);O.setHeight(P)},{tag:Ea})},[u,t]),T=(y,S)=>S.getElementByKey(y.getKey())?.clientHeight,C=(y,S)=>{let w;return S.forEach(L=>{L.forEach((E,v)=>{E.cell===y&&(w=v)})}),w},x=Wt(y=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Xr(u.elem);if(!Ta(S))throw new Error("TableCellResizer: Table cell node not found.");let w=Kr(S),[L]=hg(w,null,null),E=C(S,L);if(E===void 0)throw new Error("TableCellResizer: Table column not found.");let v=w.getColWidths();if(!v)return;let $=v[E];if($===void 0)return;let O=[...v],F=Math.max($+y,Na);O[E]=F,w.setColWidths(O)},{tag:Ea})},[u,t]),b=Wt(y=>{let S=w=>{if(w.preventDefault(),w.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:L,y:E}=i.current;if(u===null)return;let v=Sa(w.target);if(N(y)){let $=(w.clientY-E)/v;R($)}else{let $=(w.clientX-L)/v;x($)}g(),document.removeEventListener("mouseup",S)}};return S},[u,g,x,R]),_=Wt(y=>S=>{if(S.preventDefault(),S.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");i.current={x:S.clientX,y:S.clientY},c(i.current),f(y),document.addEventListener("mouseup",b(y))},[u,b]),[D,I]=ut({bottom:null,left:null,right:null,top:null});return zr(()=>{if(u){let{height:y,left:S,top:w,width:L}=u.elem.getBoundingClientRect(),E=Sa(u.elem),v=10,$={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${v}px`,left:`${window.scrollX+S}px`,top:`${window.scrollY+w+y-v/2}px`,width:`${L}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${y}px`,left:`${window.scrollX+S+L-v/2}px`,top:`${window.scrollY+w}px`,width:`${v}px`}},O=r.current;h&&d&&O&&(N(h)?($[h].left=`${window.scrollX+O.left}px`,$[h].top=`${window.scrollY+d.y/E}px`,$[h].height="3px",$[h].width=`${O.width}px`):($[h].top=`${window.scrollY+O.top}px`,$[h].left=`${window.scrollX+d.x/E}px`,$[h].width="3px",$[h].height=`${O.height}px`),$[h].backgroundColor="#adf"),I($)}else I({bottom:null,left:null,right:null,top:null})},[u,h,d]),vo("div",{ref:o,children:u!=null&&!m&&mg(La.Fragment,{children:[vo("div",{className:`${s.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:_("right"),style:D.right||void 0}),vo("div",{className:`${s.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:_("bottom"),style:D.bottom||void 0})]})})}var ya=()=>{let t=dg(3),[e]=pg(),o=fg(),r;return t[0]!==e||t[1]!==o?(r=o?Tg(vo(Sg,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],r};import{c as Mg}from"react/compiler-runtime";import{jsx as Zr,jsxs as Dg,Fragment as $g}from"react/jsx-runtime";import{useLexicalComposerContext as Og}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Aa}from"@lexical/react/useLexicalEditable";import{$getTableAndElementByKey as Ag,$getTableColumnIndexFromTableCellNode as Fg,$getTableRowIndexFromTableCellNode as Pg,$insertTableColumnAtSelection as Bg,$insertTableRowAtSelection as jg,$isTableCellNode as Hg,$isTableNode as va,getTableElement as Ug,TableNode as Wg}from"@lexical/table";import{$findMatchingParent as Gg,mergeRegister as Vg}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Ma,isHTMLElement as Jg}from"lexical";import{useEffect as Da,useMemo as Kg,useRef as $a,useState as Mo}from"react";import"react";import{createPortal as Xg}from"react-dom";import{c as Rg}from"react/compiler-runtime";import{useEffect as Ig,useRef as vg}from"react";var Eg="Expected a function",Ng=Math.max,Lg=Math.min;function yg(t,e,o){let r,n,l=0,s,i=!1,d=!1,c,u,a,m=!0;if(typeof t!="function")throw new TypeError(Eg);e=e||0,typeof o=="object"&&(i=!!o.leading,d="maxWait"in o,c=d?Ng(o.maxWait||0,e):c,m="trailing"in o?!!o.trailing:m);function p(x){let b=r,_=s;return r=s=void 0,l=x,u=t.apply(_,b),u}function h(x){return l=x,a=setTimeout(k,e),i?p(x):u}function f(x){let b=x-n,_=x-l,D=e-b;return d?Lg(D,c-_):D}function g(x){let b=x-n,_=x-l;return n===void 0||b>=e||b<0||d&&_>=c}function k(){let x=Date.now();if(g(x))return N(x);a=setTimeout(k,f(x))}function N(x){return a=void 0,m&&r?p(x):(r=s=void 0,u)}function R(){a!==void 0&&clearTimeout(a),l=0,r=n=s=a=void 0}function T(){return a===void 0?u:N(Date.now())}function C(){let x=Date.now(),b=g(x);if(r=arguments,s=this,n=x,b){if(a===void 0)return h(n);if(d)return clearTimeout(a),a=setTimeout(k,e),p(n)}return a===void 0&&(a=setTimeout(k,e)),u}return C.cancel=R,C.flush=T,C}var Ra=yg;function Ia(t,e,o){let r=Rg(6),n=vg(null),l,s;r[0]!==t||r[1]!==o||r[2]!==e?(l=()=>(n.current=Ra(t,e,{maxWait:o}),()=>{n.current?.cancel()}),s=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=l,r[4]=s):(l=r[3],s=r[4]),Ig(l,s);let i;return r[5]===Symbol.for("react.memo_cache_sentinel")?(i=(...c)=>{let u=c;n.current&&n.current(...u)},r[5]=i):i=r[5],i}var Oa=20;function zg({anchorElem:t}){let[e]=Og(),o=Aa(),r=U(),[n,l]=Mo(!1),[s,i]=Mo(!1),[d,c]=Mo(!1),[u,a]=Mo({}),m=$a(new Set),p=$a(null),h=Ia(k=>{let{isOutside:N,tableDOMNode:R}=Zg(k,r.editorConfig?.lexical);if(N){l(!1),i(!1);return}if(!R)return;p.current=R;let T=null,C=null,x=null;if(e.getEditorState().read(()=>{let $=Ma(R);if(Hg($)){let O=Gg($,F=>va(F));if(!va(O))return;if(x=Ug(O,e.getElementByKey(O.getKey())),x){let F=O.getChildrenSize(),P=O.getChildAtIndex(0)?.getChildrenSize(),Z=Pg($),K=Fg($);Z===F-1?T=$:K===P-1&&(C=$)}}},{editor:e}),!x)return;let b=x.parentElement;if(!b)return;let{bottom:_,height:D,left:I,right:y,width:S,y:w}=x.getBoundingClientRect(),L=!1;b&&b.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(L=b.scrollWidth>b.clientWidth);let{left:E,y:v}=t.getBoundingClientRect();T?(i(!1),l(!0),a({height:Oa,left:L&&b?b.offsetLeft:I-E,top:_-v+5,width:L&&b?b.offsetWidth:S})):C&&(i(!0),l(!1),a({height:D,left:y-E+5,top:w-v,width:Oa}))},50,250),f=Kg(()=>new ResizeObserver(()=>{l(!1),i(!1)}),[]);Da(()=>{if(d)return document.addEventListener("mousemove",h),()=>{l(!1),i(!1),document.removeEventListener("mousemove",h)}},[d,h]),Da(()=>Vg(e.registerMutationListener(Wg,k=>{e.getEditorState().read(()=>{let N=!1;for(let[R,T]of k)switch(T){case"created":{m.current.add(R),N=!0;break}case"destroyed":{m.current.delete(R),N=!0;break}default:break}if(N){f.disconnect();for(let R of m.current){let{tableElement:T}=Ag(R);f.observe(T)}c(m.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let g=k=>{e.update(()=>{p.current&&(Ma(p.current)?.selectEnd(),k?(jg(),l(!1)):(Bg(),i(!1)))})};return o?Dg($g,{children:[n&&Zr("button",{"aria-label":"Add Row",className:r.editorConfig.lexical.theme.tableAddRows,onClick:()=>g(!0),style:{...u},type:"button"}),s&&Zr("button",{"aria-label":"Add Column",className:r.editorConfig.lexical.theme.tableAddColumns,onClick:()=>g(!1),style:{...u},type:"button"})]}):null}function Zg(t,e){let o=t.target;if(Jg(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Fa(t){let e=Mg(2),{anchorElem:o}=t,r=o===void 0?document.body:o;if(!Aa())return null;let l;return e[0]!==r?(l=Xg(Zr(zg,{anchorElem:r}),r),e[0]=r,e[1]=l):l=e[1],l}import{c as Yg}from"react/compiler-runtime";import{jsx as Yr,jsxs as qg}from"react/jsx-runtime";import{useLexicalComposerContext as Qg}from"@lexical/react/LexicalComposerContext";import{TablePlugin as ex}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as tx,TableCellNode as ox,TableNode as rx,TableRowNode as nx}from"@lexical/table";import{mergeRegister as lx}from"@lexical/utils";import{formatDrawerSlug as ix,useEditDepth as sx}from"@payloadcms/ui";import{$getSelection as ax,$isRangeSelection as cx,COMMAND_PRIORITY_EDITOR as ux,createCommand as dx}from"lexical";import{createContext as mx,use as px,useEffect as fx,useMemo as hx,useState as gx}from"react";import*as Pa from"react";var Do=dx("OPEN_EMBED_DRAWER_COMMAND"),Ba=mx({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function ja({children:t}){let[e,o]=gx({cellEditorConfig:null,cellEditorPlugins:null});return Yr(Ba,{value:hx(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Ha=()=>{let t=Yg(16),[e]=Qg(),o=px(Ba),r=sx(),{fieldProps:n,uuid:l}=U(),{schemaPath:s}=n,i="lexical-table-create-"+l,d;t[0]!==r||t[1]!==i?(d=ix({slug:i,depth:r}),t[0]=r,t[1]=i,t[2]=d):d=t[2];let c=d,{toggleDrawer:u}=xe(c,!0),a;t[3]!==e||t[4]!==u?(a=()=>{if(!e.hasNodes([rx,nx,ox]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return lx(e.registerCommand(Do,()=>{let f=null;return e.getEditorState().read(()=>{let g=ax();cx(g)&&(f=g)}),f&&u(),!0},ux))},t[3]=e,t[4]=u,t[5]=a):a=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==u?(m=[o,e,u],t[6]=o,t[7]=e,t[8]=u,t[9]=m):m=t[9],fx(a,m);let p;t[10]!==e?(p=(f,g)=>{!g.columns||!g.rows||e.dispatchCommand(tx,{columns:String(g.columns),rows:String(g.rows)})},t[10]=e,t[11]=p):p=t[11];let h;return t[12]!==c||t[13]!==s||t[14]!==p?(h=qg(Pa.Fragment,{children:[Yr(Ct,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:s,schemaPathSuffix:"fields"}),Yr(ex,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=s,t[14]=p,t[15]=h):h=t[15],h};var kx=M({markdownTransformers:[ma],nodes:[Cx,xx,bx],plugins:[{Component:Ha,position:"normal"},{Component:ya,position:"normal"},{Component:_a,position:"floatingAnchorElem"},{Component:Fa,position:"floatingAnchorElem"}],providers:[ja],slashMenu:{groups:[X([{Icon:Br,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Do,{})}}])]},toolbarFixed:{groups:[ke([{ChildComponent:Br,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Do,{})}}])]}});import{$isNodeSelection as oC}from"lexical";import{jsx as qr,jsxs as _x}from"react/jsx-runtime";import"react";var Qr=()=>_x("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[qr("path",{d:"M14.6667 4H5.33333C4.59695 4 4 4.59695 4 5.33333V14.6667C4 15.403 4.59695 16 5.33333 16H14.6667C15.403 16 16 15.403 16 14.6667V5.33333C16 4.59695 15.403 4 14.6667 4Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),qr("path",{d:"M7.99984 9.33366C8.73622 9.33366 9.33317 8.73671 9.33317 8.00033C9.33317 7.26395 8.73622 6.66699 7.99984 6.66699C7.26346 6.66699 6.6665 7.26395 6.6665 8.00033C6.6665 8.73671 7.26346 9.33366 7.99984 9.33366Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),qr("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ja}from"react/jsx-runtime";import Ka from"bson-objectid";import{$applyNodeReplacement as Lx}from"lexical";import*as Xa from"react";import Tx from"bson-objectid";function $o(t,e){if(t.hasAttribute("data-lexical-pending-upload-form-id")){let r=t.getAttribute("data-lexical-pending-upload-form-id");if(r!=null)return{node:e({data:{pending:{formID:r,src:t.getAttribute("src")||""}}})}}if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let r=t.getAttribute("data-lexical-upload-id"),n=t.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:e({data:{fields:{},relationTo:n,value:r}})}}return{node:e({data:{pending:{formID:new Tx.default().toHexString(),src:t.getAttribute("src")||""}}})}}import{DecoratorBlockNode as wx}from"@lexical/react/LexicalDecoratorBlockNode.js";import{addClassNamesToElement as Sx}from"@lexical/utils";import Wa from"bson-objectid";import{$applyNodeReplacement as Ex}from"lexical";var Gt=class extends wx{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:o=>$o(o,Ua),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Wa.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=Ua({data:o});return r.setFormat(e.format),r}static isInline(){return!1}createDOM(e){let o=document.createElement("div");return Sx(o,e?.theme?.upload),o}decorate(){return null}exportDOM(){let e=document.createElement("img"),o=this.__data;return o.pending?(e.setAttribute("data-lexical-pending-upload-form-id",String(o?.pending?.formID)),e.setAttribute("src",o?.pending?.src||"")):(e.setAttribute("data-lexical-upload-id",String(o?.value)),e.setAttribute("data-lexical-upload-relation-to",o?.relationTo)),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function Ua({data:t}){return t?.id||(t.id=new Wa.default().toHexString()),Ex(new Gt({data:t}))}import{jsx as Ga}from"react/jsx-runtime";import{ShimmerEffect as Nx}from"@payloadcms/ui";var Va=()=>Ga("div",{className:"lexical-upload",children:Ga(Nx,{height:"95px",width:"203px"})});var yx=Xa.lazy(()=>import("./component-XIHC3W6W.js").then(t=>({default:t.UploadComponent}))),pe=class extends Gt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:o=>$o(o,fe),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Ka.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=fe({data:o});return r.setFormat(e.format),r}decorate(e,o){return this.__data.pending?Ja(Va,{}):Ja(yx,{className:o?.theme?.upload??"LexicalEditorTheme__upload",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function fe({data:t}){return t?.id||(t.id=new Ka.default().toHexString()),Lx(new pe({data:t}))}function dt(t){return t instanceof pe}import{c as Ax}from"react/compiler-runtime";import{jsx as Fx}from"react/jsx-runtime";import{useLexicalComposerContext as Px}from"@lexical/react/LexicalComposerContext.js";import{$dfsIterator as lc,$insertNodeToNearestRoot as on,mergeRegister as Bx}from"@lexical/utils";import{useBulkUpload as jx,useEffectEvent as Hx,useModal as Ux}from"@payloadcms/ui";import rn from"bson-objectid";import{$createRangeSelection as Wx,$getPreviousSelection as ec,$getSelection as tc,$isParagraphNode as nn,$isRangeSelection as oc,$setSelection as Gx,COMMAND_PRIORITY_EDITOR as Vx,COMMAND_PRIORITY_LOW as rc,createCommand as Jx,DROP_COMMAND as Kx,getDOMSelectionFromTarget as Xx,isHTMLElement as nc,PASTE_COMMAND as zx}from"lexical";import{useEffect as Zx}from"react";import{c as za}from"react/compiler-runtime";import{jsx as en}from"react/jsx-runtime";import{useLexicalComposerContext as Za}from"@lexical/react/LexicalComposerContext.js";import{toast as Rx}from"@payloadcms/ui";import{$getNodeByKey as Ix,COMMAND_PRIORITY_EDITOR as Ya}from"lexical";import{useEffect as qa,useState as vx}from"react";var Mx=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Ix(o);n&&n.replace(fe({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(tn,{fields:null,relationTo:e,value:r})},Dx=t=>{let e=za(13),{enabledCollectionSlugs:o}=t,[r]=Za(),[n,l]=vx(null),s;e[0]!==o?(s={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=s):s=e[1];let{closeListDrawer:i,ListDrawer:d,openListDrawer:c}=Pt(s),u,a;e[2]!==r||e[3]!==c?(u=()=>r.registerCommand(ze,f=>(l(f?.replace?f?.replace.nodeKey:null),c(),!0),Ya),a=[r,c],e[2]=r,e[3]=c,e[4]=u,e[5]=a):(u=e[4],a=e[5]),qa(u,a);let m;e[6]!==i||e[7]!==r||e[8]!==n?(m=f=>{let{collectionSlug:g,doc:k}=f;i(),Mx({editor:r,relationTo:g,replaceNodeKey:n,value:k.id})},e[6]=i,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,h;return e[10]!==d||e[11]!==p?(h=en(d,{onSelect:p}),e[10]=d,e[11]=p,e[12]=h):h=e[12],h},$x=()=>{let t=za(3),[e]=Za(),o,r;return t[0]!==e?(o=()=>e.registerCommand(ze,Ox,Ya),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),qa(o,r),null},Qa=({enabledCollectionSlugs:t})=>t?.length?en(Dx,{enabledCollectionSlugs:t}):en($x,{});function Ox(){return Rx.error("No upload collections enabled"),!0}function Yx(t){let e=t.target;return!!(nc(e)&&!e.closest("code, span.editor-image")&&nc(e.parentElement)&&e.parentElement.closest("div.ContentEditable__root"))}function qx(t){let e,o=Xx(t.target);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&o!==null)o.collapse(t.rangeParent,t.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var tn=Jx("INSERT_UPLOAD_COMMAND"),ic=t=>{let e=Ax(21),{clientProps:o}=t,[r]=Px(),n=o?.disabledCollections,l=o?.enabledCollections,s;e[0]!==n||e[1]!==l?(s={collectionSlugsBlacklist:n,collectionSlugsWhitelist:l,uploads:!0},e[0]=n,e[1]=l,e[2]=s):s=e[2];let{enabledCollectionSlugs:i}=ko(s),{drawerSlug:d,setCollectionSlug:c,setInitialForms:u,setOnCancel:a,setOnSuccess:m,setSelectableCollections:p}=jx(),{isModalOpen:h,openModal:f}=Ux(),g;e[3]!==d||e[4]!==r||e[5]!==i||e[6]!==h||e[7]!==f||e[8]!==c||e[9]!==u||e[10]!==a||e[11]!==m||e[12]!==p?(g=C=>{let{files:x}=C;if(x?.length!==0&&(u(b=>[...b??[],...x.map(Qx)]),!h(d))){if(!i.length||!i[0])return;c(i[0]),p(i),a(()=>{r.update(eC)}),m(b=>{let _=new Map(b.map(tC));r.update(()=>{for(let D of lc()){let I=D.node;if(dt(I)){let y=I.getData();if(y?.pending){let S=_.get(y.pending?.formID);S&&I.replace(fe({data:{id:new rn.default().toHexString(),fields:{},relationTo:S.collectionSlug,value:S.doc.id}}))}}}})}),f(d)}},e[3]=d,e[4]=r,e[5]=i,e[6]=h,e[7]=f,e[8]=c,e[9]=u,e[10]=a,e[11]=m,e[12]=p,e[13]=g):g=e[13];let k=Hx(g),N;e[14]!==r||e[15]!==k?(N=()=>{if(!r.hasNodes([pe]))throw new Error("UploadPlugin: UploadNode not registered on editor");return Bx(r.registerNodeTransform(pe,C=>{let x=C.getData();if(!x?.pending)return;(async function(){let D=null,I=x?.pending?.src,y=x?.pending?.formID;if(I?.startsWith("data:")){let S=I.match(/data:(image\/[a-zA-Z]+);base64,/),w=S?S[1]:"image/png",L=I.replace(/^data:image\/[a-zA-Z]+;base64,/,""),E=atob(L),v=new Array(E.length);for(let F=0;F<E.length;F++)v[F]=E.charCodeAt(F);let $=new Uint8Array(v);D={alt:void 0,file:new File([$],"pasted-image."+w?.split("/",2)[1],{type:w}),formID:y}}else if(I?.startsWith("http")||I?.startsWith("https")){let w=await(await fetch(I)).blob(),L=I.split("/").pop()||"pasted-image"+w.type.split("/",2)[1];D={alt:void 0,file:new File([w],L,{type:w.type}),formID:y}}D&&k({files:[D]})})()}),r.registerCommand(tn,C=>(r.update(()=>{let x=tc()||ec();if(oc(x)){let b=fe({data:{id:C.id,fields:C.fields,relationTo:C.relationTo,value:C.value}}),{focus:_}=x,D=_.getNode();on(b),nn(D)&&!D.__first&&D.remove()}}),!0),Vx),r.registerCommand(zx,C=>{if(!(C instanceof ClipboardEvent))return!1;let x=C.clipboardData;if(!x?.types?.length||x?.types?.includes("text/html"))return!1;let b=[];return x?.files?.length&&Array.from(x.files).forEach(_=>{b.push({alt:"",file:_,formID:new rn.default().toHexString()})}),b.length?(r.update(()=>{let _=tc()||ec();if(oc(_))for(let D of b){let I=fe({data:{pending:{formID:D.formID,src:URL.createObjectURL(D.file)}}}),{focus:y}=_,S=y.getNode();on(I),nn(S)&&!S.__first&&S.remove()}}),k({files:b}),!0):!1},rc),r.registerCommand(Kx,C=>{if(!(C instanceof DragEvent))return!1;let x=C.dataTransfer;if(!x?.types?.length)return!1;let b=[];return x?.files?.length&&Array.from(x.files).forEach(_=>{b.push({alt:"",file:_,formID:new rn.default().toHexString()})}),b.length?(C.preventDefault(),C.stopPropagation(),r.update(()=>{if(Yx(C)){let _=qx(C),D=Wx();_!=null&&D.applyDOMRange(_),Gx(D);for(let I of b){let y=fe({data:{pending:{formID:I.formID,src:URL.createObjectURL(I.file)}}}),{focus:S}=D,w=S.getNode();on(y),nn(w)&&!w.__first&&w.remove()}}}),k({files:b}),!0):!1},rc))},e[14]=r,e[15]=k,e[16]=N):N=e[16];let R;e[17]!==r?(R=[r],e[17]=r,e[18]=R):R=e[18],Zx(N,R);let T;return e[19]!==i?(T=Fx(Qa,{enabledCollectionSlugs:i}),e[19]=i,e[20]=T):T=e[20],T};function Qx(t){return{file:t.file,formID:t.formID}}function eC(){for(let t of lc()){let e=t.node;dt(e)&&e.getData()?.pending&&e.remove()}}function tC(t){return[t.formID,t]}var rC=M({nodes:[pe],plugins:[{Component:ic,position:"normal"}],slashMenu:{groups:[X([{Icon:Qr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(ze,{replace:!1})}}])]},toolbarFixed:{groups:[ke([{ChildComponent:Qr,isActive:({selection:t})=>{if(!oC(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return dt(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(ze,{replace:!1})}}])]}});import{c as lC}from"react/compiler-runtime";import{jsx as Oo}from"react/jsx-runtime";import{createElement as iC}from"react";import{ShimmerEffect as sC,useConfig as aC}from"@payloadcms/ui";import{lazy as cC,Suspense as uC,useEffect as dC,useState as mC}from"react";var sc={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",inlineBlock:"LexicalEditorTheme__inlineBlock",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",placeholder:"LexicalEditorTheme__placeholder",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"LexicalEditorTheme__upload"};var ln={namespace:"lexical",theme:sc};function ac({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:l}){let s=new Map;for(let c of l.features){if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");s.set(c.clientFeatureProps.featureKey,c)}l.features=l.features.sort((c,u)=>c.clientFeatureProps.order-u.clientFeatureProps.order);let i=new Map,d=0;for(let c of l.features){let u=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:s,field:r,resolvedFeatures:i,schemaPath:n,unSanitizedEditorConfig:l}):c.feature;u.key=c.clientFeatureProps.featureKey,u.order=d,i.set(c.clientFeatureProps.featureKey,u),d++}return i}import{deepMerge as nC}from"payload/shared";var cc=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,l)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+l,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let l=e.toolbarInline.groups.find(s=>s.key===n.key);l?e.toolbarInline.groups=e.toolbarInline.groups.filter(s=>s.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarInline?.groups.push(l)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let l=e.toolbarFixed.groups.find(s=>s.key===n.key);l?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(s=>s.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarFixed?.groups.push(l)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let l=e.slashMenu.groups.find(s=>s.key===n.key);l?e.slashMenu.groups=e.slashMenu.groups.filter(s=>s.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.slashMenu.groups.push(l)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?nC(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);return e};function sn(t,e,o,r){return{admin:o,features:cc(t),lexical:e,resolvedFeatureMap:t,view:r}}var pC=cC(()=>import("./Field-J6MIUIWP.js").then(t=>({default:t.RichText}))),fC=t=>Oo(Uo,{inheritable:!0,views:t.views,children:Oo(hC,{...t})}),hC=t=>{let e=lC(23),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:l,field:s,lexicalEditorConfig:i,schemaPath:d,views:c}=t,u;e[0]!==o?(u=o===void 0?{}:o,e[0]=o,e[1]=u):u=e[1];let a=u,m;e[2]!==n?(m=n===void 0?{}:n,e[2]=n,e[3]=m):m=e[3];let p=m,h=i===void 0?ln:i,{currentView:f}=Wo(),g=c?.[f]?.admin??a,k=c?.[f]?.lexical,N;e[4]!==h||e[5]!==k?(N=typeof k=="function"?k(h):k??h,e[4]=h,e[5]=k,e[6]=N):N=e[6];let R=N,{config:T}=aC(),[C,x]=mC(null),b,_;e[7]!==r||e[8]!==T||e[9]!==f||e[10]!==g||e[11]!==R||e[12]!==p||e[13]!==l||e[14]!==s||e[15]!==C||e[16]!==d||e[17]!==c?(b=()=>{if(C&&C.view===f)return;let I=c?.[f],y=I?.filterFeatures?I.filterFeatures(r):r,S=[];for(let L of Object.values(y))L.clientFeatureProvider&&S.push(L.clientFeatureProvider(L.clientFeatureProps));let w=ac({config:T,featureClientImportMap:p,featureClientSchemaMap:l,field:s,schemaPath:d??s.name,unSanitizedEditorConfig:{features:S,lexical:R}});x(sn(w,R,g,f))},_=[g,r,T,p,l,s,C,R,d,f,c],e[7]=r,e[8]=T,e[9]=f,e[10]=g,e[11]=R,e[12]=p,e[13]=l,e[14]=s,e[15]=C,e[16]=d,e[17]=c,e[18]=b,e[19]=_):(b=e[18],_=e[19]),dC(b,_);let D;return e[20]!==C||e[21]!==t?(D=Oo(uC,{fallback:Oo(sC,{height:"35vh"}),children:C&&iC(pC,{...t,editorConfig:C,key:C.view})}),e[20]=C,e[21]=t,e[22]=D):D=e[22],D};function gC(t){return t instanceof HTMLElement}function xC(...t){return t.filter(Boolean).join(" ")}var Ao=new WeakMap;function uc(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function Fo(t,e){let o=Ao.get(t);if(o===void 0){let r=new Set,n=s=>{o!==void 0&&(o.start=uc(s))},l=s=>{if(o===void 0)return;let{start:i}=o;if(i===null)return;let d=uc(s);for(let c of r)d!==null&&c([d[0]-i[0],d[1]-i[1]],s)};t.addEventListener("touchstart",n),t.addEventListener("touchend",l),o={handleTouchend:l,handleTouchstart:n,listeners:r,start:null},Ao.set(t,o)}return o.listeners.add(e),()=>{CC(t,e)}}function CC(t,e){let o=Ao.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(Ao.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function bC(t,e){return Fo(t,(o,r)=>{let[n,l]=o;n<0&&-n>Math.abs(l)&&e(n,r)})}function kC(t,e){return Fo(t,(o,r)=>{let[n,l]=o;n>0&&n>Math.abs(l)&&e(n,r)})}function _C(t,e){return Fo(t,(o,r)=>{let[n,l]=o;l<0&&-l>Math.abs(n)&&e(n,r)})}function TC(t,e){return Fo(t,(o,r)=>{let[n,l]=o;l>0&&l>Math.abs(n)&&e(n,r)})}import{c as wC}from"react/compiler-runtime";import{jsx as SC}from"react/jsx-runtime";import"react";var EC=()=>{let t=wC(2),{EditButton:e}=Ce(),o;return t[0]!==e?(o=e?SC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as NC}from"react/compiler-runtime";import{jsx as LC}from"react/jsx-runtime";import"react";var yC=()=>{let t=NC(2),{RemoveButton:e}=Ce(),o;return t[0]!==e?(o=e?LC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as RC}from"react/compiler-runtime";import{jsx as IC}from"react/jsx-runtime";import"react";var vC=()=>{let t=RC(2),{Label:e}=Ce(),o;return t[0]!==e?(o=e?IC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as MC}from"react/compiler-runtime";import{jsx as DC}from"react/jsx-runtime";import"react";var $C=t=>{let e=MC(3),{children:o}=t,{InlineBlockContainer:r}=Ce(),n;return e[0]!==r||e[1]!==o?(n=r?DC(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{jsx as OC}from"react/jsx-runtime";import"react";var AC=t=>{let{children:e,...o}=t,{BlockCollapsible:r}=ie();return r?OC(r,{...o,children:e}):null};import{c as FC}from"react/compiler-runtime";import{jsx as PC}from"react/jsx-runtime";import"react";var BC=()=>{let t=FC(2),{EditButton:e}=ie(),o;return t[0]!==e?(o=e?PC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as jC}from"react/compiler-runtime";import{jsx as HC}from"react/jsx-runtime";import"react";var UC=()=>{let t=jC(2),{RemoveButton:e}=ie(),o;return t[0]!==e?(o=e?HC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as WC}from"qs-esm";var GC=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:l,collectionSlug:s,select:i})=>{let d=WC({depth:e??0,draft:o??!1,locale:r,select:i},{addQueryPrefix:!0});return await fetch(`${t}/${s}/${l}${d}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(u=>u.json())};var dc={customEndRegex:{optional:!0,regExp:/[ \t]*```$/},customStartRegex:/^[ \t]*```(\w+)?/,doNotTrimChildren:!0,export:({fields:t})=>!t.code.includes(`
61
61
  `)&&!t.language?.length?"```"+t.code+"```":"```"+(t.language||"")+(t.code?`
62
62
  `+t.code:"")+"\n```",import:({children:t,closeMatch:e,openMatch:o})=>{let r=o?.[1];return t.startsWith(`
63
63
  `)&&(t=t.slice(1)),t.endsWith(`
@@ -0,0 +1,160 @@
1
+ import { createHeadlessEditor } from '@lexical/headless';
2
+ import { LinkNode } from '@lexical/link';
3
+ import { ListItemNode, ListNode } from '@lexical/list';
4
+ import { HeadingNode, QuoteNode } from '@lexical/rich-text';
5
+ import { $getRoot, $getState, $isElementNode, $isLineBreakNode, $isTextNode } from 'lexical';
6
+ import { describe, expect, it } from 'vitest';
7
+ import { $convertFromMarkdownString, $convertToMarkdownString } from './index.js';
8
+ import { hardLineBreakState, normalizeMarkdown } from './MarkdownTransformers.js';
9
+ function createEditor() {
10
+ return createHeadlessEditor({
11
+ nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode]
12
+ });
13
+ }
14
+ function importMarkdown(markdown) {
15
+ const editor = createEditor();
16
+ editor.update(() => $convertFromMarkdownString(markdown), {
17
+ discrete: true
18
+ });
19
+ let result = {
20
+ hasLineBreak: false,
21
+ textContent: ''
22
+ };
23
+ editor.getEditorState().read(() => {
24
+ const firstChild = $getRoot().getFirstChild();
25
+ if (!$isElementNode(firstChild)) {
26
+ throw new Error('Expected an element block');
27
+ }
28
+ result = {
29
+ hasLineBreak: firstChild.getChildren().some(child => $isLineBreakNode(child)),
30
+ textContent: firstChild.getTextContent()
31
+ };
32
+ });
33
+ return result;
34
+ }
35
+ // Returns the hard line break marker stored on the first LineBreakNode of the
36
+ // first block, plus the text content of every text node in that block. Used to
37
+ // assert the marker was moved off the text and onto the line break node, even
38
+ // when the trailing whitespace was split into its own text node by an inline
39
+ // transformer (e.g. after bold or a link).
40
+ function getStoredHardLineBreak(markdown) {
41
+ const editor = createEditor();
42
+ editor.update(() => $convertFromMarkdownString(markdown), {
43
+ discrete: true
44
+ });
45
+ let result = {
46
+ marker: '',
47
+ textNodeTexts: []
48
+ };
49
+ editor.getEditorState().read(() => {
50
+ const block = $getRoot().getFirstChild();
51
+ if (!$isElementNode(block)) {
52
+ throw new Error('Expected an element block');
53
+ }
54
+ const lineBreakNode = block.getChildren().find(child => $isLineBreakNode(child));
55
+ if (lineBreakNode === undefined) {
56
+ throw new Error('Expected a line break node');
57
+ }
58
+ result = {
59
+ marker: $getState(lineBreakNode, hardLineBreakState),
60
+ textNodeTexts: block.getChildren().filter($isTextNode).map(child => child.getTextContent())
61
+ };
62
+ });
63
+ return result;
64
+ }
65
+ function roundTrip(markdown) {
66
+ const editor = createEditor();
67
+ editor.update(() => $convertFromMarkdownString(markdown), {
68
+ discrete: true
69
+ });
70
+ let output = '';
71
+ editor.getEditorState().read(() => {
72
+ output = $convertToMarkdownString();
73
+ });
74
+ return output;
75
+ }
76
+ describe('markdown hard line break normalization', () => {
77
+ it('should preserve trailing-space hard breaks when merging adjacent lines', () => {
78
+ const md = ['foo ', 'bar'].join('\n');
79
+ expect(normalizeMarkdown(md, true)).toBe(md);
80
+ });
81
+ it('should preserve the exact number of trailing spaces', () => {
82
+ const md = ['foo ', 'bar'].join('\n');
83
+ expect(normalizeMarkdown(md, true)).toBe(md);
84
+ });
85
+ it('should preserve backslash hard breaks when merging adjacent lines', () => {
86
+ const md = 'foo\\\nbar';
87
+ expect(normalizeMarkdown(md, true)).toBe(md);
88
+ });
89
+ it('should still merge a soft break into the previous line', () => {
90
+ const md = ['foo', 'bar'].join('\n');
91
+ expect(normalizeMarkdown(md, true)).toBe('foo bar');
92
+ });
93
+ it('should merge a soft break before a hard-breaking line', () => {
94
+ const md = ['foo', 'bar ', 'baz'].join('\n');
95
+ expect(normalizeMarkdown(md, true)).toBe(['foo bar ', 'baz'].join('\n'));
96
+ });
97
+ });
98
+ describe('markdown hard line break import', () => {
99
+ it('should import a trailing-space hard break as a line break node with the marker stripped', () => {
100
+ const {
101
+ hasLineBreak,
102
+ textContent
103
+ } = importMarkdown(['foo ', 'bar'].join('\n'));
104
+ expect(hasLineBreak).toBe(true);
105
+ // The marker is stripped from the text and represented by the line break node.
106
+ expect(textContent).toBe('foo\nbar');
107
+ });
108
+ it('should import a backslash hard break as a line break node with the marker stripped', () => {
109
+ const {
110
+ hasLineBreak,
111
+ textContent
112
+ } = importMarkdown('foo\\\nbar');
113
+ expect(hasLineBreak).toBe(true);
114
+ expect(textContent).toBe('foo\nbar');
115
+ });
116
+ it('should store the marker on the line break when the hard break follows formatted text', () => {
117
+ const {
118
+ marker,
119
+ textNodeTexts
120
+ } = getStoredHardLineBreak('**foo** \nbar');
121
+ expect(marker).toBe(' ');
122
+ // The trailing-space marker is split into its own text node by the bold
123
+ // transformer; it must be moved onto the line break node, not left as text.
124
+ expect(textNodeTexts).not.toContain(' ');
125
+ });
126
+ it('should store the exact number of trailing spaces when the hard break follows formatted text', () => {
127
+ const {
128
+ marker
129
+ } = getStoredHardLineBreak('**foo** \nbar');
130
+ expect(marker).toBe(' ');
131
+ });
132
+ it('should store the marker on the line break when the hard break follows a link', () => {
133
+ const {
134
+ marker
135
+ } = getStoredHardLineBreak('[foo](https://payloadcms.com) \nbar');
136
+ expect(marker).toBe(' ');
137
+ });
138
+ });
139
+ describe('markdown hard line break round trip', () => {
140
+ it('should round trip a trailing-space hard break', () => {
141
+ const md = ['foo ', 'bar'].join('\n');
142
+ expect(roundTrip(md)).toBe(md);
143
+ });
144
+ it('should round trip a backslash hard break', () => {
145
+ const md = 'foo\\\nbar';
146
+ expect(roundTrip(md)).toBe(md);
147
+ });
148
+ it('should not introduce a hard break for a soft wrap', () => {
149
+ expect(roundTrip(['foo', 'bar'].join('\n'))).toBe('foo bar');
150
+ });
151
+ it('should round trip a hard break after formatted text', () => {
152
+ const md = '**foo** \nbar';
153
+ expect(roundTrip(md)).toBe(md);
154
+ });
155
+ it('should round trip a hard break after a link', () => {
156
+ const md = '[foo](https://payloadcms.com) \nbar';
157
+ expect(roundTrip(md)).toBe(md);
158
+ });
159
+ });
160
+ //# sourceMappingURL=LexicalMarkdownHardLineBreak.spec.js.map