@payloadcms/richtext-lexical 3.21.0-canary.db74962 → 3.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/react/components/RichText/converter/converters/list.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/list.js +7 -1
- package/dist/exports/react/components/RichText/converter/converters/list.js.map +1 -1
- package/dist/exports/react/components/RichText/index.d.ts +0 -1
- package/dist/exports/react/components/RichText/index.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/index.js +0 -1
- package/dist/exports/react/components/RichText/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +3 -8
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js +0 -2
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +0 -1
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/utilities/buildInitialState.d.ts +0 -1
- package/dist/utilities/buildInitialState.d.ts.map +1 -1
- package/dist/utilities/buildInitialState.js +0 -1
- package/dist/utilities/buildInitialState.js.map +1 -1
- package/package.json +7 -7
- package/dist/exports/react/components/RichText/index.css +0 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use client";import{a as
|
|
1
|
+
"use client";import{a as de,c as co,d as uo,e as mo}from"./chunk-KDV47ZNZ.js";import{a as ze}from"./chunk-DBWINSQN.js";import{a as Ye,b as Lt,c as Pe}from"./chunk-QP2NYEWJ.js";import{a as ue}from"./chunk-INBEEENE.js";import{a as ks}from"./chunk-F26IQ5RE.js";import{a as Es,b as kr,d as Lr,e as Nr,f as Ls,g as Ns,h as Rs,j as Ss,l as Is,m as ys}from"./chunk-JKFXKPNG.js";import{a as ws,b as P}from"./chunk-3LGFOM34.js";function V(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{$isElementNode as we,$isRangeSelection as Rt,FORMAT_ELEMENT_COMMAND as St}from"lexical";import{jsx as po,jsxs as vs}from"react/jsx-runtime";import"react";var Rr=()=>vs("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:[po("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),po("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),po("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as fo,jsxs as Ms}from"react/jsx-runtime";import"react";var Sr=()=>Ms("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:[fo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),fo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),fo("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as ho,jsxs as Ds}from"react/jsx-runtime";import"react";var Nt=()=>Ds("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:[ho("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ho("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ho("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as go,jsxs as As}from"react/jsx-runtime";import"react";var Ir=()=>As("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:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var y=t=>o=>{let r={clientFeatureProps:o};if(typeof t=="function")r.feature=({featureClientSchemaMap:n,featureProviderMap:i,field:l,resolvedFeatures:s,schemaPath:a,unSanitizedEditorConfig:u})=>{let c=t({featureClientSchemaMap:n,featureProviderMap:i,field:l,props:o,resolvedFeatures:s,schemaPath:a,unSanitizedEditorConfig:u});return c.sanitizedClientFeatureProps===null&&(c.sanitizedClientFeatureProps=o),c};else{let n={...t};n.sanitizedClientFeatureProps=o,r.feature=n}return r};var yr=t=>({type:"dropdown",ChildComponent:Nt,items:t,key:"align",order:30});var vr=[yr([{ChildComponent:Nt,isActive:({selection:t})=>{if(!Rt(t))return!1;for(let e of t.getNodes()){if(we(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(we(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(St,"left")},order:1},{ChildComponent:Rr,isActive:({selection:t})=>{if(!Rt(t))return!1;for(let e of t.getNodes()){if(we(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(we(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(St,"center")},order:2},{ChildComponent:Ir,isActive:({selection:t})=>{if(!Rt(t))return!1;for(let e of t.getNodes()){if(we(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(we(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(St,"right")},order:3},{ChildComponent:Sr,isActive:({selection:t})=>{if(!Rt(t))return!1;for(let e of t.getNodes()){if(we(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(we(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(St,"justify")},order:4}])],Os=y({toolbarFixed:{groups:vr},toolbarInline:{groups:vr}});import{$createQuoteNode as Pr,$isQuoteNode as $r,QuoteNode as Bs}from"@lexical/rich-text";import{$setBlocksType as Br}from"@lexical/selection";import{$getSelection as Hr,$isRangeSelection as Hs}from"lexical";import{jsx as Mr}from"react/jsx-runtime";import"react";var Co=()=>Mr("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:Mr("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 Dr}from"react/jsx-runtime";import"react";var Xe=()=>Dr("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:Dr("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 X=t=>({type:"dropdown",ChildComponent:Xe,items:t,key:"text",order:25});import{$createQuoteNode as $s,$isQuoteNode as Ar,QuoteNode as Fs}from"@lexical/rich-text";import{$createLineBreakNode as Ps}from"lexical";var Or={type:"element",dependencies:[Fs],export:(t,e)=>{if(!Ar(t))return null;let o=e(t).split(`
|
|
2
2
|
`),r=[];for(let n of o)r.push("> "+n);return r.join(`
|
|
3
|
-
`)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let i=t.getPreviousSibling();if(Or(i)){i.splice(i.getChildrenSize(),0,[Hs(),...e]),i.select(0,0),t.remove();return}}let n=Ps();n.append(...e),t.replace(n),n.select(0,0)}};var Pr=[z([{ChildComponent:Co,isActive:({selection:t})=>{if(!Us(t))return!1;for(let e of t.getNodes())if(!$r(e)&&!$r(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=jr();Hr(e,()=>Br())})},order:20}])],Gs=y({markdownTransformers:[Fr],nodes:[js],slashMenu:{groups:[V([{Icon:Co,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=jr();Hr(e,()=>Br())})}}])]},toolbarFixed:{groups:Pr},toolbarInline:{groups:Pr}});import{getTranslation as Ft}from"@payloadcms/translations";import{jsx as xo,jsxs as Ws}from"react/jsx-runtime";import"react";var yt=()=>Ws("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:[xo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),xo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),xo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as Ur}from"react/jsx-runtime";import"react";var vt=()=>Ur("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:Ur("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 Vs}from"react/jsx-runtime";import"react";function Mt(t,e){return t?()=>Vs("img",{alt:e??"Block Image",className:"lexical-block-custom-image",src:t,style:{maxHeight:20,maxWidth:20}}):yt}import{jsx as wa}from"react/jsx-runtime";import Ea from"bson-objectid";import"react";import{DecoratorBlockNode as Ks}from"@lexical/react/LexicalDecoratorBlockNode.js";import Zs from"bson-objectid";var Qe=class extends Ks{__cacheBuster;__fields;constructor({cacheBuster:e,fields:o,format:r,key:n}){super(r,n),this.__fields=o,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,format:e.__format,key:e.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Ys(e.fields);return o.setFormat(e.format),o}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div"),o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e,o){let r=this.getWritable();r.__fields=e,o||r.__cacheBuster++}};function Ys(t){return new Qe({fields:{...t,id:t?.id||new Zs.default().toHexString()}})}import{jsx as G,jsxs as et,Fragment as ta}from"react/jsx-runtime";import{Button as Kr,Collapsible as oa,Drawer as ra,EditDepthProvider as na,ErrorPill as ia,Form as la,formatDrawerSlug as sa,FormSubmit as aa,Pill as ca,RenderFields as ua,SectionTitle as da,useDocumentForm as ma,useDocumentInfo as Zr,useEditDepth as pa,useFormSubmitted as fa,useServerFunctions as ha,useTranslation as ga}from"@payloadcms/ui";import{abortAndIgnore as bo}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as _o,reduceFieldsToValues as Ca}from"payload/shared";import tt,{useCallback as To,useEffect as wo,useMemo as ot,useRef as xa}from"react";import{useLexicalComposerContext as ba}from"@lexical/react/LexicalComposerContext";import{getTranslation as _a}from"@payloadcms/translations";import{$getNodeByKey as Eo}from"lexical";import{v4 as Ta}from"uuid";import{c as zs}from"react/compiler-runtime";import{jsx as Dt,jsxs as Xs}from"react/jsx-runtime";import{RenderFields as Js,useFormSubmitted as qs}from"@payloadcms/ui";import Qs,{createContext as ea}from"react";var Gr=ea({initialState:!1}),Re=()=>Qs.useContext(Gr),Wr=t=>{let e=zs(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:s,initialState:a,nodeKey:u,RemoveButton:c}=t,m=qs()&&l>0,p,f;e[0]!==r||e[1]!==l||e[2]!==m?(f=b=>Dt(r,{editButton:b.editButton,errorCount:l,fieldHasErrors:m,Label:b.Label,removeButton:b.removeButton,children:b.children}),e[0]=r,e[1]=l,e[2]=m,e[3]=f):f=e[3],p=f;let h=p,C;return e[4]!==o||e[5]!==h||e[6]!==n||e[7]!==i||e[8]!==c||e[9]!==s||e[10]!==a||e[11]!==u?(C=n?Xs(Gr.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:a,nodeKey:u,RemoveButton:c},children:[n,Dt(o,{})]}):Dt(h,{children:Dt(Js,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=o,e[5]=h,e[6]=n,e[7]=i,e[8]=c,e[9]=s,e[10]=a,e[11]=u,e[12]=C):C=e[12],C};function Vr({fields:t}){for(let e in t){let o=t[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var ee="lexical-block",Yr=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=fa(),{id:i,collectionSlug:l,globalSlug:s}=Zr(),{fieldProps:{featureClientSchemaMap:a,field:u,initialLexicalFormState:c,permissions:d,readOnly:m,schemaPath:p},uuid:f}=P(),{fields:h}=ma(),C=xa(new AbortController),b=pa(),[k,v]=tt.useState(0),x=sa({slug:`lexical-blocks-create-${f}-${o.id}`,depth:b}),{toggleDrawer:T}=ae(x),{getDocPreferences:g,setDocFieldPreferences:w}=Zr(),[N]=ba(),{getFormState:L}=ha(),R=`${p}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}.fields`,[S,E]=tt.useState(c?.[o.id]?.formState?{...c?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1);wo(()=>{E(!1)},[e]);let[_,I]=tt.useState(S?._components?.customComponents?.BlockLabel),[M,D]=tt.useState(S?._components?.customComponents?.Block);wo(()=>{let B=new AbortController;return o&&!S&&(async()=>{let{state:U}=await L({id:i,collectionSlug:l,data:o,docPermissions:{fields:!0},docPreferences:await g(),fullFormStateOverride:_o(h),globalSlug:s,operation:"update",renderAllFields:!0,schemaPath:R,signal:B.signal});U&&(U.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName},E(U),I(U._components?.customComponents?.BlockLabel),D(U._components?.customComponents?.Block))})(),()=>{bo(B)}},[L,R,i,o,S,l,s,g,h]);let[F,A]=tt.useState(c?.[o.id]?.collapsed??!1),H=`${p}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}`,J=a.blocks[H]?.[0]?.blocks?.[0],{i18n:Ne,t:j}=ga(),Q=To(async({formState:B,submit:re})=>{bo(C.current);let U=new AbortController;C.current=U;let{state:Y}=await L({id:i,collectionSlug:l,docPermissions:{fields:!0},docPreferences:await g(),formState:B,fullFormStateOverride:_o(h),globalSlug:s,operation:"update",renderAllFields:!!re,schemaPath:R,signal:U.signal});if(!Y)return B;Y.blockName=B.blockName;let q=Ca(Vr({fields:_o(Y)}),!0);if(setTimeout(()=>{N.update(()=>{let se=Eo(r);if(se&&At(se)){let Pe=q;Pe.blockType=o.blockType,se.setFields(Pe,!0)}})},0),re){I(Y._components?.customComponents?.BlockLabel),D(Y._components?.customComponents?.Block);let se=0;for(let Pe of Object.values(Y))Pe?.valid===!1&&se++;v(se)}return Y},[L,i,l,g,s,R,o.blockType,h,N,r]);wo(()=>()=>{bo(C.current)},[]);let Ye=To(()=>{N.update(()=>{Eo(r)?.remove()})},[N,r]),_e=J?.labels?.singular?_a(J.labels.singular,Ne):J?.slug,Te=To(B=>{g().then(re=>{let Y=re?.fields?.[u.name]?.collapsed,q=Y&&Y?.length?Y:[];B?q.includes(o.id)||q.push(o.id):q.includes(o.id)&&q.splice(q.indexOf(o.id),1),w(u.name,{collapsed:q,hello:"hi"})})},[g,u.name,w,o.id]),Fe=ot(()=>()=>G(Kr,{buttonStyle:"icon-label",className:`${ee}__editButton`,disabled:m,el:"button",icon:"edit",onClick:B=>(B.preventDefault(),B.stopPropagation(),T(),!1),onMouseDown:B=>{B.preventDefault()},round:!0,size:"small",tooltip:j("lexical:blocks:inlineBlocks:edit",{label:_e})}),[_e,m,j,T]),$e=ot(()=>()=>G(Kr,{buttonStyle:"icon-label",className:`${ee}__removeButton`,disabled:u?.admin?.readOnly||!1,icon:"x",onClick:B=>{B.preventDefault(),Ye()},round:!0,tooltip:"Remove Block"}),[u?.admin?.readOnly,Ye]),ze=ot(()=>({children:B,disableBlockName:re,editButton:U,errorCount:Y,fieldHasErrors:q,Label:se,removeButton:Pe})=>G("div",{className:ee+" "+ee+"-"+o.blockType,children:G(oa,{className:[`${ee}__row`,q?`${ee}__row--has-errors`:`${ee}__row--no-errors`].join(" "),collapsibleStyle:q?"error":"default",header:et("div",{className:`${ee}__block-header`,children:[se??_?se??_:et("div",{children:[G(ca,{className:`${ee}__block-pill ${ee}__block-pill-${o?.blockType}`,pillStyle:"white",children:_e??o?.blockType}),!re&&G(da,{path:"blockName",readOnly:u?.admin?.readOnly||!1}),q&&G(ia,{count:Y??0,i18n:Ne,withMessage:!0})]}),et("div",{children:[M&&U!==!1||!M&&U?G(Fe,{}):null,Pe!==!1&&N.isEditable()?G($e,{}):null]})]}),isCollapsed:F,onToggle:kr=>{Te(kr),A(kr)},children:B},0)}),[M,_,Fe,$e,_e,N,o.blockType,Ne,F,Te,u?.admin?.readOnly]),Lt=ot(()=>()=>G(na,{children:G(ra,{className:"",slug:x,title:j(`lexical:blocks:inlineBlocks:${o?.id?"edit":"create"}`,{label:_e??j("lexical:blocks:inlineBlocks:label")}),children:S?et(ta,{children:[G(ua,{fields:J?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:R,permissions:d,readOnly:!1}),G(aa,{programmaticSubmit:!0,children:j("fields:saveChanges")})]}):null})}),[S,x,_e,j,J?.fields,R,d]),Es=ot(()=>S?G(la,{beforeSubmit:[async({formState:B})=>await Q({formState:B,submit:!0})],fields:J?.fields,initialState:S,onChange:[Q],onSubmit:(B,re)=>{re.blockType=o.blockType,N.update(()=>{let U=Eo(r);U&&At(U)&&U.setFields(re,!0)}),T()},submitted:n,uuid:Ta(),children:G(Wr,{baseClass:ee,BlockDrawer:Lt,Collapsible:ze,CustomBlock:M,EditButton:Fe,errorCount:k,formSchema:J?.fields,initialState:S,nodeKey:r,RemoveButton:$e})}):null,[ze,Lt,M,$e,Fe,N,k,T,J?.fields,S,r,Q,n]);return J?Es:G(ze,{disableBlockName:!0,fieldHasErrors:!0,children:et("div",{className:"lexical-block-not-found",children:["Error: Block '",o.blockType,"' not found in the config but exists in the lexical data"]})})};var ue=class extends Qe{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Ot(e.fields);return o.setFormat(e.format),o}decorate(e,o){return wa(Yr,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ot(t){return new ue({fields:{...t,id:t?.id||new Ea.default().toHexString()}})}function At(t){return t instanceof ue}import{createCommand as zr}from"lexical";var rt=zr("INSERT_BLOCK_COMMAND"),nt=zr("INSERT_INLINE_BLOCK_COMMAND");import{c as ka}from"react/compiler-runtime";import{useLexicalComposerContext as La}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Na,$wrapNodeInElement as Ra,mergeRegister as Sa}from"@lexical/utils";import{formatDrawerSlug as Ia,useEditDepth as ya}from"@payloadcms/ui";import{$createParagraphNode as va,$getNodeByKey as Ma,$getPreviousSelection as Da,$getSelection as Aa,$insertNodes as Oa,$isParagraphNode as Jr,$isRangeSelection as Fa,$isRootOrShadowRoot as $a,COMMAND_PRIORITY_EDITOR as Xr}from"lexical";import{useEffect as Pa,useState as Ba}from"react";var qr=()=>{let t=ka(12),[e]=La(),[o,r]=Ba(null),{setCreatedInlineBlock:n,uuid:i}=P(),l=ya(),s="lexical-inlineBlocks-create-"+i,a;t[0]!==l||t[1]!==s?(a=Ia({slug:s,depth:l}),t[0]=l,t[1]=s,t[2]=a):a=t[2];let u=a,{toggleDrawer:c}=ae(u,!0),d;t[3]!==e||t[4]!==n||t[5]!==o?(d=()=>{if(!e.hasNodes([ue]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return Sa(e.registerCommand(rt,p=>(e.update(()=>{let f=Aa()||Da();if(Fa(f)){let h=Ot(p);Na(h);let{focus:C}=f,b=C.getNode();Jr(b)&&b.getTextContentSize()===0&&b.getParentOrThrow().getChildren().filter(Ha).length>1&&b.remove()}}),!0),Xr),e.registerCommand(nt,p=>{if(o){let h=Ma(o);return!h||!mo(h)?!1:(h.setFields(p),r(null),!0)}let f=uo(p);return n?.(f),Oa([f]),$a(f.getParentOrThrow())&&Ra(f,va).selectEnd(),!0},Xr))},t[3]=e,t[4]=n,t[5]=o,t[6]=d):d=t[6];let m;return t[7]!==e||t[8]!==n||t[9]!==o||t[10]!==c?(m=[e,n,o,c],t[7]=e,t[8]=n,t[9]=o,t[10]=c,t[11]=m):m=t[11],Pa(d,m),null};function Ha(t){return Jr(t)}var ja=y(({featureClientSchemaMap:t,props:e,schemaPath:o})=>{let r=`${o}.lexical_internal_feature.blocks.lexical_blocks`,n=`${o}.lexical_internal_feature.blocks.lexical_inline_blocks`,i=t.blocks,l=Object.entries(i).filter(([c])=>c.startsWith(r+".")&&!c.replace(r+".","").includes(".")).map(([c,d])=>d[0]),s=Object.entries(i).filter(([c])=>c.startsWith(n+".")&&!c.replace(n+".","").includes(".")).map(([c,d])=>d[0]),a=l.map(c=>c.blocks[0]),u=s.map(c=>c.blocks[0]);return{nodes:[ue,co],plugins:[{Component:qr,position:"normal"}],sanitizedClientFeatureProps:e,slashMenu:{groups:[a?.length?{items:a.map(c=>({Icon:Mt(c.imageURL,c.imageAltText),key:"block-"+c.slug,keywords:["block","blocks",c.slug],label:({i18n:d})=>c?.labels?.singular?Ft(c.labels.singular,d):c?.slug,onSelect:({editor:d})=>{d.dispatchCommand(rt,{blockName:"",blockType:c.slug})}})),key:"blocks",label:({i18n:c})=>c.t("lexical:blocks:label")}:null,u?.length?{items:u.map(c=>({Icon:vt,key:"inlineBlocks-"+c.slug,keywords:["inlineBlock","inline block",c.slug],label:({i18n:d})=>c?.labels?.singular?Ft(c.labels.singular,d):c?.slug,onSelect:({editor:d})=>{d.dispatchCommand(nt,{blockName:"",blockType:c.slug})}})),key:"inlineBlocks",label:({i18n:c})=>c.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[a.length?{type:"dropdown",ChildComponent:yt,items:a.map((c,d)=>({ChildComponent:Mt(c.imageURL,c.imageAltText),isActive:void 0,key:"block-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Ft(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(rt,{blockName:"",blockType:c.slug})},order:d})),key:"blocks",order:20}:null,u?.length?{type:"dropdown",ChildComponent:vt,items:u.map((c,d)=>({ChildComponent:c.imageURL?Mt(c.imageURL,c.imageAltText):vt,isActive:void 0,key:"inlineBlock-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Ft(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(nt,{blockName:"",blockType:c.slug})},order:d})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Ua}from"react/compiler-runtime";import{jsx as Ie,jsxs as Ro}from"react/jsx-runtime";import{useLexicalComposerContext as Ga}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Wa,$createTextNode as Va,$getRoot as Ka,getDOMSelection as ko}from"lexical";import*as on from"react";import{useCallback as Se,useEffect as Lo,useLayoutEffect as Qr,useRef as No,useState as $t}from"react";var Za=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},Ya=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},za=t=>{let o=((r,n)=>{switch(r){case"click":return` await page.mouse.click(${n.x}, ${n.y});`;case"keydown":return` await page.keyboard.keydown('${n}');`;case"keyup":return` await page.keyboard.keyup('${n}');`;case"press":return` await page.keyboard.press('${n}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
3
|
+
`)},regExp:/^>\s/,replace:(t,e,o,r)=>{if(r){let i=t.getPreviousSibling();if(Ar(i)){i.splice(i.getChildrenSize(),0,[Ps(),...e]),i.select(0,0),t.remove();return}}let n=$s();n.append(...e),t.replace(n),n.select(0,0)}};var Fr=[X([{ChildComponent:Co,isActive:({selection:t})=>{if(!Hs(t))return!1;for(let e of t.getNodes())if(!$r(e)&&!$r(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Hr();Br(e,()=>Pr())})},order:20}])],js=y({markdownTransformers:[Or],nodes:[Bs],slashMenu:{groups:[V([{Icon:Co,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Hr();Br(e,()=>Pr())})}}])]},toolbarFixed:{groups:Fr},toolbarInline:{groups:Fr}});import{getTranslation as Ot}from"@payloadcms/translations";import{jsx as xo,jsxs as Us}from"react/jsx-runtime";import"react";var It=()=>Us("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:[xo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),xo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),xo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as jr}from"react/jsx-runtime";import"react";var yt=()=>jr("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:jr("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 Gs}from"react/jsx-runtime";import"react";function vt(t,e){return t?()=>Gs("img",{alt:e??"Block Image",className:"lexical-block-custom-image",src:t,style:{maxHeight:20,maxWidth:20}}):It}import{jsx as _a}from"react/jsx-runtime";import Ta from"bson-objectid";import"react";import{DecoratorBlockNode as Ws}from"@lexical/react/LexicalDecoratorBlockNode.js";import Vs from"bson-objectid";var Je=class extends Ws{__cacheBuster;__fields;constructor({cacheBuster:e,fields:o,format:r,key:n}){super(r,n),this.__fields=o,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,format:e.__format,key:e.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Ks(e.fields);return o.setFormat(e.format),o}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div"),o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e,o){let r=this.getWritable();r.__fields=e,o||r.__cacheBuster++}};function Ks(t){return new Je({fields:{...t,id:t?.id||new Vs.default().toHexString()}})}import{jsx as U,jsxs as qe,Fragment as Qs}from"react/jsx-runtime";import{Button as Vr,Collapsible as ea,Drawer as ta,EditDepthProvider as oa,ErrorPill as ra,Form as na,formatDrawerSlug as ia,FormSubmit as la,Pill as sa,RenderFields as aa,SectionTitle as ca,useDocumentInfo as Kr,useEditDepth as ua,useFormSubmitted as da,useServerFunctions as ma,useTranslation as pa}from"@payloadcms/ui";import{abortAndIgnore as bo}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as fa,reduceFieldsToValues as ha}from"payload/shared";import Qe,{useCallback as _o,useEffect as To,useMemo as et,useRef as ga}from"react";import{useLexicalComposerContext as Ca}from"@lexical/react/LexicalComposerContext";import{getTranslation as xa}from"@payloadcms/translations";import{$getNodeByKey as wo}from"lexical";import{v4 as ba}from"uuid";import{c as Zs}from"react/compiler-runtime";import{jsx as Mt,jsxs as Ys}from"react/jsx-runtime";import{RenderFields as zs,useFormSubmitted as Xs}from"@payloadcms/ui";import Js,{createContext as qs}from"react";var Ur=qs({initialState:!1}),Ne=()=>Js.useContext(Ur),Gr=t=>{let e=Zs(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:s,initialState:a,nodeKey:u,RemoveButton:c}=t,m=Xs()&&l>0,p,f;e[0]!==r||e[1]!==l||e[2]!==m?(f=b=>Mt(r,{editButton:b.editButton,errorCount:l,fieldHasErrors:m,Label:b.Label,removeButton:b.removeButton,children:b.children}),e[0]=r,e[1]=l,e[2]=m,e[3]=f):f=e[3],p=f;let h=p,x;return e[4]!==o||e[5]!==h||e[6]!==n||e[7]!==i||e[8]!==c||e[9]!==s||e[10]!==a||e[11]!==u?(x=n?Ys(Ur.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:a,nodeKey:u,RemoveButton:c},children:[n,Mt(o,{})]}):Mt(h,{children:Mt(zs,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=o,e[5]=h,e[6]=n,e[7]=i,e[8]=c,e[9]=s,e[10]=a,e[11]=u,e[12]=x):x=e[12],x};function Wr({fields:t}){for(let e in t){let o=t[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var Q="lexical-block",Zr=t=>{let{cacheBuster:e,formData:o,nodeKey:r}=t,n=da(),{id:i,collectionSlug:l,globalSlug:s}=Kr(),{fieldProps:{featureClientSchemaMap:a,field:u,initialLexicalFormState:c,permissions:d,readOnly:m,schemaPath:p},uuid:f}=P(),h=ga(new AbortController),x=ua(),[b,N]=Qe.useState(0),I=ia({slug:`lexical-blocks-create-${f}-${o.id}`,depth:x}),{toggleDrawer:C}=ue(I),{getDocPreferences:T,setDocFieldPreferences:g}=Kr(),[_]=Ca(),{getFormState:S}=ma(),L=`${p}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}.fields`,[k,v]=Qe.useState(c?.[o.id]?.formState?{...c?.[o.id]?.formState,blockName:{initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName}}:!1);To(()=>{v(!1)},[e]);let[E,w]=Qe.useState(k?._components?.customComponents?.BlockLabel),[R,M]=Qe.useState(k?._components?.customComponents?.Block);To(()=>{let B=new AbortController;return o&&!k&&(async()=>{let{state:j}=await S({id:i,collectionSlug:l,data:o,docPermissions:{fields:!0},docPreferences:await T(),globalSlug:s,operation:"update",renderAllFields:!0,schemaPath:L,signal:B.signal});j&&(j.blockName={initialValue:o.blockName,passesCondition:!0,valid:!0,value:o.blockName},v(j),w(j._components?.customComponents?.BlockLabel),M(j._components?.customComponents?.Block))})(),()=>{bo(B)}},[S,L,i,o,k,l,s,T]);let[D,$]=Qe.useState(c?.[o.id]?.collapsed??!1),A=`${p}.lexical_internal_feature.blocks.lexical_blocks.${o.blockType}`,H=a.blocks[A]?.[0]?.blocks?.[0],{i18n:Oe,t:te}=pa(),Y=_o(async({formState:B,submit:ne})=>{bo(h.current);let j=new AbortController;h.current=j;let{state:z}=await S({id:i,collectionSlug:l,docPermissions:{fields:!0},docPreferences:await T(),formState:B,globalSlug:s,operation:"update",renderAllFields:!!ne,schemaPath:L,signal:j.signal});if(!z)return B;z.blockName=B.blockName;let q=ha(Wr({fields:fa(z)}),!0);if(setTimeout(()=>{_.update(()=>{let ce=wo(r);if(ce&&Dt(ce)){let Fe=q;Fe.blockType=o.blockType,ce.setFields(Fe,!0)}})},0),ne){w(z._components?.customComponents?.BlockLabel),M(z._components?.customComponents?.Block);let ce=0;for(let Fe of Object.values(z))Fe?.valid===!1&&ce++;N(ce)}return z},[S,i,l,T,s,L,o.blockType,_,r]);To(()=>()=>{bo(h.current)},[]);let oe=_o(()=>{_.update(()=>{wo(r)?.remove()})},[_,r]),ae=H?.labels?.singular?xa(H.labels.singular,Oe):H?.slug,Et=_o(B=>{T().then(ne=>{let z=ne?.fields?.[u.name]?.collapsed,q=z&&z?.length?z:[];B?q.includes(o.id)||q.push(o.id):q.includes(o.id)&&q.splice(q.indexOf(o.id),1),g(u.name,{collapsed:q,hello:"hi"})})},[T,u.name,g,o.id]),re=et(()=>()=>U(Vr,{buttonStyle:"icon-label",className:`${Q}__editButton`,disabled:m,el:"button",icon:"edit",onClick:B=>(B.preventDefault(),B.stopPropagation(),C(),!1),onMouseDown:B=>{B.preventDefault()},round:!0,size:"small",tooltip:te("lexical:blocks:inlineBlocks:edit",{label:ae})}),[ae,m,te,C]),$e=et(()=>()=>U(Vr,{buttonStyle:"icon-label",className:`${Q}__removeButton`,disabled:u?.admin?.readOnly||!1,icon:"x",onClick:B=>{B.preventDefault(),oe()},round:!0,tooltip:"Remove Block"}),[u?.admin?.readOnly,oe]),Ze=et(()=>({children:B,disableBlockName:ne,editButton:j,errorCount:z,fieldHasErrors:q,Label:ce,removeButton:Fe})=>U("div",{className:Q+" "+Q+"-"+o.blockType,children:U(ea,{className:[`${Q}__row`,q?`${Q}__row--has-errors`:`${Q}__row--no-errors`].join(" "),collapsibleStyle:q?"error":"default",header:qe("div",{className:`${Q}__block-header`,children:[ce??E?ce??E:qe("div",{children:[U(sa,{className:`${Q}__block-pill ${Q}__block-pill-${o?.blockType}`,pillStyle:"white",children:ae??o?.blockType}),!ne&&U(ca,{path:"blockName",readOnly:u?.admin?.readOnly||!1}),q&&U(ra,{count:z??0,i18n:Oe,withMessage:!0})]}),qe("div",{children:[R&&j!==!1||!R&&j?U(re,{}):null,Fe!==!1&&_.isEditable()?U($e,{}):null]})]}),isCollapsed:D,onToggle:Er=>{Et(Er),$(Er)},children:B},0)}),[R,E,re,$e,ae,_,o.blockType,Oe,D,Et,u?.admin?.readOnly]),kt=et(()=>()=>U(oa,{children:U(ta,{className:"",slug:I,title:te(`lexical:blocks:inlineBlocks:${o?.id?"edit":"create"}`,{label:ae??te("lexical:blocks:inlineBlocks:label")}),children:k?qe(Qs,{children:[U(aa,{fields:H?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:L,permissions:d,readOnly:!1}),U(la,{programmaticSubmit:!0,children:te("fields:saveChanges")})]}):null})}),[k,I,ae,te,H?.fields,L,d]),ao=et(()=>k?U(na,{beforeSubmit:[async({formState:B})=>await Y({formState:B,submit:!0})],fields:H?.fields,initialState:k,onChange:[Y],onSubmit:(B,ne)=>{ne.blockType=o.blockType,_.update(()=>{let j=wo(r);j&&Dt(j)&&j.setFields(ne,!0)}),C()},submitted:n,uuid:ba(),children:U(Gr,{baseClass:Q,BlockDrawer:kt,Collapsible:Ze,CustomBlock:R,EditButton:re,errorCount:b,formSchema:H?.fields,initialState:k,nodeKey:r,RemoveButton:$e})}):null,[Ze,kt,R,$e,re,_,b,C,H?.fields,k,r,Y,n]);return H?ao:U(Ze,{disableBlockName:!0,fieldHasErrors:!0,children:qe("div",{className:"lexical-block-not-found",children:["Error: Block '",o.blockType,"' not found in the config but exists in the lexical data"]})})};var me=class extends Je{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=At(e.fields);return o.setFormat(e.format),o}decorate(e,o){return _a(Zr,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function At(t){return new me({fields:{...t,id:t?.id||new Ta.default().toHexString()}})}function Dt(t){return t instanceof me}import{createCommand as Yr}from"lexical";var tt=Yr("INSERT_BLOCK_COMMAND"),ot=Yr("INSERT_INLINE_BLOCK_COMMAND");import{c as wa}from"react/compiler-runtime";import{useLexicalComposerContext as Ea}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as ka,$wrapNodeInElement as La,mergeRegister as Na}from"@lexical/utils";import{formatDrawerSlug as Ra,useEditDepth as Sa}from"@payloadcms/ui";import{$createParagraphNode as Ia,$getNodeByKey as ya,$getPreviousSelection as va,$getSelection as Ma,$insertNodes as Da,$isParagraphNode as Xr,$isRangeSelection as Aa,$isRootOrShadowRoot as Oa,COMMAND_PRIORITY_EDITOR as zr}from"lexical";import{useEffect as $a,useState as Fa}from"react";var Jr=()=>{let t=wa(12),[e]=Ea(),[o,r]=Fa(null),{setCreatedInlineBlock:n,uuid:i}=P(),l=Sa(),s="lexical-inlineBlocks-create-"+i,a;t[0]!==l||t[1]!==s?(a=Ra({slug:s,depth:l}),t[0]=l,t[1]=s,t[2]=a):a=t[2];let u=a,{toggleDrawer:c}=ue(u,!0),d;t[3]!==e||t[4]!==n||t[5]!==o?(d=()=>{if(!e.hasNodes([me]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return Na(e.registerCommand(tt,p=>(e.update(()=>{let f=Ma()||va();if(Aa(f)){let h=At(p);ka(h);let{focus:x}=f,b=x.getNode();Xr(b)&&b.getTextContentSize()===0&&b.getParentOrThrow().getChildren().filter(Pa).length>1&&b.remove()}}),!0),zr),e.registerCommand(ot,p=>{if(o){let h=ya(o);return!h||!mo(h)?!1:(h.setFields(p),r(null),!0)}let f=uo(p);return n?.(f),Da([f]),Oa(f.getParentOrThrow())&&La(f,Ia).selectEnd(),!0},zr))},t[3]=e,t[4]=n,t[5]=o,t[6]=d):d=t[6];let m;return t[7]!==e||t[8]!==n||t[9]!==o||t[10]!==c?(m=[e,n,o,c],t[7]=e,t[8]=n,t[9]=o,t[10]=c,t[11]=m):m=t[11],$a(d,m),null};function Pa(t){return Xr(t)}var Ba=y(({featureClientSchemaMap:t,props:e,schemaPath:o})=>{let r=`${o}.lexical_internal_feature.blocks.lexical_blocks`,n=`${o}.lexical_internal_feature.blocks.lexical_inline_blocks`,i=t.blocks,l=Object.entries(i).filter(([c])=>c.startsWith(r+".")&&!c.replace(r+".","").includes(".")).map(([c,d])=>d[0]),s=Object.entries(i).filter(([c])=>c.startsWith(n+".")&&!c.replace(n+".","").includes(".")).map(([c,d])=>d[0]),a=l.map(c=>c.blocks[0]),u=s.map(c=>c.blocks[0]);return{nodes:[me,co],plugins:[{Component:Jr,position:"normal"}],sanitizedClientFeatureProps:e,slashMenu:{groups:[a?.length?{items:a.map(c=>({Icon:vt(c.imageURL,c.imageAltText),key:"block-"+c.slug,keywords:["block","blocks",c.slug],label:({i18n:d})=>c?.labels?.singular?Ot(c.labels.singular,d):c?.slug,onSelect:({editor:d})=>{d.dispatchCommand(tt,{blockName:"",blockType:c.slug})}})),key:"blocks",label:({i18n:c})=>c.t("lexical:blocks:label")}:null,u?.length?{items:u.map(c=>({Icon:yt,key:"inlineBlocks-"+c.slug,keywords:["inlineBlock","inline block",c.slug],label:({i18n:d})=>c?.labels?.singular?Ot(c.labels.singular,d):c?.slug,onSelect:({editor:d})=>{d.dispatchCommand(ot,{blockName:"",blockType:c.slug})}})),key:"inlineBlocks",label:({i18n:c})=>c.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[a.length?{type:"dropdown",ChildComponent:It,items:a.map((c,d)=>({ChildComponent:vt(c.imageURL,c.imageAltText),isActive:void 0,key:"block-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Ot(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(tt,{blockName:"",blockType:c.slug})},order:d})),key:"blocks",order:20}:null,u?.length?{type:"dropdown",ChildComponent:yt,items:u.map((c,d)=>({ChildComponent:c.imageURL?vt(c.imageURL,c.imageAltText):yt,isActive:void 0,key:"inlineBlock-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Ot(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(ot,{blockName:"",blockType:c.slug})},order:d})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Ha}from"react/compiler-runtime";import{jsx as Se,jsxs as No}from"react/jsx-runtime";import{useLexicalComposerContext as ja}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Ua,$createTextNode as Ga,$getRoot as Wa,getDOMSelection as Eo}from"lexical";import*as tn from"react";import{useCallback as Re,useEffect as ko,useLayoutEffect as qr,useRef as Lo,useState as $t}from"react";var Va=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},Ka=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},Za=t=>{let o=((r,n)=>{switch(r){case"click":return` await page.mouse.click(${n.x}, ${n.y});`;case"keydown":return` await page.keyboard.keydown('${n}');`;case"keyup":return` await page.keyboard.keyup('${n}');`;case"press":return` await page.keyboard.press('${n}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
4
4
|
await assertSelection(page, {
|
|
5
5
|
anchorPath: [${n.anchorPath.toString()}],
|
|
6
6
|
anchorOffset: ${n.anchorOffset},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
`;case"type":return` await page.keyboard.type('${n}');`;default:return""}})(t.name,t.value);switch(t.count){case 1:return o;case 2:return[o,o].join(`
|
|
11
11
|
`);default:return` await repeat(${t.count}, async () => {
|
|
12
12
|
${o}
|
|
13
|
-
);`}};function
|
|
13
|
+
);`}};function Ya(t){return t.key.toLowerCase()==="a"&&(kr?t.metaKey:t.ctrlKey)}function za(t){let{anchorNode:e,focusNode:o}=t,{anchorOffset:r,focusOffset:n}=t;return r!==0&&r--,n!==0&&n--,{anchorNode:e,anchorOffset:r,focusNode:o,focusOffset:n}}function Qr(t,e){let o=t,r=[];for(;o!==e;)o!=null&&r.unshift(Array.from(o?.parentNode?.childNodes??[]).indexOf(o)),o=o?.parentNode;return r}var en=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Backspace","Delete","Enter","Escape"]);function Xa(t){let[e,o]=$t([]),[r,n]=$t(!1),[,i]=$t(""),[l,s]=$t(""),a=Lo(null),u=Lo(!1),c=Lo(null),d=Re(()=>t,[t]),m=Re(()=>{let C=t.getRootElement(),T=Eo(t._window);return C==null||T==null||T.anchorNode==null||T.focusNode==null||!C.contains(T.anchorNode)||!C.contains(T.focusNode)?null:`
|
|
14
14
|
import {
|
|
15
15
|
initializeE2E,
|
|
16
16
|
assertHTMLSnapshot,
|
|
@@ -27,15 +27,15 @@ describe('Test case', () => {
|
|
|
27
27
|
const {page} = e2e;
|
|
28
28
|
|
|
29
29
|
await page.focus('div[contenteditable="true"]');
|
|
30
|
-
${e.map(
|
|
30
|
+
${e.map(Za).join(`
|
|
31
31
|
`)}
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
-
`},[t,e]),p=Se((x,T)=>{o(g=>{let w=e.length-1,N=e[w];if(N&&N.name===x){if(x==="type")return[...e.slice(0,w),{...N,value:N.value+T}];if(N.value===T)return[...e.slice(0,w),{...N,count:N.count+1}]}return[...g,{name:x,count:1,value:T}]})},[e,o]);Qr(()=>{let x=g=>{if(!r)return;let w=g.key;Xa(g)?p("selectAll",""):tn.has(w)?p("press",g.key):[...w].length>1?p("keydown",g.key):p("type",g.key)},T=g=>{if(!r)return;let w=g.key;!tn.has(w)&&[...w].length>1&&p("keyup",g.key)};return t.registerRootListener((g,w)=>{w!==null&&(w.removeEventListener("keydown",x),w.removeEventListener("keyup",T)),g!==null&&(g.addEventListener("keydown",x),g.addEventListener("keyup",T))})},[t,r,p]),Qr(()=>{c.current&&c.current.scrollTo(0,c.current.scrollHeight)},[m]),Lo(()=>{if(e){let x=m();x!==null&&s(x),c.current&&c.current.scrollTo(0,c.current.scrollHeight)}},[m,e]),Lo(()=>t.registerUpdateListener(({dirtyElements:T,dirtyLeaves:g,editorState:w})=>{if(!r)return;let N=w._selection,L=a.current,R=u.current;if(L!==N){if(g.size===0&&T.size===0&&!R){let E=ko(t._window);if(E&&(E.anchorNode==null||E.focusNode==null))return}a.current=N}u.current=!1;let S=m();S!==null&&s(S)}),[t,m,r,p]),Lo(()=>r?t.registerUpdateListener(()=>{let T=t.getRootElement();T!==null&&i(T?.innerHTML)}):void 0,[t,r]);let f=Se(x=>{r||(x.update(()=>{let T=Ka();T.clear();let g=Va();T.append(Wa().append(g)),g.select()}),o([])),n(T=>!T)},[r]),h=Se(()=>{if(!r)return;let x=ko(t._window);if(x===null||x.anchorNode==null||x.focusNode==null)return;let{anchorNode:T,anchorOffset:g,focusNode:w,focusOffset:N}=Ja(x),L=d().getRootElement(),R;T!==null&&(R=en(T,L));let S;w!==null&&(S=en(w,L)),p("snapshot",{anchorNode:T,anchorOffset:g,anchorPath:R,focusNode:w,focusOffset:N,focusPath:S})},[p,r,d]),C=Se(()=>{Za(m())},[m]),b=Se(()=>{Ya("test.js",m())},[m]);return[Ie("button",{className:`editor-dev-button ${r?"active":""}`,id:"test-recorder-button",onClick:x=>{f(d()),x.preventDefault()},title:r?"Disable test recorder":"Enable test recorder",type:"button",children:r?"Disable test recorder":"Enable test recorder"}),r?Ro("div",{className:"test-recorder-output",children:[Ro("div",{className:"test-recorder-toolbar",children:[Ie("button",{className:"test-recorder-button",id:"test-recorder-button-snapshot",onClick:x=>{h(),x.preventDefault()},title:"Insert snapshot",type:"button",children:"Insert Snapshot"}),Ie("button",{className:"test-recorder-button",id:"test-recorder-button-copy",onClick:x=>{C(),x.preventDefault()},title:"Copy to clipboard",type:"button",children:"Copy"}),Ie("button",{className:"test-recorder-button",id:"test-recorder-button-download",onClick:x=>{b(),x.preventDefault()},title:"Download as a file",type:"button",children:"Download"})]}),Ie("pre",{id:"test-recorder",ref:c,children:l})]}):null]}var rn=()=>{let t=Ua(3),[e]=Ga(),[o,r]=qa(e),n;return t[0]!==o||t[1]!==r?(n=Ro(on.Fragment,{children:[Ie("p",{children:"HI"}),o,r,Ie("p",{children:"DONE"})]}),t[0]=o,t[1]=r,t[2]=n):n=t[2],n};var Qa=y({plugins:[{Component:rn,position:"bottom"}]});import{c as ec}from"react/compiler-runtime";import{jsx as tc}from"react/jsx-runtime";import{useLexicalComposerContext as oc}from"@lexical/react/LexicalComposerContext.js";import{TreeView as rc}from"@lexical/react/LexicalTreeView.js";import"react";var nn=()=>{let t=ec(2),[e]=oc(),o;return t[0]!==e?(o=tc(rc,{editor:e,timeTravelButtonClassName:"debug-timetravel-button",timeTravelPanelButtonClassName:"debug-timetravel-panel-button",timeTravelPanelClassName:"debug-timetravel-panel",timeTravelPanelSliderClassName:"debug-timetravel-panel-slider",treeTypeButtonClassName:"debug-treetype-button",viewClassName:"tree-view-output"}),t[0]=e,t[1]=o):o=t[1],o};var nc=y({plugins:[{Component:nn,position:"bottom"}]});import{$isTableSelection as ic}from"@lexical/table";import{$isRangeSelection as lc,FORMAT_TEXT_COMMAND as sc}from"lexical";import{jsx as ln}from"react/jsx-runtime";import"react";var sn=()=>ln("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:ln("path",{d:"M10.6772 15H6.27017V5.718H10.4172C12.6792 5.718 13.8492 6.602 13.8492 8.292C13.8492 9.098 13.1992 9.982 12.4712 10.216C13.3812 10.476 14.1742 11.256 14.1742 12.322C14.1742 14.09 12.9002 15 10.6772 15ZM8.46717 9.501H10.3262C11.3012 9.501 11.7042 9.046 11.7042 8.409C11.7042 7.72 11.2362 7.317 10.3392 7.317H8.46717V9.501ZM8.46717 11.061V13.401H10.4822C11.4702 13.401 11.9642 12.959 11.9642 12.218C11.9642 11.49 11.4702 11.061 10.4822 11.061H8.46717Z",fill:"currentColor"})});var K=t=>({type:"buttons",items:t,key:"format",order:40});var an={type:"text-format",format:["bold","italic"],tag:"***"},cn={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},un={type:"text-format",format:["bold"],tag:"**"},dn={type:"text-format",format:["bold"],intraword:!1,tag:"__"};var mn=[K([{ChildComponent:sn,isActive:({selection:t})=>lc(t)||ic(t)?t.hasFormat("bold"):!1,key:"bold",onSelect:({editor:t})=>{t.dispatchCommand(sc,"bold")},order:1}])],ac=y(({featureProviderMap:t})=>{let e=[un,dn];return t.get("italic")&&e.push(cn,an),{enableFormats:["bold"],markdownTransformers:e,toolbarFixed:{groups:mn},toolbarInline:{groups:mn}}});import{$isTableSelection as uc}from"@lexical/table";import{$isRangeSelection as dc,FORMAT_TEXT_COMMAND as mc}from"lexical";import{jsx as pn,jsxs as cc}from"react/jsx-runtime";import"react";var fn=()=>cc("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:[pn("path",{d:"M7.76465 6L3.76465 10L7.76465 14",stroke:"currentColor"}),pn("path",{d:"M12.2354 6L16.2354 10L12.2354 14",stroke:"currentColor"})]});var hn={type:"text-format",format:["code"],tag:"`"};var gn=[K([{ChildComponent:fn,isActive:({selection:t})=>dc(t)||uc(t)?t.hasFormat("code"):!1,key:"inlineCode",onSelect:({editor:t})=>{t.dispatchCommand(mc,"code")},order:7}])],pc=y({enableFormats:["code"],markdownTransformers:[hn],toolbarFixed:{groups:gn},toolbarInline:{groups:gn}});import{$isTableSelection as fc}from"@lexical/table";import{$isRangeSelection as hc,FORMAT_TEXT_COMMAND as gc}from"lexical";import{jsx as Cn}from"react/jsx-runtime";import"react";var xn=()=>Cn("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:Cn("path",{d:"M11.311 14.2969L11.0327 15H6.18408L6.4624 14.2969C7.54639 14.2969 7.70752 14.209 7.83936 13.8721L10.8423 6.45996C10.8716 6.38672 10.8862 6.32812 10.8862 6.26953C10.8862 6.09375 10.6519 6.03516 9.80225 6.03516L10.0952 5.33203H14.9438L14.6509 6.03516C13.5669 6.03516 13.4204 6.12305 13.2886 6.45996L10.2856 13.8721C10.2563 13.9453 10.2271 14.0039 10.2271 14.0625C10.2271 14.2383 10.4614 14.2969 11.311 14.2969Z",fill:"currentColor"})});var bn={type:"text-format",format:["italic"],tag:"*"},_n={type:"text-format",format:["italic"],intraword:!1,tag:"_"};var Tn=[K([{ChildComponent:xn,isActive:({selection:t})=>hc(t)||fc(t)?t.hasFormat("italic"):!1,key:"italic",onSelect:({editor:t})=>{t.dispatchCommand(gc,"italic")},order:2}])],Cc=y({enableFormats:["italic"],markdownTransformers:[bn,_n],toolbarFixed:{groups:Tn},toolbarInline:{groups:Tn}});import{$isTableSelection as bc}from"@lexical/table";import{$isRangeSelection as _c,FORMAT_TEXT_COMMAND as Tc}from"lexical";import{jsx as wn,jsxs as xc}from"react/jsx-runtime";import"react";var En=()=>xc("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:"M5.50756 12.76H7.42756C7.56256 14.215 8.82256 14.71 10.1576 14.71C11.4326 14.71 12.4226 14.14 12.4226 13.06C12.4226 12.28 11.9576 11.845 10.6676 11.605L8.70256 11.245C7.12756 10.96 5.85256 10.21 5.85256 8.335C5.85256 6.43 7.53256 5.11 9.87256 5.11C12.4226 5.11 13.9526 6.22 14.1626 8.23H12.2876C12.1526 7.18 11.2226 6.595 9.88756 6.595C8.59756 6.595 7.78756 7.27 7.78756 8.215C7.78756 9.1 8.34256 9.385 9.49756 9.61L11.5676 10.015C13.3226 10.345 14.3726 11.215 14.3726 12.94C14.3726 14.89 12.5876 16.18 10.2176 16.18C7.66756 16.18 5.70256 15.115 5.50756 12.76Z",fill:"currentColor"}),wn("path",{d:"M4.99756 11.44H15.0026V12.19H4.99756V11.44Z",fill:"currentColor"})]});var kn={type:"text-format",format:["strikethrough"],tag:"~~"};var Ln=[K([{ChildComponent:En,isActive:({selection:t})=>_c(t)||bc(t)?t.hasFormat("strikethrough"):!1,key:"strikethrough",onSelect:({editor:t})=>{t.dispatchCommand(Tc,"strikethrough")},order:4}])],wc=y({enableFormats:["strikethrough"],markdownTransformers:[kn],toolbarFixed:{groups:Ln},toolbarInline:{groups:Ln}});import{$isTableSelection as Ec}from"@lexical/table";import{$isRangeSelection as kc,FORMAT_TEXT_COMMAND as Lc}from"lexical";import{jsx as Nn}from"react/jsx-runtime";import"react";var Rn=()=>Nn("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:Nn("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 13.258C16.7768 14.155 16.1398 14.532 15.2038 15C14.5538 15.325 14.2808 15.546 14.2418 15.78H16.7898V16.82H12.7208V16.339C12.7208 15.286 13.5918 14.675 14.3588 14.233C15.0868 13.83 15.4378 13.635 15.4378 13.232C15.4378 12.894 15.2038 12.686 14.8268 12.686C14.3848 12.686 14.1248 13.024 14.1118 13.427H12.7468C12.8248 12.426 13.5528 11.633 14.8398 11.633C15.9448 11.633 16.7768 12.257 16.7768 13.258Z",fill:"currentColor"})});var Sn=[K([{ChildComponent:Rn,isActive:({selection:t})=>kc(t)||Ec(t)?t.hasFormat("subscript"):!1,key:"subscript",onSelect:({editor:t})=>{t.dispatchCommand(Lc,"subscript")},order:5}])],Nc=y({enableFormats:["subscript"],toolbarFixed:{groups:Sn},toolbarInline:{groups:Sn}});import{$isTableSelection as Rc}from"@lexical/table";import{$isRangeSelection as Sc,FORMAT_TEXT_COMMAND as Ic}from"lexical";import{jsx as In}from"react/jsx-runtime";import"react";var yn=()=>In("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:In("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 7.252C16.7768 8.149 16.1398 8.526 15.2038 8.994C14.5538 9.319 14.2808 9.54 14.2418 9.774H16.7898V10.814H12.7208V10.333C12.7208 9.28 13.5918 8.669 14.3588 8.227C15.0868 7.824 15.4378 7.629 15.4378 7.226C15.4378 6.888 15.2038 6.68 14.8268 6.68C14.3848 6.68 14.1248 7.018 14.1118 7.421H12.7468C12.8248 6.42 13.5528 5.627 14.8398 5.627C15.9448 5.627 16.7768 6.251 16.7768 7.252Z",fill:"currentColor"})});var vn=[K([{ChildComponent:yn,isActive:({selection:t})=>Sc(t)||Rc(t)?t.hasFormat("superscript"):!1,key:"superscript",onSelect:({editor:t})=>{t.dispatchCommand(Ic,"superscript")},order:6}])],yc=y({enableFormats:["superscript"],toolbarFixed:{groups:vn},toolbarInline:{groups:vn}});import{$isTableSelection as Mc}from"@lexical/table";import{$isRangeSelection as Dc,FORMAT_TEXT_COMMAND as Ac}from"lexical";import{jsx as Mn,jsxs as vc}from"react/jsx-runtime";import"react";var Dn=()=>vc("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:[Mn("path",{d:"M13.9656 11.256C13.9656 13.791 12.5096 15.156 10.0006 15.156C7.50461 15.156 6.03561 13.791 6.03561 11.23V5.718H7.76461V11.243C7.76461 12.868 8.50561 13.778 10.0006 13.778C11.4956 13.778 12.2496 12.868 12.2496 11.243V5.718H13.9656V11.256Z",fill:"currentColor"}),Mn("path",{d:"M5.09961 16.3H14.9016V16.95H5.09961V16.3Z",fill:"currentColor"})]});var An=[K([{ChildComponent:Dn,isActive:({selection:t})=>Dc(t)||Mc(t)?t.hasFormat("underline"):!1,key:"underline",onSelect:({editor:t})=>{t.dispatchCommand(Ac,"underline")},order:3}])],Oc=y({enableFormats:["underline"],toolbarFixed:{groups:An},toolbarInline:{groups:An}});import{$createHeadingNode as Bc,$isHeadingNode as Yn,HeadingNode as Hc}from"@lexical/rich-text";import{$setBlocksType as jc}from"@lexical/selection";import{$getSelection as Uc,$isRangeSelection as Gc}from"lexical";import{jsx as On}from"react/jsx-runtime";import"react";var Fn=()=>On("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:On("path",{d:"M4.639 13.5V7.074H6.196V9.648H9.076V7.074H10.642V13.5H9.076V10.836H6.196V13.5H4.639ZM11.5656 9.045V8.019C12.6636 8.019 13.1316 7.731 13.2846 7.065H14.4006V13.5H12.8436V9.045H11.5656Z",fill:"currentColor"})});import{jsx as $n}from"react/jsx-runtime";import"react";var Pn=()=>$n("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:$n("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM15.9796 8.973C15.9796 10.116 15.1696 10.656 14.0356 11.232C13.2256 11.646 12.8206 11.943 12.7846 12.294H15.9886V13.5H11.0566V12.951C11.0566 11.601 12.1636 10.845 13.1176 10.287C14.0356 9.756 14.5126 9.486 14.5126 8.946C14.5126 8.46 14.2156 8.145 13.6306 8.145C13.0186 8.145 12.6586 8.613 12.6226 9.198H11.1196C11.2186 7.947 12.1006 6.966 13.6396 6.966C15.0346 6.966 15.9796 7.785 15.9796 8.973Z",fill:"currentColor"})});import{jsx as Bn}from"react/jsx-runtime";import"react";var Hn=()=>Bn("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:Bn("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM16.1146 11.745C16.1146 12.744 15.2236 13.608 13.6126 13.608C12.0736 13.608 11.0926 12.762 10.9846 11.547H12.4696C12.5146 12.114 13.0006 12.456 13.6126 12.456C14.2876 12.456 14.6746 12.132 14.6746 11.619C14.6746 11.061 14.2426 10.836 13.6216 10.836H12.9826V9.738H13.6036C14.1526 9.738 14.5486 9.486 14.5486 8.937C14.5486 8.46 14.2156 8.127 13.6486 8.127C13.0366 8.127 12.6586 8.514 12.6226 9.045H11.1916C11.2726 7.929 12.1276 6.966 13.6666 6.966C15.1876 6.966 15.9706 7.848 15.9706 8.865C15.9706 9.603 15.5026 10.143 14.8186 10.269C15.6196 10.404 16.1146 10.971 16.1146 11.745Z",fill:"currentColor"})});import{jsx as jn}from"react/jsx-runtime";import"react";var Un=()=>jn("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:jn("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM15.1736 7.074V10.854H16.3706V12.033H15.1736V13.5H13.6796V12.033H10.5116V10.845L13.4996 7.074H15.1736ZM13.6796 8.46L11.8256 10.854H13.6796V8.46Z",fill:"currentColor"})});import{jsx as Gn}from"react/jsx-runtime";import"react";var Wn=()=>Gn("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:Gn("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.1576 10.269C12.6896 10.269 12.3746 10.494 12.2216 10.737H10.8176L11.1956 7.074H15.2546V8.28H12.3206L12.1856 9.549C12.4016 9.351 12.8516 9.126 13.4636 9.126C14.7866 9.126 15.6596 10.053 15.6596 11.358C15.6596 12.609 14.7326 13.608 13.1756 13.608C11.5826 13.608 10.6556 12.753 10.5566 11.511H12.1136C12.1586 12.06 12.5456 12.465 13.1576 12.465C13.8236 12.465 14.1746 11.97 14.1746 11.376C14.1746 10.764 13.8416 10.269 13.1576 10.269Z",fill:"currentColor"})});import{jsx as Vn}from"react/jsx-runtime";import"react";var Kn=()=>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",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.3646 8.127C12.5456 8.127 12.0416 8.937 12.0416 9.999C12.3296 9.54 12.8246 9.207 13.5536 9.207C14.8586 9.207 15.8036 10.134 15.8036 11.376C15.8036 12.645 14.8226 13.608 13.3196 13.608C11.7266 13.608 10.6196 12.393 10.6196 10.395C10.6196 8.316 11.7716 6.966 13.4186 6.966C14.7056 6.966 15.5786 7.749 15.7316 8.829H14.3186C14.2016 8.415 13.9226 8.127 13.3646 8.127ZM13.3106 12.51C13.9586 12.51 14.3816 12.042 14.3816 11.385C14.3816 10.737 13.9586 10.278 13.3106 10.278C12.6536 10.278 12.2126 10.737 12.2126 11.385C12.2126 12.042 12.6536 12.51 13.3106 12.51Z",fill:"currentColor"})});import{$createHeadingNode as Fc,$isHeadingNode as $c,HeadingNode as Pc}from"@lexical/rich-text";var So=t=>(e,o,r)=>{let n=t(r);n&&(n.append(...o),e.replace(n),n.select(0,0))};var Zn=t=>{let o=`^(${t.map(n=>Number(n.slice(1))).map(n=>`#{${n}}`).join("|")})\\s`,r=new RegExp(o);return{type:"element",dependencies:[Pc],export:(n,i)=>{if(!$c(n))return null;let l=Number(n.getTag().slice(1));return"#".repeat(l)+" "+i(n)},regExp:r,replace:So(n=>{let i="h"+n[1].length;return Fc(i)})}};var zn=t=>{let e=Uc();jc(e,()=>Bc(t))},Xn={h1:Fn,h2:Pn,h3:Hn,h4:Un,h5:Wn,h6:Kn},Wc=y(({props:t})=>{let{enabledHeadingSizes:e=["h1","h2","h3","h4","h5","h6"]}=t,o=[z(e.map((r,n)=>({ChildComponent:Xn[r],isActive:({selection:i})=>{if(!Gc(i))return!1;for(let l of i.getNodes()){if(Yn(l)&&l.getTag()===r)continue;let s=l.getParent();if(!(Yn(s)&&s.getTag()===r))return!1}return!0},key:r,label:({i18n:i})=>i.t("lexical:heading:label",{headingLevel:r.charAt(1)}),onSelect:({editor:i})=>{i.update(()=>{zn(r)})},order:n+2})))];return{markdownTransformers:[Zn(e)],nodes:[Hc],sanitizedClientFeatureProps:t,slashMenu:{groups:e?.length?[V(e.map(r=>({Icon:Xn[r],key:`heading-${r.charAt(1)}`,keywords:["heading",r],label:({i18n:n})=>n.t("lexical:heading:label",{headingLevel:r.charAt(1)}),onSelect:({editor:n})=>{n.update(()=>{zn(r)})}})))]:[]},toolbarFixed:{groups:e?.length?o:[]},toolbarInline:{groups:e?.length?o:[]}}});import{$isNodeSelection as lu}from"lexical";import{jsx as Jn}from"react/jsx-runtime";import"react";var Io=()=>Jn("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:Jn("rect",{fill:"currentColor",height:"1",width:"12",x:"4",y:"9.5"})});import{jsx as qn,jsxs as Vc}from"react/jsx-runtime";import"react";var Qn=()=>Vc("svg",{fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[qn("path",{d:"M5 10h10",stroke:"currentColor"}),qn("path",{d:"M10 15V5",stroke:"currentColor"})]});var de=t=>({type:"dropdown",ChildComponent:Qn,items:t,key:"add",order:10});import{addClassNamesToElement as Kc}from"@lexical/utils";import{$applyNodeReplacement as Zc,createCommand as Yc,DecoratorNode as zc}from"lexical";var lt=Yc("INSERT_HORIZONTAL_RULE_COMMAND"),it=class extends zc{static clone(e){return new this(e.__key)}static getType(){return"horizontalrule"}static importDOM(){return{hr:()=>({conversion:Xc,priority:0})}}static importJSON(e){return ei()}createDOM(e){let o=document.createElement("hr");return Kc(o,e.theme.hr),o}decorate(){return null}exportDOM(){return{element:document.createElement("hr")}}exportJSON(){return{type:"horizontalrule",version:1}}getTextContent(){return`
|
|
35
|
-
`}isInline(){return!1}updateDOM(){return!1}};function Xc(){return{node:ei()}}function ei(){return Zc(new it)}import{$applyNodeReplacement as Jc}from"lexical";import"react";var Ee=class extends it{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return st()}decorate(){return null}exportJSON(){return super.exportJSON()}};function st(){return Jc(new Ee)}function Pt(t){return t instanceof Ee}var ti={type:"element",dependencies:[Ee],export:(t,e)=>Pt(t)?"---":null,regExp:/^---\s*$/,replace:t=>{let e=st();e&&t.replace(e)}};import{c as qc}from"react/compiler-runtime";import{useLexicalComposerContext as Qc}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as eu}from"@lexical/utils";import{$getSelection as tu,$isRangeSelection as ou,COMMAND_PRIORITY_EDITOR as ru}from"lexical";import{useEffect as nu}from"react";var oi=()=>{let t=qc(3),[e]=Qc(),o,r;return t[0]!==e?(o=()=>e.registerCommand(lt,iu,ru),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),nu(o,r),null};function iu(t){let e=tu();if(!ou(e))return!1;if(e.focus.getNode()!==null){let r=st();eu(r)}return!0}var su=y({markdownTransformers:[ti],nodes:[Ee],plugins:[{Component:oi,position:"normal"}],slashMenu:{groups:[V([{Icon:Io,key:"horizontalRule",keywords:["hr","horizontal rule","line","separator"],label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(lt,void 0)}}])]},toolbarFixed:{groups:[de([{ChildComponent:Io,isActive:({selection:t})=>{if(!lu(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return Pt(e)},key:"horizontalRule",label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(lt,void 0)}}])]}});import{TabIndentationPlugin as uu}from"@lexical/react/LexicalTabIndentationPlugin";import{INDENT_CONTENT_COMMAND as du,OUTDENT_CONTENT_COMMAND as mu}from"lexical";import{jsx as Bt,jsxs as au}from"react/jsx-runtime";import"react";var ri=()=>au("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:[Bt("path",{d:"M2.5 5H10.5",stroke:"currentColor",strokeWidth:"1.5"}),Bt("path",{d:"M2.5 10H10.5",stroke:"currentColor",strokeWidth:"1.5"}),Bt("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Bt("path",{d:"M12.25 7.25L17.25 3.75V10.75L12.25 7.25Z",fill:"currentColor"})]});import{jsx as Ht,jsxs as cu}from"react/jsx-runtime";import"react";var ni=()=>cu("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:[Ht("path",{d:"M17.5 5H9.5",stroke:"currentColor",strokeWidth:"1.5"}),Ht("path",{d:"M17.5 10H9.5",stroke:"currentColor",strokeWidth:"1.5"}),Ht("path",{d:"M17.5 15H2.5",stroke:"currentColor",strokeWidth:"1.5"}),Ht("path",{d:"M7.75 7.25L2.75 3.75V10.75L7.75 7.25Z",fill:"currentColor"})]});var ii=t=>({type:"buttons",items:t,key:"indent",order:35});var li=[ii([{ChildComponent:ri,isActive:()=>!1,isEnabled:({selection:t})=>{if(!t||!t?.getNodes()?.length)return!1;for(let e of t.getNodes()){let o=e.getParentOrThrow();if("__indent"in e&&e.__indent>0||"__indent"in o&&o.__indent>0)return!0}return!1},key:"indentDecrease",label:({i18n:t})=>t.t("lexical:indent:decreaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(mu,void 0)},order:1},{ChildComponent:ni,isActive:()=>!1,key:"indentIncrease",label:({i18n:t})=>t.t("lexical:indent:increaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(du,void 0)},order:2}])],pu=y({plugins:[{Component:uu,position:"normal"}],toolbarFixed:{groups:li},toolbarInline:{groups:li}});import{$findMatchingParent as Ld}from"@lexical/utils";import{$getSelection as Po,$isRangeSelection as $i}from"lexical";import{jsx as si}from"react/jsx-runtime";import"react";var ai=()=>si("svg",{"aria-hidden":"true",className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:si("path",{d:"M8.5 11.5L11.5 8.5M8.5 7L9.625 5.875C10.868 4.633 12.882 4.633 14.125 5.875C15.368 7.118 15.368 9.133 14.125 10.375L13 11.5M7 8.5L5.746 9.754C4.56 10.94 4.519 12.85 5.652 14.087C6.814 15.354 8.78 15.449 10.058 14.298L11.5 13",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})});import{$isAtNodeEnd as ci}from"@lexical/selection";function He(t){let{anchor:e}=t,{focus:o}=t,r=t.anchor.getNode(),n=t.focus.getNode();return r===n?r:t.isBackward()?ci(o)?r:n:ci(e)?r:n}var yo=t=>({type:"buttons",items:t,key:"features",order:50});import{$createTextNode as ku}from"lexical";import{addClassNamesToElement as fu,isHTMLAnchorElement as hu}from"@lexical/utils";import Do from"bson-objectid";import{$applyNodeReplacement as gu,$createTextNode as ui,$getSelection as Cu,$isElementNode as di,$isRangeSelection as Mo,createCommand as xu,ElementNode as bu}from"lexical";var _u=new Set(["http:","https:","mailto:","sms:","tel:"]),X=class t extends bu{__fields;__id;constructor({id:e,fields:o={linkType:"custom",newTab:!1},key:r}){super(r),this.__fields=o,this.__id=e}static clone(e){return new t({id:e.__id,fields:e.__fields,key:e.__key})}static getType(){return"link"}static importDOM(){return{a:e=>({conversion:Tu,priority:1})}}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2),e.version===2&&!e.id&&(e.id=new Do.default().toHexString(),e.version=3);let o=me({id:e.id,fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}canBeEmpty(){return!1}canInsertTextAfter(){return!1}canInsertTextBefore(){return!1}createDOM(e){let o=document.createElement("a");return this.__fields?.linkType==="custom"&&(o.href=this.sanitizeUrl(this.__fields.url??"")),(this.__fields?.newTab??!1)&&(o.target="_blank"),this.__fields?.newTab===!0&&this.__fields?.linkType==="custom"&&(o.rel=vo(o.rel,"add","noopener")),fu(o,e.theme.link),o}exportJSON(){let e=this.getFields();e?.linkType==="internal"?delete e.url:e?.linkType==="custom"&&delete e.doc;let o={...super.exportJSON(),type:"link",fields:e,version:3},r=this.getID();return r&&(o.id=r),o}extractWithChild(e,o,r){if(!Mo(o))return!1;let n=o.anchor.getNode(),i=o.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&o.getTextContent().length>0}getFields(){return this.getLatest().__fields}getID(){return this.getLatest().__id}insertNewAfter(e,o=!0){let r=this.getParentOrThrow().insertNewAfter(e,o);if(di(r)){let n=me({fields:this.__fields});return r.append(n),n}return null}isInline(){return!0}sanitizeUrl(e){try{let o=new URL(e);if(!_u.has(o.protocol))return"about:blank"}catch{return"https://"}return e}setFields(e){let o=this.getWritable();o.__fields=e}updateDOM(e,o,r){let n=this.__fields?.url,i=this.__fields?.newTab;return n!=null&&n!==e.__fields?.url&&this.__fields?.linkType==="custom"&&(o.href=n),this.__fields?.linkType==="internal"&&e.__fields?.linkType==="custom"&&o.removeAttribute("href"),o.rel==null&&(o.rel=""),i!==e.__fields?.newTab&&(i??!1?(o.target="_blank",this.__fields?.linkType==="custom"&&(o.rel=vo(o.rel,"add","noopener"))):(o.removeAttribute("target"),o.rel=vo(o.rel,"remove","noopener"))),!1}};function Tu(t){let e=null;if(hu(t)){let o=t.textContent;o!==null&&o!==""&&(e=me({id:new Do.default().toHexString(),fields:{doc:null,linkType:"custom",newTab:t.getAttribute("target")==="_blank",url:t.getAttribute("href")??""}}))}return{node:e}}function me({id:t,fields:e}){return gu(new X({id:t??new Do.default().toHexString(),fields:e}))}function W(t){return t instanceof X}var ne=xu("TOGGLE_LINK_COMMAND");function Ao(t){let e=Cu();if(!Mo(e)&&(t===null||!t.selectedNodes?.length))return;let o=Mo(e)?e.extract():t===null?[]:t.selectedNodes;if(t===null){o?.forEach(i=>{let l=i.getParent();if(W(l)){let s=l.getChildren();for(let a=0;a<s.length;a+=1)l.insertBefore(s[a]);l.remove()}});return}if(o?.length===1){let i=o[0],l=W(i)?i:wu(i);if(l!==null){l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(ui(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}}let r=null,n=null;o?.forEach(i=>{let l=i.getParent();if(!(l===n||l===null||di(i)&&!i.isInline())){if(W(l)){n=l,l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(ui(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}if(l.is(r)||(r=l,n=me({fields:t.fields}),W(l)?i.getPreviousSibling()===null?l.insertBefore(n):l.insertAfter(n):i.insertBefore(n)),W(i)){if(i.is(n))return;if(n!==null){let s=i.getChildren();for(let a=0;a<s.length;a+=1)n.append(s[a])}i.remove();return}n!==null&&n.append(i)}})}function wu(t){return Eu(t,e=>W(e))}function Eu(t,e){let o=t;for(;o!==null&&(o=o.getParent(),!(o===null||e(o))););return o}function vo(t,e,o){let r,n=`${t}`;if(e==="add"){if(n.includes(o)){let i=new RegExp(o,"g");n=n.replace(i,"").trim()}n=n.trim(),r=n.length===0?`${o}`:`${n} ${o}`}else{let i=new RegExp(o,"g");r=n.replace(i,"").trim()}return r}var mi={type:"text-match",dependencies:[X],export:(t,e)=>{if(!W(t))return null;let o=t,{url:r}=o.getFields();return`[${e(o)}](${r})`},importRegExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)/,regExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)$/,replace:(t,e)=>{let[,o,r]=e,n=me({fields:{doc:null,linkType:"custom",newTab:!1,url:r}}),i=ku(o);return i.setFormat(t.getFormat()),n.append(i),t.replace(n),i},trigger:")"};import{$applyNodeReplacement as Lu,$isElementNode as Nu}from"lexical";var pe=class t extends X{static clone(e){return new t({id:"",fields:e.__fields,key:e.__key})}static getType(){return"autolink"}static importDOM(){return null}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2);let o=at({fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}exportJSON(){let e=super.exportJSON();return{type:"autolink",children:e.children,direction:e.direction,fields:e.fields,format:e.format,indent:e.indent,version:2}}insertNewAfter(e,o=!0){let r=this.getParentOrThrow().insertNewAfter(e,o);if(Nu(r)){let n=at({fields:this.__fields});return r.append(n),n}return null}};function at({fields:t}){return Lu(new pe({id:"",fields:t}))}function fe(t){return t instanceof pe}import{c as Ru}from"react/compiler-runtime";import{useLexicalComposerContext as Su}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Iu}from"@lexical/utils";import{$createTextNode as pi,$getSelection as yu,$isElementNode as hi,$isLineBreakNode as gi,$isNodeSelection as vu,$isRangeSelection as Mu,$isTextNode as ct,TextNode as Du}from"lexical";import{useEffect as Au}from"react";function fi(t,e=o=>o){return o=>{let r=t.exec(o);return r===null?null:{index:r.index,length:r[0].length,text:r[0],url:e(r[0])}}}function Ci(t,e){for(let o=0;o<e.length;o++){let r=e[o](t);if(r!=null)return r}return null}var Ou=/[.,;\s]/;function Ut(t){return Ou.test(t)}function xi(t){return Ut(t[t.length-1])}function Fo(t){return Ut(t[0])}function Fu(t,e){return e?/^\.[a-z]{2,}/i.test(t):/^\.[a-z0-9]+/i.test(t)}function bi(t){let e=t.getPreviousSibling();return hi(e)&&(e=e.getLastDescendant()),e===null||gi(e)||ct(e)&&xi(e.getTextContent())}function _i(t){let e=t.getNextSibling();return hi(e)&&(e=e.getFirstDescendant()),e===null||gi(e)||ct(e)&&Fo(e.getTextContent())}function $u(t,e,o,r){return(t>0?Ut(o[t-1]):bi(r[0]))?e<o.length?Ut(o[e]):_i(r[r.length-1]):!1}function Pu(t,e,o){let r=[],n=[],i=[],l=0,s=0,a=[...t];for(;a.length>0;){let u=a[0],d=u.getTextContent().length,m=s;s+d<=e?(r.push(u),l+=d):m>=o?i.push(u):n.push(u),s+=d,a.shift()}return[l,r,n,i]}function Bu(t,e,o,r){let n={linkType:"custom",url:r.url,...r.fields},i=at({fields:n});if(t.length===1){let l=t[0],s;e===0?[s,l]=l.splitText(o):[,s,l]=l.splitText(e,o);let a=pi(r.text);return a.setFormat(s.getFormat()),a.setDetail(s.getDetail()),a.setStyle(s.getStyle()),i.append(a),s.replace(i),l}else if(t.length>1){let l=t[0],s=l.getTextContent().length,a;e===0?a=l:[,a]=l.splitText(e);let u=[],c;for(let f=1;f<t.length;f++){let h=t[f],b=h.getTextContent().length,k=s,v=s+b;if(k<o)if(v<=o)u.push(h);else{let[x,T]=h.splitText(o-k);u.push(x),c=T}s+=b}let d=yu(),m=d?d.getNodes().find(ct):void 0,p=pi(a.getTextContent());return p.setFormat(a.getFormat()),p.setDetail(a.getDetail()),p.setStyle(a.getStyle()),i.append(p,...u),m&&m===a&&(Mu(d)?p.select(d.anchor.offset,d.focus.offset):vu(d)&&p.select(0,p.getTextContent().length)),a.replace(i),c}}function Hu(t,e,o){let r=[...t],n=r.map(a=>a.getTextContent()).join(""),i=n,l,s=0;for(;(l=Ci(i,e))!=null&&l!==null;){let a=l.index,u=l.length,c=a+u;if($u(s+a,s+c,n,r)){let[m,,p,f]=Pu(r,s+a,s+c),h=s+a-m,C=s+c-m,b=Bu(p,h,C,l);r=b?[b,...f]:f,o(l.url,null),s=0}else s+=c;i=i.substring(c)}}function Oo(t,e,o){let r=t.getChildren(),n=r.length;for(let a=0;a<n;a++){let u=r[a];if(!ct(u)||!u.isSimpleText()){jt(t),o(null,t.getFields()?.url??null);return}}let i=t.getTextContent(),l=Ci(i,e);if(l===null||l.text!==i){jt(t),o(null,t.getFields()?.url??null);return}if(!bi(t)||!_i(t)){jt(t),o(null,t.getFields()?.url??null);return}let s=t.getFields()?.url;if(s!==l?.url){let a=t.getFields();a.url=l?.url,t.setFields(a),o(l.url,s??null)}}function ju(t,e,o){let r=t.getPreviousSibling(),n=t.getNextSibling(),i=t.getTextContent();if(fe(r)){let l=r.getFields()?.url?r.getFields()?.url?.startsWith("mailto:")??!1:!1;(!Fo(i)||Fu(i,l))&&(r.append(t),Oo(r,e,o),o(null,r.getFields()?.url??null))}fe(n)&&!xi(i)&&(jt(n),Oo(n,e,o),o(null,n.getFields()?.url??null))}function jt(t){let e=t.getChildren(),o=e.length;for(let r=o-1;r>=0;r--)t.insertAfter(e[r]);return t.remove(),e.map(r=>r.getLatest())}function Uu(t){let e=[t],o=t.getNextSibling();for(;o!==null&&ct(o)&&o.isSimpleText()&&(e.push(o),!/\s/.test(o.getTextContent()));)o=o.getNextSibling();return e}function Gu(t,e,o){let r=Ru(5),n,i;r[0]!==t||r[1]!==e||r[2]!==o?(n=()=>{if(!t.hasNodes([pe]))throw new Error("LexicalAutoLinkPlugin: AutoLinkNode not registered on editor");let l=(s,a)=>{o?.(s,a)};return Iu(t.registerNodeTransform(Du,s=>{let a=s.getParentOrThrow(),u=s.getPreviousSibling();if(fe(a))Oo(a,e,l);else if(!W(a)){if(s.isSimpleText()&&(Fo(s.getTextContent())||!fe(u))){let c=Uu(s);Hu(c,e,l)}ju(s,e,l)}}))},i=[t,e,o],r[0]=t,r[1]=e,r[2]=o,r[3]=n,r[4]=i):(n=r[3],i=r[4]),Au(n,i)}var Wu=/((https?:\/\/(www\.)?)|(www\.))[-\w@:%.+~#=]{1,256}\.[a-zA-Z\d()]{1,6}\b([-\w()@:%+.~#?&/=]*)(?<![-.+():%])/,Vu=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-\d]+\.)+[a-z]{2,}))/i,Ku=[fi(Wu,t=>t.startsWith("http")?t:`https://${t}`),fi(Vu,t=>`mailto:${t}`)],Ti=()=>{let[t]=Su();return Gu(t,Ku),null};import{jsx as Zu}from"react/jsx-runtime";import{ClickableLinkPlugin as Yu}from"@lexical/react/LexicalClickableLinkPlugin.js";import"react";var wi=()=>Zu(Yu,{});import{jsx as md}from"react/jsx-runtime";import"react";import{createPortal as pd}from"react-dom";import{jsx as he,jsxs as ut,Fragment as Xu}from"react/jsx-runtime";import{useLexicalComposerContext as Ju}from"@lexical/react/LexicalComposerContext.js";import{$findMatchingParent as Ei,mergeRegister as ki}from"@lexical/utils";import{getTranslation as $o}from"@payloadcms/translations";import{CloseMenuIcon as qu,EditIcon as Qu,ExternalLinkIcon as Li,formatDrawerSlug as ed,useConfig as td,useEditDepth as od,useLocale as rd,useTranslation as nd}from"@payloadcms/ui";import{requests as id}from"@payloadcms/ui/shared";import{$getSelection as Ni,$isLineBreakNode as ld,$isRangeSelection as Ri,COMMAND_PRIORITY_HIGH as sd,COMMAND_PRIORITY_LOW as Si,getDOMSelection as ad,KEY_ESCAPE_COMMAND as cd,SELECTION_CHANGE_COMMAND as ud}from"lexical";import Ii,{useCallback as yi,useEffect as Vt,useRef as dd,useState as ye}from"react";function Gt(t,e,o,r=10,n=5){let i=o.parentElement;if(t===null||i==null){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let l=e.getBoundingClientRect(),s=o.getBoundingClientRect(),a=i.getBoundingClientRect(),u=t.top-r,c=t.left-n;u<a.top&&(u+=l.height+t.height+r*2),c+l.width>a.right&&(c=a.right-l.width-n),u-=s.top,c-=s.left,e.style.opacity="1",e.style.transform=`translate(${c}px, ${u}px)`}import{createCommand as zu}from"lexical";var Wt=zu("TOGGLE_LINK_WITH_MODAL_COMMAND");function vi(t){t.preventDefault()}function Mi({anchorElem:t}){let[e]=Ju(),[o,r]=ye(),n=dd(null),[i,l]=ye(null),[s,a]=ye(null),{fieldProps:{schemaPath:u},uuid:c}=P(),{config:d,getEntityConfig:m}=td(),{i18n:p,t:f}=nd(),[h,C]=ye(),b=od(),[k,v]=ye(!1),[x,T]=ye([]),g=rd(),[w,N]=ye(!1),L=ed({slug:"lexical-rich-text-link-"+c,depth:b}),{toggleDrawer:R}=ae(L),S=yi(()=>{v(!1),n&&n.current&&(n.current.style.opacity="0",n.current.style.transform="translate(-10000px, -10000px)"),N(!1),l(null),a(null),T([]),C(void 0)},[v,l,a,T]),E=yi(()=>{let _=Ni(),I;if(!Ri(_)||!_){S();return}let M=He(_);I=e.getElementByKey(M.getKey())?.getBoundingClientRect();let D=Ei(M,W),F=_.getNodes().filter(j=>!ld(j)).find(j=>{let Q=Ei(j,W);return D&&!D.is(Q)||Q&&!Q.is(D)});if(D==null||F){S();return}r(D);let A=D.getFields(),H={...A,id:D.getID(),text:D.getTextContent()};if(A?.linkType==="custom")l(A?.url??null),a(null);else{l(`${d.routes.admin==="/"?"":d.routes.admin}/collections/${A?.doc?.relationTo}/${A?.doc?.value}`);let j=A?.doc?.relationTo?m({collectionSlug:A?.doc?.relationTo}):void 0;if(!j)a(A?.label?String(A?.label):null),l(A?.url?String(A?.url):null);else{let Q=typeof A.doc?.value=="object"?A.doc.value.id:A.doc?.value,Ye=A.doc?.relationTo;if(!Q||!Ye)throw new Error("Focus link parent is missing doc.value or doc.relationTo");let _e=f("fields:linkedTo",{label:`${$o(j.labels.singular,p)} - ${f("lexical:link:loadingWithEllipsis",p)}`}).replace(/<[^>]*>?/g,"");a(_e),id.get(`${d.serverURL}${d.routes.api}/${Ye}/${Q}`,{headers:{"Accept-Language":p.language},params:{depth:0,locale:g?.code}}).then(async Te=>{if(!Te.ok)throw new Error(`HTTP error! Status: ${Te.status}`);let Fe=await Te.json(),$e=j?.admin?.useAsTitle||"id",ze=Fe[$e],Lt=f("fields:linkedTo",{label:`${$o(j.labels.singular,p)} - ${ze}`}).replace(/<[^>]*>?/g,"");a(Lt)}).catch(()=>{let Te=f("fields:linkedTo",{label:`${$o(j.labels.singular,p)} - ${f("general:untitled",p)} - ID: ${Q}`}).replace(/<[^>]*>?/g,"");a(Te)})}}C(H),v(!0),T(_?_?.getNodes():[]),fe(D)?N(!0):N(!1);let Z=n.current,oe=ad(e._window),{activeElement:J}=document;if(Z===null)return;let Ne=e.getRootElement();return oe!==null&&Ne!==null&&Ne.contains(oe.anchorNode)?(I||(I=oe.getRangeAt(0).getBoundingClientRect()),I!=null&&(I.y+=40,Gt(I,Z,t))):(J==null||J.className!=="link-input")&&(Ne!==null&&Gt(null,Z,t),l(null),a(null)),!0},[e,S,d.routes.admin,d.routes.api,d.serverURL,m,f,p,g?.code,t]);return Vt(()=>ki(e.registerCommand(Wt,_=>(e.dispatchCommand(ne,_),E(),R(),!0),Si)),[e,E,R,L]),Vt(()=>{let _=t.parentElement,I=()=>{e.getEditorState().read(()=>{E()})};return window.addEventListener("resize",I),_?.addEventListener("scroll",I),()=>{window.removeEventListener("resize",I),_?.removeEventListener("scroll",I)}},[t.parentElement,e,E]),Vt(()=>ki(e.registerUpdateListener(({editorState:_})=>{_.read(()=>{E()})}),e.registerCommand(ud,()=>(E(),!0),Si),e.registerCommand(cd,()=>k?(S(),!0):!1,sd)),[e,E,k,S]),Vt(()=>{e.getEditorState().read(()=>{E()})},[e,E]),ut(Ii.Fragment,{children:[he("div",{className:"link-editor",ref:n,children:ut("div",{className:"link-input",children:[i&&i.length>0?ut("a",{href:i,rel:"noopener noreferrer",target:"_blank",children:[o?.__fields.newTab?he(Li,{}):null,s!=null&&s.length>0?s:i]}):s!=null&&s.length>0?ut(Xu,{children:[o?.__fields.newTab?he(Li,{}):null,he("span",{className:"link-input__label-pure",children:s})]}):null,e.isEditable()&&ut(Ii.Fragment,{children:[he("button",{"aria-label":"Edit link",className:"link-edit",onClick:_=>{_.preventDefault(),R()},onMouseDown:vi,tabIndex:0,type:"button",children:he(Qu,{})}),!w&&he("button",{"aria-label":"Remove link",className:"link-trash",onClick:()=>{e.dispatchCommand(ne,null)},onMouseDown:vi,tabIndex:0,type:"button",children:he(qu,{})})]})]})}),he(Xe,{className:"lexical-link-edit-drawer",data:h,drawerSlug:L,drawerTitle:f("fields:editLink"),featureKey:"link",handleDrawerSubmit:(_,I)=>{let M=I,D={...M};delete D.text,e.update(()=>{let F=Ni(),A=null;if(Ri(F)?A=He(F).getParent():x.length&&(A=x[0].getParent()),A&&fe(A)){let H=me({fields:D});A.replace(H,!0)}}),e.dispatchCommand(ne,{fields:D,selectedNodes:x,text:M.text})},schemaPath:u,schemaPathSuffix:"fields"})]})}var Di=t=>{let{anchorElem:e=document.body}=t;return pd(md(Mi,{anchorElem:e}),e)};import{c as gd}from"react/compiler-runtime";import{useLexicalComposerContext as Cd}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as xd}from"@lexical/utils";import{$getSelection as bd,$isElementNode as _d,$isRangeSelection as Td,COMMAND_PRIORITY_LOW as Oi,PASTE_COMMAND as wd}from"lexical";import{useEffect as Ed}from"react";var fd=/^(?:[a-zA-Z][a-zA-Z\d+.-]*:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d]+(?:\.[A-Za-z\d]+)+|www\.[A-Za-z\d]+(?:\.[A-Za-z\d]+)+|(?:tel|mailto):[\w+.-]+)(?:\/[+~%/\w-]*)?(?:\?[-;&=%\w]*)?(?:#\w+)?$/,hd=/^(?:\/[\w\-./]*(?:#\w[\w-]*)?|#[\w\-]+)$/;function Ai(t){if(!t)return!1;if(t==="https://"||fd.test(t)||hd.test(t))return!0;try{return new URL(t),!0}catch{}return!1}var Fi=t=>{let e=gd(5),{clientProps:o}=t,[r]=Cd(),n,i;return e[0]!==o.defaultLinkType||e[1]!==o.defaultLinkURL||e[2]!==r?(n=()=>{if(!r.hasNodes([X]))throw new Error("LinkPlugin: LinkNode not registered on editor");return xd(r.registerCommand(ne,l=>l===null?(Ao(null),!0):(l.fields?.linkType||(l.fields.linkType=o.defaultLinkType),l.fields?.url||(l.fields.url=o.defaultLinkURL),Ao(l),!0),Oi),r.registerCommand(wd,l=>{let s=bd();if(!Td(s)||s.isCollapsed()||!(l instanceof ClipboardEvent)||l.clipboardData==null)return!1;let a=l.clipboardData.getData("text");if(!Ai(a))return!1;if(!s.getNodes().some(kd)){let u={doc:null,linkType:"custom",newTab:!1,url:a};return r.dispatchCommand(ne,{fields:u,text:null}),l.preventDefault(),!0}return!1},Oi))},i=[o.defaultLinkType,o.defaultLinkURL,r],e[0]=o.defaultLinkType,e[1]=o.defaultLinkURL,e[2]=r,e[3]=n,e[4]=i):(n=e[3],i=e[4]),Ed(n,i),null};function kd(t){return _d(t)}var Pi=[yo([{ChildComponent:ai,isActive:({selection:t})=>{if($i(t)){let e=He(t);return Ld(e,W)!=null}return!1},isEnabled:({selection:t})=>!!($i(t)&&Po()?.getTextContent()?.length),key:"link",label:({i18n:t})=>t.t("lexical:link:label"),onSelect:({editor:t,isActive:e})=>{if(e)t.dispatchCommand(ne,null);else{let o,r=[];if(t.getEditorState().read(()=>{o=Po()?.getTextContent(),r=Po()?.getNodes()??[]}),!o?.length)return;let n={doc:null,newTab:!1};t.dispatchCommand(Wt,{fields:n,selectedNodes:r,text:o})}},order:1}])],Nd=y({markdownTransformers:[mi],nodes:[X,pe],plugins:[{Component:Fi,position:"normal"},{Component:Ti,position:"normal"},{Component:wi,position:"normal"},{Component:Di,position:"floatingAnchorElem"}],toolbarFixed:{groups:Pi},toolbarInline:{groups:Pi}});import{$isListNode as jo,INSERT_CHECK_LIST_COMMAND as Wi,ListItemNode as Pd,ListNode as Bd}from"@lexical/list";import{$isRangeSelection as Hd}from"lexical";import{jsx as Bi,jsxs as Rd}from"react/jsx-runtime";import"react";var Bo=()=>Rd("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:[Bi("rect",{height:"13",rx:"1.5",stroke:"currentColor",width:"13",x:"3.5",y:"3.5"}),Bi("path",{d:"M7 10L9 12.5L13 7.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Sd}from"react/jsx-runtime";import{ListPlugin as Id}from"@lexical/react/LexicalListPlugin.js";import"react";var je=()=>Sd(Id,{});function Ue(t){return{items:t,key:"lists",label:({i18n:e})=>e.t("lexical:general:slashMenuListGroupLabel")}}import{$isListNode as Dd,ListItemNode as Ad,ListNode as Od}from"@lexical/list";import{$createListItemNode as yd,$createListNode as vd,$isListItemNode as Md,$isListNode as Ho}from"@lexical/list";var Hi=4,Ge=t=>(e,o,r)=>{let n=e.getPreviousSibling(),i=e.getNextSibling(),l=yd(t==="check"?r[3]==="x":void 0);if(Ho(i)&&i.getListType()===t){let a=i.getFirstChild();a!==null?a.insertBefore(l):i.append(l),e.remove()}else if(Ho(n)&&n.getListType()===t)n.append(l),e.remove();else{let a=vd(t,t==="number"?Number(r[2]):void 0);a.append(l),e.replace(a)}l.append(...o),l.select(0,0);let s=Math.floor(r[1].length/Hi);s&&l.setIndent(s)},ve=(t,e,o)=>{let r=[],n=t.getChildren(),i=0;for(let l of n)if(Md(l)){if(l.getChildrenSize()===1){let c=l.getFirstChild();if(Ho(c)){r.push(ve(c,e,o+1));continue}}let s=" ".repeat(o*Hi),a=t.getListType(),u=a==="number"?`${t.getStart()+i}. `:a==="check"?`- [${l.getChecked()?"x":" "}] `:"- ";r.push(s+u+e(l)),i++}return r.join(`
|
|
36
|
-
`)};var ji={type:"element",dependencies:[Od,Ad],export:(t,e)=>Dd(t)?ve(t,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:Ge("check")};import{jsx as Fd}from"react/jsx-runtime";import{CheckListPlugin as $d}from"@lexical/react/LexicalCheckListPlugin.js";import"react";var Ui=()=>Fd($d,{});var Gi=[z([{ChildComponent:Bo,isActive:({selection:t})=>{if(!Hd(t))return!1;for(let e of t.getNodes()){if(jo(e)&&e.getListType()==="check")continue;let o=e.getParent();if(jo(o)&&o.getListType()==="check")continue;let r=o?.getParent();if(!(jo(r)&&r.getListType()==="check"))return!1}return!0},key:"checklist",label:({i18n:t})=>t.t("lexical:checklist:label"),onSelect:({editor:t})=>{t.dispatchCommand(Wi,void 0)},order:12}])],jd=y(({featureProviderMap:t})=>{let e=[{Component:Ui,position:"normal"}];return!t.has("unorderedList")&&!t.has("orderedList")&&e.push({Component:je,position:"normal"}),{markdownTransformers:[ji],nodes:t.has("unorderedList")||t.has("orderedList")?[]:[Bd,Pd],plugins:e,slashMenu:{groups:[Ue([{Icon:Bo,key:"checklist",keywords:["check list","check","checklist","cl"],label:({i18n:o})=>o.t("lexical:checklist:label"),onSelect:({editor:o})=>{o.dispatchCommand(Wi,void 0)}}])]},toolbarFixed:{groups:Gi},toolbarInline:{groups:Gi}}});import{$isListNode as Go,INSERT_ORDERED_LIST_COMMAND as Zi,ListItemNode as Kd,ListNode as Zd}from"@lexical/list";import{$isRangeSelection as Yd}from"lexical";import{jsx as dt,jsxs as Ud}from"react/jsx-runtime";import"react";var Uo=()=>Ud("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:[dt("path",{d:"M5.89284 12.479C5.89284 13.368 5.26284 13.788 4.38084 14.236C3.75084 14.558 3.43584 14.789 3.40784 15.062H5.89984V16H2.06384V15.573C2.06384 14.523 2.92484 13.935 3.66684 13.501C4.38084 13.088 4.75184 12.878 4.75184 12.458C4.75184 12.08 4.52084 11.835 4.06584 11.835C3.58984 11.835 3.30984 12.199 3.28184 12.654H2.11284C2.18984 11.681 2.87584 10.918 4.07284 10.918C5.15784 10.918 5.89284 11.555 5.89284 12.479Z",fill:"currentColor"}),dt("path",{d:"M2.68608 4.535V3.737C3.54008 3.737 3.90408 3.513 4.02308 2.995H4.89108V8H3.68008L3.68008 4.535H2.68608Z",fill:"currentColor"}),dt("path",{d:"M8 15L17 15",stroke:"currentColor",strokeWidth:"1.5"}),dt("path",{d:"M8 10L17 10",stroke:"currentColor",strokeWidth:"1.5"}),dt("path",{d:"M8 5L17 5",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as Gd,ListItemNode as Wd,ListNode as Vd}from"@lexical/list";var Vi={type:"element",dependencies:[Vd,Wd],export:(t,e)=>Gd(t)?ve(t,e,0):null,regExp:/^(\s*)(\d+)\.\s/,replace:Ge("number")};var Ki=[z([{ChildComponent:Uo,isActive:({selection:t})=>{if(!Yd(t))return!1;for(let e of t.getNodes()){if(Go(e)&&e.getListType()==="number")continue;let o=e.getParent();if(Go(o)&&o.getListType()==="number")continue;let r=o?.getParent();if(!(Go(r)&&r.getListType()==="number"))return!1}return!0},key:"orderedList",label:({i18n:t})=>t.t("lexical:orderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Zi,void 0)},order:10}])],zd=y(({featureProviderMap:t})=>({markdownTransformers:[Vi],nodes:t.has("orderedList")?[]:[Zd,Kd],plugins:t.has("orderedList")?[]:[{Component:je,position:"normal"}],slashMenu:{groups:[Ue([{Icon:Uo,key:"orderedList",keywords:["ordered list","ol"],label:({i18n:e})=>e.t("lexical:orderedList:label"),onSelect:({editor:e})=>{e.dispatchCommand(Zi,void 0)}}])]},toolbarFixed:{groups:Ki},toolbarInline:{groups:Ki}}));import{$isListNode as Vo,INSERT_UNORDERED_LIST_COMMAND as Xi,ListItemNode as em,ListNode as tm}from"@lexical/list";import{$isRangeSelection as om}from"lexical";import{jsx as We,jsxs as Xd}from"react/jsx-runtime";import"react";var Wo=()=>Xd("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:[We("circle",{cx:"4",cy:"5",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),We("circle",{cx:"4",cy:"10",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),We("circle",{cx:"4",cy:"15",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),We("path",{d:"M17 5H7",stroke:"currentColor",strokeWidth:"1.5"}),We("path",{d:"M17 10H7",stroke:"currentColor",strokeWidth:"1.5"}),We("path",{d:"M17 15H7",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as Jd,ListItemNode as qd,ListNode as Qd}from"@lexical/list";var Yi={type:"element",dependencies:[Qd,qd],export:(t,e)=>Jd(t)?ve(t,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:Ge("bullet")};var zi=[z([{ChildComponent:Wo,isActive:({selection:t})=>{if(!om(t))return!1;for(let e of t.getNodes()){if(Vo(e)&&e.getListType()==="bullet")continue;let o=e.getParent();if(Vo(o)&&o.getListType()==="bullet")continue;let r=o?.getParent();if(!(Vo(r)&&r.getListType()==="bullet"))return!1}return!0},key:"unorderedList",label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xi,void 0)},order:11}])],rm=y({markdownTransformers:[Yi],nodes:[tm,em],plugins:[{Component:je,position:"normal"}],slashMenu:{groups:[Ue([{Icon:Wo,key:"unorderedList",keywords:["unordered list","ul"],label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xi,void 0)}}])]},toolbarFixed:{groups:zi},toolbarInline:{groups:zi}});import{jsx as nm}from"react/jsx-runtime";import{addClassNamesToElement as im}from"@lexical/utils";import{DecoratorNode as lm}from"lexical";import*as Ji from"react";var sm=Ji.lazy(()=>import("./Component-MBLHTKDK.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),mt=class t extends lm{__data;constructor({data:e,key:o}){super(o),this.__data=e}static clone(e){return new t({data:e.__data,key:e.__key})}static getType(){return"unknownConverted"}static importJSON(e){return am({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return im(o,"unknownConverted"),o}decorate(){return nm(sm,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function am({data:t}){return new mt({data:t})}var cm=y(()=>({nodes:[mt]}));import{jsx as um}from"react/jsx-runtime";import{addClassNamesToElement as dm}from"@lexical/utils";import{DecoratorNode as mm}from"lexical";import*as qi from"react";var pm=qi.lazy(()=>import("./Component-DOSSWC76.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),pt=class t extends mm{__data;constructor({data:e,key:o}){super(o),this.__data=e}static clone(e){return new t({data:e.__data,key:e.__key})}static getType(){return"unknownConverted"}static importJSON(e){return fm({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return dm(o,"unknownConverted"),o}decorate(){return um(pm,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function fm({data:t}){return new pt({data:t})}var hm=y(()=>({nodes:[pt]}));import{$setBlocksType as tl}from"@lexical/selection";import{$createParagraphNode as ol,$getSelection as rl,$isParagraphNode as Qi,$isRangeSelection as gm}from"lexical";var el=[z([{ChildComponent:qe,isActive:({selection:t})=>{if(!gm(t))return!1;for(let e of t.getNodes())if(!Qi(e)&&!Qi(e.getParent()))return!1;return!0},key:"paragraph",label:({i18n:t})=>t.t("lexical:paragraph:label2"),onSelect:({editor:t})=>{t.update(()=>{let e=rl();tl(e,()=>ol())})},order:1}])],Cm=y({slashMenu:{groups:[V([{Icon:qe,key:"paragraph",keywords:["normal","paragraph","p","text"],label:({i18n:t})=>t.t("lexical:paragraph:label"),onSelect:({editor:t})=>{t.update(()=>{let e=rl();tl(e,()=>ol())})}}])]},toolbarFixed:{groups:el},toolbarInline:{groups:el}});import{$isNodeSelection as tp}from"lexical";import{jsx as ft,jsxs as xm}from"react/jsx-runtime";import"react";var Ko=()=>xm("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:[ft("g",{clipPath:"url(#clip0_4397_10817)",children:ft("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"})}),ft("defs",{children:ft("clipPath",{id:"clip0_4397_10817",children:ft("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{jsx as Tm}from"react/jsx-runtime";import*as il from"react";import{DecoratorBlockNode as bm}from"@lexical/react/LexicalDecoratorBlockNode.js";function _m(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:nl({relationTo:o,value:e})}:null}var ht=class extends bm{__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:_m,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=nl(o);return r.setFormat(e.format),r}static isInline(){return!1}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 nl(t){return new ht({data:t})}var wm=il.lazy(()=>import("./RelationshipComponent-JPESGV4Q.js").then(t=>({default:t.RelationshipComponent})));function Em(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:Me({relationTo:o,value:e})}:null}var ge=class extends ht{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:Em,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=Me(o);return r.setFormat(e.format),r}decorate(e,o){return Tm(wm,{className:o.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Me(t){return new ge({data:t})}function Zo(t){return t instanceof ge}import{c as jm}from"react/compiler-runtime";import{jsx as Um}from"react/jsx-runtime";import{useLexicalComposerContext as Gm}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Wm}from"@lexical/utils";import{useConfig as Vm}from"@payloadcms/ui";import{$getPreviousSelection as Km,$getSelection as Zm,$isParagraphNode as dl,$isRangeSelection as Ym,COMMAND_PRIORITY_EDITOR as zm,createCommand as Xm}from"lexical";import{useEffect as Jm}from"react";import{c as Om}from"react/compiler-runtime";import{jsx as Kt}from"react/jsx-runtime";import{useLexicalComposerContext as Fm}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as $m,COMMAND_PRIORITY_EDITOR as Pm}from"lexical";import{useEffect as Bm,useState as al}from"react";import{c as km}from"react/compiler-runtime";import{jsx as Lm}from"react/jsx-runtime";import{useLexicalComposerContext as Nm}from"@lexical/react/LexicalComposerContext";import{useListDrawer as Rm,useModal as Sm}from"@payloadcms/ui";import{$getNodeByKey as ll,$getPreviousSelection as Im,$getRoot as ym,$getSelection as vm,$isRangeSelection as Mm,$setSelection as Dm}from"lexical";import{useEffect as Am,useState as sl}from"react";var gt=t=>{let e=km(23),[o]=Nm(),[r,n]=sl(null),[i,l]=sl(!1),[s,a,u]=Rm(t),{closeDrawer:c,drawerSlug:d,isDrawerOpen:m,openDrawer:p}=u,{modalState:f}=Sm(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let R=vm()??Im();n(R)},e[0]=h):h=e[0];let C=h,b;e[1]!==o||e[2]!==r?(b=()=>{r&&o.update(()=>{if(Mm(r)){let{anchor:R,focus:S}=r;ll(R.key)&&ll(S.key)&&Dm(r.clone())}else ym().selectEnd()},{discrete:!0,skipTransforms:!0})},e[1]=o,e[2]=r,e[3]=b):b=e[3];let k=b,v;e[4]!==c?(v=()=>{c()},e[4]=c,e[5]=v):v=e[5];let x=v,T,g;e[6]!==d||e[7]!==f||e[8]!==k||e[9]!==i?(T=()=>{if(!i)return;let R=f[d];R&&!R?.isOpen&&(l(!1),setTimeout(()=>{k()},1))},g=[f,d,k,i],e[6]=d,e[7]=f,e[8]=k,e[9]=i,e[10]=T,e[11]=g):(T=e[10],g=e[11]),Am(T,g);let w;e[12]!==a?(w=R=>Lm(a,{...R,onClick:()=>{C()}}),e[12]=a,e[13]=w):w=e[13];let N;e[14]!==p?(N=()=>{C(),p(),l(!0)},e[14]=p,e[15]=N):N=e[15];let L;return e[16]!==s||e[17]!==x||e[18]!==m||e[19]!==d||e[20]!==w||e[21]!==N?(L={closeListDrawer:x,isListDrawerOpen:m,ListDrawer:s,listDrawerSlug:d,ListDrawerToggler:w,openListDrawer:N},e[16]=s,e[17]=x,e[18]=m,e[19]=d,e[20]=w,e[21]=N,e[22]=L):L=e[22],L};var Hm=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=$m(o);n&&n.replace(Me({relationTo:e,value:r}))}):t.dispatchCommand(Yo,{relationTo:e,value:r})},cl=t=>{let e=Om(16),{enabledCollectionSlugs:o}=t,[r]=Fm(),n;e[0]!==o?(n=()=>o?.[0],e[0]=o,e[1]=n):n=e[1];let[i]=al(n),[l,s]=al(null),a=o||void 0,u;e[2]!==i||e[3]!==a?(u={collectionSlugs:a,selectedCollection:i},e[2]=i,e[3]=a,e[4]=u):u=e[4];let{closeListDrawer:c,ListDrawer:d,openListDrawer:m}=gt(u),p,f;e[5]!==r||e[6]!==m?(p=()=>r.registerCommand(Je,k=>(s(k?.replace?k?.replace.nodeKey:null),m(),!0),Pm),f=[r,m],e[5]=r,e[6]=m,e[7]=p,e[8]=f):(p=e[7],f=e[8]),Bm(p,f);let h;e[9]!==c||e[10]!==r||e[11]!==l?(h=k=>{let{collectionSlug:v,docID:x}=k;Hm({editor:r,relationTo:v,replaceNodeKey:l,value:x}),c()},e[9]=c,e[10]=r,e[11]=l,e[12]=h):h=e[12];let C=h,b;return e[13]!==d||e[14]!==C?(b=Kt(d,{onSelect:C}),e[13]=d,e[14]=C,e[15]=b):b=e[15],b},ul=t=>(t?.enabledCollectionSlugs?.length??-1)>0?Kt(cl,{...t}):Kt(Nt,{...t,children:Kt(cl,{...t})});var Yo=Xm("INSERT_RELATIONSHIP_COMMAND"),ml=t=>{let e=jm(10),{clientProps:o}=t,[r]=Gm(),{config:n}=Vm(),{collections:i}=n,l=null;if(o?.enabledCollections)l=o?.enabledCollections;else if(o?.disabledCollections){let c;if(e[0]!==o?.disabledCollections||e[1]!==i){let d;e[3]!==o?.disabledCollections?(d=m=>{let{slug:p}=m;return!o?.disabledCollections?.includes(p)},e[3]=o?.disabledCollections,e[4]=d):d=e[4],c=i.filter(d).map(qm),e[0]=o?.disabledCollections,e[1]=i,e[2]=c}else c=e[2];l=c}let s,a;e[5]!==r?(s=()=>{if(!r.hasNodes([ge]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand(Yo,ep,zm)},a=[r],e[5]=r,e[6]=s,e[7]=a):(s=e[6],a=e[7]),Jm(s,a);let u;return e[8]!==l?(u=Um(ul,{enabledCollectionSlugs:l}),e[8]=l,e[9]=u):u=e[9],u};function qm(t){let{slug:e}=t;return e}function Qm(t){return dl(t)}function ep(t){let e=Zm()||Km();if(Ym(e)){let o=Me(t);Wm(o);let{focus:r}=e,n=r.getNode();dl(n)&&n.getTextContentSize()===0&&n.getParentOrThrow().getChildren().filter(Qm).length>1&&n.remove()}return!0}var op=y({nodes:[ge],plugins:[{Component:ml,position:"normal"}],slashMenu:{groups:[V([{Icon:Ko,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Je,{replace:!1})}}])]},toolbarFixed:{groups:[de([{ChildComponent:Ko,isActive:({selection:t})=>{if(!tp(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return Zo(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Je,{replace:!1})}}])]}});import{c as xl}from"react/compiler-runtime";import{jsx as te,jsxs as wp}from"react/jsx-runtime";import{useLexicalComposerContext as Ep}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as kp,useThrottledEffect as Lp,useTranslation as Np}from"@payloadcms/ui";import*as Ce from"react";import{useMemo as Rp}from"react";import{c as rp}from"react/compiler-runtime";import{jsx as np}from"react/jsx-runtime";import{mergeRegister as ip}from"@lexical/utils";import{$addUpdateTag as lp,$getSelection as sp}from"lexical";import{useEffect as Zt,useState as zo}from"react";var Xo="toolbar-popup__button",Ct=t=>{let e=rp(34),{children:o,editor:r,item:n}=t,[i,l]=zo(!0),[s,a]=zo(!1),[u,c]=zo(Xo),d=P(),m;e[0]!==s||e[1]!==r||e[2]!==d||e[3]!==i||e[4]!==n?(m=()=>{r.getEditorState().read(()=>{let N=sp();if(N){if(n.isActive){let L=n.isActive({editor:r,editorConfigContext:d,selection:N});s!==L&&a(L)}if(n.isEnabled){let L=n.isEnabled({editor:r,editorConfigContext:d,selection:N});i!==L&&l(L)}}})},e[0]=s,e[1]=r,e[2]=d,e[3]=i,e[4]=n,e[5]=m):m=e[5];let p=m,f,h;e[6]!==p?(f=()=>{p()},h=[p],e[6]=p,e[7]=f,e[8]=h):(f=e[7],h=e[8]),Zt(f,h);let C,b;e[9]!==p?(C=()=>(document.addEventListener("mouseup",p),()=>{document.removeEventListener("mouseup",p)}),b=[p],e[9]=p,e[10]=C,e[11]=b):(C=e[10],b=e[11]),Zt(C,b);let k,v;e[12]!==r||e[13]!==p?(k=()=>ip(r.registerUpdateListener(()=>{p()})),v=[r,p],e[12]=r,e[13]=p,e[14]=k,e[15]=v):(k=e[14],v=e[15]),Zt(k,v);let x;e[16]!==s||e[17]!==i||e[18]!==n.key?(x=()=>{c([Xo,i===!1?"disabled":"",s?"active":"",n?.key?`${Xo}-`+n.key:""].filter(Boolean).join(" "))},e[16]=s,e[17]=i,e[18]=n.key,e[19]=x):x=e[19];let T;e[20]!==s||e[21]!==u||e[22]!==i||e[23]!==n.key?(T=[i,s,u,n.key],e[20]=s,e[21]=u,e[22]=i,e[23]=n.key,e[24]=T):T=e[24],Zt(x,T);let g;e[25]!==s||e[26]!==r||e[27]!==i||e[28]!==n?(g=()=>{if(i!==!1)return r.focus(()=>{r.update(ap),n.onSelect?.({editor:r,isActive:s})}),!0},e[25]=s,e[26]=r,e[27]=i,e[28]=n,e[29]=g):g=e[29];let w;return e[30]!==o||e[31]!==u||e[32]!==g?(w=np("button",{className:u,onClick:g,onMouseDown:cp,type:"button",children:o}),e[30]=o,e[31]=u,e[32]=g,e[33]=w):w=e[33],w};function ap(){lp("toolbar")}function cp(t){t.preventDefault()}import{c as gp}from"react/compiler-runtime";import{jsx as Ve}from"react/jsx-runtime";import Qo,{useCallback as Cp,useEffect as Cl}from"react";import{mergeRegister as xp}from"@lexical/utils";import{useTranslation as bp}from"@payloadcms/ui";import{$getSelection as _p}from"lexical";import{jsx as ke,jsxs as pl}from"react/jsx-runtime";import{Button as up}from"@payloadcms/ui";import{$addUpdateTag as dp}from"lexical";import Yt,{useCallback as mp,useEffect as xt,useMemo as pp,useRef as qo,useState as zt}from"react";import{createPortal as fp}from"react-dom";var Jo="toolbar-popup__dropdown-item",fl=Yt.createContext(null);function hl({active:t,children:e,editor:o,enabled:r,Icon:n,item:i,tooltip:l}){let[s,a]=zt(Jo);xt(()=>{a([Jo,r===!1?"disabled":"",t?"active":"",i?.key?`${Jo}-${i.key}`:""].filter(Boolean).join(" "))},[r,t,s,i.key]);let u=qo(null),c=Yt.useContext(fl);if(c===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:d}=c;return xt(()=>{u?.current!=null&&d(u)},[u,d]),ke(up,{"aria-label":l,buttonStyle:"none",className:s,disabled:r===!1,icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{dp("toolbar")}),i.onSelect?.({editor:o,isActive:t})})},onMouseDown:m=>{m.preventDefault()},ref:u,tooltip:l,type:"button",children:e})}function hp({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,i]=zt(),[l,s]=zt(),a=mp(d=>{i(m=>m!=null?[...m,d]:[d])},[i]),u=d=>{if(n==null)return;let{key:m}=d;["ArrowDown","ArrowUp","Escape","Tab"].includes(m)&&d.preventDefault(),m==="Escape"||m==="Tab"?r():m==="ArrowUp"?s(p=>{if(p==null)return n[0];let f=n.indexOf(p)-1;return n[f===-1?n.length-1:f]}):m==="ArrowDown"&&s(p=>p==null?n[0]:n[n.indexOf(p)+1])},c=pp(()=>({registerItem:a}),[a]);return xt(()=>{n!=null&&l==null&&s(n[0]),l!=null&&l?.current!=null&&l.current.focus()},[n,l]),ke(fl.Provider,{value:c,children:ke("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:u,ref:e,children:t})})}function gl({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,Icon:n,itemsContainerClassNames:i,label:l,stopCloseOnClickSelf:s}){let a=qo(null),u=qo(null),[c,d]=zt(!1),m=()=>{d(!1),u?.current!=null&&u.current.focus()};xt(()=>{let f=u.current,h=a.current;if(c&&f!==null&&h!==null){let{left:C,top:b}=f.getBoundingClientRect(),k=window.scrollY||document.documentElement.scrollTop;h.style.top=`${b+k+f.offsetHeight+5}px`,h.style.left=`${Math.min(C-5,window.innerWidth-h.offsetWidth-20)}px`}},[a,u,c]),xt(()=>{let f=u.current;if(f!==null&&c){let h=C=>{let{target:b}=C;s!=null&&a.current!=null&&a.current.contains(b)||f.contains(b)||d(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[a,u,c,s]);let p=fp(ke(hp,{dropDownRef:a,itemsContainerClassNames:i,onClose:m,children:o}),document.body);return pl(Yt.Fragment,{children:[pl("button",{"aria-label":t,className:e+(c?" active":""),disabled:r,onClick:f=>{f.preventDefault(),d(!c)},onMouseDown:f=>{f.preventDefault()},ref:u,type:"button",children:[n&&ke(n,{}),l&&ke("span",{className:"toolbar-popup__dropdown-label",children:l}),ke("i",{className:"toolbar-popup__dropdown-caret"})]}),c&&ke(Yt.Fragment,{children:p})]})}var er="toolbar-popup__dropdown",Tp=t=>{let e=gp(18),{active:o,anchorElem:r,editor:n,enabled:i,item:l}=t,{i18n:s}=bp(),{fieldProps:a}=P(),{featureClientSchemaMap:u,schemaPath:c}=a;if(l.Component){let f;return e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==i||e[4]!==l?(f=l?.Component&&Ve(l.Component,{active:o,anchorElem:r,editor:n,enabled:i,item:l},l.key),e[0]=o,e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=f):f=e[5],f}let d=l.key,m;if(l.label){let f;e[6]!==u||e[7]!==s||e[8]!==l||e[9]!==c?(f=typeof l.label=="function"?l.label({featureClientSchemaMap:u,i18n:s,schemaPath:c}):l.label,e[6]=u,e[7]=s,e[8]=l,e[9]=c,e[10]=f):f=e[10],d=f}d.length>25?m=d.substring(0,25)+"...":m=d;let p;return e[11]!==o||e[12]!==m||e[13]!==n||e[14]!==i||e[15]!==l||e[16]!==d?(p=Ve(hl,{active:o,editor:n,enabled:i,Icon:l?.ChildComponent?Ve(l.ChildComponent,{}):void 0,item:l,tooltip:d,children:Ve("span",{className:"text",children:m})},l.key),e[11]=o,e[12]=m,e[13]=n,e[14]=i,e[15]=l,e[16]=d,e[17]=p):p=e[17],p},De=({anchorElem:t,classNames:e,editor:o,group:r,Icon:n,itemsContainerClassNames:i,label:l,maxActiveItems:s,onActiveChange:a})=>{let[u,c]=Qo.useState([]),[d,m]=Qo.useState([]),[p,f]=Qo.useState(!0),h=P(),{items:C,key:b}=r,k=Cp(()=>{o.getEditorState().read(()=>{let v=_p();if(!v)return;let x=[],T=[],g=[];for(let w of C)w.isActive&&(!s||x.length<s)&&w.isActive({editor:o,editorConfigContext:h,selection:v})&&(x.push(w.key),T.push(w)),w.isEnabled?w.isEnabled({editor:o,editorConfigContext:h,selection:v})&&g.push(w.key):g.push(w.key);r.isEnabled&&f(r.isEnabled({editor:o,editorConfigContext:h,selection:v})),c(x),m(g),a&&a({activeItems:T})})},[o,h,r,C,s,a]);return Cl(()=>{k()},[k]),Cl(()=>xp(o.registerUpdateListener(()=>{k()})),[o,k]),Ve(gl,{buttonAriaLabel:`${b} dropdown`,buttonClassName:[er,`${er}-${b}`,...e||[]].filter(Boolean).join(" "),disabled:!p,Icon:n,itemsContainerClassNames:[`${er}-items`,...i||[]],label:l,children:C.length?C.map(v=>Ve(Tp,{active:u.includes(v.key),anchorElem:t,editor:o,enabled:d.includes(v.key),item:v},v.key)):null},b)};function Sp({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&te(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?te(Ct,{editor:e,item:o,children:te(o.ChildComponent,{})},o.key):null}function Ip(t){let e=xl(23),{anchorElem:o,editor:r,editorConfig:n,group:i,index:l}=t,{i18n:s}=Np(),{fieldProps:a}=P(),{featureClientSchemaMap:u,schemaPath:c}=a,[d,m]=Ce.useState(void 0),[p,f]=Ce.useState(void 0),h;e[0]!==i.ChildComponent||e[1]!==i.items||e[2]!==i.type?(h=()=>{i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0)},e[0]=i.ChildComponent,e[1]=i.items,e[2]=i.type,e[3]=h):h=e[3];let C;e[4]!==i?(C=[i],e[4]=i,e[5]=C):C=e[5],Ce.useEffect(h,C);let b;e[6]!==u||e[7]!==i.ChildComponent||e[8]!==i.items||e[9]!==i.type||e[10]!==s||e[11]!==c?(b=T=>{let{activeItems:g}=T;if(!g.length){i?.type==="dropdown"&&i.items.length&&i.ChildComponent?(f(()=>i.ChildComponent),m(void 0)):(f(void 0),m(void 0));return}let w=g[0],N=w.key;w.label&&(N=typeof w.label=="function"?w.label({featureClientSchemaMap:u,i18n:s,schemaPath:c}):w.label),N.length>25&&(N=N.substring(0,25)+"..."),g.length===1?(m(N),f(()=>w.ChildComponent)):(m(s.t("lexical:general:toolbarItemsActive",{count:g.length})),i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0))},e[6]=u,e[7]=i.ChildComponent,e[8]=i.items,e[9]=i.type,e[10]=s,e[11]=c,e[12]=b):b=e[12];let k=b,v=`fixed-toolbar__group fixed-toolbar__group-${i.key}`,x;return e[13]!==p||e[14]!==o||e[15]!==d||e[16]!==r||e[17]!==n.features.toolbarFixed?.groups.length||e[18]!==i||e[19]!==l||e[20]!==k||e[21]!==v?(x=wp("div",{className:v,children:[i.type==="dropdown"&&i.items.length?p?te(De,{anchorElem:o,editor:r,group:i,Icon:p,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:d,maxActiveItems:i.maxActiveItems??1,onActiveChange:k}):te(De,{anchorElem:o,editor:r,group:i,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:d,maxActiveItems:i.maxActiveItems??1,onActiveChange:k}):null,i.type==="buttons"&&i.items.length?i.items.map(T=>te(Sp,{anchorElem:o,editor:r,item:T},T.key)):null,l<n.features.toolbarFixed?.groups.length-1&&te("div",{className:"divider"})]},i.key),e[13]=p,e[14]=o,e[15]=d,e[16]=r,e[17]=n.features.toolbarFixed?.groups.length,e[18]=i,e[19]=l,e[20]=k,e[21]=v,e[22]=x):x=e[22],x}function yp({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let i=Ce.useRef(null),{y:l}=kp(),s=Rp(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let u=n.editorContainerRef.current.previousElementSibling;for(;u;){if(u.classList.contains("fixed-toolbar"))return u;u=u.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return Lp(()=>{if(!s)return;let a=i.current;if(!a)return;let u=a.getBoundingClientRect(),c=s.getBoundingClientRect();if(!(u.bottom<c.top||u.top>c.bottom))a.classList.remove("fixed-toolbar"),a.classList.add("fixed-toolbar","fixed-toolbar--overlapping"),s.classList.remove("fixed-toolbar"),s.classList.add("fixed-toolbar","fixed-toolbar--hide");else{if(!a.classList.contains("fixed-toolbar--overlapping"))return;a.classList.remove("fixed-toolbar--overlapping"),a.classList.add("fixed-toolbar"),s.classList.remove("fixed-toolbar--hide"),s.classList.add("fixed-toolbar")}},50,[i,s,l]),te("div",{className:"fixed-toolbar",onFocus:a=>{a.stopPropagation()},ref:i,children:o.isEditable()&&te(Ce.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((a,u)=>te(Ip,{anchorElem:t,editor:o,editorConfig:r,group:a,index:u},a.key))})})}var bl=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return bl(t.parentEditor)}return!1},_l=t=>{let e=xl(6),{clientProps:o}=t,[r]=Ep(),n=P(),{editorConfig:i}=n,l=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,s=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||i,a,u;if(e[0]!==o.disableIfParentHasFixedToolbar||e[1]!==l||e[2]!==s||e[3]!==n){u=Symbol.for("react.early_return_sentinel");e:{let c=bl(n);if(o?.disableIfParentHasFixedToolbar&&c){u=null;break e}if(!s?.features?.toolbarFixed?.groups?.length){u=null;break e}a=te(yp,{anchorElem:document.body,editor:l,editorConfig:s,parentWithFixedToolbar:c})}e[0]=o.disableIfParentHasFixedToolbar,e[1]=l,e[2]=s,e[3]=n,e[4]=a,e[5]=u}else a=e[4],u=e[5];return u!==Symbol.for("react.early_return_sentinel")?u:a};var vp=y({plugins:[{Component:_l,position:"aboveContainer"}]});import{c as El}from"react/compiler-runtime";import{jsx as ie,jsxs as kl}from"react/jsx-runtime";import{useLexicalComposerContext as Mp}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Ll}from"@lexical/utils";import{$getSelection as Nl,$isRangeSelection as Tl,$isTextNode as Dp,COMMAND_PRIORITY_LOW as Ap,getDOMSelection as Rl,SELECTION_CHANGE_COMMAND as Op}from"lexical";import{useCallback as Jt,useEffect as bt,useRef as wl,useState as Fp}from"react";import*as qt from"react";import{createPortal as $p}from"react-dom";function tr(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 Xt(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:i=32,horizontalPosition:l="left",specialHandlingForCaret:s=!1,targetRect:a,verticalGap:u=10}=t,c=o.parentElement;if(a===null||c==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let d=n.getBoundingClientRect(),m=o.getBoundingClientRect(),p=c.getBoundingClientRect(),f=a.top-d.height-u,h=a.left-i;l==="center"&&(h=a.left+a.width/2-d.width/2);let C=0;return!e&&f<p.top&&!s&&(C=d.height+a.height+u*2,f+=C),l==="center"?h+d.width>p.right?h=p.right-d.width-i:h<p.left&&(h=p.left+i):h+d.width>p.right&&(h=p.right-d.width-i),h-=m.left,n.style.opacity="1",s&&r!==0?(f-=m.bottom-r+d.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=m.top,n.style.transform=`translate(${h}px, ${f}px)`),C}function Pp({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&ie(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?ie(Ct,{editor:e,item:o,children:ie(o.ChildComponent,{})},o.key):null}function Bp(t){let e=El(19),{anchorElem:o,editor:r,group:n,index:i}=t,{editorConfig:l}=P(),[s,a]=qt.useState(),u;e[0]!==n.ChildComponent||e[1]!==n.items||e[2]!==n.type?(u=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0)},e[0]=n.ChildComponent,e[1]=n.items,e[2]=n.type,e[3]=u):u=e[3];let c;e[4]!==n?(c=[n],e[4]=n,e[5]=c):c=e[5],qt.useEffect(u,c);let d;e[6]!==n.ChildComponent||e[7]!==n.items||e[8]!==n.type?(d=h=>{let{activeItems:C}=h;if(!C.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0);return}let b=C[0];a(()=>b.ChildComponent)},e[6]=n.ChildComponent,e[7]=n.items,e[8]=n.type,e[9]=d):d=e[9];let m=d,p=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;return e[10]!==s||e[11]!==o||e[12]!==r||e[13]!==l.features.toolbarInline?.groups.length||e[14]!==n||e[15]!==i||e[16]!==m||e[17]!==p?(f=kl("div",{className:p,children:[n.type==="dropdown"&&n.items.length?s?ie(De,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:n.maxActiveItems??1,onActiveChange:m}):ie(De,{anchorElem:o,editor:r,group:n,maxActiveItems:n.maxActiveItems??1,onActiveChange:m}):null,n.type==="buttons"&&n.items.length?n.items.map(h=>ie(Pp,{anchorElem:o,editor:r,item:h},h.key)):null,i<l.features.toolbarInline?.groups.length-1&&ie("div",{className:"divider"})]},n.key),e[10]=s,e[11]=o,e[12]=r,e[13]=l.features.toolbarInline?.groups.length,e[14]=n,e[15]=i,e[16]=m,e[17]=p,e[18]=f):f=e[18],f}function Hp({anchorElem:t,editor:e}){let o=wl(null),r=wl(null),{editorConfig:n}=P(),i=Jt(()=>{if(o?.current){let u=o.current.style.opacity==="0",c=o.current.style.pointerEvents==="none";u||(o.current.style.opacity="0"),c||(o.current.style.pointerEvents="none")}},[o]),l=Jt(u=>{if(o?.current&&(u.buttons===1||u.buttons===3)){let c=o.current.style.opacity==="0",d=o.current.style.pointerEvents==="none";if(!c||!d){let m=u.clientX,p=u.clientY,f=document.elementFromPoint(m,p);o.current.contains(f)||i()}}},[i]),s=Jt(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);bt(()=>(document.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}),[o,l,s]);let a=Jt(()=>{let u=Nl(),c=Rl(e._window);if(o.current===null)return;let d=t.querySelector(":scope > .link-editor"),m=d!==null&&"style"in d&&d?.style?.opacity==="1",p=e.getRootElement();if(u!==null&&c!==null&&!c.isCollapsed&&p!==null&&p.contains(c.anchorNode)){let f=tr(c,p),h=Xt({alwaysDisplayOnTop:m,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&Xt({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else i()},[e,i,t]);return bt(()=>{let u=t.parentElement,c=()=>{e.getEditorState().read(()=>{a()})};return window.addEventListener("resize",c),u&&u.addEventListener("scroll",c),()=>{window.removeEventListener("resize",c),u&&u.removeEventListener("scroll",c)}},[e,a,t]),bt(()=>(e.getEditorState().read(()=>{a()}),Ll(e.registerUpdateListener(({editorState:u})=>{u.read(()=>{a()})}),e.registerCommand(Op,()=>(a(),!1),Ap))),[e,a]),kl("div",{className:"inline-toolbar-popup",ref:o,children:[ie("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((u,c)=>ie(Bp,{anchorElem:t,editor:e,group:u,index:c},u.key))]})}function jp(t,e){let o=El(12),[r,n]=Fp(!1),i;o[0]!==t?(i=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let m=Nl(),p=Rl(t._window),f=t.getRootElement();if(p!==null&&(!Tl(m)||f===null||!f.contains(p.anchorNode))){n(!1);return}if(!Tl(m))return;if(m.getTextContent()!==""){let C=m.getNodes(),b=!1;for(let k of C)if(Dp(k)){n(!0),b=!0;break}b||n(!1)}else n(!1);let h=m.getTextContent().replace(/\n/g,"");if(!m.isCollapsed()&&h===""){n(!1);return}})},o[0]=t,o[1]=i):i=o[1];let l=i,s,a;o[2]!==l?(s=()=>(document.addEventListener("selectionchange",l),document.addEventListener("mouseup",l),()=>{document.removeEventListener("selectionchange",l),document.removeEventListener("mouseup",l)}),a=[l],o[2]=l,o[3]=s,o[4]=a):(s=o[3],a=o[4]),bt(s,a);let u,c;if(o[5]!==t||o[6]!==l?(u=()=>Ll(t.registerUpdateListener(()=>{l()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),c=[t,l],o[5]=t,o[6]=l,o[7]=u,o[8]=c):(u=o[7],c=o[8]),bt(u,c),!r||!t.isEditable())return null;let d;return o[9]!==e||o[10]!==t?(d=$p(ie(Hp,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=d):d=o[11],d}var Sl=t=>{let{anchorElem:e}=t,[o]=Mp();return jp(o,e)};var Up=y({plugins:[{Component:Sl,position:"floatingAnchorElem"}]});import{TableCellNode as N1,TableNode as R1,TableRowNode as S1}from"@lexical/table";import{jsx as Il}from"react/jsx-runtime";import"react";var or=()=>Il("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Il("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 Gp,$createTableNode as Wp,$createTableRowNode as Vp,$isTableCellNode as yl,$isTableNode as rr,$isTableRowNode as nr,TableCellHeaderStates as Qt,TableCellNode as Kp,TableNode as Zp,TableRowNode as Yp}from"@lexical/table";import{$isParagraphNode as zp,$isTextNode as Xp}from"lexical";var Ml=/^\|(.+)\|\s?$/,Jp=/^(\| ?:?-*:? ?)+\|\s?$/,Dl=({allTransformers:t})=>({type:"element",dependencies:[Zp,Yp,Kp],export:e=>{if(!rr(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!nr(r))continue;let i=!1;for(let l of r.getChildren())yl(l)&&(n.push(Rr(t,l).replace(/\n/g,"\\n")),l.__headerState===Qt.ROW&&(i=!0));o.push(`| ${n.join(" | ")} |`),i&&o.push(`| ${n.map(l=>"---").join(" | ")} |`)}return o.join(`
|
|
37
|
-
`)},regExp:
|
|
38
|
-
`);let o=Gp(Qt.NO_STATUS);return Nr(t,e,o),o},vl=(t,e)=>{let o=t.match(Ml);return!o||!o[1]?null:o[1].split("|").map(r=>Al(r,e))};import{c as ef}from"react/compiler-runtime";import{jsx as $,jsxs as xe}from"react/jsx-runtime";import{useLexicalComposerContext as Bl}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as tf}from"@lexical/react/useLexicalEditable";import{$deleteTableColumn__EXPERIMENTAL as of,$deleteTableRow__EXPERIMENTAL as rf,$getNodeTriplet as nf,$getTableCellNodeFromLexicalNode as Fl,$getTableColumnIndexFromTableCellNode as lf,$getTableNodeFromLexicalNodeOrThrow as Ae,$getTableRowIndexFromTableCellNode as sf,$insertTableColumn__EXPERIMENTAL as af,$insertTableRow__EXPERIMENTAL as cf,$isTableCellNode as _t,$isTableRowNode as $l,$isTableSelection as Tt,$unmergeCell as uf,getTableElement as sr,getTableObserverFromTableElement as ar,TableCellHeaderStates as Le,TableCellNode as df}from"@lexical/table";import{mergeRegister as mf}from"@lexical/utils";import{useScrollInfo as pf}from"@payloadcms/ui";import{$createParagraphNode as ff,$getRoot as hf,$getSelection as to,$isElementNode as gf,$isParagraphNode as Hl,$isRangeSelection as cr,$isTextNode as Cf,COMMAND_PRIORITY_CRITICAL as xf,getDOMSelection as bf,SELECTION_CHANGE_COMMAND as _f}from"lexical";import*as ur from"react";import{useCallback as le,useEffect as Ke,useRef as eo,useState as Ze}from"react";import{createPortal as jl}from"react-dom";import{jsx as ir,jsxs as Qp}from"react/jsx-runtime";import"react";var Ol=()=>Qp("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[ir("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"}),ir("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"}),ir("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 lr(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Tf(){let t=to();if(cr(t)&&!t.isCollapsed()||Tt(t)&&!t.anchor.is(t.focus)||!cr(t)&&!Tt(t))return!1;let[e]=nf(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Pl(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!Hl(e)||!e.isEmpty())}function wf(t){let e=t.getLastDescendant();Cf(e)?e.select():gf(e)?e.selectEnd():e!==null&&e.selectNext()}function Ef({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=Bl(),l=eo(null),[s,a]=Ze(n),[u,c]=Ze({columns:1,rows:1}),[d,m]=Ze(!1),[p,f]=Ze(!1),{y:h}=pf();Ke(()=>i.registerMutationListener(df,E=>{E.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{a(s.getLatest())})},{skipInitialization:!0}),[i,s]),Ke(()=>{i.getEditorState().read(()=>{let E=to();if(Tt(E)){let _=lr(E);c(lr(E)),m(_.columns>1||_.rows>1)}f(Tf())})},[i]),Ke(()=>{let E=e.current,_=l.current,I=i.getRootElement();if(E!=null&&_!=null&&I!=null){let M=I.getBoundingClientRect(),D=E.getBoundingClientRect();_.style.opacity="1";let F=_.getBoundingClientRect(),A=5,H=D.right+A;if(H+F.width>window.innerWidth||H+F.width>M.right){let oe=D.left-F.width-A;H=(oe<0?A:oe)+window.pageXOffset}_.style.left=`${H+window.pageXOffset}px`;let Z=D.top;if(Z+F.height>window.innerHeight){let oe=D.bottom-F.height;Z=oe<0?A:oe}_.style.top=`${Z}px`}},[e,l,i,h]),Ke(()=>{function E(_){l.current!=null&&e.current!=null&&!l.current.contains(_.target)&&!e.current.contains(_.target)&&r(!1)}return window.addEventListener("click",E),()=>window.removeEventListener("click",E)},[r,e]);let C=le(()=>{i.update(()=>{if(s.isAttached()){let _=Ae(s),I=sr(_,i.getElementByKey(_.getKey()));if(I===null)throw new Error("Expected to find tableElement in DOM");let M=ar(I);M!==null&&M.$clearHighlight(),_.markDirty(),a(s.getLatest())}hf().selectStart()})},[i,s]),b=()=>{i.update(()=>{let E=to();if(Tt(E)){let{columns:_,rows:I}=lr(E),M=E.getNodes(),D=null;for(let F=0;F<M.length;F++){let A=M[F];if(_t(A))if(D===null){A.setColSpan(_).setRowSpan(I),D=A;let H=Pl(A),Z;H&&Hl(Z=A.getFirstChild())&&Z.remove()}else _t(D)&&(Pl(A)||D.append(...A.getChildren()),A.remove())}D!==null&&(D.getChildrenSize()===0&&D.append(ff()),wf(D)),o()}})},k=()=>{i.update(()=>{uf()})},v=le(E=>{i.update(()=>{cf(E),o()})},[i,o]),x=le(E=>{i.update(()=>{for(let _=0;_<u.columns;_++)af(E);o()})},[i,o,u.columns]),T=le(()=>{i.update(()=>{rf(),o()})},[i,o]),g=le(()=>{i.update(()=>{Ae(s).remove(),C(),o()})},[i,s,C,o]),w=le(()=>{i.update(()=>{of(),o()})},[i,o]),N=le(()=>{i.update(()=>{let E=Ae(s),_=sf(s),I=E.getChildren();if(_>=I.length||_<0)throw new Error("Expected table cell to be inside of table row.");let M=I[_];if(!$l(M))throw new Error("Expected table row");let D=s.getHeaderStyles()^Le.ROW;M.getChildren().forEach(F=>{if(!_t(F))throw new Error("Expected table cell");F.setHeaderStyles(D,Le.ROW)}),C(),o()})},[i,s,C,o]),L=le(()=>{i.update(()=>{let E=Ae(s),_=lf(s),I=E.getChildren(),M=Math.max(...I.map(F=>F.getChildren().length));if(_>=M||_<0)throw new Error("Expected table cell to be inside of table row.");let D=s.getHeaderStyles()^Le.COLUMN;for(let F=0;F<I.length;F++){let A=I[F];if(!$l(A))throw new Error("Expected table row");let H=A.getChildren();if(_>=H.length)continue;let Z=H[_];if(!_t(Z))throw new Error("Expected table cell");Z.setHeaderStyles(D,Le.COLUMN)}C(),o()})},[i,s,C,o]),R=le(()=>{i.update(()=>{if(s.isAttached()){let E=Ae(s);E&&E.setRowStriping(!E.getRowStriping())}C(),o()})},[i,s,C,o]),S=null;return t&&(d?S=$("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>b(),type:"button",children:$("span",{className:"text",children:"Merge cells"})}):p&&(S=$("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>k(),type:"button",children:$("span",{className:"text",children:"Unmerge cells"})}))),jl(xe("div",{className:"table-action-menu-dropdown",onClick:E=>{E.stopPropagation()},ref:l,children:[S?xe(ur.Fragment,{children:[S,$("hr",{})]}):null,$("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>R(),type:"button",children:$("span",{className:"text",children:"Toggle Row Striping"})}),$("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>v(!1),type:"button",children:xe("span",{className:"text",children:["Insert ",u.rows===1?"row":`${u.rows} rows`," above"]})}),$("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>v(!0),type:"button",children:xe("span",{className:"text",children:["Insert ",u.rows===1?"row":`${u.rows} rows`," below"]})}),$("hr",{}),$("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>x(!1),type:"button",children:xe("span",{className:"text",children:["Insert ",u.columns===1?"column":`${u.columns} columns`," ","left"]})}),$("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>x(!0),type:"button",children:xe("span",{className:"text",children:["Insert ",u.columns===1?"column":`${u.columns} columns`," ","right"]})}),$("hr",{}),$("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>w(),type:"button",children:$("span",{className:"text",children:"Delete column"})}),$("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>T(),type:"button",children:$("span",{className:"text",children:"Delete row"})}),$("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:$("span",{className:"text",children:"Delete table"})}),$("hr",{}),$("button",{className:"item",onClick:()=>N(),type:"button",children:xe("span",{className:"text",children:[(s.__headerState&Le.ROW)===Le.ROW?"Remove":"Add"," ","row header"]})}),$("button",{className:"item","data-test-id":"table-column-header",onClick:()=>L(),type:"button",children:xe("span",{className:"text",children:[(s.__headerState&Le.COLUMN)===Le.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function kf({anchorElem:t,cellMerge:e}){let[o]=Bl(),r=eo(null),n=eo(null),[i,l]=Ze(!1),[s,a]=Ze(null),u=le(()=>{let d=r.current,m=to(),p=bf(o._window),f=document.activeElement;function h(){d&&(d.classList.remove("table-cell-action-button-container--active"),d.classList.add("table-cell-action-button-container--inactive")),a(null)}if(m==null||d==null)return h();let C=o.getRootElement(),b=null,k=null;if(cr(m)&&C!==null&&p!==null&&C.contains(p.anchorNode)){let x=Fl(m.anchor.getNode());if(x==null||(k=o.getElementByKey(x.getKey()),k==null||!x.isAttached()))return h();let T=Ae(x),g=sr(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=ar(g),a(x)}else if(Tt(m)){let x=Fl(m.anchor.getNode());if(!_t(x))throw new Error("TableSelection anchorNode must be a TableCellNode");let T=Ae(x),g=sr(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=ar(g),k=o.getElementByKey(x.getKey())}else if(!f)return h();if(b===null||k===null)return h();let v=!b||!b.isSelecting;if(d.classList.toggle("table-cell-action-button-container--active",v),d.classList.toggle("table-cell-action-button-container--inactive",!v),v){let x=k.getBoundingClientRect(),T=t.getBoundingClientRect(),g=x.top-T.top,w=x.right-T.left;d.style.transform=`translate(${w}px, ${g}px)`}},[o,t]);Ke(()=>{let d,m=()=>{d=void 0,o.getEditorState().read(u)},p=()=>(d===void 0&&(d=setTimeout(m,0)),!1);return mf(o.registerUpdateListener(p),o.registerCommand(_f,p,xf),o.registerRootListener((f,h)=>{h&&h.removeEventListener("mouseup",p),f&&(f.addEventListener("mouseup",p),p())}),()=>clearTimeout(d))});let c=eo(s);return Ke(()=>{c.current!==s&&l(!1),c.current=s},[c,s]),$("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&xe(ur.Fragment,{children:[$("button",{className:"table-cell-action-button",onClick:d=>{d.stopPropagation(),l(!i)},ref:n,type:"button",children:$(Ol,{})}),i&&$(Ef,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Ul=t=>{let e=ef(3),{anchorElem:o}=t,r=tf(),n;return e[0]!==o||e[1]!==r?(n=jl(r?$(kf,{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 Lf}from"react/compiler-runtime";import{jsx as ro,jsxs as Nf}from"react/jsx-runtime";import{useLexicalComposerContext as Rf}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Sf}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as If,$getTableNodeFromLexicalNodeOrThrow as dr,$getTableRowIndexFromTableCellNode as yf,$isTableCellNode as Gl,$isTableRowNode as vf,getDOMCellFromTarget as Mf,getTableElement as Df,TableNode as Af}from"@lexical/table";import{calculateZoomLevel as Wl}from"@lexical/utils";import{$getNearestNodeFromDOMNode as mr}from"lexical";import*as Kl from"react";import{useCallback as wt,useEffect as pr,useRef as oo,useState as Et}from"react";import{createPortal as Of}from"react-dom";var Ff=33,Vl=92;function $f({editor:t}){let e=oo(null),o=oo(null),r=oo(null),n=P(),i=oo(null),[l,s]=Et(null),[a,u]=Et(null),[c,d]=Et(!1),[m,p]=Et(null),f=wt(()=>{u(null),e.current=null,p(null),i.current=null,r.current=null},[]),h=L=>(L.buttons&1)===1;pr(()=>t.registerNodeTransform(Af,L=>{if(L.getColWidths())return L;let R=L.getColumnCount(),S=Vl;return L.setColWidths(Array(R).fill(S)),L}),[t]),pr(()=>{let L=_=>{let I=_.target;if(m){s({x:_.clientX,y:_.clientY});return}if(d(h(_)),!(o.current&&o.current.contains(I))&&e.current!==I){e.current=I;let M=Mf(I);M&&a!==M?t.getEditorState().read(()=>{let D=mr(M.elem);if(!D)throw new Error("TableCellResizer: Table cell node not found.");let F=dr(D),A=Df(F,t.getElementByKey(F.getKey()));if(!A)throw new Error("TableCellResizer: Table element not found.");e.current=I,r.current=A.getBoundingClientRect(),u(M)},{editor:t}):M==null&&f()}},R=_=>{d(!0)},S=_=>{d(!1)},E=t.registerRootListener((_,I)=>{I?.removeEventListener("mousemove",L),I?.removeEventListener("mousedown",R),I?.removeEventListener("mouseup",S),_?.addEventListener("mousemove",L),_?.addEventListener("mousedown",R),_?.addEventListener("mouseup",S)});return()=>{E()}},[a,m,t,f]);let C=L=>L==="bottom",b=wt(L=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let R=mr(a.elem);if(!Gl(R))throw new Error("TableCellResizer: Table cell node not found.");let S=dr(R),E=yf(R)+R.getRowSpan()-1,_=S.getChildren();if(E>=_.length||E<0)throw new Error("Expected table cell to be inside of table row.");let I=_[E];if(!vf(I))throw new Error("Expected table row");let M=I.getHeight();if(M===void 0){let F=I.getChildren();M=Math.min(...F.map(A=>k(A,t)??1/0))}let D=Math.max(M+L,Ff);I.setHeight(D)},{tag:"skip-scroll-into-view"})},[a,t]),k=(L,R)=>R.getElementByKey(L.getKey())?.clientHeight,v=(L,R)=>{for(let S=0;S<R.length;S++)for(let E=0;E<R[S].length;E++)if(R[S][E].cell===L)return E},x=wt(L=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let R=mr(a.elem);if(!Gl(R))throw new Error("TableCellResizer: Table cell node not found.");let S=dr(R),[E]=If(S,null,null),_=v(R,E);if(_===void 0)throw new Error("TableCellResizer: Table column not found.");let I=S.getColWidths();if(!I)return;let M=I[_];if(M===void 0)return;let D=[...I],F=Math.max(M+L,Vl);D[_]=F,S.setColWidths(D)},{tag:"skip-scroll-into-view"})},[a,t]),T=wt(L=>{let R=S=>{if(S.preventDefault(),S.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:E,y:_}=i.current;if(a===null)return;let I=Wl(S.target);if(C(L)){let M=(S.clientY-_)/I;b(M)}else{let M=(S.clientX-E)/I;x(M)}f(),document.removeEventListener("mouseup",R)}};return R},[a,f,x,b]),g=wt(L=>R=>{if(R.preventDefault(),R.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");i.current={x:R.clientX,y:R.clientY},s(i.current),p(L),document.addEventListener("mouseup",T(L))},[a,T]),[w,N]=Et({bottom:null,left:null,right:null,top:null});return pr(()=>{if(a){let{height:L,left:R,top:S,width:E}=a.elem.getBoundingClientRect(),_=Wl(a.elem),I=10,M={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${I}px`,left:`${window.scrollX+R}px`,top:`${window.scrollY+S+L-I/2}px`,width:`${E}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${L}px`,left:`${window.scrollX+R+E-I/2}px`,top:`${window.scrollY+S}px`,width:`${I}px`}},D=r.current;m&&l&&D&&(C(m)?(M[m].left=`${window.scrollX+D.left}px`,M[m].top=`${window.scrollY+l.y/_}px`,M[m].height="3px",M[m].width=`${D.width}px`):(M[m].top=`${window.scrollY+D.top}px`,M[m].left=`${window.scrollX+l.x/_}px`,M[m].width="3px",M[m].height=`${D.height}px`),M[m].backgroundColor="#adf"),N(M)}else N({bottom:null,left:null,right:null,top:null})},[a,m,l]),ro("div",{ref:o,children:a!=null&&!c&&Nf(Kl.Fragment,{children:[ro("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:g("right"),style:w.right||void 0}),ro("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:g("bottom"),style:w.bottom||void 0})]})})}var Zl=()=>{let t=Lf(3),[e]=Rf(),o=Sf(),r,n;return t[0]!==e||t[1]!==o?(n=o?Of(ro($f,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=n):n=t[2],r=n,r};import{c as Vf}from"react/compiler-runtime";import{jsx as fr,jsxs as Kf,Fragment as Zf}from"react/jsx-runtime";import{useLexicalComposerContext as ts}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as Yf,$getTableColumnIndexFromTableCellNode as zf,$getTableRowIndexFromTableCellNode as Xf,$insertTableColumn__EXPERIMENTAL as Jf,$insertTableRow__EXPERIMENTAL as qf,$isTableCellNode as Qf,$isTableNode as Xl,getTableElement as e1,TableNode as t1}from"@lexical/table";import{$findMatchingParent as o1,mergeRegister as r1}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Jl}from"lexical";import{useEffect as ql,useMemo as n1,useRef as Ql,useState as no}from"react";import"react";import{createPortal as i1}from"react-dom";import{c as Uf}from"react/compiler-runtime";import{useEffect as Gf,useRef as Wf}from"react";var Pf="Expected a function",Bf=Math.max,Hf=Math.min;function jf(t,e,o){let r,n,i=0,l,s=!1,a=!1,u,c,d,m=!0;if(typeof t!="function")throw new TypeError(Pf);e=e||0,typeof o=="object"&&(s=!!o.leading,a="maxWait"in o,u=a?Bf(o.maxWait||0,e):u,m="trailing"in o?!!o.trailing:m);function p(g){let w=r,N=l;return r=l=void 0,i=g,c=t.apply(N,w),c}function f(g){return i=g,d=setTimeout(b,e),s?p(g):c}function h(g){let w=g-n,N=g-i,L=e-w;return a?Hf(L,u-N):L}function C(g){let w=g-n,N=g-i;return n===void 0||w>=e||w<0||a&&N>=u}function b(){let g=Date.now();if(C(g))return k(g);d=setTimeout(b,h(g))}function k(g){return d=void 0,m&&r?p(g):(r=l=void 0,c)}function v(){d!==void 0&&clearTimeout(d),i=0,r=n=l=d=void 0}function x(){return d===void 0?c:k(Date.now())}function T(){let g=Date.now(),w=C(g);if(r=arguments,l=this,n=g,w){if(d===void 0)return f(n);if(a)return clearTimeout(d),d=setTimeout(b,e),p(n)}return d===void 0&&(d=setTimeout(b,e)),c}return T.cancel=v,T.flush=x,T}var Yl=jf;function zl(t,e,o){let r=Uf(6),n=Wf(null),i,l;r[0]!==t||r[1]!==o||r[2]!==e?(i=()=>(n.current=Yl(t,e,{maxWait:o}),()=>{n.current?.cancel()}),l=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=i,r[4]=l):(i=r[3],l=r[4]),Gf(i,l);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...u)=>{let c=u;n.current&&n.current(...c)},r[5]=s):s=r[5],s}var es=20;function l1({anchorElem:t}){let[e]=ts(),o=P(),[r,n]=no(!1),[i,l]=no(!1),[s,a]=no(!1),[u,c]=no({}),d=Ql(new Set),m=Ql(null),p=zl(C=>{let{isOutside:b,tableDOMNode:k}=s1(C,o.editorConfig?.lexical);if(b){n(!1),l(!1);return}if(!k)return;m.current=k;let v=null,x=null,T=null;if(e.getEditorState().read(()=>{let g=Jl(k);if(Qf(g)){let w=o1(g,N=>Xl(N));if(!Xl(w))return;if(T=e1(w,e.getElementByKey(w.getKey())),T){let N=w.getChildrenSize(),L=w.getChildAtIndex(0)?.getChildrenSize(),R=Xf(g),S=zf(g);R===N-1?v=g:S===L-1&&(x=g)}}},{editor:e}),T){let{bottom:g,height:w,left:N,right:L,width:R,y:S}=T.getBoundingClientRect(),{left:E,y:_}=t.getBoundingClientRect();v?(l(!1),n(!0),c({height:es,left:N-E,top:g-_+5,width:R})):x&&(l(!0),n(!1),c({height:w,left:L-E+5,top:S-_,width:es}))}},50,250),f=n1(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);ql(()=>{if(s)return document.addEventListener("mousemove",p),()=>{n(!1),l(!1),document.removeEventListener("mousemove",p)}},[s,p]),ql(()=>r1(e.registerMutationListener(t1,C=>{e.getEditorState().read(()=>{let b=!1;for(let[k,v]of C)switch(v){case"created":{d.current.add(k),b=!0;break}case"destroyed":{d.current.delete(k),b=!0;break}default:break}if(b){f.disconnect();for(let k of d.current){let{tableElement:v}=Yf(k);f.observe(v)}a(d.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=C=>{e.update(()=>{m.current&&(Jl(m.current)?.selectEnd(),C?(qf(),n(!1)):(Jf(),l(!1)))})};return e?.isEditable()?Kf(Zf,{children:[r&&fr("button",{className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...u},type:"button"}),i&&fr("button",{className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...u},type:"button"})]}):null}function s1(t,e){let o=t.target;if(o&&o instanceof HTMLElement){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 os(t){let e=Vf(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=ts();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=i1(fr(l1,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as a1}from"react/compiler-runtime";import{jsx as hr,jsxs as c1}from"react/jsx-runtime";import{useLexicalComposerContext as u1}from"@lexical/react/LexicalComposerContext";import{TablePlugin as d1}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as m1,TableNode as p1}from"@lexical/table";import{mergeRegister as f1}from"@lexical/utils";import{formatDrawerSlug as h1,useEditDepth as g1}from"@payloadcms/ui";import{$getSelection as C1,$isRangeSelection as x1,COMMAND_PRIORITY_EDITOR as b1,createCommand as _1}from"lexical";import{createContext as T1,useContext as w1,useEffect as E1,useMemo as k1,useState as L1}from"react";import*as rs from"react";var io=_1("OPEN_EMBED_DRAWER_COMMAND"),ns=T1({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function is({children:t}){let[e,o]=L1({cellEditorConfig:null,cellEditorPlugins:null});return hr(ns.Provider,{value:k1(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var ls=()=>{let t=a1(16),[e]=u1(),o=w1(ns),r=g1(),{fieldProps:n,uuid:i}=P(),{schemaPath:l}=n,s="lexical-table-create-"+i,a;t[0]!==r||t[1]!==s?(a=h1({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=a):a=t[2];let u=a,{toggleDrawer:c}=ae(u,!0),d;t[3]!==e||t[4]!==c?(d=()=>{if(!e.hasNodes([p1]))throw new Error("TablePlugin: TableNode is not registered on editor");return f1(e.registerCommand(io,()=>{let h;return h=null,e.getEditorState().read(()=>{let C=C1();x1(C)&&(h=C)}),h&&c(),!0},b1))},t[3]=e,t[4]=c,t[5]=d):d=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==c?(m=[o,e,c],t[6]=o,t[7]=e,t[8]=c,t[9]=m):m=t[9],E1(d,m);let p;t[10]!==e?(p=(h,C)=>{!C.columns||!C.rows||e.dispatchCommand(m1,{columns:String(C.columns),rows:String(C.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==u||t[13]!==l||t[14]!==p?(f=c1(rs.Fragment,{children:[hr(Xe,{drawerSlug:u,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:l,schemaPathSuffix:"fields"}),hr(d1,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=u,t[13]=l,t[14]=p,t[15]=f):f=t[15],f};var I1=y({markdownTransformers:[Dl],nodes:[R1,N1,S1],plugins:[{Component:ls,position:"normal"},{Component:Zl,position:"normal"},{Component:Ul,position:"floatingAnchorElem"},{Component:os,position:"floatingAnchorElem"}],providers:[is],slashMenu:{groups:[V([{Icon:or,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(io,{})}}])]},toolbarFixed:{groups:[de([{ChildComponent:or,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(io,{})}}])]}});import{$isNodeSelection as lh}from"lexical";import{jsx as gr,jsxs as y1}from"react/jsx-runtime";import"react";var Cr=()=>y1("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:[gr("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"}),gr("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"}),gr("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 O1}from"react/jsx-runtime";import cs from"bson-objectid";import{$applyNodeReplacement as F1}from"lexical";import*as us from"react";import{jsx as v1}from"react/jsx-runtime";import{DecoratorBlockNode as M1}from"@lexical/react/LexicalDecoratorBlockNode.js";import ss from"bson-objectid";import{$applyNodeReplacement as D1}from"lexical";import"react";function xr(t){return t.parentElement!=null&&t.parentElement.tagName==="LI"&&t.previousSibling===null&&t.getAttribute("aria-roledescription")==="checkbox"}function A1(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:as({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||xr(e),null}var kt=class extends M1{__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:A1,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new ss.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=as({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return v1(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let e=document.createElement("img");return e.setAttribute("data-lexical-upload-id",String(this.__data?.value)),e.setAttribute("data-lexical-upload-relation-to",this.__data?.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 as({data:t}){return t?.id||(t.id=new ss.default().toHexString()),D1(new kt({data:t}))}var $1=us.lazy(()=>import("./component-VJVZFYZJ.js").then(t=>({default:t.UploadComponent})));function P1(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:Oe({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||xr(e),null}var be=class extends kt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:P1,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new cs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=Oe({data:o});return r.setFormat(e.format),r}decorate(){return O1($1,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Oe({data:t}){return t?.id||(t.id=new cs.default().toHexString()),F1(new be({data:t}))}function br(t){return t instanceof be}import{c as K1}from"react/compiler-runtime";import{jsx as Z1}from"react/jsx-runtime";import{useLexicalComposerContext as Y1}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as z1,mergeRegister as X1}from"@lexical/utils";import{useConfig as J1}from"@payloadcms/ui";import{$getPreviousSelection as q1,$getSelection as Q1,$isParagraphNode as eh,$isRangeSelection as th,COMMAND_PRIORITY_EDITOR as oh,createCommand as rh}from"lexical";import{useEffect as nh}from"react";import{c as ds}from"react/compiler-runtime";import{jsx as _r}from"react/jsx-runtime";import{useLexicalComposerContext as ms}from"@lexical/react/LexicalComposerContext.js";import{toast as B1}from"@payloadcms/ui";import{$getNodeByKey as H1,COMMAND_PRIORITY_EDITOR as ps}from"lexical";import{useEffect as fs,useState as j1}from"react";var U1=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=H1(o);n&&n.replace(Oe({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Tr,{fields:null,relationTo:e,value:r})},G1=t=>{let e=ds(13),{enabledCollectionSlugs:o}=t,[r]=ms(),[n,i]=j1(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:a,openListDrawer:u}=gt(l),c,d;e[2]!==r||e[3]!==u?(c=()=>r.registerCommand(Be,h=>(i(h?.replace?h?.replace.nodeKey:null),u(),!0),ps),d=[r,u],e[2]=r,e[3]=u,e[4]=c,e[5]=d):(c=e[4],d=e[5]),fs(c,d);let m;e[6]!==s||e[7]!==r||e[8]!==n?(m=h=>{let{collectionSlug:C,docID:b}=h;s(),U1({editor:r,relationTo:C,replaceNodeKey:n,value:b})},e[6]=s,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,f;return e[10]!==a||e[11]!==p?(f=_r(a,{onSelect:p}),e[10]=a,e[11]=p,e[12]=f):f=e[12],f},W1=()=>{let t=ds(3),[e]=ms(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Be,V1,ps),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),fs(o,r),null},hs=t=>_r(Nt,{...t,FallbackComponent:W1,uploads:!0,children:_r(G1,{...t})});function V1(){return B1.error("No upload collections enabled"),!0}var Tr=rh("INSERT_UPLOAD_COMMAND"),gs=t=>{let e=K1(5),[o]=Y1(),{config:r}=J1(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([be]))throw new Error("UploadPlugin: UploadNode not registered on editor");return X1(o.registerCommand(Tr,a=>(o.update(()=>{let u=Q1()||q1();if(th(u)){let c=Oe({data:{id:a.id,fields:a.fields,relationTo:a.relationTo,value:a.value}});z1(c);let{focus:d}=u,m=d.getNode();eh(m)&&!m.__first&&(m.__prev||m.__next)&&m.remove()}}),!0),oh))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),nh(i,l);let s;return e[3]!==n?(s=Z1(hs,{enabledCollectionSlugs:n.map(ih)}),e[3]=n,e[4]=s):s=e[4],s};function ih(t){let{slug:e}=t;return e}var sh=y({nodes:[be],plugins:[{Component:gs,position:"normal"}],slashMenu:{groups:[V([{Icon:Cr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Be,{replace:!1})}}])]},toolbarFixed:{groups:[de([{ChildComponent:Cr,isActive:({selection:t})=>{if(!lh(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return br(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Be,{replace:!1})}}])]}});import{c as ah}from"react/compiler-runtime";import{jsx as Er}from"react/jsx-runtime";import{ShimmerEffect as ch}from"@payloadcms/ui";import{lazy as uh,Suspense as dh,useEffect as mh,useState as ph}from"react";var Cs={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",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",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",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:"editor-upload"};var lo={namespace:"lexical",theme:Cs};function xs({featureClientSchemaMap:t,field:e,schemaPath:o,unSanitizedEditorConfig:r}){for(let s of r.features)if(!s?.clientFeatureProps?.featureKey||s?.clientFeatureProps?.order===void 0||s?.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.");r.features=r.features.sort((s,a)=>s.clientFeatureProps.order-a.clientFeatureProps.order);let n=new Map;for(let s of r.features)n.set(s.clientFeatureProps.featureKey,s);let i=new Map,l=0;for(let s of r.features){let a=typeof s.feature=="function"?s.feature({featureClientSchemaMap:t,featureProviderMap:n,field:e,resolvedFeatures:i,schemaPath:o,unSanitizedEditorConfig:r}):s.feature;a.key=s.clientFeatureProps.featureKey,a.order=l,i.set(s.clientFeatureProps.featureKey,a),l++}return i}var bs=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}};if(!t?.size)return e;t.forEach(o=>{if(o.providers?.length&&(e.providers=e.providers.concat(o.providers)),o.enableFormats?.length&&e.enabledFormats.push(...o.enableFormats),o.nodes?.length)for(let r of o.nodes)e.nodes.push(r);if(o.plugins?.length&&o.plugins.forEach((r,n)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:r.Component,key:o.key+n,position:r.position})}),o.toolbarInline?.groups?.length)for(let r of o.toolbarInline.groups){let n=e.toolbarInline.groups.find(i=>i.key===r.key);n?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarInline?.groups.push(n)}if(o.toolbarFixed?.groups?.length)for(let r of o.toolbarFixed.groups){let n=e.toolbarFixed.groups.find(i=>i.key===r.key);n?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarFixed?.groups.push(n)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let r of o.slashMenu.groups){let n=e.slashMenu.groups.find(i=>i.key===r.key);n?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.slashMenu.groups.push(n)}}if(o.markdownTransformers?.length)for(let r of o.markdownTransformers)typeof r=="function"?e.markdownTransformers.push(r({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(r);e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0),e.toolbarFixed.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);return e};function wr(t,e,o){return{admin:o,features:bs(t),lexical:e,resolvedFeatureMap:t}}var fh=uh(()=>import("./Field-LOLYH42M.js").then(t=>({default:t.RichText}))),hh=t=>{let e=ah(14),{admin:o,clientFeatures:r,featureClientSchemaMap:n,field:i,lexicalEditorConfig:l,schemaPath:s}=t,a;e[0]!==o?(a=o===void 0?{}:o,e[0]=o,e[1]=a):a=e[1];let u=a,c=l===void 0?lo:l,[d,m]=ph(null),p,f;e[2]!==u||e[3]!==r||e[4]!==n||e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==s?(p=()=>{if(d)return;let C=[];for(let[v,x]of Object.entries(r))x.clientFeatureProvider&&C.push(x.clientFeatureProvider(x.clientFeatureProps));let b=c||lo,k=xs({featureClientSchemaMap:n,field:i,schemaPath:s??i.name,unSanitizedEditorConfig:{features:C,lexical:b}});m(wr(k,b,u))},f=[c,u,d,r,n,i,s],e[2]=u,e[3]=r,e[4]=n,e[5]=i,e[6]=d,e[7]=c,e[8]=s,e[9]=p,e[10]=f):(p=e[9],f=e[10]),mh(p,f);let h;return e[11]!==d||e[12]!==t?(h=Er(dh,{fallback:Er(ch,{height:"35vh"}),children:d&&Er(fh,{...t,editorConfig:d})}),e[11]=d,e[12]=t,e[13]=h):h=e[13],h};function gh(...t){return t.filter(Boolean).join(" ")}var so=new WeakMap;function _s(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function ao(t,e){let o=so.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=_s(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let a=_s(l);for(let u of r)a!==null&&u([a[0]-s[0],a[1]-s[1]],l)};t.addEventListener("touchstart",n),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:n,listeners:r,start:null},so.set(t,o)}return o.listeners.add(e),()=>{Ch(t,e)}}function Ch(t,e){let o=so.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(so.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function xh(t,e){return ao(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function bh(t,e){return ao(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function _h(t,e){return ao(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function Th(t,e){return ao(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}var O={DOM_ELEMENT_TYPE:1,DOM_TEXT_TYPE:3,NO_DIRTY_NODES:0,HAS_DIRTY_NODES:1,FULL_RECONCILE:2,IS_NORMAL:0,IS_TOKEN:1,IS_SEGMENTED:2,IS_INERT:3,IS_BOLD:1,IS_ITALIC:2,IS_STRIKETHROUGH:4,IS_UNDERLINE:8,IS_CODE:16,IS_SUBSCRIPT:32,IS_SUPERSCRIPT:64,IS_HIGHLIGHT:128,IS_DIRECTIONLESS:1,IS_UNMERGEABLE:2,IS_ALIGN_LEFT:1,IS_ALIGN_CENTER:2,IS_ALIGN_RIGHT:3,IS_ALIGN_JUSTIFY:4,IS_ALIGN_START:5,IS_ALIGN_END:6},wh=O.IS_BOLD|O.IS_ITALIC|O.IS_STRIKETHROUGH|O.IS_UNDERLINE|O.IS_CODE|O.IS_SUBSCRIPT|O.IS_SUPERSCRIPT|O.IS_HIGHLIGHT,Eh="\xA0",kh=`
|
|
34
|
+
`},[t,e]),p=Re((C,T)=>{o(g=>{let _=e.length-1,S=e[_];if(S&&S.name===C){if(C==="type")return[...e.slice(0,_),{...S,value:S.value+T}];if(S.value===T)return[...e.slice(0,_),{...S,count:S.count+1}]}return[...g,{name:C,count:1,value:T}]})},[e,o]);qr(()=>{let C=g=>{if(!r)return;let _=g.key;Ya(g)?p("selectAll",""):en.has(_)?p("press",g.key):[..._].length>1?p("keydown",g.key):p("type",g.key)},T=g=>{if(!r)return;let _=g.key;!en.has(_)&&[..._].length>1&&p("keyup",g.key)};return t.registerRootListener((g,_)=>{_!==null&&(_.removeEventListener("keydown",C),_.removeEventListener("keyup",T)),g!==null&&(g.addEventListener("keydown",C),g.addEventListener("keyup",T))})},[t,r,p]),qr(()=>{c.current&&c.current.scrollTo(0,c.current.scrollHeight)},[m]),ko(()=>{if(e){let C=m();C!==null&&s(C),c.current&&c.current.scrollTo(0,c.current.scrollHeight)}},[m,e]),ko(()=>t.registerUpdateListener(({dirtyElements:T,dirtyLeaves:g,editorState:_})=>{if(!r)return;let S=_._selection,L=a.current,k=u.current;if(L!==S){if(g.size===0&&T.size===0&&!k){let E=Eo(t._window);if(E&&(E.anchorNode==null||E.focusNode==null))return}a.current=S}u.current=!1;let v=m();v!==null&&s(v)}),[t,m,r,p]),ko(()=>r?t.registerUpdateListener(()=>{let T=t.getRootElement();T!==null&&i(T?.innerHTML)}):void 0,[t,r]);let f=Re(C=>{r||(C.update(()=>{let T=Wa();T.clear();let g=Ga();T.append(Ua().append(g)),g.select()}),o([])),n(T=>!T)},[r]),h=Re(()=>{if(!r)return;let C=Eo(t._window);if(C===null||C.anchorNode==null||C.focusNode==null)return;let{anchorNode:T,anchorOffset:g,focusNode:_,focusOffset:S}=za(C),L=d().getRootElement(),k;T!==null&&(k=Qr(T,L));let v;_!==null&&(v=Qr(_,L)),p("snapshot",{anchorNode:T,anchorOffset:g,anchorPath:k,focusNode:_,focusOffset:S,focusPath:v})},[p,r,d]),x=Re(()=>{Va(m())},[m]),b=Re(()=>{Ka("test.js",m())},[m]);return[Se("button",{className:`editor-dev-button ${r?"active":""}`,id:"test-recorder-button",onClick:C=>{f(d()),C.preventDefault()},title:r?"Disable test recorder":"Enable test recorder",type:"button",children:r?"Disable test recorder":"Enable test recorder"}),r?No("div",{className:"test-recorder-output",children:[No("div",{className:"test-recorder-toolbar",children:[Se("button",{className:"test-recorder-button",id:"test-recorder-button-snapshot",onClick:C=>{h(),C.preventDefault()},title:"Insert snapshot",type:"button",children:"Insert Snapshot"}),Se("button",{className:"test-recorder-button",id:"test-recorder-button-copy",onClick:C=>{x(),C.preventDefault()},title:"Copy to clipboard",type:"button",children:"Copy"}),Se("button",{className:"test-recorder-button",id:"test-recorder-button-download",onClick:C=>{b(),C.preventDefault()},title:"Download as a file",type:"button",children:"Download"})]}),Se("pre",{id:"test-recorder",ref:c,children:l})]}):null]}var on=()=>{let t=Ha(3),[e]=ja(),[o,r]=Xa(e),n;return t[0]!==o||t[1]!==r?(n=No(tn.Fragment,{children:[Se("p",{children:"HI"}),o,r,Se("p",{children:"DONE"})]}),t[0]=o,t[1]=r,t[2]=n):n=t[2],n};var Ja=y({plugins:[{Component:on,position:"bottom"}]});import{c as qa}from"react/compiler-runtime";import{jsx as Qa}from"react/jsx-runtime";import{useLexicalComposerContext as ec}from"@lexical/react/LexicalComposerContext.js";import{TreeView as tc}from"@lexical/react/LexicalTreeView.js";import"react";var rn=()=>{let t=qa(2),[e]=ec(),o;return t[0]!==e?(o=Qa(tc,{editor:e,timeTravelButtonClassName:"debug-timetravel-button",timeTravelPanelButtonClassName:"debug-timetravel-panel-button",timeTravelPanelClassName:"debug-timetravel-panel",timeTravelPanelSliderClassName:"debug-timetravel-panel-slider",treeTypeButtonClassName:"debug-treetype-button",viewClassName:"tree-view-output"}),t[0]=e,t[1]=o):o=t[1],o};var oc=y({plugins:[{Component:rn,position:"bottom"}]});import{$isTableSelection as rc}from"@lexical/table";import{$isRangeSelection as nc,FORMAT_TEXT_COMMAND as ic}from"lexical";import{jsx as nn}from"react/jsx-runtime";import"react";var ln=()=>nn("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:nn("path",{d:"M10.6772 15H6.27017V5.718H10.4172C12.6792 5.718 13.8492 6.602 13.8492 8.292C13.8492 9.098 13.1992 9.982 12.4712 10.216C13.3812 10.476 14.1742 11.256 14.1742 12.322C14.1742 14.09 12.9002 15 10.6772 15ZM8.46717 9.501H10.3262C11.3012 9.501 11.7042 9.046 11.7042 8.409C11.7042 7.72 11.2362 7.317 10.3392 7.317H8.46717V9.501ZM8.46717 11.061V13.401H10.4822C11.4702 13.401 11.9642 12.959 11.9642 12.218C11.9642 11.49 11.4702 11.061 10.4822 11.061H8.46717Z",fill:"currentColor"})});var K=t=>({type:"buttons",items:t,key:"format",order:40});var sn={type:"text-format",format:["bold","italic"],tag:"***"},an={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},cn={type:"text-format",format:["bold"],tag:"**"},un={type:"text-format",format:["bold"],intraword:!1,tag:"__"};var dn=[K([{ChildComponent:ln,isActive:({selection:t})=>nc(t)||rc(t)?t.hasFormat("bold"):!1,key:"bold",onSelect:({editor:t})=>{t.dispatchCommand(ic,"bold")},order:1}])],lc=y(({featureProviderMap:t})=>{let e=[cn,un];return t.get("italic")&&e.push(an,sn),{enableFormats:["bold"],markdownTransformers:e,toolbarFixed:{groups:dn},toolbarInline:{groups:dn}}});import{$isTableSelection as ac}from"@lexical/table";import{$isRangeSelection as cc,FORMAT_TEXT_COMMAND as uc}from"lexical";import{jsx as mn,jsxs as sc}from"react/jsx-runtime";import"react";var pn=()=>sc("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:[mn("path",{d:"M7.76465 6L3.76465 10L7.76465 14",stroke:"currentColor"}),mn("path",{d:"M12.2354 6L16.2354 10L12.2354 14",stroke:"currentColor"})]});var fn={type:"text-format",format:["code"],tag:"`"};var hn=[K([{ChildComponent:pn,isActive:({selection:t})=>cc(t)||ac(t)?t.hasFormat("code"):!1,key:"inlineCode",onSelect:({editor:t})=>{t.dispatchCommand(uc,"code")},order:7}])],dc=y({enableFormats:["code"],markdownTransformers:[fn],toolbarFixed:{groups:hn},toolbarInline:{groups:hn}});import{$isTableSelection as mc}from"@lexical/table";import{$isRangeSelection as pc,FORMAT_TEXT_COMMAND as fc}from"lexical";import{jsx as gn}from"react/jsx-runtime";import"react";var Cn=()=>gn("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:gn("path",{d:"M11.311 14.2969L11.0327 15H6.18408L6.4624 14.2969C7.54639 14.2969 7.70752 14.209 7.83936 13.8721L10.8423 6.45996C10.8716 6.38672 10.8862 6.32812 10.8862 6.26953C10.8862 6.09375 10.6519 6.03516 9.80225 6.03516L10.0952 5.33203H14.9438L14.6509 6.03516C13.5669 6.03516 13.4204 6.12305 13.2886 6.45996L10.2856 13.8721C10.2563 13.9453 10.2271 14.0039 10.2271 14.0625C10.2271 14.2383 10.4614 14.2969 11.311 14.2969Z",fill:"currentColor"})});var xn={type:"text-format",format:["italic"],tag:"*"},bn={type:"text-format",format:["italic"],intraword:!1,tag:"_"};var _n=[K([{ChildComponent:Cn,isActive:({selection:t})=>pc(t)||mc(t)?t.hasFormat("italic"):!1,key:"italic",onSelect:({editor:t})=>{t.dispatchCommand(fc,"italic")},order:2}])],hc=y({enableFormats:["italic"],markdownTransformers:[xn,bn],toolbarFixed:{groups:_n},toolbarInline:{groups:_n}});import{$isTableSelection as Cc}from"@lexical/table";import{$isRangeSelection as xc,FORMAT_TEXT_COMMAND as bc}from"lexical";import{jsx as Tn,jsxs as gc}from"react/jsx-runtime";import"react";var wn=()=>gc("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:[Tn("path",{d:"M5.50756 12.76H7.42756C7.56256 14.215 8.82256 14.71 10.1576 14.71C11.4326 14.71 12.4226 14.14 12.4226 13.06C12.4226 12.28 11.9576 11.845 10.6676 11.605L8.70256 11.245C7.12756 10.96 5.85256 10.21 5.85256 8.335C5.85256 6.43 7.53256 5.11 9.87256 5.11C12.4226 5.11 13.9526 6.22 14.1626 8.23H12.2876C12.1526 7.18 11.2226 6.595 9.88756 6.595C8.59756 6.595 7.78756 7.27 7.78756 8.215C7.78756 9.1 8.34256 9.385 9.49756 9.61L11.5676 10.015C13.3226 10.345 14.3726 11.215 14.3726 12.94C14.3726 14.89 12.5876 16.18 10.2176 16.18C7.66756 16.18 5.70256 15.115 5.50756 12.76Z",fill:"currentColor"}),Tn("path",{d:"M4.99756 11.44H15.0026V12.19H4.99756V11.44Z",fill:"currentColor"})]});var En={type:"text-format",format:["strikethrough"],tag:"~~"};var kn=[K([{ChildComponent:wn,isActive:({selection:t})=>xc(t)||Cc(t)?t.hasFormat("strikethrough"):!1,key:"strikethrough",onSelect:({editor:t})=>{t.dispatchCommand(bc,"strikethrough")},order:4}])],_c=y({enableFormats:["strikethrough"],markdownTransformers:[En],toolbarFixed:{groups:kn},toolbarInline:{groups:kn}});import{$isTableSelection as Tc}from"@lexical/table";import{$isRangeSelection as wc,FORMAT_TEXT_COMMAND as Ec}from"lexical";import{jsx as Ln}from"react/jsx-runtime";import"react";var Nn=()=>Ln("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:Ln("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 13.258C16.7768 14.155 16.1398 14.532 15.2038 15C14.5538 15.325 14.2808 15.546 14.2418 15.78H16.7898V16.82H12.7208V16.339C12.7208 15.286 13.5918 14.675 14.3588 14.233C15.0868 13.83 15.4378 13.635 15.4378 13.232C15.4378 12.894 15.2038 12.686 14.8268 12.686C14.3848 12.686 14.1248 13.024 14.1118 13.427H12.7468C12.8248 12.426 13.5528 11.633 14.8398 11.633C15.9448 11.633 16.7768 12.257 16.7768 13.258Z",fill:"currentColor"})});var Rn=[K([{ChildComponent:Nn,isActive:({selection:t})=>wc(t)||Tc(t)?t.hasFormat("subscript"):!1,key:"subscript",onSelect:({editor:t})=>{t.dispatchCommand(Ec,"subscript")},order:5}])],kc=y({enableFormats:["subscript"],toolbarFixed:{groups:Rn},toolbarInline:{groups:Rn}});import{$isTableSelection as Lc}from"@lexical/table";import{$isRangeSelection as Nc,FORMAT_TEXT_COMMAND as Rc}from"lexical";import{jsx as Sn}from"react/jsx-runtime";import"react";var In=()=>Sn("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:Sn("path",{d:"M10.167 15L7.45002 11.36L4.73302 15H2.91302L6.55302 10.177L3.23802 5.718H5.20102L7.54102 8.89L9.89402 5.718H11.714L8.43802 10.06L12.13 15H10.167ZM16.7768 7.252C16.7768 8.149 16.1398 8.526 15.2038 8.994C14.5538 9.319 14.2808 9.54 14.2418 9.774H16.7898V10.814H12.7208V10.333C12.7208 9.28 13.5918 8.669 14.3588 8.227C15.0868 7.824 15.4378 7.629 15.4378 7.226C15.4378 6.888 15.2038 6.68 14.8268 6.68C14.3848 6.68 14.1248 7.018 14.1118 7.421H12.7468C12.8248 6.42 13.5528 5.627 14.8398 5.627C15.9448 5.627 16.7768 6.251 16.7768 7.252Z",fill:"currentColor"})});var yn=[K([{ChildComponent:In,isActive:({selection:t})=>Nc(t)||Lc(t)?t.hasFormat("superscript"):!1,key:"superscript",onSelect:({editor:t})=>{t.dispatchCommand(Rc,"superscript")},order:6}])],Sc=y({enableFormats:["superscript"],toolbarFixed:{groups:yn},toolbarInline:{groups:yn}});import{$isTableSelection as yc}from"@lexical/table";import{$isRangeSelection as vc,FORMAT_TEXT_COMMAND as Mc}from"lexical";import{jsx as vn,jsxs as Ic}from"react/jsx-runtime";import"react";var Mn=()=>Ic("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:[vn("path",{d:"M13.9656 11.256C13.9656 13.791 12.5096 15.156 10.0006 15.156C7.50461 15.156 6.03561 13.791 6.03561 11.23V5.718H7.76461V11.243C7.76461 12.868 8.50561 13.778 10.0006 13.778C11.4956 13.778 12.2496 12.868 12.2496 11.243V5.718H13.9656V11.256Z",fill:"currentColor"}),vn("path",{d:"M5.09961 16.3H14.9016V16.95H5.09961V16.3Z",fill:"currentColor"})]});var Dn=[K([{ChildComponent:Mn,isActive:({selection:t})=>vc(t)||yc(t)?t.hasFormat("underline"):!1,key:"underline",onSelect:({editor:t})=>{t.dispatchCommand(Mc,"underline")},order:3}])],Dc=y({enableFormats:["underline"],toolbarFixed:{groups:Dn},toolbarInline:{groups:Dn}});import{$createHeadingNode as Fc,$isHeadingNode as Zn,HeadingNode as Pc}from"@lexical/rich-text";import{$setBlocksType as Bc}from"@lexical/selection";import{$getSelection as Hc,$isRangeSelection as jc}from"lexical";import{jsx as An}from"react/jsx-runtime";import"react";var On=()=>An("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:An("path",{d:"M4.639 13.5V7.074H6.196V9.648H9.076V7.074H10.642V13.5H9.076V10.836H6.196V13.5H4.639ZM11.5656 9.045V8.019C12.6636 8.019 13.1316 7.731 13.2846 7.065H14.4006V13.5H12.8436V9.045H11.5656Z",fill:"currentColor"})});import{jsx as $n}from"react/jsx-runtime";import"react";var Fn=()=>$n("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:$n("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM15.9796 8.973C15.9796 10.116 15.1696 10.656 14.0356 11.232C13.2256 11.646 12.8206 11.943 12.7846 12.294H15.9886V13.5H11.0566V12.951C11.0566 11.601 12.1636 10.845 13.1176 10.287C14.0356 9.756 14.5126 9.486 14.5126 8.946C14.5126 8.46 14.2156 8.145 13.6306 8.145C13.0186 8.145 12.6586 8.613 12.6226 9.198H11.1196C11.2186 7.947 12.1006 6.966 13.6396 6.966C15.0346 6.966 15.9796 7.785 15.9796 8.973Z",fill:"currentColor"})});import{jsx as Pn}from"react/jsx-runtime";import"react";var Bn=()=>Pn("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:Pn("path",{d:"M4.139 13.5V7.074H5.696V9.648H8.576V7.074H10.142V13.5H8.576V10.836H5.696V13.5H4.139ZM16.1146 11.745C16.1146 12.744 15.2236 13.608 13.6126 13.608C12.0736 13.608 11.0926 12.762 10.9846 11.547H12.4696C12.5146 12.114 13.0006 12.456 13.6126 12.456C14.2876 12.456 14.6746 12.132 14.6746 11.619C14.6746 11.061 14.2426 10.836 13.6216 10.836H12.9826V9.738H13.6036C14.1526 9.738 14.5486 9.486 14.5486 8.937C14.5486 8.46 14.2156 8.127 13.6486 8.127C13.0366 8.127 12.6586 8.514 12.6226 9.045H11.1916C11.2726 7.929 12.1276 6.966 13.6666 6.966C15.1876 6.966 15.9706 7.848 15.9706 8.865C15.9706 9.603 15.5026 10.143 14.8186 10.269C15.6196 10.404 16.1146 10.971 16.1146 11.745Z",fill:"currentColor"})});import{jsx as Hn}from"react/jsx-runtime";import"react";var jn=()=>Hn("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:Hn("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM15.1736 7.074V10.854H16.3706V12.033H15.1736V13.5H13.6796V12.033H10.5116V10.845L13.4996 7.074H15.1736ZM13.6796 8.46L11.8256 10.854H13.6796V8.46Z",fill:"currentColor"})});import{jsx as Un}from"react/jsx-runtime";import"react";var Gn=()=>Un("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:Un("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.1576 10.269C12.6896 10.269 12.3746 10.494 12.2216 10.737H10.8176L11.1956 7.074H15.2546V8.28H12.3206L12.1856 9.549C12.4016 9.351 12.8516 9.126 13.4636 9.126C14.7866 9.126 15.6596 10.053 15.6596 11.358C15.6596 12.609 14.7326 13.608 13.1756 13.608C11.5826 13.608 10.6556 12.753 10.5566 11.511H12.1136C12.1586 12.06 12.5456 12.465 13.1576 12.465C13.8236 12.465 14.1746 11.97 14.1746 11.376C14.1746 10.764 13.8416 10.269 13.1576 10.269Z",fill:"currentColor"})});import{jsx as Wn}from"react/jsx-runtime";import"react";var Vn=()=>Wn("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:Wn("path",{d:"M3.639 13.5V7.074H5.196V9.648H8.076V7.074H9.642V13.5H8.076V10.836H5.196V13.5H3.639ZM13.3646 8.127C12.5456 8.127 12.0416 8.937 12.0416 9.999C12.3296 9.54 12.8246 9.207 13.5536 9.207C14.8586 9.207 15.8036 10.134 15.8036 11.376C15.8036 12.645 14.8226 13.608 13.3196 13.608C11.7266 13.608 10.6196 12.393 10.6196 10.395C10.6196 8.316 11.7716 6.966 13.4186 6.966C14.7056 6.966 15.5786 7.749 15.7316 8.829H14.3186C14.2016 8.415 13.9226 8.127 13.3646 8.127ZM13.3106 12.51C13.9586 12.51 14.3816 12.042 14.3816 11.385C14.3816 10.737 13.9586 10.278 13.3106 10.278C12.6536 10.278 12.2126 10.737 12.2126 11.385C12.2126 12.042 12.6536 12.51 13.3106 12.51Z",fill:"currentColor"})});import{$createHeadingNode as Ac,$isHeadingNode as Oc,HeadingNode as $c}from"@lexical/rich-text";var Ro=t=>(e,o,r)=>{let n=t(r);n&&(n.append(...o),e.replace(n),n.select(0,0))};var Kn=t=>{let o=`^(${t.map(n=>Number(n.slice(1))).map(n=>`#{${n}}`).join("|")})\\s`,r=new RegExp(o);return{type:"element",dependencies:[$c],export:(n,i)=>{if(!Oc(n))return null;let l=Number(n.getTag().slice(1));return"#".repeat(l)+" "+i(n)},regExp:r,replace:Ro(n=>{let i="h"+n[1].length;return Ac(i)})}};var Yn=t=>{let e=Hc();Bc(e,()=>Fc(t))},zn={h1:On,h2:Fn,h3:Bn,h4:jn,h5:Gn,h6:Vn},Uc=y(({props:t})=>{let{enabledHeadingSizes:e=["h1","h2","h3","h4","h5","h6"]}=t,o=[X(e.map((r,n)=>({ChildComponent:zn[r],isActive:({selection:i})=>{if(!jc(i))return!1;for(let l of i.getNodes()){if(Zn(l)&&l.getTag()===r)continue;let s=l.getParent();if(!(Zn(s)&&s.getTag()===r))return!1}return!0},key:r,label:({i18n:i})=>i.t("lexical:heading:label",{headingLevel:r.charAt(1)}),onSelect:({editor:i})=>{i.update(()=>{Yn(r)})},order:n+2})))];return{markdownTransformers:[Kn(e)],nodes:[Pc],sanitizedClientFeatureProps:t,slashMenu:{groups:e?.length?[V(e.map(r=>({Icon:zn[r],key:`heading-${r.charAt(1)}`,keywords:["heading",r],label:({i18n:n})=>n.t("lexical:heading:label",{headingLevel:r.charAt(1)}),onSelect:({editor:n})=>{n.update(()=>{Yn(r)})}})))]:[]},toolbarFixed:{groups:e?.length?o:[]},toolbarInline:{groups:e?.length?o:[]}}});import{$isNodeSelection as nu}from"lexical";import{jsx as Xn}from"react/jsx-runtime";import"react";var So=()=>Xn("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:Xn("rect",{fill:"currentColor",height:"1",width:"12",x:"4",y:"9.5"})});import{jsx as Jn,jsxs as Gc}from"react/jsx-runtime";import"react";var qn=()=>Gc("svg",{fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Jn("path",{d:"M5 10h10",stroke:"currentColor"}),Jn("path",{d:"M10 15V5",stroke:"currentColor"})]});var pe=t=>({type:"dropdown",ChildComponent:qn,items:t,key:"add",order:10});import{addClassNamesToElement as Wc}from"@lexical/utils";import{$applyNodeReplacement as Vc,createCommand as Kc,DecoratorNode as Zc}from"lexical";var nt=Kc("INSERT_HORIZONTAL_RULE_COMMAND"),rt=class extends Zc{static clone(e){return new this(e.__key)}static getType(){return"horizontalrule"}static importDOM(){return{hr:()=>({conversion:Yc,priority:0})}}static importJSON(e){return Qn()}createDOM(e){let o=document.createElement("hr");return Wc(o,e.theme.hr),o}decorate(){return null}exportDOM(){return{element:document.createElement("hr")}}exportJSON(){return{type:"horizontalrule",version:1}}getTextContent(){return`
|
|
35
|
+
`}isInline(){return!1}updateDOM(){return!1}};function Yc(){return{node:Qn()}}function Qn(){return Vc(new rt)}import{$applyNodeReplacement as zc}from"lexical";import"react";var Ee=class extends rt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return it()}decorate(){return null}exportJSON(){return super.exportJSON()}};function it(){return zc(new Ee)}function Ft(t){return t instanceof Ee}var ei={type:"element",dependencies:[Ee],export:(t,e)=>Ft(t)?"---":null,regExp:/^---\s*$/,replace:t=>{let e=it();e&&t.replace(e)}};import{c as Xc}from"react/compiler-runtime";import{useLexicalComposerContext as Jc}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as qc}from"@lexical/utils";import{$getSelection as Qc,$isRangeSelection as eu,COMMAND_PRIORITY_EDITOR as tu}from"lexical";import{useEffect as ou}from"react";var ti=()=>{let t=Xc(3),[e]=Jc(),o,r;return t[0]!==e?(o=()=>e.registerCommand(nt,ru,tu),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ou(o,r),null};function ru(t){let e=Qc();if(!eu(e))return!1;if(e.focus.getNode()!==null){let r=it();qc(r)}return!0}var iu=y({markdownTransformers:[ei],nodes:[Ee],plugins:[{Component:ti,position:"normal"}],slashMenu:{groups:[V([{Icon:So,key:"horizontalRule",keywords:["hr","horizontal rule","line","separator"],label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(nt,void 0)}}])]},toolbarFixed:{groups:[pe([{ChildComponent:So,isActive:({selection:t})=>{if(!nu(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return Ft(e)},key:"horizontalRule",label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(nt,void 0)}}])]}});import{TabIndentationPlugin as au}from"@lexical/react/LexicalTabIndentationPlugin";import{INDENT_CONTENT_COMMAND as cu,OUTDENT_CONTENT_COMMAND as uu}from"lexical";import{jsx as Pt,jsxs as lu}from"react/jsx-runtime";import"react";var oi=()=>lu("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:[Pt("path",{d:"M2.5 5H10.5",stroke:"currentColor",strokeWidth:"1.5"}),Pt("path",{d:"M2.5 10H10.5",stroke:"currentColor",strokeWidth:"1.5"}),Pt("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Pt("path",{d:"M12.25 7.25L17.25 3.75V10.75L12.25 7.25Z",fill:"currentColor"})]});import{jsx as Bt,jsxs as su}from"react/jsx-runtime";import"react";var ri=()=>su("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:[Bt("path",{d:"M17.5 5H9.5",stroke:"currentColor",strokeWidth:"1.5"}),Bt("path",{d:"M17.5 10H9.5",stroke:"currentColor",strokeWidth:"1.5"}),Bt("path",{d:"M17.5 15H2.5",stroke:"currentColor",strokeWidth:"1.5"}),Bt("path",{d:"M7.75 7.25L2.75 3.75V10.75L7.75 7.25Z",fill:"currentColor"})]});var ni=t=>({type:"buttons",items:t,key:"indent",order:35});var ii=[ni([{ChildComponent:oi,isActive:()=>!1,isEnabled:({selection:t})=>{if(!t||!t?.getNodes()?.length)return!1;for(let e of t.getNodes()){let o=e.getParentOrThrow();if("__indent"in e&&e.__indent>0||"__indent"in o&&o.__indent>0)return!0}return!1},key:"indentDecrease",label:({i18n:t})=>t.t("lexical:indent:decreaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(uu,void 0)},order:1},{ChildComponent:ri,isActive:()=>!1,key:"indentIncrease",label:({i18n:t})=>t.t("lexical:indent:increaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(cu,void 0)},order:2}])],du=y({plugins:[{Component:au,position:"normal"}],toolbarFixed:{groups:ii},toolbarInline:{groups:ii}});import{$findMatchingParent as Ed}from"@lexical/utils";import{$getSelection as Fo,$isRangeSelection as $i}from"lexical";import{jsx as li}from"react/jsx-runtime";import"react";var si=()=>li("svg",{"aria-hidden":"true",className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:li("path",{d:"M8.5 11.5L11.5 8.5M8.5 7L9.625 5.875C10.868 4.633 12.882 4.633 14.125 5.875C15.368 7.118 15.368 9.133 14.125 10.375L13 11.5M7 8.5L5.746 9.754C4.56 10.94 4.519 12.85 5.652 14.087C6.814 15.354 8.78 15.449 10.058 14.298L11.5 13",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})});import{$isAtNodeEnd as ai}from"@lexical/selection";function Be(t){let{anchor:e}=t,{focus:o}=t,r=t.anchor.getNode(),n=t.focus.getNode();return r===n?r:t.isBackward()?ai(o)?r:n:ai(e)?r:n}var Io=t=>({type:"buttons",items:t,key:"features",order:50});import{$createTextNode as wu}from"lexical";import{addClassNamesToElement as mu,isHTMLAnchorElement as pu}from"@lexical/utils";import Mo from"bson-objectid";import{$applyNodeReplacement as fu,$createTextNode as ci,$getSelection as hu,$isElementNode as ui,$isRangeSelection as vo,createCommand as gu,ElementNode as Cu}from"lexical";var xu=new Set(["http:","https:","mailto:","sms:","tel:"]),J=class t extends Cu{__fields;__id;constructor({id:e,fields:o={linkType:"custom",newTab:!1},key:r}){super(r),this.__fields=o,this.__id=e}static clone(e){return new t({id:e.__id,fields:e.__fields,key:e.__key})}static getType(){return"link"}static importDOM(){return{a:e=>({conversion:bu,priority:1})}}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2),e.version===2&&!e.id&&(e.id=new Mo.default().toHexString(),e.version=3);let o=fe({id:e.id,fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}canBeEmpty(){return!1}canInsertTextAfter(){return!1}canInsertTextBefore(){return!1}createDOM(e){let o=document.createElement("a");return this.__fields?.linkType==="custom"&&(o.href=this.sanitizeUrl(this.__fields.url??"")),(this.__fields?.newTab??!1)&&(o.target="_blank"),this.__fields?.newTab===!0&&this.__fields?.linkType==="custom"&&(o.rel=yo(o.rel,"add","noopener")),mu(o,e.theme.link),o}exportJSON(){let e=this.getFields();e?.linkType==="internal"?delete e.url:e?.linkType==="custom"&&delete e.doc;let o={...super.exportJSON(),type:"link",fields:e,version:3},r=this.getID();return r&&(o.id=r),o}extractWithChild(e,o,r){if(!vo(o))return!1;let n=o.anchor.getNode(),i=o.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&o.getTextContent().length>0}getFields(){return this.getLatest().__fields}getID(){return this.getLatest().__id}insertNewAfter(e,o=!0){let r=this.getParentOrThrow().insertNewAfter(e,o);if(ui(r)){let n=fe({fields:this.__fields});return r.append(n),n}return null}isInline(){return!0}sanitizeUrl(e){try{let o=new URL(e);if(!xu.has(o.protocol))return"about:blank"}catch{return"https://"}return e}setFields(e){let o=this.getWritable();o.__fields=e}updateDOM(e,o,r){let n=this.__fields?.url,i=this.__fields?.newTab;return n!=null&&n!==e.__fields?.url&&this.__fields?.linkType==="custom"&&(o.href=n),this.__fields?.linkType==="internal"&&e.__fields?.linkType==="custom"&&o.removeAttribute("href"),o.rel==null&&(o.rel=""),i!==e.__fields?.newTab&&(i??!1?(o.target="_blank",this.__fields?.linkType==="custom"&&(o.rel=yo(o.rel,"add","noopener"))):(o.removeAttribute("target"),o.rel=yo(o.rel,"remove","noopener"))),!1}};function bu(t){let e=null;if(pu(t)){let o=t.textContent;o!==null&&o!==""&&(e=fe({id:new Mo.default().toHexString(),fields:{doc:null,linkType:"custom",newTab:t.getAttribute("target")==="_blank",url:t.getAttribute("href")??""}}))}return{node:e}}function fe({id:t,fields:e}){return fu(new J({id:t??new Mo.default().toHexString(),fields:e}))}function G(t){return t instanceof J}var ie=gu("TOGGLE_LINK_COMMAND");function Do(t){let e=hu();if(!vo(e)&&(t===null||!t.selectedNodes?.length))return;let o=vo(e)?e.extract():t===null?[]:t.selectedNodes;if(t===null){o?.forEach(i=>{let l=i.getParent();if(G(l)){let s=l.getChildren();for(let a=0;a<s.length;a+=1)l.insertBefore(s[a]);l.remove()}});return}if(o?.length===1){let i=o[0],l=G(i)?i:_u(i);if(l!==null){l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(ci(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}}let r=null,n=null;o?.forEach(i=>{let l=i.getParent();if(!(l===n||l===null||ui(i)&&!i.isInline())){if(G(l)){n=l,l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(ci(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}if(l.is(r)||(r=l,n=fe({fields:t.fields}),G(l)?i.getPreviousSibling()===null?l.insertBefore(n):l.insertAfter(n):i.insertBefore(n)),G(i)){if(i.is(n))return;if(n!==null){let s=i.getChildren();for(let a=0;a<s.length;a+=1)n.append(s[a])}i.remove();return}n!==null&&n.append(i)}})}function _u(t){return Tu(t,e=>G(e))}function Tu(t,e){let o=t;for(;o!==null&&(o=o.getParent(),!(o===null||e(o))););return o}function yo(t,e,o){let r,n=`${t}`;if(e==="add"){if(n.includes(o)){let i=new RegExp(o,"g");n=n.replace(i,"").trim()}n=n.trim(),r=n.length===0?`${o}`:`${n} ${o}`}else{let i=new RegExp(o,"g");r=n.replace(i,"").trim()}return r}var di={type:"text-match",dependencies:[J],export:(t,e)=>{if(!G(t))return null;let o=t,{url:r}=o.getFields();return`[${e(o)}](${r})`},importRegExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)/,regExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)$/,replace:(t,e)=>{let[,o,r]=e,n=fe({fields:{doc:null,linkType:"custom",newTab:!1,url:r}}),i=wu(o);return i.setFormat(t.getFormat()),n.append(i),t.replace(n),i},trigger:")"};import{$applyNodeReplacement as Eu,$isElementNode as ku}from"lexical";var he=class t extends J{static clone(e){return new t({id:"",fields:e.__fields,key:e.__key})}static getType(){return"autolink"}static importDOM(){return null}static importJSON(e){e.version===1&&typeof e.fields?.doc?.value=="object"&&e.fields?.doc?.value?.id&&(e.fields.doc.value=e.fields.doc.value.id,e.version=2);let o=lt({fields:e.fields});return o.setFormat(e.format),o.setIndent(e.indent),o.setDirection(e.direction),o}exportJSON(){let e=super.exportJSON();return{type:"autolink",children:e.children,direction:e.direction,fields:e.fields,format:e.format,indent:e.indent,version:2}}insertNewAfter(e,o=!0){let r=this.getParentOrThrow().insertNewAfter(e,o);if(ku(r)){let n=lt({fields:this.__fields});return r.append(n),n}return null}};function lt({fields:t}){return Eu(new he({id:"",fields:t}))}function ge(t){return t instanceof he}import{c as Lu}from"react/compiler-runtime";import{useLexicalComposerContext as Nu}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Ru}from"@lexical/utils";import{$createTextNode as mi,$getSelection as Su,$isElementNode as fi,$isLineBreakNode as hi,$isNodeSelection as Iu,$isRangeSelection as yu,$isTextNode as st,TextNode as vu}from"lexical";import{useEffect as Mu}from"react";function pi(t,e=o=>o){return o=>{let r=t.exec(o);return r===null?null:{index:r.index,length:r[0].length,text:r[0],url:e(r[0])}}}function gi(t,e){for(let o=0;o<e.length;o++){let r=e[o](t);if(r!=null)return r}return null}var Du=/[.,;\s]/;function jt(t){return Du.test(t)}function Ci(t){return jt(t[t.length-1])}function Oo(t){return jt(t[0])}function Au(t,e){return e?/^\.[a-z]{2,}/i.test(t):/^\.[a-z0-9]+/i.test(t)}function xi(t){let e=t.getPreviousSibling();return fi(e)&&(e=e.getLastDescendant()),e===null||hi(e)||st(e)&&Ci(e.getTextContent())}function bi(t){let e=t.getNextSibling();return fi(e)&&(e=e.getFirstDescendant()),e===null||hi(e)||st(e)&&Oo(e.getTextContent())}function Ou(t,e,o,r){return(t>0?jt(o[t-1]):xi(r[0]))?e<o.length?jt(o[e]):bi(r[r.length-1]):!1}function $u(t,e,o){let r=[],n=[],i=[],l=0,s=0,a=[...t];for(;a.length>0;){let u=a[0],d=u.getTextContent().length,m=s;s+d<=e?(r.push(u),l+=d):m>=o?i.push(u):n.push(u),s+=d,a.shift()}return[l,r,n,i]}function Fu(t,e,o,r){let n={linkType:"custom",url:r.url,...r.fields},i=lt({fields:n});if(t.length===1){let l=t[0],s;e===0?[s,l]=l.splitText(o):[,s,l]=l.splitText(e,o);let a=mi(r.text);return a.setFormat(s.getFormat()),a.setDetail(s.getDetail()),a.setStyle(s.getStyle()),i.append(a),s.replace(i),l}else if(t.length>1){let l=t[0],s=l.getTextContent().length,a;e===0?a=l:[,a]=l.splitText(e);let u=[],c;for(let f=1;f<t.length;f++){let h=t[f],b=h.getTextContent().length,N=s,I=s+b;if(N<o)if(I<=o)u.push(h);else{let[C,T]=h.splitText(o-N);u.push(C),c=T}s+=b}let d=Su(),m=d?d.getNodes().find(st):void 0,p=mi(a.getTextContent());return p.setFormat(a.getFormat()),p.setDetail(a.getDetail()),p.setStyle(a.getStyle()),i.append(p,...u),m&&m===a&&(yu(d)?p.select(d.anchor.offset,d.focus.offset):Iu(d)&&p.select(0,p.getTextContent().length)),a.replace(i),c}}function Pu(t,e,o){let r=[...t],n=r.map(a=>a.getTextContent()).join(""),i=n,l,s=0;for(;(l=gi(i,e))!=null&&l!==null;){let a=l.index,u=l.length,c=a+u;if(Ou(s+a,s+c,n,r)){let[m,,p,f]=$u(r,s+a,s+c),h=s+a-m,x=s+c-m,b=Fu(p,h,x,l);r=b?[b,...f]:f,o(l.url,null),s=0}else s+=c;i=i.substring(c)}}function Ao(t,e,o){let r=t.getChildren(),n=r.length;for(let a=0;a<n;a++){let u=r[a];if(!st(u)||!u.isSimpleText()){Ht(t),o(null,t.getFields()?.url??null);return}}let i=t.getTextContent(),l=gi(i,e);if(l===null||l.text!==i){Ht(t),o(null,t.getFields()?.url??null);return}if(!xi(t)||!bi(t)){Ht(t),o(null,t.getFields()?.url??null);return}let s=t.getFields()?.url;if(s!==l?.url){let a=t.getFields();a.url=l?.url,t.setFields(a),o(l.url,s??null)}}function Bu(t,e,o){let r=t.getPreviousSibling(),n=t.getNextSibling(),i=t.getTextContent();if(ge(r)){let l=r.getFields()?.url?r.getFields()?.url?.startsWith("mailto:")??!1:!1;(!Oo(i)||Au(i,l))&&(r.append(t),Ao(r,e,o),o(null,r.getFields()?.url??null))}ge(n)&&!Ci(i)&&(Ht(n),Ao(n,e,o),o(null,n.getFields()?.url??null))}function Ht(t){let e=t.getChildren(),o=e.length;for(let r=o-1;r>=0;r--)t.insertAfter(e[r]);return t.remove(),e.map(r=>r.getLatest())}function Hu(t){let e=[t],o=t.getNextSibling();for(;o!==null&&st(o)&&o.isSimpleText()&&(e.push(o),!/\s/.test(o.getTextContent()));)o=o.getNextSibling();return e}function ju(t,e,o){let r=Lu(5),n,i;r[0]!==t||r[1]!==e||r[2]!==o?(n=()=>{if(!t.hasNodes([he]))throw new Error("LexicalAutoLinkPlugin: AutoLinkNode not registered on editor");let l=(s,a)=>{o?.(s,a)};return Ru(t.registerNodeTransform(vu,s=>{let a=s.getParentOrThrow(),u=s.getPreviousSibling();if(ge(a))Ao(a,e,l);else if(!G(a)){if(s.isSimpleText()&&(Oo(s.getTextContent())||!ge(u))){let c=Hu(s);Pu(c,e,l)}Bu(s,e,l)}}))},i=[t,e,o],r[0]=t,r[1]=e,r[2]=o,r[3]=n,r[4]=i):(n=r[3],i=r[4]),Mu(n,i)}var Uu=/((https?:\/\/(www\.)?)|(www\.))[-\w@:%.+~#=]{1,256}\.[a-zA-Z\d()]{1,6}\b([-\w()@:%+.~#?&/=]*)(?<![-.+():%])/,Gu=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-\d]+\.)+[a-z]{2,}))/i,Wu=[pi(Uu,t=>t.startsWith("http")?t:`https://${t}`),pi(Gu,t=>`mailto:${t}`)],_i=()=>{let[t]=Nu();return ju(t,Wu),null};import{jsx as Vu}from"react/jsx-runtime";import{ClickableLinkPlugin as Ku}from"@lexical/react/LexicalClickableLinkPlugin.js";import"react";var Ti=()=>Vu(Ku,{});import{jsx as ud}from"react/jsx-runtime";import"react";import{createPortal as dd}from"react-dom";import{jsx as Ce,jsxs as at,Fragment as Yu}from"react/jsx-runtime";import{useLexicalComposerContext as zu}from"@lexical/react/LexicalComposerContext.js";import{$findMatchingParent as wi,mergeRegister as Ei}from"@lexical/utils";import{getTranslation as $o}from"@payloadcms/translations";import{CloseMenuIcon as Xu,EditIcon as Ju,ExternalLinkIcon as ki,formatDrawerSlug as qu,useConfig as Qu,useEditDepth as ed,useLocale as td,useTranslation as od}from"@payloadcms/ui";import{requests as rd}from"@payloadcms/ui/shared";import{$getSelection as Li,$isLineBreakNode as nd,$isRangeSelection as Ni,COMMAND_PRIORITY_HIGH as id,COMMAND_PRIORITY_LOW as Ri,getDOMSelection as ld,KEY_ESCAPE_COMMAND as sd,SELECTION_CHANGE_COMMAND as ad}from"lexical";import Si,{useCallback as Ii,useEffect as Wt,useRef as cd,useState as Ie}from"react";function Ut(t,e,o,r=10,n=5){let i=o.parentElement;if(t===null||i==null){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let l=e.getBoundingClientRect(),s=o.getBoundingClientRect(),a=i.getBoundingClientRect(),u=t.top-r,c=t.left-n;u<a.top&&(u+=l.height+t.height+r*2),c+l.width>a.right&&(c=a.right-l.width-n),u-=s.top,c-=s.left,e.style.opacity="1",e.style.transform=`translate(${c}px, ${u}px)`}import{createCommand as Zu}from"lexical";var Gt=Zu("TOGGLE_LINK_WITH_MODAL_COMMAND");function yi(t){t.preventDefault()}function vi({anchorElem:t}){let[e]=zu(),[o,r]=Ie(),n=cd(null),[i,l]=Ie(null),[s,a]=Ie(null),{fieldProps:{schemaPath:u},uuid:c}=P(),{config:d,getEntityConfig:m}=Qu(),{i18n:p,t:f}=od(),[h,x]=Ie(),b=ed(),[N,I]=Ie(!1),[C,T]=Ie([]),g=td(),[_,S]=Ie(!1),L=qu({slug:"lexical-rich-text-link-"+c,depth:b}),{toggleDrawer:k}=ue(L),v=Ii(()=>{I(!1),n&&n.current&&(n.current.style.opacity="0",n.current.style.transform="translate(-10000px, -10000px)"),S(!1),l(null),a(null),T([]),x(void 0)},[I,l,a,T]),E=Ii(()=>{let w=Li(),R;if(!Ni(w)||!w){v();return}let M=Be(w);R=e.getElementByKey(M.getKey())?.getBoundingClientRect();let D=wi(M,G),$=w.getNodes().filter(Y=>!nd(Y)).find(Y=>{let oe=wi(Y,G);return D&&!D.is(oe)||oe&&!oe.is(D)});if(D==null||$){v();return}r(D);let A=D.getFields(),W={...A,id:D.getID(),text:D.getTextContent()};if(A?.linkType==="custom")l(A?.url??null),a(null);else{l(`${d.routes.admin==="/"?"":d.routes.admin}/collections/${A?.doc?.relationTo}/${A?.doc?.value}`);let Y=A?.doc?.relationTo?m({collectionSlug:A?.doc?.relationTo}):void 0;if(!Y)a(A?.label?String(A?.label):null),l(A?.url?String(A?.url):null);else{let oe=typeof A.doc?.value=="object"?A.doc.value.id:A.doc?.value,ae=A.doc?.relationTo;if(!oe||!ae)throw new Error("Focus link parent is missing doc.value or doc.relationTo");let Et=f("fields:linkedTo",{label:`${$o(Y.labels.singular,p)} - ${f("lexical:link:loadingWithEllipsis",p)}`}).replace(/<[^>]*>?/g,"");a(Et),rd.get(`${d.serverURL}${d.routes.api}/${ae}/${oe}`,{headers:{"Accept-Language":p.language},params:{depth:0,locale:g?.code}}).then(async re=>{if(!re.ok)throw new Error(`HTTP error! Status: ${re.status}`);let $e=await re.json(),Ze=Y?.admin?.useAsTitle||"id",kt=$e[Ze],ao=f("fields:linkedTo",{label:`${$o(Y.labels.singular,p)} - ${kt}`}).replace(/<[^>]*>?/g,"");a(ao)}).catch(()=>{let re=f("fields:linkedTo",{label:`${$o(Y.labels.singular,p)} - ${f("general:untitled",p)} - ID: ${oe}`}).replace(/<[^>]*>?/g,"");a(re)})}}x(W),I(!0),T(w?w?.getNodes():[]),ge(D)?S(!0):S(!1);let Z=n.current,H=ld(e._window),{activeElement:Oe}=document;if(Z===null)return;let te=e.getRootElement();return H!==null&&te!==null&&te.contains(H.anchorNode)?(R||(R=H.getRangeAt(0).getBoundingClientRect()),R!=null&&(R.y+=40,Ut(R,Z,t))):(Oe==null||Oe.className!=="link-input")&&(te!==null&&Ut(null,Z,t),l(null),a(null)),!0},[e,v,d.routes.admin,d.routes.api,d.serverURL,m,f,p,g?.code,t]);return Wt(()=>Ei(e.registerCommand(Gt,w=>(e.dispatchCommand(ie,w),E(),k(),!0),Ri)),[e,E,k,L]),Wt(()=>{let w=t.parentElement,R=()=>{e.getEditorState().read(()=>{E()})};return window.addEventListener("resize",R),w?.addEventListener("scroll",R),()=>{window.removeEventListener("resize",R),w?.removeEventListener("scroll",R)}},[t.parentElement,e,E]),Wt(()=>Ei(e.registerUpdateListener(({editorState:w})=>{w.read(()=>{E()})}),e.registerCommand(ad,()=>(E(),!0),Ri),e.registerCommand(sd,()=>N?(v(),!0):!1,id)),[e,E,N,v]),Wt(()=>{e.getEditorState().read(()=>{E()})},[e,E]),at(Si.Fragment,{children:[Ce("div",{className:"link-editor",ref:n,children:at("div",{className:"link-input",children:[i&&i.length>0?at("a",{href:i,rel:"noopener noreferrer",target:"_blank",children:[o?.__fields.newTab?Ce(ki,{}):null,s!=null&&s.length>0?s:i]}):s!=null&&s.length>0?at(Yu,{children:[o?.__fields.newTab?Ce(ki,{}):null,Ce("span",{className:"link-input__label-pure",children:s})]}):null,e.isEditable()&&at(Si.Fragment,{children:[Ce("button",{"aria-label":"Edit link",className:"link-edit",onClick:w=>{w.preventDefault(),k()},onMouseDown:yi,tabIndex:0,type:"button",children:Ce(Ju,{})}),!_&&Ce("button",{"aria-label":"Remove link",className:"link-trash",onClick:()=>{e.dispatchCommand(ie,null)},onMouseDown:yi,tabIndex:0,type:"button",children:Ce(Xu,{})})]})]})}),Ce(Ye,{className:"lexical-link-edit-drawer",data:h,drawerSlug:L,drawerTitle:f("fields:editLink"),featureKey:"link",handleDrawerSubmit:(w,R)=>{let M=R,D={...M};delete D.text,e.update(()=>{let $=Li(),A=null;if(Ni($)?A=Be($).getParent():C.length&&(A=C[0].getParent()),A&&ge(A)){let W=fe({fields:D});A.replace(W,!0)}}),e.dispatchCommand(ie,{fields:D,selectedNodes:C,text:M.text})},schemaPath:u,schemaPathSuffix:"fields"})]})}var Mi=t=>{let{anchorElem:e=document.body}=t;return dd(ud(vi,{anchorElem:e}),e)};import{c as fd}from"react/compiler-runtime";import{useLexicalComposerContext as hd}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as gd}from"@lexical/utils";import{$getSelection as Cd,$isElementNode as xd,$isRangeSelection as bd,COMMAND_PRIORITY_LOW as Ai,PASTE_COMMAND as _d}from"lexical";import{useEffect as Td}from"react";var md=/^(?:[a-zA-Z][a-zA-Z\d+.-]*:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d]+(?:\.[A-Za-z\d]+)+|www\.[A-Za-z\d]+(?:\.[A-Za-z\d]+)+|(?:tel|mailto):[\w+.-]+)(?:\/[+~%/\w-]*)?(?:\?[-;&=%\w]*)?(?:#\w+)?$/,pd=/^(?:\/[\w\-./]*(?:#\w[\w-]*)?|#[\w\-]+)$/;function Di(t){if(!t)return!1;if(t==="https://"||md.test(t)||pd.test(t))return!0;try{return new URL(t),!0}catch{}return!1}var Oi=t=>{let e=fd(5),{clientProps:o}=t,[r]=hd(),n,i;return e[0]!==o.defaultLinkType||e[1]!==o.defaultLinkURL||e[2]!==r?(n=()=>{if(!r.hasNodes([J]))throw new Error("LinkPlugin: LinkNode not registered on editor");return gd(r.registerCommand(ie,l=>l===null?(Do(null),!0):(l.fields?.linkType||(l.fields.linkType=o.defaultLinkType),l.fields?.url||(l.fields.url=o.defaultLinkURL),Do(l),!0),Ai),r.registerCommand(_d,l=>{let s=Cd();if(!bd(s)||s.isCollapsed()||!(l instanceof ClipboardEvent)||l.clipboardData==null)return!1;let a=l.clipboardData.getData("text");if(!Di(a))return!1;if(!s.getNodes().some(wd)){let u={doc:null,linkType:"custom",newTab:!1,url:a};return r.dispatchCommand(ie,{fields:u,text:null}),l.preventDefault(),!0}return!1},Ai))},i=[o.defaultLinkType,o.defaultLinkURL,r],e[0]=o.defaultLinkType,e[1]=o.defaultLinkURL,e[2]=r,e[3]=n,e[4]=i):(n=e[3],i=e[4]),Td(n,i),null};function wd(t){return xd(t)}var Fi=[Io([{ChildComponent:si,isActive:({selection:t})=>{if($i(t)){let e=Be(t);return Ed(e,G)!=null}return!1},isEnabled:({selection:t})=>!!($i(t)&&Fo()?.getTextContent()?.length),key:"link",label:({i18n:t})=>t.t("lexical:link:label"),onSelect:({editor:t,isActive:e})=>{if(e)t.dispatchCommand(ie,null);else{let o,r=[];if(t.getEditorState().read(()=>{o=Fo()?.getTextContent(),r=Fo()?.getNodes()??[]}),!o?.length)return;let n={doc:null,newTab:!1};t.dispatchCommand(Gt,{fields:n,selectedNodes:r,text:o})}},order:1}])],kd=y({markdownTransformers:[di],nodes:[J,he],plugins:[{Component:Oi,position:"normal"},{Component:_i,position:"normal"},{Component:Ti,position:"normal"},{Component:Mi,position:"floatingAnchorElem"}],toolbarFixed:{groups:Fi},toolbarInline:{groups:Fi}});import{$isListNode as Ho,INSERT_CHECK_LIST_COMMAND as Gi,ListItemNode as $d,ListNode as Fd}from"@lexical/list";import{$isRangeSelection as Pd}from"lexical";import{jsx as Pi,jsxs as Ld}from"react/jsx-runtime";import"react";var Po=()=>Ld("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:[Pi("rect",{height:"13",rx:"1.5",stroke:"currentColor",width:"13",x:"3.5",y:"3.5"}),Pi("path",{d:"M7 10L9 12.5L13 7.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Nd}from"react/jsx-runtime";import{ListPlugin as Rd}from"@lexical/react/LexicalListPlugin.js";import"react";var He=()=>Nd(Rd,{});function je(t){return{items:t,key:"lists",label:({i18n:e})=>e.t("lexical:general:slashMenuListGroupLabel")}}import{$isListNode as vd,ListItemNode as Md,ListNode as Dd}from"@lexical/list";import{$createListItemNode as Sd,$createListNode as Id,$isListItemNode as yd,$isListNode as Bo}from"@lexical/list";var Bi=4,Ue=t=>(e,o,r)=>{let n=e.getPreviousSibling(),i=e.getNextSibling(),l=Sd(t==="check"?r[3]==="x":void 0);if(Bo(i)&&i.getListType()===t){let a=i.getFirstChild();a!==null?a.insertBefore(l):i.append(l),e.remove()}else if(Bo(n)&&n.getListType()===t)n.append(l),e.remove();else{let a=Id(t,t==="number"?Number(r[2]):void 0);a.append(l),e.replace(a)}l.append(...o),l.select(0,0);let s=Math.floor(r[1].length/Bi);s&&l.setIndent(s)},ye=(t,e,o)=>{let r=[],n=t.getChildren(),i=0;for(let l of n)if(yd(l)){if(l.getChildrenSize()===1){let c=l.getFirstChild();if(Bo(c)){r.push(ye(c,e,o+1));continue}}let s=" ".repeat(o*Bi),a=t.getListType(),u=a==="number"?`${t.getStart()+i}. `:a==="check"?`- [${l.getChecked()?"x":" "}] `:"- ";r.push(s+u+e(l)),i++}return r.join(`
|
|
36
|
+
`)};var Hi={type:"element",dependencies:[Dd,Md],export:(t,e)=>vd(t)?ye(t,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:Ue("check")};import{jsx as Ad}from"react/jsx-runtime";import{CheckListPlugin as Od}from"@lexical/react/LexicalCheckListPlugin.js";import"react";var ji=()=>Ad(Od,{});var Ui=[X([{ChildComponent:Po,isActive:({selection:t})=>{if(!Pd(t))return!1;for(let e of t.getNodes()){if(Ho(e)&&e.getListType()==="check")continue;let o=e.getParent();if(Ho(o)&&o.getListType()==="check")continue;let r=o?.getParent();if(!(Ho(r)&&r.getListType()==="check"))return!1}return!0},key:"checklist",label:({i18n:t})=>t.t("lexical:checklist:label"),onSelect:({editor:t})=>{t.dispatchCommand(Gi,void 0)},order:12}])],Bd=y(({featureProviderMap:t})=>{let e=[{Component:ji,position:"normal"}];return!t.has("unorderedList")&&!t.has("orderedList")&&e.push({Component:He,position:"normal"}),{markdownTransformers:[Hi],nodes:t.has("unorderedList")||t.has("orderedList")?[]:[Fd,$d],plugins:e,slashMenu:{groups:[je([{Icon:Po,key:"checklist",keywords:["check list","check","checklist","cl"],label:({i18n:o})=>o.t("lexical:checklist:label"),onSelect:({editor:o})=>{o.dispatchCommand(Gi,void 0)}}])]},toolbarFixed:{groups:Ui},toolbarInline:{groups:Ui}}});import{$isListNode as Uo,INSERT_ORDERED_LIST_COMMAND as Ki,ListItemNode as Wd,ListNode as Vd}from"@lexical/list";import{$isRangeSelection as Kd}from"lexical";import{jsx as ct,jsxs as Hd}from"react/jsx-runtime";import"react";var jo=()=>Hd("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:[ct("path",{d:"M5.89284 12.479C5.89284 13.368 5.26284 13.788 4.38084 14.236C3.75084 14.558 3.43584 14.789 3.40784 15.062H5.89984V16H2.06384V15.573C2.06384 14.523 2.92484 13.935 3.66684 13.501C4.38084 13.088 4.75184 12.878 4.75184 12.458C4.75184 12.08 4.52084 11.835 4.06584 11.835C3.58984 11.835 3.30984 12.199 3.28184 12.654H2.11284C2.18984 11.681 2.87584 10.918 4.07284 10.918C5.15784 10.918 5.89284 11.555 5.89284 12.479Z",fill:"currentColor"}),ct("path",{d:"M2.68608 4.535V3.737C3.54008 3.737 3.90408 3.513 4.02308 2.995H4.89108V8H3.68008L3.68008 4.535H2.68608Z",fill:"currentColor"}),ct("path",{d:"M8 15L17 15",stroke:"currentColor",strokeWidth:"1.5"}),ct("path",{d:"M8 10L17 10",stroke:"currentColor",strokeWidth:"1.5"}),ct("path",{d:"M8 5L17 5",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as jd,ListItemNode as Ud,ListNode as Gd}from"@lexical/list";var Wi={type:"element",dependencies:[Gd,Ud],export:(t,e)=>jd(t)?ye(t,e,0):null,regExp:/^(\s*)(\d+)\.\s/,replace:Ue("number")};var Vi=[X([{ChildComponent:jo,isActive:({selection:t})=>{if(!Kd(t))return!1;for(let e of t.getNodes()){if(Uo(e)&&e.getListType()==="number")continue;let o=e.getParent();if(Uo(o)&&o.getListType()==="number")continue;let r=o?.getParent();if(!(Uo(r)&&r.getListType()==="number"))return!1}return!0},key:"orderedList",label:({i18n:t})=>t.t("lexical:orderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ki,void 0)},order:10}])],Zd=y(({featureProviderMap:t})=>({markdownTransformers:[Wi],nodes:t.has("orderedList")?[]:[Vd,Wd],plugins:t.has("orderedList")?[]:[{Component:He,position:"normal"}],slashMenu:{groups:[je([{Icon:jo,key:"orderedList",keywords:["ordered list","ol"],label:({i18n:e})=>e.t("lexical:orderedList:label"),onSelect:({editor:e})=>{e.dispatchCommand(Ki,void 0)}}])]},toolbarFixed:{groups:Vi},toolbarInline:{groups:Vi}}));import{$isListNode as Wo,INSERT_UNORDERED_LIST_COMMAND as zi,ListItemNode as qd,ListNode as Qd}from"@lexical/list";import{$isRangeSelection as em}from"lexical";import{jsx as Ge,jsxs as Yd}from"react/jsx-runtime";import"react";var Go=()=>Yd("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:[Ge("circle",{cx:"4",cy:"5",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Ge("circle",{cx:"4",cy:"10",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Ge("circle",{cx:"4",cy:"15",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Ge("path",{d:"M17 5H7",stroke:"currentColor",strokeWidth:"1.5"}),Ge("path",{d:"M17 10H7",stroke:"currentColor",strokeWidth:"1.5"}),Ge("path",{d:"M17 15H7",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as zd,ListItemNode as Xd,ListNode as Jd}from"@lexical/list";var Zi={type:"element",dependencies:[Jd,Xd],export:(t,e)=>zd(t)?ye(t,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:Ue("bullet")};var Yi=[X([{ChildComponent:Go,isActive:({selection:t})=>{if(!em(t))return!1;for(let e of t.getNodes()){if(Wo(e)&&e.getListType()==="bullet")continue;let o=e.getParent();if(Wo(o)&&o.getListType()==="bullet")continue;let r=o?.getParent();if(!(Wo(r)&&r.getListType()==="bullet"))return!1}return!0},key:"unorderedList",label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(zi,void 0)},order:11}])],tm=y({markdownTransformers:[Zi],nodes:[Qd,qd],plugins:[{Component:He,position:"normal"}],slashMenu:{groups:[je([{Icon:Go,key:"unorderedList",keywords:["unordered list","ul"],label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(zi,void 0)}}])]},toolbarFixed:{groups:Yi},toolbarInline:{groups:Yi}});import{jsx as om}from"react/jsx-runtime";import{addClassNamesToElement as rm}from"@lexical/utils";import{DecoratorNode as nm}from"lexical";import*as Xi from"react";var im=Xi.lazy(()=>import("./Component-MBLHTKDK.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),ut=class t extends nm{__data;constructor({data:e,key:o}){super(o),this.__data=e}static clone(e){return new t({data:e.__data,key:e.__key})}static getType(){return"unknownConverted"}static importJSON(e){return lm({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return rm(o,"unknownConverted"),o}decorate(){return om(im,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function lm({data:t}){return new ut({data:t})}var sm=y(()=>({nodes:[ut]}));import{jsx as am}from"react/jsx-runtime";import{addClassNamesToElement as cm}from"@lexical/utils";import{DecoratorNode as um}from"lexical";import*as Ji from"react";var dm=Ji.lazy(()=>import("./Component-DOSSWC76.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),dt=class t extends um{__data;constructor({data:e,key:o}){super(o),this.__data=e}static clone(e){return new t({data:e.__data,key:e.__key})}static getType(){return"unknownConverted"}static importJSON(e){return mm({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return cm(o,"unknownConverted"),o}decorate(){return am(dm,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function mm({data:t}){return new dt({data:t})}var pm=y(()=>({nodes:[dt]}));import{$setBlocksType as el}from"@lexical/selection";import{$createParagraphNode as tl,$getSelection as ol,$isParagraphNode as qi,$isRangeSelection as fm}from"lexical";var Qi=[X([{ChildComponent:Xe,isActive:({selection:t})=>{if(!fm(t))return!1;for(let e of t.getNodes())if(!qi(e)&&!qi(e.getParent()))return!1;return!0},key:"paragraph",label:({i18n:t})=>t.t("lexical:paragraph:label2"),onSelect:({editor:t})=>{t.update(()=>{let e=ol();el(e,()=>tl())})},order:1}])],hm=y({slashMenu:{groups:[V([{Icon:Xe,key:"paragraph",keywords:["normal","paragraph","p","text"],label:({i18n:t})=>t.t("lexical:paragraph:label"),onSelect:({editor:t})=>{t.update(()=>{let e=ol();el(e,()=>tl())})}}])]},toolbarFixed:{groups:Qi},toolbarInline:{groups:Qi}});import{$isNodeSelection as Qm}from"lexical";import{jsx as mt,jsxs as gm}from"react/jsx-runtime";import"react";var Vo=()=>gm("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:[mt("g",{clipPath:"url(#clip0_4397_10817)",children:mt("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"})}),mt("defs",{children:mt("clipPath",{id:"clip0_4397_10817",children:mt("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{jsx as bm}from"react/jsx-runtime";import*as nl from"react";import{DecoratorBlockNode as Cm}from"@lexical/react/LexicalDecoratorBlockNode.js";function xm(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:rl({relationTo:o,value:e})}:null}var pt=class extends Cm{__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:xm,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=rl(o);return r.setFormat(e.format),r}static isInline(){return!1}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 rl(t){return new pt({data:t})}var _m=nl.lazy(()=>import("./RelationshipComponent-JPESGV4Q.js").then(t=>({default:t.RelationshipComponent})));function Tm(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:ve({relationTo:o,value:e})}:null}var xe=class extends pt{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:Tm,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=ve(o);return r.setFormat(e.format),r}decorate(e,o){return bm(_m,{className:o.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function ve(t){return new xe({data:t})}function Ko(t){return t instanceof xe}import{c as Bm}from"react/compiler-runtime";import{jsx as Hm}from"react/jsx-runtime";import{useLexicalComposerContext as jm}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Um}from"@lexical/utils";import{useConfig as Gm}from"@payloadcms/ui";import{$getPreviousSelection as Wm,$getSelection as Vm,$isParagraphNode as ul,$isRangeSelection as Km,COMMAND_PRIORITY_EDITOR as Zm,createCommand as Ym}from"lexical";import{useEffect as zm}from"react";import{c as Dm}from"react/compiler-runtime";import{jsx as Vt}from"react/jsx-runtime";import{useLexicalComposerContext as Am}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as Om,COMMAND_PRIORITY_EDITOR as $m}from"lexical";import{useEffect as Fm,useState as sl}from"react";import{c as wm}from"react/compiler-runtime";import{jsx as Em}from"react/jsx-runtime";import{useLexicalComposerContext as km}from"@lexical/react/LexicalComposerContext";import{useListDrawer as Lm,useModal as Nm}from"@payloadcms/ui";import{$getNodeByKey as il,$getPreviousSelection as Rm,$getRoot as Sm,$getSelection as Im,$isRangeSelection as ym,$setSelection as vm}from"lexical";import{useEffect as Mm,useState as ll}from"react";var ft=t=>{let e=wm(23),[o]=km(),[r,n]=ll(null),[i,l]=ll(!1),[s,a,u]=Lm(t),{closeDrawer:c,drawerSlug:d,isDrawerOpen:m,openDrawer:p}=u,{modalState:f}=Nm(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let k=Im()??Rm();n(k)},e[0]=h):h=e[0];let x=h,b;e[1]!==o||e[2]!==r?(b=()=>{r&&o.update(()=>{if(ym(r)){let{anchor:k,focus:v}=r;il(k.key)&&il(v.key)&&vm(r.clone())}else Sm().selectEnd()},{discrete:!0,skipTransforms:!0})},e[1]=o,e[2]=r,e[3]=b):b=e[3];let N=b,I;e[4]!==c?(I=()=>{c()},e[4]=c,e[5]=I):I=e[5];let C=I,T,g;e[6]!==d||e[7]!==f||e[8]!==N||e[9]!==i?(T=()=>{if(!i)return;let k=f[d];k&&!k?.isOpen&&(l(!1),setTimeout(()=>{N()},1))},g=[f,d,N,i],e[6]=d,e[7]=f,e[8]=N,e[9]=i,e[10]=T,e[11]=g):(T=e[10],g=e[11]),Mm(T,g);let _;e[12]!==a?(_=k=>Em(a,{...k,onClick:()=>{x()}}),e[12]=a,e[13]=_):_=e[13];let S;e[14]!==p?(S=()=>{x(),p(),l(!0)},e[14]=p,e[15]=S):S=e[15];let L;return e[16]!==s||e[17]!==C||e[18]!==m||e[19]!==d||e[20]!==_||e[21]!==S?(L={closeListDrawer:C,isListDrawerOpen:m,ListDrawer:s,listDrawerSlug:d,ListDrawerToggler:_,openListDrawer:S},e[16]=s,e[17]=C,e[18]=m,e[19]=d,e[20]=_,e[21]=S,e[22]=L):L=e[22],L};var Pm=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Om(o);n&&n.replace(ve({relationTo:e,value:r}))}):t.dispatchCommand(Zo,{relationTo:e,value:r})},al=t=>{let e=Dm(16),{enabledCollectionSlugs:o}=t,[r]=Am(),n;e[0]!==o?(n=()=>o?.[0],e[0]=o,e[1]=n):n=e[1];let[i]=sl(n),[l,s]=sl(null),a=o||void 0,u;e[2]!==i||e[3]!==a?(u={collectionSlugs:a,selectedCollection:i},e[2]=i,e[3]=a,e[4]=u):u=e[4];let{closeListDrawer:c,ListDrawer:d,openListDrawer:m}=ft(u),p,f;e[5]!==r||e[6]!==m?(p=()=>r.registerCommand(ze,N=>(s(N?.replace?N?.replace.nodeKey:null),m(),!0),$m),f=[r,m],e[5]=r,e[6]=m,e[7]=p,e[8]=f):(p=e[7],f=e[8]),Fm(p,f);let h;e[9]!==c||e[10]!==r||e[11]!==l?(h=N=>{let{collectionSlug:I,docID:C}=N;Pm({editor:r,relationTo:I,replaceNodeKey:l,value:C}),c()},e[9]=c,e[10]=r,e[11]=l,e[12]=h):h=e[12];let x=h,b;return e[13]!==d||e[14]!==x?(b=Vt(d,{onSelect:x}),e[13]=d,e[14]=x,e[15]=b):b=e[15],b},cl=t=>(t?.enabledCollectionSlugs?.length??-1)>0?Vt(al,{...t}):Vt(Lt,{...t,children:Vt(al,{...t})});var Zo=Ym("INSERT_RELATIONSHIP_COMMAND"),dl=t=>{let e=Bm(10),{clientProps:o}=t,[r]=jm(),{config:n}=Gm(),{collections:i}=n,l=null;if(o?.enabledCollections)l=o?.enabledCollections;else if(o?.disabledCollections){let c;if(e[0]!==o?.disabledCollections||e[1]!==i){let d;e[3]!==o?.disabledCollections?(d=m=>{let{slug:p}=m;return!o?.disabledCollections?.includes(p)},e[3]=o?.disabledCollections,e[4]=d):d=e[4],c=i.filter(d).map(Xm),e[0]=o?.disabledCollections,e[1]=i,e[2]=c}else c=e[2];l=c}let s,a;e[5]!==r?(s=()=>{if(!r.hasNodes([xe]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand(Zo,qm,Zm)},a=[r],e[5]=r,e[6]=s,e[7]=a):(s=e[6],a=e[7]),zm(s,a);let u;return e[8]!==l?(u=Hm(cl,{enabledCollectionSlugs:l}),e[8]=l,e[9]=u):u=e[9],u};function Xm(t){let{slug:e}=t;return e}function Jm(t){return ul(t)}function qm(t){let e=Vm()||Wm();if(Km(e)){let o=ve(t);Um(o);let{focus:r}=e,n=r.getNode();ul(n)&&n.getTextContentSize()===0&&n.getParentOrThrow().getChildren().filter(Jm).length>1&&n.remove()}return!0}var ep=y({nodes:[xe],plugins:[{Component:dl,position:"normal"}],slashMenu:{groups:[V([{Icon:Vo,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(ze,{replace:!1})}}])]},toolbarFixed:{groups:[pe([{ChildComponent:Vo,isActive:({selection:t})=>{if(!Qm(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return Ko(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(ze,{replace:!1})}}])]}});import{c as Cl}from"react/compiler-runtime";import{jsx as ee,jsxs as _p}from"react/jsx-runtime";import{useLexicalComposerContext as Tp}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as wp,useThrottledEffect as Ep,useTranslation as kp}from"@payloadcms/ui";import*as be from"react";import{useMemo as Lp}from"react";import{c as tp}from"react/compiler-runtime";import{jsx as op}from"react/jsx-runtime";import{mergeRegister as rp}from"@lexical/utils";import{$addUpdateTag as np,$getSelection as ip}from"lexical";import{useEffect as Kt,useState as Yo}from"react";var zo="toolbar-popup__button",ht=t=>{let e=tp(34),{children:o,editor:r,item:n}=t,[i,l]=Yo(!0),[s,a]=Yo(!1),[u,c]=Yo(zo),d=P(),m;e[0]!==s||e[1]!==r||e[2]!==d||e[3]!==i||e[4]!==n?(m=()=>{r.getEditorState().read(()=>{let S=ip();if(S){if(n.isActive){let L=n.isActive({editor:r,editorConfigContext:d,selection:S});s!==L&&a(L)}if(n.isEnabled){let L=n.isEnabled({editor:r,editorConfigContext:d,selection:S});i!==L&&l(L)}}})},e[0]=s,e[1]=r,e[2]=d,e[3]=i,e[4]=n,e[5]=m):m=e[5];let p=m,f,h;e[6]!==p?(f=()=>{p()},h=[p],e[6]=p,e[7]=f,e[8]=h):(f=e[7],h=e[8]),Kt(f,h);let x,b;e[9]!==p?(x=()=>(document.addEventListener("mouseup",p),()=>{document.removeEventListener("mouseup",p)}),b=[p],e[9]=p,e[10]=x,e[11]=b):(x=e[10],b=e[11]),Kt(x,b);let N,I;e[12]!==r||e[13]!==p?(N=()=>rp(r.registerUpdateListener(()=>{p()})),I=[r,p],e[12]=r,e[13]=p,e[14]=N,e[15]=I):(N=e[14],I=e[15]),Kt(N,I);let C;e[16]!==s||e[17]!==i||e[18]!==n.key?(C=()=>{c([zo,i===!1?"disabled":"",s?"active":"",n?.key?`${zo}-`+n.key:""].filter(Boolean).join(" "))},e[16]=s,e[17]=i,e[18]=n.key,e[19]=C):C=e[19];let T;e[20]!==s||e[21]!==u||e[22]!==i||e[23]!==n.key?(T=[i,s,u,n.key],e[20]=s,e[21]=u,e[22]=i,e[23]=n.key,e[24]=T):T=e[24],Kt(C,T);let g;e[25]!==s||e[26]!==r||e[27]!==i||e[28]!==n?(g=()=>{if(i!==!1)return r.focus(()=>{r.update(lp),n.onSelect?.({editor:r,isActive:s})}),!0},e[25]=s,e[26]=r,e[27]=i,e[28]=n,e[29]=g):g=e[29];let _;return e[30]!==o||e[31]!==u||e[32]!==g?(_=op("button",{className:u,onClick:g,onMouseDown:sp,type:"button",children:o}),e[30]=o,e[31]=u,e[32]=g,e[33]=_):_=e[33],_};function lp(){np("toolbar")}function sp(t){t.preventDefault()}import{c as fp}from"react/compiler-runtime";import{jsx as We}from"react/jsx-runtime";import qo,{useCallback as hp,useEffect as gl}from"react";import{mergeRegister as gp}from"@lexical/utils";import{useTranslation as Cp}from"@payloadcms/ui";import{$getSelection as xp}from"lexical";import{jsx as ke,jsxs as ml}from"react/jsx-runtime";import{Button as ap}from"@payloadcms/ui";import{$addUpdateTag as cp}from"lexical";import Zt,{useCallback as up,useEffect as gt,useMemo as dp,useRef as Jo,useState as Yt}from"react";import{createPortal as mp}from"react-dom";var Xo="toolbar-popup__dropdown-item",pl=Zt.createContext(null);function fl({active:t,children:e,editor:o,enabled:r,Icon:n,item:i,tooltip:l}){let[s,a]=Yt(Xo);gt(()=>{a([Xo,r===!1?"disabled":"",t?"active":"",i?.key?`${Xo}-${i.key}`:""].filter(Boolean).join(" "))},[r,t,s,i.key]);let u=Jo(null),c=Zt.useContext(pl);if(c===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:d}=c;return gt(()=>{u?.current!=null&&d(u)},[u,d]),ke(ap,{"aria-label":l,buttonStyle:"none",className:s,disabled:r===!1,icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{cp("toolbar")}),i.onSelect?.({editor:o,isActive:t})})},onMouseDown:m=>{m.preventDefault()},ref:u,tooltip:l,type:"button",children:e})}function pp({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,i]=Yt(),[l,s]=Yt(),a=up(d=>{i(m=>m!=null?[...m,d]:[d])},[i]),u=d=>{if(n==null)return;let{key:m}=d;["ArrowDown","ArrowUp","Escape","Tab"].includes(m)&&d.preventDefault(),m==="Escape"||m==="Tab"?r():m==="ArrowUp"?s(p=>{if(p==null)return n[0];let f=n.indexOf(p)-1;return n[f===-1?n.length-1:f]}):m==="ArrowDown"&&s(p=>p==null?n[0]:n[n.indexOf(p)+1])},c=dp(()=>({registerItem:a}),[a]);return gt(()=>{n!=null&&l==null&&s(n[0]),l!=null&&l?.current!=null&&l.current.focus()},[n,l]),ke(pl.Provider,{value:c,children:ke("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:u,ref:e,children:t})})}function hl({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,Icon:n,itemsContainerClassNames:i,label:l,stopCloseOnClickSelf:s}){let a=Jo(null),u=Jo(null),[c,d]=Yt(!1),m=()=>{d(!1),u?.current!=null&&u.current.focus()};gt(()=>{let f=u.current,h=a.current;if(c&&f!==null&&h!==null){let{left:x,top:b}=f.getBoundingClientRect(),N=window.scrollY||document.documentElement.scrollTop;h.style.top=`${b+N+f.offsetHeight+5}px`,h.style.left=`${Math.min(x-5,window.innerWidth-h.offsetWidth-20)}px`}},[a,u,c]),gt(()=>{let f=u.current;if(f!==null&&c){let h=x=>{let{target:b}=x;s!=null&&a.current!=null&&a.current.contains(b)||f.contains(b)||d(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[a,u,c,s]);let p=mp(ke(pp,{dropDownRef:a,itemsContainerClassNames:i,onClose:m,children:o}),document.body);return ml(Zt.Fragment,{children:[ml("button",{"aria-label":t,className:e+(c?" active":""),disabled:r,onClick:f=>{f.preventDefault(),d(!c)},onMouseDown:f=>{f.preventDefault()},ref:u,type:"button",children:[n&&ke(n,{}),l&&ke("span",{className:"toolbar-popup__dropdown-label",children:l}),ke("i",{className:"toolbar-popup__dropdown-caret"})]}),c&&ke(Zt.Fragment,{children:p})]})}var Qo="toolbar-popup__dropdown",bp=t=>{let e=fp(18),{active:o,anchorElem:r,editor:n,enabled:i,item:l}=t,{i18n:s}=Cp(),{fieldProps:a}=P(),{featureClientSchemaMap:u,schemaPath:c}=a;if(l.Component){let f;return e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==i||e[4]!==l?(f=l?.Component&&We(l.Component,{active:o,anchorElem:r,editor:n,enabled:i,item:l},l.key),e[0]=o,e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=f):f=e[5],f}let d=l.key,m;if(l.label){let f;e[6]!==u||e[7]!==s||e[8]!==l||e[9]!==c?(f=typeof l.label=="function"?l.label({featureClientSchemaMap:u,i18n:s,schemaPath:c}):l.label,e[6]=u,e[7]=s,e[8]=l,e[9]=c,e[10]=f):f=e[10],d=f}d.length>25?m=d.substring(0,25)+"...":m=d;let p;return e[11]!==o||e[12]!==m||e[13]!==n||e[14]!==i||e[15]!==l||e[16]!==d?(p=We(fl,{active:o,editor:n,enabled:i,Icon:l?.ChildComponent?We(l.ChildComponent,{}):void 0,item:l,tooltip:d,children:We("span",{className:"text",children:m})},l.key),e[11]=o,e[12]=m,e[13]=n,e[14]=i,e[15]=l,e[16]=d,e[17]=p):p=e[17],p},Me=({anchorElem:t,classNames:e,editor:o,group:r,Icon:n,itemsContainerClassNames:i,label:l,maxActiveItems:s,onActiveChange:a})=>{let[u,c]=qo.useState([]),[d,m]=qo.useState([]),[p,f]=qo.useState(!0),h=P(),{items:x,key:b}=r,N=hp(()=>{o.getEditorState().read(()=>{let I=xp();if(!I)return;let C=[],T=[],g=[];for(let _ of x)_.isActive&&(!s||C.length<s)&&_.isActive({editor:o,editorConfigContext:h,selection:I})&&(C.push(_.key),T.push(_)),_.isEnabled?_.isEnabled({editor:o,editorConfigContext:h,selection:I})&&g.push(_.key):g.push(_.key);r.isEnabled&&f(r.isEnabled({editor:o,editorConfigContext:h,selection:I})),c(C),m(g),a&&a({activeItems:T})})},[o,h,r,x,s,a]);return gl(()=>{N()},[N]),gl(()=>gp(o.registerUpdateListener(()=>{N()})),[o,N]),We(hl,{buttonAriaLabel:`${b} dropdown`,buttonClassName:[Qo,`${Qo}-${b}`,...e||[]].filter(Boolean).join(" "),disabled:!p,Icon:n,itemsContainerClassNames:[`${Qo}-items`,...i||[]],label:l,children:x.length?x.map(I=>We(bp,{active:u.includes(I.key),anchorElem:t,editor:o,enabled:d.includes(I.key),item:I},I.key)):null},b)};function Np({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&ee(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?ee(ht,{editor:e,item:o,children:ee(o.ChildComponent,{})},o.key):null}function Rp(t){let e=Cl(23),{anchorElem:o,editor:r,editorConfig:n,group:i,index:l}=t,{i18n:s}=kp(),{fieldProps:a}=P(),{featureClientSchemaMap:u,schemaPath:c}=a,[d,m]=be.useState(void 0),[p,f]=be.useState(void 0),h;e[0]!==i.ChildComponent||e[1]!==i.items||e[2]!==i.type?(h=()=>{i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0)},e[0]=i.ChildComponent,e[1]=i.items,e[2]=i.type,e[3]=h):h=e[3];let x;e[4]!==i?(x=[i],e[4]=i,e[5]=x):x=e[5],be.useEffect(h,x);let b;e[6]!==u||e[7]!==i.ChildComponent||e[8]!==i.items||e[9]!==i.type||e[10]!==s||e[11]!==c?(b=T=>{let{activeItems:g}=T;if(!g.length){i?.type==="dropdown"&&i.items.length&&i.ChildComponent?(f(()=>i.ChildComponent),m(void 0)):(f(void 0),m(void 0));return}let _=g[0],S=_.key;_.label&&(S=typeof _.label=="function"?_.label({featureClientSchemaMap:u,i18n:s,schemaPath:c}):_.label),S.length>25&&(S=S.substring(0,25)+"..."),g.length===1?(m(S),f(()=>_.ChildComponent)):(m(s.t("lexical:general:toolbarItemsActive",{count:g.length})),i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0))},e[6]=u,e[7]=i.ChildComponent,e[8]=i.items,e[9]=i.type,e[10]=s,e[11]=c,e[12]=b):b=e[12];let N=b,I=`fixed-toolbar__group fixed-toolbar__group-${i.key}`,C;return e[13]!==p||e[14]!==o||e[15]!==d||e[16]!==r||e[17]!==n.features.toolbarFixed?.groups.length||e[18]!==i||e[19]!==l||e[20]!==N||e[21]!==I?(C=_p("div",{className:I,children:[i.type==="dropdown"&&i.items.length?p?ee(Me,{anchorElem:o,editor:r,group:i,Icon:p,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:d,maxActiveItems:i.maxActiveItems??1,onActiveChange:N}):ee(Me,{anchorElem:o,editor:r,group:i,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:d,maxActiveItems:i.maxActiveItems??1,onActiveChange:N}):null,i.type==="buttons"&&i.items.length?i.items.map(T=>ee(Np,{anchorElem:o,editor:r,item:T},T.key)):null,l<n.features.toolbarFixed?.groups.length-1&&ee("div",{className:"divider"})]},i.key),e[13]=p,e[14]=o,e[15]=d,e[16]=r,e[17]=n.features.toolbarFixed?.groups.length,e[18]=i,e[19]=l,e[20]=N,e[21]=I,e[22]=C):C=e[22],C}function Sp({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let i=be.useRef(null),{y:l}=wp(),s=Lp(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let u=n.editorContainerRef.current.previousElementSibling;for(;u;){if(u.classList.contains("fixed-toolbar"))return u;u=u.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return Ep(()=>{if(!s)return;let a=i.current;if(!a)return;let u=a.getBoundingClientRect(),c=s.getBoundingClientRect();if(!(u.bottom<c.top||u.top>c.bottom))a.classList.remove("fixed-toolbar"),a.classList.add("fixed-toolbar","fixed-toolbar--overlapping"),s.classList.remove("fixed-toolbar"),s.classList.add("fixed-toolbar","fixed-toolbar--hide");else{if(!a.classList.contains("fixed-toolbar--overlapping"))return;a.classList.remove("fixed-toolbar--overlapping"),a.classList.add("fixed-toolbar"),s.classList.remove("fixed-toolbar--hide"),s.classList.add("fixed-toolbar")}},50,[i,s,l]),ee("div",{className:"fixed-toolbar",onFocus:a=>{a.stopPropagation()},ref:i,children:o.isEditable()&&ee(be.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((a,u)=>ee(Rp,{anchorElem:t,editor:o,editorConfig:r,group:a,index:u},a.key))})})}var xl=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return xl(t.parentEditor)}return!1},bl=t=>{let e=Cl(6),{clientProps:o}=t,[r]=Tp(),n=P(),{editorConfig:i}=n,l=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,s=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||i,a,u;if(e[0]!==o.disableIfParentHasFixedToolbar||e[1]!==l||e[2]!==s||e[3]!==n){u=Symbol.for("react.early_return_sentinel");e:{let c=xl(n);if(o?.disableIfParentHasFixedToolbar&&c){u=null;break e}if(!s?.features?.toolbarFixed?.groups?.length){u=null;break e}a=ee(Sp,{anchorElem:document.body,editor:l,editorConfig:s,parentWithFixedToolbar:c})}e[0]=o.disableIfParentHasFixedToolbar,e[1]=l,e[2]=s,e[3]=n,e[4]=a,e[5]=u}else a=e[4],u=e[5];return u!==Symbol.for("react.early_return_sentinel")?u:a};var Ip=y({plugins:[{Component:bl,position:"aboveContainer"}]});import{c as wl}from"react/compiler-runtime";import{jsx as le,jsxs as El}from"react/jsx-runtime";import{useLexicalComposerContext as yp}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as kl}from"@lexical/utils";import{$getSelection as Ll,$isRangeSelection as _l,$isTextNode as vp,COMMAND_PRIORITY_LOW as Mp,getDOMSelection as Nl,SELECTION_CHANGE_COMMAND as Dp}from"lexical";import{useCallback as Xt,useEffect as Ct,useRef as Tl,useState as Ap}from"react";import*as Jt from"react";import{createPortal as Op}from"react-dom";function er(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 zt(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:i=32,horizontalPosition:l="left",specialHandlingForCaret:s=!1,targetRect:a,verticalGap:u=10}=t,c=o.parentElement;if(a===null||c==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let d=n.getBoundingClientRect(),m=o.getBoundingClientRect(),p=c.getBoundingClientRect(),f=a.top-d.height-u,h=a.left-i;l==="center"&&(h=a.left+a.width/2-d.width/2);let x=0;return!e&&f<p.top&&!s&&(x=d.height+a.height+u*2,f+=x),l==="center"?h+d.width>p.right?h=p.right-d.width-i:h<p.left&&(h=p.left+i):h+d.width>p.right&&(h=p.right-d.width-i),h-=m.left,n.style.opacity="1",s&&r!==0?(f-=m.bottom-r+d.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=m.top,n.style.transform=`translate(${h}px, ${f}px)`),x}function $p({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&le(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?le(ht,{editor:e,item:o,children:le(o.ChildComponent,{})},o.key):null}function Fp(t){let e=wl(19),{anchorElem:o,editor:r,group:n,index:i}=t,{editorConfig:l}=P(),[s,a]=Jt.useState(),u;e[0]!==n.ChildComponent||e[1]!==n.items||e[2]!==n.type?(u=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0)},e[0]=n.ChildComponent,e[1]=n.items,e[2]=n.type,e[3]=u):u=e[3];let c;e[4]!==n?(c=[n],e[4]=n,e[5]=c):c=e[5],Jt.useEffect(u,c);let d;e[6]!==n.ChildComponent||e[7]!==n.items||e[8]!==n.type?(d=h=>{let{activeItems:x}=h;if(!x.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0);return}let b=x[0];a(()=>b.ChildComponent)},e[6]=n.ChildComponent,e[7]=n.items,e[8]=n.type,e[9]=d):d=e[9];let m=d,p=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;return e[10]!==s||e[11]!==o||e[12]!==r||e[13]!==l.features.toolbarInline?.groups.length||e[14]!==n||e[15]!==i||e[16]!==m||e[17]!==p?(f=El("div",{className:p,children:[n.type==="dropdown"&&n.items.length?s?le(Me,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:n.maxActiveItems??1,onActiveChange:m}):le(Me,{anchorElem:o,editor:r,group:n,maxActiveItems:n.maxActiveItems??1,onActiveChange:m}):null,n.type==="buttons"&&n.items.length?n.items.map(h=>le($p,{anchorElem:o,editor:r,item:h},h.key)):null,i<l.features.toolbarInline?.groups.length-1&&le("div",{className:"divider"})]},n.key),e[10]=s,e[11]=o,e[12]=r,e[13]=l.features.toolbarInline?.groups.length,e[14]=n,e[15]=i,e[16]=m,e[17]=p,e[18]=f):f=e[18],f}function Pp({anchorElem:t,editor:e}){let o=Tl(null),r=Tl(null),{editorConfig:n}=P(),i=Xt(()=>{if(o?.current){let u=o.current.style.opacity==="0",c=o.current.style.pointerEvents==="none";u||(o.current.style.opacity="0"),c||(o.current.style.pointerEvents="none")}},[o]),l=Xt(u=>{if(o?.current&&(u.buttons===1||u.buttons===3)){let c=o.current.style.opacity==="0",d=o.current.style.pointerEvents==="none";if(!c||!d){let m=u.clientX,p=u.clientY,f=document.elementFromPoint(m,p);o.current.contains(f)||i()}}},[i]),s=Xt(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);Ct(()=>(document.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}),[o,l,s]);let a=Xt(()=>{let u=Ll(),c=Nl(e._window);if(o.current===null)return;let d=t.querySelector(":scope > .link-editor"),m=d!==null&&"style"in d&&d?.style?.opacity==="1",p=e.getRootElement();if(u!==null&&c!==null&&!c.isCollapsed&&p!==null&&p.contains(c.anchorNode)){let f=er(c,p),h=zt({alwaysDisplayOnTop:m,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&zt({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else i()},[e,i,t]);return Ct(()=>{let u=t.parentElement,c=()=>{e.getEditorState().read(()=>{a()})};return window.addEventListener("resize",c),u&&u.addEventListener("scroll",c),()=>{window.removeEventListener("resize",c),u&&u.removeEventListener("scroll",c)}},[e,a,t]),Ct(()=>(e.getEditorState().read(()=>{a()}),kl(e.registerUpdateListener(({editorState:u})=>{u.read(()=>{a()})}),e.registerCommand(Dp,()=>(a(),!1),Mp))),[e,a]),El("div",{className:"inline-toolbar-popup",ref:o,children:[le("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((u,c)=>le(Fp,{anchorElem:t,editor:e,group:u,index:c},u.key))]})}function Bp(t,e){let o=wl(12),[r,n]=Ap(!1),i;o[0]!==t?(i=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let m=Ll(),p=Nl(t._window),f=t.getRootElement();if(p!==null&&(!_l(m)||f===null||!f.contains(p.anchorNode))){n(!1);return}if(!_l(m))return;if(m.getTextContent()!==""){let x=m.getNodes(),b=!1;for(let N of x)if(vp(N)){n(!0),b=!0;break}b||n(!1)}else n(!1);let h=m.getTextContent().replace(/\n/g,"");if(!m.isCollapsed()&&h===""){n(!1);return}})},o[0]=t,o[1]=i):i=o[1];let l=i,s,a;o[2]!==l?(s=()=>(document.addEventListener("selectionchange",l),document.addEventListener("mouseup",l),()=>{document.removeEventListener("selectionchange",l),document.removeEventListener("mouseup",l)}),a=[l],o[2]=l,o[3]=s,o[4]=a):(s=o[3],a=o[4]),Ct(s,a);let u,c;if(o[5]!==t||o[6]!==l?(u=()=>kl(t.registerUpdateListener(()=>{l()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),c=[t,l],o[5]=t,o[6]=l,o[7]=u,o[8]=c):(u=o[7],c=o[8]),Ct(u,c),!r||!t.isEditable())return null;let d;return o[9]!==e||o[10]!==t?(d=Op(le(Pp,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=d):d=o[11],d}var Rl=t=>{let{anchorElem:e}=t,[o]=yp();return Bp(o,e)};var Hp=y({plugins:[{Component:Rl,position:"floatingAnchorElem"}]});import{TableCellNode as k1,TableNode as L1,TableRowNode as N1}from"@lexical/table";import{jsx as Sl}from"react/jsx-runtime";import"react";var tr=()=>Sl("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Sl("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 jp,$createTableNode as Up,$createTableRowNode as Gp,$isTableCellNode as Il,$isTableNode as or,$isTableRowNode as rr,TableCellHeaderStates as qt,TableCellNode as Wp,TableNode as Vp,TableRowNode as Kp}from"@lexical/table";import{$isParagraphNode as Zp,$isTextNode as Yp}from"lexical";var vl=/^\|(.+)\|\s?$/,zp=/^(\| ?:?-*:? ?)+\|\s?$/,Ml=({allTransformers:t})=>({type:"element",dependencies:[Vp,Kp,Wp],export:e=>{if(!or(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!rr(r))continue;let i=!1;for(let l of r.getChildren())Il(l)&&(n.push(Nr(t,l).replace(/\n/g,"\\n")),l.__headerState===qt.ROW&&(i=!0));o.push(`| ${n.join(" | ")} |`),i&&o.push(`| ${n.map(l=>"---").join(" | ")} |`)}return o.join(`
|
|
37
|
+
`)},regExp:vl,replace:(e,o,r)=>{if(zp.test(r[0])){let c=e.getPreviousSibling();if(!c||!or(c))return;let d=c.getChildren(),m=d[d.length-1];if(!m||!rr(m))return;m.getChildren().forEach(p=>{Il(p)&&p.setHeaderStyles(qt.ROW,qt.ROW)}),e.remove();return}let n=yl(r[0],t);if(n==null)return;let i=[n],l=e.getPreviousSibling(),s=n.length;for(;l&&!(!Zp(l)||l.getChildrenSize()!==1);){let c=l.getFirstChild();if(!Yp(c))break;let d=yl(c.getTextContent(),t);if(d==null)break;s=Math.max(s,d.length),i.unshift(d);let m=l.getPreviousSibling();l.remove(),l=m}let a=Up();for(let c of i){let d=Gp();a.append(d);for(let m=0;m<s;m++)d.append(m<c.length?c[m]:Dl("",t))}let u=e.getPreviousSibling();or(u)&&Xp(u)===s?(u.append(...a.getChildren()),e.remove()):e.replace(a),a.selectEnd()}});function Xp(t){let e=t.getFirstChild();return rr(e)?e.getChildrenSize():0}var Dl=(t,e)=>{t=t.replace(/\\n/g,`
|
|
38
|
+
`);let o=jp(qt.NO_STATUS);return Lr(t,e,o),o},yl=(t,e)=>{let o=t.match(vl);return!o||!o[1]?null:o[1].split("|").map(r=>Dl(r,e))};import{c as qp}from"react/compiler-runtime";import{jsx as F,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Pl}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Qp}from"@lexical/react/useLexicalEditable";import{$deleteTableColumn__EXPERIMENTAL as ef,$deleteTableRow__EXPERIMENTAL as tf,$getNodeTriplet as of,$getTableCellNodeFromLexicalNode as Ol,$getTableColumnIndexFromTableCellNode as rf,$getTableNodeFromLexicalNodeOrThrow as De,$getTableRowIndexFromTableCellNode as nf,$insertTableColumn__EXPERIMENTAL as lf,$insertTableRow__EXPERIMENTAL as sf,$isTableCellNode as xt,$isTableRowNode as $l,$isTableSelection as bt,$unmergeCell as af,getTableElement as lr,getTableObserverFromTableElement as sr,TableCellHeaderStates as Le,TableCellNode as cf}from"@lexical/table";import{mergeRegister as uf}from"@lexical/utils";import{useScrollInfo as df}from"@payloadcms/ui";import{$createParagraphNode as mf,$getRoot as pf,$getSelection as eo,$isElementNode as ff,$isParagraphNode as Bl,$isRangeSelection as ar,$isTextNode as hf,COMMAND_PRIORITY_CRITICAL as gf,getDOMSelection as Cf,SELECTION_CHANGE_COMMAND as xf}from"lexical";import*as cr from"react";import{useCallback as se,useEffect as Ve,useRef as Qt,useState as Ke}from"react";import{createPortal as Hl}from"react-dom";import{jsx as nr,jsxs as Jp}from"react/jsx-runtime";import"react";var Al=()=>Jp("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[nr("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"}),nr("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"}),nr("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 ir(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function bf(){let t=eo();if(ar(t)&&!t.isCollapsed()||bt(t)&&!t.anchor.is(t.focus)||!ar(t)&&!bt(t))return!1;let[e]=of(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Fl(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!Bl(e)||!e.isEmpty())}function _f(t){let e=t.getLastDescendant();hf(e)?e.select():ff(e)?e.selectEnd():e!==null&&e.selectNext()}function Tf({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=Pl(),l=Qt(null),[s,a]=Ke(n),[u,c]=Ke({columns:1,rows:1}),[d,m]=Ke(!1),[p,f]=Ke(!1),{y:h}=df();Ve(()=>i.registerMutationListener(cf,E=>{E.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{a(s.getLatest())})},{skipInitialization:!0}),[i,s]),Ve(()=>{i.getEditorState().read(()=>{let E=eo();if(bt(E)){let w=ir(E);c(ir(E)),m(w.columns>1||w.rows>1)}f(bf())})},[i]),Ve(()=>{let E=e.current,w=l.current,R=i.getRootElement();if(E!=null&&w!=null&&R!=null){let M=R.getBoundingClientRect(),D=E.getBoundingClientRect();w.style.opacity="1";let $=w.getBoundingClientRect(),A=5,W=D.right+A;if(W+$.width>window.innerWidth||W+$.width>M.right){let H=D.left-$.width-A;W=(H<0?A:H)+window.pageXOffset}w.style.left=`${W+window.pageXOffset}px`;let Z=D.top;if(Z+$.height>window.innerHeight){let H=D.bottom-$.height;Z=H<0?A:H}w.style.top=`${Z}px`}},[e,l,i,h]),Ve(()=>{function E(w){l.current!=null&&e.current!=null&&!l.current.contains(w.target)&&!e.current.contains(w.target)&&r(!1)}return window.addEventListener("click",E),()=>window.removeEventListener("click",E)},[r,e]);let x=se(()=>{i.update(()=>{if(s.isAttached()){let w=De(s),R=lr(w,i.getElementByKey(w.getKey()));if(R===null)throw new Error("Expected to find tableElement in DOM");let M=sr(R);M!==null&&M.$clearHighlight(),w.markDirty(),a(s.getLatest())}pf().selectStart()})},[i,s]),b=()=>{i.update(()=>{let E=eo();if(bt(E)){let{columns:w,rows:R}=ir(E),M=E.getNodes(),D=null;for(let $=0;$<M.length;$++){let A=M[$];if(xt(A))if(D===null){A.setColSpan(w).setRowSpan(R),D=A;let W=Fl(A),Z;W&&Bl(Z=A.getFirstChild())&&Z.remove()}else xt(D)&&(Fl(A)||D.append(...A.getChildren()),A.remove())}D!==null&&(D.getChildrenSize()===0&&D.append(mf()),_f(D)),o()}})},N=()=>{i.update(()=>{af()})},I=se(E=>{i.update(()=>{sf(E),o()})},[i,o]),C=se(E=>{i.update(()=>{for(let w=0;w<u.columns;w++)lf(E);o()})},[i,o,u.columns]),T=se(()=>{i.update(()=>{tf(),o()})},[i,o]),g=se(()=>{i.update(()=>{De(s).remove(),x(),o()})},[i,s,x,o]),_=se(()=>{i.update(()=>{ef(),o()})},[i,o]),S=se(()=>{i.update(()=>{let E=De(s),w=nf(s),R=E.getChildren();if(w>=R.length||w<0)throw new Error("Expected table cell to be inside of table row.");let M=R[w];if(!$l(M))throw new Error("Expected table row");let D=s.getHeaderStyles()^Le.ROW;M.getChildren().forEach($=>{if(!xt($))throw new Error("Expected table cell");$.setHeaderStyles(D,Le.ROW)}),x(),o()})},[i,s,x,o]),L=se(()=>{i.update(()=>{let E=De(s),w=rf(s),R=E.getChildren(),M=Math.max(...R.map($=>$.getChildren().length));if(w>=M||w<0)throw new Error("Expected table cell to be inside of table row.");let D=s.getHeaderStyles()^Le.COLUMN;for(let $=0;$<R.length;$++){let A=R[$];if(!$l(A))throw new Error("Expected table row");let W=A.getChildren();if(w>=W.length)continue;let Z=W[w];if(!xt(Z))throw new Error("Expected table cell");Z.setHeaderStyles(D,Le.COLUMN)}x(),o()})},[i,s,x,o]),k=se(()=>{i.update(()=>{if(s.isAttached()){let E=De(s);E&&E.setRowStriping(!E.getRowStriping())}x(),o()})},[i,s,x,o]),v=null;return t&&(d?v=F("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>b(),type:"button",children:F("span",{className:"text",children:"Merge cells"})}):p&&(v=F("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>N(),type:"button",children:F("span",{className:"text",children:"Unmerge cells"})}))),Hl(_e("div",{className:"table-action-menu-dropdown",onClick:E=>{E.stopPropagation()},ref:l,children:[v?_e(cr.Fragment,{children:[v,F("hr",{})]}):null,F("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>k(),type:"button",children:F("span",{className:"text",children:"Toggle Row Striping"})}),F("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>I(!1),type:"button",children:_e("span",{className:"text",children:["Insert ",u.rows===1?"row":`${u.rows} rows`," above"]})}),F("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>I(!0),type:"button",children:_e("span",{className:"text",children:["Insert ",u.rows===1?"row":`${u.rows} rows`," below"]})}),F("hr",{}),F("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>C(!1),type:"button",children:_e("span",{className:"text",children:["Insert ",u.columns===1?"column":`${u.columns} columns`," ","left"]})}),F("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>C(!0),type:"button",children:_e("span",{className:"text",children:["Insert ",u.columns===1?"column":`${u.columns} columns`," ","right"]})}),F("hr",{}),F("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>_(),type:"button",children:F("span",{className:"text",children:"Delete column"})}),F("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>T(),type:"button",children:F("span",{className:"text",children:"Delete row"})}),F("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:F("span",{className:"text",children:"Delete table"})}),F("hr",{}),F("button",{className:"item",onClick:()=>S(),type:"button",children:_e("span",{className:"text",children:[(s.__headerState&Le.ROW)===Le.ROW?"Remove":"Add"," ","row header"]})}),F("button",{className:"item","data-test-id":"table-column-header",onClick:()=>L(),type:"button",children:_e("span",{className:"text",children:[(s.__headerState&Le.COLUMN)===Le.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function wf({anchorElem:t,cellMerge:e}){let[o]=Pl(),r=Qt(null),n=Qt(null),[i,l]=Ke(!1),[s,a]=Ke(null),u=se(()=>{let d=r.current,m=eo(),p=Cf(o._window),f=document.activeElement;function h(){d&&(d.classList.remove("table-cell-action-button-container--active"),d.classList.add("table-cell-action-button-container--inactive")),a(null)}if(m==null||d==null)return h();let x=o.getRootElement(),b=null,N=null;if(ar(m)&&x!==null&&p!==null&&x.contains(p.anchorNode)){let C=Ol(m.anchor.getNode());if(C==null||(N=o.getElementByKey(C.getKey()),N==null||!C.isAttached()))return h();let T=De(C),g=lr(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=sr(g),a(C)}else if(bt(m)){let C=Ol(m.anchor.getNode());if(!xt(C))throw new Error("TableSelection anchorNode must be a TableCellNode");let T=De(C),g=lr(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=sr(g),N=o.getElementByKey(C.getKey())}else if(!f)return h();if(b===null||N===null)return h();let I=!b||!b.isSelecting;if(d.classList.toggle("table-cell-action-button-container--active",I),d.classList.toggle("table-cell-action-button-container--inactive",!I),I){let C=N.getBoundingClientRect(),T=t.getBoundingClientRect(),g=C.top-T.top,_=C.right-T.left;d.style.transform=`translate(${_}px, ${g}px)`}},[o,t]);Ve(()=>{let d,m=()=>{d=void 0,o.getEditorState().read(u)},p=()=>(d===void 0&&(d=setTimeout(m,0)),!1);return uf(o.registerUpdateListener(p),o.registerCommand(xf,p,gf),o.registerRootListener((f,h)=>{h&&h.removeEventListener("mouseup",p),f&&(f.addEventListener("mouseup",p),p())}),()=>clearTimeout(d))});let c=Qt(s);return Ve(()=>{c.current!==s&&l(!1),c.current=s},[c,s]),F("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&_e(cr.Fragment,{children:[F("button",{className:"table-cell-action-button",onClick:d=>{d.stopPropagation(),l(!i)},ref:n,type:"button",children:F(Al,{})}),i&&F(Tf,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var jl=t=>{let e=qp(3),{anchorElem:o}=t,r=Qp(),n;return e[0]!==o||e[1]!==r?(n=Hl(r?F(wf,{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 Ef}from"react/compiler-runtime";import{jsx as oo,jsxs as kf}from"react/jsx-runtime";import{useLexicalComposerContext as Lf}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Nf}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Rf,$getTableNodeFromLexicalNodeOrThrow as ur,$getTableRowIndexFromTableCellNode as Sf,$isTableCellNode as Ul,$isTableRowNode as If,getDOMCellFromTarget as yf,getTableElement as vf,TableNode as Mf}from"@lexical/table";import{calculateZoomLevel as Gl}from"@lexical/utils";import{$getNearestNodeFromDOMNode as dr}from"lexical";import*as Vl from"react";import{useCallback as _t,useEffect as mr,useRef as to,useState as Tt}from"react";import{createPortal as Df}from"react-dom";var Af=33,Wl=92;function Of({editor:t}){let e=to(null),o=to(null),r=to(null),n=P(),i=to(null),[l,s]=Tt(null),[a,u]=Tt(null),[c,d]=Tt(!1),[m,p]=Tt(null),f=_t(()=>{u(null),e.current=null,p(null),i.current=null,r.current=null},[]),h=L=>(L.buttons&1)===1;mr(()=>t.registerNodeTransform(Mf,L=>{if(L.getColWidths())return L;let k=L.getColumnCount(),v=Wl;return L.setColWidths(Array(k).fill(v)),L}),[t]),mr(()=>{let L=w=>{let R=w.target;if(m){s({x:w.clientX,y:w.clientY});return}if(d(h(w)),!(o.current&&o.current.contains(R))&&e.current!==R){e.current=R;let M=yf(R);M&&a!==M?t.getEditorState().read(()=>{let D=dr(M.elem);if(!D)throw new Error("TableCellResizer: Table cell node not found.");let $=ur(D),A=vf($,t.getElementByKey($.getKey()));if(!A)throw new Error("TableCellResizer: Table element not found.");e.current=R,r.current=A.getBoundingClientRect(),u(M)},{editor:t}):M==null&&f()}},k=w=>{d(!0)},v=w=>{d(!1)},E=t.registerRootListener((w,R)=>{R?.removeEventListener("mousemove",L),R?.removeEventListener("mousedown",k),R?.removeEventListener("mouseup",v),w?.addEventListener("mousemove",L),w?.addEventListener("mousedown",k),w?.addEventListener("mouseup",v)});return()=>{E()}},[a,m,t,f]);let x=L=>L==="bottom",b=_t(L=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let k=dr(a.elem);if(!Ul(k))throw new Error("TableCellResizer: Table cell node not found.");let v=ur(k),E=Sf(k)+k.getRowSpan()-1,w=v.getChildren();if(E>=w.length||E<0)throw new Error("Expected table cell to be inside of table row.");let R=w[E];if(!If(R))throw new Error("Expected table row");let M=R.getHeight();if(M===void 0){let $=R.getChildren();M=Math.min(...$.map(A=>N(A,t)??1/0))}let D=Math.max(M+L,Af);R.setHeight(D)},{tag:"skip-scroll-into-view"})},[a,t]),N=(L,k)=>k.getElementByKey(L.getKey())?.clientHeight,I=(L,k)=>{for(let v=0;v<k.length;v++)for(let E=0;E<k[v].length;E++)if(k[v][E].cell===L)return E},C=_t(L=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let k=dr(a.elem);if(!Ul(k))throw new Error("TableCellResizer: Table cell node not found.");let v=ur(k),[E]=Rf(v,null,null),w=I(k,E);if(w===void 0)throw new Error("TableCellResizer: Table column not found.");let R=v.getColWidths();if(!R)return;let M=R[w];if(M===void 0)return;let D=[...R],$=Math.max(M+L,Wl);D[w]=$,v.setColWidths(D)},{tag:"skip-scroll-into-view"})},[a,t]),T=_t(L=>{let k=v=>{if(v.preventDefault(),v.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:E,y:w}=i.current;if(a===null)return;let R=Gl(v.target);if(x(L)){let M=(v.clientY-w)/R;b(M)}else{let M=(v.clientX-E)/R;C(M)}f(),document.removeEventListener("mouseup",k)}};return k},[a,f,C,b]),g=_t(L=>k=>{if(k.preventDefault(),k.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");i.current={x:k.clientX,y:k.clientY},s(i.current),p(L),document.addEventListener("mouseup",T(L))},[a,T]),[_,S]=Tt({bottom:null,left:null,right:null,top:null});return mr(()=>{if(a){let{height:L,left:k,top:v,width:E}=a.elem.getBoundingClientRect(),w=Gl(a.elem),R=10,M={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${R}px`,left:`${window.scrollX+k}px`,top:`${window.scrollY+v+L-R/2}px`,width:`${E}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${L}px`,left:`${window.scrollX+k+E-R/2}px`,top:`${window.scrollY+v}px`,width:`${R}px`}},D=r.current;m&&l&&D&&(x(m)?(M[m].left=`${window.scrollX+D.left}px`,M[m].top=`${window.scrollY+l.y/w}px`,M[m].height="3px",M[m].width=`${D.width}px`):(M[m].top=`${window.scrollY+D.top}px`,M[m].left=`${window.scrollX+l.x/w}px`,M[m].width="3px",M[m].height=`${D.height}px`),M[m].backgroundColor="#adf"),S(M)}else S({bottom:null,left:null,right:null,top:null})},[a,m,l]),oo("div",{ref:o,children:a!=null&&!c&&kf(Vl.Fragment,{children:[oo("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:g("right"),style:_.right||void 0}),oo("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:g("bottom"),style:_.bottom||void 0})]})})}var Kl=()=>{let t=Ef(3),[e]=Lf(),o=Nf(),r,n;return t[0]!==e||t[1]!==o?(n=o?Df(oo(Of,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=n):n=t[2],r=n,r};import{c as Gf}from"react/compiler-runtime";import{jsx as pr,jsxs as Wf,Fragment as Vf}from"react/jsx-runtime";import{useLexicalComposerContext as es}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as Kf,$getTableColumnIndexFromTableCellNode as Zf,$getTableRowIndexFromTableCellNode as Yf,$insertTableColumn__EXPERIMENTAL as zf,$insertTableRow__EXPERIMENTAL as Xf,$isTableCellNode as Jf,$isTableNode as zl,getTableElement as qf,TableNode as Qf}from"@lexical/table";import{$findMatchingParent as e1,mergeRegister as t1}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Xl}from"lexical";import{useEffect as Jl,useMemo as o1,useRef as ql,useState as ro}from"react";import"react";import{createPortal as r1}from"react-dom";import{c as Hf}from"react/compiler-runtime";import{useEffect as jf,useRef as Uf}from"react";var $f="Expected a function",Ff=Math.max,Pf=Math.min;function Bf(t,e,o){let r,n,i=0,l,s=!1,a=!1,u,c,d,m=!0;if(typeof t!="function")throw new TypeError($f);e=e||0,typeof o=="object"&&(s=!!o.leading,a="maxWait"in o,u=a?Ff(o.maxWait||0,e):u,m="trailing"in o?!!o.trailing:m);function p(g){let _=r,S=l;return r=l=void 0,i=g,c=t.apply(S,_),c}function f(g){return i=g,d=setTimeout(b,e),s?p(g):c}function h(g){let _=g-n,S=g-i,L=e-_;return a?Pf(L,u-S):L}function x(g){let _=g-n,S=g-i;return n===void 0||_>=e||_<0||a&&S>=u}function b(){let g=Date.now();if(x(g))return N(g);d=setTimeout(b,h(g))}function N(g){return d=void 0,m&&r?p(g):(r=l=void 0,c)}function I(){d!==void 0&&clearTimeout(d),i=0,r=n=l=d=void 0}function C(){return d===void 0?c:N(Date.now())}function T(){let g=Date.now(),_=x(g);if(r=arguments,l=this,n=g,_){if(d===void 0)return f(n);if(a)return clearTimeout(d),d=setTimeout(b,e),p(n)}return d===void 0&&(d=setTimeout(b,e)),c}return T.cancel=I,T.flush=C,T}var Zl=Bf;function Yl(t,e,o){let r=Hf(6),n=Uf(null),i,l;r[0]!==t||r[1]!==o||r[2]!==e?(i=()=>(n.current=Zl(t,e,{maxWait:o}),()=>{n.current?.cancel()}),l=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=i,r[4]=l):(i=r[3],l=r[4]),jf(i,l);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...u)=>{let c=u;n.current&&n.current(...c)},r[5]=s):s=r[5],s}var Ql=20;function n1({anchorElem:t}){let[e]=es(),o=P(),[r,n]=ro(!1),[i,l]=ro(!1),[s,a]=ro(!1),[u,c]=ro({}),d=ql(new Set),m=ql(null),p=Yl(x=>{let{isOutside:b,tableDOMNode:N}=i1(x,o.editorConfig?.lexical);if(b){n(!1),l(!1);return}if(!N)return;m.current=N;let I=null,C=null,T=null;if(e.getEditorState().read(()=>{let g=Xl(N);if(Jf(g)){let _=e1(g,S=>zl(S));if(!zl(_))return;if(T=qf(_,e.getElementByKey(_.getKey())),T){let S=_.getChildrenSize(),L=_.getChildAtIndex(0)?.getChildrenSize(),k=Yf(g),v=Zf(g);k===S-1?I=g:v===L-1&&(C=g)}}},{editor:e}),T){let{bottom:g,height:_,left:S,right:L,width:k,y:v}=T.getBoundingClientRect(),{left:E,y:w}=t.getBoundingClientRect();I?(l(!1),n(!0),c({height:Ql,left:S-E,top:g-w+5,width:k})):C&&(l(!0),n(!1),c({height:_,left:L-E+5,top:v-w,width:Ql}))}},50,250),f=o1(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);Jl(()=>{if(s)return document.addEventListener("mousemove",p),()=>{n(!1),l(!1),document.removeEventListener("mousemove",p)}},[s,p]),Jl(()=>t1(e.registerMutationListener(Qf,x=>{e.getEditorState().read(()=>{let b=!1;for(let[N,I]of x)switch(I){case"created":{d.current.add(N),b=!0;break}case"destroyed":{d.current.delete(N),b=!0;break}default:break}if(b){f.disconnect();for(let N of d.current){let{tableElement:I}=Kf(N);f.observe(I)}a(d.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=x=>{e.update(()=>{m.current&&(Xl(m.current)?.selectEnd(),x?(Xf(),n(!1)):(zf(),l(!1)))})};return e?.isEditable()?Wf(Vf,{children:[r&&pr("button",{className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...u},type:"button"}),i&&pr("button",{className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...u},type:"button"})]}):null}function i1(t,e){let o=t.target;if(o&&o instanceof HTMLElement){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 ts(t){let e=Gf(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=es();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=r1(pr(n1,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as l1}from"react/compiler-runtime";import{jsx as fr,jsxs as s1}from"react/jsx-runtime";import{useLexicalComposerContext as a1}from"@lexical/react/LexicalComposerContext";import{TablePlugin as c1}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as u1,TableNode as d1}from"@lexical/table";import{mergeRegister as m1}from"@lexical/utils";import{formatDrawerSlug as p1,useEditDepth as f1}from"@payloadcms/ui";import{$getSelection as h1,$isRangeSelection as g1,COMMAND_PRIORITY_EDITOR as C1,createCommand as x1}from"lexical";import{createContext as b1,useContext as _1,useEffect as T1,useMemo as w1,useState as E1}from"react";import*as os from"react";var no=x1("OPEN_EMBED_DRAWER_COMMAND"),rs=b1({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function ns({children:t}){let[e,o]=E1({cellEditorConfig:null,cellEditorPlugins:null});return fr(rs.Provider,{value:w1(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var is=()=>{let t=l1(16),[e]=a1(),o=_1(rs),r=f1(),{fieldProps:n,uuid:i}=P(),{schemaPath:l}=n,s="lexical-table-create-"+i,a;t[0]!==r||t[1]!==s?(a=p1({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=a):a=t[2];let u=a,{toggleDrawer:c}=ue(u,!0),d;t[3]!==e||t[4]!==c?(d=()=>{if(!e.hasNodes([d1]))throw new Error("TablePlugin: TableNode is not registered on editor");return m1(e.registerCommand(no,()=>{let h;return h=null,e.getEditorState().read(()=>{let x=h1();g1(x)&&(h=x)}),h&&c(),!0},C1))},t[3]=e,t[4]=c,t[5]=d):d=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==c?(m=[o,e,c],t[6]=o,t[7]=e,t[8]=c,t[9]=m):m=t[9],T1(d,m);let p;t[10]!==e?(p=(h,x)=>{!x.columns||!x.rows||e.dispatchCommand(u1,{columns:String(x.columns),rows:String(x.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==u||t[13]!==l||t[14]!==p?(f=s1(os.Fragment,{children:[fr(Ye,{drawerSlug:u,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:l,schemaPathSuffix:"fields"}),fr(c1,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=u,t[13]=l,t[14]=p,t[15]=f):f=t[15],f};var R1=y({markdownTransformers:[Ml],nodes:[L1,k1,N1],plugins:[{Component:is,position:"normal"},{Component:Kl,position:"normal"},{Component:jl,position:"floatingAnchorElem"},{Component:ts,position:"floatingAnchorElem"}],providers:[ns],slashMenu:{groups:[V([{Icon:tr,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(no,{})}}])]},toolbarFixed:{groups:[pe([{ChildComponent:tr,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(no,{})}}])]}});import{$isNodeSelection as nh}from"lexical";import{jsx as hr,jsxs as S1}from"react/jsx-runtime";import"react";var gr=()=>S1("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:[hr("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"}),hr("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"}),hr("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 D1}from"react/jsx-runtime";import as from"bson-objectid";import{$applyNodeReplacement as A1}from"lexical";import*as cs from"react";import{jsx as I1}from"react/jsx-runtime";import{DecoratorBlockNode as y1}from"@lexical/react/LexicalDecoratorBlockNode.js";import ls from"bson-objectid";import{$applyNodeReplacement as v1}from"lexical";import"react";function Cr(t){return t.parentElement!=null&&t.parentElement.tagName==="LI"&&t.previousSibling===null&&t.getAttribute("aria-roledescription")==="checkbox"}function M1(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:ss({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||Cr(e),null}var wt=class extends y1{__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:M1,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new ls.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=ss({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return I1(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let e=document.createElement("img");return e.setAttribute("data-lexical-upload-id",String(this.__data?.value)),e.setAttribute("data-lexical-upload-relation-to",this.__data?.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 ss({data:t}){return t?.id||(t.id=new ls.default().toHexString()),v1(new wt({data:t}))}var O1=cs.lazy(()=>import("./component-VJVZFYZJ.js").then(t=>({default:t.UploadComponent})));function $1(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:Ae({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||Cr(e),null}var Te=class extends wt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:$1,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new as.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=Ae({data:o});return r.setFormat(e.format),r}decorate(){return D1(O1,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ae({data:t}){return t?.id||(t.id=new as.default().toHexString()),A1(new Te({data:t}))}function xr(t){return t instanceof Te}import{c as W1}from"react/compiler-runtime";import{jsx as V1}from"react/jsx-runtime";import{useLexicalComposerContext as K1}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Z1,mergeRegister as Y1}from"@lexical/utils";import{useConfig as z1}from"@payloadcms/ui";import{$getPreviousSelection as X1,$getSelection as J1,$isParagraphNode as q1,$isRangeSelection as Q1,COMMAND_PRIORITY_EDITOR as eh,createCommand as th}from"lexical";import{useEffect as oh}from"react";import{c as us}from"react/compiler-runtime";import{jsx as br}from"react/jsx-runtime";import{useLexicalComposerContext as ds}from"@lexical/react/LexicalComposerContext.js";import{toast as F1}from"@payloadcms/ui";import{$getNodeByKey as P1,COMMAND_PRIORITY_EDITOR as ms}from"lexical";import{useEffect as ps,useState as B1}from"react";var H1=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=P1(o);n&&n.replace(Ae({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(_r,{fields:null,relationTo:e,value:r})},j1=t=>{let e=us(13),{enabledCollectionSlugs:o}=t,[r]=ds(),[n,i]=B1(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:a,openListDrawer:u}=ft(l),c,d;e[2]!==r||e[3]!==u?(c=()=>r.registerCommand(Pe,h=>(i(h?.replace?h?.replace.nodeKey:null),u(),!0),ms),d=[r,u],e[2]=r,e[3]=u,e[4]=c,e[5]=d):(c=e[4],d=e[5]),ps(c,d);let m;e[6]!==s||e[7]!==r||e[8]!==n?(m=h=>{let{collectionSlug:x,docID:b}=h;s(),H1({editor:r,relationTo:x,replaceNodeKey:n,value:b})},e[6]=s,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,f;return e[10]!==a||e[11]!==p?(f=br(a,{onSelect:p}),e[10]=a,e[11]=p,e[12]=f):f=e[12],f},U1=()=>{let t=us(3),[e]=ds(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Pe,G1,ms),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ps(o,r),null},fs=t=>br(Lt,{...t,FallbackComponent:U1,uploads:!0,children:br(j1,{...t})});function G1(){return F1.error("No upload collections enabled"),!0}var _r=th("INSERT_UPLOAD_COMMAND"),hs=t=>{let e=W1(5),[o]=K1(),{config:r}=z1(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([Te]))throw new Error("UploadPlugin: UploadNode not registered on editor");return Y1(o.registerCommand(_r,a=>(o.update(()=>{let u=J1()||X1();if(Q1(u)){let c=Ae({data:{id:a.id,fields:a.fields,relationTo:a.relationTo,value:a.value}});Z1(c);let{focus:d}=u,m=d.getNode();q1(m)&&!m.__first&&(m.__prev||m.__next)&&m.remove()}}),!0),eh))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),oh(i,l);let s;return e[3]!==n?(s=V1(fs,{enabledCollectionSlugs:n.map(rh)}),e[3]=n,e[4]=s):s=e[4],s};function rh(t){let{slug:e}=t;return e}var ih=y({nodes:[Te],plugins:[{Component:hs,position:"normal"}],slashMenu:{groups:[V([{Icon:gr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Pe,{replace:!1})}}])]},toolbarFixed:{groups:[pe([{ChildComponent:gr,isActive:({selection:t})=>{if(!nh(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return xr(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Pe,{replace:!1})}}])]}});import{c as lh}from"react/compiler-runtime";import{jsx as wr}from"react/jsx-runtime";import{ShimmerEffect as sh}from"@payloadcms/ui";import{lazy as ah,Suspense as ch,useEffect as uh,useState as dh}from"react";var gs={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",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",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",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:"editor-upload"};var io={namespace:"lexical",theme:gs};function Cs({featureClientSchemaMap:t,field:e,schemaPath:o,unSanitizedEditorConfig:r}){for(let s of r.features)if(!s?.clientFeatureProps?.featureKey||s?.clientFeatureProps?.order===void 0||s?.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.");r.features=r.features.sort((s,a)=>s.clientFeatureProps.order-a.clientFeatureProps.order);let n=new Map;for(let s of r.features)n.set(s.clientFeatureProps.featureKey,s);let i=new Map,l=0;for(let s of r.features){let a=typeof s.feature=="function"?s.feature({featureClientSchemaMap:t,featureProviderMap:n,field:e,resolvedFeatures:i,schemaPath:o,unSanitizedEditorConfig:r}):s.feature;a.key=s.clientFeatureProps.featureKey,a.order=l,i.set(s.clientFeatureProps.featureKey,a),l++}return i}var xs=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}};if(!t?.size)return e;t.forEach(o=>{if(o.providers?.length&&(e.providers=e.providers.concat(o.providers)),o.enableFormats?.length&&e.enabledFormats.push(...o.enableFormats),o.nodes?.length)for(let r of o.nodes)e.nodes.push(r);if(o.plugins?.length&&o.plugins.forEach((r,n)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:r.Component,key:o.key+n,position:r.position})}),o.toolbarInline?.groups?.length)for(let r of o.toolbarInline.groups){let n=e.toolbarInline.groups.find(i=>i.key===r.key);n?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarInline?.groups.push(n)}if(o.toolbarFixed?.groups?.length)for(let r of o.toolbarFixed.groups){let n=e.toolbarFixed.groups.find(i=>i.key===r.key);n?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarFixed?.groups.push(n)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let r of o.slashMenu.groups){let n=e.slashMenu.groups.find(i=>i.key===r.key);n?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.slashMenu.groups.push(n)}}if(o.markdownTransformers?.length)for(let r of o.markdownTransformers)typeof r=="function"?e.markdownTransformers.push(r({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(r);e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0),e.toolbarFixed.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);return e};function Tr(t,e,o){return{admin:o,features:xs(t),lexical:e,resolvedFeatureMap:t}}var mh=ah(()=>import("./Field-LOLYH42M.js").then(t=>({default:t.RichText}))),ph=t=>{let e=lh(14),{admin:o,clientFeatures:r,featureClientSchemaMap:n,field:i,lexicalEditorConfig:l,schemaPath:s}=t,a;e[0]!==o?(a=o===void 0?{}:o,e[0]=o,e[1]=a):a=e[1];let u=a,c=l===void 0?io:l,[d,m]=dh(null),p,f;e[2]!==u||e[3]!==r||e[4]!==n||e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==s?(p=()=>{if(d)return;let x=[];for(let[I,C]of Object.entries(r))C.clientFeatureProvider&&x.push(C.clientFeatureProvider(C.clientFeatureProps));let b=c||io,N=Cs({featureClientSchemaMap:n,field:i,schemaPath:s??i.name,unSanitizedEditorConfig:{features:x,lexical:b}});m(Tr(N,b,u))},f=[c,u,d,r,n,i,s],e[2]=u,e[3]=r,e[4]=n,e[5]=i,e[6]=d,e[7]=c,e[8]=s,e[9]=p,e[10]=f):(p=e[9],f=e[10]),uh(p,f);let h;return e[11]!==d||e[12]!==t?(h=wr(ch,{fallback:wr(sh,{height:"35vh"}),children:d&&wr(mh,{...t,editorConfig:d})}),e[11]=d,e[12]=t,e[13]=h):h=e[13],h};function fh(...t){return t.filter(Boolean).join(" ")}var lo=new WeakMap;function bs(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function so(t,e){let o=lo.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=bs(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let a=bs(l);for(let u of r)a!==null&&u([a[0]-s[0],a[1]-s[1]],l)};t.addEventListener("touchstart",n),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:n,listeners:r,start:null},lo.set(t,o)}return o.listeners.add(e),()=>{hh(t,e)}}function hh(t,e){let o=lo.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(lo.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function gh(t,e){return so(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function Ch(t,e){return so(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function xh(t,e){return so(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function bh(t,e){return so(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}var O={DOM_ELEMENT_TYPE:1,DOM_TEXT_TYPE:3,NO_DIRTY_NODES:0,HAS_DIRTY_NODES:1,FULL_RECONCILE:2,IS_NORMAL:0,IS_TOKEN:1,IS_SEGMENTED:2,IS_INERT:3,IS_BOLD:1,IS_ITALIC:2,IS_STRIKETHROUGH:4,IS_UNDERLINE:8,IS_CODE:16,IS_SUBSCRIPT:32,IS_SUPERSCRIPT:64,IS_HIGHLIGHT:128,IS_DIRECTIONLESS:1,IS_UNMERGEABLE:2,IS_ALIGN_LEFT:1,IS_ALIGN_CENTER:2,IS_ALIGN_RIGHT:3,IS_ALIGN_JUSTIFY:4,IS_ALIGN_START:5,IS_ALIGN_END:6},_h=O.IS_BOLD|O.IS_ITALIC|O.IS_STRIKETHROUGH|O.IS_UNDERLINE|O.IS_CODE|O.IS_SUBSCRIPT|O.IS_SUPERSCRIPT|O.IS_HIGHLIGHT,Th="\xA0",wh=`
|
|
39
39
|
|
|
40
|
-
`,
|
|
40
|
+
`,_s="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",Ts="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",Eh=new RegExp("^[^"+Ts+"]*["+_s+"]"),kh=new RegExp("^[^"+_s+"]*["+Ts+"]"),Lh={bold:O.IS_BOLD,code:O.IS_CODE,highlight:O.IS_HIGHLIGHT,italic:O.IS_ITALIC,strikethrough:O.IS_STRIKETHROUGH,subscript:O.IS_SUBSCRIPT,superscript:O.IS_SUPERSCRIPT,underline:O.IS_UNDERLINE},Nh={directionless:O.IS_DIRECTIONLESS,unmergeable:O.IS_UNMERGEABLE},Rh={center:O.IS_ALIGN_CENTER,end:O.IS_ALIGN_END,justify:O.IS_ALIGN_JUSTIFY,left:O.IS_ALIGN_LEFT,right:O.IS_ALIGN_RIGHT,start:O.IS_ALIGN_START},Sh={[O.IS_ALIGN_CENTER]:"center",[O.IS_ALIGN_END]:"end",[O.IS_ALIGN_JUSTIFY]:"justify",[O.IS_ALIGN_LEFT]:"left",[O.IS_ALIGN_RIGHT]:"right",[O.IS_ALIGN_START]:"start"},Ih={normal:O.IS_NORMAL,segmented:O.IS_SEGMENTED,token:O.IS_TOKEN},yh={[O.IS_NORMAL]:"normal",[O.IS_SEGMENTED]:"segmented",[O.IS_TOKEN]:"token"};import{c as vh}from"react/compiler-runtime";import{jsx as Mh}from"react/jsx-runtime";import"react";var Dh=()=>{let t=vh(2),{EditButton:e}=de(),o;return t[0]!==e?(o=e?Mh(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Ah}from"react/compiler-runtime";import{jsx as Oh}from"react/jsx-runtime";import"react";var $h=()=>{let t=Ah(2),{RemoveButton:e}=de(),o;return t[0]!==e?(o=e?Oh(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Fh}from"react/compiler-runtime";import{jsx as Ph}from"react/jsx-runtime";import"react";var Bh=()=>{let t=Fh(2),{Label:e}=de(),o;return t[0]!==e?(o=e?Ph(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Hh}from"react/compiler-runtime";import{jsx as jh}from"react/jsx-runtime";import"react";var Uh=t=>{let e=Hh(3),{children:o}=t,{InlineBlockContainer:r}=de(),n;return e[0]!==r||e[1]!==o?(n=r?jh(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as Gh}from"react/compiler-runtime";import{jsx as Wh}from"react/jsx-runtime";import"react";var Vh=t=>{let e=Gh(6),{children:o,editButton:r,Label:n,removeButton:i}=t,{BlockCollapsible:l}=Ne(),s;return e[0]!==l||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==i?(s=l?Wh(l,{editButton:r,Label:n,removeButton:i,children:o}):null,e[0]=l,e[1]=n,e[2]=o,e[3]=r,e[4]=i,e[5]=s):s=e[5],s};import{c as Kh}from"react/compiler-runtime";import{jsx as Zh}from"react/jsx-runtime";import"react";var Yh=()=>{let t=Kh(2),{EditButton:e}=Ne(),o;return t[0]!==e?(o=e?Zh(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as zh}from"react/compiler-runtime";import{jsx as Xh}from"react/jsx-runtime";import"react";var Jh=()=>{let t=zh(2),{RemoveButton:e}=Ne(),o;return t[0]!==e?(o=e?Xh(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};export{lt as $createAutoLinkNode,At as $createBlockNode,uo as $createInlineBlockNode,fe as $createLinkNode,ve as $createRelationshipNode,Ae as $createUploadNode,ge as $isAutoLinkNode,Dt as $isBlockNode,mo as $isInlineBlockNode,G as $isLinkNode,Ko as $isRelationshipNode,xr as $isUploadNode,Os as AlignFeatureClient,he as AutoLinkNode,Vh as BlockCollapsible,Yh as BlockEditButton,me as BlockNode,Jh as BlockRemoveButton,js as BlockquoteFeatureClient,Ba as BlocksFeatureClient,lc as BoldFeatureClient,Es as CAN_USE_DOM,Bd as ChecklistFeatureClient,Nh as DETAIL_TYPE_TO_DETAIL,wh as DOUBLE_LINE_BREAK,Sh as ELEMENT_FORMAT_TO_TYPE,Rh as ELEMENT_TYPE_TO_FORMAT,Ss as ENABLE_SLASH_MENU_COMMAND,ws as EditorConfigProvider,Ye as FieldsDrawer,Ip as FixedToolbarFeatureClient,Uc as HeadingFeatureClient,iu as HorizontalRuleFeatureClient,_h as IS_ALL_FORMATTING,du as IndentFeatureClient,Uh as InlineBlockContainer,Dh as InlineBlockEditButton,Bh as InlineBlockLabel,co as InlineBlockNode,$h as InlineBlockRemoveButton,dc as InlineCodeFeatureClient,Hp as InlineToolbarFeatureClient,hc as ItalicFeatureClient,kh as LTR_REGEX,sm as LexicalPluginToLexicalFeatureClient,kd as LinkFeatureClient,J as LinkNode,Th as NON_BREAKING_SPACE,O as NodeFormat,Zd as OrderedListFeatureClient,hm as ParagraphFeatureClient,Ns as Point,Eh as RTL_REGEX,Is as Rect,ep as RelationshipFeatureClient,xe as RelationshipNode,ph as RichTextField,pm as SlateToLexicalFeatureClient,_c as StrikethroughFeatureClient,kc as SubscriptFeatureClient,Sc as SuperscriptFeatureClient,Ih as TEXT_MODE_TO_TYPE,Lh as TEXT_TYPE_TO_FORMAT,yh as TEXT_TYPE_TO_MODE,ie as TOGGLE_LINK_COMMAND,R1 as TableFeatureClient,Ja as TestRecorderFeatureClient,ht as ToolbarButton,Me as ToolbarDropdown,oc as TreeViewFeatureClient,Dc as UnderlineFeatureClient,tm as UnorderedListFeatureClient,ih as UploadFeatureClient,Te as UploadNode,bh as addSwipeDownListener,gh as addSwipeLeftListener,Ch as addSwipeRightListener,xh as addSwipeUpListener,Ro as createBlockNode,y as createClientFeature,io as defaultEditorLexicalConfig,er as getDOMRangeRect,ys as getEnabledNodes,Be as getSelectedNode,Ls as isHTMLElement,Rs as isPoint,fh as joinClasses,Tr as sanitizeClientEditorConfig,xs as sanitizeClientFeatures,zt as setFloatingElemPosition,Ut as setFloatingElemPositionForLinkEditor,V as slashMenuBasicGroupWithItems,pe as toolbarAddDropdownGroupWithItems,Io as toolbarFeatureButtonsGroupWithItems,K as toolbarFormatGroupWithItems,X as toolbarTextDropdownGroupWithItems,Ne as useBlockComponentContext,P as useEditorConfigContext,de as useInlineBlockComponentContext,ks as useLexicalDocumentDrawer,ue as useLexicalDrawer,ft as useLexicalListDrawer};
|
|
41
41
|
//# sourceMappingURL=index.js.map
|