@payloadcms/richtext-lexical 3.58.0-internal.8775d75 → 3.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,5 +37,5 @@ ${e.map(tu).join(`
37
37
 
38
38
  `,Ui="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",Gi="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",nf=new RegExp("^[^"+Gi+"]*["+Ui+"]"),lf=new RegExp("^[^"+Ui+"]*["+Gi+"]"),sf={bold:O.IS_BOLD,code:O.IS_CODE,highlight:O.IS_HIGHLIGHT,italic:O.IS_ITALIC,strikethrough:O.IS_STRIKETHROUGH,subscript:O.IS_SUBSCRIPT,superscript:O.IS_SUPERSCRIPT,underline:O.IS_UNDERLINE},af={directionless:O.IS_DIRECTIONLESS,unmergeable:O.IS_UNMERGEABLE},cf={center:O.IS_ALIGN_CENTER,end:O.IS_ALIGN_END,justify:O.IS_ALIGN_JUSTIFY,left:O.IS_ALIGN_LEFT,right:O.IS_ALIGN_RIGHT,start:O.IS_ALIGN_START},uf={[O.IS_ALIGN_CENTER]:"center",[O.IS_ALIGN_END]:"end",[O.IS_ALIGN_JUSTIFY]:"justify",[O.IS_ALIGN_LEFT]:"left",[O.IS_ALIGN_RIGHT]:"right",[O.IS_ALIGN_START]:"start"},df={normal:O.IS_NORMAL,segmented:O.IS_SEGMENTED,token:O.IS_TOKEN},mf={[O.IS_NORMAL]:"normal",[O.IS_SEGMENTED]:"segmented",[O.IS_TOKEN]:"token"};var Wi={text:({node:t})=>{let e=t.text;return t.format&O.IS_BOLD&&(e=Fe("strong",{children:e})),t.format&O.IS_ITALIC&&(e=Fe("em",{children:e})),t.format&O.IS_STRIKETHROUGH&&(e=Fe("span",{style:{textDecoration:"line-through"},children:e})),t.format&O.IS_UNDERLINE&&(e=Fe("span",{style:{textDecoration:"underline"},children:e})),t.format&O.IS_CODE&&(e=Fe("code",{children:e})),t.format&O.IS_SUBSCRIPT&&(e=Fe("sub",{children:e})),t.format&O.IS_SUPERSCRIPT&&(e=Fe("sup",{children:e})),e}};import{jsx as Tt}from"react/jsx-runtime";var Vi={upload:({node:t})=>{let e=t;if(typeof e.value!="object")return null;let o=e.value,r=o.url;if(!o.mimeType.startsWith("image"))return Tt("a",{href:r,rel:"noopener noreferrer",children:o.filename});if(!o.sizes||!Object.keys(o.sizes).length)return Tt("img",{alt:o.filename,height:o.height,src:r,width:o.width});let n=[];for(let l in o.sizes){let i=o.sizes[l];if(!i||!i.width||!i.height||!i.mimeType||!i.filesize||!i.filename||!i.url)continue;let s=i?.url;n.push(Tt("source",{media:`(max-width: ${i.width}px)`,srcSet:s,type:i.mimeType},l))}return n.push(Tt("img",{alt:o?.filename,height:o?.height,src:r,width:o?.width},"image")),Tt("picture",{children:n})}};var Ye={...Bi,...Wi,...Oi,...Mi,...ji,...Di,...Ai,...Pi,...$i({}),...Vi,...Hi};import{jsx as Ji,Fragment as pf}from"react/jsx-runtime";import ar from"react";function Ki(t){let e=!!t?.root?.children?.length,o=!1;if(t?.root?.children?.length===1&&t?.root?.children[0]?.type==="paragraph"){let r=t?.root?.children[0];if(!r?.children||r?.children?.length===0)o=!0;else if(r?.children?.length===1){let n=r?.children[0];n?.type==="text"&&(n?.text?.length||(o=!0))}}return!(!e||o)}function Xi({converters:t,data:e,disableIndent:o,disableTextAlign:r}){return Ki(e)?zi({converters:t,disableIndent:o,disableTextAlign:r,nodes:e?.root?.children,parent:e?.root}):Ji(pf,{})}function zi({converters:t,disableIndent:e,disableTextAlign:o,nodes:r,parent:n}){let l=t.unknown;return r.map((s,u)=>{let c;s.type==="block"?(c=t?.blocks?.[s?.fields?.blockType],!c&&!l&&console.error(`Lexical => JSX converter: Blocks converter: found ${s?.fields?.blockType} block, but no converter is provided`)):s.type==="inlineBlock"?(c=t?.inlineBlocks?.[s?.fields?.blockType],!c&&!l&&console.error(`Lexical => JSX converter: Inline Blocks converter: found ${s?.fields?.blockType} inline block, but no converter is provided`)):c=t[s.type];try{!c&&l&&(c=l);let d;c?d=typeof c=="function"?c({childIndex:u,converters:t,node:s,nodesToJSX:m=>zi({converters:m.converters??t,disableIndent:m.disableIndent??e,disableTextAlign:m.disableTextAlign??o,nodes:m.nodes,parent:m.parent??{...s,parent:n}}),parent:n}):c:d=Ji("span",{children:"unknown node"},u);let a={};if(!o&&(!Array.isArray(o)||!o?.includes(s.type))&&"format"in s&&s.format)switch(s.format){case"center":a.textAlign="center";break;case"end":a.textAlign="right";break;case"justify":a.textAlign="justify";break;case"left":break;case"right":a.textAlign="right";break;case"start":a.textAlign="left";break}if(!e&&(!Array.isArray(e)||!e?.includes(s.type))&&"indent"in s&&s.indent&&s.type!=="listitem"&&(a.paddingInlineStart=`${Number(s.indent)*40}px`),ar.isValidElement(d)){if(a.textAlign||a.paddingInlineStart){let p={...a,...d?.props?.style??{}};return ar.cloneElement(d,{key:u,style:p})}return ar.cloneElement(d,{key:u})}return d}catch(d){return console.error("Error converting lexical node to JSX:",d,"node:",s),null}}).filter(Boolean)}var cr=({className:t,converters:e,data:o,disableContainer:r,disableIndent:n,disableTextAlign:l})=>{if(!o)return null;let i={};e?typeof e=="function"?i=e({defaultConverters:Ye}):i=e:i=Ye;let s=o&&!Array.isArray(o)&&typeof o=="object"&&"root"in o&&Xi({converters:i,data:o,disableIndent:n,disableTextAlign:l});return r?Zi(ff,{children:s}):Zi("div",{className:t??"payload-richtext",children:s})};function qi(){let t=hf(7),[e]=gf(),o;t[0]!==e?(o=e.getEditorState().toJSON(),t[0]=e,t[1]=o):o=t[1];let[r,n]=Cf(o),l,i;t[2]!==e?(l=()=>e.registerUpdateListener(u=>{let{editorState:c}=u;n(c.toJSON())}),i=[e],t[2]=e,t[3]=l,t[4]=i):(l=t[3],i=t[4]),xf(l,i);let s;return t[5]!==r?(s=Yi("div",{className:"debug-jsx-converter",children:Yi(cr,{converters:Ye,data:r})}),t[5]=r,t[6]=s):s=t[6],s}var bf=v({plugins:[{Component:qi,position:"bottom"}]});var B={amber:{50:"oklch(0.987 0.022 95.277)",100:"oklch(0.962 0.059 95.617)",200:"oklch(0.924 0.12 95.746)",300:"oklch(0.879 0.169 91.605)",400:"oklch(0.828 0.189 84.429)",500:"oklch(0.769 0.188 70.08)",600:"oklch(0.666 0.179 58.318)",700:"oklch(0.555 0.163 48.998)",800:"oklch(0.473 0.137 46.201)",900:"oklch(0.414 0.112 45.904)",950:"oklch(0.279 0.077 45.635)"},black:"#000",blue:{50:"oklch(0.97 0.014 254.604)",100:"oklch(0.932 0.032 255.585)",200:"oklch(0.882 0.059 254.128)",300:"oklch(0.809 0.105 251.813)",400:"oklch(0.707 0.165 254.624)",500:"oklch(0.623 0.214 259.815)",600:"oklch(0.546 0.245 262.881)",700:"oklch(0.488 0.243 264.376)",800:"oklch(0.424 0.199 265.638)",900:"oklch(0.379 0.146 265.522)",950:"oklch(0.282 0.091 267.935)"},current:"currentColor",cyan:{50:"oklch(0.984 0.019 200.873)",100:"oklch(0.956 0.045 203.388)",200:"oklch(0.917 0.08 205.041)",300:"oklch(0.865 0.127 207.078)",400:"oklch(0.789 0.154 211.53)",500:"oklch(0.715 0.143 215.221)",600:"oklch(0.609 0.126 221.723)",700:"oklch(0.52 0.105 223.128)",800:"oklch(0.45 0.085 224.283)",900:"oklch(0.398 0.07 227.392)",950:"oklch(0.302 0.056 229.695)"},emerald:{50:"oklch(0.979 0.021 166.113)",100:"oklch(0.95 0.052 163.051)",200:"oklch(0.905 0.093 164.15)",300:"oklch(0.845 0.143 164.978)",400:"oklch(0.765 0.177 163.223)",500:"oklch(0.696 0.17 162.48)",600:"oklch(0.596 0.145 163.225)",700:"oklch(0.508 0.118 165.612)",800:"oklch(0.432 0.095 166.913)",900:"oklch(0.378 0.077 168.94)",950:"oklch(0.262 0.051 172.552)"},fuchsia:{50:"oklch(0.977 0.017 320.058)",100:"oklch(0.952 0.037 318.852)",200:"oklch(0.903 0.076 319.62)",300:"oklch(0.833 0.145 321.434)",400:"oklch(0.74 0.238 322.16)",500:"oklch(0.667 0.295 322.15)",600:"oklch(0.591 0.293 322.896)",700:"oklch(0.518 0.253 323.949)",800:"oklch(0.452 0.211 324.591)",900:"oklch(0.401 0.17 325.612)",950:"oklch(0.293 0.136 325.661)"},gray:{50:"oklch(0.985 0.002 247.839)",100:"oklch(0.967 0.003 264.542)",200:"oklch(0.928 0.006 264.531)",300:"oklch(0.872 0.01 258.338)",400:"oklch(0.707 0.022 261.325)",500:"oklch(0.551 0.027 264.364)",600:"oklch(0.446 0.03 256.802)",700:"oklch(0.373 0.034 259.733)",800:"oklch(0.278 0.033 256.848)",900:"oklch(0.21 0.034 264.665)",950:"oklch(0.13 0.028 261.692)"},green:{50:"oklch(0.982 0.018 155.826)",100:"oklch(0.962 0.044 156.743)",200:"oklch(0.925 0.084 155.995)",300:"oklch(0.871 0.15 154.449)",400:"oklch(0.792 0.209 151.711)",500:"oklch(0.723 0.219 149.579)",600:"oklch(0.627 0.194 149.214)",700:"oklch(0.527 0.154 150.069)",800:"oklch(0.448 0.119 151.328)",900:"oklch(0.393 0.095 152.535)",950:"oklch(0.266 0.065 152.934)"},indigo:{50:"oklch(0.962 0.018 272.314)",100:"oklch(0.93 0.034 272.788)",200:"oklch(0.87 0.065 274.039)",300:"oklch(0.785 0.115 274.713)",400:"oklch(0.673 0.182 276.935)",500:"oklch(0.585 0.233 277.117)",600:"oklch(0.511 0.262 276.966)",700:"oklch(0.457 0.24 277.023)",800:"oklch(0.398 0.195 277.366)",900:"oklch(0.359 0.144 278.697)",950:"oklch(0.257 0.09 281.288)"},inherit:"inherit",lime:{50:"oklch(0.986 0.031 120.757)",100:"oklch(0.967 0.067 122.328)",200:"oklch(0.938 0.127 124.321)",300:"oklch(0.897 0.196 126.665)",400:"oklch(0.841 0.238 128.85)",500:"oklch(0.768 0.233 130.85)",600:"oklch(0.648 0.2 131.684)",700:"oklch(0.532 0.157 131.589)",800:"oklch(0.453 0.124 130.933)",900:"oklch(0.405 0.101 131.063)",950:"oklch(0.274 0.072 132.109)"},neutral:{50:"oklch(0.985 0 0)",100:"oklch(0.97 0 0)",200:"oklch(0.922 0 0)",300:"oklch(0.87 0 0)",400:"oklch(0.708 0 0)",500:"oklch(0.556 0 0)",600:"oklch(0.439 0 0)",700:"oklch(0.371 0 0)",800:"oklch(0.269 0 0)",900:"oklch(0.205 0 0)",950:"oklch(0.145 0 0)"},orange:{50:"oklch(0.98 0.016 73.684)",100:"oklch(0.954 0.038 75.164)",200:"oklch(0.901 0.076 70.697)",300:"oklch(0.837 0.128 66.29)",400:"oklch(0.75 0.183 55.934)",500:"oklch(0.705 0.213 47.604)",600:"oklch(0.646 0.222 41.116)",700:"oklch(0.553 0.195 38.402)",800:"oklch(0.47 0.157 37.304)",900:"oklch(0.408 0.123 38.172)",950:"oklch(0.266 0.079 36.259)"},pink:{50:"oklch(0.971 0.014 343.198)",100:"oklch(0.948 0.028 342.258)",200:"oklch(0.899 0.061 343.231)",300:"oklch(0.823 0.12 346.018)",400:"oklch(0.718 0.202 349.761)",500:"oklch(0.656 0.241 354.308)",600:"oklch(0.592 0.249 0.584)",700:"oklch(0.525 0.223 3.958)",800:"oklch(0.459 0.187 3.815)",900:"oklch(0.408 0.153 2.432)",950:"oklch(0.284 0.109 3.907)"},purple:{50:"oklch(0.977 0.014 308.299)",100:"oklch(0.946 0.033 307.174)",200:"oklch(0.902 0.063 306.703)",300:"oklch(0.827 0.119 306.383)",400:"oklch(0.714 0.203 305.504)",500:"oklch(0.627 0.265 303.9)",600:"oklch(0.558 0.288 302.321)",700:"oklch(0.496 0.265 301.924)",800:"oklch(0.438 0.218 303.724)",900:"oklch(0.381 0.176 304.987)",950:"oklch(0.291 0.149 302.717)"},red:{50:"oklch(0.971 0.013 17.38)",100:"oklch(0.936 0.032 17.717)",200:"oklch(0.885 0.062 18.334)",300:"oklch(0.808 0.114 19.571)",400:"oklch(0.704 0.191 22.216)",500:"oklch(0.637 0.237 25.331)",600:"oklch(0.577 0.245 27.325)",700:"oklch(0.505 0.213 27.518)",800:"oklch(0.444 0.177 26.899)",900:"oklch(0.396 0.141 25.723)",950:"oklch(0.258 0.092 26.042)"},rose:{50:"oklch(0.969 0.015 12.422)",100:"oklch(0.941 0.03 12.58)",200:"oklch(0.892 0.058 10.001)",300:"oklch(0.81 0.117 11.638)",400:"oklch(0.712 0.194 13.428)",500:"oklch(0.645 0.246 16.439)",600:"oklch(0.586 0.253 17.585)",700:"oklch(0.514 0.222 16.935)",800:"oklch(0.455 0.188 13.697)",900:"oklch(0.41 0.159 10.272)",950:"oklch(0.271 0.105 12.094)"},sky:{50:"oklch(0.977 0.013 236.62)",100:"oklch(0.951 0.026 236.824)",200:"oklch(0.901 0.058 230.902)",300:"oklch(0.828 0.111 230.318)",400:"oklch(0.746 0.16 232.661)",500:"oklch(0.685 0.169 237.323)",600:"oklch(0.588 0.158 241.966)",700:"oklch(0.5 0.134 242.749)",800:"oklch(0.443 0.11 240.79)",900:"oklch(0.391 0.09 240.876)",950:"oklch(0.293 0.066 243.157)"},slate:{50:"oklch(0.984 0.003 247.858)",100:"oklch(0.968 0.007 247.896)",200:"oklch(0.929 0.013 255.508)",300:"oklch(0.869 0.022 252.894)",400:"oklch(0.704 0.04 256.788)",500:"oklch(0.554 0.046 257.417)",600:"oklch(0.446 0.043 257.281)",700:"oklch(0.372 0.044 257.287)",800:"oklch(0.279 0.041 260.031)",900:"oklch(0.208 0.042 265.755)",950:"oklch(0.129 0.042 264.695)"},stone:{50:"oklch(0.985 0.001 106.423)",100:"oklch(0.97 0.001 106.424)",200:"oklch(0.923 0.003 48.717)",300:"oklch(0.869 0.005 56.366)",400:"oklch(0.709 0.01 56.259)",500:"oklch(0.553 0.013 58.071)",600:"oklch(0.444 0.011 73.639)",700:"oklch(0.374 0.01 67.558)",800:"oklch(0.268 0.007 34.298)",900:"oklch(0.216 0.006 56.043)",950:"oklch(0.147 0.004 49.25)"},teal:{50:"oklch(0.984 0.014 180.72)",100:"oklch(0.953 0.051 180.801)",200:"oklch(0.91 0.096 180.426)",300:"oklch(0.855 0.138 181.071)",400:"oklch(0.777 0.152 181.912)",500:"oklch(0.704 0.14 182.503)",600:"oklch(0.6 0.118 184.704)",700:"oklch(0.511 0.096 186.391)",800:"oklch(0.437 0.078 188.216)",900:"oklch(0.386 0.063 188.416)",950:"oklch(0.277 0.046 192.524)"},transparent:"transparent",violet:{50:"oklch(0.969 0.016 293.756)",100:"oklch(0.943 0.029 294.588)",200:"oklch(0.894 0.057 293.283)",300:"oklch(0.811 0.111 293.571)",400:"oklch(0.702 0.183 293.541)",500:"oklch(0.606 0.25 292.717)",600:"oklch(0.541 0.281 293.009)",700:"oklch(0.491 0.27 292.581)",800:"oklch(0.432 0.232 292.759)",900:"oklch(0.38 0.189 293.745)",950:"oklch(0.283 0.141 291.089)"},white:"#fff",yellow:{50:"oklch(0.987 0.026 102.212)",100:"oklch(0.973 0.071 103.193)",200:"oklch(0.945 0.129 101.54)",300:"oklch(0.905 0.182 98.111)",400:"oklch(0.852 0.199 91.936)",500:"oklch(0.795 0.184 86.047)",600:"oklch(0.681 0.162 75.834)",700:"oklch(0.554 0.135 66.442)",800:"oklch(0.476 0.114 61.907)",900:"oklch(0.421 0.095 57.708)",950:"oklch(0.286 0.066 53.813)"},zinc:{50:"oklch(0.985 0 0)",100:"oklch(0.967 0.001 286.375)",200:"oklch(0.92 0.004 286.32)",300:"oklch(0.871 0.006 286.286)",400:"oklch(0.705 0.015 286.067)",500:"oklch(0.552 0.016 285.938)",600:"oklch(0.442 0.017 285.786)",700:"oklch(0.37 0.013 285.805)",800:"oklch(0.274 0.006 286.033)",900:"oklch(0.21 0.006 285.885)",950:"oklch(0.141 0.005 285.823)"}},kf={text:{"text-red":{css:{color:`light-dark(${B.red[600]}, ${B.red[400]})`},label:"Red"},"text-orange":{css:{color:`light-dark(${B.orange[600]}, ${B.orange[400]})`},label:"Orange"},"text-yellow":{css:{color:`light-dark(${B.yellow[700]}, ${B.yellow[300]})`},label:"Yellow"},"text-green":{css:{color:`light-dark(${B.green[700]}, ${B.green[400]})`},label:"Green"},"text-blue":{css:{color:`light-dark(${B.blue[600]}, ${B.blue[400]})`},label:"Blue"},"text-purple":{css:{color:`light-dark(${B.purple[600]}, ${B.purple[400]})`},label:"Purple"},"text-pink":{css:{color:`light-dark(${B.pink[600]}, ${B.pink[400]})`},label:"Pink"}},background:{"bg-red":{css:{"background-color":`light-dark(${B.red[400]}, ${B.red[600]})`},label:"Red"},"bg-orange":{css:{"background-color":`light-dark(${B.orange[400]}, ${B.orange[600]})`},label:"Orange"},"bg-yellow":{css:{"background-color":`light-dark(${B.yellow[300]}, ${B.yellow[700]})`},label:"Yellow"},"bg-green":{css:{"background-color":`light-dark(${B.green[400]}, ${B.green[700]})`},label:"Green"},"bg-blue":{css:{"background-color":`light-dark(${B.blue[400]}, ${B.blue[600]})`},label:"Blue"},"bg-purple":{css:{"background-color":`light-dark(${B.purple[400]}, ${B.purple[600]})`},label:"Purple"},"bg-pink":{css:{"background-color":`light-dark(${B.pink[400]}, ${B.pink[600]})`},label:"Pink"}}};import{$isNodeSelection as n0}from"lexical";import{jsx as wt,jsxs as _f}from"react/jsx-runtime";import"react";var ur=()=>_f("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:[wt("g",{clipPath:"url(#clip0_4397_10817)",children:wt("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"})}),wt("defs",{children:wt("clipPath",{id:"clip0_4397_10817",children:wt("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{jsx as Ef}from"react/jsx-runtime";import*as es from"react";import{DecoratorBlockNode as Tf}from"@lexical/react/LexicalDecoratorBlockNode.js";function wf(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:Qi({relationTo:o,value:e})}:null}var Et=class extends Tf{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"relationship"}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:wf,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=Qi(o);return r.setFormat(e.format),r}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div");e.setAttribute("data-lexical-relationship-id",String(typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value)),e.setAttribute("data-lexical-relationship-relationTo",this.__data?.relationTo);let o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"relationship",version:2}}getData(){return this.getLatest().__data}getTextContent(){return`${this.__data?.relationTo} relation to ${typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value}`}setData(e){let o=this.getWritable();o.__data=e}};function Qi(t){return new Et({data:t})}var Sf=es.lazy(()=>import("./RelationshipComponent-APF3CN47.js").then(t=>({default:t.RelationshipComponent})));function Nf(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:$e({relationTo:o,value:e})}:null}var ke=class extends Et{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:Nf,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=$e(o);return r.setFormat(e.format),r}decorate(e,o){return Ef(Sf,{className:o.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function $e(t){return new ke({data:t})}function dr(t){return t instanceof ke}import{c as Wf}from"react/compiler-runtime";import{jsx as Vf}from"react/jsx-runtime";import{useLexicalComposerContext as Kf}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Jf}from"@lexical/utils";import{useConfig as Xf}from"@payloadcms/ui";import{$getPreviousSelection as zf,$getSelection as Zf,$isParagraphNode as Yf,$isRangeSelection as qf,COMMAND_PRIORITY_EDITOR as Qf,createCommand as e0}from"lexical";import{useEffect as t0}from"react";import{c as Pf}from"react/compiler-runtime";import{jsx as no}from"react/jsx-runtime";import{useLexicalComposerContext as Bf}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as Hf,COMMAND_PRIORITY_EDITOR as jf}from"lexical";import{useEffect as Uf,useState as rs}from"react";import{c as Lf}from"react/compiler-runtime";import{jsx as yf}from"react/jsx-runtime";import{useLexicalComposerContext as If}from"@lexical/react/LexicalComposerContext";import{useListDrawer as Rf,useModal as vf}from"@payloadcms/ui";import{$getNodeByKey as ts,$getPreviousSelection as Mf,$getRoot as Df,$getSelection as Af,$isRangeSelection as Of,$setSelection as Ff}from"lexical";import{useEffect as $f,useState as os}from"react";var St=t=>{let e=Lf(23),[o]=If(),[r,n]=os(null),[l,i]=os(!1),[s,u,c]=Rf(t),{closeDrawer:d,drawerSlug:a,isDrawerOpen:p,openDrawer:m}=c,{modalState:f}=vf(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let F=Af()??Mf();n(F)},e[0]=h):h=e[0];let x=h,b;e[1]!==o||e[2]!==r?(b=()=>{r&&o.update(()=>{if(Of(r)){let{anchor:F,focus:R}=r;ts(F.key)&&ts(R.key)&&Ff(r.clone())}else Df().selectEnd()},{discrete:!0,skipTransforms:!0})},e[1]=o,e[2]=r,e[3]=b):b=e[3];let T=b,E;e[4]!==d?(E=()=>{d()},e[4]=d,e[5]=E):E=e[5];let C=E,k,g;e[6]!==a||e[7]!==f||e[8]!==T||e[9]!==l?(k=()=>{if(!l)return;let F=f[a];F&&!F?.isOpen&&(i(!1),setTimeout(()=>{T()},1))},g=[f,a,T,l],e[6]=a,e[7]=f,e[8]=T,e[9]=l,e[10]=k,e[11]=g):(k=e[10],g=e[11]),$f(k,g);let w;e[12]!==u?(w=F=>yf(u,{...F,onClick:()=>{x()}}),e[12]=u,e[13]=w):w=e[13];let L;e[14]!==m?(L=()=>{x(),m(),i(!0)},e[14]=m,e[15]=L):L=e[15];let D;return e[16]!==s||e[17]!==C||e[18]!==p||e[19]!==a||e[20]!==w||e[21]!==L?(D={closeListDrawer:C,isListDrawerOpen:p,ListDrawer:s,listDrawerSlug:a,ListDrawerToggler:w,openListDrawer:L},e[16]=s,e[17]=C,e[18]=p,e[19]=a,e[20]=w,e[21]=L,e[22]=D):D=e[22],D};var Gf=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Hf(o);n&&n.replace($e({relationTo:e,value:r}))}):t.dispatchCommand(mr,{relationTo:e,value:r})},ns=t=>{let e=Pf(16),{enabledCollectionSlugs:o}=t,[r]=Bf(),n;e[0]!==o?.[0]?(n=()=>o?.[0],e[0]=o?.[0],e[1]=n):n=e[1];let[l]=rs(n),[i,s]=rs(null),u=o||void 0,c;e[2]!==l||e[3]!==u?(c={collectionSlugs:u,selectedCollection:l},e[2]=l,e[3]=u,e[4]=c):c=e[4];let{closeListDrawer:d,ListDrawer:a,openListDrawer:p}=St(c),m,f;e[5]!==r||e[6]!==p?(m=()=>r.registerCommand(lt,T=>(s(T?.replace?T?.replace.nodeKey:null),p(),!0),jf),f=[r,p],e[5]=r,e[6]=p,e[7]=m,e[8]=f):(m=e[7],f=e[8]),Uf(m,f);let h;e[9]!==d||e[10]!==r||e[11]!==i?(h=T=>{let{collectionSlug:E,doc:C}=T;Gf({editor:r,relationTo:E,replaceNodeKey:i,value:C.id}),d()},e[9]=d,e[10]=r,e[11]=i,e[12]=h):h=e[12];let x=h,b;return e[13]!==a||e[14]!==x?(b=no(a,{onSelect:x}),e[13]=a,e[14]=x,e[15]=b):b=e[15],b},ls=t=>(t?.enabledCollectionSlugs?.length??-1)>0?no(ns,{...t}):no(Ot,{...t,children:no(ns,{...t})});var mr=e0("INSERT_RELATIONSHIP_COMMAND"),is=t=>{let e=Wf(5),{clientProps:o}=t,[r]=Kf(),{config:n}=Xf(),{collections:l}=n,i=null;if(o?.enabledCollections)i=o?.enabledCollections;else if(o?.disabledCollections){let c;e[0]!==o?.disabledCollections?(c=d=>{let{slug:a}=d;return!o?.disabledCollections?.includes(a)},e[0]=o?.disabledCollections,e[1]=c):c=e[1],i=l.filter(c).map(o0)}let s,u;return e[2]!==r?(s=()=>{if(!r.hasNodes([ke]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand(mr,r0,Qf)},u=[r],e[2]=r,e[3]=s,e[4]=u):(s=e[3],u=e[4]),t0(s,u),Vf(ls,{enabledCollectionSlugs:i})};function o0(t){let{slug:e}=t;return e}function r0(t){let e=Zf()||zf();if(qf(e)){let o=$e(t),{focus:r}=e,n=r.getNode();Jf(o),Yf(n)&&!n.__first&&n.remove()}return!0}var l0=v({nodes:[ke],plugins:[{Component:is,position:"normal"}],slashMenu:{groups:[Z([{Icon:ur,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(lt,{replace:!1})}}])]},toolbarFixed:{groups:[he([{ChildComponent:ur,isActive:({selection:t})=>{if(!n0(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return dr(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(lt,{replace:!1})}}])]}});import{c as hs}from"react/compiler-runtime";import{jsx as ie,jsxs as M0}from"react/jsx-runtime";import{useLexicalComposerContext as D0}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as A0,useThrottledEffect as O0,useTranslation as F0}from"@payloadcms/ui";import*as _e from"react";import{useMemo as $0}from"react";import{c as i0}from"react/compiler-runtime";import{jsx as s0}from"react/jsx-runtime";import{mergeRegister as a0}from"@lexical/utils";import{$addUpdateTag as c0,$getSelection as u0}from"lexical";import{useDeferredValue as d0,useEffect as m0,useState as p0}from"react";var ss="toolbar-popup__button",Nt=t=>{let e=i0(23),{children:o,editor:r,item:n}=t,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={active:!1,enabled:!0},e[0]=l):l=e[0];let[i,s]=p0(l),u=d0(i),c=H(),d=u.enabled?"":"disabled",a=u.active?"active":"",p=n.key?`${ss}-${n.key}`:"",m;e[1]!==d||e[2]!==a||e[3]!==p?(m=[ss,d,a,p].filter(Boolean),e[1]=d,e[2]=a,e[3]=p,e[4]=m):m=e[4];let f=m.join(" "),h;e[5]!==r||e[6]!==c||e[7]!==n?(h=()=>{r.getEditorState().read(()=>{let L=u0();if(!L)return;let D=n.isActive?n.isActive({editor:r,editorConfigContext:c,selection:L}):!1,F=n.isEnabled?n.isEnabled({editor:r,editorConfigContext:c,selection:L}):!0;s(R=>R.active===D&&R.enabled===F?R:{active:D,enabled:F})})},e[5]=r,e[6]=c,e[7]=n,e[8]=h):h=e[8];let x=h,b=Ft(),T,E;e[9]!==r||e[10]!==b||e[11]!==x?(T=()=>{b(x);let L=()=>b(x),D=a0(r.registerUpdateListener(L));return document.addEventListener("mouseup",L),()=>{D(),document.removeEventListener("mouseup",L)}},E=[r,b,x],e[9]=r,e[10]=b,e[11]=x,e[12]=T,e[13]=E):(T=e[12],E=e[13]),m0(T,E);let C;e[14]!==i||e[15]!==r||e[16]!==n?(C=()=>{i.enabled&&r.focus(()=>{r.update(f0),n.onSelect?.({editor:r,isActive:i.active})})},e[14]=i,e[15]=r,e[16]=n,e[17]=C):C=e[17];let k=C,g=h0,w;return e[18]!==o||e[19]!==f||e[20]!==k||e[21]!==n.key?(w=s0("button",{className:f,"data-button-key":n.key,onClick:k,onMouseDown:g,type:"button",children:o}),e[18]=o,e[19]=f,e[20]=k,e[21]=n.key,e[22]=w):w=e[22],w};function f0(){c0("toolbar")}function h0(t){t.preventDefault()}import{c as T0}from"react/compiler-runtime";import{jsx as qe}from"react/jsx-runtime";import fs,{useCallback as w0,useDeferredValue as E0,useEffect as S0,useMemo as N0}from"react";import{mergeRegister as L0}from"@lexical/utils";import{useTranslation as y0}from"@payloadcms/ui";import{$getSelection as I0}from"lexical";import{jsx as Le,jsxs as as}from"react/jsx-runtime";import{Button as g0}from"@payloadcms/ui";import{$addUpdateTag as x0,isDOMNode as C0}from"lexical";import lo,{useCallback as b0,useEffect as io,useMemo as us,useRef as pr,useState as fr}from"react";import{createPortal as k0}from"react-dom";var cs="toolbar-popup__dropdown-item",ds=lo.createContext(null);function ms({active:t,children:e,editor:o,enabled:r,Icon:n,item:l,itemKey:i,tooltip:s}){let u=us(()=>[cs,r===!1?"disabled":"",t?"active":"",l?.key?`${cs}-${l.key}`:""].filter(Boolean).join(" "),[r,t,l.key]),c=pr(null),d=lo.use(ds);if(d===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:a}=d;return io(()=>{c?.current!=null&&a(c)},[c,a]),Le(g0,{"aria-label":s,buttonStyle:"none",className:u,disabled:r===!1,extraButtonProps:{"data-item-key":i},icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{x0("toolbar")}),l.onSelect?.({editor:o,isActive:t})})},onMouseDown:p=>{p.preventDefault()},ref:c,tooltip:s,type:"button",children:e})}function _0({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,l]=fr(),[i,s]=fr(),u=b0(a=>{l(p=>p!=null?[...p,a]:[a])},[l]),c=a=>{if(n==null)return;let{key:p}=a;["ArrowDown","ArrowUp","Escape","Tab"].includes(p)&&a.preventDefault(),p==="Escape"||p==="Tab"?r():p==="ArrowUp"?s(m=>{if(m==null)return n[0];let f=n.indexOf(m)-1;return n[f===-1?n.length-1:f]}):p==="ArrowDown"&&s(m=>m==null?n[0]:n[n.indexOf(m)+1])},d=us(()=>({registerItem:u}),[u]);return io(()=>{n!=null&&i==null&&s(n[0]),i!=null&&i?.current!=null&&i.current.focus()},[n,i]),Le(ds,{value:d,children:Le("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:c,ref:e,children:t})})}function ps({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,dropdownKey:n,Icon:l,itemsContainerClassNames:i,label:s,stopCloseOnClickSelf:u}){let c=pr(null),d=pr(null),[a,p]=fr(!1),m=()=>{p(!1),d?.current!=null&&d.current.focus()};io(()=>{let h=d.current,x=c.current;if(a&&h!==null&&x!==null){let{left:b,top:T}=h.getBoundingClientRect(),E=window.scrollY||document.documentElement.scrollTop;x.style.top=`${T+E+h.offsetHeight+5}px`,x.style.left=`${Math.min(b-5,window.innerWidth-x.offsetWidth-20)}px`}},[c,d,a]),io(()=>{let h=d.current;if(h!==null&&a){let x=b=>{let T=b.target;C0(T)&&(u&&c.current&&c.current.contains(T)||h.contains(T)||p(!1))};return document.addEventListener("click",x),()=>{document.removeEventListener("click",x)}}},[c,d,a,u]);let f=k0(Le(_0,{dropDownRef:c,itemsContainerClassNames:i,onClose:m,children:o}),document.body);return as(lo.Fragment,{children:[as("button",{"aria-label":t,className:e+(a?" active":""),"data-dropdown-key":n,disabled:r,onClick:h=>{h.preventDefault(),p(!a)},onMouseDown:h=>{h.preventDefault()},ref:d,type:"button",children:[l&&Le(l,{}),s&&Le("span",{className:"toolbar-popup__dropdown-label",children:s}),Le("i",{className:"toolbar-popup__dropdown-caret"})]}),a&&Le(lo.Fragment,{children:f})]})}var hr="toolbar-popup__dropdown",R0=t=>{let e=T0(14),{active:o,anchorElem:r,editor:n,enabled:l,item:i}=t,{i18n:s}=y0(),{fieldProps:u}=H(),{featureClientSchemaMap:c,schemaPath:d}=u;if(i.Component){let p;return e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==i?(p=i?.Component&&qe(i.Component,{active:o,anchorElem:r,editor:n,enabled:l,item:i},i.key),e[0]=o,e[1]=r,e[2]=n,e[3]=l,e[4]=i,e[5]=p):p=e[5],p}let a;if(e[6]!==o||e[7]!==n||e[8]!==l||e[9]!==c||e[10]!==s||e[11]!==i||e[12]!==d){let p=i.key,m;i.label&&(p=typeof i.label=="function"?i.label({featureClientSchemaMap:c,i18n:s,schemaPath:d}):i.label),p.length>25?m=p.substring(0,25)+"...":m=p,a=qe(ms,{active:o,editor:n,enabled:l,Icon:i?.ChildComponent?qe(i.ChildComponent,{}):void 0,item:i,itemKey:i.key,tooltip:p,children:qe("span",{className:"text",children:m})},i.key),e[6]=o,e[7]=n,e[8]=l,e[9]=c,e[10]=s,e[11]=i,e[12]=d,e[13]=a}else a=e[13];return a},v0=fs.memo(R0),Pe=({anchorElem:t,classNames:e,editor:o,group:r,Icon:n,itemsContainerClassNames:l,label:i,maxActiveItems:s,onActiveChange:u})=>{let[c,d]=fs.useState({activeItemKeys:[],enabledGroup:!0,enabledItemKeys:[]}),a=E0(c),p=H(),{items:m,key:f}=r,h=Ft(),x=w0(()=>{o.getEditorState().read(()=>{let T=I0();if(!T)return;let E=[],C=[],k=[];for(let g of m)g.isActive&&(!s||E.length<s)&&g.isActive({editor:o,editorConfigContext:p,selection:T})&&(E.push(g.key),C.push(g)),g.isEnabled?g.isEnabled({editor:o,editorConfigContext:p,selection:T})&&k.push(g.key):k.push(g.key);d({activeItemKeys:E,enabledGroup:r.isEnabled?r.isEnabled({editor:o,editorConfigContext:p,selection:T}):!0,enabledItemKeys:k}),u&&u({activeItems:C})})},[o,p,r,m,s,u]);S0(()=>(h(x),L0(o.registerUpdateListener(async()=>{await h(x)}))),[o,h,x]);let b=N0(()=>m?.length?m.map(T=>qe(v0,{active:a.activeItemKeys.includes(T.key),anchorElem:t,editor:o,enabled:a.enabledItemKeys.includes(T.key),item:T},T.key)):null,[m,a,t,o]);return qe(ps,{buttonAriaLabel:`${f} dropdown`,buttonClassName:[hr,`${hr}-${f}`,...e||[]].filter(Boolean).join(" "),disabled:!a.enabledGroup,dropdownKey:f,Icon:n,itemsContainerClassNames:[`${hr}-items`,...l||[]],label:i,children:b},f)};function P0({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(Nt,{editor:e,item:o,children:ie(o.ChildComponent,{})},o.key):null}function B0(t){let e=hs(23),{anchorElem:o,editor:r,editorConfig:n,group:l,index:i}=t,{i18n:s}=F0(),{fieldProps:u}=H(),{featureClientSchemaMap:c,schemaPath:d}=u,[a,p]=_e.useState(void 0),[m,f]=_e.useState(void 0),h;e[0]!==l.ChildComponent||e[1]!==l.items||e[2]!==l.type?(h=()=>{l?.type==="dropdown"&&l.items.length&&l.ChildComponent?f(()=>l.ChildComponent):f(void 0)},e[0]=l.ChildComponent,e[1]=l.items,e[2]=l.type,e[3]=h):h=e[3];let x;e[4]!==l?(x=[l],e[4]=l,e[5]=x):x=e[5],_e.useEffect(h,x);let b;e[6]!==c||e[7]!==l.ChildComponent||e[8]!==l.items||e[9]!==l.type||e[10]!==s||e[11]!==d?(b=k=>{let{activeItems:g}=k;if(!g.length){l?.type==="dropdown"&&l.items.length&&l.ChildComponent?(f(()=>l.ChildComponent),p(void 0)):(f(void 0),p(void 0));return}let w=g[0],L=w.key;w.label&&(L=typeof w.label=="function"?w.label({featureClientSchemaMap:c,i18n:s,schemaPath:d}):w.label),L.length>25&&(L=L.substring(0,25)+"..."),g.length===1?(p(L),f(()=>w.ChildComponent)):(p(s.t("lexical:general:toolbarItemsActive",{count:g.length})),l?.type==="dropdown"&&l.items.length&&l.ChildComponent?f(()=>l.ChildComponent):f(void 0))},e[6]=c,e[7]=l.ChildComponent,e[8]=l.items,e[9]=l.type,e[10]=s,e[11]=d,e[12]=b):b=e[12];let T=b,E=`fixed-toolbar__group fixed-toolbar__group-${l.key}`,C;return e[13]!==m||e[14]!==o||e[15]!==a||e[16]!==r||e[17]!==n.features.toolbarFixed?.groups.length||e[18]!==l||e[19]!==i||e[20]!==T||e[21]!==E?(C=M0("div",{className:E,"data-toolbar-group-key":l.key,children:[l.type==="dropdown"&&l.items.length?m?ie(Pe,{anchorElem:o,editor:r,group:l,Icon:m,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:l.maxActiveItems??1,onActiveChange:T}):ie(Pe,{anchorElem:o,editor:r,group:l,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:l.maxActiveItems??1,onActiveChange:T}):null,l.type==="buttons"&&l.items.length?l.items.map(k=>ie(P0,{anchorElem:o,editor:r,item:k},k.key)):null,i<n.features.toolbarFixed?.groups.length-1&&ie("div",{className:"divider"})]},l.key),e[13]=m,e[14]=o,e[15]=a,e[16]=r,e[17]=n.features.toolbarFixed?.groups.length,e[18]=l,e[19]=i,e[20]=T,e[21]=E,e[22]=C):C=e[22],C}function H0({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let l=_e.useRef(null),{y:i}=A0(),s=$0(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let c=n.editorContainerRef.current.previousElementSibling;for(;c;){if(c.classList.contains("fixed-toolbar"))return c;c=c.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return O0(()=>{if(!s)return;let u=l.current;if(!u)return;let c=u.getBoundingClientRect(),d=s.getBoundingClientRect();if(!(c.bottom<d.top||c.top>d.bottom))u.classList.remove("fixed-toolbar"),u.classList.add("fixed-toolbar","fixed-toolbar--overlapping"),s.classList.remove("fixed-toolbar"),s.classList.add("fixed-toolbar","fixed-toolbar--hide");else{if(!u.classList.contains("fixed-toolbar--overlapping"))return;u.classList.remove("fixed-toolbar--overlapping"),u.classList.add("fixed-toolbar"),s.classList.remove("fixed-toolbar--hide"),s.classList.add("fixed-toolbar")}},50,[l,s,i]),ie("div",{className:"fixed-toolbar",onFocus:u=>{u.stopPropagation()},ref:l,children:o.isEditable()&&ie(_e.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((u,c)=>ie(B0,{anchorElem:t,editor:o,editorConfig:r,group:u,index:c},u.key))})})}var gs=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return gs(t.parentEditor)}return!1},xs=t=>{let e=hs(6),{clientProps:o}=t,[r]=D0(),n=H(),{editorConfig:l}=n,i=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,s=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||l,u,c;if(e[0]!==o.disableIfParentHasFixedToolbar||e[1]!==i||e[2]!==s||e[3]!==n){c=Symbol.for("react.early_return_sentinel");e:{let d=gs(n);if(o?.disableIfParentHasFixedToolbar&&d){c=null;break e}if(!s?.features?.toolbarFixed?.groups?.length){c=null;break e}u=ie(H0,{anchorElem:document.body,editor:i,editorConfig:s,parentWithFixedToolbar:d})}e[0]=o.disableIfParentHasFixedToolbar,e[1]=i,e[2]=s,e[3]=n,e[4]=u,e[5]=c}else u=e[4],c=e[5];return c!==Symbol.for("react.early_return_sentinel")?c:u};var j0=v({plugins:[{Component:xs,position:"aboveContainer"}]});import{c as ks}from"react/compiler-runtime";import{jsx as ue,jsxs as _s}from"react/jsx-runtime";import{useLexicalComposerContext as U0}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Ts}from"@lexical/utils";import{$getSelection as ws,$isRangeSelection as Cs,$isTextNode as G0,COMMAND_PRIORITY_LOW as W0,getDOMSelection as Es,SELECTION_CHANGE_COMMAND as V0}from"lexical";import{useCallback as ao,useEffect as Lt,useRef as bs,useState as K0}from"react";import*as co from"react";import{createPortal as J0}from"react-dom";function gr(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 so(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:l=32,horizontalPosition:i="left",specialHandlingForCaret:s=!1,targetRect:u,verticalGap:c=10}=t,d=o.parentElement;if(u===null||d==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let a=n.getBoundingClientRect(),p=o.getBoundingClientRect(),m=d.getBoundingClientRect(),f=u.top-a.height-c,h=u.left-l;i==="center"&&(h=u.left+u.width/2-a.width/2);let x=0;return!e&&f<m.top&&!s&&(x=a.height+u.height+c*2,f+=x),i==="center"?h+a.width>m.right?h=m.right-a.width-l:h<m.left&&(h=m.left+l):h+a.width>m.right&&(h=m.right-a.width-l),h-=p.left,n.style.opacity="1",s&&r!==0?(f-=p.bottom-r+a.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=p.top,n.style.transform=`translate(${h}px, ${f}px)`),x}function X0({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&ue(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?ue(Nt,{editor:e,item:o,children:ue(o.ChildComponent,{})},o.key):null}function z0(t){let e=ks(19),{anchorElem:o,editor:r,group:n,index:l}=t,{editorConfig:i}=H(),[s,u]=co.useState(),c;e[0]!==n.ChildComponent||e[1]!==n.items||e[2]!==n.type?(c=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?u(()=>n.ChildComponent):u(void 0)},e[0]=n.ChildComponent,e[1]=n.items,e[2]=n.type,e[3]=c):c=e[3];let d;e[4]!==n?(d=[n],e[4]=n,e[5]=d):d=e[5],co.useEffect(c,d);let a;e[6]!==n.ChildComponent||e[7]!==n.items||e[8]!==n.type?(a=h=>{let{activeItems:x}=h;if(!x.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?u(()=>n.ChildComponent):u(void 0);return}let b=x[0];u(()=>b?.ChildComponent)},e[6]=n.ChildComponent,e[7]=n.items,e[8]=n.type,e[9]=a):a=e[9];let p=a,m=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;return e[10]!==s||e[11]!==o||e[12]!==r||e[13]!==i.features.toolbarInline?.groups.length||e[14]!==n||e[15]!==l||e[16]!==p||e[17]!==m?(f=_s("div",{className:m,"data-toolbar-group-key":n.key,children:[n.type==="dropdown"&&n.items.length?s?ue(Pe,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:n.maxActiveItems??1,onActiveChange:p}):ue(Pe,{anchorElem:o,editor:r,group:n,maxActiveItems:n.maxActiveItems??1,onActiveChange:p}):null,n.type==="buttons"&&n.items.length?n.items.map(h=>ue(X0,{anchorElem:o,editor:r,item:h},h.key)):null,l<i.features.toolbarInline?.groups.length-1&&ue("div",{className:"divider"})]},n.key),e[10]=s,e[11]=o,e[12]=r,e[13]=i.features.toolbarInline?.groups.length,e[14]=n,e[15]=l,e[16]=p,e[17]=m,e[18]=f):f=e[18],f}function Z0({anchorElem:t,editor:e}){let o=bs(null),r=bs(null),{editorConfig:n}=H(),l=ao(()=>{if(o?.current){let c=o.current.style.opacity==="0",d=o.current.style.pointerEvents==="none";c||(o.current.style.opacity="0"),d||(o.current.style.pointerEvents="none")}},[o]),i=ao(c=>{if(o?.current&&(c.buttons===1||c.buttons===3)){let d=o.current.style.opacity==="0",a=o.current.style.pointerEvents==="none";if(!d||!a){let p=c.clientX,m=c.clientY,f=document.elementFromPoint(p,m);o.current.contains(f)||l()}}},[l]),s=ao(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);Lt(()=>(document.addEventListener("mousemove",i),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)}),[o,i,s]);let u=ao(()=>{let c=ws(),d=Es(e._window);if(o.current===null)return;let a=t.querySelector(":scope > .link-editor"),p=a!==null&&"style"in a&&a?.style?.opacity==="1",m=e.getRootElement();if(c!==null&&d!==null&&!d.isCollapsed&&m!==null&&m.contains(d.anchorNode)){let f=gr(d,m),h=so({alwaysDisplayOnTop:p,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&so({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else l()},[e,l,t]);return Lt(()=>{let c=t.parentElement,d=()=>{e.getEditorState().read(()=>{u()})};return window.addEventListener("resize",d),c&&c.addEventListener("scroll",d),()=>{window.removeEventListener("resize",d),c&&c.removeEventListener("scroll",d)}},[e,u,t]),Lt(()=>(e.getEditorState().read(()=>{u()}),Ts(e.registerUpdateListener(({editorState:c})=>{c.read(()=>{u()})}),e.registerCommand(V0,()=>(u(),!1),W0))),[e,u]),_s("div",{className:"inline-toolbar-popup",ref:o,children:[ue("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((c,d)=>ue(z0,{anchorElem:t,editor:e,group:c,index:d},c.key))]})}function Y0(t,e){let o=ks(12),[r,n]=K0(!1),l;o[0]!==t?(l=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let p=ws(),m=Es(t._window),f=t.getRootElement();if(m!==null&&(!Cs(p)||f===null||!f.contains(m.anchorNode))){n(!1);return}if(!Cs(p))return;if(p.getTextContent()!==""){let x=p.getNodes(),b=!1;for(let T of x)if(G0(T)){n(!0),b=!0;break}b||n(!1)}else n(!1);let h=p.getTextContent().replace(/\n/g,"");if(!p.isCollapsed()&&h===""){n(!1);return}})},o[0]=t,o[1]=l):l=o[1];let i=l,s,u;o[2]!==i?(s=()=>(document.addEventListener("selectionchange",i),document.addEventListener("mouseup",i),()=>{document.removeEventListener("selectionchange",i),document.removeEventListener("mouseup",i)}),u=[i],o[2]=i,o[3]=s,o[4]=u):(s=o[3],u=o[4]),Lt(s,u);let c,d;if(o[5]!==t||o[6]!==i?(c=()=>Ts(t.registerUpdateListener(()=>{i()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),d=[t,i],o[5]=t,o[6]=i,o[7]=c,o[8]=d):(c=o[7],d=o[8]),Lt(c,d),!r||!t.isEditable())return null;let a;return o[9]!==e||o[10]!==t?(a=J0(ue(Z0,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=a):a=o[11],a}var Ss=t=>{let{anchorElem:e}=t,[o]=U0();return Y0(o,e)};var q0=v({plugins:[{Component:Ss,position:"floatingAnchorElem"}]});import{TableCellNode as Hh,TableNode as jh,TableRowNode as Uh}from"@lexical/table";import{jsx as Ns}from"react/jsx-runtime";import"react";var xr=()=>Ns("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Ns("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 Q0,$createTableNode as e1,$createTableRowNode as t1,$isTableCellNode as Ls,$isTableNode as Cr,$isTableRowNode as br,TableCellHeaderStates as uo,TableCellNode as o1,TableNode as r1,TableRowNode as n1}from"@lexical/table";import{$isParagraphNode as l1,$isTextNode as i1}from"lexical";var Is=/^\|(.+)\|\s?$/,s1=/^(\| ?:?-*:? ?)+\|\s?$/,Rs=({allTransformers:t})=>({type:"element",dependencies:[r1,n1,o1],export:e=>{if(!Cr(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!br(r))continue;let l=!1;for(let i of r.getChildren())Ls(i)&&(n.push(Ur(t,i).replace(/\n/g,"\\n").trim()),i.__headerState===uo.ROW&&(l=!0));o.push(`| ${n.join(" | ")} |`),l&&o.push(`| ${n.map(i=>"---").join(" | ")} |`)}return o.join(`
39
39
  `)},regExp:Is,replace:(e,o,r)=>{let n=r[0];if(!n)return;if(s1.test(n)){let a=e.getPreviousSibling();if(!a||!Cr(a))return;let p=a.getChildren(),m=p[p.length-1];if(!m||!br(m))return;m.getChildren().forEach(f=>{Ls(f)&&f.setHeaderStyles(uo.ROW,uo.ROW)}),e.remove();return}let l=ys(n,t);if(l==null)return;let i=[l],s=e.getPreviousSibling(),u=l.length;for(;s&&!(!l1(s)||s.getChildrenSize()!==1);){let a=s.getFirstChild();if(!i1(a))break;let p=ys(a.getTextContent(),t);if(p==null)break;u=Math.max(u,p.length),i.unshift(p);let m=s.getPreviousSibling();s.remove(),s=m}let c=e1();for(let a of i){let p=t1();c.append(p);for(let m=0;m<u;m++)p.append(m<a.length?a[m]:vs("",t))}let d=e.getPreviousSibling();Cr(d)&&a1(d)===u?(d.append(...c.getChildren()),e.remove()):e.replace(c),c.selectEnd()}});function a1(t){let e=t.getFirstChild();return br(e)?e.getChildrenSize():0}var vs=(t,e)=>{t=t.replace(/\\n/g,`
40
- `);let o=Q0(uo.NO_STATUS);return jr(t,e,o),o},ys=(t,e)=>{let o=t.match(Is);return!o||!o[1]?null:o[1].split("|").map(r=>vs(r,e))};import{c as u1}from"react/compiler-runtime";import{jsx as P,jsxs as Te}from"react/jsx-runtime";import{useLexicalComposerContext as Fs}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as d1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Ds,$deleteTableColumnAtSelection as m1,$deleteTableRowAtSelection as p1,$getNodeTriplet as f1,$getTableCellNodeFromLexicalNode as As,$getTableColumnIndexFromTableCellNode as h1,$getTableNodeFromLexicalNodeOrThrow as Ie,$getTableRowIndexFromTableCellNode as g1,$insertTableColumnAtSelection as x1,$insertTableRowAtSelection as C1,$isTableCellNode as $s,$isTableSelection as yt,$mergeCells as b1,$unmergeCell as k1,getTableElement as _r,getTableObserverFromTableElement as Tr,TableCellHeaderStates as ye,TableCellNode as _1}from"@lexical/table";import{mergeRegister as T1}from"@lexical/utils";import{useScrollInfo as w1}from"@payloadcms/ui";import{$getSelection as po,$isElementNode as E1,$isRangeSelection as wr,$isTextNode as S1,$setSelection as N1,COMMAND_PRIORITY_CRITICAL as L1,getDOMSelection as y1,isDOMNode as I1,SELECTION_CHANGE_COMMAND as R1}from"lexical";import*as Er from"react";import{useCallback as se,useEffect as Qe,useRef as mo,useState as et}from"react";import{createPortal as Ps}from"react-dom";import{jsx as kr,jsxs as c1}from"react/jsx-runtime";import"react";var Ms=()=>c1("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[kr("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"}),kr("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"}),kr("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 Os(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function v1(){let t=po();if(wr(t)&&!t.isCollapsed()||yt(t)&&!t.anchor.is(t.focus)||!wr(t)&&!yt(t))return!1;let[e]=f1(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function M1(t){let e=t.getLastDescendant();S1(e)?e.select():E1(e)?e.selectEnd():e!==null&&e.selectNext()}function D1({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[l]=Fs(),i=mo(null),[s,u]=et(n),[c,d]=et({columns:1,rows:1}),[a,p]=et(!1),[m,f]=et(!1),{y:h}=w1();Qe(()=>l.registerMutationListener(_1,_=>{_.get(s.getKey())==="updated"&&l.getEditorState().read(()=>{u(s.getLatest())})},{skipInitialization:!0}),[l,s]),Qe(()=>{l.getEditorState().read(()=>{let _=po();if(yt(_)){let N=Os(_);d(Os(_)),p(N.columns>1||N.rows>1)}f(v1())})},[l]),Qe(()=>{let _=e.current,N=i.current,M=l.getRootElement();if(_!=null&&N!=null&&M!=null){let I=M.getBoundingClientRect(),A=_.getBoundingClientRect();N.style.opacity="1";let y=N.getBoundingClientRect(),$=5,G=A.right+$;if(G+y.width>window.innerWidth||G+y.width>I.right){let te=A.left-y.width-$;G=(te<0?$:te)+window.pageXOffset}N.style.left=`${G+window.pageXOffset}px`;let q=A.top;if(q+y.height>window.innerHeight){let te=A.bottom-y.height;q=te<0?$:te}N.style.top=`${q}px`}},[e,i,l,h]),Qe(()=>{function _(N){i.current!=null&&e.current!=null&&I1(N.target)&&!i.current.contains(N.target)&&!e.current.contains(N.target)&&r(!1)}return window.addEventListener("click",_),()=>window.removeEventListener("click",_)},[r,e]);let x=se(()=>{l.update(()=>{if(s.isAttached()){let _=Ie(s),N=_r(_,l.getElementByKey(_.getKey()));if(N===null)throw new Error("Expected to find tableElement in DOM");let M=Tr(N);M!==null&&M.$clearHighlight(),_.markDirty(),u(s.getLatest())}N1(null)})},[l,s]),b=()=>{l.update(()=>{let _=po();if(!yt(_))return;let M=_.getNodes().filter($s),I=b1(M);I&&(M1(I),o())})},T=()=>{l.update(()=>{k1()})},E=se(_=>{l.update(()=>{for(let N=0;N<c.rows;N++)C1(_);o()})},[l,o,c.rows]),C=se(_=>{l.update(()=>{for(let N=0;N<c.columns;N++)x1(_);o()})},[l,o,c.columns]),k=se(()=>{l.update(()=>{p1(),o()})},[l,o]),g=se(()=>{l.update(()=>{Ie(s).remove(),x(),o()})},[l,s,x,o]),w=se(()=>{l.update(()=>{m1(),o()})},[l,o]),L=se(()=>{l.update(()=>{let _=Ie(s),N=g1(s),[M]=Ds(_,null,null),I=new Set,A=s.getHeaderStyles()^ye.ROW;if(M[N])for(let y=0;y<M[N].length;y++){let $=M[N][y];$?.cell&&(I.has($.cell)||(I.add($.cell),$.cell.setHeaderStyles(A,ye.ROW)))}x(),o()})},[l,s,x,o]),D=se(()=>{l.update(()=>{let _=Ie(s),N=h1(s),[M]=Ds(_,null,null),I=new Set,A=s.getHeaderStyles()^ye.COLUMN;if(M)for(let y=0;y<M.length;y++){let $=M?.[y]?.[N];$?.cell&&(I.has($.cell)||(I.add($.cell),$.cell.setHeaderStyles(A,ye.COLUMN)))}x(),o()})},[l,s,x,o]),F=se(()=>{l.update(()=>{if(s.isAttached()){let _=Ie(s);_&&_.setRowStriping(!_.getRowStriping())}x(),o()})},[l,s,x,o]),R=se(()=>{l.update(()=>{if(s.isAttached()){let _=Ie(s);_&&_.setFrozenColumns(_.getFrozenColumns()===0?1:0)}x(),o()})},[l,s,x,o]),S=null;return t&&(a?S=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>b(),type:"button",children:P("span",{className:"text",children:"Merge cells"})}):m&&(S=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>T(),type:"button",children:P("span",{className:"text",children:"Unmerge cells"})}))),Ps(Te("div",{className:"table-action-menu-dropdown",onClick:_=>{_.stopPropagation()},ref:i,children:[S?Te(Er.Fragment,{children:[S,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>F(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>R(),type:"button",children:P("span",{className:"text",children:"Toggle First Column Freeze"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>E(!1),type:"button",children:Te("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>E(!0),type:"button",children:Te("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>C(!1),type:"button",children:Te("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>C(!0),type:"button",children:Te("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>w(),type:"button",children:P("span",{className:"text",children:"Delete column"})}),P("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>k(),type:"button",children:P("span",{className:"text",children:"Delete row"})}),P("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-row-header",onClick:()=>L(),type:"button",children:Te("span",{className:"text",children:[(s.__headerState&ye.ROW)===ye.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:Te("span",{className:"text",children:[(s.__headerState&ye.COLUMN)===ye.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function A1({anchorElem:t,cellMerge:e}){let[o]=Fs(),r=mo(null),n=mo(null),[l,i]=et(!1),[s,u]=et(null),c=se(()=>{let a=r.current,p=po(),m=y1(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),u(null)}if(p==null||a==null)return h();let x=o.getRootElement(),b=null,T=null;if(wr(p)&&x!==null&&m!==null&&x.contains(m.anchorNode)){let C=As(p.anchor.getNode());if(C==null||(T=o.getElementByKey(C.getKey()),T==null||!C.isAttached()))return h();let k=Ie(C),g=_r(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=Tr(g),u(C)}else if(yt(p)){let C=As(p.anchor.getNode());if(!$s(C))throw new Error("TableSelection anchorNode must be a TableCellNode");let k=Ie(C),g=_r(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=Tr(g),T=o.getElementByKey(C.getKey())}else if(!f)return h();if(b===null||T===null)return h();let E=!b||!b.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",E),a.classList.toggle("table-cell-action-button-container--inactive",!E),E){let C=T.getBoundingClientRect(),k=t.getBoundingClientRect(),g=C.top-k.top,w=C.right-k.left;a.style.transform=`translate(${w}px, ${g}px)`}},[o,t]);Qe(()=>{let a,p=()=>{a=void 0,o.getEditorState().read(c)},m=()=>(a===void 0&&(a=setTimeout(p,0)),!1);return T1(o.registerUpdateListener(m),o.registerCommand(R1,m,L1),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",m),f&&(f.addEventListener("pointerup",m),m())}),()=>clearTimeout(a))});let d=mo(s);return Qe(()=>{d.current!==s&&i(!1),d.current=s},[d,s]),P("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Te(Er.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),i(!l)},ref:n,type:"button",children:P(Ms,{})}),l&&P(D1,{cellMerge:e,contextRef:n,onClose:()=>i(!1),setIsMenuOpen:i,tableCellNode:s})]})})}var Bs=t=>{let e=u1(3),{anchorElem:o}=t,r=d1(),n;return e[0]!==o||e[1]!==r?(n=Ps(r?P(A1,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as O1}from"react/compiler-runtime";import{jsx as ho,jsxs as F1}from"react/jsx-runtime";import{useLexicalComposerContext as $1}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as P1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as B1,$getTableNodeFromLexicalNodeOrThrow as Sr,$getTableRowIndexFromTableCellNode as H1,$isTableCellNode as Hs,$isTableRowNode as j1,getDOMCellFromTarget as U1,getTableElement as G1,TableNode as js}from"@lexical/table";import{calculateZoomLevel as Us,mergeRegister as W1}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Nr,isHTMLElement as V1,SKIP_SCROLL_INTO_VIEW_TAG as Gs}from"lexical";import*as Vs from"react";import{useCallback as It,useEffect as Lr,useRef as fo,useState as tt}from"react";import{createPortal as K1}from"react-dom";var J1=33,Ws=92;function X1({editor:t}){let e=fo(null),o=fo(null),r=fo(null),[n,l]=tt(!1),i=H(),s=fo(null),[u,c]=tt(null),[d,a]=tt(null),[p,m]=tt(!1),[f,h]=tt(null),x=It(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),b=R=>(R.buttons&1)===1;Lr(()=>{let R=new Set;return W1(t.registerMutationListener(js,S=>{for(let[_,N]of S)N==="destroyed"?R.delete(_):R.add(_);l(R.size>0)}),t.registerNodeTransform(js,S=>{if(S.getColWidths())return S;let _=S.getColumnCount(),N=Ws;return S.setColWidths(Array(_).fill(N)),S}))},[t]),Lr(()=>{if(!n)return;let R=M=>{let I=M.target;if(V1(I)){if(f){c({x:M.clientX,y:M.clientY});return}if(m(b(M)),!(o.current&&o.current.contains(I))&&e.current!==I){e.current=I;let A=U1(I);A&&d!==A?t.getEditorState().read(()=>{let y=Nr(A.elem);if(!y)throw new Error("TableCellResizer: Table cell node not found.");let $=Sr(y),G=G1($,t.getElementByKey($.getKey()));if(!G)throw new Error("TableCellResizer: Table element not found.");e.current=I,r.current=G.getBoundingClientRect(),a(A)},{editor:t}):A==null&&x()}}},S=M=>{m(!0)},_=M=>{m(!1)},N=t.registerRootListener((M,I)=>{I?.removeEventListener("mousemove",R),I?.removeEventListener("mousedown",S),I?.removeEventListener("mouseup",_),M?.addEventListener("mousemove",R),M?.addEventListener("mousedown",S),M?.addEventListener("mouseup",_)});return()=>{N()}},[d,f,t,n,x]);let T=R=>R==="bottom",E=It(R=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Nr(d.elem);if(!Hs(S))throw new Error("TableCellResizer: Table cell node not found.");let _=Sr(S),N=H1(S),M=_.getChildren(),A=S.getColSpan()===_.getColumnCount()?N:N+S.getRowSpan()-1;if(A>=M.length||A<0)throw new Error("Expected table cell to be inside of table row.");let y=M[A];if(!j1(y))throw new Error("Expected table row");let $=y.getHeight();if($===void 0){let q=y.getChildren();$=Math.min(...q.map(te=>C(te,t)??1/0))}let G=Math.max($+R,J1);y.setHeight(G)},{tag:Gs})},[d,t]),C=(R,S)=>S.getElementByKey(R.getKey())?.clientHeight,k=(R,S)=>{let _;return S.forEach(N=>{N.forEach((M,I)=>{M.cell===R&&(_=I)})}),_},g=It(R=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Nr(d.elem);if(!Hs(S))throw new Error("TableCellResizer: Table cell node not found.");let _=Sr(S),[N]=B1(_,null,null),M=k(S,N);if(M===void 0)throw new Error("TableCellResizer: Table column not found.");let I=_.getColWidths();if(!I)return;let A=I[M];if(A===void 0)return;let y=[...I],$=Math.max(A+R,Ws);y[M]=$,_.setColWidths(y)},{tag:Gs})},[d,t]),w=It(R=>{let S=_=>{if(_.preventDefault(),_.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:N,y:M}=s.current;if(d===null)return;let I=Us(_.target);if(T(R)){let A=(_.clientY-M)/I;E(A)}else{let A=(_.clientX-N)/I;g(A)}x(),document.removeEventListener("mouseup",S)}};return S},[d,x,g,E]),L=It(R=>S=>{if(S.preventDefault(),S.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");s.current={x:S.clientX,y:S.clientY},c(s.current),h(R),document.addEventListener("mouseup",w(R))},[d,w]),[D,F]=tt({bottom:null,left:null,right:null,top:null});return Lr(()=>{if(d){let{height:R,left:S,top:_,width:N}=d.elem.getBoundingClientRect(),M=Us(d.elem),I=10,A={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${I}px`,left:`${window.scrollX+S}px`,top:`${window.scrollY+_+R-I/2}px`,width:`${N}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${R}px`,left:`${window.scrollX+S+N-I/2}px`,top:`${window.scrollY+_}px`,width:`${I}px`}},y=r.current;f&&u&&y&&(T(f)?(A[f].left=`${window.scrollX+y.left}px`,A[f].top=`${window.scrollY+u.y/M}px`,A[f].height="3px",A[f].width=`${y.width}px`):(A[f].top=`${window.scrollY+y.top}px`,A[f].left=`${window.scrollX+u.x/M}px`,A[f].width="3px",A[f].height=`${y.height}px`),A[f].backgroundColor="#adf"),F(A)}else F({bottom:null,left:null,right:null,top:null})},[d,f,u]),ho("div",{ref:o,children:d!=null&&!p&&F1(Vs.Fragment,{children:[ho("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:L("right"),style:D.right||void 0}),ho("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:L("bottom"),style:D.bottom||void 0})]})})}var Ks=()=>{let t=O1(3),[e]=$1(),o=P1(),r;return t[0]!==e||t[1]!==o?(r=o?K1(ho(X1,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],r};import{c as oh}from"react/compiler-runtime";import{jsx as yr,jsxs as rh,Fragment as nh}from"react/jsx-runtime";import{useLexicalComposerContext as ea}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as lh,$getTableColumnIndexFromTableCellNode as ih,$getTableRowIndexFromTableCellNode as sh,$insertTableColumnAtSelection as ah,$insertTableRowAtSelection as ch,$isTableCellNode as uh,$isTableNode as zs,getTableElement as dh,TableNode as mh}from"@lexical/table";import{$findMatchingParent as ph,mergeRegister as fh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Zs,isHTMLElement as hh}from"lexical";import{useEffect as Ys,useMemo as gh,useRef as qs,useState as go}from"react";import"react";import{createPortal as xh}from"react-dom";import{c as Q1}from"react/compiler-runtime";import{useEffect as eh,useRef as th}from"react";var z1="Expected a function",Z1=Math.max,Y1=Math.min;function q1(t,e,o){let r,n,l=0,i,s=!1,u=!1,c,d,a,p=!0;if(typeof t!="function")throw new TypeError(z1);e=e||0,typeof o=="object"&&(s=!!o.leading,u="maxWait"in o,c=u?Z1(o.maxWait||0,e):c,p="trailing"in o?!!o.trailing:p);function m(g){let w=r,L=i;return r=i=void 0,l=g,d=t.apply(L,w),d}function f(g){return l=g,a=setTimeout(b,e),s?m(g):d}function h(g){let w=g-n,L=g-l,D=e-w;return u?Y1(D,c-L):D}function x(g){let w=g-n,L=g-l;return n===void 0||w>=e||w<0||u&&L>=c}function b(){let g=Date.now();if(x(g))return T(g);a=setTimeout(b,h(g))}function T(g){return a=void 0,p&&r?m(g):(r=i=void 0,d)}function E(){a!==void 0&&clearTimeout(a),l=0,r=n=i=a=void 0}function C(){return a===void 0?d:T(Date.now())}function k(){let g=Date.now(),w=x(g);if(r=arguments,i=this,n=g,w){if(a===void 0)return f(n);if(u)return clearTimeout(a),a=setTimeout(b,e),m(n)}return a===void 0&&(a=setTimeout(b,e)),d}return k.cancel=E,k.flush=C,k}var Js=q1;function Xs(t,e,o){let r=Q1(6),n=th(null),l,i;r[0]!==t||r[1]!==o||r[2]!==e?(l=()=>(n.current=Js(t,e,{maxWait:o}),()=>{n.current?.cancel()}),i=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=l,r[4]=i):(l=r[3],i=r[4]),eh(l,i);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let d=c;n.current&&n.current(...d)},r[5]=s):s=r[5],s}var Qs=20;function Ch({anchorElem:t}){let[e]=ea(),o=H(),[r,n]=go(!1),[l,i]=go(!1),[s,u]=go(!1),[c,d]=go({}),a=qs(new Set),p=qs(null),m=Xs(x=>{let{isOutside:b,tableDOMNode:T}=bh(x,o.editorConfig?.lexical);if(b){n(!1),i(!1);return}if(!T)return;p.current=T;let E=null,C=null,k=null;if(e.getEditorState().read(()=>{let I=Zs(T);if(uh(I)){let A=ph(I,y=>zs(y));if(!zs(A))return;if(k=dh(A,e.getElementByKey(A.getKey())),k){let y=A.getChildrenSize(),$=A.getChildAtIndex(0)?.getChildrenSize(),G=sh(I),q=ih(I);G===y-1?E=I:q===$-1&&(C=I)}}},{editor:e}),!k)return;let g=k.parentElement;if(!g)return;let{bottom:w,height:L,left:D,right:F,width:R,y:S}=k.getBoundingClientRect(),_=!1;g&&g.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(_=g.scrollWidth>g.clientWidth);let{left:N,y:M}=t.getBoundingClientRect();E?(i(!1),n(!0),d({height:Qs,left:_&&g?g.offsetLeft:D-N,top:w-M+5,width:_&&g?g.offsetWidth:R})):C&&(i(!0),n(!1),d({height:L,left:F-N+5,top:S-M,width:Qs}))},50,250),f=gh(()=>new ResizeObserver(()=>{n(!1),i(!1)}),[]);Ys(()=>{if(s)return document.addEventListener("mousemove",m),()=>{n(!1),i(!1),document.removeEventListener("mousemove",m)}},[s,m]),Ys(()=>fh(e.registerMutationListener(mh,x=>{e.getEditorState().read(()=>{let b=!1;for(let[T,E]of x)switch(E){case"created":{a.current.add(T),b=!0;break}case"destroyed":{a.current.delete(T),b=!0;break}default:break}if(b){f.disconnect();for(let T of a.current){let{tableElement:E}=lh(T);f.observe(E)}u(a.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=x=>{e.update(()=>{p.current&&(Zs(p.current)?.selectEnd(),x?(ch(),n(!1)):(ah(),i(!1)))})};return e?.isEditable()?rh(nh,{children:[r&&yr("button",{"aria-label":"Add Row",className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...c},type:"button"}),l&&yr("button",{"aria-label":"Add Column",className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...c},type:"button"})]}):null}function bh(t,e){let o=t.target;if(hh(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function ta(t){let e=oh(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=ea();if(!n?.isEditable())return null;let l;return e[0]!==r?(l=xh(yr(Ch,{anchorElem:r}),r),e[0]=r,e[1]=l):l=e[1],l}import{c as kh}from"react/compiler-runtime";import{jsx as Ir,jsxs as _h}from"react/jsx-runtime";import{useLexicalComposerContext as Th}from"@lexical/react/LexicalComposerContext";import{TablePlugin as wh}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Eh,TableCellNode as Sh,TableNode as Nh,TableRowNode as Lh}from"@lexical/table";import{mergeRegister as yh}from"@lexical/utils";import{formatDrawerSlug as Ih,useEditDepth as Rh}from"@payloadcms/ui";import{$getSelection as vh,$isRangeSelection as Mh,COMMAND_PRIORITY_EDITOR as Dh,createCommand as Ah}from"lexical";import{createContext as Oh,use as Fh,useEffect as $h,useMemo as Ph,useState as Bh}from"react";import*as oa from"react";var xo=Ah("OPEN_EMBED_DRAWER_COMMAND"),ra=Oh({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function na({children:t}){let[e,o]=Bh({cellEditorConfig:null,cellEditorPlugins:null});return Ir(ra,{value:Ph(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var la=()=>{let t=kh(16),[e]=Th(),o=Fh(ra),r=Rh(),{fieldProps:n,uuid:l}=H(),{schemaPath:i}=n,s="lexical-table-create-"+l,u;t[0]!==r||t[1]!==s?(u=Ih({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=me(c,!0),a;t[3]!==e||t[4]!==d?(a=()=>{if(!e.hasNodes([Nh,Lh,Sh]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return yh(e.registerCommand(xo,()=>{let h=null;return e.getEditorState().read(()=>{let x=vh();Mh(x)&&(h=x)}),h&&d(),!0},Dh))},t[3]=e,t[4]=d,t[5]=a):a=t[5];let p;t[6]!==o||t[7]!==e||t[8]!==d?(p=[o,e,d],t[6]=o,t[7]=e,t[8]=d,t[9]=p):p=t[9],$h(a,p);let m;t[10]!==e?(m=(h,x)=>{!x.columns||!x.rows||e.dispatchCommand(Eh,{columns:String(x.columns),rows:String(x.rows)})},t[10]=e,t[11]=m):m=t[11];let f;return t[12]!==c||t[13]!==i||t[14]!==m?(f=_h(oa.Fragment,{children:[Ir(nt,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:m,schemaPath:i,schemaPathSuffix:"fields"}),Ir(wh,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=i,t[14]=m,t[15]=f):f=t[15],f};var Gh=v({markdownTransformers:[Rs],nodes:[jh,Hh,Uh],plugins:[{Component:la,position:"normal"},{Component:Ks,position:"normal"},{Component:Bs,position:"floatingAnchorElem"},{Component:ta,position:"floatingAnchorElem"}],providers:[na],slashMenu:{groups:[Z([{Icon:xr,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(xo,{})}}])]},toolbarFixed:{groups:[he([{ChildComponent:xr,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(xo,{})}}])]}});import{$isNodeSelection as yg}from"lexical";import{jsx as Rr,jsxs as Wh}from"react/jsx-runtime";import"react";var vr=()=>Wh("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{jsx as ua}from"react/jsx-runtime";import da from"bson-objectid";import{$applyNodeReplacement as zh}from"lexical";import*as ma from"react";import Vh from"bson-objectid";function Co(t,e){if(t.hasAttribute("data-lexical-pending-upload-form-id")){let r=t.getAttribute("data-lexical-pending-upload-form-id");if(r!=null)return{node:e({data:{pending:{formID:r,src:t.getAttribute("src")||""}}})}}if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let r=t.getAttribute("data-lexical-upload-id"),n=t.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:e({data:{fields:{},relationTo:n,value:r}})}}return{node:e({data:{pending:{formID:new Vh.default().toHexString(),src:t.getAttribute("src")||""}}})}}import{DecoratorBlockNode as Kh}from"@lexical/react/LexicalDecoratorBlockNode.js";import sa from"bson-objectid";import{$applyNodeReplacement as Jh}from"lexical";var Rt=class extends Kh{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:o=>Co(o,ia),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new sa.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=ia({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return null}exportDOM(){let e=document.createElement("img"),o=this.__data;return o.pending?(e.setAttribute("data-lexical-pending-upload-form-id",String(o?.pending?.formID)),e.setAttribute("src",o?.pending?.src||"")):(e.setAttribute("data-lexical-upload-id",String(o?.value)),e.setAttribute("data-lexical-upload-relation-to",o?.relationTo)),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function ia({data:t}){return t?.id||(t.id=new sa.default().toHexString()),Jh(new Rt({data:t}))}import{jsx as aa}from"react/jsx-runtime";import{ShimmerEffect as Xh}from"@payloadcms/ui";var ca=()=>aa("div",{className:"lexical-upload",children:aa(Xh,{height:"95px",width:"203px"})});var Zh=ma.lazy(()=>import("./component-VDJI45F2.js").then(t=>({default:t.UploadComponent}))),ne=class extends Rt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:o=>Co(o,Re),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new da.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=Re({data:o});return r.setFormat(e.format),r}decorate(){return this.__data.pending?ua(ca,{}):ua(Zh,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Re({data:t}){return t?.id||(t.id=new da.default().toHexString()),zh(new ne({data:t}))}function ot(t){return t instanceof ne}import{c as ng}from"react/compiler-runtime";import{jsx as lg}from"react/jsx-runtime";import{useLexicalComposerContext as ig}from"@lexical/react/LexicalComposerContext.js";import{$dfsIterator as wa,$insertNodeToNearestRoot as Ar,mergeRegister as sg}from"@lexical/utils";import{useBulkUpload as ag,useConfig as cg,useEffectEvent as ug,useModal as dg}from"@payloadcms/ui";import Or from"bson-objectid";import{$createRangeSelection as mg,$getPreviousSelection as Ca,$getSelection as ba,$isParagraphNode as Fr,$isRangeSelection as ka,$setSelection as pg,COMMAND_PRIORITY_EDITOR as fg,COMMAND_PRIORITY_LOW as _a,createCommand as hg,DROP_COMMAND as gg,getDOMSelectionFromTarget as xg,isHTMLElement as Ta,PASTE_COMMAND as Cg}from"lexical";import{useEffect as bg}from"react";import{c as pa}from"react/compiler-runtime";import{jsx as Mr}from"react/jsx-runtime";import{useLexicalComposerContext as fa}from"@lexical/react/LexicalComposerContext.js";import{toast as Yh}from"@payloadcms/ui";import{$getNodeByKey as qh,COMMAND_PRIORITY_EDITOR as ha}from"lexical";import{useEffect as ga,useState as Qh}from"react";var eg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=qh(o);n&&n.replace(Re({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Dr,{fields:null,relationTo:e,value:r})},tg=t=>{let e=pa(13),{enabledCollectionSlugs:o}=t,[r]=fa(),[n,l]=Qh(null),i;e[0]!==o?(i={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=i):i=e[1];let{closeListDrawer:s,ListDrawer:u,openListDrawer:c}=St(i),d,a;e[2]!==r||e[3]!==c?(d=()=>r.registerCommand(Ue,h=>(l(h?.replace?h?.replace.nodeKey:null),c(),!0),ha),a=[r,c],e[2]=r,e[3]=c,e[4]=d,e[5]=a):(d=e[4],a=e[5]),ga(d,a);let p;e[6]!==s||e[7]!==r||e[8]!==n?(p=h=>{let{collectionSlug:x,doc:b}=h;s(),eg({editor:r,relationTo:x,replaceNodeKey:n,value:b.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=p):p=e[9];let m=p,f;return e[10]!==u||e[11]!==m?(f=Mr(u,{onSelect:m}),e[10]=u,e[11]=m,e[12]=f):f=e[12],f},og=()=>{let t=pa(3),[e]=fa(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Ue,rg,ha),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ga(o,r),null},xa=t=>Mr(Ot,{...t,FallbackComponent:og,uploads:!0,children:Mr(tg,{...t})});function rg(){return Yh.error("No upload collections enabled"),!0}function kg(t){let e=t.target;return!!(Ta(e)&&!e.closest("code, span.editor-image")&&Ta(e.parentElement)&&e.parentElement.closest("div.ContentEditable__root"))}function _g(t){let e,o=xg(t.target);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&o!==null)o.collapse(t.rangeParent,t.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var Dr=hg("INSERT_UPLOAD_COMMAND"),Ea=()=>{let t=ng(18),[e]=ig(),{config:o}=cg(),{collections:r}=o,{drawerSlug:n,setCollectionSlug:l,setInitialForms:i,setOnCancel:s,setOnSuccess:u,setSelectableCollections:c}=ag(),{isModalOpen:d,openModal:a}=dg(),p;t[0]!==n||t[1]!==r||t[2]!==e||t[3]!==d||t[4]!==a||t[5]!==l||t[6]!==i||t[7]!==s||t[8]!==u||t[9]!==c?(p=b=>{let{files:T}=b;if(T?.length!==0&&(i(E=>[...E??[],...T.map(Tg)]),!d(n))){let E=r.filter(wg).map(Eg);if(!E.length||!E[0])return;l(E[0]),c(E),s(()=>{e.update(Sg)}),u(C=>{let k=new Map(C.map(Ng));e.update(()=>{for(let g of wa()){let w=g.node;if(ot(w)){let L=w.getData();if(L?.pending){let D=k.get(L.pending?.formID);D&&w.replace(Re({data:{id:new Or.default().toHexString(),fields:{},relationTo:D.collectionSlug,value:D.doc.id}}))}}}})}),a(n)}},t[0]=n,t[1]=r,t[2]=e,t[3]=d,t[4]=a,t[5]=l,t[6]=i,t[7]=s,t[8]=u,t[9]=c,t[10]=p):p=t[10];let m=ug(p),f;t[11]!==e||t[12]!==m?(f=()=>{if(!e.hasNodes([ne]))throw new Error("UploadPlugin: UploadNode not registered on editor");return sg(e.registerNodeTransform(ne,b=>{let T=b.getData();if(!T?.pending)return;(async function(){let k=null,g=T?.pending?.src,w=T?.pending?.formID;if(g?.startsWith("data:")){let L=g.match(/data:(image\/[a-zA-Z]+);base64,/),D=L?L[1]:"image/png",F=g.replace(/^data:image\/[a-zA-Z]+;base64,/,""),R=atob(F),S=new Array(R.length);for(let M=0;M<R.length;M++)S[M]=R.charCodeAt(M);let _=new Uint8Array(S);k={alt:void 0,file:new File([_],"pasted-image."+D?.split("/")[1],{type:D}),formID:w}}else if(g?.startsWith("http")||g?.startsWith("https")){let D=await(await fetch(g)).blob(),F=g.split("/").pop()||"pasted-image"+D.type.split("/")[1];k={alt:void 0,file:new File([D],F,{type:D.type}),formID:w}}k&&m({files:[k]})})()}),e.registerCommand(Dr,b=>(e.update(()=>{let T=ba()||Ca();if(ka(T)){let E=Re({data:{id:b.id,fields:b.fields,relationTo:b.relationTo,value:b.value}}),{focus:C}=T,k=C.getNode();Ar(E),Fr(k)&&!k.__first&&k.remove()}}),!0),fg),e.registerCommand(Cg,b=>{if(!(b instanceof ClipboardEvent))return!1;let T=b.clipboardData;if(!T?.types?.length||T?.types?.includes("text/html"))return!1;let E=[];return T?.files?.length&&Array.from(T.files).forEach(C=>{E.push({alt:"",file:C,formID:new Or.default().toHexString()})}),E.length?(e.update(()=>{let C=ba()||Ca();if(ka(C))for(let k of E){let g=new ne({data:{pending:{formID:k.formID,src:URL.createObjectURL(k.file)}}}),{focus:w}=C,L=w.getNode();Ar(g),Fr(L)&&!L.__first&&L.remove()}}),m({files:E}),!0):!1},_a),e.registerCommand(gg,b=>{if(!(b instanceof DragEvent))return!1;let T=b.dataTransfer;if(!T?.types?.length)return!1;let E=[];return T?.files?.length&&Array.from(T.files).forEach(C=>{E.push({alt:"",file:C,formID:new Or.default().toHexString()})}),E.length?(b.preventDefault(),b.stopPropagation(),e.update(()=>{if(kg(b)){let C=_g(b),k=mg();C!=null&&k.applyDOMRange(C),pg(k);for(let g of E){let w=new ne({data:{pending:{formID:g.formID,src:URL.createObjectURL(g.file)}}}),{focus:L}=k,D=L.getNode();Ar(w),Fr(D)&&!D.__first&&D.remove()}}}),m({files:E}),!0):!1},_a))},t[11]=e,t[12]=m,t[13]=f):f=t[13];let h;t[14]!==e?(h=[e],t[14]=e,t[15]=h):h=t[15],bg(f,h);let x;return t[16]!==r?(x=lg(xa,{enabledCollectionSlugs:r.map(Lg)}),t[16]=r,t[17]=x):x=t[17],x};function Tg(t){return{file:t.file,formID:t.formID}}function wg(t){let{upload:e}=t;return!!e}function Eg(t){let{slug:e}=t;return e}function Sg(){for(let t of wa()){let e=t.node;ot(e)&&e.getData()?.pending&&e.remove()}}function Ng(t){return[t.formID,t]}function Lg(t){let{slug:e}=t;return e}var Ig=v({nodes:[ne],plugins:[{Component:Ea,position:"normal"}],slashMenu:{groups:[Z([{Icon:vr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ue,{replace:!1})}}])]},toolbarFixed:{groups:[he([{ChildComponent:vr,isActive:({selection:t})=>{if(!yg(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return ot(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ue,{replace:!1})}}])]}});import{c as vg}from"react/compiler-runtime";import{jsx as Pr}from"react/jsx-runtime";import{ShimmerEffect as Mg,useConfig as Dg}from"@payloadcms/ui";import{lazy as Ag,Suspense as Og,useEffect as Fg,useState as $g}from"react";var Sa={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",hrSelected:"LexicalEditorTheme__hrSelected",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",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var bo={namespace:"lexical",theme:Sa};function Na({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:l}){for(let c of l.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");l.features=l.features.sort((c,d)=>c.clientFeatureProps.order-d.clientFeatureProps.order);let i=new Map;for(let c of l.features)i.set(c.clientFeatureProps.featureKey,c);let s=new Map,u=0;for(let c of l.features){let d=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:i,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:l}):c.feature;d.key=c.clientFeatureProps.featureKey,d.order=u,s.set(c.clientFeatureProps.featureKey,d),u++}return s}import{deepMerge as Rg}from"payload/shared";var La=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,l)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+l,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let l=e.toolbarInline.groups.find(i=>i.key===n.key);l?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarInline?.groups.push(l)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let l=e.toolbarFixed.groups.find(i=>i.key===n.key);l?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarFixed?.groups.push(l)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let l=e.slashMenu.groups.find(i=>i.key===n.key);l?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.slashMenu.groups.push(l)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?Rg(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);return e};function $r(t,e,o){return{admin:o,features:La(t),lexical:e,resolvedFeatureMap:t}}var Pg=Ag(()=>import("./Field-D5RCNN4A.js").then(t=>({default:t.RichText}))),Bg=t=>{let e=vg(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:l,field:i,lexicalEditorConfig:s,schemaPath:u}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let d=c,a=s===void 0?bo:s,{config:p}=Dg(),[m,f]=$g(null),h,x;e[2]!==d||e[3]!==r||e[4]!==p||e[5]!==n||e[6]!==l||e[7]!==i||e[8]!==m||e[9]!==a||e[10]!==u?(h=()=>{if(m)return;let T=[];for(let[k,g]of Object.entries(r))g.clientFeatureProvider&&T.push(g.clientFeatureProvider(g.clientFeatureProps));let E=a||bo,C=Na({config:p,featureClientImportMap:n,featureClientSchemaMap:l,field:i,schemaPath:u??i.name,unSanitizedEditorConfig:{features:T,lexical:E}});f($r(C,E,d))},x=[a,d,m,r,n,l,i,p,u],e[2]=d,e[3]=r,e[4]=p,e[5]=n,e[6]=l,e[7]=i,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=x):(h=e[11],x=e[12]),Fg(h,x);let b;return e[13]!==m||e[14]!==t?(b=Pr(Og,{fallback:Pr(Mg,{height:"35vh"}),children:m&&Pr(Pg,{...t,editorConfig:m})}),e[13]=m,e[14]=t,e[15]=b):b=e[15],b};function Hg(t){return t instanceof HTMLElement}function jg(...t){return t.filter(Boolean).join(" ")}var ko=new WeakMap;function ya(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function _o(t,e){let o=ko.get(t);if(o===void 0){let r=new Set,n=i=>{o!==void 0&&(o.start=ya(i))},l=i=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let u=ya(i);for(let c of r)u!==null&&c([u[0]-s[0],u[1]-s[1]],i)};t.addEventListener("touchstart",n),t.addEventListener("touchend",l),o={handleTouchend:l,handleTouchstart:n,listeners:r,start:null},ko.set(t,o)}return o.listeners.add(e),()=>{Ug(t,e)}}function Ug(t,e){let o=ko.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(ko.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function Gg(t,e){return _o(t,(o,r)=>{let[n,l]=o;n<0&&-n>Math.abs(l)&&e(n,r)})}function Wg(t,e){return _o(t,(o,r)=>{let[n,l]=o;n>0&&n>Math.abs(l)&&e(n,r)})}function Vg(t,e){return _o(t,(o,r)=>{let[n,l]=o;l<0&&-l>Math.abs(n)&&e(n,r)})}function Kg(t,e){return _o(t,(o,r)=>{let[n,l]=o;l>0&&l>Math.abs(n)&&e(n,r)})}import{c as Jg}from"react/compiler-runtime";import{jsx as Xg}from"react/jsx-runtime";import"react";var zg=()=>{let t=Jg(2),{EditButton:e}=pe(),o;return t[0]!==e?(o=e?Xg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Zg}from"react/compiler-runtime";import{jsx as Yg}from"react/jsx-runtime";import"react";var qg=()=>{let t=Zg(2),{RemoveButton:e}=pe(),o;return t[0]!==e?(o=e?Yg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Qg}from"react/compiler-runtime";import{jsx as ex}from"react/jsx-runtime";import"react";var tx=()=>{let t=Qg(2),{Label:e}=pe(),o;return t[0]!==e?(o=e?ex(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as ox}from"react/compiler-runtime";import{jsx as rx}from"react/jsx-runtime";import"react";var nx=t=>{let e=ox(3),{children:o}=t,{InlineBlockContainer:r}=pe(),n;return e[0]!==r||e[1]!==o?(n=r?rx(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as lx}from"react/compiler-runtime";import{jsx as ix}from"react/jsx-runtime";import"react";var sx=t=>{let e=lx(6),{children:o,editButton:r,Label:n,removeButton:l}=t,{BlockCollapsible:i}=ve(),s;return e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==l?(s=i?ix(i,{editButton:r,Label:n,removeButton:l,children:o}):null,e[0]=i,e[1]=n,e[2]=o,e[3]=r,e[4]=l,e[5]=s):s=e[5],s};import{c as ax}from"react/compiler-runtime";import{jsx as cx}from"react/jsx-runtime";import"react";var ux=()=>{let t=ax(2),{EditButton:e}=ve(),o;return t[0]!==e?(o=e?cx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as dx}from"react/compiler-runtime";import{jsx as mx}from"react/jsx-runtime";import"react";var px=()=>{let t=dx(2),{RemoveButton:e}=ve(),o;return t[0]!==e?(o=e?mx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as fx}from"qs-esm";var hx=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:l,collectionSlug:i,select:s})=>{let u=fx({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${i}/${l}${u}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(d=>d.json())};import{c as gx}from"react/compiler-runtime";import{jsx as rt}from"react/jsx-runtime";import{FieldContext as xx,FieldPathContext as Ia,ServerFunctionsContext as Ra,ShimmerEffect as Cx,useServerFunctions as bx}from"@payloadcms/ui";import kx,{useEffect as _x,useRef as Tx}from"react";var wx=t=>{let e=gx(9),{field:o,initialValue:r,Loading:n,path:l,schemaPath:i,setValue:s,value:u}=t,[c,d]=kx.useState(null),a=bx(),{_internal_renderField:p}=a,[m,f]=i.split("."),h=l??(o&&"name"in o?o?.name:"")??"",x;e[0]!==p||e[1]!==o||e[2]!==r||e[3]!==l||e[4]!==i?(x=()=>{(async function(){let{Field:D}=await p({field:{...o||{},type:"richText",admin:{hidden:!1}},initialValue:r??void 0,path:l,schemaPath:i});d(D)})()},e[0]=p,e[1]=o,e[2]=r,e[3]=l,e[4]=i,e[5]=x):x=e[5];let b=x,T=Tx(!1),E,C;if(e[6]!==b?(E=()=>{T.current||(T.current=!0,b())},C=[b],e[6]=b,e[7]=E,e[8]=C):(E=e[7],C=e[8]),_x(E,C),!c)return typeof n<"u"?n:rt(Cx,{});let k={...a,getFormState:async w=>a.getFormState({...w,collectionSlug:m==="collection"?f:void 0,globalSlug:m==="global"?f:void 0})};if(typeof u>"u"&&!s)return rt(Ra,{value:{...k},children:rt(Ia,{value:h,children:c},h)});let g={disabled:!1,formInitializing:!1,formProcessing:!1,formSubmitted:!1,initialValue:u,path:h,setValue:s??Ex,showError:!1,value:u};return rt(Ra,{value:{...k},children:rt(Ia,{value:h,children:rt(xx,{value:g,children:c})},h)})};function Ex(){}function Sx({nodes:t,text:e}){let o={root:{type:"root",children:[],direction:"ltr",format:"",indent:0,version:1}};return e&&o.root.children.push({type:"paragraph",children:[{type:"text",detail:0,format:0,mode:"normal",style:"",text:e,version:1}],direction:"ltr",format:"",indent:0,textFormat:0,textStyle:"",version:1}),t?.length&&o.root.children.push(...t),o}export{ht as $createAutoLinkNode,Kt as $createBlockNode,Eo as $createInlineBlockNode,ge as $createLinkNode,$e as $createRelationshipNode,Re as $createUploadNode,Ce as $isAutoLinkNode,dt as $isBlockNode,So as $isInlineBlockNode,J as $isLinkNode,dr as $isRelationshipNode,ot as $isUploadNode,Ga as AlignFeatureClient,xe as AutoLinkNode,sx as BlockCollapsible,ux as BlockEditButton,fe as BlockNode,px as BlockRemoveButton,Xa as BlockquoteFeatureClient,Vc as BlocksFeatureClient,fu as BoldFeatureClient,re as CAN_USE_DOM,xp as ChecklistFeatureClient,af as DETAIL_TYPE_TO_DETAIL,rf as DOUBLE_LINE_BREAK,bf as DebugJsxConverterFeatureClient,uf as ELEMENT_FORMAT_TO_TYPE,cf as ELEMENT_TYPE_TO_FORMAT,Fa as ENABLE_SLASH_MENU_COMMAND,Ma as EditorConfigProvider,nt as FieldsDrawer,j0 as FixedToolbarFeatureClient,cd as HeadingFeatureClient,Ld as HorizontalRuleFeatureClient,Ge as INSERT_BLOCK_COMMAND,We as INSERT_INLINE_BLOCK_COMMAND,tf as IS_ALL_FORMATTING,Gd as IndentFeatureClient,nx as InlineBlockContainer,zg as InlineBlockEditButton,tx as InlineBlockLabel,wo as InlineBlockNode,qg as InlineBlockRemoveButton,bu as InlineCodeFeatureClient,q0 as InlineToolbarFeatureClient,wu as ItalicFeatureClient,lf as LTR_REGEX,Bp as LexicalPluginToLexicalFeatureClient,op as LinkFeatureClient,ee as LinkNode,of as NON_BREAKING_SPACE,O as NodeFormat,Sp as OrderedListFeatureClient,Jp as ParagraphFeatureClient,Aa as Point,nf as RTL_REGEX,$a as Rect,l0 as RelationshipFeatureClient,ke as RelationshipNode,wx as RenderLexical,Bg as RichTextField,Vp as SlateToLexicalFeatureClient,yu as StrikethroughFeatureClient,Mu as SubscriptFeatureClient,Fu as SuperscriptFeatureClient,df as TEXT_MODE_TO_TYPE,sf as TEXT_TYPE_TO_FORMAT,mf as TEXT_TYPE_TO_MODE,ce as TOGGLE_LINK_COMMAND,Gh as TableFeatureClient,lu as TestRecorderFeatureClient,qu as TextStateFeatureClient,Nt as ToolbarButton,Pe as ToolbarDropdown,uu as TreeViewFeatureClient,ju as UnderlineFeatureClient,Dp as UnorderedListFeatureClient,Ig as UploadFeatureClient,ne as UploadNode,Kg as addSwipeDownListener,Gg as addSwipeLeftListener,Wg as addSwipeRightListener,Vg as addSwipeUpListener,Sx as buildEditorState,Go as createBlockNode,v as createClientFeature,kf as defaultColors,bo as defaultEditorLexicalConfig,gr as getDOMRangeRect,Pa as getEnabledNodes,hx as getRestPopulateFn,Ve as getSelectedNode,Hg as isHTMLElement,Oa as isPoint,jg as joinClasses,$r as sanitizeClientEditorConfig,La as sanitizeClientFeatures,so as setFloatingElemPosition,to as setFloatingElemPositionForLinkEditor,Z as slashMenuBasicGroupWithItems,he as toolbarAddDropdownGroupWithItems,Vo as toolbarFeatureButtonsGroupWithItems,Y as toolbarFormatGroupWithItems,Q as toolbarTextDropdownGroupWithItems,ve as useBlockComponentContext,H as useEditorConfigContext,pe as useInlineBlockComponentContext,Da as useLexicalDocumentDrawer,me as useLexicalDrawer,St as useLexicalListDrawer};
40
+ `);let o=Q0(uo.NO_STATUS);return jr(t,e,o),o},ys=(t,e)=>{let o=t.match(Is);return!o||!o[1]?null:o[1].split("|").map(r=>vs(r,e))};import{c as u1}from"react/compiler-runtime";import{jsx as P,jsxs as Te}from"react/jsx-runtime";import{useLexicalComposerContext as Fs}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as d1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Ds,$deleteTableColumnAtSelection as m1,$deleteTableRowAtSelection as p1,$getNodeTriplet as f1,$getTableCellNodeFromLexicalNode as As,$getTableColumnIndexFromTableCellNode as h1,$getTableNodeFromLexicalNodeOrThrow as Ie,$getTableRowIndexFromTableCellNode as g1,$insertTableColumnAtSelection as x1,$insertTableRowAtSelection as C1,$isTableCellNode as $s,$isTableSelection as yt,$mergeCells as b1,$unmergeCell as k1,getTableElement as _r,getTableObserverFromTableElement as Tr,TableCellHeaderStates as ye,TableCellNode as _1}from"@lexical/table";import{mergeRegister as T1}from"@lexical/utils";import{useScrollInfo as w1}from"@payloadcms/ui";import{$getSelection as po,$isElementNode as E1,$isRangeSelection as wr,$isTextNode as S1,$setSelection as N1,COMMAND_PRIORITY_CRITICAL as L1,getDOMSelection as y1,isDOMNode as I1,SELECTION_CHANGE_COMMAND as R1}from"lexical";import*as Er from"react";import{useCallback as se,useEffect as Qe,useRef as mo,useState as et}from"react";import{createPortal as Ps}from"react-dom";import{jsx as kr,jsxs as c1}from"react/jsx-runtime";import"react";var Ms=()=>c1("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[kr("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"}),kr("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"}),kr("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 Os(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function v1(){let t=po();if(wr(t)&&!t.isCollapsed()||yt(t)&&!t.anchor.is(t.focus)||!wr(t)&&!yt(t))return!1;let[e]=f1(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function M1(t){let e=t.getLastDescendant();S1(e)?e.select():E1(e)?e.selectEnd():e!==null&&e.selectNext()}function D1({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[l]=Fs(),i=mo(null),[s,u]=et(n),[c,d]=et({columns:1,rows:1}),[a,p]=et(!1),[m,f]=et(!1),{y:h}=w1();Qe(()=>l.registerMutationListener(_1,_=>{_.get(s.getKey())==="updated"&&l.getEditorState().read(()=>{u(s.getLatest())})},{skipInitialization:!0}),[l,s]),Qe(()=>{l.getEditorState().read(()=>{let _=po();if(yt(_)){let N=Os(_);d(Os(_)),p(N.columns>1||N.rows>1)}f(v1())})},[l]),Qe(()=>{let _=e.current,N=i.current,M=l.getRootElement();if(_!=null&&N!=null&&M!=null){let I=M.getBoundingClientRect(),A=_.getBoundingClientRect();N.style.opacity="1";let y=N.getBoundingClientRect(),$=5,G=A.right+$;if(G+y.width>window.innerWidth||G+y.width>I.right){let te=A.left-y.width-$;G=(te<0?$:te)+window.pageXOffset}N.style.left=`${G+window.pageXOffset}px`;let q=A.top;if(q+y.height>window.innerHeight){let te=A.bottom-y.height;q=te<0?$:te}N.style.top=`${q}px`}},[e,i,l,h]),Qe(()=>{function _(N){i.current!=null&&e.current!=null&&I1(N.target)&&!i.current.contains(N.target)&&!e.current.contains(N.target)&&r(!1)}return window.addEventListener("click",_),()=>window.removeEventListener("click",_)},[r,e]);let x=se(()=>{l.update(()=>{if(s.isAttached()){let _=Ie(s),N=_r(_,l.getElementByKey(_.getKey()));if(N===null)throw new Error("Expected to find tableElement in DOM");let M=Tr(N);M!==null&&M.$clearHighlight(),_.markDirty(),u(s.getLatest())}N1(null)})},[l,s]),b=()=>{l.update(()=>{let _=po();if(!yt(_))return;let M=_.getNodes().filter($s),I=b1(M);I&&(M1(I),o())})},T=()=>{l.update(()=>{k1()})},E=se(_=>{l.update(()=>{for(let N=0;N<c.rows;N++)C1(_);o()})},[l,o,c.rows]),C=se(_=>{l.update(()=>{for(let N=0;N<c.columns;N++)x1(_);o()})},[l,o,c.columns]),k=se(()=>{l.update(()=>{p1(),o()})},[l,o]),g=se(()=>{l.update(()=>{Ie(s).remove(),x(),o()})},[l,s,x,o]),w=se(()=>{l.update(()=>{m1(),o()})},[l,o]),L=se(()=>{l.update(()=>{let _=Ie(s),N=g1(s),[M]=Ds(_,null,null),I=new Set,A=s.getHeaderStyles()^ye.ROW;if(M[N])for(let y=0;y<M[N].length;y++){let $=M[N][y];$?.cell&&(I.has($.cell)||(I.add($.cell),$.cell.setHeaderStyles(A,ye.ROW)))}x(),o()})},[l,s,x,o]),D=se(()=>{l.update(()=>{let _=Ie(s),N=h1(s),[M]=Ds(_,null,null),I=new Set,A=s.getHeaderStyles()^ye.COLUMN;if(M)for(let y=0;y<M.length;y++){let $=M?.[y]?.[N];$?.cell&&(I.has($.cell)||(I.add($.cell),$.cell.setHeaderStyles(A,ye.COLUMN)))}x(),o()})},[l,s,x,o]),F=se(()=>{l.update(()=>{if(s.isAttached()){let _=Ie(s);_&&_.setRowStriping(!_.getRowStriping())}x(),o()})},[l,s,x,o]),R=se(()=>{l.update(()=>{if(s.isAttached()){let _=Ie(s);_&&_.setFrozenColumns(_.getFrozenColumns()===0?1:0)}x(),o()})},[l,s,x,o]),S=null;return t&&(a?S=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>b(),type:"button",children:P("span",{className:"text",children:"Merge cells"})}):m&&(S=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>T(),type:"button",children:P("span",{className:"text",children:"Unmerge cells"})}))),Ps(Te("div",{className:"table-action-menu-dropdown",onClick:_=>{_.stopPropagation()},ref:i,children:[S?Te(Er.Fragment,{children:[S,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>F(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>R(),type:"button",children:P("span",{className:"text",children:"Toggle First Column Freeze"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>E(!1),type:"button",children:Te("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>E(!0),type:"button",children:Te("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>C(!1),type:"button",children:Te("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>C(!0),type:"button",children:Te("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>w(),type:"button",children:P("span",{className:"text",children:"Delete column"})}),P("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>k(),type:"button",children:P("span",{className:"text",children:"Delete row"})}),P("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-row-header",onClick:()=>L(),type:"button",children:Te("span",{className:"text",children:[(s.__headerState&ye.ROW)===ye.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:Te("span",{className:"text",children:[(s.__headerState&ye.COLUMN)===ye.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function A1({anchorElem:t,cellMerge:e}){let[o]=Fs(),r=mo(null),n=mo(null),[l,i]=et(!1),[s,u]=et(null),c=se(()=>{let a=r.current,p=po(),m=y1(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),u(null)}if(p==null||a==null)return h();let x=o.getRootElement(),b=null,T=null;if(wr(p)&&x!==null&&m!==null&&x.contains(m.anchorNode)){let C=As(p.anchor.getNode());if(C==null||(T=o.getElementByKey(C.getKey()),T==null||!C.isAttached()))return h();let k=Ie(C),g=_r(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=Tr(g),u(C)}else if(yt(p)){let C=As(p.anchor.getNode());if(!$s(C))throw new Error("TableSelection anchorNode must be a TableCellNode");let k=Ie(C),g=_r(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");b=Tr(g),T=o.getElementByKey(C.getKey())}else if(!f)return h();if(b===null||T===null)return h();let E=!b||!b.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",E),a.classList.toggle("table-cell-action-button-container--inactive",!E),E){let C=T.getBoundingClientRect(),k=t.getBoundingClientRect(),g=C.top-k.top,w=C.right-k.left;a.style.transform=`translate(${w}px, ${g}px)`}},[o,t]);Qe(()=>{let a,p=()=>{a=void 0,o.getEditorState().read(c)},m=()=>(a===void 0&&(a=setTimeout(p,0)),!1);return T1(o.registerUpdateListener(m),o.registerCommand(R1,m,L1),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",m),f&&(f.addEventListener("pointerup",m),m())}),()=>clearTimeout(a))});let d=mo(s);return Qe(()=>{d.current!==s&&i(!1),d.current=s},[d,s]),P("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Te(Er.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),i(!l)},ref:n,type:"button",children:P(Ms,{})}),l&&P(D1,{cellMerge:e,contextRef:n,onClose:()=>i(!1),setIsMenuOpen:i,tableCellNode:s})]})})}var Bs=t=>{let e=u1(3),{anchorElem:o}=t,r=d1(),n;return e[0]!==o||e[1]!==r?(n=Ps(r?P(A1,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as O1}from"react/compiler-runtime";import{jsx as ho,jsxs as F1}from"react/jsx-runtime";import{useLexicalComposerContext as $1}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as P1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as B1,$getTableNodeFromLexicalNodeOrThrow as Sr,$getTableRowIndexFromTableCellNode as H1,$isTableCellNode as Hs,$isTableRowNode as j1,getDOMCellFromTarget as U1,getTableElement as G1,TableNode as js}from"@lexical/table";import{calculateZoomLevel as Us,mergeRegister as W1}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Nr,isHTMLElement as V1,SKIP_SCROLL_INTO_VIEW_TAG as Gs}from"lexical";import*as Vs from"react";import{useCallback as It,useEffect as Lr,useRef as fo,useState as tt}from"react";import{createPortal as K1}from"react-dom";var J1=33,Ws=92;function X1({editor:t}){let e=fo(null),o=fo(null),r=fo(null),[n,l]=tt(!1),i=H(),s=fo(null),[u,c]=tt(null),[d,a]=tt(null),[p,m]=tt(!1),[f,h]=tt(null),x=It(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),b=R=>(R.buttons&1)===1;Lr(()=>{let R=new Set;return W1(t.registerMutationListener(js,S=>{for(let[_,N]of S)N==="destroyed"?R.delete(_):R.add(_);l(R.size>0)}),t.registerNodeTransform(js,S=>{if(S.getColWidths())return S;let _=S.getColumnCount(),N=Ws;return S.setColWidths(Array(_).fill(N)),S}))},[t]),Lr(()=>{if(!n)return;let R=M=>{let I=M.target;if(V1(I)){if(f){c({x:M.clientX,y:M.clientY});return}if(m(b(M)),!(o.current&&o.current.contains(I))&&e.current!==I){e.current=I;let A=U1(I);A&&d!==A?t.getEditorState().read(()=>{let y=Nr(A.elem);if(!y)throw new Error("TableCellResizer: Table cell node not found.");let $=Sr(y),G=G1($,t.getElementByKey($.getKey()));if(!G)throw new Error("TableCellResizer: Table element not found.");e.current=I,r.current=G.getBoundingClientRect(),a(A)},{editor:t}):A==null&&x()}}},S=M=>{m(!0)},_=M=>{m(!1)},N=t.registerRootListener((M,I)=>{I?.removeEventListener("mousemove",R),I?.removeEventListener("mousedown",S),I?.removeEventListener("mouseup",_),M?.addEventListener("mousemove",R),M?.addEventListener("mousedown",S),M?.addEventListener("mouseup",_)});return()=>{N()}},[d,f,t,n,x]);let T=R=>R==="bottom",E=It(R=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Nr(d.elem);if(!Hs(S))throw new Error("TableCellResizer: Table cell node not found.");let _=Sr(S),N=H1(S),M=_.getChildren(),A=S.getColSpan()===_.getColumnCount()?N:N+S.getRowSpan()-1;if(A>=M.length||A<0)throw new Error("Expected table cell to be inside of table row.");let y=M[A];if(!j1(y))throw new Error("Expected table row");let $=y.getHeight();if($===void 0){let q=y.getChildren();$=Math.min(...q.map(te=>C(te,t)??1/0))}let G=Math.max($+R,J1);y.setHeight(G)},{tag:Gs})},[d,t]),C=(R,S)=>S.getElementByKey(R.getKey())?.clientHeight,k=(R,S)=>{let _;return S.forEach(N=>{N.forEach((M,I)=>{M.cell===R&&(_=I)})}),_},g=It(R=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let S=Nr(d.elem);if(!Hs(S))throw new Error("TableCellResizer: Table cell node not found.");let _=Sr(S),[N]=B1(_,null,null),M=k(S,N);if(M===void 0)throw new Error("TableCellResizer: Table column not found.");let I=_.getColWidths();if(!I)return;let A=I[M];if(A===void 0)return;let y=[...I],$=Math.max(A+R,Ws);y[M]=$,_.setColWidths(y)},{tag:Gs})},[d,t]),w=It(R=>{let S=_=>{if(_.preventDefault(),_.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:N,y:M}=s.current;if(d===null)return;let I=Us(_.target);if(T(R)){let A=(_.clientY-M)/I;E(A)}else{let A=(_.clientX-N)/I;g(A)}x(),document.removeEventListener("mouseup",S)}};return S},[d,x,g,E]),L=It(R=>S=>{if(S.preventDefault(),S.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");s.current={x:S.clientX,y:S.clientY},c(s.current),h(R),document.addEventListener("mouseup",w(R))},[d,w]),[D,F]=tt({bottom:null,left:null,right:null,top:null});return Lr(()=>{if(d){let{height:R,left:S,top:_,width:N}=d.elem.getBoundingClientRect(),M=Us(d.elem),I=10,A={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${I}px`,left:`${window.scrollX+S}px`,top:`${window.scrollY+_+R-I/2}px`,width:`${N}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${R}px`,left:`${window.scrollX+S+N-I/2}px`,top:`${window.scrollY+_}px`,width:`${I}px`}},y=r.current;f&&u&&y&&(T(f)?(A[f].left=`${window.scrollX+y.left}px`,A[f].top=`${window.scrollY+u.y/M}px`,A[f].height="3px",A[f].width=`${y.width}px`):(A[f].top=`${window.scrollY+y.top}px`,A[f].left=`${window.scrollX+u.x/M}px`,A[f].width="3px",A[f].height=`${y.height}px`),A[f].backgroundColor="#adf"),F(A)}else F({bottom:null,left:null,right:null,top:null})},[d,f,u]),ho("div",{ref:o,children:d!=null&&!p&&F1(Vs.Fragment,{children:[ho("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:L("right"),style:D.right||void 0}),ho("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:L("bottom"),style:D.bottom||void 0})]})})}var Ks=()=>{let t=O1(3),[e]=$1(),o=P1(),r;return t[0]!==e||t[1]!==o?(r=o?K1(ho(X1,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],r};import{c as oh}from"react/compiler-runtime";import{jsx as yr,jsxs as rh,Fragment as nh}from"react/jsx-runtime";import{useLexicalComposerContext as ea}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as lh,$getTableColumnIndexFromTableCellNode as ih,$getTableRowIndexFromTableCellNode as sh,$insertTableColumnAtSelection as ah,$insertTableRowAtSelection as ch,$isTableCellNode as uh,$isTableNode as zs,getTableElement as dh,TableNode as mh}from"@lexical/table";import{$findMatchingParent as ph,mergeRegister as fh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Zs,isHTMLElement as hh}from"lexical";import{useEffect as Ys,useMemo as gh,useRef as qs,useState as go}from"react";import"react";import{createPortal as xh}from"react-dom";import{c as Q1}from"react/compiler-runtime";import{useEffect as eh,useRef as th}from"react";var z1="Expected a function",Z1=Math.max,Y1=Math.min;function q1(t,e,o){let r,n,l=0,i,s=!1,u=!1,c,d,a,p=!0;if(typeof t!="function")throw new TypeError(z1);e=e||0,typeof o=="object"&&(s=!!o.leading,u="maxWait"in o,c=u?Z1(o.maxWait||0,e):c,p="trailing"in o?!!o.trailing:p);function m(g){let w=r,L=i;return r=i=void 0,l=g,d=t.apply(L,w),d}function f(g){return l=g,a=setTimeout(b,e),s?m(g):d}function h(g){let w=g-n,L=g-l,D=e-w;return u?Y1(D,c-L):D}function x(g){let w=g-n,L=g-l;return n===void 0||w>=e||w<0||u&&L>=c}function b(){let g=Date.now();if(x(g))return T(g);a=setTimeout(b,h(g))}function T(g){return a=void 0,p&&r?m(g):(r=i=void 0,d)}function E(){a!==void 0&&clearTimeout(a),l=0,r=n=i=a=void 0}function C(){return a===void 0?d:T(Date.now())}function k(){let g=Date.now(),w=x(g);if(r=arguments,i=this,n=g,w){if(a===void 0)return f(n);if(u)return clearTimeout(a),a=setTimeout(b,e),m(n)}return a===void 0&&(a=setTimeout(b,e)),d}return k.cancel=E,k.flush=C,k}var Js=q1;function Xs(t,e,o){let r=Q1(6),n=th(null),l,i;r[0]!==t||r[1]!==o||r[2]!==e?(l=()=>(n.current=Js(t,e,{maxWait:o}),()=>{n.current?.cancel()}),i=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=l,r[4]=i):(l=r[3],i=r[4]),eh(l,i);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let d=c;n.current&&n.current(...d)},r[5]=s):s=r[5],s}var Qs=20;function Ch({anchorElem:t}){let[e]=ea(),o=H(),[r,n]=go(!1),[l,i]=go(!1),[s,u]=go(!1),[c,d]=go({}),a=qs(new Set),p=qs(null),m=Xs(x=>{let{isOutside:b,tableDOMNode:T}=bh(x,o.editorConfig?.lexical);if(b){n(!1),i(!1);return}if(!T)return;p.current=T;let E=null,C=null,k=null;if(e.getEditorState().read(()=>{let I=Zs(T);if(uh(I)){let A=ph(I,y=>zs(y));if(!zs(A))return;if(k=dh(A,e.getElementByKey(A.getKey())),k){let y=A.getChildrenSize(),$=A.getChildAtIndex(0)?.getChildrenSize(),G=sh(I),q=ih(I);G===y-1?E=I:q===$-1&&(C=I)}}},{editor:e}),!k)return;let g=k.parentElement;if(!g)return;let{bottom:w,height:L,left:D,right:F,width:R,y:S}=k.getBoundingClientRect(),_=!1;g&&g.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(_=g.scrollWidth>g.clientWidth);let{left:N,y:M}=t.getBoundingClientRect();E?(i(!1),n(!0),d({height:Qs,left:_&&g?g.offsetLeft:D-N,top:w-M+5,width:_&&g?g.offsetWidth:R})):C&&(i(!0),n(!1),d({height:L,left:F-N+5,top:S-M,width:Qs}))},50,250),f=gh(()=>new ResizeObserver(()=>{n(!1),i(!1)}),[]);Ys(()=>{if(s)return document.addEventListener("mousemove",m),()=>{n(!1),i(!1),document.removeEventListener("mousemove",m)}},[s,m]),Ys(()=>fh(e.registerMutationListener(mh,x=>{e.getEditorState().read(()=>{let b=!1;for(let[T,E]of x)switch(E){case"created":{a.current.add(T),b=!0;break}case"destroyed":{a.current.delete(T),b=!0;break}default:break}if(b){f.disconnect();for(let T of a.current){let{tableElement:E}=lh(T);f.observe(E)}u(a.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=x=>{e.update(()=>{p.current&&(Zs(p.current)?.selectEnd(),x?(ch(),n(!1)):(ah(),i(!1)))})};return e?.isEditable()?rh(nh,{children:[r&&yr("button",{"aria-label":"Add Row",className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...c},type:"button"}),l&&yr("button",{"aria-label":"Add Column",className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...c},type:"button"})]}):null}function bh(t,e){let o=t.target;if(hh(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function ta(t){let e=oh(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=ea();if(!n?.isEditable())return null;let l;return e[0]!==r?(l=xh(yr(Ch,{anchorElem:r}),r),e[0]=r,e[1]=l):l=e[1],l}import{c as kh}from"react/compiler-runtime";import{jsx as Ir,jsxs as _h}from"react/jsx-runtime";import{useLexicalComposerContext as Th}from"@lexical/react/LexicalComposerContext";import{TablePlugin as wh}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Eh,TableCellNode as Sh,TableNode as Nh,TableRowNode as Lh}from"@lexical/table";import{mergeRegister as yh}from"@lexical/utils";import{formatDrawerSlug as Ih,useEditDepth as Rh}from"@payloadcms/ui";import{$getSelection as vh,$isRangeSelection as Mh,COMMAND_PRIORITY_EDITOR as Dh,createCommand as Ah}from"lexical";import{createContext as Oh,use as Fh,useEffect as $h,useMemo as Ph,useState as Bh}from"react";import*as oa from"react";var xo=Ah("OPEN_EMBED_DRAWER_COMMAND"),ra=Oh({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function na({children:t}){let[e,o]=Bh({cellEditorConfig:null,cellEditorPlugins:null});return Ir(ra,{value:Ph(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var la=()=>{let t=kh(16),[e]=Th(),o=Fh(ra),r=Rh(),{fieldProps:n,uuid:l}=H(),{schemaPath:i}=n,s="lexical-table-create-"+l,u;t[0]!==r||t[1]!==s?(u=Ih({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=me(c,!0),a;t[3]!==e||t[4]!==d?(a=()=>{if(!e.hasNodes([Nh,Lh,Sh]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return yh(e.registerCommand(xo,()=>{let h=null;return e.getEditorState().read(()=>{let x=vh();Mh(x)&&(h=x)}),h&&d(),!0},Dh))},t[3]=e,t[4]=d,t[5]=a):a=t[5];let p;t[6]!==o||t[7]!==e||t[8]!==d?(p=[o,e,d],t[6]=o,t[7]=e,t[8]=d,t[9]=p):p=t[9],$h(a,p);let m;t[10]!==e?(m=(h,x)=>{!x.columns||!x.rows||e.dispatchCommand(Eh,{columns:String(x.columns),rows:String(x.rows)})},t[10]=e,t[11]=m):m=t[11];let f;return t[12]!==c||t[13]!==i||t[14]!==m?(f=_h(oa.Fragment,{children:[Ir(nt,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:m,schemaPath:i,schemaPathSuffix:"fields"}),Ir(wh,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=i,t[14]=m,t[15]=f):f=t[15],f};var Gh=v({markdownTransformers:[Rs],nodes:[jh,Hh,Uh],plugins:[{Component:la,position:"normal"},{Component:Ks,position:"normal"},{Component:Bs,position:"floatingAnchorElem"},{Component:ta,position:"floatingAnchorElem"}],providers:[na],slashMenu:{groups:[Z([{Icon:xr,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(xo,{})}}])]},toolbarFixed:{groups:[he([{ChildComponent:xr,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(xo,{})}}])]}});import{$isNodeSelection as yg}from"lexical";import{jsx as Rr,jsxs as Wh}from"react/jsx-runtime";import"react";var vr=()=>Wh("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{jsx as ua}from"react/jsx-runtime";import da from"bson-objectid";import{$applyNodeReplacement as zh}from"lexical";import*as ma from"react";import Vh from"bson-objectid";function Co(t,e){if(t.hasAttribute("data-lexical-pending-upload-form-id")){let r=t.getAttribute("data-lexical-pending-upload-form-id");if(r!=null)return{node:e({data:{pending:{formID:r,src:t.getAttribute("src")||""}}})}}if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let r=t.getAttribute("data-lexical-upload-id"),n=t.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:e({data:{fields:{},relationTo:n,value:r}})}}return{node:e({data:{pending:{formID:new Vh.default().toHexString(),src:t.getAttribute("src")||""}}})}}import{DecoratorBlockNode as Kh}from"@lexical/react/LexicalDecoratorBlockNode.js";import sa from"bson-objectid";import{$applyNodeReplacement as Jh}from"lexical";var Rt=class extends Kh{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:o=>Co(o,ia),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new sa.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=ia({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return null}exportDOM(){let e=document.createElement("img"),o=this.__data;return o.pending?(e.setAttribute("data-lexical-pending-upload-form-id",String(o?.pending?.formID)),e.setAttribute("src",o?.pending?.src||"")):(e.setAttribute("data-lexical-upload-id",String(o?.value)),e.setAttribute("data-lexical-upload-relation-to",o?.relationTo)),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function ia({data:t}){return t?.id||(t.id=new sa.default().toHexString()),Jh(new Rt({data:t}))}import{jsx as aa}from"react/jsx-runtime";import{ShimmerEffect as Xh}from"@payloadcms/ui";var ca=()=>aa("div",{className:"lexical-upload",children:aa(Xh,{height:"95px",width:"203px"})});var Zh=ma.lazy(()=>import("./component-VDJI45F2.js").then(t=>({default:t.UploadComponent}))),ne=class extends Rt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:o=>Co(o,Re),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new da.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=Re({data:o});return r.setFormat(e.format),r}decorate(){return this.__data.pending?ua(ca,{}):ua(Zh,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Re({data:t}){return t?.id||(t.id=new da.default().toHexString()),zh(new ne({data:t}))}function ot(t){return t instanceof ne}import{c as ng}from"react/compiler-runtime";import{jsx as lg}from"react/jsx-runtime";import{useLexicalComposerContext as ig}from"@lexical/react/LexicalComposerContext.js";import{$dfsIterator as wa,$insertNodeToNearestRoot as Ar,mergeRegister as sg}from"@lexical/utils";import{useBulkUpload as ag,useConfig as cg,useEffectEvent as ug,useModal as dg}from"@payloadcms/ui";import Or from"bson-objectid";import{$createRangeSelection as mg,$getPreviousSelection as Ca,$getSelection as ba,$isParagraphNode as Fr,$isRangeSelection as ka,$setSelection as pg,COMMAND_PRIORITY_EDITOR as fg,COMMAND_PRIORITY_LOW as _a,createCommand as hg,DROP_COMMAND as gg,getDOMSelectionFromTarget as xg,isHTMLElement as Ta,PASTE_COMMAND as Cg}from"lexical";import{useEffect as bg}from"react";import{c as pa}from"react/compiler-runtime";import{jsx as Mr}from"react/jsx-runtime";import{useLexicalComposerContext as fa}from"@lexical/react/LexicalComposerContext.js";import{toast as Yh}from"@payloadcms/ui";import{$getNodeByKey as qh,COMMAND_PRIORITY_EDITOR as ha}from"lexical";import{useEffect as ga,useState as Qh}from"react";var eg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=qh(o);n&&n.replace(Re({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Dr,{fields:null,relationTo:e,value:r})},tg=t=>{let e=pa(13),{enabledCollectionSlugs:o}=t,[r]=fa(),[n,l]=Qh(null),i;e[0]!==o?(i={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=i):i=e[1];let{closeListDrawer:s,ListDrawer:u,openListDrawer:c}=St(i),d,a;e[2]!==r||e[3]!==c?(d=()=>r.registerCommand(Ue,h=>(l(h?.replace?h?.replace.nodeKey:null),c(),!0),ha),a=[r,c],e[2]=r,e[3]=c,e[4]=d,e[5]=a):(d=e[4],a=e[5]),ga(d,a);let p;e[6]!==s||e[7]!==r||e[8]!==n?(p=h=>{let{collectionSlug:x,doc:b}=h;s(),eg({editor:r,relationTo:x,replaceNodeKey:n,value:b.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=p):p=e[9];let m=p,f;return e[10]!==u||e[11]!==m?(f=Mr(u,{onSelect:m}),e[10]=u,e[11]=m,e[12]=f):f=e[12],f},og=()=>{let t=pa(3),[e]=fa(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Ue,rg,ha),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ga(o,r),null},xa=t=>Mr(Ot,{...t,FallbackComponent:og,uploads:!0,children:Mr(tg,{...t})});function rg(){return Yh.error("No upload collections enabled"),!0}function kg(t){let e=t.target;return!!(Ta(e)&&!e.closest("code, span.editor-image")&&Ta(e.parentElement)&&e.parentElement.closest("div.ContentEditable__root"))}function _g(t){let e,o=xg(t.target);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&o!==null)o.collapse(t.rangeParent,t.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var Dr=hg("INSERT_UPLOAD_COMMAND"),Ea=()=>{let t=ng(18),[e]=ig(),{config:o}=cg(),{collections:r}=o,{drawerSlug:n,setCollectionSlug:l,setInitialForms:i,setOnCancel:s,setOnSuccess:u,setSelectableCollections:c}=ag(),{isModalOpen:d,openModal:a}=dg(),p;t[0]!==n||t[1]!==r||t[2]!==e||t[3]!==d||t[4]!==a||t[5]!==l||t[6]!==i||t[7]!==s||t[8]!==u||t[9]!==c?(p=b=>{let{files:T}=b;if(T?.length!==0&&(i(E=>[...E??[],...T.map(Tg)]),!d(n))){let E=r.filter(wg).map(Eg);if(!E.length||!E[0])return;l(E[0]),c(E),s(()=>{e.update(Sg)}),u(C=>{let k=new Map(C.map(Ng));e.update(()=>{for(let g of wa()){let w=g.node;if(ot(w)){let L=w.getData();if(L?.pending){let D=k.get(L.pending?.formID);D&&w.replace(Re({data:{id:new Or.default().toHexString(),fields:{},relationTo:D.collectionSlug,value:D.doc.id}}))}}}})}),a(n)}},t[0]=n,t[1]=r,t[2]=e,t[3]=d,t[4]=a,t[5]=l,t[6]=i,t[7]=s,t[8]=u,t[9]=c,t[10]=p):p=t[10];let m=ug(p),f;t[11]!==e||t[12]!==m?(f=()=>{if(!e.hasNodes([ne]))throw new Error("UploadPlugin: UploadNode not registered on editor");return sg(e.registerNodeTransform(ne,b=>{let T=b.getData();if(!T?.pending)return;(async function(){let k=null,g=T?.pending?.src,w=T?.pending?.formID;if(g?.startsWith("data:")){let L=g.match(/data:(image\/[a-zA-Z]+);base64,/),D=L?L[1]:"image/png",F=g.replace(/^data:image\/[a-zA-Z]+;base64,/,""),R=atob(F),S=new Array(R.length);for(let M=0;M<R.length;M++)S[M]=R.charCodeAt(M);let _=new Uint8Array(S);k={alt:void 0,file:new File([_],"pasted-image."+D?.split("/")[1],{type:D}),formID:w}}else if(g?.startsWith("http")||g?.startsWith("https")){let D=await(await fetch(g)).blob(),F=g.split("/").pop()||"pasted-image"+D.type.split("/")[1];k={alt:void 0,file:new File([D],F,{type:D.type}),formID:w}}k&&m({files:[k]})})()}),e.registerCommand(Dr,b=>(e.update(()=>{let T=ba()||Ca();if(ka(T)){let E=Re({data:{id:b.id,fields:b.fields,relationTo:b.relationTo,value:b.value}}),{focus:C}=T,k=C.getNode();Ar(E),Fr(k)&&!k.__first&&k.remove()}}),!0),fg),e.registerCommand(Cg,b=>{if(!(b instanceof ClipboardEvent))return!1;let T=b.clipboardData;if(!T?.types?.length||T?.types?.includes("text/html"))return!1;let E=[];return T?.files?.length&&Array.from(T.files).forEach(C=>{E.push({alt:"",file:C,formID:new Or.default().toHexString()})}),E.length?(e.update(()=>{let C=ba()||Ca();if(ka(C))for(let k of E){let g=new ne({data:{pending:{formID:k.formID,src:URL.createObjectURL(k.file)}}}),{focus:w}=C,L=w.getNode();Ar(g),Fr(L)&&!L.__first&&L.remove()}}),m({files:E}),!0):!1},_a),e.registerCommand(gg,b=>{if(!(b instanceof DragEvent))return!1;let T=b.dataTransfer;if(!T?.types?.length)return!1;let E=[];return T?.files?.length&&Array.from(T.files).forEach(C=>{E.push({alt:"",file:C,formID:new Or.default().toHexString()})}),E.length?(b.preventDefault(),b.stopPropagation(),e.update(()=>{if(kg(b)){let C=_g(b),k=mg();C!=null&&k.applyDOMRange(C),pg(k);for(let g of E){let w=new ne({data:{pending:{formID:g.formID,src:URL.createObjectURL(g.file)}}}),{focus:L}=k,D=L.getNode();Ar(w),Fr(D)&&!D.__first&&D.remove()}}}),m({files:E}),!0):!1},_a))},t[11]=e,t[12]=m,t[13]=f):f=t[13];let h;t[14]!==e?(h=[e],t[14]=e,t[15]=h):h=t[15],bg(f,h);let x;return t[16]!==r?(x=lg(xa,{enabledCollectionSlugs:r.map(Lg)}),t[16]=r,t[17]=x):x=t[17],x};function Tg(t){return{file:t.file,formID:t.formID}}function wg(t){let{upload:e}=t;return!!e}function Eg(t){let{slug:e}=t;return e}function Sg(){for(let t of wa()){let e=t.node;ot(e)&&e.getData()?.pending&&e.remove()}}function Ng(t){return[t.formID,t]}function Lg(t){let{slug:e}=t;return e}var Ig=v({nodes:[ne],plugins:[{Component:Ea,position:"normal"}],slashMenu:{groups:[Z([{Icon:vr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ue,{replace:!1})}}])]},toolbarFixed:{groups:[he([{ChildComponent:vr,isActive:({selection:t})=>{if(!yg(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return ot(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ue,{replace:!1})}}])]}});import{c as vg}from"react/compiler-runtime";import{jsx as Pr}from"react/jsx-runtime";import{ShimmerEffect as Mg,useConfig as Dg}from"@payloadcms/ui";import{lazy as Ag,Suspense as Og,useEffect as Fg,useState as $g}from"react";var Sa={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",hrSelected:"LexicalEditorTheme__hrSelected",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",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var bo={namespace:"lexical",theme:Sa};function Na({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:l}){for(let c of l.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");l.features=l.features.sort((c,d)=>c.clientFeatureProps.order-d.clientFeatureProps.order);let i=new Map;for(let c of l.features)i.set(c.clientFeatureProps.featureKey,c);let s=new Map,u=0;for(let c of l.features){let d=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:i,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:l}):c.feature;d.key=c.clientFeatureProps.featureKey,d.order=u,s.set(c.clientFeatureProps.featureKey,d),u++}return s}import{deepMerge as Rg}from"payload/shared";var La=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,l)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+l,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let l=e.toolbarInline.groups.find(i=>i.key===n.key);l?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarInline?.groups.push(l)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let l=e.toolbarFixed.groups.find(i=>i.key===n.key);l?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarFixed?.groups.push(l)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let l=e.slashMenu.groups.find(i=>i.key===n.key);l?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.slashMenu.groups.push(l)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?Rg(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);return e};function $r(t,e,o){return{admin:o,features:La(t),lexical:e,resolvedFeatureMap:t}}var Pg=Ag(()=>import("./Field-U4WLAHNW.js").then(t=>({default:t.RichText}))),Bg=t=>{let e=vg(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:l,field:i,lexicalEditorConfig:s,schemaPath:u}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let d=c,a=s===void 0?bo:s,{config:p}=Dg(),[m,f]=$g(null),h,x;e[2]!==d||e[3]!==r||e[4]!==p||e[5]!==n||e[6]!==l||e[7]!==i||e[8]!==m||e[9]!==a||e[10]!==u?(h=()=>{if(m)return;let T=[];for(let[k,g]of Object.entries(r))g.clientFeatureProvider&&T.push(g.clientFeatureProvider(g.clientFeatureProps));let E=a||bo,C=Na({config:p,featureClientImportMap:n,featureClientSchemaMap:l,field:i,schemaPath:u??i.name,unSanitizedEditorConfig:{features:T,lexical:E}});f($r(C,E,d))},x=[a,d,m,r,n,l,i,p,u],e[2]=d,e[3]=r,e[4]=p,e[5]=n,e[6]=l,e[7]=i,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=x):(h=e[11],x=e[12]),Fg(h,x);let b;return e[13]!==m||e[14]!==t?(b=Pr(Og,{fallback:Pr(Mg,{height:"35vh"}),children:m&&Pr(Pg,{...t,editorConfig:m})}),e[13]=m,e[14]=t,e[15]=b):b=e[15],b};function Hg(t){return t instanceof HTMLElement}function jg(...t){return t.filter(Boolean).join(" ")}var ko=new WeakMap;function ya(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function _o(t,e){let o=ko.get(t);if(o===void 0){let r=new Set,n=i=>{o!==void 0&&(o.start=ya(i))},l=i=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let u=ya(i);for(let c of r)u!==null&&c([u[0]-s[0],u[1]-s[1]],i)};t.addEventListener("touchstart",n),t.addEventListener("touchend",l),o={handleTouchend:l,handleTouchstart:n,listeners:r,start:null},ko.set(t,o)}return o.listeners.add(e),()=>{Ug(t,e)}}function Ug(t,e){let o=ko.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(ko.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function Gg(t,e){return _o(t,(o,r)=>{let[n,l]=o;n<0&&-n>Math.abs(l)&&e(n,r)})}function Wg(t,e){return _o(t,(o,r)=>{let[n,l]=o;n>0&&n>Math.abs(l)&&e(n,r)})}function Vg(t,e){return _o(t,(o,r)=>{let[n,l]=o;l<0&&-l>Math.abs(n)&&e(n,r)})}function Kg(t,e){return _o(t,(o,r)=>{let[n,l]=o;l>0&&l>Math.abs(n)&&e(n,r)})}import{c as Jg}from"react/compiler-runtime";import{jsx as Xg}from"react/jsx-runtime";import"react";var zg=()=>{let t=Jg(2),{EditButton:e}=pe(),o;return t[0]!==e?(o=e?Xg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Zg}from"react/compiler-runtime";import{jsx as Yg}from"react/jsx-runtime";import"react";var qg=()=>{let t=Zg(2),{RemoveButton:e}=pe(),o;return t[0]!==e?(o=e?Yg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Qg}from"react/compiler-runtime";import{jsx as ex}from"react/jsx-runtime";import"react";var tx=()=>{let t=Qg(2),{Label:e}=pe(),o;return t[0]!==e?(o=e?ex(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as ox}from"react/compiler-runtime";import{jsx as rx}from"react/jsx-runtime";import"react";var nx=t=>{let e=ox(3),{children:o}=t,{InlineBlockContainer:r}=pe(),n;return e[0]!==r||e[1]!==o?(n=r?rx(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as lx}from"react/compiler-runtime";import{jsx as ix}from"react/jsx-runtime";import"react";var sx=t=>{let e=lx(6),{children:o,editButton:r,Label:n,removeButton:l}=t,{BlockCollapsible:i}=ve(),s;return e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==l?(s=i?ix(i,{editButton:r,Label:n,removeButton:l,children:o}):null,e[0]=i,e[1]=n,e[2]=o,e[3]=r,e[4]=l,e[5]=s):s=e[5],s};import{c as ax}from"react/compiler-runtime";import{jsx as cx}from"react/jsx-runtime";import"react";var ux=()=>{let t=ax(2),{EditButton:e}=ve(),o;return t[0]!==e?(o=e?cx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as dx}from"react/compiler-runtime";import{jsx as mx}from"react/jsx-runtime";import"react";var px=()=>{let t=dx(2),{RemoveButton:e}=ve(),o;return t[0]!==e?(o=e?mx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as fx}from"qs-esm";var hx=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:l,collectionSlug:i,select:s})=>{let u=fx({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${i}/${l}${u}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(d=>d.json())};import{c as gx}from"react/compiler-runtime";import{jsx as rt}from"react/jsx-runtime";import{FieldContext as xx,FieldPathContext as Ia,ServerFunctionsContext as Ra,ShimmerEffect as Cx,useServerFunctions as bx}from"@payloadcms/ui";import kx,{useEffect as _x,useRef as Tx}from"react";var wx=t=>{let e=gx(9),{field:o,initialValue:r,Loading:n,path:l,schemaPath:i,setValue:s,value:u}=t,[c,d]=kx.useState(null),a=bx(),{_internal_renderField:p}=a,[m,f]=i.split("."),h=l??(o&&"name"in o?o?.name:"")??"",x;e[0]!==p||e[1]!==o||e[2]!==r||e[3]!==l||e[4]!==i?(x=()=>{(async function(){let{Field:D}=await p({field:{...o||{},type:"richText",admin:{hidden:!1}},initialValue:r??void 0,path:l,schemaPath:i});d(D)})()},e[0]=p,e[1]=o,e[2]=r,e[3]=l,e[4]=i,e[5]=x):x=e[5];let b=x,T=Tx(!1),E,C;if(e[6]!==b?(E=()=>{T.current||(T.current=!0,b())},C=[b],e[6]=b,e[7]=E,e[8]=C):(E=e[7],C=e[8]),_x(E,C),!c)return typeof n<"u"?n:rt(Cx,{});let k={...a,getFormState:async w=>a.getFormState({...w,collectionSlug:m==="collection"?f:void 0,globalSlug:m==="global"?f:void 0})};if(typeof u>"u"&&!s)return rt(Ra,{value:{...k},children:rt(Ia,{value:h,children:c},h)});let g={disabled:!1,formInitializing:!1,formProcessing:!1,formSubmitted:!1,initialValue:u,path:h,setValue:s??Ex,showError:!1,value:u};return rt(Ra,{value:{...k},children:rt(Ia,{value:h,children:rt(xx,{value:g,children:c})},h)})};function Ex(){}function Sx({nodes:t,text:e}){let o={root:{type:"root",children:[],direction:"ltr",format:"",indent:0,version:1}};return e&&o.root.children.push({type:"paragraph",children:[{type:"text",detail:0,format:0,mode:"normal",style:"",text:e,version:1}],direction:"ltr",format:"",indent:0,textFormat:0,textStyle:"",version:1}),t?.length&&o.root.children.push(...t),o}export{ht as $createAutoLinkNode,Kt as $createBlockNode,Eo as $createInlineBlockNode,ge as $createLinkNode,$e as $createRelationshipNode,Re as $createUploadNode,Ce as $isAutoLinkNode,dt as $isBlockNode,So as $isInlineBlockNode,J as $isLinkNode,dr as $isRelationshipNode,ot as $isUploadNode,Ga as AlignFeatureClient,xe as AutoLinkNode,sx as BlockCollapsible,ux as BlockEditButton,fe as BlockNode,px as BlockRemoveButton,Xa as BlockquoteFeatureClient,Vc as BlocksFeatureClient,fu as BoldFeatureClient,re as CAN_USE_DOM,xp as ChecklistFeatureClient,af as DETAIL_TYPE_TO_DETAIL,rf as DOUBLE_LINE_BREAK,bf as DebugJsxConverterFeatureClient,uf as ELEMENT_FORMAT_TO_TYPE,cf as ELEMENT_TYPE_TO_FORMAT,Fa as ENABLE_SLASH_MENU_COMMAND,Ma as EditorConfigProvider,nt as FieldsDrawer,j0 as FixedToolbarFeatureClient,cd as HeadingFeatureClient,Ld as HorizontalRuleFeatureClient,Ge as INSERT_BLOCK_COMMAND,We as INSERT_INLINE_BLOCK_COMMAND,tf as IS_ALL_FORMATTING,Gd as IndentFeatureClient,nx as InlineBlockContainer,zg as InlineBlockEditButton,tx as InlineBlockLabel,wo as InlineBlockNode,qg as InlineBlockRemoveButton,bu as InlineCodeFeatureClient,q0 as InlineToolbarFeatureClient,wu as ItalicFeatureClient,lf as LTR_REGEX,Bp as LexicalPluginToLexicalFeatureClient,op as LinkFeatureClient,ee as LinkNode,of as NON_BREAKING_SPACE,O as NodeFormat,Sp as OrderedListFeatureClient,Jp as ParagraphFeatureClient,Aa as Point,nf as RTL_REGEX,$a as Rect,l0 as RelationshipFeatureClient,ke as RelationshipNode,wx as RenderLexical,Bg as RichTextField,Vp as SlateToLexicalFeatureClient,yu as StrikethroughFeatureClient,Mu as SubscriptFeatureClient,Fu as SuperscriptFeatureClient,df as TEXT_MODE_TO_TYPE,sf as TEXT_TYPE_TO_FORMAT,mf as TEXT_TYPE_TO_MODE,ce as TOGGLE_LINK_COMMAND,Gh as TableFeatureClient,lu as TestRecorderFeatureClient,qu as TextStateFeatureClient,Nt as ToolbarButton,Pe as ToolbarDropdown,uu as TreeViewFeatureClient,ju as UnderlineFeatureClient,Dp as UnorderedListFeatureClient,Ig as UploadFeatureClient,ne as UploadNode,Kg as addSwipeDownListener,Gg as addSwipeLeftListener,Wg as addSwipeRightListener,Vg as addSwipeUpListener,Sx as buildEditorState,Go as createBlockNode,v as createClientFeature,kf as defaultColors,bo as defaultEditorLexicalConfig,gr as getDOMRangeRect,Pa as getEnabledNodes,hx as getRestPopulateFn,Ve as getSelectedNode,Hg as isHTMLElement,Oa as isPoint,jg as joinClasses,$r as sanitizeClientEditorConfig,La as sanitizeClientFeatures,so as setFloatingElemPosition,to as setFloatingElemPositionForLinkEditor,Z as slashMenuBasicGroupWithItems,he as toolbarAddDropdownGroupWithItems,Vo as toolbarFeatureButtonsGroupWithItems,Y as toolbarFormatGroupWithItems,Q as toolbarTextDropdownGroupWithItems,ve as useBlockComponentContext,H as useEditorConfigContext,pe as useInlineBlockComponentContext,Da as useLexicalDocumentDrawer,me as useLexicalDrawer,St as useLexicalListDrawer};
41
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAO5D,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CAgK9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAqC,CAAA"}
1
+ {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAO5D,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CAmK9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAqC,CAAA"}
@@ -3,6 +3,7 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { FieldDescription, FieldError, FieldLabel, RenderCustomComponent, useEditDepth, useEffectEvent, useField } from '@payloadcms/ui';
5
5
  import { mergeFieldStyles } from '@payloadcms/ui/shared';
6
+ import { dequal } from 'dequal/lite';
6
7
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
7
8
  import { ErrorBoundary } from 'react-error-boundary';
8
9
  import './bundled.css';
@@ -97,8 +98,11 @@ const RichTextComponent = props => {
97
98
  const styles = useMemo(() => mergeFieldStyles(field), [field]);
98
99
  const handleInitialValueChange = useEffectEvent(initialValue_0 => {
99
100
  // Object deep equality check here, as re-mounting the editor if
100
- // the new value is the same as the old one is not necessary
101
- if (prevValueRef.current !== value_0 && JSON.stringify(prevValueRef.current) !== JSON.stringify(value_0)) {
101
+ // the new value is the same as the old one is not necessary.
102
+ // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,
103
+ // so we need to do a deep equality check here that does not care about key order => we use dequal.
104
+ // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.
105
+ if (prevValueRef.current !== value_0 && !dequal(JSON.parse(JSON.stringify(prevValueRef.current)), value_0)) {
102
106
  prevInitialValueRef.current = initialValue_0;
103
107
  prevValueRef.current = value_0;
104
108
  setRerenderProviderKey(new Date());
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","stringify","Date","Object","is","_jsxs","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","composerKey","fieldProps","onChange","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary\n if (\n prevValueRef.current !== value &&\n JSON.stringify(prevValueRef.current) !== JSON.stringify(value)\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"AAAA;;;AAIA,SACEA,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,cAAc,EACdC,QAAQ,QACH;AACP,SAASC,gBAAgB,QAAQ;AACjC,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACjE,SAASC,aAAa,QAAQ;AAK9B,OAAO;AAKP,SAASC,eAAe,QAAQ;AAChC,SAASC,mBAAmB,QAAQ;AAEpC,MAAMC,SAAA,GAAY;AAElB,MAAMC,iBAAA,GAIDC,KAAA;EACH,MAAM;IACJC,YAAY;IACZC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,QAAA,EAAUC;MAAiB,CAAE,GAAG,CAAC,CAAC;MACnEC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAA,EAAMC,aAAa;IACnBN,QAAA,EAAUO,yBAAyB;IACnCC;EAAQ,CACT,GAAGd,KAAA;EAEJ,MAAMe,iBAAA,GAAoBF,yBAAA,IAA6BN,iBAAA;EAEvD,MAAMS,SAAA,GAAY9B,YAAA;EAElB,MAAM+B,gBAAA,GAAmB1B,WAAA,CACvB,CAAC2B,KAAA,EAAOC,iBAAA;IACN,IAAI,OAAOL,QAAA,KAAa,YAAY;MAClC;MACA,OAAOA,QAAA,CAASI,KAAA,EAAO;QAAE,GAAGC,iBAAiB;QAAET;MAAS;IAC1D;IACA,OAAO;EACT;EACA;EACA;EACA;EACA,CAACI,QAAA,EAAUJ,QAAA,CAAS;EAGtB,MAAM;IACJU,gBAAA,EAAkB;MAAEC,UAAU;MAAEC,WAAW;MAAEC,WAAW;MAAEC,KAAK;MAAEC;IAAK,CAAE,GAAG,CAAC,CAAC;IAC7EC,QAAA,EAAUC,iBAAiB;IAC3BC,YAAY;IACZjB,IAAI;IACJkB,QAAQ;IACRC,SAAS;IACTZ,KAAK,EAALA;EAAK,CACN,GAAG9B,QAAA,CAAgC;IAClC2C,oBAAA,EAAsBnB,aAAA;IACtBE,QAAA,EAAUG;EACZ;EAEA,MAAMS,QAAA,GAAWX,iBAAA,IAAqBY,iBAAA;EAEtC,MAAM,CAACK,oBAAA,EAAsBC,uBAAA,CAAwB,GAAGvC,QAAA,CAAkB;EAC1E,MAAM,CAACwC,mBAAA,EAAqBC,sBAAA,CAAuB,GAAGzC,QAAA;EAEtD,MAAM0C,mBAAA,GAAsB9C,KAAA,CAAM+C,MAAM,CAAoCT,YAAA;EAC5E,MAAMU,YAAA,GAAehD,KAAA,CAAM+C,MAAM,CAAoCnB,OAAA;EAErE1B,SAAA,CAAU;IACR,MAAM+C,mBAAA,GAAsBA,CAAA;MAC1B,MAAMC,wBAAA,GAA2BC,MAAA,CAAOC,UAAU,CAAC,sBAAsBC,OAAO;MAEhF,IAAIH,wBAAA,KAA6BR,oBAAA,EAAsB;QACrDC,uBAAA,CAAwBO,wBAAA;MAC1B;IACF;IACAD,mBAAA;IACAE,MAAA,CAAOG,gBAAgB,CAAC,UAAUL,mBAAA;IAElC,OAAO;MACLE,MAAA,CAAOI,mBAAmB,CAAC,UAAUN,mBAAA;IACvC;EACF,GAAG,CAACP,oBAAA,CAAqB;EAEzB,MAAMc,OAAA,GAAU,CACdhD,SAAA,EACA,cACAM,SAAA,EACA0B,SAAA,IAAa,SACbJ,QAAA,IAAY,GAAG5B,SAAA,aAAsB,EACrCG,YAAA,EAAcE,KAAA,EAAO4C,UAAA,KAAe,QAAQ,CAACf,oBAAA,GACzC,GAAGlC,SAAA,eAAwB,GAC3B,KACL,CACEkD,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;EAER,MAAMC,iBAAA,GAAoB,GAAGxC,IAAA,IAAQK,SAAA,EAAW;EAEhD,MAAMoC,gBAAA,GAAmBvD,mBAAA,GAAsB;EAAA;EAE/C,MAAMwD,YAAA,GAAe9D,WAAA,CAClB+D,WAAA;IACC;IACA,MAAMC,gBAAA,GAAmBA,CAAA;MACvB,MAAMC,QAAA,GAAWF,WAAA,CAAYG,MAAM;MACnCnB,YAAA,CAAaoB,OAAO,GAAGF,QAAA;MACvB3B,QAAA,CAAS2B,QAAA;IACX;IAEA;IACA;IACA,KAAKJ,gBAAA,CAAiBG,gBAAA;EACxB,GACA,CAAC1B,QAAA,EAAUuB,gBAAA,CAAiB;EAG9B,MAAMO,MAAA,GAASlE,OAAA,CAAQ,MAAMJ,gBAAA,CAAiBa,KAAA,GAAQ,CAACA,KAAA,CAAM;EAE7D,MAAM0D,wBAAA,GAA2BzE,cAAA,CAC9ByC,cAAA;IACC;IACA;IACA,IACEU,YAAA,CAAaoB,OAAO,KAAKxC,OAAA,IACzB2C,IAAA,CAAKC,SAAS,CAACxB,YAAA,CAAaoB,OAAO,MAAMG,IAAA,CAAKC,SAAS,CAAC5C,OAAA,GACxD;MACAkB,mBAAA,CAAoBsB,OAAO,GAAG9B,cAAA;MAC9BU,YAAA,CAAaoB,OAAO,GAAGxC,OAAA;MACvBiB,sBAAA,CAAuB,IAAI4B,IAAA;IAC7B;EACF;EAGFvE,SAAA,CAAU;IACR;IACA;IACA;IACA;IACA,IAAI,CAACwE,MAAA,CAAOC,EAAE,CAACrC,YAAA,EAAcQ,mBAAA,CAAoBsB,OAAO,GAAG;MACzDE,wBAAA,CAAyBhC,YAAA;IAC3B;EACF,GAAG,CAACA,YAAA,CAAa;EAEjB,oBACEsC,KAAA,CAAC;IAAI9D,SAAA,EAAW0C,OAAA;IAAiCqB,KAAA,EAAOR,MAAA;4BACtDS,IAAA,CAACnF,qBAAA;MACCoF,eAAA,EAAiB7C,KAAA;MACjB8C,QAAA,eAAUF,IAAA,CAACrF,UAAA;QAAW4B,IAAA,EAAMA,IAAA;QAAMmB,SAAA,EAAWA;;QAE9CL,KAAA,iBAAS2C,IAAA,CAACpF,UAAA;MAAWwB,KAAA,EAAOA,KAAA;MAAOC,SAAA,EAAWA,SAAA;MAAWE,IAAA,EAAMA,IAAA;MAAMD,QAAA,EAAUA;qBAChFwD,KAAA,CAAC;MAAI9D,SAAA,EAAW,GAAGN,SAAA,QAAiB;8BAClCoE,KAAA,CAACvE,aAAA;QAAc4E,cAAA,EAAgBA,cAAA;QAAgBC,OAAA,EAASA,CAAA,MAAO;mBAC5DlD,WAAA,E,aACD8C,IAAA,CAACxE,eAAA;UACC6E,WAAA,EAAatB,iBAAA;UACblD,YAAA,EAAcA,YAAA;UACdyE,UAAA,EAAY1E,KAAA;UACZgC,oBAAA,EAAsBA,oBAAA;UAEtB2C,QAAA,EAAUtB,YAAA;UACV/C,QAAA,EAAUoB,QAAA;UACVR,KAAA,EAAOA;WAHF2C,IAAA,CAAKC,SAAS,CAAC;UAAEnD,IAAA;UAAMuB;QAAoB,KAKjDb,UAAA;uBAEH+C,IAAA,CAACnF,qBAAA;QACCoF,eAAA,EAAiB9C,WAAA;QACjB+C,QAAA,eAAUF,IAAA,CAACtF,gBAAA;UAAiBuB,WAAA,EAAaA,WAAA;UAAaM,IAAA,EAAMA;;;;KAvBpCwC,iBAAA;AA4BlC;AAEA,SAASoB,eAAe;EAAEK;AAAK,CAAoB;EACjD;EAEA,oBACEV,KAAA,CAAC;IAAI9D,SAAA,EAAU;IAAgByE,IAAA,EAAK;4BAClCT,IAAA,CAAC;gBAAE;qBACHA,IAAA,CAAC;MAAID,KAAA,EAAO;QAAEW,KAAA,EAAO;MAAM;gBAAIF,KAAA,CAAMG;;;AAG3C;AAEA,OAAO,MAAMC,QAAA,GAAqCjF,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"Field.js","names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","dequal","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","parse","stringify","Date","Object","is","_jsxs","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","composerKey","fieldProps","onChange","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport { dequal } from 'dequal/lite'\nimport { type Validate } from 'payload'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary.\n // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,\n // so we need to do a deep equality check here that does not care about key order => we use dequal.\n // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.\n if (\n prevValueRef.current !== value &&\n !dequal(JSON.parse(JSON.stringify(prevValueRef.current)), value)\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"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","ignoreList":[]}