PageSourceSearch

https://www.smartcms.ai/_next/static/chunks/9713.0a3f4a8435eb78af.js

js smartcms.ai collected 2026-10-05 15:00:30 UTC 72,163 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9713],{24319:()=>{},40173:(e,t,a)=>{"use strict";a.d(t,{I:()=>s,a:()=>d});var r=a(95155),l=a(12115);let n=(0,l.createContext)(null);function s(e){let{value:t,children:a}=e;return(0,r.jsx)(n.Provider,{value:t,children:a})}function d(){return(0,l.useContext)(n)}},71693:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>eZ});var r=a(95155),l=a(12115),n=a(65361),s=a(88125),d=a(10874),i=a(22544),o=a(45517),c=a(50800),u=a(76908),g=a(4435),m=a(77004),x=a(63660),b=a(19148),h=a(43419),p=a(31363),y=a(55404),f=a(67327),v=a(85210),k=a(12338),j=a(78336),N=a(79371),w=a(22984);a(24319);var C=a(75940),A=a(48656),I=a(1831),S=a(3028),T=a(45021),L=a(18121),R=a(70898);let E=e=>{var t,a,n,s,d,i,o,c,u,g;let{editor:m,richtextSettings:x,disabled:b}=e,h=(0,S.bs)(),[p,y]=(0,l.useState)(!1),[f,v]=(0,l.useState)(""),[k,j]=(0,l.useState)(!1),[N,w]=(0,l.useState)(""),[E,D]=(0,l.useState)(""),[M,F]=(0,l.useState)(null),[O,P]=(0,l.useState)(!1),[W,q]=(0,l.useState)(null);(0,l.useEffect)(()=>{p&&(null==m?void 0:m.isActive("link"))?v(m.getAttributes("link").href||""):p&&v("")},[p,m]);let H=(0,l.useCallback)(()=>{""===f?null==m||m.chain().focus().extendMarkRange("link").unsetLink().run():null==m||m.chain().focus().extendMarkRange("link").setLink({href:f}).run(),y(!1)},[m,f]),_=(0,l.useCallback)(()=>{v((null==m?void 0:m.getAttributes("link").href)||""),q(null),y(!0)},[m]),B=(0,l.useCallback)(()=>{y(!1),q(null)},[]),U=(0,l.useCallback)(e=>{null==m||m.chain().focus().extendMarkRange("link").setLinkWithRefs({href:"#",recordId:e,assetId:null}).run(),B()},[m,B]),z=(0,l.useCallback)(e=>{null==m||m.chain().focus().extendMarkRange("link").setLinkWithRefs({href:e.url,assetId:e.id,recordId:null}).run(),B()},[m,B]),K=(0,l.useCallback)(e=>{"string"==typeof e&&m&&m.commands.insertEmbeddedRecord({recordId:e,display:null!=M?M:"block"}),F(null)},[m,M]),J=(0,l.useCallback)(e=>{null==m||m.commands.insertEmbeddedAsset({assetId:e.id}),P(!1)},[m]),V=(0,l.useCallback)(()=>{N&&m&&m.commands.setImage({src:N,alt:E}),j(!1),w(""),D("")},[m,N,E]),G=(0,l.useCallback)(()=>{w(""),D(""),j(!0)},[]),Y=null==x||null==(a=x.embeds)||null==(t=a.assetBlock)?void 0:t.linkMimetypeGroups,Z=JSON.stringify(null!=Y?Y:null),X=(0,l.useMemo)(()=>{if(!Y||0===Y.length)return;let{patterns:e}=(0,L.Pb)(Y);return e.length>0?e:void 0},[Z]);if(!m)return null;let $=(0,T.WW)(x,"bold"),Q=(0,T.WW)(x,"italic"),ee=(0,T.WW)(x,"strike"),et=(0,T.WW)(x,"underline"),ea=(0,T.WW)(x,"superscript"),er=(0,T.WW)(x,"subscript"),el=(0,T.fc)(x,"heading",{level:1}),en=(0,T.fc)(x,"heading",{level:2}),es=(0,T.fc)(x,"heading",{level:3}),ed=(0,T.fc)(x,"bulletList"),ei=(0,T.fc)(x,"orderedList"),eo=(0,T.fc)(x,"blockquote"),ec=(0,T.fc)(x,"horizontalRule"),eu=(0,T.fc)(x,"table"),eg=(0,T.fc)(x,"embeddedRecordBlock"),em=(0,T.fc)(x,"embeddedRecordInline"),ex=(0,T.fc)(x,"embeddedAsset"),eb=(0,T.fc)(x,"link",{}),eh=(0,T.fc)(x,"link",{recordId:"placeholder"}),ep=(0,T.fc)(x,"link",{assetId:"placeholder"}),ey=eb||eh||ep,ef=!!((null==x?void 0:x.enabledMarks)||(null==x?void 0:x.enabledNodeTypes)),ev=[...null!=(u=null==x?void 0:x.enabledMarks)?u:[],...null!=(g=null==x?void 0:x.enabledNodeTypes)?g:[]],ek=ef?(0,T.LF)(m.getJSON(),x):{marks:[],nodes:[]},ej=[...ek.marks,...ek.nodes],eN=e=>"p-2 rounded hover:bg-gray-200 dark:hover:bg-gray-700 ".concat(e?"bg-gray-200 dark:bg-gray-700 text-blue-500 dark:text-blue-400":"text-gray-700 dark:text-gray-300");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b border-gray-300 dark:border-gray-700 mb-2",children:(0,r.jsxs)("fieldset",{disabled:b,className:"contents",children:[$&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleBold().run(),disabled:!m.can().chain().focus().toggleBold().run(),className:eN(m.isActive("bold")),title:"Bold",children:(0,r.jsx)(R.ljE,{})}),Q&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleItalic().run(),disabled:!m.can().chain().focus().toggleItalic().run(),className:eN(m.isActive("italic")),title:"Italic",children:(0,r.jsx)(R._Me,{})}),ee&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleStrike().run(),disabled:!m.can().chain().focus().toggleStrike().run(),className:eN(m.isActive("strike")),title:"Str
1ikethrough",children:(0,r.jsx)(R.RPD,{})}),et&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleUnderline().run(),disabled:!m.can().chain().focus().toggleUnderline().run(),className:eN(m.isActive("underline")),"aria-label":"Underline",title:"Underline",children:(0,r.jsx)(R.INR,{})}),ea&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleSuperscript().run(),disabled:!m.can().chain().focus().toggleSuperscript().run(),className:eN(m.isActive("superscript")),"aria-label":"Superscript",title:"Superscript",children:(0,r.jsx)(R.OwI,{})}),er&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleSubscript().run(),disabled:!m.can().chain().focus().toggleSubscript().run(),className:eN(m.isActive("subscript")),"aria-label":"Subscript",title:"Subscript",children:(0,r.jsx)(R.xAi,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().setParagraph().run(),className:eN(m.isActive("paragraph")),title:"Paragraph",children:(0,r.jsx)(R.Wti,{})}),el&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleHeading({level:1}).run(),className:eN(m.isActive("heading",{level:1})),title:"Heading 1",children:"H1"}),en&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleHeading({level:2}).run(),className:eN(m.isActive("heading",{level:2})),title:"Heading 2",children:"H2"}),es&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleHeading({level:3}).run(),className:eN(m.isActive("heading",{level:3})),title:"Heading 3",children:"H3"}),ed&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleBulletList().run(),className:eN(m.isActive("bulletList")),title:"Bullet List",children:(0,r.jsx)(R.v5n,{})}),ei&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleOrderedList().run(),className:eN(m.isActive("orderedList")),title:"Ordered List",children:(0,r.jsx)(R.lfF,{})}),eo&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleBlockquote().run(),className:eN(m.isActive("blockquote")),title:"Blockquote",children:(0,r.jsx)(R.JwJ,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleCodeBlock().run(),className:eN(m.isActive("codeBlock")),title:"Code Block",children:(0,r.jsx)(R.FSj,{})}),ec&&(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().setHorizontalRule().run(),className:eN(),title:"Horizontal Rule",children:(0,r.jsx)(R.iu5,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().unsetAllMarks().clearNodes().run(),className:eN(),title:"Clear Format",children:(0,r.jsx)(R.Gml,{})}),ey&&(0,r.jsx)("button",{type:"button",onClick:_,className:eN(m.isActive("link")),title:"Set/Edit Link",children:(0,r.jsx)(R.AnD,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().unsetLink().run(),disabled:!m.isActive("link"),className:eN(),title:"Unlink",children:(0,r.jsx)(R.fSB,{})}),(0,r.jsx)("button",{type:"button",onClick:G,className:eN(),title:"Add Image",children:(0,r.jsx)(R.dkL,{})}),eg&&(0,r.jsx)("button",{type:"button",onClick:()=>F("block"),disabled:!h,className:eN(),title:h?"Embed record":"No editor scope available",children:(0,r.jsx)(R.yRn,{})}),em&&(0,r.jsx)("button",{type:"button",onClick:()=>F("inline"),disabled:!h,className:eN(),title:h?"Embed record inline":"No editor scope available",children:(0,r.jsx)(R.FrV,{})}),ex&&(0,r.jsx)("button",{type:"button",onClick:()=>P(!0),disabled:!h,className:eN(),title:h?"Embed asset":"No editor scope available",children:(0,r.jsx)(R.EHs,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().setTextAlign("left").run(),className:eN(m.isActive({textAlign:"left"})),title:"Align Left",children:(0,r.jsx)(R.E7i,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().setTextAlign("center").run(),className:eN(m.isActive({textAlign:"center"})),title:"Align Center",children:(0,r.jsx)(R.qAe,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().setTextAlign("right").run(),className:eN(m.isActive({textAlign:"right"})),title:"Align Right",children:(0,r.jsx)(R.v$9,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().setTextAlign("justify").run(),className:eN(m.isActive({textAlign:"justify"})),title:"Align Justify",children:(0,r.jsx)(R.f08,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().toggleTaskList().run(),className:eN(m.isActive("taskList")),title:"Task List",children:(0,r.jsx)(R.w8j,{})}),eu&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>m.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),className:eN(),title:"Insert Table",children:(0,r.jsx)(R.ist,{})}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().addColumnBefore().run(),disabled:!m.can().addColumnBefore(),className:eN(),title:"Add Column Before",children:[(0,r.jsx)(R.vgu,{className:"transform -rotate-90"})," "]}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().addColumnAfter().run(),disabled:!m.can().addColumnAfter(),className:eN(),title:"Add Column After",children:[(0,r.jsx)(R.vgu,{})," "]}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().deleteColumn().run(),disabled:!m.can().deleteColumn(),className:eN(),title:"Delete Column",children:[(0,r.jsx)(R.RCe,{className:"text-red-500"})," "]}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().addRowBefore().run(),disabled:!m.can().addRowBefore(),className:eN(),title:"Add Row Before",children:[(0,r.jsx)(R.QhK,{className:"transform -rotate-90"})," "]}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().addRowAfter().run(),disabled:!m.can().addRowAfter(),className:eN(),title:"Add Row After",children:[(0,r.jsx)(R.QhK,{})," "]}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().deleteRow().run(),disabled:!m.can().deleteRow(),className:eN(),title:"Delete Row",children:[(0,r.jsx)(R.RCe,{className:"text-red-500"})," "]}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().deleteTable().run(),disabled:!m.can().deleteTable(),className:eN(),title:"Delete Table",children:[(0,r.jsx)(R.ist,{className:"text-red-500"})," ",(0,r.jsx)(R.RCe,{className:"text-red-500 text-xs"})," "]}),(0,r.jsxs)("button",{type:"button",onClick:()=>m.chain().focus().toggleHeaderCell().run(),disabled:!m.can().toggleHeaderCell(),className:eN(m.isActive("headerCell")),title:"Toggle Header Cell",children:[(0,r.jsx)(R.qgn,{})," "]})]})]})}),(ef||ej.length>0)&&(0,r.jsxs)("div",{className:"px-2 pb-2 -mt-1.5 space-y-0.5",children:[ef&&(0,r.jsxs)("p",{"data-testid":"richtext-allowed-hint",className:"text-xs text-gray-500 dark:text-gray-400",children:["This field allows: ",ev.join(", ")
1]}),ej.length>0&&(0,r.jsxs)("p",{"data-testid":"richtext-disallowed-hint",className:"text-xs text-amber-600 dark:text-amber-400",children:["Contains formatting this field no longer allows:"," ",ej.join(", ")]})]}),p&&(0,r.jsx)(C.A,{isOpen:p,onClose:B,title:"Set/Edit Link URL",size:"sm",children:(0,r.jsxs)("div",{className:"space-y-4",children:[eb&&(0,r.jsx)("input",{type:"url",autoFocus:!0,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"https://example.com",value:f,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),H())}}),(eh||ep)&&(0,r.jsxs)("div",{className:"flex gap-2 text-sm",children:[eh&&(0,r.jsx)("button",{type:"button",onClick:()=>q("record"),disabled:!h,title:h?void 0:"No editor scope available",className:"px-2.5 py-1 rounded-md border border-dashed border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 disabled:opacity-50 disabled:cursor-not-allowed",children:"Link to record"}),ep&&(0,r.jsx)("button",{type:"button",onClick:()=>q("asset"),disabled:!h,title:h?void 0:"No editor scope available",className:"px-2.5 py-1 rounded-md border border-dashed border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 disabled:opacity-50 disabled:cursor-not-allowed",children:"Link to asset"})]}),(0,r.jsxs)("div",{className:"flex justify-end space-x-2",children:[(0,r.jsx)("button",{type:"button",onClick:B,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-md hover:bg-gray-200 dark:text-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Cancel"}),eb&&(0,r.jsx)("button",{type:"button",onClick:H,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Save Link"})]})]})}),p&&"record"===W&&h&&(0,r.jsx)(C.A,{isOpen:!0,onClose:()=>q(null),title:"Link to record",size:"lg",children:(0,r.jsx)(A.A,{value:null,onChange:e=>{"string"==typeof e&&U(e)},multi:!1,linkContentTypes:null==x||null==(s=x.embeds)||null==(n=s.entryHyperlink)?void 0:n.linkContentTypes,spaceId:h.spaceId,environmentId:h.environmentId})}),p&&"asset"===W&&h&&(0,r.jsx)(I.A,{isOpen:!0,onClose:()=>q(null),onSelect:z,spaceId:h.spaceId,title:"Link to asset"}),M&&h&&(0,r.jsx)(C.A,{isOpen:!0,onClose:()=>F(null),title:"inline"===M?"Embed record inline":"Embed record",size:"lg",children:(0,r.jsx)(A.A,{value:null,onChange:K,multi:!1,linkContentTypes:"inline"===M?null==x||null==(i=x.embeds)||null==(d=i.entryInline)?void 0:d.linkContentTypes:null==x||null==(c=x.embeds)||null==(o=c.entryBlock)?void 0:o.linkContentTypes,spaceId:h.spaceId,environmentId:h.environmentId})}),O&&h&&(0,r.jsx)(I.A,{isOpen:O,onClose:()=>P(!1),onSelect:J,spaceId:h.spaceId,title:"Embed asset",allowedMimeTypes:X}),k&&(0,r.jsx)(C.A,{isOpen:k,onClose:()=>j(!1),title:"Add Image from URL",size:"md",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"imageUrl",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Image URL"}),(0,r.jsx)("input",{type:"url",id:"imageUrl",autoFocus:!0,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"https://example.com/image.jpg",value:N,onChange:e=>w(e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"imageAlt",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Alt Text (Optional)"}),(0,r.jsx)("input",{type:"text",id:"imageAlt",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Descriptive text for the image",value:E,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),V())}})]}),(0,r.jsxs)("div",{className:"flex justify-end space-x-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>j(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-md hover:bg-gray-200 dark:text-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:V,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Add Image"})]})]})})]})},D=a(56135).Ay.extend({addAttributes(){var e;return{...null==(e=this.parent)?void 0:e.call(this),recordId:{default:null,parseHTML:e=>e.getAttribute("data-record-id"),renderHTML:e=>e.recordId?{"data-record-id":e.recordId}:{}},assetId:{default:null,parseHTML:e=>e.getAttribute("data-asset-id"),renderHTML:e=>e.assetId?{"data-asset-id":e.assetId}:{}}}},addCommands(){var e;
1return{...null==(e=this.parent)?void 0:e.call(this),setLinkWithRefs:e=>t=>{let{commands:a}=t;return a.setMark(this.name,e)}}}});var M=a(52619),F=a.n(M),O=a(22454),P=a(71155),W=a(52704),q=a(9554),H=a(97782),_=a(3906);async function B(e){let t=await fetch("/api/cms/content-records/".concat(e));return t.ok?t.json():null}function U(e){var t,a,l;let{node:n,deleteNode:s,selected:d,editor:i}=e,o=n.attrs.recordId,u="embeddedRecordInline"===n.type.name,g=(0,S.bs)(),{data:m,isLoading:x}=(0,O.I)({queryKey:["referenced-record",o],queryFn:()=>B(o),enabled:!!o&&!!g,staleTime:6e4}),b=!!g&&!x&&null===m,h=(null==m||null==(t=m.contentType)?void 0:t.fields)||[],p=m?(0,H.i4)(m,h,{defaultLocale:m.defaultLocale}):null,y=(null==m||null==(a=m.contentType)?void 0:a.displayName)||(null==m||null==(l=m.contentType)?void 0:l.name),f=g?(0,_.sp)(o,g.uiLocale,g.spaceId,g.environmentId):void 0,v=g?b?"Record not found":null!=p?p:"Loading…":o,k=u?"inline-flex items-center gap-1.5 align-middle px-2 py-0.5 mx-0.5 rounded-md border text-sm ".concat(d?"ring-2 ring-blue-500 border-blue-400":"border-gray-300 dark:border-gray-600"," ").concat(b?"bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 border-red-300 dark:border-red-700":"bg-blue-50 dark:bg-blue-950/40 text-blue-800 dark:text-blue-200"):"not-prose flex items-center gap-3 px-3 py-2.5 my-2 rounded-lg border ".concat(d?"ring-2 ring-blue-500 border-blue-400":"border-gray-200 dark:border-gray-700"," ").concat(b?"bg-red-50 dark:bg-red-950 border-red-300 dark:border-red-700":"bg-gray-50 dark:bg-gray-800");return(0,r.jsxs)(c.VR,{as:u?"span":"div","data-record-id":o,"data-testid":u?"embedded-record-inline":"embedded-record-block",contentEditable:!1,className:k,children:[!u&&(0,r.jsx)(P.A,{className:"h-5 w-5 flex-shrink-0 text-gray-400 dark:text-gray-500"}),f?(0,r.jsxs)(F(),{href:f,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),"aria-label":"Open ".concat(v," in new tab"),className:"inline-flex items-center gap-1 font-medium hover:underline ".concat(b?"text-red-700 dark:text-red-300":"text-gray-900 dark:text-gray-100"),children:[v,!b&&(0,r.jsx)(W.A,{className:"w-3.5 h-3.5 text-gray-400"})]}):(0,r.jsx)("span",{className:"font-mono text-xs ".concat(b?"text-red-700 dark:text-red-300":"text-gray-700 dark:text-gray-300"),children:v}),!u&&y&&(0,r.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:y}),(0,r.jsx)("button",{type:"button",disabled:!i.isEditable,onClick:()=>{i.isEditable&&s()},className:"ml-auto text-gray-400 hover:text-red-500 flex-shrink-0",title:"Remove embedded record","aria-label":"Remove embedded record",children:(0,r.jsx)(q.A,{className:"w-4 h-4"})})]})}var z=a(51876);function K(e,t){let a=e.selection;if(!(a instanceof z.nh))return;let r=a.to,l=r<e.doc.content.size?z.LN.near(e.doc.resolve(r),1):null;if(l&&!(l instanceof z.nh))return void e.setSelection(l);let n=t.nodes.paragraph;if(n){e.insert(r,n.create()),e.setSelection(z.U3.near(e.doc.resolve(r+1)));return}e.setSelection(null!=l?l:z.LN.near(e.doc.resolve(r),1))}let J=u.bP.create({name:"embeddedRecordBlock",group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes:()=>({recordId:{default:null,parseHTML:e=>e.getAttribute("data-record-id"),renderHTML:e=>e.recordId?{"data-record-id":e.recordId}:{}}}),parseHTML:()=>[{tag:"div[data-embedded-record]"}],renderHTML(e){let{HTMLAttributes:t}=e;return["div",(0,u.KV)(t,{"data-embedded-record":""})]},addNodeView:()=>(0,c.gu)(U),addCommands:()=>({insertEmbeddedRecord:e=>t=>{let{chain:a,editor:r}=t,l="inline"===e.display?"embeddedRecordInline":"embeddedRecordBlock";return a().insertContent({type:l,attrs:{recordId:e.recordId}}).command(e=>{let{tr:t}=e;return K(t,r.schema),!0}).run()}})}),V=u.bP.create({name:"embeddedRecordInline",group:"inline",inline:!0,atom:!0,draggable:!0,selectable:!0,addAttributes:()=>({recordId:{default:null,parseHTML:e=>e.getAttribute("data-record-id"),renderHTML:e=>e.recordId?{"data-record-id":e.recordId}:{}}}),parseHTML:()=>[{tag:"span[data-embedded-record-inline]"}],renderHTML(e){let{HTMLAttributes:t}=e;return["span",(0,u.KV)(t,{"data-embedded-record-inline":""})]},addNodeView:()=>(0,c.gu)(U)});var G=a(34065),Y=a(94534),Z=a(76381);async function X(e){let t=await fetch("/api/cms/assets/".concat(e));return t.ok?t.json():null}function $(e){var t,a,l;let{node:n,deleteNode:s,selected:d,editor:i}=e,o=n.attrs.assetId,u=(0,S.bs)(),{activeLocale:g}=(0,Z.PZ)(),{data:m,isLoading:x}
1=(0,O.I)({queryKey:["cms-asset",o],queryFn:()=>X(o),enabled:!!o&&!!u,staleTime:6e4}),b=!!u&&!x&&null===m,h=m?null!=(l=null==(t=m.files)?void 0:t[g])?l:m:void 0,p=!!(null==h||null==(a=h.contentType)?void 0:a.startsWith("image/")),y="not-prose relative my-2 rounded-lg border overflow-hidden ".concat(d?"ring-2 ring-blue-500 border-blue-400":"border-gray-200 dark:border-gray-700"," ").concat(b?"border-red-300 dark:border-red-700":"");return(0,r.jsxs)(c.VR,{as:"div","data-asset-id":o,"data-testid":"embedded-asset",contentEditable:!1,className:y,children:[(0,r.jsx)("button",{type:"button",disabled:!i.isEditable,onClick:()=>{i.isEditable&&s()},className:"absolute top-2 right-2 z-10 p-1 rounded-full bg-white/90 dark:bg-gray-900/90 text-gray-500 hover:text-red-500 shadow",title:"Remove embedded asset","aria-label":"Remove embedded asset",children:(0,r.jsx)(q.A,{className:"w-4 h-4"})}),!u||x?(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-4 text-sm text-gray-500 dark:text-gray-400",children:[(0,r.jsx)(P.A,{className:"h-5 w-5 flex-shrink-0"}),u?"Loading…":o]}):b?(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-4 text-sm text-red-700 dark:text-red-300 bg-red-50 dark:bg-red-950",children:[(0,r.jsx)(P.A,{className:"h-5 w-5 flex-shrink-0"}),"Asset not found"]}):p?(0,r.jsx)("img",{src:function(e,t){var a;let r=(()=>{try{return new URL(e).pathname.split("/").filter(Boolean)}catch(e){return[]}})(),l=null!=(a=r[0])?a:"",n=r.slice(1).join("/");return(0,Y.uq)("https://cdn.smartcms.ai/".concat(l,"/").concat(n),{preset:"preview",focal:(0,Y._X)(t)})}(h.url,m),alt:m.altText||m.title||h.filename,className:"block max-h-80 w-full object-contain bg-gray-50 dark:bg-gray-900"}):(0,r.jsxs)("a",{href:h.url,download:!0,onClick:e=>e.stopPropagation(),className:"flex items-center gap-2 px-3 py-3 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-800",children:[(0,r.jsx)(P.A,{className:"h-5 w-5 flex-shrink-0 text-gray-400"}),(0,r.jsx)("span",{className:"truncate",children:m.title||h.filename}),(0,r.jsx)(G.A,{className:"h-4 w-4 flex-shrink-0 text-gray-400 ml-auto"})]})]})}let Q=u.bP.create({name:"embeddedAsset",group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes:()=>({assetId:{default:null,parseHTML:e=>e.getAttribute("data-asset-id"),renderHTML:e=>e.assetId?{"data-asset-id":e.assetId}:{}}}),parseHTML:()=>[{tag:"div[data-embedded-asset]"}],renderHTML(e){let{HTMLAttributes:t}=e;return["div",(0,u.KV)(t,{"data-embedded-asset":""})]},addNodeView:()=>(0,c.gu)($),addCommands(){return{insertEmbeddedAsset:e=>t=>{let{chain:a,editor:r}=t;return a().insertContent({type:this.name,attrs:e}).command(e=>{let{tr:t}=e;return K(t,r.schema),!0}).run()}}}}),ee=new Set(["embeddedRecordBlock","embeddedRecordInline","embeddedAsset"]);function et(e){return e instanceof z.nh&&ee.has(e.node.type.name)}let ea=u.YY.create({name:"embedNodeSelectionGuard",addProseMirrorPlugins:()=>[new z.k_({key:new z.hs("embedNodeSelectionGuard"),props:{handleTextInput(e,t,a,r){let{state:l}=e;if(!et(l.selection))return!1;let n=l.tr;return K(n,l.schema),n.insertText(r,n.selection.from,n.selection.to),e.dispatch(n),!0},handleKeyDown(e,t){if("Enter"!==t.key||t.shiftKey||t.ctrlKey||t.metaKey||t.altKey)return!1;let{state:a}=e;if(!et(a.selection))return!1;let r=a.tr;K(r,a.schema);let l=r.selection.from;return"paragraph"===r.doc.resolve(l).parent.type.name&&r.split(l),e.dispatch(r.scrollIntoView()),!0},handlePaste(e,t,a){let{state:r}=e;if(!et(r.selection))return!1;let l=r.tr;return K(l,r.schema),l.replaceSelection(a),e.dispatch(l.scrollIntoView()),!0}}})]}),er=u.YY.create({name:"readOnlyGuard",addProseMirrorPlugins(){let e=this;return[new z.k_({key:new z.hs("readOnlyGuard"),filterTransaction:t=>!t.docChanged||!0===t.getMeta("preventUpdate")||e.editor.isEditable})]}});var el=a(92322);function en(e,t){return"link"===e.type.name?(0,T.fc)(t,"link",e.attrs):(0,T.WW)(t,e.type.name)}let es=u.YY.create({name:"richtextRestrictions",addOptions:()=>({settings:void 0}),addProseMirrorPlugins(){let e=this.options;return[new z.k_({key:new z.hs("richtextRestrictions"),props:{transformPasted:(t,a)=>{let{settings:r}=e;
1if(!(null==r?void 0:r.enabledMarks)&&!(null==r?void 0:r.enabledNodeTypes))return t;let l=a.state.schema,n=[];return t.content.forEach(e=>{n.push(...function e(t,a,r){if(t.isText){let e=t.marks.filter(e=>en(e,r));return[t.mark(e)]}if(!(0,T.fc)(r,t.type.name,t.attrs)){let l=[];return!function t(a,r,l,n){if(a.inlineContent){let t=[];a.content.forEach(a=>{t.push(...e(a,r,l))}),t.length>0&&n.push(r.nodes.paragraph.create(null,el.FK.fromArray(t)));return}0!==a.content.size&&a.content.forEach(e=>{t(e,r,l,n)})}(t,a,r,l),l}let l=[];t.content.forEach(t=>{l.push(...e(t,a,r))});let n=t.marks.filter(e=>en(e,r));return[t.copy(el.FK.fromArray(l)).mark(n)]}(e,l,r))}),new el.Ji(el.FK.fromArray(n),0,0)}},filterTransaction:(t,a)=>{if(!t.docChanged||!0===t.getMeta("preventUpdate"))return!0;let{settings:r}=e;if(!(null==r?void 0:r.enabledMarks)&&!(null==r?void 0:r.enabledNodeTypes))return!0;let l=(0,T.W)(a.doc.toJSON(),r);return(0,T.W)(t.doc.toJSON(),r)<=l}})]}}),ed=[g.A.configure({}),m.A.configure({placeholder:"Start typing..."}),D.configure({openOnClick:!1,autolink:!0}),x.Ay.configure({}),b.A.configure({types:["heading","paragraph"]}),h.A,p.A,y.A,f.A,v.Ay.configure({nested:!0}),k.Ay.configure({resizable:!0}),j.A,N.h,w.A,J,V,Q,ea,er],ei=(0,u._w)(ed);function eo(e,t){if(!t||"string"==typeof t)return!0;try{return e.nodeFromJSON(t).check(),!0}catch(e){return!1}}let ec=e=>{let{field:t,initialContent:a,disabled:n=!1,ariaLabelledBy:s,fieldId:d,richtextSettings:i}=e,[o,u]=l.useState(()=>!eo(ei,t.value||a||"")),g=t.value||a||"",m=JSON.stringify(null!=i?i:null),x=l.useMemo(()=>[...ed,es.configure({settings:i})],[m]),b=(0,c.hG)({extensions:x,content:o?"":g,editable:!n&&!o,immediatelyRender:!1,enableContentCheck:!0,onContentError:()=>u(!0),editorProps:{attributes:{class:"prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl focus:outline-none h-full",...d?{id:d}:{},...s?{"aria-labelledby":s}:{}}},onUpdate:e=>{let{editor:a}=e;if(o||n)return;let r=a.getJSON();t.onChange(r)}},[n,o,m]);return(l.useEffect(()=>{if(b&&t.value){if(!b.isFocused){if(!eo(b.schema,t.value))return void u(!0);o&&u(!1),JSON.stringify(b.getJSON())!==JSON.stringify(t.value)&&b.commands.setContent(t.value,!1)}}else b&&!t.value&&(o&&u(!1),b.commands.clearContent(!1))},[t.value,b,o]),b)?(0,r.jsxs)("div",{className:"tiptap-editor-wrapper border border-gray-300 dark:border-gray-700 rounded-md flex flex-col",style:{resize:"vertical",overflow:"auto",minHeight:"300px",height:"480px"},children:[o&&(0,r.jsx)("div",{role:"alert","data-testid":"richtext-content-error",className:"m-2 p-3 rounded-md border border-red-300 bg-red-50 text-red-800 dark:border-red-700 dark:bg-red-950 dark:text-red-200 text-sm",children:"This field contains content the editor cannot display. The stored value is left untouched and editing is locked until the field holds a value the editor can read."}),b&&(0,r.jsx)(E,{editor:b,richtextSettings:i,disabled:n||o}),(0,r.jsxs)("div",{className:"flex-grow overflow-y-auto bg-white dark:bg-gray-800 relative",children:[" ",b&&!n&&(0,r.jsxs)(c.mM,{editor:b,tippyOptions:{duration:100,placement:"top-start"},className:"bubble-menu flex items-center gap-1 bg-gray-800 dark:bg-gray-900 text-white p-2 rounded-md shadow-lg border border-gray-700 dark:border-gray-600",children:[(0,T.WW)(i,"bold")&&(0,r.jsx)("button",{onClick:()=>b.chain().focus().toggleBold().run(),className:"p-1 rounded hover:bg-gray-700 dark:hover:bg-gray-800 ".concat(b.isActive("bold")?"is-active bg-gray-700 dark:bg-gray-800":""),title:"Bold",children:(0,r.jsx)(R.ljE,{size:16})}),(0,T.WW)(i,"italic")&&(0,r.jsx)("button",{onClick:()=>b.chain().focus().toggleItalic().run(),className:"p-1 rounded hover:bg-gray-700 dark:hover:bg-gray-800 ".concat(b.isActive("italic")?"is-active bg-gray-700 dark:bg-gray-800":""),title:"Italic",children:(0,r.jsx)(R._Me,{size:16})}),(0,T.WW)(i,"underline")&&(0,r.jsx)("button",{onClick:()=>b.chain().focus().toggleUnderline().run(),className:"p-1 rounded hover:bg-gray-700 dark:hover:bg-gray-800 ".concat(b.isActive("underline")?"is-active bg-gray-700 dark:bg-gray-800":""),title:"Underline",children:(0,r.jsx)(R.INR,{size:16})}),(0,T.WW)(i,"superscript")&&(0,r.jsx)("button",{onClick:()=>b.chain().focus().toggleSuperscript().run(),className:"p-1 rounded hover:bg-gray-700 dark:hover:bg-gray-800 ".concat(b.isActive("superscript")?"is-active bg-gray-700 dark:bg-gray-800":""),title:"Superscript",children:(0,r.jsx)(R.OwI,{size:16})}),(0,T.WW)(i,"subscript")&&(0,r.jsx)("button",{onClick:()=>b.chain().focus().toggleSubscript().run(),className:"p-1 rounded hover:bg-gray-700 dark:hover:bg-gray-800 ".concat(b.isActive("subscript")?"is-active bg-gray-700 dark:bg-gray-800":""),title:"Subscript",children:(0,r.jsx)(R.xAi,{size:16})}),(0,T.fc)(i,"link",{})&&(0,r.jsx)("button",{onClick:()=>{let e=b.getAttributes("link").href,t=window.prompt("Enter URL",e);if(null!==t){if(""===t)return void b.chain().focus().extendMarkRange("link").unsetLink().run();b.chain().focus().extendMarkRange("link").setLink({href:t}).run()}},className:"p-1 rounded hover:bg-gray-700 dark:hover:bg-gray-800 ".concat(b.isActive("link")?"is-active bg-gray-700 dark:bg-gray-800":""),title:"Link",children:(0,r.jsx)(R.AnD,{size:16})})]}),(0,r.jsx)(c.$Z,{editor:b,disabled:n,className:"h-full"})]})]}):null};var eu=a(15239),eg=a(57218),em=a(96059),ex=a(41444),eb=a(20063),eh=a(71406),ep=a(22163);let ey=e=>{let{thumbUrl:t,fallbackUrl:a,alt:n,onClick:s,className:d}=e,[i,o]=l.useState(t),[c,u]=l.useState(!1);return(0,r.jsx)("div",{className:"relative w-full h-full ".concat(d||""),onClick:s,children:c?(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center cursor-pointer hover:opacity-80 transition-opacity",children:(0,r.jsx)("div",{className:"text-2xl",children:"\uD83D\uDDBC️"})}):(0,r.jsx)(eu.default,{src:i,alt:n,fill:!0,className:"object-cover cursor-pointer hover:opacity-80 transition-opacity",unoptimized:!0,onError:()=>{i!==a?o(a):u(!0)}})})},ef=e=>{var t,a,l;let{url:n,spaceId:s,onReplace:d,onEdit:i,onRemove:o}=e,{data:c}=(0,ep.Cl)(s,n),u=(e=>{var t;return["jpg","jpeg","png","gif","webp","svg"].includes((null==(t=e.split(".").pop())?void 0:t.toLowerCase())||"")?"image":"file"})(n),g=n.split("/").pop()||"Unknown file",{activeLocale:m}=(0,Z.PZ)(),x=null==c||null==(t=c.files)?void 0:t[m],b=null!=(l=null==x?void 0:x.url)?l:n;return(0,r.jsx)("div",{className:"relative border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden bg-white dark:bg-gray-800",children:(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"w-24 h-24 flex-shrink-0 bg-gray-100 dark:bg-gray-700 flex items-center justify-center",children:"image"===u?(()=>{let e="";try{var t;
1e=null!=(t=new URL(b).pathname.split("/").filter(Boolean)[0])?t:""}catch(e){}let a=(0,Y.ay)(b),l=(0,Y.uq)("https://cdn.smartcms.ai/".concat(e,"/").concat(a),{preset:"thumb",focal:(0,Y._X)(null!=c?c:{})});return(0,r.jsx)(ey,{thumbUrl:l,fallbackUrl:b,alt:g,onClick:i})})():(0,r.jsx)("div",{className:"text-2xl",children:"\uD83D\uDCC4"})}),(0,r.jsx)("div",{className:"flex-1 p-4 min-w-0",children:(0,r.jsxs)("div",{className:"flex items-start justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:g}),(0,r.jsxs)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["image"===u?"Image":"File"," •"," ",null==(a=n.split(".").pop())?void 0:a.toUpperCase()]}),x&&(0,r.jsxs)("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:["Showing ",m," variant"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ml-4",children:[(0,r.jsx)("button",{type:"button",onClick:d,className:"text-xs px-2 py-1 text-blue-600 hover:text-blue-700 hover:bg-blue-50 dark:text-blue-400 dark:hover:text-blue-300 dark:hover:bg-blue-900/20 rounded transition-colors",children:"Replace"}),(0,r.jsx)("button",{type:"button",onClick:i,className:"text-xs px-2 py-1 text-gray-600 hover:text-gray-700 hover:bg-gray-50 dark:text-gray-400 dark:hover:text-gray-300 dark:hover:bg-gray-700/50 rounded transition-colors",children:"Edit Details"}),(0,r.jsx)("button",{type:"button",onClick:o,className:"text-xs px-2 py-1 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20 rounded transition-colors",children:"Remove"})]})]})})]})})},ev=e=>{var t;let{fieldName:a,description:n,spaceId:s,filterType:d="",isDisabled:o=!1,multiple:c=!1}=e,{setValue:u,watch:g,formState:{errors:m}}=(0,i.xW)(),[x,b]=(0,l.useState)(!1),[h,p]=(0,l.useState)(null),[y,f]=(0,l.useState)(null),v=(0,eb.useParams)(),k=(null==v?void 0:v.locale)||"en",j=g(a),N=m[a],w=Array.isArray(j)?j.filter(e=>"string"==typeof e&&e.length>0):"string"==typeof j&&j.length>0?[j]:[],C=e=>{if(c)u(a,e,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0});else{var t;u(a,null!=(t=e[0])?t:"",{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})}},A=(0,r.jsx)(I.A,{isOpen:x,onClose:()=>{p(null),b(!1)},onSelect:e=>{c&&null===h?w.includes(e.url)||C([...w,e.url]):null!==h?C(w.map(t=>t===h?e.url:t)):C([e.url]),p(null),b(!1)},spaceId:s,filterType:d,title:"Select ".concat("image/*"===d?"Image":"Media")}),S=y?(0,r.jsx)(eh.A,{isOpen:!!y,onClose:()=>f(null),assetUrl:y,spaceId:s,currentLocale:k,onSave:e=>{ex.v.log("Asset updated:",e),f(null)}}):null,T=(0,r.jsxs)(r.Fragment,{children:[n&&(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n}),N&&(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:null==(t=N.message)?void 0:t.toString()})]}),L=(0,r.jsx)("div",{className:"\n        relative border-2 border-dashed rounded-lg p-8 text-center\n        ".concat(N?"border-red-300 dark:border-red-600 bg-red-50 dark:bg-red-900/10":"border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800/50","\n        ").concat(o?"opacity-50 cursor-not-allowed":"hover:border-gray-400 dark:hover:border-gray-500","\n        transition-colors\n      "),children:(0,r.jsx)("div",{className:"relative inline-block",children:(0,r.jsxs)("button",{type:"button",onClick:()=>{p(null),b(!0)},disabled:o,className:"\n            inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md transition-colors\n            ".concat(o?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600 shadow-sm","\n          "),children:[(0,r.jsx)(eg.A,{className:"w-4 h-4"}),"Add media",(0,r.jsx)(em.A,{className:"w-4 h-4"})]})})});return 0===w.length?(0,r.jsxs)("div",{className:"space-y-2",children:[L,T,A,S]}):(0,r.jsxs)("div",{className:"space-y-2",children:[w.map(e=>(0,r.jsx)(ef,{url:e,spaceId:s,onReplace:()=>{p(e),b(!0)},onEdit:()=>f(e),onRemove:()=>{C(w.filter(t=>t!==e))}},e)),c&&!o&&L,T,A,S]})};var ek=a(73511),ej=a(84875),eN=a(78207),ew=a(49537),eC=a(53866),eA=a(37819),eI=a(66786);function eS(e){let{fields:t,isDisabled:a}=e;return l.Fragment,(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)(eI.A,{fields:t.map((e,t)=>{var a,r;return{id:null!=(a=e.id)?a:"".concat(e.name,"-").concat(t),name:e.name,type:e.type,required:null!=(r=e.required)&&r,...e}}),isDisabled:a})})}let eT=function(e){let{item:t,index:a,parentRhfPath:n,draggableProvided:s,onDuplicate:d,onDelete:i,isDisabled:o,depth:c,maxDepth:u}=e,[g,m]=(0,l.useState)(!1),x=t.__id.slice(0,8),b=(0,eA.wp)(t.__contentType),{activeLocale:h,defaultLocale:p,knownLocales:y}=(0,Z.PZ)(),f="".concat(n,".").concat(a,".data.");return(0,r.jsxs)("div",{ref:s.innerRef,...s.draggableProps,className:"rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm","data-testid":"blok-item-".concat(t.__id),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,r.jsx)("button",{type:"button",...s.dragHandleProps,"aria-label":"Drag handle for item ".concat(a+1),className:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-grab disabled:cursor-not-allowed disabled:opacity-40",disabled:o,children:(0,r.jsx)(eN.A,{className:"h-4 w-4"})}),(0,r.jsx)("button",{type:"button",onClick:()=>m(e=>!e),"aria-expanded":g,"aria-label":g?"Collapse item":"Expand item",className:"p-0.5 rounded text-gray-500 hover:text-gray-900 dark:hover:text-gray-100","data-testid":"blok-item-toggle-".concat(t.__id),children:g?(0,r.jsx)(em.A,{className:"h-4 w-4"}):(0,r.jsx)(ew.A,{className:"h-4 w-4"})}),(0,r.jsxs)("div",{className:"flex-1 flex items-baseline gap-2 min-w-0",children:[(0,r.jsxs)("span",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 shrink-0",children:["#",a+1]}),(0,r.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:t.__contentType}),(0,r.jsx)("span",{className:"text-[10px] font-mono text-gray-400 dark:text-gray-500 shrink-0",title:t.__id,children:x})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:d,disabled:o,"aria-label":"Duplicate item",className:"p-1 rounded text-gray-500 hover:text-gray-900 hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-gray-100 disabled:opacity-40 disabled:cursor-not-allowed",children:(0,r.jsx)(eC.A,{className:"h-4 w-4"})}),(0,r.jsx)("button",{type:"button",onClick:i,disabled:o,"aria-label":"Delete item",className:"p-1 rounded text-gray-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/30 dark:hover:text-red-300 disabled:opacity-40 disabled:cursor-not-allowed",children:(0,r.jsx)(q.A,{className:"h-4 w-4"})})]})]}),g&&(0,r.jsx)("div",{className:"px-3 pb-3 pt-1 border-t border-gray-100 dark:border-gray-700","data-testid":"blok-item-body-".concat(t.__id),children:null===b?(0,r.jsxs)("p",{className:"text-sm text-amber-700 dark:text-amber-300 italic",children:["ContentType ",(0,r.jsx)("code",{children:t.__contentType})," not found in this environment. Refresh, or remove this item."]}):0===b.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"This ContentType has no fields."}):(0,r.jsx)(Z.YO,{activeLocale:h,defaultLocale:p,knownLocales:y,pathPrefix:f,children:(0,r.jsx)(eS,{fields:b,isDisabled:o})})})]})},eL=(0,l.createContext)({depth:0,max:ej.m4});function eR(e){let{depth:t,max:a,children:n}=e,s=(0,l.useMemo)(()=>({depth:t,max:a}),[t,a]);return(0,r.jsx)(eL.Provider,{value:s,children:n})}let eE=function(e){var t,a;let{rhfPath:n,field:s,isDisabled:d}=e,{control:o}=(0,i.xW)(),{fields:c,append:u,remove:g,move:m,insert:x}=(0,i.jz)({control:o,name:n,keyName:"__rhfKey"}),[b,h]=(0,l.useState)(!1),p=(0,ej.du)({type:s.type,settings:s.settings}),y=null!=(t=null==p?void 0:p.allowedContentTypeNames)?t:[],f=null==p?void 0:p.minItems,v=null==p?void 0:p.maxItems,k=void 0!==v&&c.length>=v,j=(0,l.useContext)(eL),N=Math.min(j.max,null!=(a=null==p?void 0:p.maxDepth)?a:j.max),w=j.depth+1,C=w>N;if(!p)return(0,r.jsxs)("div",{className:"rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-900/20 dark:border-amber-700 p-3 text-sm text-amber-800 dark:text-amber-200",children:["This bloks field has no ",(0,r.jsx)("code",{children:"allowedContentTypeNames"}
1)," configured. Open the ContentType editor and pick at least one nested type before adding items."]});let A=d||k||C;return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"bloks-field-".concat(s.name),children:[(0,r.jsx)(eR,{depth:w,max:N,children:(0,r.jsx)(ek.JY,{onDragEnd:e=>{e.destination&&e.source.index!==e.destination.index&&m(e.source.index,e.destination.index)},children:(0,r.jsx)(ek.gL,{droppableId:"bloks-".concat(n),children:e=>(0,r.jsxs)("div",{ref:e.innerRef,...e.droppableProps,className:"space-y-2",children:[0===c.length?(0,r.jsx)("div",{className:"rounded-md border border-dashed border-gray-300 dark:border-gray-600 px-4 py-6 text-center text-sm text-gray-500 dark:text-gray-400",children:"No items yet. Add one with the button below."}):c.map((e,t)=>(0,r.jsx)(ek.sx,{draggableId:e.__rhfKey,index:t,isDragDisabled:!!d,children:a=>(0,r.jsx)(eT,{item:e,index:t,parentRhfPath:n,draggableProvided:a,onDuplicate:()=>(e=>{let{__rhfKey:t,...a}=c[e];x(e+1,(0,ej.Vc)(a))})(t),onDelete:()=>g(t),isDisabled:d,depth:w,maxDepth:N})},e.__rhfKey)),e.placeholder]})})})}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>h(e=>!e),disabled:A,className:"inline-flex items-center gap-1.5 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 shadow-sm hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"bloks-add-button","aria-expanded":b,"aria-haspopup":"menu",children:[(0,r.jsx)(eg.A,{className:"h-4 w-4"}),"Add item"]}),b&&!A&&(0,r.jsx)("div",{role:"menu",className:"absolute left-0 z-10 mt-1 w-64 rounded-md border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-lg py-1",children:y.map(e=>(0,r.jsx)("button",{type:"button",role:"menuitem",onClick:()=>{u((0,ej.KH)(e)),h(!1)},className:"block w-full text-left px-3 py-1.5 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700","data-testid":"bloks-add-option-".concat(e),children:e},e))})]}),(0,r.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[(0,r.jsxs)("span",{children:[c.length," item",1===c.length?"":"s"]}),(void 0!==f||void 0!==v)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",null!=f?f:0,"…",null!=v?v:"∞"," allowed)"]}),k&&(0,r.jsx)("span",{className:"ml-2 text-amber-700 dark:text-amber-300",children:"max reached"}),C&&(0,r.jsxs)("span",{className:"ml-2 text-amber-700 dark:text-amber-300",children:["max nesting depth (",N,") reached"]})]})]})]})};var eD=a(49824);let eM=[{value:"story",label:"Internal record"},{value:"url",label:"External URL"},{value:"email",label:"Email (mailto)"},{value:"asset",label:"Media asset"}],eF="w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800";function eO(e){var t,a,n,s,d,o,c,u,g;let{rhfPath:m,field:x,isDisabled:b,spaceId:h}=e,{setValue:p,watch:y,formState:f}=(0,i.xW)(),v=y(m),k=f.errors[m],{activeLocale:j,defaultLocale:N}=(0,Z.PZ)(),[w,C]=(0,l.useState)(!1),[I,S]=(0,l.useState)(!1),T=v&&"object"==typeof v?v:{},L="story"===T.kind||"url"===T.kind||"email"===T.kind||"asset"===T.kind?T.kind:"url";(0,l.useEffect)(()=>{(T.anchor&&T.anchor.length>0||T.newTab)&&S(!0)},[m]);let R=e=>p(m,e,{shouldDirty:!0}),E=e=>R({...T,...e,kind:L}),[D,M]=(0,l.useState)(null);return(0,l.useEffect)(()=>{var e;if(M(null),"story"!==L)return;let t=null==(e=T.recordId)?void 0:e.trim();if(!t||!h)return;let a=new AbortController;return(async()=>{try{var e,r,l;let n=await fetch("/api/cms/content-records/".concat(t,"?spaceId=").concat(h),{signal:a.signal});if(!n.ok)return;let s=await n.json(),d=null!=(e=null==s?void 0:s.data)?e:{},i=e=>{if("string"==typeof e&&e.trim().length>0)return e.trim();if(e&&"object"==typeof e&&!Array.isArray(e)){let t=e[j];if("string"==typeof t&&t.trim().length>0)return t.trim();let a=e[N];if("string"==typeof a&&a.trim().length>0)return a.trim()}return null},o=null!=(l=null!=(r=i(d.title))?r:i(d.name))?l:i(d.headline);o&&M(o)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name||e instanceof TypeError&&/failed to fetch/i.test(e.message))return}})(),()=>a.abort()},[L,T.recordId,h,j,N]),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("select",{id:"".concat(m,"-kind"),"data-testid":"multilink-kind-".concat(x.name),value:L,onChange:e=>{R({kind:e.target.value,...T.anchor?{anchor:T.anchor}:{},...T.newTab?{newTab:T.newTab}:{}})},disabled:b,className:"".concat(eF," ").concat(b?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),children:eM.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))}),"url"===L&&(0,r.jsx)("input",{type:"url","data-testid":"multilink-url-".concat(x.name),value:null!=(t=T.url)?t:"",onChange:e=>E({url:e.target.value}),disabled:b,placeholder:"https://example.com",className:eF}),"email"===L&&(0,r.jsx)("input",{type:"email","data-testid":"multilink-email-".concat(x.name),value:null!=(a=T.email)?a:"",onCh
1ange:e=>E({email:e.target.value}),disabled:b,placeholder:"[email protected]",className:eF}),"story"===L&&(h?(0,r.jsxs)("div",{"data-testid":"multilink-recordPicker-".concat(x.name),className:"space-y-2",children:[(0,r.jsx)(A.A,{value:null!=(n=T.recordId)?n:null,onChange:e=>E({recordId:"string"==typeof e?e:""}),multi:!1,spaceId:h,isDisabled:b}),D&&T.recordId?(0,r.jsxs)("p",{className:"text-xs text-gray-600 dark:text-gray-300","data-testid":"multilink-storyTitle-".concat(x.name),children:["Resolved title:"," ",(0,r.jsx)("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:D})]}):null,(0,r.jsx)("input",{type:"hidden","data-testid":"multilink-recordId-".concat(x.name),value:null!=(s=T.recordId)?s:"",readOnly:!0})]}):(0,r.jsx)("input",{type:"text","data-testid":"multilink-recordId-".concat(x.name),value:null!=(d=T.recordId)?d:"",onChange:e=>E({recordId:e.target.value}),disabled:b,placeholder:"Record ID (cmp…)",className:eF})),"asset"===L&&(h?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>C(!0),disabled:b,"data-testid":"multilink-assetPicker-open-".concat(x.name),className:"inline-flex items-center px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed",children:T.assetId?"Change asset":"Pick asset"}),T.assetId&&(0,r.jsx)("button",{type:"button",onClick:()=>E({assetId:void 0}),disabled:b,"data-testid":"multilink-assetPicker-clear-".concat(x.name),className:"text-sm text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-300",children:"Clear"})]}),(0,r.jsx)("input",{type:"hidden","data-testid":"multilink-assetId-".concat(x.name),value:null!=(o=T.assetId)?o:"",readOnly:!0}),T.assetId&&(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:T.assetId}),(0,r.jsx)(eD.A,{isOpen:w,onClose:()=>C(!1),spaceId:h,onAssetsSelected:e=>{e.length>0&&E({assetId:e[0]}),C(!1)}})]}):(0,r.jsx)("input",{type:"text","data-testid":"multilink-assetId-".concat(x.name),value:null!=(c=T.assetId)?c:"",onChange:e=>E({assetId:e.target.value}),disabled:b,placeholder:"Asset ID (cmp…)",className:eF})),(0,r.jsxs)("div",{className:"pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>S(e=>!e),"aria-expanded":I,"data-testid":"multilink-advanced-toggle-".concat(x.name),className:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 underline underline-offset-2",children:I?"Hide advanced":"Show advanced"}),I&&(0,r.jsxs)("div",{className:"mt-2 space-y-2","data-testid":"multilink-advanced-".concat(x.name),children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"".concat(m,"-anchor"),className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Anchor (optional)"}),(0,r.jsx)("input",{id:"".concat(m,"-anchor"),type:"text","data-testid":"multilink-anchor-".concat(x.name),value:null!=(u=T.anchor)?u:"",onChange:e=>E({anchor:e.target.value||void 0}),disabled:b,placeholder:"#contact",className:eF}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-500 dark:text-gray-400",children:"Appended at render-time. Don't include the leading hash — the renderer adds it."})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{id:"".concat(m,"-newTab"),type:"checkbox","data-testid":"multilink-newTab-".concat(x.name),checked:!!T.newTab,onChange:e=>E({newTab:e.target.checked||void 0}),disabled:b,className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),(0,r.jsx)("label",{htmlFor:"".concat(m,"-newTab"),className:"text-sm text-gray-700 dark:text-gray-300",children:'Open in new tab (target="_blank")'})]})]})]}),k?(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:String(null!=(g=null==k?void 0:k.message)?g:"")}):null]})}var eP=a(67909);let eW={kebab:"-",snake:"_",lower:""};function eq(e){var t,a;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"kebab";if(!e)return"";let l=null!=(t=eW[r])?t:"-",n=RegExp("[\\u0300-\\u036f]","g");return(null!=(a=e.normalize("NFKD").replace(n,"").toLowerCase().match(/[a-z0-9]+/g))?a:[]).join(l)}let eH=(0,eP.default)(()=>Promise.all([a.e(1761),a.e(8213)]).then(a.bind(a,48213)),{loadableGenerated:{webpack:()=>[48213]},ssr:!1}),e_=(0,eP.default)(()=>Promise.all([a.e(1761),a.e(9486)]).then(a.bind(a,59486)),{loadableGenerated:{webpack:()=>[59486]},ssr:!1});function eB(e){let{value:t,onChange:a,isDisabled:n}=e,s=Array.isArray(t)?t:[],[d,i]=(0,l.useState)(""),o=()=>{let e=d.trim();if(e){if(s.includes(e))return void i("");a([...s,e]),i("")}};return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-2 py-2 border border-gray-300 dark:border-gray-700 rounded-md bg-white dark:bg-gray-800 ".concat(n?"opacity-60 cursor-not-allowed":""),children:[s.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-700 rounded",children:[e,!n&&(0,r.jsx)("button",{type:"button",onClick:()=>a(s.filter(t=>t!==e)),className:"text-gray-400 hover:text-red-500",children:"\xd7"})]},e)),(0,r.jsx)("input",{type:"text",value:d,disabled:n,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key||","===e.key?(e.preventDefault(),o()):"Backspace"===e.key&&!d&&s.length&&a(s.slice(0,-1))},onBlur:o,placeholder:0===s.length?"Type and press Enter…":"",className:"flex-1 min-w-[120px] bg-transparent text-sm outline-none"})]})}function eU(e){let{value:t}=e,a="";try{a=JSON.stringify(null!=t?t:null,null,2)}catch(e){a=String(t)}return(0,r.jsx)("pre",{className:"text-xs bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded p-3 overflow-x-auto text-gray-700 dark:text-gray-300 max-h-60",children:a})}function ez(e){let{type:t,value:a}=e;return(0,r.jsx)("div",{className:"rounded-md border border-amber-200 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 p-3",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(s.A,{className:"w-5 h-5 text-amber-600 dar
1k:text-amber-300 flex-shrink-0 mt-0.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Field type"," ",(0,r.jsx)("code",{className:"font-mono text-xs px-1 py-0.5 bg-amber-100 dark:bg-amber-800/40 rounded",children:t})," ","isn't editable in the form yet"]}),(0,r.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:"The stored value is preserved on save — you can edit it via the delivery API or remove the field from the content type if it's no longer needed."}),null!=a&&(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-xs text-amber-700 dark:text-amber-300",children:"Show stored value"}),(0,r.jsx)(eU,{value:a})]})]})]})})}function eK(e){let{reason:t}=e;return(0,r.jsx)("div",{className:"rounded-md border border-amber-200 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 p-3 text-sm text-amber-800 dark:text-amber-200",children:t})}function eJ(e){var t;let{rhfPath:a,controlKey:n,settings:s,isDisabled:o,requiredRule:c,inputClass:u}=e,{control:g,watch:m}=(0,i.xW)(),{activeLocale:x,defaultLocale:b}=(0,Z.PZ)(),h=null!=(t=null==s?void 0:s.strategy)?t:"kebab",p="string"==typeof(null==s?void 0:s.sourceField)?s.sourceField:null,y=p?m(p):void 0,f=()=>{if("string"==typeof y)return y;if(y&&"object"==typeof y){var e;let t=null!=(e=y[x])?e:y[b];return"string"==typeof t?t:""}return""},v=l.useRef(!1),k=l.useRef(null);return(0,r.jsx)(i.xI,{name:a,control:g,rules:{required:c},render:e=>{let{field:t}=e,l=f();if(!v.current&&p){let e=eq(l,h),a="string"==typeof t.value?t.value:"",r=null===k.current?null:eq(k.current,h);(""===a||(null!==r?a===r:a===e))&&e&&e!==a&&queueMicrotask(()=>t.onChange(e))}k.current=l;let n="string"==typeof t.value?t.value:"";return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",id:a,inputMode:"url",spellCheck:!1,className:"".concat(u," font-mono ").concat(o?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:o,value:n,placeholder:p?"auto-generated from "+p:"my-slug",onChange:e=>{v.current=!0,t.onChange(e.target.value)},onBlur:e=>t.onChange(eq(e.target.value,h))}),p?(0,r.jsx)("button",{type:"button",disabled:o,title:'Regenerate from "'.concat(p,'"'),className:"flex-shrink-0 rounded-md border border-gray-300 dark:border-gray-700 px-2 py-2 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50",onClick:()=>{v.current=!0,t.onChange(eq(f(),h))},children:(0,r.jsx)(d.A,{className:"h-4 w-4"})}):null]}),(0,r.jsxs)("p",{className:"mt-1 text-[11px] uppercase tracking-wider text-gray-400 dark:text-gray-500",children:["url-safe \xb7 ",h,p?" \xb7 follows ".concat(p," until edited"):""]})]})}},n)}function eV(e){let{rhfPath:t,isDisabled:a,requiredRule:l,hasError:n}=e,{control:s}=(0,i.xW)(),d=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,o=n?"border-red-500":"border-gray-300 dark:border-gray-700";return(0,r.jsx)(i.xI,{name:t,control:s,rules:{required:l},render:e=>{let{field:l}=e,n="string"==typeof l.value?l.value:"";return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"color","aria-label":"Color picker",value:d.test(n)?4===n.length?"#".concat(n[1]).concat(n[1]).concat(n[2]).concat(n[2]).concat(n[3]).concat(n[3]):n:"#000000",disabled:a,onChange:e=>l.onChange(e.target.value),className:"h-9 w-12 flex-shrink-0 cursor-pointer rounded border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 disabled:cursor-not-allowed"}),(0,r.jsx)("input",{type:"text",id:t,value:n,placeholder:"#1a2b3c",spellCheck:!1,disabled:a,onChange:e=>l.onChange(e.target.value),className:"w-full rounded-md border ".concat(o," px-3 py-2 font-mono text-sm shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 ").concat(a?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":"")})]})}})}function eG(e){let{rhfPath:t,controlKey:a,requiredRule:l,hasError:n}=e,{control:s}=(0,i.xW)();return(0,r.jsx)(i.xI,{name:t,control:s,rules:{required:l},render:e=>{let{field:a}=e;return(0,r.jsx)(eY,{id:t,value:a.value,onChange:a.onChange,hasError:n})}},a)}function eY(e){let{id:t,value:a,onChange:n,hasError:s}=e,[d,i]=(0,l.useState)(()=>null==a?"":JSON.stringify(a,null,2)),[o,c]=(0,l.useState)(null),u=s||o?"border-red-500":"border-gray-300 dark:border-gray-700";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("textarea",{id:t,rows:8,spellCheck:!1,value:d,placeholder:'{\n  "key": "value"\n}',onChange:e=>i(e.target.value),onBlur:()=>{let e=d.trim();if(""===e){n(null),c(null);return}try{let t=JSON.parse(e);n(t),c(null),i(JSON.stringify(t,null,2))}catch(e){c(e.message)}},className:"w-full rounded-md border ".concat(u," px-3 py-2 font-mono text-[13px] shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800")}
1),o?(0,r.jsxs)("p",{className:"mt-1 text-sm text-amber-600 dark:text-amber-400",children:["Invalid JSON: ",o]}):null]})}let eZ=e=>{var t,a,l,s,d,c,u,g,m,x,b,h,p,y,f,v,k,j,N,w;let{field:C,onAIAssist:I,isDisabled:T=!1}=e,{register:L,control:R,formState:{errors:E},setValue:D,watch:M}=(0,i.xW)(),{activeLocale:F,defaultLocale:O,fieldPath:P,isDefaultLocaleActive:W}=(0,Z.PZ)(),q=P(C),H=(0,i.Jt)(E,q),_=M(q),B="".concat(q,"::").concat(F),{spaceId:U,environmentId:z}=(0,S.fU)(),K=(()=>{if(!C.localized||W||null!=_&&""!==_)return;let e=M("".concat(C.name,".").concat(O));return"string"==typeof e&&e.trim().length>0?e:void 0})(),J=(()=>{if(!C.localized||W||null!=_&&""!==_)return!1;let e=M("".concat(C.name,".").concat(O));return null!=e&&""!==e})(),V=()=>J?(0,r.jsxs)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 italic",children:["Empty in ",F," — falls back to ",O,"."]}):null,G=e=>I?(0,r.jsx)("button",{type:"button",onClick:()=>I(q,e),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20",title:"Generate with AI",children:(0,r.jsx)(n.A,{className:"h-4 w-4"})}):null,Y="w-full px-3 py-2 pr-10 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800",X="border-red-500",$=!!C.required&&!!W&&"".concat(C.name," is required."),Q=()=>K?(0,r.jsxs)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 italic",children:["Empty in ",F," — fallback to ",O,":"," ",(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-200",children:K.length>80?"".concat(K.slice(0,80),"…"):K})]}):null;switch(C.type){case"text":case"symbol":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:"text",id:q,className:"".concat(Y," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,...L(q,{required:$})}),G("text")]}),Q(),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(t=H.message)?void 0:t.toString()})]});case"url":case"email":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:"email"===C.type?"email":"url",inputMode:"email"===C.type?"email":"url",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,id:q,placeholder:"email"===C.type?"[email protected]":"https://example.com",className:"".concat(Y," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,...L(q,{required:$})}),G(C.type)]}),Q(),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(a=H.message)?void 0:a.toString()})]});case"textarea":case"longtext":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("textarea",{id:q,rows:4,className:"".concat(Y," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,...L(q,{required:$})}),(0,r.jsx)("div",{className:"absolute right-2 top-2",children:G(C.type)})]}),Q(),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(l=H.message)?void 0:l.toString()})]});case"markdown":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("textarea",{id:q,rows:8,spellCheck:!1,placeholder:"# Heading\n\nWrite **markdown** here…",className:"".concat(Y," font-mono text-[13px] ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,...L(q,{required:$})}),(0,r.jsx)("div",{className:"absolute right-2 top-2",children:G("markdown")})]}),(0,r.jsx)("p",{className:"mt-1 text-[11px] uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"markdown \xb7 rendered by your app/delivery"}),Q(),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(s=H.message)?void 0:s.toString()})]});case"color":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eV,{rhfPath:q,isDisabled:T,requiredRule:$,hasError:!!H}),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(d=H.message)?void 0:d.toString()})]});case"richtext":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.xI,{name:q,control:R,rules:{required:$},render:e=>{var t;let{field:a}=e;return(0,r.jsx)(ec,{field:a,disabled:T,ariaLabelledBy:"".concat(q,"-label"),fieldId:q,richtextSettings:null==(t=C.settings)?void 0:t.richtext})}},B),Q(),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(c=H.message)?void 0:c.toString()})]});case"number":case"integer":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{type:"number",id:q,step:"integer"===C.type?"1":"any",className:"".concat(Y.replace("pr-10","")," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,...L(q,{required:$,valueAsNumber:!0})}),V(),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(u=H.message)?void 0:u.toString()})]});case"boolean":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.xI,{name:q,control:R,render:e=>{let{field:t}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-3 py-1",children:[(0,r.jsx)(o.dO,{id:q,checked:!!t.value,onChange:e=>t.onChange(e),disabled:T,className:"".concat(t.value?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"," relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ").
1concat(T?"opacity-50 cursor-not-allowed":""),children:(0,r.jsx)("span",{className:"".concat(t.value?"translate-x-6":"translate-x-1"," inline-block h-4 w-4 transform rounded-full bg-white transition-transform")})}),(0,r.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:t.value?"Enabled":"Disabled"})]})}}),V()]});case"date":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.xI,{name:q,control:R,rules:{required:$},render:e=>{let{field:t}=e,a="";try{if(t.value){let e=new Date(t.value);if(!Number.isNaN(e.getTime())){let t=e.getUTCFullYear(),r=String(e.getUTCMonth()+1).padStart(2,"0"),l=String(e.getUTCDate()).padStart(2,"0");a="".concat(t,"-").concat(r,"-").concat(l)}}}catch(e){a=""}return(0,r.jsx)("input",{type:"date",id:q,className:"".concat(Y.replace("pr-10","")," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,value:a,onChange:e=>{let a=e.target.value;t.onChange(a?new Date(a).toISOString():null)}})}},B),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(g=H.message)?void 0:g.toString()})]});case"datetime":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.xI,{name:q,control:R,rules:{required:$},render:e=>{let{field:t}=e,a="";try{if(t.value){let e=new Date(t.value);if(!Number.isNaN(e.getTime())){let t=e=>String(e).padStart(2,"0"),r=e.getFullYear(),l=t(e.getMonth()+1),n=t(e.getDate()),s=t(e.getHours()),d=t(e.getMinutes());a="".concat(r,"-").concat(l,"-").concat(n,"T").concat(s,":").concat(d)}}}catch(e){a=""}return(0,r.jsx)("input",{type:"datetime-local",id:q,className:"".concat(Y.replace("pr-10","")," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,value:a,onChange:e=>{let a=e.target.value;t.onChange(a?new Date(a).toISOString():null)}})}},B),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(m=H.message)?void 0:m.toString()})]});case"location":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.xI,{name:q,control:R,rules:{validate:e=>{let t=null==e?void 0:e.lat,a=null==e?void 0:e.lng,r=null!=t&&""!==t,l=null!=a&&""!==a;if(!r&&!l)return $||!0;if(r&&!l||!r&&l)return"Both latitude and longitude are required";if(r){if("number"!=typeof t||Number.isNaN(t))return"Latitude must be a number";if(t<-90||t>90)return"Latitude must be between -90 and 90"}if(l){if("number"!=typeof a||Number.isNaN(a))return"Longitude must be a number";if(a<-180||a>180)return"Longitude must be between -180 and 180"}return!0}},defaultValue:{lat:null,lng:null,description:""},render:e=>{var t,a;let{field:l}=e,n=l.value||{lat:null,lng:null,description:""};return(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,r.jsx)("input",{type:"number",placeholder:"Latitude (-90 to 90)",min:-90,max:90,step:"0.000001",value:null!=(t=n.lat)?t:"",onChange:e=>(e=>{let t=""===e||Number.isNaN(parseFloat(e))?null:parseFloat(e);l.onChange({...n,lat:t})})(e.target.value),className:"".concat(Y," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T}),(0,r.jsx)("input",{type:"number",placeholder:"Longitude (-180 to 180)",min:-180,max:180,step:"0.000001",value:null!=(a=n.lng)?a:"",onChange:e=>(e=>{let t=""===e||Number.isNaN(parseFloat(e))?null:parseFloat(e);l.onChange({...n,lng:t})})(e.target.value),className:"".concat(Y," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T})]})}},B),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(x=H.message)?void 0:x.toString()}),!H&&(null==_?void 0:_.lat)!==null&&(null==_?void 0:_.lat)!==void 0&&(null==_?void 0:_.lng)!==null&&(null==_?void 0:_.lng)!==void 0&&(0,r.jsxs)("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,r.jsx)("a",{href:"https://www.google.com/maps?q=".concat(_.lat,",").concat(_.lng),target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"Open in Google Maps"}),(0,r.jsx)("span",{className:"mx-2",children:"•"}),(0,r.jsx)("a",{href:"https://www.openstreetmap.org/?mlat=".concat(_.lat,"&mlon=").concat(_.lng,"#map=15/").concat(_.lat,"/").concat(_.lng),target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dar
1k:text-blue-400 hover:underline",children:"Open in OpenStreetMap"})]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Location description"}),(0,r.jsx)("textarea",{rows:2,className:"".concat(Y," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,placeholder:"Optional description for this location",value:null!=(b=null==_?void 0:_.description)?b:"",onChange:e=>D(q,{..._||{lat:null,lng:null,description:""},description:e.target.value},{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})})]}),(0,r.jsx)(eH,{lat:null!=(h=null==_?void 0:_.lat)?h:null,lng:null!=(p=null==_?void 0:_.lng)?p:null,disabled:T,onChange:e=>{D(q,{..._||{lat:null,lng:null,description:""},lat:e.lat,lng:e.lng},{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},height:260},B)]});case"select":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{id:q,className:"".concat(Y.replace("pr-10","")," ").concat(H?X:""," ").concat(T?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":""),disabled:T,...L(q,{required:$}),children:[(0,r.jsx)("option",{value:"",children:"Select an option"}),null==(y=C.options)?void 0:y.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))]}),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(f=H.message)?void 0:f.toString()})]});case"multiselect":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.xI,{name:q,control:R,rules:{required:$},defaultValue:[],render:e=>{var t;let{field:a}=e;return(0,r.jsx)("div",{className:"space-y-2",children:null==(t=C.options)?void 0:t.map(e=>(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("input",{type:"checkbox",id:"".concat(q,"-").concat(e.value),checked:(a.value||[]).includes(e.value),onChange:t=>{let r=a.value||[];a.onChange(t.target.checked?[...r,e.value]:r.filter(t=>t!==e.value))},disabled:T,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded ".concat(T?"cursor-not-allowed opacity-50":"")}),(0,r.jsx)("label",{htmlFor:"".concat(q,"-").concat(e.value),className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:e.label})]},e.value))})}}),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(v=H.message)?void 0:v.toString()})]});case"stringArray":return(0,r.jsx)(i.xI,{name:q,control:R,defaultValue:[],render:e=>{let{field:t}=e;return(0,r.jsx)(eB,{value:t.value,onChange:e=>t.onChange(e),isDisabled:T})}});case"reference":case"referenceArray":return U?(0,r.jsx)(i.xI,{name:q,control:R,render:e=>{var t,a;let{field:l}=e;return(0,r.jsx)(A.A,{value:l.value,onChange:e=>l.onChange(e),multi:"referenceArray"===C.type,linkContentTypes:null!=(a=null==(t=C.settings)?void 0:t.linkContentTypes)?a:[],spaceId:U,environmentId:z,isDisabled:T})}}):(0,r.jsx)(eK,{reason:"Space context missing for reference picker."});case"asset":case"assetArray":case"image":case"file":case"media":return U?(0,r.jsx)(ev,{fieldName:q,label:null!=(k=C.displayName)?k:C.name,description:C.description,required:C.required&&W,spaceId:U,filterType:"image"===C.type?"image/*":"",isDisabled:T,multiple:"assetArray"===C.type}):(0,r.jsx)(eK,{reason:"Space context missing for media picker."});case"gpx":return(0,r.jsxs)(r.Fragment,{children:[U?(0,r.jsx)(ev,{fieldName:q,label:null!=(j=C.displayName)?j:C.name,description:C.description,required:C.required&&W,spaceId:U,filterType:"application/gpx+xml",isDisabled:T}):(0,r.jsx)(eK,{reason:"Space context missing for GPX picker."}),"string"==typeof _&&_&&(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsx)(e_,{url:_,height:340})})]});case"json":case"object":return T?(0,r.jsx)(eU,{value:_}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eG,{rhfPath:q,controlKey:B,requiredRule:$,hasError:!!H}),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(N=H.message)?void 0:N.toString()})]});case"bloks":return(0,r.jsx)(eE,{rhfPath:q,field:C,isDisabled:T});case"group":return null;case"multilink":return(0,r.jsx)(eO,{rhfPath:q,field:C,isDisabled:T,spaceId:U});case"slug":return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eJ,{rhfPath:q,controlKey:B,settings:C.settings,isDisabled:T,requiredRule:$,inputClass:"".concat(Y," ").concat(H?X:"")}),Q(),H&&(0,r.jsx)("p",{className:"mt-1 text-sm text-red-600",children:null==(w=H.message)?void 0:w.toString()})]});default:return ex.v.warn("Unsupported field type: ".concat(C.type)),(0,r.jsx)(ez,{type:C.type,value:_})}}},75940:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(95155),l=a(12115);let n=e=>{let{isOpen:t,onClose:a,title:n,children:s,size:d="md"}=e;if((0,l.useEffect)(()=>{let e=e=>{"Escape"===e.key&&a()};return t?(document.addEventListener("keydown",e),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",e),document.body.style.overflow=""),()=>{document.removeEventListener("keydown",e),document.body.style.overflow=""}},[t,a]),!t)return null;let i={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"},o=i[d]||i.md;return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-75 backdrop-blur-sm",onClick:a,children:(0,r.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ".concat(o," mx-4 overflow-hidden"),onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[n&&(0,r.jsx)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n}),(0,r.jsx)("button",{onClick:a,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close modal",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"p-6 max-h-[70vh] overflow-y-auto",children:s})]})})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.