1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6713],{1987:(e,t,a)=>{"use strict";a.d(t,{default:()=>ea});var r=a(95155);function n(e){let{report:t,locale:a}=e,n=a.startsWith("de"),s=e=>{var t,a;return e.startsWith("source-unparsed:")?"".concat(n?"Datei nicht analysierbar":"Could not analyze file",": ").concat(e.slice(16)):e.startsWith("ambiguous-related:")?"".concat(n?"Referenzziel nicht eindeutig":"Ambiguous reference target",": ").concat(e.slice(18)):null!=(a=null==(t=({"external-consumers-and-dynamic-code-unverified":["Externe REST-/GraphQL-Anwendungen und dynamische Zugriffe sind nicht vollst\xe4ndig nachweisbar.","External REST/GraphQL applications and dynamic access cannot be fully verified."],"unrestricted-reference-values-unverified":["Referenzen ohne festgelegten Zieltyp: Datensatzwerte wurden nicht durchsucht.","References without a declared target type: record values were not scanned."],"non-default-environment":["Dieses Modell liegt nicht im Standard-Environment der Apps. Gleiche Typnamen belegen keine Verwendung dieses Environments.","This model is outside the apps' default environment. Matching type names do not prove usage of this environment."],"published-revision-unavailable":["F\xfcr diese Ver\xf6ffentlichung ist kein Git-Commit hinterlegt. Der ver\xf6ffentlichte Quellstand ist nicht verifiziert.","No Git commit is recorded for this publication. Published source dependencies are not verified."],"repository-unavailable":["Aktueller App-Stand nicht lesbar.","Current app revision could not be read."],"snapshot-unavailable":["Dieser Git-Stand konnte nicht vollst\xe4ndig gelesen werden.","This Git revision could not be fully read."],"invalid-or-unsupported-config":["Komponentenkonfiguration ung\xfcltig oder nicht unterst\xfctzt.","Component configuration is invalid or unsupported."]})[e])?void 0:t[+!n])?a:n?"Analysegrenze erreicht; Ergebnis ist unvollst\xe4ndig.":"Analysis limit reached; results are incomplete."};return(0,r.jsxs)("section",{"aria-label":n?"App-Bindungen und Referenzen":"App bindings and references",className:"min-w-0 space-y-3 border-t pt-4",children:[(0,r.jsx)("h4",{className:"font-semibold",children:n?"App-Bindungen und Referenzen":"App bindings and references"}),(0,r.jsx)("p",{children:n?"Gepr\xfcft werden gespeicherte Git-St\xe4nde. Eine konfigurierte Bindung belegt die Zuordnung, nicht dass die Komponente auf jeder Seite gerendert wird. Ungespeicherte App-\xc4nderungen sind nicht enthalten.":"Analysis uses committed Git revisions. A configured binding proves the mapping, not that the component is rendered on every page. Uncommitted app changes are not included."}),0===t.apps.length&&(0,r.jsx)("p",{children:n?"Keine Apps im gepr\xfcften Space gefunden.":"No apps found in this space."}),t.apps.map(e=>(0,r.jsxs)("details",{className:"min-w-0 rounded border p-3",children:[(0,r.jsxs)("summary",{className:"cursor-pointer font-medium",children:[e.name," \xb7"," ",e.snapshots.reduce((e,t)=>e+t.bindings.length,0)," ",n?"Bindungsnachweise":"binding findings",e.snapshots.some(e=>"parsed"!==e.configStatus||e.warnings.length>0)&&(0,r.jsxs)("span",{children:[" ","\xb7 ",n?"unvollst\xe4ndig gepr\xfcft":"partially inspected"]})]}),e.snapshots.map(e=>(0,r.jsxs)("div",{className:"min-w-0 space-y-2 border-t py-3",children:[(0,r.jsxs)("p",{className:"break-words font-medium",children:["current"===e.stage?n?"Aktueller Stand":"Current revision":"published"===e.stage?n?"Ver\xf6ffentlicht":"Published":n?"Aktuell und ver\xf6ffentlicht":"Current and published"," ",e.revision.slice(0,8)]}),(0,r.jsx)("p",{children:"missing"===e.configStatus?n?"Keine Komponentenkonfiguration vorhanden. Das bedeutet nicht, dass keine CMS-Abh\xe4ngigkeiten bestehen.":"No component configuration found. This does not mean there are no CMS dependencies.":"parsed"!==e.configStatus?n?"Komponentenbindungen konnten nicht verifiziert werden.":"Component bindings could not be verified.":n?"Konfigurierte Bindungen (smartcms-components.json)":"Configured bindings (smartcms-components.json)"}),(0,r.jsx)("ul",{className:"space-y-1",children:e.bindings.map((e,t)=>(0,r.jsxs)("li",{className:"break-words",children:[(0,r.jsx)("code",{children:e.field})," â"," ",(0,r.jsxs)("code",{children:[e.instance,".",e.slot]}),e.affected&&(0,r.jsxs)("strong",{children:[" ","\xb7 ",n?"von \xc4nderung betroffen":"affected by change"]})]},t))}),e.hints.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"font-medium",children:n?"Code-Fundstellen â Typzuordnung und Ausf\xfchrung manuell pr\xfcfen":"Code findings â verify type mapping and execution manually"}),(0,r.jsx)("ul",{children:e.hints.map((e,t)=>{var a;return(0,r.jsxs)("li",{className:"break-words",children:[(0,r.jsxs)("code",{children:[e.path,":",e.line]})," ","\xb7"," ",null!=(a=e.field)?a:n?"Abfrage des Inhaltstyps":"Content type query"]},t)})})]}),e.warnings.map((e,t)=>(0,r.jsx)("p",{className:"text-amber-800 dark:text-amber-300",children:s(e)},t))]},e.stage+e.revision))]},e.id)),(0,r.jsx)("h4",{className:"font-semibold",children:n?"Eingehende Modellreferenzen":"Incoming model references"}),t.references.length?(0,r.jsx)("ul",{children:t.references.map((e,t)=>(0,r.jsxs)("li",{children:[(0,r.jsxs)("code",{children:[e.contentType,".",e.field]})," ","\xb7 ",e.kind]},t))}):(0,r.jsx)("p",{children:n?"Keine expliziten Zieltyp-Verweise im gepr\xfcften Environment gefunden.":"No explicit target-type references found in the inspected environment."}),(0,r.jsx)("div",{className:"space-y-1 text-sm",children:t.warnings.map((e,t)=>(0,r.jsx)("p",{children:s(e)},t))})]})}let s={"record-limit":["Obergrenze von Datens\xe4tzen erreicht","Record limit reached"],"time-budget":["Zeitbudget erreicht","Time budget reached"],"finding-limit":["Befundliste gek\xfcrzt, Z\xe4hler vollst\xe4ndig","Finding list truncated, counts remain complete"],"missing-active-version":["Datens\xe4tze ohne aktive Version \xfcbersprungen","Records without an active version were skipped"],"no-records":["Keine Datens\xe4tze","No records"],"scan-failed":["Pr\xfcfung fehlgeschlagen","Scan failed"]},i={unique:["Eindeutigkeit","uniqueness"],"richtext-embeds":["Richtext-Einbettungen","rich text embeds"],"asset-constraints":["Asset-Vorgaben","asset constraints"],"select-options":["Auswahloptionen","select options"],"inactive-locales":["inaktive Sprachen","inactive locales"]};function l(e,t){return e.futurePublishOnly?t?"W\xfcrde k\xfcnftige Ver\xf6ffentlichung blockieren":"Would block future publish":e.preexisting?t?"Bereits vorher ung\xfcltig":"Already invali
1d before":t?"Neu ung\xfcltig":"Newly invalid"}function o(e,t){return"draft"===e?t?"Entwurf":"Draft":t?"Ver\xf6ffentlicht":"Published"}function d(e){var t;let{scan:a,locale:n,onContinue:d,continuing:c}=e,u=n.startsWith("de"),m=(()=>{let e=new Date(a.boundTo.scannedAt);return Number.isNaN(e.getTime())?a.boundTo.scannedAt:e.toLocaleString(u?"de-DE":"en-US")})(),g=a.findings.filter(e=>!e.futurePublishOnly&&!e.preexisting),p=a.findings.filter(e=>!e.futurePublishOnly&&e.preexisting),h=a.findings.filter(e=>e.futurePublishOnly),x=[{key:"new",label:u?"Neu ung\xfcltig":"Newly invalid",items:g},{key:"preexisting",label:u?"Bereits vorher ung\xfcltig":"Already invalid before",items:p},{key:"future-publish",label:u?"K\xfcnftige Ver\xf6ffentlichung":"Future publish",items:h,note:h.length>0?u?"Die Auslieferung zeigt heute den Wert der Standardsprache; eine Ver\xf6ffentlichung dieser Sprache w\xfcrde abgelehnt.":"Delivery currently shows the default locale's value; publishing this locale would be rejected.":void 0}];return(0,r.jsxs)("section",{"aria-label":u?"Migrationspr\xfcfung":"Migration scan",className:"min-w-0 space-y-3 border-t pt-4",children:[(0,r.jsx)("h4",{className:"font-semibold",children:u?"Migrationspr\xfcfung":"Migration scan"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,r.jsxs)("span",{children:[u?"Gepr\xfcft":"Checked",": ",a.scanned.records," ",u?"Datens\xe4tze":"records"," \xb7 ",a.scanned.versions," ",u?"Versionen":"versions"," \xb7 ",a.scanned.locales," ",u?"Locales":"locales"]}),(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium",children:(t=a.coverage,"complete"===t?u?"Vollst\xe4ndig":"C
1omplete":"partial"===t?u?"Teilweise":"Partial":u?"Nicht gepr\xfcft":"Skipped")}),(0,r.jsxs)("span",{className:"text-gray-600 dark:text-gray-400",children:[u?"Gepr\xfcft am":"Scanned at"," ",m]}),(0,r.jsxs)("span",{className:"text-gray-600 dark:text-gray-400",children:[u?"Bestand":"Total records",": ",a.boundTo.recordsTotal]})]}),"complete"!==a.coverage&&(0,r.jsxs)("div",{className:"min-w-0 space-y-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm dark:border-amber-800 dark:bg-amber-900/20",children:[(0,r.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:u?"Teilweise gepr\xfcft":"Partially checked"}),a.partialReasons.length>0&&(0,r.jsx)("ul",{className:"list-inside list-disc space-y-0.5",children:a.partialReasons.map((e,t)=>{var a,n;return(0,r.jsx)("li",{children:null!=(n=null==(a=s[e])?void 0:a[+!u])?n:e},t)})}),a.nextCursor&&d&&(0,r.jsx)("button",{type:"button",onClick:()=>d(a.nextCursor),disabled:!!c,className:"inline-flex items-center gap-2 rounded border px-3 py-1.5 text-sm disabled:opacity-50",children:c?u?"Wird gepr\xfcftâ¦":"Checkingâ¦":u?"Weiter pr\xfcfen":"Continue checking"})]}),(0,r.jsxs)("div",{className:"min-w-0 space-y-1 rounded border p-3 text-sm",children:[(0,r.jsx)("p",{className:"font-medium",children:u?"Nicht gepr\xfcft":"Not checked"}),a.notChecked.length>0&&(0,r.jsx)("ul",{className:"list-inside list-disc space-y-0.5",children:a.notChecked.map((e,t)=>{var n,s;return(0,r.jsx)("li",{children:"historical-versions"===e?u?"historische Versionen (".concat(a.historicalVersionsSkipped,")"):"historical versions (".concat(a.historicalVersionsSkipped,")"):null!=(s=null==(n=i[e])?void 0:n[+!u])?s:e},t)})}),(0,r.jsx)("p",{children:u?"Kein Treffer bedeutet nicht, dass keine Inhalte betroffen sind.":"No findings does not mean no content is affected."})]}),(0,r.jsxs)("div",{className:"grid min-w-0 grid-cols-2 gap-2 sm:grid-cols-4",children:[(0,r.jsxs)("div",{className:"min-w-0 rounded border p-3",children:[(0,r.jsx)("p",{className:"text-2xl font-semibold",children:a.counts.newErrors}),(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u?"Neu ung\xfcltig":"Newly invalid"})]}),(0,r.jsxs)("div",{className:"min-w-0 rounded border p-3",children:[(0,r.jsx)("p",{className:"text-2xl font-semibold",children:a.counts.preexistingErrors}),(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u?"Bereits vorher ung\xfcltig":"Already invali
1d before"})]}),(0,r.jsxs)("div",{className:"min-w-0 rounded border p-3",children:[(0,r.jsx)("p",{className:"text-2xl font-semibold",children:a.counts.resolvedErrors}),(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u?"W\xfcrde behoben":"Would be resolved"})]}),(0,r.jsxs)("div",{className:"min-w-0 rounded border p-3",children:[(0,r.jsx)("p",{className:"text-2xl font-semibold",children:a.counts.futurePublishBlockers}),(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u?"W\xfcrde k\xfcnftige Ver\xf6ffentlichung blockieren":"Would block future publish"})]})]}),Object.keys(a.counts.byField).length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(a.counts.byField).map(e=>{let[t,a]=e;return(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-xs",children:[t,": ",a]},t)})}),Object.keys(a.counts.byCode).length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(a.counts.byCode).map(e=>{let[t,a]=e;return(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-xs",children:[t,": ",a]},t)})}),a.partialReasons.includes("finding-limit")&&(0,r.jsx)("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:u?"Die Befundliste wurde gek\xfcrzt; die Z\xe4hler oben sind dennoch vollst\xe4ndig.":"The finding list was truncated; the counts above remain complete."}),(0,r.jsx)("div",{className:"min-w-0 space-y-4",children:x.map(e=>(0,r.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,r.jsx)("p",{className:"font-medium",children:e.label}),e.note&&(0,r.jsx)("p",{className:"text-sm",children:e.note}),0===e.items.length?(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u?"Keine":"None"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"hidden overflow-x-auto md:block",children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b text-left",children:[(0,r.jsx)("th",{className:"p-2",children:u?"Datensatz":"Record"}),(0,r.jsx)("th",{className:"p-2",children:u?"Kontext":"Context"}),(0,r.jsx)("th",{className:"p-2",children:"Version"}),(0,r.jsx)("th",{className:"p-2",children:"Locale"}),(0,r.jsx)("th",{className:"p-2",children:u?"Feld":"Field"}),(0,r.jsx)("th",{className:"p-2",children:u?"Grund":"Reason"}),(0,r.jsx)("th",{className:"p-2",children:"Status"})]})}),(0,r.jsx)("tbody",{children:e.items.map((e,t)=>{var a,n;return(0,r.jsxs)("tr",{className:"border-b align-top",children:[(0,r.jsxs)("td",{className:"break-words p-2",children:[null!=(a=e.title)?a:"â"," (",e.recordId,")"]}),(0,r.jsx)("td",{className:"p-2",children:o(e.context,u)}),(0,r.jsx)("td",{className:"p-2",children:e.versionNumber}),(0,r.jsx)("td",{className:"p-2",children:null!=(n=e.locale)?n:"â"}),(0,r.jsx)("td",{className:"break-words p-2",children:(0,r.jsx)("code",{children:e.field})}),(0,r.jsx)("td",{className:"break-words p-2",children:e.message}),(0,r.jsx)("td",{className:"break-words p-2",children:l(e,u)})]},t)})})]})}),(0,r.jsx)("div",{className:"min-w-0 space-y-2 md:hidden",children:e.items.map((e,t)=>{var a,n;return(0,r.jsxs)("div",{className:"min-w-0 space-y-1 rounded border p-3 text-sm",children:[(0,r.jsxs)("p",{className:"break-words font-medium",children:[null!=(a=e.title)?a:"â"," (",e.recordId,")"]}),(0,r.jsxs)("p",{children:[o(e.context,u)," \xb7"," ","Version"," ",e.versionNumber," \xb7"," ",null!=(n=e.locale)?n:"â"]}),(0,r.jsxs)("p",{className:"break-words",children:[(0,r.jsx)("code",{children:e.field}),": ",e.message]}),(0,r.jsx)("p",{className:"break-words font-medium",children:l(e,u)})]},t)})})]})]},e.key))})]})}var c=a(12115);let u="w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-900 disabled:opacity-60",m=new Set(["text","textarea","longtext","markdown","slug","url","email","color"]),g=new Set(["number","integer"]);function p(e){let{plan:t,recordCount:a,locale:n,fields:s,fieldSchema:i,contentTypeId:l,spaceId:o,baseRevision:d,onStarted:p}=e,h=n.startsWith("de"),[x,b]=(0,c.useState)(()=>{let e={};for(let a of t.needsInput)e[a.fieldId]=function(e,t){let a=t.find(t=>
1t.id===e.fieldId);if(!a||void 0===a.defaultValue)return"";if("boolean"===e.type)return a.defaultValue?"true":"false";if(m.has(e.type)||g.has(e.type))return String(a.defaultValue);try{return JSON.stringify(a.defaultValue)}catch(e){return""}}(a,s);return e}),[f,y]=(0,c.useState)(!1),[v,k]=(0,c.useState)(!1),[j,N]=(0,c.useState)(null),w=t.needsInput.map(e=>({item:e,...function(e,t){if(void 0===t||""===t)return{valid:!1,value:void 0};if(m.has(e.type))return{valid:!0,value:t};if(g.has(e.type)){let a=Number(t);return Number.isNaN(a)?{valid:!1,value:void 0}:{valid:!0,value:"integer"===e.type?Math.trunc(a):a}}if("boolean"===e.type)return{valid:!0,value:"true"===t};try{return{valid:!0,value:JSON.parse(t)}}catch(e){return{valid:!1,value:void 0}}}(e,x[e.fieldId])})),S=w.every(e=>e.valid),C=(e,t)=>{b(a=>({...a,[e]:t})),y(!1),N(null)};async function I(){k(!0),N(null);try{let e={};for(let t of w)e[t.item.fieldId]=t.value;let a="/api/cms/content-types/".concat(l,"/migrations?spaceId=").concat(encodeURIComponent(o)),r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseRevision:d,fields:s,fieldSchema:null!=i?i:void 0,defaults:e,planHash:t.planHash})}),n=await r.json().catch(()=>({}));if(!r.ok)throw Error(n.error||(h?"Migration konnte nicht gestartet werden.":"Could not start the migration."));p(n.migration)}catch(e){N(e instanceof Error?e.message:String(e)),y(!1)}finally{k(!1)}}return(0,r.jsxs)("section",{"aria-label":h?"Migration vorbereiten":"Prepare migration",className:"min-w-0 space-y-3 rounded-md border border-blue-200 bg-blue-50 p-3 dark:border-blue-800 dark:bg-blue-900/20",children:[(0,r.jsx)("h4",{className:"font-semibold",children:h?"Migration vorbereiten":"Prepare migration"}),(0,r.jsx)("p",{className:"text-sm",children:h?"Diese \xc4nderung kann mit einer kontrollierten Migration \xfcbernommen werden. Bestehende Datens\xe4tze werden dabei umgeschrieben, nicht ersetzt.":"This change can be applied with a controlled migration. Existing records are rewritten in place, not replaced."}),t.operations.length>0&&(0,r.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,r.jsx)("p",{className:"font-medium text-sm",children:h?"Geplante Schritte":"Planned steps"}),(0,r.jsx)("ul",{className:"list-inside list-disc space-y-1 text-sm",children:t.operations.map((e,t)=>(0,r.jsx)("li",{className:"break-words",children:function(e,t){switch(e.op){case"rename":return t?'Umbenennen: "'.concat(e.from,'" â "').concat(e.to,'"'):'Rename: "'.concat(e.from,'" â "').concat(e.to,'"');case"remove":return t?'Entfernt: "'.concat(e.field,'"'):'Removed: "'.concat(e.field,'"');case"addRequiredWithDefault":return t?'Neues Pflichtfeld mit Standardwert: "'.concat(e.field,'" = ').concat(JSON.stringify(e.value)):'New required field with default: "'.concat(e.field,'" = ').concat(JSON.stringify(e.value));case"localize":return t?'Lokalisierung aktiviert: "'.concat(e.field,'"'):'Localization enabled: "'.concat(e.field,'"');case"delocalize":return t?'Lokalisierung entfernt: "'.concat(e.field,'"'):'Localization removed: "'.concat(e.field,'"');case"convertType":return t?'Typwechsel: "'.concat(e.field,'" ').concat(e.from," â ").concat(e.to):'Type change: "'.concat(e.field,'" ').concat(e.from," â ").concat(e.to);default:return t?"Unbekannte Operation":"Unknown operation"}}(e,h)},t))})]}),t.needsInput.length>0&&(0,r.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,r.jsx)("p",{className:"font-medium text-sm",children:h?"Standardwerte f\xfcr neue Pflichtfelder":"Default values for new required fields"}),w.map(e=>{var t,a,n,s;let{item:i,valid:l}=e;return(0,r.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,r.jsxs)("label",{htmlFor:"migration-default-".concat(i.fieldId),className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[i.field," ",(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:["(",i.type,")"]})]}),"boolean"===i.type?(0,r.jsxs)("select",{id:"migration-default-".concat(i.fieldId),className:u,value:null!=(t=x[i.fieldId])?t:"",onChange:e=>C(i.fieldId,e.target.value),children:[(0,r.jsx)("option",{value:"",children:h?"Bitte w\xe4hlen":"Please choose"}),(0,r.jsx)("option",{value:"true",children:h?"Wahr":"True"}),(0,r.jsx)("option",{value:"false",children:h?"Falsch":"False"})]}):g.has(i.type)?(0,r.jsx)("input",{id:"migration-default-".concat(i.fieldId),type:"number",step:"integer"===i.type?1:"any",className:u,value:null!=(a=x[i.fieldId])?a:"",onCh
1ange:e=>C(i.fieldId,e.target.value)}):m.has(i.type)?(0,r.jsx)("input",{id:"migration-default-".concat(i.fieldId),type:"text",className:u,value:null!=(n=x[i.fieldId])?n:"",onChange:e=>C(i.fieldId,e.target.value)}):(0,r.jsx)("textarea",{id:"migration-default-".concat(i.fieldId),className:u,rows:3,placeholder:h?"Wert als JSON":"Value as JSON",value:null!=(s=x[i.fieldId])?s:"",onChange:e=>C(i.fieldId,e.target.value)}),!l&&x[i.fieldId]&&(0,r.jsx)("p",{className:"text-xs text-red-700 dark:text-red-300",children:h?"Ung\xfcltiger Wert.":"Invalid value."})]},i.fieldId)})]}),t.warnings.length>0&&(0,r.jsx)("ul",{className:"list-inside list-disc space-y-1 text-sm text-amber-800 dark:text-amber-300",children:t.warnings.map((e,t)=>(0,r.jsx)("li",{className:"break-words",children:e},t))}),a>50&&(0,r.jsx)("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:h?"W\xe4hrend der Migration k\xf6nnen bereits migrierte Datens\xe4tze in der Auslieferung kurzzeitig ohne die umbenannten/neuen Felder erscheinen (".concat(a," Datens\xe4tze betroffen)."):"While the migration runs, already-migrated records may briefly appear in delivery without the renamed/new fields (".concat(a," records affected).")}),j&&(0,r.jsx)("p",{className:"text-sm text-red-700 dark:text-red-300",children:j}),f?(0,r.jsxs)("div",{className:"min-w-0 space-y-2 rounded-md border border-blue-300 bg-white p-3 dark:border-blue-700 dark:bg-gray-900",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:h?"".concat(a," Datens\xe4tze werden umgeschrieben. Das kann nicht per Klick r\xfcckg\xe4ngig gemacht werden â daf\xfcr gibt es die separate R\xfcckg\xe4ngig-Funktion nach Abschluss."):"".concat(a," records will be rewritten. This cannot be undone with one click â use the separate rollback action once it finishes.")}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>y(!1),disabled:v,className:"py-2 px-4 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50",children:h?"Zur\xfcck":"Back"}),(0,r.jsx)("button",{type:"button",onClick:I,disabled:v||!S,className:"inline-flex items-center gap-2 rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50",children:v?h?"Wird gestartetâ¦":"Startingâ¦":h?"Migration starten":"Start migration"})]})]}):(0,r.jsx)("button",{type:"button",onClick:()=>y(!0),disabled:!S,className:"inline-flex items-center gap-2 rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50",children:h?"Migration vorbereiten":"Prepare migration"})]})}let h=new Set(["completed","failed","rolledBack"]),x={planned:["Geplant","Planned"],running:["L\xe4uft","Running"],completed:["Abgeschlossen","Completed"],failed:["Fehlgeschlagen","Failed"],rolledBack:["Zur\xfcckgerollt","Rolled back"]};function b(e){var t,a,n;let{contentTypeId:s,migrationId:i,spaceId:l,locale:o,onFinished:d,onRollbackStarted:u}=e,m=o.startsWith("de"),[g,p]=(0,c.useState)(i),[b,f]=(0,c.useState)(null),[y,v]=(0,c.useState)(null),[k,j]=(0,c.useState)("idle"),[N,w]=(0,c.useState)(!1),[S,C]=(0,c.useState)(null),I=(0,c.useRef)(null),A=(0,c.useCallback)(()=>{I.current&&(clearInterval(I.current),I.current=null)},[]);(0,c.useEffect)(()=>A,[A]);let F=(0,c.useCallback)(e=>{A();let t=async()=>{let t="/api/cms/content-types/".concat(s,"/migrations/").concat(e,"?spaceId=").concat(encodeURIComponent(l)),a=await fetch(t);if(!a.ok){A(),v(m?"Status konnte nicht geladen werden.":"Could not load status.");return}let r=await a.json();v(null),f(r),h.has(r.status)&&(A(),null==d||d(r))};t(),I.current=setInterval(t,2e3)},[s,l,A,d,m]);async function R(e){w(!0),C(null);try{let t="/api/cms/content-types/".concat(s,"/migrations/").concat(g,"/rollback?spaceId=").concat(encodeURIComponent(l)),a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({includeChangedSince:e})}),r=await a.json().catch(()=>({}));if(!a.ok)throw Error(r.error||(m?"R\xfcckg\xe4ngig machen konnte nicht gestartet werden.":"Could not start the rollback."));j("idle");let n=r.migration;p(n.id),f(null),null==u||u(n),F(n.id)}catch(e){C(e instanceof Error?e.message:String(e))}finally{w(!1)}}if((0,c.useEffect)(()=>{p(i),f(null),j("idle"),F(i)},[i]),y)return(0,r.jsx)("p",{className:"text-sm text-red-700 dark:text-red-300",children:y});if(!b)return(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:m?"L\xe4dtâ¦":"Loadingâ¦"});let T=null!=(a=null==(t=x[b.status])?void 0:t[+!m])?a:b.status,M=b.totalRecords>0?Math.min(100,Math.round(b.processedRecords/b.totalRecords*100)):0,P="planned"===b.status||"running"===b.status,D="completed"===b.status&&"migrate"===b.kind&&!b.rollbackId;return(0,r.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium",children:T}),(0,r.jsxs)("span",{children:[m?"Verarbeitet":"Processed",": ",b.processedRecords," /"," ",b.totalRecords]}),(0,r.jsxs)("span",{children:[m?"Migriert":"Migrated",": ",b.migratedRecords]}),(0,r.jsxs)("span",{children:[m?"\xdcbersprungen":"Skipped",": ",b.ski
1ppedRecords]}),(0,r.jsxs)("span",{children:[m?"Fehlgeschlagen":"Failed",": ",b.failedRecords]})]}),P&&(0,r.jsx)("div",{role:"progressbar","aria-valuenow":M,"aria-valuemin":0,"aria-valuemax":100,className:"h-2 w-full min-w-0 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:(0,r.jsx)("div",{className:"h-full bg-blue-600 transition-all",style:{width:"".concat(M,"%")}})}),"failed"===b.status&&(0,r.jsxs)("div",{className:"min-w-0 space-y-2 rounded-md border border-red-300 bg-red-50 p-3 text-sm dark:border-red-800 dark:bg-red-900/20",children:[(0,r.jsx)("p",{className:"font-medium text-red-800 dark:text-red-300",children:null!=(n=b.error)?n:m?"Migration fehlgeschlagen.":"Migration failed."}),b.failedItems.length>0&&(0,r.jsx)("ul",{className:"min-w-0 list-inside list-disc space-y-1",children:b.failedItems.map(e=>(0,r.jsxs)("li",{className:"break-words",children:[(0,r.jsx)("code",{children:e.contentRecordId}),e.error?": ".concat(e.error):""]},e.contentRecordId))})]}),"completed"===b.status&&(0,r.jsxs)("div",{className:"min-w-0 space-y-2 rounded-md border border-green-300 bg-green-50 p-3 text-sm dark:border-green-800 dark:bg-green-900/20",children:[(0,r.jsx)("p",{className:"font-medium text-green-800 dark:text-green-300",children:m?"Migration abgeschlossen: ".concat(b.migratedRecords," migriert, ").concat(b.skippedRecords," \xfcbersprungen, ").concat(b.failedRecords," fehlgeschlagen."):"Migration completed: ".concat(b.migratedRecords," migrated, ").concat(b.skippedRecords," skipped, ").concat(b.failedRecords," failed.")}),b.rollbackId&&(0,r.jsx)("p",{children:m?"Diese Migration wurde bereits r\xfcckg\xe4ngig gemacht.":"This migration has already been rolled back."}),D&&"idle"===k&&(0,r.jsx)("button",{type:"button",onClick:()=>j("confirm"),className:"py-2 px-4 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700",children:m?"R\xfcckg\xe4ngig machen":"Undo migration"}),D&&"confirm"===k&&(0,r.jsxs)("div",{className:"min-w-0 space-y-2 rounded-md border border-amber-300 bg-white p-3 dark:border-amber-700 dark:bg-gray-900",children:[b.changedSinceCount?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm",children:m?"".concat(b.changedSinceCount," Datens\xe4tze wurden seit der Migration ge\xe4ndert. Sie k\xf6nnen beim R\xfcckg\xe4ngigmachen \xfcbersprungen (Standard) oder einbezogen werden â Letzteres verwirft die seitherigen \xc4nderungen aus der aktiven Fassung."):"".concat(b.changedSinceCount," records were changed since the migration. They can be skipped on rollback (default) or included â including them discards those changes from the active version.")}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>R(!1),disabled:N,className:"py-2 px-4 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50",children:m?"Ohne die ".concat(b.changedSinceCount," ge\xe4nderten"):"Without the ".concat(b.changedSinceCount," changed")}),(0,r.jsx)("button",{type:"button",onClick:()=>R(!0),disabled:N,className:"py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-red-600 hover:bg-red-700 disabled:opacity-50",children:m?"Inklusive der ".concat(b.changedSinceCount," ge\xe4nderten"):"Including the ".concat(b.changedSinceCount," changed")})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm",children:m?"Migration wirklich r\xfcckg\xe4ngig machen?":"Really undo this migration?"}),(0,r.jsx)("button",{type:"button",onClick:()=>R(!1),disabled:N,className:"py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-red-600 hover:bg-red-700 disabled:opacity-50",children:N?m?"Wird gestartetâ¦":"Startingâ¦":m?"R\xfcckg\xe4ngig best\xe4tigen":"Confirm undo"})]}),(0,r.jsx)("button",{type:"button",onClick:()=>j("idle"),disabled:N,className:"block text-sm text-gray-600 underline dark:text-gray-400",children:m?"Abbrechen":"Cancel"})]}),S&&(0,r.jsx)("p",{className:"text-sm text-red-700 dark:text-red-300",children:S})]}),"rolledBack"===b.status&&(0,r.jsx)("p",{className:"text-sm",children:m?"Diese Migration wurde r\xfcckg\xe4ngig gemacht.":"This migration has been rolled back."})]})}let f={planned:["Geplant","Planned"],running:["L\xe4uft","Running"],completed:["Abgeschlossen","Completed"],failed:["Fehlgeschlagen","Failed"],rolledBack:["Zur\xfcckgerollt","Rolled back"]};function y(e){let{migrations:t,loading:a,locale:n,onExpand:s}=e,i=n.startsWith("de");return(0,r.jsxs)("details",{className:"min-w-0 rounded-lg border border-gray-300 dark:border-gray-700",onToggle:e=>{e.target.open&&(null==s||s())},children:[(0,r.jsxs)("summary",{className:"cursor-pointer p-4 font-semibold",children:[i?"Migrationsverlauf":"Migration history",t.length>0&&" (".concat(t.length,")")]}),(0,r.jsxs)("div",{className:"min-w-0 space-y-2 border-t p-4",children:[a&&(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:i?"L\xe4dtâ¦":"Loadingâ¦"}),!a&&0===t.length&&(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:i?"F\xfcr dieses Modell wurde noch keine Migration ausgef\xfchrt.":"No migration has run for this model yet."}),t.length>0&&(0,r.jsx)("ul",{className:"min-w-0 space-y-2",children:t.map(e=>{var t,a;return(0,r.jsxs)("li",{className:"min-w-0 space-y-1 rounded border p-3 text-sm",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium",children:null!=(a=null==(t=f[e.status])?void 0:t[+!i])?a:e.status}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:"rollback"===e.kind?i?"R\xfcckg\xe4ngigmachung":"Rollback":"Migration"}),(0,r.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:function(e,t){let a=new Date(e);
1return Number.isNaN(a.getTime())?e:a.toLocaleString(t?"de-DE":"en-US")}(e.createdAt,i)})]}),(0,r.jsxs)("p",{className:"break-words",children:[i?"Migriert":"Migrated",": ",e.migratedRecords," \xb7"," ",i?"\xdcbersprungen":"Skipped",": ",e.skippedRecords," \xb7"," ",i?"Fehlgeschlagen":"Failed",": ",e.failedRecords," /"," ",e.totalRecords]}),e.error&&(0,r.jsx)("p",{className:"break-words text-red-700 dark:text-red-300",children:e.error}),e.rollbackOfId&&(0,r.jsxs)("p",{className:"break-words text-gray-600 dark:text-gray-400",children:[i?"R\xfcckg\xe4ngigmachung von":"Rollback of"," ",(0,r.jsx)("code",{children:e.rollbackOfId})]}),e.rollbackId&&(0,r.jsxs)("p",{className:"break-words text-gray-600 dark:text-gray-400",children:[i?"R\xfcckg\xe4ngig gemacht:":"Rolled back:"," ",(0,r.jsx)("code",{children:e.rollbackId})]})]},e.id)})})]})]})}var v=a(20063),k=a(41444);function j(e){let{isOpen:t,onClose:a,title:n,message:s,type:i}=e,l=(0,v.useRouter)(),o=(0,v.useParams)().locale;if(!t)return null;let d="success"===i;return(0,r.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,r.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full",children:[(0,r.jsx)("div",{className:"flex items-center justify-center mb-4",children:(0,r.jsx)("div",{className:"".concat(d?"bg-green-100":"bg-red-100"," rounded-full p-2"),children:d?(0,r.jsx)("svg",{className:"h-8 w-8 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,r.jsx)("svg",{className:"h-8 w-8 text-red-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})})}),(0,r.jsx)("h3",{className:"text-lg font-medium text-center text-gray-900 dark:text-white mb-2",children:n}),(0,r.jsx)("p",{className:"text-center text-gray-600 dark:text-gray-300 mb-6",children:s}),(0,r.jsx)("div",{className:"flex justify-center space-x-3",children:d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>{l.refresh(),l.push("/".concat(o,"/cms/content-types"))},className:"py-2 px-4 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Go Back to Content-Types"}),(0,r.jsx)("button",{type:"button",onClick:a,className:"py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Continue Editing"})]}):(0,r.jsx)("button",{type:"button",onClick:a,className:"py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500",children:"Close"})})]})})}var N=a(65361);function w(e){let{name:t,setName:a,displayName:n,setDisplayName:s,description:i,setDescription:l,isEditing:o}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"API Name - Content Type ID"}),(0,r.jsx)("input",{type:"text",id:"name",value:t,onChange:e=>a(e.target.value),className:"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",placeholder:"product",disabled:o,required:!0}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Used in API calls and code references. No spaces or special characters."})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"displayName",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Display Name"}),(0,r.jsx)("input",{type:"text",id:"displayName",value:n,onChange:e=>s(e.target.value),className:"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",placeholder:"Product",required:!0}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Shown in the UI."})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"description",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description (Optional)"}),(0,r.jsx)("textarea",{id:"description",value:i,onChange:e=>l(e.target.value),rows:3,className:"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",placeholder:"A description of this content type"})]})]})}var S=a(73511),C=a(85514),I=a(96059);let A=new Set(["text","textarea","longtext","richtext","markdown","symbol","slug","url","email"]),F=new Set(["number","integer"]),R=new Set(["date","datetime"]),T=new Set(["multiselect","referenceArray","assetArray","stringArray"]),M=new Set(["asset","image","media","file","assetArray"]);function P(e){return!!e&&Object.entries(e).some(e=>{let[,t]=e;return null!=t&&(!("string"==typeof t||Array.isArray(t))||t.length>0)})}function D(e){var t,a,n;let{fieldId:s,fieldType:i,validations:l,onChange:o}=e,[d,u]=(0,c.useState)(P(l)),m=null!=l?l:{},g=e=>{o({...m,...e})},p=A.has(i),h=F.has(i),x=R.has(i),b=T.has(i),f=M.has(i);return p||h||x||b||f?(0,r.jsxs)("div",{className:"mt-4 border-t border-gray-200 dark:border-gray-700 pt-3",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>u(e=>!e),className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-200 hover:text-gray-900 dark:hover:text-white",children:[d?(0,r.jsx)(C.A,{className:"w-4 h-4"}):(0,r.jsx)(I.A,{className:"w-4 h-4"}),"Validations",P(l)&&(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide bg-blue-100 dar
1k:bg-blue-900/40 text-blue-700 dark:text-blue-200 px-1.5 py-0.5 rounded",children:"active"})]}),d&&(0,r.jsxs)("div",{className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-3",children:[(p||h)&&(0,r.jsxs)("label",{htmlFor:"val-unique-".concat(s),className:"md:col-span-2 flex items-start gap-2 cursor-pointer",children:[(0,r.jsx)("input",{id:"val-unique-".concat(s),type:"checkbox",checked:!!m.unique,onChange:e=>g({unique:e.target.checked||void 0}),className:"mt-0.5 h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),(0,r.jsxs)("span",{className:"text-sm text-gray-700 dark:text-gray-200",children:["Unique",(0,r.jsx)("span",{className:"block text-xs text-gray-500 dark:text-gray-400",children:"No two entries of this content type may share the same value."})]})]}),p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E,{id:"val-minlen-".concat(s),label:"Minimum length",value:m.minLength,placeholder:"No minimum",min:0,onChange:e=>g({minLength:e})}),(0,r.jsx)(E,{id:"val-maxlen-".concat(s),label:"Maximum length",value:m.maxLength,placeholder:"No maximum",min:0,onChange:e=>g({maxLength:e})}),(0,r.jsx)(z,{id:"val-pattern-".concat(s),label:"Regex pattern",value:m.pattern,placeholder:"^[a-z0-9-]+$",onChange:e=>g({pattern:e||void 0}),className:"md:col-span-2"}),(0,r.jsx)(z,{id:"val-in-".concat(s),label:"Allowed values",value:(null!=(t=m.in)?t:[]).join(", "),placeholder:"comma, separated, list",onChange:e=>g({in:e?e.split(",").map(e=>e.trim()).filter(Boolean):void 0}),className:"md:col-span-2"}),(0,r.jsx)(U,{id:"val-format-".concat(s),label:"Format",value:null!=(a=m.format)?a:"",options:[{value:"",label:"â"},{value:"email",label:"Email"},{value:"url",label:"URL"}],onChange:e=>g({format:""===e?void 0:e})})]}),h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E,{id:"val-min-".concat(s),label:"Minimum",value:m.min,placeholder:"No minimum",onChange:e=>g({min:e})}),(0,r.jsx)(E,{id:"val-max-".concat(s),label:"Maximum",value:m.max,placeholder:"No maximum",onChange:e=>g({max:e})})]}),x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L,{id:"val-mindate-".concat(s),label:"Earliest date",value:m.minDate,onChange:e=>g({minDate:e||void 0})}),(0,r.jsx)(L,{id:"val-maxdate-".concat(s),label:"Latest date",value:m.maxDate,onChange:e=>g({maxDate:e||void 0})})]}),b&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E,{id:"val-minitems-".concat(s),label:"Minimum items",value:m.minItems,placeholder:"No minimum",min:0,onChange:e=>g({minItems:e})}),(0,r.jsx)(E,{id:"val-maxitems-".concat(s),label:"Maximum items",value:m.max
1Items,placeholder:"No maximum",min:0,onChange:e=>g({maxItems:e})})]}),f&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(z,{id:"val-mime-".concat(s),label:"Allowed file types (MIME)",value:(null!=(n=m.allowedMimeTypes)?n:[]).join(", "),placeholder:"image/png, image/jpeg, image/*",onChange:e=>g({allowedMimeTypes:e?e.split(",").map(e=>e.trim()).filter(Boolean):void 0}),className:"md:col-span-2"}),(0,r.jsx)(E,{id:"val-maxsize-".concat(s),label:"Max file size (MB)",value:null!=m.maxFileSizeBytes?Math.round(m.maxFileSizeBytes/1024/1024*100)/100:void 0,placeholder:"No limit",min:0,onChange:e=>g({maxFileSizeBytes:null==e?void 0:Math.round(1024*e*1024)}),className:"md:col-span-2"}),(0,r.jsx)(E,{id:"val-minw-".concat(s),label:"Min width (px)",value:m.minWidth,placeholder:"No minimum",min:0,onChange:e=>g({minWidth:e})}),(0,r.jsx)(E,{id:"val-maxw-".concat(s),label:"Max width (px)",value:m.maxWidth,placeholder:"No maximum",min:0,onChange:e=>g({maxWidth:e})}),(0,r.jsx)(E,{id:"val-minh-".concat(s),label:"Min height (px)",value:m.minHeight,placeholder:"No minimum",min:0,onChange:e=>g({minHeight:e})}),(0,r.jsx)(E,{id:"val-maxh-".concat(s),label:"Max height (px)",value:m.maxHeight,placeholder:"No maximum",min:0,onChange:e=>g({maxHeight:e})})]})]})]}):null}let O="w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-50 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500";function E(e){var t;return(0,r.jsxs)("div",{className:e.className,children:[(0,r.jsx)("label",{htmlFor:e.id,className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:e.label}),(0,r.jsx)("input",{id:e.id,type:"number",value:null!=(t=e.value)?t:"",placeholder:e.placeholder,min:e.min,onChange:t=>{let a=t.target.value;if(""===a)return e.onChange(void 0);let r=Number(a);e.onChange(Number.isFinite(r)?r:void 0)},className:O})]})}function z(e){var t;return(0,r.jsxs)("div",{className:e.className,children:[(0,r.jsx)("label",{htmlFor:e.id,className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:e.label}),(0,r.jsx)("input",{id:e.id,type:"text",value:null!=(t=e.value)?t:"",placeholder:e.placeholder,onChange:t=>e.onChange(t.target.value),className:"".concat(O," font-mono text-xs")})]})}function L(e){var t;return(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:e.id,className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:e.label}),(0,r.jsx)("input",{id:e.id,type:"date",value:null!=(t=e.value)?t:"",onChange:t=>e.onChange(t.target.value),className:O})]})}function U(e){return(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:e.id,className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:e.label}),(0,r.jsx)("select",{id:e.id,value:e.value,onChange:t=>e.onChange(t.target.value),className:O,children:e.options.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]})}var _=a(84875);function W(e){var t,a,n,s;let{field:i,spaceId:l,environmentId:o,parentContentTypeName:d,onChange:u}=e,[m,g]=(0,c.useState)([]),[p,h]=(0,c.useState)(!1),[x,b]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!l)return;let e=!1;h(!0),b(null);let t=new URLSearchParams({spaceId:l});return o&&t.set("environmentId",o),fetch("/api/cms/content-types?".concat(t.toString())).then(e=>{if(!e.ok)throw Error("HTTP ".concat(e.status));return e.json()}).then(t=>{if(e)return;let a=Array.isArray(t)?t.map(e=>{var t;return{id:e.id,name:e.name,displayName:null!=(t=e.displayName)?t:e.name}}):[];g((d?a.filter(e=>e.name!==d):a).sort((e,t)=>e.displayName.localeCompare(t.displayName)))}).catch(t=>{var a;e||b(String(null!=(a=t.message)?a:t))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,o,d]);let f=null!=(t=i.settings)?t:{},y=(0,c.useMemo)(()=>{var e;return new Set(null!=(e=f.allowedContentTypeNames)?e:[])},[f.allowedContentTypeNames]),v=e=>{u({...f,...e})},k=e=>t=>{let a=t.target.value;if(""===a){let t={...f};delete t[e],u(t);return}let r=Number(a);Number.isFinite(r)&&v({[e]:r})},j=0===y.size;return(0,r.jsxs)("div",{className:"mt-4 p-4 border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 rounded-md space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Allowed nested content types"}),(0,r.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:"Editors will be able to add items of these types as nested blocks inside this field. At least one must be selected."}),j&&(0,r.jsx)("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:"Pick at least one allowed content type â saves will be rejected otherwise."}),(0,r.jsx)("div",{className:"mt-3",children:l?p?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Loading content typesâ¦"}):x?(0,r.jsxs)("p",{className:"text-sm text-red-600",children:["Failed to load content types: ",x]}):0===m.length?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No other content types in this environment yet. Create at least one to use as a nested block."}):(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 max-h-56 overflow-y-auto pr-1",children:m.map(e=>{let t="blok-".concat(i.id,"-").concat(e.id);return(0,r.jsxs)("label",{htmlFor:t,className:"flex items-center gap-2 px-2 py-1 rounded hover:bg-amber-100/60 dark:hover:bg-amber-900/30 cursor-pointer",children:[(0,r.jsx)("input",{id:t,type:"checkbox","data-testid":"bloks-allowed-".concat(e.name),checked:y.has(e.name),onChange:()=>(e=>{let t=new Set(y);t.has(e)?t.delete(e):t.add(e),v({allowedContentTypeNames:Array.from(t)})})(e.name),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsxs)("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:[e.displayName,(0,r.jsxs)("span",{className:"ml-1 text-xs text-gray-500",children:["(",e.name,")"]})]})]},e.id)})}):(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No active space selected â pick one to load available content types."})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Item limits & nesting"}),(0,r.jsxs)("div",{className:"mt-2 grid grid-cols-1 sm:grid-cols-3 gap-3",children:[(0,r.jsxs)("label",{className:"block text-sm",children:[(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:"Min items"}),(0,r.jsx)("input",{type:"number",min:0,value:null!=(a=f.minItems)?a:"",onCh
1ange:k("minItems"),placeholder:"none","data-testid":"bloks-min-items",className:"mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 dark:bg-gray-800 text-sm focus:ring-blue-500 focus:border-blue-500"})]}),(0,r.jsxs)("label",{className:"block text-sm",children:[(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:"Max items"}),(0,r.jsx)("input",{type:"number",min:0,value:null!=(n=f.maxItems)?n:"",onChange:k("maxItems"),placeholder:"none","data-testid":"bloks-max-items",className:"mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 dark:bg-gray-800 text-sm focus:ring-blue-500 focus:border-blue-500"})]}),(0,r.jsxs)("label",{className:"block text-sm",children:[(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:"Max nesting depth"}),(0,r.jsx)("input",{type:"number",min:1,max:10,value:null!=(s=f.maxDepth)?s:"",onChange:k("maxDepth"),placeholder:String(_.m4),"data-testid":"bloks-max-depth",className:"mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 dark:bg-gray-800 text-sm focus:ring-blue-500 focus:border-blue-500"}),(0,r.jsxs)("span",{className:"mt-1 block text-xs text-gray-500",children:["Default ",_.m4,". Hard cap enforced server-side."]})]})]})]})]})}function V(e){var t;let{field:a,spaceId:n,environmentId:s,onChange:i}=e,[l,o]=(0,c.useState)([]),[d,u]=(0,c.useState)(!1),[m,g]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!n)return;let e=!1;u(!0),g(null);let t=new URLSearchParams({spaceId:n});return s&&t.set("environmentId",s),fetch("/api/cms/content-types?".concat(t.toString())).then(e=>{if(!e.ok)throw Error("HTTP ".concat(e.status));return e.json()}).then(t=>{e||o((Array.isArray(t)?t.map(e=>{var t;return{id:e.id,name:e.name,displayName:null!=(t=e.displayName)?t:e.name}}):[]).sort((e,t)=>e.displayName.localeCompare(t.displayName)))}).catch(t=>{var a;e||g(String(null!=(a=t.message)?a:t))}).finally(()=>{e||u(!1)}),()=>{e=!0}},[n,s]);let p=null!=(t=a.settings)?t:{},h=(0,c.useMemo)(()=>{var e;return new Set(null!=(e=p.linkContentTypes)?e:[])},[p.linkContentTypes]),x=0===h.size;return(0,r.jsxs)("div",{className:"mt-4 p-4 border border-sky-200 dark:border-sky-800 bg-sky-50 dark:bg-sky-900/20 rounded-md",children:[(0,r.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Allowed reference types"}),(0,r.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:"Restrict which content types this field may point to. The record picker only offers entries of these types, and writes are rejected if a reference points elsewhere."}),(0,r.jsx)("p",{className:"mt-2 text-xs ".concat(x?"text-sky-700 dark:text-sky-300":"text-gray-500 dark:text-gray-400"),children:x?"No restriction â any content type may be referenced.":"".concat(h.size," type").concat(1===h.size?"":"s"," allowed.")}),(0,r.jsx)("div",{className:"mt-3",children:n?d?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Loading content typesâ¦"}):m?(0,r.jsxs)("p",{className:"text-sm text-red-600",children:["Failed to load content types: ",m]}):0===l.length?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No content types in this environment yet."}):(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 max-h-56 overflow-y-auto pr-1",children:l.map(e=>{let t="ref-".concat(a.id,"-").concat(e.id);return(0,r.jsxs)("label",{htmlFor:t,className:"flex items-center gap-2 px-2 py-1 rounded hover:bg-sky-100/60 dark:hover:bg-sky-900/30 cursor-pointer",children:[(0,r.jsx)("input",{id:t,type:"checkbox","data-testid":"ref-allowed-".concat(e.name),checked:h.has(e.name),onChange:()=>(e=>{let t=new Set(h);t.has(e)?t.delete(e):t.add(e),i({...p,linkContentTypes:Array.from(t)})})(e.name),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsxs)("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:[e.displayName,(0,r.jsxs)("span",{className:"ml-1 text-xs text-gray-500",children:["(",e.name,")"]})]})]},e.id)})}):(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No active space selected â pick one to load available content types."})})]})}let B=["bold","italic","underline","code","superscript","subscript","strikethrough"],$=["heading-1","heading-2","heading-3","heading-4","heading-5","heading-6","ordered-list","unordered-list","hr","blockquote","embedded-entry-block","embedded-asset-block","embedded-entry-inline","entry-hyperlink","asset-hyperlink","hyperlink","table"];function q(e){var t,a,n,s;let{field:i,onChange:l}=e,o=null!=(t=i.settings)?t:{},d=null!=(a=o.richtext)?a:{},c=void 0!==d.enabledMarks,u=void 0!==d.enabledNodeTypes,m=new Set(null!=(n=d.enabledMarks)?n:[]),g=new Set(null!=(s=d.enabledNodeTypes)?s:[]),p=e=>{l({...o,richtext:{...d,...e}})};return(0,r.jsxs)("div",{className:"mt-4 p-4 border border-sky-200 dark:border-sky-800 bg-sky-50 dark:bg-sky-900/20 rounded-md space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h5",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Toolbar restrictions"}),(0,r.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:"Restrict which marks and node types this field allows. The editor toolbar only offers the checked ones, and writes are rejected if the content contains anything else â matching how Contentfulâs rich-text validations work."})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{htmlFor:"richtext-marks-restrict-".concat(i.id),className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)("input",{id:"richtext-marks-restrict-".concat(i.id),type:"checkbox",checked:c,onChange:e=>{p({enabledMarks:e.target.checked?Array.from(m):void 0})},className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsx)("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:"Restrict marks"})]}),c?(0,r.jsx)("div",{className:"mt-2 ml-6 grid grid-cols-2 sm:grid-cols-3 gap-2",children:B.map(e=>{let t="richtext-mark-".concat(i.id,"-").concat(e);return(0,r.jsxs)("label",{htmlFor:t,className:"flex items-center gap-2 px-2 py-1 rounded hover:bg-sky-100/60 dark:hover:bg-sky-900/30 cursor-pointer",children:[(0,r.jsx)("input",{id:t,type:"checkbox","data-testid":"richtext-mark-".concat(e),checked:m.has(e),onChange:()=>(e=>{let t=new Set(m);t.has(e)?t.delete(e):t.add(e),p({enabledMarks:Array.from(t)})})(e),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsx)("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:e})]},e)})}):(0,r.jsx)("p",{className:"mt-1 ml-6 text-xs text-sky-700 dark:text-sky-300",children:"No restriction â all marks allowed."})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{htmlFor:"richtext-nodes-restrict-".concat(i.id),className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)("input",{id:"richtext-nodes-restrict-".concat(i.id),type:"checkbox",checked:u,onChange:e=>{p({enabledNodeTypes:e.target.checked?Array.from(g):void 0})},className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsx)("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:"Restrict node types"})]}),u?(0,r.jsx)("div",{className:"mt-2 ml-6 grid grid-cols-2 sm:grid-cols-3 gap-2",children:$.map(e=>{let t="richtext-node-".concat(i.id,"-").concat(e);return(0,r.jsxs)("label",{htmlFor:t,className:"flex items-center gap-2 px-2 py-1 rounded hover:bg-sky-100/60 dark:hover:bg-sky-900/30 cursor-pointer",children:[(0,r.jsx)("input",{id:t,type:"checkbox","data-testid":"richtext-node-".concat(e),checked:g.has(e),onChange:()=>(e=>{let t=new Set(g);t.has(e)?t.delete(e):t.add(e),p({enabledNodeTypes:Array.from(t)})})(e),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsx)("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:e})]},e)})}):(0,r.jsx)("p",{className:"mt-1 ml-6 text-xs text-sky-700 dark:text-sky-300",children:"No restriction â all node types allowed."})]})]})}var G=a(22064);let J=new Set(["text","textarea","symbol","slug","url","email","color","markdown","number","integer","boolean"]);function H(e){var t,a,n,s,i,l;let{field:o,index:d,fieldTypes:c,languages:u,loadingLanguages:m,locale:g,spaceId:p,environmentId:h,parentContentTypeName:x,onRemoveField:b,onFieldChange:f,onAddOption:y,onRemoveOption:v,onOptionChange:k,setFields:j,fields:N,dragHandleProps:w,isOpen:S,toggleFieldOpen:C}=e;return(0,r.jsxs)("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center p-4 hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer",children:[(0,r.jsxs)("div",{className:"flex items-center flex-grow",children:[" ",(0,r.jsxs)("span",{...w,className:"cursor-grab mr-2",children:[" ",(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v12a1 1 0 11-2 0V4a1 1 0 011-1zM4 10a1 1 0 011-1h10a1 1 0 110 2H5a1 1 0 01-1-1z",clipRule:"evenodd"}),(0,r.jsx)("path",{d:"M3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM10 3a1 1 0 011 1v12a1 1 0 11-2 0V4a1 1 0 011-1z"})," "]})]}),(0,r.jsxs)("h4",{className:"text-md font-medium flex-grow",onClick:()=>C&&C(o.id),children:[o.name?o.name:"Field ".concat(d+1),o.type&&(0,r.jsxs)("span",{className:"text-sm text-gray-500 ml-2",children:["(",(null==(t=c.find(e=>e.value===o.type))?void 0:t.label)||o.type,")"]})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-3 flex-shrink-0",children:[" ",(0,r.jsx)("button",{type:"button",title:"Remove Field",onClick:e=>{e.stopPropagation(),b(o.id)},className:"text-red-600 hover:text-red-800 text-sm p-1 rounded hover:bg-red-100 dark:hover:bg-red-900/50",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,r.jsx)("button",{type:"button",title:S?"Collapse Field":"Expand Field",onClick:()=>C&&C(o.id),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-500 transition-transform duration-200 ".concat(S?"rotate-180":""),viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})})," "]})]}),S&&(0,r.jsxs)("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"field-name-".concat(o.id),className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"API Name - Field ID"}),(0,r.jsx)("input",{type:"text",id:"field-name-".concat(o.id),value:o.name,onChange:e=>f(o.id,"name",e.target.value),className:"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",placeholder:"title"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Used in API calls and GraphQL queries"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"field-display-name-".concat(o.id),className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Display Name"}),(0,r.jsx)("input",{type:"text",id:"field-display-name-".concat(o.id),value:o.displayName||"",onChange:e=>f(o.id,"displayName",e.target.value),className:"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",placeholder:((l=o.name)?l.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()):"")||"Display name"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Shown in the UI"})]})]}),(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("label",{htmlFor:"field-type-".concat(o.id),className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Field Type"}),(0,r.jsxs)("select",{id:"field-type-".concat(o.id),value:o.type,onCh
1ange:e=>f(o.id,"type",e.target.value),className:"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",children:[!c.some(e=>e.value===o.type)&&(0,r.jsxs)("option",{value:o.type,children:[o.type," (unrecognized type)"]}),c.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))]})]}),(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("label",{htmlFor:"field-description-".concat(o.id),className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description (Optional)"}),(0,r.jsx)("input",{type:"text",id:"field-description-".concat(o.id),value:o.description||"",onChange:e=>f(o.id,"description",e.target.value),className:"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",placeholder:"A description of this field"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Helps content editors understand the purpose of this field"})]}),J.has(o.type)&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("label",{htmlFor:"field-default-".concat(o.id),className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Default value (Optional)"}),"boolean"===o.type?(0,r.jsxs)("select",{id:"field-default-".concat(o.id),value:!0===o.defaultValue?"true":!1===o.defaultValue?"false":"",onChange:e=>f(o.id,"defaultValue",""===e.target.value?void 0:"true"===e.target.value),className:"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",children:[(0,r.jsx)("option",{value:"",children:"â none â"}),(0,r.jsx)("option",{value:"true",children:"true"}),(0,r.jsx)("option",{value:"false",children:"false"})]}):(0,r.jsx)("input",{type:"number"===o.type||"integer"===o.type?"number":"color"===o.type?"color":"text",id:"field-default-".concat(o.id),value:void 0===o.defaultValue||null===o.defaultValue?"color"===o.type?"#000000":"":String(o.defaultValue),onChange:e=>{let t=e.target.value;f(o.id,"defaultValue",""===t?void 0:"number"===o.type||"integer"===o.type?Number(t):t)},className:"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",placeholder:"Pre-filled on new records"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Pre-filled when a new record of this type is created. Editors can still change it."})]}),"group"===o.type&&(0,r.jsx)("p",{className:"mb-4 text-sm text-gray-600 dark:text-gray-400 italic","data-testid":"group-hint-".concat(o.id),children:"Visual-only section header â groups the fields below it in the record editor. Does not store any data."}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:["group"!==o.type&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("input",{type:"checkbox",id:"field-required-".concat(o.id),checked:o.required,onChange:e=>f(o.id,"required",e.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsx)("label",{htmlFor:"field-required-".concat(o.id),className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:"Required field"})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("input",{type:"checkbox",id:"field-technical-".concat(o.id),checked:o.technical||!1,onChange:e=>f(o.id,"technical",e.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsx)("label",{htmlFor:"field-technical-".concat(o.id),className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:"Technical field"})]}),(0,r.jsx)("p",{className:"ml-6 text-xs text-gray-500 dark:text-gray-400",children:"Collapsed by default in the record editor. Delivery is unaffected â the field is still returned as usual."}),"text"===o.type&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("input",{type:"checkbox",id:"field-is-title-".concat(o.id),checked:o.isTitle||!1,onChange:e=>{e.target.checked?j(N.map(e=>({...e,isTitle:e.id===o.id}))):f(o.id,"isTitle",!1)},className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,r.jsx)("label",{htmlFor:"field-is-title-".concat(o.id),className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:"This field represents the Entry title"})]})]}),(0,r.jsx)("div",{className:"space-y-2",children:G.cm.includes(o.type)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("input",{type:"checkbox",id:"field-localized-".concat(o.id),checked:o.localized||!1,onChange:e=>f(o.id,"localized",e.target.checked),disabled:m||0===u.length,className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded ".concat(m||0===u.length?"opacity-50 cursor-not-allowed":"")}),(0,r.jsxs)("label",{htmlFor:"field-localized-".concat(o.id),className:"ml-2 block text-sm text-gray-700 dark:text-gray-300 ".concat(m||0===u.length?"opacity-50":""),children:["Enable localization of this field",m&&(0,r.jsx)("span",{className:"ml-1 text-xs text-gray-500",children:"(loading languages...)"})]})]}),(0,r.jsx)("div",{className:"mt-1 ml-6 text-xs text-gray-500 dark:text-gray-400",children:m?"Checking available languages...":u.length>0?o.localized&&(0,r.jsxs)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Available languages:"," ",u.map(e=>
1e.name).join(", ")]}):(0,r.jsx)("div",{className:"info-message p-2 bg-blue-50 dark:bg-blue-900/20 border border-blue-100 dark:border-blue-800 rounded-md",children:(0,r.jsxs)("p",{className:"text-gray-700 dark:text-gray-300 text-sm",children:["No languages available for localization. Visit"," ",(0,r.jsx)("a",{href:"/".concat(g,"/cms/settings/localization"),className:"font-medium text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:"Localization Settings"})," ","to add languages."]})})})]})})]}),(0,r.jsx)(D,{fieldId:o.id,fieldType:o.type,validations:o.validations,onChange:e=>f(o.id,"validations",e)}),"bloks"===o.type&&(0,r.jsx)(W,{field:o,spaceId:p,environmentId:h,parentContentTypeName:x,onChange:e=>f(o.id,"settings",e)}),("reference"===o.type||"referenceArray"===o.type)&&(0,r.jsx)(V,{field:o,spaceId:p,environmentId:h,parentContentTypeName:x,onChange:e=>f(o.id,"settings",e)}),"richtext"===o.type&&(0,r.jsx)(q,{field:o,onChange:e=>f(o.id,"settings",e)}),("select"===o.type||"multiselect"===o.type)&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,r.jsx)("h5",{className:"text-sm font-medium",children:"Options"}),(0,r.jsx)("button",{type:"button",onClick:()=>y(o.id),className:"text-blue-600 hover:text-blue-800 text-sm",children:"Add Option"})]}),o.options&&o.options.length>0?(0,r.jsx)("div",{className:"space-y-2",children:o.options.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("input",{type:"text",value:e.label,onChange:e=>k(o.id,t,"label",e.target.value),className:"flex-1 px-3 py-1 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",placeholder:"Label"}),(0,r.jsx)("input",{type:"text",value:e.value,onChange:e=>k(o.id,t,"value",e.target.value),className:"flex-1 px-3 py-1 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",placeholder:"Value"}),(0,r.jsx)("button",{type:"button",onClick:()=>v(o.id,t),className:"text-red-600 hover:text-red-800",children:"â"})]},t))}):(0,r.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:'No options added yet. Click "Add Option" to add one.'})]}),"slug"===o.type&&(0,r.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Auto-generate from"}),(0,r.jsxs)("select",{value:null!=(s=null==(a=o.settings)?void 0:a.sourceField)?s:"",onChange:e=>{var t;return f(o.id,"settings",{...null!=(t=o.settings)?t:{},sourceField:e.target.value||void 0})},className:"w-full px-3 py-1.5 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 text-sm",children:[(0,r.jsx)("option",{value:"",children:"â none (manual entry) â"}),N.filter(e=>e.id!==o.id&&["text","textarea","symbol","richtext"].includes(e.type)).map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.id))]}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"The slug tracks this field until the editor edits it."})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Strategy"}),(0,r.jsxs)("select",{value:null!=(i=null==(n=o.settings)?void 0:n.strategy)?i:"kebab",onChange:e=>{var t;return f(o.id,"settings",{...null!=(t=o.settings)?t:{},strategy:e.target.value})},className:"w-full px-3 py-1.5 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 text-sm",children:[(0,r.jsx)("option",{value:"kebab",children:"kebab-case (my-post-title)"}),(0,r.jsx)("option",{value:"snake",children:"snake_case (my_post_title)"}),(0,r.jsx)("option",{value:"lower",children:"lowercase (myposttitle)"})]})]})]})]})]})}let K=[{label:"Text (Short)",value:"text"},{label:"Text (Long)",value:"textarea"},{label:"Rich Text",value:"richtext"},{label:"Markdown",value:"markdown"},{label:"Slug (URL-safe)",value:"slug"},{label:"URL",value:"url"},{label:"Email",value:"email"},{label:"Color (Hex)",value:"color"},{label:"Number",value:"number"},{label:"Integer",value:"integer"},{label:"Boolean",value:"boolean"},{label:"Date",value:"date"},{label:"Date + Time",value:"datetime"},{label:"Image",value:"image"},{label:"File",value:"file"},{label:"Media (Any)",value:"asset"},{label:"Media (Multiple)",value:"assetArray"},{label:"GPX Track",value:"gpx"},{label:"Reference",value:"reference"},{label:"Reference (Multiple)",value:"referenceArray"},{label:"Select",value:"select"},{label:"Location (Lat/Lng)",value:"location"},{label:"Multi-select",value:"multiselect"},{label:"Text List (Free-form)",value:"stringArray"},{label:"Bloks (Nested Components)",value:"bloks"},{label:"Group / Section (Visual Only)",value:"group"},{label:"Link (Multilink)",value:"multilink"},{label:"JSON / Object",value:"json"}];function Z(e){let{fields:t,setFields:a,languages:n,loadingLanguages:s,locale:i,openFieldIds:l,toggleFieldOpen:o,spaceId:d,environmentId:c,parentContentTypeName:u}=e,m=e=>{a(t.filter(t=>t.id!==e))},g=(e,r,n)=>{a(t.map(t=>{if(t.id===e){if("type"===r){let e={...t,[r]:n};return t.isTitle&&!G.A.includes(n)&&(e.isTitle=!1),t.localized&&!G.cm.includes(n)&&(e.localized=!1),e}return{...t,[r]:n}}return t}))},p=e=>{a(t.map(t=>{if(t.id===e){let e=t.options||[];return{...t,options:[...e,{label:"",value:""}]}}return t}))},h=(e,r)=>{a(t.map(t=>{if(t.id===e){let e=[...t.options||[]];return e.splice(r,1),{...t,options:e}}return t}))},x=(e,r,n,s)=>{a(t.map(t=>{if(t.id===e){let e=[...t.options||[]];return e[r]={...e[r],[n]:s},{...t,options:e}}return t}))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,r.jsx)("h3",{className:"text-lg font-medium",children:"Fields"}),(0,r.jsxs)("div",{className:"space-x-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>
1t.forEach(e=>o(e.id)),className:"text-sm text-blue-600 hover:underline",disabled:0===t.length||t.length===l.size,children:"Open All"}),(0,r.jsx)("button",{type:"button",onClick:()=>t.forEach(e=>l.has(e.id)&&o(e.id)),className:"text-sm text-blue-600 hover:underline",disabled:0===l.size,children:"Close All"})]})]}),(0,r.jsx)(S.JY,{onDragEnd:e=>{let{source:r,destination:n}=e;if(!n)return;let s=Array.from(t),[i]=s.splice(r.index,1);s.splice(n.index,0,i),a(s)},children:(0,r.jsx)(S.gL,{droppableId:"fieldsDroppable",children:e=>(0,r.jsxs)("div",{...e.droppableProps,ref:e.innerRef,className:"space-y-4",children:[t.map((e,b)=>(0,r.jsx)(S.sx,{draggableId:e.id,index:b,children:f=>(0,r.jsx)("div",{ref:f.innerRef,...f.draggableProps,children:(0,r.jsx)(H,{field:e,index:b,fieldTypes:K,languages:n,loadingLanguages:s,locale:i,spaceId:d,environmentId:c,parentContentTypeName:u,onRemoveField:m,onFieldChange:g,onAddOption:p,onRemoveOption:h,onOptionChange:x,setFields:a,fields:t,dragHandleProps:f.dragHandleProps,isOpen:l.has(e.id),toggleFieldOpen:o})})},e.id)),e.placeholder]})})}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)("button",{type:"button",onClick:()=>{let e=crypto.randomUUID();a([...t,{id:e,name:"",type:"text",required:!1}]),o(e)},className:"w-full py-2 px-4 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Add Field"})})]})}function Q(e){let{schema:t}=e,a=t?JSON.stringify(t,null,2):"";return(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"generatedSchemaDisplay",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Generated JSON Schema (Read-only)"}),(0,r.jsx)("pre",{id:"generatedSchemaDisplay",className:"w-full p-3 border border-gray-300 dark:border-gray-700 rounded-md bg-gray-50 dark:bg-gray-900 text-xs text-gray-800 dark:text-gray-200 overflow-auto whitespace-pre-wrap break-words",style:{maxHeight:"300px"},children:a||"Schema will generate as you add fields..."}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"This schema is automatically generated based on the fields above and will be saved."})]})}var X=a(25589),Y=a(86327),ee=a(72569);let et=e=>e instanceof DOMException&&"AbortError"===e.name||e instanceof TypeError&&/failed to fetch/i.test(e.message);function ea(e){var t,a,s,i,l,o;let{locale:u,spaceId:m,initialData:g={},isEditing:h=!1}=e,x=(0,v.useRouter)(),[f,S]=(0,c.useState)(null),[C,I]=(0,c.useState)(g.updatedAt),[A,F]=(0,c.useState)(!1),[R,T]=(0,c.useState)(!1),[M,P]=(0,c.useState)(null),[D,O]=(0,c.useState)(null),[E,z]=(0,c.useState)(!1),[L,U]=(0,c.useState)(!1),[_,W]=(0,c.useState)(null!=(s=g.activeMigration)?s:null),[V,B]=(0,c.useState)([]),[$,q]=(0,c.useState)(!1),[G,J]=(0,c.useState)(g.name||""),[H,K]=(0,c.useState)(g.displayName||""),[ea,er]=(0,c.useState)(g.description||""),[en,es]=(0,c.useState)(g.fields||[{id:crypto.randomUUID(),name:"",type:"text",required:!1}]);(0,c.useEffect)(()=>{S(null)},[G,H,ea,en]);let ei=(0,c.useRef)("");ei.current=JSON.stringify([G,H,ea,en]);let[el,eo]=(0,c.useState)(void 0),[ed,ec]=(0,c.useState)(void 0),[eu,em]=(0,c.useState)(new Set),[eg,ep]=(0,c.useState)(null),[eh,ex]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let e=localStorage.getItem("cms_selected_space");k.v.log("Reading context from localStorage - Space:",e),eo(null!=e?e:void 0);let t=m||e;if(t){let e=localStorage.getItem("cms_selected_environment_".concat(t));k.v.log("Reading context from localStorage - Environment for space ".concat(t,":"),e),e?ec(e):(k.v.warn("No environment ID found in localStorage for space ".concat(t)),ec(void 0))}else k.v.warn("No space ID found (prop or localStorage)."),ec(void 0)},[m]);let{languages:eb,loadingLanguages:ef}=function(e){let[t,a]=(0,c.useState)([]),[r,n]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{(async()=>{if(!e){k.v.log("No spaceId provided, skipping language fetch"),n(!1);return}n(!0);try{k.v.log("Fetching languages for spaceId: ".concat(e));let t=await fetch("/api/cms/localization/languages?spaceId=".concat(e));if(t.ok){let r=await t.json();k.v.log("Languages fetched:",r),k.v.log("Raw languages data returned from API:",r),Array.isArray(r)&&0===r.length&&k.v.
1warn("Server returned empty languages array - this may indicate no languages are configured for this environment"),Array.isArray(r)&&r.length>0&&(k.v.log("Found languages before filtering:",r.length),r.forEach((e,t)=>{k.v.log("Language ".concat(t,":"),{id:e.id,code:e.code,name:e.name,isDefault:e.isDefault,isActive:e.isActive,spaceId:e.spaceId||"unknown"})}));let n=r.filter(e=>e.isActive);a(n),k.v.log("Space ID used for languages request:",e),k.v.log("Languages after filtering for active:",n),k.v.log("Active languages count:",n.length)}else{let e=await t.text();k.v.error("Failed to fetch languages - HTTP status:",t.status,"Response:",e);try{let t=JSON.parse(e);k.v.error("Error details:",t)}catch(e){}}}catch(e){k.v.error("Failed to fetch languages:",e)}finally{n(!1)}})()},[e]),{languages:t,loadingLanguages:r}}(el||"");(0,c.useEffect)(()=>{ep((e=>{let t={type:"object",properties:{}},a=[];return e.forEach(e=>{if(!e.name||"group"===e.type)return;let r={title:e.displayName||e.name,description:e.description||void 0};switch(e.type){case"text":case"textarea":case"slug":case"markdown":case"reference":case"asset":default:r.type="string";break;case"color":r.type="string",r.pattern="^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$";break;case"url":r.type="string",r.format="uri";break;case"email":r.type="string",r.format="email";break;case"richtext":r.type=["object","string"];break;case"number":r.type="number";break;case"integer":r.type="integer";break;case"json":r.type=["object","array","string","number","boolean"];break;case"boolean":r.type="boolean";break;case"date":case"datetime":r.type="string",r.format="date-time";break;case"select":r.type="string",e.options&&e.options.length>0&&(r.enum=e.options.map(e=>e.value).filter(Boolean));break;case"multiselect":r.type="array",r.items={type:"string"},e.options&&e.options.length>0&&(r.items.enum=e.options.map(e=>e.value).filter(Boolean));break;case"multilink":r.type="object",r.properties={kind:{type:"string",enum:["story","url","email","asset"]},url:{type:"string"},email:{type:"string"},recordId:{type:"string"},assetId:{type:"string"},anchor:{type:"string"},newTab:{type:"boolean"}},r.required=["kind"];break;case"bloks":r.type="array",r.items={type:"object",properties:{__type:{type:"string",const:"blok"},__id:{type:"string"},__contentType:{type:"string",minLength:1},data:{type:"object"}},required:["__type","__contentType","data"]}}e.validations&&(void 0!==e.validations.minLength&&(r.minLength=e.validations.minLength),void 0!==e.validations.maxLength&&(r.maxLength=e.validations.maxLength),void 0!==e.validations.pattern&&(r.pattern=e.validations.pattern)),t.properties[e.name]=r,e.required&&a.push(e.name)}),a.length>0&&(t.required=a),t})(en))},[en]);let ey=async e=>{let t;if(e.preventDefault(),P(null),O(null),h)t=g.environmentId,k.v.log("handleSubmit (Editing) - Using environmentId from initialData:",t);else{let e=m||localStorage.getItem("cms_selected_space");e?(t=localStorage.getItem("cms_selected_environment_".concat(e)),k.v.log("handleSubmit (Creating) - Read environmentId from localStorage for space ".concat(e,":"),t)):(t=null,k.v.log("handleSubmit (Creating) - Could not find spaceId in localStorage."))}if(!t){P("Cannot save content type: Environment context is missing. Please ensure an organization, space, and environment are selected using the dropdown selector."),U(!0);return}if(!function(e){let{name:t,displayName:a,fields:r,setError:n,setShowErrorModal:s}=e;if(!t.trim())return n("API Name - Content Type ID is required"),s(!0),!1;if(!a.trim())return n("Display Name is required"),s(!0),!1;if(!/^[a-zA-Z0-9_]+$/.test(t))return n("API Name - Content Type ID can only contain letters, numbers, and underscores"),s(!0),!1;let i=new Set;for(let e of r){if(!e.name.trim())return n("All fields must have a name"),s(!0),!1;if(!/^[a-zA-Z0-9_]+$/.test(e.name))return n('Field name "'.concat(e.name,'" can only contain letters, numbers, and underscores')),s(!0),!1;if(i.has(e.name))return n('Duplicate field name "'.concat(e.name,'". Field names must be unique within a content type.')),s(!0),!1;if(i.add(e.name),"select"===e.type||"multiselect"===e.type){if(e.options&&Array.isArray(e.options)||(e.options=[]),0===e.options.length)return n('Select field "'.concat(e.name,'" must have at least one option')),s(!0),!1;for(let t of e.options)if(!t||"object"!=typeof t||!t.label||!t.value||!t.label.trim()||!t.value.trim())return n('All options for field "'.concat(e.name,'" must have a valid label and value')),s(!0),!1}else if(e.options&&Array.isArray(e.options)){for(let t of e.options)if(!t.label.trim()||!t.value.trim())return n('All options for field "'.concat(e.name,'" must have a label and value')),s(!0),!1}}return!0}({name:G,displayName:H,fields:en,setError:P,setShowErrorModal:U}))return;F(!0);let a=ei.current;try{let e=h?"PUT":"POST",n=h?"/api/cms/content-types/".concat(g.id):"/api/cms/content-types";if(h){let e=m||el||localStorage.getItem("cms_selected_space");if(e){let t=n.includes("?")?"&":"?";n="".concat(n).concat(t,"spaceId=").concat(encodeURIComponent(e))}else k.v.warn("ContentTypeForm: No spaceId available to append to PUT URL; API may reject with 'Space ID is required'.")}let s={name:G,displayName:H,description:ea||null,fields:en,environmentId:t,fieldSchema:eg};if(h&&(!f||f.request!==JSON.stringify(s))){var r;let e=await fetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,preview:!0,baseRevision:C})}),t=await e.json();if(!e.ok)throw Error(t.error||"Could not review model changes.");if(ei.current!==a)return;S({...t,request:JSON.stringify(s)}),W(null!=(r=t.activeMigration)?r:null);return}if(h&&(null==f?void 0:f.blocked))throw Error("This change requires a data migration. Existing content and app bindings have not been changed.");let i=await fetch(n,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,...h?{baseRevision:null==f?void 0:f.baseRevision}:{}})});if(!i.ok){let e=await i.json();throw Error(e.error||"Error: ".concat(i.status))}let l=await i.json();I(l.updatedAt),S(null),O(h?'Content type "'.concat(H,'" has been updated successfully.'):'Content type "'.concat(H,'" has been created successfully.')),z(!0),!h&&l.id&&(g.i
1d=l.id,g.name=G,g.displayName=H,g.description=ea,g.fields=en,g.environmentId=t),x.refresh()}catch(e){k.v.error("Failed to save content type:",e),P((0,ee.u)(e)||"Failed to save content type"),U(!0)}finally{F(!1)}},ev=async e=>{if(f){T(!0);try{let t=m||el||localStorage.getItem("cms_selected_space"),a="/api/cms/content-types/".concat(g.id);t&&(a="".concat(a,"?spaceId=").concat(encodeURIComponent(t)));let r={name:G,displayName:H,description:ea||null,fields:en,environmentId:g.environmentId,fieldSchema:eg},n=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,preview:!0,baseRevision:C,scan:{cursor:e}})}),s=await n.json();if(!n.ok)throw Error(s.error||"Could not continue scanning.");S({...s,request:JSON.stringify(r),scanContinued:!0})}catch(e){k.v.error("Failed to continue migration scan:",e),P((0,ee.u)(e)||"Failed to continue migration scan"),U(!0)}finally{T(!1)}}},ek=()=>m||el||localStorage.getItem("cms_selected_space"),ej=async()=>{if(g.id){q(!0);try{let e=ek(),t="/api/cms/content-types/".concat(g.id,"/migrations");e&&(t="".concat(t,"?spaceId=").concat(encodeURIComponent(e)));let a=await fetch(t);if(!a.ok)return;let r=await a.json(),n=Array.isArray(r.migrations)?r.migrations:[];B(n);let s=n.find(e=>"planned"===e.status||"running"===e.status);W(e=>{if(s)return{id:s.id,status:s.status,kind:s.kind};if(!e)return null;let t=n.find(t=>t.id===e.id);return t?{id:t.id,status:t.status,kind:t.kind}:e})}catch(e){if(et(e))return;k.v.error("Failed to load migration history:",e)}finally{q(!1)}}},eN=async e=>{if(W({id:e.id,status:e.status,kind:e.kind}),ej(),"completed"===e.status)try{let e=ek(),t="/api/cms/content-types/".concat(g.id);e&&(t="".concat(t,"?spaceId=").concat(encodeURIComponent(e)));let a=await fetch(t);if(a.ok){let e=await a.json();(null==e?void 0:e.updatedAt)&&I(e.updatedAt)}}catch(e){et(e)||k.v.error("Failed to reload content type after migration:",e)}S(null)},ew=u.startsWith("de"),eS=!!_&&("planned"===_.status||"running"===_.status);return(0,r.jsxs)("form",{onSubmit:ey,className:"space-y-6",children:[_&&(0,r.jsxs)("section",{"aria-label":eS?ew?"Migration l\xe4uft":"Migration in progress":ew?"Migrationsergebnis":"Migration result",className:eS?"min-w-0 space-y-3 rounded-lg border border-blue-300 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-900/20":"min-w-0 space-y-3 rounded-lg border border-gray-300 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/40",children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-2",children:[(0,r.jsx)("p",{className:"min-w-0 font-medium",children:eS?ew?"F\xfcr dieses Modell l\xe4uft gerade eine Migration. Das Formular ist schreibgesch\xfctzt, bis sie abgeschlossen ist.":"A migration is currently running for this model. The form is read-only until it finishes.":ew?"Die Migration ist beendet. Das Formular ist wieder bearbeitbar.":"The migration has finished. The form is editable again."}),!eS&&(0,r.jsx)("button",{type:"button",onClick:()=>W(null),className:"shrink-0 text-sm text-gray-600 underline hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",children:ew?"Ergebnis schlie\xdfen":"Dismiss result"})]}),g.id&&(0,r.jsx)(b,{contentTypeId:g.id,migrationId:_.id,spaceId:null!=(i=ek())?i:"",locale:u,onFinished:eN,onRollbackStarted:e=>{W({id:e.id,status:e.status,kind:e.kind})}})]}),(0,r.jsxs)("fieldset",{disabled:eS,className:"min-w-0 space-y-6 border-0 p-0 m-0",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Content Type Details"}),(0,r.jsx)(w,{name:G,setName:J,displayName:H,setDisplayName:K,description:ea,setDescription:er,isEditing:h})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>ex(!0),className:"inline-flex items-center gap-2 rounded border px-4 py-2",children:[(0,r.jsx)(N.A,{className:"h-5 w-5"}),u.startsWith("de")?"Modell\xe4nderung mit KI vorschlagen":"Suggest model changes with AI"]}),(0,r.jsx)(Z,{fields:en,setFields:es,languages:eb,loadingLanguages:ef,locale:u,openFieldIds:eu,toggleFieldOpen:e=>{em(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},spaceId:null!=m?m:el,environmentId:null!=(l=null==g?void 0:g.environmentId)?l:ed,parentContentTypeName:G||(null==g?void 0:g.name)}),(0,r.jsx)(Q,{schema:eg}),h&&f&&(0,r.jsxs)("section",{className:"rounded-lg border border-gray-300 p-4 space-y-3","aria-label":"Model change review",children:[(0,r.jsx)("h3",{className:"font-semibold",children:u.startsWith("de")?"Modell\xe4nderungen pr\xfcfen":"Review model changes"}),(0,r.jsx)(X.A,{changes:f.changes,locale:u}),f.bindingReport&&(0,r.jsx)(n,{report:f.bindingReport,locale:u}),f.migrationScan&&(0,r.jsxs)(r.Fragment,{children:[f.scanContinued&&(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u.startsWith("de")?"Fortsetzung ab Cursor.":"Continued from cursor."}),(0,r.jsx)(d,{scan:f.migrationScan,locale:u,onContinue:ev,continuing:R})]}),(0,r.jsxs)("p",{children:[f.recordCount," ",u.startsWith("de")?"Datens\xe4tze dieses Inhaltstyps bleiben unver\xe4ndert.":"records of this content type remain unchanged."]}),(0,r.jsxs)("p",{children:[f.potentialAppCount," ",u.startsWith("de")?"Apps im Space. Konkrete Bindungsnachweise und Grenzen stehen in der Analyse.":"apps in this space. See the analysis for specific bindings and its limits."]}),f.blocked&&(null==(t=f.migrationPlan)?void 0:t.classification)==="migratable"&&g.id?(0,r.jsx)(p,{plan:f.migrationPlan,recordCount:f.recordCount,locale:u,fields:en,fieldSchema:eg,contentTypeId:g.id,spaceId:null!=(o=ek())?o:"",baseRevision:f.baseRevision,onStarted:e=>{W({id:e.id,status:e.status,kind:e.kind}),B(t=>[e,...t.filter(t=>t.id!==e.id)]),S(null)}}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:f.blocked?u.startsWith("de")?"Speichern gesperrt: Diese \xc4nderung ben\xf6tigt eine Datenmigration. Bestehende Daten werden nicht umgeschrieben.":"Saving blocked: this change requires a data migration. Existing data will not be rewritten.":u.startsWith("de")?"Kompatible \xc4nderung. Pr\xfcfe den Diff und best\xe4tige das Speichern.":"Compatible change. Review the diff and confirm saving."}),f.blocked&&(null==(a=f.migrationPlan)?void 0:a.blockers)&&f.migrationPlan.blockers.length>0&&(0,r.jsx)("ul",{className:"list-inside list-disc space-y-1 text-sm text-red-700 dark:text-red-300",children:f.migrationPlan.blockers.map((e,t)=>(0,r.jsxs)("li",{className:"break-words",children:[(0,r.jsx)("code",{children:e.field}),": ",e.reason]},t))})]})]}),(0,r.jsxs)("div",{className:"flex justify-end space-x-3 mt-6",children:[(0,r.jsx)("button",{type:"button",onClick:()=>x.back(),className:"py-2 px-4 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:A||!!(null==f?void 0:f.blocked),className:"py-2 px-4 border border-transparent roun
1ded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50",children:A?"Saving...":h?f?u.startsWith("de")?"Modell\xe4nderungen speichern":"Confirm model changes":u.startsWith("de")?"Modell\xe4nderungen pr\xfcfen":"Review model changes":"Create Content Type"})]})]}),h&&g.id&&(0,r.jsx)(y,{migrations:V,loading:$,locale:u,onExpand:ej}),(0,r.jsx)(j,{isOpen:E,onClose:()=>z(!1),title:"Success!",message:D,type:"success"}),(0,r.jsx)(j,{isOpen:L,onClose:()=>U(!1),title:"Error",message:M,type:"error"}),(0,r.jsx)(Y.A,{locale:u,isOpen:eh,onClose:()=>ex(!1),onApply:e=>{!h&&e.name&&J(e.name),!h&&e.displayName&&K(e.displayName),!h&&e.description&&er(e.description),es(e.fields),em(new Set(e.fields.map(e=>e.id))),ex(!1)},existingFields:en.filter(e=>e.name&&e.type),spaceId:null!=m?m:el,existingName:G,existingDisplayName:H})]})}},5322:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(86779);function n(e,t,a){return(t=(0,r.A)(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}},17571:(e,t,a)=>{Promise.resolve().then(a.t.bind(a,52619,23)),Promise.resolve().then(a.bind(a,1987))},20063:(e,t,a)=>{"use strict";var r=a(47260);a.o(r,"notFound")&&a.d(t,{notFound:function(){return r.notFound}}),a.o(r,"useParams")&&a.d(t,{useParams:function(){return r.useParams}}),a.o(r,"usePathname")&&a.d(t,{usePathname:function(){return r.usePathname}}),a.o(r,"useRouter")&&a.d(t,{useRouter:function(){return r.useRouter}}),a.o(r,"useSearchParams")&&a.d(t,{useSearchParams:function(){return r.useSearchParams}}),a.o(r,"useSelectedLayoutSegments")&&a.d(t,{useSelectedLayoutSegments:function(){return r.useSelectedLayoutSegments}})},33861:(e,t,a)=>{"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}a.d(t,{A:()=>r})},37849:(e,t,a)=>{"use strict";e.exports=a(68381)},67810:(e,t,a)=>{"use strict";function r(e,t){if(null==e)return{};var a={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;a[r]=e[r]}return a}
1a.d(t,{A:()=>r})},68381:(e,t)=>{"use strict";var a="function"==typeof Symbol&&Symbol.for,r=a?Symbol.for("react.element"):60103,n=a?Symbol.for("react.portal"):60106,s=a?Symbol.for("react.fragment"):60107,i=a?Symbol.for("react.strict_mode"):60108,l=a?Symbol.for("react.profiler"):60114,o=a?Symbol.for("react.provider"):60109,d=a?Symbol.for("react.context"):60110,c=a?Symbol.for("react.async_mode"):60111,u=a?Symbol.for("react.concurrent_mode"):60111,m=a?Symbol.for("react.forward_ref"):60112,g=a?Symbol.for("react.suspense"):60113,p=a?Symbol.for("react.suspense_list"):60120,h=a?Symbol.for("react.memo"):60115,x=a?Symbol.for("react.lazy"):60116,b=a?Symbol.for("react.block"):60121,f=a?Symbol.for("react.fundamental"):60117,y=a?Symbol.for("react.responder"):60118,v=a?Symbol.for("react.scope"):60119;function k(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case c:case u:case s:case l:case i:case g:return e;default:switch(e=e&&e.$$typeof){case d:case m:case x:case h:case o:return e;default:return t}}case n:return t}}}function j(e){return k(e)===u}t.AsyncMode=c,t.ConcurrentMode=u,t.ContextConsumer=d,t.ContextProvider=o,t.Element=r,t.ForwardRef=m,t.Fragment=s,t.Lazy=x,t.Memo=h,t.Portal=n,t.Profiler=l,t.StrictMode=i,t.Suspense=g,t.isAsyncMode=function(e){return j(e)||k(e)===c},t.isConcurrentMode=j,t.isContextConsumer=function(e){return k(e)===d},t.isContextProvider=function(e){return k(e)===o},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return k(e)===m},t.isFragment=function(e){return k(e)===s},t.isLazy=function(e){return k(e)===x},t.isMemo=function(e){return k(e)===h},t.isPortal=function(e){return k(e)===n},t.isProfiler=function(e){return k(e)===l},t.isStrictMode=function(e){return k(e)===i},t.isSuspense=function(e){return k(e)===g},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===s||e===u||e===l||e===i||e===g||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===x||e.$$typeof===h||e.$$typeof===o||e.$$typeof===d||e.$$typeof===m||e.$$typeof===f||e.$$typeof===y||e.$$typeof===v||e.$$typeof===b)},t.typeOf=k},74879:(e,t,a)=>{"use strict";let r;a.d(t,{A:()=>l});let n={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)},s=new Uint8Array(16),i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).slice(1));let l=function(e,t,a){if(n.randomUUID&&!t&&!e)return n.randomUUID();let l=(e=e||{}).random??e.rng?.()??function(){if(!r){if("undefined"==typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(s)}();if(l.length<16)throw Error("Random bytes length must be >= 16");if(l[6]=15&l[6]|64,l[8]=63&l[8]|128,t){if((a=a||0)<0||a+16>t.length)throw RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[a+e]=l[e];return t}return function(e,t=0){return(i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]).toLowerCase()}(l)}},76076:(e,t,a)=>{"use strict";var r=a(37849),n={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},s={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},l={};function o(e){return r.isMemo(e)?i:l[e.$$typeof]||n}l[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},l[r.Memo]=i;var d=Object.defineProperty,c=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,g=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,a,r){if("string"!=typeof a){if(p){var n=g(a);n&&n!==p&&e(t,n,r)}var i=c(a);u&&(i=i.concat(u(a)));for(var l=o(t),h=o(a),x=0;x<i.length;++x){var b=i[x];if(!s[b]&&!(r&&r[b])&&!(h&&h[b])&&!(l&&l[b])){var f=m(a,b);try{d(t,b,f)}catch(e){}}}}return t}},77167:(e,t,a)=>{"use strict";function r(e,t){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}a.d(t,{A:()=>r})},85514:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(12115);let n=r.forwardRef(function(e,t){let{title:a,titleId:n,...s}=e;return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":n},s),a?r.createElement("title",{id:n},a):null,r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5"}))})},86779:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(33861);function n(e){var t=function(e,t){if("object"!=(0,r.A)(e)||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var n=a.call(e,t||"default");if("object"!=(0,r.A)(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==(0,r.A)(t)?t:t+""}},88945:(e,t,a)=>{"use strict";function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)({}).hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e}).apply(null,arguments)}a.d(t,{A:()=>r})},93322:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});var r=a(5322);function n(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function s(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};
1t%2?n(Object(a),!0).forEach(function(t){(0,r.A)(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):n(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}},96059:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(12115);let n=r.forwardRef(function(e,t){let{title:a,titleId:n,...s}=e;return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":n},s),a?r.createElement("title",{id:n},a):null,r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"}))})}}]);
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.