@payloadcms/richtext-lexical 3.0.2 → 3.0.3-canary.5abb7d5
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/Field-CO3ZH6ER.js +2 -0
- package/dist/exports/client/Field-CO3ZH6ER.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-XOQBVKA3.js +2 -0
- package/dist/exports/client/RelationshipComponent-XOQBVKA3.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-C7S3V4EB.js → chunk-DOK5S7LE.js} +2 -2
- package/dist/exports/client/chunk-DOK5S7LE.js.map +7 -0
- package/dist/exports/client/{chunk-U7O7EYCP.js → chunk-FBDJRK3A.js} +2 -2
- package/dist/exports/client/{chunk-U7O7EYCP.js.map → chunk-FBDJRK3A.js.map} +2 -2
- package/dist/exports/client/chunk-LMCV6WAN.js +12 -0
- package/dist/exports/client/chunk-LMCV6WAN.js.map +7 -0
- package/dist/exports/client/chunk-ZTAS32RX.js +2 -0
- package/dist/exports/client/{chunk-MI5HS4QX.js.map → chunk-ZTAS32RX.js.map} +3 -3
- package/dist/exports/client/{component-H3EYQ5KG.js → component-D6PKVJ2K.js} +2 -2
- package/dist/exports/client/component-D6PKVJ2K.js.map +7 -0
- package/dist/exports/client/componentInline-XC7SFQPN.js +2 -0
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +11 -11
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/server/ast/mdx.d.ts.map +1 -1
- package/dist/exports/server/ast/mdx.js +6 -0
- package/dist/exports/server/ast/mdx.js.map +1 -1
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blockquote/server/index.js +2 -1
- package/dist/features/blockquote/server/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 +2 -0
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +2 -0
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.d.ts.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.js +2 -1
- package/dist/features/converters/html/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/html/converter/defaultConverters.d.ts +1 -1
- package/dist/features/converters/html/converter/defaultConverters.d.ts.map +1 -1
- package/dist/features/converters/html/converter/defaultConverters.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +23 -17
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +4 -2
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/utils/debounce.d.ts.map +1 -1
- package/dist/features/experimental_table/client/utils/debounce.js +3 -0
- package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
- package/dist/features/experimental_table/client/utils/useDebounce.d.ts +1 -5
- package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +1 -1
- package/dist/features/experimental_table/client/utils/useDebounce.js +40 -10
- package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +2 -1
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/lists/checklist/server/index.js.map +1 -1
- package/dist/features/lists/orderedList/server/index.js.map +1 -1
- package/dist/features/lists/unorderedList/server/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +1 -3
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js +3 -3
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts +2 -2
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +51 -69
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +31 -51
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +152 -62
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +4 -2
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +8 -20
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/typesClient.d.ts +39 -36
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts +2 -2
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/Field.d.ts +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +2 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/rscEntry.js +1 -1
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +1 -0
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +2 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +139 -88
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +2 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +4 -7
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +8 -14
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +1 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +4 -1
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/utilities/jsx/jsx.d.ts.map +1 -1
- package/dist/utilities/jsx/jsx.js +1 -0
- package/dist/utilities/jsx/jsx.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-IS3XMKMO.js +0 -2
- package/dist/exports/client/Field-IS3XMKMO.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-2RT3YXUT.js +0 -2
- package/dist/exports/client/RelationshipComponent-2RT3YXUT.js.map +0 -7
- package/dist/exports/client/chunk-C7S3V4EB.js.map +0 -7
- package/dist/exports/client/chunk-CBUZKU7S.js +0 -12
- package/dist/exports/client/chunk-CBUZKU7S.js.map +0 -7
- package/dist/exports/client/chunk-MI5HS4QX.js +0 -2
- package/dist/exports/client/component-H3EYQ5KG.js.map +0 -7
- package/dist/exports/client/componentInline-ZGO3K4TA.js +0 -2
- /package/dist/exports/client/{componentInline-ZGO3K4TA.js.map → componentInline-XC7SFQPN.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use client";import{a as be,c as eo,d as to,e as oo}from"./chunk-
|
|
1
|
+
"use client";import{a as be,c as eo,d as to,e as oo}from"./chunk-FBDJRK3A.js";import{a as Be,b as pt,c as ft,d as ht}from"./chunk-XCEM47RI.js";import{a as je,b as Ge,c as Ue,d as ro}from"./chunk-ZTAS32RX.js";import{a as He,b as gt,c as We,d as Ve,e as Ke,f as no}from"./chunk-DOK5S7LE.js";import{a as ae}from"./chunk-2CYU43GM.js";import{a as cs}from"./chunk-5PBXL4HT.js";import{a as as,b as ur,d as dr,e as mr,f as pr,g as us,h as ds,i as ms,k as ps,m as fs,n as hs}from"./chunk-LMCV6WAN.js";import{a as ss,b as B}from"./chunk-CUIBIFW2.js";function K(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{$isElementNode as _e,$isRangeSelection as xt,FORMAT_ELEMENT_COMMAND as bt}from"lexical";import{jsx as io,jsxs as gs}from"react/jsx-runtime";import"react";var fr=()=>gs("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:[io("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),io("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),io("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as lo,jsxs as Cs}from"react/jsx-runtime";import"react";var hr=()=>Cs("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:[lo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),lo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),lo("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as so,jsxs as xs}from"react/jsx-runtime";import"react";var Ct=()=>xs("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:[so("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),so("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),so("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as ao,jsxs as bs}from"react/jsx-runtime";import"react";var gr=()=>bs("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:[ao("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ao("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ao("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:d})=>{let c=t({featureClientSchemaMap:n,featureProviderMap:i,field:l,props:o,resolvedFeatures:s,schemaPath:a,unSanitizedEditorConfig:d});return c.sanitizedClientFeatureProps===null&&(c.sanitizedClientFeatureProps=o),c};else{let n={...t};n.sanitizedClientFeatureProps=o,r.feature=n}return r};var Cr=t=>({type:"dropdown",ChildComponent:Ct,items:t,key:"align",order:30});var xr=[Cr([{ChildComponent:Ct,isActive:({selection:t})=>{if(!xt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(bt,"left")},order:1},{ChildComponent:fr,isActive:({selection:t})=>{if(!xt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(bt,"center")},order:2},{ChildComponent:gr,isActive:({selection:t})=>{if(!xt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(bt,"right")},order:3},{ChildComponent:hr,isActive:({selection:t})=>{if(!xt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(bt,"justify")},order:4}])],_s=y({toolbarFixed:{groups:xr},toolbarInline:{groups:xr}});import{$createQuoteNode as Nr,$isQuoteNode as wr,QuoteNode as ks}from"@lexical/rich-text";import{$setBlocksType as Lr}from"@lexical/selection";import{$getSelection as Rr,$isRangeSelection as Ns}from"lexical";import{jsx as br}from"react/jsx-runtime";import"react";var co=()=>br("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:br("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 _r}from"react/jsx-runtime";import"react";var ze=()=>_r("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:_r("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 J=t=>({type:"dropdown",ChildComponent:ze,items:t,key:"text",order:25});import{$createQuoteNode as Ts,$isQuoteNode as Tr,QuoteNode as Es}from"@lexical/rich-text";import{$createLineBreakNode as ws}from"lexical";var Er={type:"element",dependencies:[Es],export:(t,e)=>{if(!Tr(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(_r(i)){i.splice(i.getChildrenSize(),0,[Es(),...e]),i.select(0,0),t.remove();return}}let n=_s();n.append(...e),t.replace(n),n.select(0,0)}};var wr=[J([{ChildComponent:co,isActive:({selection:t})=>{if(!Ns(t))return!1;for(let e of t.getNodes())if(!Er(e)&&!Er(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Lr();kr(e,()=>Nr())})},order:20}])],ks=y({markdownTransformers:[Tr],nodes:[ws],slashMenu:{groups:[K([{Icon:co,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Lr();kr(e,()=>Nr())})}}])]},toolbarFixed:{groups:wr},toolbarInline:{groups:wr}});import{getTranslation as Nt}from"@payloadcms/translations";import{jsx as uo,jsxs as Ls}from"react/jsx-runtime";import"react";var xt=()=>Ls("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:[uo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),uo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),uo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as Rr}from"react/jsx-runtime";import"react";var bt=()=>Rr("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:Rr("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 ra}from"react/jsx-runtime";import na from"bson-objectid";import"react";import{DecoratorBlockNode as Rs}from"@lexical/react/LexicalDecoratorBlockNode.js";import Ss from"bson-objectid";import{deepCopyObjectSimple as Is}from"payload/shared";var Xe=class extends Rs{__fields;constructor({fields:e,format:o,key:r}){super(o,r),this.__fields=e}static clone(e){return new this({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}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e){let o=Is(e),r=this.getWritable();r.__fields=o}};function ys(t){return new Xe({fields:{...t,id:t?.id||new Ss.default().toHexString()}})}import{jsx as z,jsxs as Tt,Fragment as $s}from"react/jsx-runtime";import{Button as vr,Collapsible as Ps,Drawer as Bs,EditDepthProvider as Hs,ErrorPill as js,Form as Gs,formatDrawerSlug as Ws,FormSubmit as Us,Pill as Vs,RenderFields as Ks,SectionTitle as zs,useDocumentInfo as Mr,useEditDepth as Zs,useFormSubmitted as Xs,useServerFunctions as Ys,useTranslation as Js}from"@payloadcms/ui";import{abortAndIgnore as mo}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as qs,reduceFieldsToValues as Dr}from"payload/shared";import po,{useCallback as fo,useEffect as Or,useMemo as Ye,useRef as Qs}from"react";import{useLexicalComposerContext as ea}from"@lexical/react/LexicalComposerContext";import{getTranslation as ta}from"@payloadcms/translations";import{$getNodeByKey as ho}from"lexical";import{v4 as oa}from"uuid";import{c as vs}from"react/compiler-runtime";import{jsx as _t,jsxs as Ms}from"react/jsx-runtime";import{RenderFields as Ds,useFormSubmitted as Os}from"@payloadcms/ui";import As,{createContext as Fs}from"react";var Sr=Fs({initialState:!1}),ve=()=>As.useContext(Sr),Ir=t=>{let e=vs(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:s,initialState:a,nodeKey:d,RemoveButton:c}=t,m=Os()&&l>0,p,f;e[0]!==r||e[1]!==l||e[2]!==m?(f=T=>_t(r,{editButton:T.editButton,errorCount:l,fieldHasErrors:m,Label:T.Label,removeButton:T.removeButton,children:T.children}),e[0]=r,e[1]=l,e[2]=m,e[3]=f):f=e[3],p=f;let h=p,g;return e[4]!==n||e[5]!==h||e[6]!==i||e[7]!==a||e[8]!==d||e[9]!==c||e[10]!==o||e[11]!==s?(g=n?Ms(Sr.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:a,nodeKey:d,RemoveButton:c},children:[n,_t(o,{})]}):_t(h,{children:_t(Ds,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=n,e[5]=h,e[6]=i,e[7]=a,e[8]=d,e[9]=c,e[10]=o,e[11]=s,e[12]=g):g=e[12],g};function yr({fields:t}){for(let e in t){let o=t[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var oe="lexical-block",Ar=t=>{let{formData:e,nodeKey:o}=t,r=Xs(),{id:n,collectionSlug:i,globalSlug:l}=Mr(),{fieldProps:{featureClientSchemaMap:s,field:a,initialLexicalFormState:d,permissions:c,readOnly:u,schemaPath:m},uuid:p}=B(),f=Qs(new AbortController),h=Zs(),[g,T]=po.useState(0),M=Ws({slug:`lexical-blocks-create-${p}-${e.id}`,depth:h}),{toggleDrawer:O}=xe(M,!0),{getDocPreferences:C,setDocFieldPreferences:E}=Mr(),[x]=ea(),{getFormState:N}=Ys(),S=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}.fields`,[w,k]=po.useState(d?.[e.id]?.formState?{...d?.[e.id]?.formState,blockName:{initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName}}:!1);Or(()=>{let U=new AbortController;return e&&!w&&(async()=>{let{state:X}=await N({id:n,collectionSlug:i,data:e,docPermissions:{fields:!0},docPreferences:await C(),globalSlug:l,operation:"update",renderAllFields:!0,schemaPath:S,signal:U.signal});X&&(X.blockName={initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName},k(X))})(),()=>{mo(U)}},[N,S,n,e,w,i,l,C]);let[R,b]=po.useState(d?.[e.id]?.collapsed??!1),_=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}`,D=s.blocks[_][0].blocks[0],{i18n:v,t:A}=Js(),H=fo(async({formState:U,submit:ee})=>{mo(f.current);let X=new AbortController;f.current=X;let{state:Y}=await N({id:n,collectionSlug:i,docPermissions:{fields:!0},docPreferences:await C(),formState:U,globalSlug:l,operation:"update",schemaPath:S,signal:X.signal});if(!Y)return U;Y.blockName=U.blockName;let te=Dr(yr({fields:qs(Y)}),!0);if(setTimeout(()=>{x.update(()=>{let Ce=ho(o);if(Ce&&Et(Ce)){let ye={...te,blockType:e.blockType};Ce.setFields(ye)}})},0),ee){let Ce=0;for(let ye of Object.values(Y))ye?.valid===!1&&Ce++;T(Ce)}return Y},[N,n,i,C,l,S,e.blockType,x,o]);Or(()=>()=>{mo(f.current)},[]);let $=fo(()=>{x.update(()=>{ho(o)?.remove()})},[x,o]),j=w?._components?.customComponents?.BlockLabel,Q=w?._components?.customComponents?.Block,W=D?.labels?.singular?ta(D.labels.singular,v):D?.slug,G=fo(U=>{C().then(ee=>{let Y=ee?.fields[a.name]?.collapsed,te=Y&&Y?.length?Y:[];U?te.includes(e.id)||te.push(e.id):te.includes(e.id)&&te.splice(te.indexOf(e.id),1),E(a.name,{collapsed:te,hello:"hi"})})},[C,a.name,E,e.id]),se=Ye(()=>()=>z(vr,{buttonStyle:"icon-label",className:`${oe}__editButton`,disabled:u,el:"div",icon:"edit",onClick:()=>{O()},round:!0,size:"small",tooltip:A("lexical:blocks:inlineBlocks:edit",{label:W})}),[W,u,A,O]),Ie=Ye(()=>()=>z(vr,{buttonStyle:"icon-label",className:`${oe}__removeButton`,disabled:a?.admin?.readOnly||!1,icon:"x",onClick:U=>{U.preventDefault(),$()},round:!0,tooltip:"Remove Block"}),[a?.admin?.readOnly,$]),ge=Ye(()=>({children:U,editButton:ee,errorCount:X,fieldHasErrors:Y,Label:te,removeButton:Ce})=>z("div",{className:oe+" "+oe+"-"+e.blockType,children:z(Ps,{className:[`${oe}__row`,Y?`${oe}__row--has-errors`:`${oe}__row--no-errors`].join(" "),collapsibleStyle:Y?"error":"default",header:Tt("div",{className:`${oe}__block-header`,children:[te??j?te??j:Tt("div",{children:[z(Vs,{className:`${oe}__block-pill ${oe}__block-pill-${e?.blockType}`,pillStyle:"white",children:W}),z(zs,{path:"blockName",readOnly:a?.admin?.readOnly||!1}),Y&&z(js,{count:X??0,i18n:v,withMessage:!0})]}),Tt("div",{children:[Q&&ee!==!1||!Q&&ee?z(se,{}):null,Ce!==!1&&x.isEditable()?z(Ie,{}):null]})]}),isCollapsed:R,onToggle:ye=>{G(ye),b(ye)},children:U},0)}),[Q,j,se,Ie,W,x,e.blockType,v,R,G,a?.admin?.readOnly]),ut=Ye(()=>()=>z(Hs,{children:z(Bs,{className:"",slug:M,title:A(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:W??A("lexical:blocks:inlineBlocks:label")}),children:w?Tt($s,{children:[z(Ks,{fields:D.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:S,permissions:c,readOnly:!1}),z(Us,{children:A("fields:saveChanges")})]}):null})}),[w,M,W,A,D.fields,S,c]);return Ye(()=>w?z(Gs,{beforeSubmit:[async({formState:U})=>await H({formState:U,submit:!0})],fields:D.fields,initialState:w,onChange:[H],onSubmit:U=>{let ee=Dr(U);ee.blockType=e.blockType,x.update(()=>{let X=ho(o);X&&Et(X)&&X.setFields(ee)}),O()},submitted:r,uuid:oa(),children:z(Ir,{baseClass:oe,BlockDrawer:ut,Collapsible:ge,CustomBlock:Q,EditButton:se,errorCount:g,formSchema:D.fields,initialState:w,nodeKey:o,RemoveButton:Ie})}):null,[ge,ut,Q,Ie,se,x,g,O,D.fields,w,o,H,r])};var ae=class extends Xe{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=wt(e.fields);return o.setFormat(e.format),o}decorate(e,o){return ra(Ar,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function wt(t){return new ae({fields:{...t,id:t?.id||new na.default().toHexString()}})}function Et(t){return t instanceof ae}import{createCommand as Fr}from"lexical";var Je=Fr("INSERT_BLOCK_COMMAND"),qe=Fr("INSERT_INLINE_BLOCK_COMMAND");import{c as ia}from"react/compiler-runtime";import{useLexicalComposerContext as la}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as sa,$wrapNodeInElement as aa,mergeRegister as ca}from"@lexical/utils";import{formatDrawerSlug as ua,useEditDepth as da}from"@payloadcms/ui";import{$createParagraphNode as ma,$getNodeByKey as pa,$getPreviousSelection as fa,$getSelection as ha,$insertNodes as ga,$isParagraphNode as $r,$isRangeSelection as Ca,$isRootOrShadowRoot as xa,COMMAND_PRIORITY_EDITOR as Pr}from"lexical";import{useEffect as ba,useState as _a}from"react";var Br=()=>{let t=ia(10),[e]=la(),[o,r]=_a(null),{uuid:n}=B(),i=da(),l="lexical-inlineBlocks-create-"+n,s;t[0]!==l||t[1]!==i?(s=ua({slug:l,depth:i}),t[0]=l,t[1]=i,t[2]=s):s=t[2];let a=s,{toggleDrawer:d}=xe(a,!0),c;t[3]!==e||t[4]!==o?(c=()=>{if(!e.hasNodes([ae]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return ca(e.registerCommand(Je,m=>(e.update(()=>{let p=ha()||fa();if(Ca(p)){let f=wt(m);sa(f);let{focus:h}=p,g=h.getNode();$r(g)&&g.getTextContentSize()===0&&g.getParentOrThrow().getChildren().filter(T=>$r(T)).length>1&&g.remove()}}),!0),Pr),e.registerCommand(qe,m=>{if(o){let f=pa(o);return!f||!oo(f)?!1:(f.setFields(m),r(null),!0)}let p=to(m);return ga([p]),xa(p.getParentOrThrow())&&aa(p,ma).selectEnd(),!0},Pr))},t[3]=e,t[4]=o,t[5]=c):c=t[5];let u;return t[6]!==e||t[7]!==o||t[8]!==d?(u=[e,o,d],t[6]=e,t[7]=o,t[8]=d,t[9]=u):u=t[9],ba(c,u),null};var Ta=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,u])=>u[0]),s=Object.entries(i).filter(([c])=>c.startsWith(n+".")&&!c.replace(n+".","").includes(".")).map(([c,u])=>u[0]),a=l.map(c=>c.blocks[0]),d=s.map(c=>c.blocks[0]);return{nodes:[ae,eo],plugins:[{Component:Br,position:"normal"}],sanitizedClientFeatureProps:e,slashMenu:{groups:[a?.length?{items:a.map(c=>({Icon:xt,key:"block-"+c.slug,keywords:["block","blocks",c.slug],label:({i18n:u})=>c?.labels?.singular?Nt(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(Je,{blockName:"",blockType:c.slug})}})),key:"blocks",label:({i18n:c})=>c.t("lexical:blocks:label")}:null,d?.length?{items:d.map(c=>({Icon:bt,key:"inlineBlocks-"+c.slug,keywords:["inlineBlock","inline block",c.slug],label:({i18n:u})=>c?.labels?.singular?Nt(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(qe,{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:xt,items:a.map((c,u)=>({ChildComponent:xt,isActive:void 0,key:"block-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Nt(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Je,{blockName:"",blockType:c.slug})},order:u})),key:"blocks",order:20}:null,d?.length?{type:"dropdown",ChildComponent:bt,items:d.map((c,u)=>({ChildComponent:bt,isActive:void 0,key:"inlineBlock-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Nt(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(qe,{blockName:"",blockType:c.slug})},order:u})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as Ea}from"react/compiler-runtime";import{jsx as Ne,jsxs as xo}from"react/jsx-runtime";import{useLexicalComposerContext as wa}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Na,$createTextNode as ka,$getRoot as La}from"lexical";import*as Wr from"react";import{useCallback as we,useEffect as go,useLayoutEffect as Hr,useRef as Co,useState as kt}from"react";var Ra=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)},Sa=(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)},Ia=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(Tr(i)){i.splice(i.getChildrenSize(),0,[ws(),...e]),i.select(0,0),t.remove();return}}let n=Ts();n.append(...e),t.replace(n),n.select(0,0)}};var kr=[J([{ChildComponent:co,isActive:({selection:t})=>{if(!Ns(t))return!1;for(let e of t.getNodes())if(!wr(e)&&!wr(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Rr();Lr(e,()=>Nr())})},order:20}])],Ls=y({markdownTransformers:[Er],nodes:[ks],slashMenu:{groups:[K([{Icon:co,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Rr();Lr(e,()=>Nr())})}}])]},toolbarFixed:{groups:kr},toolbarInline:{groups:kr}});import{getTranslation as Lt}from"@payloadcms/translations";import{jsx as uo,jsxs as Rs}from"react/jsx-runtime";import"react";var _t=()=>Rs("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:[uo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),uo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),uo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as Sr}from"react/jsx-runtime";import"react";var Tt=()=>Sr("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:Sr("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 na}from"react/jsx-runtime";import ia from"bson-objectid";import"react";import{DecoratorBlockNode as Ss}from"@lexical/react/LexicalDecoratorBlockNode.js";import Is from"bson-objectid";import{deepCopyObjectSimple as ys}from"payload/shared";var Ze=class extends Ss{__fields;constructor({fields:e,format:o,key:r}){super(o,r),this.__fields=e}static clone(e){return new this({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=vs(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}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e){let o=ys(e),r=this.getWritable();r.__fields=o}};function vs(t){return new Ze({fields:{...t,id:t?.id||new Is.default().toHexString()}})}import{jsx as z,jsxs as wt,Fragment as Ps}from"react/jsx-runtime";import{Button as Mr,Collapsible as Bs,Drawer as Hs,EditDepthProvider as js,ErrorPill as Gs,Form as Us,formatDrawerSlug as Ws,FormSubmit as Vs,Pill as Ks,RenderFields as zs,SectionTitle as Zs,useDocumentInfo as Dr,useEditDepth as Xs,useFormSubmitted as Ys,useServerFunctions as Js,useTranslation as qs}from"@payloadcms/ui";import{abortAndIgnore as mo}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as Qs,reduceFieldsToValues as Ar}from"payload/shared";import po,{useCallback as fo,useEffect as Or,useMemo as Xe,useRef as ea}from"react";import{useLexicalComposerContext as ta}from"@lexical/react/LexicalComposerContext";import{getTranslation as oa}from"@payloadcms/translations";import{$getNodeByKey as ho}from"lexical";import{v4 as ra}from"uuid";import{c as Ms}from"react/compiler-runtime";import{jsx as Et,jsxs as Ds}from"react/jsx-runtime";import{RenderFields as As,useFormSubmitted as Os}from"@payloadcms/ui";import Fs,{createContext as $s}from"react";var Ir=$s({initialState:!1}),ve=()=>Fs.useContext(Ir),yr=t=>{let e=Ms(13),{BlockDrawer:o,Collapsible:r,CustomBlock:n,EditButton:i,errorCount:l,formSchema:s,initialState:a,nodeKey:d,RemoveButton:c}=t,m=Os()&&l>0,p,f;e[0]!==r||e[1]!==l||e[2]!==m?(f=E=>Et(r,{editButton:E.editButton,errorCount:l,fieldHasErrors:m,Label:E.Label,removeButton:E.removeButton,children:E.children}),e[0]=r,e[1]=l,e[2]=m,e[3]=f):f=e[3],p=f;let h=p,g;return e[4]!==n||e[5]!==h||e[6]!==i||e[7]!==a||e[8]!==d||e[9]!==c||e[10]!==o||e[11]!==s?(g=n?Ds(Ir.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:a,nodeKey:d,RemoveButton:c},children:[n,Et(o,{})]}):Et(h,{children:Et(As,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=n,e[5]=h,e[6]=i,e[7]=a,e[8]=d,e[9]=c,e[10]=o,e[11]=s,e[12]=g):g=e[12],g};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 oe="lexical-block",Fr=t=>{let{formData:e,nodeKey:o}=t,r=Ys(),{id:n,collectionSlug:i,globalSlug:l}=Dr(),{fieldProps:{featureClientSchemaMap:s,field:a,initialLexicalFormState:d,permissions:c,readOnly:u,schemaPath:m},uuid:p}=B(),f=ea(new AbortController),h=Xs(),[g,E]=po.useState(0),M=Ws({slug:`lexical-blocks-create-${p}-${e.id}`,depth:h}),{toggleDrawer:D}=ae(M,!0),{getDocPreferences:x,setDocFieldPreferences:T}=Dr(),[C]=ta(),{getFormState:_}=Js(),N=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}.fields`,[k,L]=po.useState(d?.[e.id]?.formState?{...d?.[e.id]?.formState,blockName:{initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName}}:!1);Or(()=>{let U=new AbortController;return e&&!k&&(async()=>{let{state:X}=await _({id:n,collectionSlug:i,data:e,docPermissions:{fields:!0},docPreferences:await x(),globalSlug:l,operation:"update",renderAllFields:!0,schemaPath:N,signal:U.signal});X&&(X.blockName={initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName},L(X))})(),()=>{mo(U)}},[_,N,n,e,k,i,l,x]);let[S,b]=po.useState(d?.[e.id]?.collapsed??!1),w=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}`,A=s.blocks[w][0].blocks[0],{i18n:v,t:O}=qs(),H=fo(async({formState:U,submit:ee})=>{mo(f.current);let X=new AbortController;f.current=X;let{state:Y}=await _({id:n,collectionSlug:i,docPermissions:{fields:!0},docPreferences:await x(),formState:U,globalSlug:l,operation:"update",schemaPath:N,signal:X.signal});if(!Y)return U;Y.blockName=U.blockName;let te=Ar(vr({fields:Qs(Y)}),!0);if(setTimeout(()=>{C.update(()=>{let xe=ho(o);if(xe&&kt(xe)){let ye={...te,blockType:e.blockType};xe.setFields(ye)}})},0),ee){let xe=0;for(let ye of Object.values(Y))ye?.valid===!1&&xe++;E(xe)}return Y},[_,n,i,x,l,N,e.blockType,C,o]);Or(()=>()=>{mo(f.current)},[]);let $=fo(()=>{C.update(()=>{ho(o)?.remove()})},[C,o]),W=k?._components?.customComponents?.BlockLabel,Q=k?._components?.customComponents?.Block,G=A?.labels?.singular?oa(A.labels.singular,v):A?.slug,j=fo(U=>{x().then(ee=>{let Y=ee?.fields[a.name]?.collapsed,te=Y&&Y?.length?Y:[];U?te.includes(e.id)||te.push(e.id):te.includes(e.id)&&te.splice(te.indexOf(e.id),1),T(a.name,{collapsed:te,hello:"hi"})})},[x,a.name,T,e.id]),se=Xe(()=>()=>z(Mr,{buttonStyle:"icon-label",className:`${oe}__editButton`,disabled:u,el:"div",icon:"edit",onClick:()=>{D()},round:!0,size:"small",tooltip:O("lexical:blocks:inlineBlocks:edit",{label:G})}),[G,u,O,D]),Ie=Xe(()=>()=>z(Mr,{buttonStyle:"icon-label",className:`${oe}__removeButton`,disabled:a?.admin?.readOnly||!1,icon:"x",onClick:U=>{U.preventDefault(),$()},round:!0,tooltip:"Remove Block"}),[a?.admin?.readOnly,$]),Ce=Xe(()=>({children:U,editButton:ee,errorCount:X,fieldHasErrors:Y,Label:te,removeButton:xe})=>z("div",{className:oe+" "+oe+"-"+e.blockType,children:z(Bs,{className:[`${oe}__row`,Y?`${oe}__row--has-errors`:`${oe}__row--no-errors`].join(" "),collapsibleStyle:Y?"error":"default",header:wt("div",{className:`${oe}__block-header`,children:[te??W?te??W:wt("div",{children:[z(Ks,{className:`${oe}__block-pill ${oe}__block-pill-${e?.blockType}`,pillStyle:"white",children:G}),z(Zs,{path:"blockName",readOnly:a?.admin?.readOnly||!1}),Y&&z(Gs,{count:X??0,i18n:v,withMessage:!0})]}),wt("div",{children:[Q&&ee!==!1||!Q&&ee?z(se,{}):null,xe!==!1&&C.isEditable()?z(Ie,{}):null]})]}),isCollapsed:S,onToggle:ye=>{j(ye),b(ye)},children:U},0)}),[Q,W,se,Ie,G,C,e.blockType,v,S,j,a?.admin?.readOnly]),mt=Xe(()=>()=>z(js,{children:z(Hs,{className:"",slug:M,title:O(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:G??O("lexical:blocks:inlineBlocks:label")}),children:k?wt(Ps,{children:[z(zs,{fields:A.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:N,permissions:c,readOnly:!1}),z(Vs,{children:O("fields:saveChanges")})]}):null})}),[k,M,G,O,A.fields,N,c]);return Xe(()=>k?z(Us,{beforeSubmit:[async({formState:U})=>await H({formState:U,submit:!0})],fields:A.fields,initialState:k,onChange:[H],onSubmit:U=>{let ee=Ar(U);ee.blockType=e.blockType,C.update(()=>{let X=ho(o);X&&kt(X)&&X.setFields(ee)}),D()},submitted:r,uuid:ra(),children:z(yr,{baseClass:oe,BlockDrawer:mt,Collapsible:Ce,CustomBlock:Q,EditButton:se,errorCount:g,formSchema:A.fields,initialState:k,nodeKey:o,RemoveButton:Ie})}):null,[Ce,mt,Q,Ie,se,C,g,D,A.fields,k,o,H,r])};var ce=class extends Ze{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=Nt(e.fields);return o.setFormat(e.format),o}decorate(e,o){return na(Fr,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Nt(t){return new ce({fields:{...t,id:t?.id||new ia.default().toHexString()}})}function kt(t){return t instanceof ce}import{createCommand as $r}from"lexical";var Ye=$r("INSERT_BLOCK_COMMAND"),Je=$r("INSERT_INLINE_BLOCK_COMMAND");import{c as la}from"react/compiler-runtime";import{useLexicalComposerContext as sa}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as aa,$wrapNodeInElement as ca,mergeRegister as ua}from"@lexical/utils";import{formatDrawerSlug as da,useEditDepth as ma}from"@payloadcms/ui";import{$createParagraphNode as pa,$getNodeByKey as fa,$getPreviousSelection as ha,$getSelection as ga,$insertNodes as Ca,$isParagraphNode as Pr,$isRangeSelection as xa,$isRootOrShadowRoot as ba,COMMAND_PRIORITY_EDITOR as Br}from"lexical";import{useEffect as _a,useState as Ta}from"react";var Hr=()=>{let t=la(10),[e]=sa(),[o,r]=Ta(null),{uuid:n}=B(),i=ma(),l="lexical-inlineBlocks-create-"+n,s;t[0]!==l||t[1]!==i?(s=da({slug:l,depth:i}),t[0]=l,t[1]=i,t[2]=s):s=t[2];let a=s,{toggleDrawer:d}=ae(a,!0),c;t[3]!==e||t[4]!==o?(c=()=>{if(!e.hasNodes([ce]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return ua(e.registerCommand(Ye,m=>(e.update(()=>{let p=ga()||ha();if(xa(p)){let f=Nt(m);aa(f);let{focus:h}=p,g=h.getNode();Pr(g)&&g.getTextContentSize()===0&&g.getParentOrThrow().getChildren().filter(E=>Pr(E)).length>1&&g.remove()}}),!0),Br),e.registerCommand(Je,m=>{if(o){let f=fa(o);return!f||!oo(f)?!1:(f.setFields(m),r(null),!0)}let p=to(m);return Ca([p]),ba(p.getParentOrThrow())&&ca(p,pa).selectEnd(),!0},Br))},t[3]=e,t[4]=o,t[5]=c):c=t[5];let u;return t[6]!==e||t[7]!==o||t[8]!==d?(u=[e,o,d],t[6]=e,t[7]=o,t[8]=d,t[9]=u):u=t[9],_a(c,u),null};var Ea=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,u])=>u[0]),s=Object.entries(i).filter(([c])=>c.startsWith(n+".")&&!c.replace(n+".","").includes(".")).map(([c,u])=>u[0]),a=l.map(c=>c.blocks[0]),d=s.map(c=>c.blocks[0]);return{nodes:[ce,eo],plugins:[{Component:Hr,position:"normal"}],sanitizedClientFeatureProps:e,slashMenu:{groups:[a?.length?{items:a.map(c=>({Icon:_t,key:"block-"+c.slug,keywords:["block","blocks",c.slug],label:({i18n:u})=>c?.labels?.singular?Lt(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(Ye,{blockName:"",blockType:c.slug})}})),key:"blocks",label:({i18n:c})=>c.t("lexical:blocks:label")}:null,d?.length?{items:d.map(c=>({Icon:Tt,key:"inlineBlocks-"+c.slug,keywords:["inlineBlock","inline block",c.slug],label:({i18n:u})=>c?.labels?.singular?Lt(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(Je,{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:_t,items:a.map((c,u)=>({ChildComponent:_t,isActive:void 0,key:"block-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Lt(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Ye,{blockName:"",blockType:c.slug})},order:u})),key:"blocks",order:20}:null,d?.length?{type:"dropdown",ChildComponent:Tt,items:d.map((c,u)=>({ChildComponent:Tt,isActive:void 0,key:"inlineBlock-"+c.slug,label:({i18n:m})=>c?.labels?.singular?Lt(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Je,{blockName:"",blockType:c.slug})},order:u})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as wa}from"react/compiler-runtime";import{jsx as ke,jsxs as xo}from"react/jsx-runtime";import{useLexicalComposerContext as ka}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Na,$createTextNode as La,$getRoot as Ra}from"lexical";import*as Wr from"react";import{useCallback as we,useEffect as go,useLayoutEffect as jr,useRef as Co,useState as Rt}from"react";var Sa=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)},Ia=(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)},ya=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 va(t){return t.key.toLowerCase()==="a"&&(ur?t.metaKey:t.ctrlKey)}function Ma(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 Gr(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 Ur=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Backspace","Delete","Enter","Escape"]);function Da(t){let[e,o]=Rt([]),[r,n]=Rt(!1),[,i]=Rt(""),[l,s]=Rt(""),a=Co(null),d=Co(!1),c=Co(null),u=we(()=>t,[t]),m=we(()=>{let x=t.getRootElement(),T=window.getSelection();return x==null||T==null||T.anchorNode==null||T.focusNode==null||!x.contains(T.anchorNode)||!x.contains(T.focusNode)?null:`
|
|
14
14
|
import {
|
|
15
15
|
initializeE2E,
|
|
16
16
|
assertHTMLSnapshot,
|
|
@@ -27,16 +27,16 @@ describe('Test case', () => {
|
|
|
27
27
|
const {page} = e2e;
|
|
28
28
|
|
|
29
29
|
await page.focus('div[contenteditable="true"]');
|
|
30
|
-
${e.map(
|
|
30
|
+
${e.map(ya).join(`
|
|
31
31
|
`)}
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
-
`},[t,e]),p=we((C,E)=>{o(x=>{let N=e.length-1,S=e[N];if(S&&S.name===C){if(C==="type")return[...e.slice(0,N),{...S,value:S.value+E}];if(S.value===E)return[...e.slice(0,N),{...S,count:S.count+1}]}return[...x,{name:C,count:1,value:E}]})},[e,o]);Hr(()=>{let C=x=>{if(!r)return;let N=x.key;ya(x)?p("selectAll",""):Gr.has(N)?p("press",x.key):[...N].length>1?p("keydown",x.key):p("type",x.key)},E=x=>{if(!r)return;let N=x.key;!Gr.has(N)&&[...N].length>1&&p("keyup",x.key)};return t.registerRootListener((x,N)=>{N!==null&&(N.removeEventListener("keydown",C),N.removeEventListener("keyup",E)),x!==null&&(x.addEventListener("keydown",C),x.addEventListener("keyup",E))})},[t,r,p]),Hr(()=>{c.current&&c.current.scrollTo(0,c.current.scrollHeight)},[m]),go(()=>{if(e){let C=m();C!==null&&s(C),c.current&&c.current.scrollTo(0,c.current.scrollHeight)}},[m,e]),go(()=>t.registerUpdateListener(({dirtyElements:E,dirtyLeaves:x,editorState:N})=>{if(!r)return;let S=N._selection,w=a.current,k=d.current;if(w!==S){if(x.size===0&&E.size===0&&!k){let b=window.getSelection();if(b&&(b.anchorNode==null||b.focusNode==null))return}a.current=S}d.current=!1;let R=m();R!==null&&s(R)}),[t,m,r,p]),go(()=>r?t.registerUpdateListener(()=>{let E=t.getRootElement();E!==null&&i(E?.innerHTML)}):void 0,[t,r]);let f=we(C=>{r||(C.update(()=>{let E=La();E.clear();let x=ka();E.append(Na().append(x)),x.select()}),o([])),n(E=>!E)},[r]),h=we(()=>{if(!r)return;let C=window.getSelection();if(C===null||C.anchorNode==null||C.focusNode==null)return;let{anchorNode:E,anchorOffset:x,focusNode:N,focusOffset:S}=va(C),w=u().getRootElement(),k;E!==null&&(k=jr(E,w));let R;N!==null&&(R=jr(N,w)),p("snapshot",{anchorNode:E,anchorOffset:x,anchorPath:k,focusNode:N,focusOffset:S,focusPath:R})},[p,r,u]),g=we(()=>{Ra(m())},[m]),T=we(()=>{Sa("test.js",m())},[m]);return[Ne("button",{className:`editor-dev-button ${r?"active":""}`,id:"test-recorder-button",onClick:C=>{f(u()),C.preventDefault()},title:r?"Disable test recorder":"Enable test recorder",type:"button",children:r?"Disable test recorder":"Enable test recorder"}),r?xo("div",{className:"test-recorder-output",children:[xo("div",{className:"test-recorder-toolbar",children:[Ne("button",{className:"test-recorder-button",id:"test-recorder-button-snapshot",onClick:C=>{h(),C.preventDefault()},title:"Insert snapshot",type:"button",children:"Insert Snapshot"}),Ne("button",{className:"test-recorder-button",id:"test-recorder-button-copy",onClick:C=>{g(),C.preventDefault()},title:"Copy to clipboard",type:"button",children:"Copy"}),Ne("button",{className:"test-recorder-button",id:"test-recorder-button-download",onClick:C=>{T(),C.preventDefault()},title:"Download as a file",type:"button",children:"Download"})]}),Ne("pre",{id:"test-recorder",ref:c,children:l})]}):null]}var Ur=()=>{let t=Ea(3),[e]=wa(),[o,r]=Ma(e),n;return t[0]!==o||t[1]!==r?(n=xo(Wr.Fragment,{children:[Ne("p",{children:"HI"}),o,r,Ne("p",{children:"DONE"})]}),t[0]=o,t[1]=r,t[2]=n):n=t[2],n};var Da=y({plugins:[{Component:Ur,position:"bottom"}]});import{c as Oa}from"react/compiler-runtime";import{jsx as Aa}from"react/jsx-runtime";import{useLexicalComposerContext as Fa}from"@lexical/react/LexicalComposerContext.js";import{TreeView as $a}from"@lexical/react/LexicalTreeView.js";import"react";var Vr=()=>{let t=Oa(2),[e]=Fa(),o;return t[0]!==e?(o=Aa($a,{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 Pa=y({plugins:[{Component:Vr,position:"bottom"}]});import{$isTableSelection as Ba}from"@lexical/table";import{$isRangeSelection as Ha,FORMAT_TEXT_COMMAND as ja}from"lexical";import{jsx as Kr}from"react/jsx-runtime";import"react";var zr=()=>Kr("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:Kr("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 Z=t=>({type:"buttons",items:t,key:"format",order:40});var Zr={type:"text-format",format:["bold","italic"],tag:"***"},Xr={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},Yr={type:"text-format",format:["bold"],tag:"**"},Jr={type:"text-format",format:["bold"],intraword:!1,tag:"__"};var qr=[Z([{ChildComponent:zr,isActive:({selection:t})=>Ha(t)||Ba(t)?t.hasFormat("bold"):!1,key:"bold",onSelect:({editor:t})=>{t.dispatchCommand(ja,"bold")},order:1}])],Ga=y(({featureProviderMap:t})=>{let e=[Yr,Jr];return t.get("italic")&&e.push(Xr,Zr),{markdownTransformers:e,toolbarFixed:{groups:qr},toolbarInline:{groups:qr}}});import{$isTableSelection as Ua}from"@lexical/table";import{$isRangeSelection as Va,FORMAT_TEXT_COMMAND as Ka}from"lexical";import{jsx as Qr,jsxs as Wa}from"react/jsx-runtime";import"react";var en=()=>Wa("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Qr("path",{d:"M7.76465 6L3.76465 10L7.76465 14",stroke:"currentColor"}),Qr("path",{d:"M12.2354 6L16.2354 10L12.2354 14",stroke:"currentColor"})]});var tn={type:"text-format",format:["code"],tag:"`"};var on=[Z([{ChildComponent:en,isActive:({selection:t})=>Va(t)||Ua(t)?t.hasFormat("code"):!1,key:"inlineCode",onSelect:({editor:t})=>{t.dispatchCommand(Ka,"code")},order:7}])],za=y({markdownTransformers:[tn],toolbarFixed:{groups:on},toolbarInline:{groups:on}});import{$isTableSelection as Za}from"@lexical/table";import{$isRangeSelection as Xa,FORMAT_TEXT_COMMAND as Ya}from"lexical";import{jsx as rn}from"react/jsx-runtime";import"react";var nn=()=>rn("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:rn("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 ln={type:"text-format",format:["italic"],tag:"*"},sn={type:"text-format",format:["italic"],intraword:!1,tag:"_"};var an=[Z([{ChildComponent:nn,isActive:({selection:t})=>Xa(t)||Za(t)?t.hasFormat("italic"):!1,key:"italic",onSelect:({editor:t})=>{t.dispatchCommand(Ya,"italic")},order:2}])],Ja=y({markdownTransformers:[ln,sn],toolbarFixed:{groups:an},toolbarInline:{groups:an}});import{$isTableSelection as Qa}from"@lexical/table";import{$isRangeSelection as ec,FORMAT_TEXT_COMMAND as tc}from"lexical";import{jsx as cn,jsxs as qa}from"react/jsx-runtime";import"react";var un=()=>qa("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:"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"}),cn("path",{d:"M4.99756 11.44H15.0026V12.19H4.99756V11.44Z",fill:"currentColor"})]});var dn={type:"text-format",format:["strikethrough"],tag:"~~"};var mn=[Z([{ChildComponent:un,isActive:({selection:t})=>ec(t)||Qa(t)?t.hasFormat("strikethrough"):!1,key:"strikethrough",onSelect:({editor:t})=>{t.dispatchCommand(tc,"strikethrough")},order:4}])],oc=y({markdownTransformers:[dn],toolbarFixed:{groups:mn},toolbarInline:{groups:mn}});import{$isTableSelection as rc}from"@lexical/table";import{$isRangeSelection as nc,FORMAT_TEXT_COMMAND as ic}from"lexical";import{jsx as pn}from"react/jsx-runtime";import"react";var fn=()=>pn("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:pn("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 hn=[Z([{ChildComponent:fn,isActive:({selection:t})=>nc(t)||rc(t)?t.hasFormat("subscript"):!1,key:"subscript",onSelect:({editor:t})=>{t.dispatchCommand(ic,"subscript")},order:5}])],lc=y({toolbarFixed:{groups:hn},toolbarInline:{groups:hn}});import{$isTableSelection as sc}from"@lexical/table";import{$isRangeSelection as ac,FORMAT_TEXT_COMMAND as cc}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:"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 xn=[Z([{ChildComponent:Cn,isActive:({selection:t})=>ac(t)||sc(t)?t.hasFormat("superscript"):!1,key:"superscript",onSelect:({editor:t})=>{t.dispatchCommand(cc,"superscript")},order:6}])],uc=y({toolbarFixed:{groups:xn},toolbarInline:{groups:xn}});import{$isTableSelection as mc}from"@lexical/table";import{$isRangeSelection as pc,FORMAT_TEXT_COMMAND as fc}from"lexical";import{jsx as bn,jsxs as dc}from"react/jsx-runtime";import"react";var _n=()=>dc("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:[bn("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"}),bn("path",{d:"M5.09961 16.3H14.9016V16.95H5.09961V16.3Z",fill:"currentColor"})]});var Tn=[Z([{ChildComponent:_n,isActive:({selection:t})=>pc(t)||mc(t)?t.hasFormat("underline"):!1,key:"underline",onSelect:({editor:t})=>{t.dispatchCommand(fc,"underline")},order:3}])],hc=y({toolbarFixed:{groups:Tn},toolbarInline:{groups:Tn}});import{$createHeadingNode as bc,$isHeadingNode as An,HeadingNode as _c}from"@lexical/rich-text";import{$setBlocksType as Tc}from"@lexical/selection";import{$getSelection as Ec,$isRangeSelection as wc}from"lexical";import{jsx as En}from"react/jsx-runtime";import"react";var wn=()=>En("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:En("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 Nn}from"react/jsx-runtime";import"react";var kn=()=>Nn("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:Nn("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 Ln}from"react/jsx-runtime";import"react";var Rn=()=>Ln("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:Ln("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 Sn}from"react/jsx-runtime";import"react";var In=()=>Sn("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:Sn("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 yn}from"react/jsx-runtime";import"react";var vn=()=>yn("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:yn("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 Mn}from"react/jsx-runtime";import"react";var Dn=()=>Mn("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:"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 gc,$isHeadingNode as Cc,HeadingNode as xc}from"@lexical/rich-text";var bo=t=>(e,o,r)=>{let n=t(r);n&&(n.append(...o),e.replace(n),n.select(0,0))};var On=t=>{let o=`^(${t.map(n=>Number(n.slice(1))).map(n=>`#{${n}}`).join("|")})\\s`,r=new RegExp(o);return{type:"element",dependencies:[xc],export:(n,i)=>{if(!Cc(n))return null;let l=Number(n.getTag().slice(1));return"#".repeat(l)+" "+i(n)},regExp:r,replace:bo(n=>{let i="h"+n[1].length;return gc(i)})}};var Fn=t=>{let e=Ec();Tc(e,()=>bc(t))},$n={h1:wn,h2:kn,h3:Rn,h4:In,h5:vn,h6:Dn},Nc=y(({props:t})=>{let{enabledHeadingSizes:e=["h1","h2","h3","h4","h5","h6"]}=t,o=[J(e.map((r,n)=>({ChildComponent:$n[r],isActive:({selection:i})=>{if(!wc(i))return!1;for(let l of i.getNodes()){if(An(l)&&l.getTag()===r)continue;let s=l.getParent();if(!(An(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(()=>{Fn(r)})},order:n+2})))];return{markdownTransformers:[On(e)],nodes:[_c],sanitizedClientFeatureProps:t,slashMenu:{groups:e?.length?[K(e.map(r=>({Icon:$n[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(()=>{Fn(r)})}})))]:[]},toolbarFixed:{groups:e?.length?o:[]},toolbarInline:{groups:e?.length?o:[]}}});import{$isNodeSelection as Dc}from"lexical";import{jsx as Pn}from"react/jsx-runtime";import"react";var _o=()=>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("rect",{fill:"currentColor",height:"1",width:"12",x:"4",y:"9.5"})});import{jsx as Bn,jsxs as kc}from"react/jsx-runtime";import"react";var Hn=()=>kc("svg",{fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Bn("path",{d:"M5 10h10",stroke:"currentColor"}),Bn("path",{d:"M10 15V5",stroke:"currentColor"})]});var ce=t=>({type:"dropdown",ChildComponent:Hn,items:t,key:"add",order:10});var jn={type:"element",dependencies:[dt],export:(t,e)=>pt(t)?"---":null,regExp:/^---\s*$/,replace:t=>{let e=mt();e&&t.replace(e)}};import{c as Lc}from"react/compiler-runtime";import{useLexicalComposerContext as Rc}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Sc}from"@lexical/utils";import{$getSelection as Ic,$isRangeSelection as yc,COMMAND_PRIORITY_EDITOR as vc}from"lexical";import{useEffect as Mc}from"react";var Gn=()=>{let t=Lc(3),[e]=Rc(),o,r;return t[0]!==e?(o=()=>e.registerCommand(He,n=>{let i=Ic();if(!yc(i))return!1;if(i.focus.getNode()!==null){let s=mt();Sc(s)}return!0},vc),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Mc(o,r),null};var Oc=y({markdownTransformers:[jn],nodes:[dt],plugins:[{Component:Gn,position:"normal"}],slashMenu:{groups:[K([{Icon:_o,key:"horizontalRule",keywords:["hr","horizontal rule","line","separator"],label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(He,void 0)}}])]},toolbarFixed:{groups:[ce([{ChildComponent:_o,isActive:({selection:t})=>{if(!Dc(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(He,void 0)}}])]}});import{INDENT_CONTENT_COMMAND as $c,OUTDENT_CONTENT_COMMAND as Pc}from"lexical";import{jsx as Lt,jsxs as Ac}from"react/jsx-runtime";import"react";var Wn=()=>Ac("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Lt("path",{d:"M2.5 5H10.5",stroke:"currentColor",strokeWidth:"1.5"}),Lt("path",{d:"M2.5 10H10.5",stroke:"currentColor",strokeWidth:"1.5"}),Lt("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Lt("path",{d:"M12.25 7.25L17.25 3.75V10.75L12.25 7.25Z",fill:"currentColor"})]});import{jsx as Rt,jsxs as Fc}from"react/jsx-runtime";import"react";var Un=()=>Fc("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:[Rt("path",{d:"M17.5 5H9.5",stroke:"currentColor",strokeWidth:"1.5"}),Rt("path",{d:"M17.5 10H9.5",stroke:"currentColor",strokeWidth:"1.5"}),Rt("path",{d:"M17.5 15H2.5",stroke:"currentColor",strokeWidth:"1.5"}),Rt("path",{d:"M7.75 7.25L2.75 3.75V10.75L7.75 7.25Z",fill:"currentColor"})]});var Vn=t=>({type:"buttons",items:t,key:"indent",order:35});var Kn=[Vn([{ChildComponent:Wn,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(Pc,void 0)},order:1},{ChildComponent:Un,isActive:()=>!1,key:"indentIncrease",label:({i18n:t})=>t.t("lexical:indent:increaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand($c,void 0)},order:2}])],Bc=y({toolbarFixed:{groups:Kn},toolbarInline:{groups:Kn}});import{$findMatchingParent as Yu}from"@lexical/utils";import{$getSelection as So,$isRangeSelection as wi}from"lexical";import{jsx as zn}from"react/jsx-runtime";import"react";var Zn=()=>zn("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:zn("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 Xn}from"@lexical/selection";function Me(t){let{anchor:e}=t,{focus:o}=t,r=t.anchor.getNode(),n=t.focus.getNode();return r===n?r:t.isBackward()?Xn(o)?r:n:Xn(e)?r:n}var To=t=>({type:"buttons",items:t,key:"features",order:50});import{$createTextNode as Yc,$isTextNode as Jc}from"lexical";import{addClassNamesToElement as Hc,isHTMLAnchorElement as jc}from"@lexical/utils";import No from"bson-objectid";import{$applyNodeReplacement as Gc,$createTextNode as Yn,$getSelection as Wc,$isElementNode as Jn,$isRangeSelection as wo,createCommand as Uc,ElementNode as Vc}from"lexical";var Kc=new Set(["http:","https:","mailto:","sms:","tel:"]),q=class t extends Vc{__fields;__id;constructor({id:e,fields:o={doc:null,linkType:"custom",newTab:!1,url:""},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:zc,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 No.default().toHexString(),e.version=3);let o=ue({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=Eo(o.rel,"add","noopener")),Hc(o,e.theme.link),o}exportJSON(){let e={...super.exportJSON(),type:"link",fields:this.getFields(),version:3},o=this.getID();return o&&(e.id=o),e}extractWithChild(e,o,r){if(!wo(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(Jn(r)){let n=ue({fields:this.__fields});return r.append(n),n}return null}isInline(){return!0}sanitizeUrl(e){try{let o=new URL(e);if(!Kc.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=Eo(o.rel,"add","noopener"))):(o.removeAttribute("target"),o.rel=Eo(o.rel,"remove","noopener"))),!1}};function zc(t){let e=null;if(jc(t)){let o=t.textContent;o!==null&&o!==""&&(e=ue({id:new No.default().toHexString(),fields:{doc:null,linkType:"custom",newTab:t.getAttribute("target")==="_blank",url:t.getAttribute("href")??""}}))}return{node:e}}function ue({id:t,fields:e}){return Gc(new q({id:t??new No.default().toHexString(),fields:e}))}function V(t){return t instanceof q}var ne=Uc("TOGGLE_LINK_COMMAND");function qn(t){let e=Wc();if(!wo(e)&&!t.selectedNodes?.length)return;let o=wo(e)?e.extract():t.selectedNodes;if(t===null)o?.forEach(r=>{let n=r.getParent();if(V(n)){let i=n.getChildren();for(let l=0;l<i.length;l+=1)n.insertBefore(i[l]);n.remove()}});else{if(o?.length===1){let i=o[0],l=V(i)?i:Zc(i);if(l!==null){l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(Yn(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||Jn(i)&&!i.isInline())){if(V(l)){n=l,l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(Yn(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}if(l.is(r)||(r=l,n=ue({fields:t.fields}),V(l)?i.getPreviousSibling()===null?l.insertBefore(n):l.insertAfter(n):i.insertBefore(n)),V(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 Zc(t){return Xc(t,e=>V(e))}function Xc(t,e){let o=t;for(;o!==null&&(o=o.getParent(),!(o===null||e(o))););return o}function Eo(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 Qn={type:"text-match",dependencies:[q],export:(t,e,o)=>{if(!V(t))return null;let r=t,{url:n}=r.getFields(),i=`[${r.getTextContent()}](${n})`,l=r.getFirstChild();return r.getChildrenSize()===1&&Jc(l)?o(l,i):i},importRegExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)/,regExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)$/,replace:(t,e)=>{let[,o,r]=e,n=ue({fields:{doc:null,linkType:"custom",newTab:!1,url:r}}),i=Yc(o);i.setFormat(t.getFormat()),n.append(i),t.replace(n)},trigger:")"};import{$applyNodeReplacement as qc,$isElementNode as Qc}from"lexical";var de=class t extends q{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=Qe({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(Qc(r)){let n=Qe({fields:this.__fields});return r.append(n),n}return null}};function Qe({fields:t}){return qc(new de({id:"",fields:t}))}function me(t){return t instanceof de}import{c as eu}from"react/compiler-runtime";import{useLexicalComposerContext as tu}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ou}from"@lexical/utils";import{$createTextNode as ei,$getSelection as ru,$isElementNode as oi,$isLineBreakNode as ri,$isNodeSelection as nu,$isRangeSelection as iu,$isTextNode as et,TextNode as lu}from"lexical";import{useEffect as su}from"react";function ti(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 ni(t,e){for(let o=0;o<e.length;o++){let r=e[o](t);if(r!=null)return r}return null}var au=/[.,;\s]/;function It(t){return au.test(t)}function ii(t){return It(t[t.length-1])}function Lo(t){return It(t[0])}function cu(t,e){return e?/^\.[a-z]{2,}/i.test(t):/^\.[a-z0-9]+/i.test(t)}function li(t){let e=t.getPreviousSibling();return oi(e)&&(e=e.getLastDescendant()),e===null||ri(e)||et(e)&&ii(e.getTextContent())}function si(t){let e=t.getNextSibling();return oi(e)&&(e=e.getFirstDescendant()),e===null||ri(e)||et(e)&&Lo(e.getTextContent())}function uu(t,e,o,r){return(t>0?It(o[t-1]):li(r[0]))?e<o.length?It(o[e]):si(r[r.length-1]):!1}function du(t,e,o){let r=[],n=[],i=[],l=0,s=0,a=[...t];for(;a.length>0;){let d=a[0],u=d.getTextContent().length,m=s;s+u<=e?(r.push(d),l+=u):m>=o?i.push(d):n.push(d),s+=u,a.shift()}return[l,r,n,i]}function mu(t,e,o,r){let n={linkType:"custom",url:r.url,...r.fields},i=Qe({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=ei(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 d=[],c;for(let f=1;f<t.length;f++){let h=t[f],T=h.getTextContent().length,M=s,O=s+T;if(M<o)if(O<=o)d.push(h);else{let[C,E]=h.splitText(o-M);d.push(C),c=E}s+=T}let u=ru(),m=u?u.getNodes().find(et):void 0,p=ei(a.getTextContent());return p.setFormat(a.getFormat()),p.setDetail(a.getDetail()),p.setStyle(a.getStyle()),i.append(p,...d),m&&m===a&&(iu(u)?p.select(u.anchor.offset,u.focus.offset):nu(u)&&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=ni(i,e))!=null&&l!==null;){let a=l.index,d=l.length,c=a+d;if(uu(s+a,s+c,n,r)){let[m,,p,f]=du(r,s+a,s+c),h=s+a-m,g=s+c-m,T=mu(p,h,g,l);r=T?[T,...f]:f,o(l.url,null),s=0}else s+=c;i=i.substring(c)}}function ko(t,e,o){let r=t.getChildren(),n=r.length;for(let a=0;a<n;a++){let d=r[a];if(!et(d)||!d.isSimpleText()){St(t),o(null,t.getFields()?.url??null);return}}let i=t.getTextContent(),l=ni(i,e);if(l===null||l.text!==i){St(t),o(null,t.getFields()?.url??null);return}if(!li(t)||!si(t)){St(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 fu(t,e,o){let r=t.getPreviousSibling(),n=t.getNextSibling(),i=t.getTextContent();if(me(r)){let l=r.getFields()?.url?r.getFields()?.url?.startsWith("mailto:"):!1;(!Lo(i)||cu(i,l))&&(r.append(t),ko(r,e,o),o(null,r.getFields()?.url??null))}me(n)&&!ii(i)&&(St(n),ko(n,e,o),o(null,n.getFields()?.url??null))}function St(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&&et(o)&&o.isSimpleText()&&(e.push(o),!/\s/.test(o.getTextContent()));)o=o.getNextSibling();return e}function gu(t,e,o){let r=eu(5),n,i;r[0]!==t||r[1]!==o||r[2]!==e?(n=()=>{if(!t.hasNodes([de]))throw new Error("LexicalAutoLinkPlugin: AutoLinkNode not registered on editor");let l=(s,a)=>{o?.(s,a)};return ou(t.registerNodeTransform(lu,s=>{let a=s.getParentOrThrow(),d=s.getPreviousSibling();if(me(a))ko(a,e,l);else if(!V(a)){if(s.isSimpleText()&&(Lo(s.getTextContent())||!me(d))){let c=hu(s);pu(c,e,l)}fu(s,e,l)}}))},i=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=n,r[4]=i):(n=r[3],i=r[4]),su(n,i)}var Cu=/((https?:\/\/(www\.)?)|(www\.))[-\w@:%.+~#=]{1,256}\.[a-zA-Z\d()]{1,6}\b([-\w()@:%+.~#?&/=]*)(?<![-.+():%])/,xu=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-\d]+\.)+[a-z]{2,}))/i,bu=[ti(Cu,t=>t.startsWith("http")?t:`https://${t}`),ti(xu,t=>`mailto:${t}`)],ai=()=>{let[t]=tu();return gu(t,bu),null};import{jsx as _u}from"react/jsx-runtime";import{ClickableLinkPlugin as Tu}from"@lexical/react/LexicalClickableLinkPlugin.js";import"react";var ci=()=>_u(Tu,{});import{jsx as Pu}from"react/jsx-runtime";import"react";import{createPortal as Bu}from"react-dom";import{jsx as pe,jsxs as tt,Fragment as wu}from"react/jsx-runtime";import{useLexicalComposerContext as Nu}from"@lexical/react/LexicalComposerContext.js";import{$findMatchingParent as ui,mergeRegister as di}from"@lexical/utils";import{getTranslation as Ro}from"@payloadcms/translations";import{CloseMenuIcon as ku,EditIcon as Lu,ExternalLinkIcon as mi,formatDrawerSlug as Ru,useConfig as Su,useEditDepth as Iu,useLocale as yu,useTranslation as vu}from"@payloadcms/ui";import{requests as Mu}from"@payloadcms/ui/shared";import{$getSelection as pi,$isLineBreakNode as Du,$isRangeSelection as fi,COMMAND_PRIORITY_HIGH as Ou,COMMAND_PRIORITY_LOW as hi,KEY_ESCAPE_COMMAND as Au,SELECTION_CHANGE_COMMAND as Fu}from"lexical";import gi,{useCallback as Ci,useEffect as Mt,useRef as $u,useState as ke}from"react";function yt(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(),d=t.top-r,c=t.left-n;d<a.top&&(d+=l.height+t.height+r*2),c+l.width>a.right&&(c=a.right-l.width-n),d-=s.top,c-=s.left,e.style.opacity="1",e.style.transform=`translate(${c}px, ${d}px)`}import{createCommand as Eu}from"lexical";var vt=Eu("TOGGLE_LINK_WITH_MODAL_COMMAND");function xi({anchorElem:t}){let[e]=Nu(),[o,r]=ke(),n=$u(null),[i,l]=ke(null),[s,a]=ke(null),{fieldProps:{schemaPath:d},uuid:c}=B(),{config:u}=Su(),{i18n:m,t:p}=vu(),[f,h]=ke(),g=Iu(),[T,M]=ke(!1),[O,C]=ke([]),E=yu(),[x,N]=ke(!1),S=Ru({slug:"lexical-rich-text-link-"+c,depth:g}),{toggleDrawer:w}=xe(S),k=Ci(()=>{M(!1),n&&n.current&&(n.current.style.opacity="0",n.current.style.transform="translate(-10000px, -10000px)"),N(!1),l(null),a(null),C([]),h(void 0)},[M,l,a,C]),R=Ci(()=>{let b=pi(),_;if(!fi(b)||!b){k();return}let I=Me(b);_=e.getElementByKey(I.getKey())?.getBoundingClientRect();let L=ui(I,V),D=b.getNodes().filter(W=>!Du(W)).find(W=>{let G=ui(W,V);return L&&!L.is(G)||G&&!G.is(L)});if(L==null||D){k();return}r(L);let v=L.getFields(),A={...v,id:L.getID(),text:L.getTextContent()};if(v?.linkType==="custom")l(v?.url??null),a(null);else{l(`${u.routes.admin==="/"?"":u.routes.admin}/collections/${v?.doc?.relationTo}/${v?.doc?.value}`);let W=u.collections.find(G=>G.slug===v?.doc?.relationTo);if(!W)a(v?.label?String(v?.label):null),l(v?.url?String(v?.url):null);else{let G=typeof v.doc?.value=="object"?v.doc.value.id:v.doc?.value,se=v.doc?.relationTo;if(!G||!se)throw new Error("Focus link parent is missing doc.value or doc.relationTo");let Ie=p("fields:linkedTo",{label:`${Ro(W.labels.singular,m)} - ${p("lexical:link:loadingWithEllipsis",m)}`}).replace(/<[^>]*>?/g,"");a(Ie),Mu.get(`${u.serverURL}${u.routes.api}/${se}/${G}`,{headers:{"Accept-Language":m.language},params:{depth:0,locale:E?.code}}).then(async ge=>{if(!ge.ok)throw new Error(`HTTP error! Status: ${ge.status}`);let ut=await ge.json(),ar=W?.admin?.useAsTitle||"id",U=ut[ar],ee=p("fields:linkedTo",{label:`${Ro(W.labels.singular,m)} - ${U}`}).replace(/<[^>]*>?/g,"");a(ee)}).catch(()=>{let ge=p("fields:linkedTo",{label:`${Ro(W.labels.singular,m)} - ${p("general:untitled",m)} - ID: ${G}`}).replace(/<[^>]*>?/g,"");a(ge)})}}h(A),M(!0),C(b?b?.getNodes():[]),me(L)?N(!0):N(!1);let H=n.current,$=window.getSelection(),{activeElement:j}=document;if(H===null)return;let Q=e.getRootElement();return $!==null&&Q!==null&&Q.contains($.anchorNode)?(_||(_=$.getRangeAt(0).getBoundingClientRect()),_!=null&&(_.y+=40,yt(_,H,t))):(j==null||j.className!=="link-input")&&(Q!==null&&yt(null,H,t),l(null),a(null)),!0},[e,k,u.routes.admin,u.routes.api,u.collections,u.serverURL,p,m,E?.code,t]);return Mt(()=>di(e.registerCommand(vt,b=>(e.dispatchCommand(ne,b),R(),w(),!0),hi)),[e,R,w,S]),Mt(()=>{let b=t.parentElement,_=()=>{e.getEditorState().read(()=>{R()})};return window.addEventListener("resize",_),b?.addEventListener("scroll",_),()=>{window.removeEventListener("resize",_),b?.removeEventListener("scroll",_)}},[t.parentElement,e,R]),Mt(()=>di(e.registerUpdateListener(({editorState:b})=>{b.read(()=>{R()})}),e.registerCommand(Fu,()=>(R(),!0),hi),e.registerCommand(Au,()=>T?(k(),!0):!1,Ou)),[e,R,T,k]),Mt(()=>{e.getEditorState().read(()=>{R()})},[e,R]),tt(gi.Fragment,{children:[pe("div",{className:"link-editor",ref:n,children:tt("div",{className:"link-input",children:[i&&i.length>0?tt("a",{href:i,rel:"noopener noreferrer",target:"_blank",children:[o?.__fields.newTab?pe(mi,{}):null,s!=null&&s.length>0?s:i]}):s!=null&&s.length>0?tt(wu,{children:[o?.__fields.newTab?pe(mi,{}):null,pe("span",{className:"link-input__label-pure",children:s})]}):null,e.isEditable()&&tt(gi.Fragment,{children:[pe("button",{"aria-label":"Edit link",className:"link-edit",onClick:()=>{w()},onMouseDown:b=>{b.preventDefault()},tabIndex:0,type:"button",children:pe(Lu,{})}),!x&&pe("button",{"aria-label":"Remove link",className:"link-trash",onClick:()=>{e.dispatchCommand(ne,null)},onMouseDown:b=>{b.preventDefault()},tabIndex:0,type:"button",children:pe(ku,{})})]})]})}),pe(je,{className:"lexical-link-edit-drawer",data:f,drawerSlug:S,drawerTitle:p("fields:editLink"),featureKey:"link",handleDrawerSubmit:(b,_)=>{let I=_,L={...I};delete L.text,e.update(()=>{let D=pi(),v=null;if(fi(D)?v=Me(D).getParent():O.length&&(v=O[0].getParent()),v&&me(v)){let A=ue({fields:L});v.replace(A,!0)}}),e.dispatchCommand(ne,{fields:L,selectedNodes:O,text:I.text})},schemaPath:d,schemaPathSuffix:"fields"})]})}var bi=t=>{let{anchorElem:e=document.body}=t;return Bu(Pu(xi,{anchorElem:e}),e)};import{c as Gu}from"react/compiler-runtime";import{useLexicalComposerContext as Wu}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Uu}from"@lexical/utils";import{$getSelection as Vu,$isElementNode as Ku,$isRangeSelection as zu,COMMAND_PRIORITY_LOW as Ti,PASTE_COMMAND as Zu}from"lexical";import{useEffect as Xu}from"react";var Hu=/(?:[A-Za-z]{3,9}:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z\d.-]+)(?:\/[+~%/.\w-]*)?\??[-+=&;%@.\w]*#?\w*/,ju=/^[\w\-./]*(?:#\w[\w-]*)?$/;function _i(t){if(!t)return!1;if(t==="https://"||Hu.test(t)||ju.test(t))return!0;try{return new URL(t),!0}catch{}return!1}var Ei=()=>{let t=Gu(3),[e]=Wu(),o,r;return t[0]!==e?(o=()=>{if(!e.hasNodes([q]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Uu(e.registerCommand(ne,n=>(qn(n),!0),Ti),e.registerCommand(Zu,n=>{let i=Vu();if(!zu(i)||i.isCollapsed()||!(n instanceof ClipboardEvent)||n.clipboardData==null)return!1;let l=n.clipboardData.getData("text");if(!_i(l))return!1;if(!i.getNodes().some(s=>Ku(s))){let s={doc:null,linkType:"custom",newTab:!1,url:l};return e.dispatchCommand(ne,{fields:s,text:null}),n.preventDefault(),!0}return!1},Ti))},r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Xu(o,r),null};var Ni=[To([{ChildComponent:Zn,isActive:({selection:t})=>{if(wi(t)){let e=Me(t);return Yu(e,V)!=null}return!1},isEnabled:({selection:t})=>!!(wi(t)&&So()?.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=So()?.getTextContent(),r=So()?.getNodes()??[]}),!o?.length)return;let n={doc:null,linkType:"custom",newTab:!1,url:"https://"};t.dispatchCommand(vt,{fields:n,selectedNodes:r,text:o})}},order:1}])],Ju=y({markdownTransformers:[Qn],nodes:[q,de],plugins:[{Component:Ei,position:"normal"},{Component:ai,position:"normal"},{Component:ci,position:"normal"},{Component:bi,position:"floatingAnchorElem"}],toolbarFixed:{groups:Ni},toolbarInline:{groups:Ni}});import{$isListNode as vo,INSERT_CHECK_LIST_COMMAND as yi,ListItemNode as cd,ListNode as ud}from"@lexical/list";import{$isRangeSelection as dd}from"lexical";import{jsx as ki,jsxs as qu}from"react/jsx-runtime";import"react";var Io=()=>qu("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:[ki("rect",{height:"13",rx:"1.5",stroke:"currentColor",width:"13",x:"3.5",y:"3.5"}),ki("path",{d:"M7 10L9 12.5L13 7.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Qu}from"react/jsx-runtime";import{ListPlugin as ed}from"@lexical/react/LexicalListPlugin.js";import"react";var De=()=>Qu(ed,{});function Oe(t){return{items:t,key:"lists",label:({i18n:e})=>e.t("lexical:general:slashMenuListGroupLabel")}}import{$isListNode as nd,ListItemNode as id,ListNode as ld}from"@lexical/list";import{$createListItemNode as td,$createListNode as od,$isListItemNode as rd,$isListNode as yo}from"@lexical/list";var Li=4,Ae=t=>(e,o,r)=>{let n=e.getPreviousSibling(),i=e.getNextSibling(),l=td(t==="check"?r[3]==="x":void 0);if(yo(i)&&i.getListType()===t){let a=i.getFirstChild();a!==null?a.insertBefore(l):i.append(l),e.remove()}else if(yo(n)&&n.getListType()===t)n.append(l),e.remove();else{let a=od(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/Li);s&&l.setIndent(s)},Le=(t,e,o)=>{let r=[],n=t.getChildren(),i=0;for(let l of n)if(rd(l)){if(l.getChildrenSize()===1){let c=l.getFirstChild();if(yo(c)){r.push(Le(c,e,o+1));continue}}let s=" ".repeat(o*Li),a=t.getListType(),d=a==="number"?`${t.getStart()+i}. `:a==="check"?`- [${l.getChecked()?"x":" "}] `:"- ";r.push(s+d+e(l)),i++}return r.join(`
|
|
35
|
-
`)};var Ri={type:"element",dependencies:[ld,id],export:(t,e)=>nd(t)?Le(t,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:Ae("check")};import{jsx as sd}from"react/jsx-runtime";import{CheckListPlugin as ad}from"@lexical/react/LexicalCheckListPlugin.js";import"react";var Si=()=>sd(ad,{});var Ii=[J([{ChildComponent:Io,isActive:({selection:t})=>{if(!dd(t))return!1;for(let e of t.getNodes()){if(vo(e)&&e.getListType()==="check")continue;let o=e.getParent();if(vo(o)&&o.getListType()==="check")continue;let r=o?.getParent();if(!(vo(r)&&r.getListType()==="check"))return!1}return!0},key:"checklist",label:({i18n:t})=>t.t("lexical:checklist:label"),onSelect:({editor:t})=>{t.dispatchCommand(yi,void 0)},order:12}])],md=y(({featureProviderMap:t})=>{let e=[{Component:Si,position:"normal"}];return!t.has("unorderedList")&&!t.has("orderedList")&&e.push({Component:De,position:"normal"}),{markdownTransformers:[Ri],nodes:t.has("unorderedList")||t.has("orderedList")?[]:[ud,cd],plugins:e,slashMenu:{groups:[Oe([{Icon:Io,key:"checklist",keywords:["check list","check","checklist","cl"],label:({i18n:o})=>o.t("lexical:checklist:label"),onSelect:({editor:o})=>{o.dispatchCommand(yi,void 0)}}])]},toolbarFixed:{groups:Ii},toolbarInline:{groups:Ii}}});import{$isListNode as Do,INSERT_ORDERED_LIST_COMMAND as Di,ListItemNode as Cd,ListNode as xd}from"@lexical/list";import{$isRangeSelection as bd}from"lexical";import{jsx as ot,jsxs as pd}from"react/jsx-runtime";import"react";var Mo=()=>pd("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:[ot("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"}),ot("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"}),ot("path",{d:"M8 15L17 15",stroke:"currentColor",strokeWidth:"1.5"}),ot("path",{d:"M8 10L17 10",stroke:"currentColor",strokeWidth:"1.5"}),ot("path",{d:"M8 5L17 5",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as fd,ListItemNode as hd,ListNode as gd}from"@lexical/list";var vi={type:"element",dependencies:[gd,hd],export:(t,e)=>fd(t)?Le(t,e,0):null,regExp:/^(\s*)(\d+)\.\s/,replace:Ae("number")};var Mi=[J([{ChildComponent:Mo,isActive:({selection:t})=>{if(!bd(t))return!1;for(let e of t.getNodes()){if(Do(e)&&e.getListType()==="number")continue;let o=e.getParent();if(Do(o)&&o.getListType()==="number")continue;let r=o?.getParent();if(!(Do(r)&&r.getListType()==="number"))return!1}return!0},key:"orderedList",label:({i18n:t})=>t.t("lexical:orderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Di,void 0)},order:10}])],_d=y(({featureProviderMap:t})=>({markdownTransformers:[vi],nodes:t.has("orderedList")?[]:[xd,Cd],plugins:t.has("orderedList")?[]:[{Component:De,position:"normal"}],slashMenu:{groups:[Oe([{Icon:Mo,key:"orderedList",keywords:["ordered list","ol"],label:({i18n:e})=>e.t("lexical:orderedList:label"),onSelect:({editor:e})=>{e.dispatchCommand(Di,void 0)}}])]},toolbarFixed:{groups:Mi},toolbarInline:{groups:Mi}}));import{$isListNode as Ao,INSERT_UNORDERED_LIST_COMMAND as Fi,ListItemNode as kd,ListNode as Ld}from"@lexical/list";import{$isRangeSelection as Rd}from"lexical";import{jsx as Fe,jsxs as Td}from"react/jsx-runtime";import"react";var Oo=()=>Td("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:[Fe("circle",{cx:"4",cy:"5",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Fe("circle",{cx:"4",cy:"10",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Fe("circle",{cx:"4",cy:"15",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Fe("path",{d:"M17 5H7",stroke:"currentColor",strokeWidth:"1.5"}),Fe("path",{d:"M17 10H7",stroke:"currentColor",strokeWidth:"1.5"}),Fe("path",{d:"M17 15H7",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as Ed,ListItemNode as wd,ListNode as Nd}from"@lexical/list";var Oi={type:"element",dependencies:[Nd,wd],export:(t,e)=>Ed(t)?Le(t,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:Ae("bullet")};var Ai=[J([{ChildComponent:Oo,isActive:({selection:t})=>{if(!Rd(t))return!1;for(let e of t.getNodes()){if(Ao(e)&&e.getListType()==="bullet")continue;let o=e.getParent();if(Ao(o)&&o.getListType()==="bullet")continue;let r=o?.getParent();if(!(Ao(r)&&r.getListType()==="bullet"))return!1}return!0},key:"unorderedList",label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Fi,void 0)},order:11}])],Sd=y({markdownTransformers:[Oi],nodes:[Ld,kd],plugins:[{Component:De,position:"normal"}],slashMenu:{groups:[Oe([{Icon:Oo,key:"unorderedList",keywords:["unordered list","ul"],label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Fi,void 0)}}])]},toolbarFixed:{groups:Ai},toolbarInline:{groups:Ai}});import{jsx as Id}from"react/jsx-runtime";import{addClassNamesToElement as yd}from"@lexical/utils";import{DecoratorNode as vd}from"lexical";import*as $i from"react";var Md=$i.lazy(()=>import("./Component-MBLHTKDK.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),rt=class t extends vd{__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 Dd({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return yd(o,"unknownConverted"),o}decorate(){return Id(Md,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function Dd({data:t}){return new rt({data:t})}var Od=y(()=>({nodes:[rt]}));import{jsx as Ad}from"react/jsx-runtime";import{addClassNamesToElement as Fd}from"@lexical/utils";import{DecoratorNode as $d}from"lexical";import*as Pi from"react";var Pd=Pi.lazy(()=>import("./Component-DOSSWC76.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),nt=class t extends $d{__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 Bd({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return Fd(o,"unknownConverted"),o}decorate(){return Ad(Pd,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function Bd({data:t}){return new nt({data:t})}var Hd=y(()=>({nodes:[nt]}));import{$setBlocksType as ji}from"@lexical/selection";import{$createParagraphNode as Gi,$getSelection as Wi,$isParagraphNode as Bi,$isRangeSelection as jd}from"lexical";var Hi=[J([{ChildComponent:Ze,isActive:({selection:t})=>{if(!jd(t))return!1;for(let e of t.getNodes())if(!Bi(e)&&!Bi(e.getParent()))return!1;return!0},key:"paragraph",label:({i18n:t})=>t.t("lexical:paragraph:label2"),onSelect:({editor:t})=>{t.update(()=>{let e=Wi();ji(e,()=>Gi())})},order:1}])],Gd=y({slashMenu:{groups:[K([{Icon:Ze,key:"paragraph",keywords:["normal","paragraph","p","text"],label:({i18n:t})=>t.t("lexical:paragraph:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Wi();ji(e,()=>Gi())})}}])]},toolbarFixed:{groups:Hi},toolbarInline:{groups:Hi}});import{$isNodeSelection as gm}from"lexical";import{jsx as it,jsxs as Wd}from"react/jsx-runtime";import"react";var Fo=()=>Wd("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:[it("g",{clipPath:"url(#clip0_4397_10817)",children:it("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"})}),it("defs",{children:it("clipPath",{id:"clip0_4397_10817",children:it("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{c as nm}from"react/compiler-runtime";import{jsx as im}from"react/jsx-runtime";import{useLexicalComposerContext as lm}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as sm}from"@lexical/utils";import{useConfig as am}from"@payloadcms/ui";import{$getPreviousSelection as cm,$getSelection as um,$isParagraphNode as Xi,$isRangeSelection as dm,COMMAND_PRIORITY_EDITOR as mm,createCommand as pm}from"lexical";import{useEffect as fm}from"react";import{c as Qd}from"react/compiler-runtime";import{jsx as Ot}from"react/jsx-runtime";import{useLexicalComposerContext as em}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as tm,COMMAND_PRIORITY_EDITOR as om}from"lexical";import{useEffect as Vi,useState as Ki}from"react";import{c as Ud}from"react/compiler-runtime";import{jsx as Vd}from"react/jsx-runtime";import{useLexicalComposerContext as Kd}from"@lexical/react/LexicalComposerContext";import{useListDrawer as zd,useModal as Zd}from"@payloadcms/ui";import{$getPreviousSelection as Xd,$getSelection as Yd,$setSelection as Jd}from"lexical";import{useEffect as qd,useState as Ui}from"react";var Dt=t=>{let e=Ud(23),[o]=Kd(),[r,n]=Ui(null),[i,l]=Ui(!1),[s,a,d]=zd(t),{closeDrawer:c,drawerSlug:u,isDrawerOpen:m,openDrawer:p}=d,{modalState:f}=Zd(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let k=Yd()??Xd();n(k)},e[0]=h):h=e[0];let g=h,T;e[1]!==r||e[2]!==o?(T=()=>{r&&o.update(()=>{Jd(r.clone())},{discrete:!0,skipTransforms:!0})},e[1]=r,e[2]=o,e[3]=T):T=e[3];let M=T,O;e[4]!==c?(O=()=>{c()},e[4]=c,e[5]=O):O=e[5];let C=O,E,x;e[6]!==i||e[7]!==f||e[8]!==u||e[9]!==M?(E=()=>{if(!i)return;let k=f[u];k&&!k?.isOpen&&(l(!1),setTimeout(()=>{M()},1))},x=[f,u,M,i],e[6]=i,e[7]=f,e[8]=u,e[9]=M,e[10]=E,e[11]=x):(E=e[10],x=e[11]),qd(E,x);let N;e[12]!==a?(N=k=>Vd(a,{...k,onClick:()=>{g()}}),e[12]=a,e[13]=N):N=e[13];let S;e[14]!==p?(S=()=>{g(),p(),l(!0)},e[14]=p,e[15]=S):S=e[15];let w;return e[16]!==C||e[17]!==m||e[18]!==s||e[19]!==u||e[20]!==N||e[21]!==S?(w={closeListDrawer:C,isListDrawerOpen:m,ListDrawer:s,listDrawerSlug:u,ListDrawerToggler:N,openListDrawer:S},e[16]=C,e[17]=m,e[18]=s,e[19]=u,e[20]=N,e[21]=S,e[22]=w):w=e[22],w};var rm=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=tm(o);n&&n.replace(Ue({relationTo:e,value:r}))}):t.dispatchCommand($o,{relationTo:e,value:r})},zi=t=>{let e=Qd(21),{enabledCollectionSlugs:o}=t,[r]=em(),n;e[0]!==o?(n=()=>o?.[0],e[0]=o,e[1]=n):n=e[1];let[i,l]=Ki(n),[s,a]=Ki(null),d=o||void 0,c;e[2]!==d||e[3]!==i?(c={collectionSlugs:d,selectedCollection:i},e[2]=d,e[3]=i,e[4]=c):c=e[4];let{closeListDrawer:u,isListDrawerOpen:m,ListDrawer:p,openListDrawer:f}=Dt(c),h,g;e[5]!==r||e[6]!==f?(h=()=>r.registerCommand(Ge,x=>(a(x?.replace?x?.replace.nodeKey:null),f(),!0),om),g=[r,f],e[5]=r,e[6]=f,e[7]=h,e[8]=g):(h=e[7],g=e[8]),Vi(h,g);let T;e[9]!==r||e[10]!==s||e[11]!==u?(T=x=>{let{collectionSlug:N,docID:S}=x;rm({editor:r,relationTo:N,replaceNodeKey:s,value:S}),u()},e[9]=r,e[10]=s,e[11]=u,e[12]=T):T=e[12];let M=T,O;e[13]!==o?(O=()=>{l(o?.[0])},e[13]=o,e[14]=O):O=e[14];let C;e[15]!==m||e[16]!==o?(C=[m,o],e[15]=m,e[16]=o,e[17]=C):C=e[17],Vi(O,C);let E;return e[18]!==M||e[19]!==p?(E=Ot(p,{onSelect:M}),e[18]=M,e[19]=p,e[20]=E):E=e[20],E},Zi=t=>(t?.enabledCollectionSlugs?.length??-1)>0?Ot(zi,{...t}):Ot(ft,{...t,children:Ot(zi,{...t})});var $o=pm("INSERT_RELATIONSHIP_COMMAND"),Yi=t=>{let e=nm(10),{clientProps:o}=t,[r]=lm(),{config:n}=am(),{collections:i}=n,l=null;if(o?.enabledCollections)l=o?.enabledCollections;else if(o?.disabledCollections){let c;if(e[0]!==o||e[1]!==i){let u;e[3]!==o?(u=m=>{let{slug:p}=m;return!o?.disabledCollections?.includes(p)},e[3]=o,e[4]=u):u=e[4],c=i.filter(u).map(hm),e[0]=o,e[1]=i,e[2]=c}else c=e[2];l=c}let s,a;e[5]!==r?(s=()=>{if(!r.hasNodes([We]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand($o,c=>{let u=um()||cm();if(dm(u)){let m=Ue(c);sm(m);let{focus:p}=u,f=p.getNode();Xi(f)&&f.getTextContentSize()===0&&f.getParentOrThrow().getChildren().filter(h=>Xi(h)).length>1&&f.remove()}return!0},mm)},a=[r],e[5]=r,e[6]=s,e[7]=a):(s=e[6],a=e[7]),fm(s,a);let d;return e[8]!==l?(d=im(Zi,{enabledCollectionSlugs:l}),e[8]=l,e[9]=d):d=e[9],d};function hm(t){let{slug:e}=t;return e}var Cm=y({nodes:[We],plugins:[{Component:Yi,position:"normal"}],slashMenu:{groups:[K([{Icon:Fo,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ge,{replace:!1})}}])]},toolbarFixed:{groups:[ce([{ChildComponent:Fo,isActive:({selection:t})=>{if(!gm(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return ro(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ge,{replace:!1})}}])]}});import{c as rl}from"react/compiler-runtime";import{jsx as re,jsxs as vm}from"react/jsx-runtime";import{useLexicalComposerContext as Mm}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as Dm,useThrottledEffect as Om,useTranslation as Am}from"@payloadcms/ui";import*as fe from"react";import{useMemo as Fm}from"react";import{jsx as xm}from"react/jsx-runtime";import{mergeRegister as bm}from"@lexical/utils";import{$getSelection as _m}from"lexical";import{useCallback as Tm,useEffect as At,useState as Po}from"react";var Bo="toolbar-popup__button",lt=({children:t,editor:e,item:o})=>{let[r,n]=Po(!0),[i,l]=Po(!1),[s,a]=Po(Bo),d=B(),c=Tm(()=>{e.getEditorState().read(()=>{let u=_m();if(u){if(o.isActive){let m=o.isActive({editor:e,editorConfigContext:d,selection:u});i!==m&&l(m)}if(o.isEnabled){let m=o.isEnabled({editor:e,editorConfigContext:d,selection:u});r!==m&&n(m)}}})},[i,e,d,r,o]);return At(()=>{c()},[c]),At(()=>(document.addEventListener("mouseup",c),()=>{document.removeEventListener("mouseup",c)}),[c]),At(()=>bm(e.registerUpdateListener(()=>{c()})),[e,c]),At(()=>{a([Bo,r===!1?"disabled":"",i?"active":"",o?.key?`${Bo}-`+o.key:""].filter(Boolean).join(" "))},[r,i,s,o.key]),xm("button",{className:s,onClick:()=>{if(r!==!1)return e._updateTags=new Set(["toolbar",...e._updateTags]),e.focus(()=>{o.onSelect?.({editor:e,isActive:i})}),!0},onMouseDown:u=>{u.preventDefault()},type:"button",children:t})};import{c as ol}from"react/compiler-runtime";import{jsx as $e}from"react/jsx-runtime";import Go,{useEffect as tl}from"react";import{mergeRegister as Rm}from"@lexical/utils";import{useTranslation as Sm}from"@payloadcms/ui";import{$getSelection as Im}from"lexical";import{jsx as Te,jsxs as Ji}from"react/jsx-runtime";import{Button as Em}from"@payloadcms/ui";import Ft,{useCallback as wm,useEffect as st,useMemo as Nm,useRef as jo,useState as $t}from"react";import{createPortal as km}from"react-dom";var Ho="toolbar-popup__dropdown-item",qi=Ft.createContext(null);function Qi({active:t,children:e,editor:o,enabled:r,Icon:n,item:i,tooltip:l}){let[s,a]=$t(Ho);st(()=>{a([Ho,r===!1?"disabled":"",t?"active":"",i?.key?`${Ho}-${i.key}`:""].filter(Boolean).join(" "))},[r,t,s,i.key]);let d=jo(null),c=Ft.useContext(qi);if(c===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:u}=c;return st(()=>{d?.current!=null&&u(d)},[d,u]),Te(Em,{"aria-label":l,buttonStyle:"none",className:s,disabled:r===!1,icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&(o._updateTags=new Set(["toolbar",...o._updateTags]),o.focus(()=>{i.onSelect?.({editor:o,isActive:t})}))},onMouseDown:m=>{m.preventDefault()},ref:d,tooltip:l,type:"button",children:e})}function Lm({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,i]=$t(),[l,s]=$t(),a=wm(u=>{i(m=>m!=null?[...m,u]:[u])},[i]),d=u=>{if(n==null)return;let{key:m}=u;["ArrowDown","ArrowUp","Escape","Tab"].includes(m)&&u.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=Nm(()=>({registerItem:a}),[a]);return st(()=>{n!=null&&l==null&&s(n[0]),l!=null&&l?.current!=null&&l.current.focus()},[n,l]),Te(qi.Provider,{value:c,children:Te("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:d,ref:e,children:t})})}function el({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,Icon:n,itemsContainerClassNames:i,label:l,stopCloseOnClickSelf:s}){let a=jo(null),d=jo(null),[c,u]=$t(!1),m=()=>{u(!1),d?.current!=null&&d.current.focus()};st(()=>{let f=d.current,h=a.current;if(c&&f!==null&&h!==null){let{left:g,top:T}=f.getBoundingClientRect(),M=window.scrollY||document.documentElement.scrollTop;h.style.top=`${T+M+f.offsetHeight+5}px`,h.style.left=`${Math.min(g-5,window.innerWidth-h.offsetWidth-20)}px`}},[a,d,c]),st(()=>{let f=d.current;if(f!==null&&c){let h=g=>{let{target:T}=g;s!=null&&a.current!=null&&a.current.contains(T)||f.contains(T)||u(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[a,d,c,s]);let p=km(Te(Lm,{dropDownRef:a,itemsContainerClassNames:i,onClose:m,children:o}),document.body);return Ji(Ft.Fragment,{children:[Ji("button",{"aria-label":t,className:e+(c?" active":""),disabled:r,onClick:f=>{f.preventDefault(),u(!c)},onMouseDown:f=>{f.preventDefault()},ref:d,type:"button",children:[n&&Te(n,{}),l&&Te("span",{className:"toolbar-popup__dropdown-label",children:l}),Te("i",{className:"toolbar-popup__dropdown-caret"})]}),c&&Te(Ft.Fragment,{children:p})]})}var Wo="toolbar-popup__dropdown",ym=t=>{let e=ol(18),{active:o,anchorElem:r,editor:n,enabled:i,item:l}=t,{i18n:s}=Sm(),{fieldProps:a}=B(),{featureClientSchemaMap:d,schemaPath:c}=a;if(l.Component){let f;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==n||e[4]!==i?(f=l?.Component&&$e(l.Component,{active:o,anchorElem:r,editor:n,enabled:i,item:l},l.key),e[0]=l,e[1]=o,e[2]=r,e[3]=n,e[4]=i,e[5]=f):f=e[5],f}let u=l.key,m;if(l.label){let f;e[6]!==l||e[7]!==d||e[8]!==s||e[9]!==c?(f=typeof l.label=="function"?l.label({featureClientSchemaMap:d,i18n:s,schemaPath:c}):l.label,e[6]=l,e[7]=d,e[8]=s,e[9]=c,e[10]=f):f=e[10],u=f}u.length>25?m=u.substring(0,25)+"...":m=u;let p;return e[11]!==l||e[12]!==m||e[13]!==o||e[14]!==n||e[15]!==i||e[16]!==u?(p=$e(Qi,{active:o,editor:n,enabled:i,Icon:l?.ChildComponent?$e(l.ChildComponent,{}):void 0,item:l,tooltip:u,children:$e("span",{className:"text",children:m})},l.key),e[11]=l,e[12]=m,e[13]=o,e[14]=n,e[15]=i,e[16]=u,e[17]=p):p=e[17],p},Re=t=>{let e=ol(42),{anchorElem:o,classNames:r,editor:n,group:i,Icon:l,itemsContainerClassNames:s,label:a,maxActiveItems:d,onActiveChange:c}=t,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];let[m,p]=Go.useState(u),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[1]=f):f=e[1];let[h,g]=Go.useState(f),[T,M]=Go.useState(!0),O=B(),{items:C,key:E}=i,x;e[2]!==n||e[3]!==C||e[4]!==d||e[5]!==O||e[6]!==i||e[7]!==c?(x=()=>{n.getEditorState().read(()=>{let $=Im();if(!$)return;let j=[],Q=[],W=[];for(let G of C)G.isActive&&(!d||j.length<d)&&G.isActive({editor:n,editorConfigContext:O,selection:$})&&(j.push(G.key),Q.push(G)),G.isEnabled?G.isEnabled({editor:n,editorConfigContext:O,selection:$})&&W.push(G.key):W.push(G.key);i.isEnabled&&M(i.isEnabled({editor:n,editorConfigContext:O,selection:$})),p(j),g(W),c&&c({activeItems:Q})})},e[2]=n,e[3]=C,e[4]=d,e[5]=O,e[6]=i,e[7]=c,e[8]=x):x=e[8];let N=x,S,w;e[9]!==N?(S=()=>{N()},w=[N],e[9]=N,e[10]=S,e[11]=w):(S=e[10],w=e[11]),tl(S,w);let k,R;e[12]!==n||e[13]!==N?(k=()=>Rm(n.registerUpdateListener(()=>{N()})),R=[n,N],e[12]=n,e[13]=N,e[14]=k,e[15]=R):(k=e[14],R=e[15]),tl(k,R);let b=`${E} dropdown`,_=`${Wo}-${E}`,I;e[16]!==r?(I=r||[],e[16]=r,e[17]=I):I=e[17];let L;e[18]!==_||e[19]!==I?(L=[Wo,_,...I].filter(Boolean),e[18]=_,e[19]=I,e[20]=L):L=e[20];let D=L.join(" "),v=!T,A;e[21]!==s?(A=s||[],e[21]=s,e[22]=A):A=e[22];let H;if(e[23]!==A||e[24]!==C||e[25]!==m||e[26]!==o||e[27]!==n||e[28]!==h||e[29]!==b||e[30]!==D||e[31]!==v||e[32]!==l||e[33]!==a||e[34]!==E){let $;e[36]!==C||e[37]!==m||e[38]!==o||e[39]!==n||e[40]!==h?($=C.length&&C.map(j=>$e(ym,{active:m.includes(j.key),anchorElem:o,editor:n,enabled:h.includes(j.key),item:j},j.key)),e[36]=C,e[37]=m,e[38]=o,e[39]=n,e[40]=h,e[41]=$):$=e[41],H=$e(el,{buttonAriaLabel:b,buttonClassName:D,disabled:v,Icon:l,itemsContainerClassNames:[`${Wo}-items`,...A],label:a,children:$},E),e[23]=A,e[24]=C,e[25]=m,e[26]=o,e[27]=n,e[28]=h,e[29]=b,e[30]=D,e[31]=v,e[32]=l,e[33]=a,e[34]=E,e[35]=H}else H=e[35];return H};function $m({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&re(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?re(lt,{editor:e,item:o,children:re(o.ChildComponent,{})},o.key):null}function Pm(t){let e=rl(26),{anchorElem:o,editor:r,editorConfig:n,group:i,index:l}=t,{i18n:s}=Am(),{fieldProps:a}=B(),{featureClientSchemaMap:d,schemaPath:c}=a,[u,m]=fe.useState(void 0),[p,f]=fe.useState(void 0),h,g;e[0]!==i?(h=()=>{i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0)},g=[i],e[0]=i,e[1]=h,e[2]=g):(h=e[1],g=e[2]),fe.useEffect(h,g);let T;e[3]!==i||e[4]!==d||e[5]!==s||e[6]!==c?(T=N=>{let{activeItems:S}=N;if(!S.length){i?.type==="dropdown"&&i.items.length&&i.ChildComponent?(f(()=>i.ChildComponent),m(void 0)):(f(void 0),m(void 0));return}let w=S[0],k=w.key;w.label&&(k=typeof w.label=="function"?w.label({featureClientSchemaMap:d,i18n:s,schemaPath:c}):w.label),k.length>25&&(k=k.substring(0,25)+"..."),m(k),f(()=>w.ChildComponent)},e[3]=i,e[4]=d,e[5]=s,e[6]=c,e[7]=T):T=e[7];let M=T,O=`fixed-toolbar__group fixed-toolbar__group-${i.key}`,C;e[8]!==i||e[9]!==p||e[10]!==o||e[11]!==r||e[12]!==u||e[13]!==M?(C=i.type==="dropdown"&&i.items.length&&(p?re(Re,{anchorElem:o,editor:r,group:i,Icon:p,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:u,maxActiveItems:1,onActiveChange:M}):re(Re,{anchorElem:o,editor:r,group:i,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:u,maxActiveItems:1,onActiveChange:M})),e[8]=i,e[9]=p,e[10]=o,e[11]=r,e[12]=u,e[13]=M,e[14]=C):C=e[14];let E;e[15]!==i||e[16]!==o||e[17]!==r?(E=i.type==="buttons"&&i.items.length&&i.items.map(N=>re($m,{anchorElem:o,editor:r,item:N},N.key)),e[15]=i,e[16]=o,e[17]=r,e[18]=E):E=e[18];let x;return e[19]!==n.features.toolbarFixed||e[20]!==l||e[21]!==C||e[22]!==E||e[23]!==O||e[24]!==i.key?(x=vm("div",{className:O,children:[C,E,l<n.features.toolbarFixed?.groups.length-1&&re("div",{className:"divider"})]},i.key),e[19]=n.features.toolbarFixed,e[20]=l,e[21]=C,e[22]=E,e[23]=O,e[24]=i.key,e[25]=x):x=e[25],x}function Bm({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let i=fe.useRef(null),{y:l}=Dm(),s=Fm(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let d=n.editorContainerRef.current.previousElementSibling;for(;d;){if(d.classList.contains("fixed-toolbar"))return d;d=d.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return Om(()=>{if(!s)return;let a=i.current;if(!a)return;let d=a.getBoundingClientRect(),c=s.getBoundingClientRect();if(!(d.bottom<c.top||d.top>c.bottom))a.className="fixed-toolbar fixed-toolbar--overlapping",s.className="fixed-toolbar fixed-toolbar--hide";else{if(!a.classList.contains("fixed-toolbar--overlapping"))return;a.className="fixed-toolbar",s.className="fixed-toolbar"}},50,[i,s,l]),re("div",{className:"fixed-toolbar",onFocus:a=>{a.stopPropagation()},ref:i,children:o.isEditable()&&re(fe.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((a,d)=>re(Pm,{anchorElem:t,editor:o,editorConfig:r,group:a,index:d},a.key))})})}var nl=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return nl(t.parentEditor)}return!1},il=t=>{let e=rl(7),{anchorElem:o,clientProps:r}=t,[n]=Mm(),i=B(),{editorConfig:l}=i,s=r.applyToFocusedEditor&&i.focusedEditor?.editor||n,a=r.applyToFocusedEditor&&i.focusedEditor?.editorConfig||l,d,c;if(e[0]!==i||e[1]!==r?.disableIfParentHasFixedToolbar||e[2]!==a||e[3]!==o||e[4]!==s){c=Symbol.for("react.early_return_sentinel");e:{let u=nl(i);if(r?.disableIfParentHasFixedToolbar&&u){c=null;break e}if(!a?.features?.toolbarFixed?.groups?.length){c=null;break e}d=re(Bm,{anchorElem:o,editor:s,editorConfig:a,parentWithFixedToolbar:u})}e[0]=i,e[1]=r?.disableIfParentHasFixedToolbar,e[2]=a,e[3]=o,e[4]=s,e[5]=d,e[6]=c}else d=e[5],c=e[6];return c!==Symbol.for("react.early_return_sentinel")?c:d};var Hm=y({plugins:[{Component:il,position:"aboveContainer"}]});import{c as al}from"react/compiler-runtime";import{jsx as ie,jsxs as cl}from"react/jsx-runtime";import{useLexicalComposerContext as jm}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ul}from"@lexical/utils";import{$getSelection as dl,$isRangeSelection as ll,$isTextNode as Gm,COMMAND_PRIORITY_LOW as Wm,SELECTION_CHANGE_COMMAND as Um}from"lexical";import{useCallback as Bt,useEffect as at,useRef as sl,useState as Vm}from"react";import*as Ht from"react";import{createPortal as Km}from"react-dom";function Uo(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 Pt(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:i=32,horizontalPosition:l="left",specialHandlingForCaret:s=!1,targetRect:a,verticalGap:d=10}=t,c=o.parentElement;if(a===null||c==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let u=n.getBoundingClientRect(),m=o.getBoundingClientRect(),p=c.getBoundingClientRect(),f=a.top-u.height-d,h=a.left-i;l==="center"&&(h=a.left+a.width/2-u.width/2);let g=0;return!e&&f<p.top&&!s&&(g=u.height+a.height+d*2,f+=g),l==="center"?h+u.width>p.right?h=p.right-u.width-i:h<p.left&&(h=p.left+i):h+u.width>p.right&&(h=p.right-u.width-i),h-=m.left,n.style.opacity="1",s&&r!==0?(f-=m.bottom-r+u.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=m.top,n.style.transform=`translate(${h}px, ${f}px)`),g}function zm({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(lt,{editor:e,item:o,children:ie(o.ChildComponent,{})},o.key):null}function Zm(t){let e=al(22),{anchorElem:o,editor:r,group:n,index:i}=t,{editorConfig:l}=B(),[s,a]=Ht.useState(),d,c;e[0]!==n?(d=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0)},c=[n],e[0]=n,e[1]=d,e[2]=c):(d=e[1],c=e[2]),Ht.useEffect(d,c);let u;e[3]!==n?(u=T=>{let{activeItems:M}=T;if(!M.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0);return}let O=M[0];a(()=>O.ChildComponent)},e[3]=n,e[4]=u):u=e[4];let m=u,p=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;e[5]!==n||e[6]!==s||e[7]!==o||e[8]!==r||e[9]!==m?(f=n.type==="dropdown"&&n.items.length&&(s?ie(Re,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:1,onActiveChange:m}):ie(Re,{anchorElem:o,editor:r,group:n,maxActiveItems:1,onActiveChange:m})),e[5]=n,e[6]=s,e[7]=o,e[8]=r,e[9]=m,e[10]=f):f=e[10];let h;e[11]!==n||e[12]!==o||e[13]!==r?(h=n.type==="buttons"&&n.items.length&&n.items.map(T=>ie(zm,{anchorElem:o,editor:r,item:T},T.key)),e[11]=n,e[12]=o,e[13]=r,e[14]=h):h=e[14];let g;return e[15]!==l.features.toolbarInline||e[16]!==i||e[17]!==f||e[18]!==h||e[19]!==p||e[20]!==n.key?(g=cl("div",{className:p,children:[f,h,i<l.features.toolbarInline?.groups.length-1&&ie("div",{className:"divider"})]},n.key),e[15]=l.features.toolbarInline,e[16]=i,e[17]=f,e[18]=h,e[19]=p,e[20]=n.key,e[21]=g):g=e[21],g}function Xm({anchorElem:t,editor:e}){let o=sl(null),r=sl(null),{editorConfig:n}=B(),i=Bt(()=>{if(o?.current){let d=o.current.style.opacity==="0",c=o.current.style.pointerEvents==="none";d||(o.current.style.opacity="0"),c||(o.current.style.pointerEvents="none")}},[o]),l=Bt(d=>{if(o?.current&&(d.buttons===1||d.buttons===3)){let c=o.current.style.opacity==="0",u=o.current.style.pointerEvents==="none";if(!c||!u){let m=d.clientX,p=d.clientY,f=document.elementFromPoint(m,p);o.current.contains(f)||i()}}},[i]),s=Bt(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);at(()=>(document.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}),[o,l,s]);let a=Bt(()=>{let d=dl(),c=window.getSelection();if(o.current===null)return;let u=t.querySelector(":scope > .link-editor"),m=u!==null&&"style"in u&&u?.style?.opacity==="1",p=e.getRootElement();if(d!==null&&c!==null&&!c.isCollapsed&&p!==null&&p.contains(c.anchorNode)){let f=Uo(c,p),h=Pt({alwaysDisplayOnTop:m,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&Pt({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else i()},[e,i,t]);return at(()=>{let d=t.parentElement,c=()=>{e.getEditorState().read(()=>{a()})};return window.addEventListener("resize",c),d&&d.addEventListener("scroll",c),()=>{window.removeEventListener("resize",c),d&&d.removeEventListener("scroll",c)}},[e,a,t]),at(()=>(e.getEditorState().read(()=>{a()}),ul(e.registerUpdateListener(({editorState:d})=>{d.read(()=>{a()})}),e.registerCommand(Um,()=>(a(),!1),Wm))),[e,a]),cl("div",{className:"inline-toolbar-popup",ref:o,children:[ie("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((d,c)=>ie(Zm,{anchorElem:t,editor:e,group:d,index:c},d.key))]})}function Ym(t,e){let o=al(12),[r,n]=Vm(!1),i;o[0]!==t?(i=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let m=dl(),p=window.getSelection(),f=t.getRootElement();if(p!==null&&(!ll(m)||f===null||!f.contains(p.anchorNode))){n(!1);return}if(!ll(m))return;if(m.getTextContent()!==""){let g=m.getNodes(),T=!1;for(let M of g)if(Gm(M)){n(!0),T=!0;break}T||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]),at(s,a);let d,c;if(o[5]!==t||o[6]!==l?(d=()=>ul(t.registerUpdateListener(()=>{l()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),c=[t,l],o[5]=t,o[6]=l,o[7]=d,o[8]=c):(d=o[7],c=o[8]),at(d,c),!r||!t.isEditable())return null;let u;return o[9]!==e||o[10]!==t?(u=Km(ie(Xm,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=u):u=o[11],u}var ml=t=>{let{anchorElem:e}=t,[o]=jm();return Ym(o,e)};var Jm=y({plugins:[{Component:ml,position:"floatingAnchorElem"}]});import{TableCellNode as $f,TableNode as Pf,TableRowNode as Bf}from"@lexical/table";import{jsx as pl}from"react/jsx-runtime";import"react";var Vo=()=>pl("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:pl("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 lp,$createTableNode as sp,$createTableRowNode as ap,$isTableCellNode as Tl,$isTableNode as Ko,$isTableRowNode as zo,TableCellHeaderStates as jt,TableCellNode as cp,TableNode as up,TableRowNode as dp}from"@lexical/table";import{$isParagraphNode as mp,$isTextNode as pp}from"lexical";var fl=/^[\t ]*$/,qm=/^(\s*)(\d+)\.\s/,Qm=/^(\s*)[-*+]\s/,ep=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,hl=/^(#{1,6})\s/,tp=/^>\s/,gl=/^[ \t]*```(\w+)?/,Cl=/[ \t]*```$/,op=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,rp=/^\|(.+)\|\s?$/,np=/^(\| ?:?-*:? ?)+\|\s?$/,xl=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,bl=/^[ \t]*<\/[a-z_][\w-]*\s*>/i;function ip(t,e=!1){let o=t.split(`
|
|
36
|
-
`),r=!1,n=[];for(let i=0;i<o.length;i++){let l=o[i],s=n[n.length-1];if(
|
|
37
|
-
`)}function
|
|
38
|
-
`)},regExp:
|
|
39
|
-
`);let o=lp(jt.NO_STATUS);return _l(t,e,o),o},El=(t,e)=>{let o=t.match(wl);return!o||!o[1]?null:o[1].split("|").map(r=>kl(r,e))};import{c as Cp}from"react/compiler-runtime";import{jsx as P,jsxs as he}from"react/jsx-runtime";import{useLexicalComposerContext as Il}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as xp}from"@lexical/react/useLexicalEditable";import{$deleteTableColumn__EXPERIMENTAL as bp,$deleteTableRow__EXPERIMENTAL as _p,$getNodeTriplet as Tp,$getTableCellNodeFromLexicalNode as Ep,$getTableColumnIndexFromTableCellNode as wp,$getTableNodeFromLexicalNodeOrThrow as ct,$getTableRowIndexFromTableCellNode as Np,$insertTableColumn__EXPERIMENTAL as kp,$insertTableRow__EXPERIMENTAL as Lp,$isTableCellNode as Gt,$isTableRowNode as Rl,$isTableSelection as Ut,$unmergeCell as Rp,getTableObserverFromTableElement as Sp,TableCellHeaderStates as Ee,TableCellNode as Ip}from"@lexical/table";import{useScrollInfo as yp}from"@payloadcms/ui";import{$createParagraphNode as vp,$getRoot as Mp,$getSelection as Vt,$isElementNode as Dp,$isParagraphNode as yl,$isRangeSelection as Yo,$isTextNode as Op}from"lexical";import*as Jo from"react";import{useCallback as le,useEffect as Se,useRef as Wt,useState as Pe}from"react";import{createPortal as vl}from"react-dom";import{jsx as Zo,jsxs as gp}from"react/jsx-runtime";import"react";var Ll=()=>gp("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Zo("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"}),Zo("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"}),Zo("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 Xo(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Ap(){let t=Vt();if(Yo(t)&&!t.isCollapsed()||Ut(t)&&!t.anchor.is(t.focus)||!Yo(t)&&!Ut(t))return!1;let[e]=Tp(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Sl(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!yl(e)||!e.isEmpty())}function Fp(t){let e=t.getLastDescendant();Op(e)?e.select():Dp(e)?e.selectEnd():e!==null&&e.selectNext()}function $p({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=Il(),l=Wt(null),[s,a]=Pe(n),[d,c]=Pe({columns:1,rows:1}),[u,m]=Pe(!1),[p,f]=Pe(!1),{y:h}=yp();Se(()=>i.registerMutationListener(Ip,b=>{b.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{a(s.getLatest())})},{skipInitialization:!0}),[i,s]),Se(()=>{i.getEditorState().read(()=>{let b=Vt();if(Ut(b)){let _=Xo(b);c(Xo(b)),m(_.columns>1||_.rows>1)}f(Ap())})},[i]),Se(()=>{let b=e.current,_=l.current,I=i.getRootElement();if(b!=null&&_!=null&&I!=null){let L=I.getBoundingClientRect(),D=b.getBoundingClientRect();_.style.opacity="1";let v=_.getBoundingClientRect(),A=5,H=D.right+A;if(H+v.width>window.innerWidth||H+v.width>L.right){let j=D.left-v.width-A;H=(j<0?A:j)+window.pageXOffset}_.style.left=`${H+window.pageXOffset}px`;let $=D.top;if($+v.height>window.innerHeight){let j=D.bottom-v.height;$=(j<0?A:j)+window.pageYOffset}_.style.top=`${$}px`}},[e,l,i,h]),Se(()=>{function b(_){l.current!=null&&e.current!=null&&!l.current.contains(_.target)&&!e.current.contains(_.target)&&r(!1)}return window.addEventListener("click",b),()=>window.removeEventListener("click",b)},[r,e]);let g=le(()=>{i.update(()=>{if(s.isAttached()){let _=ct(s),I=i.getElementByKey(_.getKey());if(!I)throw new Error("Expected to find tableElement in DOM");let L=Sp(I);L!==null&&L.clearHighlight(),_.markDirty(),a(s.getLatest())}Mp().selectStart()})},[i,s]),T=()=>{i.update(()=>{let b=Vt();if(Ut(b)){let{columns:_,rows:I}=Xo(b),L=b.getNodes(),D=null;for(let v=0;v<L.length;v++){let A=L[v];if(Gt(A))if(D===null){A.setColSpan(_).setRowSpan(I),D=A;let H=Sl(A),$;H&&yl($=A.getFirstChild())&&$.remove()}else Gt(D)&&(Sl(A)||D.append(...A.getChildren()),A.remove())}D!==null&&(D.getChildrenSize()===0&&D.append(vp()),Fp(D)),o()}})},M=()=>{i.update(()=>{Rp()})},O=le(b=>{i.update(()=>{Lp(b),o()})},[i,o]),C=le(b=>{i.update(()=>{for(let _=0;_<d.columns;_++)kp(b);o()})},[i,o,d.columns]),E=le(()=>{i.update(()=>{_p(),o()})},[i,o]),x=le(()=>{i.update(()=>{ct(s).remove(),g(),o()})},[i,s,g,o]),N=le(()=>{i.update(()=>{bp(),o()})},[i,o]),S=le(()=>{i.update(()=>{let b=ct(s),_=Np(s),I=b.getChildren();if(_>=I.length||_<0)throw new Error("Expected table cell to be inside of table row.");let L=I[_];if(!Rl(L))throw new Error("Expected table row");let D=s.getHeaderStyles()^Ee.ROW;L.getChildren().forEach(v=>{if(!Gt(v))throw new Error("Expected table cell");v.setHeaderStyles(D,Ee.ROW)}),g(),o()})},[i,s,g,o]),w=le(()=>{i.update(()=>{let b=ct(s),_=wp(s),I=b.getChildren(),L=Math.max(...I.map(v=>v.getChildren().length));if(_>=L||_<0)throw new Error("Expected table cell to be inside of table row.");let D=s.getHeaderStyles()^Ee.COLUMN;for(let v=0;v<I.length;v++){let A=I[v];if(!Rl(A))throw new Error("Expected table row");let H=A.getChildren();if(_>=H.length)continue;let $=H[_];if(!Gt($))throw new Error("Expected table cell");$.setHeaderStyles(D,Ee.COLUMN)}g(),o()})},[i,s,g,o]),k=le(()=>{i.update(()=>{if(s.isAttached()){let b=ct(s);b&&b.setRowStriping(!b.getRowStriping())}g(),o()})},[i,s,g,o]),R=null;return t&&(u?R=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>T(),type:"button",children:"Merge cells"}):p&&(R=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>M(),type:"button",children:"Unmerge cells"}))),vl(he("div",{className:"table-action-menu-dropdown",onClick:b=>{b.stopPropagation()},ref:l,children:[R?he(Jo.Fragment,{children:[R,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>k(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>O(!1),type:"button",children:he("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>O(!0),type:"button",children:he("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>C(!1),type:"button",children:he("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>C(!0),type:"button",children:he("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>N(),type:"button",children:P("span",{className:"text",children:"Delete column"})}),P("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>E(),type:"button",children:P("span",{className:"text",children:"Delete row"})}),P("button",{className:"item","data-test-id":"table-delete",onClick:()=>x(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item",onClick:()=>S(),type:"button",children:he("span",{className:"text",children:[(s.__headerState&Ee.ROW)===Ee.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>w(),type:"button",children:he("span",{className:"text",children:[(s.__headerState&Ee.COLUMN)===Ee.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function Pp({anchorElem:t,cellMerge:e}){let[o]=Il(),r=Wt(null),n=Wt(null),[i,l]=Pe(!1),[s,a]=Pe(null),d=le(()=>{let u=r.current,m=Vt(),p=window.getSelection(),f=document.activeElement;if(m==null||u==null){a(null);return}let h=o.getRootElement();if(Yo(m)&&h!==null&&p!==null&&h.contains(p.anchorNode)){let g=Ep(m.anchor.getNode());if(g==null){a(null);return}if(o.getElementByKey(g.getKey())==null){a(null);return}a(g)}else f||a(null)},[o]);Se(()=>o.registerUpdateListener(()=>{o.getEditorState().read(()=>{d()})})),Se(()=>{let u=r.current;if(u!=null&&s!=null){let m=o.getElementByKey(s.getKey());if(m!=null){let p=m.getBoundingClientRect(),f=u.getBoundingClientRect(),h=t.getBoundingClientRect(),g=p.top-h.top+4,T=p.right-f.width-10-h.left;u.style.opacity="1",u.style.transform=`translate(${T}px, ${g}px)`}else u.style.opacity="0",u.style.transform="translate(-10000px, -10000px)"}},[r,s,o,t]);let c=Wt(s);return Se(()=>{c.current!==s&&l(!1),c.current=s},[c,s]),P("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&he(Jo.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:u=>{u.stopPropagation(),l(!i)},ref:n,type:"button",children:P(Ll,{})}),i&&P($p,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Ml=t=>{let e=Cp(3),{anchorElem:o}=t,r=xp(),n;return e[0]!==r||e[1]!==o?(n=vl(r?P(Pp,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as Bp}from"react/compiler-runtime";import{jsx as Zt,jsxs as Hp}from"react/jsx-runtime";import{useLexicalComposerContext as jp}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Gp}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Wp,$getTableNodeFromLexicalNodeOrThrow as qo,$getTableRowIndexFromTableCellNode as Up,$isTableCellNode as Dl,$isTableRowNode as Vp,getDOMCellFromTarget as Kp,TableNode as zp}from"@lexical/table";import{calculateZoomLevel as Ol}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Qo}from"lexical";import*as $l from"react";import{useCallback as Be,useEffect as Al,useRef as Kt,useState as zt}from"react";import{createPortal as Zp}from"react-dom";var Xp=33,Fl=92;function Yp({editor:t}){let e=Kt(null),o=Kt(null),r=Kt(null),n=B(),i=Kt(null),[l,s]=zt(null),[a,d]=zt(null),[c,u]=zt(!1),[m,p]=zt(null),f=Be(()=>{d(null),e.current=null,p(null),i.current=null,r.current=null},[]),h=w=>(w.buttons&1)===1;Al(()=>t.registerNodeTransform(zp,w=>{if(w.getColWidths())return w;let k=w.getColumnCount(),R=Fl;return w.setColWidths(Array(k).fill(R)),w}),[t]),Al(()=>{let w=_=>{setTimeout(()=>{let I=_.target;if(m){s({x:_.clientX,y:_.clientY});return}if(u(h(_)),!(o.current&&o.current.contains(I))&&e.current!==I){e.current=I;let L=Kp(I);L&&a!==L?t.update(()=>{let D=Qo(L.elem);if(!D)throw new Error("TableCellResizer: Table cell node not found.");let v=qo(D),A=t.getElementByKey(v.getKey());if(!A)throw new Error("TableCellResizer: Table element not found.");e.current=I,r.current=A.getBoundingClientRect(),d(L)}):L==null&&f()}},0)},k=_=>{setTimeout(()=>{u(!0)},0)},R=_=>{setTimeout(()=>{u(!1)},0)},b=t.registerRootListener((_,I)=>{I?.removeEventListener("mousemove",w),I?.removeEventListener("mousedown",k),I?.removeEventListener("mouseup",R),_?.addEventListener("mousemove",w),_?.addEventListener("mousedown",k),_?.addEventListener("mouseup",R)});return()=>{b()}},[a,m,t,f]);let g=w=>w==="bottom",T=Be(w=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let k=Qo(a.elem);if(!Dl(k))throw new Error("TableCellResizer: Table cell node not found.");let R=qo(k),b=Up(k)+k.getRowSpan()-1,_=R.getChildren();if(b>=_.length||b<0)throw new Error("Expected table cell to be inside of table row.");let I=_[b];if(!Vp(I))throw new Error("Expected table row");let L=I.getHeight();if(L===void 0){let v=I.getChildren();L=Math.min(...v.map(A=>M(A,t)??1/0))}let D=Math.max(L+w,Xp);I.setHeight(D)},{tag:"skip-scroll-into-view"})},[a,t]),M=(w,k)=>k.getElementByKey(w.getKey())?.clientHeight,O=(w,k)=>{for(let R=0;R<k.length;R++)for(let b=0;b<k[R].length;b++)if(k[R][b].cell===w)return b},C=Be(w=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let k=Qo(a.elem);if(!Dl(k))throw new Error("TableCellResizer: Table cell node not found.");let R=qo(k),[b]=Wp(R,null,null),_=O(k,b);if(_===void 0)throw new Error("TableCellResizer: Table column not found.");let I=R.getColWidths();if(!I)return;let L=I[_];if(L===void 0)return;let D=[...I],v=Math.max(L+w,Fl);D[_]=v,R.setColWidths(D)},{tag:"skip-scroll-into-view"})},[a,t]),E=Be(w=>{let k=R=>{if(R.preventDefault(),R.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:b,y:_}=i.current;if(a===null)return;let I=Ol(R.target);if(g(w)){let L=(R.clientY-_)/I;T(L)}else{let L=(R.clientX-b)/I;C(L)}f(),document.removeEventListener("mouseup",k)}};return k},[a,f,C,T]),x=Be(w=>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(w),document.addEventListener("mouseup",E(w))},[a,E]),S=Be(()=>{if(a){let{height:w,left:k,top:R,width:b}=a.elem.getBoundingClientRect(),_=Ol(a.elem),I=10,L={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${I}px`,left:`${window.pageXOffset+k}px`,top:`${window.pageYOffset+R+w-I/2}px`,width:`${b}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${w}px`,left:`${window.pageXOffset+k+b-I/2}px`,top:`${window.pageYOffset+R}px`,width:`${I}px`}},D=r.current;return m&&l&&D&&(g(m)?(L[m].left=`${window.pageXOffset+D.left}px`,L[m].top=`${window.pageYOffset+l.y/_}px`,L[m].height="3px",L[m].width=`${D.width}px`):(L[m].top=`${window.pageYOffset+D.top}px`,L[m].left=`${window.pageXOffset+l.x/_}px`,L[m].width="3px",L[m].height=`${D.height}px`),L[m].backgroundColor="#adf"),L}return{bottom:null,left:null,right:null,top:null}},[a,m,l])();return Zt("div",{ref:o,children:a!=null&&!c&&Hp($l.Fragment,{children:[Zt("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:x("right"),style:S.right||void 0}),Zt("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:x("bottom"),style:S.bottom||void 0})]})})}var Pl=()=>{let t=Bp(3),[e]=jp(),o=Gp(),r,n;return t[0]!==o||t[1]!==e?(n=o?Zp(Zt(Yp,{editor:e}),document.body):null,t[0]=o,t[1]=e,t[2]=n):n=t[2],r=n,r};import{c as rf}from"react/compiler-runtime";import{jsx as er,jsxs as nf,Fragment as lf}from"react/jsx-runtime";import{useLexicalComposerContext as Kl}from"@lexical/react/LexicalComposerContext";import{$getTableColumnIndexFromTableCellNode as sf,$getTableRowIndexFromTableCellNode as af,$insertTableColumn__EXPERIMENTAL as cf,$insertTableRow__EXPERIMENTAL as uf,$isTableCellNode as df,$isTableNode as jl,TableNode as mf}from"@lexical/table";import{$findMatchingParent as pf,mergeRegister as ff}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Gl}from"lexical";import{useEffect as Wl,useMemo as hf,useRef as Ul,useState as Xt}from"react";import"react";import{createPortal as gf}from"react-dom";import{useMemo as tf,useRef as of}from"react";var Jp="Expected a function",qp=Math.max,Qp=Math.min;function ef(t,e,o){let r,n,i=0,l,s=!1,a=!1,d,c,u,m=!0;if(typeof t!="function")throw new TypeError(Jp);e=e||0,typeof o=="object"&&(s=!!o.leading,a="maxWait"in o,d=a?qp(o.maxWait||0,e):d,m="trailing"in o?!!o.trailing:m);function p(x){let N=r,S=l;return r=l=void 0,i=x,c=t.apply(S,N),c}function f(x){return i=x,u=setTimeout(T,e),s?p(x):c}function h(x){let N=x-n,S=x-i,w=e-N;return a?Qp(w,d-S):w}function g(x){let N=x-n,S=x-i;return n===void 0||N>=e||N<0||a&&S>=d}function T(){let x=Date.now();if(g(x))return M(x);u=setTimeout(T,h(x))}function M(x){return u=void 0,m&&r?p(x):(r=l=void 0,c)}function O(){u!==void 0&&clearTimeout(u),i=0,r=n=l=u=void 0}function C(){return u===void 0?c:M(Date.now())}function E(){let x=Date.now(),N=g(x);if(r=arguments,l=this,n=x,N){if(u===void 0)return f(n);if(a)return clearTimeout(u),u=setTimeout(T,e),p(n)}return u===void 0&&(u=setTimeout(T,e)),c}return E.cancel=O,E.flush=C,E}var Bl=ef;function Hl(t,e,o){let r=of(null);return r.current=t,tf(()=>Bl((...n)=>{r.current&&r.current(...n)},e,{maxWait:o}),[e,o])}var Vl=20;function Cf({anchorElem:t}){let[e]=Kl(),o=B(),[r,n]=Xt(!1),[i,l]=Xt(!1),[s,a]=Xt(!1),[d,c]=Xt({}),u=Ul(new Set),m=Ul(null),p=Hl(g=>{let{isOutside:T,tableDOMNode:M}=xf(g,o.editorConfig?.lexical);if(T){n(!1),l(!1);return}if(!M)return;m.current=M;let O=null,C=null,E=null;if(e.update(()=>{let x=Gl(M);if(df(x)){let N=pf(x,S=>jl(S));if(!jl(N))return;if(E=e.getElementByKey(N?.getKey()),E){let S=N.getChildrenSize(),w=N.getChildAtIndex(0)?.getChildrenSize(),k=af(x),R=sf(x);k===S-1?O=x:R===w-1&&(C=x)}}}),E){let{bottom:x,height:N,left:S,right:w,width:k,y:R}=E.getBoundingClientRect(),{left:b,y:_}=t.getBoundingClientRect();O?(l(!1),n(!0),c({height:Vl,left:S-b,top:x-_+5,width:k})):C&&(l(!0),n(!1),c({height:N,left:w-b+5,top:R-_,width:Vl}))}},50,250),f=hf(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);Wl(()=>{if(s)return document.addEventListener("mousemove",p),()=>{n(!1),l(!1),document.removeEventListener("mousemove",p)}},[s,p]),Wl(()=>ff(e.registerMutationListener(mf,g=>{e.getEditorState().read(()=>{for(let[T,M]of g){let O=e.getElementByKey(T);switch(M){case"created":u.current.add(T),a(u.current.size>0),O&&f.observe(O);break;case"destroyed":u.current.delete(T),a(u.current.size>0),f.disconnect(),u.current.forEach(C=>{let E=e.getElementByKey(C);E&&f.observe(E)});break;default:break}}})},{skipInitialization:!1})),[e,f]);let h=g=>{e.update(()=>{m.current&&(Gl(m.current)?.selectEnd(),g?(uf(),n(!1)):(cf(),l(!1)))})};return e?.isEditable()?nf(lf,{children:[r&&er("button",{className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...d}}),i&&er("button",{className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...d}})]}):null}function xf(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 zl(t){let e=rf(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=Kl();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=gf(er(Cf,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as bf}from"react/compiler-runtime";import{jsx as tr,jsxs as _f}from"react/jsx-runtime";import{useLexicalComposerContext as Tf}from"@lexical/react/LexicalComposerContext";import{TablePlugin as Ef}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as wf,TableNode as Nf}from"@lexical/table";import{mergeRegister as kf}from"@lexical/utils";import{formatDrawerSlug as Lf,useEditDepth as Rf}from"@payloadcms/ui";import{$getSelection as Sf,$isRangeSelection as If,COMMAND_PRIORITY_EDITOR as yf,createCommand as vf}from"lexical";import{createContext as Mf,useContext as Df,useEffect as Of,useMemo as Af,useState as Ff}from"react";import*as Zl from"react";var Yt=vf("OPEN_EMBED_DRAWER_COMMAND"),Xl=Mf({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Yl({children:t}){let[e,o]=Ff({cellEditorConfig:null,cellEditorPlugins:null});return tr(Xl.Provider,{value:Af(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Jl=()=>{let t=bf(16),[e]=Tf(),o=Df(Xl),r=Rf(),{fieldProps:n,uuid:i}=B(),{schemaPath:l}=n,s="lexical-table-create-"+i,a;t[0]!==s||t[1]!==r?(a=Lf({slug:s,depth:r}),t[0]=s,t[1]=r,t[2]=a):a=t[2];let d=a,{toggleDrawer:c}=xe(d,!0),u;t[3]!==e||t[4]!==c?(u=()=>{if(!e.hasNodes([Nf]))throw new Error("TablePlugin: TableNode is not registered on editor");return kf(e.registerCommand(Yt,()=>{let h;return h=null,e.getEditorState().read(()=>{let g=Sf();If(g)&&(h=g)}),h&&c(),!0},yf))},t[3]=e,t[4]=c,t[5]=u):u=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],Of(u,m);let p;t[10]!==e?(p=(h,g)=>{!g.columns||!g.rows||e.dispatchCommand(wf,{columns:String(g.columns),rows:String(g.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==d||t[13]!==p||t[14]!==l?(f=_f(Zl.Fragment,{children:[tr(je,{drawerSlug:d,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:l,schemaPathSuffix:"fields"}),tr(Ef,{hasCellBackgroundColor:!1,hasCellMerge:!0})]}),t[12]=d,t[13]=p,t[14]=l,t[15]=f):f=t[15],f};var Hf=y({markdownTransformers:[Nl],nodes:[Pf,$f,Bf],plugins:[{Component:Jl,position:"normal"},{Component:Pl,position:"normal"},{Component:Ml,position:"floatingAnchorElem"},{Component:zl,position:"floatingAnchorElem"}],providers:[Yl],slashMenu:{groups:[K([{Icon:Vo,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Yt,{})}}])]},toolbarFixed:{groups:[ce([{ChildComponent:Vo,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Yt,{})}}])]}});import{$isNodeSelection as c1}from"lexical";import{jsx as or,jsxs as jf}from"react/jsx-runtime";import"react";var rr=()=>jf("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:[or("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"}),or("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"}),or("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{c as Yf}from"react/compiler-runtime";import{jsx as Jf}from"react/jsx-runtime";import{useLexicalComposerContext as qf}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Qf,mergeRegister as e1}from"@lexical/utils";import{useConfig as t1}from"@payloadcms/ui";import{$getPreviousSelection as o1,$getSelection as r1,$isParagraphNode as Ql,$isRangeSelection as n1,COMMAND_PRIORITY_EDITOR as i1,createCommand as l1}from"lexical";import{useEffect as s1}from"react";import{c as Gf}from"react/compiler-runtime";import{jsx as nr}from"react/jsx-runtime";import{useLexicalComposerContext as Wf}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as Uf,COMMAND_PRIORITY_EDITOR as Vf}from"lexical";import{useEffect as Kf,useState as zf}from"react";var Zf=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Uf(o);n&&n.replace(ze({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(ir,{fields:null,relationTo:e,value:r})},Xf=t=>{let e=Gf(13),{enabledCollectionSlugs:o}=t,[r]=Wf(),[n,i]=zf(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:d}=Dt(l),c,u;e[2]!==r||e[3]!==d?(c=()=>r.registerCommand(Ve,h=>(i(h?.replace?h?.replace.nodeKey:null),d(),!0),Vf),u=[r,d],e[2]=r,e[3]=d,e[4]=c,e[5]=u):(c=e[4],u=e[5]),Kf(c,u);let m;e[6]!==s||e[7]!==r||e[8]!==n?(m=h=>{let{collectionSlug:g,docID:T}=h;s(),Zf({editor:r,relationTo:g,replaceNodeKey:n,value:T})},e[6]=s,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,f;return e[10]!==p||e[11]!==a?(f=nr(a,{onSelect:p}),e[10]=p,e[11]=a,e[12]=f):f=e[12],f},ql=t=>nr(ft,{...t,uploads:!0,children:nr(Xf,{...t})});var ir=l1("INSERT_UPLOAD_COMMAND"),es=t=>{let e=Yf(5),[o]=qf(),{config:r}=t1(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([Ke]))throw new Error("UploadPlugin: UploadNode not registered on editor");return e1(o.registerCommand(ir,a=>(o.update(()=>{let d=r1()||o1();if(n1(d)){let c=ze({data:{id:a.id,fields:a.fields,relationTo:a.relationTo,value:a.value}});Qf(c);let{focus:u}=d,m=u.getNode();Ql(m)&&m.getTextContentSize()===0&&m.getParentOrThrow().getChildren().filter(p=>Ql(p)).length>1&&m.remove()}}),!0),i1))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),s1(i,l);let s;return e[3]!==n?(s=Jf(ql,{enabledCollectionSlugs:n.map(a1)}),e[3]=n,e[4]=s):s=e[4],s};function a1(t){let{slug:e}=t;return e}var u1=y({nodes:[Ke],plugins:[{Component:es,position:"normal"}],slashMenu:{groups:[K([{Icon:rr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]},toolbarFixed:{groups:[ce([{ChildComponent:rr,isActive:({selection:t})=>{if(!c1(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return no(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]}});import{c as d1}from"react/compiler-runtime";import{jsx as sr}from"react/jsx-runtime";import{ShimmerEffect as m1}from"@payloadcms/ui";import{lazy as p1,Suspense as f1,useEffect as h1,useState as g1}from"react";var ts={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",tableCellEditing:"LexicalEditorTheme__tableCellEditing",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellPrimarySelected:"LexicalEditorTheme__tableCellPrimarySelected",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableCellSortedIndicator:"LexicalEditorTheme__tableCellSortedIndicator",tableResizeRuler:"LexicalEditorTheme__tableCellResizeRuler",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableSelected:"LexicalEditorTheme__tableSelected",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 Jt={namespace:"lexical",theme:ts};function os({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 rs=t=>{let e={enabledFeatures:[],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.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 lr(t,e,o){return{admin:o,features:rs(t),lexical:e,resolvedFeatureMap:t}}var C1=p1(()=>import("./Field-IS3XMKMO.js").then(t=>({default:t.RichText}))),x1=t=>{let e=d1(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 d=a,c=l===void 0?Jt:l,[u,m]=g1(null),p,f;e[2]!==u||e[3]!==r||e[4]!==c||e[5]!==n||e[6]!==i||e[7]!==s||e[8]!==d?(p=()=>{if(u)return;let g=[];for(let[O,C]of Object.entries(r))C.clientFeatureProvider&&g.push(C.clientFeatureProvider(C.clientFeatureProps));let T=c||Jt,M=os({featureClientSchemaMap:n,field:i,schemaPath:s??i.name,unSanitizedEditorConfig:{features:g,lexical:T}});m(lr(M,T,d))},f=[c,d,u,r,n,i,s],e[2]=u,e[3]=r,e[4]=c,e[5]=n,e[6]=i,e[7]=s,e[8]=d,e[9]=p,e[10]=f):(p=e[9],f=e[10]),h1(p,f);let h;return e[11]!==u||e[12]!==t?(h=sr(f1,{fallback:sr(m1,{height:"35vh"}),children:u&&sr(C1,{...t,editorConfig:u})}),e[11]=u,e[12]=t,e[13]=h):h=e[13],h};function b1(...t){return t.filter(Boolean).join(" ")}var qt=new WeakMap;function ns(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function Qt(t,e){let o=qt.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=ns(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let a=ns(l);for(let d of r)a!==null&&d([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},qt.set(t,o)}return o.listeners.add(e),()=>{_1(t,e)}}function _1(t,e){let o=qt.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(qt.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function T1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function E1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function w1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function N1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}var F={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},k1=F.IS_BOLD|F.IS_ITALIC|F.IS_STRIKETHROUGH|F.IS_UNDERLINE|F.IS_CODE|F.IS_SUBSCRIPT|F.IS_SUPERSCRIPT|F.IS_HIGHLIGHT,L1="\xA0",R1=`
|
|
34
|
+
`},[t,e]),p=we((x,T)=>{o(C=>{let _=e.length-1,N=e[_];if(N&&N.name===x){if(x==="type")return[...e.slice(0,_),{...N,value:N.value+T}];if(N.value===T)return[...e.slice(0,_),{...N,count:N.count+1}]}return[...C,{name:x,count:1,value:T}]})},[e,o]);jr(()=>{let x=C=>{if(!r)return;let _=C.key;va(C)?p("selectAll",""):Ur.has(_)?p("press",C.key):[..._].length>1?p("keydown",C.key):p("type",C.key)},T=C=>{if(!r)return;let _=C.key;!Ur.has(_)&&[..._].length>1&&p("keyup",C.key)};return t.registerRootListener((C,_)=>{_!==null&&(_.removeEventListener("keydown",x),_.removeEventListener("keyup",T)),C!==null&&(C.addEventListener("keydown",x),C.addEventListener("keyup",T))})},[t,r,p]),jr(()=>{c.current&&c.current.scrollTo(0,c.current.scrollHeight)},[m]),go(()=>{if(e){let x=m();x!==null&&s(x),c.current&&c.current.scrollTo(0,c.current.scrollHeight)}},[m,e]),go(()=>t.registerUpdateListener(({dirtyElements:T,dirtyLeaves:C,editorState:_})=>{if(!r)return;let N=_._selection,k=a.current,L=d.current;if(k!==N){if(C.size===0&&T.size===0&&!L){let b=window.getSelection();if(b&&(b.anchorNode==null||b.focusNode==null))return}a.current=N}d.current=!1;let S=m();S!==null&&s(S)}),[t,m,r,p]),go(()=>r?t.registerUpdateListener(()=>{let T=t.getRootElement();T!==null&&i(T?.innerHTML)}):void 0,[t,r]);let f=we(x=>{r||(x.update(()=>{let T=Ra();T.clear();let C=La();T.append(Na().append(C)),C.select()}),o([])),n(T=>!T)},[r]),h=we(()=>{if(!r)return;let x=window.getSelection();if(x===null||x.anchorNode==null||x.focusNode==null)return;let{anchorNode:T,anchorOffset:C,focusNode:_,focusOffset:N}=Ma(x),k=u().getRootElement(),L;T!==null&&(L=Gr(T,k));let S;_!==null&&(S=Gr(_,k)),p("snapshot",{anchorNode:T,anchorOffset:C,anchorPath:L,focusNode:_,focusOffset:N,focusPath:S})},[p,r,u]),g=we(()=>{Sa(m())},[m]),E=we(()=>{Ia("test.js",m())},[m]);return[ke("button",{className:`editor-dev-button ${r?"active":""}`,id:"test-recorder-button",onClick:x=>{f(u()),x.preventDefault()},title:r?"Disable test recorder":"Enable test recorder",type:"button",children:r?"Disable test recorder":"Enable test recorder"}),r?xo("div",{className:"test-recorder-output",children:[xo("div",{className:"test-recorder-toolbar",children:[ke("button",{className:"test-recorder-button",id:"test-recorder-button-snapshot",onClick:x=>{h(),x.preventDefault()},title:"Insert snapshot",type:"button",children:"Insert Snapshot"}),ke("button",{className:"test-recorder-button",id:"test-recorder-button-copy",onClick:x=>{g(),x.preventDefault()},title:"Copy to clipboard",type:"button",children:"Copy"}),ke("button",{className:"test-recorder-button",id:"test-recorder-button-download",onClick:x=>{E(),x.preventDefault()},title:"Download as a file",type:"button",children:"Download"})]}),ke("pre",{id:"test-recorder",ref:c,children:l})]}):null]}var Vr=()=>{let t=wa(3),[e]=ka(),[o,r]=Da(e),n;return t[0]!==o||t[1]!==r?(n=xo(Wr.Fragment,{children:[ke("p",{children:"HI"}),o,r,ke("p",{children:"DONE"})]}),t[0]=o,t[1]=r,t[2]=n):n=t[2],n};var Aa=y({plugins:[{Component:Vr,position:"bottom"}]});import{c as Oa}from"react/compiler-runtime";import{jsx as Fa}from"react/jsx-runtime";import{useLexicalComposerContext as $a}from"@lexical/react/LexicalComposerContext.js";import{TreeView as Pa}from"@lexical/react/LexicalTreeView.js";import"react";var Kr=()=>{let t=Oa(2),[e]=$a(),o;return t[0]!==e?(o=Fa(Pa,{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 Ba=y({plugins:[{Component:Kr,position:"bottom"}]});import{$isTableSelection as Ha}from"@lexical/table";import{$isRangeSelection as ja,FORMAT_TEXT_COMMAND as Ga}from"lexical";import{jsx as zr}from"react/jsx-runtime";import"react";var Zr=()=>zr("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:zr("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 Z=t=>({type:"buttons",items:t,key:"format",order:40});var Xr={type:"text-format",format:["bold","italic"],tag:"***"},Yr={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},Jr={type:"text-format",format:["bold"],tag:"**"},qr={type:"text-format",format:["bold"],intraword:!1,tag:"__"};var Qr=[Z([{ChildComponent:Zr,isActive:({selection:t})=>ja(t)||Ha(t)?t.hasFormat("bold"):!1,key:"bold",onSelect:({editor:t})=>{t.dispatchCommand(Ga,"bold")},order:1}])],Ua=y(({featureProviderMap:t})=>{let e=[Jr,qr];return t.get("italic")&&e.push(Yr,Xr),{markdownTransformers:e,toolbarFixed:{groups:Qr},toolbarInline:{groups:Qr}}});import{$isTableSelection as Va}from"@lexical/table";import{$isRangeSelection as Ka,FORMAT_TEXT_COMMAND as za}from"lexical";import{jsx as en,jsxs as Wa}from"react/jsx-runtime";import"react";var tn=()=>Wa("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:[en("path",{d:"M7.76465 6L3.76465 10L7.76465 14",stroke:"currentColor"}),en("path",{d:"M12.2354 6L16.2354 10L12.2354 14",stroke:"currentColor"})]});var on={type:"text-format",format:["code"],tag:"`"};var rn=[Z([{ChildComponent:tn,isActive:({selection:t})=>Ka(t)||Va(t)?t.hasFormat("code"):!1,key:"inlineCode",onSelect:({editor:t})=>{t.dispatchCommand(za,"code")},order:7}])],Za=y({markdownTransformers:[on],toolbarFixed:{groups:rn},toolbarInline:{groups:rn}});import{$isTableSelection as Xa}from"@lexical/table";import{$isRangeSelection as Ya,FORMAT_TEXT_COMMAND as Ja}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:"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 sn={type:"text-format",format:["italic"],tag:"*"},an={type:"text-format",format:["italic"],intraword:!1,tag:"_"};var cn=[Z([{ChildComponent:ln,isActive:({selection:t})=>Ya(t)||Xa(t)?t.hasFormat("italic"):!1,key:"italic",onSelect:({editor:t})=>{t.dispatchCommand(Ja,"italic")},order:2}])],qa=y({markdownTransformers:[sn,an],toolbarFixed:{groups:cn},toolbarInline:{groups:cn}});import{$isTableSelection as ec}from"@lexical/table";import{$isRangeSelection as tc,FORMAT_TEXT_COMMAND as oc}from"lexical";import{jsx as un,jsxs as Qa}from"react/jsx-runtime";import"react";var dn=()=>Qa("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:[un("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"}),un("path",{d:"M4.99756 11.44H15.0026V12.19H4.99756V11.44Z",fill:"currentColor"})]});var mn={type:"text-format",format:["strikethrough"],tag:"~~"};var pn=[Z([{ChildComponent:dn,isActive:({selection:t})=>tc(t)||ec(t)?t.hasFormat("strikethrough"):!1,key:"strikethrough",onSelect:({editor:t})=>{t.dispatchCommand(oc,"strikethrough")},order:4}])],rc=y({markdownTransformers:[mn],toolbarFixed:{groups:pn},toolbarInline:{groups:pn}});import{$isTableSelection as nc}from"@lexical/table";import{$isRangeSelection as ic,FORMAT_TEXT_COMMAND as lc}from"lexical";import{jsx as fn}from"react/jsx-runtime";import"react";var hn=()=>fn("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:fn("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 gn=[Z([{ChildComponent:hn,isActive:({selection:t})=>ic(t)||nc(t)?t.hasFormat("subscript"):!1,key:"subscript",onSelect:({editor:t})=>{t.dispatchCommand(lc,"subscript")},order:5}])],sc=y({toolbarFixed:{groups:gn},toolbarInline:{groups:gn}});import{$isTableSelection as ac}from"@lexical/table";import{$isRangeSelection as cc,FORMAT_TEXT_COMMAND as uc}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:"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 bn=[Z([{ChildComponent:xn,isActive:({selection:t})=>cc(t)||ac(t)?t.hasFormat("superscript"):!1,key:"superscript",onSelect:({editor:t})=>{t.dispatchCommand(uc,"superscript")},order:6}])],dc=y({toolbarFixed:{groups:bn},toolbarInline:{groups:bn}});import{$isTableSelection as pc}from"@lexical/table";import{$isRangeSelection as fc,FORMAT_TEXT_COMMAND as hc}from"lexical";import{jsx as _n,jsxs as mc}from"react/jsx-runtime";import"react";var Tn=()=>mc("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:[_n("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"}),_n("path",{d:"M5.09961 16.3H14.9016V16.95H5.09961V16.3Z",fill:"currentColor"})]});var En=[Z([{ChildComponent:Tn,isActive:({selection:t})=>fc(t)||pc(t)?t.hasFormat("underline"):!1,key:"underline",onSelect:({editor:t})=>{t.dispatchCommand(hc,"underline")},order:3}])],gc=y({toolbarFixed:{groups:En},toolbarInline:{groups:En}});import{$createHeadingNode as _c,$isHeadingNode as Fn,HeadingNode as Tc}from"@lexical/rich-text";import{$setBlocksType as Ec}from"@lexical/selection";import{$getSelection as wc,$isRangeSelection as kc}from"lexical";import{jsx as wn}from"react/jsx-runtime";import"react";var kn=()=>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:"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 Nn}from"react/jsx-runtime";import"react";var Ln=()=>Nn("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:Nn("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 Rn}from"react/jsx-runtime";import"react";var Sn=()=>Rn("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:Rn("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 In}from"react/jsx-runtime";import"react";var yn=()=>In("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:In("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 vn}from"react/jsx-runtime";import"react";var Mn=()=>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.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 Dn}from"react/jsx-runtime";import"react";var An=()=>Dn("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:Dn("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 Cc,$isHeadingNode as xc,HeadingNode as bc}from"@lexical/rich-text";var bo=t=>(e,o,r)=>{let n=t(r);n&&(n.append(...o),e.replace(n),n.select(0,0))};var On=t=>{let o=`^(${t.map(n=>Number(n.slice(1))).map(n=>`#{${n}}`).join("|")})\\s`,r=new RegExp(o);return{type:"element",dependencies:[bc],export:(n,i)=>{if(!xc(n))return null;let l=Number(n.getTag().slice(1));return"#".repeat(l)+" "+i(n)},regExp:r,replace:bo(n=>{let i="h"+n[1].length;return Cc(i)})}};var $n=t=>{let e=wc();Ec(e,()=>_c(t))},Pn={h1:kn,h2:Ln,h3:Sn,h4:yn,h5:Mn,h6:An},Nc=y(({props:t})=>{let{enabledHeadingSizes:e=["h1","h2","h3","h4","h5","h6"]}=t,o=[J(e.map((r,n)=>({ChildComponent:Pn[r],isActive:({selection:i})=>{if(!kc(i))return!1;for(let l of i.getNodes()){if(Fn(l)&&l.getTag()===r)continue;let s=l.getParent();if(!(Fn(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(()=>{$n(r)})},order:n+2})))];return{markdownTransformers:[On(e)],nodes:[Tc],sanitizedClientFeatureProps:t,slashMenu:{groups:e?.length?[K(e.map(r=>({Icon:Pn[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(()=>{$n(r)})}})))]:[]},toolbarFixed:{groups:e?.length?o:[]},toolbarInline:{groups:e?.length?o:[]}}});import{$isNodeSelection as Ac}from"lexical";import{jsx as Bn}from"react/jsx-runtime";import"react";var _o=()=>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("rect",{fill:"currentColor",height:"1",width:"12",x:"4",y:"9.5"})});import{jsx as Hn,jsxs as Lc}from"react/jsx-runtime";import"react";var jn=()=>Lc("svg",{fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Hn("path",{d:"M5 10h10",stroke:"currentColor"}),Hn("path",{d:"M10 15V5",stroke:"currentColor"})]});var ue=t=>({type:"dropdown",ChildComponent:jn,items:t,key:"add",order:10});var Gn={type:"element",dependencies:[pt],export:(t,e)=>ht(t)?"---":null,regExp:/^---\s*$/,replace:t=>{let e=ft();e&&t.replace(e)}};import{c as Rc}from"react/compiler-runtime";import{useLexicalComposerContext as Sc}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Ic}from"@lexical/utils";import{$getSelection as yc,$isRangeSelection as vc,COMMAND_PRIORITY_EDITOR as Mc}from"lexical";import{useEffect as Dc}from"react";var Un=()=>{let t=Rc(3),[e]=Sc(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Be,n=>{let i=yc();if(!vc(i))return!1;if(i.focus.getNode()!==null){let s=ft();Ic(s)}return!0},Mc),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Dc(o,r),null};var Oc=y({markdownTransformers:[Gn],nodes:[pt],plugins:[{Component:Un,position:"normal"}],slashMenu:{groups:[K([{Icon:_o,key:"horizontalRule",keywords:["hr","horizontal rule","line","separator"],label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(Be,void 0)}}])]},toolbarFixed:{groups:[ue([{ChildComponent:_o,isActive:({selection:t})=>{if(!Ac(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return ht(e)},key:"horizontalRule",label:({i18n:t})=>t.t("lexical:horizontalRule:label"),onSelect:({editor:t})=>{t.dispatchCommand(Be,void 0)}}])]}});import{INDENT_CONTENT_COMMAND as Pc,OUTDENT_CONTENT_COMMAND as Bc}from"lexical";import{jsx as St,jsxs as Fc}from"react/jsx-runtime";import"react";var Wn=()=>Fc("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:[St("path",{d:"M2.5 5H10.5",stroke:"currentColor",strokeWidth:"1.5"}),St("path",{d:"M2.5 10H10.5",stroke:"currentColor",strokeWidth:"1.5"}),St("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"}),St("path",{d:"M12.25 7.25L17.25 3.75V10.75L12.25 7.25Z",fill:"currentColor"})]});import{jsx as It,jsxs as $c}from"react/jsx-runtime";import"react";var Vn=()=>$c("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[It("path",{d:"M17.5 5H9.5",stroke:"currentColor",strokeWidth:"1.5"}),It("path",{d:"M17.5 10H9.5",stroke:"currentColor",strokeWidth:"1.5"}),It("path",{d:"M17.5 15H2.5",stroke:"currentColor",strokeWidth:"1.5"}),It("path",{d:"M7.75 7.25L2.75 3.75V10.75L7.75 7.25Z",fill:"currentColor"})]});var Kn=t=>({type:"buttons",items:t,key:"indent",order:35});var zn=[Kn([{ChildComponent:Wn,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(Bc,void 0)},order:1},{ChildComponent:Vn,isActive:()=>!1,key:"indentIncrease",label:({i18n:t})=>t.t("lexical:indent:increaseLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Pc,void 0)},order:2}])],Hc=y({toolbarFixed:{groups:zn},toolbarInline:{groups:zn}});import{$findMatchingParent as Ju}from"@lexical/utils";import{$getSelection as So,$isRangeSelection as ki}from"lexical";import{jsx as Zn}from"react/jsx-runtime";import"react";var Xn=()=>Zn("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:Zn("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 Yn}from"@lexical/selection";function Me(t){let{anchor:e}=t,{focus:o}=t,r=t.anchor.getNode(),n=t.focus.getNode();return r===n?r:t.isBackward()?Yn(o)?r:n:Yn(e)?r:n}var To=t=>({type:"buttons",items:t,key:"features",order:50});import{$createTextNode as Jc,$isTextNode as qc}from"lexical";import{addClassNamesToElement as jc,isHTMLAnchorElement as Gc}from"@lexical/utils";import ko from"bson-objectid";import{$applyNodeReplacement as Uc,$createTextNode as Jn,$getSelection as Wc,$isElementNode as qn,$isRangeSelection as wo,createCommand as Vc,ElementNode as Kc}from"lexical";var zc=new Set(["http:","https:","mailto:","sms:","tel:"]),q=class t extends Kc{__fields;__id;constructor({id:e,fields:o={doc:null,linkType:"custom",newTab:!1,url:""},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:Zc,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 ko.default().toHexString(),e.version=3);let o=de({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=Eo(o.rel,"add","noopener")),jc(o,e.theme.link),o}exportJSON(){let e={...super.exportJSON(),type:"link",fields:this.getFields(),version:3},o=this.getID();return o&&(e.id=o),e}extractWithChild(e,o,r){if(!wo(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(qn(r)){let n=de({fields:this.__fields});return r.append(n),n}return null}isInline(){return!0}sanitizeUrl(e){try{let o=new URL(e);if(!zc.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=Eo(o.rel,"add","noopener"))):(o.removeAttribute("target"),o.rel=Eo(o.rel,"remove","noopener"))),!1}};function Zc(t){let e=null;if(Gc(t)){let o=t.textContent;o!==null&&o!==""&&(e=de({id:new ko.default().toHexString(),fields:{doc:null,linkType:"custom",newTab:t.getAttribute("target")==="_blank",url:t.getAttribute("href")??""}}))}return{node:e}}function de({id:t,fields:e}){return Uc(new q({id:t??new ko.default().toHexString(),fields:e}))}function V(t){return t instanceof q}var ne=Vc("TOGGLE_LINK_COMMAND");function Qn(t){let e=Wc();if(!wo(e)&&!t.selectedNodes?.length)return;let o=wo(e)?e.extract():t.selectedNodes;if(t===null)o?.forEach(r=>{let n=r.getParent();if(V(n)){let i=n.getChildren();for(let l=0;l<i.length;l+=1)n.insertBefore(i[l]);n.remove()}});else{if(o?.length===1){let i=o[0],l=V(i)?i:Xc(i);if(l!==null){l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(Jn(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||qn(i)&&!i.isInline())){if(V(l)){n=l,l.setFields(t.fields),t.text!=null&&t.text!==l.getTextContent()&&(l.append(Jn(t.text)),l.getChildren().forEach(s=>{s!==l.getLastChild()&&s.remove()}));return}if(l.is(r)||(r=l,n=de({fields:t.fields}),V(l)?i.getPreviousSibling()===null?l.insertBefore(n):l.insertAfter(n):i.insertBefore(n)),V(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 Xc(t){return Yc(t,e=>V(e))}function Yc(t,e){let o=t;for(;o!==null&&(o=o.getParent(),!(o===null||e(o))););return o}function Eo(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 ei={type:"text-match",dependencies:[q],export:(t,e,o)=>{if(!V(t))return null;let r=t,{url:n}=r.getFields(),i=`[${r.getTextContent()}](${n})`,l=r.getFirstChild();return r.getChildrenSize()===1&&qc(l)?o(l,i):i},importRegExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)/,regExp:/\[([^[]+)\]\(([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?\)$/,replace:(t,e)=>{let[,o,r]=e,n=de({fields:{doc:null,linkType:"custom",newTab:!1,url:r}}),i=Jc(o);i.setFormat(t.getFormat()),n.append(i),t.replace(n)},trigger:")"};import{$applyNodeReplacement as Qc,$isElementNode as eu}from"lexical";var me=class t extends q{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=qe({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(eu(r)){let n=qe({fields:this.__fields});return r.append(n),n}return null}};function qe({fields:t}){return Qc(new me({id:"",fields:t}))}function pe(t){return t instanceof me}import{c as tu}from"react/compiler-runtime";import{useLexicalComposerContext as ou}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ru}from"@lexical/utils";import{$createTextNode as ti,$getSelection as nu,$isElementNode as ri,$isLineBreakNode as ni,$isNodeSelection as iu,$isRangeSelection as lu,$isTextNode as Qe,TextNode as su}from"lexical";import{useEffect as au}from"react";function oi(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 ii(t,e){for(let o=0;o<e.length;o++){let r=e[o](t);if(r!=null)return r}return null}var cu=/[.,;\s]/;function vt(t){return cu.test(t)}function li(t){return vt(t[t.length-1])}function Lo(t){return vt(t[0])}function uu(t,e){return e?/^\.[a-z]{2,}/i.test(t):/^\.[a-z0-9]+/i.test(t)}function si(t){let e=t.getPreviousSibling();return ri(e)&&(e=e.getLastDescendant()),e===null||ni(e)||Qe(e)&&li(e.getTextContent())}function ai(t){let e=t.getNextSibling();return ri(e)&&(e=e.getFirstDescendant()),e===null||ni(e)||Qe(e)&&Lo(e.getTextContent())}function du(t,e,o,r){return(t>0?vt(o[t-1]):si(r[0]))?e<o.length?vt(o[e]):ai(r[r.length-1]):!1}function mu(t,e,o){let r=[],n=[],i=[],l=0,s=0,a=[...t];for(;a.length>0;){let d=a[0],u=d.getTextContent().length,m=s;s+u<=e?(r.push(d),l+=u):m>=o?i.push(d):n.push(d),s+=u,a.shift()}return[l,r,n,i]}function pu(t,e,o,r){let n={linkType:"custom",url:r.url,...r.fields},i=qe({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=ti(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 d=[],c;for(let f=1;f<t.length;f++){let h=t[f],E=h.getTextContent().length,M=s,D=s+E;if(M<o)if(D<=o)d.push(h);else{let[x,T]=h.splitText(o-M);d.push(x),c=T}s+=E}let u=nu(),m=u?u.getNodes().find(Qe):void 0,p=ti(a.getTextContent());return p.setFormat(a.getFormat()),p.setDetail(a.getDetail()),p.setStyle(a.getStyle()),i.append(p,...d),m&&m===a&&(lu(u)?p.select(u.anchor.offset,u.focus.offset):iu(u)&&p.select(0,p.getTextContent().length)),a.replace(i),c}}function fu(t,e,o){let r=[...t],n=r.map(a=>a.getTextContent()).join(""),i=n,l,s=0;for(;(l=ii(i,e))!=null&&l!==null;){let a=l.index,d=l.length,c=a+d;if(du(s+a,s+c,n,r)){let[m,,p,f]=mu(r,s+a,s+c),h=s+a-m,g=s+c-m,E=pu(p,h,g,l);r=E?[E,...f]:f,o(l.url,null),s=0}else s+=c;i=i.substring(c)}}function No(t,e,o){let r=t.getChildren(),n=r.length;for(let a=0;a<n;a++){let d=r[a];if(!Qe(d)||!d.isSimpleText()){yt(t),o(null,t.getFields()?.url??null);return}}let i=t.getTextContent(),l=ii(i,e);if(l===null||l.text!==i){yt(t),o(null,t.getFields()?.url??null);return}if(!si(t)||!ai(t)){yt(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 hu(t,e,o){let r=t.getPreviousSibling(),n=t.getNextSibling(),i=t.getTextContent();if(pe(r)){let l=r.getFields()?.url?r.getFields()?.url?.startsWith("mailto:"):!1;(!Lo(i)||uu(i,l))&&(r.append(t),No(r,e,o),o(null,r.getFields()?.url??null))}pe(n)&&!li(i)&&(yt(n),No(n,e,o),o(null,n.getFields()?.url??null))}function yt(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 gu(t){let e=[t],o=t.getNextSibling();for(;o!==null&&Qe(o)&&o.isSimpleText()&&(e.push(o),!/\s/.test(o.getTextContent()));)o=o.getNextSibling();return e}function Cu(t,e,o){let r=tu(5),n,i;r[0]!==t||r[1]!==o||r[2]!==e?(n=()=>{if(!t.hasNodes([me]))throw new Error("LexicalAutoLinkPlugin: AutoLinkNode not registered on editor");let l=(s,a)=>{o?.(s,a)};return ru(t.registerNodeTransform(su,s=>{let a=s.getParentOrThrow(),d=s.getPreviousSibling();if(pe(a))No(a,e,l);else if(!V(a)){if(s.isSimpleText()&&(Lo(s.getTextContent())||!pe(d))){let c=gu(s);fu(c,e,l)}hu(s,e,l)}}))},i=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=n,r[4]=i):(n=r[3],i=r[4]),au(n,i)}var xu=/((https?:\/\/(www\.)?)|(www\.))[-\w@:%.+~#=]{1,256}\.[a-zA-Z\d()]{1,6}\b([-\w()@:%+.~#?&/=]*)(?<![-.+():%])/,bu=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-\d]+\.)+[a-z]{2,}))/i,_u=[oi(xu,t=>t.startsWith("http")?t:`https://${t}`),oi(bu,t=>`mailto:${t}`)],ci=()=>{let[t]=ou();return Cu(t,_u),null};import{jsx as Tu}from"react/jsx-runtime";import{ClickableLinkPlugin as Eu}from"@lexical/react/LexicalClickableLinkPlugin.js";import"react";var ui=()=>Tu(Eu,{});import{jsx as Bu}from"react/jsx-runtime";import"react";import{createPortal as Hu}from"react-dom";import{jsx as fe,jsxs as et,Fragment as ku}from"react/jsx-runtime";import{useLexicalComposerContext as Nu}from"@lexical/react/LexicalComposerContext.js";import{$findMatchingParent as di,mergeRegister as mi}from"@lexical/utils";import{getTranslation as Ro}from"@payloadcms/translations";import{CloseMenuIcon as Lu,EditIcon as Ru,ExternalLinkIcon as pi,formatDrawerSlug as Su,useConfig as Iu,useEditDepth as yu,useLocale as vu,useTranslation as Mu}from"@payloadcms/ui";import{requests as Du}from"@payloadcms/ui/shared";import{$getSelection as fi,$isLineBreakNode as Au,$isRangeSelection as hi,COMMAND_PRIORITY_HIGH as Ou,COMMAND_PRIORITY_LOW as gi,KEY_ESCAPE_COMMAND as Fu,SELECTION_CHANGE_COMMAND as $u}from"lexical";import Ci,{useCallback as xi,useEffect as At,useRef as Pu,useState as Ne}from"react";function Mt(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(),d=t.top-r,c=t.left-n;d<a.top&&(d+=l.height+t.height+r*2),c+l.width>a.right&&(c=a.right-l.width-n),d-=s.top,c-=s.left,e.style.opacity="1",e.style.transform=`translate(${c}px, ${d}px)`}import{createCommand as wu}from"lexical";var Dt=wu("TOGGLE_LINK_WITH_MODAL_COMMAND");function bi({anchorElem:t}){let[e]=Nu(),[o,r]=Ne(),n=Pu(null),[i,l]=Ne(null),[s,a]=Ne(null),{fieldProps:{schemaPath:d},uuid:c}=B(),{config:u}=Iu(),{i18n:m,t:p}=Mu(),[f,h]=Ne(),g=yu(),[E,M]=Ne(!1),[D,x]=Ne([]),T=vu(),[C,_]=Ne(!1),N=Su({slug:"lexical-rich-text-link-"+c,depth:g}),{toggleDrawer:k}=ae(N),L=xi(()=>{M(!1),n&&n.current&&(n.current.style.opacity="0",n.current.style.transform="translate(-10000px, -10000px)"),_(!1),l(null),a(null),x([]),h(void 0)},[M,l,a,x]),S=xi(()=>{let b=fi(),w;if(!hi(b)||!b){L();return}let I=Me(b);w=e.getElementByKey(I.getKey())?.getBoundingClientRect();let R=di(I,V),A=b.getNodes().filter(G=>!Au(G)).find(G=>{let j=di(G,V);return R&&!R.is(j)||j&&!j.is(R)});if(R==null||A){L();return}r(R);let v=R.getFields(),O={...v,id:R.getID(),text:R.getTextContent()};if(v?.linkType==="custom")l(v?.url??null),a(null);else{l(`${u.routes.admin==="/"?"":u.routes.admin}/collections/${v?.doc?.relationTo}/${v?.doc?.value}`);let G=u.collections.find(j=>j.slug===v?.doc?.relationTo);if(!G)a(v?.label?String(v?.label):null),l(v?.url?String(v?.url):null);else{let j=typeof v.doc?.value=="object"?v.doc.value.id:v.doc?.value,se=v.doc?.relationTo;if(!j||!se)throw new Error("Focus link parent is missing doc.value or doc.relationTo");let Ie=p("fields:linkedTo",{label:`${Ro(G.labels.singular,m)} - ${p("lexical:link:loadingWithEllipsis",m)}`}).replace(/<[^>]*>?/g,"");a(Ie),Du.get(`${u.serverURL}${u.routes.api}/${se}/${j}`,{headers:{"Accept-Language":m.language},params:{depth:0,locale:T?.code}}).then(async Ce=>{if(!Ce.ok)throw new Error(`HTTP error! Status: ${Ce.status}`);let mt=await Ce.json(),cr=G?.admin?.useAsTitle||"id",U=mt[cr],ee=p("fields:linkedTo",{label:`${Ro(G.labels.singular,m)} - ${U}`}).replace(/<[^>]*>?/g,"");a(ee)}).catch(()=>{let Ce=p("fields:linkedTo",{label:`${Ro(G.labels.singular,m)} - ${p("general:untitled",m)} - ID: ${j}`}).replace(/<[^>]*>?/g,"");a(Ce)})}}h(O),M(!0),x(b?b?.getNodes():[]),pe(R)?_(!0):_(!1);let H=n.current,$=window.getSelection(),{activeElement:W}=document;if(H===null)return;let Q=e.getRootElement();return $!==null&&Q!==null&&Q.contains($.anchorNode)?(w||(w=$.getRangeAt(0).getBoundingClientRect()),w!=null&&(w.y+=40,Mt(w,H,t))):(W==null||W.className!=="link-input")&&(Q!==null&&Mt(null,H,t),l(null),a(null)),!0},[e,L,u.routes.admin,u.routes.api,u.collections,u.serverURL,p,m,T?.code,t]);return At(()=>mi(e.registerCommand(Dt,b=>(e.dispatchCommand(ne,b),S(),k(),!0),gi)),[e,S,k,N]),At(()=>{let b=t.parentElement,w=()=>{e.getEditorState().read(()=>{S()})};return window.addEventListener("resize",w),b?.addEventListener("scroll",w),()=>{window.removeEventListener("resize",w),b?.removeEventListener("scroll",w)}},[t.parentElement,e,S]),At(()=>mi(e.registerUpdateListener(({editorState:b})=>{b.read(()=>{S()})}),e.registerCommand($u,()=>(S(),!0),gi),e.registerCommand(Fu,()=>E?(L(),!0):!1,Ou)),[e,S,E,L]),At(()=>{e.getEditorState().read(()=>{S()})},[e,S]),et(Ci.Fragment,{children:[fe("div",{className:"link-editor",ref:n,children:et("div",{className:"link-input",children:[i&&i.length>0?et("a",{href:i,rel:"noopener noreferrer",target:"_blank",children:[o?.__fields.newTab?fe(pi,{}):null,s!=null&&s.length>0?s:i]}):s!=null&&s.length>0?et(ku,{children:[o?.__fields.newTab?fe(pi,{}):null,fe("span",{className:"link-input__label-pure",children:s})]}):null,e.isEditable()&&et(Ci.Fragment,{children:[fe("button",{"aria-label":"Edit link",className:"link-edit",onClick:()=>{k()},onMouseDown:b=>{b.preventDefault()},tabIndex:0,type:"button",children:fe(Ru,{})}),!C&&fe("button",{"aria-label":"Remove link",className:"link-trash",onClick:()=>{e.dispatchCommand(ne,null)},onMouseDown:b=>{b.preventDefault()},tabIndex:0,type:"button",children:fe(Lu,{})})]})]})}),fe(He,{className:"lexical-link-edit-drawer",data:f,drawerSlug:N,drawerTitle:p("fields:editLink"),featureKey:"link",handleDrawerSubmit:(b,w)=>{let I=w,R={...I};delete R.text,e.update(()=>{let A=fi(),v=null;if(hi(A)?v=Me(A).getParent():D.length&&(v=D[0].getParent()),v&&pe(v)){let O=de({fields:R});v.replace(O,!0)}}),e.dispatchCommand(ne,{fields:R,selectedNodes:D,text:I.text})},schemaPath:d,schemaPathSuffix:"fields"})]})}var _i=t=>{let{anchorElem:e=document.body}=t;return Hu(Bu(bi,{anchorElem:e}),e)};import{c as Uu}from"react/compiler-runtime";import{useLexicalComposerContext as Wu}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Vu}from"@lexical/utils";import{$getSelection as Ku,$isElementNode as zu,$isRangeSelection as Zu,COMMAND_PRIORITY_LOW as Ei,PASTE_COMMAND as Xu}from"lexical";import{useEffect as Yu}from"react";var ju=/(?:[A-Za-z]{3,9}:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z\d.-]+)(?:\/[+~%/.\w-]*)?\??[-+=&;%@.\w]*#?\w*/,Gu=/^[\w\-./]*(?:#\w[\w-]*)?$/;function Ti(t){if(!t)return!1;if(t==="https://"||ju.test(t)||Gu.test(t))return!0;try{return new URL(t),!0}catch{}return!1}var wi=()=>{let t=Uu(3),[e]=Wu(),o,r;return t[0]!==e?(o=()=>{if(!e.hasNodes([q]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Vu(e.registerCommand(ne,n=>(Qn(n),!0),Ei),e.registerCommand(Xu,n=>{let i=Ku();if(!Zu(i)||i.isCollapsed()||!(n instanceof ClipboardEvent)||n.clipboardData==null)return!1;let l=n.clipboardData.getData("text");if(!Ti(l))return!1;if(!i.getNodes().some(s=>zu(s))){let s={doc:null,linkType:"custom",newTab:!1,url:l};return e.dispatchCommand(ne,{fields:s,text:null}),n.preventDefault(),!0}return!1},Ei))},r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Yu(o,r),null};var Ni=[To([{ChildComponent:Xn,isActive:({selection:t})=>{if(ki(t)){let e=Me(t);return Ju(e,V)!=null}return!1},isEnabled:({selection:t})=>!!(ki(t)&&So()?.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=So()?.getTextContent(),r=So()?.getNodes()??[]}),!o?.length)return;let n={doc:null,linkType:"custom",newTab:!1,url:"https://"};t.dispatchCommand(Dt,{fields:n,selectedNodes:r,text:o})}},order:1}])],qu=y({markdownTransformers:[ei],nodes:[q,me],plugins:[{Component:wi,position:"normal"},{Component:ci,position:"normal"},{Component:ui,position:"normal"},{Component:_i,position:"floatingAnchorElem"}],toolbarFixed:{groups:Ni},toolbarInline:{groups:Ni}});import{$isListNode as vo,INSERT_CHECK_LIST_COMMAND as vi,ListItemNode as ud,ListNode as dd}from"@lexical/list";import{$isRangeSelection as md}from"lexical";import{jsx as Li,jsxs as Qu}from"react/jsx-runtime";import"react";var Io=()=>Qu("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:[Li("rect",{height:"13",rx:"1.5",stroke:"currentColor",width:"13",x:"3.5",y:"3.5"}),Li("path",{d:"M7 10L9 12.5L13 7.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as ed}from"react/jsx-runtime";import{ListPlugin as td}from"@lexical/react/LexicalListPlugin.js";import"react";var De=()=>ed(td,{});function Ae(t){return{items:t,key:"lists",label:({i18n:e})=>e.t("lexical:general:slashMenuListGroupLabel")}}import{$isListNode as id,ListItemNode as ld,ListNode as sd}from"@lexical/list";import{$createListItemNode as od,$createListNode as rd,$isListItemNode as nd,$isListNode as yo}from"@lexical/list";var Ri=4,Oe=t=>(e,o,r)=>{let n=e.getPreviousSibling(),i=e.getNextSibling(),l=od(t==="check"?r[3]==="x":void 0);if(yo(i)&&i.getListType()===t){let a=i.getFirstChild();a!==null?a.insertBefore(l):i.append(l),e.remove()}else if(yo(n)&&n.getListType()===t)n.append(l),e.remove();else{let a=rd(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/Ri);s&&l.setIndent(s)},Le=(t,e,o)=>{let r=[],n=t.getChildren(),i=0;for(let l of n)if(nd(l)){if(l.getChildrenSize()===1){let c=l.getFirstChild();if(yo(c)){r.push(Le(c,e,o+1));continue}}let s=" ".repeat(o*Ri),a=t.getListType(),d=a==="number"?`${t.getStart()+i}. `:a==="check"?`- [${l.getChecked()?"x":" "}] `:"- ";r.push(s+d+e(l)),i++}return r.join(`
|
|
35
|
+
`)};var Si={type:"element",dependencies:[sd,ld],export:(t,e)=>id(t)?Le(t,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:Oe("check")};import{jsx as ad}from"react/jsx-runtime";import{CheckListPlugin as cd}from"@lexical/react/LexicalCheckListPlugin.js";import"react";var Ii=()=>ad(cd,{});var yi=[J([{ChildComponent:Io,isActive:({selection:t})=>{if(!md(t))return!1;for(let e of t.getNodes()){if(vo(e)&&e.getListType()==="check")continue;let o=e.getParent();if(vo(o)&&o.getListType()==="check")continue;let r=o?.getParent();if(!(vo(r)&&r.getListType()==="check"))return!1}return!0},key:"checklist",label:({i18n:t})=>t.t("lexical:checklist:label"),onSelect:({editor:t})=>{t.dispatchCommand(vi,void 0)},order:12}])],pd=y(({featureProviderMap:t})=>{let e=[{Component:Ii,position:"normal"}];return!t.has("unorderedList")&&!t.has("orderedList")&&e.push({Component:De,position:"normal"}),{markdownTransformers:[Si],nodes:t.has("unorderedList")||t.has("orderedList")?[]:[dd,ud],plugins:e,slashMenu:{groups:[Ae([{Icon:Io,key:"checklist",keywords:["check list","check","checklist","cl"],label:({i18n:o})=>o.t("lexical:checklist:label"),onSelect:({editor:o})=>{o.dispatchCommand(vi,void 0)}}])]},toolbarFixed:{groups:yi},toolbarInline:{groups:yi}}});import{$isListNode as Do,INSERT_ORDERED_LIST_COMMAND as Ai,ListItemNode as xd,ListNode as bd}from"@lexical/list";import{$isRangeSelection as _d}from"lexical";import{jsx as tt,jsxs as fd}from"react/jsx-runtime";import"react";var Mo=()=>fd("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:[tt("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"}),tt("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"}),tt("path",{d:"M8 15L17 15",stroke:"currentColor",strokeWidth:"1.5"}),tt("path",{d:"M8 10L17 10",stroke:"currentColor",strokeWidth:"1.5"}),tt("path",{d:"M8 5L17 5",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as hd,ListItemNode as gd,ListNode as Cd}from"@lexical/list";var Mi={type:"element",dependencies:[Cd,gd],export:(t,e)=>hd(t)?Le(t,e,0):null,regExp:/^(\s*)(\d+)\.\s/,replace:Oe("number")};var Di=[J([{ChildComponent:Mo,isActive:({selection:t})=>{if(!_d(t))return!1;for(let e of t.getNodes()){if(Do(e)&&e.getListType()==="number")continue;let o=e.getParent();if(Do(o)&&o.getListType()==="number")continue;let r=o?.getParent();if(!(Do(r)&&r.getListType()==="number"))return!1}return!0},key:"orderedList",label:({i18n:t})=>t.t("lexical:orderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ai,void 0)},order:10}])],Td=y(({featureProviderMap:t})=>({markdownTransformers:[Mi],nodes:t.has("orderedList")?[]:[bd,xd],plugins:t.has("orderedList")?[]:[{Component:De,position:"normal"}],slashMenu:{groups:[Ae([{Icon:Mo,key:"orderedList",keywords:["ordered list","ol"],label:({i18n:e})=>e.t("lexical:orderedList:label"),onSelect:({editor:e})=>{e.dispatchCommand(Ai,void 0)}}])]},toolbarFixed:{groups:Di},toolbarInline:{groups:Di}}));import{$isListNode as Oo,INSERT_UNORDERED_LIST_COMMAND as $i,ListItemNode as Ld,ListNode as Rd}from"@lexical/list";import{$isRangeSelection as Sd}from"lexical";import{jsx as Fe,jsxs as Ed}from"react/jsx-runtime";import"react";var Ao=()=>Ed("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:[Fe("circle",{cx:"4",cy:"5",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Fe("circle",{cx:"4",cy:"10",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Fe("circle",{cx:"4",cy:"15",fill:"currentColor",r:"1.15",stroke:"currentColor",strokeWidth:"0.3"}),Fe("path",{d:"M17 5H7",stroke:"currentColor",strokeWidth:"1.5"}),Fe("path",{d:"M17 10H7",stroke:"currentColor",strokeWidth:"1.5"}),Fe("path",{d:"M17 15H7",stroke:"currentColor",strokeWidth:"1.5"})]});import{$isListNode as wd,ListItemNode as kd,ListNode as Nd}from"@lexical/list";var Oi={type:"element",dependencies:[Nd,kd],export:(t,e)=>wd(t)?Le(t,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:Oe("bullet")};var Fi=[J([{ChildComponent:Ao,isActive:({selection:t})=>{if(!Sd(t))return!1;for(let e of t.getNodes()){if(Oo(e)&&e.getListType()==="bullet")continue;let o=e.getParent();if(Oo(o)&&o.getListType()==="bullet")continue;let r=o?.getParent();if(!(Oo(r)&&r.getListType()==="bullet"))return!1}return!0},key:"unorderedList",label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand($i,void 0)},order:11}])],Id=y({markdownTransformers:[Oi],nodes:[Rd,Ld],plugins:[{Component:De,position:"normal"}],slashMenu:{groups:[Ae([{Icon:Ao,key:"unorderedList",keywords:["unordered list","ul"],label:({i18n:t})=>t.t("lexical:unorderedList:label"),onSelect:({editor:t})=>{t.dispatchCommand($i,void 0)}}])]},toolbarFixed:{groups:Fi},toolbarInline:{groups:Fi}});import{jsx as yd}from"react/jsx-runtime";import{addClassNamesToElement as vd}from"@lexical/utils";import{DecoratorNode as Md}from"lexical";import*as Pi from"react";var Dd=Pi.lazy(()=>import("./Component-MBLHTKDK.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),ot=class t extends Md{__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 Ad({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return vd(o,"unknownConverted"),o}decorate(){return yd(Dd,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function Ad({data:t}){return new ot({data:t})}var Od=y(()=>({nodes:[ot]}));import{jsx as Fd}from"react/jsx-runtime";import{addClassNamesToElement as $d}from"@lexical/utils";import{DecoratorNode as Pd}from"lexical";import*as Bi from"react";var Bd=Bi.lazy(()=>import("./Component-DOSSWC76.js").then(t=>({default:t.UnknownConvertedNodeComponent}))),rt=class t extends Pd{__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 Hd({data:e.data})}canInsertTextAfter(){return!0}canInsertTextBefore(){return!0}createDOM(e){let o=document.createElement("span");return $d(o,"unknownConverted"),o}decorate(){return Fd(Bd,{data:this.__data})}exportJSON(){return{type:this.getType(),data:this.__data,version:1}}isInline(){return!0}updateDOM(e,o){return!1}};function Hd({data:t}){return new rt({data:t})}var jd=y(()=>({nodes:[rt]}));import{$setBlocksType as Gi}from"@lexical/selection";import{$createParagraphNode as Ui,$getSelection as Wi,$isParagraphNode as Hi,$isRangeSelection as Gd}from"lexical";var ji=[J([{ChildComponent:ze,isActive:({selection:t})=>{if(!Gd(t))return!1;for(let e of t.getNodes())if(!Hi(e)&&!Hi(e.getParent()))return!1;return!0},key:"paragraph",label:({i18n:t})=>t.t("lexical:paragraph:label2"),onSelect:({editor:t})=>{t.update(()=>{let e=Wi();Gi(e,()=>Ui())})},order:1}])],Ud=y({slashMenu:{groups:[K([{Icon:ze,key:"paragraph",keywords:["normal","paragraph","p","text"],label:({i18n:t})=>t.t("lexical:paragraph:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Wi();Gi(e,()=>Ui())})}}])]},toolbarFixed:{groups:ji},toolbarInline:{groups:ji}});import{$isNodeSelection as Cm}from"lexical";import{jsx as nt,jsxs as Wd}from"react/jsx-runtime";import"react";var Fo=()=>Wd("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:[nt("g",{clipPath:"url(#clip0_4397_10817)",children:nt("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"})}),nt("defs",{children:nt("clipPath",{id:"clip0_4397_10817",children:nt("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{c as im}from"react/compiler-runtime";import{jsx as lm}from"react/jsx-runtime";import{useLexicalComposerContext as sm}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as am}from"@lexical/utils";import{useConfig as cm}from"@payloadcms/ui";import{$getPreviousSelection as um,$getSelection as dm,$isParagraphNode as Yi,$isRangeSelection as mm,COMMAND_PRIORITY_EDITOR as pm,createCommand as fm}from"lexical";import{useEffect as hm}from"react";import{c as em}from"react/compiler-runtime";import{jsx as Ot}from"react/jsx-runtime";import{useLexicalComposerContext as tm}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as om,COMMAND_PRIORITY_EDITOR as rm}from"lexical";import{useEffect as Ki,useState as zi}from"react";import{c as Vd}from"react/compiler-runtime";import{jsx as Kd}from"react/jsx-runtime";import{useLexicalComposerContext as zd}from"@lexical/react/LexicalComposerContext";import{useListDrawer as Zd,useModal as Xd}from"@payloadcms/ui";import{$getPreviousSelection as Yd,$getSelection as Jd,$setSelection as qd}from"lexical";import{useEffect as Qd,useState as Vi}from"react";var it=t=>{let e=Vd(23),[o]=zd(),[r,n]=Vi(null),[i,l]=Vi(!1),[s,a,d]=Zd(t),{closeDrawer:c,drawerSlug:u,isDrawerOpen:m,openDrawer:p}=d,{modalState:f}=Xd(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let L=Jd()??Yd();n(L)},e[0]=h):h=e[0];let g=h,E;e[1]!==r||e[2]!==o?(E=()=>{r&&o.update(()=>{qd(r.clone())},{discrete:!0,skipTransforms:!0})},e[1]=r,e[2]=o,e[3]=E):E=e[3];let M=E,D;e[4]!==c?(D=()=>{c()},e[4]=c,e[5]=D):D=e[5];let x=D,T,C;e[6]!==i||e[7]!==f||e[8]!==u||e[9]!==M?(T=()=>{if(!i)return;let L=f[u];L&&!L?.isOpen&&(l(!1),setTimeout(()=>{M()},1))},C=[f,u,M,i],e[6]=i,e[7]=f,e[8]=u,e[9]=M,e[10]=T,e[11]=C):(T=e[10],C=e[11]),Qd(T,C);let _;e[12]!==a?(_=L=>Kd(a,{...L,onClick:()=>{g()}}),e[12]=a,e[13]=_):_=e[13];let N;e[14]!==p?(N=()=>{g(),p(),l(!0)},e[14]=p,e[15]=N):N=e[15];let k;return e[16]!==x||e[17]!==m||e[18]!==s||e[19]!==u||e[20]!==_||e[21]!==N?(k={closeListDrawer:x,isListDrawerOpen:m,ListDrawer:s,listDrawerSlug:u,ListDrawerToggler:_,openListDrawer:N},e[16]=x,e[17]=m,e[18]=s,e[19]=u,e[20]=_,e[21]=N,e[22]=k):k=e[22],k};var nm=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=om(o);n&&n.replace(Ue({relationTo:e,value:r}))}):t.dispatchCommand($o,{relationTo:e,value:r})},Zi=t=>{let e=em(21),{enabledCollectionSlugs:o}=t,[r]=tm(),n;e[0]!==o?(n=()=>o?.[0],e[0]=o,e[1]=n):n=e[1];let[i,l]=zi(n),[s,a]=zi(null),d=o||void 0,c;e[2]!==d||e[3]!==i?(c={collectionSlugs:d,selectedCollection:i},e[2]=d,e[3]=i,e[4]=c):c=e[4];let{closeListDrawer:u,isListDrawerOpen:m,ListDrawer:p,openListDrawer:f}=it(c),h,g;e[5]!==r||e[6]!==f?(h=()=>r.registerCommand(je,C=>(a(C?.replace?C?.replace.nodeKey:null),f(),!0),rm),g=[r,f],e[5]=r,e[6]=f,e[7]=h,e[8]=g):(h=e[7],g=e[8]),Ki(h,g);let E;e[9]!==r||e[10]!==s||e[11]!==u?(E=C=>{let{collectionSlug:_,docID:N}=C;nm({editor:r,relationTo:_,replaceNodeKey:s,value:N}),u()},e[9]=r,e[10]=s,e[11]=u,e[12]=E):E=e[12];let M=E,D;e[13]!==o?(D=()=>{l(o?.[0])},e[13]=o,e[14]=D):D=e[14];let x;e[15]!==m||e[16]!==o?(x=[m,o],e[15]=m,e[16]=o,e[17]=x):x=e[17],Ki(D,x);let T;return e[18]!==M||e[19]!==p?(T=Ot(p,{onSelect:M}),e[18]=M,e[19]=p,e[20]=T):T=e[20],T},Xi=t=>(t?.enabledCollectionSlugs?.length??-1)>0?Ot(Zi,{...t}):Ot(gt,{...t,children:Ot(Zi,{...t})});var $o=fm("INSERT_RELATIONSHIP_COMMAND"),Ji=t=>{let e=im(10),{clientProps:o}=t,[r]=sm(),{config:n}=cm(),{collections:i}=n,l=null;if(o?.enabledCollections)l=o?.enabledCollections;else if(o?.disabledCollections){let c;if(e[0]!==o||e[1]!==i){let u;e[3]!==o?(u=m=>{let{slug:p}=m;return!o?.disabledCollections?.includes(p)},e[3]=o,e[4]=u):u=e[4],c=i.filter(u).map(gm),e[0]=o,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($o,c=>{let u=dm()||um();if(mm(u)){let m=Ue(c);am(m);let{focus:p}=u,f=p.getNode();Yi(f)&&f.getTextContentSize()===0&&f.getParentOrThrow().getChildren().filter(h=>Yi(h)).length>1&&f.remove()}return!0},pm)},a=[r],e[5]=r,e[6]=s,e[7]=a):(s=e[6],a=e[7]),hm(s,a);let d;return e[8]!==l?(d=lm(Xi,{enabledCollectionSlugs:l}),e[8]=l,e[9]=d):d=e[9],d};function gm(t){let{slug:e}=t;return e}var xm=y({nodes:[Ge],plugins:[{Component:Ji,position:"normal"}],slashMenu:{groups:[K([{Icon:Fo,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(je,{replace:!1})}}])]},toolbarFixed:{groups:[ue([{ChildComponent:Fo,isActive:({selection:t})=>{if(!Cm(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return ro(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(je,{replace:!1})}}])]}});import{c as nl}from"react/compiler-runtime";import{jsx as re,jsxs as Om}from"react/jsx-runtime";import{useLexicalComposerContext as Fm}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as $m,useThrottledEffect as Pm,useTranslation as Bm}from"@payloadcms/ui";import*as he from"react";import{useMemo as Hm}from"react";import{c as bm}from"react/compiler-runtime";import{jsx as _m}from"react/jsx-runtime";import{mergeRegister as Tm}from"@lexical/utils";import{$addUpdateTag as Em,$getSelection as wm}from"lexical";import{useEffect as Ft,useState as Po}from"react";var Bo="toolbar-popup__button",lt=t=>{let e=bm(34),{children:o,editor:r,item:n}=t,[i,l]=Po(!0),[s,a]=Po(!1),[d,c]=Po(Bo),u=B(),m;e[0]!==r||e[1]!==n||e[2]!==u||e[3]!==s||e[4]!==i?(m=()=>{r.getEditorState().read(()=>{let N=wm();if(N){if(n.isActive){let k=n.isActive({editor:r,editorConfigContext:u,selection:N});s!==k&&a(k)}if(n.isEnabled){let k=n.isEnabled({editor:r,editorConfigContext:u,selection:N});i!==k&&l(k)}}})},e[0]=r,e[1]=n,e[2]=u,e[3]=s,e[4]=i,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]),Ft(f,h);let g,E;e[9]!==p?(g=()=>(document.addEventListener("mouseup",p),()=>{document.removeEventListener("mouseup",p)}),E=[p],e[9]=p,e[10]=g,e[11]=E):(g=e[10],E=e[11]),Ft(g,E);let M,D;e[12]!==r||e[13]!==p?(M=()=>Tm(r.registerUpdateListener(()=>{p()})),D=[r,p],e[12]=r,e[13]=p,e[14]=M,e[15]=D):(M=e[14],D=e[15]),Ft(M,D);let x;e[16]!==i||e[17]!==s||e[18]!==n?(x=()=>{c([Bo,i===!1?"disabled":"",s?"active":"",n?.key?`${Bo}-`+n.key:""].filter(Boolean).join(" "))},e[16]=i,e[17]=s,e[18]=n,e[19]=x):x=e[19];let T;e[20]!==i||e[21]!==s||e[22]!==d||e[23]!==n.key?(T=[i,s,d,n.key],e[20]=i,e[21]=s,e[22]=d,e[23]=n.key,e[24]=T):T=e[24],Ft(x,T);let C;e[25]!==i||e[26]!==r||e[27]!==n.onSelect||e[28]!==s?(C=()=>{if(i!==!1)return r.focus(()=>{r.update(()=>{Em("toolbar")}),n.onSelect?.({editor:r,isActive:s})}),!0},e[25]=i,e[26]=r,e[27]=n.onSelect,e[28]=s,e[29]=C):C=e[29];let _;return e[30]!==d||e[31]!==C||e[32]!==o?(_=_m("button",{className:d,onClick:C,onMouseDown:km,type:"button",children:o}),e[30]=d,e[31]=C,e[32]=o,e[33]=_):_=e[33],_};function km(t){t.preventDefault()}import{c as rl}from"react/compiler-runtime";import{jsx as $e}from"react/jsx-runtime";import Go,{useEffect as ol}from"react";import{mergeRegister as vm}from"@lexical/utils";import{useTranslation as Mm}from"@payloadcms/ui";import{$getSelection as Dm}from"lexical";import{jsx as Te,jsxs as qi}from"react/jsx-runtime";import{Button as Nm}from"@payloadcms/ui";import{$addUpdateTag as Lm}from"lexical";import $t,{useCallback as Rm,useEffect as st,useMemo as Sm,useRef as jo,useState as Pt}from"react";import{createPortal as Im}from"react-dom";var Ho="toolbar-popup__dropdown-item",Qi=$t.createContext(null);function el({active:t,children:e,editor:o,enabled:r,Icon:n,item:i,tooltip:l}){let[s,a]=Pt(Ho);st(()=>{a([Ho,r===!1?"disabled":"",t?"active":"",i?.key?`${Ho}-${i.key}`:""].filter(Boolean).join(" "))},[r,t,s,i.key]);let d=jo(null),c=$t.useContext(Qi);if(c===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:u}=c;return st(()=>{d?.current!=null&&u(d)},[d,u]),Te(Nm,{"aria-label":l,buttonStyle:"none",className:s,disabled:r===!1,icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{Lm("toolbar")}),i.onSelect?.({editor:o,isActive:t})})},onMouseDown:m=>{m.preventDefault()},ref:d,tooltip:l,type:"button",children:e})}function ym({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,i]=Pt(),[l,s]=Pt(),a=Rm(u=>{i(m=>m!=null?[...m,u]:[u])},[i]),d=u=>{if(n==null)return;let{key:m}=u;["ArrowDown","ArrowUp","Escape","Tab"].includes(m)&&u.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=Sm(()=>({registerItem:a}),[a]);return st(()=>{n!=null&&l==null&&s(n[0]),l!=null&&l?.current!=null&&l.current.focus()},[n,l]),Te(Qi.Provider,{value:c,children:Te("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:d,ref:e,children:t})})}function tl({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,Icon:n,itemsContainerClassNames:i,label:l,stopCloseOnClickSelf:s}){let a=jo(null),d=jo(null),[c,u]=Pt(!1),m=()=>{u(!1),d?.current!=null&&d.current.focus()};st(()=>{let f=d.current,h=a.current;if(c&&f!==null&&h!==null){let{left:g,top:E}=f.getBoundingClientRect(),M=window.scrollY||document.documentElement.scrollTop;h.style.top=`${E+M+f.offsetHeight+5}px`,h.style.left=`${Math.min(g-5,window.innerWidth-h.offsetWidth-20)}px`}},[a,d,c]),st(()=>{let f=d.current;if(f!==null&&c){let h=g=>{let{target:E}=g;s!=null&&a.current!=null&&a.current.contains(E)||f.contains(E)||u(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[a,d,c,s]);let p=Im(Te(ym,{dropDownRef:a,itemsContainerClassNames:i,onClose:m,children:o}),document.body);return qi($t.Fragment,{children:[qi("button",{"aria-label":t,className:e+(c?" active":""),disabled:r,onClick:f=>{f.preventDefault(),u(!c)},onMouseDown:f=>{f.preventDefault()},ref:d,type:"button",children:[n&&Te(n,{}),l&&Te("span",{className:"toolbar-popup__dropdown-label",children:l}),Te("i",{className:"toolbar-popup__dropdown-caret"})]}),c&&Te($t.Fragment,{children:p})]})}var Uo="toolbar-popup__dropdown",Am=t=>{let e=rl(18),{active:o,anchorElem:r,editor:n,enabled:i,item:l}=t,{i18n:s}=Mm(),{fieldProps:a}=B(),{featureClientSchemaMap:d,schemaPath:c}=a;if(l.Component){let f;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==n||e[4]!==i?(f=l?.Component&&$e(l.Component,{active:o,anchorElem:r,editor:n,enabled:i,item:l},l.key),e[0]=l,e[1]=o,e[2]=r,e[3]=n,e[4]=i,e[5]=f):f=e[5],f}let u=l.key,m;if(l.label){let f;e[6]!==l||e[7]!==d||e[8]!==s||e[9]!==c?(f=typeof l.label=="function"?l.label({featureClientSchemaMap:d,i18n:s,schemaPath:c}):l.label,e[6]=l,e[7]=d,e[8]=s,e[9]=c,e[10]=f):f=e[10],u=f}u.length>25?m=u.substring(0,25)+"...":m=u;let p;return e[11]!==l||e[12]!==m||e[13]!==o||e[14]!==n||e[15]!==i||e[16]!==u?(p=$e(el,{active:o,editor:n,enabled:i,Icon:l?.ChildComponent?$e(l.ChildComponent,{}):void 0,item:l,tooltip:u,children:$e("span",{className:"text",children:m})},l.key),e[11]=l,e[12]=m,e[13]=o,e[14]=n,e[15]=i,e[16]=u,e[17]=p):p=e[17],p},Re=t=>{let e=rl(36),{anchorElem:o,classNames:r,editor:n,group:i,Icon:l,itemsContainerClassNames:s,label:a,maxActiveItems:d,onActiveChange:c}=t,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];let[m,p]=Go.useState(u),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[1]=f):f=e[1];let[h,g]=Go.useState(f),[E,M]=Go.useState(!0),D=B(),{items:x,key:T}=i,C;e[2]!==n||e[3]!==x||e[4]!==d||e[5]!==D||e[6]!==i||e[7]!==c?(C=()=>{n.getEditorState().read(()=>{let $=Dm();if(!$)return;let W=[],Q=[],G=[];for(let j of x)j.isActive&&(!d||W.length<d)&&j.isActive({editor:n,editorConfigContext:D,selection:$})&&(W.push(j.key),Q.push(j)),j.isEnabled?j.isEnabled({editor:n,editorConfigContext:D,selection:$})&&G.push(j.key):G.push(j.key);i.isEnabled&&M(i.isEnabled({editor:n,editorConfigContext:D,selection:$})),p(W),g(G),c&&c({activeItems:Q})})},e[2]=n,e[3]=x,e[4]=d,e[5]=D,e[6]=i,e[7]=c,e[8]=C):C=e[8];let _=C,N,k;e[9]!==_?(N=()=>{_()},k=[_],e[9]=_,e[10]=N,e[11]=k):(N=e[10],k=e[11]),ol(N,k);let L,S;e[12]!==n||e[13]!==_?(L=()=>vm(n.registerUpdateListener(()=>{_()})),S=[n,_],e[12]=n,e[13]=_,e[14]=L,e[15]=S):(L=e[14],S=e[15]),ol(L,S);let b=`${T} dropdown`,w=`${Uo}-${T}`,I;e[16]!==r?(I=r||[],e[16]=r,e[17]=I):I=e[17];let R;e[18]!==w||e[19]!==I?(R=[Uo,w,...I].filter(Boolean),e[18]=w,e[19]=I,e[20]=R):R=e[20];let A=R.join(" "),v=!E,O;e[21]!==s?(O=s||[],e[21]=s,e[22]=O):O=e[22];let H;return e[23]!==O||e[24]!==x||e[25]!==m||e[26]!==o||e[27]!==n||e[28]!==h||e[29]!==b||e[30]!==A||e[31]!==v||e[32]!==l||e[33]!==a||e[34]!==T?(H=$e(tl,{buttonAriaLabel:b,buttonClassName:A,disabled:v,Icon:l,itemsContainerClassNames:[`${Uo}-items`,...O],label:a,children:x.length?x.map($=>$e(Am,{active:m.includes($.key),anchorElem:o,editor:n,enabled:h.includes($.key),item:$},$.key)):null},T),e[23]=O,e[24]=x,e[25]=m,e[26]=o,e[27]=n,e[28]=h,e[29]=b,e[30]=A,e[31]=v,e[32]=l,e[33]=a,e[34]=T,e[35]=H):H=e[35],H};function jm({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&re(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?re(lt,{editor:e,item:o,children:re(o.ChildComponent,{})},o.key):null}function Gm(t){let e=nl(18),{anchorElem:o,editor:r,editorConfig:n,group:i,index:l}=t,{i18n:s}=Bm(),{fieldProps:a}=B(),{featureClientSchemaMap:d,schemaPath:c}=a,[u,m]=he.useState(void 0),[p,f]=he.useState(void 0),h,g;e[0]!==i?(h=()=>{i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0)},g=[i],e[0]=i,e[1]=h,e[2]=g):(h=e[1],g=e[2]),he.useEffect(h,g);let E;e[3]!==i||e[4]!==d||e[5]!==s||e[6]!==c?(E=T=>{let{activeItems:C}=T;if(!C.length){i?.type==="dropdown"&&i.items.length&&i.ChildComponent?(f(()=>i.ChildComponent),m(void 0)):(f(void 0),m(void 0));return}let _=C[0],N=_.key;_.label&&(N=typeof _.label=="function"?_.label({featureClientSchemaMap:d,i18n:s,schemaPath:c}):_.label),N.length>25&&(N=N.substring(0,25)+"..."),m(N),f(()=>_.ChildComponent)},e[3]=i,e[4]=d,e[5]=s,e[6]=c,e[7]=E):E=e[7];let M=E,D=`fixed-toolbar__group fixed-toolbar__group-${i.key}`,x;return e[8]!==i||e[9]!==p||e[10]!==o||e[11]!==r||e[12]!==u||e[13]!==M||e[14]!==n.features.toolbarFixed||e[15]!==l||e[16]!==D?(x=Om("div",{className:D,children:[i.type==="dropdown"&&i.items.length?p?re(Re,{anchorElem:o,editor:r,group:i,Icon:p,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:u,maxActiveItems:1,onActiveChange:M}):re(Re,{anchorElem:o,editor:r,group:i,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:u,maxActiveItems:1,onActiveChange:M}):null,i.type==="buttons"&&i.items.length?i.items.map(T=>re(jm,{anchorElem:o,editor:r,item:T},T.key)):null,l<n.features.toolbarFixed?.groups.length-1&&re("div",{className:"divider"})]},i.key),e[8]=i,e[9]=p,e[10]=o,e[11]=r,e[12]=u,e[13]=M,e[14]=n.features.toolbarFixed,e[15]=l,e[16]=D,e[17]=x):x=e[17],x}function Um({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let i=he.useRef(null),{y:l}=$m(),s=Hm(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let d=n.editorContainerRef.current.previousElementSibling;for(;d;){if(d.classList.contains("fixed-toolbar"))return d;d=d.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return Pm(()=>{if(!s)return;let a=i.current;if(!a)return;let d=a.getBoundingClientRect(),c=s.getBoundingClientRect();if(!(d.bottom<c.top||d.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]),re("div",{className:"fixed-toolbar",onFocus:a=>{a.stopPropagation()},ref:i,children:o.isEditable()&&re(he.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((a,d)=>re(Gm,{anchorElem:t,editor:o,editorConfig:r,group:a,index:d},a.key))})})}var il=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return il(t.parentEditor)}return!1},ll=t=>{let e=nl(6),{clientProps:o}=t,[r]=Fm(),n=B(),{editorConfig:i}=n,l=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,s=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||i,a,d;if(e[0]!==n||e[1]!==o?.disableIfParentHasFixedToolbar||e[2]!==s||e[3]!==l){d=Symbol.for("react.early_return_sentinel");e:{let c=il(n);if(o?.disableIfParentHasFixedToolbar&&c){d=null;break e}if(!s?.features?.toolbarFixed?.groups?.length){d=null;break e}a=re(Um,{anchorElem:document.body,editor:l,editorConfig:s,parentWithFixedToolbar:c})}e[0]=n,e[1]=o?.disableIfParentHasFixedToolbar,e[2]=s,e[3]=l,e[4]=a,e[5]=d}else a=e[4],d=e[5];return d!==Symbol.for("react.early_return_sentinel")?d:a};var Wm=y({plugins:[{Component:ll,position:"aboveContainer"}]});import{c as cl}from"react/compiler-runtime";import{jsx as ie,jsxs as ul}from"react/jsx-runtime";import{useLexicalComposerContext as Vm}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as dl}from"@lexical/utils";import{$getSelection as ml,$isRangeSelection as sl,$isTextNode as Km,COMMAND_PRIORITY_LOW as zm,SELECTION_CHANGE_COMMAND as Zm}from"lexical";import{useCallback as Ht,useEffect as at,useRef as al,useState as Xm}from"react";import*as jt from"react";import{createPortal as Ym}from"react-dom";function Wo(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 Bt(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:i=32,horizontalPosition:l="left",specialHandlingForCaret:s=!1,targetRect:a,verticalGap:d=10}=t,c=o.parentElement;if(a===null||c==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let u=n.getBoundingClientRect(),m=o.getBoundingClientRect(),p=c.getBoundingClientRect(),f=a.top-u.height-d,h=a.left-i;l==="center"&&(h=a.left+a.width/2-u.width/2);let g=0;return!e&&f<p.top&&!s&&(g=u.height+a.height+d*2,f+=g),l==="center"?h+u.width>p.right?h=p.right-u.width-i:h<p.left&&(h=p.left+i):h+u.width>p.right&&(h=p.right-u.width-i),h-=m.left,n.style.opacity="1",s&&r!==0?(f-=m.bottom-r+u.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=m.top,n.style.transform=`translate(${h}px, ${f}px)`),g}function Jm({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(lt,{editor:e,item:o,children:ie(o.ChildComponent,{})},o.key):null}function qm(t){let e=cl(14),{anchorElem:o,editor:r,group:n,index:i}=t,{editorConfig:l}=B(),[s,a]=jt.useState(),d,c;e[0]!==n?(d=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0)},c=[n],e[0]=n,e[1]=d,e[2]=c):(d=e[1],c=e[2]),jt.useEffect(d,c);let u;e[3]!==n?(u=h=>{let{activeItems:g}=h;if(!g.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?a(()=>n.ChildComponent):a(void 0);return}let E=g[0];a(()=>E.ChildComponent)},e[3]=n,e[4]=u):u=e[4];let m=u,p=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;return e[5]!==n||e[6]!==s||e[7]!==o||e[8]!==r||e[9]!==m||e[10]!==l.features.toolbarInline||e[11]!==i||e[12]!==p?(f=ul("div",{className:p,children:[n.type==="dropdown"&&n.items.length?s?ie(Re,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:1,onActiveChange:m}):ie(Re,{anchorElem:o,editor:r,group:n,maxActiveItems:1,onActiveChange:m}):null,n.type==="buttons"&&n.items.length?n.items.map(h=>ie(Jm,{anchorElem:o,editor:r,item:h},h.key)):null,i<l.features.toolbarInline?.groups.length-1&&ie("div",{className:"divider"})]},n.key),e[5]=n,e[6]=s,e[7]=o,e[8]=r,e[9]=m,e[10]=l.features.toolbarInline,e[11]=i,e[12]=p,e[13]=f):f=e[13],f}function Qm({anchorElem:t,editor:e}){let o=al(null),r=al(null),{editorConfig:n}=B(),i=Ht(()=>{if(o?.current){let d=o.current.style.opacity==="0",c=o.current.style.pointerEvents==="none";d||(o.current.style.opacity="0"),c||(o.current.style.pointerEvents="none")}},[o]),l=Ht(d=>{if(o?.current&&(d.buttons===1||d.buttons===3)){let c=o.current.style.opacity==="0",u=o.current.style.pointerEvents==="none";if(!c||!u){let m=d.clientX,p=d.clientY,f=document.elementFromPoint(m,p);o.current.contains(f)||i()}}},[i]),s=Ht(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);at(()=>(document.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}),[o,l,s]);let a=Ht(()=>{let d=ml(),c=window.getSelection();if(o.current===null)return;let u=t.querySelector(":scope > .link-editor"),m=u!==null&&"style"in u&&u?.style?.opacity==="1",p=e.getRootElement();if(d!==null&&c!==null&&!c.isCollapsed&&p!==null&&p.contains(c.anchorNode)){let f=Wo(c,p),h=Bt({alwaysDisplayOnTop:m,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&Bt({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else i()},[e,i,t]);return at(()=>{let d=t.parentElement,c=()=>{e.getEditorState().read(()=>{a()})};return window.addEventListener("resize",c),d&&d.addEventListener("scroll",c),()=>{window.removeEventListener("resize",c),d&&d.removeEventListener("scroll",c)}},[e,a,t]),at(()=>(e.getEditorState().read(()=>{a()}),dl(e.registerUpdateListener(({editorState:d})=>{d.read(()=>{a()})}),e.registerCommand(Zm,()=>(a(),!1),zm))),[e,a]),ul("div",{className:"inline-toolbar-popup",ref:o,children:[ie("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((d,c)=>ie(qm,{anchorElem:t,editor:e,group:d,index:c},d.key))]})}function ep(t,e){let o=cl(12),[r,n]=Xm(!1),i;o[0]!==t?(i=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let m=ml(),p=window.getSelection(),f=t.getRootElement();if(p!==null&&(!sl(m)||f===null||!f.contains(p.anchorNode))){n(!1);return}if(!sl(m))return;if(m.getTextContent()!==""){let g=m.getNodes(),E=!1;for(let M of g)if(Km(M)){n(!0),E=!0;break}E||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]),at(s,a);let d,c;if(o[5]!==t||o[6]!==l?(d=()=>dl(t.registerUpdateListener(()=>{l()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),c=[t,l],o[5]=t,o[6]=l,o[7]=d,o[8]=c):(d=o[7],c=o[8]),at(d,c),!r||!t.isEditable())return null;let u;return o[9]!==e||o[10]!==t?(u=Ym(ie(Qm,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=u):u=o[11],u}var pl=t=>{let{anchorElem:e}=t,[o]=Vm();return ep(o,e)};var tp=y({plugins:[{Component:pl,position:"floatingAnchorElem"}]});import{TableCellNode as Gf,TableNode as Uf,TableRowNode as Wf}from"@lexical/table";import{jsx as fl}from"react/jsx-runtime";import"react";var Vo=()=>fl("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:fl("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 up,$createTableNode as dp,$createTableRowNode as mp,$isTableCellNode as El,$isTableNode as Ko,$isTableRowNode as zo,TableCellHeaderStates as Gt,TableCellNode as pp,TableNode as fp,TableRowNode as hp}from"@lexical/table";import{$isParagraphNode as gp,$isTextNode as Cp}from"lexical";var hl=/^[\t ]*$/,op=/^(\s*)(\d+)\.\s/,rp=/^(\s*)[-*+]\s/,np=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,gl=/^(#{1,6})\s/,ip=/^>\s/,Cl=/^[ \t]*```(\w+)?/,xl=/[ \t]*```$/,lp=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,sp=/^\|(.+)\|\s?$/,ap=/^(\| ?:?-*:? ?)+\|\s?$/,bl=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,_l=/^[ \t]*<\/[a-z_][\w-]*\s*>/i;function cp(t,e=!1){let o=t.split(`
|
|
36
|
+
`),r=!1,n=[];for(let i=0;i<o.length;i++){let l=o[i],s=n[n.length-1];if(lp.test(l)){n.push(l);continue}if((Cl.test(l)&&!r||xl.test(l)&&r)&&(r=!r),Cl.test(l)||xl.test(l)){n.push(l);continue}if(r){n.push(l);continue}hl.test(l)||hl.test(s)||!s||gl.test(s)||gl.test(l)||ip.test(l)||op.test(l)||rp.test(l)||np.test(l)||sp.test(l)||ap.test(l)||!e||bl.test(l)||_l.test(l)||bl.test(s)||_l.test(s)?n.push(l):n[n.length-1]=s+" "+l.trim()}return n.join(`
|
|
37
|
+
`)}function Tl(t,e=dr,o,r=!1,n=!0){let i=r?t:cp(t,n);return mr(i,e,o)}var kl=/^\|(.+)\|\s?$/,xp=/^(\| ?:?-*:? ?)+\|\s?$/,Nl=({allTransformers:t})=>({type:"element",dependencies:[fp,hp,pp],export:e=>{if(!Ko(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!zo(r))continue;let i=!1;for(let l of r.getChildren())El(l)&&(n.push(pr(t,l).replace(/\n/g,"\\n")),l.__headerState===Gt.ROW&&(i=!0));o.push(`| ${n.join(" | ")} |`),i&&o.push(`| ${n.map(l=>"---").join(" | ")} |`)}return o.join(`
|
|
38
|
+
`)},regExp:kl,replace:(e,o,r)=>{if(xp.test(r[0])){let c=e.getPreviousSibling();if(!c||!Ko(c))return;let u=c.getChildren(),m=u[u.length-1];if(!m||!zo(m))return;m.getChildren().forEach(p=>{El(p)&&p.setHeaderStyles(Gt.ROW,Gt.ROW)}),e.remove();return}let n=wl(r[0],t);if(n==null)return;let i=[n],l=e.getPreviousSibling(),s=n.length;for(;l&&!(!gp(l)||l.getChildrenSize()!==1);){let c=l.getFirstChild();if(!Cp(c))break;let u=wl(c.getTextContent(),t);if(u==null)break;s=Math.max(s,u.length),i.unshift(u);let m=l.getPreviousSibling();l.remove(),l=m}let a=dp();for(let c of i){let u=mp();a.append(u);for(let m=0;m<s;m++)u.append(m<c.length?c[m]:Ll("",t))}let d=e.getPreviousSibling();Ko(d)&&bp(d)===s?(d.append(...a.getChildren()),e.remove()):e.replace(a),a.selectEnd()}});function bp(t){let e=t.getFirstChild();return zo(e)?e.getChildrenSize():0}var Ll=(t,e)=>{t=t.replace(/\\n/g,`
|
|
39
|
+
`);let o=up(Gt.NO_STATUS);return Tl(t,e,o),o},wl=(t,e)=>{let o=t.match(kl);return!o||!o[1]?null:o[1].split("|").map(r=>Ll(r,e))};import{c as Tp}from"react/compiler-runtime";import{jsx as P,jsxs as ge}from"react/jsx-runtime";import{useLexicalComposerContext as yl}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Ep}from"@lexical/react/useLexicalEditable";import{$deleteTableColumn__EXPERIMENTAL as wp,$deleteTableRow__EXPERIMENTAL as kp,$getNodeTriplet as Np,$getTableCellNodeFromLexicalNode as Lp,$getTableColumnIndexFromTableCellNode as Rp,$getTableNodeFromLexicalNodeOrThrow as ct,$getTableRowIndexFromTableCellNode as Sp,$insertTableColumn__EXPERIMENTAL as Ip,$insertTableRow__EXPERIMENTAL as yp,$isTableCellNode as Ut,$isTableRowNode as Sl,$isTableSelection as Vt,$unmergeCell as vp,getTableObserverFromTableElement as Mp,TableCellHeaderStates as Ee,TableCellNode as Dp}from"@lexical/table";import{useScrollInfo as Ap}from"@payloadcms/ui";import{$createParagraphNode as Op,$getRoot as Fp,$getSelection as Kt,$isElementNode as $p,$isParagraphNode as vl,$isRangeSelection as Yo,$isTextNode as Pp}from"lexical";import*as Jo from"react";import{useCallback as le,useEffect as Se,useRef as Wt,useState as Pe}from"react";import{createPortal as Ml}from"react-dom";import{jsx as Zo,jsxs as _p}from"react/jsx-runtime";import"react";var Rl=()=>_p("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Zo("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"}),Zo("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"}),Zo("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 Xo(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Bp(){let t=Kt();if(Yo(t)&&!t.isCollapsed()||Vt(t)&&!t.anchor.is(t.focus)||!Yo(t)&&!Vt(t))return!1;let[e]=Np(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Il(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!vl(e)||!e.isEmpty())}function Hp(t){let e=t.getLastDescendant();Pp(e)?e.select():$p(e)?e.selectEnd():e!==null&&e.selectNext()}function jp({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=yl(),l=Wt(null),[s,a]=Pe(n),[d,c]=Pe({columns:1,rows:1}),[u,m]=Pe(!1),[p,f]=Pe(!1),{y:h}=Ap();Se(()=>i.registerMutationListener(Dp,b=>{b.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{a(s.getLatest())})},{skipInitialization:!0}),[i,s]),Se(()=>{i.getEditorState().read(()=>{let b=Kt();if(Vt(b)){let w=Xo(b);c(Xo(b)),m(w.columns>1||w.rows>1)}f(Bp())})},[i]),Se(()=>{let b=e.current,w=l.current,I=i.getRootElement();if(b!=null&&w!=null&&I!=null){let R=I.getBoundingClientRect(),A=b.getBoundingClientRect();w.style.opacity="1";let v=w.getBoundingClientRect(),O=5,H=A.right+O;if(H+v.width>window.innerWidth||H+v.width>R.right){let W=A.left-v.width-O;H=(W<0?O:W)+window.pageXOffset}w.style.left=`${H+window.pageXOffset}px`;let $=A.top;if($+v.height>window.innerHeight){let W=A.bottom-v.height;$=(W<0?O:W)+window.pageYOffset}w.style.top=`${$}px`}},[e,l,i,h]),Se(()=>{function b(w){l.current!=null&&e.current!=null&&!l.current.contains(w.target)&&!e.current.contains(w.target)&&r(!1)}return window.addEventListener("click",b),()=>window.removeEventListener("click",b)},[r,e]);let g=le(()=>{i.update(()=>{if(s.isAttached()){let w=ct(s),I=i.getElementByKey(w.getKey());if(!I)throw new Error("Expected to find tableElement in DOM");let R=Mp(I);R!==null&&R.clearHighlight(),w.markDirty(),a(s.getLatest())}Fp().selectStart()})},[i,s]),E=()=>{i.update(()=>{let b=Kt();if(Vt(b)){let{columns:w,rows:I}=Xo(b),R=b.getNodes(),A=null;for(let v=0;v<R.length;v++){let O=R[v];if(Ut(O))if(A===null){O.setColSpan(w).setRowSpan(I),A=O;let H=Il(O),$;H&&vl($=O.getFirstChild())&&$.remove()}else Ut(A)&&(Il(O)||A.append(...O.getChildren()),O.remove())}A!==null&&(A.getChildrenSize()===0&&A.append(Op()),Hp(A)),o()}})},M=()=>{i.update(()=>{vp()})},D=le(b=>{i.update(()=>{yp(b),o()})},[i,o]),x=le(b=>{i.update(()=>{for(let w=0;w<d.columns;w++)Ip(b);o()})},[i,o,d.columns]),T=le(()=>{i.update(()=>{kp(),o()})},[i,o]),C=le(()=>{i.update(()=>{ct(s).remove(),g(),o()})},[i,s,g,o]),_=le(()=>{i.update(()=>{wp(),o()})},[i,o]),N=le(()=>{i.update(()=>{let b=ct(s),w=Sp(s),I=b.getChildren();if(w>=I.length||w<0)throw new Error("Expected table cell to be inside of table row.");let R=I[w];if(!Sl(R))throw new Error("Expected table row");let A=s.getHeaderStyles()^Ee.ROW;R.getChildren().forEach(v=>{if(!Ut(v))throw new Error("Expected table cell");v.setHeaderStyles(A,Ee.ROW)}),g(),o()})},[i,s,g,o]),k=le(()=>{i.update(()=>{let b=ct(s),w=Rp(s),I=b.getChildren(),R=Math.max(...I.map(v=>v.getChildren().length));if(w>=R||w<0)throw new Error("Expected table cell to be inside of table row.");let A=s.getHeaderStyles()^Ee.COLUMN;for(let v=0;v<I.length;v++){let O=I[v];if(!Sl(O))throw new Error("Expected table row");let H=O.getChildren();if(w>=H.length)continue;let $=H[w];if(!Ut($))throw new Error("Expected table cell");$.setHeaderStyles(A,Ee.COLUMN)}g(),o()})},[i,s,g,o]),L=le(()=>{i.update(()=>{if(s.isAttached()){let b=ct(s);b&&b.setRowStriping(!b.getRowStriping())}g(),o()})},[i,s,g,o]),S=null;return t&&(u?S=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>E(),type:"button",children:"Merge cells"}):p&&(S=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>M(),type:"button",children:"Unmerge cells"}))),Ml(ge("div",{className:"table-action-menu-dropdown",onClick:b=>{b.stopPropagation()},ref:l,children:[S?ge(Jo.Fragment,{children:[S,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>L(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>D(!1),type:"button",children:ge("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>D(!0),type:"button",children:ge("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>x(!1),type:"button",children:ge("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>x(!0),type:"button",children:ge("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>_(),type:"button",children:P("span",{className:"text",children:"Delete column"})}),P("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>T(),type:"button",children:P("span",{className:"text",children:"Delete row"})}),P("button",{className:"item","data-test-id":"table-delete",onClick:()=>C(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item",onClick:()=>N(),type:"button",children:ge("span",{className:"text",children:[(s.__headerState&Ee.ROW)===Ee.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>k(),type:"button",children:ge("span",{className:"text",children:[(s.__headerState&Ee.COLUMN)===Ee.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function Gp({anchorElem:t,cellMerge:e}){let[o]=yl(),r=Wt(null),n=Wt(null),[i,l]=Pe(!1),[s,a]=Pe(null),d=le(()=>{let u=r.current,m=Kt(),p=window.getSelection(),f=document.activeElement;if(m==null||u==null){a(null);return}let h=o.getRootElement();if(Yo(m)&&h!==null&&p!==null&&h.contains(p.anchorNode)){let g=Lp(m.anchor.getNode());if(g==null){a(null);return}if(o.getElementByKey(g.getKey())==null){a(null);return}a(g)}else f||a(null)},[o]);Se(()=>o.registerUpdateListener(()=>{o.getEditorState().read(()=>{d()})})),Se(()=>{let u=r.current;if(u!=null&&s!=null){let m=o.getElementByKey(s.getKey());if(m!=null){let p=m.getBoundingClientRect(),f=u.getBoundingClientRect(),h=t.getBoundingClientRect(),g=p.top-h.top+4,E=p.right-f.width-10-h.left;u.style.opacity="1",u.style.transform=`translate(${E}px, ${g}px)`}else u.style.opacity="0",u.style.transform="translate(-10000px, -10000px)"}},[r,s,o,t]);let c=Wt(s);return Se(()=>{c.current!==s&&l(!1),c.current=s},[c,s]),P("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&ge(Jo.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:u=>{u.stopPropagation(),l(!i)},ref:n,type:"button",children:P(Rl,{})}),i&&P(jp,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Dl=t=>{let e=Tp(3),{anchorElem:o}=t,r=Ep(),n;return e[0]!==r||e[1]!==o?(n=Ml(r?P(Gp,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as Up}from"react/compiler-runtime";import{jsx as Zt,jsxs as Wp}from"react/jsx-runtime";import{useLexicalComposerContext as Vp}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Kp}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as zp,$getTableNodeFromLexicalNodeOrThrow as qo,$getTableRowIndexFromTableCellNode as Zp,$isTableCellNode as Al,$isTableRowNode as Xp,getDOMCellFromTarget as Yp,TableNode as Jp}from"@lexical/table";import{calculateZoomLevel as Ol}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Qo}from"lexical";import*as $l from"react";import{useCallback as ut,useEffect as er,useRef as zt,useState as dt}from"react";import{createPortal as qp}from"react-dom";var Qp=33,Fl=92;function ef({editor:t}){let e=zt(null),o=zt(null),r=zt(null),n=B(),i=zt(null),[l,s]=dt(null),[a,d]=dt(null),[c,u]=dt(!1),[m,p]=dt(null),f=ut(()=>{d(null),e.current=null,p(null),i.current=null,r.current=null},[]),h=k=>(k.buttons&1)===1;er(()=>t.registerNodeTransform(Jp,k=>{if(k.getColWidths())return k;let L=k.getColumnCount(),S=Fl;return k.setColWidths(Array(L).fill(S)),k}),[t]),er(()=>{let k=w=>{setTimeout(()=>{let I=w.target;if(m){s({x:w.clientX,y:w.clientY});return}if(u(h(w)),!(o.current&&o.current.contains(I))&&e.current!==I){e.current=I;let R=Yp(I);R&&a!==R?t.update(()=>{let A=Qo(R.elem);if(!A)throw new Error("TableCellResizer: Table cell node not found.");let v=qo(A),O=t.getElementByKey(v.getKey());if(!O)throw new Error("TableCellResizer: Table element not found.");e.current=I,r.current=O.getBoundingClientRect(),d(R)}):R==null&&f()}},0)},L=w=>{setTimeout(()=>{u(!0)},0)},S=w=>{setTimeout(()=>{u(!1)},0)},b=t.registerRootListener((w,I)=>{I?.removeEventListener("mousemove",k),I?.removeEventListener("mousedown",L),I?.removeEventListener("mouseup",S),w?.addEventListener("mousemove",k),w?.addEventListener("mousedown",L),w?.addEventListener("mouseup",S)});return()=>{b()}},[a,m,t,f]);let g=k=>k==="bottom",E=ut(k=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let L=Qo(a.elem);if(!Al(L))throw new Error("TableCellResizer: Table cell node not found.");let S=qo(L),b=Zp(L)+L.getRowSpan()-1,w=S.getChildren();if(b>=w.length||b<0)throw new Error("Expected table cell to be inside of table row.");let I=w[b];if(!Xp(I))throw new Error("Expected table row");let R=I.getHeight();if(R===void 0){let v=I.getChildren();R=Math.min(...v.map(O=>M(O,t)??1/0))}let A=Math.max(R+k,Qp);I.setHeight(A)},{tag:"skip-scroll-into-view"})},[a,t]),M=(k,L)=>L.getElementByKey(k.getKey())?.clientHeight,D=(k,L)=>{for(let S=0;S<L.length;S++)for(let b=0;b<L[S].length;b++)if(L[S][b].cell===k)return b},x=ut(k=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let L=Qo(a.elem);if(!Al(L))throw new Error("TableCellResizer: Table cell node not found.");let S=qo(L),[b]=zp(S,null,null),w=D(L,b);if(w===void 0)throw new Error("TableCellResizer: Table column not found.");let I=S.getColWidths();if(!I)return;let R=I[w];if(R===void 0)return;let A=[...I],v=Math.max(R+k,Fl);A[w]=v,S.setColWidths(A)},{tag:"skip-scroll-into-view"})},[a,t]),T=ut(k=>{let L=S=>{if(S.preventDefault(),S.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:b,y:w}=i.current;if(a===null)return;let I=Ol(S.target);if(g(k)){let R=(S.clientY-w)/I;E(R)}else{let R=(S.clientX-b)/I;x(R)}f(),document.removeEventListener("mouseup",L)}};return L},[a,f,x,E]),C=ut(k=>L=>{if(L.preventDefault(),L.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");i.current={x:L.clientX,y:L.clientY},s(i.current),p(k),document.addEventListener("mouseup",T(k))},[a,T]),[_,N]=dt({bottom:null,left:null,right:null,top:null});return er(()=>{if(a){let{height:k,left:L,top:S,width:b}=a.elem.getBoundingClientRect(),w=Ol(a.elem),I=10,R={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${I}px`,left:`${window.scrollX+L}px`,top:`${window.scrollY+S+k-I/2}px`,width:`${b}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${k}px`,left:`${window.scrollX+L+b-I/2}px`,top:`${window.scrollY+S}px`,width:`${I}px`}},A=r.current;m&&l&&A&&(g(m)?(R[m].left=`${window.scrollX+A.left}px`,R[m].top=`${window.scrollY+l.y/w}px`,R[m].height="3px",R[m].width=`${A.width}px`):(R[m].top=`${window.scrollY+A.top}px`,R[m].left=`${window.scrollX+l.x/w}px`,R[m].width="3px",R[m].height=`${A.height}px`),R[m].backgroundColor="#adf"),N(R)}else N({bottom:null,left:null,right:null,top:null})},[a,m,l]),Zt("div",{ref:o,children:a!=null&&!c&&Wp($l.Fragment,{children:[Zt("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:C("right"),style:_.right||void 0}),Zt("div",{className:`${n.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:C("bottom"),style:_.bottom||void 0})]})})}var Pl=()=>{let t=Up(3),[e]=Vp(),o=Kp(),r,n;return t[0]!==o||t[1]!==e?(n=o?qp(Zt(ef,{editor:e}),document.body):null,t[0]=o,t[1]=e,t[2]=n):n=t[2],r=n,r};import{c as cf}from"react/compiler-runtime";import{jsx as tr,jsxs as uf,Fragment as df}from"react/jsx-runtime";import{useLexicalComposerContext as Kl}from"@lexical/react/LexicalComposerContext";import{$getTableColumnIndexFromTableCellNode as mf,$getTableRowIndexFromTableCellNode as pf,$insertTableColumn__EXPERIMENTAL as ff,$insertTableRow__EXPERIMENTAL as hf,$isTableCellNode as gf,$isTableNode as jl,TableNode as Cf}from"@lexical/table";import{$findMatchingParent as xf,mergeRegister as bf}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Gl}from"lexical";import{useEffect as Ul,useMemo as _f,useRef as Wl,useState as Xt}from"react";import"react";import{createPortal as Tf}from"react-dom";import{c as lf}from"react/compiler-runtime";import{useEffect as sf,useRef as af}from"react";var tf="Expected a function",of=Math.max,rf=Math.min;function nf(t,e,o){let r,n,i=0,l,s=!1,a=!1,d,c,u,m=!0;if(typeof t!="function")throw new TypeError(tf);e=e||0,typeof o=="object"&&(s=!!o.leading,a="maxWait"in o,d=a?of(o.maxWait||0,e):d,m="trailing"in o?!!o.trailing:m);function p(C){let _=r,N=l;return r=l=void 0,i=C,c=t.apply(N,_),c}function f(C){return i=C,u=setTimeout(E,e),s?p(C):c}function h(C){let _=C-n,N=C-i,k=e-_;return a?rf(k,d-N):k}function g(C){let _=C-n,N=C-i;return n===void 0||_>=e||_<0||a&&N>=d}function E(){let C=Date.now();if(g(C))return M(C);u=setTimeout(E,h(C))}function M(C){return u=void 0,m&&r?p(C):(r=l=void 0,c)}function D(){u!==void 0&&clearTimeout(u),i=0,r=n=l=u=void 0}function x(){return u===void 0?c:M(Date.now())}function T(){let C=Date.now(),_=g(C);if(r=arguments,l=this,n=C,_){if(u===void 0)return f(n);if(a)return clearTimeout(u),u=setTimeout(E,e),p(n)}return u===void 0&&(u=setTimeout(E,e)),c}return T.cancel=D,T.flush=x,T}var Bl=nf;function Hl(t,e,o){let r=lf(6),n=af(null),i,l;r[0]!==t||r[1]!==e||r[2]!==o?(i=()=>(n.current=Bl(t,e,{maxWait:o}),()=>{n.current?.cancel()}),l=[t,e,o],r[0]=t,r[1]=e,r[2]=o,r[3]=i,r[4]=l):(i=r[3],l=r[4]),sf(i,l);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...d)=>{let c=d;n.current&&n.current(...c)},r[5]=s):s=r[5],s}var Vl=20;function Ef({anchorElem:t}){let[e]=Kl(),o=B(),[r,n]=Xt(!1),[i,l]=Xt(!1),[s,a]=Xt(!1),[d,c]=Xt({}),u=Wl(new Set),m=Wl(null),p=Hl(g=>{let{isOutside:E,tableDOMNode:M}=wf(g,o.editorConfig?.lexical);if(E){n(!1),l(!1);return}if(!M)return;m.current=M;let D=null,x=null,T=null;if(e.update(()=>{let C=Gl(M);if(gf(C)){let _=xf(C,N=>jl(N));if(!jl(_))return;if(T=e.getElementByKey(_?.getKey()),T){let N=_.getChildrenSize(),k=_.getChildAtIndex(0)?.getChildrenSize(),L=pf(C),S=mf(C);L===N-1?D=C:S===k-1&&(x=C)}}}),T){let{bottom:C,height:_,left:N,right:k,width:L,y:S}=T.getBoundingClientRect(),{left:b,y:w}=t.getBoundingClientRect();D?(l(!1),n(!0),c({height:Vl,left:N-b,top:C-w+5,width:L})):x&&(l(!0),n(!1),c({height:_,left:k-b+5,top:S-w,width:Vl}))}},50,250),f=_f(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);Ul(()=>{if(s)return document.addEventListener("mousemove",p),()=>{n(!1),l(!1),document.removeEventListener("mousemove",p)}},[s,p]),Ul(()=>bf(e.registerMutationListener(Cf,g=>{e.getEditorState().read(()=>{for(let[E,M]of g){let D=e.getElementByKey(E);switch(M){case"created":u.current.add(E),a(u.current.size>0),D&&f.observe(D);break;case"destroyed":u.current.delete(E),a(u.current.size>0),f.disconnect(),u.current.forEach(x=>{let T=e.getElementByKey(x);T&&f.observe(T)});break;default:break}}})},{skipInitialization:!1})),[e,f]);let h=g=>{e.update(()=>{m.current&&(Gl(m.current)?.selectEnd(),g?(hf(),n(!1)):(ff(),l(!1)))})};return e?.isEditable()?uf(df,{children:[r&&tr("button",{className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...d},type:"button"}),i&&tr("button",{className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...d},type:"button"})]}):null}function wf(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 zl(t){let e=cf(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=Kl();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=Tf(tr(Ef,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as kf}from"react/compiler-runtime";import{jsx as or,jsxs as Nf}from"react/jsx-runtime";import{useLexicalComposerContext as Lf}from"@lexical/react/LexicalComposerContext";import{TablePlugin as Rf}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Sf,TableNode as If}from"@lexical/table";import{mergeRegister as yf}from"@lexical/utils";import{formatDrawerSlug as vf,useEditDepth as Mf}from"@payloadcms/ui";import{$getSelection as Df,$isRangeSelection as Af,COMMAND_PRIORITY_EDITOR as Of,createCommand as Ff}from"lexical";import{createContext as $f,useContext as Pf,useEffect as Bf,useMemo as Hf,useState as jf}from"react";import*as Zl from"react";var Yt=Ff("OPEN_EMBED_DRAWER_COMMAND"),Xl=$f({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Yl({children:t}){let[e,o]=jf({cellEditorConfig:null,cellEditorPlugins:null});return or(Xl.Provider,{value:Hf(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Jl=()=>{let t=kf(16),[e]=Lf(),o=Pf(Xl),r=Mf(),{fieldProps:n,uuid:i}=B(),{schemaPath:l}=n,s="lexical-table-create-"+i,a;t[0]!==s||t[1]!==r?(a=vf({slug:s,depth:r}),t[0]=s,t[1]=r,t[2]=a):a=t[2];let d=a,{toggleDrawer:c}=ae(d,!0),u;t[3]!==e||t[4]!==c?(u=()=>{if(!e.hasNodes([If]))throw new Error("TablePlugin: TableNode is not registered on editor");return yf(e.registerCommand(Yt,()=>{let h;return h=null,e.getEditorState().read(()=>{let g=Df();Af(g)&&(h=g)}),h&&c(),!0},Of))},t[3]=e,t[4]=c,t[5]=u):u=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],Bf(u,m);let p;t[10]!==e?(p=(h,g)=>{!g.columns||!g.rows||e.dispatchCommand(Sf,{columns:String(g.columns),rows:String(g.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==d||t[13]!==p||t[14]!==l?(f=Nf(Zl.Fragment,{children:[or(He,{drawerSlug:d,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:l,schemaPathSuffix:"fields"}),or(Rf,{hasCellBackgroundColor:!1,hasCellMerge:!0})]}),t[12]=d,t[13]=p,t[14]=l,t[15]=f):f=t[15],f};var Vf=y({markdownTransformers:[Nl],nodes:[Uf,Gf,Wf],plugins:[{Component:Jl,position:"normal"},{Component:Pl,position:"normal"},{Component:Dl,position:"floatingAnchorElem"},{Component:zl,position:"floatingAnchorElem"}],providers:[Yl],slashMenu:{groups:[K([{Icon:Vo,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Yt,{})}}])]},toolbarFixed:{groups:[ue([{ChildComponent:Vo,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Yt,{})}}])]}});import{$isNodeSelection as f1}from"lexical";import{jsx as rr,jsxs as Kf}from"react/jsx-runtime";import"react";var nr=()=>Kf("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:[rr("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"}),rr("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"}),rr("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{c as t1}from"react/compiler-runtime";import{jsx as o1}from"react/jsx-runtime";import{useLexicalComposerContext as r1}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as n1,mergeRegister as i1}from"@lexical/utils";import{useConfig as l1}from"@payloadcms/ui";import{$getPreviousSelection as s1,$getSelection as a1,$isParagraphNode as Ql,$isRangeSelection as c1,COMMAND_PRIORITY_EDITOR as u1,createCommand as d1}from"lexical";import{useEffect as m1}from"react";import{c as zf}from"react/compiler-runtime";import{jsx as ir}from"react/jsx-runtime";import{useLexicalComposerContext as Zf}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as Xf,COMMAND_PRIORITY_EDITOR as Yf}from"lexical";import{useEffect as Jf,useState as qf}from"react";var Qf=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Xf(o);n&&n.replace(Ke({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(lr,{fields:null,relationTo:e,value:r})},e1=t=>{let e=zf(13),{enabledCollectionSlugs:o}=t,[r]=Zf(),[n,i]=qf(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:d}=it(l),c,u;e[2]!==r||e[3]!==d?(c=()=>r.registerCommand(We,h=>(i(h?.replace?h?.replace.nodeKey:null),d(),!0),Yf),u=[r,d],e[2]=r,e[3]=d,e[4]=c,e[5]=u):(c=e[4],u=e[5]),Jf(c,u);let m;e[6]!==s||e[7]!==r||e[8]!==n?(m=h=>{let{collectionSlug:g,docID:E}=h;s(),Qf({editor:r,relationTo:g,replaceNodeKey:n,value:E})},e[6]=s,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,f;return e[10]!==p||e[11]!==a?(f=ir(a,{onSelect:p}),e[10]=p,e[11]=a,e[12]=f):f=e[12],f},ql=t=>ir(gt,{...t,uploads:!0,children:ir(e1,{...t})});var lr=d1("INSERT_UPLOAD_COMMAND"),es=t=>{let e=t1(5),[o]=r1(),{config:r}=l1(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([Ve]))throw new Error("UploadPlugin: UploadNode not registered on editor");return i1(o.registerCommand(lr,a=>(o.update(()=>{let d=a1()||s1();if(c1(d)){let c=Ke({data:{id:a.id,fields:a.fields,relationTo:a.relationTo,value:a.value}});n1(c);let{focus:u}=d,m=u.getNode();Ql(m)&&m.getTextContentSize()===0&&m.getParentOrThrow().getChildren().filter(p=>Ql(p)).length>1&&m.remove()}}),!0),u1))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),m1(i,l);let s;return e[3]!==n?(s=o1(ql,{enabledCollectionSlugs:n.map(p1)}),e[3]=n,e[4]=s):s=e[4],s};function p1(t){let{slug:e}=t;return e}var h1=y({nodes:[Ve],plugins:[{Component:es,position:"normal"}],slashMenu:{groups:[K([{Icon:nr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(We,{replace:!1})}}])]},toolbarFixed:{groups:[ue([{ChildComponent:nr,isActive:({selection:t})=>{if(!f1(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return no(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(We,{replace:!1})}}])]}});import{c as g1}from"react/compiler-runtime";import{jsx as ar}from"react/jsx-runtime";import{ShimmerEffect as C1}from"@payloadcms/ui";import{lazy as x1,Suspense as b1,useEffect as _1,useState as T1}from"react";var ts={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",tableCellEditing:"LexicalEditorTheme__tableCellEditing",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellPrimarySelected:"LexicalEditorTheme__tableCellPrimarySelected",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableCellSortedIndicator:"LexicalEditorTheme__tableCellSortedIndicator",tableResizeRuler:"LexicalEditorTheme__tableCellResizeRuler",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableSelected:"LexicalEditorTheme__tableSelected",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 Jt={namespace:"lexical",theme:ts};function os({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 rs=t=>{let e={enabledFeatures:[],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.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 sr(t,e,o){return{admin:o,features:rs(t),lexical:e,resolvedFeatureMap:t}}var E1=x1(()=>import("./Field-CO3ZH6ER.js").then(t=>({default:t.RichText}))),w1=t=>{let e=g1(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 d=a,c=l===void 0?Jt:l,[u,m]=T1(null),p,f;e[2]!==u||e[3]!==r||e[4]!==c||e[5]!==n||e[6]!==i||e[7]!==s||e[8]!==d?(p=()=>{if(u)return;let g=[];for(let[D,x]of Object.entries(r))x.clientFeatureProvider&&g.push(x.clientFeatureProvider(x.clientFeatureProps));let E=c||Jt,M=os({featureClientSchemaMap:n,field:i,schemaPath:s??i.name,unSanitizedEditorConfig:{features:g,lexical:E}});m(sr(M,E,d))},f=[c,d,u,r,n,i,s],e[2]=u,e[3]=r,e[4]=c,e[5]=n,e[6]=i,e[7]=s,e[8]=d,e[9]=p,e[10]=f):(p=e[9],f=e[10]),_1(p,f);let h;return e[11]!==u||e[12]!==t?(h=ar(b1,{fallback:ar(C1,{height:"35vh"}),children:u&&ar(E1,{...t,editorConfig:u})}),e[11]=u,e[12]=t,e[13]=h):h=e[13],h};function k1(...t){return t.filter(Boolean).join(" ")}var qt=new WeakMap;function ns(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function Qt(t,e){let o=qt.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=ns(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let a=ns(l);for(let d of r)a!==null&&d([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},qt.set(t,o)}return o.listeners.add(e),()=>{N1(t,e)}}function N1(t,e){let o=qt.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(qt.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function L1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function R1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function S1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function I1(t,e){return Qt(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}var F={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},y1=F.IS_BOLD|F.IS_ITALIC|F.IS_STRIKETHROUGH|F.IS_UNDERLINE|F.IS_CODE|F.IS_SUBSCRIPT|F.IS_SUPERSCRIPT|F.IS_HIGHLIGHT,v1="\xA0",M1=`
|
|
40
40
|
|
|
41
|
-
`,is="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",ls="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",
|
|
41
|
+
`,is="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",ls="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",D1=new RegExp("^[^"+ls+"]*["+is+"]"),A1=new RegExp("^[^"+is+"]*["+ls+"]"),O1={bold:F.IS_BOLD,code:F.IS_CODE,highlight:F.IS_HIGHLIGHT,italic:F.IS_ITALIC,strikethrough:F.IS_STRIKETHROUGH,subscript:F.IS_SUBSCRIPT,superscript:F.IS_SUPERSCRIPT,underline:F.IS_UNDERLINE},F1={directionless:F.IS_DIRECTIONLESS,unmergeable:F.IS_UNMERGEABLE},$1={center:F.IS_ALIGN_CENTER,end:F.IS_ALIGN_END,justify:F.IS_ALIGN_JUSTIFY,left:F.IS_ALIGN_LEFT,right:F.IS_ALIGN_RIGHT,start:F.IS_ALIGN_START},P1={[F.IS_ALIGN_CENTER]:"center",[F.IS_ALIGN_END]:"end",[F.IS_ALIGN_JUSTIFY]:"justify",[F.IS_ALIGN_LEFT]:"left",[F.IS_ALIGN_RIGHT]:"right",[F.IS_ALIGN_START]:"start"},B1={normal:F.IS_NORMAL,segmented:F.IS_SEGMENTED,token:F.IS_TOKEN},H1={[F.IS_NORMAL]:"normal",[F.IS_SEGMENTED]:"segmented",[F.IS_TOKEN]:"token"};import{c as j1}from"react/compiler-runtime";import{jsx as G1}from"react/jsx-runtime";import"react";var U1=()=>{let t=j1(2),{EditButton:e}=be(),o;return t[0]!==e?(o=e?G1(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as W1}from"react/compiler-runtime";import{jsx as V1}from"react/jsx-runtime";import"react";var K1=()=>{let t=W1(2),{RemoveButton:e}=be(),o;return t[0]!==e?(o=e?V1(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as z1}from"react/compiler-runtime";import{jsx as Z1}from"react/jsx-runtime";import"react";var X1=()=>{let t=z1(2),{Label:e}=be(),o;return t[0]!==e?(o=e?Z1(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Y1}from"react/compiler-runtime";import{jsx as J1}from"react/jsx-runtime";import"react";var q1=t=>{let e=Y1(3),{children:o}=t,{InlineBlockContainer:r}=be(),n;return e[0]!==r||e[1]!==o?(n=r?J1(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as Q1}from"react/compiler-runtime";import{jsx as eh}from"react/jsx-runtime";import"react";var th=t=>{let e=Q1(6),{children:o,editButton:r,Label:n,removeButton:i}=t,{BlockCollapsible:l}=ve(),s;return e[0]!==l||e[1]!==r||e[2]!==n||e[3]!==i||e[4]!==o?(s=l?eh(l,{editButton:r,Label:n,removeButton:i,children:o}):null,e[0]=l,e[1]=r,e[2]=n,e[3]=i,e[4]=o,e[5]=s):s=e[5],s};import{c as oh}from"react/compiler-runtime";import{jsx as rh}from"react/jsx-runtime";import"react";var nh=()=>{let t=oh(2),{EditButton:e}=ve(),o;return t[0]!==e?(o=e?rh(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as ih}from"react/compiler-runtime";import{jsx as lh}from"react/jsx-runtime";import"react";var sh=()=>{let t=ih(2),{RemoveButton:e}=ve(),o;return t[0]!==e?(o=e?lh(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};export{qe as $createAutoLinkNode,Nt as $createBlockNode,to as $createInlineBlockNode,de as $createLinkNode,Ue as $createRelationshipNode,Ke as $createUploadNode,pe as $isAutoLinkNode,kt as $isBlockNode,oo as $isInlineBlockNode,V as $isLinkNode,ro as $isRelationshipNode,no as $isUploadNode,_s as AlignFeatureClient,me as AutoLinkNode,th as BlockCollapsible,nh as BlockEditButton,ce as BlockNode,sh as BlockRemoveButton,Ls as BlockquoteFeatureClient,Ea as BlocksFeatureClient,Ua as BoldFeatureClient,as as CAN_USE_DOM,pd as ChecklistFeatureClient,F1 as DETAIL_TYPE_TO_DETAIL,M1 as DOUBLE_LINE_BREAK,P1 as ELEMENT_FORMAT_TO_TYPE,$1 as ELEMENT_TYPE_TO_FORMAT,ps as ENABLE_SLASH_MENU_COMMAND,ss as EditorConfigProvider,He as FieldsDrawer,Wm as FixedToolbarFeatureClient,Nc as HeadingFeatureClient,Oc as HorizontalRuleFeatureClient,y1 as IS_ALL_FORMATTING,Hc as IndentFeatureClient,q1 as InlineBlockContainer,U1 as InlineBlockEditButton,X1 as InlineBlockLabel,eo as InlineBlockNode,K1 as InlineBlockRemoveButton,Za as InlineCodeFeatureClient,tp as InlineToolbarFeatureClient,qa as ItalicFeatureClient,A1 as LTR_REGEX,Od as LexicalPluginToLexicalFeatureClient,qu as LinkFeatureClient,q as LinkNode,v1 as NON_BREAKING_SPACE,F as NodeFormat,Td as OrderedListFeatureClient,Ud as ParagraphFeatureClient,ds as Point,D1 as RTL_REGEX,fs as Rect,xm as RelationshipFeatureClient,Ge as RelationshipNode,w1 as RichTextField,jd as SlateToLexicalFeatureClient,rc as StrikethroughFeatureClient,sc as SubscriptFeatureClient,dc as SuperscriptFeatureClient,B1 as TEXT_MODE_TO_TYPE,O1 as TEXT_TYPE_TO_FORMAT,H1 as TEXT_TYPE_TO_MODE,ne as TOGGLE_LINK_COMMAND,Vf as TableFeatureClient,Aa as TestRecorderFeatureClient,lt as ToolbarButton,Re as ToolbarDropdown,Ba as TreeViewFeatureClient,gc as UnderlineFeatureClient,Id as UnorderedListFeatureClient,h1 as UploadFeatureClient,Ve as UploadNode,I1 as addSwipeDownListener,L1 as addSwipeLeftListener,R1 as addSwipeRightListener,S1 as addSwipeUpListener,bo as createBlockNode,y as createClientFeature,Jt as defaultEditorLexicalConfig,Wo as getDOMRangeRect,hs as getEnabledNodes,Me as getSelectedNode,us as isHTMLElement,ms as isPoint,k1 as joinClasses,sr as sanitizeClientEditorConfig,rs as sanitizeClientFeatures,Bt as setFloatingElemPosition,Mt as setFloatingElemPositionForLinkEditor,K as slashMenuBasicGroupWithItems,ue as toolbarAddDropdownGroupWithItems,To as toolbarFeatureButtonsGroupWithItems,Z as toolbarFormatGroupWithItems,J as toolbarTextDropdownGroupWithItems,B as useEditorConfigContext,cs as useLexicalDocumentDrawer,ae as useLexicalDrawer,it as useLexicalListDrawer};
|
|
42
42
|
//# sourceMappingURL=index.js.map
|