@kyro-cms/admin 0.12.5 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var Ta=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),Ql=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),reactI18next=require('react-i18next'),$u=require('i18next'),Ou=require('i18next-browser-languagedetector'),reactDom=require('react-dom'),react=require('@tiptap/react'),gp=require('@tiptap/starter-kit'),vp=require('@tiptap/extension-link'),bp=require('@tiptap/extension-image'),xp=require('@tiptap/extension-text-align'),kp=require('@tiptap/extension-underline'),hp=require('@tiptap/extension-highlight'),wp=require('@tiptap/extension-task-list'),Np=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),Sp=require('@tiptap/extension-color'),np=require('react-image-crop');require('react-image-crop/dist/ReactCrop.css');var codemirrorThemeGithub=require('@uiw/codemirror-theme-github'),codemirrorThemeAura=require('@uiw/codemirror-theme-aura'),unstorage=require('unstorage'),um=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Mo=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),Af=require('@uiw/react-codemirror'),langJson=require('@codemirror/lang-json');require('@kyro-cms/core');var br=require('path'),url=require('url'),esbuild=require('esbuild'),dotenv=require('dotenv'),worker_threads=require('worker_threads');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Ta__default=/*#__PURE__*/_interopDefault(Ta);var Ql__namespace=/*#__PURE__*/_interopNamespace(Ql);var $u__default=/*#__PURE__*/_interopDefault($u);var Ou__default=/*#__PURE__*/_interopDefault(Ou);var gp__default=/*#__PURE__*/_interopDefault(gp);var vp__default=/*#__PURE__*/_interopDefault(vp);var bp__default=/*#__PURE__*/_interopDefault(bp);var xp__default=/*#__PURE__*/_interopDefault(xp);var kp__default=/*#__PURE__*/_interopDefault(kp);var hp__default=/*#__PURE__*/_interopDefault(hp);var wp__default=/*#__PURE__*/_interopDefault(wp);var Np__default=/*#__PURE__*/_interopDefault(Np);var Sp__default=/*#__PURE__*/_interopDefault(Sp);var np__default=/*#__PURE__*/_interopDefault(np);var um__default=/*#__PURE__*/_interopDefault(um);var Mo__default=/*#__PURE__*/_interopDefault(Mo);var Af__default=/*#__PURE__*/_interopDefault(Af);var br__default=/*#__PURE__*/_interopDefault(br);var Ue=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",wr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function qe(e){if(e.startsWith("http")||e.startsWith(wr))return e;if(e.startsWith("/api/"))return wr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${wr}${t}${e}`}function hs(e){return e.startsWith("http")||e.startsWith(Ue)?e:e.startsWith("/admin/")?Ue+e.slice(6):e.startsWith("/")?Ue+e:e}function Ca(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var Nu={admin:Ue,api:wr,resolveApi:qe,resolveAdmin:hs,resolveMedia:Ca};var _r=zustand.create(e=>({user:null,permissions:null,isAuthenticated:false,isLoading:true,error:null,setUser:(t,r=null)=>e({user:t,permissions:r,isAuthenticated:!!t,isLoading:false,error:null}),setLoading:t=>e({isLoading:t}),setError:t=>e({error:t,isLoading:false,isAuthenticated:false,user:null,permissions:null}),logout:()=>e({user:null,permissions:null,isAuthenticated:false,isLoading:false,error:null})}));var Xt=zustand.create(e=>({toasts:[],addToast:(t,r)=>{let o=Math.random().toString(36).substring(7);e(a=>({toasts:[...a.toasts,{id:o,type:t,message:r}]}));},removeToast:t=>e(r=>({toasts:r.toasts.filter(o=>o.id!==t)})),clearToasts:()=>e({toasts:[]})})),V={success:e=>Xt.getState().addToast("success",e),error:e=>Xt.getState().addToast("error",e),warning:e=>Xt.getState().addToast("warning",e),info:e=>Xt.getState().addToast("info",e)};zustand.create()(middleware.persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var yt=zustand.create(e=>({sidebarOpen:true,toggleSidebar:()=>e(t=>({sidebarOpen:!t.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),modal:{open:false,config:null},confirm:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default"}}}),alert:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default",confirmLabel:t.confirmLabel||"OK",onConfirm:()=>e(r=>({modal:{...r.modal,open:false}}))}}}),closeModal:()=>e(t=>({modal:{...t.modal,open:false},activeModal:null})),activeModal:null,openModal:t=>e({activeModal:t})}));zustand.create(e=>({editor:null,setEditor:t=>e({editor:t}),blockDrawerOpen:false,openBlockDrawer:t=>e({blockDrawerOpen:true,pendingInsert:{pos:null,column:t?.targetColumn??null}}),closeBlockDrawer:()=>e({blockDrawerOpen:false,pendingInsert:{pos:null,column:null}}),toggleBlockDrawer:()=>e(t=>({blockDrawerOpen:!t.blockDrawerOpen})),selectedBlock:null,setSelectedBlock:t=>e({selectedBlock:t}),pendingInsert:{pos:null,column:null},setPendingInsert:(t,r)=>e({pendingInsert:{pos:t,column:r??null}}),clearPendingInsert:()=>e({pendingInsert:{pos:null,column:null}})}));zustand.create((e,t)=>({cache:{},setCache:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:o,loading:false,error:null,lastFetch:Date.now()}}})),setLoading:(r,o)=>e(a=>({cache:{...a.cache,[r]:{...a.cache[r],loading:o,error:null}}})),setError:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:null,loading:false,error:o,lastFetch:null}}})),getCache:r=>t().cache[r]||null,invalidateCache:r=>e(o=>{if(r){let{[r]:a,...n}=o.cache;return {cache:n}}return {cache:{}}})}));var Su="/api/auth/refresh";async function Ei(){try{return (await fetch(qe(Su),{method:"POST",credentials:"include"})).ok}catch{return false}}async function lt(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(qe(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await Ei()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(qe(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function Ee(e,t){let{autoToast:r=true,...o}=t||{},a=await lt(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&V.error(n),new Error(n)}return a.json()}async function dt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await lt(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let i=await n.json();i.error&&(s=i.error);}catch{}throw o&&V.error(s),new Error(s)}return n.json()}async function Yt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await lt(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let i=await n.json();i.error&&(s=i.error);}catch{}throw o&&V.error(s),new Error(s)}return n.json()}async function At(e,t){let{autoToast:r=true,...o}={},a=await lt(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let i=await a.json();i.error&&(s=i.error);}catch{}throw r&&V.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function Kr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function nn(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function sn(e,t,r){if(!r){let o=await lt(e,{method:"POST",body:t});if(!o.ok)throw new Error(`Upload Error: ${o.status}`);return o.json()}return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("POST",qe(e)),n.withCredentials=true,n.upload.addEventListener("progress",s=>{s.lengthComputable&&r(Math.round(s.loaded/s.total*100));}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{o(JSON.parse(n.responseText));}catch{a(new Error("Invalid JSON response"));}else n.status===401?Ei().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let i=new XMLHttpRequest;i.open("POST",qe(e)),i.withCredentials=true,i.upload.addEventListener("progress",l=>{l.lengthComputable&&r(Math.round(l.loaded/l.total*100));}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{o(JSON.parse(i.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${i.status}`));}),i.addEventListener("error",()=>a(new Error("Network error"))),i.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function ar({size:e="md",className:t=""}){return jsxRuntime.jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}function jt({variant:e,count:t=1,className:r=""}){let o={text:"h-3 rounded-md",circle:"size-10 rounded-full",rect:"h-10 rounded-xl",card:"h-32 rounded-2xl","table-row":"h-14 rounded-xl","media-card":"aspect-square rounded-2xl","stat-card":"h-24 rounded-2xl"};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:Array.from({length:t}).map((a,n)=>jsxRuntime.jsx("div",{className:`kyro-shimmer ${o[e]} ${r}`},n))})}function bl({back:e}){return e.href?jsxRuntime.jsx("a",{href:e.href,onClick:t=>{e.onClick&&(t.preventDefault(),e.onClick());},className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}):jsxRuntime.jsx("button",{type:"button",onClick:e.onClick,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})})}function Du({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[r>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),t.href||t.onClick?jsxRuntime.jsx("a",{href:t.href,onClick:o=>{t.onClick&&(o.preventDefault(),t.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:t.label}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:t.label})]},r))}function xl({actions:e}){return Array.isArray(e)?jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>{let o=`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all ${t.variant==="outline"?"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":t.variant==="ghost"?"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] shadow-none":"kyro-btn-primary hover:opacity-90"} ${t.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${t.className||""}`;return t.href&&!t.disabled?jsxRuntime.jsxs("a",{href:t.href,className:o,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r):jsxRuntime.jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:o,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r)})}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function kl({action:e}){let t=`kyro-btn kyro-btn-primary flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`;return e.href&&!e.disabled?jsxRuntime.jsxs("a",{href:e.href,className:t,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]}):jsxRuntime.jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:t,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function Lt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:i,children:l}){let d=o?.[o.length-1];return jsxRuntime.jsxs("div",{className:"surface-tile px-3 md:px-6 py-3 md:pt-4 mb-4 md:mb-8",children:[jsxRuntime.jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n&&jsxRuntime.jsx(bl,{back:n}),jsxRuntime.jsxs("details",{className:"group [&::-webkit-details-marker]:hidden flex-1 min-w-0",children:[jsxRuntime.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[jsxRuntime.jsx("span",{className:"flex-1 text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] truncate",children:d?.label||""}),jsxRuntime.jsx("svg",{className:"w-3 h-3 text-[var(--kyro-text-secondary)] opacity-40 group-open:rotate-180 transition-transform",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--kyro-border)] space-y-2",children:[o&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o.map((c,u)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[u>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsxRuntime.jsx("a",{href:c.href,onClick:m=>{c.onClick&&(m.preventDefault(),c.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:c.label}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:c.label})]},u))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,u)=>jsxRuntime.jsx(Ta__default.default.Fragment,{children:c},u))}),l]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r&&jsxRuntime.jsx(r,{className:"w-5 h-5 text-[var(--kyro-primary)] shrink-0"}),e&&jsxRuntime.jsx("h1",{className:"text-lg font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e}),a&&!t&&jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full bg-[var(--kyro-primary)] shrink-0"})]}),t&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0 text-xs",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[u===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))})]})]}),jsxRuntime.jsxs("div",{className:"hidden md:flex md:flex-row md:items-center justify-between gap-6",children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n&&jsxRuntime.jsx(bl,{back:n}),o&&jsxRuntime.jsx(Du,{breadcrumbs:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[r&&jsxRuntime.jsx(r,{className:"w-6 h-6 text-[var(--kyro-primary)]"}),e&&jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e})]}),(t||a)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-1",children:[t&&jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[u===0&&(t||u>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))}),l]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[i&&jsxRuntime.jsx(xl,{actions:i}),s&&jsxRuntime.jsx(kl,{action:s})]})]}),(i||s)&&jsxRuntime.jsxs("div",{className:"md:hidden flex items-center gap-2 mt-3 pt-3 border-t border-[var(--kyro-border)]",children:[s&&jsxRuntime.jsx(kl,{action:s}),i&&jsxRuntime.jsx(xl,{actions:i})]})]})}var Pu={draft:{class:"bg-gray-100 text-gray-600",label:"Draft"},published:{class:"bg-green-100 text-green-700",label:"Published"},scheduled:{class:"bg-blue-100 text-blue-700",label:"Scheduled"},archived:{class:"bg-yellow-100 text-yellow-700",label:"Archived"},active:{class:"bg-green-100 text-green-700",label:"Active"},inactive:{class:"bg-gray-100 text-gray-600",label:"Inactive"},pending:{class:"bg-yellow-100 text-yellow-700",label:"Pending"},completed:{class:"bg-green-100 text-green-700",label:"Completed"},cancelled:{class:"bg-red-100 text-red-700",label:"Cancelled"}};function Rt({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=Pu[n],i=s?s.class:`kyro-badge-${n}`;return jsxRuntime.jsxs("span",{className:`kyro-badge ${i} ${r}`,children:[a&&jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1.5 opacity-60"}),o||s?.label||n]})}function Rs({count:e,max:t=99}){return e===0?null:jsxRuntime.jsx("span",{className:"inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 text-xs font-medium bg-gray-200 text-gray-700 rounded-full",children:e>t?`${t}+`:e})}function Is({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let i="kyro-btn",l=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${i} ${l} ${d} ${a}`,disabled:n||r,...s,children:[r?jsxRuntime.jsx("span",{className:"kyro-btn-loading",children:jsxRuntime.jsx("svg",{className:"kyro-btn-spinner",viewBox:"0 0 24 24",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"60 30"})})}):null,jsxRuntime.jsx("span",{className:r?"kyro-btn-text-hidden":"",children:o})]})}function wl({page:e,totalPages:t,totalDocs:r,limit:o,onPageChange:a,onLimitChange:n}){return t<=1?null:jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 px-4 py-3 border-t border-[var(--kyro-border)]",children:[r!==void 0&&o?jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Showing ",(e-1)*o+1," to ",Math.min(e*o,r)," of ",r]}):jsxRuntime.jsx("span",{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[n&&jsxRuntime.jsxs("select",{value:o,onChange:s=>n(Number(s.target.value)),className:"text-xs border border-[var(--kyro-border)] rounded-lg px-2 py-1 bg-[var(--kyro-bg)] text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("option",{value:10,children:"10/page"}),jsxRuntime.jsx("option",{value:25,children:"25/page"}),jsxRuntime.jsx("option",{value:50,children:"50/page"}),jsxRuntime.jsx("option",{value:100,children:"100/page"})]}),jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Page ",e," of ",t]}),jsxRuntime.jsxs("div",{className:"flex gap-1",children:[jsxRuntime.jsx(Is,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(Is,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}var Nl={actions:{cancel:"Cancel",create:"Create {{item}}",delete:"Delete",deleteDocument:"Delete Document",deleteEntry:"Delete Entry",deleting:"Deleting...",duplicateDocument:"Duplicate Document",duplicating:"Duplicating...",edit:"Edit",new:"New",newDocument:"New Document",signOut:"Sign Out",view:"View"},common:{na:"N/A",no:"No",yes:"Yes"},dashboard:{activeUsers:"Active Users",authService:"Auth Service",cloudApi:"Cloud API",contentGrowth:"Content Growth",contentGrowthDesc:"Snapshot of document velocity over the last 7 days",dbNode:"Database Node",description:"Everything looks great in your command center today.",mediaAssets:"Media Assets",mediaCdn:"Media CDN",mediaLibrary:"Media Library",mediaLibraryDesc:"Manage high-fidelity assets with our liquid masonry gallery.",newAction:"New {{item}}",noCollections:"No collections available for creation.",openAssets:"Open Assets",quickLinks:"Quick Links",recentActivity:"Recent Activity",statusActive:"Active",statusHealthy:"Healthy",statusOptimal:"Optimal",statusSecure:"Secure",systemHealth:"System Health",systemStatus:"System Status",totalContent:"Total Content",viewAuditLogs:"View Audit Logs",welcome:"Welcome back, {{name}}"},days:{fri:"Fri",mon:"Mon",sat:"Sat",sun:"Sun",thu:"Thu",tue:"Tue",wed:"Wed"},detailView:{collections:"Collections",coreConfiguration:"Core Configuration",dateCreated:"Date Created",deleteMessage:"This action cannot be undone.",deleteTitle:"Delete {{label}}?",dynamicStatus:"Dynamic Status",generatingPreview:"Generating preview URL...",globals:"Globals",justNow:"Just now",lastModified:"Last Modified",metadata:"Metadata",newDocument:"New {{label}}",openPreview:"Open Preview in New Tab",publicAt:"Public At",quickLinks:"Quick Links"},listView:{actionsCol:"Actions",addFilter:"Add Filter",advancedFilters:"Advanced Filters",clearAll:"Clear All",columns:"Columns",createdCol:"Created",deleteBulkMessage_one:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkMessage_other:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkTitle:"Delete Documents",deleteMessage:"Are you sure you want to delete this document? This cannot be undone.",deleteSelected:"Delete Selected",deleteTitle:"Delete Document",filters:"Filters",getStartedCreate:"Get started by creating your first {{item}}.",lastModifiedCol:"Last Modified",noDocuments:"No documents found",noFilters:'No filters applied. Click "Add Filter" to create one.',searchPlaceholder:"Search...",selectedCount_one:"{{count}} selected",selectedCount_other:"{{count}} selected",toggleColumns:"Toggle Columns",tryAdjustingFilters:"Try adjusting your filters or search query."},login:{confirmPassword:"Confirm Password",createAccount:"Create Account",createAccountDesc:"Create an account to access the admin",createAdminAccount:"Create Admin Account",creatingAccount:"Creating account...",email:"Email",enterCredentials:"Enter your credentials to access the admin",hasAccount:"Already have an account?",noAccount:"Don't have an account?",password:"Password",setupAdmin:"Set up your admin account to get started",signIn:"Sign In",signInAction:"Sign in",signingIn:"Signing in...",signUp:"Sign up"},nav:{dashboard:"Dashboard",media:"Media",users:"Users",plugins:"Plugins",settings:"Settings",content:"Content",developer:"Developer",resources:"Resources"},sidebar:{darkMode:"Dark Mode",lightMode:"Light Mode"},toast:{accountCreated:"Account created!",connectionFailed:"Connection failed",copyError:"Failed to copy document data",dataCopied:"Document data copied to clipboard",dataPasted:"Document data pasted",draftSaved:"Draft saved",duplicated:"Document duplicated",duplicateError:"Failed to duplicate document",pasteError:"Clipboard does not contain valid document JSON",published:"Published successfully",publishError:"Failed to publish",saveError:"Failed to save changes",unpublished:"Document unpublished",unpublishError:"Failed to unpublish",updated:"Updated",welcomeBack:"Welcome back!"},userMenu:{account:"Account",apiExplorer:"API Explorer",apiKeys:"API Keys",auditLogs:"Audit Logs",developer:"Developer",documentation:"Documentation",getSupport:"Get Support",graphqlPlayground:"GraphQL Playground",permissions:"Permissions",profileSettings:"Profile Settings",resources:"Resources",sessions:"Sessions",webHooks:"Web Hooks"}};var Cl={actions:{cancel:"Annuler",create:"Cr\xE9er {{item}}",delete:"Supprimer",deleteDocument:"Supprimer le document",deleteEntry:"Supprimer l'entr\xE9e",deleting:"Suppression...",duplicateDocument:"Dupliquer le document",duplicating:"Duplication...",edit:"Modifier",new:"Nouveau",newDocument:"Nouveau Document",signOut:"D\xE9connexion",view:"Voir"},common:{na:"N/D",no:"Non",yes:"Oui"},dashboard:{activeUsers:"Utilisateurs Actifs",authService:"Service d'Authentification",cloudApi:"API Cloud",contentGrowth:"Croissance du Contenu",contentGrowthDesc:"Aper\xE7u de la vitesse des documents sur les 7 derniers jours",dbNode:"N\u0153ud de Base de Donn\xE9es",description:"Tout semble parfait dans votre centre de contr\xF4le aujourd'hui.",mediaAssets:"Ressources Multim\xE9dias",mediaCdn:"CDN Multim\xE9dia",mediaLibrary:"M\xE9diath\xE8que",mediaLibraryDesc:"G\xE9rez des ressources haute fid\xE9lit\xE9 avec notre galerie fluide.",newAction:"Nouveau {{item}}",noCollections:"Aucune collection disponible \xE0 cr\xE9er.",openAssets:"Ouvrir les Ressources",quickLinks:"Liens Rapides",recentActivity:"Activit\xE9 R\xE9cente",statusActive:"Actif",statusHealthy:"Sain",statusOptimal:"Optimal",statusSecure:"S\xE9curis\xE9",systemHealth:"Sant\xE9 du Syst\xE8me",systemStatus:"\xC9tat du Syst\xE8me",totalContent:"Contenu Total",viewAuditLogs:"Voir les Journaux d'Audit",welcome:"Bon retour, {{name}}"},days:{fri:"Ven",mon:"Lun",sat:"Sam",sun:"Dim",thu:"Jeu",tue:"Mar",wed:"Mer"},detailView:{collections:"Collections",coreConfiguration:"Configuration Principale",dateCreated:"Date de Cr\xE9ation",deleteMessage:"Cette action est irr\xE9versible.",deleteTitle:"Supprimer {{label}} ?",dynamicStatus:"Statut Dynamique",generatingPreview:"G\xE9n\xE9ration de l'URL d'aper\xE7u...",globals:"Variables Globales",justNow:"\xC0 l'instant",lastModified:"Derni\xE8re Modification",metadata:"M\xE9tadonn\xE9es",newDocument:"Nouveau {{label}}",openPreview:"Ouvrir l'Aper\xE7u",publicAt:"Public \xE0",quickLinks:"Liens Rapides"},listView:{actionsCol:"Actions",addFilter:"Ajouter un Filtre",advancedFilters:"Filtres Avanc\xE9s",clearAll:"Tout Effacer",columns:"Colonnes",createdCol:"Cr\xE9\xE9",deleteBulkMessage_one:"Voulez-vous vraiment supprimer {{count}} document ? C'est irr\xE9versible.",deleteBulkMessage_other:"Voulez-vous vraiment supprimer {{count}} documents ? C'est irr\xE9versible.",deleteBulkTitle:"Supprimer des Documents",deleteMessage:"Voulez-vous vraiment supprimer ce document ? C'est irr\xE9versible.",deleteSelected:"Supprimer la S\xE9lection",deleteTitle:"Supprimer le Document",filters:"Filtres",getStartedCreate:"Commencez par cr\xE9er votre premier {{item}}.",lastModifiedCol:"Derni\xE8re Modification",noDocuments:"Aucun document trouv\xE9",noFilters:'Aucun filtre appliqu\xE9. Cliquez sur "Ajouter un Filtre" pour en cr\xE9er un.',searchPlaceholder:"Rechercher...",selectedCount_one:"{{count}} s\xE9lectionn\xE9",selectedCount_other:"{{count}} s\xE9lectionn\xE9s",toggleColumns:"Afficher/Masquer les Colonnes",tryAdjustingFilters:"Essayez de modifier vos filtres ou votre requ\xEAte de recherche."},login:{confirmPassword:"Confirmer le Mot de Passe",createAccount:"Cr\xE9er un Compte",createAccountDesc:"Cr\xE9ez un compte pour acc\xE9der \xE0 l'administration",createAdminAccount:"Cr\xE9er un Compte Administrateur",creatingAccount:"Cr\xE9ation du compte...",email:"Email",enterCredentials:"Entrez vos identifiants pour acc\xE9der \xE0 l'administration",hasAccount:"Vous avez d\xE9j\xE0 un compte ?",noAccount:"Vous n'avez pas de compte ?",password:"Mot de Passe",setupAdmin:"Configurez votre compte administrateur pour commencer",signIn:"Se Connecter",signInAction:"Se connecter",signingIn:"Connexion...",signUp:"S'inscrire"},nav:{content:"Contenu",dashboard:"Tableau de Bord",developer:"D\xE9veloppeur",media:"M\xE9dias",plugins:"Extensions",resources:"Ressources",settings:"Param\xE8tres",users:"Utilisateurs"},sidebar:{darkMode:"Mode Sombre",lightMode:"Mode Clair"},toast:{accountCreated:"Compte cr\xE9\xE9 !",connectionFailed:"\xC9chec de la connexion",copyError:"\xC9chec de la copie des donn\xE9es",dataCopied:"Donn\xE9es copi\xE9es dans le presse-papiers",dataPasted:"Donn\xE9es coll\xE9es",draftSaved:"Brouillon enregistr\xE9",duplicated:"Document dupliqu\xE9",duplicateError:"\xC9chec de la duplication du document",pasteError:"Le presse-papiers ne contient pas de JSON valide",published:"Publi\xE9 avec succ\xE8s",publishError:"\xC9chec de la publication",saveError:"\xC9chec de l'enregistrement",unpublished:"Document d\xE9publi\xE9",unpublishError:"\xC9chec de la d\xE9publication",updated:"Mise \xE0 jour r\xE9ussie",welcomeBack:"Bon retour !"},userMenu:{account:"Compte",apiExplorer:"Explorateur d'API",apiKeys:"Cl\xE9s d'API",auditLogs:"Journaux d'Audit",developer:"D\xE9veloppeur",documentation:"Documentation",getSupport:"Obtenir de l'Aide",graphqlPlayground:"Playground GraphQL",permissions:"Permissions",profileSettings:"Param\xE8tres du Profil",resources:"Ressources",sessions:"Sessions",webHooks:"Webhooks"}};var Sl={actions:{cancel:"Cancelar",create:"Crear {{item}}",delete:"Eliminar",deleteDocument:"Eliminar Documento",deleteEntry:"Eliminar Entrada",deleting:"Eliminando...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Nuevo",newDocument:"Nuevo Documento",signOut:"Cerrar Sesi\xF3n",view:"Ver"},common:{na:"N/D",no:"No",yes:"S\xED"},dashboard:{activeUsers:"Usuarios Activos",authService:"Servicio de Autenticaci\xF3n",cloudApi:"API en la Nube",contentGrowth:"Crecimiento de Contenido",contentGrowthDesc:"Instant\xE1nea de la velocidad de los documentos en los \xFAltimos 7 d\xEDas",dbNode:"Nodo de Base de Datos",description:"Todo se ve genial en tu centro de comando hoy.",mediaAssets:"Recursos Multimedia",mediaCdn:"CDN Multimedia",mediaLibrary:"Biblioteca Multimedia",mediaLibraryDesc:"Administre recursos de alta fidelidad con nuestra galer\xEDa fluida.",newAction:"Nuevo {{item}}",noCollections:"No hay colecciones disponibles para crear.",openAssets:"Abrir Recursos",quickLinks:"Enlaces R\xE1pidos",recentActivity:"Actividad Reciente",statusActive:"Activo",statusHealthy:"Saludable",statusOptimal:"\xD3ptimo",statusSecure:"Seguro",systemHealth:"Salud del Sistema",systemStatus:"Estado del Sistema",totalContent:"Contenido Total",viewAuditLogs:"Ver Registros de Auditor\xEDa",welcome:"Bienvenido, {{name}}"},days:{fri:"Vie",mon:"Lun",sat:"S\xE1b",sun:"Dom",thu:"Jue",tue:"Mar",wed:"Mi\xE9"},detailView:{collections:"Colecciones",coreConfiguration:"Configuraci\xF3n Principal",dateCreated:"Fecha de Creaci\xF3n",deleteMessage:"Esta acci\xF3n no se puede deshacer.",deleteTitle:"\xBFEliminar {{label}}?",dynamicStatus:"Estado Din\xE1mico",generatingPreview:"Generando URL de vista previa...",globals:"Variables Globales",justNow:"Justo ahora",lastModified:"\xDAltima Modificaci\xF3n",metadata:"Metadatos",newDocument:"Nuevo {{label}}",openPreview:"Abrir Vista Previa",publicAt:"P\xFAblico a las",quickLinks:"Enlaces R\xE1pidos"},listView:{actionsCol:"Acciones",addFilter:"A\xF1adir Filtro",advancedFilters:"Filtros Avanzados",clearAll:"Borrar Todo",columns:"Columnas",createdCol:"Creado",deleteBulkMessage_one:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documento? Esto no se puede deshacer.",deleteBulkMessage_other:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documentos? Esto no se puede deshacer.",deleteBulkTitle:"Eliminar Documentos",deleteMessage:"\xBFEst\xE1s seguro de que quieres eliminar este documento? Esto no se puede deshacer.",deleteSelected:"Eliminar Selecci\xF3n",deleteTitle:"Eliminar Documento",filters:"Filtros",getStartedCreate:"Comienza creando tu primer {{item}}.",lastModifiedCol:"\xDAltima Modificaci\xF3n",noDocuments:"No se encontraron documentos",noFilters:'No hay filtros aplicados. Haz clic en "A\xF1adir Filtro" para crear uno.',searchPlaceholder:"Buscar...",selectedCount_one:"{{count}} seleccionado",selectedCount_other:"{{count}} seleccionados",toggleColumns:"Mostrar/Ocultar Columnas",tryAdjustingFilters:"Intenta ajustar tus filtros o consulta de b\xFAsqueda."},login:{confirmPassword:"Confirmar Contrase\xF1a",createAccount:"Crear Cuenta",createAccountDesc:"Crea una cuenta para acceder a la administraci\xF3n",createAdminAccount:"Crear Cuenta de Administrador",creatingAccount:"Creando cuenta...",email:"Correo Electr\xF3nico",enterCredentials:"Ingresa tus credenciales para acceder a la administraci\xF3n",hasAccount:"\xBFYa tienes una cuenta?",noAccount:"\xBFNo tienes una cuenta?",password:"Contrase\xF1a",setupAdmin:"Configura tu cuenta de administrador para empezar",signIn:"Iniciar Sesi\xF3n",signInAction:"Iniciar sesi\xF3n",signingIn:"Iniciando sesi\xF3n...",signUp:"Registrarse"},nav:{content:"Contenido",dashboard:"Panel de Control",developer:"Desarrollador",media:"Multimedia",plugins:"Complementos",resources:"Recursos",settings:"Ajustes",users:"Usuarios"},sidebar:{darkMode:"Modo Oscuro",lightMode:"Modo Claro"},toast:{accountCreated:"\xA1Cuenta creada!",connectionFailed:"Error de conexi\xF3n",copyError:"Error al copiar los datos del documento",dataCopied:"Datos del documento copiados al portapapeles",dataPasted:"Datos del documento pegados",draftSaved:"Borrador guardado",duplicated:"Documento duplicado",duplicateError:"Error al duplicar el documento",pasteError:"El portapapeles no contiene un JSON de documento v\xE1lido",published:"Publicado con \xE9xito",publishError:"Error al publicar",saveError:"Error al guardar los cambios",unpublished:"Documento despublicado",unpublishError:"Error al despublicar",updated:"Actualizado",welcomeBack:"\xA1Bienvenido de nuevo!"},userMenu:{account:"Cuenta",apiExplorer:"Explorador de API",apiKeys:"Claves de API",auditLogs:"Registros de Auditor\xEDa",developer:"Desarrollador",documentation:"Documentaci\xF3n",getSupport:"Obtener Soporte",graphqlPlayground:"Playground de GraphQL",permissions:"Permisos",profileSettings:"Ajustes de Perfil",resources:"Recursos",sessions:"Sesiones",webHooks:"Webhooks"}};var Al={actions:{cancel:"Abbrechen",create:"{{item}} Erstellen",delete:"L\xF6schen",deleteDocument:"Dokument L\xF6schen",deleteEntry:"Eintrag L\xF6schen",deleting:"Wird gel\xF6scht...",duplicateDocument:"Dokument Duplizieren",duplicating:"Wird dupliziert...",edit:"Bearbeiten",new:"Neu",newDocument:"Neues Dokument",signOut:"Abmelden",view:"Ansehen"},common:{na:"k.A.",no:"Nein",yes:"Ja"},dashboard:{activeUsers:"Aktive Benutzer",authService:"Authentifizierungsdienst",cloudApi:"Cloud API",contentGrowth:"Inhaltswachstum",contentGrowthDesc:"\xDCbersicht der Dokumentgeschwindigkeit in den letzten 7 Tagen",dbNode:"Datenbankknoten",description:"Alles sieht in Ihrer Kommandozentrale heute gro\xDFartig aus.",mediaAssets:"Medieninhalte",mediaCdn:"Medien CDN",mediaLibrary:"Mediathek",mediaLibraryDesc:"Verwalten Sie hochaufl\xF6sende Assets mit unserer fl\xFCssigen Galerie.",newAction:"Neues {{item}}",noCollections:"Keine Sammlungen zur Erstellung verf\xFCgbar.",openAssets:"Assets \xD6ffnen",quickLinks:"Schnellzugriff",recentActivity:"Letzte Aktivit\xE4ten",statusActive:"Aktiv",statusHealthy:"Gesund",statusOptimal:"Optimal",statusSecure:"Sicher",systemHealth:"Systemgesundheit",systemStatus:"Systemstatus",totalContent:"Gesamter Inhalt",viewAuditLogs:"Audit-Protokolle ansehen",welcome:"Willkommen zur\xFCck, {{name}}"},days:{fri:"Fr",mon:"Mo",sat:"Sa",sun:"So",thu:"Do",tue:"Di",wed:"Mi"},detailView:{collections:"Sammlungen",coreConfiguration:"Kernkonfiguration",dateCreated:"Erstellungsdatum",deleteMessage:"Diese Aktion kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteTitle:"{{label}} l\xF6schen?",dynamicStatus:"Dynamischer Status",generatingPreview:"Vorschau-URL wird generiert...",globals:"Globale Variablen",justNow:"Gerade eben",lastModified:"Zuletzt Ge\xE4ndert",metadata:"Metadaten",newDocument:"Neues {{label}}",openPreview:"Vorschau in neuem Tab \xF6ffnen",publicAt:"\xD6ffentlich um",quickLinks:"Schnellzugriff"},listView:{actionsCol:"Aktionen",addFilter:"Filter hinzuf\xFCgen",advancedFilters:"Erweiterte Filter",clearAll:"Alles l\xF6schen",columns:"Spalten",createdCol:"Erstellt",deleteBulkMessage_one:"Sind Sie sicher, dass Sie {{count}} Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkMessage_other:"Sind Sie sicher, dass Sie {{count}} Dokumente l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkTitle:"Dokumente L\xF6schen",deleteMessage:"Sind Sie sicher, dass Sie dieses Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteSelected:"Auswahl l\xF6schen",deleteTitle:"Dokument l\xF6schen",filters:"Filter",getStartedCreate:"Beginnen Sie mit der Erstellung Ihres ersten {{item}}.",lastModifiedCol:"Zuletzt Ge\xE4ndert",noDocuments:"Keine Dokumente gefunden",noFilters:'Keine Filter angewendet. Klicken Sie auf "Filter hinzuf\xFCgen", um einen zu erstellen.',searchPlaceholder:"Suchen...",selectedCount_one:"{{count}} ausgew\xE4hlt",selectedCount_other:"{{count}} ausgew\xE4hlt",toggleColumns:"Spalten umschalten",tryAdjustingFilters:"Versuchen Sie, Ihre Filter oder die Suchanfrage anzupassen."},login:{confirmPassword:"Passwort best\xE4tigen",createAccount:"Konto erstellen",createAccountDesc:"Erstellen Sie ein Konto, um auf die Verwaltung zuzugreifen",createAdminAccount:"Admin-Konto erstellen",creatingAccount:"Konto wird erstellt...",email:"E-Mail",enterCredentials:"Geben Sie Ihre Anmeldedaten ein, um auf die Verwaltung zuzugreifen",hasAccount:"Haben Sie bereits ein Konto?",noAccount:"Sie haben noch kein Konto?",password:"Passwort",setupAdmin:"Richten Sie Ihr Admin-Konto ein, um loszulegen",signIn:"Anmelden",signInAction:"Anmelden",signingIn:"Wird angemeldet...",signUp:"Registrieren"},nav:{content:"Inhalt",dashboard:"Dashboard",developer:"Entwickler",media:"Medien",plugins:"Plugins",resources:"Ressourcen",settings:"Einstellungen",users:"Benutzer"},sidebar:{darkMode:"Dunkler Modus",lightMode:"Heller Modus"},toast:{accountCreated:"Konto erstellt!",connectionFailed:"Verbindung fehlgeschlagen",copyError:"Fehler beim Kopieren der Dokumentdaten",dataCopied:"Dokumentdaten in die Zwischenablage kopiert",dataPasted:"Dokumentdaten eingef\xFCgt",draftSaved:"Entwurf gespeichert",duplicated:"Dokument dupliziert",duplicateError:"Fehler beim Duplizieren des Dokuments",pasteError:"Die Zwischenablage enth\xE4lt kein g\xFCltiges Dokument-JSON",published:"Erfolgreich ver\xF6ffentlicht",publishError:"Fehler beim Ver\xF6ffentlichen",saveError:"Fehler beim Speichern der \xC4nderungen",unpublished:"Ver\xF6ffentlichung r\xFCckg\xE4ngig gemacht",unpublishError:"Fehler beim R\xFCckg\xE4ngigmachen der Ver\xF6ffentlichung",updated:"Aktualisiert",welcomeBack:"Willkommen zur\xFCck!"},userMenu:{account:"Konto",apiExplorer:"API Explorer",apiKeys:"API-Schl\xFCssel",auditLogs:"Audit-Protokolle",developer:"Entwickler",documentation:"Dokumentation",getSupport:"Hilfe erhalten",graphqlPlayground:"GraphQL Playground",permissions:"Berechtigungen",profileSettings:"Profileinstellungen",resources:"Ressourcen",sessions:"Sitzungen",webHooks:"Webhooks"}};var Dl={actions:{cancel:"Cancelar",create:"Criar {{item}}",delete:"Excluir",deleteDocument:"Excluir Documento",deleteEntry:"Excluir Entrada",deleting:"Excluindo...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Novo",newDocument:"Novo Documento",signOut:"Sair",view:"Ver"},common:{na:"N/A",no:"N\xE3o",yes:"Sim"},dashboard:{activeUsers:"Usu\xE1rios Ativos",authService:"Servi\xE7o de Autentica\xE7\xE3o",cloudApi:"API em Nuvem",contentGrowth:"Crescimento de Conte\xFAdo",contentGrowthDesc:"Vis\xE3o geral da velocidade dos documentos nos \xFAltimos 7 dias",dbNode:"N\xF3 de Banco de Dados",description:"Tudo parece \xF3timo no seu centro de comando hoje.",mediaAssets:"Ativos de M\xEDdia",mediaCdn:"CDN de M\xEDdia",mediaLibrary:"Biblioteca de M\xEDdia",mediaLibraryDesc:"Gerencie ativos de alta fidelidade com nossa galeria fluida.",newAction:"Novo {{item}}",noCollections:"Nenhuma cole\xE7\xE3o dispon\xEDvel para cria\xE7\xE3o.",openAssets:"Abrir Ativos",quickLinks:"Links R\xE1pidos",recentActivity:"Atividade Recente",statusActive:"Ativo",statusHealthy:"Saud\xE1vel",statusOptimal:"Ideal",statusSecure:"Seguro",systemHealth:"Sa\xFAde do Sistema",systemStatus:"Status do Sistema",totalContent:"Conte\xFAdo Total",viewAuditLogs:"Ver Registros de Auditoria",welcome:"Bem-vindo de volta, {{name}}"},days:{fri:"Sex",mon:"Seg",sat:"S\xE1b",sun:"Dom",thu:"Qui",tue:"Ter",wed:"Qua"},detailView:{collections:"Cole\xE7\xF5es",coreConfiguration:"Configura\xE7\xE3o Principal",dateCreated:"Data de Cria\xE7\xE3o",deleteMessage:"Esta a\xE7\xE3o n\xE3o pode ser desfeita.",deleteTitle:"Excluir {{label}}?",dynamicStatus:"Status Din\xE2mico",generatingPreview:"Gerando URL de visualiza\xE7\xE3o...",globals:"Vari\xE1veis Globais",justNow:"Agora mesmo",lastModified:"\xDAltima Modifica\xE7\xE3o",metadata:"Metadados",newDocument:"Novo {{label}}",openPreview:"Abrir Visualiza\xE7\xE3o em Nova Guia",publicAt:"P\xFAblico \xE0s",quickLinks:"Links R\xE1pidos"},listView:{actionsCol:"A\xE7\xF5es",addFilter:"Adicionar Filtro",advancedFilters:"Filtros Avan\xE7ados",clearAll:"Limpar Tudo",columns:"Colunas",createdCol:"Criado",deleteBulkMessage_one:"Tem certeza de que deseja excluir {{count}} documento? Isso n\xE3o pode ser desfeito.",deleteBulkMessage_other:"Tem certeza de que deseja excluir {{count}} documentos? Isso n\xE3o pode ser desfeito.",deleteBulkTitle:"Excluir Documentos",deleteMessage:"Tem certeza de que deseja excluir este documento? Isso n\xE3o pode ser desfeito.",deleteSelected:"Excluir Selecionados",deleteTitle:"Excluir Documento",filters:"Filtros",getStartedCreate:"Comece criando seu primeiro {{item}}.",lastModifiedCol:"\xDAltima Modifica\xE7\xE3o",noDocuments:"Nenhum documento encontrado",noFilters:'Nenhum filtro aplicado. Clique em "Adicionar Filtro" para criar um.',searchPlaceholder:"Pesquisar...",selectedCount_one:"{{count}} selecionado",selectedCount_other:"{{count}} selecionados",toggleColumns:"Alternar Colunas",tryAdjustingFilters:"Tente ajustar seus filtros ou a consulta de pesquisa."},login:{confirmPassword:"Confirmar Senha",createAccount:"Criar Conta",createAccountDesc:"Crie uma conta para acessar a administra\xE7\xE3o",createAdminAccount:"Criar Conta de Administrador",creatingAccount:"Criando conta...",email:"E-mail",enterCredentials:"Insira suas credenciais para acessar a administra\xE7\xE3o",hasAccount:"J\xE1 tem uma conta?",noAccount:"N\xE3o tem uma conta?",password:"Senha",setupAdmin:"Configure sua conta de administrador para come\xE7ar",signIn:"Entrar",signInAction:"Entrar",signingIn:"Entrando...",signUp:"Inscrever-se"},nav:{content:"Conte\xFAdo",dashboard:"Painel de Controle",developer:"Desenvolvedor",media:"M\xEDdia",plugins:"Plugins",resources:"Recursos",settings:"Configura\xE7\xF5es",users:"Usu\xE1rios"},sidebar:{darkMode:"Modo Escuro",lightMode:"Modo Claro"},toast:{accountCreated:"Conta criada!",connectionFailed:"Falha na conex\xE3o",copyError:"Falha ao copiar os dados do documento",dataCopied:"Dados do documento copiados para a \xE1rea de transfer\xEAncia",dataPasted:"Dados do documento colados",draftSaved:"Rascunho salvo",duplicated:"Documento duplicado",duplicateError:"Falha ao duplicar documento",pasteError:"A \xE1rea de transfer\xEAncia n\xE3o cont\xE9m um JSON de documento v\xE1lido",published:"Publicado com sucesso",publishError:"Falha ao publicar",saveError:"Falha ao salvar as altera\xE7\xF5es",unpublished:"Documento despublicado",unpublishError:"Falha ao despublicar",updated:"Atualizado",welcomeBack:"Bem-vindo de volta!"},userMenu:{account:"Conta",apiExplorer:"Explorador de API",apiKeys:"Chaves de API",auditLogs:"Registros de Auditoria",developer:"Desenvolvedor",documentation:"Documenta\xE7\xE3o",getSupport:"Obter Suporte",graphqlPlayground:"Playground GraphQL",permissions:"Permiss\xF5es",profileSettings:"Configura\xE7\xF5es de Perfil",resources:"Recursos",sessions:"Sess\xF5es",webHooks:"Webhooks"}};var zu={en:{translation:Nl},fr:{translation:Cl},es:{translation:Sl},de:{translation:Al},pt:{translation:Dl}},Tl=typeof window<"u"&&window.KYRO_LANG?window.KYRO_LANG:"en";$u__default.default.use(Ou__default.default).use(reactI18next.initReactI18next).init({resources:zu,fallbackLng:Tl,lng:Tl,interpolation:{escapeValue:false}});function ho(e,t,r){return r in t?t[r]:Bs(e,t,r)}function Bs(e,t,r){for(let o of e)if(o.name){if(o.type==="tabs"&&"tabs"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Bs(o.tabs?.flatMap(s=>s.fields||[])||[],a,r);if(n!==void 0)return n}}if((o.type==="group"||o.type==="collapsible")&&"fields"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Bs(o.fields||[],a,r);if(n!==void 0)return n}}}}function Ms({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let{t:i}=reactI18next.useTranslation(),l=t||e.slug,{permissions:d}=_r(),c=d?.collections?.[l]?.create!==false,u=d?.collections?.[l]?.delete!==false,m=d?.collections?.[l]?.update!==false,v=()=>{if(c)if(a)a();else {let B=`${Ue}/${l}/new`;import('astro:transitions/client').then(({navigate:X})=>{X(B);}).catch(()=>{window.location.href=B;});}},x=B=>{if(n)n(B);else {let X=`${Ue}/${l}/${B}`;import('astro:transitions/client').then(({navigate:ae})=>{ae(X);}).catch(()=>{window.location.href=X;});}},[g,f]=Ta.useState(r),[b,p]=Ta.useState(o),[h,A]=Ta.useState(false),[$,T]=Ta.useState(1),[k,y]=Ta.useState(10),[w,D]=Ta.useState(new Set),[U,O]=Ta.useState(""),[z,P]=Ta.useState([]),{confirm:R,alert:Ae}=yt(),E=()=>{P([...z,{field:"",operator:"equals",value:""}]);},oe=()=>{O(""),P([]),ye(null);},ie=B=>{P(z.filter((X,ae)=>ae!==B));},ee=(B,X)=>{P(z.map((ae,Jt)=>Jt===B?{...ae,...X}:ae));},[G,ye]=Ta.useState(null),[De,L]=Ta.useState(false),[W,re]=Ta.useState(false);function H(B){let X=[];for(let ae of B||[])if(!(!ae.name||ae.hidden===true||ae.admin?.hidden||ae.name==="id"))if(ae.type==="tabs"&&ae.tabs)for(let Jt of ae.tabs)Jt.fields&&X.push(...H(Jt.fields));else (ae.type==="row"||ae.type==="collapsible")&&ae.fields?X.push(...H(ae.fields)):X.push(ae);return X}let Te=Ta.useMemo(()=>H(e.fields),[e.fields]),fe=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:Te.find(B=>B.type!=="group"&&typeof B.name=="string")?.name,[we,S]=Ta.useState(()=>{let B;return e.admin?.defaultColumns?B=[...e.admin?.defaultColumns||[]]:B=Te.slice(0,4).map(X=>X.name).filter(X=>!!X),fe&&B.includes(fe)&&(B=[fe,...B.filter(X=>X!==fe)]),B.includes("updatedAt")||B.push("updatedAt"),new Set(B)}),j=Ta.useCallback(B=>{S(X=>{let ae=new Set(X);return ae.has(B)?ae.delete(B):ae.add(B),ae});},[]);function xe(B){let X=Te.find(ae=>ae.name===B);return X&&X.type==="group"&&X.fields?.[0]?.name?`${B}.${X.fields[0].name}`:B}let Le=Ta.useCallback(B=>{let X=xe(B);ye(ae=>ae&&ae.field===X?{field:X,direction:ae.direction==="asc"?"desc":"asc"}:{field:X,direction:"asc"});},[]),Be=Ta.useMemo(()=>{let B=[];for(let X of Array.from(we))if(X==="status")B.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]});else {let ae=Te.find(Jt=>Jt.name===X);ae&&ae.name&&B.push(ae);}return B},[Te,we]);function Pe(B){return !B.name||!fe?false:B.name===fe||B.type==="group"&&B.fields?.[0]?.name===fe}function ft(B,X){return X.name?ho(e.fields,B,X.name)??null:null}let qt=Ta.useCallback(async()=>{A(true);try{let B=new URLSearchParams({page:$.toString(),limit:k.toString()});U&&B.append("search",U),G&&B.append("sort",G.field),G&&B.append("order",G.direction),z.length>0&&B.append("filters",JSON.stringify(z));let X=await Ee(Kr(`/api/${l}?${B}`),{autoToast:!1});f(X.docs||[]),p(X.totalDocs||0);}catch(B){console.error("Failed to load docs:",B);}finally{A(false);}},[l,$,k,U,G,z]);Ta.useEffect(()=>{g.length===0&&o===0&&qt();},[]);let J=Ta.useRef(true);Ta.useEffect(()=>{if(J.current){J.current=false;return}qt();},[$,k,U,G,z]);let M=()=>{w.size===g.length?D(new Set):D(new Set(g.map(B=>B.id)));},K=B=>{let X=new Set(w);X.has(B)?X.delete(B):X.add(B),D(X);},le=()=>{R({title:i("listView.deleteBulkTitle",{defaultValue:"Delete Documents"}),message:i("listView.deleteBulkMessage",{defaultValue:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",count:w.size}),variant:"danger",onConfirm:async()=>{try{for(let B of Array.from(w))await At(`/api/${l}/${B}`);D(new Set),qt(),V.success("Documents deleted");}catch(B){console.error("Bulk delete failed:",B),V.error("Failed to delete some documents");}}});},Fe=B=>{R({title:i("listView.deleteTitle",{defaultValue:"Delete Document"}),message:i("listView.deleteMessage",{defaultValue:"Are you sure you want to delete this document? This cannot be undone."}),variant:"danger",onConfirm:async()=>{try{await At(`/api/${l}/${B}`),qt(),V.success("Document deleted");}catch(X){console.error("Delete failed:",X),V.error("Failed to delete document");}}});},Oe=Math.ceil(b/k),gt=U||z.length>0||G;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Lt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:b>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[b," documents"]},"count")]:void 0,action:c?{label:i("actions.create",{defaultValue:"Create {{item}}",item:e.singularLabel||e.label||l}),href:a?void 0:`${Ue}/${l}/new`,onClick:a?v:void 0,icon:Ql.Plus}:void 0}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:i("listView.searchPlaceholder",{defaultValue:"Search..."}),value:U,onChange:B=>O(B.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-sm font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>L(!De),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${De||z.length>0?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Ql.Filter,{className:"w-4 h-4"}),i("listView.filters",{defaultValue:"Filters"}),z.length>0&&jsxRuntime.jsx("span",{className:"ml-1 px-1.5 py-0.5 bg-[var(--kyro-sidebar-text-active)] text-[var(--kyro-sidebar-active)] rounded-full text-xs",children:z.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>re(!W),className:"flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",children:[jsxRuntime.jsx(Ql.Columns3,{className:"w-4 h-4"}),i("listView.columns",{defaultValue:"Columns"})]}),W&&jsxRuntime.jsxs("div",{className:"absolute right-0 top-full mt-2 w-56 surface-tile border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 overflow-hidden",children:[jsxRuntime.jsx("div",{className:"p-3 border-b border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-xs font-bold tracking-wider text-[var(--kyro-text-secondary)]",children:i("listView.toggleColumns",{defaultValue:"Toggle Columns"})})}),jsxRuntime.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:Te.map(B=>B.name?jsxRuntime.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:we.has(B.name),onChange:()=>j(B.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:B.label||B.name})]},B.name):null)})]})]}),gt&&jsxRuntime.jsx("button",{type:"button",onClick:oe,className:"px-4 py-2 rounded-xl font-bold text-sm text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 transition-all",children:i("listView.clearAll",{defaultValue:"Clear All"})})]})]}),De&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("h3",{className:"font-medium text-[var(--kyro-text-primary)]",children:i("listView.advancedFilters",{defaultValue:"Advanced Filters"})}),jsxRuntime.jsxs("button",{type:"button",onClick:E,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-bold text-[var(--kyro-sidebar-active)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),i("listView.addFilter",{defaultValue:"Add Filter"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[z.map((B,X)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:B.field,onChange:ae=>ee(X,{field:ae.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:Te.map(ae=>jsxRuntime.jsx("option",{value:ae.name,children:ae.label||ae.name},ae.name))}),jsxRuntime.jsxs("select",{value:B.operator,onChange:ae=>ee(X,{operator:ae.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("option",{value:"equals",children:"Equals"}),jsxRuntime.jsx("option",{value:"contains",children:"Contains"}),jsxRuntime.jsx("option",{value:"gt",children:"Greater than"}),jsxRuntime.jsx("option",{value:"lt",children:"Less than"}),jsxRuntime.jsx("option",{value:"gte",children:"Greater or equal"}),jsxRuntime.jsx("option",{value:"lte",children:"Less or equal"})]}),jsxRuntime.jsx("input",{type:"text",value:B.value,onChange:ae=>ee(X,{value:ae.target.value}),placeholder:i("fields.value",{defaultValue:"Value..."}),className:"flex-1 min-w-[150px] px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>ie(X),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]},X)),z.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:i("listView.noFilters",{defaultValue:'No filters applied. Click "Add Filter" to create one.'})})]})]}),w.size>0&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex items-center justify-between border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:i("listView.selectedCount",{defaultValue:"{{count}} selected",count:w.size})}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[u&&jsxRuntime.jsxs("button",{type:"button",onClick:le,className:"flex items-center gap-2 px-4 py-2 bg-red-500 text-white rounded-lg font-bold text-sm hover:bg-red-600 transition-all",children:[jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"}),i("listView.deleteSelected",{defaultValue:"Delete Selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>D(new Set),className:"px-4 py-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] font-bold text-sm transition-all",children:i("actions.cancel",{defaultValue:"Cancel"})})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden",children:h?jsxRuntime.jsx("div",{className:"space-y-2 p-4",children:jsxRuntime.jsx(jt,{variant:"table-row",count:8})}):g.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsxRuntime.jsx(Ql.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:i("listView.noDocuments",{defaultValue:"No documents found"})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:gt?i("listView.tryAdjustingFilters",{defaultValue:"Try adjusting your filters or search query."}):i("listView.getStartedCreate",{defaultValue:"Get started by creating your first {{item}}.",item:(e.singularLabel||e.label||l).toLowerCase()})}),!gt&&c&&jsxRuntime.jsxs("button",{type:"button",onClick:v,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),i("actions.create",{defaultValue:"Create {{item}}",item:String(e.singularLabel||e.label||l)})]})]}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[10px] tracking-[0.3em] border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-4 py-4 w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:w.size===g.length&&g.length>0,onChange:M,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Be.map(B=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Le(B.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[_u(Be,B.type)??(B.label||B.name),G&&G.field===B.name&&jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4"})]})},B.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:i("listView.createdCol",{defaultValue:"Created"})}):null,e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:i("listView.lastModifiedCol",{defaultValue:"Last Modified"})}):null,jsxRuntime.jsx("th",{className:"px-4 py-4 text-right",children:i("listView.actionsCol",{defaultValue:"Actions"})})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:g.map(B=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>x(B.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:X=>X.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:w.has(B.id),onChange:()=>K(B.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Be.map(X=>{let ae=ft(B,X),Jt=X.type==="select"&&ae&&Array.isArray(X.options)?X.options.find(fo=>fo.value===ae)?.label||ae:Hu(ae,X.type,i);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${Pe(X)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:Jt},X.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:B.createdAt?new Date(B.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:B.updatedAt?new Date(B.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:X=>X.stopPropagation(),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(B.id),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",title:m?i("actions.edit",{defaultValue:"Edit"}):i("actions.view",{defaultValue:"View"}),children:jsxRuntime.jsx(Ql.Pencil,{className:"w-4 h-4"})}),u&&jsxRuntime.jsx("button",{type:"button",onClick:()=>Fe(B.id),className:"inline-flex items-center justify-center w-8 h-8 rounded-md text-[var(--kyro-text-muted)] hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-500/10 transition-colors",title:i("actions.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"})})]})})]},B.id))})]})})}),jsxRuntime.jsx(wl,{page:$,totalPages:Oe,totalDocs:b,limit:k,onPageChange:T,onLimitChange:B=>{y(B),T(1);}})]})}function Hu(e,t,r){return e==null?"\u2014":typeof e=="boolean"?e?r?r("common.yes",{defaultValue:"Yes"}):"Yes":r?r("common.no",{defaultValue:"No"}):"No":t==="number"||t==="price"?String(e):t==="date"||t==="datetime"?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):Array.isArray(e)?e.map(o=>o&&typeof o=="object"?o.title||o.name||o.email||o.filename||o.url||JSON.stringify(o).slice(0,30):String(o??"").slice(0,30)).filter(Boolean).join(", "):typeof e=="object"?e.title?e.title:e.name?e.name:e.email?e.email:JSON.stringify(e).slice(0,50):String(e).slice(0,60)}function _u(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var Ls=(e,t)=>{let r=e?.toLowerCase()||"",o=t?.toLowerCase()||"";return r.startsWith("image/")||o.match(/\.(jpe?g|png|gif|webp|avif|svg)$/i)?"image":r.startsWith("video/")||o.match(/\.(mp4|webm|ogg|mov)$/i)?"video":r.startsWith("audio/")||o.match(/\.(mp3|wav|ogg|m4a)$/i)?"audio":r.includes("pdf")||o.endsWith(".pdf")?"pdf":o.match(/\.(doc|docx|txt|rtf|odt)$/i)?"document":o.match(/\.(xls|xlsx|csv)$/i)?"spreadsheet":o.match(/\.(zip|tar|gz|7z|rar)$/i)?"archive":"other"},El=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(Ql.Image,{className:t});case "video":return jsxRuntime.jsx(Ql.Film,{className:t});case "audio":return jsxRuntime.jsx(Ql.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(Ql.FileText,{className:t});default:return jsxRuntime.jsx(Ql.File,{className:t})}};function mr({field:e,value:t,onChange:r,disabled:o}){let a=Ta.useRef(null),n=Ta.useRef(null),[s,i]=Ta.useState(false),[l,d]=Ta.useState(false),[c,u]=Ta.useState(false),[m,v]=Ta.useState([]),[x,g]=Ta.useState([]),[f,b]=Ta.useState(""),[p,h]=Ta.useState(false),[A,$]=Ta.useState(""),[T,k]=Ta.useState(false),[y,w]=Ta.useState(""),[D,U]=Ta.useState(""),[O,z]=Ta.useState([]),P=e?.label||e?.name||"File",R=e.maxCount??(e.hasMany?999:1),Ae=R>1,E=Array.isArray(t)?t:t?[t]:[],oe=E.length<R,[ie,ee]=Ta.useState({});Ta.useEffect(()=>{(async()=>{let j=E.filter(Pe=>typeof Pe=="string").map(Pe=>Pe),xe=E.filter(Pe=>typeof Pe=="object"&&Pe!==null&&typeof Pe.id=="string"&&!Pe.url&&!Pe.filename&&!Pe.mimeType).map(Pe=>Pe.id),Be=[...j,...xe].filter(Pe=>!ie[Pe]);if(Be.length!==0)try{let Pe=await Promise.all(Be.map(ft=>Ee(`/api/media/${ft}`)));ee(ft=>{let qt={...ft};return Pe.forEach(J=>{J&&J.id&&(qt[J.id]=J);}),qt});}catch(Pe){console.error("Failed to fetch media details:",Pe);}})();},[t,ie]),Ta.useEffect(()=>{l&&(G(),ye());},[l,f]);let G=async()=>{try{let S=await Ee(Kr("/api/media/folders"));g(S.folders||[]);}catch{g([]);}},ye=async()=>{h(true);try{let S=Kr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");f&&(S+="&folder="+encodeURIComponent(f));let j=await Ee(S);v(j.docs||[]);}catch{v([]);}finally{h(false);}},De=async S=>{i(true);try{let j=new FormData;j.append("file",S),f&&j.append("folder",f);let xe=await sn("/api/media/upload",j),Le=xe.data||xe.doc||xe,Be={...Le,id:Le.id,filename:Le.filename,originalName:Le.originalName??S.name,url:Le.url,mimeType:Le.mimeType||S.type};r(Ae?[...E,Be]:Be),V.success(`Asset synchronized: ${Be.filename}`);}catch(j){console.error("Upload failed:",j),V.error(`Upload failed: ${j instanceof Error?j.message:"Unknown error"}`);}finally{i(false);}},L=async()=>{let S=y.trim();if(S){U("");try{let j=await dt("/api/media/upload",{url:S}),xe=(()=>{try{return new URL(S).pathname.split("/").pop()||j.originalName||"url-image"}catch{return j.originalName||"url-image"}})(),Le={id:j.id,filename:j.filename,originalName:xe,url:j.url,mimeType:j.mimeType||"image/*"};r(Ae?[...E,Le]:Le),V.success(`URL asset established: ${Le.filename}`),w(""),k(!1);}catch(j){let xe=j instanceof Error?j.message:"Invalid URL";U(xe);}}},W=S=>({id:S.id,filename:S.filename,url:S.url,mimeType:S.mimeType}),re=S=>{Ae?z(j=>j.find(Le=>Le.id===S.id)?j.filter(Le=>Le.id!==S.id):[...j,S]):(r(W(S)),d(false),$(""));},H=()=>{if(O.length>0){let S=[...E,...O.map(W)];r(S);}z([]),d(false),$("");},Te=S=>{let j=[...E];j.splice(S,1),r(Ae?j:j[0]||null);},fe=Ta.useMemo(()=>m.filter(S=>!A||S.filename?.toLowerCase().includes(A.toLowerCase())||S.title?.toLowerCase().includes(A.toLowerCase())),[m,A]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let we=(S,j)=>{if(!S)return null;let xe=typeof S=="string"?S:S.id,Le=ie[xe]||(typeof S=="object"?S:{}),Be=Ls(Le.mimeType,Le.filename||Le.url);return jsxRuntime.jsxs("div",{className:"flex items-center gap-3 p-2.5 bg-[var(--kyro-surface-accent)] rounded-lg border border-[var(--kyro-border)] group",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 rounded-md overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex items-center justify-center flex-shrink-0",children:Be==="image"?jsxRuntime.jsx("img",{src:Ca(Le.url),alt:Le.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(El,{type:Be,className:"w-5 h-5 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-[11px] font-medium truncate text-[var(--kyro-text-primary)]",children:Le.originalName||Le.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:P})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>j!==void 0?Te(j):r(null),disabled:o,className:"p-1.5 rounded-md text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)] transition-all opacity-0 group-hover:opacity-100",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]},j)};return jsxRuntime.jsxs("div",{className:"space-y-2 relative",children:[jsxRuntime.jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:S=>{let j=S.target.files?.[0];j&&De(j);},disabled:o,className:"hidden"}),E.length>0&&jsxRuntime.jsx("div",{className:Ae?"grid grid-cols-2 gap-2":"space-y-2",children:E.map((S,j)=>we(S,j))}),(!E.length||oe)&&jsxRuntime.jsxs("div",{className:"flex gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a.current?.click(),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:["+ Upload ",P]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{z([]),d(true);},disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"Library"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>k(!T),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"URL"})]}),T&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:y,onChange:S=>{w(S.target.value),U("");},onKeyDown:S=>S.key==="Enter"&&L(),disabled:o,className:"flex-1 px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),jsxRuntime.jsx("button",{type:"button",onClick:L,disabled:o||!y.trim(),className:"kyro-btn kyro-btn-primary px-3 py-1.5 text-xs rounded cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50",children:"Add"}),D&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:D})]}),l&&(c?reactDom.createPortal(jsxRuntime.jsx(Bl,{isFullscreen:true,isMultiple:Ae,selectedItems:O,pickerSearch:A,setPickerSearch:$,folders:x,selectedFolder:f,setSelectedFolder:b,mediaLoading:p,filteredMedia:fe,selectFromLibrary:re,onDone:H,setIsPickerFullscreen:u,setShowPicker:d}),document.body):jsxRuntime.jsx(Bl,{isFullscreen:false,isMultiple:Ae,selectedItems:O,pickerSearch:A,setPickerSearch:$,folders:x,selectedFolder:f,setSelectedFolder:b,mediaLoading:p,filteredMedia:fe,selectFromLibrary:re,onDone:H,setIsPickerFullscreen:u,setShowPicker:d}))]})}function Bl({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:i,mediaLoading:l,filteredMedia:d,selectFromLibrary:c,onDone:u,setIsPickerFullscreen:m,setShowPicker:v}){let{t:x}=reactI18next.useTranslation(),g=f=>r.some(b=>b.id===f);return jsxRuntime.jsxs("div",{className:`${e?"fixed inset-0 z-[9999]":"relative z-[9999] w-[360px] max-h-[400px] mt-1 rounded-lg shadow-lg"} overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex flex-col`,children:[jsxRuntime.jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsxRuntime.jsx("input",{type:"text",placeholder:x("fields.searchMedia",{defaultValue:"Search media..."}),value:o,onChange:f=>a(f.target.value),className:"w-full px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),n.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(""),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===""?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:"All"}),n.slice(0,6).map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(f.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===f.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:f.name},f.path))]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-2",children:l?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"No media found"}):jsxRuntime.jsx("div",{className:`grid gap-1 ${e?"grid-cols-[repeat(auto-fill,minmax(140px,1fr))]":"grid-cols-3"}`,children:d.map(f=>{let b=g(f.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(f),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${b?"border-[var(--kyro-primary)] ring-2 ring-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]"}`,children:[jsxRuntime.jsx("div",{className:`w-full flex items-center justify-center bg-[var(--kyro-surface-accent)] ${e?"h-[120px]":"h-[80px]"}`,children:Ls(f.mimeType,f.filename)==="image"?jsxRuntime.jsx("img",{src:Ca(f.thumbnailUrl||f.url),alt:f.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(El,{type:Ls(f.mimeType,f.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&b&&jsxRuntime.jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsxRuntime.jsx(Ql.Check,{className:"w-3 h-3 text-white"})})]},f.id)})})}),jsxRuntime.jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[d.length," items"]}),jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[t&&jsxRuntime.jsxs("button",{type:"button",onClick:u,className:"kyro-btn kyro-btn-primary px-3 py-1 text-xs font-semibold rounded cursor-pointer hover:opacity-90 transition-opacity",children:["Done",r.length>0?` (${r.length})`:""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(!e),className:"p-1.5 rounded text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",title:e?"Exit fullscreen":"Fullscreen",children:e?jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})}):jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(false),m(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function ct({field:e,error:t,children:r,hideLabel:o=false}){return jsxRuntime.jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsxRuntime.jsx("div",{className:"flex justify-between items-end mb-1",children:jsxRuntime.jsxs("label",{className:"block text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 group-focus-within:opacity-100 group-focus-within:text-[var(--kyro-primary)] transition-all duration-300",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsxRuntime.jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsxRuntime.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin.description}),t&&jsxRuntime.jsxs("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-error)] font-bold flex items-center gap-2 animate-in fade-in slide-in-from-top-1 duration-300",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function yr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let i=Ta.useRef(null),[l,d]=Ta.useState(false);Ta.useEffect(()=>{d(true);},[]),Ta.useEffect(()=>{let u=m=>{m.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",u),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",u),document.body.style.overflow="";}},[e,t]);let c={sm:"w-full sm:w-[320px]",md:"w-full sm:w-[400px]",lg:"w-full sm:w-[550px]",xl:"w-full sm:w-[700px]"};return !e||!l?null:reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-[99998] bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{ref:i,"data-kyro-slide-panel":"true","data-kyro-slide-width":a,className:`fixed right-0 top-0 bottom-0 z-[99999] ${c[a]} bg-[var(--kyro-surface)] ${s?`border-l-2 ${s}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1.5 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsxRuntime.jsx("style",{children:`
1
+ 'use strict';var oa=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),Nc=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),shim=require('use-sync-external-store/shim'),reactDom=require('react-dom'),react=require('@tiptap/react'),jf=require('@tiptap/starter-kit'),Uf=require('@tiptap/extension-link'),zf=require('@tiptap/extension-image'),Hf=require('@tiptap/extension-text-align'),_f=require('@tiptap/extension-underline'),Kf=require('@tiptap/extension-highlight'),Gf=require('@tiptap/extension-task-list'),Wf=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),Jf=require('@tiptap/extension-color'),Rf=require('react-image-crop');require('react-image-crop/dist/ReactCrop.css');var codemirrorThemeGithub=require('@uiw/codemirror-theme-github'),codemirrorThemeAura=require('@uiw/codemirror-theme-aura'),unstorage=require('unstorage'),Ly=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Ko=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),yv=require('@uiw/react-codemirror'),langJson=require('@codemirror/lang-json');require('@kyro-cms/core');var Nr=require('path'),url=require('url'),esbuild=require('esbuild'),dotenv=require('dotenv'),worker_threads=require('worker_threads');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var oa__default=/*#__PURE__*/_interopDefault(oa);var Nc__namespace=/*#__PURE__*/_interopNamespace(Nc);var jf__default=/*#__PURE__*/_interopDefault(jf);var Uf__default=/*#__PURE__*/_interopDefault(Uf);var zf__default=/*#__PURE__*/_interopDefault(zf);var Hf__default=/*#__PURE__*/_interopDefault(Hf);var _f__default=/*#__PURE__*/_interopDefault(_f);var Kf__default=/*#__PURE__*/_interopDefault(Kf);var Gf__default=/*#__PURE__*/_interopDefault(Gf);var Wf__default=/*#__PURE__*/_interopDefault(Wf);var Jf__default=/*#__PURE__*/_interopDefault(Jf);var Rf__default=/*#__PURE__*/_interopDefault(Rf);var Ly__default=/*#__PURE__*/_interopDefault(Ly);var Ko__default=/*#__PURE__*/_interopDefault(Ko);var yv__default=/*#__PURE__*/_interopDefault(yv);var Nr__default=/*#__PURE__*/_interopDefault(Nr);var Wp=Object.create;var Pl=Object.defineProperty;var qp=Object.getOwnPropertyDescriptor;var Jp=Object.getOwnPropertyNames;var Xp=Object.getPrototypeOf,Yp=Object.prototype.hasOwnProperty;var Qp=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Zp=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Jp(t))!Yp.call(e,a)&&a!==r&&Pl(e,a,{get:()=>t[a],enumerable:!(o=qp(t,a))||o.enumerable});return e};var em=(e,t,r)=>(r=e!=null?Wp(Xp(e)):{},Zp(!e||!e.__esModule?Pl(r,"default",{value:e,enumerable:true}):r,e));var Id=Qp((c0,Fd)=>{Fd.exports={area:true,base:true,br:true,col:true,embed:true,hr:true,img:true,input:true,link:true,meta:true,param:true,source:true,track:true,wbr:true};});var He=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",Tr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Xe(e){if(e.startsWith("http")||e.startsWith(Tr))return e;if(e.startsWith("/api/"))return Tr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${Tr}${t}${e}`}function ri(e){return e.startsWith("http")||e.startsWith(He)?e:e.startsWith("/admin/")?He+e.slice(6):e.startsWith("/")?He+e:e}function Va(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var tm={admin:He,api:Tr,resolveApi:Xe,resolveAdmin:ri,resolveMedia:Va};var Yr=zustand.create(e=>({user:null,permissions:null,isAuthenticated:false,isLoading:true,error:null,setUser:(t,r=null)=>e({user:t,permissions:r,isAuthenticated:!!t,isLoading:false,error:null}),setLoading:t=>e({isLoading:t}),setError:t=>e({error:t,isLoading:false,isAuthenticated:false,user:null,permissions:null}),logout:()=>e({user:null,permissions:null,isAuthenticated:false,isLoading:false,error:null})}));var Zt=zustand.create(e=>({toasts:[],addToast:(t,r)=>{let o=Math.random().toString(36).substring(7);e(a=>({toasts:[...a.toasts,{id:o,type:t,message:r}]}));},removeToast:t=>e(r=>({toasts:r.toasts.filter(o=>o.id!==t)})),clearToasts:()=>e({toasts:[]})})),U={success:e=>Zt.getState().addToast("success",e),error:e=>Zt.getState().addToast("error",e),warning:e=>Zt.getState().addToast("warning",e),info:e=>Zt.getState().addToast("info",e)};zustand.create()(middleware.persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var gt=zustand.create(e=>({sidebarOpen:true,toggleSidebar:()=>e(t=>({sidebarOpen:!t.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),modal:{open:false,config:null},confirm:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default"}}}),alert:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default",confirmLabel:t.confirmLabel||"OK",onConfirm:()=>e(r=>({modal:{...r.modal,open:false}}))}}}),closeModal:()=>e(t=>({modal:{...t.modal,open:false},activeModal:null})),activeModal:null,openModal:t=>e({activeModal:t})}));zustand.create(e=>({editor:null,setEditor:t=>e({editor:t}),blockDrawerOpen:false,openBlockDrawer:t=>e({blockDrawerOpen:true,pendingInsert:{pos:null,column:t?.targetColumn??null}}),closeBlockDrawer:()=>e({blockDrawerOpen:false,pendingInsert:{pos:null,column:null}}),toggleBlockDrawer:()=>e(t=>({blockDrawerOpen:!t.blockDrawerOpen})),selectedBlock:null,setSelectedBlock:t=>e({selectedBlock:t}),pendingInsert:{pos:null,column:null},setPendingInsert:(t,r)=>e({pendingInsert:{pos:t,column:r??null}}),clearPendingInsert:()=>e({pendingInsert:{pos:null,column:null}})}));zustand.create((e,t)=>({cache:{},setCache:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:o,loading:false,error:null,lastFetch:Date.now()}}})),setLoading:(r,o)=>e(a=>({cache:{...a.cache,[r]:{...a.cache[r],loading:o,error:null}}})),setError:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:null,loading:false,error:o,lastFetch:null}}})),getCache:r=>t().cache[r]||null,invalidateCache:r=>e(o=>{if(r){let{[r]:a,...n}=o.cache;return {cache:n}}return {cache:{}}})}));var om="/api/auth/refresh";async function Rl(){try{return (await fetch(Xe(om),{method:"POST",credentials:"include"})).ok}catch{return false}}async function ct(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(Xe(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await Rl()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(Xe(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function Be(e,t){let{autoToast:r=true,...o}=t||{},a=await ct(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&U.error(n),new Error(n)}return a.json()}async function ut(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ct(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let i=await n.json();i.error&&(s=i.error);}catch{}throw o&&U.error(s),new Error(s)}return n.json()}async function er(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ct(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let i=await n.json();i.error&&(s=i.error);}catch{}throw o&&U.error(s),new Error(s)}return n.json()}async function Dt(e,t){let{autoToast:r=true,...o}={},a=await ct(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let i=await a.json();i.error&&(s=i.error);}catch{}throw r&&U.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function Qr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function An(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function Tn(e,t,r){if(!r){let o=await ct(e,{method:"POST",body:t});if(!o.ok)throw new Error(`Upload Error: ${o.status}`);return o.json()}return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("POST",Xe(e)),n.withCredentials=true,n.upload.addEventListener("progress",s=>{s.lengthComputable&&r(Math.round(s.loaded/s.total*100));}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{o(JSON.parse(n.responseText));}catch{a(new Error("Invalid JSON response"));}else n.status===401?Rl().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let i=new XMLHttpRequest;i.open("POST",Xe(e)),i.withCredentials=true,i.upload.addEventListener("progress",l=>{l.lengthComputable&&r(Math.round(l.loaded/l.total*100));}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{o(JSON.parse(i.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${i.status}`));}),i.addEventListener("error",()=>a(new Error("Network error"))),i.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function ir({size:e="md",className:t=""}){return jsxRuntime.jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}function Kt({variant:e,count:t=1,className:r=""}){let o={text:"h-3 rounded-md",circle:"size-10 rounded-full",rect:"h-10 rounded-xl",card:"h-32 rounded-2xl","table-row":"h-14 rounded-xl","media-card":"aspect-square rounded-2xl","stat-card":"h-24 rounded-2xl"};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:Array.from({length:t}).map((a,n)=>jsxRuntime.jsx("div",{className:`kyro-shimmer ${o[e]} ${r}`},n))})}function fd({back:e}){return e.href?jsxRuntime.jsx("a",{href:e.href,onClick:t=>{e.onClick&&(t.preventDefault(),e.onClick());},className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}):jsxRuntime.jsx("button",{type:"button",onClick:e.onClick,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})})}function nm({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(oa__default.default.Fragment,{children:[r>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),t.href||t.onClick?jsxRuntime.jsx("a",{href:t.href,onClick:o=>{t.onClick&&(o.preventDefault(),t.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:t.label}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:t.label})]},r))}function yd({actions:e}){return Array.isArray(e)?jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>{let o=`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all ${t.variant==="outline"?"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":t.variant==="ghost"?"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] shadow-none":"kyro-btn-primary hover:opacity-90"} ${t.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${t.className||""}`;return t.href&&!t.disabled?jsxRuntime.jsxs("a",{href:t.href,className:o,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r):jsxRuntime.jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:o,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r)})}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function gd({action:e}){let t=`kyro-btn kyro-btn-primary flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`;return e.href&&!e.disabled?jsxRuntime.jsxs("a",{href:e.href,className:t,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]}):jsxRuntime.jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:t,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function Vt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:i,children:l}){let d=o?.[o.length-1];return jsxRuntime.jsxs("div",{className:"surface-tile px-3 md:px-6 py-3 md:pt-4 mb-4 md:mb-8",children:[jsxRuntime.jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n&&jsxRuntime.jsx(fd,{back:n}),jsxRuntime.jsxs("details",{className:"group [&::-webkit-details-marker]:hidden flex-1 min-w-0",children:[jsxRuntime.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[jsxRuntime.jsx("span",{className:"flex-1 text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] truncate",children:d?.label||""}),jsxRuntime.jsx("svg",{className:"w-3 h-3 text-[var(--kyro-text-secondary)] opacity-40 group-open:rotate-180 transition-transform",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--kyro-border)] space-y-2",children:[o&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o.map((c,u)=>jsxRuntime.jsxs(oa__default.default.Fragment,{children:[u>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsxRuntime.jsx("a",{href:c.href,onClick:p=>{c.onClick&&(p.preventDefault(),c.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:c.label}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:c.label})]},u))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,u)=>jsxRuntime.jsx(oa__default.default.Fragment,{children:c},u))}),l]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r&&jsxRuntime.jsx(r,{className:"w-5 h-5 text-[var(--kyro-primary)] shrink-0"}),e&&jsxRuntime.jsx("h1",{className:"text-lg font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e}),a&&!t&&jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full bg-[var(--kyro-primary)] shrink-0"})]}),t&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0 text-xs",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxRuntime.jsxs(oa__default.default.Fragment,{children:[u===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))})]})]}),jsxRuntime.jsxs("div",{className:"hidden md:flex md:flex-row md:items-center justify-between gap-6",children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n&&jsxRuntime.jsx(fd,{back:n}),o&&jsxRuntime.jsx(nm,{breadcrumbs:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[r&&jsxRuntime.jsx(r,{className:"w-6 h-6 text-[var(--kyro-primary)]"}),e&&jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e})]}),(t||a)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-1",children:[t&&jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxRuntime.jsxs(oa__default.default.Fragment,{children:[u===0&&(t||u>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))}),l]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[i&&jsxRuntime.jsx(yd,{actions:i}),s&&jsxRuntime.jsx(gd,{action:s})]})]}),(i||s)&&jsxRuntime.jsxs("div",{className:"md:hidden flex items-center gap-2 mt-3 pt-3 border-t border-[var(--kyro-border)]",children:[s&&jsxRuntime.jsx(gd,{action:s}),i&&jsxRuntime.jsx(yd,{actions:i})]})]})}var im={draft:{class:"bg-gray-100 text-gray-600",label:"Draft"},published:{class:"bg-green-100 text-green-700",label:"Published"},scheduled:{class:"bg-blue-100 text-blue-700",label:"Scheduled"},archived:{class:"bg-yellow-100 text-yellow-700",label:"Archived"},active:{class:"bg-green-100 text-green-700",label:"Active"},inactive:{class:"bg-gray-100 text-gray-600",label:"Inactive"},pending:{class:"bg-yellow-100 text-yellow-700",label:"Pending"},completed:{class:"bg-green-100 text-green-700",label:"Completed"},cancelled:{class:"bg-red-100 text-red-700",label:"Cancelled"}};function Lt({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=im[n],i=s?s.class:`kyro-badge-${n}`;return jsxRuntime.jsxs("span",{className:`kyro-badge ${i} ${r}`,children:[a&&jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1.5 opacity-60"}),o||s?.label||n]})}function pi({count:e,max:t=99}){return e===0?null:jsxRuntime.jsx("span",{className:"inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 text-xs font-medium bg-gray-200 text-gray-700 rounded-full",children:e>t?`${t}+`:e})}function mi({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let i="kyro-btn",l=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${i} ${l} ${d} ${a}`,disabled:n||r,...s,children:[r?jsxRuntime.jsx("span",{className:"kyro-btn-loading",children:jsxRuntime.jsx("svg",{className:"kyro-btn-spinner",viewBox:"0 0 24 24",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"60 30"})})}):null,jsxRuntime.jsx("span",{className:r?"kyro-btn-text-hidden":"",children:o})]})}function bd({page:e,totalPages:t,totalDocs:r,limit:o,onPageChange:a,onLimitChange:n}){return t<=1?null:jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 px-4 py-3 border-t border-[var(--kyro-border)]",children:[r!==void 0&&o?jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Showing ",(e-1)*o+1," to ",Math.min(e*o,r)," of ",r]}):jsxRuntime.jsx("span",{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[n&&jsxRuntime.jsxs("select",{value:o,onChange:s=>n(Number(s.target.value)),className:"text-xs border border-[var(--kyro-border)] rounded-lg px-2 py-1 bg-[var(--kyro-bg)] text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("option",{value:10,children:"10/page"}),jsxRuntime.jsx("option",{value:25,children:"25/page"}),jsxRuntime.jsx("option",{value:50,children:"50/page"}),jsxRuntime.jsx("option",{value:100,children:"100/page"})]}),jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Page ",e," of ",t]}),jsxRuntime.jsxs("div",{className:"flex gap-1",children:[jsxRuntime.jsx(mi,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(mi,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}var ve=e=>typeof e=="string",_a=()=>{let e,t,r=new Promise((o,a)=>{e=o,t=a;});return r.resolve=e,r.reject=t,r},hd=e=>e==null?"":String(e),cm=(e,t,r)=>{e.forEach(o=>{t[o]&&(r[o]=t[o]);});},um=/###/g,xd=e=>e&&e.includes("###")?e.replace(um,"."):e,kd=e=>!e||ve(e),Ka=(e,t,r)=>{let o=ve(t)?t.split("."):t,a=0;for(;a<o.length-1;){if(kd(e))return {};let n=xd(o[a]);!e[n]&&r&&(e[n]=new r),Object.prototype.hasOwnProperty.call(e,n)?e=e[n]:e={},++a;}return kd(e)?{}:{obj:e,k:xd(o[a])}},wd=(e,t,r)=>{let{obj:o,k:a}=Ka(e,t,Object);if(o!==void 0||t.length===1){o[a]=r;return}let n=t[t.length-1],s=t.slice(0,t.length-1),i=Ka(e,s,Object);for(;i.obj===void 0&&s.length;)n=`${s[s.length-1]}.${n}`,s=s.slice(0,s.length-1),i=Ka(e,s,Object),i?.obj&&typeof i.obj[`${i.k}.${n}`]<"u"&&(i.obj=void 0);i.obj[`${i.k}.${n}`]=r;},pm=(e,t,r,o)=>{let{obj:a,k:n}=Ka(e,t,Object);a[n]=a[n]||[],a[n].push(r);},Yn=(e,t)=>{let{obj:r,k:o}=Ka(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,o))return r[o]},mm=(e,t,r)=>{let o=Yn(e,r);return o!==void 0?o:Yn(t,r)},Dd=(e,t,r)=>{for(let o in t)o!=="__proto__"&&o!=="constructor"&&(Object.prototype.hasOwnProperty.call(e,o)?ve(e[o])||e[o]instanceof String||ve(t[o])||t[o]instanceof String?r&&(e[o]=t[o]):Dd(e[o],t[o],r):e[o]=t[o]);return e},Ur=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),fm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},ym=e=>ve(e)?e.replace(/[&<>"'\/]/g,t=>fm[t]):e,gi=class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[];}getRegExp(t){let r=this.regExpMap.get(t);if(r!==void 0)return r;let o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}},gm=[" ",",","?","!",";"],vm=new gi(20),bm=(e,t,r)=>{t=t||"",r=r||"";let o=gm.filter(s=>!t.includes(s)&&!r.includes(s));if(o.length===0)return true;let a=vm.getRegExp(`(${o.map(s=>s==="?"?"\\?":s).join("|")})`),n=!a.test(e);if(!n){let s=e.indexOf(r);s>0&&!a.test(e.substring(0,s))&&(n=true);}return n},vi=(e,t,r=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let o=t.split(r),a=e;for(let n=0;n<o.length;){if(!a||typeof a!="object")return;let s,i="";for(let l=n;l<o.length;++l)if(l!==n&&(i+=r),i+=o[l],s=a[i],s!==void 0){if(["string","number","boolean"].includes(typeof s)&&l<o.length-1)continue;n+=l-n+1;break}a=s;}return a},Ga=e=>e?.replace(/_/g,"-"),hm={type:"logger",log(e){this.output("log",e);},warn(e){this.output("warn",e);},error(e){this.output("error",e);},output(e,t){console?.[e]?.apply?.(console,t);}},bi=class e{constructor(t,r={}){this.init(t,r);}init(t,r={}){this.prefix=r.prefix||"i18next:",this.logger=t||hm,this.options=r,this.debug=r.debug;}log(...t){return this.forward(t,"log","",true)}warn(...t){return this.forward(t,"warn","",true)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",true)}forward(t,r,o,a){return a&&!this.debug?null:(t=t.map(n=>ve(n)?n.replace(/[\r\n\x00-\x1F\x7F]/g," "):n),ve(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[r](t))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},Pr=new bi,ta=class{constructor(){this.observers={};}on(t,r){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);let a=this.observers[o].get(r)||0;this.observers[o].set(r,a+1);}),this}off(t,r){if(this.observers[t]){if(!r){delete this.observers[t];return}this.observers[t].delete(r);}}once(t,r){let o=(...a)=>{r(...a),this.off(t,o);};return this.on(t,o),this}emit(t,...r){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([a,n])=>{for(let s=0;s<n;s++)a(...r);}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([a,n])=>{for(let s=0;s<n;s++)a(t,...r);});}},Qn=class extends ta{constructor(t,r={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=true);}addNamespaces(t){this.options.ns.includes(t)||this.options.ns.push(t);}removeNamespaces(t){let r=this.options.ns.indexOf(t);r>-1&&this.options.ns.splice(r,1);}getResource(t,r,o,a={}){let n=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,s=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,i;t.includes(".")?i=t.split("."):(i=[t,r],o&&(Array.isArray(o)?i.push(...o):ve(o)&&n?i.push(...o.split(n)):i.push(o)));let l=Yn(this.data,i);return !l&&!r&&!o&&t.includes(".")&&(t=i[0],r=i[1],o=i.slice(2).join(".")),l||!s||!ve(o)?l:vi(this.data?.[t]?.[r],o,n)}addResource(t,r,o,a,n={silent:false}){let s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,i=[t,r];o&&(i=i.concat(s?o.split(s):o)),t.includes(".")&&(i=t.split("."),a=r,r=i[1]),this.addNamespaces(r),wd(this.data,i,a),n.silent||this.emit("added",t,r,o,a);}addResources(t,r,o,a={silent:false}){for(let n in o)(ve(o[n])||Array.isArray(o[n]))&&this.addResource(t,r,n,o[n],{silent:true});a.silent||this.emit("added",t,r,o);}addResourceBundle(t,r,o,a,n,s={silent:false,skipCopy:false}){let i=[t,r];t.includes(".")&&(i=t.split("."),a=o,o=r,r=i[1]),this.addNamespaces(r);let l=Yn(this.data,i)||{};s.skipCopy||(o=JSON.parse(JSON.stringify(o))),a?Dd(l,o,n):l={...l,...o},wd(this.data,i,l),s.silent||this.emit("added",t,r,o);}removeResourceBundle(t,r){this.hasResourceBundle(t,r)&&delete this.data[t][r],this.removeNamespaces(r),this.emit("removed",t,r);}hasResourceBundle(t,r){return this.getResource(t,r)!==void 0}getResourceBundle(t,r){return r||(r=this.options.defaultNS),this.getResource(t,r)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){let r=this.getDataByLanguage(t);return !!(r&&Object.keys(r)||[]).find(a=>r[a]&&Object.keys(r[a]).length>0)}toJSON(){return this.data}},Pd={processors:{},addPostProcessor(e){this.processors[e.name]=e;},handle(e,t,r,o,a){return e.forEach(n=>{t=this.processors[n]?.process(t,r,o,a)??t;}),t}},Rd=Symbol("i18next/PATH_KEY");function xm(){let e=[],t=Object.create(null),r;return t.get=(o,a)=>(r?.revoke?.(),a===Rd?e:(e.push(a),r=Proxy.revocable(o,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Ro(e,t){let{[Rd]:r}=e(xm()),o=t?.keySeparator??".",a=t?.nsSeparator??":",n=t?.enableSelector==="strict";if(r.length>1&&a){let s=t?.ns,i=n?Array.isArray(s)?s:s?[s]:null:Array.isArray(s)?s:null;if(i&&(n?i:i.length>1?i.slice(1):[]).includes(r[0]))return `${r[0]}${a}${r.slice(1).join(o)}`}return r.join(o)}var fi=e=>!ve(e)&&typeof e!="boolean"&&typeof e!="number",Zn=class e extends ta{constructor(t,r={}){super(),cm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Pr.create("translator"),this.checkedLoadedFor={};}changeLanguage(t){t&&(this.language=t);}exists(t,r={interpolation:{}}){let o={...r};if(t==null)return false;let a=this.resolve(t,o);if(a?.res===void 0)return false;let n=fi(a.res);return !(o.returnObjects===false&&n)}extractFromKey(t,r){let o=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");let a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,n=r.ns||this.options.defaultNS||[],s=o&&t.includes(o),i=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!bm(t,o,a);if(s&&!i){let l=t.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return {key:t,namespaces:ve(n)?[n]:n};let d=t.split(o);(o!==a||o===a&&this.options.ns.includes(d[0]))&&(n=d.shift()),t=d.join(a);}return {key:t,namespaces:ve(n)?[n]:n}}translate(t,r,o){let a=typeof r=="object"?{...r}:r;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),t==null)return "";typeof t=="function"&&(t=Ro(t,{...this.options,...a})),Array.isArray(t)||(t=[String(t)]),t=t.map(I=>typeof I=="function"?Ro(I,{...this.options,...a}):String(I));let n=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:i,namespaces:l}=this.extractFromKey(t[t.length-1],a),d=l[l.length-1],c=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;c===void 0&&(c=":");let u=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?n?{res:`${d}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:`${d}${c}${i}`:n?{res:i,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:i;let f=this.resolve(t,a),y=f?.res,g=f?.usedKey||i,v=f?.exactUsedKey||i,h=["[object Number]","[object Function]","[object RegExp]"],m=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,C=a.count!==void 0&&!ve(a.count),E=e.hasDefaultValue(a),D=C?this.pluralResolver.getSuffix(u,a.count,a):"",k=a.ordinal&&C?this.pluralResolver.getSuffix(u,a.count,{ordinal:false}):"",b=C&&!a.ordinal&&a.count===0,x=b&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${D}`]||a[`defaultValue${k}`]||a.defaultValue,N=y;w&&!y&&E&&(N=x);let O=fi(N),M=Object.prototype.toString.apply(N);if(w&&N&&O&&!h.includes(M)&&!(ve(m)&&Array.isArray(N))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let I=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,N,{...a,ns:l}):`key '${i} (${this.language})' returned an object instead of string.`;return n?(f.res=I,f.usedParams=this.getUsedParamsDetails(a),f):I}if(s){let I=Array.isArray(N),P=I?[]:{},R=I?v:g;for(let fe in N)if(Object.prototype.hasOwnProperty.call(N,fe)){let L=`${R}${s}${fe}`;E&&!y?P[fe]=this.translate(L,{...a,defaultValue:fi(x)?x[fe]:void 0,joinArrays:false,ns:l}):P[fe]=this.translate(L,{...a,joinArrays:false,ns:l}),P[fe]===L&&(P[fe]=N[fe]);}y=P;}}else if(w&&ve(m)&&Array.isArray(y))y=y.join(m),y&&(y=this.extendTranslation(y,t,a,o));else {let I=false,P=false;!this.isValidLookup(y)&&E&&(I=true,y=x),this.isValidLookup(y)||(P=true,y=i);let fe=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:y,L=E&&x!==y&&this.options.updateMissing;if(P||I||L){if(this.logger.log(L?"updateKey":"missingKey",u,d,C&&!L?`${i}${this.pluralResolver.getSuffix(u,a.count,a)}`:i,L?x:y),s){let H=this.resolve(i,{...a,keySeparator:false});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");}let re=[],ne=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ne&&ne[0])for(let H=0;H<ne.length;H++)re.push(ne[H]);else this.options.saveMissingTo==="all"?re=this.languageUtils.toResolveHierarchy(a.lng||this.language):re.push(a.lng||this.language);let ee=(H,pe,be)=>{let V=E&&be!==y?be:fe;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,pe,V,L,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,pe,V,L,a),this.emit("missingKey",H,d,pe,y);};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?re.forEach(H=>{let pe=this.pluralResolver.getSuffixes(H,a);b&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!pe.includes(`${this.options.pluralSeparator}zero`)&&pe.push(`${this.options.pluralSeparator}zero`),pe.forEach(be=>{ee([H],i+be,a[`defaultValue${be}`]||x);});}):ee(re,i,x));}y=this.extendTranslation(y,t,a,f,o),P&&y===i&&this.options.appendNamespaceToMissingKey&&(y=`${d}${c}${i}`),(P||I)&&this.options.parseMissingKeyHandler&&(y=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${c}${i}`:i,I?y:void 0,a));}return n?(f.res=y,f.usedParams=this.getUsedParamsDetails(a),f):y}extendTranslation(t,r,o,a,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});let l=ve(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),d;if(l){let u=t.match(this.interpolator.nestingRegexp);d=u&&u.length;}let c=o.replace&&!ve(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,o.lng||this.language||a.usedLng,o),l){let u=t.match(this.interpolator.nestingRegexp),p=u&&u.length;d<p&&(o.nest=false);}!o.lng&&a&&a.res&&(o.lng=this.language||a.usedLng),o.nest!==false&&(t=this.interpolator.nest(t,(...u)=>n?.[0]===u[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${r[0]}`),null):this.translate(...u,r),o)),o.interpolation&&this.interpolator.reset();}let s=o.postProcess||this.options.postProcess,i=ve(s)?[s]:s;return t!=null&&i?.length&&o.applyPostProcessor!==false&&(t=Pd.handle(i,t,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,r={}){let o,a,n,s,i;return ve(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(l=>typeof l=="function"?Ro(l,{...this.options,...r}):l)),t.forEach(l=>{if(this.isValidLookup(o))return;let d=this.extractFromKey(l,r),c=d.key;a=c;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let p=r.count!==void 0&&!ve(r.count),f=p&&!r.ordinal&&r.count===0,y=r.context!==void 0&&(ve(r.context)||typeof r.context=="number")&&r.context!=="",g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach(v=>{this.isValidLookup(o)||(i=v,!this.checkedLoadedFor[`${g[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(this.checkedLoadedFor[`${g[0]}-${v}`]=true,this.logger.warn(`key "${a}" for languages "${g.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach(h=>{if(this.isValidLookup(o))return;s=h;let m=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(m,c,h,v,r);else {let C;p&&(C=this.pluralResolver.getSuffix(h,r.count,r));let E=`${this.options.pluralSeparator}zero`,D=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&C.startsWith(D)&&m.push(c+C.replace(D,this.options.pluralSeparator)),m.push(c+C),f&&m.push(c+E)),y){let k=`${c}${this.options.contextSeparator||"_"}${r.context}`;m.push(k),p&&(r.ordinal&&C.startsWith(D)&&m.push(k+C.replace(D,this.options.pluralSeparator)),m.push(k+C),f&&m.push(k+E));}}let w;for(;w=m.pop();)this.isValidLookup(o)||(n=w,o=this.getResource(h,v,w,r));}));});}),{res:o,usedKey:a,exactUsedKey:n,usedLng:s,usedNS:i}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,r,o,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,r,o,a):this.resourceStore.getResource(t,r,o,a)}getUsedParamsDetails(t={}){let r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!ve(t.replace),a=o?t.replace:t;if(o&&typeof t.count<"u"&&(a={...a,count:t.count}),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!o){a={...a};for(let n of r)delete a[n];}return a}static hasDefaultValue(t){let r="defaultValue";for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&o.startsWith(r)&&t[o]!==void 0)return true;return false}},es=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||false,this.logger=Pr.create("languageUtils");}getScriptPartFromCode(t){if(t=Ga(t),!t||!t.includes("-"))return null;let r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(t){if(t=Ga(t),!t||!t.includes("-"))return t;let r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(ve(t)&&t.includes("-")){let r;try{r=Intl.getCanonicalLocales(t)[0];}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return (this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(t)}getBestMatchFromCodes(t){if(!t)return null;let r;return t.forEach(o=>{if(r)return;let a=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(a))&&(r=a);}),!r&&this.options.supportedLngs&&t.forEach(o=>{if(r)return;let a=this.getScriptPartFromCode(o);if(this.isSupportedCode(a))return r=a;let n=this.getLanguagePartFromCode(o);if(this.isSupportedCode(n))return r=n;r=this.options.supportedLngs.find(s=>s===n?true:!s.includes("-")&&!n.includes("-")?false:!!(s.includes("-")&&!n.includes("-")&&s.slice(0,s.indexOf("-"))===n||s.startsWith(n)&&n.length>1));}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(t,r){if(!t)return [];if(typeof t=="function"&&(t=t(r)),ve(t)&&(t=[t]),Array.isArray(t))return t;if(!r)return t.default||[];let o=t[r];return o||(o=t[this.getScriptPartFromCode(r)]),o||(o=t[this.formatLanguageCode(r)]),o||(o=t[this.getLanguagePartFromCode(r)]),o||(o=t.default),o||[]}toResolveHierarchy(t,r){let o=this.getFallbackCodes((r===false?[]:r)||this.options.fallbackLng||[],t),a=[],n=s=>{s&&(this.isSupportedCode(s)?a.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`));};return ve(t)&&(t.includes("-")||t.includes("_"))?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(t))):ve(t)&&n(this.formatLanguageCode(t)),o.forEach(s=>{a.includes(s)||n(this.formatLanguageCode(s));}),a}},Nd={zero:0,one:1,two:2,few:3,many:4,other:5},Cd={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},hi=class{constructor(t,r={}){this.languageUtils=t,this.options=r,this.logger=Pr.create("pluralResolver"),this.pluralRulesCache={};}clearCache(){this.pluralRulesCache={};}getRule(t,r={}){let o=Ga(t==="dev"?"en":t),a=r.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:o,type:a});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let s;try{s=new Intl.PluralRules(o,{type:a});}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Cd;if(!t.match(/-|_/))return Cd;let l=this.languageUtils.getLanguagePartFromCode(t);s=this.getRule(l,r);}return this.pluralRulesCache[n]=s,s}needsPlural(t,r={}){let o=this.getRule(t,r);return o||(o=this.getRule("dev",r)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,r,o={}){return this.getSuffixes(t,o).map(a=>`${r}${a}`)}getSuffixes(t,r={}){let o=this.getRule(t,r);return o||(o=this.getRule("dev",r)),o?o.resolvedOptions().pluralCategories.sort((a,n)=>Nd[a]-Nd[n]).map(a=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(t,r,o={}){let a=this.getRule(t,o);return a?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${a.select(r)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",r,o))}},Sd=(e,t,r,o=".",a=true)=>{let n=mm(e,t,r);return !n&&a&&ve(r)&&(n=vi(e,r,o),n===void 0&&(n=vi(t,r,o))),n},km=e=>e.replace(/\$/g,"$$$$"),ts=class{constructor(t={}){this.logger=Pr.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(r=>r),this.init(t);}init(t={}){t.interpolation||(t.interpolation={escapeValue:true});let{escape:r,escapeValue:o,useRawValueToEscape:a,prefix:n,prefixEscaped:s,suffix:i,suffixEscaped:l,formatSeparator:d,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:f,nestingSuffix:y,nestingSuffixEscaped:g,nestingOptionsSeparator:v,maxReplaces:h,alwaysFormat:m}=t.interpolation;this.escape=r!==void 0?r:ym,this.escapeValue=o!==void 0?o:true,this.useRawValueToEscape=a!==void 0?a:false,this.prefix=n?Ur(n):s||"{{",this.suffix=i?Ur(i):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=c?"":u?Ur(u):"-",this.unescapeSuffix=this.unescapePrefix?"":c?Ur(c):"",this.nestingPrefix=p?Ur(p):f||Ur("$t("),this.nestingSuffix=y?Ur(y):g||Ur(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=h||1e3,this.alwaysFormat=m!==void 0?m:false,this.resetRegExp();}reset(){this.options&&this.init(this.options);}resetRegExp(){let t=(r,o)=>r?.source===o?(r.lastIndex=0,r):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);}interpolate(t,r,o,a){let n,s,i,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=f=>{if(!f.includes(this.formatSeparator)){let h=Sd(r,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(h,void 0,o,{...a,...r,interpolationkey:f}):h}let y=f.split(this.formatSeparator),g=y.shift().trim(),v=y.join(this.formatSeparator).trim();return this.format(Sd(r,l,g,this.options.keySeparator,this.options.ignoreJSONStructure),v,o,{...a,...r,interpolationkey:g})};this.resetRegExp(),!this.escapeValue&&typeof t=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false \u2014 if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");let c=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return [{regex:this.regexpUnescape,safeValue:f=>f},{regex:this.regexp,safeValue:f=>this.escapeValue?this.escape(f):f}].forEach(f=>{for(i=0;n=f.regex.exec(t);){let y=n[1].trim();if(s=d(y),s===void 0)if(typeof c=="function"){let v=c(t,n,a);s=ve(v)?v:"";}else if(a&&Object.prototype.hasOwnProperty.call(a,y))s="";else if(u){s=n[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),s="";else !ve(s)&&!this.useRawValueToEscape&&(s=hd(s));let g=f.safeValue(s);if(t=t.replace(n[0],km(g)),u?(f.regex.lastIndex+=g.length,f.regex.lastIndex-=n[0].length):f.regex.lastIndex=0,i++,i>=this.maxReplaces)break}}),t}nest(t,r,o={}){let a,n,s,i=(l,d)=>{let c=this.nestingOptionsSeparator;if(!l.includes(c))return l;let u=l.split(new RegExp(`${Ur(c)}[ ]*{`)),p=`{${u[1]}`;l=u[0],p=this.interpolate(p,s);let f=p.match(/'/g),y=p.match(/"/g);((f?.length??0)%2===0&&!y||(y?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{s=JSON.parse(p),d&&(s={...d,...s});}catch(g){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,g),`${l}${c}${p}`}return s.defaultValue&&s.defaultValue.includes(this.prefix)&&delete s.defaultValue,l};for(;a=this.nestingRegexp.exec(t);){let l=[];s={...o},s=s.replace&&!ve(s.replace)?s.replace:s,s.applyPostProcessor=false,delete s.defaultValue;let d=/{.*}/s.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(d!==-1&&(l=a[1].slice(d).split(this.formatSeparator).map(c=>c.trim()).filter(Boolean),a[1]=a[1].slice(0,d)),n=r(i.call(this,a[1].trim(),s),s),n&&a[0]===t&&!ve(n))return n;ve(n)||(n=hd(n)),n||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${t}`),n=""),l.length&&(n=l.reduce((c,u)=>this.format(c,u,o.lng,{...o,interpolationkey:a[1].trim()}),n.trim())),t=t.replace(a[0],n),this.regexp.lastIndex=0;}return t}},wm=e=>{let t=e.toLowerCase().trim(),r={};if(e.includes("(")){let o=e.split("(");t=o[0].toLowerCase().trim();let a=o[1].slice(0,-1);t==="currency"&&!a.includes(":")?r.currency||(r.currency=a.trim()):t==="relativetime"&&!a.includes(":")?r.range||(r.range=a.trim()):a.split(";").forEach(s=>{if(s){let[i,...l]=s.split(":"),d=l.join(":").trim().replace(/^'+|'+$/g,""),c=i.trim();r[c]||(r[c]=d),d==="false"&&(r[c]=false),d==="true"&&(r[c]=true),isNaN(d)||(r[c]=parseInt(d,10));}});}return {formatName:t,formatOptions:r}},Ad=e=>{let t={};return (r,o,a)=>{let n=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(n={...n,[a.interpolationkey]:void 0});let s=o+JSON.stringify(n),i=t[s];return i||(i=e(Ga(o),a),t[s]=i),i(r)}},Nm=e=>(t,r,o)=>e(Ga(r),o)(t),xi=class{constructor(t={}){this.logger=Pr.create("formatter"),this.options=t,this.init(t);}init(t,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";let o=r.cacheInBuiltFormats?Ad:Nm;this.formats={number:o((a,n)=>{let s=new Intl.NumberFormat(a,{...n});return i=>s.format(i)}),currency:o((a,n)=>{let s=new Intl.NumberFormat(a,{...n,style:"currency"});return i=>s.format(i)}),datetime:o((a,n)=>{let s=new Intl.DateTimeFormat(a,{...n});return i=>s.format(i)}),relativetime:o((a,n)=>{let s=new Intl.RelativeTimeFormat(a,{...n});return i=>s.format(i,n.range||"day")}),list:o((a,n)=>{let s=new Intl.ListFormat(a,{...n});return i=>s.format(i)})};}add(t,r){this.formats[t.toLowerCase().trim()]=r;}addCached(t,r){this.formats[t.toLowerCase().trim()]=Ad(r);}format(t,r,o,a={}){if(!r||t==null)return t;let n=r.split(this.formatSeparator),s=[];for(let l=0;l<n.length;l++){let d=n[l];for(;d.indexOf("(")>-1&&!d.includes(")")&&l+1<n.length;)d=`${d}${this.formatSeparator}${n[++l]}`;s.push(d);}return s.reduce((l,d)=>{let{formatName:c,formatOptions:u}=wm(d);if(this.formats[c]){let p=l;try{let f=a?.formatParams?.[a.interpolationkey]||{},y=f.locale||f.lng||a.locale||a.lng||o;p=this.formats[c](l,y,{...u,...a,...f});}catch(f){this.logger.warn(f);}return p}else this.logger.warn(`there was no format function for ${c}`);return l},t)}},Cm=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--);},ki=class extends ta{constructor(t,r,o,a={}){super(),this.backend=t,this.store=r,this.services=o,this.languageUtils=o.languageUtils,this.options=a,this.logger=Pr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,a.backend,a);}queueLoad(t,r,o,a){let n={},s={},i={},l={};return t.forEach(d=>{let c=true;r.forEach(u=>{let p=`${d}|${u}`;!o.reload&&this.store.hasResourceBundle(d,u)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?s[p]===void 0&&(s[p]=true):(this.state[p]=1,c=false,s[p]===void 0&&(s[p]=true),n[p]===void 0&&(n[p]=true),l[u]===void 0&&(l[u]=true)));}),c||(i[d]=true);}),(Object.keys(n).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(n),pending:Object.keys(s),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(l)}}loaded(t,r,o){let a=t.split("|"),n=a[0],s=a[1];r&&this.emit("failedLoading",n,s,r),!r&&o&&this.store.addResourceBundle(n,s,o,void 0,void 0,{skipCopy:true}),this.state[t]=r?-1:2,r&&o&&(this.state[t]=0);let i={};this.queue.forEach(l=>{pm(l.loaded,[n],s),Cm(l,t),r&&l.errors.push(r),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(d=>{i[d]||(i[d]={});let c=l.loaded[d];c.length&&c.forEach(u=>{i[d][u]===void 0&&(i[d][u]=true);});}),l.done=true,l.errors.length?l.callback(l.errors):l.callback());}),this.emit("loaded",i),this.queue=this.queue.filter(l=>!l.done);}read(t,r,o,a=0,n=this.retryTimeout,s){if(!t.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:r,fcName:o,tried:a,wait:n,callback:s});return}this.readingCalls++;let i=(d,c)=>{if(this.readingCalls--,this.waitingReads.length>0){let u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback);}if(d&&c&&a<this.maxRetries){setTimeout(()=>{this.read(t,r,o,a+1,n*2,s);},n);return}s(d,c);},l=this.backend[o].bind(this.backend);if(l.length===2){try{let d=l(t,r);d&&typeof d.then=="function"?d.then(c=>i(null,c)).catch(i):i(null,d);}catch(d){i(d);}return}return l(t,r,i)}prepareLoading(t,r,o={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();ve(t)&&(t=this.languageUtils.toResolveHierarchy(t)),ve(r)&&(r=[r]);let n=this.queueLoad(t,r,o,a);if(!n.toLoad.length)return n.pending.length||a(),null;n.toLoad.forEach(s=>{this.loadOne(s);});}load(t,r,o){this.prepareLoading(t,r,{},o);}reload(t,r,o){this.prepareLoading(t,r,{reload:true},o);}loadOne(t,r=""){let o=t.split("|"),a=o[0],n=o[1];this.read(a,n,"read",void 0,void 0,(s,i)=>{s&&this.logger.warn(`${r}loading namespace ${n} for language ${a} failed`,s),!s&&i&&this.logger.log(`${r}loaded namespace ${n} for language ${a}`,i),this.loaded(t,s,i);});}saveMissing(t,r,o,a,n,s={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${o}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){let l={...s,isUpdate:n},d=this.backend.create.bind(this.backend);if(d.length<6)try{let c;d.length===5?c=d(t,r,o,a,l):c=d(t,r,o,a),c&&typeof c.then=="function"?c.then(u=>i(null,u)).catch(i):i(null,c);}catch(c){i(c);}else d(t,r,o,a,i,l);}!t||!t[0]||this.store.addResource(t[0],r,o,a);}}},yi=()=>({debug:false,initAsync:true,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:false,supportedLngs:false,nonExplicitSupportedLngs:false,load:"all",preload:false,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:false,partialBundledLanguages:false,saveMissing:false,updateMissing:false,saveMissingTo:"fallback",saveMissingPlurals:true,missingKeyHandler:false,missingInterpolationHandler:false,postProcess:false,postProcessPassResolved:false,returnNull:false,returnEmptyString:true,returnObjects:false,joinArrays:false,returnedObjectHandler:false,parseMissingKeyHandler:false,appendNamespaceToMissingKey:false,appendNamespaceToCIMode:false,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),ve(e[1])&&(t.defaultValue=e[1]),ve(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){let r=e[3]||e[2];Object.keys(r).forEach(o=>{t[o]=r[o];});}return t},interpolation:{escapeValue:true,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:true},cacheInBuiltFormats:true}),Td=e=>(ve(e.ns)&&(e.ns=[e.ns]),ve(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),ve(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Xn=()=>{},Sm=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e));});},wi=class e extends ta{constructor(t={},r){if(super(),this.options=Td(t),this.services={},this.logger=Pr,this.modules={external:[]},Sm(this),r&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,r),this;setTimeout(()=>{this.init(t,r);},0);}}init(t={},r){this.isInitializing=true,typeof t=="function"&&(r=t,t={}),t.defaultNS==null&&t.ns&&(ve(t.ns)?t.defaultNS=t.ns:t.ns.includes("translation")||(t.defaultNS=t.ns[0]));let o=yi();this.options={...o,...this.options,...Td(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler);let a=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Pr.init(a(this.modules.logger),this.options):Pr.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=xi;let c=new es(this.options);this.store=new Qn(this.options.resources,this.options);let u=this.services;u.logger=Pr,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new hi(c,{prepend:this.options.pluralSeparator}),d&&(u.formatter=a(d),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new ts(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new ki(a(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(p,...f)=>{this.emit(p,...f);}),this.modules.languageDetector&&(u.languageDetector=a(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=a(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new Zn(this.services,this.options),this.translator.on("*",(p,...f)=>{this.emit(p,...f);}),this.modules.external.forEach(p=>{p.init&&p.init(this);});}if(this.format=this.options.interpolation.format,r||(r=Xn),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0]);}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...c)=>this.store[d](...c);}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...c)=>(this.store[d](...c),this);});let i=_a(),l=()=>{let d=(c,u)=>{this.isInitializing=false,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=true,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),i.resolve(u),r(c,u);};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d);};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),i}loadResources(t,r=Xn){let o=r,a=ve(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();let n=[],s=i=>{if(!i||i==="cimode")return;this.services.languageUtils.toResolveHierarchy(i).forEach(d=>{d!=="cimode"&&(n.includes(d)||n.push(d));});};a?s(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>s(l)),this.options.preload?.forEach?.(i=>s(i)),this.services.backendConnector.load(n,this.options.ns,i=>{!i&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(i);});}else o(null);}reloadResources(t,r,o){let a=_a();return typeof t=="function"&&(o=t,t=void 0),typeof r=="function"&&(o=r,r=void 0),t||(t=this.languages),r||(r=this.options.ns),o||(o=Xn),this.services.backendConnector.reload(t,r,n=>{a.resolve(),o(n);}),a}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Pd.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!["cimode","dev"].includes(t)){for(let r=0;r<this.languages.length;r++){let o=this.languages[r];if(!["cimode","dev"].includes(o)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&!this.languages.includes(t)&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t));}}changeLanguage(t,r){this.isLanguageChangingTo=t;let o=_a();this.emit("languageChanging",t);let a=i=>{this.language=i,this.languages=this.services.languageUtils.toResolveHierarchy(i),this.resolvedLanguage=void 0,this.setResolvedLanguage(i);},n=(i,l)=>{l?this.isLanguageChangingTo===t&&(a(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,o.resolve((...d)=>this.t(...d)),r&&r(i,(...d)=>this.t(...d));},s=i=>{!t&&!i&&this.services.languageDetector&&(i=[]);let l=ve(i)?i:i&&i[0],d=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(ve(i)?[i]:i);d&&(this.language||a(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,c=>{n(c,d);});};return !t&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(t),o}getFixedT(t,r,o,a){let n=a?.scopeNs,s=(i,l,...d)=>{let c;typeof l!="object"?c=this.options.overloadTranslationOptionHandler([i,l].concat(d)):c={...l},c.lng=c.lng||s.lng,c.lngs=c.lngs||s.lngs;let u=c.ns!==void 0&&c.ns!==null;c.ns=c.ns||s.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||o||s.keyPrefix);let p={...this.options,...c};Array.isArray(n)&&!u&&(p.ns=n),typeof c.keyPrefix=="function"&&(c.keyPrefix=Ro(c.keyPrefix,p));let f=this.options.keySeparator||".",y;return c.keyPrefix&&Array.isArray(i)?y=i.map(g=>(typeof g=="function"&&(g=Ro(g,p)),`${c.keyPrefix}${f}${g}`)):(typeof i=="function"&&(i=Ro(i,p)),y=c.keyPrefix?`${c.keyPrefix}${f}${i}`:i),this.t(y,c)};return ve(t)?s.lng=t:s.lngs=t,s.ns=r,s.keyPrefix=o,s}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t;}hasLoadedNamespace(t,r={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),false;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),false;let o=r.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:false,n=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return true;let s=(i,l)=>{let d=this.services.backendConnector.state[`${i}|${l}`];return d===-1||d===0||d===2};if(r.precheck){let i=r.precheck(this,s);if(i!==void 0)return i}return !!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(o,t)&&(!a||s(n,t)))}loadNamespaces(t,r){let o=_a();return this.options.ns?(ve(t)&&(t=[t]),t.forEach(a=>{this.options.ns.includes(a)||this.options.ns.push(a);}),this.loadResources(a=>{o.resolve(),r&&r(a);}),o):(r&&r(),Promise.resolve())}loadLanguages(t,r){let o=_a();ve(t)&&(t=[t]);let a=this.options.preload||[],n=t.filter(s=>!a.includes(s)&&this.services.languageUtils.isSupportedCode(s));return n.length?(this.options.preload=a.concat(n),this.loadResources(s=>{o.resolve(),r&&r(s);}),o):(r&&r(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return "rtl";try{let a=new Intl.Locale(t);if(a&&a.getTextInfo){let n=a.getTextInfo();if(n&&n.direction)return n.direction}}catch{}let r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new es(yi());return t.toLowerCase().indexOf("-latn")>1?"ltr":r.includes(o.getLanguagePartFromCode(t))||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},r){let o=new e(t,r);return o.createInstance=e.createInstance,o}cloneInstance(t={},r=Xn){let o=t.forkResourceStore;o&&delete t.forkResourceStore;let a={...this.options,...t,isClone:true},n=new e(a);if((t.debug!==void 0||t.prefix!==void 0)&&(n.logger=n.logger.clone(t)),["store","services","language"].forEach(i=>{n[i]=this[i];}),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},o){let i=Object.keys(this.store.data).reduce((l,d)=>(l[d]={...this.store.data[d]},l[d]=Object.keys(l[d]).reduce((c,u)=>(c[u]={...l[d][u]},c),l[d]),l),{});n.store=new Qn(i,a),n.services.resourceStore=n.store;}if(t.interpolation){let l={...yi().interpolation,...this.options.interpolation,...t.interpolation},d={...a,interpolation:l};n.services.interpolator=new ts(d);}return n.translator=new Zn(n.services,a),n.translator.on("*",(i,...l)=>{n.emit(i,...l);}),n.init(a,r),n.translator.options=a,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return {options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},Et=wi.createInstance();Et.createInstance;Et.dir;Et.init;Et.loadResources;Et.reloadResources;Et.use;Et.changeLanguage;Et.getFixedT;Et.t;Et.exists;Et.setDefaultNamespace;Et.hasLoadedNamespace;Et.loadNamespaces;Et.loadLanguages;em(Id());var rs=(e,t,r,o)=>{let a=[r,{code:t,...o||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(a,"warn","react-i18next::",true);gr(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...a):console?.warn&&console.warn(...a);},Ld={},to=(e,t,r,o)=>{gr(r)&&Ld[r]||(gr(r)&&(Ld[r]=new Date),rs(e,t,r,o));},Ed=(e,t)=>()=>{if(e.isInitialized)t();else {let r=()=>{setTimeout(()=>{e.off("initialized",r);},0),t();};e.on("initialized",r);}},os=(e,t,r)=>{e.loadNamespaces(t,Ed(e,r));},Ni=(e,t,r,o)=>{if(gr(r)&&(r=[r]),e.options.preload&&e.options.preload.indexOf(t)>-1)return os(e,r,o);r.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a);}),e.loadLanguages(t,Ed(e,o));},Md=(e,t,r={})=>!t.languages||!t.languages.length?(to(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),true):t.hasLoadedNamespace(e,{lng:r.lng,precheck:(o,a)=>{if(r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!a(o.isLanguageChangingTo,e))return false}});var gr=e=>typeof e=="string",Ci=e=>typeof e=="object"&&e!==null;var Tm=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Dm={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"\xA9","&#169;":"\xA9","&reg;":"\xAE","&#174;":"\xAE","&hellip;":"\u2026","&#8230;":"\u2026","&#x2F;":"/","&#47;":"/"},Pm=e=>Dm[e],Si=e=>e.replace(Tm,Pm);var Ai={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:true,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:true,unescape:Si,transDefaultProps:void 0},as=(e={})=>{Ai={...Ai,...e};},Wa=()=>Ai;var Bd,ns=e=>{Bd=e;},vr=()=>Bd;var ss={type:"3rdParty",init(e){as(e.options.react),ns(e);}};var ro=oa.createContext(),is=class{constructor(){this.usedNamespaces={};}addUsedNamespaces(t){t.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=true);});}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}};var $d={"&nbsp;":"\xA0","&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&copy;":"\xA9","&reg;":"\xAE","&trade;":"\u2122","&hellip;":"\u2026","&ndash;":"\u2013","&mdash;":"\u2014","&lsquo;":"\u2018","&rsquo;":"\u2019","&sbquo;":"\u201A","&ldquo;":"\u201C","&rdquo;":"\u201D","&bdquo;":"\u201E","&dagger;":"\u2020","&Dagger;":"\u2021","&bull;":"\u2022","&prime;":"\u2032","&Prime;":"\u2033","&lsaquo;":"\u2039","&rsaquo;":"\u203A","&sect;":"\xA7","&para;":"\xB6","&middot;":"\xB7","&ensp;":"\u2002","&emsp;":"\u2003","&thinsp;":"\u2009","&euro;":"\u20AC","&pound;":"\xA3","&yen;":"\xA5","&cent;":"\xA2","&curren;":"\xA4","&times;":"\xD7","&divide;":"\xF7","&minus;":"\u2212","&plusmn;":"\xB1","&ne;":"\u2260","&le;":"\u2264","&ge;":"\u2265","&asymp;":"\u2248","&equiv;":"\u2261","&infin;":"\u221E","&int;":"\u222B","&sum;":"\u2211","&prod;":"\u220F","&radic;":"\u221A","&part;":"\u2202","&permil;":"\u2030","&deg;":"\xB0","&micro;":"\xB5","&larr;":"\u2190","&uarr;":"\u2191","&rarr;":"\u2192","&darr;":"\u2193","&harr;":"\u2194","&crarr;":"\u21B5","&lArr;":"\u21D0","&uArr;":"\u21D1","&rArr;":"\u21D2","&dArr;":"\u21D3","&hArr;":"\u21D4","&alpha;":"\u03B1","&beta;":"\u03B2","&gamma;":"\u03B3","&delta;":"\u03B4","&epsilon;":"\u03B5","&zeta;":"\u03B6","&eta;":"\u03B7","&theta;":"\u03B8","&iota;":"\u03B9","&kappa;":"\u03BA","&lambda;":"\u03BB","&mu;":"\u03BC","&nu;":"\u03BD","&xi;":"\u03BE","&omicron;":"\u03BF","&pi;":"\u03C0","&rho;":"\u03C1","&sigma;":"\u03C3","&tau;":"\u03C4","&upsilon;":"\u03C5","&phi;":"\u03C6","&chi;":"\u03C7","&psi;":"\u03C8","&omega;":"\u03C9","&Alpha;":"\u0391","&Beta;":"\u0392","&Gamma;":"\u0393","&Delta;":"\u0394","&Epsilon;":"\u0395","&Zeta;":"\u0396","&Eta;":"\u0397","&Theta;":"\u0398","&Iota;":"\u0399","&Kappa;":"\u039A","&Lambda;":"\u039B","&Mu;":"\u039C","&Nu;":"\u039D","&Xi;":"\u039E","&Omicron;":"\u039F","&Pi;":"\u03A0","&Rho;":"\u03A1","&Sigma;":"\u03A3","&Tau;":"\u03A4","&Upsilon;":"\u03A5","&Phi;":"\u03A6","&Chi;":"\u03A7","&Psi;":"\u03A8","&Omega;":"\u03A9","&Agrave;":"\xC0","&Aacute;":"\xC1","&Acirc;":"\xC2","&Atilde;":"\xC3","&Auml;":"\xC4","&Aring;":"\xC5","&AElig;":"\xC6","&Ccedil;":"\xC7","&Egrave;":"\xC8","&Eacute;":"\xC9","&Ecirc;":"\xCA","&Euml;":"\xCB","&Igrave;":"\xCC","&Iacute;":"\xCD","&Icirc;":"\xCE","&Iuml;":"\xCF","&ETH;":"\xD0","&Ntilde;":"\xD1","&Ograve;":"\xD2","&Oacute;":"\xD3","&Ocirc;":"\xD4","&Otilde;":"\xD5","&Ouml;":"\xD6","&Oslash;":"\xD8","&Ugrave;":"\xD9","&Uacute;":"\xDA","&Ucirc;":"\xDB","&Uuml;":"\xDC","&Yacute;":"\xDD","&THORN;":"\xDE","&szlig;":"\xDF","&agrave;":"\xE0","&aacute;":"\xE1","&acirc;":"\xE2","&atilde;":"\xE3","&auml;":"\xE4","&aring;":"\xE5","&aelig;":"\xE6","&ccedil;":"\xE7","&egrave;":"\xE8","&eacute;":"\xE9","&ecirc;":"\xEA","&euml;":"\xEB","&igrave;":"\xEC","&iacute;":"\xED","&icirc;":"\xEE","&iuml;":"\xEF","&eth;":"\xF0","&ntilde;":"\xF1","&ograve;":"\xF2","&oacute;":"\xF3","&ocirc;":"\xF4","&otilde;":"\xF5","&ouml;":"\xF6","&oslash;":"\xF8","&ugrave;":"\xF9","&uacute;":"\xFA","&ucirc;":"\xFB","&uuml;":"\xFC","&yacute;":"\xFD","&thorn;":"\xFE","&yuml;":"\xFF","&iexcl;":"\xA1","&iquest;":"\xBF","&fnof;":"\u0192","&circ;":"\u02C6","&tilde;":"\u02DC","&OElig;":"\u0152","&oelig;":"\u0153","&Scaron;":"\u0160","&scaron;":"\u0161","&Yuml;":"\u0178","&ordf;":"\xAA","&ordm;":"\xBA","&macr;":"\xAF","&acute;":"\xB4","&cedil;":"\xB8","&sup1;":"\xB9","&sup2;":"\xB2","&sup3;":"\xB3","&frac14;":"\xBC","&frac12;":"\xBD","&frac34;":"\xBE","&spades;":"\u2660","&clubs;":"\u2663","&hearts;":"\u2665","&diams;":"\u2666","&loz;":"\u25CA","&oline;":"\u203E","&frasl;":"\u2044","&weierp;":"\u2118","&image;":"\u2111","&real;":"\u211C","&alefsym;":"\u2135"};new RegExp(Object.keys($d).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),"g");var jm=(e,t)=>{if(gr(t))return t;if(Ci(t)&&gr(t.defaultValue))return t.defaultValue;if(typeof e=="function")return "";if(Array.isArray(e)){let r=e[e.length-1];return typeof r=="function"?"":r}return e},Um={t:jm,ready:false},zm=()=>()=>{},z=(e,t={})=>{let{i18n:r}=t,{i18n:o,defaultNS:a}=oa.useContext(ro)||{},n=r||o||vr();n&&!n.reportNamespaces&&(n.reportNamespaces=new is),n||to(n,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");let s=oa.useMemo(()=>({...Wa(),...n?.options?.react,...t}),[n,t]),{useSuspense:i,keyPrefix:l}=s,d=a||n?.options?.defaultNS,c=gr(d)?[d]:d||["translation"],u=oa.useMemo(()=>c,c);n?.reportNamespaces?.addUsedNamespaces?.(u);let p=oa.useRef(0),f=oa.useCallback(x=>{if(!n)return zm;let{bindI18n:N,bindI18nStore:O}=s,M=()=>{p.current+=1,x();};return N&&n.on(N,M),O&&n.store.on(O,M),()=>{N&&N.split(" ").forEach(I=>n.off(I,M)),O&&O.split(" ").forEach(I=>n.store.off(I,M));}},[n,s]),y=oa.useRef(),g=oa.useCallback(()=>{if(!n)return Um;let x=!!(n.isInitialized||n.initializedStoreOnce)&&u.every(R=>Md(R,n,s)),N=t.lng||n.language,O=p.current,M=y.current;if(M&&M.ready===x&&M.lng===N&&M.keyPrefix===l&&M.revision===O)return M;let P={t:n.getFixedT(N,s.nsMode==="fallback"?u:u[0],l,{scopeNs:u}),ready:x,lng:N,keyPrefix:l,revision:O};return y.current=P,P},[n,u,l,s,t.lng]),[v,h]=oa.useState(0),{t:m,ready:w}=shim.useSyncExternalStore(f,g,g);oa.useEffect(()=>{if(n&&!w&&!i){let x=()=>h(N=>N+1);t.lng?Ni(n,t.lng,u,x):os(n,u,x);}},[n,t.lng,u,w,i,v]);let C=n||{},E=oa.useRef(null),D=oa.useRef(),k=x=>{let N=Object.getOwnPropertyDescriptors(x);N.__original&&delete N.__original;let O=Object.create(Object.getPrototypeOf(x),N);if(!Object.prototype.hasOwnProperty.call(O,"__original"))try{Object.defineProperty(O,"__original",{value:x,writable:!1,enumerable:!1,configurable:!1});}catch{}return O},b=oa.useMemo(()=>{let x=C,N=x?.language,O=x;x&&(E.current&&E.current.__original===x?D.current!==N?(O=k(x),E.current=O,D.current=N):O=E.current:(O=k(x),E.current=O,D.current=N));let M=!w&&!i?(...P)=>(to(n,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),m(...P)):m,I=[M,O,w];return I.t=M,I.i18n=O,I.ready=w,I},[m,C,w,C.resolvedLanguage,C.language,C.languages]);if(n&&i&&!w)throw new Promise(x=>{let N=()=>x();t.lng?Ni(n,t.lng,u,N):os(n,u,N);});return b};var{slice:Gm,forEach:Wm}=[];function qm(e){return Wm.call(Gm.call(arguments,1),t=>{if(t)for(let r in t)e[r]===void 0&&(e[r]=t[r]);}),e}function Jm(e){return typeof e!="string"?false:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(r=>r.test(e))}var Hd=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Xm=function(e,t){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},a=encodeURIComponent(t),n=`${e}=${a}`;if(o.maxAge>0){let s=o.maxAge-0;if(Number.isNaN(s))throw new Error("maxAge should be a Number");n+=`; Max-Age=${Math.floor(s)}`;}if(o.domain){if(!Hd.test(o.domain))throw new TypeError("option domain is invalid");n+=`; Domain=${o.domain}`;}if(o.path){if(!Hd.test(o.path))throw new TypeError("option path is invalid");n+=`; Path=${o.path}`;}if(o.expires){if(typeof o.expires.toUTCString!="function")throw new TypeError("option expires is invalid");n+=`; Expires=${o.expires.toUTCString()}`;}if(o.httpOnly&&(n+="; HttpOnly"),o.secure&&(n+="; Secure"),o.sameSite)switch(typeof o.sameSite=="string"?o.sameSite.toLowerCase():o.sameSite){case true:n+="; SameSite=Strict";break;case "lax":n+="; SameSite=Lax";break;case "strict":n+="; SameSite=Strict";break;case "none":n+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return o.partitioned&&(n+="; Partitioned"),n},_d={create(e,t,r,o){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+r*60*1e3)),o&&(a.domain=o),document.cookie=Xm(e,t,a);},read(e){let t=`${e}=`,r=document.cookie.split(";");for(let o=0;o<r.length;o++){let a=r[o];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return a.substring(t.length,a.length)}return null},remove(e,t){this.create(e,"",-1,t);}},Ym={name:"cookie",lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<"u")return _d.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:r,cookieMinutes:o,cookieDomain:a,cookieOptions:n}=t;r&&typeof document<"u"&&_d.create(r,e,o,a,n);}},Qm={name:"querystring",lookup(e){let{lookupQuerystring:t}=e,r;if(typeof window<"u"){let{search:o}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(o=window.location.hash.substring(window.location.hash.indexOf("?")));let n=o.substring(1).split("&");for(let s=0;s<n.length;s++){let i=n[s].indexOf("=");i>0&&n[s].substring(0,i)===t&&(r=n[s].substring(i+1));}}return r}},Zm={name:"hash",lookup(e){let{lookupHash:t,lookupFromHashIndex:r}=e,o;if(typeof window<"u"){let{hash:a}=window.location;if(a&&a.length>2){let n=a.substring(1);if(t){let s=n.split("&");for(let i=0;i<s.length;i++){let l=s[i].indexOf("=");l>0&&s[i].substring(0,l)===t&&(o=s[i].substring(l+1));}}if(o)return o;if(!o&&r>-1){let s=a.match(/\/([a-zA-Z-]*)/g);return Array.isArray(s)?s[typeof r=="number"?r:0]?.replace("/",""):void 0}}}return o}},aa=null,Kd=()=>{if(aa!==null)return aa;try{if(aa=typeof window<"u"&&window.localStorage!==null,!aa)return !1;let e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e);}catch{aa=false;}return aa},ef={name:"localStorage",lookup(e){let{lookupLocalStorage:t}=e;if(t&&Kd())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:r}=t;r&&Kd()&&window.localStorage.setItem(r,e);}},na=null,Gd=()=>{if(na!==null)return na;try{if(na=typeof window<"u"&&window.sessionStorage!==null,!na)return !1;let e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e);}catch{na=false;}return na},tf={name:"sessionStorage",lookup(e){let{lookupSessionStorage:t}=e;if(t&&Gd())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:r}=t;r&&Gd()&&window.sessionStorage.setItem(r,e);}},rf={name:"navigator",lookup(e){let t=[];if(typeof navigator<"u"){let{languages:r,userLanguage:o,language:a}=navigator;if(r)for(let n=0;n<r.length;n++)t.push(r[n]);o&&t.push(o),a&&t.push(a);}return t.length>0?t:void 0}},of={name:"htmlTag",lookup(e){let{htmlTag:t}=e,r,o=t||(typeof document<"u"?document.documentElement:null);return o&&typeof o.getAttribute=="function"&&(r=o.getAttribute("lang")),r}},af={name:"path",lookup(e){let{lookupFromPathIndex:t}=e;if(typeof window>"u")return;let r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?r[typeof t=="number"?t:0]?.replace("/",""):void 0}},nf={name:"subdomain",lookup(e){let{lookupFromSubdomainIndex:t}=e,r=typeof t=="number"?t+1:1,o=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(o)return o[r]}},Wd=false;try{document.cookie,Wd=!0;}catch{}var qd=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Wd||qd.splice(1,1);var sf=()=>({order:qd,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e}),qa=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(t,r);}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=qm(r,this.options||{},sf()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=a=>a.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=o,this.addDetector(Ym),this.addDetector(Qm),this.addDetector(ef),this.addDetector(tf),this.addDetector(rf),this.addDetector(of),this.addDetector(af),this.addDetector(nf),this.addDetector(Zm);}addDetector(t){return this.detectors[t.name]=t,this}detect(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,r=[];return t.forEach(o=>{if(this.detectors[o]){let a=this.detectors[o].lookup(this.options);a&&typeof a=="string"&&(a=[a]),a&&(r=r.concat(a));}}),r=r.filter(o=>o!=null&&!Jm(o)).map(o=>this.options.convertDetectedLanguage(o)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||r.forEach(o=>{this.detectors[o]&&this.detectors[o].cacheUserLanguage(t,this.options);}));}};qa.type="languageDetector";var Jd={actions:{cancel:"Cancel",create:"Create {{item}}",delete:"Delete",deleteDocument:"Delete Document",deleteEntry:"Delete Entry",deleting:"Deleting...",duplicateDocument:"Duplicate Document",duplicating:"Duplicating...",edit:"Edit",new:"New",newDocument:"New Document",signOut:"Sign Out",view:"View"},common:{na:"N/A",no:"No",yes:"Yes"},dashboard:{activeUsers:"Active Users",authService:"Auth Service",cloudApi:"Cloud API",contentGrowth:"Content Growth",contentGrowthDesc:"Snapshot of document velocity over the last 7 days",dbNode:"Database Node",description:"Everything looks great in your command center today.",mediaAssets:"Media Assets",mediaCdn:"Media CDN",mediaLibrary:"Media Library",mediaLibraryDesc:"Manage high-fidelity assets with our liquid masonry gallery.",newAction:"New {{item}}",noCollections:"No collections available for creation.",openAssets:"Open Assets",quickLinks:"Quick Links",recentActivity:"Recent Activity",statusActive:"Active",statusHealthy:"Healthy",statusOptimal:"Optimal",statusSecure:"Secure",systemHealth:"System Health",systemStatus:"System Status",totalContent:"Total Content",viewAuditLogs:"View Audit Logs",welcome:"Welcome back, {{name}}"},days:{fri:"Fri",mon:"Mon",sat:"Sat",sun:"Sun",thu:"Thu",tue:"Tue",wed:"Wed"},detailView:{collections:"Collections",coreConfiguration:"Core Configuration",dateCreated:"Date Created",deleteMessage:"This action cannot be undone.",deleteTitle:"Delete {{label}}?",dynamicStatus:"Dynamic Status",generatingPreview:"Generating preview URL...",globals:"Globals",justNow:"Just now",lastModified:"Last Modified",metadata:"Metadata",newDocument:"New {{label}}",openPreview:"Open Preview in New Tab",publicAt:"Public At",quickLinks:"Quick Links"},listView:{actionsCol:"Actions",addFilter:"Add Filter",advancedFilters:"Advanced Filters",clearAll:"Clear All",columns:"Columns",createdCol:"Created",deleteBulkMessage_one:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkMessage_other:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkTitle:"Delete Documents",deleteMessage:"Are you sure you want to delete this document? This cannot be undone.",deleteSelected:"Delete Selected",deleteTitle:"Delete Document",filters:"Filters",getStartedCreate:"Get started by creating your first {{item}}.",lastModifiedCol:"Last Modified",noDocuments:"No documents found",noFilters:'No filters applied. Click "Add Filter" to create one.',searchPlaceholder:"Search...",selectedCount_one:"{{count}} selected",selectedCount_other:"{{count}} selected",toggleColumns:"Toggle Columns",tryAdjustingFilters:"Try adjusting your filters or search query."},login:{confirmPassword:"Confirm Password",createAccount:"Create Account",createAccountDesc:"Create an account to access the admin",createAdminAccount:"Create Admin Account",creatingAccount:"Creating account...",email:"Email",enterCredentials:"Enter your credentials to access the admin",hasAccount:"Already have an account?",noAccount:"Don't have an account?",password:"Password",setupAdmin:"Set up your admin account to get started",signIn:"Sign In",signInAction:"Sign in",signingIn:"Signing in...",signUp:"Sign up"},nav:{dashboard:"Dashboard",media:"Media",users:"Users",plugins:"Plugins",settings:"Settings",content:"Content",developer:"Developer",resources:"Resources"},sidebar:{darkMode:"Dark Mode",lightMode:"Light Mode"},toast:{accountCreated:"Account created!",connectionFailed:"Connection failed",copyError:"Failed to copy document data",dataCopied:"Document data copied to clipboard",dataPasted:"Document data pasted",draftSaved:"Draft saved",duplicated:"Document duplicated",duplicateError:"Failed to duplicate document",pasteError:"Clipboard does not contain valid document JSON",published:"Published successfully",publishError:"Failed to publish",saveError:"Failed to save changes",unpublished:"Document unpublished",unpublishError:"Failed to unpublish",updated:"Updated",welcomeBack:"Welcome back!"},userMenu:{account:"Account",apiExplorer:"API Explorer",apiKeys:"API Keys",auditLogs:"Audit Logs",developer:"Developer",documentation:"Documentation",getSupport:"Get Support",graphqlPlayground:"GraphQL Playground",permissions:"Permissions",profileSettings:"Profile Settings",resources:"Resources",sessions:"Sessions",webHooks:"Web Hooks"}};var Xd={actions:{cancel:"Annuler",create:"Cr\xE9er {{item}}",delete:"Supprimer",deleteDocument:"Supprimer le document",deleteEntry:"Supprimer l'entr\xE9e",deleting:"Suppression...",duplicateDocument:"Dupliquer le document",duplicating:"Duplication...",edit:"Modifier",new:"Nouveau",newDocument:"Nouveau Document",signOut:"D\xE9connexion",view:"Voir"},common:{na:"N/D",no:"Non",yes:"Oui"},dashboard:{activeUsers:"Utilisateurs Actifs",authService:"Service d'Authentification",cloudApi:"API Cloud",contentGrowth:"Croissance du Contenu",contentGrowthDesc:"Aper\xE7u de la vitesse des documents sur les 7 derniers jours",dbNode:"N\u0153ud de Base de Donn\xE9es",description:"Tout semble parfait dans votre centre de contr\xF4le aujourd'hui.",mediaAssets:"Ressources Multim\xE9dias",mediaCdn:"CDN Multim\xE9dia",mediaLibrary:"M\xE9diath\xE8que",mediaLibraryDesc:"G\xE9rez des ressources haute fid\xE9lit\xE9 avec notre galerie fluide.",newAction:"Nouveau {{item}}",noCollections:"Aucune collection disponible \xE0 cr\xE9er.",openAssets:"Ouvrir les Ressources",quickLinks:"Liens Rapides",recentActivity:"Activit\xE9 R\xE9cente",statusActive:"Actif",statusHealthy:"Sain",statusOptimal:"Optimal",statusSecure:"S\xE9curis\xE9",systemHealth:"Sant\xE9 du Syst\xE8me",systemStatus:"\xC9tat du Syst\xE8me",totalContent:"Contenu Total",viewAuditLogs:"Voir les Journaux d'Audit",welcome:"Bon retour, {{name}}"},days:{fri:"Ven",mon:"Lun",sat:"Sam",sun:"Dim",thu:"Jeu",tue:"Mar",wed:"Mer"},detailView:{collections:"Collections",coreConfiguration:"Configuration Principale",dateCreated:"Date de Cr\xE9ation",deleteMessage:"Cette action est irr\xE9versible.",deleteTitle:"Supprimer {{label}} ?",dynamicStatus:"Statut Dynamique",generatingPreview:"G\xE9n\xE9ration de l'URL d'aper\xE7u...",globals:"Variables Globales",justNow:"\xC0 l'instant",lastModified:"Derni\xE8re Modification",metadata:"M\xE9tadonn\xE9es",newDocument:"Nouveau {{label}}",openPreview:"Ouvrir l'Aper\xE7u",publicAt:"Public \xE0",quickLinks:"Liens Rapides"},listView:{actionsCol:"Actions",addFilter:"Ajouter un Filtre",advancedFilters:"Filtres Avanc\xE9s",clearAll:"Tout Effacer",columns:"Colonnes",createdCol:"Cr\xE9\xE9",deleteBulkMessage_one:"Voulez-vous vraiment supprimer {{count}} document ? C'est irr\xE9versible.",deleteBulkMessage_other:"Voulez-vous vraiment supprimer {{count}} documents ? C'est irr\xE9versible.",deleteBulkTitle:"Supprimer des Documents",deleteMessage:"Voulez-vous vraiment supprimer ce document ? C'est irr\xE9versible.",deleteSelected:"Supprimer la S\xE9lection",deleteTitle:"Supprimer le Document",filters:"Filtres",getStartedCreate:"Commencez par cr\xE9er votre premier {{item}}.",lastModifiedCol:"Derni\xE8re Modification",noDocuments:"Aucun document trouv\xE9",noFilters:'Aucun filtre appliqu\xE9. Cliquez sur "Ajouter un Filtre" pour en cr\xE9er un.',searchPlaceholder:"Rechercher...",selectedCount_one:"{{count}} s\xE9lectionn\xE9",selectedCount_other:"{{count}} s\xE9lectionn\xE9s",toggleColumns:"Afficher/Masquer les Colonnes",tryAdjustingFilters:"Essayez de modifier vos filtres ou votre requ\xEAte de recherche."},login:{confirmPassword:"Confirmer le Mot de Passe",createAccount:"Cr\xE9er un Compte",createAccountDesc:"Cr\xE9ez un compte pour acc\xE9der \xE0 l'administration",createAdminAccount:"Cr\xE9er un Compte Administrateur",creatingAccount:"Cr\xE9ation du compte...",email:"Email",enterCredentials:"Entrez vos identifiants pour acc\xE9der \xE0 l'administration",hasAccount:"Vous avez d\xE9j\xE0 un compte ?",noAccount:"Vous n'avez pas de compte ?",password:"Mot de Passe",setupAdmin:"Configurez votre compte administrateur pour commencer",signIn:"Se Connecter",signInAction:"Se connecter",signingIn:"Connexion...",signUp:"S'inscrire"},nav:{content:"Contenu",dashboard:"Tableau de Bord",developer:"D\xE9veloppeur",media:"M\xE9dias",plugins:"Extensions",resources:"Ressources",settings:"Param\xE8tres",users:"Utilisateurs"},sidebar:{darkMode:"Mode Sombre",lightMode:"Mode Clair"},toast:{accountCreated:"Compte cr\xE9\xE9 !",connectionFailed:"\xC9chec de la connexion",copyError:"\xC9chec de la copie des donn\xE9es",dataCopied:"Donn\xE9es copi\xE9es dans le presse-papiers",dataPasted:"Donn\xE9es coll\xE9es",draftSaved:"Brouillon enregistr\xE9",duplicated:"Document dupliqu\xE9",duplicateError:"\xC9chec de la duplication du document",pasteError:"Le presse-papiers ne contient pas de JSON valide",published:"Publi\xE9 avec succ\xE8s",publishError:"\xC9chec de la publication",saveError:"\xC9chec de l'enregistrement",unpublished:"Document d\xE9publi\xE9",unpublishError:"\xC9chec de la d\xE9publication",updated:"Mise \xE0 jour r\xE9ussie",welcomeBack:"Bon retour !"},userMenu:{account:"Compte",apiExplorer:"Explorateur d'API",apiKeys:"Cl\xE9s d'API",auditLogs:"Journaux d'Audit",developer:"D\xE9veloppeur",documentation:"Documentation",getSupport:"Obtenir de l'Aide",graphqlPlayground:"Playground GraphQL",permissions:"Permissions",profileSettings:"Param\xE8tres du Profil",resources:"Ressources",sessions:"Sessions",webHooks:"Webhooks"}};var Yd={actions:{cancel:"Cancelar",create:"Crear {{item}}",delete:"Eliminar",deleteDocument:"Eliminar Documento",deleteEntry:"Eliminar Entrada",deleting:"Eliminando...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Nuevo",newDocument:"Nuevo Documento",signOut:"Cerrar Sesi\xF3n",view:"Ver"},common:{na:"N/D",no:"No",yes:"S\xED"},dashboard:{activeUsers:"Usuarios Activos",authService:"Servicio de Autenticaci\xF3n",cloudApi:"API en la Nube",contentGrowth:"Crecimiento de Contenido",contentGrowthDesc:"Instant\xE1nea de la velocidad de los documentos en los \xFAltimos 7 d\xEDas",dbNode:"Nodo de Base de Datos",description:"Todo se ve genial en tu centro de comando hoy.",mediaAssets:"Recursos Multimedia",mediaCdn:"CDN Multimedia",mediaLibrary:"Biblioteca Multimedia",mediaLibraryDesc:"Administre recursos de alta fidelidad con nuestra galer\xEDa fluida.",newAction:"Nuevo {{item}}",noCollections:"No hay colecciones disponibles para crear.",openAssets:"Abrir Recursos",quickLinks:"Enlaces R\xE1pidos",recentActivity:"Actividad Reciente",statusActive:"Activo",statusHealthy:"Saludable",statusOptimal:"\xD3ptimo",statusSecure:"Seguro",systemHealth:"Salud del Sistema",systemStatus:"Estado del Sistema",totalContent:"Contenido Total",viewAuditLogs:"Ver Registros de Auditor\xEDa",welcome:"Bienvenido, {{name}}"},days:{fri:"Vie",mon:"Lun",sat:"S\xE1b",sun:"Dom",thu:"Jue",tue:"Mar",wed:"Mi\xE9"},detailView:{collections:"Colecciones",coreConfiguration:"Configuraci\xF3n Principal",dateCreated:"Fecha de Creaci\xF3n",deleteMessage:"Esta acci\xF3n no se puede deshacer.",deleteTitle:"\xBFEliminar {{label}}?",dynamicStatus:"Estado Din\xE1mico",generatingPreview:"Generando URL de vista previa...",globals:"Variables Globales",justNow:"Justo ahora",lastModified:"\xDAltima Modificaci\xF3n",metadata:"Metadatos",newDocument:"Nuevo {{label}}",openPreview:"Abrir Vista Previa",publicAt:"P\xFAblico a las",quickLinks:"Enlaces R\xE1pidos"},listView:{actionsCol:"Acciones",addFilter:"A\xF1adir Filtro",advancedFilters:"Filtros Avanzados",clearAll:"Borrar Todo",columns:"Columnas",createdCol:"Creado",deleteBulkMessage_one:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documento? Esto no se puede deshacer.",deleteBulkMessage_other:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documentos? Esto no se puede deshacer.",deleteBulkTitle:"Eliminar Documentos",deleteMessage:"\xBFEst\xE1s seguro de que quieres eliminar este documento? Esto no se puede deshacer.",deleteSelected:"Eliminar Selecci\xF3n",deleteTitle:"Eliminar Documento",filters:"Filtros",getStartedCreate:"Comienza creando tu primer {{item}}.",lastModifiedCol:"\xDAltima Modificaci\xF3n",noDocuments:"No se encontraron documentos",noFilters:'No hay filtros aplicados. Haz clic en "A\xF1adir Filtro" para crear uno.',searchPlaceholder:"Buscar...",selectedCount_one:"{{count}} seleccionado",selectedCount_other:"{{count}} seleccionados",toggleColumns:"Mostrar/Ocultar Columnas",tryAdjustingFilters:"Intenta ajustar tus filtros o consulta de b\xFAsqueda."},login:{confirmPassword:"Confirmar Contrase\xF1a",createAccount:"Crear Cuenta",createAccountDesc:"Crea una cuenta para acceder a la administraci\xF3n",createAdminAccount:"Crear Cuenta de Administrador",creatingAccount:"Creando cuenta...",email:"Correo Electr\xF3nico",enterCredentials:"Ingresa tus credenciales para acceder a la administraci\xF3n",hasAccount:"\xBFYa tienes una cuenta?",noAccount:"\xBFNo tienes una cuenta?",password:"Contrase\xF1a",setupAdmin:"Configura tu cuenta de administrador para empezar",signIn:"Iniciar Sesi\xF3n",signInAction:"Iniciar sesi\xF3n",signingIn:"Iniciando sesi\xF3n...",signUp:"Registrarse"},nav:{content:"Contenido",dashboard:"Panel de Control",developer:"Desarrollador",media:"Multimedia",plugins:"Complementos",resources:"Recursos",settings:"Ajustes",users:"Usuarios"},sidebar:{darkMode:"Modo Oscuro",lightMode:"Modo Claro"},toast:{accountCreated:"\xA1Cuenta creada!",connectionFailed:"Error de conexi\xF3n",copyError:"Error al copiar los datos del documento",dataCopied:"Datos del documento copiados al portapapeles",dataPasted:"Datos del documento pegados",draftSaved:"Borrador guardado",duplicated:"Documento duplicado",duplicateError:"Error al duplicar el documento",pasteError:"El portapapeles no contiene un JSON de documento v\xE1lido",published:"Publicado con \xE9xito",publishError:"Error al publicar",saveError:"Error al guardar los cambios",unpublished:"Documento despublicado",unpublishError:"Error al despublicar",updated:"Actualizado",welcomeBack:"\xA1Bienvenido de nuevo!"},userMenu:{account:"Cuenta",apiExplorer:"Explorador de API",apiKeys:"Claves de API",auditLogs:"Registros de Auditor\xEDa",developer:"Desarrollador",documentation:"Documentaci\xF3n",getSupport:"Obtener Soporte",graphqlPlayground:"Playground de GraphQL",permissions:"Permisos",profileSettings:"Ajustes de Perfil",resources:"Recursos",sessions:"Sesiones",webHooks:"Webhooks"}};var Qd={actions:{cancel:"Abbrechen",create:"{{item}} Erstellen",delete:"L\xF6schen",deleteDocument:"Dokument L\xF6schen",deleteEntry:"Eintrag L\xF6schen",deleting:"Wird gel\xF6scht...",duplicateDocument:"Dokument Duplizieren",duplicating:"Wird dupliziert...",edit:"Bearbeiten",new:"Neu",newDocument:"Neues Dokument",signOut:"Abmelden",view:"Ansehen"},common:{na:"k.A.",no:"Nein",yes:"Ja"},dashboard:{activeUsers:"Aktive Benutzer",authService:"Authentifizierungsdienst",cloudApi:"Cloud API",contentGrowth:"Inhaltswachstum",contentGrowthDesc:"\xDCbersicht der Dokumentgeschwindigkeit in den letzten 7 Tagen",dbNode:"Datenbankknoten",description:"Alles sieht in Ihrer Kommandozentrale heute gro\xDFartig aus.",mediaAssets:"Medieninhalte",mediaCdn:"Medien CDN",mediaLibrary:"Mediathek",mediaLibraryDesc:"Verwalten Sie hochaufl\xF6sende Assets mit unserer fl\xFCssigen Galerie.",newAction:"Neues {{item}}",noCollections:"Keine Sammlungen zur Erstellung verf\xFCgbar.",openAssets:"Assets \xD6ffnen",quickLinks:"Schnellzugriff",recentActivity:"Letzte Aktivit\xE4ten",statusActive:"Aktiv",statusHealthy:"Gesund",statusOptimal:"Optimal",statusSecure:"Sicher",systemHealth:"Systemgesundheit",systemStatus:"Systemstatus",totalContent:"Gesamter Inhalt",viewAuditLogs:"Audit-Protokolle ansehen",welcome:"Willkommen zur\xFCck, {{name}}"},days:{fri:"Fr",mon:"Mo",sat:"Sa",sun:"So",thu:"Do",tue:"Di",wed:"Mi"},detailView:{collections:"Sammlungen",coreConfiguration:"Kernkonfiguration",dateCreated:"Erstellungsdatum",deleteMessage:"Diese Aktion kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteTitle:"{{label}} l\xF6schen?",dynamicStatus:"Dynamischer Status",generatingPreview:"Vorschau-URL wird generiert...",globals:"Globale Variablen",justNow:"Gerade eben",lastModified:"Zuletzt Ge\xE4ndert",metadata:"Metadaten",newDocument:"Neues {{label}}",openPreview:"Vorschau in neuem Tab \xF6ffnen",publicAt:"\xD6ffentlich um",quickLinks:"Schnellzugriff"},listView:{actionsCol:"Aktionen",addFilter:"Filter hinzuf\xFCgen",advancedFilters:"Erweiterte Filter",clearAll:"Alles l\xF6schen",columns:"Spalten",createdCol:"Erstellt",deleteBulkMessage_one:"Sind Sie sicher, dass Sie {{count}} Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkMessage_other:"Sind Sie sicher, dass Sie {{count}} Dokumente l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkTitle:"Dokumente L\xF6schen",deleteMessage:"Sind Sie sicher, dass Sie dieses Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteSelected:"Auswahl l\xF6schen",deleteTitle:"Dokument l\xF6schen",filters:"Filter",getStartedCreate:"Beginnen Sie mit der Erstellung Ihres ersten {{item}}.",lastModifiedCol:"Zuletzt Ge\xE4ndert",noDocuments:"Keine Dokumente gefunden",noFilters:'Keine Filter angewendet. Klicken Sie auf "Filter hinzuf\xFCgen", um einen zu erstellen.',searchPlaceholder:"Suchen...",selectedCount_one:"{{count}} ausgew\xE4hlt",selectedCount_other:"{{count}} ausgew\xE4hlt",toggleColumns:"Spalten umschalten",tryAdjustingFilters:"Versuchen Sie, Ihre Filter oder die Suchanfrage anzupassen."},login:{confirmPassword:"Passwort best\xE4tigen",createAccount:"Konto erstellen",createAccountDesc:"Erstellen Sie ein Konto, um auf die Verwaltung zuzugreifen",createAdminAccount:"Admin-Konto erstellen",creatingAccount:"Konto wird erstellt...",email:"E-Mail",enterCredentials:"Geben Sie Ihre Anmeldedaten ein, um auf die Verwaltung zuzugreifen",hasAccount:"Haben Sie bereits ein Konto?",noAccount:"Sie haben noch kein Konto?",password:"Passwort",setupAdmin:"Richten Sie Ihr Admin-Konto ein, um loszulegen",signIn:"Anmelden",signInAction:"Anmelden",signingIn:"Wird angemeldet...",signUp:"Registrieren"},nav:{content:"Inhalt",dashboard:"Dashboard",developer:"Entwickler",media:"Medien",plugins:"Plugins",resources:"Ressourcen",settings:"Einstellungen",users:"Benutzer"},sidebar:{darkMode:"Dunkler Modus",lightMode:"Heller Modus"},toast:{accountCreated:"Konto erstellt!",connectionFailed:"Verbindung fehlgeschlagen",copyError:"Fehler beim Kopieren der Dokumentdaten",dataCopied:"Dokumentdaten in die Zwischenablage kopiert",dataPasted:"Dokumentdaten eingef\xFCgt",draftSaved:"Entwurf gespeichert",duplicated:"Dokument dupliziert",duplicateError:"Fehler beim Duplizieren des Dokuments",pasteError:"Die Zwischenablage enth\xE4lt kein g\xFCltiges Dokument-JSON",published:"Erfolgreich ver\xF6ffentlicht",publishError:"Fehler beim Ver\xF6ffentlichen",saveError:"Fehler beim Speichern der \xC4nderungen",unpublished:"Ver\xF6ffentlichung r\xFCckg\xE4ngig gemacht",unpublishError:"Fehler beim R\xFCckg\xE4ngigmachen der Ver\xF6ffentlichung",updated:"Aktualisiert",welcomeBack:"Willkommen zur\xFCck!"},userMenu:{account:"Konto",apiExplorer:"API Explorer",apiKeys:"API-Schl\xFCssel",auditLogs:"Audit-Protokolle",developer:"Entwickler",documentation:"Dokumentation",getSupport:"Hilfe erhalten",graphqlPlayground:"GraphQL Playground",permissions:"Berechtigungen",profileSettings:"Profileinstellungen",resources:"Ressourcen",sessions:"Sitzungen",webHooks:"Webhooks"}};var Zd={actions:{cancel:"Cancelar",create:"Criar {{item}}",delete:"Excluir",deleteDocument:"Excluir Documento",deleteEntry:"Excluir Entrada",deleting:"Excluindo...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Novo",newDocument:"Novo Documento",signOut:"Sair",view:"Ver"},common:{na:"N/A",no:"N\xE3o",yes:"Sim"},dashboard:{activeUsers:"Usu\xE1rios Ativos",authService:"Servi\xE7o de Autentica\xE7\xE3o",cloudApi:"API em Nuvem",contentGrowth:"Crescimento de Conte\xFAdo",contentGrowthDesc:"Vis\xE3o geral da velocidade dos documentos nos \xFAltimos 7 dias",dbNode:"N\xF3 de Banco de Dados",description:"Tudo parece \xF3timo no seu centro de comando hoje.",mediaAssets:"Ativos de M\xEDdia",mediaCdn:"CDN de M\xEDdia",mediaLibrary:"Biblioteca de M\xEDdia",mediaLibraryDesc:"Gerencie ativos de alta fidelidade com nossa galeria fluida.",newAction:"Novo {{item}}",noCollections:"Nenhuma cole\xE7\xE3o dispon\xEDvel para cria\xE7\xE3o.",openAssets:"Abrir Ativos",quickLinks:"Links R\xE1pidos",recentActivity:"Atividade Recente",statusActive:"Ativo",statusHealthy:"Saud\xE1vel",statusOptimal:"Ideal",statusSecure:"Seguro",systemHealth:"Sa\xFAde do Sistema",systemStatus:"Status do Sistema",totalContent:"Conte\xFAdo Total",viewAuditLogs:"Ver Registros de Auditoria",welcome:"Bem-vindo de volta, {{name}}"},days:{fri:"Sex",mon:"Seg",sat:"S\xE1b",sun:"Dom",thu:"Qui",tue:"Ter",wed:"Qua"},detailView:{collections:"Cole\xE7\xF5es",coreConfiguration:"Configura\xE7\xE3o Principal",dateCreated:"Data de Cria\xE7\xE3o",deleteMessage:"Esta a\xE7\xE3o n\xE3o pode ser desfeita.",deleteTitle:"Excluir {{label}}?",dynamicStatus:"Status Din\xE2mico",generatingPreview:"Gerando URL de visualiza\xE7\xE3o...",globals:"Vari\xE1veis Globais",justNow:"Agora mesmo",lastModified:"\xDAltima Modifica\xE7\xE3o",metadata:"Metadados",newDocument:"Novo {{label}}",openPreview:"Abrir Visualiza\xE7\xE3o em Nova Guia",publicAt:"P\xFAblico \xE0s",quickLinks:"Links R\xE1pidos"},listView:{actionsCol:"A\xE7\xF5es",addFilter:"Adicionar Filtro",advancedFilters:"Filtros Avan\xE7ados",clearAll:"Limpar Tudo",columns:"Colunas",createdCol:"Criado",deleteBulkMessage_one:"Tem certeza de que deseja excluir {{count}} documento? Isso n\xE3o pode ser desfeito.",deleteBulkMessage_other:"Tem certeza de que deseja excluir {{count}} documentos? Isso n\xE3o pode ser desfeito.",deleteBulkTitle:"Excluir Documentos",deleteMessage:"Tem certeza de que deseja excluir este documento? Isso n\xE3o pode ser desfeito.",deleteSelected:"Excluir Selecionados",deleteTitle:"Excluir Documento",filters:"Filtros",getStartedCreate:"Comece criando seu primeiro {{item}}.",lastModifiedCol:"\xDAltima Modifica\xE7\xE3o",noDocuments:"Nenhum documento encontrado",noFilters:'Nenhum filtro aplicado. Clique em "Adicionar Filtro" para criar um.',searchPlaceholder:"Pesquisar...",selectedCount_one:"{{count}} selecionado",selectedCount_other:"{{count}} selecionados",toggleColumns:"Alternar Colunas",tryAdjustingFilters:"Tente ajustar seus filtros ou a consulta de pesquisa."},login:{confirmPassword:"Confirmar Senha",createAccount:"Criar Conta",createAccountDesc:"Crie uma conta para acessar a administra\xE7\xE3o",createAdminAccount:"Criar Conta de Administrador",creatingAccount:"Criando conta...",email:"E-mail",enterCredentials:"Insira suas credenciais para acessar a administra\xE7\xE3o",hasAccount:"J\xE1 tem uma conta?",noAccount:"N\xE3o tem uma conta?",password:"Senha",setupAdmin:"Configure sua conta de administrador para come\xE7ar",signIn:"Entrar",signInAction:"Entrar",signingIn:"Entrando...",signUp:"Inscrever-se"},nav:{content:"Conte\xFAdo",dashboard:"Painel de Controle",developer:"Desenvolvedor",media:"M\xEDdia",plugins:"Plugins",resources:"Recursos",settings:"Configura\xE7\xF5es",users:"Usu\xE1rios"},sidebar:{darkMode:"Modo Escuro",lightMode:"Modo Claro"},toast:{accountCreated:"Conta criada!",connectionFailed:"Falha na conex\xE3o",copyError:"Falha ao copiar os dados do documento",dataCopied:"Dados do documento copiados para a \xE1rea de transfer\xEAncia",dataPasted:"Dados do documento colados",draftSaved:"Rascunho salvo",duplicated:"Documento duplicado",duplicateError:"Falha ao duplicar documento",pasteError:"A \xE1rea de transfer\xEAncia n\xE3o cont\xE9m um JSON de documento v\xE1lido",published:"Publicado com sucesso",publishError:"Falha ao publicar",saveError:"Falha ao salvar as altera\xE7\xF5es",unpublished:"Documento despublicado",unpublishError:"Falha ao despublicar",updated:"Atualizado",welcomeBack:"Bem-vindo de volta!"},userMenu:{account:"Conta",apiExplorer:"Explorador de API",apiKeys:"Chaves de API",auditLogs:"Registros de Auditoria",developer:"Desenvolvedor",documentation:"Documenta\xE7\xE3o",getSupport:"Obter Suporte",graphqlPlayground:"Playground GraphQL",permissions:"Permiss\xF5es",profileSettings:"Configura\xE7\xF5es de Perfil",resources:"Recursos",sessions:"Sess\xF5es",webHooks:"Webhooks"}};var mf={en:{translation:Jd},fr:{translation:Xd},es:{translation:Yd},de:{translation:Qd},pt:{translation:Zd}},ec=typeof window<"u"&&window.KYRO_LANG?window.KYRO_LANG:"en";Et.use(qa).use(ss).init({resources:mf,fallbackLng:ec,lng:ec,interpolation:{escapeValue:false}});function Fo(e,t,r){return r in t?t[r]:Di(e,t,r)}function Di(e,t,r){for(let o of e)if(o.name){if(o.type==="tabs"&&"tabs"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Di(o.tabs?.flatMap(s=>s.fields||[])||[],a,r);if(n!==void 0)return n}}if((o.type==="group"||o.type==="collapsible")&&"fields"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Di(o.fields||[],a,r);if(n!==void 0)return n}}}}function Ri({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let{t:i}=z(),l=t||e.slug,{permissions:d}=Yr(),c=d?.collections?.[l]?.create!==false,u=d?.collections?.[l]?.delete!==false,p=d?.collections?.[l]?.update!==false,f=()=>{if(c)if(a)a();else {let $=`${He}/${l}/new`;import('astro:transitions/client').then(({navigate:Y})=>{Y($);}).catch(()=>{window.location.href=$;});}},y=$=>{if(n)n($);else {let Y=`${He}/${l}/${$}`;import('astro:transitions/client').then(({navigate:se})=>{se(Y);}).catch(()=>{window.location.href=Y;});}},[g,v]=oa.useState(r),[h,m]=oa.useState(o),[w,C]=oa.useState(false),[E,D]=oa.useState(1),[k,b]=oa.useState(10),[x,N]=oa.useState(new Set),[O,M]=oa.useState(""),[I,P]=oa.useState([]),{confirm:R,alert:fe}=gt(),L=()=>{P([...I,{field:"",operator:"equals",value:""}]);},re=()=>{M(""),P([]),pe(null);},ne=$=>{P(I.filter((Y,se)=>se!==$));},ee=($,Y)=>{P(I.map((se,Qt)=>Qt===$?{...se,...Y}:se));},[H,pe]=oa.useState(null),[be,V]=oa.useState(false),[q,ae]=oa.useState(false);function K($){let Y=[];for(let se of $||[])if(!(!se.name||se.hidden===true||se.admin?.hidden||se.name==="id"))if(se.type==="tabs"&&se.tabs)for(let Qt of se.tabs)Qt.fields&&Y.push(...K(Qt.fields));else (se.type==="row"||se.type==="collapsible")&&se.fields?Y.push(...K(se.fields)):Y.push(se);return Y}let Re=oa.useMemo(()=>K(e.fields),[e.fields]),he=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:Re.find($=>$.type!=="group"&&typeof $.name=="string")?.name,[Ae,T]=oa.useState(()=>{let $;return e.admin?.defaultColumns?$=[...e.admin?.defaultColumns||[]]:$=Re.slice(0,4).map(Y=>Y.name).filter(Y=>!!Y),he&&$.includes(he)&&($=[he,...$.filter(Y=>Y!==he)]),$.includes("updatedAt")||$.push("updatedAt"),new Set($)}),_=oa.useCallback($=>{T(Y=>{let se=new Set(Y);return se.has($)?se.delete($):se.add($),se});},[]);function Ne($){let Y=Re.find(se=>se.name===$);return Y&&Y.type==="group"&&Y.fields?.[0]?.name?`${$}.${Y.fields[0].name}`:$}let Oe=oa.useCallback($=>{let Y=Ne($);pe(se=>se&&se.field===Y?{field:Y,direction:se.direction==="asc"?"desc":"asc"}:{field:Y,direction:"asc"});},[]),Me=oa.useMemo(()=>{let $=[];for(let Y of Array.from(Ae))if(Y==="status")$.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]});else {let se=Re.find(Qt=>Qt.name===Y);se&&se.name&&$.push(se);}return $},[Re,Ae]);function Fe($){return !$.name||!he?false:$.name===he||$.type==="group"&&$.fields?.[0]?.name===he}function vt($,Y){return Y.name?Fo(e.fields,$,Y.name)??null:null}let Yt=oa.useCallback(async()=>{C(true);try{let $=new URLSearchParams({page:E.toString(),limit:k.toString()});O&&$.append("search",O),H&&$.append("sort",H.field),H&&$.append("order",H.direction),I.length>0&&$.append("filters",JSON.stringify(I));let Y=await Be(Qr(`/api/${l}?${$}`),{autoToast:!1});v(Y.docs||[]),m(Y.totalDocs||0);}catch($){console.error("Failed to load docs:",$);}finally{C(false);}},[l,E,k,O,H,I]);oa.useEffect(()=>{g.length===0&&o===0&&Yt();},[]);let X=oa.useRef(true);oa.useEffect(()=>{if(X.current){X.current=false;return}Yt();},[E,k,O,H,I]);let j=()=>{x.size===g.length?N(new Set):N(new Set(g.map($=>$.id)));},W=$=>{let Y=new Set(x);Y.has($)?Y.delete($):Y.add($),N(Y);},de=()=>{R({title:i("listView.deleteBulkTitle",{defaultValue:"Delete Documents"}),message:i("listView.deleteBulkMessage",{defaultValue:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",count:x.size}),variant:"danger",onConfirm:async()=>{try{for(let $ of Array.from(x))await Dt(`/api/${l}/${$}`);N(new Set),Yt(),U.success("Documents deleted");}catch($){console.error("Bulk delete failed:",$),U.error("Failed to delete some documents");}}});},Ie=$=>{R({title:i("listView.deleteTitle",{defaultValue:"Delete Document"}),message:i("listView.deleteMessage",{defaultValue:"Are you sure you want to delete this document? This cannot be undone."}),variant:"danger",onConfirm:async()=>{try{await Dt(`/api/${l}/${$}`),Yt(),U.success("Document deleted");}catch(Y){console.error("Delete failed:",Y),U.error("Failed to delete document");}}});},Ue=Math.ceil(h/k),bt=O||I.length>0||H;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Vt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:h>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[h," documents"]},"count")]:void 0,action:c?{label:i("actions.create",{defaultValue:"Create {{item}}",item:e.singularLabel||e.label||l}),href:a?void 0:`${He}/${l}/new`,onClick:a?f:void 0,icon:Nc.Plus}:void 0}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsxRuntime.jsx(Nc.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:i("listView.searchPlaceholder",{defaultValue:"Search..."}),value:O,onChange:$=>M($.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-sm font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>V(!be),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${be||I.length>0?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Nc.Filter,{className:"w-4 h-4"}),i("listView.filters",{defaultValue:"Filters"}),I.length>0&&jsxRuntime.jsx("span",{className:"ml-1 px-1.5 py-0.5 bg-[var(--kyro-sidebar-text-active)] text-[var(--kyro-sidebar-active)] rounded-full text-xs",children:I.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>ae(!q),className:"flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",children:[jsxRuntime.jsx(Nc.Columns3,{className:"w-4 h-4"}),i("listView.columns",{defaultValue:"Columns"})]}),q&&jsxRuntime.jsxs("div",{className:"absolute right-0 top-full mt-2 w-56 surface-tile border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 overflow-hidden",children:[jsxRuntime.jsx("div",{className:"p-3 border-b border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-xs font-bold tracking-wider text-[var(--kyro-text-secondary)]",children:i("listView.toggleColumns",{defaultValue:"Toggle Columns"})})}),jsxRuntime.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:Re.map($=>$.name?jsxRuntime.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:Ae.has($.name),onChange:()=>_($.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:$.label||$.name})]},$.name):null)})]})]}),bt&&jsxRuntime.jsx("button",{type:"button",onClick:re,className:"px-4 py-2 rounded-xl font-bold text-sm text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 transition-all",children:i("listView.clearAll",{defaultValue:"Clear All"})})]})]}),be&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("h3",{className:"font-medium text-[var(--kyro-text-primary)]",children:i("listView.advancedFilters",{defaultValue:"Advanced Filters"})}),jsxRuntime.jsxs("button",{type:"button",onClick:L,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-bold text-[var(--kyro-sidebar-active)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-4 h-4"}),i("listView.addFilter",{defaultValue:"Add Filter"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[I.map(($,Y)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:$.field,onChange:se=>ee(Y,{field:se.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:Re.map(se=>jsxRuntime.jsx("option",{value:se.name,children:se.label||se.name},se.name))}),jsxRuntime.jsxs("select",{value:$.operator,onChange:se=>ee(Y,{operator:se.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("option",{value:"equals",children:"Equals"}),jsxRuntime.jsx("option",{value:"contains",children:"Contains"}),jsxRuntime.jsx("option",{value:"gt",children:"Greater than"}),jsxRuntime.jsx("option",{value:"lt",children:"Less than"}),jsxRuntime.jsx("option",{value:"gte",children:"Greater or equal"}),jsxRuntime.jsx("option",{value:"lte",children:"Less or equal"})]}),jsxRuntime.jsx("input",{type:"text",value:$.value,onChange:se=>ee(Y,{value:se.target.value}),placeholder:i("fields.value",{defaultValue:"Value..."}),className:"flex-1 min-w-[150px] px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>ne(Y),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]},Y)),I.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:i("listView.noFilters",{defaultValue:'No filters applied. Click "Add Filter" to create one.'})})]})]}),x.size>0&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex items-center justify-between border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:i("listView.selectedCount",{defaultValue:"{{count}} selected",count:x.size})}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[u&&jsxRuntime.jsxs("button",{type:"button",onClick:de,className:"flex items-center gap-2 px-4 py-2 bg-red-500 text-white rounded-lg font-bold text-sm hover:bg-red-600 transition-all",children:[jsxRuntime.jsx(Nc.Trash2,{className:"w-4 h-4"}),i("listView.deleteSelected",{defaultValue:"Delete Selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>N(new Set),className:"px-4 py-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] font-bold text-sm transition-all",children:i("actions.cancel",{defaultValue:"Cancel"})})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden",children:w?jsxRuntime.jsx("div",{className:"space-y-2 p-4",children:jsxRuntime.jsx(Kt,{variant:"table-row",count:8})}):g.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsxRuntime.jsx(Nc.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:i("listView.noDocuments",{defaultValue:"No documents found"})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:bt?i("listView.tryAdjustingFilters",{defaultValue:"Try adjusting your filters or search query."}):i("listView.getStartedCreate",{defaultValue:"Get started by creating your first {{item}}.",item:(e.singularLabel||e.label||l).toLowerCase()})}),!bt&&c&&jsxRuntime.jsxs("button",{type:"button",onClick:f,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-4 h-4"}),i("actions.create",{defaultValue:"Create {{item}}",item:String(e.singularLabel||e.label||l)})]})]}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[10px] tracking-[0.3em] border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-4 py-4 w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:x.size===g.length&&g.length>0,onChange:j,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Me.map($=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Oe($.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[gf(Me,$.type)??($.label||$.name),H&&H.field===$.name&&jsxRuntime.jsx(Nc.ChevronUp,{className:"w-4 h-4"})]})},$.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:i("listView.createdCol",{defaultValue:"Created"})}):null,e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:i("listView.lastModifiedCol",{defaultValue:"Last Modified"})}):null,jsxRuntime.jsx("th",{className:"px-4 py-4 text-right",children:i("listView.actionsCol",{defaultValue:"Actions"})})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:g.map($=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>y($.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:Y=>Y.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:x.has($.id),onChange:()=>W($.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Me.map(Y=>{let se=vt($,Y),Qt=Y.type==="select"&&se&&Array.isArray(Y.options)?Y.options.find(Co=>Co.value===se)?.label||se:yf(se,Y.type,i);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${Fe(Y)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:Qt},Y.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:$.createdAt?new Date($.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:$.updatedAt?new Date($.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:Y=>Y.stopPropagation(),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>y($.id),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",title:p?i("actions.edit",{defaultValue:"Edit"}):i("actions.view",{defaultValue:"View"}),children:jsxRuntime.jsx(Nc.Pencil,{className:"w-4 h-4"})}),u&&jsxRuntime.jsx("button",{type:"button",onClick:()=>Ie($.id),className:"inline-flex items-center justify-center w-8 h-8 rounded-md text-[var(--kyro-text-muted)] hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-500/10 transition-colors",title:i("actions.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Nc.Trash2,{className:"w-4 h-4"})})]})})]},$.id))})]})})}),jsxRuntime.jsx(bd,{page:E,totalPages:Ue,totalDocs:h,limit:k,onPageChange:D,onLimitChange:$=>{b($),D(1);}})]})}function yf(e,t,r){return e==null?"\u2014":typeof e=="boolean"?e?r?r("common.yes",{defaultValue:"Yes"}):"Yes":r?r("common.no",{defaultValue:"No"}):"No":t==="number"||t==="price"?String(e):t==="date"||t==="datetime"?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):Array.isArray(e)?e.map(o=>o&&typeof o=="object"?o.title||o.name||o.email||o.filename||o.url||JSON.stringify(o).slice(0,30):String(o??"").slice(0,30)).filter(Boolean).join(", "):typeof e=="object"?e.title?e.title:e.name?e.name:e.email?e.email:JSON.stringify(e).slice(0,50):String(e).slice(0,60)}function gf(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var Fi=(e,t)=>{let r=e?.toLowerCase()||"",o=t?.toLowerCase()||"";return r.startsWith("image/")||o.match(/\.(jpe?g|png|gif|webp|avif|svg)$/i)?"image":r.startsWith("video/")||o.match(/\.(mp4|webm|ogg|mov)$/i)?"video":r.startsWith("audio/")||o.match(/\.(mp3|wav|ogg|m4a)$/i)?"audio":r.includes("pdf")||o.endsWith(".pdf")?"pdf":o.match(/\.(doc|docx|txt|rtf|odt)$/i)?"document":o.match(/\.(xls|xlsx|csv)$/i)?"spreadsheet":o.match(/\.(zip|tar|gz|7z|rar)$/i)?"archive":"other"},sc=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(Nc.Image,{className:t});case "video":return jsxRuntime.jsx(Nc.Film,{className:t});case "audio":return jsxRuntime.jsx(Nc.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(Nc.FileText,{className:t});default:return jsxRuntime.jsx(Nc.File,{className:t})}};function br({field:e,value:t,onChange:r,disabled:o}){let a=oa.useRef(null),n=oa.useRef(null),[s,i]=oa.useState(false),[l,d]=oa.useState(false),[c,u]=oa.useState(false),[p,f]=oa.useState([]),[y,g]=oa.useState([]),[v,h]=oa.useState(""),[m,w]=oa.useState(false),[C,E]=oa.useState(""),[D,k]=oa.useState(false),[b,x]=oa.useState(""),[N,O]=oa.useState(""),[M,I]=oa.useState([]),P=e?.label||e?.name||"File",R=e.maxCount??(e.hasMany?999:1),fe=R>1,L=Array.isArray(t)?t:t?[t]:[],re=L.length<R,[ne,ee]=oa.useState({});oa.useEffect(()=>{(async()=>{let _=L.filter(Fe=>typeof Fe=="string").map(Fe=>Fe),Ne=L.filter(Fe=>typeof Fe=="object"&&Fe!==null&&typeof Fe.id=="string"&&!Fe.url&&!Fe.filename&&!Fe.mimeType).map(Fe=>Fe.id),Me=[..._,...Ne].filter(Fe=>!ne[Fe]);if(Me.length!==0)try{let Fe=await Promise.all(Me.map(vt=>Be(`/api/media/${vt}`)));ee(vt=>{let Yt={...vt};return Fe.forEach(X=>{X&&X.id&&(Yt[X.id]=X);}),Yt});}catch(Fe){console.error("Failed to fetch media details:",Fe);}})();},[t,ne]),oa.useEffect(()=>{l&&(H(),pe());},[l,v]);let H=async()=>{try{let T=await Be(Qr("/api/media/folders"));g(T.folders||[]);}catch{g([]);}},pe=async()=>{w(true);try{let T=Qr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");v&&(T+="&folder="+encodeURIComponent(v));let _=await Be(T);f(_.docs||[]);}catch{f([]);}finally{w(false);}},be=async T=>{i(true);try{let _=new FormData;_.append("file",T),v&&_.append("folder",v);let Ne=await Tn("/api/media/upload",_),Oe=Ne.data||Ne.doc||Ne,Me={...Oe,id:Oe.id,filename:Oe.filename,originalName:Oe.originalName??T.name,url:Oe.url,mimeType:Oe.mimeType||T.type};r(fe?[...L,Me]:Me),U.success(`Asset synchronized: ${Me.filename}`);}catch(_){console.error("Upload failed:",_),U.error(`Upload failed: ${_ instanceof Error?_.message:"Unknown error"}`);}finally{i(false);}},V=async()=>{let T=b.trim();if(T){O("");try{let _=await ut("/api/media/upload",{url:T}),Ne=(()=>{try{return new URL(T).pathname.split("/").pop()||_.originalName||"url-image"}catch{return _.originalName||"url-image"}})(),Oe={id:_.id,filename:_.filename,originalName:Ne,url:_.url,mimeType:_.mimeType||"image/*"};r(fe?[...L,Oe]:Oe),U.success(`URL asset established: ${Oe.filename}`),x(""),k(!1);}catch(_){let Ne=_ instanceof Error?_.message:"Invalid URL";O(Ne);}}},q=T=>({id:T.id,filename:T.filename,url:T.url,mimeType:T.mimeType}),ae=T=>{fe?I(_=>_.find(Oe=>Oe.id===T.id)?_.filter(Oe=>Oe.id!==T.id):[..._,T]):(r(q(T)),d(false),E(""));},K=()=>{if(M.length>0){let T=[...L,...M.map(q)];r(T);}I([]),d(false),E("");},Re=T=>{let _=[...L];_.splice(T,1),r(fe?_:_[0]||null);},he=oa.useMemo(()=>p.filter(T=>!C||T.filename?.toLowerCase().includes(C.toLowerCase())||T.title?.toLowerCase().includes(C.toLowerCase())),[p,C]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let Ae=(T,_)=>{if(!T)return null;let Ne=typeof T=="string"?T:T.id,Oe=ne[Ne]||(typeof T=="object"?T:{}),Me=Fi(Oe.mimeType,Oe.filename||Oe.url);return jsxRuntime.jsxs("div",{className:"flex items-center gap-3 p-2.5 bg-[var(--kyro-surface-accent)] rounded-lg border border-[var(--kyro-border)] group",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 rounded-md overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex items-center justify-center flex-shrink-0",children:Me==="image"?jsxRuntime.jsx("img",{src:Va(Oe.url),alt:Oe.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(sc,{type:Me,className:"w-5 h-5 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-[11px] font-medium truncate text-[var(--kyro-text-primary)]",children:Oe.originalName||Oe.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:P})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>_!==void 0?Re(_):r(null),disabled:o,className:"p-1.5 rounded-md text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)] transition-all opacity-0 group-hover:opacity-100",children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]},_)};return jsxRuntime.jsxs("div",{className:"space-y-2 relative",children:[jsxRuntime.jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:T=>{let _=T.target.files?.[0];_&&be(_);},disabled:o,className:"hidden"}),L.length>0&&jsxRuntime.jsx("div",{className:fe?"grid grid-cols-2 gap-2":"space-y-2",children:L.map((T,_)=>Ae(T,_))}),(!L.length||re)&&jsxRuntime.jsxs("div",{className:"flex gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a.current?.click(),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:["+ Upload ",P]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{I([]),d(true);},disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"Library"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>k(!D),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"URL"})]}),D&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:b,onChange:T=>{x(T.target.value),O("");},onKeyDown:T=>T.key==="Enter"&&V(),disabled:o,className:"flex-1 px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),jsxRuntime.jsx("button",{type:"button",onClick:V,disabled:o||!b.trim(),className:"kyro-btn kyro-btn-primary px-3 py-1.5 text-xs rounded cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50",children:"Add"}),N&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:N})]}),l&&(c?reactDom.createPortal(jsxRuntime.jsx(nc,{isFullscreen:true,isMultiple:fe,selectedItems:M,pickerSearch:C,setPickerSearch:E,folders:y,selectedFolder:v,setSelectedFolder:h,mediaLoading:m,filteredMedia:he,selectFromLibrary:ae,onDone:K,setIsPickerFullscreen:u,setShowPicker:d}),document.body):jsxRuntime.jsx(nc,{isFullscreen:false,isMultiple:fe,selectedItems:M,pickerSearch:C,setPickerSearch:E,folders:y,selectedFolder:v,setSelectedFolder:h,mediaLoading:m,filteredMedia:he,selectFromLibrary:ae,onDone:K,setIsPickerFullscreen:u,setShowPicker:d}))]})}function nc({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:i,mediaLoading:l,filteredMedia:d,selectFromLibrary:c,onDone:u,setIsPickerFullscreen:p,setShowPicker:f}){let{t:y}=z(),g=v=>r.some(h=>h.id===v);return jsxRuntime.jsxs("div",{className:`${e?"fixed inset-0 z-[9999]":"relative z-[9999] w-[360px] max-h-[400px] mt-1 rounded-lg shadow-lg"} overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex flex-col`,children:[jsxRuntime.jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsxRuntime.jsx("input",{type:"text",placeholder:y("fields.searchMedia",{defaultValue:"Search media..."}),value:o,onChange:v=>a(v.target.value),className:"w-full px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),n.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(""),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===""?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:"All"}),n.slice(0,6).map(v=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(v.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===v.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:v.name},v.path))]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-2",children:l?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"No media found"}):jsxRuntime.jsx("div",{className:`grid gap-1 ${e?"grid-cols-[repeat(auto-fill,minmax(140px,1fr))]":"grid-cols-3"}`,children:d.map(v=>{let h=g(v.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(v),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${h?"border-[var(--kyro-primary)] ring-2 ring-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]"}`,children:[jsxRuntime.jsx("div",{className:`w-full flex items-center justify-center bg-[var(--kyro-surface-accent)] ${e?"h-[120px]":"h-[80px]"}`,children:Fi(v.mimeType,v.filename)==="image"?jsxRuntime.jsx("img",{src:Va(v.thumbnailUrl||v.url),alt:v.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(sc,{type:Fi(v.mimeType,v.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&h&&jsxRuntime.jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsxRuntime.jsx(Nc.Check,{className:"w-3 h-3 text-white"})})]},v.id)})})}),jsxRuntime.jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[d.length," items"]}),jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[t&&jsxRuntime.jsxs("button",{type:"button",onClick:u,className:"kyro-btn kyro-btn-primary px-3 py-1 text-xs font-semibold rounded cursor-pointer hover:opacity-90 transition-opacity",children:["Done",r.length>0?` (${r.length})`:""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(!e),className:"p-1.5 rounded text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",title:e?"Exit fullscreen":"Fullscreen",children:e?jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})}):jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{f(false),p(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function pt({field:e,error:t,children:r,hideLabel:o=false}){return jsxRuntime.jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsxRuntime.jsx("div",{className:"flex justify-between items-end mb-1",children:jsxRuntime.jsxs("label",{className:"block text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 group-focus-within:opacity-100 group-focus-within:text-[var(--kyro-primary)] transition-all duration-300",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsxRuntime.jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsxRuntime.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin.description}),t&&jsxRuntime.jsxs("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-error)] font-bold flex items-center gap-2 animate-in fade-in slide-in-from-top-1 duration-300",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function hr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let i=oa.useRef(null),[l,d]=oa.useState(false);oa.useEffect(()=>{d(true);},[]),oa.useEffect(()=>{let u=p=>{p.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",u),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",u),document.body.style.overflow="";}},[e,t]);let c={sm:"w-full sm:w-[320px]",md:"w-full sm:w-[400px]",lg:"w-full sm:w-[550px]",xl:"w-full sm:w-[700px]"};return !e||!l?null:reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-[99998] bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{ref:i,"data-kyro-slide-panel":"true","data-kyro-slide-width":a,className:`fixed right-0 top-0 bottom-0 z-[99999] ${c[a]} bg-[var(--kyro-surface)] ${s?`border-l-2 ${s}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1.5 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors",children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsxRuntime.jsx("style",{children:`
2
2
  @keyframes slideIn {
3
3
  from { transform: translateX(100%); }
4
4
  to { transform: translateX(0); }
@@ -6,24 +6,24 @@
6
6
  .animate-slideIn {
7
7
  animation: slideIn 300ms ease-out;
8
8
  }
9
- `})]}),document.body)}function Cr({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Mr({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function St({open:e,onClose:t,title:r,children:o,footer:a,size:n="lg",variant:s="default"}){if(Ta.useEffect(()=>{let d=c=>{c.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="";}},[e,t]),!e)return null;let i={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl",full:"w-full h-full max-w-none rounded-none border-0"},l=s==="lightbox";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[jsxRuntime.jsx("div",{className:`absolute inset-0 transition-all duration-500 ${l?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxRuntime.jsxs("div",{className:`relative ${i[n]} ${l?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!l&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${l?"":"border"} ${s==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!l&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-8 py-6 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50 backdrop-blur-md",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-2 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-xl hover:bg-[var(--kyro-surface)] transition-all duration-200",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:`flex-1 overflow-auto ${l?"":"px-8 py-8"}`,children:o}),a&&!l&&jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 px-8 py-6 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50",children:a})]})]}),document.body)}function Vs({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:s="Cancel",variant:i="default",loading:l=false}){return jsxRuntime.jsx(St,{open:e,onClose:t,title:o,size:"sm",footer:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:l,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:s}),jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:l,className:`kyro-btn kyro-btn-md ${i==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:l?"Loading...":n})]}),children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function Ll({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,i]=Ta.useState(n),l=d=>{d.preventDefault(),s.trim()&&(r(s.trim()),i(""),t());};return e?reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-[var(--kyro-surface)] rounded-lg shadow-2xl animate-in fade-in zoom-in-95 duration-200 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-[var(--kyro-text-primary)]",children:o}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-lg hover:bg-[var(--kyro-surface-accent)] transition-colors",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:l,children:[jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsx("input",{type:"text",value:s,onChange:d=>i(d.target.value),placeholder:a,autoFocus:true,className:"w-full px-3 py-2 border border-[var(--kyro-input-border)] rounded-lg bg-[var(--kyro-input-bg)] text-[var(--kyro-text-primary)] placeholder-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] rounded-b-lg",children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-lg font-medium text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",disabled:!s.trim(),className:"px-4 py-2 rounded-lg font-medium text-sm bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] hover:opacity-90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Confirm"})]})]})]})]}),document.body):null}function Vl({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[s,i]=Ta.useState("crop"),[l,d]=Ta.useState(t?{unit:"%",...t}:void 0),[c,u]=Ta.useState(r||{x:40,y:40,width:20,height:20}),[m,v]=Ta.useState(!!r),x=Ta.useRef(null),g=Ta.useRef(null),[f,b]=Ta.useState(false),[p,h]=Ta.useState(null),A=Ta.useRef(null),$=(z,P)=>{s==="hotspot"&&(z.stopPropagation(),z.preventDefault(),P?h(P):b(true),A.current={x:z.clientX,y:z.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},T=Ta.useCallback(z=>{if(!A.current||!x.current)return;let P=x.current.getBoundingClientRect(),R=(z.clientX-A.current.x)/P.width*100,Ae=(z.clientY-A.current.y)/P.height*100,E=A.current;if(f){let oe=E.hX+R,ie=E.hY+Ae;oe=Math.max(0,Math.min(oe,100-E.hW)),ie=Math.max(0,Math.min(ie,100-E.hH)),u(ee=>({...ee,x:oe,y:ie}));}else if(p){let oe=E.hX,ie=E.hY,ee=E.hW,G=E.hH;p.includes("e")&&(ee=E.hW+R),p.includes("w")&&(oe=E.hX+R,ee=E.hW-R),p.includes("s")&&(G=E.hH+Ae),p.includes("n")&&(ie=E.hY+Ae,G=E.hH-Ae),ee<5&&(ee=5,p.includes("w")&&(oe=E.hX+E.hW-5)),G<5&&(G=5,p.includes("n")&&(ie=E.hY+E.hH-5)),oe=Math.max(0,Math.min(oe,100-ee)),ie=Math.max(0,Math.min(ie,100-G)),ee=Math.min(ee,100-oe),G=Math.min(G,100-ie),u({x:oe,y:ie,width:ee,height:G});}},[f,p,c]),k=Ta.useCallback(()=>{b(false),h(null),A.current=null;},[]);Ta.useEffect(()=>((f||p)&&(window.addEventListener("pointermove",T),window.addEventListener("pointerup",k)),()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",k);}),[f,p,T,k]);let y=z=>{},w=()=>{let z=l?.width&&l?.height?{x:l.x,y:l.y,width:l.width,height:l.height}:void 0;o(z,m?c:void 0);},D=()=>{d(void 0),v(false);},U=Ta.useMemo(()=>{if(!l||!l.width||!l.height)return null;let z=new URLSearchParams({url:e});return z.set("cx",String(l.x)),z.set("cy",String(l.y)),z.set("cw",String(l.width)),z.set("ch",String(l.height)),`/api/media/resize?${z.toString()}`},[e,l]),O=l?.width&&l.height;return jsxRuntime.jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("button",{onClick:()=>i("crop"),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="crop"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Ql.Crop,{className:"w-4 h-4"}),"Crop"]}),jsxRuntime.jsxs("button",{onClick:()=>{i("hotspot"),m||v(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Ql.MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("button",{onClick:D,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:[jsxRuntime.jsx(Ql.RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{onClick:w,disabled:n,className:"flex items-center justify-center min-w-[120px] px-6 py-2 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] text-sm font-bold rounded-lg shadow-lg hover:opacity-90 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",children:n?jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4 text-current",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):"Save Edits"})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxRuntime.jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:g,children:[jsxRuntime.jsx(np__default.default,{crop:l,onChange:(z,P)=>d(P),locked:s==="hotspot",className:s==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsxRuntime.jsx("img",{ref:x,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:y})}),m&&x.current&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"relative",style:{width:x.current.width,height:x.current.height},children:jsxRuntime.jsxs("div",{className:`absolute border-2 shadow-2xl transition-colors duration-200 ${s==="hotspot"?"border-blue-500 bg-blue-500/20 cursor-move pointer-events-auto shadow-blue-500/50":"border-blue-500/50 bg-blue-500/10 pointer-events-none"}`,style:{left:`${c.x}%`,top:`${c.y}%`,width:`${c.width}%`,height:`${c.height}%`,borderRadius:"50%"},onPointerDown:z=>$(z),children:[jsxRuntime.jsx("div",{className:"absolute top-1/2 left-1/2 w-2 h-2 -ml-1 -mt-1 bg-blue-500 rounded-full"}),s==="hotspot"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-1/2 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:z=>$(z,"n")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-1/2 w-4 h-4 -ml-2 -mb-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:z=>$(z,"s")}),jsxRuntime.jsx("div",{className:"absolute top-1/2 left-0 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:z=>$(z,"w")}),jsxRuntime.jsx("div",{className:"absolute top-1/2 right-0 w-4 h-4 -mr-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:z=>$(z,"e")})]})]})})})]})}),O&&jsxRuntime.jsxs("div",{className:"w-[280px] border-l border-[var(--kyro-border)] bg-[var(--kyro-surface)] flex flex-col overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)] tracking-wide uppercase",children:"Preview"})]}),jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-hidden",children:U&&jsxRuntime.jsx("img",{src:U,alt:"Crop preview",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg border border-[var(--kyro-border)]"})}),jsxRuntime.jsxs("div",{className:"px-4 py-3 border-t border-[var(--kyro-border)] text-[10px] text-[var(--kyro-text-secondary)] font-mono",children:[jsxRuntime.jsxs("div",{children:["x: ",l?.x?.toFixed(1),"% y: ",l?.y?.toFixed(1),"%"]}),jsxRuntime.jsxs("div",{children:["w: ",l?.width?.toFixed(1),"% h: ",l?.height?.toFixed(1),"%"]})]})]})]}),jsxRuntime.jsx("div",{className:"p-4 text-center bg-[var(--kyro-surface-accent)] border-t border-[var(--kyro-border)] text-sm text-[var(--kyro-text-secondary)]",children:s==="crop"?"Drag to define the crop area. The preview panel shows the result in real-time.":"Drag the circle to define the focal hotspot. This area will always remain visible when the image is resized."})]})}function Lr(e){if(typeof e!="string"||!e)return "";if(typeof window>"u"||e.startsWith("http")||e.startsWith("blob:"))return e;let t=e.replace(/^\/+/,"/");return `${window.location.origin}${t}`}function In(e,t){if(!e.metadata?.crop)return null;let{x:r,y:o,width:a,height:n}=e.metadata.crop;if(!a||!n||!Lr(e.url))return null;let i=new URLSearchParams({url:e.url});i.set("cx",String(r)),i.set("cy",String(o)),i.set("cw",String(a)),i.set("ch",String(n)),t&&i.set("w",String(t));let l=`/api/media/resize?${i.toString()}`;return typeof window>"u"?l:`${window.location.origin}${l}`}function Bn(e){if(e===0)return "0 B";let t=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,o)).toFixed(1))+" "+r[o]}function cp(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function up(e){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.includes("zip")||e.includes("tar")||e.includes("archive")?"archive":e.includes("pdf")||e.includes("doc")||e.includes("text")?"document":"other"}function En({onSelect:e,multiple:t=true,pickerMode:r=false}){let{t:o}=reactI18next.useTranslation(),{permissions:a}=_r(),n=a?.media?.create!==false,s=a?.media?.delete!==false,i=a?.media?.update!==false,[l,d]=Ta.useState([]),[c,u]=Ta.useState(true),[m,v]=Ta.useState(false),[x,g]=Ta.useState([]),[f,b]=Ta.useState(""),[p,h]=Ta.useState(""),[A,$]=Ta.useState("all"),[T,k]=Ta.useState("grid"),[y,w]=Ta.useState(null),[D,U]=Ta.useState(false),[O,z]=Ta.useState(false),[P,R]=Ta.useState(false),[Ae,E]=Ta.useState({}),[oe,ie]=Ta.useState(false),[ee,G]=Ta.useState(false),[ye,De]=Ta.useState(null),[L,W]=Ta.useState(false),[re,H]=Ta.useState(false),[Te,fe]=Ta.useState(1),[we,S]=Ta.useState(0),[j,xe]=Ta.useState(1),Le=40,[Be,Pe]=Ta.useState(new Set),{confirm:ft,alert:qt}=yt(),[J,M]=Ta.useState(false),K=Ta.useRef(null),le=Ta.useCallback(async C=>{C===1?u(true):v(true);try{let me=new URLSearchParams({page:C.toString(),limit:Le.toString()});f&&me.append("folder",f),p&&me.append("search",p),A!=="all"&&me.append("type",A);let $e=await Ee(Kr(`/api/media?${me}`)),tr=($e.docs||[]).map(Et=>({...Et,type:up(Et.mimeType)}));d(Et=>C===1?tr:[...Et,...tr]),S($e.totalDocs||0),xe($e.totalPages||1);}catch(me){console.error("Failed to load media:",me);}finally{u(false),v(false);}},[f,p,A,Le]),Fe=Ta.useCallback(async()=>{try{let C=await Ee(Kr("/api/media/folders"));g(Array.isArray(C)?C:C.folders||[]);}catch(C){console.error("Failed to load folders:",C);}},[]),Oe=Ta.useCallback(async()=>{try{let me=!!(await Ee("/api/globals/storage-settings"))?.data?.provider;De(me);}catch{De(false);}},[]);Ta.useEffect(()=>{r||Oe();},[Oe,r]),Ta.useEffect(()=>{r||ye===false&&!L&&(W(true),H(true));},[r,ye,L]),Ta.useEffect(()=>{fe(1),le(1);},[f,p,A,le]);let gt=()=>{if(m||Te>=j)return;let C=Te+1;fe(C),le(C);};Ta.useEffect(()=>{Fe();},[Fe]),Ta.useEffect(()=>{if(r)return;let C=me=>{let $e=me.clipboardData?.files;$e&&$e.length>0&&B($e);};return window.addEventListener("paste",C),()=>window.removeEventListener("paste",C)},[r,f,ye]);let B=async C=>{if(!ye){H(true);return}R(true);let me=0,$e=0;for(let tr=0;tr<C.length;tr++){let Et=C[tr];try{let xr=new FormData;xr.append("file",Et),f&&xr.append("folder",f),await sn("/api/media/upload",xr,xs=>{E(Lo=>({...Lo,[Et.name]:xs}));}),me++;}catch(xr){console.error(`Upload failed for ${Et.name}:`,xr),$e++;}}R(false),E({}),fe(1),le(1),Fe(),$e>0&&V.error(`${$e} file(s) failed to upload`),me>0&&V.success(`${me} file(s) uploaded successfully`);},X=()=>{ft({title:"Delete Media",message:`Are you sure you want to delete ${Be.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let C of Array.from(Be))await At(`/api/media/${C}`);Pe(new Set),fe(1),le(1),V.success(`${Be.size} item(s) deleted`);}catch(C){console.error("Bulk delete failed:",C),V.error("Failed to delete some items");}}});},ae=(C,me)=>{me.stopPropagation();let $e=new Set(Be);$e.has(C)?$e.delete(C):(t||$e.clear(),$e.add(C)),Pe($e);},Jt=async C=>{try{await dt("/api/media/folders",{name:C}),Fe(),ie(!1),V.success(`Folder "${C}" created`);}catch(me){console.error("Failed to create folder:",me),V.error("Failed to create folder");}},fo=C=>{ft({title:"Delete Folder",message:`Are you sure you want to delete the folder "${C}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await At(`/api/media/folders?path=${encodeURIComponent(C)}`),f===C&&b(""),Fe(),fe(1),le(1),V.success(`Folder "${C}" deleted`);}catch(me){console.error("Failed to delete folder:",me),V.error("Failed to delete folder");}}});},ka=async(C,me)=>{try{let $e=await Yt(`/api/media/${C}`,me);d(tr=>tr.map(Et=>Et.id===C?$e.doc:Et)),y?.id===C&&w($e.doc),V.success("Metadata updated");}catch($e){console.error("Failed to update metadata:",$e),V.error("Failed to update metadata");}},Za=async(C,me)=>{if(y)try{R(!0);let $e={...y.metadata,crop:C,hotspot:me},tr=await Yt(`/api/media/${y.id}`,{metadata:$e});d(Et=>Et.map(xr=>xr.id===y.id?tr.doc:xr)),w(tr.doc),z(!1),V.success("Crop & hotspot saved");}catch($e){console.error("Save failed:",$e),V.error("Failed to save focal metadata");}finally{R(false);}},bs=Ta.useMemo(()=>l.reduce((C,me)=>(C.totalSize+=me.fileSize||0,C),{totalSize:0}),[l]);return jsxRuntime.jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${J?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:C=>{C.preventDefault(),M(true);},onDragLeave:()=>M(false),onDrop:C=>{C.preventDefault(),M(false),C.dataTransfer.files&&B(C.dataTransfer.files);}},children:[jsxRuntime.jsxs("div",{className:`flex flex-col ${r?"gap-2 p-2":"gap-4 md:gap-6 p-4 md:p-6 rounded-md md:rounded-t-xl surface-tile"} border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 z-10`,children:[!r&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg md:text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[we," Items ",jsxRuntime.jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",Bn(bs.totalSize)]})]})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)] hidden sm:flex",children:[jsxRuntime.jsx("button",{onClick:()=>k("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${T==="grid"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Ql.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>k("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${T==="list"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Ql.File,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("button",{onClick:()=>G(true),className:"md:hidden p-2 rounded-xl bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:jsxRuntime.jsx(Ql.Filter,{className:"w-4 h-4"})}),n&&jsxRuntime.jsxs("button",{onClick:()=>K.current?.click(),className:"flex items-center justify-center gap-2 px-3 md:px-6 py-2 md:py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg active:scale-95 transition-all",children:[jsxRuntime.jsx("span",{className:"md:hidden text-lg leading-none",children:"+"}),jsxRuntime.jsx(Ql.Maximize2,{className:"w-4 h-4 hidden md:block"}),jsxRuntime.jsx("span",{className:"hidden md:inline",children:"Upload"})]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center w-full",children:jsxRuntime.jsxs("div",{className:"relative group flex-1",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:o("fields.searchAssets",{defaultValue:"Search assets..."}),value:p,onChange:C=>h(C.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsxRuntime.jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxRuntime.jsxs("div",{className:"p-6 space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(C=>jsxRuntime.jsxs("button",{onClick:()=>$(C),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${A===C?"text-[var(--kyro-text-primary)] bg-[var(--kyro-surface-accent)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${A===C?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),C]},C))})]}),jsxRuntime.jsxs("div",{className:"pt-6 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>ie(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Ql.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>b(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Ql.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),x.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>b(C),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===C?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Ql.Folder,{fill:f===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),fo(C);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})})]},C))]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxRuntime.jsxs("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${r?"px-2 py-4":"py-4 px-2 md:py-8 md:px-4"}`,children:[c?jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsxRuntime.jsx(jt,{variant:"media-card",count:12})}):l.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsxRuntime.jsx("div",{className:"w-24 h-24 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-8 rotate-12 group-hover:rotate-0 transition-transform duration-500",children:jsxRuntime.jsx(Ql.Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsxRuntime.jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-2 max-w-xs mx-auto text-sm font-medium leading-relaxed",children:"Upload your first file or create a folder to organize your media assets."}),!r&&n&&jsxRuntime.jsx("button",{onClick:()=>K.current?.click(),className:"mt-8 px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-2xl font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Start Uploading"})]}):T==="grid"?jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-1",children:l.map((C,me)=>jsxRuntime.jsxs("div",{className:`group relative aspect-square rounded-lg overflow-hidden bg-[var(--kyro-surface-accent)] border-2 transition-all duration-300 cursor-pointer ${Be.has(C.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>w(C),onContextMenu:$e=>{$e.preventDefault(),ae(C.id,$e);},children:[C.type==="image"?jsxRuntime.jsx("img",{src:In(C,400)||C.url,alt:C.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 gap-4",children:[jsxRuntime.jsx("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface)] shadow-inner text-[var(--kyro-text-secondary)] group-hover:scale-110 transition-transform duration-500",children:C.type==="video"?jsxRuntime.jsx(Ql.Film,{className:"w-8 h-8"}):C.type==="audio"?jsxRuntime.jsx(Ql.Music,{className:"w-8 h-8"}):C.type==="document"?jsxRuntime.jsx(Ql.FileText,{className:"w-8 h-8"}):C.type==="archive"?jsxRuntime.jsx(Ql.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(Ql.File,{className:"w-8 h-8"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:C.title})]}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-[10px] truncate max-w-[120px]",children:C.filename}),jsxRuntime.jsx("div",{className:"flex gap-1",children:jsxRuntime.jsx("button",{onClick:$e=>ae(C.id,$e),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${Be.has(C.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})})})]})}),Be.has(C.id)&&jsxRuntime.jsx("div",{className:"absolute top-3 left-3 w-6 h-6 rounded-lg bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center shadow-lg border-2 border-white/20 animate-in zoom-in duration-300",children:jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})})]},C.id))}):jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden animate-in fade-in duration-500",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-12",children:jsxRuntime.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]",checked:Be.size===l.length,onChange:C=>{C.target.checked?Pe(new Set(l.map(me=>me.id))):Pe(new Set);}})}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Asset"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Type"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Size"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Date"}),jsxRuntime.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:l.map(C=>jsxRuntime.jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${Be.has(C.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>w(C),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:me=>me.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:Be.has(C.id),onChange:me=>ae(C.id,me),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]"})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 rounded-xl bg-[var(--kyro-bg)] overflow-hidden border border-[var(--kyro-border)] flex-shrink-0 flex items-center justify-center",children:C.type==="image"?jsxRuntime.jsx("img",{src:In(C,96)||C.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(Ql.File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[jsxRuntime.jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:C.title||C.filename}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:C.filename})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px]",children:C.mimeType})}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Bn(C.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:cp(C.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),ae(C.id,me);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${Be.has(C.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(Ql.Grid3X3,{className:"w-4 h-4"})})})]},C.id))})]})}),!c&&Te<j&&jsxRuntime.jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsxRuntime.jsx("button",{onClick:gt,disabled:m,className:"px-8 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs hover:scale-105 active:scale-95 transition-all shadow-xl disabled:opacity-50 flex items-center gap-2",children:m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ar,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&P&&jsxRuntime.jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-[2rem] shadow-2xl p-6 ring-1 ring-white/10 animate-in slide-in-from-bottom-12 duration-700",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center animate-pulse",children:jsxRuntime.jsx(ar,{})}),jsxRuntime.jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(Ae).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(Ae).map(([C,me])=>jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] font-bold",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:C}),jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)]",children:[me,"%"]})]}),jsxRuntime.jsx("div",{className:"h-1.5 w-full bg-[var(--kyro-surface-accent)] rounded-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)] transition-all duration-300 rounded-full",style:{width:`${me}%`}})})]},C))})]})}),Be.size>0&&jsxRuntime.jsxs("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-full shadow-2xl px-2 py-2 flex items-center gap-12 animate-in slide-in-from-bottom-12 duration-700 ring-1 ring-white/10 backdrop-blur-xl",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-5 border-r border-[var(--kyro-border)] ",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center text-lg font-bold shadow-inner",children:Be.size}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsxRuntime.jsx("button",{onClick:()=>Pe(new Set),className:"text-[10px] font-bold text-[var(--kyro-primary)] hover:underline opacity-80",children:"Clear all"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[e&&jsxRuntime.jsx("button",{onClick:()=>{let C=l.filter(me=>Be.has(me.id));e(C);},className:"px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-full font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Confirm Selection"}),!r&&s&&jsxRuntime.jsx("button",{onClick:X,className:"p-3 bg-red-500/10 text-red-500 hover:bg-red-500 hover:text-white rounded-full transition-all active:scale-90",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-5 h-5"})})]})]}),ee&&!r&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[70] md:hidden",children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>G(false)}),jsxRuntime.jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-[var(--kyro-surface)] rounded-t-3xl shadow-2xl max-h-[70vh] overflow-y-auto animate-in slide-in-from-bottom-12 duration-300",children:[jsxRuntime.jsxs("div",{className:"sticky top-0 bg-[var(--kyro-surface)] z-10 flex items-center justify-between p-6 pb-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Filters"}),jsxRuntime.jsx("button",{onClick:()=>G(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("div",{className:"p-6 space-y-8",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(C=>jsxRuntime.jsx("button",{onClick:()=>{$(C),G(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${A===C?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] border-transparent":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] border-[var(--kyro-border)] hover:border-[var(--kyro-text-muted)]"}`,children:C},C))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>{ie(true),G(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Ql.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{b(""),G(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Ql.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),x.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{b(C),G(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===C?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Ql.Folder,{fill:f===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),fo(C),G(false);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})})]},C))]})]})]})]})]}),jsxRuntime.jsx(yr,{open:!!y,onClose:()=>w(null),title:o("tooltips.assetDetails",{defaultValue:"Asset Details"}),subtitle:y?.filename,children:y&&jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"aspect-video w-full rounded-2xl bg-[var(--kyro-bg)] border border-[var(--kyro-border)] overflow-hidden relative group",children:[y.type==="image"?jsxRuntime.jsx("img",{src:In(y)||Lr(y.url),alt:"",className:"w-full h-full object-contain p-4"}):y.type==="video"?jsxRuntime.jsx("video",{src:Lr(y.url),controls:true,className:"w-full h-full"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsxRuntime.jsx(Ql.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-xs font-bold",children:y.mimeType})]}),jsxRuntime.jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsxRuntime.jsx("button",{onClick:()=>U(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(Ql.Maximize2,{className:"w-4 h-4"})})})]}),jsxRuntime.jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:y.type==="image"?"Original Resolution":"N/A"})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"File Size"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:Bn(y.fileSize)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Public Link"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{type:"text",readOnly:true,value:Lr(y.url),className:"flex-1 px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-[10px] font-bold font-mono focus:outline-none"}),jsxRuntime.jsx("button",{onClick:()=>{navigator.clipboard.writeText(Lr(y.url)),V.success("URL copied to clipboard");},className:"p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] border border-[var(--kyro-border)] rounded-xl transition-all",children:jsxRuntime.jsx(Ql.Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsxRuntime.jsx("textarea",{value:y.alt||"",onChange:C=>ka(y.id,{alt:C.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.describeThisAsset",{defaultValue:"Describe this asset..."})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Caption"}),jsxRuntime.jsx("textarea",{value:y.caption||"",onChange:C=>ka(y.id,{caption:C.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.addACaption",{defaultValue:"Add a caption..."})})]})]})]})]}),!r&&jsxRuntime.jsxs("div",{className:"pt-8 border-t border-[var(--kyro-border)] mt-8 flex gap-3 pb-8",children:[jsxRuntime.jsxs("button",{onClick:()=>{let C=document.createElement("a");C.href=Lr(y.url),C.download=y.filename,C.click();},className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg hover:opacity-90 transition-all",children:[jsxRuntime.jsx(Ql.Download,{className:"w-4 h-4"}),"Download"]}),y.type==="image"&&i&&jsxRuntime.jsx("button",{onClick:()=>z(true),className:"p-3 border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:jsxRuntime.jsx(Ql.Crop,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{onClick:()=>{ft({title:"Delete Asset",message:`Are you sure you want to delete ${y.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await At(`/api/media/${y.id}`),w(null),le(1);}catch(C){console.error("Delete failed:",C),V.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"})})]})]})}),D&&y&&jsxRuntime.jsxs(St,{open:D,onClose:()=>U(false),title:"",size:"full",variant:"lightbox",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:y.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[Bn(y.fileSize)," \xB7 ",y.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>U(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(Ql.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:y.type==="image"?jsxRuntime.jsx("img",{src:In(y)||Lr(y.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):y.type==="video"?jsxRuntime.jsx("video",{src:Lr(y.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxRuntime.jsxs("div",{className:"text-white text-center",children:[jsxRuntime.jsx(Ql.File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsxRuntime.jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&O&&y&&jsxRuntime.jsx(St,{open:O,onClose:()=>z(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsx(Vl,{url:Lr(y.url),initialCrop:y.metadata?.crop,initialHotspot:y.metadata?.hotspot,onSave:Za,onCancel:()=>z(false),isSaving:P})}),!r&&jsxRuntime.jsx(Ll,{open:oe,onClose:()=>ie(false),onSubmit:Jt,title:o("tooltips.createNewFolder",{defaultValue:"Create New Folder"}),placeholder:o("fields.folderName",{defaultValue:"Folder name"})}),!r&&jsxRuntime.jsx(St,{open:re,onClose:()=>H(false),title:o("tooltips.storageNotConfigured",{defaultValue:"Storage Not Configured"}),size:"md",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--kyro-sidebar-active)] flex items-center justify-center",children:jsxRuntime.jsx(Ql.Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mb-6 text-sm",children:"Before uploading media, you need to configure your storage settings. Choose where files should be stored and how URLs are generated."}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsx("a",{href:`${Ue}/settings/storage-settings`,className:"flex-1 px-4 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-center hover:opacity-90 transition-colors",children:"Configure Storage"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{dt("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{H(false),De(true),window.location.reload();}).catch(()=>{V.error("Failed to configure storage");});},className:"flex-1 px-4 py-3 border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded-xl font-bold hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Use Defaults"})]})]})}),!r&&jsxRuntime.jsx("input",{type:"file",ref:K,onChange:C=>{C.target.files&&B(C.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var Up=[{name:"Default",value:"inherit"},{name:"Red",value:"#ef4444"},{name:"Orange",value:"#f97316"},{name:"Amber",value:"#f59e0b"},{name:"Emerald",value:"#10b981"},{name:"Blue",value:"#3b82f6"},{name:"Indigo",value:"#6366f1"},{name:"Violet",value:"#8b5cf6"},{name:"Rose",value:"#f43f5e"},{name:"Slate",value:"#64748b"}],ql=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let{t:a}=reactI18next.useTranslation(),[n,s]=Ta.useState(null),i=Ta.useRef(null);if(Ta.useEffect(()=>{function p(h){i.current&&!i.current.contains(h.target)&&s(null);}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]),!e)return null;let l=()=>{o();},d=()=>{let p=e.getAttributes("link").href,h=window.prompt("URL",p);if(h!==null){if(h===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:h}).run();}},c=p=>{p==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(p).run(),s(null);},u=p=>{s(n===p?null:p);},m=()=>e.isActive("heading",{level:1})?"Heading 1":e.isActive("heading",{level:2})?"Heading 2":e.isActive("heading",{level:3})?"Heading 3":e.isActive("heading",{level:4})?"Heading 4":"Normal Text",v=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(Ql.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(Ql.AlignRight,{size:12}):jsxRuntime.jsx(Ql.AlignLeft,{size:12}),x=()=>e.isActive("orderedList")?jsxRuntime.jsx(Ql.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(Ql.CheckSquare,{size:12}):jsxRuntime.jsx(Ql.List,{size:12}),g=()=>e.isActive("codeBlock")?jsxRuntime.jsx(Ql.Terminal,{size:12}):jsxRuntime.jsx(Ql.Quote,{size:12}),f=({onClick:p,isActive:h=false,disabled:A=false,children:$,title:T})=>jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:A,title:T,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
10
- ${h?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xs scale-95":"text-[var(--kyro-text)] hover:bg-[var(--kyro-bg-hover)]"}
11
- ${A?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:$}),b=({onClick:p,isActive:h,children:A,title:$})=>jsxRuntime.jsxs("button",{type:"button",onClick:p,title:$,className:`px-2 py-1 rounded flex items-center gap-1 transition-all duration-150 text-xs border border-transparent hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] active:scale-98
12
- ${h?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[A,jsxRuntime.jsx(Ql.ChevronDown,{size:10,className:"opacity-60"})]});return jsxRuntime.jsxs("div",{ref:i,className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg select-none",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().chain().focus().undo().run(),title:a("tooltips.undoCtrlz",{defaultValue:"Undo (Ctrl+Z)"}),children:jsxRuntime.jsx(Ql.Undo,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().chain().focus().redo().run(),title:a("tooltips.redoCtrly",{defaultValue:"Redo (Ctrl+Y)"}),children:jsxRuntime.jsx(Ql.Redo,{size:12})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleBold().run(),disabled:!e.can().chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:a("tooltips.boldCtrlb",{defaultValue:"Bold (Ctrl+B)"}),children:jsxRuntime.jsx(Ql.Bold,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleItalic().run(),disabled:!e.can().chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:a("tooltips.italicCtrli",{defaultValue:"Italic (Ctrl+I)"}),children:jsxRuntime.jsx(Ql.Italic,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleUnderline().run(),disabled:!e.can().chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:a("tooltips.underlineCtrlu",{defaultValue:"Underline (Ctrl+U)"}),children:jsxRuntime.jsx(Ql.Underline,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleStrike().run(),disabled:!e.can().chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:a("tooltips.strikethrough",{defaultValue:"Strikethrough"}),children:jsxRuntime.jsx(Ql.Strikethrough,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleCode().run(),disabled:!e.can().chain().focus().toggleCode().run(),isActive:e.isActive("code"),title:a("tooltips.inlineCode",{defaultValue:"Inline Code"}),children:jsxRuntime.jsx(Ql.Code,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:a("tooltips.highlightText",{defaultValue:"Highlight Text"}),children:jsxRuntime.jsx(Ql.Highlighter,{size:12})}),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center",children:[jsxRuntime.jsx(f,{onClick:()=>u("color"),title:a("tooltips.textColor",{defaultValue:"Text Color"}),isActive:n==="color"||e.isActive("textStyle"),children:jsxRuntime.jsx(Ql.Palette,{size:12})}),n==="color"&&jsxRuntime.jsx("div",{className:"absolute top-full left-0 mt-1.5 p-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 flex flex-wrap gap-1 w-44 animate-in fade-in slide-in-from-top-1 duration-150",children:Up.map(p=>jsxRuntime.jsx("button",{type:"button",onClick:()=>c(p.value),title:p.name,className:"w-6 h-6 rounded-full border border-[var(--kyro-border)] transition-transform hover:scale-115 active:scale-95 cursor-pointer relative",style:{backgroundColor:p.value==="inherit"?"transparent":p.value},children:p.value==="inherit"&&jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] text-[var(--kyro-text)] font-semibold",children:"\u2205"})},p.name))})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("heading"),isActive:n==="heading",title:a("tooltips.headingHierarchy",{defaultValue:"Heading hierarchy"}),children:jsxRuntime.jsx("span",{className:"font-medium text-[11px] leading-none min-w-[70px] text-left",children:m()})}),n==="heading"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{e.chain().focus().setParagraph().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
13
- ${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(p=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:p}).run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
14
- ${e.isActive("heading",{level:p})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",p]},p))]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("lists"),isActive:n==="lists",title:a("tooltips.listTypes",{defaultValue:"List Types"}),children:x()}),n==="lists"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBulletList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
15
- ${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.List,{size:12}),"Bullet List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleOrderedList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
16
- ${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.ListOrdered,{size:12}),"Ordered List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleTaskList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
17
- ${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.CheckSquare,{size:12}),"Task Checklist"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("blocks"),isActive:n==="blocks",title:a("tooltips.structuralBlocks",{defaultValue:"Structural Blocks"}),children:g()}),n==="blocks"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBlockquote().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
18
- ${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.Quote,{size:12}),"Blockquote"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleCodeBlock().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
19
- ${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.Terminal,{size:12}),"Code Block"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),s(null);},className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors",children:[jsxRuntime.jsx(Ql.Minus,{size:12}),"Horizontal Rule"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("align"),isActive:n==="align",title:a("tooltips.alignment",{defaultValue:"Alignment"}),children:v()}),n==="align"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-32 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("left").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
20
- ${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.AlignLeft,{size:12}),"Align Left"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("center").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
21
- ${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.AlignCenter,{size:12}),"Align Center"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("right").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
22
- ${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.AlignRight,{size:12}),"Align Right"]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(f,{onClick:d,isActive:e.isActive("link"),title:a("tooltips.link",{defaultValue:"Link"}),children:jsxRuntime.jsx(Ql.Link,{size:12})}),jsxRuntime.jsx(f,{onClick:l,title:a("tooltips.addImage",{defaultValue:"Add Image"}),children:jsxRuntime.jsx(Ql.Image,{size:12})})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs ml-auto",children:jsxRuntime.jsx(f,{onClick:()=>r(!t),title:t?"Collapse Workspace":"Enlarge Workspace",children:t?jsxRuntime.jsx(Ql.Minimize2,{size:12}):jsxRuntime.jsx(Ql.Maximize2,{size:12})})})]})};function Wo({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false);return Ta.useEffect(()=>{s(true);},[]),n?jsxRuntime.jsx(jp,{field:e,value:t,onChange:r,error:o,disabled:a}):jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
9
+ `})]}),document.body)}function Rr({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function zr({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function Tt({open:e,onClose:t,title:r,children:o,footer:a,size:n="lg",variant:s="default"}){if(oa.useEffect(()=>{let d=c=>{c.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="";}},[e,t]),!e)return null;let i={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl",full:"w-full h-full max-w-none rounded-none border-0"},l=s==="lightbox";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[jsxRuntime.jsx("div",{className:`absolute inset-0 transition-all duration-500 ${l?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxRuntime.jsxs("div",{className:`relative ${i[n]} ${l?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!l&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${l?"":"border"} ${s==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!l&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-8 py-6 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50 backdrop-blur-md",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-2 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-xl hover:bg-[var(--kyro-surface)] transition-all duration-200",children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:`flex-1 overflow-auto ${l?"":"px-8 py-8"}`,children:o}),a&&!l&&jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 px-8 py-6 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50",children:a})]})]}),document.body)}function Li({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:s="Cancel",variant:i="default",loading:l=false}){return jsxRuntime.jsx(Tt,{open:e,onClose:t,title:o,size:"sm",footer:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:l,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:s}),jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:l,className:`kyro-btn kyro-btn-md ${i==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:l?"Loading...":n})]}),children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function lc({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,i]=oa.useState(n),l=d=>{d.preventDefault(),s.trim()&&(r(s.trim()),i(""),t());};return e?reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-[var(--kyro-surface)] rounded-lg shadow-2xl animate-in fade-in zoom-in-95 duration-200 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-[var(--kyro-text-primary)]",children:o}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-lg hover:bg-[var(--kyro-surface-accent)] transition-colors",children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:l,children:[jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsx("input",{type:"text",value:s,onChange:d=>i(d.target.value),placeholder:a,autoFocus:true,className:"w-full px-3 py-2 border border-[var(--kyro-input-border)] rounded-lg bg-[var(--kyro-input-bg)] text-[var(--kyro-text-primary)] placeholder-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] rounded-b-lg",children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-lg font-medium text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",disabled:!s.trim(),className:"px-4 py-2 rounded-lg font-medium text-sm bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] hover:opacity-90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Confirm"})]})]})]})]}),document.body):null}function cc({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[s,i]=oa.useState("crop"),[l,d]=oa.useState(t?{unit:"%",...t}:void 0),[c,u]=oa.useState(r||{x:40,y:40,width:20,height:20}),[p,f]=oa.useState(!!r),y=oa.useRef(null),g=oa.useRef(null),[v,h]=oa.useState(false),[m,w]=oa.useState(null),C=oa.useRef(null),E=(I,P)=>{s==="hotspot"&&(I.stopPropagation(),I.preventDefault(),P?w(P):h(true),C.current={x:I.clientX,y:I.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},D=oa.useCallback(I=>{if(!C.current||!y.current)return;let P=y.current.getBoundingClientRect(),R=(I.clientX-C.current.x)/P.width*100,fe=(I.clientY-C.current.y)/P.height*100,L=C.current;if(v){let re=L.hX+R,ne=L.hY+fe;re=Math.max(0,Math.min(re,100-L.hW)),ne=Math.max(0,Math.min(ne,100-L.hH)),u(ee=>({...ee,x:re,y:ne}));}else if(m){let re=L.hX,ne=L.hY,ee=L.hW,H=L.hH;m.includes("e")&&(ee=L.hW+R),m.includes("w")&&(re=L.hX+R,ee=L.hW-R),m.includes("s")&&(H=L.hH+fe),m.includes("n")&&(ne=L.hY+fe,H=L.hH-fe),ee<5&&(ee=5,m.includes("w")&&(re=L.hX+L.hW-5)),H<5&&(H=5,m.includes("n")&&(ne=L.hY+L.hH-5)),re=Math.max(0,Math.min(re,100-ee)),ne=Math.max(0,Math.min(ne,100-H)),ee=Math.min(ee,100-re),H=Math.min(H,100-ne),u({x:re,y:ne,width:ee,height:H});}},[v,m,c]),k=oa.useCallback(()=>{h(false),w(null),C.current=null;},[]);oa.useEffect(()=>((v||m)&&(window.addEventListener("pointermove",D),window.addEventListener("pointerup",k)),()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",k);}),[v,m,D,k]);let b=I=>{},x=()=>{let I=l?.width&&l?.height?{x:l.x,y:l.y,width:l.width,height:l.height}:void 0;o(I,p?c:void 0);},N=()=>{d(void 0),f(false);},O=oa.useMemo(()=>{if(!l||!l.width||!l.height)return null;let I=new URLSearchParams({url:e});return I.set("cx",String(l.x)),I.set("cy",String(l.y)),I.set("cw",String(l.width)),I.set("ch",String(l.height)),`/api/media/resize?${I.toString()}`},[e,l]),M=l?.width&&l.height;return jsxRuntime.jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("button",{onClick:()=>i("crop"),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="crop"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Nc.Crop,{className:"w-4 h-4"}),"Crop"]}),jsxRuntime.jsxs("button",{onClick:()=>{i("hotspot"),p||f(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Nc.MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("button",{onClick:N,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:[jsxRuntime.jsx(Nc.RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{onClick:x,disabled:n,className:"flex items-center justify-center min-w-[120px] px-6 py-2 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] text-sm font-bold rounded-lg shadow-lg hover:opacity-90 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",children:n?jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4 text-current",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):"Save Edits"})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxRuntime.jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:g,children:[jsxRuntime.jsx(Rf__default.default,{crop:l,onChange:(I,P)=>d(P),locked:s==="hotspot",className:s==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsxRuntime.jsx("img",{ref:y,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:b})}),p&&y.current&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"relative",style:{width:y.current.width,height:y.current.height},children:jsxRuntime.jsxs("div",{className:`absolute border-2 shadow-2xl transition-colors duration-200 ${s==="hotspot"?"border-blue-500 bg-blue-500/20 cursor-move pointer-events-auto shadow-blue-500/50":"border-blue-500/50 bg-blue-500/10 pointer-events-none"}`,style:{left:`${c.x}%`,top:`${c.y}%`,width:`${c.width}%`,height:`${c.height}%`,borderRadius:"50%"},onPointerDown:I=>E(I),children:[jsxRuntime.jsx("div",{className:"absolute top-1/2 left-1/2 w-2 h-2 -ml-1 -mt-1 bg-blue-500 rounded-full"}),s==="hotspot"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-1/2 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:I=>E(I,"n")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-1/2 w-4 h-4 -ml-2 -mb-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:I=>E(I,"s")}),jsxRuntime.jsx("div",{className:"absolute top-1/2 left-0 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:I=>E(I,"w")}),jsxRuntime.jsx("div",{className:"absolute top-1/2 right-0 w-4 h-4 -mr-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:I=>E(I,"e")})]})]})})})]})}),M&&jsxRuntime.jsxs("div",{className:"w-[280px] border-l border-[var(--kyro-border)] bg-[var(--kyro-surface)] flex flex-col overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx(Nc.Eye,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)] tracking-wide uppercase",children:"Preview"})]}),jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-hidden",children:O&&jsxRuntime.jsx("img",{src:O,alt:"Crop preview",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg border border-[var(--kyro-border)]"})}),jsxRuntime.jsxs("div",{className:"px-4 py-3 border-t border-[var(--kyro-border)] text-[10px] text-[var(--kyro-text-secondary)] font-mono",children:[jsxRuntime.jsxs("div",{children:["x: ",l?.x?.toFixed(1),"% y: ",l?.y?.toFixed(1),"%"]}),jsxRuntime.jsxs("div",{children:["w: ",l?.width?.toFixed(1),"% h: ",l?.height?.toFixed(1),"%"]})]})]})]}),jsxRuntime.jsx("div",{className:"p-4 text-center bg-[var(--kyro-surface-accent)] border-t border-[var(--kyro-border)] text-sm text-[var(--kyro-text-secondary)]",children:s==="crop"?"Drag to define the crop area. The preview panel shows the result in real-time.":"Drag the circle to define the focal hotspot. This area will always remain visible when the image is resized."})]})}function Hr(e){if(typeof e!="string"||!e)return "";if(typeof window>"u"||e.startsWith("http")||e.startsWith("blob:"))return e;let t=e.replace(/^\/+/,"/");return `${window.location.origin}${t}`}function ms(e,t){if(!e.metadata?.crop)return null;let{x:r,y:o,width:a,height:n}=e.metadata.crop;if(!a||!n||!Hr(e.url))return null;let i=new URLSearchParams({url:e.url});i.set("cx",String(r)),i.set("cy",String(o)),i.set("cw",String(a)),i.set("ch",String(n)),t&&i.set("w",String(t));let l=`/api/media/resize?${i.toString()}`;return typeof window>"u"?l:`${window.location.origin}${l}`}function fs(e){if(e===0)return "0 B";let t=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,o)).toFixed(1))+" "+r[o]}function Ef(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Mf(e){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.includes("zip")||e.includes("tar")||e.includes("archive")?"archive":e.includes("pdf")||e.includes("doc")||e.includes("text")?"document":"other"}function ys({onSelect:e,multiple:t=true,pickerMode:r=false}){let{t:o}=z(),{permissions:a}=Yr(),n=a?.media?.create!==false,s=a?.media?.delete!==false,i=a?.media?.update!==false,[l,d]=oa.useState([]),[c,u]=oa.useState(true),[p,f]=oa.useState(false),[y,g]=oa.useState([]),[v,h]=oa.useState(""),[m,w]=oa.useState(""),[C,E]=oa.useState("all"),[D,k]=oa.useState("grid"),[b,x]=oa.useState(null),[N,O]=oa.useState(false),[M,I]=oa.useState(false),[P,R]=oa.useState(false),[fe,L]=oa.useState({}),[re,ne]=oa.useState(false),[ee,H]=oa.useState(false),[pe,be]=oa.useState(null),[V,q]=oa.useState(false),[ae,K]=oa.useState(false),[Re,he]=oa.useState(1),[Ae,T]=oa.useState(0),[_,Ne]=oa.useState(1),Oe=40,[Me,Fe]=oa.useState(new Set),{confirm:vt,alert:Yt}=gt(),[X,j]=oa.useState(false),W=oa.useRef(null),de=oa.useCallback(async A=>{A===1?u(true):f(true);try{let ge=new URLSearchParams({page:A.toString(),limit:Oe.toString()});v&&ge.append("folder",v),m&&ge.append("search",m),C!=="all"&&ge.append("type",C);let Ve=await Be(Qr(`/api/media?${ge}`)),ar=(Ve.docs||[]).map($t=>({...$t,type:Mf($t.mimeType)}));d($t=>A===1?ar:[...$t,...ar]),T(Ve.totalDocs||0),Ne(Ve.totalPages||1);}catch(ge){console.error("Failed to load media:",ge);}finally{u(false),f(false);}},[v,m,C,Oe]),Ie=oa.useCallback(async()=>{try{let A=await Be(Qr("/api/media/folders"));g(Array.isArray(A)?A:A.folders||[]);}catch(A){console.error("Failed to load folders:",A);}},[]),Ue=oa.useCallback(async()=>{try{let ge=!!(await Be("/api/globals/storage-settings"))?.data?.provider;be(ge);}catch{be(false);}},[]);oa.useEffect(()=>{r||Ue();},[Ue,r]),oa.useEffect(()=>{r||pe===false&&!V&&(q(true),K(true));},[r,pe,V]),oa.useEffect(()=>{he(1),de(1);},[v,m,C,de]);let bt=()=>{if(p||Re>=_)return;let A=Re+1;he(A),de(A);};oa.useEffect(()=>{Ie();},[Ie]),oa.useEffect(()=>{if(r)return;let A=ge=>{let Ve=ge.clipboardData?.files;Ve&&Ve.length>0&&$(Ve);};return window.addEventListener("paste",A),()=>window.removeEventListener("paste",A)},[r,v,pe]);let $=async A=>{if(!pe){K(true);return}R(true);let ge=0,Ve=0;for(let ar=0;ar<A.length;ar++){let $t=A[ar];try{let Cr=new FormData;Cr.append("file",$t),v&&Cr.append("folder",v),await Tn("/api/media/upload",Cr,ei=>{L(Go=>({...Go,[$t.name]:ei}));}),ge++;}catch(Cr){console.error(`Upload failed for ${$t.name}:`,Cr),Ve++;}}R(false),L({}),he(1),de(1),Ie(),Ve>0&&U.error(`${Ve} file(s) failed to upload`),ge>0&&U.success(`${ge} file(s) uploaded successfully`);},Y=()=>{vt({title:"Delete Media",message:`Are you sure you want to delete ${Me.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let A of Array.from(Me))await Dt(`/api/media/${A}`);Fe(new Set),he(1),de(1),U.success(`${Me.size} item(s) deleted`);}catch(A){console.error("Bulk delete failed:",A),U.error("Failed to delete some items");}}});},se=(A,ge)=>{ge.stopPropagation();let Ve=new Set(Me);Ve.has(A)?Ve.delete(A):(t||Ve.clear(),Ve.add(A)),Fe(Ve);},Qt=async A=>{try{await ut("/api/media/folders",{name:A}),Ie(),ne(!1),U.success(`Folder "${A}" created`);}catch(ge){console.error("Failed to create folder:",ge),U.error("Failed to create folder");}},Co=A=>{vt({title:"Delete Folder",message:`Are you sure you want to delete the folder "${A}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await Dt(`/api/media/folders?path=${encodeURIComponent(A)}`),v===A&&h(""),Ie(),he(1),de(1),U.success(`Folder "${A}" deleted`);}catch(ge){console.error("Failed to delete folder:",ge),U.error("Failed to delete folder");}}});},Ma=async(A,ge)=>{try{let Ve=await er(`/api/media/${A}`,ge);d(ar=>ar.map($t=>$t.id===A?Ve.doc:$t)),b?.id===A&&x(Ve.doc),U.success("Metadata updated");}catch(Ve){console.error("Failed to update metadata:",Ve),U.error("Failed to update metadata");}},xn=async(A,ge)=>{if(b)try{R(!0);let Ve={...b.metadata,crop:A,hotspot:ge},ar=await er(`/api/media/${b.id}`,{metadata:Ve});d($t=>$t.map(Cr=>Cr.id===b.id?ar.doc:Cr)),x(ar.doc),I(!1),U.success("Crop & hotspot saved");}catch(Ve){console.error("Save failed:",Ve),U.error("Failed to save focal metadata");}finally{R(false);}},Zs=oa.useMemo(()=>l.reduce((A,ge)=>(A.totalSize+=ge.fileSize||0,A),{totalSize:0}),[l]);return jsxRuntime.jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${X?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:A=>{A.preventDefault(),j(true);},onDragLeave:()=>j(false),onDrop:A=>{A.preventDefault(),j(false),A.dataTransfer.files&&$(A.dataTransfer.files);}},children:[jsxRuntime.jsxs("div",{className:`flex flex-col ${r?"gap-2 p-2":"gap-4 md:gap-6 p-4 md:p-6 rounded-md md:rounded-t-xl surface-tile"} border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 z-10`,children:[!r&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg md:text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[Ae," Items ",jsxRuntime.jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",fs(Zs.totalSize)]})]})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)] hidden sm:flex",children:[jsxRuntime.jsx("button",{onClick:()=>k("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${D==="grid"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Nc.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>k("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${D==="list"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Nc.File,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("button",{onClick:()=>H(true),className:"md:hidden p-2 rounded-xl bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:jsxRuntime.jsx(Nc.Filter,{className:"w-4 h-4"})}),n&&jsxRuntime.jsxs("button",{onClick:()=>W.current?.click(),className:"flex items-center justify-center gap-2 px-3 md:px-6 py-2 md:py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg active:scale-95 transition-all",children:[jsxRuntime.jsx("span",{className:"md:hidden text-lg leading-none",children:"+"}),jsxRuntime.jsx(Nc.Maximize2,{className:"w-4 h-4 hidden md:block"}),jsxRuntime.jsx("span",{className:"hidden md:inline",children:"Upload"})]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center w-full",children:jsxRuntime.jsxs("div",{className:"relative group flex-1",children:[jsxRuntime.jsx(Nc.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:o("fields.searchAssets",{defaultValue:"Search assets..."}),value:m,onChange:A=>w(A.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsxRuntime.jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxRuntime.jsxs("div",{className:"p-6 space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(A=>jsxRuntime.jsxs("button",{onClick:()=>E(A),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${C===A?"text-[var(--kyro-text-primary)] bg-[var(--kyro-surface-accent)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C===A?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),A]},A))})]}),jsxRuntime.jsxs("div",{className:"pt-6 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>ne(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Nc.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>h(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Nc.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),y.map(A=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>h(A),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===A?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Nc.Folder,{fill:v===A?"currentColor":"none"})}),A]}),jsxRuntime.jsx("button",{onClick:ge=>{ge.stopPropagation(),Co(A);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(Nc.Trash2,{className:"w-3.5 h-3.5"})})]},A))]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxRuntime.jsxs("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${r?"px-2 py-4":"py-4 px-2 md:py-8 md:px-4"}`,children:[c?jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsxRuntime.jsx(Kt,{variant:"media-card",count:12})}):l.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsxRuntime.jsx("div",{className:"w-24 h-24 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-8 rotate-12 group-hover:rotate-0 transition-transform duration-500",children:jsxRuntime.jsx(Nc.Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsxRuntime.jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-2 max-w-xs mx-auto text-sm font-medium leading-relaxed",children:"Upload your first file or create a folder to organize your media assets."}),!r&&n&&jsxRuntime.jsx("button",{onClick:()=>W.current?.click(),className:"mt-8 px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-2xl font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Start Uploading"})]}):D==="grid"?jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-1",children:l.map((A,ge)=>jsxRuntime.jsxs("div",{className:`group relative aspect-square rounded-lg overflow-hidden bg-[var(--kyro-surface-accent)] border-2 transition-all duration-300 cursor-pointer ${Me.has(A.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>x(A),onContextMenu:Ve=>{Ve.preventDefault(),se(A.id,Ve);},children:[A.type==="image"?jsxRuntime.jsx("img",{src:ms(A,400)||A.url,alt:A.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 gap-4",children:[jsxRuntime.jsx("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface)] shadow-inner text-[var(--kyro-text-secondary)] group-hover:scale-110 transition-transform duration-500",children:A.type==="video"?jsxRuntime.jsx(Nc.Film,{className:"w-8 h-8"}):A.type==="audio"?jsxRuntime.jsx(Nc.Music,{className:"w-8 h-8"}):A.type==="document"?jsxRuntime.jsx(Nc.FileText,{className:"w-8 h-8"}):A.type==="archive"?jsxRuntime.jsx(Nc.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(Nc.File,{className:"w-8 h-8"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:A.title})]}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-[10px] truncate max-w-[120px]",children:A.filename}),jsxRuntime.jsx("div",{className:"flex gap-1",children:jsxRuntime.jsx("button",{onClick:Ve=>se(A.id,Ve),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${Me.has(A.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(Nc.Check,{className:"w-4 h-4"})})})]})}),Me.has(A.id)&&jsxRuntime.jsx("div",{className:"absolute top-3 left-3 w-6 h-6 rounded-lg bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center shadow-lg border-2 border-white/20 animate-in zoom-in duration-300",children:jsxRuntime.jsx(Nc.Check,{className:"w-4 h-4"})})]},A.id))}):jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden animate-in fade-in duration-500",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-12",children:jsxRuntime.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]",checked:Me.size===l.length,onChange:A=>{A.target.checked?Fe(new Set(l.map(ge=>ge.id))):Fe(new Set);}})}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Asset"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Type"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Size"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Date"}),jsxRuntime.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:l.map(A=>jsxRuntime.jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${Me.has(A.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>x(A),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:ge=>ge.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:Me.has(A.id),onChange:ge=>se(A.id,ge),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]"})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 rounded-xl bg-[var(--kyro-bg)] overflow-hidden border border-[var(--kyro-border)] flex-shrink-0 flex items-center justify-center",children:A.type==="image"?jsxRuntime.jsx("img",{src:ms(A,96)||A.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(Nc.File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[jsxRuntime.jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:A.title||A.filename}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:A.filename})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsx(Lt,{variant:"outline",className:"text-[9px]",children:A.mimeType})}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:fs(A.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Ef(A.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:ge=>{ge.stopPropagation(),se(A.id,ge);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${Me.has(A.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(Nc.Grid3X3,{className:"w-4 h-4"})})})]},A.id))})]})}),!c&&Re<_&&jsxRuntime.jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsxRuntime.jsx("button",{onClick:bt,disabled:p,className:"px-8 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs hover:scale-105 active:scale-95 transition-all shadow-xl disabled:opacity-50 flex items-center gap-2",children:p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ir,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&P&&jsxRuntime.jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-[2rem] shadow-2xl p-6 ring-1 ring-white/10 animate-in slide-in-from-bottom-12 duration-700",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center animate-pulse",children:jsxRuntime.jsx(ir,{})}),jsxRuntime.jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(fe).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(fe).map(([A,ge])=>jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] font-bold",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:A}),jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)]",children:[ge,"%"]})]}),jsxRuntime.jsx("div",{className:"h-1.5 w-full bg-[var(--kyro-surface-accent)] rounded-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)] transition-all duration-300 rounded-full",style:{width:`${ge}%`}})})]},A))})]})}),Me.size>0&&jsxRuntime.jsxs("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-full shadow-2xl px-2 py-2 flex items-center gap-12 animate-in slide-in-from-bottom-12 duration-700 ring-1 ring-white/10 backdrop-blur-xl",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-5 border-r border-[var(--kyro-border)] ",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center text-lg font-bold shadow-inner",children:Me.size}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsxRuntime.jsx("button",{onClick:()=>Fe(new Set),className:"text-[10px] font-bold text-[var(--kyro-primary)] hover:underline opacity-80",children:"Clear all"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[e&&jsxRuntime.jsx("button",{onClick:()=>{let A=l.filter(ge=>Me.has(ge.id));e(A);},className:"px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-full font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Confirm Selection"}),!r&&s&&jsxRuntime.jsx("button",{onClick:Y,className:"p-3 bg-red-500/10 text-red-500 hover:bg-red-500 hover:text-white rounded-full transition-all active:scale-90",children:jsxRuntime.jsx(Nc.Trash2,{className:"w-5 h-5"})})]})]}),ee&&!r&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[70] md:hidden",children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>H(false)}),jsxRuntime.jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-[var(--kyro-surface)] rounded-t-3xl shadow-2xl max-h-[70vh] overflow-y-auto animate-in slide-in-from-bottom-12 duration-300",children:[jsxRuntime.jsxs("div",{className:"sticky top-0 bg-[var(--kyro-surface)] z-10 flex items-center justify-between p-6 pb-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Filters"}),jsxRuntime.jsx("button",{onClick:()=>H(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("div",{className:"p-6 space-y-8",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(A=>jsxRuntime.jsx("button",{onClick:()=>{E(A),H(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${C===A?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] border-transparent":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] border-[var(--kyro-border)] hover:border-[var(--kyro-text-muted)]"}`,children:A},A))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>{ne(true),H(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Nc.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{h(""),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Nc.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),y.map(A=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{h(A),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===A?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Nc.Folder,{fill:v===A?"currentColor":"none"})}),A]}),jsxRuntime.jsx("button",{onClick:ge=>{ge.stopPropagation(),Co(A),H(false);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(Nc.Trash2,{className:"w-3.5 h-3.5"})})]},A))]})]})]})]})]}),jsxRuntime.jsx(hr,{open:!!b,onClose:()=>x(null),title:o("tooltips.assetDetails",{defaultValue:"Asset Details"}),subtitle:b?.filename,children:b&&jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"aspect-video w-full rounded-2xl bg-[var(--kyro-bg)] border border-[var(--kyro-border)] overflow-hidden relative group",children:[b.type==="image"?jsxRuntime.jsx("img",{src:ms(b)||Hr(b.url),alt:"",className:"w-full h-full object-contain p-4"}):b.type==="video"?jsxRuntime.jsx("video",{src:Hr(b.url),controls:true,className:"w-full h-full"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsxRuntime.jsx(Nc.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(Lt,{variant:"outline",className:"text-xs font-bold",children:b.mimeType})]}),jsxRuntime.jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsxRuntime.jsx("button",{onClick:()=>O(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(Nc.Maximize2,{className:"w-4 h-4"})})})]}),jsxRuntime.jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:b.type==="image"?"Original Resolution":"N/A"})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"File Size"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:fs(b.fileSize)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Public Link"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{type:"text",readOnly:true,value:Hr(b.url),className:"flex-1 px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-[10px] font-bold font-mono focus:outline-none"}),jsxRuntime.jsx("button",{onClick:()=>{navigator.clipboard.writeText(Hr(b.url)),U.success("URL copied to clipboard");},className:"p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] border border-[var(--kyro-border)] rounded-xl transition-all",children:jsxRuntime.jsx(Nc.Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsxRuntime.jsx("textarea",{value:b.alt||"",onChange:A=>Ma(b.id,{alt:A.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.describeThisAsset",{defaultValue:"Describe this asset..."})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Caption"}),jsxRuntime.jsx("textarea",{value:b.caption||"",onChange:A=>Ma(b.id,{caption:A.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.addACaption",{defaultValue:"Add a caption..."})})]})]})]})]}),!r&&jsxRuntime.jsxs("div",{className:"pt-8 border-t border-[var(--kyro-border)] mt-8 flex gap-3 pb-8",children:[jsxRuntime.jsxs("button",{onClick:()=>{let A=document.createElement("a");A.href=Hr(b.url),A.download=b.filename,A.click();},className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg hover:opacity-90 transition-all",children:[jsxRuntime.jsx(Nc.Download,{className:"w-4 h-4"}),"Download"]}),b.type==="image"&&i&&jsxRuntime.jsx("button",{onClick:()=>I(true),className:"p-3 border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:jsxRuntime.jsx(Nc.Crop,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{onClick:()=>{vt({title:"Delete Asset",message:`Are you sure you want to delete ${b.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`/api/media/${b.id}`),x(null),de(1);}catch(A){console.error("Delete failed:",A),U.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsxRuntime.jsx(Nc.Trash2,{className:"w-4 h-4"})})]})]})}),N&&b&&jsxRuntime.jsxs(Tt,{open:N,onClose:()=>O(false),title:"",size:"full",variant:"lightbox",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:b.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[fs(b.fileSize)," \xB7 ",b.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>O(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(Nc.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:b.type==="image"?jsxRuntime.jsx("img",{src:ms(b)||Hr(b.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):b.type==="video"?jsxRuntime.jsx("video",{src:Hr(b.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxRuntime.jsxs("div",{className:"text-white text-center",children:[jsxRuntime.jsx(Nc.File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsxRuntime.jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&M&&b&&jsxRuntime.jsx(Tt,{open:M,onClose:()=>I(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsx(cc,{url:Hr(b.url),initialCrop:b.metadata?.crop,initialHotspot:b.metadata?.hotspot,onSave:xn,onCancel:()=>I(false),isSaving:P})}),!r&&jsxRuntime.jsx(lc,{open:re,onClose:()=>ne(false),onSubmit:Qt,title:o("tooltips.createNewFolder",{defaultValue:"Create New Folder"}),placeholder:o("fields.folderName",{defaultValue:"Folder name"})}),!r&&jsxRuntime.jsx(Tt,{open:ae,onClose:()=>K(false),title:o("tooltips.storageNotConfigured",{defaultValue:"Storage Not Configured"}),size:"md",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--kyro-sidebar-active)] flex items-center justify-center",children:jsxRuntime.jsx(Nc.Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mb-6 text-sm",children:"Before uploading media, you need to configure your storage settings. Choose where files should be stored and how URLs are generated."}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsx("a",{href:`${He}/settings/storage-settings`,className:"flex-1 px-4 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-center hover:opacity-90 transition-colors",children:"Configure Storage"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{ut("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{K(false),be(true),window.location.reload();}).catch(()=>{U.error("Failed to configure storage");});},className:"flex-1 px-4 py-3 border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded-xl font-bold hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Use Defaults"})]})]})}),!r&&jsxRuntime.jsx("input",{type:"file",ref:W,onChange:A=>{A.target.files&&$(A.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var uy=[{name:"Default",value:"inherit"},{name:"Red",value:"#ef4444"},{name:"Orange",value:"#f97316"},{name:"Amber",value:"#f59e0b"},{name:"Emerald",value:"#10b981"},{name:"Blue",value:"#3b82f6"},{name:"Indigo",value:"#6366f1"},{name:"Violet",value:"#8b5cf6"},{name:"Rose",value:"#f43f5e"},{name:"Slate",value:"#64748b"}],xc=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let{t:a}=z(),[n,s]=oa.useState(null),i=oa.useRef(null);if(oa.useEffect(()=>{function m(w){i.current&&!i.current.contains(w.target)&&s(null);}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),!e)return null;let l=()=>{o();},d=()=>{let m=e.getAttributes("link").href,w=window.prompt("URL",m);if(w!==null){if(w===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:w}).run();}},c=m=>{m==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(m).run(),s(null);},u=m=>{s(n===m?null:m);},p=()=>e.isActive("heading",{level:1})?"Heading 1":e.isActive("heading",{level:2})?"Heading 2":e.isActive("heading",{level:3})?"Heading 3":e.isActive("heading",{level:4})?"Heading 4":"Normal Text",f=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(Nc.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(Nc.AlignRight,{size:12}):jsxRuntime.jsx(Nc.AlignLeft,{size:12}),y=()=>e.isActive("orderedList")?jsxRuntime.jsx(Nc.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(Nc.CheckSquare,{size:12}):jsxRuntime.jsx(Nc.List,{size:12}),g=()=>e.isActive("codeBlock")?jsxRuntime.jsx(Nc.Terminal,{size:12}):jsxRuntime.jsx(Nc.Quote,{size:12}),v=({onClick:m,isActive:w=false,disabled:C=false,children:E,title:D})=>jsxRuntime.jsx("button",{type:"button",onClick:m,disabled:C,title:D,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
10
+ ${w?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xs scale-95":"text-[var(--kyro-text)] hover:bg-[var(--kyro-bg-hover)]"}
11
+ ${C?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:E}),h=({onClick:m,isActive:w,children:C,title:E})=>jsxRuntime.jsxs("button",{type:"button",onClick:m,title:E,className:`px-2 py-1 rounded flex items-center gap-1 transition-all duration-150 text-xs border border-transparent hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] active:scale-98
12
+ ${w?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[C,jsxRuntime.jsx(Nc.ChevronDown,{size:10,className:"opacity-60"})]});return jsxRuntime.jsxs("div",{ref:i,className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg select-none",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().chain().focus().undo().run(),title:a("tooltips.undoCtrlz",{defaultValue:"Undo (Ctrl+Z)"}),children:jsxRuntime.jsx(Nc.Undo,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().chain().focus().redo().run(),title:a("tooltips.redoCtrly",{defaultValue:"Redo (Ctrl+Y)"}),children:jsxRuntime.jsx(Nc.Redo,{size:12})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleBold().run(),disabled:!e.can().chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:a("tooltips.boldCtrlb",{defaultValue:"Bold (Ctrl+B)"}),children:jsxRuntime.jsx(Nc.Bold,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleItalic().run(),disabled:!e.can().chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:a("tooltips.italicCtrli",{defaultValue:"Italic (Ctrl+I)"}),children:jsxRuntime.jsx(Nc.Italic,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleUnderline().run(),disabled:!e.can().chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:a("tooltips.underlineCtrlu",{defaultValue:"Underline (Ctrl+U)"}),children:jsxRuntime.jsx(Nc.Underline,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleStrike().run(),disabled:!e.can().chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:a("tooltips.strikethrough",{defaultValue:"Strikethrough"}),children:jsxRuntime.jsx(Nc.Strikethrough,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleCode().run(),disabled:!e.can().chain().focus().toggleCode().run(),isActive:e.isActive("code"),title:a("tooltips.inlineCode",{defaultValue:"Inline Code"}),children:jsxRuntime.jsx(Nc.Code,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:a("tooltips.highlightText",{defaultValue:"Highlight Text"}),children:jsxRuntime.jsx(Nc.Highlighter,{size:12})}),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center",children:[jsxRuntime.jsx(v,{onClick:()=>u("color"),title:a("tooltips.textColor",{defaultValue:"Text Color"}),isActive:n==="color"||e.isActive("textStyle"),children:jsxRuntime.jsx(Nc.Palette,{size:12})}),n==="color"&&jsxRuntime.jsx("div",{className:"absolute top-full left-0 mt-1.5 p-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 flex flex-wrap gap-1 w-44 animate-in fade-in slide-in-from-top-1 duration-150",children:uy.map(m=>jsxRuntime.jsx("button",{type:"button",onClick:()=>c(m.value),title:m.name,className:"w-6 h-6 rounded-full border border-[var(--kyro-border)] transition-transform hover:scale-115 active:scale-95 cursor-pointer relative",style:{backgroundColor:m.value==="inherit"?"transparent":m.value},children:m.value==="inherit"&&jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] text-[var(--kyro-text)] font-semibold",children:"\u2205"})},m.name))})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(h,{onClick:()=>u("heading"),isActive:n==="heading",title:a("tooltips.headingHierarchy",{defaultValue:"Heading hierarchy"}),children:jsxRuntime.jsx("span",{className:"font-medium text-[11px] leading-none min-w-[70px] text-left",children:p()})}),n==="heading"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{e.chain().focus().setParagraph().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
13
+ ${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(m=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:m}).run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
14
+ ${e.isActive("heading",{level:m})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",m]},m))]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(h,{onClick:()=>u("lists"),isActive:n==="lists",title:a("tooltips.listTypes",{defaultValue:"List Types"}),children:y()}),n==="lists"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBulletList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
15
+ ${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.List,{size:12}),"Bullet List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleOrderedList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
16
+ ${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.ListOrdered,{size:12}),"Ordered List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleTaskList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
17
+ ${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.CheckSquare,{size:12}),"Task Checklist"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(h,{onClick:()=>u("blocks"),isActive:n==="blocks",title:a("tooltips.structuralBlocks",{defaultValue:"Structural Blocks"}),children:g()}),n==="blocks"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBlockquote().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
18
+ ${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.Quote,{size:12}),"Blockquote"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleCodeBlock().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
19
+ ${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.Terminal,{size:12}),"Code Block"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),s(null);},className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors",children:[jsxRuntime.jsx(Nc.Minus,{size:12}),"Horizontal Rule"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(h,{onClick:()=>u("align"),isActive:n==="align",title:a("tooltips.alignment",{defaultValue:"Alignment"}),children:f()}),n==="align"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-32 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("left").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
20
+ ${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.AlignLeft,{size:12}),"Align Left"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("center").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
21
+ ${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.AlignCenter,{size:12}),"Align Center"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("right").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
22
+ ${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Nc.AlignRight,{size:12}),"Align Right"]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(v,{onClick:d,isActive:e.isActive("link"),title:a("tooltips.link",{defaultValue:"Link"}),children:jsxRuntime.jsx(Nc.Link,{size:12})}),jsxRuntime.jsx(v,{onClick:l,title:a("tooltips.addImage",{defaultValue:"Add Image"}),children:jsxRuntime.jsx(Nc.Image,{size:12})})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs ml-auto",children:jsxRuntime.jsx(v,{onClick:()=>r(!t),title:t?"Collapse Workspace":"Enlarge Workspace",children:t?jsxRuntime.jsx(Nc.Minimize2,{size:12}):jsxRuntime.jsx(Nc.Maximize2,{size:12})})})]})};function la({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=oa.useState(false);return oa.useEffect(()=>{s(true);},[]),n?jsxRuntime.jsx(py,{field:e,value:t,onChange:r,error:o,disabled:a}):jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
23
23
  ${o?"border-[var(--kyro-error)] shadow-[0_0_0_1px_var(--kyro-error)]":"border-[var(--kyro-border)]"}
24
- ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg h-[40px]"}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px] p-4"})]})})}function jp({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=reactI18next.useTranslation(),[s,i]=Ta.useState(false),[l,d]=Ta.useState(0),[c,u]=Ta.useState(false);Ta.useEffect(()=>{if(!s){d(0);return}let v=document.querySelector('[data-kyro-slide-panel="true"]'),x=()=>{d(v?v.getBoundingClientRect().width:0);};x();let g=new MutationObserver(()=>{x();});v&&g.observe(v),window.addEventListener("resize",x);let f=setInterval(x,100);return ()=>{g&&g.disconnect(),window.removeEventListener("resize",x),clearInterval(f);}},[s]);let m=react.useEditor({extensions:[gp__default.default.configure({codeBlock:true,link:false,underline:false}),vp__default.default.configure({openOnClick:false}),bp__default.default,xp__default.default.configure({types:["heading","paragraph"]}),kp__default.default,hp__default.default.configure({multicolor:true}),wp__default.default,Np__default.default.configure({nested:true}),extensionTextStyle.TextStyle,Sp__default.default],content:Array.isArray(t)?{type:"doc",content:t}:t||{type:"doc",content:[]},editable:!a,onUpdate:({editor:v})=>{r(v.getJSON());},editorProps:{attributes:{class:"prose prose-sm dark:prose-invert focus:outline-none min-h-[160px] p-4 max-w-none kyro-richtext text-[0.875rem] leading-relaxed"}}});return Ta.useEffect(()=>{m&&t&&JSON.stringify(t)!==JSON.stringify(m.getJSON())&&m.commands.setContent(Array.isArray(t)?{type:"doc",content:t}:t);},[t,m]),jsxRuntime.jsxs(ct,{field:e,error:o,children:[s?jsxRuntime.jsxs("div",{className:"border rounded-lg bg-[var(--kyro-bg-secondary)] border-[var(--kyro-border)] p-4 text-center text-xs text-[var(--kyro-text-muted)] flex items-center justify-center gap-3 h-20 transition-all duration-200 shadow-inner",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Rich text editor workspace is currently maximized."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(false),className:"px-2.5 py-1 bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] text-xs rounded-md shadow-sm font-medium hover:scale-102 active:scale-98 transition-transform cursor-pointer",children:"Minimize Workspace"})]}):jsxRuntime.jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
24
+ ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg h-[40px]"}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px] p-4"})]})})}function py({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=z(),[s,i]=oa.useState(false),[l,d]=oa.useState(0),[c,u]=oa.useState(false);oa.useEffect(()=>{if(!s){d(0);return}let f=document.querySelector('[data-kyro-slide-panel="true"]'),y=()=>{d(f?f.getBoundingClientRect().width:0);};y();let g=new MutationObserver(()=>{y();});f&&g.observe(f),window.addEventListener("resize",y);let v=setInterval(y,100);return ()=>{g&&g.disconnect(),window.removeEventListener("resize",y),clearInterval(v);}},[s]);let p=react.useEditor({extensions:[jf__default.default.configure({codeBlock:true,link:false,underline:false}),Uf__default.default.configure({openOnClick:false}),zf__default.default,Hf__default.default.configure({types:["heading","paragraph"]}),_f__default.default,Kf__default.default.configure({multicolor:true}),Gf__default.default,Wf__default.default.configure({nested:true}),extensionTextStyle.TextStyle,Jf__default.default],content:Array.isArray(t)?{type:"doc",content:t}:t||{type:"doc",content:[]},editable:!a,onUpdate:({editor:f})=>{r(f.getJSON());},editorProps:{attributes:{class:"prose prose-sm dark:prose-invert focus:outline-none min-h-[160px] p-4 max-w-none kyro-richtext text-[0.875rem] leading-relaxed"}}});return oa.useEffect(()=>{p&&t&&JSON.stringify(t)!==JSON.stringify(p.getJSON())&&p.commands.setContent(Array.isArray(t)?{type:"doc",content:t}:t);},[t,p]),jsxRuntime.jsxs(pt,{field:e,error:o,children:[s?jsxRuntime.jsxs("div",{className:"border rounded-lg bg-[var(--kyro-bg-secondary)] border-[var(--kyro-border)] p-4 text-center text-xs text-[var(--kyro-text-muted)] flex items-center justify-center gap-3 h-20 transition-all duration-200 shadow-inner",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Rich text editor workspace is currently maximized."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(false),className:"px-2.5 py-1 bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] text-xs rounded-md shadow-sm font-medium hover:scale-102 active:scale-98 transition-transform cursor-pointer",children:"Minimize Workspace"})]}):jsxRuntime.jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
25
25
  ${o?"border-[var(--kyro-error)] shadow-[0_0_0_1px_var(--kyro-error)]":"border-[var(--kyro-border)] focus-within:border-[var(--kyro-primary)] focus-within:ring-1 focus-within:ring-[var(--kyro-primary)]"}
26
- ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.jsx(ql,{editor:m,isExpanded:s,setIsExpanded:i,onOpenMediaPicker:()=>u(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px]",children:jsxRuntime.jsx(react.EditorContent,{editor:m})})]}),s&&typeof document<"u"&&reactDom.createPortal(jsxRuntime.jsxs("div",{style:{position:"fixed",top:"16px",bottom:"16px",left:"16px",right:l>0?`${l+16}px`:"16px",zIndex:9999},className:"flex flex-col bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-200 transition-all duration-300",children:[jsxRuntime.jsx(ql,{editor:m,isExpanded:s,setIsExpanded:i,onOpenMediaPicker:()=>u(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1 h-[calc(100vh-140px)] bg-[var(--kyro-bg)]",children:jsxRuntime.jsx(react.EditorContent,{editor:m})})]}),document.body),jsxRuntime.jsx("style",{children:`
26
+ ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.jsx(xc,{editor:p,isExpanded:s,setIsExpanded:i,onOpenMediaPicker:()=>u(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px]",children:jsxRuntime.jsx(react.EditorContent,{editor:p})})]}),s&&typeof document<"u"&&reactDom.createPortal(jsxRuntime.jsxs("div",{style:{position:"fixed",top:"16px",bottom:"16px",left:"16px",right:l>0?`${l+16}px`:"16px",zIndex:9999},className:"flex flex-col bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-200 transition-all duration-300",children:[jsxRuntime.jsx(xc,{editor:p,isExpanded:s,setIsExpanded:i,onOpenMediaPicker:()=>u(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1 h-[calc(100vh-140px)] bg-[var(--kyro-bg)]",children:jsxRuntime.jsx(react.EditorContent,{editor:p})})]}),document.body),jsxRuntime.jsx("style",{children:`
27
27
  .kyro-richtext ul[data-type="taskList"] {
28
28
  list-style: none !important;
29
29
  padding: 0 !important;
@@ -79,8 +79,8 @@
79
79
  font-style: italic !important;
80
80
  }
81
81
 
82
- `}),c&&jsxRuntime.jsx(yr,{open:c,onClose:()=>u(false),title:n("tooltips.selectImage",{defaultValue:"Select Image"}),width:"xl",children:jsxRuntime.jsx(En,{pickerMode:true,multiple:false,onSelect:v=>{if(v&&v.length>0){let x=v[0];m.chain().focus().setImage({src:x.url,alt:x.alt||x.title||"",title:x.title||""}).run();}u(false);}})})]})}var Xl=Object.keys(Ql__namespace).filter(e=>/^[A-Z]/.test(e)&&e!=="LucideProps"&&e!=="Icon");function Zl({open:e,onClose:t,onSelect:r}){let{t:o}=reactI18next.useTranslation(),[a,n]=Ta.useState(""),s=Ta.useMemo(()=>{if(!a)return Xl;let i=a.toLowerCase();return Xl.filter(l=>l.toLowerCase().includes(i))},[a]);return jsxRuntime.jsx(St,{open:e,onClose:t,title:o("tooltips.selectAnIcon",{defaultValue:"Select an Icon"}),size:"xl",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-[60vh]",children:[jsxRuntime.jsxs("div",{className:"relative mb-6",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:o("fields.searchIcons",{defaultValue:"Search icons..."}),value:a,onChange:i=>n(i.target.value),className:"w-full pl-10 pr-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all text-sm font-bold"})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 custom-scrollbar pr-2",children:s.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-[var(--kyro-text-secondary)] font-medium",children:"No icons found"}):jsxRuntime.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-3 pb-8",children:s.map(i=>{let l=Ql__namespace[i],d=i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(d),t();},className:"flex flex-col items-center justify-center p-3 gap-2 rounded-md border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group",title:i,children:jsxRuntime.jsx(l,{className:"w-6 h-6 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors",strokeWidth:1.5})},i)})})})]})})}function Ln({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false),i=t==null?"":String(t),l=Ta.useMemo(()=>i?i.split("-").map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(""):"",[i]),d=Ql__namespace[l],c=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsxs(ct,{field:e,error:o,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"flex-1 relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:i,onChange:u=>r?.(u.target.value),placeholder:e.admin?.placeholder||"e.g., activity",disabled:a||c,required:e.required,className:`kyro-form-input ${a||c?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`})}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),disabled:a||c,className:"flex items-center gap-2 h-10 px-4 shrink-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-sm font-bold text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[d?jsxRuntime.jsx(d,{className:"w-5 h-5",strokeWidth:2}):jsxRuntime.jsx(Ql__namespace.Search,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),"Browse"]})]}),n&&jsxRuntime.jsx(Zl,{open:n,onClose:()=>s(false),onSelect:u=>{r?.(u);}})]})}var qo={id:"light",label:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",background:"#f8fafc",surface:"#ffffff",text:"#0f172a",textMuted:"#64748b",border:"#e2e8f0",success:"#22c55e",error:"#ef4444",warning:"#f59e0b",info:"#06b6d4"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1)"}},Ea={id:"dark",label:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",background:"#0b1222",surface:"#1e293b",text:"#f1f5f9",textMuted:"#94a3b8",border:"#334155",success:"#4ade80",error:"#f87171",warning:"#fbbf24",info:"#22d3ee"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.5)"}};function Ma(e,t){return {...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows},blocks:e.blocks?{...e.blocks,...t.blocks}:t.blocks,fields:e.fields?{...e.fields,...t.fields}:t.fields}}var od=Ta.createContext(null);function Jo(){let e=Ta.useContext(od);return e||{mode:"light",theme:qo,lightTheme:qo,darkTheme:Ea,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function td(e){let t=document.documentElement;t&&(e.colors&&Object.entries(e.colors).forEach(([r,o])=>{o&&(t.style.setProperty(`--kyro-${r}`,o),t.style.setProperty(`--kyro-${r}-light`,rd(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,rd(o,.8)));}),e.typography&&(e.typography.fontFamily&&t.style.setProperty("--kyro-font-family",e.typography.fontFamily),e.typography.fontFamilyMono&&t.style.setProperty("--kyro-font-mono",e.typography.fontFamilyMono)),e.spacing&&Object.entries(e.spacing).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-spacing-${r}`,o);}),e.borderRadius&&Object.entries(e.borderRadius).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-radius-${r}`,o);}),e.shadows&&Object.entries(e.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-shadow-${r}`,o);}),e.blocks&&(e.blocks.card&&Object.entries(e.blocks.card).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-card-${r}`,o);}),e.blocks.hero?.background&&t.style.setProperty("--kyro-block-hero-bg",e.blocks.hero.background),e.blocks.code&&Object.entries(e.blocks.code).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-code-${r}`,o);})),e.fields&&(e.fields.input&&Object.entries(e.fields.input).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-field-input-${r}`,o);}),e.fields.upload&&e.fields.upload.dropzoneBackground&&t.style.setProperty("--kyro-field-upload-dropzone-bg",e.fields.upload.dropzoneBackground)));}function rd(e,t){if(!e.startsWith("#"))return e;let r=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16),n=s=>Math.round(s*t).toString(16).padStart(2,"0");return `#${n(r)}${n(o)}${n(a)}`}function Sr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=Ta.useState(t),[s,i]=Ta.useState(r||{}),[l,d]=Ta.useState(o||{}),c=Ma(qo,s),u=Ma(Ea,l),m=Ta.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?u:c:a==="dark"?u:c,[a,c,u]),[v,x]=Ta.useState(m());Ta.useEffect(()=>{let b=m();x(b),td(b);},[m]),Ta.useEffect(()=>{if(a!=="system")return;let b=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{let h=m();x(h),td(h);};return b.addEventListener("change",p),()=>b.removeEventListener("change",p)},[a,m]);let g=Ta.useCallback(b=>{i(p=>({...p,...b})),d(p=>({...p,...b}));},[]),f=Ta.useCallback(b=>`var(--kyro-${b})`,[]);return jsxRuntime.jsx(od.Provider,{value:{mode:a,theme:v,lightTheme:c,darkTheme:u,setMode:n,updateTheme:g,getCssVar:f},children:e})}var Vn=e=>jsxRuntime.jsx(Sr,{defaultMode:"light",...e}),On=e=>jsxRuntime.jsx(Sr,{defaultMode:"dark",...e});var em=Ta.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),tm=[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"json",label:"JSON"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"sql",label:"SQL"},{value:"python",label:"Python"},{value:"rust",label:"Rust"},{value:"java",label:"Java"},{value:"php",label:"PHP"},{value:"markdown",label:"Markdown"}],nd={javascript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),typescript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),js:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),jsx:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),ts:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({typescript:true})),json:()=>import('@codemirror/lang-json').then(e=>e.json()),css:()=>import('@codemirror/lang-css').then(e=>e.css()),sql:()=>import('@codemirror/lang-sql').then(e=>e.sql()),python:()=>import('@codemirror/lang-python').then(e=>e.python()),html:()=>import('@codemirror/lang-html').then(e=>e.html()),rust:()=>import('@codemirror/lang-rust').then(e=>e.rust()),java:()=>import('@codemirror/lang-java').then(e=>e.java()),cpp:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),c:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),php:()=>import('@codemirror/lang-php').then(e=>e.php()),markdown:()=>import('@codemirror/lang-markdown').then(e=>e.markdown()),py:()=>import('@codemirror/lang-python').then(e=>e.python())},La=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ta.useState(false),[i,l]=Ta.useState(false),[d,c]=Ta.useState([]),[u,m]=Ta.useState(false),[v,x]=Ta.useState(false),[g,f]=Ta.useState(false),{theme:b}=Jo(),p=b.colors?.accent||b.colors?.primary||"#6366f1",h=e.language?.toLowerCase()||"javascript";Ta.useEffect(()=>{s(true),l(document.documentElement.classList.contains("dark"));let D=new MutationObserver(()=>{l(document.documentElement.classList.contains("dark"));});return D.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>D.disconnect()},[]),Ta.useEffect(()=>{if(!n)return;(async()=>{m(true);try{let O=await(nd[h]||nd.javascript)();c([O]);}catch(U){console.error("Failed to load language extension:",U),c([]);}finally{m(false);}})();},[h,n]);let A=Ta.useCallback(D=>r?.(D),[r]),$=Ta.useCallback(()=>{navigator.clipboard.writeText(t),x(true),setTimeout(()=>x(false),1500);},[t]),T=Ta.useCallback(()=>{f(D=>!D),document.body.style.overflow=g?"":"hidden";},[g]),k=i?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,y=tm.find(D=>D.value===h)?.label||h,w=(D,U=1)=>{let O=parseInt(D.slice(1,3),16),z=parseInt(D.slice(3,5),16),P=parseInt(D.slice(5,7),16);return `rgba(${O}, ${z}, ${P}, ${U})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":p,"--accent-light":w(p,.1),"--accent-light-2":w(p,.05)},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsxRuntime.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold transition-colors",style:{backgroundColor:u?"var(--kyro-surface-accent)":p,color:u?"var(--kyro-text-muted)":"white"},children:u?"...":y})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:$,className:"text-[10px] px-2 py-0.5 rounded font-medium transition-all",style:{backgroundColor:v?"var(--kyro-success)":"var(--kyro-surface-accent)",color:v?"white":"var(--kyro-text-secondary)"},children:v?"Copied":"Copy"}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"text-[10px] px-2 py-0.5 rounded font-medium bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] transition-all",style:{color:"var(--kyro-text-secondary)"},children:g?"Exit":"Expand"})]})]}),jsxRuntime.jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${g?"fixed inset-4 z-50":""}`,style:{backgroundColor:"var(--kyro-surface)",borderColor:o?"var(--kyro-error)":"var(--kyro-border)",borderWidth:"1px"},children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 transition-all duration-200",style:{backgroundColor:p}}),jsxRuntime.jsx(Ta.Suspense,{fallback:jsxRuntime.jsx("div",{className:"h-[280px] flex items-center justify-center",style:{backgroundColor:"var(--kyro-surface)"},children:jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full animate-spin",style:{borderColor:"var(--kyro-border)",borderTopColor:p,borderWidth:"2px"}})}),children:jsxRuntime.jsx(em,{value:t??"",height:g?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:k,onChange:A,editable:!a,basicSetup:{lineNumbers:true,highlightActiveLine:true,bracketMatching:true,closeBrackets:true,autocompletion:true,foldGutter:true},style:{fontSize:"13px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"}})}),o&&jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 right-0 px-3 py-2 text-xs font-medium",style:{backgroundColor:"var(--kyro-danger-bg)",color:"var(--kyro-error)"},children:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px]",style:{color:"var(--kyro-text-muted)"},children:[jsxRuntime.jsxs("span",{children:[t.split(`
83
- `).length," lines"]}),jsxRuntime.jsx("span",{style:{color:p},children:"CodeMirror"})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-5 w-24 rounded bg-[var(--kyro-surface-accent)] animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-16 rounded bg-[var(--kyro-surface-accent)] animate-pulse"})]}),jsxRuntime.jsx("div",{className:"h-[280px] rounded-xl bg-[var(--kyro-surface-accent)] animate-pulse"})]})};function sm(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/```(\w+)?\n([\s\S]*?)```/g,'<pre class="bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto my-2"><code>$2</code></pre>').replace(/`([^`]+)`/g,'<code class="bg-gray-100 dark:bg-gray-800 px-1 rounded text-sm font-mono">$1</code>').replace(/^### (.+)$/gm,'<h3 class="text-lg font-semibold mt-4 mb-2">$1</h3>').replace(/^## (.+)$/gm,'<h2 class="text-xl font-semibold mt-4 mb-2">$1</h2>').replace(/^# (.+)$/gm,'<h1 class="text-2xl font-bold mt-4 mb-2">$1</h1>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/___(.+?)___/g,"<strong><em>$1</em></strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/~~(.+?)~~/g,"<del>$1</del>").replace(/^> (.+)$/gm,'<blockquote class="border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic my-2 text-gray-600 dark:text-gray-400">$1</blockquote>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-blue-600 hover:underline" target="_blank" rel="noopener noreferrer">$1</a>').replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="max-w-full h-auto rounded my-2" />').replace(/^---$/gm,'<hr class="border-gray-300 dark:border-gray-600 my-4" />').replace(/^\*\*\*$/gm,'<hr class="border-gray-300 dark:border-gray-600 my-4" />').replace(/^[\*\-] (.+)$/gm,'<li class="ml-4">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal">$1</li>').replace(/^(?!<[a-z]|$)(.+)$/gm,'<p class="my-2">$1</p>').replace(/<p class="my-2"><\/p>/g,"").replace(/(<li class="ml-4">.*<\/li>\n?)+/g,'<ul class="list-disc pl-6 my-2">$&</ul>'):""}var Gs=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let{t:n}=reactI18next.useTranslation(),[s,i]=Ta.useState(false),[l,d]=Ta.useState(false);Ta.useEffect(()=>{d(true);},[]);let c=Ta.useCallback(v=>{r?.(v.target.value);},[r]),u=Ta.useMemo(()=>t?t.trim().split(/\s+/).filter(Boolean).length:0,[t]),m=t?.length||0;return l?jsxRuntime.jsxs("div",{className:"kyro-form-field",style:{position:"relative",zIndex:10,pointerEvents:"auto"},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[u," words \u2022 ",m," chars"]}),jsxRuntime.jsxs("div",{className:"flex rounded-md overflow-hidden border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(false),className:`px-3 py-1 text-xs font-medium transition-colors ${s?"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"}`,children:"Write"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(true),className:`px-3 py-1 text-xs font-medium transition-colors ${s?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:"Preview"})]})]})]}),jsxRuntime.jsx("div",{style:{pointerEvents:"auto",position:"relative",zIndex:50},className:`border border-[var(--kyro-border)] rounded-md overflow-hidden ${a?"opacity-50 cursor-not-allowed":""} ${o?"border-[var(--kyro-error)]":""}`,children:s?jsxRuntime.jsx("div",{className:"p-6 min-h-[300px] overflow-auto bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",children:t?jsxRuntime.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:sm(t)}}):jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-muted)] italic",children:"Nothing to preview"})}):jsxRuntime.jsx("textarea",{value:t??"",onChange:c,disabled:a,rows:12,style:{pointerEvents:"auto",cursor:"text",zIndex:100},className:"w-full p-4 font-mono text-sm resize-y focus:outline-none bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",placeholder:n("fields.enterMarkdownContentHeading",{defaultValue:`Enter markdown content...
82
+ `}),c&&jsxRuntime.jsx(hr,{open:c,onClose:()=>u(false),title:n("tooltips.selectImage",{defaultValue:"Select Image"}),width:"xl",children:jsxRuntime.jsx(ys,{pickerMode:true,multiple:false,onSelect:f=>{if(f&&f.length>0){let y=f[0];p.chain().focus().setImage({src:y.url,alt:y.alt||y.title||"",title:y.title||""}).run();}u(false);}})})]})}var kc=Object.keys(Nc__namespace).filter(e=>/^[A-Z]/.test(e)&&e!=="LucideProps"&&e!=="Icon");function Cc({open:e,onClose:t,onSelect:r}){let{t:o}=z(),[a,n]=oa.useState(""),s=oa.useMemo(()=>{if(!a)return kc;let i=a.toLowerCase();return kc.filter(l=>l.toLowerCase().includes(i))},[a]);return jsxRuntime.jsx(Tt,{open:e,onClose:t,title:o("tooltips.selectAnIcon",{defaultValue:"Select an Icon"}),size:"xl",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-[60vh]",children:[jsxRuntime.jsxs("div",{className:"relative mb-6",children:[jsxRuntime.jsx(Nc.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:o("fields.searchIcons",{defaultValue:"Search icons..."}),value:a,onChange:i=>n(i.target.value),className:"w-full pl-10 pr-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all text-sm font-bold"})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 custom-scrollbar pr-2",children:s.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-[var(--kyro-text-secondary)] font-medium",children:"No icons found"}):jsxRuntime.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-3 pb-8",children:s.map(i=>{let l=Nc__namespace[i],d=i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(d),t();},className:"flex flex-col items-center justify-center p-3 gap-2 rounded-md border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group",title:i,children:jsxRuntime.jsx(l,{className:"w-6 h-6 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors",strokeWidth:1.5})},i)})})})]})})}function vs({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=oa.useState(false),i=t==null?"":String(t),l=oa.useMemo(()=>i?i.split("-").map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(""):"",[i]),d=Nc__namespace[l],c=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsxs(pt,{field:e,error:o,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"flex-1 relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:i,onChange:u=>r?.(u.target.value),placeholder:e.admin?.placeholder||"e.g., activity",disabled:a||c,required:e.required,className:`kyro-form-input ${a||c?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`})}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),disabled:a||c,className:"flex items-center gap-2 h-10 px-4 shrink-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-sm font-bold text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[d?jsxRuntime.jsx(d,{className:"w-5 h-5",strokeWidth:2}):jsxRuntime.jsx(Nc__namespace.Search,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),"Browse"]})]}),n&&jsxRuntime.jsx(Cc,{open:n,onClose:()=>s(false),onSelect:u=>{r?.(u);}})]})}var da={id:"light",label:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",background:"#f8fafc",surface:"#ffffff",text:"#0f172a",textMuted:"#64748b",border:"#e2e8f0",success:"#22c55e",error:"#ef4444",warning:"#f59e0b",info:"#06b6d4"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1)"}},en={id:"dark",label:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",background:"#0b1222",surface:"#1e293b",text:"#f1f5f9",textMuted:"#94a3b8",border:"#334155",success:"#4ade80",error:"#f87171",warning:"#fbbf24",info:"#22d3ee"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.5)"}};function tn(e,t){return {...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows},blocks:e.blocks?{...e.blocks,...t.blocks}:t.blocks,fields:e.fields?{...e.fields,...t.fields}:t.fields}}var Dc=oa.createContext(null);function ca(){let e=oa.useContext(Dc);return e||{mode:"light",theme:da,lightTheme:da,darkTheme:en,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function Ac(e){let t=document.documentElement;t&&(e.colors&&Object.entries(e.colors).forEach(([r,o])=>{o&&(t.style.setProperty(`--kyro-${r}`,o),t.style.setProperty(`--kyro-${r}-light`,Tc(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Tc(o,.8)));}),e.typography&&(e.typography.fontFamily&&t.style.setProperty("--kyro-font-family",e.typography.fontFamily),e.typography.fontFamilyMono&&t.style.setProperty("--kyro-font-mono",e.typography.fontFamilyMono)),e.spacing&&Object.entries(e.spacing).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-spacing-${r}`,o);}),e.borderRadius&&Object.entries(e.borderRadius).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-radius-${r}`,o);}),e.shadows&&Object.entries(e.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-shadow-${r}`,o);}),e.blocks&&(e.blocks.card&&Object.entries(e.blocks.card).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-card-${r}`,o);}),e.blocks.hero?.background&&t.style.setProperty("--kyro-block-hero-bg",e.blocks.hero.background),e.blocks.code&&Object.entries(e.blocks.code).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-code-${r}`,o);})),e.fields&&(e.fields.input&&Object.entries(e.fields.input).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-field-input-${r}`,o);}),e.fields.upload&&e.fields.upload.dropzoneBackground&&t.style.setProperty("--kyro-field-upload-dropzone-bg",e.fields.upload.dropzoneBackground)));}function Tc(e,t){if(!e.startsWith("#"))return e;let r=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16),n=s=>Math.round(s*t).toString(16).padStart(2,"0");return `#${n(r)}${n(o)}${n(a)}`}function Fr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=oa.useState(t),[s,i]=oa.useState(r||{}),[l,d]=oa.useState(o||{}),c=tn(da,s),u=tn(en,l),p=oa.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?u:c:a==="dark"?u:c,[a,c,u]),[f,y]=oa.useState(p());oa.useEffect(()=>{let h=p();y(h),Ac(h);},[p]),oa.useEffect(()=>{if(a!=="system")return;let h=window.matchMedia("(prefers-color-scheme: dark)"),m=()=>{let w=p();y(w),Ac(w);};return h.addEventListener("change",m),()=>h.removeEventListener("change",m)},[a,p]);let g=oa.useCallback(h=>{i(m=>({...m,...h})),d(m=>({...m,...h}));},[]),v=oa.useCallback(h=>`var(--kyro-${h})`,[]);return jsxRuntime.jsx(Dc.Provider,{value:{mode:a,theme:f,lightTheme:c,darkTheme:u,setMode:n,updateTheme:g,getCssVar:v},children:e})}var hs=e=>jsxRuntime.jsx(Fr,{defaultMode:"light",...e}),xs=e=>jsxRuntime.jsx(Fr,{defaultMode:"dark",...e});var Ny=oa.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),Cy=[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"json",label:"JSON"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"sql",label:"SQL"},{value:"python",label:"Python"},{value:"rust",label:"Rust"},{value:"java",label:"Java"},{value:"php",label:"PHP"},{value:"markdown",label:"Markdown"}],Rc={javascript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),typescript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),js:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),jsx:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),ts:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({typescript:true})),json:()=>import('@codemirror/lang-json').then(e=>e.json()),css:()=>import('@codemirror/lang-css').then(e=>e.css()),sql:()=>import('@codemirror/lang-sql').then(e=>e.sql()),python:()=>import('@codemirror/lang-python').then(e=>e.python()),html:()=>import('@codemirror/lang-html').then(e=>e.html()),rust:()=>import('@codemirror/lang-rust').then(e=>e.rust()),java:()=>import('@codemirror/lang-java').then(e=>e.java()),cpp:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),c:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),php:()=>import('@codemirror/lang-php').then(e=>e.php()),markdown:()=>import('@codemirror/lang-markdown').then(e=>e.markdown()),py:()=>import('@codemirror/lang-python').then(e=>e.python())},rn=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=oa.useState(false),[i,l]=oa.useState(false),[d,c]=oa.useState([]),[u,p]=oa.useState(false),[f,y]=oa.useState(false),[g,v]=oa.useState(false),{theme:h}=ca(),m=h.colors?.accent||h.colors?.primary||"#6366f1",w=e.language?.toLowerCase()||"javascript";oa.useEffect(()=>{s(true),l(document.documentElement.classList.contains("dark"));let N=new MutationObserver(()=>{l(document.documentElement.classList.contains("dark"));});return N.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>N.disconnect()},[]),oa.useEffect(()=>{if(!n)return;(async()=>{p(true);try{let M=await(Rc[w]||Rc.javascript)();c([M]);}catch(O){console.error("Failed to load language extension:",O),c([]);}finally{p(false);}})();},[w,n]);let C=oa.useCallback(N=>r?.(N),[r]),E=oa.useCallback(()=>{navigator.clipboard.writeText(t),y(true),setTimeout(()=>y(false),1500);},[t]),D=oa.useCallback(()=>{v(N=>!N),document.body.style.overflow=g?"":"hidden";},[g]),k=i?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,b=Cy.find(N=>N.value===w)?.label||w,x=(N,O=1)=>{let M=parseInt(N.slice(1,3),16),I=parseInt(N.slice(3,5),16),P=parseInt(N.slice(5,7),16);return `rgba(${M}, ${I}, ${P}, ${O})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":m,"--accent-light":x(m,.1),"--accent-light-2":x(m,.05)},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsxRuntime.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold transition-colors",style:{backgroundColor:u?"var(--kyro-surface-accent)":m,color:u?"var(--kyro-text-muted)":"white"},children:u?"...":b})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:E,className:"text-[10px] px-2 py-0.5 rounded font-medium transition-all",style:{backgroundColor:f?"var(--kyro-success)":"var(--kyro-surface-accent)",color:f?"white":"var(--kyro-text-secondary)"},children:f?"Copied":"Copy"}),jsxRuntime.jsx("button",{type:"button",onClick:D,className:"text-[10px] px-2 py-0.5 rounded font-medium bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] transition-all",style:{color:"var(--kyro-text-secondary)"},children:g?"Exit":"Expand"})]})]}),jsxRuntime.jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${g?"fixed inset-4 z-50":""}`,style:{backgroundColor:"var(--kyro-surface)",borderColor:o?"var(--kyro-error)":"var(--kyro-border)",borderWidth:"1px"},children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 transition-all duration-200",style:{backgroundColor:m}}),jsxRuntime.jsx(oa.Suspense,{fallback:jsxRuntime.jsx("div",{className:"h-[280px] flex items-center justify-center",style:{backgroundColor:"var(--kyro-surface)"},children:jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full animate-spin",style:{borderColor:"var(--kyro-border)",borderTopColor:m,borderWidth:"2px"}})}),children:jsxRuntime.jsx(Ny,{value:t??"",height:g?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:k,onChange:C,editable:!a,basicSetup:{lineNumbers:true,highlightActiveLine:true,bracketMatching:true,closeBrackets:true,autocompletion:true,foldGutter:true},style:{fontSize:"13px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"}})}),o&&jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 right-0 px-3 py-2 text-xs font-medium",style:{backgroundColor:"var(--kyro-danger-bg)",color:"var(--kyro-error)"},children:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px]",style:{color:"var(--kyro-text-muted)"},children:[jsxRuntime.jsxs("span",{children:[t.split(`
83
+ `).length," lines"]}),jsxRuntime.jsx("span",{style:{color:m},children:"CodeMirror"})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-5 w-24 rounded bg-[var(--kyro-surface-accent)] animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-16 rounded bg-[var(--kyro-surface-accent)] animate-pulse"})]}),jsxRuntime.jsx("div",{className:"h-[280px] rounded-xl bg-[var(--kyro-surface-accent)] animate-pulse"})]})};function Dy(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/```(\w+)?\n([\s\S]*?)```/g,'<pre class="bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto my-2"><code>$2</code></pre>').replace(/`([^`]+)`/g,'<code class="bg-gray-100 dark:bg-gray-800 px-1 rounded text-sm font-mono">$1</code>').replace(/^### (.+)$/gm,'<h3 class="text-lg font-semibold mt-4 mb-2">$1</h3>').replace(/^## (.+)$/gm,'<h2 class="text-xl font-semibold mt-4 mb-2">$1</h2>').replace(/^# (.+)$/gm,'<h1 class="text-2xl font-bold mt-4 mb-2">$1</h1>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/___(.+?)___/g,"<strong><em>$1</em></strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/~~(.+?)~~/g,"<del>$1</del>").replace(/^> (.+)$/gm,'<blockquote class="border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic my-2 text-gray-600 dark:text-gray-400">$1</blockquote>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-blue-600 hover:underline" target="_blank" rel="noopener noreferrer">$1</a>').replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="max-w-full h-auto rounded my-2" />').replace(/^---$/gm,'<hr class="border-gray-300 dark:border-gray-600 my-4" />').replace(/^\*\*\*$/gm,'<hr class="border-gray-300 dark:border-gray-600 my-4" />').replace(/^[\*\-] (.+)$/gm,'<li class="ml-4">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal">$1</li>').replace(/^(?!<[a-z]|$)(.+)$/gm,'<p class="my-2">$1</p>').replace(/<p class="my-2"><\/p>/g,"").replace(/(<li class="ml-4">.*<\/li>\n?)+/g,'<ul class="list-disc pl-6 my-2">$&</ul>'):""}var Ui=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let{t:n}=z(),[s,i]=oa.useState(false),[l,d]=oa.useState(false);oa.useEffect(()=>{d(true);},[]);let c=oa.useCallback(f=>{r?.(f.target.value);},[r]),u=oa.useMemo(()=>t?t.trim().split(/\s+/).filter(Boolean).length:0,[t]),p=t?.length||0;return l?jsxRuntime.jsxs("div",{className:"kyro-form-field",style:{position:"relative",zIndex:10,pointerEvents:"auto"},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[u," words \u2022 ",p," chars"]}),jsxRuntime.jsxs("div",{className:"flex rounded-md overflow-hidden border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(false),className:`px-3 py-1 text-xs font-medium transition-colors ${s?"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"}`,children:"Write"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(true),className:`px-3 py-1 text-xs font-medium transition-colors ${s?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:"Preview"})]})]})]}),jsxRuntime.jsx("div",{style:{pointerEvents:"auto",position:"relative",zIndex:50},className:`border border-[var(--kyro-border)] rounded-md overflow-hidden ${a?"opacity-50 cursor-not-allowed":""} ${o?"border-[var(--kyro-error)]":""}`,children:s?jsxRuntime.jsx("div",{className:"p-6 min-h-[300px] overflow-auto bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",children:t?jsxRuntime.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:Dy(t)}}):jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-muted)] italic",children:"Nothing to preview"})}):jsxRuntime.jsx("textarea",{value:t??"",onChange:c,disabled:a,rows:12,style:{pointerEvents:"auto",cursor:"text",zIndex:100},className:"w-full p-4 font-mono text-sm resize-y focus:outline-none bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",placeholder:n("fields.enterMarkdownContentHeading",{defaultValue:`Enter markdown content...
84
84
 
85
85
  # Heading 1
86
86
  ## Heading 2
@@ -96,14 +96,14 @@
96
96
 
97
97
  \`\`\`
98
98
  code block
99
- \`\`\``})})}),!s&&jsxRuntime.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx("span",{children:"**bold**"}),jsxRuntime.jsx("span",{children:"*italic*"}),jsxRuntime.jsx("span",{children:"`code`"}),jsxRuntime.jsx("span",{children:"[link](url)"}),jsxRuntime.jsx("span",{children:"# heading"})]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"kyro-form-help",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:o})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx("div",{className:"h-[200px] bg-[var(--kyro-surface)] animate-pulse rounded-md border border-[var(--kyro-border)]"})]})};function zn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=t??"",s=n.length>8?n.slice(0,-8)+"*".repeat(8):n;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:s,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})})})}function wo(e,t){if(e===t)return true;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return false;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!wo(e[a],t[a]))return false;return true}if(Array.isArray(e)||Array.isArray(t))return false;let r=Object.keys(e).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id"),o=Object.keys(t).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id");if(r.length!==o.length)return false;for(let a of r)if(!o.includes(a)||!wo(e[a],t[a]))return false;return true}function qs(e){if(e==null||e===""||e===false)return true;if(Array.isArray(e))return e.length===0;if(typeof e=="object"){if(Object.keys(e).length===0)return true;if(e.type==="doc"&&Array.isArray(e.content))return e.content.length===0||e.content.length===1&&e.content[0].type==="paragraph"&&!e.content[0].content}return false}function Kt(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(Kt);if(typeof e=="object"){let t=e,r=Object.keys(t),o="id"in t&&(typeof t.id=="string"||t.id===null),a="url"in t&&("filename"in t||"mimeType"in t);if(o&&a&&r.length<=25)return t.id;let n={};for(let s of r)n[s]=Kt(t[s]);return n}return e}var Un=null,id=false,Js=async()=>(Un&&id||(Un=unstorage.createStorage({driver:um__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),id=true),Un),pm=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Js()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Js()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Js()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},ge=zustand.create()(middleware.persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,previewUrl:null,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields),s=Kt(o),i=Kt(a.lastSavedData[r]);qs(s)&&qs(i)||wo(s,i)?n.delete(r):n.add(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),s={...a.formData},i=s;for(let l=0;l<n.length-1;l++)i[n[l]]===void 0&&(i[n[l]]={}),i[n[l]]={...i[n[l]]},i=i[n[l]];return i[n[n.length-1]]=o,{formData:s}});},setActiveTab:r=>e({activeTab:r}),setIsSlugLocked:r=>e(o=>({isSlugLocked:typeof r=="function"?r(o.isSlugLocked):r})),setView:r=>e({view:r}),setIsDropdownOpen:r=>e(o=>({isDropdownOpen:typeof r=="function"?r(o.isDropdownOpen):r})),setVersions:r=>e({versions:r}),setLoadingVersions:r=>e({loadingVersions:r}),setShowPreview:r=>e(o=>({showPreview:typeof r=="function"?r(o.showPreview):r})),setPreviewUrl:r=>e({previewUrl:r}),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[s,i]of Object.entries(a))o-new Date(i.draftUpdatedAt).getTime()<6048e5&&(n[s]=i);e({draftCache:n});},setDraftCache:(r,o)=>e(a=>({draftCache:{...a.draftCache,[r]:o}})),getDraftCache:r=>t().draftCache[r]||null,clearDraftCache:r=>e(o=>{let a={...o.draftCache};return delete a[r],{draftCache:a}})}),{name:"kyro-autoform-storage",storage:middleware.createJSONStorage(()=>pm()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function jn(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function Qo({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=reactI18next.useTranslation(),s=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,i=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:d,setIsSlugLocked:c,formData:u}=ge(),m=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",v=t==null?"":String(t),x={id:e.name,value:v,onChange:g=>r?.(g.target.value),placeholder:e.admin?.placeholder,disabled:a||s||l&&d,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||s||l&&d?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"relative",children:[i?jsxRuntime.jsx("textarea",{...x,rows:e.admin?.rows||4}):jsxRuntime.jsx("input",{type:m,...x,pattern:e.pattern}),l&&jsxRuntime.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r?.(jn(u[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:n("tooltips.regenerateSlug",{defaultValue:"Regenerate slug"}),children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),jsxRuntime.jsx("path",{d:"M21 3v5h-5"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>c(!d),className:`p-1.5 rounded transition-colors ${d?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:d?"Unlock slug":"Lock slug",children:d?jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})})]}),e.name?.toLowerCase().includes("metatitle")&&jsxRuntime.jsx("div",{className:"flex items-center justify-between mt-1 text-[10px] font-bold tracking-wider",children:jsxRuntime.jsxs("span",{className:v.length>60?"text-red-500":v.length>=40?"text-green-500":"text-amber-600",children:[v.length," / 60 \u2014 ",v.length>60?"Too Long":v.length>=40?"Ideal":"Short"]})})]})})}function Hn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("input",{type:"number",id:e.name,value:t??"",onChange:s=>r?.(parseFloat(s.target.value)||0),placeholder:e.admin?.placeholder,disabled:a||n,min:e.min,max:e.max,step:e.step||(e.integer?1:"any"),required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function _n({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,hideLabel:true,children:jsxRuntime.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t??false,onChange:i=>r?.(i.target.checked),disabled:a||n,className:`w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)] transition-all ${a||n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`}),jsxRuntime.jsxs("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)] tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})]})})}function Kn({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:s=>r?.(s.target.value),disabled:a||n,min:e.minDate,max:e.maxDate,required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Va(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Wn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function qn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function $a(e,t){let r=new Set(e.map(o=>o.slug));for(let o of t)r.has(o.slug)||(e.push(o),r.add(o.slug));}var fm={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function No(e,t,r){let o=t.split(".");if(o.length===0)return false;let a=o[0],n=o.slice(1).join(".");for(let s of e){if(s.name===a)if(n){if(s.fields&&Array.isArray(s.fields))return No(s.fields,n,r);if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let l of s.tabs)if(l.fields&&Array.isArray(l.fields)&&No(l.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let l=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of s.blocks)if(c.slug===l&&c.fields&&Array.isArray(c.fields))return No(c.fields,d,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?No(s.fields,n,r):false}else return Object.assign(s,r),true;if(!s.name||s.type==="tabs"||s.type==="row"||s.type==="collapsible"){if(s.fields&&Array.isArray(s.fields)&&No(s.fields,t,r))return true;if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let l of s.tabs)if(l.fields&&Array.isArray(l.fields)&&No(l.fields,t,r))return true}}}return false}function gm(e,t){for(let[r,o]of Object.entries(e)){let a=fm[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:s,...i}=n;if(o.admin={...o.admin,...i},s&&o.fields&&Array.isArray(o.fields))for(let[l,d]of Object.entries(s))No(o.fields,l,d);}}}function vm(e="blog"){let t=[],r=[];switch(e){case "minimal":t.push(...Object.values(templates.minimalCollections)),r.push(...templates.coreSettingsGlobals);break;case "starter":t.push(...Object.values(templates.starterCollections)),r.push(...templates.coreSettingsGlobals);break;case "blog":t.push(...Object.values(templates.blogCollections)),r.push(...templates.coreSettingsGlobals);break;case "ecommerce":t.push(...Object.values(templates.ecommerceCollections)),r.push(...templates.allSettingsGlobals);break;case "kitchen-sink":t.push(...Object.values(templates.minimalCollections),...Object.values(templates.starterCollections),...Object.values(templates.blogCollections),...Object.values(templates.ecommerceCollections),...Object.values(templates.kitchenSinkCollections)),r.push(...templates.allSettingsGlobals);break}return $a(t,Object.values(templates.mediaCollections)),$a(t,Object.values(templates.authCollections)),{collections:Wn(t),globals:qn(r)}}function bm(e){let t=Va(e.collections),r=Va(e.globals);if(t.length===0&&r.length===0)return vm("kitchen-sink");let o=[];return $a(o,Object.values(templates.mediaCollections)),$a(o,Object.values(templates.authCollections)),$a(o,t),{collections:Wn(o),globals:qn(r)}}var Gn=null;function xm(){if(Gn)return Gn;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Mo__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return Gn=JSON.parse(Mo__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),Gn}catch{}return null}var xd=xm()||{collections:[],globals:[]},kd=bm(xd);gm(kd.collections,xd.collectionOverrides);var hd=kd,Zo=hd.collections,wd=hd.globals,Qs=["users","audit_logs"];Object.values(Zo).filter(e=>!Qs.includes(e.slug)&&e.admin?.hidden!==true);function Jn({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,u]=Ta.useState(null),m=JSON.stringify(n||{}),v=JSON.stringify(s||{});Ta.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let f=setTimeout(async()=>{try{let b="";if(i)b=`${wr}/${i}/dynamic-options/${e.name}`;else if(l)b=`${wr}/globals/${l}/dynamic-options/${e.name}`;else return;let p=await lt(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(m),siblingData:JSON.parse(v)})});if(p.ok){let h=await p.json();h.options&&u(h.options);}}catch(b){console.error("Failed to fetch dynamic options:",b);}},300);return ()=>clearTimeout(f)},[m,v,e.name,e.options,i,l]);let x=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?x=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(x=e.options)),e.dynamicOptions==="collections"&&(x=Object.keys(Zo).filter(g=>g!=="media").map(g=>({label:Zo[g]?.label||g,value:g}))),jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:g=>{if(e.hasMany){let f=Array.from(g.target.selectedOptions,b=>b.value);r?.(f);}else r?.(g.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,style:{color:e.hasMany?void 0:x.find(g=>g.value===t)?.color||void 0},className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),x.map(g=>jsxRuntime.jsx("option",{value:g.value,style:{color:g.color||void 0,fontWeight:g.color?"bold":"normal"},children:g.label},g.value))]})})}function Xn({icon:e,title:t,description:r,action:o}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 justify-center py-16 px-8",children:[e&&jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:e}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:t}),r&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:r}),o]})}function ai(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function Em({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:i,transform:l,transition:d,isDragging:c}=sortable.useSortable({id:e}),u={transform:utilities.CSS.Transform.toString(l),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxRuntime.jsxs("span",{ref:i,style:u,className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)] border border-transparent ${c?"border-[var(--kyro-primary)] shadow-sm bg-[var(--kyro-sidebar-active)]/20":""}`,children:[!a&&jsxRuntime.jsx("div",{...n,...s,className:"cursor-grab active:cursor-grabbing hover:bg-[var(--kyro-sidebar-active)]/20 rounded p-0.5 text-[var(--kyro-sidebar-active)] opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})}function Mm({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=reactI18next.useTranslation(),[s,i]=Ta.useState(false),[l,d]=Ta.useState(""),[c,u]=Ta.useState([]),[m,v]=Ta.useState(false),[x,g]=Ta.useState([]),f=Ta.useRef(new Set),b=Ta.useRef(null),p=Ta.useRef(()=>{});p.current=r||(()=>{});let h=e.hasMany,A=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],$=A.length>1,[T,k]=Ta.useState(A[0]||""),y=Ta.useCallback(()=>t?(h?Array.isArray(t)?t:[]:t?[t]:[]).map(oe=>typeof oe=="object"&&oe!==null?oe.value||oe.id||"":String(oe)).filter(Boolean):[],[t,h]),w=Ta.useCallback(E=>{E.length!==0&&E.forEach(oe=>{if(f.current.has(oe))return;f.current.add(oe);let ie=$?(()=>{if(!t)return T;let G=(h?Array.isArray(t)?t:[]:[t]).find(ye=>typeof ye=="object"&&ye!==null?ye.value===oe||ye.id===oe:false);return G&&typeof G=="object"&&G.relationTo||T})():T;Ee(`/api/${ie}/${oe}`).then(ee=>{let G=ee.data||ee;!G||typeof G!="object"||g(ye=>ye.some(De=>De.id===oe)?ye:[...ye,{...G,id:String(G.id),relationTo:ie}]);}).catch(()=>{});});},[$,t,T,h]);Ta.useEffect(()=>{let E=y();w(E);},[y,w]);let D=Ta.useCallback((E="")=>{v(true);let ie=`/api/${T}?${nn(E,["title","name","label","email"])}`;Ee(ie).then(ee=>{u(G=>{let ye=new Set(G.map(L=>L.id)),De=(ee.docs||[]).filter(L=>!ye.has(L.id)).map(L=>({...L,id:L.id}));return [...G,...De]}),v(false);}).catch(()=>{v(false);});},[T]);Ta.useEffect(()=>{s&&(u([]),D(l));},[s,T]),Ta.useEffect(()=>{let E=oe=>{b.current&&!b.current.contains(oe.target)&&i(false);};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);let U=E=>typeof E=="object"&&E!==null?E.value||E.id||"":String(E),O=E=>{let oe=E.id;return t?h&&Array.isArray(t)?t.some(ie=>U(ie)===oe):U(t)===oe:false},z=E=>{let oe=E.id;if(h){let ie=Array.isArray(t)?t:[];if(O(E))p.current?.(ie.filter(ee=>U(ee)!==oe));else {let ee=$?{relationTo:T,value:oe}:oe;p.current?.([...ie,ee]);}}else if(O(E))p.current?.(null);else {let ie=$?{relationTo:T,value:oe}:oe;p.current?.(ie),i(false),d("");}},P=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),R=E=>{let{active:oe,over:ie}=E;if(!ie||oe.id===ie.id)return;let ee=h?Array.isArray(t)?t:[]:[],G=ee.findIndex(De=>U(De)===oe.id),ye=ee.findIndex(De=>U(De)===ie.id);if(G!==-1&&ye!==-1){let De=[...ee],[L]=De.splice(G,1);De.splice(ye,0,L),p.current?.(De);}},Ae=()=>{if(!t)return null;let E=h?Array.isArray(t)?t:[]:t?[t]:[],oe=E.map(ie=>U(ie));return h&&E.length>1?jsxRuntime.jsx(core.DndContext,{sensors:P,collisionDetection:core.closestCenter,onDragEnd:R,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:oe,strategy:sortable.horizontalListSortingStrategy,children:E.map(ie=>{let ee=U(ie),G=x.find(L=>L.id===ee),ye=G?ai(G):ee.slice(0,12),De=$&&G?G.relationTo:null;return jsxRuntime.jsx(Em,{id:ee,label:ye,relation:De,onRemove:()=>{let L=E.filter(W=>U(W)!==ee);p.current?.(L);},disabled:a},ee)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:E.map(ie=>{let ee=U(ie),G=x.find(L=>L.id===ee),ye=G?ai(G):ee.slice(0,12),De=$&&G?G.relationTo:null;return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[De&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[De,":"]}),ye,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let L=E.filter(W=>U(W)!==ee);p.current?.(h?L:L[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]},ee)})})};return jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[e.label&&jsxRuntime.jsxs("label",{className:"block text-sm font-medium text-[var(--kyro-text-primary)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]}),jsxRuntime.jsxs("div",{ref:b,className:"relative",children:[$&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:A.map(E=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{k(E),u([]),d("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${T===E?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:E},E))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:E=>{d(E.target.value),i(true),D(E.target.value);},onFocus:()=>i(true),placeholder:e.admin?.placeholder||`Search ${T}...`,disabled:a||(typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly),className:"w-full pl-9 pr-10 py-2 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent disabled:opacity-50"}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:m?jsxRuntime.jsx(Ql.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(Ql.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${s?"rotate-180":""}`})})]}),s&&jsxRuntime.jsx("div",{className:"relative z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-64 overflow-auto",children:m?jsxRuntime.jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):c.length===0?jsxRuntime.jsx(Xn,{title:n("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsxRuntime.jsx("div",{className:"py-1",children:c.map(E=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>z(E),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${O(E)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:ai(E)}),O(E)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in E&&typeof E.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:E.slug})]},E.id))})}),Ae()]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-muted)]",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-error)]",children:o})]})}var Oa=Mm;var Co=Ta.createContext(null);function Cd(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=ni(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=ta(a),{blocks:i}=o(),l=[...i];n!==void 0?l.splice(n,0,s):l.push(s),r({blocks:l});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:s}=o(),i=za(s,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=[...l];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:l,found:false}});if(i!==s){r({blocks:i});let{onBlocksChange:l}=o();l&&l();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),s=za(n,i=>{let l=i.filter(d=>d.id!==a);return l.length!==i.length?{newList:l,found:true}:{newList:i,found:false}});if(s!==n){r({blocks:s});let{onBlocksChange:i}=o();i&&i();}},moveBlock:(a,n)=>{let{blocks:s}=o(),i=za(s,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<l.length){let u=[...l];return [u[d],u[c]]=[u[c],u[d]],{newList:u,found:true}}}return {newList:l,found:false}});if(i!==s){r({blocks:i});let{onBlocksChange:l}=o();l&&l();}}}))}function ni(e){return Array.isArray(e)?e.map(t=>{let r={...t,id:t.id||Math.random().toString(36).substr(2,9)};return r.children&&Array.isArray(r.children)&&(r.children=ni(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?ni(o.children):o.children}))}),r}):[]}function ta(e){let t=Om(e),{options:r,children:o,...a}=t;return {id:Math.random().toString(36).substr(2,9),type:e,name:"",data:a,options:r,children:o,order:Date.now()}}function Om(e){return {heading:{level:1,text:""},"heading-subheading":{title:"",subtitle:""},hero:{isMultiScreen:false},card:{title:"",description:"",icon:"",link:"",linkText:"",isMultiCard:false},paragraph:{text:""},divider:{},callout:{text:"",variant:"info"},image:{src:"",alt:"",caption:""},video:{src:"",title:""},list:{type:"unordered",items:""},code:{language:"plaintext",code:""},link:{url:"",text:""},table:{rows:3,columns:3,content:""},quote:{text:"",author:""},file:{filename:"",url:""},columns:{columns:2,direction:"horizontal"},vstack:{direction:"vertical",gap:"md"},container:{options:{backgroundColor:"transparent",padding:"md",width:"full",margin:"none",minHeight:"none",borderRadius:"none"},children:[]},button:{text:"Button",url:"",variant:"primary",size:"md"},accordion:{title:"Accordion Item",content:""},gallery:{images:[]},tabs:{tabs:[{label:"Tab 1",content:""}]}}[e]||{}}function Ke(e){let t=Ta.useContext(Co);if(t)return zustand.useStore(t,r=>{let o=a=>{for(let n of a){if(n.id===e)return n;if(n.children&&n.children.length>0){let s=o(n.children);if(s)return s}if(n.data?.columnData){for(let s of n.data.columnData)if(s&&s.children&&s.children.length>0){let i=o(s.children);if(i)return i}}}};return o(r.blocks)})}function ze(){let e=Ta.useContext(Co);if(!e)throw new Error("useBlockActions must be used within a BlocksContext.Provider");return {updateBlock:(t,r)=>e.getState().updateBlock(t,r),removeBlock:t=>e.getState().removeBlock(t),moveBlock:(t,r)=>e.getState().moveBlock(t,r)}}function za(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(s=>{let i={...s},l=false;if(s.children&&s.children.length>0){let d=za(s.children,t);d!==s.children&&(i.children=d,l=true);}if(s.data?.columnData&&Array.isArray(s.data.columnData)){let d=s.data.columnData.map(c=>{if(c.children&&c.children.length>0){let u=za(c.children,t);if(u!==c.children)return {...c,children:u}}return c});d.some((c,u)=>c!==s.data.columnData[u])&&(i.data={...i.data,columnData:d},l=true);}return l&&(a=true),l?i:s});return a?n:e}function ja({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let{t:n}=reactI18next.useTranslation(),[s,i]=Ta__default.default.useState(null),l=async()=>{try{i(null);let d=await navigator.clipboard.readText(),c=JSON.parse(d);c.__kyro_block?o&&o(c):i("Clipboard does not contain a valid Kyro block.");}catch(d){i("Failed to read block from clipboard."),console.error(d);}};return e?jsxRuntime.jsxs(yr,{open:e,onClose:t,title:n("tooltips.insertBlock",{defaultValue:"Insert Block"}),width:"md",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)] mb-4",children:"Drag blocks into the editor or click to insert"}),o&&jsxRuntime.jsxs("div",{className:"mb-6 pb-6 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 py-2 px-4 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] text-sm font-semibold transition-all hover:bg-[var(--kyro-primary)]/5",children:[jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-4 h-4"}),"Paste Block from Clipboard"]}),s&&jsxRuntime.jsx("p",{className:"text-xs text-red-500 mt-2 text-center font-medium",children:s})]}),a]}):null}function Sd({block:e,onSelect:t,children:r}){let{attributes:o,listeners:a,setNodeRef:n,isDragging:s}=core.useDraggable({id:`drawer-${e.type}`,data:{source:"drawer",blockType:e.type}});return jsxRuntime.jsxs("div",{ref:n,...a,...o,onClick:()=>t(e.type),className:`flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group ${s?"opacity-50 border-[var(--kyro-primary)]":""}`,style:{opacity:s?.5:1},children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:r||jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)] leading-tight",children:e.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 leading-tight",children:e.description})]})]})}var si=({text:e="",onChange:t,compact:r=false})=>{let{t:o}=reactI18next.useTranslation();return jsxRuntime.jsx("div",{className:r?"":"space-y-3",children:jsxRuntime.jsx("input",{type:"text",value:e,onChange:n=>t("text",n.target.value),className:r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.enterHeadingText",{defaultValue:"Enter heading text..."})})})};var Ao=({id:e,type:t,label:r,children:o,className:a=""})=>{let{t:n}=reactI18next.useTranslation(),{moveBlock:s,removeBlock:i}=ze();return jsxRuntime.jsxs("div",{className:`block-${t} border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group bg-[var(--kyro-surface)] transition-all hover:border-[var(--kyro-primary)]/30 ${a}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] tracking-wider",children:r||t}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:n("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var Td=({block:e,index:t})=>{let r=Ke(e.id),{updateBlock:o}=ze(),a=r?.data||e.data||{},n=(s,i)=>{o(e.id,{data:{...a,[s]:i}});};return jsxRuntime.jsx(Ao,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx(si,{text:a.text||"",onChange:n,compact:true})})};var Fd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a}=ze(),n=o?.data||e.data||{},s=(i,l)=>{a(e.id,{data:{...n,[i]:l}});};return jsxRuntime.jsx(Ao,{id:e.id,type:"paragraph",label:"Paragraph",children:jsxRuntime.jsx("textarea",{value:n.text||"",onChange:i=>s("text",i.target.value),className:"w-full px-3 py-3 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm min-h-[100px] resize-none",placeholder:r("fields.enterParagraphText",{defaultValue:"Enter paragraph text..."})})})};var Rd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsxRuntime.jsx(mr,{field:{label:"Image Asset",name:"src",maxCount:1},value:i.src,onChange:d=>l("src",d)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Alt Text"}),jsxRuntime.jsx("input",{type:"text",value:i.alt||"",onChange:d=>l("alt",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.alternativeText",{defaultValue:"Alternative text..."})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Caption"}),jsxRuntime.jsx("input",{type:"text",value:i.caption||"",onChange:d=>l("caption",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.imageCaption",{defaultValue:"Image caption..."})})]})]})]})};var li=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{let {t:n}=reactI18next.useTranslation();e.includes("youtube.com")||e.includes("vimeo.com")||e.includes("youtu.be");return a?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"url",value:e,onChange:i=>r("src",i.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:i=>r("title",i.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(mr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(i=>r("src",i))}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsxRuntime.jsx("input",{type:"url",value:e,onChange:i=>r("src",i.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:i=>r("title",i.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]})};var Bd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(li,{src:i.src||"",title:i.title||"",onChange:l,onUploadChange:d=>l("src",d),compact:true})]})};function sy({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:i,isDragging:l}=sortable.useSortable({id:e}),d={transform:utilities.CSS.Transform.toString(s),transition:i,zIndex:l?10:1,opacity:l?.8:1};return jsxRuntime.jsxs("div",{ref:n,style:d,className:`flex items-center gap-2 group/item p-1.5 hover:bg-[var(--kyro-surface-accent)]/50 rounded-md transition-colors ${l?"bg-[var(--kyro-surface-accent)] shadow-sm":""}`,children:[jsxRuntime.jsx("div",{...o,...a,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",onClick:c=>c.stopPropagation(),children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:"opacity-0 group-hover/item:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",children:"\xD7"})]})}var Ha=({items:e=[],onChange:t,compact:r=false})=>{let{t:o}=reactI18next.useTranslation(),[a,n]=Ta__default.default.useState(""),[s,i]=Ta__default.default.useState([]);Ta__default.default.useEffect(()=>{let x=s.map(g=>g.text);JSON.stringify(x)!==JSON.stringify(e)&&i(e.map((g,f)=>({id:`${g}-${f}-${Math.random().toString(36).substr(2,4)}`,text:g})));},[e]);let l=()=>{a.trim()&&(t([...e,a.trim()]),n(""));},d=x=>{x.key==="Enter"&&(x.preventDefault(),l());},c=x=>{t(e.filter((g,f)=>f!==x));},u=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),m=x=>{let{active:g,over:f}=x;if(!f||g.id===f.id)return;let b=s.findIndex(h=>h.id===g.id),p=s.findIndex(h=>h.id===f.id);if(b!==-1&&p!==-1){let h=[...e],[A]=h.splice(b,1);h.splice(p,0,A),t(h);}},v=r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxRuntime.jsx(core.DndContext,{sensors:u,collisionDetection:core.closestCenter,onDragEnd:m,children:jsxRuntime.jsxs("div",{className:r?"space-y-1.5":"space-y-2",children:[e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:"No items. Type below to add."}):jsxRuntime.jsx(sortable.SortableContext,{items:s.map(x=>x.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:s.map((x,g)=>jsxRuntime.jsx(sy,{id:x.id,text:x.text,onRemove:()=>c(g)},x.id))})}),jsxRuntime.jsx("input",{type:"text",value:a,onChange:x=>n(x.target.value),onKeyDown:d,className:v,placeholder:o("fields.typeAndPressEnter",{defaultValue:"Type and press Enter to add..."})})]})})};var Ed=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=Array.isArray(i.items)?i.items:[],d=c=>{a(e.id,{data:{...i,items:c}});};return jsxRuntime.jsxs("div",{className:"block-list border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"List"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ha,{items:l,onChange:d,compact:true})]})};var Md=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"group/block relative border border-[var(--kyro-border)] rounded-2xl p-6 mb-6 transition-all duration-300 bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/20",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-9 h-9 rounded-xl bg-[var(--kyro-primary)]/10 flex items-center justify-center text-[var(--kyro-primary)] transition-transform group-hover/block:scale-110",children:jsxRuntime.jsx(Ql.CodeXml,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxRuntime.jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",i.language||"javascript"]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-1.5 opacity-0 group-hover/block:opacity-100 transition-all translate-x-2 group-hover/block:translate-x-0",children:jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)]/50 p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1.5 hover:bg-[var(--kyro-surface)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsxRuntime.jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(La,{field:{type:"code",name:"code",label:"Source Code",language:i.language||"javascript"},value:i.code||"",onChange:d=>l("code",d)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 bg-[var(--kyro-surface-accent)]/20 p-4 rounded-xl border border-[var(--kyro-border)]/50",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2 block",children:"Syntax Highlighting"}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("select",{value:i.language||"javascript",onChange:d=>l("language",d.target.value),className:"w-full pl-4 pr-10 py-2.5 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl text-xs font-medium text-[var(--kyro-text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)]/20 focus:border-[var(--kyro-primary)] transition-all appearance-none cursor-pointer",children:[jsxRuntime.jsx("option",{value:"plaintext",children:"Plain Text"}),jsxRuntime.jsx("option",{value:"javascript",children:"JavaScript"}),jsxRuntime.jsx("option",{value:"typescript",children:"TypeScript"}),jsxRuntime.jsx("option",{value:"python",children:"Python"}),jsxRuntime.jsx("option",{value:"json",children:"JSON"}),jsxRuntime.jsx("option",{value:"html",children:"HTML"}),jsxRuntime.jsx("option",{value:"css",children:"CSS"}),jsxRuntime.jsx("option",{value:"sql",children:"SQL"}),jsxRuntime.jsx("option",{value:"rust",children:"Rust"}),jsxRuntime.jsx("option",{value:"markdown",children:"Markdown"})]}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsxRuntime.jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var Ld=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(mr,{field:{label:"File",name:"file",maxCount:1},value:i.file,onChange:d=>l("file",d)})]})};var yi=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ta.useState(0),n=jsxRuntime.jsx("div",{className:"flex justify-end gap-1 mb-2"}),s=(m,v)=>{let x=[...e];x[m]={...x[m],title:v},t(x);},i=(m,v)=>{let x=[...e];x[m]={...x[m],content:v},t(x);},l=m=>{let v=e.filter((x,g)=>g!==m);t(v),o===m?a(null):o!==null&&o>m&&a(o-1);},d=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},c="w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",u="w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return r?jsxRuntime.jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-1.5",children:e.map((m,v)=>{let{t:x}=reactI18next.useTranslation(),g=o===v;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:v),className:"w-full flex items-center justify-between p-2.5 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:m.title||`Item ${v+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),l(v);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:x("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5"})}),g?jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:f=>s(v,f.target.value),onClick:f=>f.stopPropagation(),className:u,placeholder:x("fields.itemTitle",{defaultValue:"Item title..."})}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:f=>i(v,f.target.value),onClick:f=>f.stopPropagation(),className:`${u} min-h-[60px] resize-none`,placeholder:x("fields.itemContent",{defaultValue:"Item content..."})})]})]},v)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((m,v)=>{let{t:x}=reactI18next.useTranslation(),g=o===v;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:v),className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:m.title||`Item ${v+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),l(v);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:x("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})}),g?jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:f=>s(v,f.target.value),className:c,placeholder:x("fields.itemTitle",{defaultValue:"Item title..."})}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:f=>i(v,f.target.value),className:`${c} min-h-[60px] resize-none`,placeholder:x("fields.itemContent",{defaultValue:"Item content..."})})]})]},v)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var Vd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=Array.isArray(i.items)?i.items:[],d=c=>{a(e.id,{data:{...i,items:c}});};return jsxRuntime.jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(yi,{items:l,onChange:d,compact:true})]})};var Od=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=d=>{a(e.id,{data:{...i,content:d}});};return jsxRuntime.jsxs("div",{className:"block-richtext border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Ql.AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Wo,{field:{name:"content",label:"Content",type:"richtext"},value:i.content,onChange:l})]})};var fi=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let{t:s}=reactI18next.useTranslation(),i=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",l=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return n?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${i} font-bold text-base`,placeholder:s("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:s("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.ctaText",{defaultValue:"CTA text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${i} font-bold text-base`,placeholder:s("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:s("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.ctaText",{defaultValue:"CTA text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};function Zn({field:e,value:t,onChange:r,renderField:o}){let a=t||{};return jsxRuntime.jsxs("div",{className:"kyro-form-group border border-[var(--kyro-border)] rounded-[var(--kyro-radius-lg)] p-6 bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-6 border-b border-[var(--kyro-border)] pb-2",children:jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)]",children:e.label||e.name})}),jsxRuntime.jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields.map(n=>o(n,a,r))})]})}var Ny=new Set(["text","number","checkbox","select","radio","color","email","password"]);function Cy(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>Ny.has(r.type))}function jd({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:i,onRemove:l,disabled:d,compact:c,getItemLabel:u}){let{t:m}=reactI18next.useTranslation(),{attributes:v,listeners:x,setNodeRef:g,transform:f,transition:b,isDragging:p}=sortable.useSortable({id:e}),h={transform:utilities.CSS.Transform.toString(f),transition:b,zIndex:p?10:1,opacity:p?.8:1};return c?jsxRuntime.jsxs("div",{ref:g,style:h,className:`flex items-start gap-2 px-3 py-1.5 border-b border-[var(--kyro-border)] last:border-b-0 hover:bg-[var(--kyro-sidebar-active)]/5 transition-colors ${p?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...v,...x,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 mt-1",children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsxRuntime.jsx("div",{className:`flex-1 min-w-0 ${(n.fields||[]).length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:(n.fields||[]).map(A=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(A,a,i)},A.name))}),jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:l,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-0.5 mt-1.5 flex-shrink-0",title:m("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsxRuntime.jsxs("div",{ref:g,style:h,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${p?"border-[var(--kyro-primary)] shadow-md":""}`,children:[jsxRuntime.jsxs("div",{className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[jsxRuntime.jsx("div",{...v,...x,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),o(r?null:t));},className:"text-xs font-bold tracking-widest text-[var(--kyro-text-muted)] truncate cursor-pointer flex-1 py-1 text-left",children:u(a)||`Item ${t+1}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:A=>{A.stopPropagation(),l();},className:"text-[11px] font-bold text-[var(--kyro-error)] opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-30 hover:bg-[var(--kyro-danger-bg)] rounded px-1.5 py-0.5",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(r?null:t),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",children:r?jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsxRuntime.jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:(n.fields||[]).map(A=>s(A,a,i))})]})}function es({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=e.fields||[],i=s[0],l=i?.name||"user",d=i?.type==="relationship",[c,u]=Ta__default.default.useState(0);Ta__default.default.useEffect(()=>{let b=false,p=n.filter(h=>typeof h!="object"||h===null?(b=true,false):true).map(h=>!h.id&&!h._key?(b=true,{...h,id:Math.random().toString(36).substr(2,9)}):h);b&&r(p);},[t,r]);function m(b){for(let p of ["label","title","name"]){let h=b[p];if(h&&typeof h=="string")return h}for(let p of s){if(p.type==="text"||p.type==="textarea"){let h=b[p.name];if(h&&typeof h=="string")return h}if(p.type==="group"&&p.fields){for(let h of p.fields)if(h.type==="text"||h.type==="textarea"){let $=b[p.name]?.[h.name];if($&&typeof $=="string")return $}}}return ""}let v=Cy(e),x=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),g=b=>{let{active:p,over:h}=b;if(!h||p.id===h.id)return;let A=n.findIndex(T=>(T.id||T._key)===p.id),$=n.findIndex(T=>(T.id||T._key)===h.id);if(A!==-1&&$!==-1){let T=[...n],[k]=T.splice(A,1);T.splice($,0,k),r(T);}},f=Ta__default.default.useMemo(()=>n.map(b=>b?.id||b?._key||""),[n]);return d?jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(Oa,{field:{name:l,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(b=>b[l]).filter(Boolean),onChange:b=>{let p=(b||[]).map(h=>({[l]:h,id:Math.random().toString(36).substr(2,9)}));r(p);},disabled:a})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(core.DndContext,{sensors:x,collisionDetection:core.closestCenter,onDragEnd:g,children:v?jsxRuntime.jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md overflow-hidden",children:[jsxRuntime.jsx(sortable.SortableContext,{items:f,strategy:sortable.verticalListSortingStrategy,children:n.map((b,p)=>jsxRuntime.jsx(jd,{id:b.id||b._key||`idx-${p}`,index:p,isOpen:false,setOpenIndex:()=>{},item:b,field:e,renderField:o,onChangeItem:h=>{let A=[...n];A[p]=h,r(A);},onRemove:()=>r(n.filter((h,A)=>A!==p)),disabled:a,compact:true,getItemLabel:m},b.id||b._key||p))}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-2 border-2 border-dashed border-[var(--kyro-border)] rounded-none text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>r([...n,{id:Math.random().toString(36).substr(2,9)}]),children:"+ Add Item"})]}):jsxRuntime.jsxs("div",{className:"kyro-form-array border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md p-3 space-y-4",children:[jsxRuntime.jsx(sortable.SortableContext,{items:f,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((b,p)=>{let h=c===p;return jsxRuntime.jsx(jd,{id:b.id||b._key||`idx-${p}`,index:p,isOpen:h,setOpenIndex:u,item:b,field:e,renderField:o,onChangeItem:A=>{let $=[...n];$[p]=A,r($);},onRemove:()=>r(n.filter((A,$)=>$!==p)),disabled:a,compact:false,getItemLabel:m},b.id||b._key||p)})})}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-3 border-2 border-dashed border-[var(--kyro-border)] rounded-lg text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>{let b=Math.random().toString(36).substr(2,9);r([...n,{id:b}]),u(n.length);},children:"+ Add Item"})]})})]})}var Hd="other";function _d(){return Hd}function ts(e){Hd=e;}var To=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{ts("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(Qo,{field:e,value:t,onChange:d,error:o,disabled:a});case "icon":return jsxRuntime.jsx(Ln,{field:e,value:t,onChange:d,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(Qo,{field:{...e,variant:"textarea"},value:t,onChange:d,error:o,disabled:a});case "password":return jsxRuntime.jsx(Qo,{field:{...e,variant:"password"},value:t,onChange:d,error:o,disabled:a});case "secret":return jsxRuntime.jsx(zn,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Hn,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(_n,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx(Jn,{field:e,value:t,onChange:d,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l});case "date":return jsxRuntime.jsx(Kn,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(Wo,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(Gs,{field:e,value:t,onChange:d,disabled:a,error:o});case "code":return jsxRuntime.jsx(La,{field:e,value:t,onChange:d,disabled:a,error:o});case "image":case "upload":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx(mr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx(Oa,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx(Ha,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(es,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,u,m)=>{let v=u[c.name];return jsxRuntime.jsx(To,{field:c,value:v,onChange:x=>{m({...u,[c.name]:x});},disabled:a,error:o},c.name)}});case "blocks":return jsxRuntime.jsx(bi,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsxRuntime.jsx(Zn,{field:e,value:t,onChange:r,renderField:(c,u,m)=>{let v=u[c.name];return jsxRuntime.jsx(To,{field:c,value:v,onChange:x=>{m({...u,[c.name]:x});},disabled:a,error:o,collectionSlug:i,globalSlug:l},c.name)}});case "color":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("input",{type:"color",value:t||"#000000",onChange:c=>r(c.target.value),disabled:a,className:"h-10 w-14 p-1 cursor-pointer bg-[var(--kyro-input-bg)] border border-[var(--kyro-input-border)] rounded-lg"}),jsxRuntime.jsx("input",{type:"text",className:"kyro-form-input font-mono ",value:t||"",onChange:c=>r(c.target.value),disabled:a,placeholder:"#000000"})]})});default:return jsxRuntime.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg text-amber-800 text-xs italic",children:['Field type "',e.type,'" is not yet supported in this renderer.']})}};var aa=({block:e,blockSchema:t,onClose:r})=>{let o=Ke(e.id),{updateBlock:a}=ze(),n=o?.data||e.data||{},s=o?.children||e.children||[],i=(u,m)=>{a(e.id,{data:{...n,[u]:m}});},l=u=>{a(e.id,{children:u});},d=()=>t&&Array.isArray(t.fields)?jsxRuntime.jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(u=>{if(u.admin?.condition){if(typeof u.admin.condition=="function")try{let v={values:n,...n};if(!u.admin.condition(v,v))return null}catch(v){console.warn(`Condition error for field ${u.name}:`,v);}else if(typeof u.admin.condition=="object")try{let v=u.admin.condition,x=v.field,g=n[x],f=!0;if("equals"in v?f=g===v.equals:"notEquals"in v?f=g!==v.notEquals:"in"in v&&Array.isArray(v.in)&&(f=v.in.includes(g)),!f)return null}catch(v){console.warn(`Declarative condition error for field ${u.name}:`,v);}}let m=n[u.name];return jsxRuntime.jsx("div",{className:"kyro-block-field-row border-b border-[var(--kyro-border)]/30 pb-3 last:border-b-0 last:pb-0",children:jsxRuntime.jsx(To,{field:u,value:m,onChange:v=>i(u.name,v)})},u.name)})}):jsxRuntime.jsxs("div",{className:"text-center py-8 text-[var(--kyro-text-muted)] text-sm italic",children:['No schema defined for block type "',e.type,'"']}),c=Ve[e.type]||Ve.default;return jsxRuntime.jsxs(yr,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:c.border,children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[d(),s.length>0&&jsxRuntime.jsxs("div",{className:"pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",s.length,")"]}),jsxRuntime.jsx(to,{blockId:e.id,children:s,onUpdateChildren:l})]})]}),jsxRuntime.jsx("div",{className:"mt-6 pt-4 border-t border-[var(--kyro-border)]",children:jsxRuntime.jsx("button",{type:"button",onClick:r,className:"w-full py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-lg font-medium hover:opacity-90 transition-opacity",children:"Done"})})]})};var Sy=6,to=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Sy})=>{let[n,s]=Ta.useState(false),[i,l]=Ta.useState(new Set),[d,c]=Ta.useState(null),[u,m]=Ta.useState(null),v=Ta.useContext(Co);if(!v)throw new Error("ChildBlocksTree must be used within a BlocksContext");let x=zustand.useStore(v,y=>y.dynamicCategories),g=zustand.useStore(v,y=>y.allowedBlocks),f=o<a,b=16,p=y=>{let w=ta(y);r([...t,w]),c(w.id);},h=y=>{let w=t.filter(D=>D.id!==y);r(w);},$=(y,w)=>{let D=t.map(U=>U.id===y?{...U,children:w}:U);r(D);},T=y=>{l(w=>{let D=new Set(w);return D.has(y)?D.delete(y):D.add(y),D});},k=y=>{let w=y.children&&y.children.length>0,D=i.has(y.id);xi(y.type);let O=w,z=d===y.id,P=g.find(R=>R.slug===y.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${z?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${f?"cursor-pointer":""}`,style:{marginLeft:o*b},onClick:()=>{f&&c(z?null:y.id);},children:[O?jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(y.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:D?jsxRuntime.jsx(Ql.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Gt[y.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Gt[y.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[Ga(y),y.data?.text?` - ${y.data.text.slice(0,30)}`:"",y.data?.heading?` - ${y.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),w&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[y.children.length," nested"]}),u===y.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(y.id),m(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),m(y.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),z&&jsxRuntime.jsx(aa,{block:y,onClose:()=>c(null)}),w&&D&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Wd,{parentId:y.id,children:y.children,onUpdateChildren:R=>$(y.id,R),depth:o+1,maxDepth:a})})]},y.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),f&&jsxRuntime.jsxs("div",{style:{marginLeft:o*b},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(ja,{open:n,onClose:()=>s(false),onSelect:p,children:x.map(y=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:y.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.blocks.map(w=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{p(w.slug),s(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Gt[w.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:w.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:w.admin?.description||""})]})]},w.slug))})]},y.title))})]}),t.length===0&&f&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*b},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*b},children:["Maximum nesting level (",a,") reached"]})]})},Wd=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=Ta.useState(false),[i,l]=Ta.useState(new Set),[d,c]=Ta.useState(null),[u,m]=Ta.useState(null),v=Ta.useContext(Co);if(!v)throw new Error("NestedChildBlocks must be used within a BlocksContext");let x=zustand.useStore(v,y=>y.dynamicCategories),g=zustand.useStore(v,y=>y.allowedBlocks),f=o<a,b=16,p=y=>{let w=ta(y);r([...t,w]),c(w.id);},h=y=>{let w=t.filter(D=>D.id!==y);r(w);},$=(y,w)=>{let D=t.map(U=>U.id===y?{...U,children:w}:U);r(D);},T=y=>{l(w=>{let D=new Set(w);return D.has(y)?D.delete(y):D.add(y),D});},k=y=>{let w=y.children&&y.children.length>0,D=i.has(y.id);xi(y.type);let O=w,z=d===y.id,P=g.find(R=>R.slug===y.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${z?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${f?"cursor-pointer":""}`,style:{marginLeft:o*b},onClick:()=>{f&&c(z?null:y.id);},children:[O?jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(y.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:D?jsxRuntime.jsx(Ql.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Gt[y.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Gt[y.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[Ga(y),y.data?.text?` - ${y.data.text.slice(0,30)}`:"",y.data?.heading?` - ${y.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),w&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[y.children.length," nested"]}),u===y.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(y.id),m(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),m(y.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),z&&jsxRuntime.jsx(aa,{block:y,onClose:()=>c(null)}),w&&D&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Wd,{parentId:y.id,children:y.children,onUpdateChildren:R=>$(y.id,R),depth:o+1,maxDepth:a})})]},y.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),f&&jsxRuntime.jsxs("div",{style:{marginLeft:o*b},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(ja,{open:n,onClose:()=>s(false),onSelect:p,children:x.map(y=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:y.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.blocks.map(w=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{p(w.slug),s(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Gt[w.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:w.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:w.admin?.description||""})]})]},w.slug))})]},y.title))})]}),t.length===0&&f&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*b},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*b},children:["Maximum nesting level (",a,") reached"]})]})};var qd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=o?.children??e.children??[],d=(c,u)=>{a(e.id,{data:{...i,[c]:u}});};return jsxRuntime.jsxs("div",{className:"block-hero border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Hero Section"})}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(fi,{heading:i.title||"",subheading:i.subtitle||"",ctaText:i.ctaText||"",ctaUrl:i.ctaUrl||"",onChange:d,compact:true}),jsxRuntime.jsx(mr,{field:{label:"Background",name:"bgImage",maxCount:1},value:i.bgImage,onChange:c=>d("bgImage",c)}),jsxRuntime.jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsxRuntime.jsx(to,{blockId:e.id,children:l,onUpdateChildren:c=>a(e.id,{children:c})})]})]})]})};var ki=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:s=false})=>{let{t:i}=reactI18next.useTranslation(),l=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",d=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:c=>n("title",c.target.value),className:`${l} font-bold text-base`,placeholder:i("fields.cardTitle",{defaultValue:"Card title..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:c=>n("description",c.target.value),className:d,placeholder:i("fields.cardDescription",{defaultValue:"Card description..."})}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:c=>n("icon",c.target.value),className:l,placeholder:i("fields.iconEmojiOrName",{defaultValue:"Icon (emoji or name)..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:c=>n("linkText",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:i("fields.linkText",{defaultValue:"Link text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:c=>n("link",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var Yd=({block:e,index:t})=>{let r=Ke(e.id),{updateBlock:o}=ze(),a=r?.data||e.data||{},n=(s,i)=>{o(e.id,{data:{...a,[s]:i}});};return jsxRuntime.jsx(Ao,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(ki,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Qd=({block:e,index:t})=>{let {t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze();o?.data??e.data??{};let l=o?.children??e.children??[];return jsxRuntime.jsxs("div",{className:"block-array border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Repeater"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(to,{blockId:e.id,children:l,onUpdateChildren:d=>a(e.id,{children:d})})})]})};var qa=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let{t:i}=reactI18next.useTranslation(),[l,d]=Ta.useState(false),[c,u]=Ta.useState(""),[m,v]=Ta.useState([]),[x,g]=Ta.useState(false),[f,b]=Ta.useState([]),[p,h]=Ta.useState(true);Ta.useEffect(()=>{Ee("/api/collections").then(O=>{b((O.collections||[]).map(z=>z.slug||z.name||z)),h(false);}).catch(()=>h(false));},[]);let A=(O="")=>{g(true);let z=`/api/${e}?${nn(O,[a],20)}`;Ee(z).then(P=>{v(P.docs||[]),g(false);}).catch(()=>g(false));};Ta.useEffect(()=>{l&&A(c);},[l,c,e,a]);let $=O=>O?.[a]||O?.title||O?.name||O?.label||O?.filename||O?.slug||O?.id||"Untitled",T=t?r:o?[o]:[],k=O=>{t?T.includes(O.id)?n("selectedIds",T.filter(z=>z!==O.id)):n("selectedIds",[...T,O.id]):(n("selectedId",O.id),n("selectedIds",[O.id]),d(false));},y=O=>T.includes(O),w=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",D=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",U=e&&typeof e=="string"&&e.length>0;return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-4",children:[jsxRuntime.jsxs("div",{className:s?"flex items-center gap-2":"space-y-3",children:[!U&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:p?jsxRuntime.jsx("div",{className:D+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:O=>n("relationTo",O.target.value),className:D,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),f.map(O=>jsxRuntime.jsx("option",{value:O,children:O},O))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:O=>n("hasMany",O.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsxRuntime.jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:c,onChange:O=>{u(O.target.value),d(true);},onFocus:()=>d(true),onBlur:()=>setTimeout(()=>d(false),200),placeholder:`Search ${e}...`,className:`${w} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:x&&jsxRuntime.jsx(Ql.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsxRuntime.jsx("div",{className:"absolute z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-48 overflow-auto",children:x?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):m.length===0?jsxRuntime.jsx(Xn,{title:i("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsxRuntime.jsx("div",{className:"py-1",children:m.map(O=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:z=>z.preventDefault(),onClick:()=>k(O),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${y(O.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:$(O)}),y(O.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},O.id))})})]}),T.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:T.map(O=>{let z=m.find(P=>P.id===O)||{id:O};return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[$(z),jsxRuntime.jsx("button",{type:"button",onMouseDown:P=>P.preventDefault(),onClick:()=>{t?n("selectedIds",T.filter(P=>P!==O)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]},O)})})]})};var ec=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",i.relationTo||"pages"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(qa,{relationTo:i.relationTo||"pages",hasMany:i.hasMany||false,selectedIds:Array.isArray(i.selectedIds)?i.selectedIds:[],selectedId:i.selectedId,labelField:i.labelField||"title",onChange:l,compact:true})]})};var Iy={heading:Td,paragraph:Fd,image:Rd,video:Bd,list:Ed,code:Md,file:Ld,accordion:Vd,richtext:Od,hero:qd,card:Yd,array:Qd,relationship:ec},Ve={featureSplit:{text:"text-indigo-500",border:"border-indigo-500",borderLeft:"border-l-indigo-500"},featureGrid:{text:"text-blue-500",border:"border-blue-500",borderLeft:"border-l-blue-500"},ctaBanner:{text:"text-amber-500",border:"border-amber-500",borderLeft:"border-l-amber-500"},testimonials:{text:"text-emerald-500",border:"border-emerald-500",borderLeft:"border-l-emerald-500"},faq:{text:"text-orange-500",border:"border-orange-500",borderLeft:"border-l-orange-500"},stats:{text:"text-rose-500",border:"border-rose-500",borderLeft:"border-l-rose-500"},logoCloud:{text:"text-cyan-500",border:"border-cyan-500",borderLeft:"border-l-cyan-500"},pricing:{text:"text-green-500",border:"border-green-500",borderLeft:"border-l-green-500"},team:{text:"text-violet-500",border:"border-violet-500",borderLeft:"border-l-violet-500"},recentFeed:{text:"text-sky-500",border:"border-sky-500",borderLeft:"border-l-sky-500"},processSteps:{text:"text-fuchsia-500",border:"border-fuchsia-500",borderLeft:"border-l-fuchsia-500"},formEmbed:{text:"text-pink-500",border:"border-pink-500",borderLeft:"border-l-pink-500"},videoShowcase:{text:"text-red-500",border:"border-red-500",borderLeft:"border-l-red-500"},hero:{text:"text-yellow-500",border:"border-yellow-500",borderLeft:"border-l-yellow-500"},card:{text:"text-teal-500",border:"border-teal-500",borderLeft:"border-l-teal-500"},default:{text:"text-zinc-400",border:"border-zinc-400",borderLeft:"border-l-zinc-400"}},Gt={heading:jsxRuntime.jsx(Ql.Heading1,{className:`w-4 h-4 ${Ve.default.text}`}),paragraph:jsxRuntime.jsx(Ql.AlignLeft,{className:`w-4 h-4 ${Ve.default.text}`}),image:jsxRuntime.jsx(Ql.Image,{className:`w-4 h-4 ${Ve.default.text}`}),video:jsxRuntime.jsx(Ql.Video,{className:`w-4 h-4 ${Ve.default.text}`}),list:jsxRuntime.jsx(Ql.List,{className:`w-4 h-4 ${Ve.default.text}`}),code:jsxRuntime.jsx(Ql.Code,{className:`w-4 h-4 ${Ve.default.text}`}),file:jsxRuntime.jsx(Ql.File,{className:`w-4 h-4 ${Ve.default.text}`}),accordion:jsxRuntime.jsx(Ql.ChevronDown,{className:`w-4 h-4 ${Ve.default.text}`}),richtext:jsxRuntime.jsx(Ql.AlignLeft,{className:`w-4 h-4 ${Ve.default.text}`}),hero:jsxRuntime.jsx(Ql.Star,{className:`w-4 h-4 ${Ve.hero.text}`}),card:jsxRuntime.jsx(Ql.Box,{className:`w-4 h-4 ${Ve.card.text}`}),array:jsxRuntime.jsx(Ql.ListOrdered,{className:`w-4 h-4 ${Ve.default.text}`}),relationship:jsxRuntime.jsx(Ql.Link2,{className:`w-4 h-4 ${Ve.default.text}`}),featureSplit:jsxRuntime.jsx(Ql.Columns3,{className:`w-4 h-4 ${Ve.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(Ql.Blocks,{className:`w-4 h-4 ${Ve.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(Ql.Sparkles,{className:`w-4 h-4 ${Ve.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(Ql.Users,{className:`w-4 h-4 ${Ve.testimonials.text}`}),faq:jsxRuntime.jsx(Ql.CircleHelp,{className:`w-4 h-4 ${Ve.faq.text}`}),stats:jsxRuntime.jsx(Ql.Activity,{className:`w-4 h-4 ${Ve.stats.text}`}),logoCloud:jsxRuntime.jsx(Ql.Image,{className:`w-4 h-4 ${Ve.logoCloud.text}`}),pricing:jsxRuntime.jsx(Ql.Tag,{className:`w-4 h-4 ${Ve.pricing.text}`}),team:jsxRuntime.jsx(Ql.Users,{className:`w-4 h-4 ${Ve.team.text}`}),recentFeed:jsxRuntime.jsx(Ql.Database,{className:`w-4 h-4 ${Ve.recentFeed.text}`}),processSteps:jsxRuntime.jsx(Ql.Clock,{className:`w-4 h-4 ${Ve.processSteps.text}`}),formEmbed:jsxRuntime.jsx(Ql.Mail,{className:`w-4 h-4 ${Ve.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(Ql.Video,{className:`w-4 h-4 ${Ve.videoShowcase.text}`})};function xi(e){return Iy[e]||null}function hi(e){return {paragraph:"Paragraph",heading:"Heading",image:"Image",video:"Video",list:"List",code:"Code",file:"File",accordion:"Accordion",array:"Repeater",relationship:"Relationship",richtext:"Rich Text",hero:"Hero Section",card:"Card Block",featureSplit:"Feature Split",featureGrid:"Feature Grid",ctaBanner:"CTA Banner",testimonials:"Testimonials Stack",faq:"FAQ Section",stats:"Stats & Metrics",logoCloud:"Logo Cloud",pricing:"Pricing Grid / Plan",team:"Team Profiles Showcase",recentFeed:"Dynamic Content Feed",processSteps:"Process Timeline / Steps",formEmbed:"Lead Intake Form",videoShowcase:"Cinematic Video Showcase",headingElement:"Heading",textElement:"Text",imageElement:"Image",richtextElement:"Rich Text",buttonElement:"Button",videoElement:"Video",listElement:"List"}[e]||e}function Ga(e){let t=e.name;return t&&t.trim()?t.trim():hi(e.type)}function Wy(e,t){if(t?.fields){for(let r of t.fields)if(r.type==="text"||r.type==="textarea"){let o=e[r.name];if(o&&typeof o=="string")return o}}return e.title||e.text||e.name||e.label||""}var qy=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{t:i}=reactI18next.useTranslation(),{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:m,isDragging:v}=sortable.useSortable({id:e.id}),{removeBlock:x,updateBlock:g}=ze(),f=o===e.id,[b,p]=Ta.useState(false),[h,A]=Ta.useState(false),[$,T]=Ta.useState(e.name||""),k=Ta.useRef(null),[y,w]=Ta.useState(false);Ta.useEffect(()=>{h&&k.current&&(k.current.focus(),k.current.select());},[h]);let D=Ta.useCallback(()=>{A(false);let R=$.trim();R!==(e.name||"").trim()&&g(e.id,{name:R||""});},[$,e.name,e.id,g]),U={transform:utilities.CSS.Transform.toString(u),transition:m,zIndex:v?10:1,opacity:v?.8:1},O=Ga(e),z=e.data||{},P=Wy(z,r);return s?jsxRuntime.jsxs("div",{ref:c,style:U,className:"relative group w-full",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-2 pl-7 pr-2 py-2 w-full bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-sm ${f?`${(Ve[e.type]||Ve.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 p-0.5 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] opacity-0 group-hover:opacity-100 transition-opacity hover:bg-[var(--kyro-surface-accent)] rounded touch-none",...l,...d,onClick:R=>R.stopPropagation(),children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-2.5 h-2.5"})}),Gt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:Gt[e.type]}),h?jsxRuntime.jsx("input",{ref:k,value:$,onChange:R=>T(R.target.value),onBlur:D,onKeyDown:R=>{R.key==="Enter"&&D(),R.key==="Escape"&&(T(e.name||""),A(false));},onClick:R=>R.stopPropagation(),className:"flex-1 min-w-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-1.5 py-0.5 text-[10px] font-medium text-[var(--kyro-text-primary)] outline-none"}):jsxRuntime.jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] flex-1 min-w-0 truncate transition-colors text-left",children:O}),b?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{x(e.id),p(false);},className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(e.name||""),A(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.rename",{defaultValue:"Rename"}),children:jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.duplicateInPlace",{defaultValue:"Duplicate in place"}),children:jsxRuntime.jsx(Ql.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),p(true);},className:"p-0.5 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:i("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),f&&jsxRuntime.jsx(aa,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:c,style:U,className:"relative group mb-2",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-3 p-3 bg-[var(--kyro-bg-secondary)] rounded-lg border transition-colors cursor-pointer ${f?`${(Ve[e.type]||Ve.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 touch-none",...l,...d,onClick:R=>R.stopPropagation(),children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-4 h-4"})}),Gt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:Gt[e.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[h?jsxRuntime.jsx("input",{ref:k,value:$,onChange:R=>T(R.target.value),onBlur:D,onKeyDown:R=>{R.key==="Enter"&&D(),R.key==="Escape"&&(T(e.name||""),A(false));},onClick:R=>R.stopPropagation(),placeholder:hi(e.type),className:"w-full max-w-[150px] sm:max-w-[250px] md:max-w-[400px] bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-2 py-0.5 text-xs font-semibold text-[var(--kyro-text-primary)] outline-none"}):jsxRuntime.jsxs("div",{className:"text-xs font-semibold text-[var(--kyro-text-secondary)] truncate transition-colors",children:[O,P&&typeof P=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",P.length>40?`${P.slice(0,40)}...`:P]})]}),!!r?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:r.admin.description})]}),!!e.children&&Array.isArray(e.children)&&e.children.length>0&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[e.children.length," nested"]}),b?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{x(e.id),p(false);},className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(e.name||""),A(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.renameBlock",{defaultValue:"Rename Block"}),children:jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.duplicateBlock",{defaultValue:"Duplicate Block"}),children:jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),p(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:i("tooltips.removeBlock",{defaultValue:"Remove Block"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5"})})]})]}),f&&jsxRuntime.jsx(aa,{block:e,blockSchema:r,onClose:()=>a(null)})]})},Jy=Ta__default.default.memo(qy),bi=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:i})=>{let[l,d]=Ta.useState(false),[c,u]=Ta.useState(false),m=Ta.useRef(null),v=e.admin?.pickerMode||"drawer",x=e.blocks||[],g=x.reduce((L,W)=>{let re=W.admin?.group||"Custom Blocks";return L[re]||(L[re]=[]),L[re].push(W),L},{}),f=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],b=Object.entries(g).sort(([L],[W])=>{let re=f.indexOf(L),H=f.indexOf(W);return re!==-1&&H!==-1?re-H:re!==-1?-1:H!==-1?1:L.localeCompare(W)}).map(([L,W])=>({title:L,blocks:W})),p=Ta.useRef(null);p.current||(p.current=Cd(x,b));let h=p.current,A=zustand.useStore(h,L=>L.blocks),[$,T]=Ta.useState(null),[k,y]=Ta.useState(null),w=Ta.useRef(A.length),D=Ta.useRef(new Set(A.map(L=>L.id))),U=Ta.useRef(false);Ta.useEffect(()=>{if(U.current&&A.length>w.current){let L=A.find(W=>W.id&&!D.current.has(W.id));L&&y(L.id);}w.current=A.length,D.current=new Set(A.map(L=>L.id));},[A]),Ta.useEffect(()=>(o&&h.getState().setOnBlocksChange(o),()=>{h.getState().setOnBlocksChange(()=>{});}),[o,h]);let O=Ta.useRef(null);Ta.useEffect(()=>{let L=Array.isArray(t)?t:[],W=O.current||[];if(wo(L,W))L.length===0&&!U.current&&(U.current=true,O.current=[]);else {let re=[...L];w.current=re.length,D.current=new Set(re.map(H=>H.id)),h.getState().setBlocks(re),O.current=re,U.current=true;}},[t,e.name,h]);let z=Ta.useRef(r);z.current=r,Ta.useEffect(()=>{if(!z.current)return;let L=O.current;L&&(wo(A,L)||(O.current=[...A],z.current(A)));},[A]);let R=Ta.useCallback(L=>{h.getState().addBlock(L);},[h]),Ae=Ta.useCallback(L=>{if(!(e.blocks||[]).some(fe=>fe.slug===L.type)){alert(`The block type "${L.type}" is not allowed in this collection.`);return}let H=Math.random().toString(36).substring(2,11),Te={...L.blockProps||{},id:H,type:L.type};h.getState().setBlocks([...A,Te]),d(false);},[e.blocks,A,h]),E=Ta.useCallback(L=>{let W=A.findIndex(we=>we.id===L);if(W===-1)return;let re=A[W],H=we=>{let S=Math.random().toString(36).substr(2,9);return {...we,id:S,children:we.children?we.children.map(j=>H(j)):we.children,data:we.data?JSON.parse(JSON.stringify(we.data)):we.data}},Te=H(re),fe=[...A];fe.splice(W+1,0,Te),h.getState().setBlocks(fe);},[A,h]),oe=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),ie=L=>{T(L.active);},ee=L=>{let{active:W,over:re}=L;if(T(null),!!re){if(W.id.toString().startsWith("drawer-")){let H=W.id.toString().replace("drawer-","");if(re.id.toString().startsWith("container-")){let Te=re.id.toString().replace("container-",""),fe=A.find(we=>we.id===Te);if(fe){let we=ta(H);h.getState().updateBlock(Te,{children:[...fe.children||[],we]});}}else {let Te=A.findIndex(fe=>fe.id===re.id);Te!==-1?h.getState().addBlock(H,Te):R(H);}return}if(W.id!==re.id){let H=A.findIndex(fe=>fe.id===W.id),Te=A.findIndex(fe=>fe.id===re.id);if(H!==-1&&Te!==-1){let fe=[...A],[we]=fe.splice(H,1);fe.splice(Te,0,we),h.getState().setBlocks(fe);}}}},G=$?b.flatMap(L=>L.blocks).find(L=>`drawer-${L.type}`===$.id)||A.find(L=>L.id===$.id):null;G?"label"in G?G.label:G.type:"Block";return Ta.useEffect(()=>{if(!c)return;let L=W=>{m.current&&!m.current.contains(W.target)&&u(false);};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[c]),jsxRuntime.jsx(Co.Provider,{value:p.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",tabIndex:0,style:{outline:"none"},children:[jsxRuntime.jsxs(core.DndContext,{sensors:oe,collisionDetection:core.closestCenter,onDragStart:ie,onDragEnd:ee,children:[jsxRuntime.jsxs("div",{className:v==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:`kyro-form-label ${v==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),v==="dropdown"?jsxRuntime.jsxs("div",{ref:m,className:"relative w-full",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>u(!c),disabled:n,className:"flex w-full items-center justify-between px-3 py-2 text-sm text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)] rounded-md transition-colors disabled:opacity-50",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Select an element to add..."})]}),jsxRuntime.jsx(Ql.ChevronDown,{className:`w-4 h-4 transition-transform ${c?"rotate-180 text-[var(--kyro-primary)]":"opacity-50"}`})]}),c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full mt-1 w-full bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:b.map(L=>jsxRuntime.jsxs("div",{children:[b.length>1&&jsxRuntime.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:L.title}),L.blocks.map(W=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{R(W.slug),u(false);},className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50 transition-colors text-left",children:[jsxRuntime.jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center text-[var(--kyro-text-muted)]",children:Gt[W.slug]||jsxRuntime.jsx(Ql.Box,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"text-xs font-semibold truncate",children:W.label}),W.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:W.admin.description})]})]},W.slug))]},L.title))})]}):jsxRuntime.jsxs("button",{type:"button",onClick:()=>d(true),disabled:n,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)]/30 rounded-md transition-colors disabled:opacity-50 font-semibold",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx(ja,{open:l,onClose:()=>d(false),onSelect:R,onPasteBlock:Ae,children:jsxRuntime.jsx("div",{className:"space-y-4",children:b.map(L=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:L.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:L.blocks.map(W=>jsxRuntime.jsx(Sd,{block:{type:W.slug,label:W.label,description:W.admin?.description||"",icon:null},onSelect:R,children:jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:Gt[W.slug]||jsxRuntime.jsx(Ql.Box,{className:"w-4 h-4"})})})},W.slug))})]},L.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:A.map(L=>L.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:v==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[A.map((L,W)=>{let re=e.blocks?.find(H=>H.slug===L.type);return jsxRuntime.jsx(Jy,{block:L,index:W,blockSchema:re,editingBlockId:k,setEditingBlockId:y,onDuplicate:E,compact:v==="dropdown"},L.id||W)}),A.length===0&&jsxRuntime.jsx("div",{className:v==="dropdown"?"text-xs text-[var(--kyro-text-muted)] italic py-1":"text-center py-12 text-[var(--kyro-text-muted)] border-2 border-dashed border-[var(--kyro-border)] rounded-lg",children:v==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsxRuntime.jsx(core.DragOverlay,{children:$&&G&&jsxRuntime.jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:G.label||G.type||"Block"})})]}),a&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:a})]})})};function rc(){let e=Ta.useRef([]),t=Ta.useRef(false);return {queueTask:Ta.useCallback((o,a)=>{e.current.push(o);async function n(){if(!t.current&&!(typeof a?.beforeProcess=="function"&&a.beforeProcess()===false))for(;e.current.length>0;){let s=e.current.pop();e.current=[],t.current=true;try{await s();}catch(i){console.error("Error in queued function:",i);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function oc({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:i}){let l=ge(),{confirm:d}=yt(),{formData:c,setFormData:u,setField:m,lastSavedData:v,setLastSavedData:x,setHasUnsavedChanges:g,isSlugLocked:f,loadDocument:b,setIsAutoSaving:p,setAutoSaveStatus:h,setVersions:A,setLoadingVersions:$,sidebarCollapsed:T,setSidebarCollapsed:k,getDraftCache:y,setDraftCache:w,clearDraftCache:D,resetForm:U}=l,O=!!e.versions,z=o||t?.id||a||r,P=Ta.useRef(false);!o&&z&&c&&Object.keys(c).length>0&&c.id!==z&&(P.current=true),Ta.useEffect(()=>{P.current&&(P.current=false,U());},[U]);let R=Ta.useRef(null),Ae=Ta.useRef(null),E=Ta.useRef(null),oe=Ta.useRef(typeof navigator<"u"?navigator.onLine:true),ie=Ta.useRef(0),ee=Ta.useRef(false),G=Ta.useRef(null),ye=Ta.useRef(""),De=Ta.useRef(""),{queueTask:L}=rc(),W=Ta.useCallback(J=>o?`global:${o}`:r&&J?`${r}:${J}`:null,[r,o]),re=Ta.useCallback((J,M,K)=>{w(J,{data:M,baseUpdatedAt:v.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:K?.lastSyncedAt??null});},[v.updatedAt,w]),H=Ta.useCallback(async()=>{let J=o?qe(`/api/globals/${o}/versions`):r&&c.id?qe(`/api/${r}/${c.id}/versions`):null;if(J){$(true);try{let K=await(await lt(J)).json();A(K.docs||[]);}catch(M){console.error("Failed to fetch versions:",M);}finally{$(false);}}},[c.id,r,o,$,A]),Te=Ta.useCallback(()=>{let J=ge.getState(),M=J.formData;if(ee.current||!r||!M.id||!J.hasDirtyFields())return;let K=W(M.id);K&&re(K,M);},[r,W,re]),fe=Ta.useCallback(async J=>{let M=ge.getState(),K=M.formData,le=M.lastSavedData;if(ee.current||!o&&(!r||!K.id)||!M.hasDirtyFields())return;let Fe=W(K.id);if(Fe&&re(Fe,K),!oe.current){h("offline");return}p(true),h("saving"),M.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let Oe=o?qe(`/api/globals/${o}?autosave=true`):qe(`/api/${r}/${K.id}?autosave=true`),gt=await lt(Oe,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:J?.keepalive,body:JSON.stringify({...Kt(K),baseUpdatedAt:le.updatedAt??null})});if(gt.ok)ie.current=Date.now(),M.setRetryCount(0),M.setLastSavedAt(Date.now()),E.current&&clearTimeout(E.current),Fe&&w(Fe,{data:K,baseUpdatedAt:le.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await gt.clone().json()).data?.updatedAt||new Date().toISOString()}),h("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&h("idle");},2e3);else if(gt.status===409)h("conflict");else throw new Error(`Draft auto-save failed with status ${gt.status}`)}catch(Oe){console.error("Auto-save failed:",Oe);let gt=ge.getState(),B=gt.retryCount;if(B<5){gt.setRetryCount(B+1),h("retrying");let X=Math.min(1e3*Math.pow(2,B),6e4);E.current&&clearTimeout(E.current),E.current=setTimeout(()=>we(J),X);}else h("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),p(false),ge.getState().setBackgroundProcessing(false);}},[r,W,o,re,h,w,p,O]),we=Ta.useCallback(J=>{L(()=>fe(J),{beforeProcess:()=>true,afterProcess:()=>{}});},[fe,L]),S=Ta.useCallback(async(J,M=true)=>{let K=ge.getState(),le=J||K.formData,Fe=o?qe(`/api/globals/${o}`):qe(`/api/${r}/${le.id}`),Oe=await lt(Fe,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(M)},body:JSON.stringify({...Kt(le),baseUpdatedAt:K.lastSavedData.updatedAt??null})});return Oe.status===409&&h("conflict"),Oe},[r,o,h]),j=Ta.useCallback(async(J=true)=>{let M=ge.getState(),K=M.formData,le=o?qe(`/api/globals/${o}`):qe(`/api/${r}/${K.id}`),Fe=await lt(le,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(J)},body:JSON.stringify({...Kt(K)})});if(Fe.ok){let gt=(await Fe.json()).data||K;M.loadDocument(gt,gt),h("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&h("idle");},2e3);}return Fe},[r,o,h]);Ta.useEffect(()=>{let J=()=>{k(!T);};return window.addEventListener("toggle-sidebar",J),()=>window.removeEventListener("toggle-sidebar",J)},[T,k]);let xe=Ta.useRef(null),Le=Ta.useRef(""),Be=Ta.useRef(false);Ta.useEffect(()=>{let J=o||t?.id,M=JSON.stringify(t);Be.current&&xe.current===J&&Le.current===M||(b(t||{},t||{}),Be.current=true,xe.current=J,Le.current=M);},[r,c.id,o,t,b]),Ta.useEffect(()=>{if(!r||!t?.id)return;let J=W(c.id);if(!J||G.current===J)return;let M=false;return (async()=>{if(!O)return;let le=y(J);if(le){if(JSON.stringify(le.data)===JSON.stringify(t)){D(J);return}G.current=J,d({title:"Restore draft?",message:"A newer autosaved draft was found for this document. Restore it or discard it and continue with the saved version.",confirmLabel:"Restore draft",cancelLabel:"Discard draft",onConfirm:async()=>{if(M)return;let Oe={...ge.getState().formData,...le.data};u(Oe),s?.("Recovered autosaved draft");},onCancel:async()=>{D(J);}});}})(),()=>{M=true;}},[D,r,d,W,y,t,s,u,O]);function Pe(J,M){for(let K of J){if(K.name===M&&K.admin?.autoGenerate==="title")return K;if(K.type==="tabs"&&"tabs"in K)for(let le of K.tabs){let Fe=Pe(le.fields,M);if(Fe)return Fe}if((K.type==="group"||K.type==="collapsible")&&"fields"in K){let le=Pe(K.fields,M);if(le)return le}}}Ta.useEffect(()=>{let J=e.fields;if(!Pe(J,"metaTitle"))return;let K=ho(J,c,"title"),le=K?String(K):"";le&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&m("metaTitle",le);},[c,e.fields,m]),Ta.useEffect(()=>{let J=e.fields,M=J.find(Fe=>Fe.name==="slug"&&Fe.admin?.autoGenerate);if(!M?.admin?.autoGenerate)return;let K=M.admin.autoGenerate,le=ho(J,c,K);if(f&&le){let Fe=jn(le);Fe!==c.slug&&m("slug",Fe);}},[c,f,e.fields,m]),Ta.useEffect(()=>{if(T||!o&&(!r||!c.id)||!ge.getState().hasDirtyFields()||_d()!=="keystroke")return;ts("other");let M=JSON.stringify(c);M!==ye.current&&(R.current&&clearTimeout(R.current),R.current=setTimeout(Te,1500),Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(()=>{ye.current=M,we();},8e3));},[c,T,r,o,Te,we]),Ta.useEffect(()=>{if(!o&&(!r||!c.id))return;let J=()=>{ee.current||!ge.getState().hasDirtyFields()||we({keepalive:true});},M=()=>{document.hidden&&J();},K=()=>{oe.current=true,J();},le=()=>{oe.current=false;let Fe=ge.getState();Fe.hasDirtyFields()&&Fe.setAutoSaveStatus("offline");};return window.addEventListener("blur",J),window.addEventListener("pagehide",J),window.addEventListener("online",K),window.addEventListener("offline",le),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("blur",J),window.removeEventListener("pagehide",J),window.removeEventListener("online",K),window.removeEventListener("offline",le),document.removeEventListener("visibilitychange",M);}},[r,o,c.id,we]),Ta.useEffect(()=>{let J=JSON.stringify(c);if(J===De.current)return;De.current=J;let M=document.getElementById("form-data");M&&(M.value=J),n?.(c);},[c,n]),Ta.useEffect(()=>{(o||c.id)&&H();},[c.id,o,H]);let ft=!c.id&&!o?"draft":O&&c.status||"published",qt=(!!c.id||!!o)&&ft==="draft";return {...l,fetchVersions:H,performAutoSave:we,saveDocument:S,forceSave:j,autoSaveSkipRef:ee,lastAutoSaveTimeRef:ie,documentStatus:ft,hasUnpublishedChanges:qt,versionsEnabled:O}}function Po({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=Ta.useState(false),s=Ta.useRef(null);return Ta.useEffect(()=>{let i=l=>{s.current&&!s.current.contains(l.target)&&n(false);};return a&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),jsxRuntime.jsxs("div",{className:"relative",ref:s,children:[jsxRuntime.jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&jsxRuntime.jsx("div",{className:`absolute z-[100] min-w-[200px] py-2 bg-[var(--kyro-surface)] rounded-2xl shadow-2xl border border-[var(--kyro-border)] animate-in fade-in zoom-in-95 duration-100 ${r==="right"?"right-0":"left-0"} ${o==="down"?"top-full mt-2":"bottom-full mb-2"}`,onClick:()=>n(false),children:t})]})}function Pt({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsxRuntime.jsx("div",{className:"px-1.5",children:jsxRuntime.jsxs("button",{type:"button",onClick:t,disabled:a,className:`w-full flex items-center gap-3 px-3 py-2.5 text-[11px] font-medium tracking-wide text-left transition-all rounded-xl ${o?"text-red-500 hover:bg-red-500/10":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]"} ${a?"opacity-50 cursor-not-allowed":""} ${n}`,children:[r&&jsxRuntime.jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsxRuntime.jsx("span",{className:"flex-1",children:e})]})})}function Xa(){return jsxRuntime.jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Ro({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:s="down"}){let i=e==="published"&&!r&&t!=="saving"&&t!=="error",l=n||t==="saving"||i||t==="saved",d="kyro-btn kyro-btn-sm text-[11px] font-regular tracking-widest transition-all duration-300 rounded-lg",c=()=>t==="saving"?`${d} bg-[var(--kyro-primary)]/70 border-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] cursor-wait`:t==="saved"?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:i?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:`${d} bg-[var(--kyro-primary)] border-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] hover:bg-[var(--kyro-primary-hover)]`,u="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",m=()=>t==="saving"?`${u} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:t==="error"?`${u} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:i?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${u} bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-hover)]`,v=()=>t==="saving"?"Publishing...":t==="saved"?"Published":t==="error"?"Retry":i?"Published":"Publish Changes";return jsxRuntime.jsxs("div",{className:"inline-flex items-center",children:[jsxRuntime.jsxs("button",{type:"button",onClick:o,disabled:l,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline mr-1.5"}),(i||t==="saved")&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),v()]}),a&&jsxRuntime.jsx(Po,{trigger:jsxRuntime.jsx("button",{type:"button",className:m(),disabled:t==="saving",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}),direction:s,children:a})]})}var sc=({title:e,description:t,slug:r})=>jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg p-6 max-w-2xl shadow-sm transition-colors duration-300",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("div",{className:"w-7 h-7 bg-[var(--kyro-bg-secondary)] rounded-full flex items-center justify-center text-[10px] text-[var(--kyro-text-primary)] font-medium border border-[var(--kyro-border)]",children:"K"}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-tight",children:"kyro-cms.com"}),jsxRuntime.jsxs("span",{className:"text-[12px] text-[var(--kyro-text-secondary)] leading-tight opacity-80",children:["https://kyro-cms.com \u203A posts \u203A ",r]})]})]}),jsxRuntime.jsx("h3",{className:"text-[20px] text-[#2563eb] dark:text-[#60a5fa] font-medium hover:underline cursor-pointer mb-1 leading-tight transition-colors",children:e}),jsxRuntime.jsx("p",{className:"text-[14px] text-[var(--kyro-text-secondary)] leading-relaxed line-clamp-2",children:t})]});function lc({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=Ta.useState(0),s=e.tabs||[],i=s[a]||s[0],l=e.name?t[e.name]||{}:t;return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-[var(--kyro-border)] mb-6",children:jsxRuntime.jsx("div",{className:"flex items-center gap-2 overflow-x-auto hide-scrollbar",children:s.map((d,c)=>jsxRuntime.jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${a===c?"border-[var(--kyro-primary)] text-[var(--kyro-primary)]":"border-transparent text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] opacity-60 hover:opacity-100"}`,onClick:()=>n(c),children:d.label},c))})}),jsxRuntime.jsx("div",{className:"space-y-6",children:i?.fields.map(d=>o(d,l,r))}),i?.label==="SEO Settings"&&jsxRuntime.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold text-[var(--kyro-text-secondary)] tracking-[0.2em] mb-6 opacity-50",children:"Live Google Preview"}),jsxRuntime.jsx(sc,{title:String((typeof l.metaTitle=="object"?"":l.metaTitle)||(typeof l.title=="object"?"":l.title)||"Untitled"),description:String((typeof l.metaDescription=="object"?"":l.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function uc({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:s,handleDuplicate:i,handleUnpublish:l,handleDelete:d,handlePublish:c,handleSaveDraft:u,handleSchedulePublish:m,handleConflictOverride:v}){let{t:x}=reactI18next.useTranslation(),[g,f]=Ta.useState(Date.now()),[b,p]=Ta.useState(false),h=Ta.useRef(null),{formData:A,hasUnsavedChanges:$,autoSaveStatus:T,lastSavedAt:k,retryCount:y,view:w,setView:D,showPreview:U,setShowPreview:O,setFormData:z,markSaved:P,lastSavedData:R}=ge(),Ae=!A.id;Ta.useEffect(()=>{let H=setInterval(()=>f(Date.now()),1e4);return ()=>clearInterval(H)},[]),Ta.useEffect(()=>{let H=Te=>{h.current&&!h.current.contains(Te.target)&&p(false);};if(b)return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[b]);let E=String(A.tabs?.title||(typeof A.title=="object"?"":A.title)||(typeof A.name=="object"?"":A.name)||"Untitled"),oe=A.updatedAt?new Date(A.updatedAt).toLocaleString():"Just now",ie=A.createdAt?new Date(A.createdAt).toLocaleString():"Just now",ee=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",G=o?"Unpublished":r==="published"?"Published":"Draft",ye=r==="published"&&!$?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",De=r==="published"&&!o?"bg-[var(--kyro-success)]/10 text-[var(--kyro-success)] border-[var(--kyro-success)]/20":o?"bg-[var(--kyro-warning)]/10 text-[var(--kyro-warning)] border-[var(--kyro-warning)]/20":"bg-[var(--kyro-text-muted)]/10 text-[var(--kyro-text-muted)] border-[var(--kyro-text-muted)]/20",L=(H=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[T==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),H?"Saving\u2026":"Saving draft..."]}),T==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Ql.Check,{className:"w-3.5 h-3.5 shrink-0"}),H?"Saved":k?`Saved ${Math.floor((Date.now()-k)/6e4)}m ago`:"Draft saved"]}),T==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),H?`Retry ${y}/5`:`Retrying save (${y}/5)`]}),T==="offline"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[jsxRuntime.jsx("path",{d:"M10.61 10.61a3 3 0 0 0 4.24 4.24"}),jsxRuntime.jsx("path",{d:"M13.36 13.36a3 3 0 0 0-4.24-4.24"}),jsxRuntime.jsx("path",{d:"m2 2 20 20"}),jsxRuntime.jsx("path",{d:"M18.36 5.64a9 9 0 0 0-12.72 0"}),jsxRuntime.jsx("path",{d:"M22.61 1.39a15 15 0 0 0-21.22 0"})]}),H?"Offline":"Offline \u2014 cached locally"]}),T==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:H?"Failed":"Draft save failed"}),T==="conflict"&&(H?jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict"}):jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict detected"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>v?.(),className:"text-[var(--kyro-primary)] hover:underline",children:"Keep my changes"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"|"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-[var(--kyro-danger)] hover:underline",children:"Reload server version"})]}))]}),W=()=>!Ae&&jsxRuntime.jsxs(Po,{trigger:jsxRuntime.jsx("button",{type:"button",className:"kyro-btn p-2 md:p-2.5 rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)] transition-all",title:x("tooltips.moreActions",{defaultValue:"More actions"}),children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})}),direction:"down",children:[jsxRuntime.jsx(Pt,{onClick:u,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsxRuntime.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsxRuntime.jsx("polyline",{points:"7 3 7 8 15 8"})]}),children:"Save Draft"}),!t&&jsxRuntime.jsx(Pt,{onClick:s,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsxRuntime.jsx(Pt,{onClick:i,disabled:n,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),children:n?"Duplicating...":"Duplicate"}),jsxRuntime.jsx(Pt,{onClick:()=>p(true),icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsxRuntime.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsxRuntime.jsx(Pt,{onClick:l,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),jsxRuntime.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),children:"Unpublish"}),!t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xa,{}),jsxRuntime.jsx(Pt,{onClick:d,danger:true,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),children:"Delete"})]})]}),re=()=>b&&jsxRuntime.jsx("div",{ref:h,className:"relative",children:jsxRuntime.jsxs("div",{className:"absolute right-0 top-2 p-4 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] shadow-2xl z-50 min-w-[260px]",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsxRuntime.jsx("input",{type:"datetime-local",id:"schedule-datetime",className:"kyro-form-input text-xs mb-3 w-full",min:new Date().toISOString().slice(0,16)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let H=document.getElementById("schedule-datetime")?.value;H&&m(H);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] z-50 bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsxRuntime.jsx("a",{href:`${Ue}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:E}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-medium border ${De}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ye}`}),G]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:$,onPublish:c,disabled:a==="saving"}),W(),re()]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-[var(--kyro-border)]/50 bg-[var(--kyro-bg-secondary)]/30",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)]/50",children:["edit","version","api"].map(H=>jsxRuntime.jsx("button",{type:"button",onClick:()=>D(H),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${w===H?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 active:opacity-100"}`,children:H==="edit"?"Edit":H==="version"?"History":"API"},H))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[L(true),$&&T!=="saving"&&T!=="retrying"&&T!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument(R,R);},className:"text-[var(--kyro-primary)] text-[10px] font-medium hover:underline",children:"Revert"}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>O(!U),className:`p-1.5 rounded-lg transition-all ${U?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(Ql.ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxRuntime.jsxs("header",{className:"hidden md:flex surface-tile px-8 py-6 items-center justify-between sticky top-0 border-b border-[var(--kyro-border)] mb-8 bg-[var(--kyro-surface)] z-50 backdrop-blur-md",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsxRuntime.jsx("a",{href:`${Ue}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:E}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${De}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ye}`}),ee]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[L(false),$&&T!=="saving"&&T!=="retrying"&&T!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument(R,R);},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),k&&T!=="saving"&&T!=="retrying"&&T!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let H=g-k,Te=Math.floor(H/6e4),fe=Math.floor(H/1e3);return Te>=1?`${Te}m ago`:fe>=5?`${fe}s ago`:"just now"})()]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",oe]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",ie]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-1 bg-[var(--kyro-bg-secondary)] p-1 rounded-xl border border-[var(--kyro-border)]",children:["edit","version","api"].map(H=>jsxRuntime.jsx("button",{type:"button",onClick:()=>D(H),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${w===H?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:H.toUpperCase()},H))}),jsxRuntime.jsx("div",{className:"h-8 w-px bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>O(!U),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${U?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:x("tooltips.livePreview",{defaultValue:"Live Preview"}),children:[jsxRuntime.jsx(Ql.ExternalLink,{className:"w-4 h-4"}),U&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),W(),re(),jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:$,onPublish:c,disabled:a==="saving"})]})]})]})]})}function pc({config:e,layout:t,collectionSlug:r,renderField:o}){let{t:a}=reactI18next.useTranslation(),{showPreview:n,sidebarCollapsed:s,formData:i,previewUrl:l}=ge();if(t==="single")return jsxRuntime.jsx("div",{className:"w-full space-y-6 md:space-y-8",children:jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.map(u=>o(u))})});let c=e.fields.some(u=>u.admin?.position==="sidebar")&&!n;return jsxRuntime.jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${n?"grid-cols-1 lg:grid-cols-2":s||!c?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsxRuntime.jsx("div",{className:"space-y-6 md:space-y-8 animate-in fade-in slide-in-from-left-4 duration-500",children:e.tabs?o({type:"tabs",tabs:e.tabs}):jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(u=>!u.admin?.position||u.admin.position==="main").map(u=>o(u))})}),n?jsxRuntime.jsx("div",{className:"sticky top-36 h-[calc(100vh-280px)] animate-in fade-in slide-in-from-right-10 duration-700",children:jsxRuntime.jsxs("div",{className:"w-full h-full rounded-3xl border border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] shadow-2xl overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-white/60",children:"Live Preview Mode"})]}),jsxRuntime.jsx("iframe",{src:l||"",className:"w-full h-full border-none",title:a("tooltips.livePreview",{defaultValue:"Live Preview"})}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):s?null:jsxRuntime.jsx("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:e.fields.some(u=>u.admin?.position==="sidebar")&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-6 space-y-4 md:space-y-6",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Settings"}),e.fields.filter(u=>u.admin?.position==="sidebar").map(u=>o(u))]})})]})}function mc({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:i,setCompareDiffs:l,loadingDiffs:d,loadingVersions:c,versions:u}=ge();return jsxRuntime.jsx("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 pb-12",children:jsxRuntime.jsxs("div",{className:"surface-tile p-0 overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"px-4 md:px-6 py-3 md:py-4 border-b border-[var(--kyro-border)] flex flex-col md:flex-row md:items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-base md:text-lg font-bold text-[var(--kyro-text-primary)]",children:"Version History"}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-muted)] mt-0.5",children:o?`Select 2 versions \xB7 ${n.length}/2 chosen`:`${u.length} snapshot${u.length!==1?"s":""} \xB7 Auto-saved`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&n.length===2&&jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:d,className:"kyro-btn kyro-btn-primary px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider hover:opacity-90 disabled:opacity-50",children:d?"Comparing...":"Compare"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{a(!o),s([]),l([]);},className:`px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider transition-all ${o?"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]":"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:o?"Done":"Compare"})]})]}),i.length>0&&jsxRuntime.jsxs("div",{className:"border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"px-6 py-3 flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold text-[var(--kyro-text-primary)] tracking-wider",children:[i.length," change",i.length!==1?"s":""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>l([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:i.map((m,v)=>jsxRuntime.jsxs("div",{className:"flex flex-col md:grid md:grid-cols-4 gap-1 md:gap-3 px-4 md:px-6 py-2.5 text-[11px] font-mono border-t border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate font-semibold md:font-normal",children:m.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof m.oldValue=="object"?JSON.stringify(m.oldValue):String(m.oldValue??"null")}),jsxRuntime.jsxs("div",{className:"md:col-span-2 text-[var(--kyro-text-primary)] truncate",children:[jsxRuntime.jsx("span",{className:"md:hidden text-[var(--kyro-text-muted)]",children:"\u2192 "}),typeof m.newValue=="object"?JSON.stringify(m.newValue):String(m.newValue??"null")]})]},v))})]}),c?jsxRuntime.jsx("div",{className:"flex justify-center py-16",children:jsxRuntime.jsx("span",{className:"animate-spin text-[var(--kyro-primary)]",children:"\u231B"})}):u.length===0?jsxRuntime.jsx("div",{className:"text-center py-16 text-[var(--kyro-text-muted)] text-sm italic",children:"No versions yet."}):jsxRuntime.jsx("div",{className:"divide-y divide-[var(--kyro-border)]",children:u.map((m,v)=>{let x=n.includes(m.id),g=(m.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(m.id):void 0,className:`transition-all ${o?x?"bg-[var(--kyro-primary)]/5 cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)] cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"hidden md:grid grid-cols-12 gap-3 px-6 py-3 items-center",children:[jsxRuntime.jsx("div",{className:"col-span-1 flex items-center gap-2",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${x?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x&&jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:u.length-v})}),jsxRuntime.jsxs("div",{className:"col-span-4 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-2",children:[m.changeDescription||"Snapshot",g&&jsxRuntime.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider",children:"Auto"})]}),jsxRuntime.jsx("div",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(m.createdAt||m.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:m.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${m.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${m.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),m.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:m.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(m.id),className:"px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[11px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})})]}),jsxRuntime.jsxs("div",{className:"md:hidden flex items-start gap-3 px-4 py-3",children:[jsxRuntime.jsx("div",{className:"pt-0.5 shrink-0",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${x?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x&&jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:u.length-v})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-1.5",children:[m.changeDescription||"Snapshot",g&&jsxRuntime.jsx("span",{className:"text-[9px] px-1 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider shrink-0",children:"Auto"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(m.createdAt||m.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),m.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${m.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${m.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),m.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:m.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(m.id),className:"shrink-0 px-2.5 py-1 rounded-lg border border-[var(--kyro-border)] text-[10px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})]})]},m.id)})})]})})}function yc({collectionSlug:e,globalSlug:t}){let{t:r}=reactI18next.useTranslation(),{formData:o}=ge();return jsxRuntime.jsx("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] gap-8",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-8 min-w-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"Response Payload"}),jsxRuntime.jsx("div",{className:"bg-[#0f172a] p-6 rounded-2xl border border-white/5 overflow-x-auto max-h-[800px]",children:jsxRuntime.jsx("pre",{className:"text-blue-300 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(o,null,2)})})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsxs("div",{className:"surface-tile p-8 space-y-6",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"API Info"}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Reference Path"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg-secondary)] px-4 py-3 rounded-md border border-[var(--kyro-border)] text-[11px] font-mono break-all selection:bg-[var(--kyro-primary)]/20 text-[var(--kyro-text-primary)]",children:t?`kyro.globals('${t}').get()`:o.id?`kyro.collection('${e}').get('${o.id}')`:"Not saved yet"})]}),o.id&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Document ID"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:String(o.id)}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(o.id));},className:"p-1.5 hover:bg-[var(--kyro-bg-secondary)] rounded-lg transition-colors text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]",title:r("tooltips.copyId",{defaultValue:"Copy ID"}),children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),t&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Global Slug"}),jsxRuntime.jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:t})]})]})]})})]})})}var ds=class extends Ta.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("[ErrorBoundary] Caught:",t,r),this.setState({errorInfo:r.componentStack||null});}handleCopyToClipboard=()=>{let{error:t,errorInfo:r}=this.state,o=ge.getState().formData,a={error:t?.message,stack:t?.stack,componentStack:r,formData:o,timestamp:new Date().toISOString()};navigator.clipboard.writeText(JSON.stringify(a,null,2)).then(()=>{V.success("Crash details copied to clipboard");});};handleReload=()=>{window.location.reload();};render(){return this.state.hasError?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-8 h-8 text-red-500"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold text-[var(--kyro-text-primary)]",children:this.props.fallbackTitle||"Something went wrong"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] text-center max-w-md",children:"The form encountered an unexpected error. Your unsaved changes may still be recoverable."}),this.state.error&&jsxRuntime.jsx("p",{className:"text-xs font-mono text-red-500/70 bg-red-500/5 px-4 py-2 rounded-lg max-w-full overflow-auto",children:this.state.error.message}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[jsxRuntime.jsxs("button",{type:"button",onClick:this.handleReload,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.RefreshCw,{className:"w-4 h-4"}),"Reload Page"]}),jsxRuntime.jsxs("button",{type:"button",onClick:this.handleCopyToClipboard,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/20 transition-colors",children:[jsxRuntime.jsx(Ql.Copy,{className:"w-4 h-4"}),"Copy Details"]})]})]}):this.props.children}};function fc(e,t){if(!(!e||typeof t!="string"))return t.split(".").reduce((r,o)=>r&&r[o]!==void 0?r[o]:void 0,e)}function Ci(e,t,r){if(!e)return true;if(Array.isArray(e.and))return e.and.every(o=>Ci(o,t,r));if(Array.isArray(e.or))return e.or.some(o=>Ci(o,t,r));if(e.field){let o=e.field,a=fc(t,o);return a===void 0&&(a=fc(r,o)),"equals"in e?a===e.equals:"notEquals"in e?a!==e.notEquals:"in"in e&&Array.isArray(e.in)?e.in.includes(a):"greaterThan"in e?typeof a=="number"&&a>e.greaterThan:!!a}return true}var gc={};function Ya({config:e,data:t=gc,errors:r=gc,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:i,documentName:l,layout:d="split",onActionSuccess:c,onActionError:u,justSaved:m}){let v=e||(s?wd[s]:n?Zo[n]:null),[x,g]=Ta.useState(v);Ta.useEffect(()=>{s==="storage-settings"?Ee("/api/kyro/schema").then(I=>{I?.globals?.["storage-settings"]&&g(I.globals["storage-settings"]);}).catch(I=>console.error("[AutoForm] Failed to fetch dynamic schema",I)):g(v);},[s,v]);let f=x||v,{confirm:b}=yt(),{formData:p,hasUnsavedChanges:A,autoSaveStatus:k,lastSavedAt:y,view:Ae,setView:E,setShowPreview:De,isMenuOpen:L,setIsMenuOpen:W,loadingFields:re,setLoadingFields:H,compareSelected:we,setCompareSelected:S,setCompareDiffs:xe,setLoadingDiffs:Be,setField:Pe,setFormData:ft,setLastSavedData:J,setAutoSaveStatus:M,fetchVersions:K,saveDocument:le,forceSave:Fe,autoSaveSkipRef:Oe,lastAutoSaveTimeRef:gt,documentStatus:B,hasUnpublishedChanges:X,versionsEnabled:ae}=oc({config:f,initialData:t,collectionSlug:n,globalSlug:s,documentId:i,onChange:o,onActionSuccess:c,onActionError:u}),Jt=Ta.useRef(null),fo=Ta.useRef(null),[ka,Za]=Ta.useState(false),[bs,C]=Ta.useState("idle"),[me,$e]=Ta.useState(false),[tr,Et]=Ta.useState(Date.now()),xr=a,[xs,Lo]=Ta.useState(false),[lu,ks]=Ta.useState(false),[du,cu]=Ta.useState(0),Ii=Ta.useRef(new Map),uu=3e4;Ta.useEffect(()=>{let I=s?`global:${s}`:`${n}:${i}`;if(!(s||n&&i&&i!=="new")||t&&Object.keys(t).length>0)return;let he=Ii.current.get(I),He=he&&Date.now()-he.ts<uu,Nt=he&&!He;if(He){ge.getState().loadDocument(he.data,he.data);return}Nt&&ge.getState().loadDocument(he.data,he.data);let Ct=new AbortController;ks(false),he||Lo(true);let Rr=s?`/api/globals/${s}`:`/api/${n}/${i}`;return Ee(Rr,{autoToast:false,signal:Ct.signal}).then(vt=>{let go=vt.data||{};Ii.current.set(I,{data:go,ts:Date.now()}),ge.getState().loadDocument(go,go),Lo(false);}).catch(vt=>{vt.name!=="AbortError"&&(Lo(false),he||ks(true));}),()=>Ct.abort()},[n,i,s,t,du]),Ta.useEffect(()=>{let I=setInterval(()=>Et(Date.now()),1e4);return ()=>clearInterval(I)},[]);let Bi=(I,Z)=>{if(typeof I=="function")try{return I(p,Z)}catch(he){return console.warn("Error evaluating admin runtime flag:",he),false}return !!I},pu=I=>{b({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let Z=s?qe(`/api/globals/${s}/versions/${I}/restore`):qe(`/api/${n}/${p.id}/versions/${I}/restore`),he=await lt(Z,{method:"POST"});!he.ok&&n&&(he=await lt(qe(`/api/${n}/${p.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:I,action:"restore"})}));let He=await he.json();if(He.data){let{updatedAt:Nt,createdAt:Ct,...Rr}=He.data,vt={...p,...Rr};ft(vt),ge.getState().loadDocument(vt,vt),c?.("Version restored successfully"),K(),E("edit");}else V.error(He.error||"Failed to restore version");}catch(Z){console.error("Failed to restore version:",Z),V.error("Failed to restore version");}}});},mu=async()=>{if(we.length===2){Be(true);try{let Z=await(await lt(qe(`/api/${n}/${p.id}/versions?compareA=${we[0]}&compareB=${we[1]}`))).json();xe(Z.diffs||[]);}catch(I){console.error("Compare failed:",I),xe([]);}finally{Be(false);}}},yu=I=>{S(Z=>Z.includes(I)?Z.filter(he=>he!==I):Z.length>=2?[Z[1],I]:[...Z,I]);};Ta.useEffect(()=>{let I=Z=>{(Z.metaKey||Z.ctrlKey)&&Z.key==="s"&&(Z.preventDefault(),en()),(Z.metaKey||Z.ctrlKey)&&Z.shiftKey&&(Z.key==="P"||Z.key==="p")&&(Z.preventDefault(),document.getElementById("btn-publish")?.click()),(Z.metaKey||Z.ctrlKey)&&!Z.shiftKey&&Z.key==="p"&&(Z.preventDefault(),De(he=>!he)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(Z.key==="1"&&E("edit"),Z.key==="2"&&E("version"),Z.key==="3"&&E("api"));};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[]),Ta.useEffect(()=>{let I=()=>E("version");return window.addEventListener("kyro:show-version-history",I),()=>window.removeEventListener("kyro:show-version-history",I)},[]),Ta.useEffect(()=>{let I=Z=>{Jt.current&&!Jt.current.contains(Z.target)&&W(false);};if(L)return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[L]),Ta.useEffect(()=>{let I=Z=>{fo.current&&!fo.current.contains(Z.target)&&Za(false);};if(ka)return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[ka]);let fu=()=>{A?b({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await en(),await new Promise(I=>setTimeout(I,1e3)),window.location.href=`${Ue}/${n}/new`;}}):window.location.href=`${Ue}/${n}/new`;},gu=()=>{if(!p.id){V.error("Please save the document before duplicating.");return}let I=async()=>{try{$e(!0);let Z=await lt(`/api/${n}/${p.id}/duplicate`,{method:"POST"});if(Z.ok){let he=await Z.json();c?.("Document duplicated successfully"),he.data?.id?window.location.href=`${Ue}/${n}/${he.data.id}`:window.location.href=`${Ue}/${n}`;}else {let he=await Z.json();V.error(he.error||"Failed to duplicate");}}catch{V.error("Failed to duplicate document");}finally{$e(false);}};if(A){b({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await en(),await I();}});return}b({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await I();}});},vu=()=>{b({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{Oe.current=true;try{await At(`/api/${n}/${p.id}`),window.location.href=`${Ue}/${n}`;}catch(I){V.error(I.message||"Failed to delete document");}finally{Oe.current=false;}}});},bu=()=>{b({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{Oe.current=true;try{let I=await le({...p,status:"draft"},!1);if(I?.ok)c?.("Document unpublished successfully"),ge.getState().loadDocument({...p,status:"draft"},{...p,status:"draft"});else {let Z=await I?.json().catch(()=>({}));V.error(Z?.error||"Failed to unpublish");}}catch{V.error("Failed to unpublish");}finally{Oe.current=false;}}});},en=async()=>{let I=!p.id;Oe.current=true,C("saving");try{let Z=Kt({...p}),he=I&&!s,He=he?await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}):await le(Z);if(He.ok){let Nt=await He.json(),Ct=Nt.data||Z;ge.getState().loadDocument(Ct,Ct),gt.current=Date.now(),M("success"),C("saved"),ae&&K(),setTimeout(()=>{M("idle"),C("idle");},2e3),c?.(he?"Document created successfully":"Changes saved"),s&&window.dispatchEvent(new Event("kyro:soft-reload")),he&&setTimeout(()=>{window.location.href=`${Ue}/${n}/${Nt.data.id}`;},800);}else {let Nt=await He.json();He.status===409&&M("conflict"),C("error"),V.error(Nt.error||"Failed to save"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),V.error("Failed to save document"),setTimeout(()=>C("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),Oe.current=false;}},xu=async()=>{let I=!p.id;Oe.current=true,C("saving");try{let Z={...p};if(I&&!s){let Nt=Kt({...p}),Ct=await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Nt)});if(!Ct.ok){let go=await Ct.json().catch(()=>({}));Ct.status===409&&M("conflict"),C("error"),V.error(go.error||"Failed to create document"),setTimeout(()=>C("idle"),3e3);return}let vt=(await Ct.json()).data||Nt;ge.getState().loadDocument(vt,vt),Z=vt;}let he=Kt(Z),He=await le(he,!1);if(He?.ok){let Ct=(await He.json().catch(()=>({}))).data||he;ge.getState().loadDocument(Ct,Ct),C("saved"),c?.("Published successfully"),setTimeout(()=>{C("idle");},2e3),I&&!s&&Z.id&&setTimeout(()=>{window.location.href=`${Ue}/${n}/${Z.id}`;},800);}else {if(I&&!s&&Z.id){let Ct=await He?.json().catch(()=>({}));V.warning("Document saved as draft. Publishing failed: "+(Ct?.error||"Unknown error")),setTimeout(()=>{window.location.href=`${Ue}/${n}/${Z.id}`;},1200);return}let Nt=await He?.json().catch(()=>({}));He?.status===409&&M("conflict"),C("error"),V.error(Nt?.error||"Failed to publish"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),V.error("Failed to publish"),setTimeout(()=>C("idle"),3e3);}finally{Oe.current=false;}},ku=async I=>{let Z=!p.id;Oe.current=true;try{let he={...Kt({...p}),_schedulePublishAt:I};if(Z&&!s){let He=await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!He.ok){let Nt=await He.json().catch(()=>({}));V.error(Nt.error||"Failed to schedule publish");return}}else {let He=await le(he);if(!He.ok){let Nt=await He.json().catch(()=>({}));V.error(Nt.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(I).toLocaleString()}`),Za(!1);}catch{V.error("Failed to schedule publish");}finally{Oe.current=false;}},hu=(I,Z)=>{Pe(I,Z);},ha=(I,Z,he)=>{let He=Z!==void 0?Z:p;if(Bi(I.hidden!==void 0?I.hidden:I.admin?.hidden,He))return null;let Ct=Bi(I.readOnly!==void 0?I.readOnly:I.admin?.readOnly,He),Rr=!!(xr||Ct);if(I.admin?.condition){if(typeof I.admin.condition=="function")try{let it={values:p||{},...p||{}};if(!I.admin.condition(it,He))return null}catch(it){console.warn(`Condition error for field ${I.name}:`,it);}else if(typeof I.admin.condition=="object")try{if(!Ci(I.admin.condition,He,p))return null}catch(it){console.warn(`Declarative condition error for field ${I.name}:`,it);}}let vt=He[I.name],go=r[I.name],tn=it=>{he?he({...He,[I.name]:it}):hu(I.name,it);};if(I.type==="row"&&"fields"in I){let it=I.fields;return jsxRuntime.jsx("div",{className:"kyro-form-row flex flex-col md:flex-row gap-4 md:gap-6 items-start md:items-end w-full",children:it?.map(ot=>{let Ir=ot.admin||{},rn=Ir?.action;if((ot.type==="button"||ot.type==="action")&&rn){let kr=it?.find(wa=>wa.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let wa=I.name,on=kr?.name,an=on?p[on]:void 0;if(!an&&wa&&typeof wa=="string"&&on&&(an=p[wa]?.[on]),!!an){H(hr=>({...hr,[ot.name]:true}));try{let hr=await lt(qe(rn),{method:Ir.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:an})}),Na={};try{Na=await hr.json();}catch{Na={};}if(hr.ok&&Na.success)c?.(Na.message||"Action completed successfully");else {let wu=Na.error||`Request failed (${hr.status})`;u?.(wu);}}catch(hr){u?.(hr instanceof Error?hr.message:"Error connecting to server");}finally{H(hr=>({...hr,[ot.name]:false}));}}},disabled:re[ot.name]||Rr,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:re[ot.name]?"Sending...":ot.label||"Click"})},ot.name)}return jsxRuntime.jsx("div",{className:ot.type==="button"||ot.type==="action"?"flex-shrink-0":"flex-1",style:Ir?.width?{width:Ir.width,flex:"none"}:{},children:ha(ot,Z,he)},ot.name)})},I.name||`row-${Math.random()}`)}switch(I.type){case "tabs":return jsxRuntime.jsx(lc,{field:I,formData:p,onTabDataChange:it=>{Pe(I.name,it);},renderField:(it,ot,Ir)=>ha(it,ot,Ir)},I.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(Zn,{field:I,value:vt,onChange:tn,renderField:ha},I.name);case "array":return jsxRuntime.jsx(es,{field:I,value:vt,onChange:tn,renderField:ha,disabled:Rr},I.name);case "button":case "action":{let it=I.name,ot=re[it];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:ot||Rr,onClick:async()=>{let Ir=I.admin?.action||I.action,rn=I.admin?.method||I.method||"POST";if(Ir){H(kr=>({...kr,[it]:true}));try{let kr=await lt(Ir,{method:rn,headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});await kr.json(),kr.ok;}catch(kr){console.error("Error executing action:",kr);}finally{H(kr=>({...kr,[it]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${ot?"opacity-70 cursor-not-allowed":""}`,children:[ot&&jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),ot?"Processing...":I.label||"Click"]})},it)}case "relationship-block":return jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[I.label||I.name,I.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx(qa,{relationTo:I.relationTo,hasMany:I.hasMany,selectedIds:Array.isArray(vt)?vt:vt?[vt]:[],onChange:(it,ot)=>{tn(ot);},compact:true}),I.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(I.admin?.description)}):null]},I.name);default:return jsxRuntime.jsx(To,{field:I,value:vt,onChange:tn,error:go,disabled:Rr,formData:p,siblingData:He,collectionSlug:n,globalSlug:s},I.name||Math.random().toString())}};return xs?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(jt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(jt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(jt,{variant:"rect",count:4})})]}):lu?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{ks(false),Lo(true),cu(I=>I+1);},className:"kyro-btn kyro-btn-primary px-6 py-2 rounded-xl text-sm font-bold",children:"Retry"})]}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[d!=="single"&&jsxRuntime.jsx(uc,{collectionSlug:n,globalSlug:s,documentStatus:B||"draft",hasUnpublishedChanges:X,localSaveStatus:bs,isDuplicating:me,handleCreateNew:fu,handleDuplicate:gu,handleUnpublish:bu,handleDelete:vu,handlePublish:xu,handleSaveDraft:en,handleSchedulePublish:ku,handleConflictOverride:()=>Fe()}),d==="single"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium",children:[k==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Saving..."]}),k==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"}),y?`Saved ${Math.floor((Date.now()-y)/6e4)}m ago`:"Saved"]}),k==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Retrying..."]}),k==="offline"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),k==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),k==="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),A&&k!=="saving"&&k!=="retrying"&&k!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!A&&k!=="success"&&k!=="saving"&&k!=="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-success)]",children:"All changes saved"})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)] opacity-60",children:p.updatedAt?`Modified ${new Date(p.updatedAt).toLocaleString()}`:""})]}),jsxRuntime.jsx("button",{id:"btn-save",type:"button",style:{width:0,height:0,opacity:0,padding:0,margin:0,border:"none",position:"absolute"},onClick:async()=>{Oe.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let I=await le(p);if(I.ok){let he=(await I.json()).data||p;ft({...p,...he}),J({...p,...he}),c?.("Changes saved"),s&&window.dispatchEvent(new Event("kyro:soft-reload"));}}catch(I){console.error("Save error exception:",I),u?.("Save failed: "+I.message);}finally{Oe.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsxRuntime.jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxRuntime.jsxs(ds,{children:[Ae==="edit"&&jsxRuntime.jsx(pc,{config:f,layout:d,collectionSlug:n,renderField:ha}),Ae==="version"&&jsxRuntime.jsx(mc,{handleRestoreVersion:pu,handleCompareVersions:mu,toggleCompareSelection:yu}),Ae==="api"&&jsxRuntime.jsx(yc,{collectionSlug:n,globalSlug:s})]})})]})}var vc={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function Si({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:s,onViewHistory:i,onPreview:l,onDelete:d,onBack:c,onToggleSidebar:u,publishedAt:m,updatedAt:v,onCopyData:x,onPasteData:g}){let{t:f}=reactI18next.useTranslation(),b=ge(D=>D.view)||"edit",p=ge(D=>D.setView),[h,A]=Ta.useState(false),$=Ta.useRef(null);Ta.useEffect(()=>{let D=U=>{$.current&&!$.current.contains(U.target)&&A(false);};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);let T=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,k=["edit","version","api"],y=T(),w="p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] transition-all shrink-0";return jsxRuntime.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 bg-[var(--kyro-surface)] border-b border-[var(--kyro-border)] w-full overflow-x-auto",children:[c&&jsxRuntime.jsx("button",{type:"button",onClick:c,className:"p-1 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all shrink-0",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${vc[e]||"bg-[var(--kyro-text-muted)]"}`}),y&&jsxRuntime.jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline mr-0.5"}),y]}),jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)] shrink-0 max-md:hidden",children:k.map(D=>jsxRuntime.jsx("button",{type:"button",onClick:()=>p(D),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${b===D?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:D==="edit"?"Edit":D==="version"?"Ver":"API"},D))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${w} max-md:hidden`,title:f("tooltips.preview",{defaultValue:"Preview"}),children:jsxRuntime.jsx(Ql.Eye,{className:"w-3.5 h-3.5"})}),i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${w} max-md:hidden`,title:f("tooltips.viewHistory",{defaultValue:"View History"}),children:jsxRuntime.jsx(Ql.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${w} max-md:hidden`,title:f("tooltips.duplicate",{defaultValue:"Duplicate"}),children:jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5"})}),x&&jsxRuntime.jsx("button",{type:"button",onClick:x,className:`${w} max-md:hidden`,title:f("tooltips.copyData",{defaultValue:"Copy Data"}),children:jsxRuntime.jsx(Ql.ClipboardCopy,{className:"w-3.5 h-3.5"})}),g&&jsxRuntime.jsx("button",{type:"button",onClick:g,className:`${w} max-md:hidden`,title:f("tooltips.pasteData",{defaultValue:"Paste Data"}),children:jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsxRuntime.jsx("button",{type:"button",onClick:d,className:`${w} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:f("tooltips.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})}),u&&jsxRuntime.jsx("button",{type:"button",onClick:u,className:`${w} max-md:hidden`,title:f("tooltips.toggleSidebar",{defaultValue:"Toggle Sidebar"}),children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),jsxRuntime.jsxs("div",{ref:$,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>A(!h),className:w,title:f("tooltips.more",{defaultValue:"More"}),children:jsxRuntime.jsx(Ql.EllipsisVertical,{className:"w-3.5 h-3.5"})}),h&&jsxRuntime.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-1 max-h-[70vh] overflow-y-auto",children:[y&&jsxRuntime.jsxs("div",{className:"px-3 py-2 text-[10px] text-[var(--kyro-text-muted)] border-b border-[var(--kyro-border)] flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${vc[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:y})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:k.map(D=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{p(D),A(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${b===D?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:D==="edit"?"Edit":D==="version"?"Ver":"API"},D))}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),x&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{x(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.ClipboardCopy,{className:"w-3.5 h-3.5"})," Copy Data"]}),g&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{g(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-3.5 h-3.5"})," Paste Data"]}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.Eye,{className:"w-3.5 h-3.5"})," Preview"]}),d&&jsxRuntime.jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>{d(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger-bg)] transition-colors",children:[jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxRuntime.jsxs("button",{type:"button",onClick:a,disabled:t==="saving",className:"kyro-btn kyro-btn-primary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(Ql.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxRuntime.jsxs("button",{type:"button",onClick:n,disabled:t==="saving",className:"kyro-btn kyro-btn-secondary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(Ql.Undo,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxRuntime.jsxs(Ro,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[s&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.Copy,{className:"w-4 h-4"}),onClick:s,children:"Duplicate"}),x&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.ClipboardCopy,{className:"w-4 h-4"}),onClick:x,children:"Copy Data"}),g&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-4 h-4"}),onClick:g,children:"Paste Data"}),i&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.Clock,{className:"w-4 h-4"}),onClick:i,children:"View History"}),l&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4"}),onClick:l,children:"Preview"}),(s||x||g||i||l)&&jsxRuntime.jsx(Xa,{}),d&&jsxRuntime.jsx(Pt,{onClick:d,danger:true,icon:jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function Ai({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:i,mode:l="collection"}){let{t:d}=reactI18next.useTranslation(),{confirm:c,alert:u}=yt(),[m,v]=Ta.useState({}),[x,g]=Ta.useState({}),[f,b]=Ta.useState(true),[p,h]=Ta.useState(false),[A,$]=Ta.useState(false),[T,k]=Ta.useState(false),[y,w]=Ta.useState("idle"),[D,U]=Ta.useState("draft"),[O,z]=Ta.useState(null),[P,R]=Ta.useState(null),[Ae,E]=Ta.useState(null),[oe,ie]=Ta.useState(false),ee=ge(M=>M.showPreview),G=ge(M=>M.setShowPreview),ye=ge(M=>M.previewUrl),De=ge(M=>M.setPreviewUrl),L=r?.fields||t?.fields||[],W=r?.label||t?.label||"Document",re=r?.slug||t?.slug||"",H=JSON.stringify(m)!==JSON.stringify(x);Ta.useEffect(()=>{H&&D==="published"&&U("draft");},[H,D]),Ta.useEffect(()=>{H&&y==="saved"&&w("idle");},[H,y]),Ta.useEffect(()=>{l==="global"?fe():o&&Te();},[o,l,re]);let Te=async()=>{try{b(!0);let M=await Ee(`/api/${re}/${o}`,{autoToast:!1}),K=M.data||{};v(K),g(K),U(K?.status||M.status||"draft"),z(M.createdAt||K.createdAt||null),R(M.updatedAt||K.updatedAt||null),E(M.publishedAt||K.publishedAt||null);}catch{i("Failed to load document");}finally{b(false);}},fe=async()=>{try{b(!0);let M=await Ee(`/api/globals/${re}`,{autoToast:!1}),K=M.data||{};v(K),g(K),z(M.createdAt||null),R(M.updatedAt||null);}catch{i("Failed to load global");}finally{b(false);}},we=Ta.useCallback(async(M=false)=>{try{w("saving");let K=l==="global"?`/api/globals/${re}`:`/api/${re}/${o}`,le=D==="draft"||m?.status==="draft",Fe=await Yt(K,m,{autoToast:!1,headers:{"X-Draft":String(le)}}),Oe=Fe&&(Fe.data||Fe)||m;M||(g(Oe),n()),v(Oe),U(Oe?.status||D),w("saved"),R(new Date().toISOString()),ie(!0),setTimeout(()=>ie(!1),3e3),M||(D==="draft"||Oe?.status==="draft"?V.warning(d("toast.draftSaved",{defaultValue:"Draft saved"})):V.success(d("toast.updated",{defaultValue:"Updated"}))),setTimeout(()=>{w("idle");},2e3),ee&&ft(Oe);}catch{w("error"),M||(i(d("toast.saveError",{defaultValue:"Failed to save changes"})),V.error(d("toast.saveError",{defaultValue:"Failed to save changes"})));}finally{h(false);}},[m,l,re,o,D,n,i]),S=async()=>{try{h(!0),await Yt(`/api/${re}/${o}`,m,{autoToast:!1,headers:{"X-Draft":"false"}}),U("published"),E(new Date().toISOString()),V.success(d("toast.published",{defaultValue:"Published successfully"})),n();}catch{i(d("toast.publishError",{defaultValue:"Failed to publish"})),V.error(d("toast.publishError",{defaultValue:"Failed to publish"}));}finally{h(false);}},j=async()=>{try{h(!0),await Yt(`/api/${re}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),U("draft"),V.warning(d("toast.unpublished",{defaultValue:"Document unpublished"})),n();}catch{i(d("toast.unpublishError",{defaultValue:"Failed to unpublish"})),V.error(d("toast.unpublishError",{defaultValue:"Failed to unpublish"}));}finally{h(false);}},xe=async()=>{try{$(!0);let M=await dt(`/api/${re}/${o}/duplicate`,void 0,{autoToast:!1});V.success(d("toast.duplicated",{defaultValue:"Document duplicated"})),M?.data?.id?window.location.href=`${Ue}/${re}/${M.data.id}`:window.location.href=`${Ue}/${re}`;}catch(M){V.error(M.message||d("toast.duplicateError",{defaultValue:"Failed to duplicate document"}));}finally{$(false);}},Le=async()=>{try{let M={...m};delete M.id,delete M.createdAt,delete M.updatedAt,delete M.status,await navigator.clipboard.writeText(JSON.stringify(M)),V.success(d("toast.dataCopied",{defaultValue:"Document data copied to clipboard"}));}catch{V.error(d("toast.copyError",{defaultValue:"Failed to copy document data"}));}},Be=async()=>{try{let M=await navigator.clipboard.readText(),K=JSON.parse(M);if(typeof K!="object"||K===null)throw new Error("Invalid format");v(le=>({...le,...K,id:le.id,createdAt:le.createdAt,updatedAt:le.updatedAt,status:le.status})),V.success(d("toast.dataPasted",{defaultValue:"Document data pasted"}));}catch{V.error(d("toast.pasteError",{defaultValue:"Clipboard does not contain valid document JSON"}));}},Pe=()=>{c({title:d("detailView.deleteTitle",{defaultValue:"Delete {{label}}?",label:W}),message:d("detailView.deleteMessage",{defaultValue:"This action cannot be undone."}),variant:"danger",onConfirm:async()=>{try{k(!0),await At(`/api/${re}/${o}`),window.location.href=`${Ue}/${re}`;}catch{k(false);}}});},ft=async(M=m)=>{try{let K=l==="global"?`/api/globals/${re}/preview-url`:`/api/${re}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",K,"with data keys:",Object.keys(M||{}),"documentId:",o);let le=await dt(K,{...M,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(le)),le&&le.url?(console.log("[Kyro Preview] Setting previewUrl:",le.url),De(le.url)):console.warn("[Kyro Preview] No url in response:",le);}catch(K){console.error("[Kyro Preview] Error:",K.message,K),V.error(K.message||"Failed to generate preview URL");}};Ta.useEffect(()=>{ee&&ft(m);},[ee]);let qt=()=>{let M=!ee;G(M),M&&ft(m);};if(f)return jsxRuntime.jsx("div",{className:"kyro-detail",children:jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(jt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(jt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(jt,{variant:"rect",count:4})})]})});let J=l==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Lt,{back:{onClick:a},breadcrumbs:[{label:l==="global"?d("detailView.globals",{defaultValue:"Globals"}):d("detailView.collections",{defaultValue:"Collections"})},{label:W,href:l==="collection"?`${Ue}/${re}`:void 0},{label:l==="global"?d("actions.edit",{defaultValue:"Edit"}):o?d("actions.edit",{defaultValue:"Edit"}):d("actions.new",{defaultValue:"New"})}],title:l==="global"?W:ho(t?.fields,m,t?.admin?.useAsTitle||"title")||m.name||o||d("detailView.newDocument",{defaultValue:"New {{label}}",label:t?.singularLabel||W}),metadata:[jsxRuntime.jsx(Rt,{variant:D==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:d(`status.${D}`,{defaultValue:D})},"status")]}),jsxRuntime.jsx(Si,{status:D,saveStatus:y,hasChanges:H,onSave:()=>we(false),onPublish:S,onUnpublish:D==="published"?j:void 0,onDuplicate:xe,onCopyData:Le,onPasteData:Be,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:t?.admin?.disablePreview||r?.admin?.disablePreview?void 0:qt,onDelete:Pe,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:Ae,updatedAt:P}),jsxRuntime.jsxs("div",{className:ee?"w-full mx-auto grid grid-cols-1 lg:grid-cols-2 gap-4 md:gap-8 pt-4 md:pt-0 h-[calc(100vh-140px)]":J?"w-full pt-4 md:pt-8":"w-full mx-auto grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-4 md:gap-8 pt-4 md:pt-0",children:[jsxRuntime.jsx("div",{className:`space-y-4 md:space-y-8 min-w-0 ${ee?"overflow-y-auto pr-2 pb-20":""}`,children:jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsxRuntime.jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:d("detailView.coreConfiguration",{defaultValue:"Core Configuration"})}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(Ya,{config:t?{...t,fields:L}:{slug:"unknown",fields:L},data:m,onChange:v,layout:J?"single":"split",globalSlug:l==="global"?re:void 0,collectionSlug:l==="collection"?re:void 0,onActionSuccess:M=>V.success(M),onActionError:M=>V.error(M),documentStatus:D,justSaved:oe}),J&&jsxRuntime.jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[l==="collection"&&o&&jsxRuntime.jsx("button",{type:"button",onClick:Pe,disabled:T||p,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:T?d("actions.deleting",{defaultValue:"Deleting..."}):d("actions.deleteDocument",{defaultValue:"Delete Document"})}),jsxRuntime.jsx(Ro,{status:D,saveStatus:p?"saving":"idle",hasChanges:H,onPublish:()=>we(false),disabled:p})]})]})}),ee&&jsxRuntime.jsxs("div",{className:"surface-tile flex flex-col overflow-hidden h-full border border-[var(--kyro-border)] rounded-xl animate-in fade-in slide-in-from-right-4 duration-500 shadow-xl bg-white dark:bg-black",children:[jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface-accent)] border-b border-[var(--kyro-border)] p-2 flex items-center justify-between shrink-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-2",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-red-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-green-400/80"})]}),jsxRuntime.jsx("div",{className:"text-[10px] font-mono opacity-50 truncate max-w-[60%] bg-[var(--kyro-bg)] px-3 py-1 rounded",children:ye||d("detailView.generatingPreview",{defaultValue:"Generating preview URL..."})}),jsxRuntime.jsx("div",{className:"w-16"})]}),jsxRuntime.jsx("div",{className:"flex-1 bg-white relative",children:ye?jsxRuntime.jsx("iframe",{src:ye,className:"w-full h-full border-0 bg-white",title:d("tooltips.preview",{defaultValue:"Preview"}),sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"}):jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx(ar,{className:"w-6 h-6 text-[var(--kyro-primary)]"})})})]}),!J&&!ee&&jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4 md:mb-6",children:d("detailView.metadata",{defaultValue:"Metadata"})}),jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dynamicStatus",{defaultValue:"Dynamic Status"})}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-[9px] font-bold tracking-widest ${D==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:D||"draft"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dateCreated",{defaultValue:"Date Created"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:O?new Date(O).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("common.na",{defaultValue:"N/A"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.lastModified",{defaultValue:"Last Modified"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:P?new Date(P).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("detailView.justNow",{defaultValue:"Just now"})})]}),Ae&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.publicAt",{defaultValue:"Public At"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(Ae).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})})]})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8 bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-3 md:mb-4",children:d("detailView.quickLinks",{defaultValue:"Quick Links"})}),jsxRuntime.jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:xe,disabled:A||p,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:A?d("actions.duplicating",{defaultValue:"Duplicating..."}):d("actions.duplicateDocument",{defaultValue:"Duplicate Document"})}),ye&&jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(ye,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:d("detailView.openPreview",{defaultValue:"Open Preview in New Tab"})}),jsxRuntime.jsx("button",{type:"button",onClick:Pe,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:d("actions.deleteEntry",{defaultValue:"Delete Entry"})})]})]})]})]})]})}function Di({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=Ta.useState({}),[i,l]=Ta.useState(false),d=t.fields||[],c=t.label||t.slug,u=async m=>{try{l(!0),await dt(`/api/${t.slug}`,n),V.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(v){a(v instanceof Error?v.message:"Failed to create");}finally{l(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Lt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${Ue}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:i?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>u(),disabled:i}}),jsxRuntime.jsx("div",{className:"kyro-detail-body",children:jsxRuntime.jsx("div",{className:"kyro-card",children:jsxRuntime.jsx("div",{className:"kyro-card-content",children:jsxRuntime.jsx("form",{children:jsxRuntime.jsx(Ya,{config:{...t,fields:d},data:n,onChange:s})})})})})]})}function xc({type:e,message:t,onClose:r}){let[o,a]=Ta__default.default.useState(false),n=Ta__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},i=()=>{n.current&&clearTimeout(n.current);};Ta__default.default.useEffect(()=>(o?i():s(),i),[o,r]);let l={success:Ql.CircleCheck,error:Ql.ShieldAlert,warning:Ql.TriangleAlert,info:Ql.Info}[e];return jsxRuntime.jsxs("div",{className:`kyro-toast kyro-toast-${e} group animate-in fade-in slide-in-from-right-4 duration-300`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),children:[jsxRuntime.jsx("div",{className:"kyro-toast-accent"}),jsxRuntime.jsx("div",{className:"kyro-toast-icon-container",children:jsxRuntime.jsx(l,{className:"w-4 h-4"})}),jsxRuntime.jsx("div",{className:"kyro-toast-content",children:jsxRuntime.jsx("p",{className:"kyro-toast-message",children:t})}),jsxRuntime.jsx("button",{type:"button",className:"kyro-toast-close group-hover:opacity-100 opacity-40 transition-opacity",onClick:r,children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5"})})]})}function uF({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function pF(){let e=Xt(o=>o.addToast),t=Xt(o=>o.removeToast);return {toasts:Xt(o=>o.toasts),addToast:e,removeToast:t}}function us(){let e=Xt(r=>r.toasts),t=Xt(r=>r.removeToast);return jsxRuntime.jsx("div",{className:"kyro-toasts-container",style:{position:"fixed",bottom:"24px",right:"24px",display:"flex",flexDirection:"column",gap:"12px",zIndex:1e5,pointerEvents:"none"},children:e.map(r=>jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:jsxRuntime.jsx(xc,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Fi({onAuth:e,theme:t="light"}){let{t:r}=reactI18next.useTranslation(),[o,a]=Ta.useState("login"),[n,s]=Ta.useState(""),[i,l]=Ta.useState(""),[d,c]=Ta.useState(""),[u,m]=Ta.useState(false),[v,x]=Ta.useState(false),g=Xt(p=>p.addToast);Ta.useEffect(()=>{f();},[]);let f=async()=>{try{await Ee("/api/users");}catch{x(true),a("register");}},b=async p=>{p.preventDefault(),m(true);try{let h=o==="login"?"/api/auth/login":"/api/auth/register",A={email:n,password:i};o==="register"&&(A.confirmPassword=d);let $=await dt(h,A);$.isFirstUser&&x(!0),localStorage.setItem("kyro_user",JSON.stringify($.user)),g("success",o==="login"?r("toast.welcomeBack",{defaultValue:"Welcome back!"}):r("toast.accountCreated",{defaultValue:"Account created!"})),e($.token,$.user);}catch{g("error",r("toast.connectionFailed",{defaultValue:"Connection failed"}));}finally{m(false);}};return jsxRuntime.jsx(Sr,{defaultMode:t,children:jsxRuntime.jsxs("div",{className:"kyro-login-page",children:[jsxRuntime.jsxs("div",{className:"kyro-login-container",children:[jsxRuntime.jsxs("div",{className:"kyro-login-header",children:[jsxRuntime.jsx("h1",{className:"kyro-login-title",children:v?r("login.createAdminAccount",{defaultValue:"Create Admin Account"}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:v?r("login.setupAdmin",{defaultValue:"Set up your admin account to get started"}):o==="login"?r("login.enterCredentials",{defaultValue:"Enter your credentials to access the admin"}):r("login.createAccountDesc",{defaultValue:"Create an account to access the admin"})})]}),jsxRuntime.jsxs("form",{onSubmit:b,className:"kyro-login-form",children:[jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"email",children:r("login.email",{defaultValue:"Email"})}),jsxRuntime.jsx("input",{id:"email",type:"email",value:n,onChange:p=>s(p.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:r("login.password",{defaultValue:"Password"})}),jsxRuntime.jsx("input",{id:"password",type:"password",value:i,onChange:p=>l(p.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:o==="login"?"current-password":"new-password"})]}),o==="register"&&jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"confirmPassword",children:r("login.confirmPassword",{defaultValue:"Confirm Password"})}),jsxRuntime.jsx("input",{id:"confirmPassword",type:"password",value:d,onChange:p=>c(p.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsxRuntime.jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:u,children:u?o==="login"?r("login.signingIn",{defaultValue:"Signing in..."}):r("login.creatingAccount",{defaultValue:"Creating account..."}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})})]}),!v&&jsxRuntime.jsx("div",{className:"kyro-login-footer",children:jsxRuntime.jsx("p",{children:o==="login"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("login.noAccount",{defaultValue:"Don't have an account?"})," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("register"),children:r("login.signUp",{defaultValue:"Sign up"})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("login.hasAccount",{defaultValue:"Already have an account?"})," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("login"),children:r("login.signInAction",{defaultValue:"Sign in"})})]})})})]}),jsxRuntime.jsx(us,{})]})})}function wc({collections:e,onNavigate:t,user:r}){let{t:o}=reactI18next.useTranslation(),{permissions:a}=_r(),[n,s]=Ta.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[i,l]=Ta.useState(true);Ta.useEffect(()=>{let c=setTimeout(()=>{s({totalDocs:124,totalMedia:856,totalUsers:12,recentActivity:[{id:1,type:"edit",user:"Daniel Dozie",doc:"Getting Started with Kyro",collection:"posts",time:"2m ago"},{id:2,type:"create",user:"Jane Smith",doc:"New Product Launch",collection:"products",time:"15m ago"},{id:3,type:"upload",user:"Daniel Dozie",doc:"hero-banner.jpg",collection:"media",time:"1h ago"},{id:4,type:"publish",user:"System",doc:"Weekly Update",collection:"posts",time:"3h ago"}]}),l(false);},800);return ()=>clearTimeout(c)},[]);let d=Object.entries(e).filter(([c])=>!Qs.includes(c)&&a?.collections?.[c]?.read!==false);return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsxRuntime.jsx(Lt,{title:o("dashboard.welcome",{defaultValue:"Welcome back, {{name}}",name:r?.email?.split("@")[0]||"Admin"}),description:o("dashboard.description",{defaultValue:"Everything looks great in your command center today."}),action:d.length>0&&a?.collections?.[d[0]?.[0]]?.create!==false?{label:o("actions.newDocument",{defaultValue:"New Document"}),onClick:()=>t("create",d[0]?.[0]),icon:Ql.Plus}:void 0}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:o("dashboard.totalContent",{defaultValue:"Total Content"}),value:n.totalDocs,icon:Ql.FileText,color:"text-blue-500"},{label:o("dashboard.mediaAssets",{defaultValue:"Media Assets"}),value:n.totalMedia,icon:Ql.Image,color:"text-purple-500"},{label:o("dashboard.activeUsers",{defaultValue:"Active Users"}),value:n.totalUsers,icon:Ql.Users,color:"text-green-500"},{label:o("dashboard.systemHealth",{defaultValue:"System Health"}),value:"100%",icon:Ql.Activity,color:"text-amber-500"}].map((c,u)=>jsxRuntime.jsxs("div",{className:"surface-tile p-6 flex items-center justify-between group hover:border-[var(--kyro-primary)] transition-all duration-500 cursor-default",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:c.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:i?jsxRuntime.jsx(jt,{variant:"text",className:"w-16"}):c.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${c.color}`,children:jsxRuntime.jsx(c.icon,{className:"w-6 h-6"})})]},u))}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxRuntime.jsxs("div",{className:"space-y-8 min-w-0",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Ql.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),o("dashboard.contentGrowth",{defaultValue:"Content Growth"})]}),jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:o("dashboard.contentGrowthDesc",{defaultValue:"Snapshot of document velocity over the last 7 days"})}),jsxRuntime.jsxs("div",{className:"h-48 w-full relative mb-12",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1000 200",preserveAspectRatio:"none",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"chartGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"var(--kyro-primary)",stopOpacity:"0.3"}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"var(--kyro-primary)",stopOpacity:"0"})]})}),jsxRuntime.jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60 L1000,200 L0,200 Z",fill:"url(#chartGradient)",className:"animate-pulse duration-[4s]"}),jsxRuntime.jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60",fill:"none",stroke:"var(--kyro-primary)",strokeWidth:"4",strokeLinecap:"round",vectorEffect:"non-scaling-stroke",className:"filter drop-shadow-[0_0_8px_var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-4 text-[10px] font-bold opacity-30 tracking-widest ",children:[jsxRuntime.jsx("span",{children:o("days.mon",{defaultValue:"Mon"})}),jsxRuntime.jsx("span",{children:o("days.tue",{defaultValue:"Tue"})}),jsxRuntime.jsx("span",{children:o("days.wed",{defaultValue:"Wed"})}),jsxRuntime.jsx("span",{children:o("days.thu",{defaultValue:"Thu"})}),jsxRuntime.jsx("span",{children:o("days.fri",{defaultValue:"Fri"})}),jsxRuntime.jsx("span",{children:o("days.sat",{defaultValue:"Sat"})}),jsxRuntime.jsx("span",{children:o("days.sun",{defaultValue:"Sun"})})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:d.map(([c,u])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",c),className:"p-6 rounded-2xl border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-bg-secondary)] hover:bg-[var(--kyro-surface)] transition-all cursor-pointer group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:u.label||c}),jsxRuntime.jsx(Ql.ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsxRuntime.jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:u.admin?.description||`Manage ${c} content.`})]},c))})]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-4",children:jsxRuntime.jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-5 h-5"}),o("dashboard.quickLinks",{defaultValue:"Quick Links"})]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[d.filter(([c])=>a?.collections?.[c]?.create!==false).map(([c])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",c),className:"w-full flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group/btn",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:o("dashboard.newAction",{defaultValue:"New {{item}}",item:e[c]?.singularLabel||e[c]?.label||c})}),jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},c)),d.every(([c])=>a?.collections?.[c]?.create===false)&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:o("dashboard.noCollections",{defaultValue:"No collections available for creation."})})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-8 bg-[#0f172a] text-white border-none shadow-2xl shadow-blue-500/10 overflow-hidden relative group cursor-pointer",children:[jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("h3",{className:"text-2xl font-bold tracking-tighter mb-2",children:o("dashboard.mediaLibrary",{defaultValue:"Media Library"})}),jsxRuntime.jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:o("dashboard.mediaLibraryDesc",{defaultValue:"Manage high-fidelity assets with our liquid masonry gallery."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-bold text-xs tracking-widest text-blue-400",children:[o("dashboard.openAssets",{defaultValue:"Open Assets"})," ",jsxRuntime.jsx(Ql.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(Ql.Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-5 h-5 opacity-40"}),o("dashboard.recentActivity",{defaultValue:"Recent Activity"})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:n.recentActivity.map(c=>jsxRuntime.jsxs("div",{className:"flex gap-4 group",children:[jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-bg-secondary)] flex items-center justify-center border border-[var(--kyro-border)] group-hover:bg-[var(--kyro-primary)] transition-colors",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold",children:c.user[0]})})}),jsxRuntime.jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxRuntime.jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsxRuntime.jsx("span",{className:"font-bold",children:c.user})," ",c.type==="create"?"created":c.type==="edit"?"edited":c.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',c.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:c.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:c.time})]})]},c.id))}),jsxRuntime.jsx("button",{type:"button",className:"w-full mt-6 py-3 text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors border-t border-[var(--kyro-border)] pt-6",children:o("dashboard.viewAuditLogs",{defaultValue:"View Audit Logs"})})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Activity,{className:"w-5 h-5 opacity-40"}),o("dashboard.systemStatus",{defaultValue:"System Status"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:[{label:o("dashboard.cloudApi",{defaultValue:"Cloud API"}),status:o("dashboard.statusOptimal",{defaultValue:"Optimal"}),pulse:"bg-green-500"},{label:o("dashboard.dbNode",{defaultValue:"Database Node"}),status:o("dashboard.statusHealthy",{defaultValue:"Healthy"}),pulse:"bg-green-500"},{label:o("dashboard.mediaCdn",{defaultValue:"Media CDN"}),status:o("dashboard.statusActive",{defaultValue:"Active"}),pulse:"bg-blue-500"},{label:o("dashboard.authService",{defaultValue:"Auth Service"}),status:o("dashboard.statusSecure",{defaultValue:"Secure"}),pulse:"bg-green-500"}].map((c,u)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:c.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:c.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${c.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},u))})]})]})]})]})}function Cc(){let{t:e}=reactI18next.useTranslation(),[t,r]=Ta.useState([]),[o,a]=Ta.useState(true),[n,s]=Ta.useState(""),[i,l]=Ta.useState(false),[d,c]=Ta.useState({name:"",email:"",password:"",role:"customer"}),[u,m]=Ta.useState(""),[v,x]=Ta.useState(false),{confirm:g,alert:f}=yt();Ta.useEffect(()=>{b();},[]);let b=async()=>{try{a(!0);let k=await Ee("/api/users");r(k.docs||[]);}catch(k){console.error("Failed to load users:",k);}finally{a(false);}},p=k=>{let y=!k.locked;g({title:y?"Lock User Account?":"Unlock User Account?",message:y?`Are you sure you want to lock ${k.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${k.email}?`,variant:y?"danger":"success",onConfirm:async()=>{try{await Yt(`/api/users/${k.id}`,{locked:y}),r(w=>w.map(D=>D.id===k.id?{...D,locked:y}:D)),V.success(y?`Account locked: ${k.email}`:`Account restored: ${k.email}`);}catch(w){console.error("Failed to toggle user lock:",w),V.error("Failed to update account status");}}});},h=k=>{g({title:"Destroy User Account",message:`You are about to permanently delete ${k.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await At(`/api/users/${k.id}`),r(y=>y.filter(w=>w.id!==k.id)),V.success(`Identity purged: ${k.email}`);}catch(y){console.error("Failed to delete user:",y),V.error("Failed to delete user");}}});},A=async()=>{if(!d.email.trim()||!d.password.trim()){m("Email and password are required");return}x(true),m("");try{await dt("/api/users",{name:d.name.trim()||void 0,email:d.email.trim(),password:d.password,role:d.role}),l(!1),c({name:"",email:"",password:"",role:"customer"}),V.success("User created successfully"),b();}catch(k){let y=k instanceof Error?k.message:"Failed to create user";m(y),V.error(y);}finally{x(false);}},$=["super_admin","admin","editor","author","customer","guest"],T=t.filter(k=>k.email.toLowerCase().includes(n.toLowerCase())||k.name?.toLowerCase().includes(n.toLowerCase()));return jsxRuntime.jsxs("div",{className:"w-full space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-700 px-4 md:px-8 pb-12",children:[jsxRuntime.jsx(Lt,{title:e("tooltips.identityAccess",{defaultValue:"Identity & Access"}),description:"Manage the core administrative team and security permissions.",icon:Ql.Users,action:{label:"New User",onClick:()=>{c({name:"",email:"",password:"",role:"customer"}),m(""),l(true);},icon:Ql.UserPlus}}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 group",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-secondary)] opacity-40 group-focus-within:opacity-100 transition-opacity"}),jsxRuntime.jsx("input",{type:"text",placeholder:e("fields.searchByIdentityOr",{defaultValue:"Search by identity or email..."}),value:n,onChange:k=>s(k.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest bg-[var(--kyro-surface)] shadow-sm rounded-lg border border-[var(--kyro-border)]",children:"ALL"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"ADMINS"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"LOCKED"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[9px] tracking-[0.2em] uppercase border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-64",children:"Member Identity"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Administrative Role"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Security Status"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Last Activity"}),jsxRuntime.jsx("th",{className:"px-6 py-4 w-32 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:o?Array.from({length:6}).map((k,y)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},y)):T.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-20 text-center",children:jsxRuntime.jsx("p",{className:"text-xs font-bold opacity-30 tracking-widest uppercase italic",children:"No identity matches found"})})}):T.map(k=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${k.locked?"opacity-50 grayscale":""}`,children:[jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(wf,{user:k}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs font-bold text-[var(--kyro-text-primary)] truncate",children:k.name||k.email.split("@")[0]}),k.tenantId&&jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:k.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:k.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:k.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(Rt,{variant:k.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:k.locked?"Restricted":"Authorized"})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3 h-3"}),k.lastLogin?new Date(k.lastLogin).toLocaleDateString():"Never"]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsxRuntime.jsx("button",{onClick:()=>p(k),className:`p-1.5 rounded-lg border transition-all ${k.locked?"bg-green-500/10 text-green-500 border-green-500/20 hover:bg-green-500/20":"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20"}`,title:k.locked?"Restore Access":"Restrict Access",children:k.locked?jsxRuntime.jsx(Ql.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Ql.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>h(k),className:"p-1.5 rounded-lg border border-red-500/20 bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-all",title:e("tooltips.deleteUser",{defaultValue:"Delete User"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})})]})})]},k.id))})]})}),jsxRuntime.jsxs(St,{open:i,onClose:()=>l(false),title:e("tooltips.createUser",{defaultValue:"Create User"}),size:"lg",children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Name (optional)"}),jsxRuntime.jsx("input",{type:"text",value:d.name,onChange:k=>c({...d,name:k.target.value}),placeholder:e("fields.johnDoe",{defaultValue:"John Doe"}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Email Address"}),jsxRuntime.jsx("input",{type:"email",value:d.email,onChange:k=>c({...d,email:k.target.value}),placeholder:"user@example.com",required:true,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Password"}),jsxRuntime.jsx("input",{type:"password",value:d.password,onChange:k=>c({...d,password:k.target.value}),placeholder:e("fields.minimum12Characters",{defaultValue:"Minimum 12 characters"}),required:true,minLength:12,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Role"}),jsxRuntime.jsx("select",{value:d.role,onChange:k=>c({...d,role:k.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]",children:$.map(k=>jsxRuntime.jsx("option",{value:k,children:k},k))})]}),u&&jsxRuntime.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl flex items-center gap-2 text-red-500 text-xs font-bold",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-4 h-4"}),u]})]})}),jsxRuntime.jsxs(Mr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>l(false),className:"px-6 py-2.5 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:A,disabled:v,className:"kyro-btn kyro-btn-primary px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/10 disabled:opacity-50",children:v?"Creating...":"Create User"})]})]})]})}function wf({user:e}){let[t,r]=Ta.useState(null);return Ta.useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Ee(`/api/media/${o}`).then(a=>r(a?.thumbnailUrl||a?.url||null)).catch(()=>r(null));},[e.avatar]),t?jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border border-[var(--kyro-border)] flex-shrink-0",children:jsxRuntime.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"})}):jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] flex items-center justify-center text-xs font-bold text-[var(--kyro-primary)] flex-shrink-0",children:e.name?e.name[0]:e.email[0].toUpperCase()})}function Sc(){let{t:e}=reactI18next.useTranslation(),[t,r]=Ta.useState("Kyro CMS"),[o,a]=Ta.useState("Command Center"),[n,s]=Ta.useState("#6366f1"),[i,l]=Ta.useState("Welcome back to your Command Center."),[d,c]=Ta.useState(false),[u,m]=Ta.useState(false);Ta.useEffect(()=>{(async()=>{try{let f=await Ee("/api/globals/site-settings"),b=f.data||f;b&&Object.keys(b).length>0&&(b.siteName&&r(b.siteName),b.adminTitle&&a(b.adminTitle),b.primaryColor&&s(b.primaryColor),b.dashboardGreeting&&l(b.dashboardGreeting));}catch(f){console.error("Failed to load branding:",f);}})();},[]);let v=async()=>{c(true);try{await Yt("/api/globals/site-settings",{siteName:t,adminTitle:o,primaryColor:n,dashboardGreeting:i}),m(!0),V.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",n),setTimeout(()=>window.location.reload(),800);}catch(g){V.error("Failed to save branding"),console.error(g);}finally{c(false);}},x=[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}];return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 pt-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:["Branding ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Hub"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-1 font-medium opacity-60",children:"Customize the identity and aesthetic of your administrative ecosystem."})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:jsxRuntime.jsxs("button",{type:"button",onClick:v,disabled:d,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${u?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[d?jsxRuntime.jsx(Ql.RefreshCcw,{className:"w-4 h-4 animate-spin"}):u?jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(Ql.Save,{className:"w-4 h-4"}),d?"Saving...":u?"Identity Updated":"Publish Branding"]})})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Ql.Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:g=>r(g.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Acme Corp CMS"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Admin Dashboard Title"}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:g=>a(g.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Command Center"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"System Greeting"}),jsxRuntime.jsx("textarea",{value:i,onChange:g=>l(g.target.value),rows:3,className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all resize-none",placeholder:e("fields.greetingTextForThe",{defaultValue:"Greeting text for the dashboard..."})})]})]})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Ql.Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsxRuntime.jsx("div",{className:"grid grid-cols-6 gap-3",children:x.map(g=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(g.hex),className:`aspect-square rounded-xl transition-all border-4 ${n===g.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:g.hex},title:g.name},g.name))})]}),jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.jsxs("div",{className:"w-20 h-20 rounded-2xl bg-[var(--kyro-bg-secondary)] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-primary)] hover:text-[var(--kyro-primary)] cursor-pointer transition-all",children:[jsxRuntime.jsx(Ql.Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsxRuntime.jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsxRuntime.jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsxRuntime.jsx(Ql.Sparkles,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxRuntime.jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-2 bg-[var(--kyro-bg-secondary)] rounded-full border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[o," Online"]})]}),jsxRuntime.jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",t,"."]}),jsxRuntime.jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:i})]}),jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:`
99
+ \`\`\``})})}),!s&&jsxRuntime.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx("span",{children:"**bold**"}),jsxRuntime.jsx("span",{children:"*italic*"}),jsxRuntime.jsx("span",{children:"`code`"}),jsxRuntime.jsx("span",{children:"[link](url)"}),jsxRuntime.jsx("span",{children:"# heading"})]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"kyro-form-help",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:o})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx("div",{className:"h-[200px] bg-[var(--kyro-surface)] animate-pulse rounded-md border border-[var(--kyro-border)]"})]})};function ks({field:e,value:t,onChange:r,error:o,disabled:a}){let n=t??"",s=n.length>8?n.slice(0,-8)+"*".repeat(8):n;return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:s,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})})})}function Io(e,t){if(e===t)return true;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return false;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!Io(e[a],t[a]))return false;return true}if(Array.isArray(e)||Array.isArray(t))return false;let r=Object.keys(e).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id"),o=Object.keys(t).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id");if(r.length!==o.length)return false;for(let a of r)if(!o.includes(a)||!Io(e[a],t[a]))return false;return true}function Hi(e){if(e==null||e===""||e===false)return true;if(Array.isArray(e))return e.length===0;if(typeof e=="object"){if(Object.keys(e).length===0)return true;if(e.type==="doc"&&Array.isArray(e.content))return e.content.length===0||e.content.length===1&&e.content[0].type==="paragraph"&&!e.content[0].content}return false}function qt(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(qt);if(typeof e=="object"){let t=e,r=Object.keys(t),o="id"in t&&(typeof t.id=="string"||t.id===null),a="url"in t&&("filename"in t||"mimeType"in t);if(o&&a&&r.length<=25)return t.id;let n={};for(let s of r)n[s]=qt(t[s]);return n}return e}var ws=null,Ic=false,_i=async()=>(ws&&Ic||(ws=unstorage.createStorage({driver:Ly__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),Ic=true),ws),Ey=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await _i()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await _i()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await _i()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},xe=zustand.create()(middleware.persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,previewUrl:null,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields),s=qt(o),i=qt(a.lastSavedData[r]);Hi(s)&&Hi(i)||Io(s,i)?n.delete(r):n.add(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),s={...a.formData},i=s;for(let l=0;l<n.length-1;l++)i[n[l]]===void 0&&(i[n[l]]={}),i[n[l]]={...i[n[l]]},i=i[n[l]];return i[n[n.length-1]]=o,{formData:s}});},setActiveTab:r=>e({activeTab:r}),setIsSlugLocked:r=>e(o=>({isSlugLocked:typeof r=="function"?r(o.isSlugLocked):r})),setView:r=>e({view:r}),setIsDropdownOpen:r=>e(o=>({isDropdownOpen:typeof r=="function"?r(o.isDropdownOpen):r})),setVersions:r=>e({versions:r}),setLoadingVersions:r=>e({loadingVersions:r}),setShowPreview:r=>e(o=>({showPreview:typeof r=="function"?r(o.showPreview):r})),setPreviewUrl:r=>e({previewUrl:r}),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[s,i]of Object.entries(a))o-new Date(i.draftUpdatedAt).getTime()<6048e5&&(n[s]=i);e({draftCache:n});},setDraftCache:(r,o)=>e(a=>({draftCache:{...a.draftCache,[r]:o}})),getDraftCache:r=>t().draftCache[r]||null,clearDraftCache:r=>e(o=>{let a={...o.draftCache};return delete a[r],{draftCache:a}})}),{name:"kyro-autoform-storage",storage:middleware.createJSONStorage(()=>Ey()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function Ns(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function ma({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=z(),s=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,i=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:d,setIsSlugLocked:c,formData:u}=xe(),p=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",f=t==null?"":String(t),y={id:e.name,value:f,onChange:g=>r?.(g.target.value),placeholder:e.admin?.placeholder,disabled:a||s||l&&d,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||s||l&&d?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"relative",children:[i?jsxRuntime.jsx("textarea",{...y,rows:e.admin?.rows||4}):jsxRuntime.jsx("input",{type:p,...y,pattern:e.pattern}),l&&jsxRuntime.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r?.(Ns(u[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:n("tooltips.regenerateSlug",{defaultValue:"Regenerate slug"}),children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),jsxRuntime.jsx("path",{d:"M21 3v5h-5"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>c(!d),className:`p-1.5 rounded transition-colors ${d?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:d?"Unlock slug":"Lock slug",children:d?jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})})]}),e.name?.toLowerCase().includes("metatitle")&&jsxRuntime.jsx("div",{className:"flex items-center justify-between mt-1 text-[10px] font-bold tracking-wider",children:jsxRuntime.jsxs("span",{className:f.length>60?"text-red-500":f.length>=40?"text-green-500":"text-amber-600",children:[f.length," / 60 \u2014 ",f.length>60?"Too Long":f.length>=40?"Ideal":"Short"]})})]})})}function Cs({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx("input",{type:"number",id:e.name,value:t??"",onChange:s=>r?.(parseFloat(s.target.value)||0),placeholder:e.admin?.placeholder,disabled:a||n,min:e.min,max:e.max,step:e.step||(e.integer?1:"any"),required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Ss({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(pt,{field:e,error:o,hideLabel:true,children:jsxRuntime.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t??false,onChange:i=>r?.(i.target.checked),disabled:a||n,className:`w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)] transition-all ${a||n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`}),jsxRuntime.jsxs("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)] tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})]})})}function As({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:s=>r?.(s.target.value),disabled:a||n,min:e.minDate,max:e.maxDate,required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function an(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Ds(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Ps(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function on(e,t){let r=new Set(e.map(o=>o.slug));for(let o of t)r.has(o.slug)||(e.push(o),r.add(o.slug));}var By={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function Lo(e,t,r){let o=t.split(".");if(o.length===0)return false;let a=o[0],n=o.slice(1).join(".");for(let s of e){if(s.name===a)if(n){if(s.fields&&Array.isArray(s.fields))return Lo(s.fields,n,r);if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let l of s.tabs)if(l.fields&&Array.isArray(l.fields)&&Lo(l.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let l=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of s.blocks)if(c.slug===l&&c.fields&&Array.isArray(c.fields))return Lo(c.fields,d,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?Lo(s.fields,n,r):false}else return Object.assign(s,r),true;if(!s.name||s.type==="tabs"||s.type==="row"||s.type==="collapsible"){if(s.fields&&Array.isArray(s.fields)&&Lo(s.fields,t,r))return true;if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let l of s.tabs)if(l.fields&&Array.isArray(l.fields)&&Lo(l.fields,t,r))return true}}}return false}function $y(e,t){for(let[r,o]of Object.entries(e)){let a=By[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:s,...i}=n;if(o.admin={...o.admin,...i},s&&o.fields&&Array.isArray(o.fields))for(let[l,d]of Object.entries(s))Lo(o.fields,l,d);}}}function Oy(e="blog"){let t=[],r=[];switch(e){case "minimal":t.push(...Object.values(templates.minimalCollections)),r.push(...templates.coreSettingsGlobals);break;case "starter":t.push(...Object.values(templates.starterCollections)),r.push(...templates.coreSettingsGlobals);break;case "blog":t.push(...Object.values(templates.blogCollections)),r.push(...templates.coreSettingsGlobals);break;case "ecommerce":t.push(...Object.values(templates.ecommerceCollections)),r.push(...templates.allSettingsGlobals);break;case "kitchen-sink":t.push(...Object.values(templates.minimalCollections),...Object.values(templates.starterCollections),...Object.values(templates.blogCollections),...Object.values(templates.ecommerceCollections),...Object.values(templates.kitchenSinkCollections)),r.push(...templates.allSettingsGlobals);break}return on(t,Object.values(templates.mediaCollections)),on(t,Object.values(templates.authCollections)),{collections:Ds(t),globals:Ps(r)}}function Vy(e){let t=an(e.collections),r=an(e.globals);if(t.length===0&&r.length===0)return Oy("kitchen-sink");let o=[];return on(o,Object.values(templates.mediaCollections)),on(o,Object.values(templates.authCollections)),on(o,t),{collections:Ds(o),globals:Ps(r)}}var Ts=null;function jy(){if(Ts)return Ts;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Ko__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return Ts=JSON.parse(Ko__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),Ts}catch{}return null}var _c=jy()||{collections:[],globals:[]},Kc=Vy(_c);$y(Kc.collections,_c.collectionOverrides);var Gc=Kc,fa=Gc.collections,Wc=Gc.globals,Wi=["users","audit_logs"];Object.values(fa).filter(e=>!Wi.includes(e.slug)&&e.admin?.hidden!==true);function Rs({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,u]=oa.useState(null),p=JSON.stringify(n||{}),f=JSON.stringify(s||{});oa.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let v=setTimeout(async()=>{try{let h="";if(i)h=`${Tr}/${i}/dynamic-options/${e.name}`;else if(l)h=`${Tr}/globals/${l}/dynamic-options/${e.name}`;else return;let m=await ct(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(p),siblingData:JSON.parse(f)})});if(m.ok){let w=await m.json();w.options&&u(w.options);}}catch(h){console.error("Failed to fetch dynamic options:",h);}},300);return ()=>clearTimeout(v)},[p,f,e.name,e.options,i,l]);let y=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?y=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(y=e.options)),e.dynamicOptions==="collections"&&(y=Object.keys(fa).filter(g=>g!=="media").map(g=>({label:fa[g]?.label||g,value:g}))),jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:g=>{if(e.hasMany){let v=Array.from(g.target.selectedOptions,h=>h.value);r?.(v);}else r?.(g.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,style:{color:e.hasMany?void 0:y.find(g=>g.value===t)?.color||void 0},className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),y.map(g=>jsxRuntime.jsx("option",{value:g.value,style:{color:g.color||void 0,fontWeight:g.color?"bold":"normal"},children:g.label},g.value))]})})}function Fs({icon:e,title:t,description:r,action:o}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 justify-center py-16 px-8",children:[e&&jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:e}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:t}),r&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:r}),o]})}function Zi(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function eg({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:i,transform:l,transition:d,isDragging:c}=sortable.useSortable({id:e}),u={transform:utilities.CSS.Transform.toString(l),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxRuntime.jsxs("span",{ref:i,style:u,className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)] border border-transparent ${c?"border-[var(--kyro-primary)] shadow-sm bg-[var(--kyro-sidebar-active)]/20":""}`,children:[!a&&jsxRuntime.jsx("div",{...n,...s,className:"cursor-grab active:cursor-grabbing hover:bg-[var(--kyro-sidebar-active)]/20 rounded p-0.5 text-[var(--kyro-sidebar-active)] opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(Nc.GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})}function tg({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=z(),[s,i]=oa.useState(false),[l,d]=oa.useState(""),[c,u]=oa.useState([]),[p,f]=oa.useState(false),[y,g]=oa.useState([]),v=oa.useRef(new Set),h=oa.useRef(null),m=oa.useRef(()=>{});m.current=r||(()=>{});let w=e.hasMany,C=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],E=C.length>1,[D,k]=oa.useState(C[0]||""),b=oa.useCallback(()=>t?(w?Array.isArray(t)?t:[]:t?[t]:[]).map(re=>typeof re=="object"&&re!==null?re.value||re.id||"":String(re)).filter(Boolean):[],[t,w]),x=oa.useCallback(L=>{L.length!==0&&L.forEach(re=>{if(v.current.has(re))return;v.current.add(re);let ne=E?(()=>{if(!t)return D;let H=(w?Array.isArray(t)?t:[]:[t]).find(pe=>typeof pe=="object"&&pe!==null?pe.value===re||pe.id===re:false);return H&&typeof H=="object"&&H.relationTo||D})():D;Be(`/api/${ne}/${re}`).then(ee=>{let H=ee.data||ee;!H||typeof H!="object"||g(pe=>pe.some(be=>be.id===re)?pe:[...pe,{...H,id:String(H.id),relationTo:ne}]);}).catch(()=>{});});},[E,t,D,w]);oa.useEffect(()=>{let L=b();x(L);},[b,x]);let N=oa.useCallback((L="")=>{f(true);let ne=`/api/${D}?${An(L,["title","name","label","email"])}`;Be(ne).then(ee=>{u(H=>{let pe=new Set(H.map(V=>V.id)),be=(ee.docs||[]).filter(V=>!pe.has(V.id)).map(V=>({...V,id:V.id}));return [...H,...be]}),f(false);}).catch(()=>{f(false);});},[D]);oa.useEffect(()=>{s&&(u([]),N(l));},[s,D]),oa.useEffect(()=>{let L=re=>{h.current&&!h.current.contains(re.target)&&i(false);};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[]);let O=L=>typeof L=="object"&&L!==null?L.value||L.id||"":String(L),M=L=>{let re=L.id;return t?w&&Array.isArray(t)?t.some(ne=>O(ne)===re):O(t)===re:false},I=L=>{let re=L.id;if(w){let ne=Array.isArray(t)?t:[];if(M(L))m.current?.(ne.filter(ee=>O(ee)!==re));else {let ee=E?{relationTo:D,value:re}:re;m.current?.([...ne,ee]);}}else if(M(L))m.current?.(null);else {let ne=E?{relationTo:D,value:re}:re;m.current?.(ne),i(false),d("");}},P=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),R=L=>{let{active:re,over:ne}=L;if(!ne||re.id===ne.id)return;let ee=w?Array.isArray(t)?t:[]:[],H=ee.findIndex(be=>O(be)===re.id),pe=ee.findIndex(be=>O(be)===ne.id);if(H!==-1&&pe!==-1){let be=[...ee],[V]=be.splice(H,1);be.splice(pe,0,V),m.current?.(be);}},fe=()=>{if(!t)return null;let L=w?Array.isArray(t)?t:[]:t?[t]:[],re=L.map(ne=>O(ne));return w&&L.length>1?jsxRuntime.jsx(core.DndContext,{sensors:P,collisionDetection:core.closestCenter,onDragEnd:R,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:re,strategy:sortable.horizontalListSortingStrategy,children:L.map(ne=>{let ee=O(ne),H=y.find(V=>V.id===ee),pe=H?Zi(H):ee.slice(0,12),be=E&&H?H.relationTo:null;return jsxRuntime.jsx(eg,{id:ee,label:pe,relation:be,onRemove:()=>{let V=L.filter(q=>O(q)!==ee);m.current?.(V);},disabled:a},ee)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:L.map(ne=>{let ee=O(ne),H=y.find(V=>V.id===ee),pe=H?Zi(H):ee.slice(0,12),be=E&&H?H.relationTo:null;return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[be&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[be,":"]}),pe,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let V=L.filter(q=>O(q)!==ee);m.current?.(w?V:V[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]},ee)})})};return jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[e.label&&jsxRuntime.jsxs("label",{className:"block text-sm font-medium text-[var(--kyro-text-primary)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]}),jsxRuntime.jsxs("div",{ref:h,className:"relative",children:[E&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:C.map(L=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{k(L),u([]),d("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${D===L?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:L},L))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Nc.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:L=>{d(L.target.value),i(true),N(L.target.value);},onFocus:()=>i(true),placeholder:e.admin?.placeholder||`Search ${D}...`,disabled:a||(typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly),className:"w-full pl-9 pr-10 py-2 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent disabled:opacity-50"}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:p?jsxRuntime.jsx(Nc.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(Nc.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${s?"rotate-180":""}`})})]}),s&&jsxRuntime.jsx("div",{className:"relative z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-64 overflow-auto",children:p?jsxRuntime.jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):c.length===0?jsxRuntime.jsx(Fs,{title:n("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsxRuntime.jsx("div",{className:"py-1",children:c.map(L=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>I(L),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${M(L)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:Zi(L)}),M(L)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in L&&typeof L.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:L.slug})]},L.id))})}),fe()]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-muted)]",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-error)]",children:o})]})}var nn=tg;var Eo=oa.createContext(null);function Jc(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=el(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=ga(a),{blocks:i}=o(),l=[...i];n!==void 0?l.splice(n,0,s):l.push(s),r({blocks:l});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:s}=o(),i=sn(s,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=[...l];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:l,found:false}});if(i!==s){r({blocks:i});let{onBlocksChange:l}=o();l&&l();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),s=sn(n,i=>{let l=i.filter(d=>d.id!==a);return l.length!==i.length?{newList:l,found:true}:{newList:i,found:false}});if(s!==n){r({blocks:s});let{onBlocksChange:i}=o();i&&i();}},moveBlock:(a,n)=>{let{blocks:s}=o(),i=sn(s,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<l.length){let u=[...l];return [u[d],u[c]]=[u[c],u[d]],{newList:u,found:true}}}return {newList:l,found:false}});if(i!==s){r({blocks:i});let{onBlocksChange:l}=o();l&&l();}}}))}function el(e){return Array.isArray(e)?e.map(t=>{let r={...t,id:t.id||Math.random().toString(36).substr(2,9)};return r.children&&Array.isArray(r.children)&&(r.children=el(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?el(o.children):o.children}))}),r}):[]}function ga(e){let t=ng(e),{options:r,children:o,...a}=t;return {id:Math.random().toString(36).substr(2,9),type:e,name:"",data:a,options:r,children:o,order:Date.now()}}function ng(e){return {heading:{level:1,text:""},"heading-subheading":{title:"",subtitle:""},hero:{isMultiScreen:false},card:{title:"",description:"",icon:"",link:"",linkText:"",isMultiCard:false},paragraph:{text:""},divider:{},callout:{text:"",variant:"info"},image:{src:"",alt:"",caption:""},video:{src:"",title:""},list:{type:"unordered",items:""},code:{language:"plaintext",code:""},link:{url:"",text:""},table:{rows:3,columns:3,content:""},quote:{text:"",author:""},file:{filename:"",url:""},columns:{columns:2,direction:"horizontal"},vstack:{direction:"vertical",gap:"md"},container:{options:{backgroundColor:"transparent",padding:"md",width:"full",margin:"none",minHeight:"none",borderRadius:"none"},children:[]},button:{text:"Button",url:"",variant:"primary",size:"md"},accordion:{title:"Accordion Item",content:""},gallery:{images:[]},tabs:{tabs:[{label:"Tab 1",content:""}]}}[e]||{}}function We(e){let t=oa.useContext(Eo);if(t)return zustand.useStore(t,r=>{let o=a=>{for(let n of a){if(n.id===e)return n;if(n.children&&n.children.length>0){let s=o(n.children);if(s)return s}if(n.data?.columnData){for(let s of n.data.columnData)if(s&&s.children&&s.children.length>0){let i=o(s.children);if(i)return i}}}};return o(r.blocks)})}function ze(){let e=oa.useContext(Eo);if(!e)throw new Error("useBlockActions must be used within a BlocksContext.Provider");return {updateBlock:(t,r)=>e.getState().updateBlock(t,r),removeBlock:t=>e.getState().removeBlock(t),moveBlock:(t,r)=>e.getState().moveBlock(t,r)}}function sn(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(s=>{let i={...s},l=false;if(s.children&&s.children.length>0){let d=sn(s.children,t);d!==s.children&&(i.children=d,l=true);}if(s.data?.columnData&&Array.isArray(s.data.columnData)){let d=s.data.columnData.map(c=>{if(c.children&&c.children.length>0){let u=sn(c.children,t);if(u!==c.children)return {...c,children:u}}return c});d.some((c,u)=>c!==s.data.columnData[u])&&(i.data={...i.data,columnData:d},l=true);}return l&&(a=true),l?i:s});return a?n:e}function dn({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let{t:n}=z(),[s,i]=oa__default.default.useState(null),l=async()=>{try{i(null);let d=await navigator.clipboard.readText(),c=JSON.parse(d);c.__kyro_block?o&&o(c):i("Clipboard does not contain a valid Kyro block.");}catch(d){i("Failed to read block from clipboard."),console.error(d);}};return e?jsxRuntime.jsxs(hr,{open:e,onClose:t,title:n("tooltips.insertBlock",{defaultValue:"Insert Block"}),width:"md",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)] mb-4",children:"Drag blocks into the editor or click to insert"}),o&&jsxRuntime.jsxs("div",{className:"mb-6 pb-6 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 py-2 px-4 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] text-sm font-semibold transition-all hover:bg-[var(--kyro-primary)]/5",children:[jsxRuntime.jsx(Nc.ClipboardPaste,{className:"w-4 h-4"}),"Paste Block from Clipboard"]}),s&&jsxRuntime.jsx("p",{className:"text-xs text-red-500 mt-2 text-center font-medium",children:s})]}),a]}):null}function Xc({block:e,onSelect:t,children:r}){let{attributes:o,listeners:a,setNodeRef:n,isDragging:s}=core.useDraggable({id:`drawer-${e.type}`,data:{source:"drawer",blockType:e.type}});return jsxRuntime.jsxs("div",{ref:n,...a,...o,onClick:()=>t(e.type),className:`flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group ${s?"opacity-50 border-[var(--kyro-primary)]":""}`,style:{opacity:s?.5:1},children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:r||jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)] leading-tight",children:e.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 leading-tight",children:e.description})]})]})}var tl=({text:e="",onChange:t,compact:r=false})=>{let{t:o}=z();return jsxRuntime.jsx("div",{className:r?"":"space-y-3",children:jsxRuntime.jsx("input",{type:"text",value:e,onChange:n=>t("text",n.target.value),className:r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.enterHeadingText",{defaultValue:"Enter heading text..."})})})};var Bo=({id:e,type:t,label:r,children:o,className:a=""})=>{let{t:n}=z(),{moveBlock:s,removeBlock:i}=ze();return jsxRuntime.jsxs("div",{className:`block-${t} border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group bg-[var(--kyro-surface)] transition-all hover:border-[var(--kyro-primary)]/30 ${a}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] tracking-wider",children:r||t}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:n("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var Zc=({block:e,index:t})=>{let r=We(e.id),{updateBlock:o}=ze(),a=r?.data||e.data||{},n=(s,i)=>{o(e.id,{data:{...a,[s]:i}});};return jsxRuntime.jsx(Bo,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx(tl,{text:a.text||"",onChange:n,compact:true})})};var tu=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a}=ze(),n=o?.data||e.data||{},s=(i,l)=>{a(e.id,{data:{...n,[i]:l}});};return jsxRuntime.jsx(Bo,{id:e.id,type:"paragraph",label:"Paragraph",children:jsxRuntime.jsx("textarea",{value:n.text||"",onChange:i=>s("text",i.target.value),className:"w-full px-3 py-3 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm min-h-[100px] resize-none",placeholder:r("fields.enterParagraphText",{defaultValue:"Enter paragraph text..."})})})};var ru=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsxRuntime.jsx(br,{field:{label:"Image Asset",name:"src",maxCount:1},value:i.src,onChange:d=>l("src",d)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Alt Text"}),jsxRuntime.jsx("input",{type:"text",value:i.alt||"",onChange:d=>l("alt",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.alternativeText",{defaultValue:"Alternative text..."})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Caption"}),jsxRuntime.jsx("input",{type:"text",value:i.caption||"",onChange:d=>l("caption",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.imageCaption",{defaultValue:"Image caption..."})})]})]})]})};var ol=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{let {t:n}=z();e.includes("youtube.com")||e.includes("vimeo.com")||e.includes("youtu.be");return a?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"url",value:e,onChange:i=>r("src",i.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:i=>r("title",i.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(br,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(i=>r("src",i))}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsxRuntime.jsx("input",{type:"url",value:e,onChange:i=>r("src",i.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:i=>r("title",i.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]})};var au=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(ol,{src:i.src||"",title:i.title||"",onChange:l,onUploadChange:d=>l("src",d),compact:true})]})};function bg({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:i,isDragging:l}=sortable.useSortable({id:e}),d={transform:utilities.CSS.Transform.toString(s),transition:i,zIndex:l?10:1,opacity:l?.8:1};return jsxRuntime.jsxs("div",{ref:n,style:d,className:`flex items-center gap-2 group/item p-1.5 hover:bg-[var(--kyro-surface-accent)]/50 rounded-md transition-colors ${l?"bg-[var(--kyro-surface-accent)] shadow-sm":""}`,children:[jsxRuntime.jsx("div",{...o,...a,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",onClick:c=>c.stopPropagation(),children:jsxRuntime.jsx(Nc.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:"opacity-0 group-hover/item:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",children:"\xD7"})]})}var cn=({items:e=[],onChange:t,compact:r=false})=>{let{t:o}=z(),[a,n]=oa__default.default.useState(""),[s,i]=oa__default.default.useState([]);oa__default.default.useEffect(()=>{let y=s.map(g=>g.text);JSON.stringify(y)!==JSON.stringify(e)&&i(e.map((g,v)=>({id:`${g}-${v}-${Math.random().toString(36).substr(2,4)}`,text:g})));},[e]);let l=()=>{a.trim()&&(t([...e,a.trim()]),n(""));},d=y=>{y.key==="Enter"&&(y.preventDefault(),l());},c=y=>{t(e.filter((g,v)=>v!==y));},u=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),p=y=>{let{active:g,over:v}=y;if(!v||g.id===v.id)return;let h=s.findIndex(w=>w.id===g.id),m=s.findIndex(w=>w.id===v.id);if(h!==-1&&m!==-1){let w=[...e],[C]=w.splice(h,1);w.splice(m,0,C),t(w);}},f=r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxRuntime.jsx(core.DndContext,{sensors:u,collisionDetection:core.closestCenter,onDragEnd:p,children:jsxRuntime.jsxs("div",{className:r?"space-y-1.5":"space-y-2",children:[e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:"No items. Type below to add."}):jsxRuntime.jsx(sortable.SortableContext,{items:s.map(y=>y.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:s.map((y,g)=>jsxRuntime.jsx(bg,{id:y.id,text:y.text,onRemove:()=>c(g)},y.id))})}),jsxRuntime.jsx("input",{type:"text",value:a,onChange:y=>n(y.target.value),onKeyDown:d,className:f,placeholder:o("fields.typeAndPressEnter",{defaultValue:"Type and press Enter to add..."})})]})})};var nu=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=Array.isArray(i.items)?i.items:[],d=c=>{a(e.id,{data:{...i,items:c}});};return jsxRuntime.jsxs("div",{className:"block-list border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"List"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(cn,{items:l,onChange:d,compact:true})]})};var su=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"group/block relative border border-[var(--kyro-border)] rounded-2xl p-6 mb-6 transition-all duration-300 bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/20",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-9 h-9 rounded-xl bg-[var(--kyro-primary)]/10 flex items-center justify-center text-[var(--kyro-primary)] transition-transform group-hover/block:scale-110",children:jsxRuntime.jsx(Nc.CodeXml,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxRuntime.jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",i.language||"javascript"]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-1.5 opacity-0 group-hover/block:opacity-100 transition-all translate-x-2 group-hover/block:translate-x-0",children:jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)]/50 p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1.5 hover:bg-[var(--kyro-surface)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsxRuntime.jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(rn,{field:{type:"code",name:"code",label:"Source Code",language:i.language||"javascript"},value:i.code||"",onChange:d=>l("code",d)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 bg-[var(--kyro-surface-accent)]/20 p-4 rounded-xl border border-[var(--kyro-border)]/50",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2 block",children:"Syntax Highlighting"}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("select",{value:i.language||"javascript",onChange:d=>l("language",d.target.value),className:"w-full pl-4 pr-10 py-2.5 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl text-xs font-medium text-[var(--kyro-text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)]/20 focus:border-[var(--kyro-primary)] transition-all appearance-none cursor-pointer",children:[jsxRuntime.jsx("option",{value:"plaintext",children:"Plain Text"}),jsxRuntime.jsx("option",{value:"javascript",children:"JavaScript"}),jsxRuntime.jsx("option",{value:"typescript",children:"TypeScript"}),jsxRuntime.jsx("option",{value:"python",children:"Python"}),jsxRuntime.jsx("option",{value:"json",children:"JSON"}),jsxRuntime.jsx("option",{value:"html",children:"HTML"}),jsxRuntime.jsx("option",{value:"css",children:"CSS"}),jsxRuntime.jsx("option",{value:"sql",children:"SQL"}),jsxRuntime.jsx("option",{value:"rust",children:"Rust"}),jsxRuntime.jsx("option",{value:"markdown",children:"Markdown"})]}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsxRuntime.jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var iu=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(br,{field:{label:"File",name:"file",maxCount:1},value:i.file,onChange:d=>l("file",d)})]})};var dl=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=oa.useState(0),n=jsxRuntime.jsx("div",{className:"flex justify-end gap-1 mb-2"}),s=(p,f)=>{let y=[...e];y[p]={...y[p],title:f},t(y);},i=(p,f)=>{let y=[...e];y[p]={...y[p],content:f},t(y);},l=p=>{let f=e.filter((y,g)=>g!==p);t(f),o===p?a(null):o!==null&&o>p&&a(o-1);},d=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},c="w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",u="w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return r?jsxRuntime.jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-1.5",children:e.map((p,f)=>{let{t:y}=z(),g=o===f;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:f),className:"w-full flex items-center justify-between p-2.5 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${f+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:y("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3.5 h-3.5"})}),g?jsxRuntime.jsx(Nc.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Nc.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:p.title||"",onChange:v=>s(f,v.target.value),onClick:v=>v.stopPropagation(),className:u,placeholder:y("fields.itemTitle",{defaultValue:"Item title..."})}),jsxRuntime.jsx("textarea",{value:p.content||"",onChange:v=>i(f,v.target.value),onClick:v=>v.stopPropagation(),className:`${u} min-h-[60px] resize-none`,placeholder:y("fields.itemContent",{defaultValue:"Item content..."})})]})]},f)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((p,f)=>{let{t:y}=z(),g=o===f;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:f),className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${f+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:y("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})}),g?jsxRuntime.jsx(Nc.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Nc.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:p.title||"",onChange:v=>s(f,v.target.value),className:c,placeholder:y("fields.itemTitle",{defaultValue:"Item title..."})}),jsxRuntime.jsx("textarea",{value:p.content||"",onChange:v=>i(f,v.target.value),className:`${c} min-h-[60px] resize-none`,placeholder:y("fields.itemContent",{defaultValue:"Item content..."})})]})]},f)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var lu=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=Array.isArray(i.items)?i.items:[],d=c=>{a(e.id,{data:{...i,items:c}});};return jsxRuntime.jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(dl,{items:l,onChange:d,compact:true})]})};var du=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=d=>{a(e.id,{data:{...i,content:d}});};return jsxRuntime.jsxs("div",{className:"block-richtext border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Nc.AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(la,{field:{name:"content",label:"Content",type:"richtext"},value:i.content,onChange:l})]})};var cl=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let{t:s}=z(),i=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",l=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return n?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${i} font-bold text-base`,placeholder:s("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:s("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.ctaText",{defaultValue:"CTA text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${i} font-bold text-base`,placeholder:s("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:s("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.ctaText",{defaultValue:"CTA text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};function Es({field:e,value:t,onChange:r,renderField:o}){let a=t||{};return jsxRuntime.jsxs("div",{className:"kyro-form-group border border-[var(--kyro-border)] rounded-[var(--kyro-radius-lg)] p-6 bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-6 border-b border-[var(--kyro-border)] pb-2",children:jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)]",children:e.label||e.name})}),jsxRuntime.jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields.map(n=>o(n,a,r))})]})}var Dg=new Set(["text","number","checkbox","select","radio","color","email","password"]);function Pg(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>Dg.has(r.type))}function pu({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:i,onRemove:l,disabled:d,compact:c,getItemLabel:u}){let{t:p}=z(),{attributes:f,listeners:y,setNodeRef:g,transform:v,transition:h,isDragging:m}=sortable.useSortable({id:e}),w={transform:utilities.CSS.Transform.toString(v),transition:h,zIndex:m?10:1,opacity:m?.8:1};return c?jsxRuntime.jsxs("div",{ref:g,style:w,className:`flex items-start gap-2 px-3 py-1.5 border-b border-[var(--kyro-border)] last:border-b-0 hover:bg-[var(--kyro-sidebar-active)]/5 transition-colors ${m?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...f,...y,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 mt-1",children:jsxRuntime.jsx(Nc.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsxRuntime.jsx("div",{className:`flex-1 min-w-0 ${(n.fields||[]).length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:(n.fields||[]).map(C=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(C,a,i)},C.name))}),jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:l,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-0.5 mt-1.5 flex-shrink-0",title:p("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsxRuntime.jsxs("div",{ref:g,style:w,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${m?"border-[var(--kyro-primary)] shadow-md":""}`,children:[jsxRuntime.jsxs("div",{className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[jsxRuntime.jsx("div",{...f,...y,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",children:jsxRuntime.jsx(Nc.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(r?null:t));},className:"text-xs font-bold tracking-widest text-[var(--kyro-text-muted)] truncate cursor-pointer flex-1 py-1 text-left",children:u(a)||`Item ${t+1}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:C=>{C.stopPropagation(),l();},className:"text-[11px] font-bold text-[var(--kyro-error)] opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-30 hover:bg-[var(--kyro-danger-bg)] rounded px-1.5 py-0.5",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(r?null:t),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",children:r?jsxRuntime.jsx(Nc.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Nc.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsxRuntime.jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:(n.fields||[]).map(C=>s(C,a,i))})]})}function Ms({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=e.fields||[],i=s[0],l=i?.name||"user",d=i?.type==="relationship",[c,u]=oa__default.default.useState(0);oa__default.default.useEffect(()=>{let h=false,m=n.filter(w=>typeof w!="object"||w===null?(h=true,false):true).map(w=>!w.id&&!w._key?(h=true,{...w,id:Math.random().toString(36).substr(2,9)}):w);h&&r(m);},[t,r]);function p(h){for(let m of ["label","title","name"]){let w=h[m];if(w&&typeof w=="string")return w}for(let m of s){if(m.type==="text"||m.type==="textarea"){let w=h[m.name];if(w&&typeof w=="string")return w}if(m.type==="group"&&m.fields){for(let w of m.fields)if(w.type==="text"||w.type==="textarea"){let E=h[m.name]?.[w.name];if(E&&typeof E=="string")return E}}}return ""}let f=Pg(e),y=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),g=h=>{let{active:m,over:w}=h;if(!w||m.id===w.id)return;let C=n.findIndex(D=>(D.id||D._key)===m.id),E=n.findIndex(D=>(D.id||D._key)===w.id);if(C!==-1&&E!==-1){let D=[...n],[k]=D.splice(C,1);D.splice(E,0,k),r(D);}},v=oa__default.default.useMemo(()=>n.map(h=>h?.id||h?._key||""),[n]);return d?jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(nn,{field:{name:l,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(h=>h[l]).filter(Boolean),onChange:h=>{let m=(h||[]).map(w=>({[l]:w,id:Math.random().toString(36).substr(2,9)}));r(m);},disabled:a})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(core.DndContext,{sensors:y,collisionDetection:core.closestCenter,onDragEnd:g,children:f?jsxRuntime.jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md overflow-hidden",children:[jsxRuntime.jsx(sortable.SortableContext,{items:v,strategy:sortable.verticalListSortingStrategy,children:n.map((h,m)=>jsxRuntime.jsx(pu,{id:h.id||h._key||`idx-${m}`,index:m,isOpen:false,setOpenIndex:()=>{},item:h,field:e,renderField:o,onChangeItem:w=>{let C=[...n];C[m]=w,r(C);},onRemove:()=>r(n.filter((w,C)=>C!==m)),disabled:a,compact:true,getItemLabel:p},h.id||h._key||m))}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-2 border-2 border-dashed border-[var(--kyro-border)] rounded-none text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>r([...n,{id:Math.random().toString(36).substr(2,9)}]),children:"+ Add Item"})]}):jsxRuntime.jsxs("div",{className:"kyro-form-array border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md p-3 space-y-4",children:[jsxRuntime.jsx(sortable.SortableContext,{items:v,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((h,m)=>{let w=c===m;return jsxRuntime.jsx(pu,{id:h.id||h._key||`idx-${m}`,index:m,isOpen:w,setOpenIndex:u,item:h,field:e,renderField:o,onChangeItem:C=>{let E=[...n];E[m]=C,r(E);},onRemove:()=>r(n.filter((C,E)=>E!==m)),disabled:a,compact:false,getItemLabel:p},h.id||h._key||m)})})}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-3 border-2 border-dashed border-[var(--kyro-border)] rounded-lg text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>{let h=Math.random().toString(36).substr(2,9);r([...n,{id:h}]),u(n.length);},children:"+ Add Item"})]})})]})}var mu="other";function fu(){return mu}function Bs(e){mu=e;}var Oo=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{Bs("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(ma,{field:e,value:t,onChange:d,error:o,disabled:a});case "icon":return jsxRuntime.jsx(vs,{field:e,value:t,onChange:d,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(ma,{field:{...e,variant:"textarea"},value:t,onChange:d,error:o,disabled:a});case "password":return jsxRuntime.jsx(ma,{field:{...e,variant:"password"},value:t,onChange:d,error:o,disabled:a});case "secret":return jsxRuntime.jsx(ks,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Cs,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(Ss,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx(Rs,{field:e,value:t,onChange:d,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l});case "date":return jsxRuntime.jsx(As,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(la,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(Ui,{field:e,value:t,onChange:d,disabled:a,error:o});case "code":return jsxRuntime.jsx(rn,{field:e,value:t,onChange:d,disabled:a,error:o});case "image":case "upload":return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx(br,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx(nn,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx(cn,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(Ms,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,u,p)=>{let f=u[c.name];return jsxRuntime.jsx(Oo,{field:c,value:f,onChange:y=>{p({...u,[c.name]:y});},disabled:a,error:o},c.name)}});case "blocks":return jsxRuntime.jsx(ml,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsxRuntime.jsx(Es,{field:e,value:t,onChange:r,renderField:(c,u,p)=>{let f=u[c.name];return jsxRuntime.jsx(Oo,{field:c,value:f,onChange:y=>{p({...u,[c.name]:y});},disabled:a,error:o,collectionSlug:i,globalSlug:l},c.name)}});case "color":return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("input",{type:"color",value:t||"#000000",onChange:c=>r(c.target.value),disabled:a,className:"h-10 w-14 p-1 cursor-pointer bg-[var(--kyro-input-bg)] border border-[var(--kyro-input-border)] rounded-lg"}),jsxRuntime.jsx("input",{type:"text",className:"kyro-form-input font-mono ",value:t||"",onChange:c=>r(c.target.value),disabled:a,placeholder:"#000000"})]})});default:return jsxRuntime.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg text-amber-800 text-xs italic",children:['Field type "',e.type,'" is not yet supported in this renderer.']})}};var ha=({block:e,blockSchema:t,onClose:r})=>{let o=We(e.id),{updateBlock:a}=ze(),n=o?.data||e.data||{},s=o?.children||e.children||[],i=(u,p)=>{a(e.id,{data:{...n,[u]:p}});},l=u=>{a(e.id,{children:u});},d=()=>t&&Array.isArray(t.fields)?jsxRuntime.jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(u=>{if(u.admin?.condition){if(typeof u.admin.condition=="function")try{let f={values:n,...n};if(!u.admin.condition(f,f))return null}catch(f){console.warn(`Condition error for field ${u.name}:`,f);}else if(typeof u.admin.condition=="object")try{let f=u.admin.condition,y=f.field,g=n[y],v=!0;if("equals"in f?v=g===f.equals:"notEquals"in f?v=g!==f.notEquals:"in"in f&&Array.isArray(f.in)&&(v=f.in.includes(g)),!v)return null}catch(f){console.warn(`Declarative condition error for field ${u.name}:`,f);}}let p=n[u.name];return jsxRuntime.jsx("div",{className:"kyro-block-field-row border-b border-[var(--kyro-border)]/30 pb-3 last:border-b-0 last:pb-0",children:jsxRuntime.jsx(Oo,{field:u,value:p,onChange:f=>i(u.name,f)})},u.name)})}):jsxRuntime.jsxs("div",{className:"text-center py-8 text-[var(--kyro-text-muted)] text-sm italic",children:['No schema defined for block type "',e.type,'"']}),c=je[e.type]||je.default;return jsxRuntime.jsxs(hr,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:c.border,children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[d(),s.length>0&&jsxRuntime.jsxs("div",{className:"pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",s.length,")"]}),jsxRuntime.jsx(uo,{blockId:e.id,children:s,onUpdateChildren:l})]})]}),jsxRuntime.jsx("div",{className:"mt-6 pt-4 border-t border-[var(--kyro-border)]",children:jsxRuntime.jsx("button",{type:"button",onClick:r,className:"w-full py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-lg font-medium hover:opacity-90 transition-opacity",children:"Done"})})]})};var Rg=6,uo=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Rg})=>{let[n,s]=oa.useState(false),[i,l]=oa.useState(new Set),[d,c]=oa.useState(null),[u,p]=oa.useState(null),f=oa.useContext(Eo);if(!f)throw new Error("ChildBlocksTree must be used within a BlocksContext");let y=zustand.useStore(f,b=>b.dynamicCategories),g=zustand.useStore(f,b=>b.allowedBlocks),v=o<a,h=16,m=b=>{let x=ga(b);r([...t,x]),c(x.id);},w=b=>{let x=t.filter(N=>N.id!==b);r(x);},E=(b,x)=>{let N=t.map(O=>O.id===b?{...O,children:x}:O);r(N);},D=b=>{l(x=>{let N=new Set(x);return N.has(b)?N.delete(b):N.add(b),N});},k=b=>{let x=b.children&&b.children.length>0,N=i.has(b.id);fl(b.type);let M=x,I=d===b.id,P=g.find(R=>R.slug===b.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${I?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${v?"cursor-pointer":""}`,style:{marginLeft:o*h},onClick:()=>{v&&c(I?null:b.id);},children:[M?jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),D(b.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:N?jsxRuntime.jsx(Nc.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Jt[b.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Jt[b.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[mn(b),b.data?.text?` - ${b.data.text.slice(0,30)}`:"",b.data?.heading?` - ${b.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),x&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[b.children.length," nested"]}),u===b.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{w(b.id),p(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),p(b.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Nc.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),I&&jsxRuntime.jsx(ha,{block:b,onClose:()=>c(null)}),x&&N&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(vu,{parentId:b.id,children:b.children,onUpdateChildren:R=>E(b.id,R),depth:o+1,maxDepth:a})})]},b.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),v&&jsxRuntime.jsxs("div",{style:{marginLeft:o*h},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(dn,{open:n,onClose:()=>s(false),onSelect:m,children:y.map(b=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:b.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:b.blocks.map(x=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{m(x.slug),s(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Jt[x.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:x.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:x.admin?.description||""})]})]},x.slug))})]},b.title))})]}),t.length===0&&v&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*h},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*h},children:["Maximum nesting level (",a,") reached"]})]})},vu=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=oa.useState(false),[i,l]=oa.useState(new Set),[d,c]=oa.useState(null),[u,p]=oa.useState(null),f=oa.useContext(Eo);if(!f)throw new Error("NestedChildBlocks must be used within a BlocksContext");let y=zustand.useStore(f,b=>b.dynamicCategories),g=zustand.useStore(f,b=>b.allowedBlocks),v=o<a,h=16,m=b=>{let x=ga(b);r([...t,x]),c(x.id);},w=b=>{let x=t.filter(N=>N.id!==b);r(x);},E=(b,x)=>{let N=t.map(O=>O.id===b?{...O,children:x}:O);r(N);},D=b=>{l(x=>{let N=new Set(x);return N.has(b)?N.delete(b):N.add(b),N});},k=b=>{let x=b.children&&b.children.length>0,N=i.has(b.id);fl(b.type);let M=x,I=d===b.id,P=g.find(R=>R.slug===b.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${I?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${v?"cursor-pointer":""}`,style:{marginLeft:o*h},onClick:()=>{v&&c(I?null:b.id);},children:[M?jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),D(b.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:N?jsxRuntime.jsx(Nc.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Jt[b.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Jt[b.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[mn(b),b.data?.text?` - ${b.data.text.slice(0,30)}`:"",b.data?.heading?` - ${b.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),x&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[b.children.length," nested"]}),u===b.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{w(b.id),p(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),p(b.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Nc.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),I&&jsxRuntime.jsx(ha,{block:b,onClose:()=>c(null)}),x&&N&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(vu,{parentId:b.id,children:b.children,onUpdateChildren:R=>E(b.id,R),depth:o+1,maxDepth:a})})]},b.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),v&&jsxRuntime.jsxs("div",{style:{marginLeft:o*h},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(dn,{open:n,onClose:()=>s(false),onSelect:m,children:y.map(b=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:b.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:b.blocks.map(x=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{m(x.slug),s(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Jt[x.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:x.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:x.admin?.description||""})]})]},x.slug))})]},b.title))})]}),t.length===0&&v&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*h},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*h},children:["Maximum nesting level (",a,") reached"]})]})};var bu=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=o?.children??e.children??[],d=(c,u)=>{a(e.id,{data:{...i,[c]:u}});};return jsxRuntime.jsxs("div",{className:"block-hero border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Hero Section"})}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(cl,{heading:i.title||"",subheading:i.subtitle||"",ctaText:i.ctaText||"",ctaUrl:i.ctaUrl||"",onChange:d,compact:true}),jsxRuntime.jsx(br,{field:{label:"Background",name:"bgImage",maxCount:1},value:i.bgImage,onChange:c=>d("bgImage",c)}),jsxRuntime.jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsxRuntime.jsx(uo,{blockId:e.id,children:l,onUpdateChildren:c=>a(e.id,{children:c})})]})]})]})};var yl=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:s=false})=>{let{t:i}=z(),l=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",d=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:c=>n("title",c.target.value),className:`${l} font-bold text-base`,placeholder:i("fields.cardTitle",{defaultValue:"Card title..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:c=>n("description",c.target.value),className:d,placeholder:i("fields.cardDescription",{defaultValue:"Card description..."})}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:c=>n("icon",c.target.value),className:l,placeholder:i("fields.iconEmojiOrName",{defaultValue:"Icon (emoji or name)..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:c=>n("linkText",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:i("fields.linkText",{defaultValue:"Link text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:c=>n("link",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var ku=({block:e,index:t})=>{let r=We(e.id),{updateBlock:o}=ze(),a=r?.data||e.data||{},n=(s,i)=>{o(e.id,{data:{...a,[s]:i}});};return jsxRuntime.jsx(Bo,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(yl,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var wu=({block:e,index:t})=>{let {t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze();o?.data??e.data??{};let l=o?.children??e.children??[];return jsxRuntime.jsxs("div",{className:"block-array border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Repeater"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(uo,{blockId:e.id,children:l,onUpdateChildren:d=>a(e.id,{children:d})})})]})};var yn=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let{t:i}=z(),[l,d]=oa.useState(false),[c,u]=oa.useState(""),[p,f]=oa.useState([]),[y,g]=oa.useState(false),[v,h]=oa.useState([]),[m,w]=oa.useState(true);oa.useEffect(()=>{Be("/api/collections").then(M=>{h((M.collections||[]).map(I=>I.slug||I.name||I)),w(false);}).catch(()=>w(false));},[]);let C=(M="")=>{g(true);let I=`/api/${e}?${An(M,[a],20)}`;Be(I).then(P=>{f(P.docs||[]),g(false);}).catch(()=>g(false));};oa.useEffect(()=>{l&&C(c);},[l,c,e,a]);let E=M=>M?.[a]||M?.title||M?.name||M?.label||M?.filename||M?.slug||M?.id||"Untitled",D=t?r:o?[o]:[],k=M=>{t?D.includes(M.id)?n("selectedIds",D.filter(I=>I!==M.id)):n("selectedIds",[...D,M.id]):(n("selectedId",M.id),n("selectedIds",[M.id]),d(false));},b=M=>D.includes(M),x=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",N=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",O=e&&typeof e=="string"&&e.length>0;return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-4",children:[jsxRuntime.jsxs("div",{className:s?"flex items-center gap-2":"space-y-3",children:[!O&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:m?jsxRuntime.jsx("div",{className:N+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:M=>n("relationTo",M.target.value),className:N,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),v.map(M=>jsxRuntime.jsx("option",{value:M,children:M},M))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:M=>n("hasMany",M.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsxRuntime.jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Nc.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:c,onChange:M=>{u(M.target.value),d(true);},onFocus:()=>d(true),onBlur:()=>setTimeout(()=>d(false),200),placeholder:`Search ${e}...`,className:`${x} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:y&&jsxRuntime.jsx(Nc.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsxRuntime.jsx("div",{className:"absolute z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-48 overflow-auto",children:y?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):p.length===0?jsxRuntime.jsx(Fs,{title:i("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsxRuntime.jsx("div",{className:"py-1",children:p.map(M=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:I=>I.preventDefault(),onClick:()=>k(M),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${b(M.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:E(M)}),b(M.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},M.id))})})]}),D.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:D.map(M=>{let I=p.find(P=>P.id===M)||{id:M};return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[E(I),jsxRuntime.jsx("button",{type:"button",onMouseDown:P=>P.preventDefault(),onClick:()=>{t?n("selectedIds",D.filter(P=>P!==M)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]},M)})})]})};var Cu=({block:e,index:t})=>{let{t:r}=z(),o=We(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",i.relationTo||"pages"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(yn,{relationTo:i.relationTo||"pages",hasMany:i.hasMany||false,selectedIds:Array.isArray(i.selectedIds)?i.selectedIds:[],selectedId:i.selectedId,labelField:i.labelField||"title",onChange:l,compact:true})]})};var Ig={heading:Zc,paragraph:tu,image:ru,video:au,list:nu,code:su,file:iu,accordion:lu,richtext:du,hero:bu,card:ku,array:wu,relationship:Cu},je={featureSplit:{text:"text-indigo-500",border:"border-indigo-500",borderLeft:"border-l-indigo-500"},featureGrid:{text:"text-blue-500",border:"border-blue-500",borderLeft:"border-l-blue-500"},ctaBanner:{text:"text-amber-500",border:"border-amber-500",borderLeft:"border-l-amber-500"},testimonials:{text:"text-emerald-500",border:"border-emerald-500",borderLeft:"border-l-emerald-500"},faq:{text:"text-orange-500",border:"border-orange-500",borderLeft:"border-l-orange-500"},stats:{text:"text-rose-500",border:"border-rose-500",borderLeft:"border-l-rose-500"},logoCloud:{text:"text-cyan-500",border:"border-cyan-500",borderLeft:"border-l-cyan-500"},pricing:{text:"text-green-500",border:"border-green-500",borderLeft:"border-l-green-500"},team:{text:"text-violet-500",border:"border-violet-500",borderLeft:"border-l-violet-500"},recentFeed:{text:"text-sky-500",border:"border-sky-500",borderLeft:"border-l-sky-500"},processSteps:{text:"text-fuchsia-500",border:"border-fuchsia-500",borderLeft:"border-l-fuchsia-500"},formEmbed:{text:"text-pink-500",border:"border-pink-500",borderLeft:"border-l-pink-500"},videoShowcase:{text:"text-red-500",border:"border-red-500",borderLeft:"border-l-red-500"},hero:{text:"text-yellow-500",border:"border-yellow-500",borderLeft:"border-l-yellow-500"},card:{text:"text-teal-500",border:"border-teal-500",borderLeft:"border-l-teal-500"},default:{text:"text-zinc-400",border:"border-zinc-400",borderLeft:"border-l-zinc-400"}},Jt={heading:jsxRuntime.jsx(Nc.Heading1,{className:`w-4 h-4 ${je.default.text}`}),paragraph:jsxRuntime.jsx(Nc.AlignLeft,{className:`w-4 h-4 ${je.default.text}`}),image:jsxRuntime.jsx(Nc.Image,{className:`w-4 h-4 ${je.default.text}`}),video:jsxRuntime.jsx(Nc.Video,{className:`w-4 h-4 ${je.default.text}`}),list:jsxRuntime.jsx(Nc.List,{className:`w-4 h-4 ${je.default.text}`}),code:jsxRuntime.jsx(Nc.Code,{className:`w-4 h-4 ${je.default.text}`}),file:jsxRuntime.jsx(Nc.File,{className:`w-4 h-4 ${je.default.text}`}),accordion:jsxRuntime.jsx(Nc.ChevronDown,{className:`w-4 h-4 ${je.default.text}`}),richtext:jsxRuntime.jsx(Nc.AlignLeft,{className:`w-4 h-4 ${je.default.text}`}),hero:jsxRuntime.jsx(Nc.Star,{className:`w-4 h-4 ${je.hero.text}`}),card:jsxRuntime.jsx(Nc.Box,{className:`w-4 h-4 ${je.card.text}`}),array:jsxRuntime.jsx(Nc.ListOrdered,{className:`w-4 h-4 ${je.default.text}`}),relationship:jsxRuntime.jsx(Nc.Link2,{className:`w-4 h-4 ${je.default.text}`}),featureSplit:jsxRuntime.jsx(Nc.Columns3,{className:`w-4 h-4 ${je.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(Nc.Blocks,{className:`w-4 h-4 ${je.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(Nc.Sparkles,{className:`w-4 h-4 ${je.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(Nc.Users,{className:`w-4 h-4 ${je.testimonials.text}`}),faq:jsxRuntime.jsx(Nc.CircleHelp,{className:`w-4 h-4 ${je.faq.text}`}),stats:jsxRuntime.jsx(Nc.Activity,{className:`w-4 h-4 ${je.stats.text}`}),logoCloud:jsxRuntime.jsx(Nc.Image,{className:`w-4 h-4 ${je.logoCloud.text}`}),pricing:jsxRuntime.jsx(Nc.Tag,{className:`w-4 h-4 ${je.pricing.text}`}),team:jsxRuntime.jsx(Nc.Users,{className:`w-4 h-4 ${je.team.text}`}),recentFeed:jsxRuntime.jsx(Nc.Database,{className:`w-4 h-4 ${je.recentFeed.text}`}),processSteps:jsxRuntime.jsx(Nc.Clock,{className:`w-4 h-4 ${je.processSteps.text}`}),formEmbed:jsxRuntime.jsx(Nc.Mail,{className:`w-4 h-4 ${je.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(Nc.Video,{className:`w-4 h-4 ${je.videoShowcase.text}`})};function fl(e){return Ig[e]||null}function gl(e){return {paragraph:"Paragraph",heading:"Heading",image:"Image",video:"Video",list:"List",code:"Code",file:"File",accordion:"Accordion",array:"Repeater",relationship:"Relationship",richtext:"Rich Text",hero:"Hero Section",card:"Card Block",featureSplit:"Feature Split",featureGrid:"Feature Grid",ctaBanner:"CTA Banner",testimonials:"Testimonials Stack",faq:"FAQ Section",stats:"Stats & Metrics",logoCloud:"Logo Cloud",pricing:"Pricing Grid / Plan",team:"Team Profiles Showcase",recentFeed:"Dynamic Content Feed",processSteps:"Process Timeline / Steps",formEmbed:"Lead Intake Form",videoShowcase:"Cinematic Video Showcase",headingElement:"Heading",textElement:"Text",imageElement:"Image",richtextElement:"Rich Text",buttonElement:"Button",videoElement:"Video",listElement:"List"}[e]||e}function mn(e){let t=e.name;return t&&t.trim()?t.trim():gl(e.type)}function Gg(e,t){if(t?.fields){for(let r of t.fields)if(r.type==="text"||r.type==="textarea"){let o=e[r.name];if(o&&typeof o=="string")return o}}return e.title||e.text||e.name||e.label||""}var Wg=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{t:i}=z(),{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:p,isDragging:f}=sortable.useSortable({id:e.id}),{removeBlock:y,updateBlock:g}=ze(),v=o===e.id,[h,m]=oa.useState(false),[w,C]=oa.useState(false),[E,D]=oa.useState(e.name||""),k=oa.useRef(null),[b,x]=oa.useState(false);oa.useEffect(()=>{w&&k.current&&(k.current.focus(),k.current.select());},[w]);let N=oa.useCallback(()=>{C(false);let R=E.trim();R!==(e.name||"").trim()&&g(e.id,{name:R||""});},[E,e.name,e.id,g]),O={transform:utilities.CSS.Transform.toString(u),transition:p,zIndex:f?10:1,opacity:f?.8:1},M=mn(e),I=e.data||{},P=Gg(I,r);return s?jsxRuntime.jsxs("div",{ref:c,style:O,className:"relative group w-full",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-2 pl-7 pr-2 py-2 w-full bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-sm ${v?`${(je[e.type]||je.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 p-0.5 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] opacity-0 group-hover:opacity-100 transition-opacity hover:bg-[var(--kyro-surface-accent)] rounded touch-none",...l,...d,onClick:R=>R.stopPropagation(),children:jsxRuntime.jsx(Nc.GripVertical,{className:"w-2.5 h-2.5"})}),Jt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:Jt[e.type]}),w?jsxRuntime.jsx("input",{ref:k,value:E,onChange:R=>D(R.target.value),onBlur:N,onKeyDown:R=>{R.key==="Enter"&&N(),R.key==="Escape"&&(D(e.name||""),C(false));},onClick:R=>R.stopPropagation(),className:"flex-1 min-w-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-1.5 py-0.5 text-[10px] font-medium text-[var(--kyro-text-primary)] outline-none"}):jsxRuntime.jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] flex-1 min-w-0 truncate transition-colors text-left",children:M}),h?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{y(e.id),m(false);},className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),D(e.name||""),C(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.rename",{defaultValue:"Rename"}),children:jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.duplicateInPlace",{defaultValue:"Duplicate in place"}),children:jsxRuntime.jsx(Nc.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),m(true);},className:"p-0.5 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:i("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3 h-3"})})]})]}),v&&jsxRuntime.jsx(ha,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:c,style:O,className:"relative group mb-2",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-3 p-3 bg-[var(--kyro-bg-secondary)] rounded-lg border transition-colors cursor-pointer ${v?`${(je[e.type]||je.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 touch-none",...l,...d,onClick:R=>R.stopPropagation(),children:jsxRuntime.jsx(Nc.GripVertical,{className:"w-4 h-4"})}),Jt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:Jt[e.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[w?jsxRuntime.jsx("input",{ref:k,value:E,onChange:R=>D(R.target.value),onBlur:N,onKeyDown:R=>{R.key==="Enter"&&N(),R.key==="Escape"&&(D(e.name||""),C(false));},onClick:R=>R.stopPropagation(),placeholder:gl(e.type),className:"w-full max-w-[150px] sm:max-w-[250px] md:max-w-[400px] bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-2 py-0.5 text-xs font-semibold text-[var(--kyro-text-primary)] outline-none"}):jsxRuntime.jsxs("div",{className:"text-xs font-semibold text-[var(--kyro-text-secondary)] truncate transition-colors",children:[M,P&&typeof P=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",P.length>40?`${P.slice(0,40)}...`:P]})]}),!!r?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:r.admin.description})]}),!!e.children&&Array.isArray(e.children)&&e.children.length>0&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[e.children.length," nested"]}),h?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{y(e.id),m(false);},className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),D(e.name||""),C(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.renameBlock",{defaultValue:"Rename Block"}),children:jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.duplicateBlock",{defaultValue:"Duplicate Block"}),children:jsxRuntime.jsx(Nc.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),m(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:i("tooltips.removeBlock",{defaultValue:"Remove Block"}),children:jsxRuntime.jsx(Nc.X,{className:"w-3.5 h-3.5"})})]})]}),v&&jsxRuntime.jsx(ha,{block:e,blockSchema:r,onClose:()=>a(null)})]})},qg=oa__default.default.memo(Wg),ml=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:i})=>{let[l,d]=oa.useState(false),[c,u]=oa.useState(false),p=oa.useRef(null),f=e.admin?.pickerMode||"drawer",y=e.blocks||[],g=y.reduce((V,q)=>{let ae=q.admin?.group||"Custom Blocks";return V[ae]||(V[ae]=[]),V[ae].push(q),V},{}),v=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],h=Object.entries(g).sort(([V],[q])=>{let ae=v.indexOf(V),K=v.indexOf(q);return ae!==-1&&K!==-1?ae-K:ae!==-1?-1:K!==-1?1:V.localeCompare(q)}).map(([V,q])=>({title:V,blocks:q})),m=oa.useRef(null);m.current||(m.current=Jc(y,h));let w=m.current,C=zustand.useStore(w,V=>V.blocks),[E,D]=oa.useState(null),[k,b]=oa.useState(null),x=oa.useRef(C.length),N=oa.useRef(new Set(C.map(V=>V.id))),O=oa.useRef(false);oa.useEffect(()=>{if(O.current&&C.length>x.current){let V=C.find(q=>q.id&&!N.current.has(q.id));V&&b(V.id);}x.current=C.length,N.current=new Set(C.map(V=>V.id));},[C]),oa.useEffect(()=>(o&&w.getState().setOnBlocksChange(o),()=>{w.getState().setOnBlocksChange(()=>{});}),[o,w]);let M=oa.useRef(null);oa.useEffect(()=>{let V=Array.isArray(t)?t:[],q=M.current||[];if(Io(V,q))V.length===0&&!O.current&&(O.current=true,M.current=[]);else {let ae=[...V];x.current=ae.length,N.current=new Set(ae.map(K=>K.id)),w.getState().setBlocks(ae),M.current=ae,O.current=true;}},[t,e.name,w]);let I=oa.useRef(r);I.current=r,oa.useEffect(()=>{if(!I.current)return;let V=M.current;V&&(Io(C,V)||(M.current=[...C],I.current(C)));},[C]);let R=oa.useCallback(V=>{w.getState().addBlock(V);},[w]),fe=oa.useCallback(V=>{if(!(e.blocks||[]).some(he=>he.slug===V.type)){alert(`The block type "${V.type}" is not allowed in this collection.`);return}let K=Math.random().toString(36).substring(2,11),Re={...V.blockProps||{},id:K,type:V.type};w.getState().setBlocks([...C,Re]),d(false);},[e.blocks,C,w]),L=oa.useCallback(V=>{let q=C.findIndex(Ae=>Ae.id===V);if(q===-1)return;let ae=C[q],K=Ae=>{let T=Math.random().toString(36).substr(2,9);return {...Ae,id:T,children:Ae.children?Ae.children.map(_=>K(_)):Ae.children,data:Ae.data?JSON.parse(JSON.stringify(Ae.data)):Ae.data}},Re=K(ae),he=[...C];he.splice(q+1,0,Re),w.getState().setBlocks(he);},[C,w]),re=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),ne=V=>{D(V.active);},ee=V=>{let{active:q,over:ae}=V;if(D(null),!!ae){if(q.id.toString().startsWith("drawer-")){let K=q.id.toString().replace("drawer-","");if(ae.id.toString().startsWith("container-")){let Re=ae.id.toString().replace("container-",""),he=C.find(Ae=>Ae.id===Re);if(he){let Ae=ga(K);w.getState().updateBlock(Re,{children:[...he.children||[],Ae]});}}else {let Re=C.findIndex(he=>he.id===ae.id);Re!==-1?w.getState().addBlock(K,Re):R(K);}return}if(q.id!==ae.id){let K=C.findIndex(he=>he.id===q.id),Re=C.findIndex(he=>he.id===ae.id);if(K!==-1&&Re!==-1){let he=[...C],[Ae]=he.splice(K,1);he.splice(Re,0,Ae),w.getState().setBlocks(he);}}}},H=E?h.flatMap(V=>V.blocks).find(V=>`drawer-${V.type}`===E.id)||C.find(V=>V.id===E.id):null;H?"label"in H?H.label:H.type:"Block";return oa.useEffect(()=>{if(!c)return;let V=q=>{p.current&&!p.current.contains(q.target)&&u(false);};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[c]),jsxRuntime.jsx(Eo.Provider,{value:m.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",tabIndex:0,style:{outline:"none"},children:[jsxRuntime.jsxs(core.DndContext,{sensors:re,collisionDetection:core.closestCenter,onDragStart:ne,onDragEnd:ee,children:[jsxRuntime.jsxs("div",{className:f==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:`kyro-form-label ${f==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),f==="dropdown"?jsxRuntime.jsxs("div",{ref:p,className:"relative w-full",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>u(!c),disabled:n,className:"flex w-full items-center justify-between px-3 py-2 text-sm text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)] rounded-md transition-colors disabled:opacity-50",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Select an element to add..."})]}),jsxRuntime.jsx(Nc.ChevronDown,{className:`w-4 h-4 transition-transform ${c?"rotate-180 text-[var(--kyro-primary)]":"opacity-50"}`})]}),c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full mt-1 w-full bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:h.map(V=>jsxRuntime.jsxs("div",{children:[h.length>1&&jsxRuntime.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:V.title}),V.blocks.map(q=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{R(q.slug),u(false);},className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50 transition-colors text-left",children:[jsxRuntime.jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center text-[var(--kyro-text-muted)]",children:Jt[q.slug]||jsxRuntime.jsx(Nc.Box,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"text-xs font-semibold truncate",children:q.label}),q.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:q.admin.description})]})]},q.slug))]},V.title))})]}):jsxRuntime.jsxs("button",{type:"button",onClick:()=>d(true),disabled:n,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)]/30 rounded-md transition-colors disabled:opacity-50 font-semibold",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx(dn,{open:l,onClose:()=>d(false),onSelect:R,onPasteBlock:fe,children:jsxRuntime.jsx("div",{className:"space-y-4",children:h.map(V=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:V.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:V.blocks.map(q=>jsxRuntime.jsx(Xc,{block:{type:q.slug,label:q.label,description:q.admin?.description||"",icon:null},onSelect:R,children:jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:Jt[q.slug]||jsxRuntime.jsx(Nc.Box,{className:"w-4 h-4"})})})},q.slug))})]},V.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:C.map(V=>V.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:f==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[C.map((V,q)=>{let ae=e.blocks?.find(K=>K.slug===V.type);return jsxRuntime.jsx(qg,{block:V,index:q,blockSchema:ae,editingBlockId:k,setEditingBlockId:b,onDuplicate:L,compact:f==="dropdown"},V.id||q)}),C.length===0&&jsxRuntime.jsx("div",{className:f==="dropdown"?"text-xs text-[var(--kyro-text-muted)] italic py-1":"text-center py-12 text-[var(--kyro-text-muted)] border-2 border-dashed border-[var(--kyro-border)] rounded-lg",children:f==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsxRuntime.jsx(core.DragOverlay,{children:E&&H&&jsxRuntime.jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:H.label||H.type||"Block"})})]}),a&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:a})]})})};function Au(){let e=oa.useRef([]),t=oa.useRef(false);return {queueTask:oa.useCallback((o,a)=>{e.current.push(o);async function n(){if(!t.current&&!(typeof a?.beforeProcess=="function"&&a.beforeProcess()===false))for(;e.current.length>0;){let s=e.current.pop();e.current=[],t.current=true;try{await s();}catch(i){console.error("Error in queued function:",i);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function Tu({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:i}){let l=xe(),{confirm:d}=gt(),{formData:c,setFormData:u,setField:p,lastSavedData:f,setLastSavedData:y,setHasUnsavedChanges:g,isSlugLocked:v,loadDocument:h,setIsAutoSaving:m,setAutoSaveStatus:w,setVersions:C,setLoadingVersions:E,sidebarCollapsed:D,setSidebarCollapsed:k,getDraftCache:b,setDraftCache:x,clearDraftCache:N,resetForm:O}=l,M=!!e.versions,I=o||t?.id||a||r,P=oa.useRef(false);!o&&I&&c&&Object.keys(c).length>0&&c.id!==I&&(P.current=true),oa.useEffect(()=>{P.current&&(P.current=false,O());},[O]);let R=oa.useRef(null),fe=oa.useRef(null),L=oa.useRef(null),re=oa.useRef(typeof navigator<"u"?navigator.onLine:true),ne=oa.useRef(0),ee=oa.useRef(false),H=oa.useRef(null),pe=oa.useRef(""),be=oa.useRef(""),{queueTask:V}=Au(),q=oa.useCallback(X=>o?`global:${o}`:r&&X?`${r}:${X}`:null,[r,o]),ae=oa.useCallback((X,j,W)=>{x(X,{data:j,baseUpdatedAt:f.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:W?.lastSyncedAt??null});},[f.updatedAt,x]),K=oa.useCallback(async()=>{let X=o?Xe(`/api/globals/${o}/versions`):r&&c.id?Xe(`/api/${r}/${c.id}/versions`):null;if(X){E(true);try{let W=await(await ct(X)).json();C(W.docs||[]);}catch(j){console.error("Failed to fetch versions:",j);}finally{E(false);}}},[c.id,r,o,E,C]),Re=oa.useCallback(()=>{let X=xe.getState(),j=X.formData;if(ee.current||!r||!j.id||!X.hasDirtyFields())return;let W=q(j.id);W&&ae(W,j);},[r,q,ae]),he=oa.useCallback(async X=>{let j=xe.getState(),W=j.formData,de=j.lastSavedData;if(ee.current||!o&&(!r||!W.id)||!j.hasDirtyFields())return;let Ie=q(W.id);if(Ie&&ae(Ie,W),!re.current){w("offline");return}m(true),w("saving"),j.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let Ue=o?Xe(`/api/globals/${o}?autosave=true`):Xe(`/api/${r}/${W.id}?autosave=true`),bt=await ct(Ue,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:X?.keepalive,body:JSON.stringify({...qt(W),baseUpdatedAt:de.updatedAt??null})});if(bt.ok)ne.current=Date.now(),j.setRetryCount(0),j.setLastSavedAt(Date.now()),L.current&&clearTimeout(L.current),Ie&&x(Ie,{data:W,baseUpdatedAt:de.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await bt.clone().json()).data?.updatedAt||new Date().toISOString()}),w("success"),setTimeout(()=>{xe.getState().autoSaveStatus==="success"&&w("idle");},2e3);else if(bt.status===409)w("conflict");else throw new Error(`Draft auto-save failed with status ${bt.status}`)}catch(Ue){console.error("Auto-save failed:",Ue);let bt=xe.getState(),$=bt.retryCount;if($<5){bt.setRetryCount($+1),w("retrying");let Y=Math.min(1e3*Math.pow(2,$),6e4);L.current&&clearTimeout(L.current),L.current=setTimeout(()=>Ae(X),Y);}else w("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),m(false),xe.getState().setBackgroundProcessing(false);}},[r,q,o,ae,w,x,m,M]),Ae=oa.useCallback(X=>{V(()=>he(X),{beforeProcess:()=>true,afterProcess:()=>{}});},[he,V]),T=oa.useCallback(async(X,j=true)=>{let W=xe.getState(),de=X||W.formData,Ie=o?Xe(`/api/globals/${o}`):Xe(`/api/${r}/${de.id}`),Ue=await ct(Ie,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(j)},body:JSON.stringify({...qt(de),baseUpdatedAt:W.lastSavedData.updatedAt??null})});return Ue.status===409&&w("conflict"),Ue},[r,o,w]),_=oa.useCallback(async(X=true)=>{let j=xe.getState(),W=j.formData,de=o?Xe(`/api/globals/${o}`):Xe(`/api/${r}/${W.id}`),Ie=await ct(de,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(X)},body:JSON.stringify({...qt(W)})});if(Ie.ok){let bt=(await Ie.json()).data||W;j.loadDocument(bt,bt),w("success"),setTimeout(()=>{xe.getState().autoSaveStatus==="success"&&w("idle");},2e3);}return Ie},[r,o,w]);oa.useEffect(()=>{let X=()=>{k(!D);};return window.addEventListener("toggle-sidebar",X),()=>window.removeEventListener("toggle-sidebar",X)},[D,k]);let Ne=oa.useRef(null),Oe=oa.useRef(""),Me=oa.useRef(false);oa.useEffect(()=>{let X=o||t?.id,j=JSON.stringify(t);Me.current&&Ne.current===X&&Oe.current===j||(h(t||{},t||{}),Me.current=true,Ne.current=X,Oe.current=j);},[r,c.id,o,t,h]),oa.useEffect(()=>{if(!r||!t?.id)return;let X=q(c.id);if(!X||H.current===X)return;let j=false;return (async()=>{if(!M)return;let de=b(X);if(de){if(JSON.stringify(de.data)===JSON.stringify(t)){N(X);return}H.current=X,d({title:"Restore draft?",message:"A newer autosaved draft was found for this document. Restore it or discard it and continue with the saved version.",confirmLabel:"Restore draft",cancelLabel:"Discard draft",onConfirm:async()=>{if(j)return;let Ue={...xe.getState().formData,...de.data};u(Ue),s?.("Recovered autosaved draft");},onCancel:async()=>{N(X);}});}})(),()=>{j=true;}},[N,r,d,q,b,t,s,u,M]);function Fe(X,j){for(let W of X){if(W.name===j&&W.admin?.autoGenerate==="title")return W;if(W.type==="tabs"&&"tabs"in W)for(let de of W.tabs){let Ie=Fe(de.fields,j);if(Ie)return Ie}if((W.type==="group"||W.type==="collapsible")&&"fields"in W){let de=Fe(W.fields,j);if(de)return de}}}oa.useEffect(()=>{let X=e.fields;if(!Fe(X,"metaTitle"))return;let W=Fo(X,c,"title"),de=W?String(W):"";de&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&p("metaTitle",de);},[c,e.fields,p]),oa.useEffect(()=>{let X=e.fields,j=X.find(Ie=>Ie.name==="slug"&&Ie.admin?.autoGenerate);if(!j?.admin?.autoGenerate)return;let W=j.admin.autoGenerate,de=Fo(X,c,W);if(v&&de){let Ie=Ns(de);Ie!==c.slug&&p("slug",Ie);}},[c,v,e.fields,p]),oa.useEffect(()=>{if(D||!o&&(!r||!c.id)||!xe.getState().hasDirtyFields()||fu()!=="keystroke")return;Bs("other");let j=JSON.stringify(c);j!==pe.current&&(R.current&&clearTimeout(R.current),R.current=setTimeout(Re,1500),fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{pe.current=j,Ae();},8e3));},[c,D,r,o,Re,Ae]),oa.useEffect(()=>{if(!o&&(!r||!c.id))return;let X=()=>{ee.current||!xe.getState().hasDirtyFields()||Ae({keepalive:true});},j=()=>{document.hidden&&X();},W=()=>{re.current=true,X();},de=()=>{re.current=false;let Ie=xe.getState();Ie.hasDirtyFields()&&Ie.setAutoSaveStatus("offline");};return window.addEventListener("blur",X),window.addEventListener("pagehide",X),window.addEventListener("online",W),window.addEventListener("offline",de),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("blur",X),window.removeEventListener("pagehide",X),window.removeEventListener("online",W),window.removeEventListener("offline",de),document.removeEventListener("visibilitychange",j);}},[r,o,c.id,Ae]),oa.useEffect(()=>{let X=JSON.stringify(c);if(X===be.current)return;be.current=X;let j=document.getElementById("form-data");j&&(j.value=X),n?.(c);},[c,n]),oa.useEffect(()=>{(o||c.id)&&K();},[c.id,o,K]);let vt=!c.id&&!o?"draft":M&&c.status||"published",Yt=(!!c.id||!!o)&&vt==="draft";return {...l,fetchVersions:K,performAutoSave:Ae,saveDocument:T,forceSave:_,autoSaveSkipRef:ee,lastAutoSaveTimeRef:ne,documentStatus:vt,hasUnpublishedChanges:Yt,versionsEnabled:M}}function Vo({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=oa.useState(false),s=oa.useRef(null);return oa.useEffect(()=>{let i=l=>{s.current&&!s.current.contains(l.target)&&n(false);};return a&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),jsxRuntime.jsxs("div",{className:"relative",ref:s,children:[jsxRuntime.jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&jsxRuntime.jsx("div",{className:`absolute z-[100] min-w-[200px] py-2 bg-[var(--kyro-surface)] rounded-2xl shadow-2xl border border-[var(--kyro-border)] animate-in fade-in zoom-in-95 duration-100 ${r==="right"?"right-0":"left-0"} ${o==="down"?"top-full mt-2":"bottom-full mb-2"}`,onClick:()=>n(false),children:t})]})}function Ft({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsxRuntime.jsx("div",{className:"px-1.5",children:jsxRuntime.jsxs("button",{type:"button",onClick:t,disabled:a,className:`w-full flex items-center gap-3 px-3 py-2.5 text-[11px] font-medium tracking-wide text-left transition-all rounded-xl ${o?"text-red-500 hover:bg-red-500/10":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]"} ${a?"opacity-50 cursor-not-allowed":""} ${n}`,children:[r&&jsxRuntime.jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsxRuntime.jsx("span",{className:"flex-1",children:e})]})})}function vn(){return jsxRuntime.jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Uo({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:s="down"}){let i=e==="published"&&!r&&t!=="saving"&&t!=="error",l=n||t==="saving"||i||t==="saved",d="kyro-btn kyro-btn-sm text-[11px] font-regular tracking-widest transition-all duration-300 rounded-lg",c=()=>t==="saving"?`${d} bg-[var(--kyro-primary)]/70 border-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] cursor-wait`:t==="saved"?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:i?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:`${d} bg-[var(--kyro-primary)] border-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] hover:bg-[var(--kyro-primary-hover)]`,u="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",p=()=>t==="saving"?`${u} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:t==="error"?`${u} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:i?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${u} bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-hover)]`,f=()=>t==="saving"?"Publishing...":t==="saved"?"Published":t==="error"?"Retry":i?"Published":"Publish Changes";return jsxRuntime.jsxs("div",{className:"inline-flex items-center",children:[jsxRuntime.jsxs("button",{type:"button",onClick:o,disabled:l,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ir,{size:"sm",className:"inline mr-1.5"}),(i||t==="saved")&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),f()]}),a&&jsxRuntime.jsx(Vo,{trigger:jsxRuntime.jsx("button",{type:"button",className:p(),disabled:t==="saving",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}),direction:s,children:a})]})}var Ru=({title:e,description:t,slug:r})=>jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg p-6 max-w-2xl shadow-sm transition-colors duration-300",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("div",{className:"w-7 h-7 bg-[var(--kyro-bg-secondary)] rounded-full flex items-center justify-center text-[10px] text-[var(--kyro-text-primary)] font-medium border border-[var(--kyro-border)]",children:"K"}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-tight",children:"kyro-cms.com"}),jsxRuntime.jsxs("span",{className:"text-[12px] text-[var(--kyro-text-secondary)] leading-tight opacity-80",children:["https://kyro-cms.com \u203A posts \u203A ",r]})]})]}),jsxRuntime.jsx("h3",{className:"text-[20px] text-[#2563eb] dark:text-[#60a5fa] font-medium hover:underline cursor-pointer mb-1 leading-tight transition-colors",children:e}),jsxRuntime.jsx("p",{className:"text-[14px] text-[var(--kyro-text-secondary)] leading-relaxed line-clamp-2",children:t})]});function Iu({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=oa.useState(0),s=e.tabs||[],i=s[a]||s[0],l=e.name?t[e.name]||{}:t;return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-[var(--kyro-border)] mb-6",children:jsxRuntime.jsx("div",{className:"flex items-center gap-2 overflow-x-auto hide-scrollbar",children:s.map((d,c)=>jsxRuntime.jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${a===c?"border-[var(--kyro-primary)] text-[var(--kyro-primary)]":"border-transparent text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] opacity-60 hover:opacity-100"}`,onClick:()=>n(c),children:d.label},c))})}),jsxRuntime.jsx("div",{className:"space-y-6",children:i?.fields.map(d=>o(d,l,r))}),i?.label==="SEO Settings"&&jsxRuntime.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold text-[var(--kyro-text-secondary)] tracking-[0.2em] mb-6 opacity-50",children:"Live Google Preview"}),jsxRuntime.jsx(Ru,{title:String((typeof l.metaTitle=="object"?"":l.metaTitle)||(typeof l.title=="object"?"":l.title)||"Untitled"),description:String((typeof l.metaDescription=="object"?"":l.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function Mu({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:s,handleDuplicate:i,handleUnpublish:l,handleDelete:d,handlePublish:c,handleSaveDraft:u,handleSchedulePublish:p,handleConflictOverride:f}){let{t:y}=z(),[g,v]=oa.useState(Date.now()),[h,m]=oa.useState(false),w=oa.useRef(null),{formData:C,hasUnsavedChanges:E,autoSaveStatus:D,lastSavedAt:k,retryCount:b,view:x,setView:N,showPreview:O,setShowPreview:M,setFormData:I,markSaved:P,lastSavedData:R}=xe(),fe=!C.id;oa.useEffect(()=>{let K=setInterval(()=>v(Date.now()),1e4);return ()=>clearInterval(K)},[]),oa.useEffect(()=>{let K=Re=>{w.current&&!w.current.contains(Re.target)&&m(false);};if(h)return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[h]);let L=String(C.tabs?.title||(typeof C.title=="object"?"":C.title)||(typeof C.name=="object"?"":C.name)||"Untitled"),re=C.updatedAt?new Date(C.updatedAt).toLocaleString():"Just now",ne=C.createdAt?new Date(C.createdAt).toLocaleString():"Just now",ee=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",H=o?"Unpublished":r==="published"?"Published":"Draft",pe=r==="published"&&!E?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",be=r==="published"&&!o?"bg-[var(--kyro-success)]/10 text-[var(--kyro-success)] border-[var(--kyro-success)]/20":o?"bg-[var(--kyro-warning)]/10 text-[var(--kyro-warning)] border-[var(--kyro-warning)]/20":"bg-[var(--kyro-text-muted)]/10 text-[var(--kyro-text-muted)] border-[var(--kyro-text-muted)]/20",V=(K=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[D==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),K?"Saving\u2026":"Saving draft..."]}),D==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Nc.Check,{className:"w-3.5 h-3.5 shrink-0"}),K?"Saved":k?`Saved ${Math.floor((Date.now()-k)/6e4)}m ago`:"Draft saved"]}),D==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),K?`Retry ${b}/5`:`Retrying save (${b}/5)`]}),D==="offline"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[jsxRuntime.jsx("path",{d:"M10.61 10.61a3 3 0 0 0 4.24 4.24"}),jsxRuntime.jsx("path",{d:"M13.36 13.36a3 3 0 0 0-4.24-4.24"}),jsxRuntime.jsx("path",{d:"m2 2 20 20"}),jsxRuntime.jsx("path",{d:"M18.36 5.64a9 9 0 0 0-12.72 0"}),jsxRuntime.jsx("path",{d:"M22.61 1.39a15 15 0 0 0-21.22 0"})]}),K?"Offline":"Offline \u2014 cached locally"]}),D==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:K?"Failed":"Draft save failed"}),D==="conflict"&&(K?jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict"}):jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict detected"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f?.(),className:"text-[var(--kyro-primary)] hover:underline",children:"Keep my changes"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"|"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-[var(--kyro-danger)] hover:underline",children:"Reload server version"})]}))]}),q=()=>!fe&&jsxRuntime.jsxs(Vo,{trigger:jsxRuntime.jsx("button",{type:"button",className:"kyro-btn p-2 md:p-2.5 rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)] transition-all",title:y("tooltips.moreActions",{defaultValue:"More actions"}),children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})}),direction:"down",children:[jsxRuntime.jsx(Ft,{onClick:u,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsxRuntime.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsxRuntime.jsx("polyline",{points:"7 3 7 8 15 8"})]}),children:"Save Draft"}),!t&&jsxRuntime.jsx(Ft,{onClick:s,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsxRuntime.jsx(Ft,{onClick:i,disabled:n,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),children:n?"Duplicating...":"Duplicate"}),jsxRuntime.jsx(Ft,{onClick:()=>m(true),icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsxRuntime.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsxRuntime.jsx(Ft,{onClick:l,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),jsxRuntime.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),children:"Unpublish"}),!t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(vn,{}),jsxRuntime.jsx(Ft,{onClick:d,danger:true,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),children:"Delete"})]})]}),ae=()=>h&&jsxRuntime.jsx("div",{ref:w,className:"relative",children:jsxRuntime.jsxs("div",{className:"absolute right-0 top-2 p-4 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] shadow-2xl z-50 min-w-[260px]",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsxRuntime.jsx("input",{type:"datetime-local",id:"schedule-datetime",className:"kyro-form-input text-xs mb-3 w-full",min:new Date().toISOString().slice(0,16)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let K=document.getElementById("schedule-datetime")?.value;K&&p(K);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] z-50 bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsxRuntime.jsx("a",{href:`${He}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:L}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-medium border ${be}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${pe}`}),H]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(Uo,{status:r,saveStatus:a,hasChanges:E,onPublish:c,disabled:a==="saving"}),q(),ae()]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-[var(--kyro-border)]/50 bg-[var(--kyro-bg-secondary)]/30",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)]/50",children:["edit","version","api"].map(K=>jsxRuntime.jsx("button",{type:"button",onClick:()=>N(K),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${x===K?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 active:opacity-100"}`,children:K==="edit"?"Edit":K==="version"?"History":"API"},K))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[V(true),E&&D!=="saving"&&D!=="retrying"&&D!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{xe.getState().loadDocument(R,R);},className:"text-[var(--kyro-primary)] text-[10px] font-medium hover:underline",children:"Revert"}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>M(!O),className:`p-1.5 rounded-lg transition-all ${O?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(Nc.ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxRuntime.jsxs("header",{className:"hidden md:flex surface-tile px-8 py-6 items-center justify-between sticky top-0 border-b border-[var(--kyro-border)] mb-8 bg-[var(--kyro-surface)] z-50 backdrop-blur-md",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsxRuntime.jsx("a",{href:`${He}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Nc.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:L}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${be}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${pe}`}),ee]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[V(false),E&&D!=="saving"&&D!=="retrying"&&D!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{xe.getState().loadDocument(R,R);},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),k&&D!=="saving"&&D!=="retrying"&&D!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let K=g-k,Re=Math.floor(K/6e4),he=Math.floor(K/1e3);return Re>=1?`${Re}m ago`:he>=5?`${he}s ago`:"just now"})()]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",re]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",ne]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-1 bg-[var(--kyro-bg-secondary)] p-1 rounded-xl border border-[var(--kyro-border)]",children:["edit","version","api"].map(K=>jsxRuntime.jsx("button",{type:"button",onClick:()=>N(K),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${x===K?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:K.toUpperCase()},K))}),jsxRuntime.jsx("div",{className:"h-8 w-px bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>M(!O),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${O?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:y("tooltips.livePreview",{defaultValue:"Live Preview"}),children:[jsxRuntime.jsx(Nc.ExternalLink,{className:"w-4 h-4"}),O&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),q(),ae(),jsxRuntime.jsx(Uo,{status:r,saveStatus:a,hasChanges:E,onPublish:c,disabled:a==="saving"})]})]})]})]})}function Bu({config:e,layout:t,collectionSlug:r,renderField:o}){let{t:a}=z(),{showPreview:n,sidebarCollapsed:s,formData:i,previewUrl:l}=xe();if(t==="single")return jsxRuntime.jsx("div",{className:"w-full space-y-6 md:space-y-8",children:jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.map(u=>o(u))})});let c=e.fields.some(u=>u.admin?.position==="sidebar")&&!n;return jsxRuntime.jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${n?"grid-cols-1 lg:grid-cols-2":s||!c?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsxRuntime.jsx("div",{className:"space-y-6 md:space-y-8 animate-in fade-in slide-in-from-left-4 duration-500",children:e.tabs?o({type:"tabs",tabs:e.tabs}):jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(u=>!u.admin?.position||u.admin.position==="main").map(u=>o(u))})}),n?jsxRuntime.jsx("div",{className:"sticky top-36 h-[calc(100vh-280px)] animate-in fade-in slide-in-from-right-10 duration-700",children:jsxRuntime.jsxs("div",{className:"w-full h-full rounded-3xl border border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] shadow-2xl overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-white/60",children:"Live Preview Mode"})]}),jsxRuntime.jsx("iframe",{src:l||"",className:"w-full h-full border-none",title:a("tooltips.livePreview",{defaultValue:"Live Preview"})}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):s?null:jsxRuntime.jsx("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:e.fields.some(u=>u.admin?.position==="sidebar")&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-6 space-y-4 md:space-y-6",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Settings"}),e.fields.filter(u=>u.admin?.position==="sidebar").map(u=>o(u))]})})]})}function $u({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:i,setCompareDiffs:l,loadingDiffs:d,loadingVersions:c,versions:u}=xe();return jsxRuntime.jsx("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 pb-12",children:jsxRuntime.jsxs("div",{className:"surface-tile p-0 overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"px-4 md:px-6 py-3 md:py-4 border-b border-[var(--kyro-border)] flex flex-col md:flex-row md:items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-base md:text-lg font-bold text-[var(--kyro-text-primary)]",children:"Version History"}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-muted)] mt-0.5",children:o?`Select 2 versions \xB7 ${n.length}/2 chosen`:`${u.length} snapshot${u.length!==1?"s":""} \xB7 Auto-saved`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&n.length===2&&jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:d,className:"kyro-btn kyro-btn-primary px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider hover:opacity-90 disabled:opacity-50",children:d?"Comparing...":"Compare"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{a(!o),s([]),l([]);},className:`px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider transition-all ${o?"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]":"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:o?"Done":"Compare"})]})]}),i.length>0&&jsxRuntime.jsxs("div",{className:"border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"px-6 py-3 flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold text-[var(--kyro-text-primary)] tracking-wider",children:[i.length," change",i.length!==1?"s":""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>l([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Nc.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:i.map((p,f)=>jsxRuntime.jsxs("div",{className:"flex flex-col md:grid md:grid-cols-4 gap-1 md:gap-3 px-4 md:px-6 py-2.5 text-[11px] font-mono border-t border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate font-semibold md:font-normal",children:p.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof p.oldValue=="object"?JSON.stringify(p.oldValue):String(p.oldValue??"null")}),jsxRuntime.jsxs("div",{className:"md:col-span-2 text-[var(--kyro-text-primary)] truncate",children:[jsxRuntime.jsx("span",{className:"md:hidden text-[var(--kyro-text-muted)]",children:"\u2192 "}),typeof p.newValue=="object"?JSON.stringify(p.newValue):String(p.newValue??"null")]})]},f))})]}),c?jsxRuntime.jsx("div",{className:"flex justify-center py-16",children:jsxRuntime.jsx("span",{className:"animate-spin text-[var(--kyro-primary)]",children:"\u231B"})}):u.length===0?jsxRuntime.jsx("div",{className:"text-center py-16 text-[var(--kyro-text-muted)] text-sm italic",children:"No versions yet."}):jsxRuntime.jsx("div",{className:"divide-y divide-[var(--kyro-border)]",children:u.map((p,f)=>{let y=n.includes(p.id),g=(p.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(p.id):void 0,className:`transition-all ${o?y?"bg-[var(--kyro-primary)]/5 cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)] cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"hidden md:grid grid-cols-12 gap-3 px-6 py-3 items-center",children:[jsxRuntime.jsx("div",{className:"col-span-1 flex items-center gap-2",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${y?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:y&&jsxRuntime.jsx(Nc.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:u.length-f})}),jsxRuntime.jsxs("div",{className:"col-span-4 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-2",children:[p.changeDescription||"Snapshot",g&&jsxRuntime.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider",children:"Auto"})]}),jsxRuntime.jsx("div",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(p.createdAt||p.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:p.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${p.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),p.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:p.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(p.id),className:"px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[11px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})})]}),jsxRuntime.jsxs("div",{className:"md:hidden flex items-start gap-3 px-4 py-3",children:[jsxRuntime.jsx("div",{className:"pt-0.5 shrink-0",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${y?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:y&&jsxRuntime.jsx(Nc.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:u.length-f})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-1.5",children:[p.changeDescription||"Snapshot",g&&jsxRuntime.jsx("span",{className:"text-[9px] px-1 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider shrink-0",children:"Auto"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(p.createdAt||p.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),p.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${p.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${p.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),p.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:p.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(p.id),className:"shrink-0 px-2.5 py-1 rounded-lg border border-[var(--kyro-border)] text-[10px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})]})]},p.id)})})]})})}function Ou({collectionSlug:e,globalSlug:t}){let{t:r}=z(),{formData:o}=xe();return jsxRuntime.jsx("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] gap-8",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-8 min-w-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"Response Payload"}),jsxRuntime.jsx("div",{className:"bg-[#0f172a] p-6 rounded-2xl border border-white/5 overflow-x-auto max-h-[800px]",children:jsxRuntime.jsx("pre",{className:"text-blue-300 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(o,null,2)})})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsxs("div",{className:"surface-tile p-8 space-y-6",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"API Info"}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Reference Path"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg-secondary)] px-4 py-3 rounded-md border border-[var(--kyro-border)] text-[11px] font-mono break-all selection:bg-[var(--kyro-primary)]/20 text-[var(--kyro-text-primary)]",children:t?`kyro.globals('${t}').get()`:o.id?`kyro.collection('${e}').get('${o.id}')`:"Not saved yet"})]}),o.id&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Document ID"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:String(o.id)}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(o.id));},className:"p-1.5 hover:bg-[var(--kyro-bg-secondary)] rounded-lg transition-colors text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]",title:r("tooltips.copyId",{defaultValue:"Copy ID"}),children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),t&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Global Slug"}),jsxRuntime.jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:t})]})]})]})})]})})}var _s=class extends oa.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("[ErrorBoundary] Caught:",t,r),this.setState({errorInfo:r.componentStack||null});}handleCopyToClipboard=()=>{let{error:t,errorInfo:r}=this.state,o=xe.getState().formData,a={error:t?.message,stack:t?.stack,componentStack:r,formData:o,timestamp:new Date().toISOString()};navigator.clipboard.writeText(JSON.stringify(a,null,2)).then(()=>{U.success("Crash details copied to clipboard");});};handleReload=()=>{window.location.reload();};render(){return this.state.hasError?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:jsxRuntime.jsx(Nc.TriangleAlert,{className:"w-8 h-8 text-red-500"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold text-[var(--kyro-text-primary)]",children:this.props.fallbackTitle||"Something went wrong"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] text-center max-w-md",children:"The form encountered an unexpected error. Your unsaved changes may still be recoverable."}),this.state.error&&jsxRuntime.jsx("p",{className:"text-xs font-mono text-red-500/70 bg-red-500/5 px-4 py-2 rounded-lg max-w-full overflow-auto",children:this.state.error.message}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[jsxRuntime.jsxs("button",{type:"button",onClick:this.handleReload,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Nc.RefreshCw,{className:"w-4 h-4"}),"Reload Page"]}),jsxRuntime.jsxs("button",{type:"button",onClick:this.handleCopyToClipboard,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/20 transition-colors",children:[jsxRuntime.jsx(Nc.Copy,{className:"w-4 h-4"}),"Copy Details"]})]})]}):this.props.children}};function Vu(e,t){if(!(!e||typeof t!="string"))return t.split(".").reduce((r,o)=>r&&r[o]!==void 0?r[o]:void 0,e)}function hl(e,t,r){if(!e)return true;if(Array.isArray(e.and))return e.and.every(o=>hl(o,t,r));if(Array.isArray(e.or))return e.or.some(o=>hl(o,t,r));if(e.field){let o=e.field,a=Vu(t,o);return a===void 0&&(a=Vu(r,o)),"equals"in e?a===e.equals:"notEquals"in e?a!==e.notEquals:"in"in e&&Array.isArray(e.in)?e.in.includes(a):"greaterThan"in e?typeof a=="number"&&a>e.greaterThan:!!a}return true}var ju={};function bn({config:e,data:t=ju,errors:r=ju,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:i,documentName:l,layout:d="split",onActionSuccess:c,onActionError:u,justSaved:p}){let f=e||(s?Wc[s]:n?fa[n]:null),[y,g]=oa.useState(f);oa.useEffect(()=>{s==="storage-settings"?Be("/api/kyro/schema").then(B=>{B?.globals?.["storage-settings"]&&g(B.globals["storage-settings"]);}).catch(B=>console.error("[AutoForm] Failed to fetch dynamic schema",B)):g(f);},[s,f]);let v=y||f,{confirm:h}=gt(),{formData:m,hasUnsavedChanges:C,autoSaveStatus:k,lastSavedAt:b,view:fe,setView:L,setShowPreview:be,isMenuOpen:V,setIsMenuOpen:q,loadingFields:ae,setLoadingFields:K,compareSelected:Ae,setCompareSelected:T,setCompareDiffs:Ne,setLoadingDiffs:Me,setField:Fe,setFormData:vt,setLastSavedData:X,setAutoSaveStatus:j,fetchVersions:W,saveDocument:de,forceSave:Ie,autoSaveSkipRef:Ue,lastAutoSaveTimeRef:bt,documentStatus:$,hasUnpublishedChanges:Y,versionsEnabled:se}=Tu({config:v,initialData:t,collectionSlug:n,globalSlug:s,documentId:i,onChange:o,onActionSuccess:c,onActionError:u}),Qt=oa.useRef(null),Co=oa.useRef(null),[Ma,xn]=oa.useState(false),[Zs,A]=oa.useState("idle"),[ge,Ve]=oa.useState(false),[ar,$t]=oa.useState(Date.now()),Cr=a,[ei,Go]=oa.useState(false),[Ip,ti]=oa.useState(false),[Lp,Ep]=oa.useState(0),Tl=oa.useRef(new Map),Mp=3e4;oa.useEffect(()=>{let B=s?`global:${s}`:`${n}:${i}`;if(!(s||n&&i&&i!=="new")||t&&Object.keys(t).length>0)return;let Se=Tl.current.get(B),Ke=Se&&Date.now()-Se.ts<Mp,St=Se&&!Ke;if(Ke){xe.getState().loadDocument(Se.data,Se.data);return}St&&xe.getState().loadDocument(Se.data,Se.data);let At=new AbortController;ti(false),Se||Go(true);let $r=s?`/api/globals/${s}`:`/api/${n}/${i}`;return Be($r,{autoToast:false,signal:At.signal}).then(ht=>{let So=ht.data||{};Tl.current.set(B,{data:So,ts:Date.now()}),xe.getState().loadDocument(So,So),Go(false);}).catch(ht=>{ht.name!=="AbortError"&&(Go(false),Se||ti(true));}),()=>At.abort()},[n,i,s,t,Lp]),oa.useEffect(()=>{let B=setInterval(()=>$t(Date.now()),1e4);return ()=>clearInterval(B)},[]);let Dl=(B,te)=>{if(typeof B=="function")try{return B(m,te)}catch(Se){return console.warn("Error evaluating admin runtime flag:",Se),false}return !!B},Bp=B=>{h({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let te=s?Xe(`/api/globals/${s}/versions/${B}/restore`):Xe(`/api/${n}/${m.id}/versions/${B}/restore`),Se=await ct(te,{method:"POST"});!Se.ok&&n&&(Se=await ct(Xe(`/api/${n}/${m.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:B,action:"restore"})}));let Ke=await Se.json();if(Ke.data){let{updatedAt:St,createdAt:At,...$r}=Ke.data,ht={...m,...$r};vt(ht),xe.getState().loadDocument(ht,ht),c?.("Version restored successfully"),W(),L("edit");}else U.error(Ke.error||"Failed to restore version");}catch(te){console.error("Failed to restore version:",te),U.error("Failed to restore version");}}});},$p=async()=>{if(Ae.length===2){Me(true);try{let te=await(await ct(Xe(`/api/${n}/${m.id}/versions?compareA=${Ae[0]}&compareB=${Ae[1]}`))).json();Ne(te.diffs||[]);}catch(B){console.error("Compare failed:",B),Ne([]);}finally{Me(false);}}},Op=B=>{T(te=>te.includes(B)?te.filter(Se=>Se!==B):te.length>=2?[te[1],B]:[...te,B]);};oa.useEffect(()=>{let B=te=>{(te.metaKey||te.ctrlKey)&&te.key==="s"&&(te.preventDefault(),kn()),(te.metaKey||te.ctrlKey)&&te.shiftKey&&(te.key==="P"||te.key==="p")&&(te.preventDefault(),document.getElementById("btn-publish")?.click()),(te.metaKey||te.ctrlKey)&&!te.shiftKey&&te.key==="p"&&(te.preventDefault(),be(Se=>!Se)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(te.key==="1"&&L("edit"),te.key==="2"&&L("version"),te.key==="3"&&L("api"));};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[]),oa.useEffect(()=>{let B=()=>L("version");return window.addEventListener("kyro:show-version-history",B),()=>window.removeEventListener("kyro:show-version-history",B)},[]),oa.useEffect(()=>{let B=te=>{Qt.current&&!Qt.current.contains(te.target)&&q(false);};if(V)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[V]),oa.useEffect(()=>{let B=te=>{Co.current&&!Co.current.contains(te.target)&&xn(false);};if(Ma)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[Ma]);let Vp=()=>{C?h({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await kn(),await new Promise(B=>setTimeout(B,1e3)),window.location.href=`${He}/${n}/new`;}}):window.location.href=`${He}/${n}/new`;},jp=()=>{if(!m.id){U.error("Please save the document before duplicating.");return}let B=async()=>{try{Ve(!0);let te=await ct(`/api/${n}/${m.id}/duplicate`,{method:"POST"});if(te.ok){let Se=await te.json();c?.("Document duplicated successfully"),Se.data?.id?window.location.href=`${He}/${n}/${Se.data.id}`:window.location.href=`${He}/${n}`;}else {let Se=await te.json();U.error(Se.error||"Failed to duplicate");}}catch{U.error("Failed to duplicate document");}finally{Ve(false);}};if(C){h({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await kn(),await B();}});return}h({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await B();}});},Up=()=>{h({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{Ue.current=true;try{await Dt(`/api/${n}/${m.id}`),window.location.href=`${He}/${n}`;}catch(B){U.error(B.message||"Failed to delete document");}finally{Ue.current=false;}}});},zp=()=>{h({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{Ue.current=true;try{let B=await de({...m,status:"draft"},!1);if(B?.ok)c?.("Document unpublished successfully"),xe.getState().loadDocument({...m,status:"draft"},{...m,status:"draft"});else {let te=await B?.json().catch(()=>({}));U.error(te?.error||"Failed to unpublish");}}catch{U.error("Failed to unpublish");}finally{Ue.current=false;}}});},kn=async()=>{let B=!m.id;Ue.current=true,A("saving");try{let te=qt({...m}),Se=B&&!s,Ke=Se?await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)}):await de(te);if(Ke.ok){let St=await Ke.json(),At=St.data||te;xe.getState().loadDocument(At,At),bt.current=Date.now(),j("success"),A("saved"),se&&W(),setTimeout(()=>{j("idle"),A("idle");},2e3),c?.(Se?"Document created successfully":"Changes saved"),s&&window.dispatchEvent(new Event("kyro:soft-reload")),Se&&setTimeout(()=>{window.location.href=`${He}/${n}/${St.data.id}`;},800);}else {let St=await Ke.json();Ke.status===409&&j("conflict"),A("error"),U.error(St.error||"Failed to save"),setTimeout(()=>A("idle"),3e3);}}catch{A("error"),U.error("Failed to save document"),setTimeout(()=>A("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),Ue.current=false;}},Hp=async()=>{let B=!m.id;Ue.current=true,A("saving");try{let te={...m};if(B&&!s){let St=qt({...m}),At=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(St)});if(!At.ok){let So=await At.json().catch(()=>({}));At.status===409&&j("conflict"),A("error"),U.error(So.error||"Failed to create document"),setTimeout(()=>A("idle"),3e3);return}let ht=(await At.json()).data||St;xe.getState().loadDocument(ht,ht),te=ht;}let Se=qt(te),Ke=await de(Se,!1);if(Ke?.ok){let At=(await Ke.json().catch(()=>({}))).data||Se;xe.getState().loadDocument(At,At),A("saved"),c?.("Published successfully"),setTimeout(()=>{A("idle");},2e3),B&&!s&&te.id&&setTimeout(()=>{window.location.href=`${He}/${n}/${te.id}`;},800);}else {if(B&&!s&&te.id){let At=await Ke?.json().catch(()=>({}));U.warning("Document saved as draft. Publishing failed: "+(At?.error||"Unknown error")),setTimeout(()=>{window.location.href=`${He}/${n}/${te.id}`;},1200);return}let St=await Ke?.json().catch(()=>({}));Ke?.status===409&&j("conflict"),A("error"),U.error(St?.error||"Failed to publish"),setTimeout(()=>A("idle"),3e3);}}catch{A("error"),U.error("Failed to publish"),setTimeout(()=>A("idle"),3e3);}finally{Ue.current=false;}},_p=async B=>{let te=!m.id;Ue.current=true;try{let Se={...qt({...m}),_schedulePublishAt:B};if(te&&!s){let Ke=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Se)});if(!Ke.ok){let St=await Ke.json().catch(()=>({}));U.error(St.error||"Failed to schedule publish");return}}else {let Ke=await de(Se);if(!Ke.ok){let St=await Ke.json().catch(()=>({}));U.error(St.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(B).toLocaleString()}`),xn(!1);}catch{U.error("Failed to schedule publish");}finally{Ue.current=false;}},Kp=(B,te)=>{Fe(B,te);},Ba=(B,te,Se)=>{let Ke=te!==void 0?te:m;if(Dl(B.hidden!==void 0?B.hidden:B.admin?.hidden,Ke))return null;let At=Dl(B.readOnly!==void 0?B.readOnly:B.admin?.readOnly,Ke),$r=!!(Cr||At);if(B.admin?.condition){if(typeof B.admin.condition=="function")try{let dt={values:m||{},...m||{}};if(!B.admin.condition(dt,Ke))return null}catch(dt){console.warn(`Condition error for field ${B.name}:`,dt);}else if(typeof B.admin.condition=="object")try{if(!hl(B.admin.condition,Ke,m))return null}catch(dt){console.warn(`Declarative condition error for field ${B.name}:`,dt);}}let ht=Ke[B.name],So=r[B.name],wn=dt=>{Se?Se({...Ke,[B.name]:dt}):Kp(B.name,dt);};if(B.type==="row"&&"fields"in B){let dt=B.fields;return jsxRuntime.jsx("div",{className:"kyro-form-row flex flex-col md:flex-row gap-4 md:gap-6 items-start md:items-end w-full",children:dt?.map(nt=>{let Or=nt.admin||{},Nn=Or?.action;if((nt.type==="button"||nt.type==="action")&&Nn){let Sr=dt?.find($a=>$a.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let $a=B.name,Cn=Sr?.name,Sn=Cn?m[Cn]:void 0;if(!Sn&&$a&&typeof $a=="string"&&Cn&&(Sn=m[$a]?.[Cn]),!!Sn){K(Ar=>({...Ar,[nt.name]:true}));try{let Ar=await ct(Xe(Nn),{method:Or.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Sn})}),Oa={};try{Oa=await Ar.json();}catch{Oa={};}if(Ar.ok&&Oa.success)c?.(Oa.message||"Action completed successfully");else {let Gp=Oa.error||`Request failed (${Ar.status})`;u?.(Gp);}}catch(Ar){u?.(Ar instanceof Error?Ar.message:"Error connecting to server");}finally{K(Ar=>({...Ar,[nt.name]:false}));}}},disabled:ae[nt.name]||$r,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:ae[nt.name]?"Sending...":nt.label||"Click"})},nt.name)}return jsxRuntime.jsx("div",{className:nt.type==="button"||nt.type==="action"?"flex-shrink-0":"flex-1",style:Or?.width?{width:Or.width,flex:"none"}:{},children:Ba(nt,te,Se)},nt.name)})},B.name||`row-${Math.random()}`)}switch(B.type){case "tabs":return jsxRuntime.jsx(Iu,{field:B,formData:m,onTabDataChange:dt=>{Fe(B.name,dt);},renderField:(dt,nt,Or)=>Ba(dt,nt,Or)},B.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(Es,{field:B,value:ht,onChange:wn,renderField:Ba},B.name);case "array":return jsxRuntime.jsx(Ms,{field:B,value:ht,onChange:wn,renderField:Ba,disabled:$r},B.name);case "button":case "action":{let dt=B.name,nt=ae[dt];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:nt||$r,onClick:async()=>{let Or=B.admin?.action||B.action,Nn=B.admin?.method||B.method||"POST";if(Or){K(Sr=>({...Sr,[dt]:true}));try{let Sr=await ct(Or,{method:Nn,headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});await Sr.json(),Sr.ok;}catch(Sr){console.error("Error executing action:",Sr);}finally{K(Sr=>({...Sr,[dt]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${nt?"opacity-70 cursor-not-allowed":""}`,children:[nt&&jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),nt?"Processing...":B.label||"Click"]})},dt)}case "relationship-block":return jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[B.label||B.name,B.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx(yn,{relationTo:B.relationTo,hasMany:B.hasMany,selectedIds:Array.isArray(ht)?ht:ht?[ht]:[],onChange:(dt,nt)=>{wn(nt);},compact:true}),B.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(B.admin?.description)}):null]},B.name);default:return jsxRuntime.jsx(Oo,{field:B,value:ht,onChange:wn,error:So,disabled:$r,formData:m,siblingData:Ke,collectionSlug:n,globalSlug:s},B.name||Math.random().toString())}};return ei?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Kt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Kt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Kt,{variant:"rect",count:4})})]}):Ip?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(Nc.TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{ti(false),Go(true),Ep(B=>B+1);},className:"kyro-btn kyro-btn-primary px-6 py-2 rounded-xl text-sm font-bold",children:"Retry"})]}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[d!=="single"&&jsxRuntime.jsx(Mu,{collectionSlug:n,globalSlug:s,documentStatus:$||"draft",hasUnpublishedChanges:Y,localSaveStatus:Zs,isDuplicating:ge,handleCreateNew:Vp,handleDuplicate:jp,handleUnpublish:zp,handleDelete:Up,handlePublish:Hp,handleSaveDraft:kn,handleSchedulePublish:_p,handleConflictOverride:()=>Ie()}),d==="single"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium",children:[k==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Saving..."]}),k==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Nc.Check,{className:"w-4 h-4"}),b?`Saved ${Math.floor((Date.now()-b)/6e4)}m ago`:"Saved"]}),k==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Retrying..."]}),k==="offline"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),k==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),k==="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),C&&k!=="saving"&&k!=="retrying"&&k!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!C&&k!=="success"&&k!=="saving"&&k!=="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-success)]",children:"All changes saved"})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)] opacity-60",children:m.updatedAt?`Modified ${new Date(m.updatedAt).toLocaleString()}`:""})]}),jsxRuntime.jsx("button",{id:"btn-save",type:"button",style:{width:0,height:0,opacity:0,padding:0,margin:0,border:"none",position:"absolute"},onClick:async()=>{Ue.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let B=await de(m);if(B.ok){let Se=(await B.json()).data||m;vt({...m,...Se}),X({...m,...Se}),c?.("Changes saved"),s&&window.dispatchEvent(new Event("kyro:soft-reload"));}}catch(B){console.error("Save error exception:",B),u?.("Save failed: "+B.message);}finally{Ue.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsxRuntime.jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxRuntime.jsxs(_s,{children:[fe==="edit"&&jsxRuntime.jsx(Bu,{config:v,layout:d,collectionSlug:n,renderField:Ba}),fe==="version"&&jsxRuntime.jsx($u,{handleRestoreVersion:Bp,handleCompareVersions:$p,toggleCompareSelection:Op}),fe==="api"&&jsxRuntime.jsx(Ou,{collectionSlug:n,globalSlug:s})]})})]})}var Uu={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function xl({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:s,onViewHistory:i,onPreview:l,onDelete:d,onBack:c,onToggleSidebar:u,publishedAt:p,updatedAt:f,onCopyData:y,onPasteData:g}){let{t:v}=z(),h=xe(N=>N.view)||"edit",m=xe(N=>N.setView),[w,C]=oa.useState(false),E=oa.useRef(null);oa.useEffect(()=>{let N=O=>{E.current&&!E.current.contains(O.target)&&C(false);};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);let D=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,k=["edit","version","api"],b=D(),x="p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] transition-all shrink-0";return jsxRuntime.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 bg-[var(--kyro-surface)] border-b border-[var(--kyro-border)] w-full overflow-x-auto",children:[c&&jsxRuntime.jsx("button",{type:"button",onClick:c,className:"p-1 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all shrink-0",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${Uu[e]||"bg-[var(--kyro-text-muted)]"}`}),b&&jsxRuntime.jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ir,{size:"sm",className:"inline mr-0.5"}),b]}),jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)] shrink-0 max-md:hidden",children:k.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>m(N),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${h===N?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:N==="edit"?"Edit":N==="version"?"Ver":"API"},N))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${x} max-md:hidden`,title:v("tooltips.preview",{defaultValue:"Preview"}),children:jsxRuntime.jsx(Nc.Eye,{className:"w-3.5 h-3.5"})}),i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${x} max-md:hidden`,title:v("tooltips.viewHistory",{defaultValue:"View History"}),children:jsxRuntime.jsx(Nc.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${x} max-md:hidden`,title:v("tooltips.duplicate",{defaultValue:"Duplicate"}),children:jsxRuntime.jsx(Nc.Copy,{className:"w-3.5 h-3.5"})}),y&&jsxRuntime.jsx("button",{type:"button",onClick:y,className:`${x} max-md:hidden`,title:v("tooltips.copyData",{defaultValue:"Copy Data"}),children:jsxRuntime.jsx(Nc.ClipboardCopy,{className:"w-3.5 h-3.5"})}),g&&jsxRuntime.jsx("button",{type:"button",onClick:g,className:`${x} max-md:hidden`,title:v("tooltips.pasteData",{defaultValue:"Paste Data"}),children:jsxRuntime.jsx(Nc.ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsxRuntime.jsx("button",{type:"button",onClick:d,className:`${x} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:v("tooltips.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Nc.Trash2,{className:"w-3.5 h-3.5"})}),u&&jsxRuntime.jsx("button",{type:"button",onClick:u,className:`${x} max-md:hidden`,title:v("tooltips.toggleSidebar",{defaultValue:"Toggle Sidebar"}),children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),jsxRuntime.jsxs("div",{ref:E,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>C(!w),className:x,title:v("tooltips.more",{defaultValue:"More"}),children:jsxRuntime.jsx(Nc.EllipsisVertical,{className:"w-3.5 h-3.5"})}),w&&jsxRuntime.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-1 max-h-[70vh] overflow-y-auto",children:[b&&jsxRuntime.jsxs("div",{className:"px-3 py-2 text-[10px] text-[var(--kyro-text-muted)] border-b border-[var(--kyro-border)] flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${Uu[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(ir,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:b})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:k.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{m(N),C(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${h===N?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:N==="edit"?"Edit":N==="version"?"Ver":"API"},N))}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),C(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Nc.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),C(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Nc.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),y&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{y(),C(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Nc.ClipboardCopy,{className:"w-3.5 h-3.5"})," Copy Data"]}),g&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{g(),C(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Nc.ClipboardPaste,{className:"w-3.5 h-3.5"})," Paste Data"]}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),C(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Nc.Eye,{className:"w-3.5 h-3.5"})," Preview"]}),d&&jsxRuntime.jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>{d(),C(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger-bg)] transition-colors",children:[jsxRuntime.jsx(Nc.Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxRuntime.jsxs("button",{type:"button",onClick:a,disabled:t==="saving",className:"kyro-btn kyro-btn-primary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(Nc.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxRuntime.jsxs("button",{type:"button",onClick:n,disabled:t==="saving",className:"kyro-btn kyro-btn-secondary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(Nc.Undo,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxRuntime.jsxs(Uo,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[s&&jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Nc.Copy,{className:"w-4 h-4"}),onClick:s,children:"Duplicate"}),y&&jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Nc.ClipboardCopy,{className:"w-4 h-4"}),onClick:y,children:"Copy Data"}),g&&jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Nc.ClipboardPaste,{className:"w-4 h-4"}),onClick:g,children:"Paste Data"}),i&&jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Nc.Clock,{className:"w-4 h-4"}),onClick:i,children:"View History"}),l&&jsxRuntime.jsx(Ft,{icon:jsxRuntime.jsx(Nc.Eye,{className:"w-4 h-4"}),onClick:l,children:"Preview"}),(s||y||g||i||l)&&jsxRuntime.jsx(vn,{}),d&&jsxRuntime.jsx(Ft,{onClick:d,danger:true,icon:jsxRuntime.jsx(Nc.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function kl({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:i,mode:l="collection"}){let{t:d}=z(),{confirm:c,alert:u}=gt(),[p,f]=oa.useState({}),[y,g]=oa.useState({}),[v,h]=oa.useState(true),[m,w]=oa.useState(false),[C,E]=oa.useState(false),[D,k]=oa.useState(false),[b,x]=oa.useState("idle"),[N,O]=oa.useState("draft"),[M,I]=oa.useState(null),[P,R]=oa.useState(null),[fe,L]=oa.useState(null),[re,ne]=oa.useState(false),ee=xe(j=>j.showPreview),H=xe(j=>j.setShowPreview),pe=xe(j=>j.previewUrl),be=xe(j=>j.setPreviewUrl),V=r?.fields||t?.fields||[],q=r?.label||t?.label||"Document",ae=r?.slug||t?.slug||"",K=JSON.stringify(p)!==JSON.stringify(y);oa.useEffect(()=>{K&&N==="published"&&O("draft");},[K,N]),oa.useEffect(()=>{K&&b==="saved"&&x("idle");},[K,b]),oa.useEffect(()=>{l==="global"?he():o&&Re();},[o,l,ae]);let Re=async()=>{try{h(!0);let j=await Be(`/api/${ae}/${o}`,{autoToast:!1}),W=j.data||{};f(W),g(W),O(W?.status||j.status||"draft"),I(j.createdAt||W.createdAt||null),R(j.updatedAt||W.updatedAt||null),L(j.publishedAt||W.publishedAt||null);}catch{i("Failed to load document");}finally{h(false);}},he=async()=>{try{h(!0);let j=await Be(`/api/globals/${ae}`,{autoToast:!1}),W=j.data||{};f(W),g(W),I(j.createdAt||null),R(j.updatedAt||null);}catch{i("Failed to load global");}finally{h(false);}},Ae=oa.useCallback(async(j=false)=>{try{x("saving");let W=l==="global"?`/api/globals/${ae}`:`/api/${ae}/${o}`,de=N==="draft"||p?.status==="draft",Ie=await er(W,p,{autoToast:!1,headers:{"X-Draft":String(de)}}),Ue=Ie&&(Ie.data||Ie)||p;j||(g(Ue),n()),f(Ue),O(Ue?.status||N),x("saved"),R(new Date().toISOString()),ne(!0),setTimeout(()=>ne(!1),3e3),j||(N==="draft"||Ue?.status==="draft"?U.warning(d("toast.draftSaved",{defaultValue:"Draft saved"})):U.success(d("toast.updated",{defaultValue:"Updated"}))),setTimeout(()=>{x("idle");},2e3),ee&&vt(Ue);}catch{x("error"),j||(i(d("toast.saveError",{defaultValue:"Failed to save changes"})),U.error(d("toast.saveError",{defaultValue:"Failed to save changes"})));}finally{w(false);}},[p,l,ae,o,N,n,i]),T=async()=>{try{w(!0),await er(`/api/${ae}/${o}`,p,{autoToast:!1,headers:{"X-Draft":"false"}}),O("published"),L(new Date().toISOString()),U.success(d("toast.published",{defaultValue:"Published successfully"})),n();}catch{i(d("toast.publishError",{defaultValue:"Failed to publish"})),U.error(d("toast.publishError",{defaultValue:"Failed to publish"}));}finally{w(false);}},_=async()=>{try{w(!0),await er(`/api/${ae}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),O("draft"),U.warning(d("toast.unpublished",{defaultValue:"Document unpublished"})),n();}catch{i(d("toast.unpublishError",{defaultValue:"Failed to unpublish"})),U.error(d("toast.unpublishError",{defaultValue:"Failed to unpublish"}));}finally{w(false);}},Ne=async()=>{try{E(!0);let j=await ut(`/api/${ae}/${o}/duplicate`,void 0,{autoToast:!1});U.success(d("toast.duplicated",{defaultValue:"Document duplicated"})),j?.data?.id?window.location.href=`${He}/${ae}/${j.data.id}`:window.location.href=`${He}/${ae}`;}catch(j){U.error(j.message||d("toast.duplicateError",{defaultValue:"Failed to duplicate document"}));}finally{E(false);}},Oe=async()=>{try{let j={...p};delete j.id,delete j.createdAt,delete j.updatedAt,delete j.status,await navigator.clipboard.writeText(JSON.stringify(j)),U.success(d("toast.dataCopied",{defaultValue:"Document data copied to clipboard"}));}catch{U.error(d("toast.copyError",{defaultValue:"Failed to copy document data"}));}},Me=async()=>{try{let j=await navigator.clipboard.readText(),W=JSON.parse(j);if(typeof W!="object"||W===null)throw new Error("Invalid format");f(de=>({...de,...W,id:de.id,createdAt:de.createdAt,updatedAt:de.updatedAt,status:de.status})),U.success(d("toast.dataPasted",{defaultValue:"Document data pasted"}));}catch{U.error(d("toast.pasteError",{defaultValue:"Clipboard does not contain valid document JSON"}));}},Fe=()=>{c({title:d("detailView.deleteTitle",{defaultValue:"Delete {{label}}?",label:q}),message:d("detailView.deleteMessage",{defaultValue:"This action cannot be undone."}),variant:"danger",onConfirm:async()=>{try{k(!0),await Dt(`/api/${ae}/${o}`),window.location.href=`${He}/${ae}`;}catch{k(false);}}});},vt=async(j=p)=>{try{let W=l==="global"?`/api/globals/${ae}/preview-url`:`/api/${ae}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",W,"with data keys:",Object.keys(j||{}),"documentId:",o);let de=await ut(W,{...j,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(de)),de&&de.url?(console.log("[Kyro Preview] Setting previewUrl:",de.url),be(de.url)):console.warn("[Kyro Preview] No url in response:",de);}catch(W){console.error("[Kyro Preview] Error:",W.message,W),U.error(W.message||"Failed to generate preview URL");}};oa.useEffect(()=>{ee&&vt(p);},[ee]);let Yt=()=>{let j=!ee;H(j),j&&vt(p);};if(v)return jsxRuntime.jsx("div",{className:"kyro-detail",children:jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Kt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Kt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Kt,{variant:"rect",count:4})})]})});let X=l==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Vt,{back:{onClick:a},breadcrumbs:[{label:l==="global"?d("detailView.globals",{defaultValue:"Globals"}):d("detailView.collections",{defaultValue:"Collections"})},{label:q,href:l==="collection"?`${He}/${ae}`:void 0},{label:l==="global"?d("actions.edit",{defaultValue:"Edit"}):o?d("actions.edit",{defaultValue:"Edit"}):d("actions.new",{defaultValue:"New"})}],title:l==="global"?q:Fo(t?.fields,p,t?.admin?.useAsTitle||"title")||p.name||o||d("detailView.newDocument",{defaultValue:"New {{label}}",label:t?.singularLabel||q}),metadata:[jsxRuntime.jsx(Lt,{variant:N==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:d(`status.${N}`,{defaultValue:N})},"status")]}),jsxRuntime.jsx(xl,{status:N,saveStatus:b,hasChanges:K,onSave:()=>Ae(false),onPublish:T,onUnpublish:N==="published"?_:void 0,onDuplicate:Ne,onCopyData:Oe,onPasteData:Me,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:t?.admin?.disablePreview||r?.admin?.disablePreview?void 0:Yt,onDelete:Fe,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:fe,updatedAt:P}),jsxRuntime.jsxs("div",{className:ee?"w-full mx-auto grid grid-cols-1 lg:grid-cols-2 gap-4 md:gap-8 pt-4 md:pt-0 h-[calc(100vh-140px)]":X?"w-full pt-4 md:pt-8":"w-full mx-auto grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-4 md:gap-8 pt-4 md:pt-0",children:[jsxRuntime.jsx("div",{className:`space-y-4 md:space-y-8 min-w-0 ${ee?"overflow-y-auto pr-2 pb-20":""}`,children:jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsxRuntime.jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:d("detailView.coreConfiguration",{defaultValue:"Core Configuration"})}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(bn,{config:t?{...t,fields:V}:{slug:"unknown",fields:V},data:p,onChange:f,layout:X?"single":"split",globalSlug:l==="global"?ae:void 0,collectionSlug:l==="collection"?ae:void 0,onActionSuccess:j=>U.success(j),onActionError:j=>U.error(j),documentStatus:N,justSaved:re}),X&&jsxRuntime.jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[l==="collection"&&o&&jsxRuntime.jsx("button",{type:"button",onClick:Fe,disabled:D||m,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:D?d("actions.deleting",{defaultValue:"Deleting..."}):d("actions.deleteDocument",{defaultValue:"Delete Document"})}),jsxRuntime.jsx(Uo,{status:N,saveStatus:m?"saving":"idle",hasChanges:K,onPublish:()=>Ae(false),disabled:m})]})]})}),ee&&jsxRuntime.jsxs("div",{className:"surface-tile flex flex-col overflow-hidden h-full border border-[var(--kyro-border)] rounded-xl animate-in fade-in slide-in-from-right-4 duration-500 shadow-xl bg-white dark:bg-black",children:[jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface-accent)] border-b border-[var(--kyro-border)] p-2 flex items-center justify-between shrink-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-2",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-red-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-green-400/80"})]}),jsxRuntime.jsx("div",{className:"text-[10px] font-mono opacity-50 truncate max-w-[60%] bg-[var(--kyro-bg)] px-3 py-1 rounded",children:pe||d("detailView.generatingPreview",{defaultValue:"Generating preview URL..."})}),jsxRuntime.jsx("div",{className:"w-16"})]}),jsxRuntime.jsx("div",{className:"flex-1 bg-white relative",children:pe?jsxRuntime.jsx("iframe",{src:pe,className:"w-full h-full border-0 bg-white",title:d("tooltips.preview",{defaultValue:"Preview"}),sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"}):jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx(ir,{className:"w-6 h-6 text-[var(--kyro-primary)]"})})})]}),!X&&!ee&&jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4 md:mb-6",children:d("detailView.metadata",{defaultValue:"Metadata"})}),jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dynamicStatus",{defaultValue:"Dynamic Status"})}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-[9px] font-bold tracking-widest ${N==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:N||"draft"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dateCreated",{defaultValue:"Date Created"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:M?new Date(M).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("common.na",{defaultValue:"N/A"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.lastModified",{defaultValue:"Last Modified"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:P?new Date(P).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("detailView.justNow",{defaultValue:"Just now"})})]}),fe&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.publicAt",{defaultValue:"Public At"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(fe).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})})]})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8 bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-3 md:mb-4",children:d("detailView.quickLinks",{defaultValue:"Quick Links"})}),jsxRuntime.jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:Ne,disabled:C||m,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:C?d("actions.duplicating",{defaultValue:"Duplicating..."}):d("actions.duplicateDocument",{defaultValue:"Duplicate Document"})}),pe&&jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(pe,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:d("detailView.openPreview",{defaultValue:"Open Preview in New Tab"})}),jsxRuntime.jsx("button",{type:"button",onClick:Fe,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:d("actions.deleteEntry",{defaultValue:"Delete Entry"})})]})]})]})]})]})}function wl({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=oa.useState({}),[i,l]=oa.useState(false),d=t.fields||[],c=t.label||t.slug,u=async p=>{try{l(!0),await ut(`/api/${t.slug}`,n),U.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(f){a(f instanceof Error?f.message:"Failed to create");}finally{l(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Vt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${He}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:i?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>u(),disabled:i}}),jsxRuntime.jsx("div",{className:"kyro-detail-body",children:jsxRuntime.jsx("div",{className:"kyro-card",children:jsxRuntime.jsx("div",{className:"kyro-card-content",children:jsxRuntime.jsx("form",{children:jsxRuntime.jsx(bn,{config:{...t,fields:d},data:n,onChange:s})})})})})]})}function Hu({type:e,message:t,onClose:r}){let[o,a]=oa__default.default.useState(false),n=oa__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},i=()=>{n.current&&clearTimeout(n.current);};oa__default.default.useEffect(()=>(o?i():s(),i),[o,r]);let l={success:Nc.CircleCheck,error:Nc.ShieldAlert,warning:Nc.TriangleAlert,info:Nc.Info}[e];return jsxRuntime.jsxs("div",{className:`kyro-toast kyro-toast-${e} group animate-in fade-in slide-in-from-right-4 duration-300`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),children:[jsxRuntime.jsx("div",{className:"kyro-toast-accent"}),jsxRuntime.jsx("div",{className:"kyro-toast-icon-container",children:jsxRuntime.jsx(l,{className:"w-4 h-4"})}),jsxRuntime.jsx("div",{className:"kyro-toast-content",children:jsxRuntime.jsx("p",{className:"kyro-toast-message",children:t})}),jsxRuntime.jsx("button",{type:"button",className:"kyro-toast-close group-hover:opacity-100 opacity-40 transition-opacity",onClick:r,children:jsxRuntime.jsx(Nc.X,{className:"w-3.5 h-3.5"})})]})}function sL({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function iL(){let e=Zt(o=>o.addToast),t=Zt(o=>o.removeToast);return {toasts:Zt(o=>o.toasts),addToast:e,removeToast:t}}function Gs(){let e=Zt(r=>r.toasts),t=Zt(r=>r.removeToast);return jsxRuntime.jsx("div",{className:"kyro-toasts-container",style:{position:"fixed",bottom:"24px",right:"24px",display:"flex",flexDirection:"column",gap:"12px",zIndex:1e5,pointerEvents:"none"},children:e.map(r=>jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:jsxRuntime.jsx(Hu,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Sl({onAuth:e,theme:t="light"}){let{t:r}=z(),[o,a]=oa.useState("login"),[n,s]=oa.useState(""),[i,l]=oa.useState(""),[d,c]=oa.useState(""),[u,p]=oa.useState(false),[f,y]=oa.useState(false),g=Zt(m=>m.addToast);oa.useEffect(()=>{v();},[]);let v=async()=>{try{await Be("/api/users");}catch{y(true),a("register");}},h=async m=>{m.preventDefault(),p(true);try{let w=o==="login"?"/api/auth/login":"/api/auth/register",C={email:n,password:i};o==="register"&&(C.confirmPassword=d);let E=await ut(w,C);E.isFirstUser&&y(!0),localStorage.setItem("kyro_user",JSON.stringify(E.user)),g("success",o==="login"?r("toast.welcomeBack",{defaultValue:"Welcome back!"}):r("toast.accountCreated",{defaultValue:"Account created!"})),e(E.token,E.user);}catch{g("error",r("toast.connectionFailed",{defaultValue:"Connection failed"}));}finally{p(false);}};return jsxRuntime.jsx(Fr,{defaultMode:t,children:jsxRuntime.jsxs("div",{className:"kyro-login-page",children:[jsxRuntime.jsxs("div",{className:"kyro-login-container",children:[jsxRuntime.jsxs("div",{className:"kyro-login-header",children:[jsxRuntime.jsx("h1",{className:"kyro-login-title",children:f?r("login.createAdminAccount",{defaultValue:"Create Admin Account"}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:f?r("login.setupAdmin",{defaultValue:"Set up your admin account to get started"}):o==="login"?r("login.enterCredentials",{defaultValue:"Enter your credentials to access the admin"}):r("login.createAccountDesc",{defaultValue:"Create an account to access the admin"})})]}),jsxRuntime.jsxs("form",{onSubmit:h,className:"kyro-login-form",children:[jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"email",children:r("login.email",{defaultValue:"Email"})}),jsxRuntime.jsx("input",{id:"email",type:"email",value:n,onChange:m=>s(m.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:r("login.password",{defaultValue:"Password"})}),jsxRuntime.jsx("input",{id:"password",type:"password",value:i,onChange:m=>l(m.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:o==="login"?"current-password":"new-password"})]}),o==="register"&&jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"confirmPassword",children:r("login.confirmPassword",{defaultValue:"Confirm Password"})}),jsxRuntime.jsx("input",{id:"confirmPassword",type:"password",value:d,onChange:m=>c(m.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsxRuntime.jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:u,children:u?o==="login"?r("login.signingIn",{defaultValue:"Signing in..."}):r("login.creatingAccount",{defaultValue:"Creating account..."}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})})]}),!f&&jsxRuntime.jsx("div",{className:"kyro-login-footer",children:jsxRuntime.jsx("p",{children:o==="login"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("login.noAccount",{defaultValue:"Don't have an account?"})," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("register"),children:r("login.signUp",{defaultValue:"Sign up"})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("login.hasAccount",{defaultValue:"Already have an account?"})," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("login"),children:r("login.signInAction",{defaultValue:"Sign in"})})]})})})]}),jsxRuntime.jsx(Gs,{})]})})}function Gu({collections:e,onNavigate:t,user:r}){let{t:o}=z(),{permissions:a}=Yr(),[n,s]=oa.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[i,l]=oa.useState(true);oa.useEffect(()=>{let c=setTimeout(()=>{s({totalDocs:124,totalMedia:856,totalUsers:12,recentActivity:[{id:1,type:"edit",user:"Daniel Dozie",doc:"Getting Started with Kyro",collection:"posts",time:"2m ago"},{id:2,type:"create",user:"Jane Smith",doc:"New Product Launch",collection:"products",time:"15m ago"},{id:3,type:"upload",user:"Daniel Dozie",doc:"hero-banner.jpg",collection:"media",time:"1h ago"},{id:4,type:"publish",user:"System",doc:"Weekly Update",collection:"posts",time:"3h ago"}]}),l(false);},800);return ()=>clearTimeout(c)},[]);let d=Object.entries(e).filter(([c])=>!Wi.includes(c)&&a?.collections?.[c]?.read!==false);return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsxRuntime.jsx(Vt,{title:o("dashboard.welcome",{defaultValue:"Welcome back, {{name}}",name:r?.email?.split("@")[0]||"Admin"}),description:o("dashboard.description",{defaultValue:"Everything looks great in your command center today."}),action:d.length>0&&a?.collections?.[d[0]?.[0]]?.create!==false?{label:o("actions.newDocument",{defaultValue:"New Document"}),onClick:()=>t("create",d[0]?.[0]),icon:Nc.Plus}:void 0}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:o("dashboard.totalContent",{defaultValue:"Total Content"}),value:n.totalDocs,icon:Nc.FileText,color:"text-blue-500"},{label:o("dashboard.mediaAssets",{defaultValue:"Media Assets"}),value:n.totalMedia,icon:Nc.Image,color:"text-purple-500"},{label:o("dashboard.activeUsers",{defaultValue:"Active Users"}),value:n.totalUsers,icon:Nc.Users,color:"text-green-500"},{label:o("dashboard.systemHealth",{defaultValue:"System Health"}),value:"100%",icon:Nc.Activity,color:"text-amber-500"}].map((c,u)=>jsxRuntime.jsxs("div",{className:"surface-tile p-6 flex items-center justify-between group hover:border-[var(--kyro-primary)] transition-all duration-500 cursor-default",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:c.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:i?jsxRuntime.jsx(Kt,{variant:"text",className:"w-16"}):c.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${c.color}`,children:jsxRuntime.jsx(c.icon,{className:"w-6 h-6"})})]},u))}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxRuntime.jsxs("div",{className:"space-y-8 min-w-0",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Nc.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),o("dashboard.contentGrowth",{defaultValue:"Content Growth"})]}),jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:o("dashboard.contentGrowthDesc",{defaultValue:"Snapshot of document velocity over the last 7 days"})}),jsxRuntime.jsxs("div",{className:"h-48 w-full relative mb-12",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1000 200",preserveAspectRatio:"none",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"chartGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"var(--kyro-primary)",stopOpacity:"0.3"}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"var(--kyro-primary)",stopOpacity:"0"})]})}),jsxRuntime.jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60 L1000,200 L0,200 Z",fill:"url(#chartGradient)",className:"animate-pulse duration-[4s]"}),jsxRuntime.jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60",fill:"none",stroke:"var(--kyro-primary)",strokeWidth:"4",strokeLinecap:"round",vectorEffect:"non-scaling-stroke",className:"filter drop-shadow-[0_0_8px_var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-4 text-[10px] font-bold opacity-30 tracking-widest ",children:[jsxRuntime.jsx("span",{children:o("days.mon",{defaultValue:"Mon"})}),jsxRuntime.jsx("span",{children:o("days.tue",{defaultValue:"Tue"})}),jsxRuntime.jsx("span",{children:o("days.wed",{defaultValue:"Wed"})}),jsxRuntime.jsx("span",{children:o("days.thu",{defaultValue:"Thu"})}),jsxRuntime.jsx("span",{children:o("days.fri",{defaultValue:"Fri"})}),jsxRuntime.jsx("span",{children:o("days.sat",{defaultValue:"Sat"})}),jsxRuntime.jsx("span",{children:o("days.sun",{defaultValue:"Sun"})})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:d.map(([c,u])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",c),className:"p-6 rounded-2xl border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-bg-secondary)] hover:bg-[var(--kyro-surface)] transition-all cursor-pointer group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:u.label||c}),jsxRuntime.jsx(Nc.ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsxRuntime.jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:u.admin?.description||`Manage ${c} content.`})]},c))})]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-4",children:jsxRuntime.jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-5 h-5"}),o("dashboard.quickLinks",{defaultValue:"Quick Links"})]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[d.filter(([c])=>a?.collections?.[c]?.create!==false).map(([c])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",c),className:"w-full flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group/btn",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:o("dashboard.newAction",{defaultValue:"New {{item}}",item:e[c]?.singularLabel||e[c]?.label||c})}),jsxRuntime.jsx(Nc.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},c)),d.every(([c])=>a?.collections?.[c]?.create===false)&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:o("dashboard.noCollections",{defaultValue:"No collections available for creation."})})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-8 bg-[#0f172a] text-white border-none shadow-2xl shadow-blue-500/10 overflow-hidden relative group cursor-pointer",children:[jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("h3",{className:"text-2xl font-bold tracking-tighter mb-2",children:o("dashboard.mediaLibrary",{defaultValue:"Media Library"})}),jsxRuntime.jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:o("dashboard.mediaLibraryDesc",{defaultValue:"Manage high-fidelity assets with our liquid masonry gallery."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-bold text-xs tracking-widest text-blue-400",children:[o("dashboard.openAssets",{defaultValue:"Open Assets"})," ",jsxRuntime.jsx(Nc.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(Nc.Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Nc.Clock,{className:"w-5 h-5 opacity-40"}),o("dashboard.recentActivity",{defaultValue:"Recent Activity"})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:n.recentActivity.map(c=>jsxRuntime.jsxs("div",{className:"flex gap-4 group",children:[jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-bg-secondary)] flex items-center justify-center border border-[var(--kyro-border)] group-hover:bg-[var(--kyro-primary)] transition-colors",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold",children:c.user[0]})})}),jsxRuntime.jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxRuntime.jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsxRuntime.jsx("span",{className:"font-bold",children:c.user})," ",c.type==="create"?"created":c.type==="edit"?"edited":c.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',c.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:c.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:c.time})]})]},c.id))}),jsxRuntime.jsx("button",{type:"button",className:"w-full mt-6 py-3 text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors border-t border-[var(--kyro-border)] pt-6",children:o("dashboard.viewAuditLogs",{defaultValue:"View Audit Logs"})})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Nc.Activity,{className:"w-5 h-5 opacity-40"}),o("dashboard.systemStatus",{defaultValue:"System Status"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:[{label:o("dashboard.cloudApi",{defaultValue:"Cloud API"}),status:o("dashboard.statusOptimal",{defaultValue:"Optimal"}),pulse:"bg-green-500"},{label:o("dashboard.dbNode",{defaultValue:"Database Node"}),status:o("dashboard.statusHealthy",{defaultValue:"Healthy"}),pulse:"bg-green-500"},{label:o("dashboard.mediaCdn",{defaultValue:"Media CDN"}),status:o("dashboard.statusActive",{defaultValue:"Active"}),pulse:"bg-blue-500"},{label:o("dashboard.authService",{defaultValue:"Auth Service"}),status:o("dashboard.statusSecure",{defaultValue:"Secure"}),pulse:"bg-green-500"}].map((c,u)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:c.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:c.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${c.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},u))})]})]})]})]})}function qu(){let{t:e}=z(),[t,r]=oa.useState([]),[o,a]=oa.useState(true),[n,s]=oa.useState(""),[i,l]=oa.useState(false),[d,c]=oa.useState({name:"",email:"",password:"",role:"customer"}),[u,p]=oa.useState(""),[f,y]=oa.useState(false),{confirm:g,alert:v}=gt();oa.useEffect(()=>{h();},[]);let h=async()=>{try{a(!0);let k=await Be("/api/users");r(k.docs||[]);}catch(k){console.error("Failed to load users:",k);}finally{a(false);}},m=k=>{let b=!k.locked;g({title:b?"Lock User Account?":"Unlock User Account?",message:b?`Are you sure you want to lock ${k.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${k.email}?`,variant:b?"danger":"success",onConfirm:async()=>{try{await er(`/api/users/${k.id}`,{locked:b}),r(x=>x.map(N=>N.id===k.id?{...N,locked:b}:N)),U.success(b?`Account locked: ${k.email}`:`Account restored: ${k.email}`);}catch(x){console.error("Failed to toggle user lock:",x),U.error("Failed to update account status");}}});},w=k=>{g({title:"Destroy User Account",message:`You are about to permanently delete ${k.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await Dt(`/api/users/${k.id}`),r(b=>b.filter(x=>x.id!==k.id)),U.success(`Identity purged: ${k.email}`);}catch(b){console.error("Failed to delete user:",b),U.error("Failed to delete user");}}});},C=async()=>{if(!d.email.trim()||!d.password.trim()){p("Email and password are required");return}y(true),p("");try{await ut("/api/users",{name:d.name.trim()||void 0,email:d.email.trim(),password:d.password,role:d.role}),l(!1),c({name:"",email:"",password:"",role:"customer"}),U.success("User created successfully"),h();}catch(k){let b=k instanceof Error?k.message:"Failed to create user";p(b),U.error(b);}finally{y(false);}},E=["super_admin","admin","editor","author","customer","guest"],D=t.filter(k=>k.email.toLowerCase().includes(n.toLowerCase())||k.name?.toLowerCase().includes(n.toLowerCase()));return jsxRuntime.jsxs("div",{className:"w-full space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-700 px-4 md:px-8 pb-12",children:[jsxRuntime.jsx(Vt,{title:e("tooltips.identityAccess",{defaultValue:"Identity & Access"}),description:"Manage the core administrative team and security permissions.",icon:Nc.Users,action:{label:"New User",onClick:()=>{c({name:"",email:"",password:"",role:"customer"}),p(""),l(true);},icon:Nc.UserPlus}}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 group",children:[jsxRuntime.jsx(Nc.Search,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-secondary)] opacity-40 group-focus-within:opacity-100 transition-opacity"}),jsxRuntime.jsx("input",{type:"text",placeholder:e("fields.searchByIdentityOr",{defaultValue:"Search by identity or email..."}),value:n,onChange:k=>s(k.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest bg-[var(--kyro-surface)] shadow-sm rounded-lg border border-[var(--kyro-border)]",children:"ALL"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"ADMINS"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"LOCKED"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[9px] tracking-[0.2em] uppercase border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-64",children:"Member Identity"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Administrative Role"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Security Status"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Last Activity"}),jsxRuntime.jsx("th",{className:"px-6 py-4 w-32 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:o?Array.from({length:6}).map((k,b)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},b)):D.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-20 text-center",children:jsxRuntime.jsx("p",{className:"text-xs font-bold opacity-30 tracking-widest uppercase italic",children:"No identity matches found"})})}):D.map(k=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${k.locked?"opacity-50 grayscale":""}`,children:[jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(pv,{user:k}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs font-bold text-[var(--kyro-text-primary)] truncate",children:k.name||k.email.split("@")[0]}),k.tenantId&&jsxRuntime.jsx(Lt,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:k.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:k.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Nc.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:k.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(Lt,{variant:k.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:k.locked?"Restricted":"Authorized"})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsxRuntime.jsx(Nc.Clock,{className:"w-3 h-3"}),k.lastLogin?new Date(k.lastLogin).toLocaleDateString():"Never"]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsxRuntime.jsx("button",{onClick:()=>m(k),className:`p-1.5 rounded-lg border transition-all ${k.locked?"bg-green-500/10 text-green-500 border-green-500/20 hover:bg-green-500/20":"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20"}`,title:k.locked?"Restore Access":"Restrict Access",children:k.locked?jsxRuntime.jsx(Nc.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Nc.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>w(k),className:"p-1.5 rounded-lg border border-red-500/20 bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-all",title:e("tooltips.deleteUser",{defaultValue:"Delete User"}),children:jsxRuntime.jsx(Nc.Trash2,{className:"w-3.5 h-3.5"})})]})})]},k.id))})]})}),jsxRuntime.jsxs(Tt,{open:i,onClose:()=>l(false),title:e("tooltips.createUser",{defaultValue:"Create User"}),size:"lg",children:[jsxRuntime.jsx(Rr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Name (optional)"}),jsxRuntime.jsx("input",{type:"text",value:d.name,onChange:k=>c({...d,name:k.target.value}),placeholder:e("fields.johnDoe",{defaultValue:"John Doe"}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Email Address"}),jsxRuntime.jsx("input",{type:"email",value:d.email,onChange:k=>c({...d,email:k.target.value}),placeholder:"user@example.com",required:true,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Password"}),jsxRuntime.jsx("input",{type:"password",value:d.password,onChange:k=>c({...d,password:k.target.value}),placeholder:e("fields.minimum12Characters",{defaultValue:"Minimum 12 characters"}),required:true,minLength:12,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Role"}),jsxRuntime.jsx("select",{value:d.role,onChange:k=>c({...d,role:k.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]",children:E.map(k=>jsxRuntime.jsx("option",{value:k,children:k},k))})]}),u&&jsxRuntime.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl flex items-center gap-2 text-red-500 text-xs font-bold",children:[jsxRuntime.jsx(Nc.TriangleAlert,{className:"w-4 h-4"}),u]})]})}),jsxRuntime.jsxs(zr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>l(false),className:"px-6 py-2.5 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:C,disabled:f,className:"kyro-btn kyro-btn-primary px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/10 disabled:opacity-50",children:f?"Creating...":"Create User"})]})]})]})}function pv({user:e}){let[t,r]=oa.useState(null);return oa.useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Be(`/api/media/${o}`).then(a=>r(a?.thumbnailUrl||a?.url||null)).catch(()=>r(null));},[e.avatar]),t?jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border border-[var(--kyro-border)] flex-shrink-0",children:jsxRuntime.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"})}):jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] flex items-center justify-center text-xs font-bold text-[var(--kyro-primary)] flex-shrink-0",children:e.name?e.name[0]:e.email[0].toUpperCase()})}function Ju(){let{t:e}=z(),[t,r]=oa.useState("Kyro CMS"),[o,a]=oa.useState("Command Center"),[n,s]=oa.useState("#6366f1"),[i,l]=oa.useState("Welcome back to your Command Center."),[d,c]=oa.useState(false),[u,p]=oa.useState(false);oa.useEffect(()=>{(async()=>{try{let v=await Be("/api/globals/site-settings"),h=v.data||v;h&&Object.keys(h).length>0&&(h.siteName&&r(h.siteName),h.adminTitle&&a(h.adminTitle),h.primaryColor&&s(h.primaryColor),h.dashboardGreeting&&l(h.dashboardGreeting));}catch(v){console.error("Failed to load branding:",v);}})();},[]);let f=async()=>{c(true);try{await er("/api/globals/site-settings",{siteName:t,adminTitle:o,primaryColor:n,dashboardGreeting:i}),p(!0),U.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",n),setTimeout(()=>window.location.reload(),800);}catch(g){U.error("Failed to save branding"),console.error(g);}finally{c(false);}},y=[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}];return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 pt-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:["Branding ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Hub"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-1 font-medium opacity-60",children:"Customize the identity and aesthetic of your administrative ecosystem."})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:jsxRuntime.jsxs("button",{type:"button",onClick:f,disabled:d,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${u?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[d?jsxRuntime.jsx(Nc.RefreshCcw,{className:"w-4 h-4 animate-spin"}):u?jsxRuntime.jsx(Nc.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(Nc.Save,{className:"w-4 h-4"}),d?"Saving...":u?"Identity Updated":"Publish Branding"]})})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Nc.Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:g=>r(g.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Acme Corp CMS"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Admin Dashboard Title"}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:g=>a(g.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Command Center"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"System Greeting"}),jsxRuntime.jsx("textarea",{value:i,onChange:g=>l(g.target.value),rows:3,className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all resize-none",placeholder:e("fields.greetingTextForThe",{defaultValue:"Greeting text for the dashboard..."})})]})]})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Nc.Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsxRuntime.jsx("div",{className:"grid grid-cols-6 gap-3",children:y.map(g=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(g.hex),className:`aspect-square rounded-xl transition-all border-4 ${n===g.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:g.hex},title:g.name},g.name))})]}),jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.jsxs("div",{className:"w-20 h-20 rounded-2xl bg-[var(--kyro-bg-secondary)] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-primary)] hover:text-[var(--kyro-primary)] cursor-pointer transition-all",children:[jsxRuntime.jsx(Nc.Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsxRuntime.jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsxRuntime.jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsxRuntime.jsx(Nc.Sparkles,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxRuntime.jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-2 bg-[var(--kyro-bg-secondary)] rounded-full border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[o," Online"]})]}),jsxRuntime.jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",t,"."]}),jsxRuntime.jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:i})]}),jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:`
100
100
  :root {
101
101
  --kyro-primary-temp: ${n};
102
102
  }
103
103
  .preview-btn {
104
104
  background-color: var(--kyro-primary-temp);
105
105
  }
106
- `}})]})]})]})}var Ff=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Ac({collections:e}){let{t}=reactI18next.useTranslation(),[r,o]=Ta.useState([]),[a,n]=Ta.useState(false),[s,i]=Ta.useState(null),[l,d]=Ta.useState(""),[c,u]=Ta.useState(null),[m,v]=Ta.useState(false),{confirm:x,alert:g}=yt(),[f,b]=Ta.useState(false),[p,h]=Ta.useState(""),A=async()=>{try{let w=await Ee("/api/keys");o(w);}catch(w){console.error(w);}};Ta.useEffect(()=>{A();},[]);let $=async()=>{h(""),b(true);},T=async()=>{if(p.trim())try{await dt("/api/keys",{name:p}),A(),b(!1),h(""),V.success("API key generated");}catch(w){console.error(w),V.error("Failed to generate API key");}},k=w=>{x({title:"Revoke API Key",message:"Are you sure you want to revoke this key? Any integrations using it will stop working.",variant:"danger",onConfirm:async()=>{try{await At(`/api/keys/${w}`),A(),V.success("API key revoked");}catch(D){console.error(D),V.error("Failed to revoke API key");}}});},y=async()=>{if(l){v(true);try{let D=await(await fetch(qe(`/api/${l}`))).json();u(D);}catch{u({error:"Failed to fetch. Ensure the endpoint exists."});}finally{v(false);}}};return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Lt,{title:t("tooltips.developerCenter",{defaultValue:"Developer Center"}),description:"Provision access keys and explore the headless API ecosystem.",icon:Ql.CodeXml,actions:[{label:"Generate Key",onClick:$,icon:Ql.Key}]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxRuntime.jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:r.length===0?jsxRuntime.jsxs("div",{className:"p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx(Ql.Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):r.map(w=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-3xl p-6 hover:border-[var(--kyro-primary)]/50 transition-all duration-300",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsxRuntime.jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsxRuntime.jsx(Ql.Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:w.name})]}),jsxRuntime.jsxs("div",{className:"flex-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl px-4 py-3 flex items-center justify-between group/key overflow-hidden",children:[jsxRuntime.jsx("code",{className:"text-xs font-mono opacity-80 truncate mr-4",children:s===w.id?w.key:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(s===w.id?null:w.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:s===w.id?jsxRuntime.jsx(Ql.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",onClick:()=>{navigator.clipboard.writeText(w.key),V.success("API key copied to clipboard");},children:jsxRuntime.jsx(Ql.Copy,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Issued:"}),jsxRuntime.jsx("span",{children:new Date(w.createdAt).toLocaleDateString()})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Status:"}),jsxRuntime.jsx("span",{className:"text-green-500",children:"Active"})]})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>k(w.id),className:"p-3.5 bg-red-500/5 text-red-500 rounded-2xl hover:bg-red-500/10 transition-all border border-transparent hover:border-red-500/30 self-start md:self-center",title:t("tooltips.revokeKey",{defaultValue:"Revoke Key"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-5 h-5"})})]})},w.id))})]}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/80 p-8 group shadow-2xl shadow-[var(--kyro-primary)]/20",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.1] pointer-events-none group-hover:scale-110 transition-transform duration-700",children:jsxRuntime.jsx(Ql.Terminal,{className:"w-48 h-48 rotate-12"})}),jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsxRuntime.jsx(Ql.Terminal,{className:"w-6 h-6 text-white"})}),jsxRuntime.jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsxRuntime.jsx("p",{className:"text-white/80 text-sm font-medium leading-relaxed mb-8",children:"Kyro CMS is built for high-performance content delivery. Use these endpoints to power your headless frontends."}),jsxRuntime.jsxs("button",{type:"button",className:"w-full py-4 bg-white text-[var(--kyro-primary)] rounded-[1.2rem] font-bold text-xs uppercase tracking-widest hover:shadow-xl transition-all flex items-center justify-center gap-2 active:scale-[0.98]",children:["Full API Documentation",jsxRuntime.jsx(Ql.ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxRuntime.jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-[var(--kyro-primary)]/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://api.kyro.io/v1")})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-amber-500/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://preview.kyro.io/v1")})]})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"xl:col-span-3 rounded-[3rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-10 space-y-10 overflow-hidden relative",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsxRuntime.jsx(Ql.CirclePlay,{className:"w-96 h-96"})}),jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxRuntime.jsxs("div",{className:"max-w-xl",children:[jsxRuntime.jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Ql.CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] text-sm font-medium opacity-60 leading-relaxed",children:"Test your collection endpoints and analyze live response payloads. Enter a collection slug to fetch its latest documents."})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 flex-1 lg:max-w-2xl bg-[var(--kyro-bg)] p-2 rounded-[2rem] border border-[var(--kyro-border)] shadow-2xl",children:[jsxRuntime.jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",Ff,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:w=>d(w.target.value),placeholder:"collection-slug",className:"w-full py-4 bg-transparent focus:outline-none font-mono text-sm font-bold text-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:y,disabled:m||!l,className:"kyro-btn kyro-btn-primary px-8 py-4 rounded-[1.5rem] font-bold text-sm shadow-xl disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] transition-all flex items-center gap-3 shrink-0",children:[m?jsxRuntime.jsx(Ql.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(Ql.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),c?jsxRuntime.jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px] font-mono px-3",children:"200 OK"})]}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden border border-[var(--kyro-border)] shadow-2xl bg-[#090b10]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-6 py-4 bg-[#11141d] border-b border-[var(--kyro-border)]/50",children:[jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/20"})]}),jsxRuntime.jsx(Af__default.default,{value:JSON.stringify(c,null,2),height:"450px",theme:codemirrorThemeAura.aura,extensions:[langJson.json()],editable:false,className:"text-sm"})]})]}):jsxRuntime.jsxs("div",{className:"h-80 rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center bg-[var(--kyro-surface-accent)]/20 transition-all duration-700",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 bg-[var(--kyro-surface)] rounded-3xl flex items-center justify-center shadow-lg border border-[var(--kyro-border)] mb-6 opacity-20",children:jsxRuntime.jsx(Ql.CodeXml,{className:"w-10 h-10"})}),jsxRuntime.jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxRuntime.jsxs(St,{open:f,onClose:()=>b(false),title:t("tooltips.generateAccessToken",{defaultValue:"Generate Access Token"}),size:"lg",children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 leading-relaxed",children:"Define a name for this API key to identify its integration context. Keys are encrypted at rest and should be treated with extreme caution."}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsxRuntime.jsx("input",{type:"text",value:p,onChange:w=>h(w.target.value),placeholder:"e.g., Mobile App SDK, Production Server",className:"w-full px-6 py-4 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)] shadow-sm transition-all",onKeyDown:w=>w.key==="Enter"&&T()})]})]})}),jsxRuntime.jsxs(Mr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>b(false),className:"px-6 py-3 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"kyro-btn kyro-btn-primary px-8 py-3 rounded-xl font-bold text-sm hover:opacity-90 shadow-lg shadow-[var(--kyro-primary)]/20 transition-all",children:"Generate Token"})]})]})]})}function Dc(e){let[t,r]=Ta.useState([]),[o,a]=Ta.useState(false),[n,s]=Ta.useState(null),[i,l]=Ta.useState(false),{confirm:d}=yt(),c=Ta.useCallback(async()=>{a(true),s(null);try{let x=await Ee(e.endpoint),g=Array.isArray(x)?x:x.docs||[],f=e.transformLoad?e.transformLoad(g):g;r(f),e.onSuccess?.("load",f);}catch(x){let g=x instanceof Error?x.message:"Failed to load resources";s(g),e.onError?.("load",x);}finally{a(false);}},[e.endpoint,e.transformLoad]);Ta.useEffect(()=>{c();},[c]);let u=Ta.useCallback((x,g="item")=>{d({title:`Delete ${g}`,message:`Are you sure you want to delete this ${g.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await At(`${e.endpoint}/${x}`),r(f=>f.filter(b=>b.id!==x)),e.onSuccess?.("delete",x),V.success(`${g} deleted`);}catch(f){let b=f instanceof Error?f.message:`Failed to delete ${g}`;V.error(b),e.onError?.("delete",f);}}});},[e.endpoint,d]),m=Ta.useCallback(async x=>{s(null);try{let g=await dt(e.endpoint,x);return r(f=>[g,...f]),l(!1),e.onSuccess?.("create",g),g}catch(g){let f=g instanceof Error?g.message:"Failed to create resource";throw s(f),e.onError?.("create",g),g}},[e.endpoint]),v=Ta.useCallback(async(x,g)=>{s(null);try{let f=await Yt(`${e.endpoint}/${x}`,g);return r(b=>b.map(p=>p.id===x?f:p)),e.onSuccess?.("update",f),f}catch(f){let b=f instanceof Error?f.message:"Failed to update resource";throw s(b),e.onError?.("update",f),f}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:u,create:m,update:v,isCreateModalOpen:i,setIsCreateModalOpen:l}}var Ef={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function Tc(){let{t:e}=reactI18next.useTranslation(),{items:t,loading:r,create:o,remove:a,update:n,isCreateModalOpen:s,setIsCreateModalOpen:i}=Dc({endpoint:"/api/webhooks"}),{confirm:l}=yt(),[d,c]=Ta.useState(false),[u,m]=Ta.useState(false),[v,x]=Ta.useState(null),[g,f]=Ta.useState(null),[b,p]=Ta.useState({}),[h,A]=Ta.useState(true),[$,T]=Ta.useState("action"),[k,y]=Ta.useState("generic"),[w,D]=Ta.useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[U,O]=Ta.useState(""),[z,P]=Ta.useState(false),[R,Ae]=Ta.useState(null),[E,oe]=Ta.useState([]),[ie,ee]=Ta.useState(false);Ta.useEffect(()=>{G();},[]);let G=async()=>{try{let S=await Ee("/api/webhooks/actions");p(S.actions);}catch(S){console.error("Failed to load webhook actions:",S);}finally{A(false);}},ye=()=>{T("action"),y("generic"),D({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),O("");},De=S=>{y(S),D(j=>({...j,action:S,config:{}})),T("config");},L=(S,j)=>{D(xe=>({...xe,config:{...xe.config,[S]:j}}));},W=async()=>{if(!w.name.trim()){O("Name is required");return}if(k==="generic"&&!w.url.trim()){O("URL is required for custom webhooks");return}let S=b[k];if(S){for(let j of S.configFields)if(j.required&&!w.config[j.name]?.trim()){O(`${j.label} is required`);return}}try{await o(w),ye(),V.success(`Webhook created: ${w.name}`);}catch(j){let xe=j.message||"Failed to create webhook";O(xe),V.error(xe);}},re=async S=>{f(S),x(null),c(true);try{let j=await dt(`/api/webhooks/${S}/test`);x({success:!0,message:j.message||"Webhook triggered successfully"}),V.success("Test delivered successfully");}catch{x({success:false,message:"Failed to trigger webhook"});}},H=async(S,j)=>{try{let xe=j==="active"?"paused":"active";await n(S,{status:xe}),V.success(xe==="active"?"Webhook activated":"Webhook paused");}catch(xe){console.error(xe),V.error("Failed to toggle webhook status");}},Te=async S=>{Ae(S),P(true),ee(true);try{let j=await Ee(`/api/webhooks/${S}/history`);oe(j.docs||[]);}catch(j){console.error("Failed to load history:",j),V.error("Failed to load delivery history");}finally{ee(false);}},fe=[{label:"Create",value:"create",description:"When a new document is created"},{label:"Update",value:"update",description:"When a document is updated"},{label:"Delete",value:"delete",description:"When a document is deleted"},{label:"Auth",value:"auth",description:"User login/logout events"}],we=S=>b[S||"generic"]?.label||"Custom URL";return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Lt,{title:e("tooltips.webhooks",{defaultValue:"Webhooks"}),description:"Get notified when your content changes.",icon:Ql.Webhook,actions:[{label:"New webhook",onClick:()=>{ye(),i(true);},icon:Ql.Plus},{label:"Guide",onClick:()=>m(true),icon:Ql.Info,variant:"outline"}]}),jsxRuntime.jsx("div",{className:"relative overflow-hidden rounded-2xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-3 bg-[var(--kyro-primary)]/10 rounded-xl",children:jsxRuntime.jsx(Ql.Zap,{className:"w-6 h-6 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("div",{className:"flex-1 text-center md:text-left",children:jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Receive instant HTTP notifications when events happen in your CMS. Choose a platform preset or point to any custom endpoint."})})]})}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium text-[var(--kyro-text-secondary)]",children:"Endpoints"})]}),jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:[t.length," hook",t.length!==1&&"s"]})]}),r?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 opacity-50 text-sm text-[var(--kyro-text-secondary)]",children:"Loading webhooks..."}):t.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-2xl border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-5 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Ql.Webhook,{className:"w-8 h-8 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold mb-2",children:"No webhooks yet"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-6 max-w-sm mx-auto",children:"Create a webhook to get notified when your content changes."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{ye(),i(true);},className:"kyro-btn kyro-btn-primary inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-medium",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),"Create webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:t.map(S=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-2xl p-5 hover:border-[var(--kyro-primary)]/30 transition-all duration-200",children:jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-5 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[jsxRuntime.jsx("div",{className:"p-2 bg-[var(--kyro-surface-accent)] rounded-lg",children:jsxRuntime.jsx(Ql.Webhook,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:S.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-medium ${S.status==="active"?"text-green-500":"text-amber-500"}`,children:S.status}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:we(S.action)})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-1",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs text-[var(--kyro-text-secondary)] opacity-60 truncate max-w-[200px]",title:S.url,children:S.url||`${we(S.action)} webhook`})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[S.events.slice(0,3).map(j=>jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:j},j)),S.events.length>3&&jsxRuntime.jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",S.events.length-3]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3 h-3"}),S.lastTriggered?`Last triggered ${new Date(S.lastTriggered).toLocaleDateString()}`:"Never triggered"]}),S.lastError&&jsxRuntime.jsxs("div",{className:"text-[10px] text-red-500/80 flex items-center gap-1.5 mt-1",children:[jsxRuntime.jsx(Ql.XCircle,{className:"w-3 h-3"}),jsxRuntime.jsx("span",{className:"truncate max-w-[150px]",title:S.lastError,children:S.lastError})]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 lg:opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Te(S.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.viewDeliveryHistory",{defaultValue:"View delivery history"}),children:[jsxRuntime.jsx(Ql.Activity,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium hidden sm:inline",children:"History"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>re(S.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.sendTestRequest",{defaultValue:"Send test request"}),children:[jsxRuntime.jsx(Ql.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium",children:"Test"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>H(S.id,S.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${S.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:S.status==="active"?"Pause":"Activate",children:S.status==="active"?jsxRuntime.jsx(Ql.Pause,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Ql.Play,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(S.id,"Webhook"),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-red-500/30 hover:bg-red-500/5 transition-colors",title:e("tooltips.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5 text-red-500/50 hover:text-red-500"})})]})]})},S.id))})]}),jsxRuntime.jsx(St,{open:s&&$==="action",onClose:()=>i(false),title:e("tooltips.newWebhook",{defaultValue:"New webhook"}),children:jsxRuntime.jsx(Cr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:h?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(Ql.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(b).map(([S,j])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>De(S),className:"flex flex-col items-start p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/40 transition-all text-left group",children:[jsxRuntime.jsx("div",{className:"text-lg mb-2",children:Ef[S]||"\u{1F517}"}),jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-0.5 group-hover:text-[var(--kyro-primary)] transition-colors",children:j.label}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] opacity-50 leading-relaxed",children:j.description}),j.envVars.length>0&&jsxRuntime.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:j.envVars.map(xe=>jsxRuntime.jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:xe},xe))})]},S))})})})}),jsxRuntime.jsxs(St,{open:s&&$==="config",onClose:()=>i(false),title:b[k]?.label||"Webhook",children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-5",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Name"}),jsxRuntime.jsx("input",{type:"text",value:w.name,onChange:S=>D({...w,name:S.target.value}),placeholder:"e.g., Deploy on content update",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"URL"}),jsxRuntime.jsx("input",{type:"url",value:w.url,onChange:S=>D({...w,url:S.target.value}),placeholder:"https://your-server.com/webhook",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k!=="generic"&&b[k]?.configFields.map(S=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[S.label," ",S.required&&jsxRuntime.jsx("span",{className:"text-red-500",children:"*"})]}),jsxRuntime.jsx("input",{type:"text",value:w.config[S.name]||"",onChange:j=>L(S.name,j.target.value),placeholder:S.placeholder,className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]},S.name)),k==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Signing secret"}),jsxRuntime.jsx("input",{type:"text",value:w.secret,onChange:S=>D({...w,secret:S.target.value}),placeholder:e("fields.optional",{defaultValue:"Optional"}),className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]})]}),k!=="generic"&&b[k]?.envVars.length>0&&jsxRuntime.jsxs("div",{className:"p-3 rounded-lg bg-amber-500/5 border border-amber-500/15",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-3.5 h-3.5 text-amber-500"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-amber-600",children:"Environment variables required"})]}),jsxRuntime.jsxs("p",{className:"text-[11px] text-amber-600/60 mb-2",children:["Add these to your ",jsxRuntime.jsx("code",{className:"font-mono bg-amber-500/10 px-1 py-0.5 rounded text-[10px]",children:".env"})," file:"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:b[k].envVars.map(S=>jsxRuntime.jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[S,"=..."]},S))})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium text-[var(--kyro-text-secondary)]",children:"Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:fe.map(S=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let j=w.events.includes(S.value)?w.events.filter(xe=>xe!==S.value):[...w.events,S.value];D({...w,events:j});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${w.events.includes(S.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/20"}`,children:[jsxRuntime.jsx("div",{className:`w-3.5 h-3.5 rounded flex items-center justify-center border transition-all ${w.events.includes(S.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:w.events.includes(S.value)&&jsxRuntime.jsx(Ql.CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-medium",children:S.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-40",children:S.description})]})]},S.value))})]})]}),U&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-red-500 text-xs",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-3.5 h-3.5"}),U]})]})}),jsxRuntime.jsxs(Mr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>T("action"),className:"px-4 py-2 rounded-lg text-sm font-medium border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:W,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg text-sm font-medium",children:"Create webhook"})]})]}),jsxRuntime.jsxs(St,{open:d,onClose:()=>c(false),title:e("tooltips.testWebhook",{defaultValue:"Test webhook"}),children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsx("div",{className:"p-6 rounded-xl bg-[var(--kyro-surface)] border border-[var(--kyro-border)] text-center",children:v?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${v.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:v.success?jsxRuntime.jsx(Ql.CircleCheck,{className:"w-6 h-6"}):jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-6 h-6"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:v.success?"Delivered":"Failed"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:v.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-4 py-4",children:[jsxRuntime.jsx(Ql.RefreshCw,{className:"w-8 h-8 text-[var(--kyro-primary)] animate-spin mx-auto opacity-40"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:"Sending test payload"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:"Dispatching..."})]})]})})}),jsxRuntime.jsx(Mr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>c(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]}),jsxRuntime.jsxs(St,{open:u,onClose:()=>m(false),title:e("tooltips.howWebhooksWork",{defaultValue:"How webhooks work"}),children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Ql.ExternalLink,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Request format"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["When an event triggers, Kyro sends a ",jsxRuntime.jsx("span",{className:"font-medium",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Shield,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Signature verification"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["If a secret is set, each request includes an ",jsxRuntime.jsx("span",{className:"font-mono text-[10px] bg-[var(--kyro-surface-accent)] px-1 py-0.5 rounded",children:"X-Webhook-Signature"})," header with an HMAC-SHA256 signature. Verify it in production."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] opacity-50",children:"Example payload"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg)] rounded-md border border-[var(--kyro-border)] p-4 font-mono text-xs overflow-hidden",children:jsxRuntime.jsxs("div",{className:"space-y-0.5 text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("div",{children:"{"}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"posts"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-06-28T12:00:00Z"'})]}),jsxRuntime.jsx("div",{children:"}"})]})})]})]})}),jsxRuntime.jsx(Mr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"kyro-btn kyro-btn-primary w-full py-2.5 rounded-lg text-sm font-medium",children:"Got it"})})]}),jsxRuntime.jsxs(St,{open:z,onClose:()=>P(false),title:e("tooltips.deliveryHistory",{defaultValue:"Delivery History"}),children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:ie?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(Ql.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):E.length===0?jsxRuntime.jsx("div",{className:"text-center p-8 text-[var(--kyro-text-secondary)] opacity-60 text-sm",children:"No delivery history available for this webhook."}):jsxRuntime.jsx("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:E.map(S=>jsxRuntime.jsxs("div",{className:"p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-sm",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[S.status==="success"?jsxRuntime.jsx(Ql.CircleCheck,{className:"w-4 h-4 text-green-500"}):jsxRuntime.jsx(Ql.XCircle,{className:"w-4 h-4 text-red-500"}),jsxRuntime.jsx("span",{className:"font-medium",children:S.event})]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:new Date(S.createdAt).toLocaleString()})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs text-[var(--kyro-text-secondary)] mb-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Status: "}),jsxRuntime.jsx("span",{className:`font-medium ${S.status==="success"?"text-green-500":"text-red-500"}`,children:S.responseStatus||S.status})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Duration: "}),S.duration?`${S.duration}ms`:"-"]})]}),S.error&&jsxRuntime.jsx("div",{className:"text-xs text-red-500 bg-red-500/5 p-2 rounded border border-red-500/10 font-mono break-all mb-2",children:S.error}),S.responseBody&&jsxRuntime.jsx("div",{className:"text-[10px] font-mono bg-[var(--kyro-bg)] p-2 rounded border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] opacity-70 max-h-24 overflow-y-auto break-all",children:S.responseBody})]},S.id))})})}),jsxRuntime.jsx(Mr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>P(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]})]})}function Rc({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{t:n}=reactI18next.useTranslation(),{user:s,permissions:i}=_r(),[l,d]=Ta.useState(""),[c,u]=Ta.useState(0),[m,v]=Ta.useState(false),[x,g]=Ta.useState([]),f=Ta.useRef(null),b=Ta.useRef(null);Ta.useEffect(()=>{e&&(d(""),u(0),g([]),v(false),setTimeout(()=>f.current?.focus(),100));},[e]);let p=Ta.useCallback(async P=>{if(!P||P.length<2){g([]);return}v(true);try{let Ae=await(await fetch(qe(`/api/search?q=${encodeURIComponent(P)}&limit=15`))).json();Ae.results&&g(Ae.results);}catch(R){console.error("Search error:",R),g([]);}finally{v(false);}},[]);if(Ta.useEffect(()=>(b.current&&clearTimeout(b.current),l.length>=2?b.current=setTimeout(()=>p(l),300):g([]),()=>{b.current&&clearTimeout(b.current);}),[l,p]),!e)return null;let h=Object.entries(r).filter(([P])=>i?.collections?.[P]?.read!==false).map(([P,R])=>({id:`col-${P}`,label:R.label||P,type:"collection",slug:P,icon:Ql.FileText})),A=Object.entries(o).filter(([P])=>i?.globals?.[P]?.read!==false).map(([P,R])=>({id:`global-${P}`,label:R.label||P,type:"global",slug:P,icon:Ql.Settings})),$=typeof document<"u"&&document.documentElement.classList.contains("dark"),T=s?.role==="admin",k=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:Ql.Image,visible:i?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:Ql.Clock,visible:T},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:Ql.File,visible:T},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Ql.Shield,visible:T},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Ql.Database,visible:T},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Ql.Hexagon,visible:T},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Ql.Network,visible:T},{id:"action-theme",label:$?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:$?Ql.Sun:Ql.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:Ql.LogOut,visible:true}].filter(P=>P.visible),y=x.map((P,R)=>({id:`doc-${P.collection}-${P.id}`,label:P.title,type:"document",collection:P.collection,label2:P.label,docId:P.id,icon:Ql.File,doc:P.doc})),w=l.length>=2?[...k,...h,...A,...y]:[...k,...h,...A],D=l===""?w:w.filter(P=>P.label.toLowerCase().includes(l.toLowerCase())),U=P=>{if(P.key==="ArrowDown")P.preventDefault(),u(R=>(R+1)%D.length);else if(P.key==="ArrowUp")P.preventDefault(),u(R=>(R-1+D.length)%D.length);else if(P.key==="Enter"){let R=D[c];R&&O(R);}else P.key==="Escape"&&t();},O=P=>{P.type==="collection"?P.slug==="users"?a(P.slug,P.slug):a("list",P.slug):P.type==="global"?a("settings",P.slug):P.type==="document"?P.collection==="users"?a("users","users",P.docId):a("edit",P.collection,P.docId):P.type==="action"&&(P.view==="users"?a("users","users"):P.view==="media"?a("media","media"):a(P.view,P.view)),t();},z=()=>l===""?"Quick Actions & Collections":x.length>0?"Documents":m?"Searching...":"Search Results";return jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxRuntime.jsxs("div",{className:"relative w-full max-w-2xl bg-[var(--kyro-surface)] rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 fade-in duration-300 ring-1 ring-white/10 border border-white/5",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[m?jsxRuntime.jsx(Ql.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(Ql.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:f,placeholder:n("fields.searchAnything",{defaultValue:"Search anything..."}),className:"flex-1 bg-transparent border-none focus:outline-none text-lg font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)]",value:l,onChange:P=>d(P.target.value),onKeyDown:U}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-2 py-1 bg-[var(--kyro-bg-secondary)] rounded-lg border border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:D.length>0?jsxRuntime.jsxs("div",{className:"space-y-1 px-4",children:[jsxRuntime.jsx("p",{className:"px-4 text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4",children:z()}),D.map((P,R)=>jsxRuntime.jsxs("div",{onClick:()=>O(P),onMouseEnter:()=>u(R),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${R===c?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xl shadow-[var(--kyro-primary)]":"hover:bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:`p-2 rounded-xl ${R===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(P.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:P.label}),P.type==="document"&&P.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${R===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:P.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${R===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:P.type}),R===c&&jsxRuntime.jsx(Ql.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},P.id))]}):jsxRuntime.jsx("div",{className:"py-12 text-center",children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] italic opacity-60",children:l.length>=2&&!m?`No results found for "${l}"`:"Start typing to search..."})})}),jsxRuntime.jsxs("div",{className:"px-8 py-4 bg-[var(--kyro-bg-secondary)] border-t border-[var(--kyro-border)] flex items-center justify-between text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-60",children:[jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u2191\u2193 Navigate"}),jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u23CE Select"})]}),jsxRuntime.jsx("div",{children:"Kyro Universal Search"})]})]})]})}function Ic(){let{modal:e,closeModal:t}=yt(),[r,o]=Ta.useState(false);if(!e.open||!e.config)return null;let{config:a}=e,n=async()=>{if(a.onConfirm)try{o(!0),await a.onConfirm();}catch(i){console.error("Modal confirm action failed:",i);}finally{o(false),t();}else t();},s=()=>{a.onCancel&&a.onCancel(),t();};return jsxRuntime.jsx(Vs,{open:e.open,onClose:s,onConfirm:n,title:a.title,message:a.message,confirmLabel:a.confirmLabel,cancelLabel:a.cancelLabel,variant:a.variant==="danger"?"danger":"default",loading:r})}function Of({config:e,theme:t="light",onThemeChange:r}){let[o,a]=Ta.useState(false),[n,s]=Ta.useState(null),i=Ta.useMemo(()=>Wn(Va(e.collections)),[e.collections]),l=Ta.useMemo(()=>qn(Va(e.globals)),[e.globals]),[d,c]=Ta.useState(null),[u,m]=Ta.useState(null),[v,x]=Ta.useState("list"),[g,f]=Ta.useState(null),[b,p]=Ta.useState(false);Ta.useEffect(()=>{(async()=>{try{let k=await fetch("/api/users/me");if(k.ok){let y=await k.json();s(y),a(!0);}}catch(k){console.error("Auth check failed",k);}})();},[]),Ta.useEffect(()=>{if(o&&!d){let T=Object.keys(i)[0];T&&c(T);}},[o,i,d]);let h=(T,k=null,y=null)=>{x(T),k&&c(k),y&&f(y),p(false);};Ta.useEffect(()=>{let T=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),p(y=>!y));};return window.addEventListener("keydown",T),window.openCommandPalette=()=>p(true),()=>{window.removeEventListener("keydown",T),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(Sr,{mode:t,onChange:r,children:jsxRuntime.jsxs("div",{className:"kyro-admin min-h-screen bg-[var(--kyro-bg)] text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("div",{className:"flex h-screen overflow-hidden",children:jsxRuntime.jsx("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsxRuntime.jsx(Rc,{isOpen:b,onClose:()=>p(false),collections:i,globals:l,onNavigate:h}),(()=>{let T=d?i[d]:null;switch(v){case "create":return T?jsxRuntime.jsx(Di,{config:e,collection:T,onSuccess:()=>x("list"),onCancel:()=>x("list"),onError:k=>V.error(k)}):null;case "detail":return T&&g?jsxRuntime.jsx(Ai,{config:e,collection:T,documentId:g,onBack:()=>x("list"),onSave:()=>{},onError:k=>V.error(k)}):null;case "users":return jsxRuntime.jsx(Cc,{});case "media":return jsxRuntime.jsx(En,{});case "branding":return jsxRuntime.jsx(Sc,{});case "developer":return jsxRuntime.jsx(Ac,{collections:i});case "webhooks":return jsxRuntime.jsx(Tc,{});default:return T?jsxRuntime.jsx(Ms,{config:e,collection:T,onCreate:()=>x("create"),onEdit:k=>h("detail",d,k)}):jsxRuntime.jsx(wc,{onNavigate:h,collections:i,user:n})}})()]})})}),jsxRuntime.jsx(Ic,{}),jsxRuntime.jsx(us,{})]})}):jsxRuntime.jsx(Fi,{onAuth:(T,k)=>{s(k),a(true);},theme:t})}function zf({selectedCount:e,onClearSelection:t,actions:r,onSelectAll:o}){return e===0?null:jsxRuntime.jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-gray-50 border-b border-gray-200",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Rs,{count:e}),jsxRuntime.jsx("span",{className:"text-sm text-gray-600",children:"selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-sm text-gray-500 hover:text-gray-700",children:"Clear selection"}),o&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Select all"})]}),jsxRuntime.jsx(Po,{trigger:jsxRuntime.jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsxRuntime.jsx(Pt,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function Jf({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:i=false}){let{t:l}=reactI18next.useTranslation(),d=u=>{if(!u)return "Unknown date";let m=new Date(u);if(isNaN(m.getTime())){let v=Date.parse(u);return isNaN(v)?"Invalid date":new Date(v).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}return m.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})},c=u=>{if(!u)return "Unknown date";let m=new Date(u);if(isNaN(m.getTime()))return d(u);let x=new Date().getTime()-m.getTime();if(x<0)return "Just now";let g=Math.floor(x/6e4),f=Math.floor(x/36e5),b=Math.floor(x/864e5);return g<1?"Just now":g<60?`${g}m ago`:f<24?`${f}h ago`:b<7?`${b}d ago`:d(u)};return jsxRuntime.jsx(yr,{open:e,onClose:t,title:l("tooltips.versionHistory",{defaultValue:"Version History"}),width:"md",children:i?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12",children:jsxRuntime.jsx(ar,{})}):r.length===0?jsxRuntime.jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx(Ql.History,{className:"w-12 h-12 mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsxRuntime.jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsxRuntime.jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(u=>{let m=u.id===o;return jsxRuntime.jsxs("div",{className:`p-4 rounded-xl border transition-all duration-200 group relative overflow-hidden ${m?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]/5 shadow-sm":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30 hover:bg-[var(--kyro-surface-accent)] hover:shadow-sm bg-[var(--kyro-surface)]"}`,children:[m&&jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-[var(--kyro-primary)] shadow-[0_0_8px_var(--kyro-primary)]"}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide uppercase ${u.status==="published"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-zinc-500/10 text-zinc-600 dark:text-zinc-400"}`,children:[u.status==="published"&&jsxRuntime.jsx(Ql.CheckCircle2,{className:"w-3 h-3"}),u.status==="published"?"Published":"Draft"]}),jsxRuntime.jsxs("span",{className:"text-xs font-semibold text-[var(--kyro-text)] px-2 py-0.5 rounded-md bg-[var(--kyro-surface-accent)]",children:["v",u.version]}),m&&jsxRuntime.jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),c(u.createdAt)]}),u.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(Ql.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:u.createdBy.name||u.createdBy.email})]}),u.changelog&&jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] mt-2 italic border-l-2 border-[var(--kyro-border)] pl-2",children:['"',u.changelog,'"']})]}),jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-1.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a(u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.previewThisVersion",{defaultValue:"Preview this version"}),children:jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u,r.find(v=>v.id===o)||u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.compareWithCurrent",{defaultValue:"Compare with current"}),children:jsxRuntime.jsx(Ql.GitCompare,{className:"w-4 h-4"})}),!m&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(u),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:l("tooltips.restoreThisVersion",{defaultValue:"Restore this version"}),children:jsxRuntime.jsx(Ql.Undo2,{className:"w-4 h-4"})})]})]})]},u.id)})})})}function VR({title:e,onMenuClick:t,actions:r}){return jsxRuntime.jsxs("header",{className:"kyro-header",children:[jsxRuntime.jsxs("div",{className:"kyro-header-left",children:[jsxRuntime.jsx("button",{type:"button",className:"kyro-header-menu",onClick:t,"aria-label":"Toggle menu",children:jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M3 12h18M3 6h18M3 18h18"})})}),jsxRuntime.jsx("h1",{className:"kyro-header-title",children:e})]}),jsxRuntime.jsxs("div",{className:"kyro-header-right",children:[r,jsxRuntime.jsx("div",{className:"kyro-header-user",children:jsxRuntime.jsx("button",{type:"button",className:"kyro-header-user-btn",children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"8",r:"4"}),jsxRuntime.jsx("path",{d:"M4 20c0-4 4-6 8-6s8 2 8 6"})]})})})]})]})}var ur={ready:[],beforeDeploy:[],afterDeploy:[]};function vs(e){return ur.ready.push(e),()=>{ur.ready=ur.ready.filter(t=>t!==e);}}function Mc(e){return ur.beforeDeploy.push(e),()=>{ur.beforeDeploy=ur.beforeDeploy.filter(t=>t!==e);}}function Lc(e){return ur.afterDeploy.push(e),()=>{ur.afterDeploy=ur.afterDeploy.filter(t=>t!==e);}}async function $c(e){let t=[];for(let r of ur.ready)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function Vc(e){let t=[];for(let r of ur.beforeDeploy)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function Oc(e,t){for(let r of ur.afterDeploy)try{await r(e,t);}catch{}}function Uc(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function jc(e,t={}){let[r,o]=Ta.useState(null),[a,n]=Ta.useState(true),[s,i]=Ta.useState(null),l=Ta.useCallback(async()=>{n(true),i(null);try{let d=new URLSearchParams;t.page&&d.set("page",String(t.page)),t.limit&&d.set("limit",String(t.limit)),t.sort&&d.set("sort",t.sort),t.order&&d.set("order",t.order);let c=`${Uc(`/api/${e}`)}?${d.toString()}`,u=await fetch(c,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);let m=await u.json();o(m.data??m);}catch(d){i(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return Ta.useEffect(()=>{l();},[l]),{data:r,loading:a,error:s,refetch:l}}function Hc(e,t="POST"){let[r,o]=Ta.useState(false),[a,n]=Ta.useState(null);return {mutate:Ta.useCallback(async i=>{o(true),n(null);try{let l=Uc(`/api/${e}`),d=await fetch(l,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:i?JSON.stringify(i):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(l){return n(l instanceof Error?l.message:String(l)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var ya=new Map;function fa(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");ya.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),ya.set(e.name,e),e.apply&&e.apply({});}function _c(e){ya.delete(e);}function Kc(e){return ya.get(e)}function Gc(){return Array.from(ya.values())}function Wc(e){return Array.from(ya.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var Yf={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};fa(Yf);var Qf={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};fa(Qf);var ga=new Map;function va(e){if(!e.id||typeof e.id!="string")throw new Error("Block must have a valid id");if(!e.label)throw new Error("Block must have a label");ga.set(e.id,e);}function qc(e){ga.delete(e);}function Jc(e){return ga.get(e)}function Xc(){return Array.from(ga.values())}function Yc(e){return Array.from(ga.values()).filter(t=>t.category===e)}function Qc(e){let t=ga.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var Zf=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"1px solid #ccc",padding:8,borderRadius:6},children:[jsxRuntime.jsx("strong",{children:"Sample Block"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},eg={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:Zf};va(eg);var rg=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"2px dashed #888",padding:10,borderRadius:8},children:[jsxRuntime.jsx("strong",{children:"Sample Block 2"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},og={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:rg};va(og);var ba=new Map;function xa(e){if(!e.id||typeof e.id!="string")throw new Error("Field must have a valid id");if(!e.type||typeof e.type!="string")throw new Error("Field must have a valid type");ba.set(e.id,e);}function tu(e){ba.delete(e);}function ru(e){return ba.get(e)}function ou(){return Array.from(ba.values())}function au(e){return Array.from(ba.values()).find(t=>t.type===e)}function nu(e,t){let r=ba.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var ig=({name:e,value:t,onChange:r})=>{let{t:o}=reactI18next.useTranslation();return jsxRuntime.jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleText",{defaultValue:"Sample text"})})},lg={id:"sample-text",type:"text",label:"Sample Text",editor:ig};xa(lg);var ug=({name:e,value:t,onChange:r})=>{let{t:o}=reactI18next.useTranslation();return jsxRuntime.jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleTextarea",{defaultValue:"Sample textarea"})})},pg={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:ug};xa(pg);function su(){let e="\0virtual:use-sync-external-store-shim",t="\0virtual:use-sync-external-store-shim-with-selector",r=new Set(["use-sync-external-store/shim","use-sync-external-store/shim/index.js","use-sync-external-store"]),o=new Set(["use-sync-external-store/shim/with-selector","use-sync-external-store/shim/with-selector.js","use-sync-external-store/with-selector","use-sync-external-store/with-selector.js"]);return {name:"use-sync-external-store-shim-fix",enforce:"pre",resolveId(a){if(r.has(a))return e;if(o.has(a))return t},load(a){if(a===e)return 'export { useSyncExternalStore } from "react";';if(a===t)return `
106
+ `}})]})]})]})}var bv=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Xu({collections:e}){let{t}=z(),[r,o]=oa.useState([]),[a,n]=oa.useState(false),[s,i]=oa.useState(null),[l,d]=oa.useState(""),[c,u]=oa.useState(null),[p,f]=oa.useState(false),{confirm:y,alert:g}=gt(),[v,h]=oa.useState(false),[m,w]=oa.useState(""),C=async()=>{try{let x=await Be("/api/keys");o(x);}catch(x){console.error(x);}};oa.useEffect(()=>{C();},[]);let E=async()=>{w(""),h(true);},D=async()=>{if(m.trim())try{await ut("/api/keys",{name:m}),C(),h(!1),w(""),U.success("API key generated");}catch(x){console.error(x),U.error("Failed to generate API key");}},k=x=>{y({title:"Revoke API Key",message:"Are you sure you want to revoke this key? Any integrations using it will stop working.",variant:"danger",onConfirm:async()=>{try{await Dt(`/api/keys/${x}`),C(),U.success("API key revoked");}catch(N){console.error(N),U.error("Failed to revoke API key");}}});},b=async()=>{if(l){f(true);try{let N=await(await fetch(Xe(`/api/${l}`))).json();u(N);}catch{u({error:"Failed to fetch. Ensure the endpoint exists."});}finally{f(false);}}};return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Vt,{title:t("tooltips.developerCenter",{defaultValue:"Developer Center"}),description:"Provision access keys and explore the headless API ecosystem.",icon:Nc.CodeXml,actions:[{label:"Generate Key",onClick:E,icon:Nc.Key}]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxRuntime.jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:r.length===0?jsxRuntime.jsxs("div",{className:"p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx(Nc.Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):r.map(x=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-3xl p-6 hover:border-[var(--kyro-primary)]/50 transition-all duration-300",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsxRuntime.jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsxRuntime.jsx(Nc.Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:x.name})]}),jsxRuntime.jsxs("div",{className:"flex-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl px-4 py-3 flex items-center justify-between group/key overflow-hidden",children:[jsxRuntime.jsx("code",{className:"text-xs font-mono opacity-80 truncate mr-4",children:s===x.id?x.key:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(s===x.id?null:x.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:s===x.id?jsxRuntime.jsx(Nc.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(Nc.Eye,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",onClick:()=>{navigator.clipboard.writeText(x.key),U.success("API key copied to clipboard");},children:jsxRuntime.jsx(Nc.Copy,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Issued:"}),jsxRuntime.jsx("span",{children:new Date(x.createdAt).toLocaleDateString()})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Status:"}),jsxRuntime.jsx("span",{className:"text-green-500",children:"Active"})]})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>k(x.id),className:"p-3.5 bg-red-500/5 text-red-500 rounded-2xl hover:bg-red-500/10 transition-all border border-transparent hover:border-red-500/30 self-start md:self-center",title:t("tooltips.revokeKey",{defaultValue:"Revoke Key"}),children:jsxRuntime.jsx(Nc.Trash2,{className:"w-5 h-5"})})]})},x.id))})]}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/80 p-8 group shadow-2xl shadow-[var(--kyro-primary)]/20",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.1] pointer-events-none group-hover:scale-110 transition-transform duration-700",children:jsxRuntime.jsx(Nc.Terminal,{className:"w-48 h-48 rotate-12"})}),jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsxRuntime.jsx(Nc.Terminal,{className:"w-6 h-6 text-white"})}),jsxRuntime.jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsxRuntime.jsx("p",{className:"text-white/80 text-sm font-medium leading-relaxed mb-8",children:"Kyro CMS is built for high-performance content delivery. Use these endpoints to power your headless frontends."}),jsxRuntime.jsxs("button",{type:"button",className:"w-full py-4 bg-white text-[var(--kyro-primary)] rounded-[1.2rem] font-bold text-xs uppercase tracking-widest hover:shadow-xl transition-all flex items-center justify-center gap-2 active:scale-[0.98]",children:["Full API Documentation",jsxRuntime.jsx(Nc.ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxRuntime.jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsxRuntime.jsx(Lt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-[var(--kyro-primary)]/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsxRuntime.jsx(Nc.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://api.kyro.io/v1")})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsxRuntime.jsx(Lt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-amber-500/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsxRuntime.jsx(Nc.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://preview.kyro.io/v1")})]})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"xl:col-span-3 rounded-[3rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-10 space-y-10 overflow-hidden relative",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsxRuntime.jsx(Nc.CirclePlay,{className:"w-96 h-96"})}),jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxRuntime.jsxs("div",{className:"max-w-xl",children:[jsxRuntime.jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Nc.CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] text-sm font-medium opacity-60 leading-relaxed",children:"Test your collection endpoints and analyze live response payloads. Enter a collection slug to fetch its latest documents."})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 flex-1 lg:max-w-2xl bg-[var(--kyro-bg)] p-2 rounded-[2rem] border border-[var(--kyro-border)] shadow-2xl",children:[jsxRuntime.jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",bv,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:x=>d(x.target.value),placeholder:"collection-slug",className:"w-full py-4 bg-transparent focus:outline-none font-mono text-sm font-bold text-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:b,disabled:p||!l,className:"kyro-btn kyro-btn-primary px-8 py-4 rounded-[1.5rem] font-bold text-sm shadow-xl disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] transition-all flex items-center gap-3 shrink-0",children:[p?jsxRuntime.jsx(Nc.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(Nc.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),c?jsxRuntime.jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsxRuntime.jsx(Lt,{variant:"outline",className:"text-[9px] font-mono px-3",children:"200 OK"})]}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden border border-[var(--kyro-border)] shadow-2xl bg-[#090b10]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-6 py-4 bg-[#11141d] border-b border-[var(--kyro-border)]/50",children:[jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/20"})]}),jsxRuntime.jsx(yv__default.default,{value:JSON.stringify(c,null,2),height:"450px",theme:codemirrorThemeAura.aura,extensions:[langJson.json()],editable:false,className:"text-sm"})]})]}):jsxRuntime.jsxs("div",{className:"h-80 rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center bg-[var(--kyro-surface-accent)]/20 transition-all duration-700",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 bg-[var(--kyro-surface)] rounded-3xl flex items-center justify-center shadow-lg border border-[var(--kyro-border)] mb-6 opacity-20",children:jsxRuntime.jsx(Nc.CodeXml,{className:"w-10 h-10"})}),jsxRuntime.jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxRuntime.jsxs(Tt,{open:v,onClose:()=>h(false),title:t("tooltips.generateAccessToken",{defaultValue:"Generate Access Token"}),size:"lg",children:[jsxRuntime.jsx(Rr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 leading-relaxed",children:"Define a name for this API key to identify its integration context. Keys are encrypted at rest and should be treated with extreme caution."}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsxRuntime.jsx("input",{type:"text",value:m,onChange:x=>w(x.target.value),placeholder:"e.g., Mobile App SDK, Production Server",className:"w-full px-6 py-4 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)] shadow-sm transition-all",onKeyDown:x=>x.key==="Enter"&&D()})]})]})}),jsxRuntime.jsxs(zr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>h(false),className:"px-6 py-3 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:D,className:"kyro-btn kyro-btn-primary px-8 py-3 rounded-xl font-bold text-sm hover:opacity-90 shadow-lg shadow-[var(--kyro-primary)]/20 transition-all",children:"Generate Token"})]})]})]})}function Yu(e){let[t,r]=oa.useState([]),[o,a]=oa.useState(false),[n,s]=oa.useState(null),[i,l]=oa.useState(false),{confirm:d}=gt(),c=oa.useCallback(async()=>{a(true),s(null);try{let y=await Be(e.endpoint),g=Array.isArray(y)?y:y.docs||[],v=e.transformLoad?e.transformLoad(g):g;r(v),e.onSuccess?.("load",v);}catch(y){let g=y instanceof Error?y.message:"Failed to load resources";s(g),e.onError?.("load",y);}finally{a(false);}},[e.endpoint,e.transformLoad]);oa.useEffect(()=>{c();},[c]);let u=oa.useCallback((y,g="item")=>{d({title:`Delete ${g}`,message:`Are you sure you want to delete this ${g.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`${e.endpoint}/${y}`),r(v=>v.filter(h=>h.id!==y)),e.onSuccess?.("delete",y),U.success(`${g} deleted`);}catch(v){let h=v instanceof Error?v.message:`Failed to delete ${g}`;U.error(h),e.onError?.("delete",v);}}});},[e.endpoint,d]),p=oa.useCallback(async y=>{s(null);try{let g=await ut(e.endpoint,y);return r(v=>[g,...v]),l(!1),e.onSuccess?.("create",g),g}catch(g){let v=g instanceof Error?g.message:"Failed to create resource";throw s(v),e.onError?.("create",g),g}},[e.endpoint]),f=oa.useCallback(async(y,g)=>{s(null);try{let v=await er(`${e.endpoint}/${y}`,g);return r(h=>h.map(m=>m.id===y?v:m)),e.onSuccess?.("update",v),v}catch(v){let h=v instanceof Error?v.message:"Failed to update resource";throw s(h),e.onError?.("update",v),v}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:u,create:p,update:f,isCreateModalOpen:i,setIsCreateModalOpen:l}}var kv={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function Qu(){let{t:e}=z(),{items:t,loading:r,create:o,remove:a,update:n,isCreateModalOpen:s,setIsCreateModalOpen:i}=Yu({endpoint:"/api/webhooks"}),{confirm:l}=gt(),[d,c]=oa.useState(false),[u,p]=oa.useState(false),[f,y]=oa.useState(null),[g,v]=oa.useState(null),[h,m]=oa.useState({}),[w,C]=oa.useState(true),[E,D]=oa.useState("action"),[k,b]=oa.useState("generic"),[x,N]=oa.useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[O,M]=oa.useState(""),[I,P]=oa.useState(false),[R,fe]=oa.useState(null),[L,re]=oa.useState([]),[ne,ee]=oa.useState(false);oa.useEffect(()=>{H();},[]);let H=async()=>{try{let T=await Be("/api/webhooks/actions");m(T.actions);}catch(T){console.error("Failed to load webhook actions:",T);}finally{C(false);}},pe=()=>{D("action"),b("generic"),N({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),M("");},be=T=>{b(T),N(_=>({..._,action:T,config:{}})),D("config");},V=(T,_)=>{N(Ne=>({...Ne,config:{...Ne.config,[T]:_}}));},q=async()=>{if(!x.name.trim()){M("Name is required");return}if(k==="generic"&&!x.url.trim()){M("URL is required for custom webhooks");return}let T=h[k];if(T){for(let _ of T.configFields)if(_.required&&!x.config[_.name]?.trim()){M(`${_.label} is required`);return}}try{await o(x),pe(),U.success(`Webhook created: ${x.name}`);}catch(_){let Ne=_.message||"Failed to create webhook";M(Ne),U.error(Ne);}},ae=async T=>{v(T),y(null),c(true);try{let _=await ut(`/api/webhooks/${T}/test`);y({success:!0,message:_.message||"Webhook triggered successfully"}),U.success("Test delivered successfully");}catch{y({success:false,message:"Failed to trigger webhook"});}},K=async(T,_)=>{try{let Ne=_==="active"?"paused":"active";await n(T,{status:Ne}),U.success(Ne==="active"?"Webhook activated":"Webhook paused");}catch(Ne){console.error(Ne),U.error("Failed to toggle webhook status");}},Re=async T=>{fe(T),P(true),ee(true);try{let _=await Be(`/api/webhooks/${T}/history`);re(_.docs||[]);}catch(_){console.error("Failed to load history:",_),U.error("Failed to load delivery history");}finally{ee(false);}},he=[{label:"Create",value:"create",description:"When a new document is created"},{label:"Update",value:"update",description:"When a document is updated"},{label:"Delete",value:"delete",description:"When a document is deleted"},{label:"Auth",value:"auth",description:"User login/logout events"}],Ae=T=>h[T||"generic"]?.label||"Custom URL";return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Vt,{title:e("tooltips.webhooks",{defaultValue:"Webhooks"}),description:"Get notified when your content changes.",icon:Nc.Webhook,actions:[{label:"New webhook",onClick:()=>{pe(),i(true);},icon:Nc.Plus},{label:"Guide",onClick:()=>p(true),icon:Nc.Info,variant:"outline"}]}),jsxRuntime.jsx("div",{className:"relative overflow-hidden rounded-2xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-3 bg-[var(--kyro-primary)]/10 rounded-xl",children:jsxRuntime.jsx(Nc.Zap,{className:"w-6 h-6 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("div",{className:"flex-1 text-center md:text-left",children:jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Receive instant HTTP notifications when events happen in your CMS. Choose a platform preset or point to any custom endpoint."})})]})}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium text-[var(--kyro-text-secondary)]",children:"Endpoints"})]}),jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:[t.length," hook",t.length!==1&&"s"]})]}),r?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 opacity-50 text-sm text-[var(--kyro-text-secondary)]",children:"Loading webhooks..."}):t.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-2xl border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-5 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Nc.Webhook,{className:"w-8 h-8 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold mb-2",children:"No webhooks yet"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-6 max-w-sm mx-auto",children:"Create a webhook to get notified when your content changes."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{pe(),i(true);},className:"kyro-btn kyro-btn-primary inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-medium",children:[jsxRuntime.jsx(Nc.Plus,{className:"w-4 h-4"}),"Create webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:t.map(T=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-2xl p-5 hover:border-[var(--kyro-primary)]/30 transition-all duration-200",children:jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-5 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[jsxRuntime.jsx("div",{className:"p-2 bg-[var(--kyro-surface-accent)] rounded-lg",children:jsxRuntime.jsx(Nc.Webhook,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:T.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${T.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-medium ${T.status==="active"?"text-green-500":"text-amber-500"}`,children:T.status}),jsxRuntime.jsx(Lt,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:Ae(T.action)})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-1",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs text-[var(--kyro-text-secondary)] opacity-60 truncate max-w-[200px]",title:T.url,children:T.url||`${Ae(T.action)} webhook`})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[T.events.slice(0,3).map(_=>jsxRuntime.jsx(Lt,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:_},_)),T.events.length>3&&jsxRuntime.jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",T.events.length-3]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(Nc.Clock,{className:"w-3 h-3"}),T.lastTriggered?`Last triggered ${new Date(T.lastTriggered).toLocaleDateString()}`:"Never triggered"]}),T.lastError&&jsxRuntime.jsxs("div",{className:"text-[10px] text-red-500/80 flex items-center gap-1.5 mt-1",children:[jsxRuntime.jsx(Nc.XCircle,{className:"w-3 h-3"}),jsxRuntime.jsx("span",{className:"truncate max-w-[150px]",title:T.lastError,children:T.lastError})]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 lg:opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Re(T.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.viewDeliveryHistory",{defaultValue:"View delivery history"}),children:[jsxRuntime.jsx(Nc.Activity,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium hidden sm:inline",children:"History"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>ae(T.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.sendTestRequest",{defaultValue:"Send test request"}),children:[jsxRuntime.jsx(Nc.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium",children:"Test"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>K(T.id,T.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${T.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:T.status==="active"?"Pause":"Activate",children:T.status==="active"?jsxRuntime.jsx(Nc.Pause,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Nc.Play,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(T.id,"Webhook"),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-red-500/30 hover:bg-red-500/5 transition-colors",title:e("tooltips.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Nc.Trash2,{className:"w-3.5 h-3.5 text-red-500/50 hover:text-red-500"})})]})]})},T.id))})]}),jsxRuntime.jsx(Tt,{open:s&&E==="action",onClose:()=>i(false),title:e("tooltips.newWebhook",{defaultValue:"New webhook"}),children:jsxRuntime.jsx(Rr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:w?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(Nc.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(h).map(([T,_])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>be(T),className:"flex flex-col items-start p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/40 transition-all text-left group",children:[jsxRuntime.jsx("div",{className:"text-lg mb-2",children:kv[T]||"\u{1F517}"}),jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-0.5 group-hover:text-[var(--kyro-primary)] transition-colors",children:_.label}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] opacity-50 leading-relaxed",children:_.description}),_.envVars.length>0&&jsxRuntime.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:_.envVars.map(Ne=>jsxRuntime.jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:Ne},Ne))})]},T))})})})}),jsxRuntime.jsxs(Tt,{open:s&&E==="config",onClose:()=>i(false),title:h[k]?.label||"Webhook",children:[jsxRuntime.jsx(Rr,{children:jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-5",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Name"}),jsxRuntime.jsx("input",{type:"text",value:x.name,onChange:T=>N({...x,name:T.target.value}),placeholder:"e.g., Deploy on content update",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"URL"}),jsxRuntime.jsx("input",{type:"url",value:x.url,onChange:T=>N({...x,url:T.target.value}),placeholder:"https://your-server.com/webhook",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k!=="generic"&&h[k]?.configFields.map(T=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[T.label," ",T.required&&jsxRuntime.jsx("span",{className:"text-red-500",children:"*"})]}),jsxRuntime.jsx("input",{type:"text",value:x.config[T.name]||"",onChange:_=>V(T.name,_.target.value),placeholder:T.placeholder,className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]},T.name)),k==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Signing secret"}),jsxRuntime.jsx("input",{type:"text",value:x.secret,onChange:T=>N({...x,secret:T.target.value}),placeholder:e("fields.optional",{defaultValue:"Optional"}),className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]})]}),k!=="generic"&&h[k]?.envVars.length>0&&jsxRuntime.jsxs("div",{className:"p-3 rounded-lg bg-amber-500/5 border border-amber-500/15",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[jsxRuntime.jsx(Nc.TriangleAlert,{className:"w-3.5 h-3.5 text-amber-500"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-amber-600",children:"Environment variables required"})]}),jsxRuntime.jsxs("p",{className:"text-[11px] text-amber-600/60 mb-2",children:["Add these to your ",jsxRuntime.jsx("code",{className:"font-mono bg-amber-500/10 px-1 py-0.5 rounded text-[10px]",children:".env"})," file:"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:h[k].envVars.map(T=>jsxRuntime.jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[T,"=..."]},T))})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium text-[var(--kyro-text-secondary)]",children:"Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:he.map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let _=x.events.includes(T.value)?x.events.filter(Ne=>Ne!==T.value):[...x.events,T.value];N({...x,events:_});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${x.events.includes(T.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/20"}`,children:[jsxRuntime.jsx("div",{className:`w-3.5 h-3.5 rounded flex items-center justify-center border transition-all ${x.events.includes(T.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x.events.includes(T.value)&&jsxRuntime.jsx(Nc.CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-medium",children:T.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-40",children:T.description})]})]},T.value))})]})]}),O&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-red-500 text-xs",children:[jsxRuntime.jsx(Nc.TriangleAlert,{className:"w-3.5 h-3.5"}),O]})]})}),jsxRuntime.jsxs(zr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>D("action"),className:"px-4 py-2 rounded-lg text-sm font-medium border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:q,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg text-sm font-medium",children:"Create webhook"})]})]}),jsxRuntime.jsxs(Tt,{open:d,onClose:()=>c(false),title:e("tooltips.testWebhook",{defaultValue:"Test webhook"}),children:[jsxRuntime.jsx(Rr,{children:jsxRuntime.jsx("div",{className:"p-6 rounded-xl bg-[var(--kyro-surface)] border border-[var(--kyro-border)] text-center",children:f?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${f.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:f.success?jsxRuntime.jsx(Nc.CircleCheck,{className:"w-6 h-6"}):jsxRuntime.jsx(Nc.TriangleAlert,{className:"w-6 h-6"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:f.success?"Delivered":"Failed"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:f.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-4 py-4",children:[jsxRuntime.jsx(Nc.RefreshCw,{className:"w-8 h-8 text-[var(--kyro-primary)] animate-spin mx-auto opacity-40"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:"Sending test payload"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:"Dispatching..."})]})]})})}),jsxRuntime.jsx(zr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>c(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]}),jsxRuntime.jsxs(Tt,{open:u,onClose:()=>p(false),title:e("tooltips.howWebhooksWork",{defaultValue:"How webhooks work"}),children:[jsxRuntime.jsx(Rr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Nc.ExternalLink,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Request format"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["When an event triggers, Kyro sends a ",jsxRuntime.jsx("span",{className:"font-medium",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Nc.Shield,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Signature verification"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["If a secret is set, each request includes an ",jsxRuntime.jsx("span",{className:"font-mono text-[10px] bg-[var(--kyro-surface-accent)] px-1 py-0.5 rounded",children:"X-Webhook-Signature"})," header with an HMAC-SHA256 signature. Verify it in production."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] opacity-50",children:"Example payload"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg)] rounded-md border border-[var(--kyro-border)] p-4 font-mono text-xs overflow-hidden",children:jsxRuntime.jsxs("div",{className:"space-y-0.5 text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("div",{children:"{"}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"posts"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-06-28T12:00:00Z"'})]}),jsxRuntime.jsx("div",{children:"}"})]})})]})]})}),jsxRuntime.jsx(zr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"kyro-btn kyro-btn-primary w-full py-2.5 rounded-lg text-sm font-medium",children:"Got it"})})]}),jsxRuntime.jsxs(Tt,{open:I,onClose:()=>P(false),title:e("tooltips.deliveryHistory",{defaultValue:"Delivery History"}),children:[jsxRuntime.jsx(Rr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:ne?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(Nc.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):L.length===0?jsxRuntime.jsx("div",{className:"text-center p-8 text-[var(--kyro-text-secondary)] opacity-60 text-sm",children:"No delivery history available for this webhook."}):jsxRuntime.jsx("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:L.map(T=>jsxRuntime.jsxs("div",{className:"p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-sm",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[T.status==="success"?jsxRuntime.jsx(Nc.CircleCheck,{className:"w-4 h-4 text-green-500"}):jsxRuntime.jsx(Nc.XCircle,{className:"w-4 h-4 text-red-500"}),jsxRuntime.jsx("span",{className:"font-medium",children:T.event})]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:new Date(T.createdAt).toLocaleString()})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs text-[var(--kyro-text-secondary)] mb-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Status: "}),jsxRuntime.jsx("span",{className:`font-medium ${T.status==="success"?"text-green-500":"text-red-500"}`,children:T.responseStatus||T.status})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Duration: "}),T.duration?`${T.duration}ms`:"-"]})]}),T.error&&jsxRuntime.jsx("div",{className:"text-xs text-red-500 bg-red-500/5 p-2 rounded border border-red-500/10 font-mono break-all mb-2",children:T.error}),T.responseBody&&jsxRuntime.jsx("div",{className:"text-[10px] font-mono bg-[var(--kyro-bg)] p-2 rounded border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] opacity-70 max-h-24 overflow-y-auto break-all",children:T.responseBody})]},T.id))})})}),jsxRuntime.jsx(zr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>P(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]})]})}function tp({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{t:n}=z(),{user:s,permissions:i}=Yr(),[l,d]=oa.useState(""),[c,u]=oa.useState(0),[p,f]=oa.useState(false),[y,g]=oa.useState([]),v=oa.useRef(null),h=oa.useRef(null);oa.useEffect(()=>{e&&(d(""),u(0),g([]),f(false),setTimeout(()=>v.current?.focus(),100));},[e]);let m=oa.useCallback(async P=>{if(!P||P.length<2){g([]);return}f(true);try{let fe=await(await fetch(Xe(`/api/search?q=${encodeURIComponent(P)}&limit=15`))).json();fe.results&&g(fe.results);}catch(R){console.error("Search error:",R),g([]);}finally{f(false);}},[]);if(oa.useEffect(()=>(h.current&&clearTimeout(h.current),l.length>=2?h.current=setTimeout(()=>m(l),300):g([]),()=>{h.current&&clearTimeout(h.current);}),[l,m]),!e)return null;let w=Object.entries(r).filter(([P])=>i?.collections?.[P]?.read!==false).map(([P,R])=>({id:`col-${P}`,label:R.label||P,type:"collection",slug:P,icon:Nc.FileText})),C=Object.entries(o).filter(([P])=>i?.globals?.[P]?.read!==false).map(([P,R])=>({id:`global-${P}`,label:R.label||P,type:"global",slug:P,icon:Nc.Settings})),E=typeof document<"u"&&document.documentElement.classList.contains("dark"),D=s?.role==="admin",k=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:Nc.Image,visible:i?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:Nc.Clock,visible:D},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:Nc.File,visible:D},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Nc.Shield,visible:D},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Nc.Database,visible:D},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Nc.Hexagon,visible:D},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Nc.Network,visible:D},{id:"action-theme",label:E?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:E?Nc.Sun:Nc.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:Nc.LogOut,visible:true}].filter(P=>P.visible),b=y.map((P,R)=>({id:`doc-${P.collection}-${P.id}`,label:P.title,type:"document",collection:P.collection,label2:P.label,docId:P.id,icon:Nc.File,doc:P.doc})),x=l.length>=2?[...k,...w,...C,...b]:[...k,...w,...C],N=l===""?x:x.filter(P=>P.label.toLowerCase().includes(l.toLowerCase())),O=P=>{if(P.key==="ArrowDown")P.preventDefault(),u(R=>(R+1)%N.length);else if(P.key==="ArrowUp")P.preventDefault(),u(R=>(R-1+N.length)%N.length);else if(P.key==="Enter"){let R=N[c];R&&M(R);}else P.key==="Escape"&&t();},M=P=>{P.type==="collection"?P.slug==="users"?a(P.slug,P.slug):a("list",P.slug):P.type==="global"?a("settings",P.slug):P.type==="document"?P.collection==="users"?a("users","users",P.docId):a("edit",P.collection,P.docId):P.type==="action"&&(P.view==="users"?a("users","users"):P.view==="media"?a("media","media"):a(P.view,P.view)),t();},I=()=>l===""?"Quick Actions & Collections":y.length>0?"Documents":p?"Searching...":"Search Results";return jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxRuntime.jsxs("div",{className:"relative w-full max-w-2xl bg-[var(--kyro-surface)] rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 fade-in duration-300 ring-1 ring-white/10 border border-white/5",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[p?jsxRuntime.jsx(Nc.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(Nc.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:v,placeholder:n("fields.searchAnything",{defaultValue:"Search anything..."}),className:"flex-1 bg-transparent border-none focus:outline-none text-lg font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)]",value:l,onChange:P=>d(P.target.value),onKeyDown:O}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-2 py-1 bg-[var(--kyro-bg-secondary)] rounded-lg border border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:N.length>0?jsxRuntime.jsxs("div",{className:"space-y-1 px-4",children:[jsxRuntime.jsx("p",{className:"px-4 text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4",children:I()}),N.map((P,R)=>jsxRuntime.jsxs("div",{onClick:()=>M(P),onMouseEnter:()=>u(R),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${R===c?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xl shadow-[var(--kyro-primary)]":"hover:bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:`p-2 rounded-xl ${R===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(P.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:P.label}),P.type==="document"&&P.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${R===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:P.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${R===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:P.type}),R===c&&jsxRuntime.jsx(Nc.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},P.id))]}):jsxRuntime.jsx("div",{className:"py-12 text-center",children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] italic opacity-60",children:l.length>=2&&!p?`No results found for "${l}"`:"Start typing to search..."})})}),jsxRuntime.jsxs("div",{className:"px-8 py-4 bg-[var(--kyro-bg-secondary)] border-t border-[var(--kyro-border)] flex items-center justify-between text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-60",children:[jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u2191\u2193 Navigate"}),jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u23CE Select"})]}),jsxRuntime.jsx("div",{children:"Kyro Universal Search"})]})]})]})}function rp(){let{modal:e,closeModal:t}=gt(),[r,o]=oa.useState(false);if(!e.open||!e.config)return null;let{config:a}=e,n=async()=>{if(a.onConfirm)try{o(!0),await a.onConfirm();}catch(i){console.error("Modal confirm action failed:",i);}finally{o(false),t();}else t();},s=()=>{a.onCancel&&a.onCancel(),t();};return jsxRuntime.jsx(Li,{open:e.open,onClose:s,onConfirm:n,title:a.title,message:a.message,confirmLabel:a.confirmLabel,cancelLabel:a.cancelLabel,variant:a.variant==="danger"?"danger":"default",loading:r})}function Sv({config:e,theme:t="light",onThemeChange:r}){let[o,a]=oa.useState(false),[n,s]=oa.useState(null),i=oa.useMemo(()=>Ds(an(e.collections)),[e.collections]),l=oa.useMemo(()=>Ps(an(e.globals)),[e.globals]),[d,c]=oa.useState(null),[u,p]=oa.useState(null),[f,y]=oa.useState("list"),[g,v]=oa.useState(null),[h,m]=oa.useState(false);oa.useEffect(()=>{(async()=>{try{let k=await fetch("/api/users/me");if(k.ok){let b=await k.json();s(b),a(!0);}}catch(k){console.error("Auth check failed",k);}})();},[]),oa.useEffect(()=>{if(o&&!d){let D=Object.keys(i)[0];D&&c(D);}},[o,i,d]);let w=(D,k=null,b=null)=>{y(D),k&&c(k),b&&v(b),m(false);};oa.useEffect(()=>{let D=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),m(b=>!b));};return window.addEventListener("keydown",D),window.openCommandPalette=()=>m(true),()=>{window.removeEventListener("keydown",D),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(Fr,{mode:t,onChange:r,children:jsxRuntime.jsxs("div",{className:"kyro-admin min-h-screen bg-[var(--kyro-bg)] text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("div",{className:"flex h-screen overflow-hidden",children:jsxRuntime.jsx("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsxRuntime.jsx(tp,{isOpen:h,onClose:()=>m(false),collections:i,globals:l,onNavigate:w}),(()=>{let D=d?i[d]:null;switch(f){case "create":return D?jsxRuntime.jsx(wl,{config:e,collection:D,onSuccess:()=>y("list"),onCancel:()=>y("list"),onError:k=>U.error(k)}):null;case "detail":return D&&g?jsxRuntime.jsx(kl,{config:e,collection:D,documentId:g,onBack:()=>y("list"),onSave:()=>{},onError:k=>U.error(k)}):null;case "users":return jsxRuntime.jsx(qu,{});case "media":return jsxRuntime.jsx(ys,{});case "branding":return jsxRuntime.jsx(Ju,{});case "developer":return jsxRuntime.jsx(Xu,{collections:i});case "webhooks":return jsxRuntime.jsx(Qu,{});default:return D?jsxRuntime.jsx(Ri,{config:e,collection:D,onCreate:()=>y("create"),onEdit:k=>w("detail",d,k)}):jsxRuntime.jsx(Gu,{onNavigate:w,collections:i,user:n})}})()]})})}),jsxRuntime.jsx(rp,{}),jsxRuntime.jsx(Gs,{})]})}):jsxRuntime.jsx(Sl,{onAuth:(D,k)=>{s(k),a(true);},theme:t})}function Av({selectedCount:e,onClearSelection:t,actions:r,onSelectAll:o}){return e===0?null:jsxRuntime.jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-gray-50 border-b border-gray-200",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(pi,{count:e}),jsxRuntime.jsx("span",{className:"text-sm text-gray-600",children:"selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-sm text-gray-500 hover:text-gray-700",children:"Clear selection"}),o&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Select all"})]}),jsxRuntime.jsx(Vo,{trigger:jsxRuntime.jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsxRuntime.jsx(Ft,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function Ev({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:i=false}){let{t:l}=z(),d=u=>{if(!u)return "Unknown date";let p=new Date(u);if(isNaN(p.getTime())){let f=Date.parse(u);return isNaN(f)?"Invalid date":new Date(f).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}return p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})},c=u=>{if(!u)return "Unknown date";let p=new Date(u);if(isNaN(p.getTime()))return d(u);let y=new Date().getTime()-p.getTime();if(y<0)return "Just now";let g=Math.floor(y/6e4),v=Math.floor(y/36e5),h=Math.floor(y/864e5);return g<1?"Just now":g<60?`${g}m ago`:v<24?`${v}h ago`:h<7?`${h}d ago`:d(u)};return jsxRuntime.jsx(hr,{open:e,onClose:t,title:l("tooltips.versionHistory",{defaultValue:"Version History"}),width:"md",children:i?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12",children:jsxRuntime.jsx(ir,{})}):r.length===0?jsxRuntime.jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx(Nc.History,{className:"w-12 h-12 mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsxRuntime.jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsxRuntime.jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(u=>{let p=u.id===o;return jsxRuntime.jsxs("div",{className:`p-4 rounded-xl border transition-all duration-200 group relative overflow-hidden ${p?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]/5 shadow-sm":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30 hover:bg-[var(--kyro-surface-accent)] hover:shadow-sm bg-[var(--kyro-surface)]"}`,children:[p&&jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-[var(--kyro-primary)] shadow-[0_0_8px_var(--kyro-primary)]"}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide uppercase ${u.status==="published"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-zinc-500/10 text-zinc-600 dark:text-zinc-400"}`,children:[u.status==="published"&&jsxRuntime.jsx(Nc.CheckCircle2,{className:"w-3 h-3"}),u.status==="published"?"Published":"Draft"]}),jsxRuntime.jsxs("span",{className:"text-xs font-semibold text-[var(--kyro-text)] px-2 py-0.5 rounded-md bg-[var(--kyro-surface-accent)]",children:["v",u.version]}),p&&jsxRuntime.jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsxRuntime.jsx(Nc.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),c(u.createdAt)]}),u.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(Nc.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:u.createdBy.name||u.createdBy.email})]}),u.changelog&&jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] mt-2 italic border-l-2 border-[var(--kyro-border)] pl-2",children:['"',u.changelog,'"']})]}),jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-1.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a(u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.previewThisVersion",{defaultValue:"Preview this version"}),children:jsxRuntime.jsx(Nc.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u,r.find(f=>f.id===o)||u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.compareWithCurrent",{defaultValue:"Compare with current"}),children:jsxRuntime.jsx(Nc.GitCompare,{className:"w-4 h-4"})}),!p&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(u),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:l("tooltips.restoreThisVersion",{defaultValue:"Restore this version"}),children:jsxRuntime.jsx(Nc.Undo2,{className:"w-4 h-4"})})]})]})]},u.id)})})})}function LM({title:e,onMenuClick:t,actions:r}){return jsxRuntime.jsxs("header",{className:"kyro-header",children:[jsxRuntime.jsxs("div",{className:"kyro-header-left",children:[jsxRuntime.jsx("button",{type:"button",className:"kyro-header-menu",onClick:t,"aria-label":"Toggle menu",children:jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M3 12h18M3 6h18M3 18h18"})})}),jsxRuntime.jsx("h1",{className:"kyro-header-title",children:e})]}),jsxRuntime.jsxs("div",{className:"kyro-header-right",children:[r,jsxRuntime.jsx("div",{className:"kyro-header-user",children:jsxRuntime.jsx("button",{type:"button",className:"kyro-header-user-btn",children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"8",r:"4"}),jsxRuntime.jsx("path",{d:"M4 20c0-4 4-6 8-6s8 2 8 6"})]})})})]})]})}var fr={ready:[],beforeDeploy:[],afterDeploy:[]};function Qs(e){return fr.ready.push(e),()=>{fr.ready=fr.ready.filter(t=>t!==e);}}function np(e){return fr.beforeDeploy.push(e),()=>{fr.beforeDeploy=fr.beforeDeploy.filter(t=>t!==e);}}function sp(e){return fr.afterDeploy.push(e),()=>{fr.afterDeploy=fr.afterDeploy.filter(t=>t!==e);}}async function ip(e){let t=[];for(let r of fr.ready)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function lp(e){let t=[];for(let r of fr.beforeDeploy)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function dp(e,t){for(let r of fr.afterDeploy)try{await r(e,t);}catch{}}function up(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function pp(e,t={}){let[r,o]=oa.useState(null),[a,n]=oa.useState(true),[s,i]=oa.useState(null),l=oa.useCallback(async()=>{n(true),i(null);try{let d=new URLSearchParams;t.page&&d.set("page",String(t.page)),t.limit&&d.set("limit",String(t.limit)),t.sort&&d.set("sort",t.sort),t.order&&d.set("order",t.order);let c=`${up(`/api/${e}`)}?${d.toString()}`,u=await fetch(c,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);let p=await u.json();o(p.data??p);}catch(d){i(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return oa.useEffect(()=>{l();},[l]),{data:r,loading:a,error:s,refetch:l}}function mp(e,t="POST"){let[r,o]=oa.useState(false),[a,n]=oa.useState(null);return {mutate:oa.useCallback(async i=>{o(true),n(null);try{let l=up(`/api/${e}`),d=await fetch(l,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:i?JSON.stringify(i):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(l){return n(l instanceof Error?l.message:String(l)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var Pa=new Map;function Ra(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");Pa.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),Pa.set(e.name,e),e.apply&&e.apply({});}function fp(e){Pa.delete(e);}function yp(e){return Pa.get(e)}function gp(){return Array.from(Pa.values())}function vp(e){return Array.from(Pa.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var Bv={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};Ra(Bv);var $v={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};Ra($v);var Fa=new Map;function Ia(e){if(!e.id||typeof e.id!="string")throw new Error("Block must have a valid id");if(!e.label)throw new Error("Block must have a label");Fa.set(e.id,e);}function bp(e){Fa.delete(e);}function hp(e){return Fa.get(e)}function xp(){return Array.from(Fa.values())}function kp(e){return Array.from(Fa.values()).filter(t=>t.category===e)}function wp(e){let t=Fa.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var Ov=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"1px solid #ccc",padding:8,borderRadius:6},children:[jsxRuntime.jsx("strong",{children:"Sample Block"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},Vv={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:Ov};Ia(Vv);var Uv=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"2px dashed #888",padding:10,borderRadius:8},children:[jsxRuntime.jsx("strong",{children:"Sample Block 2"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},zv={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:Uv};Ia(zv);var La=new Map;function Ea(e){if(!e.id||typeof e.id!="string")throw new Error("Field must have a valid id");if(!e.type||typeof e.type!="string")throw new Error("Field must have a valid type");La.set(e.id,e);}function Sp(e){La.delete(e);}function Ap(e){return La.get(e)}function Tp(){return Array.from(La.values())}function Dp(e){return Array.from(La.values()).find(t=>t.type===e)}function Pp(e,t){let r=La.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var Kv=({name:e,value:t,onChange:r})=>{let{t:o}=z();return jsxRuntime.jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleText",{defaultValue:"Sample text"})})},Gv={id:"sample-text",type:"text",label:"Sample Text",editor:Kv};Ea(Gv);var qv=({name:e,value:t,onChange:r})=>{let{t:o}=z();return jsxRuntime.jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleTextarea",{defaultValue:"Sample textarea"})})},Jv={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:qv};Ea(Jv);function Rp(){let e="\0virtual:use-sync-external-store-shim",t="\0virtual:use-sync-external-store-shim-with-selector",r=new Set(["use-sync-external-store/shim","use-sync-external-store/shim/index.js","use-sync-external-store"]),o=new Set(["use-sync-external-store/shim/with-selector","use-sync-external-store/shim/with-selector.js","use-sync-external-store/with-selector","use-sync-external-store/with-selector.js"]);return {name:"use-sync-external-store-shim-fix",enforce:"pre",resolveId(a){if(r.has(a))return e;if(o.has(a))return t},load(a){if(a===e)return 'export { useSyncExternalStore } from "react";';if(a===t)return `
107
107
  import { useSyncExternalStore, useRef, useMemo } from "react";
108
108
 
109
109
  export function useSyncExternalStoreWithSelector(
@@ -141,9 +141,9 @@ export function useSyncExternalStoreWithSelector(
141
141
 
142
142
  return useSyncExternalStore(subscribe, getSelection, getServerSelection);
143
143
  }
144
- `}}}var iu=br__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/shim");br__default.default.join(iu,"use-sync-external-store.js");br__default.default.join(iu,"use-sync-external-store-with-selector.js");function bg(e={}){let{basePath:t="/admin",apiPath:r="/api",configPath:o="kyro.config.ts"}=e;return {name:"@kyro-cms/admin",hooks:{"astro:config:setup":async({config:a,updateConfig:n,injectRoute:s,logger:i})=>{i.info(`Kyro Admin mounted at ${t} (API: ${r})`);let l=br__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/default-kyro-config.ts"),d=br__default.default.resolve(a.root.pathname,"..",o),c=br__default.default.resolve(a.root.pathname,o),u=Mo__default.default.existsSync(d)?d:Mo__default.default.existsSync(c)?c:l;u!==l?i.info(`Loaded config from ${u}`):i.warn("Config file not found. Using defaults.");let m=br__default.default.join(br__default.default.dirname(u),".kyro-admin-config.json"),v="";try{let g=br__default.default.join(br__default.default.dirname(u),".env");Mo__default.default.existsSync(g)&&dotenv.config({path:g});let f=await esbuild.build({entryPoints:[u],bundle:!0,format:"esm",platform:"node",target:"es2022",write:!1,sourcemap:!1,loader:{".ts":"ts",".tsx":"tsx"},resolveExtensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".json"],external:["@kyro-cms/*"]});v=u.replace(/\.ts$/,".admin.mjs"),Mo__default.default.writeFileSync(v,f.outputFiles[0].text,"utf8");let b=`
144
+ `}}}var Fp=Nr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/shim");Nr__default.default.join(Fp,"use-sync-external-store.js");Nr__default.default.join(Fp,"use-sync-external-store-with-selector.js");function tb(e={}){let{basePath:t="/admin",apiPath:r="/api",configPath:o="kyro.config.ts"}=e;return {name:"@kyro-cms/admin",hooks:{"astro:config:setup":async({config:a,updateConfig:n,injectRoute:s,logger:i})=>{i.info(`Kyro Admin mounted at ${t} (API: ${r})`);let l=Nr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/default-kyro-config.ts"),d=Nr__default.default.resolve(a.root.pathname,"..",o),c=Nr__default.default.resolve(a.root.pathname,o),u=Ko__default.default.existsSync(d)?d:Ko__default.default.existsSync(c)?c:l;u!==l?i.info(`Loaded config from ${u}`):i.warn("Config file not found. Using defaults.");let p=Nr__default.default.join(Nr__default.default.dirname(u),".kyro-admin-config.json"),f="";try{let g=Nr__default.default.join(Nr__default.default.dirname(u),".env");Ko__default.default.existsSync(g)&&dotenv.config({path:g});let v=await esbuild.build({entryPoints:[u],bundle:!0,format:"esm",platform:"node",target:"es2022",write:!1,sourcemap:!1,loader:{".ts":"ts",".tsx":"tsx"},resolveExtensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".json"],external:["@kyro-cms/*"]});f=u.replace(/\.ts$/,".admin.mjs"),Ko__default.default.writeFileSync(f,v.outputFiles[0].text,"utf8");let h=`
145
145
  import { parentPort } from 'worker_threads';
146
- import('${url.pathToFileURL(v).href}').then(mod => {
146
+ import('${url.pathToFileURL(f).href}').then(mod => {
147
147
  const cfg = mod.default || mod;
148
148
  const serialize = (obj, key) => {
149
149
  if (obj === null || obj === undefined) return obj;
@@ -170,7 +170,7 @@ export function useSyncExternalStoreWithSelector(
170
170
  }).catch(err => {
171
171
  parentPort.postMessage({ error: err.message });
172
172
  });
173
- `,p=new worker_threads.Worker(b,{eval:!0,env:{...process.env,NODE_OPTIONS:""}}),h=await new Promise(($,T)=>{p.on("message",$),p.on("error",T);let k=setTimeout(()=>{p.terminate(),T(new Error("Config loading timed out"));},3e4);});if(p.terminate(),h.error)throw new Error(h.error);let A=[{name:"metaTitle",type:"text",label:"Meta Title",admin:{description:"The title used for search engines (recommended < 60 chars).",autoGenerate:"title"}},{name:"metaDescription",type:"textarea",label:"Meta Description",admin:{description:"A brief summary for search engines (recommended < 160 chars).",autoGenerate:"content"}},{name:"keywords",type:"text",label:"Keywords",admin:{description:"Comma-separated list of keywords for this page."}},{name:"ogImage",type:"upload",label:"OpenGraph Image",relationTo:"media",admin:{description:"The image shown when shared on social media."}},{name:"twitter",type:"group",label:"Twitter Card",fields:[{name:"title",type:"text",label:"Twitter Title"},{name:"description",type:"textarea",label:"Twitter Description"},{name:"image",type:"upload",label:"Twitter Image",relationTo:"media"}]},{name:"advanced",type:"group",label:"Advanced Search Settings",fields:[{name:"noindex",type:"checkbox",label:"Hide from search engines (noindex)",defaultValue:!1},{name:"nofollow",type:"checkbox",label:"Do not follow links (nofollow)",defaultValue:!1},{name:"canonicalUrl",type:"text",label:"Canonical URL Override",admin:{description:"Leave empty to use the default canonical URL."}},{name:"structuredData",type:"code",label:"JSON-LD Structured Data",admin:{description:"Custom JSON-LD schema for this specific page."}}]}];for(let $ of h.collections||[])if($.seo){let T=$.fields?.find(k=>k.type==="tabs"&&k.name==="tabs");T?.tabs&&(T.tabs.find(k=>k.label==="SEO Settings")||T.tabs.push({label:"SEO Settings",fields:A}));}Mo__default.default.writeFileSync(m,JSON.stringify(h,null,2),"utf8"),i.info("Project config loaded for admin");}catch(g){i.error(`Could not load project config: ${g.message}`);}finally{if(v&&Mo__default.default.existsSync(v))try{Mo__default.default.unlinkSync(v);}catch{}}n({vite:{plugins:[su(),{name:"kyro-admin-tsx-loader",enforce:"pre",config(g){let f=g.esbuild,b=f?.exclude,p=/\/node_modules\/(?!.*@kyro-cms\/(admin|core))/;return {esbuild:{...f||{},exclude:b?Array.isArray(b)?[...b,p]:[b,p]:p}}}},{name:"kyro-cjs-shim",enforce:"pre",resolveId(g){if(g.includes("react/compiler-runtime"))return "\0react-compiler-runtime";if(g==="debug"||g.includes("debug/src/browser.js"))return "\0debug-browser"},load(g){if(g==="\0react-compiler-runtime")return `
173
+ `,m=new worker_threads.Worker(h,{eval:!0,env:{...process.env,NODE_OPTIONS:""}}),w=await new Promise((E,D)=>{m.on("message",E),m.on("error",D);let k=setTimeout(()=>{m.terminate(),D(new Error("Config loading timed out"));},3e4);});if(m.terminate(),w.error)throw new Error(w.error);let C=[{name:"metaTitle",type:"text",label:"Meta Title",admin:{description:"The title used for search engines (recommended < 60 chars).",autoGenerate:"title"}},{name:"metaDescription",type:"textarea",label:"Meta Description",admin:{description:"A brief summary for search engines (recommended < 160 chars).",autoGenerate:"content"}},{name:"keywords",type:"text",label:"Keywords",admin:{description:"Comma-separated list of keywords for this page."}},{name:"ogImage",type:"upload",label:"OpenGraph Image",relationTo:"media",admin:{description:"The image shown when shared on social media."}},{name:"twitter",type:"group",label:"Twitter Card",fields:[{name:"title",type:"text",label:"Twitter Title"},{name:"description",type:"textarea",label:"Twitter Description"},{name:"image",type:"upload",label:"Twitter Image",relationTo:"media"}]},{name:"advanced",type:"group",label:"Advanced Search Settings",fields:[{name:"noindex",type:"checkbox",label:"Hide from search engines (noindex)",defaultValue:!1},{name:"nofollow",type:"checkbox",label:"Do not follow links (nofollow)",defaultValue:!1},{name:"canonicalUrl",type:"text",label:"Canonical URL Override",admin:{description:"Leave empty to use the default canonical URL."}},{name:"structuredData",type:"code",label:"JSON-LD Structured Data",admin:{description:"Custom JSON-LD schema for this specific page."}}]}];for(let E of w.collections||[])if(E.seo){let D=E.fields?.find(k=>k.type==="tabs"&&k.name==="tabs");D?.tabs&&(D.tabs.find(k=>k.label==="SEO Settings")||D.tabs.push({label:"SEO Settings",fields:C}));}Ko__default.default.writeFileSync(p,JSON.stringify(w,null,2),"utf8"),i.info("Project config loaded for admin");}catch(g){i.error(`Could not load project config: ${g.message}`);}finally{if(f&&Ko__default.default.existsSync(f))try{Ko__default.default.unlinkSync(f);}catch{}}n({vite:{plugins:[Rp(),{name:"kyro-admin-tsx-loader",enforce:"pre",config(g){let v=g.esbuild,h=v?.exclude,m=/\/node_modules\/(?!.*@kyro-cms\/(admin|core))/;return {esbuild:{...v||{},exclude:h?Array.isArray(h)?[...h,m]:[h,m]:m}}}},{name:"kyro-cjs-shim",enforce:"pre",resolveId(g){if(g.includes("react/compiler-runtime"))return "\0react-compiler-runtime";if(g==="debug"||g.includes("debug/src/browser.js"))return "\0debug-browser"},load(g){if(g==="\0react-compiler-runtime")return `
174
174
  import React from "react";
175
175
  export function c(size) {
176
176
  const internals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
@@ -192,4 +192,4 @@ debug.enable = function() {};
192
192
  debug.disable = function() {};
193
193
  debug.enabled = function() { return false; };
194
194
  export default debug;
195
- `}}],resolve:{alias:{"kyro:config":u}},optimizeDeps:{include:["@kyro-cms/admin","recharts","recharts > recharts-scale","recharts > recharts-scale > decimal.js-light","recharts > react-smooth","recharts > react-smooth > react-transition-group","use-sync-external-store","use-sync-external-store/with-selector.js","react-i18next > html-parse-stringify > void-elements","react-i18next > html-parse-stringify"],needsInterop:["decimal.js-light","use-sync-external-store","use-sync-external-store/with-selector.js","react-i18next > html-parse-stringify > void-elements","react-i18next > html-parse-stringify"],exclude:["debug","react/compiler-runtime"]},define:{__KYRO_ADMIN_PATH__:JSON.stringify(t),__KYRO_API_PATH__:JSON.stringify(r),__KYRO_ADMIN_CONFIG_FILE__:JSON.stringify(m)},ssr:{noExternal:["@kyro-cms/admin","@kyro-cms/core","@tiptap/core","@tiptap/react","@tiptap/pm","@tiptap/starter-kit","@tiptap/extension-link","@tiptap/extension-image","@tiptap/extension-text-align","@tiptap/extension-underline","@tiptap/extension-highlight","@tiptap/extension-task-list","@tiptap/extension-task-item","@tiptap/extension-text-style","@tiptap/extension-color","prosemirror-model","prosemirror-state","prosemirror-view","prosemirror-schema-list","prosemirror-commands","prosemirror-keymap","prosemirror-transform","prosemirror-inputrules"]}}}),globalThis.__KYRO_ADMIN_PROJECT_CONFIG__={collections:[],globals:[],adapter:null};let x=[{pattern:"",entrypoint:"./pages/index.astro"},{pattern:"/login",entrypoint:"./pages/auth/login.astro"},{pattern:"/register",entrypoint:"./pages/auth/register.astro"},{pattern:"/media",entrypoint:"./pages/media.astro"},{pattern:"/users",entrypoint:"./pages/users/index.astro"},{pattern:"/users/new",entrypoint:"./pages/users/new.astro"},{pattern:"/users/[id]",entrypoint:"./pages/users/[id].astro"},{pattern:"/roles",entrypoint:"./pages/roles/index.astro"},{pattern:"/settings",entrypoint:"./pages/settings/index.astro"},{pattern:"/settings/[slug]",entrypoint:"./pages/settings/[slug].astro"},{pattern:"/audit",entrypoint:"./pages/audit/index.astro"},{pattern:"/sessions",entrypoint:"./pages/sessions.astro"},{pattern:"/keys",entrypoint:"./pages/keys.astro"},{pattern:"/webhooks",entrypoint:"./pages/webhooks.astro"},{pattern:"/plugins",entrypoint:"./pages/plugins.astro"},{pattern:"/marketplace",entrypoint:"./pages/marketplace.astro"},{pattern:"/graphql",entrypoint:"./pages/graphql.astro"},{pattern:"/rest-playground",entrypoint:"./pages/rest-playground.astro"},{pattern:"/health",entrypoint:"./pages/health.astro"},{pattern:"/403",entrypoint:"./pages/403.astro"},{pattern:"/graphql-explorer",entrypoint:"./pages/graphql-explorer.astro"},{pattern:"/[collection]",entrypoint:"./pages/[collection]/index.astro"},{pattern:"/[collection]/[id]",entrypoint:"./pages/[collection]/[id].astro"}];for(let g of x){let f=`${t}${g.pattern}`.replace(/\/$/,"");s({pattern:f||"/",entrypoint:br__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,g.entrypoint)});}},"astro:build:done":({logger:a})=>{a.info("Kyro Admin build complete");}}}}exports.ActionBar=Si;exports.Admin=Of;exports.AutoForm=Ya;exports.Badge=Rt;exports.BulkActionsBar=zf;exports.Button=Is;exports.ConfirmModal=Vs;exports.CountBadge=Rs;exports.CreateView=Di;exports.DARK_THEME=Ea;exports.DarkThemeProvider=On;exports.DetailView=Ai;exports.Dropdown=Po;exports.DropdownItem=Pt;exports.DropdownSeparator=Xa;exports.ExtDarkThemeProvider=On;exports.ExtLightThemeProvider=Vn;exports.ExtThemeProvider=Sr;exports.Header=VR;exports.LIGHT_THEME=qo;exports.LightThemeProvider=Vn;exports.ListView=Ms;exports.LoginPage=Fi;exports.Modal=St;exports.PageHeader=Lt;exports.SlidePanel=yr;exports.Spinner=ar;exports.ThemeProvider=Sr;exports.Toast=xc;exports.ToastProvider=uF;exports.VersionHistoryPanel=Jf;exports.adminPath=Ue;exports.afterDeploy=Lc;exports.apiPath=wr;exports.beforeDeploy=Mc;exports.emitAdminReady=$c;exports.emitAfterDeploy=Oc;exports.emitBeforeDeploy=Vc;exports.getBlock=Jc;exports.getBlocks=Xc;exports.getBlocksByCategory=Yc;exports.getField=ru;exports.getFieldByType=au;exports.getFields=ou;exports.getPlugin=Kc;exports.getPlugins=Gc;exports.getPluginsWithHook=Wc;exports.kyroAdmin=bg;exports.mergeThemes=Ma;exports.onAdminReady=vs;exports.paths=Nu;exports.registerBlock=va;exports.registerField=xa;exports.registerPlugin=fa;exports.resolveAdmin=hs;exports.resolveApi=qe;exports.unregisterBlock=qc;exports.unregisterField=tu;exports.unregisterPlugin=_c;exports.useBlockRenderer=Qc;exports.useExtTheme=Jo;exports.useFieldRenderer=nu;exports.useKyroMutation=Hc;exports.useKyroQuery=jc;exports.useTheme=Jo;exports.useToast=pF;
195
+ `}}],resolve:{alias:{"kyro:config":u}},optimizeDeps:{include:["@kyro-cms/admin","@kyro-cms/admin > recharts","@kyro-cms/admin > recharts > recharts-scale","@kyro-cms/admin > recharts > recharts-scale > decimal.js-light","@kyro-cms/admin > recharts > react-smooth","@kyro-cms/admin > recharts > react-smooth > react-transition-group","@kyro-cms/admin > react-i18next","@kyro-cms/admin > react-i18next > html-parse-stringify","@kyro-cms/admin > react-i18next > html-parse-stringify > void-elements","@kyro-cms/admin > use-sync-external-store","@kyro-cms/admin > use-sync-external-store/with-selector.js"],needsInterop:["@kyro-cms/admin > recharts > recharts-scale > decimal.js-light","@kyro-cms/admin > react-i18next > html-parse-stringify > void-elements","@kyro-cms/admin > use-sync-external-store","@kyro-cms/admin > use-sync-external-store/with-selector.js"],exclude:["debug","react/compiler-runtime"]},define:{__KYRO_ADMIN_PATH__:JSON.stringify(t),__KYRO_API_PATH__:JSON.stringify(r),__KYRO_ADMIN_CONFIG_FILE__:JSON.stringify(p)},ssr:{noExternal:["@kyro-cms/admin","@kyro-cms/core","@tiptap/core","@tiptap/react","@tiptap/pm","@tiptap/starter-kit","@tiptap/extension-link","@tiptap/extension-image","@tiptap/extension-text-align","@tiptap/extension-underline","@tiptap/extension-highlight","@tiptap/extension-task-list","@tiptap/extension-task-item","@tiptap/extension-text-style","@tiptap/extension-color","prosemirror-model","prosemirror-state","prosemirror-view","prosemirror-schema-list","prosemirror-commands","prosemirror-keymap","prosemirror-transform","prosemirror-inputrules"]}}}),globalThis.__KYRO_ADMIN_PROJECT_CONFIG__={collections:[],globals:[],adapter:null};let y=[{pattern:"",entrypoint:"./pages/index.astro"},{pattern:"/login",entrypoint:"./pages/auth/login.astro"},{pattern:"/register",entrypoint:"./pages/auth/register.astro"},{pattern:"/media",entrypoint:"./pages/media.astro"},{pattern:"/users",entrypoint:"./pages/users/index.astro"},{pattern:"/users/new",entrypoint:"./pages/users/new.astro"},{pattern:"/users/[id]",entrypoint:"./pages/users/[id].astro"},{pattern:"/roles",entrypoint:"./pages/roles/index.astro"},{pattern:"/settings",entrypoint:"./pages/settings/index.astro"},{pattern:"/settings/[slug]",entrypoint:"./pages/settings/[slug].astro"},{pattern:"/audit",entrypoint:"./pages/audit/index.astro"},{pattern:"/sessions",entrypoint:"./pages/sessions.astro"},{pattern:"/keys",entrypoint:"./pages/keys.astro"},{pattern:"/webhooks",entrypoint:"./pages/webhooks.astro"},{pattern:"/plugins",entrypoint:"./pages/plugins.astro"},{pattern:"/marketplace",entrypoint:"./pages/marketplace.astro"},{pattern:"/graphql",entrypoint:"./pages/graphql.astro"},{pattern:"/rest-playground",entrypoint:"./pages/rest-playground.astro"},{pattern:"/health",entrypoint:"./pages/health.astro"},{pattern:"/403",entrypoint:"./pages/403.astro"},{pattern:"/graphql-explorer",entrypoint:"./pages/graphql-explorer.astro"},{pattern:"/[collection]",entrypoint:"./pages/[collection]/index.astro"},{pattern:"/[collection]/[id]",entrypoint:"./pages/[collection]/[id].astro"}];for(let g of y){let v=`${t}${g.pattern}`.replace(/\/$/,"");s({pattern:v||"/",entrypoint:Nr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,g.entrypoint)});}},"astro:build:done":({logger:a})=>{a.info("Kyro Admin build complete");}}}}exports.ActionBar=xl;exports.Admin=Sv;exports.AutoForm=bn;exports.Badge=Lt;exports.BulkActionsBar=Av;exports.Button=mi;exports.ConfirmModal=Li;exports.CountBadge=pi;exports.CreateView=wl;exports.DARK_THEME=en;exports.DarkThemeProvider=xs;exports.DetailView=kl;exports.Dropdown=Vo;exports.DropdownItem=Ft;exports.DropdownSeparator=vn;exports.ExtDarkThemeProvider=xs;exports.ExtLightThemeProvider=hs;exports.ExtThemeProvider=Fr;exports.Header=LM;exports.LIGHT_THEME=da;exports.LightThemeProvider=hs;exports.ListView=Ri;exports.LoginPage=Sl;exports.Modal=Tt;exports.PageHeader=Vt;exports.SlidePanel=hr;exports.Spinner=ir;exports.ThemeProvider=Fr;exports.Toast=Hu;exports.ToastProvider=sL;exports.VersionHistoryPanel=Ev;exports.adminPath=He;exports.afterDeploy=sp;exports.apiPath=Tr;exports.beforeDeploy=np;exports.emitAdminReady=ip;exports.emitAfterDeploy=dp;exports.emitBeforeDeploy=lp;exports.getBlock=hp;exports.getBlocks=xp;exports.getBlocksByCategory=kp;exports.getField=Ap;exports.getFieldByType=Dp;exports.getFields=Tp;exports.getPlugin=yp;exports.getPlugins=gp;exports.getPluginsWithHook=vp;exports.kyroAdmin=tb;exports.mergeThemes=tn;exports.onAdminReady=Qs;exports.paths=tm;exports.registerBlock=Ia;exports.registerField=Ea;exports.registerPlugin=Ra;exports.resolveAdmin=ri;exports.resolveApi=Xe;exports.unregisterBlock=bp;exports.unregisterField=Sp;exports.unregisterPlugin=fp;exports.useBlockRenderer=wp;exports.useExtTheme=ca;exports.useFieldRenderer=Pp;exports.useKyroMutation=mp;exports.useKyroQuery=pp;exports.useTheme=ca;exports.useToast=iL;