@kyro-cms/admin 0.11.4 → 0.11.5
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 +19 -19
- package/dist/index.css +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -19
- package/package.json +1 -1
- package/src/components/AutoForm.tsx +47 -27
- package/src/components/CreateView.tsx +1 -0
- package/src/components/DashboardMetrics.tsx +280 -0
- package/src/components/DetailView.tsx +22 -20
- package/src/components/MediaGallery.tsx +80 -123
- package/src/components/SessionsManager.tsx +5 -0
- package/src/components/Sidebar.astro +36 -17
- package/src/components/autoform/AutoFormHeader.tsx +5 -2
- package/src/components/fields/TabsLayout.tsx +1 -1
- package/src/components/ui/CommandPaletteWrapper.tsx +2 -3
- package/src/components/ui/ImageFocalEditor.tsx +299 -0
- package/src/components/ui/Modal.tsx +1 -1
- package/src/components/ui/PageHeader.tsx +5 -2
- package/src/integration.ts +32 -0
- package/src/layouts/AdminLayout.astro +1 -1
- package/src/lib/globals.ts +53 -9
- package/src/pages/index.astro +34 -113
- package/src/pages/media.astro +1 -1
- package/src/pages/settings/[slug].astro +19 -1
- package/src/styles/main.css +50 -38
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var wa=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),react=require('@tiptap/react'),wp=require('@tiptap/starter-kit'),Np=require('@tiptap/extension-link'),Cp=require('@tiptap/extension-image'),Sp=require('@tiptap/extension-text-align'),Tp=require('@tiptap/extension-underline'),Rp=require('@tiptap/extension-highlight'),Ap=require('@tiptap/extension-task-list'),Fp=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),Pp=require('@tiptap/extension-color'),mp=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'),mm=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Do=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),Ku=require('@uiw/react-codemirror'),langJson=require('@codemirror/lang-json');require('@kyro-cms/core');var gr=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}}var wa__default=/*#__PURE__*/_interopDefault(wa);var wp__default=/*#__PURE__*/_interopDefault(wp);var Np__default=/*#__PURE__*/_interopDefault(Np);var Cp__default=/*#__PURE__*/_interopDefault(Cp);var Sp__default=/*#__PURE__*/_interopDefault(Sp);var Tp__default=/*#__PURE__*/_interopDefault(Tp);var Rp__default=/*#__PURE__*/_interopDefault(Rp);var Ap__default=/*#__PURE__*/_interopDefault(Ap);var Fp__default=/*#__PURE__*/_interopDefault(Fp);var Pp__default=/*#__PURE__*/_interopDefault(Pp);var mp__default=/*#__PURE__*/_interopDefault(mp);var mm__default=/*#__PURE__*/_interopDefault(mm);var Do__default=/*#__PURE__*/_interopDefault(Do);var Ku__default=/*#__PURE__*/_interopDefault(Ku);var gr__default=/*#__PURE__*/_interopDefault(gr);var tt=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",kr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Ye(e){if(e.startsWith("http")||e.startsWith(kr))return e;if(e.startsWith("/api/"))return kr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${kr}${t}${e}`}function rs(e){return e.startsWith("http")||e.startsWith(tt)?e:e.startsWith("/admin/")?tt+e.slice(6):e.startsWith("/")?tt+e:e}function fa(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var _c={admin:tt,api:kr,resolveApi:Ye,resolveAdmin:rs,resolveMedia:fa};var Ur=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 Kt=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:[]})})),E={success:e=>Kt.getState().addToast("success",e),error:e=>Kt.getState().addToast("error",e),warning:e=>Kt.getState().addToast("warning",e),info:e=>Kt.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 it=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 Vc="/api/auth/refresh";async function mi(){try{return (await fetch(Ye(Vc),{method:"POST",credentials:"include"})).ok}catch{return false}}async function ot(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(Ye(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await mi()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(Ye(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 ot(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&E.error(n),new Error(n)}return a.json()}async function at(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ot(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&E.error(s),new Error(s)}return n.json()}async function Xt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ot(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&E.error(s),new Error(s)}return n.json()}async function ht(e,t){let{autoToast:r=true,...o}=t||{},a=await ot(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let l=await a.json();l.error&&(s=l.error);}catch{}throw r&&E.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function zr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function Qa(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function ga(e,t,r){if(!r){let o=await ot(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",Ye(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?mi().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let l=new XMLHttpRequest;l.open("POST",Ye(e)),l.withCredentials=true,l.upload.addEventListener("progress",i=>{i.lengthComputable&&r(Math.round(i.loaded/i.total*100));}),l.addEventListener("load",()=>{if(l.status>=200&&l.status<300)try{o(JSON.parse(l.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${l.status}`));}),l.addEventListener("error",()=>a(new Error("Network error"))),l.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function Pr({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 $t({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 Zi({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 Gc({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(wa__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 el({actions:e}){return Array.isArray(e)?jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>jsxRuntime.jsxs("button",{type:"button",onClick:t.onClick,className:`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all shadow-lg shadow-[var(--kyro-primary)]/10 ${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.className||""}`,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function tl({action:e}){return jsxRuntime.jsxs("button",{type:"button",onClick:e.onClick,className:`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 shadow-lg shadow-[var(--kyro-primary)]/10 w-full lg:w-auto justify-center ${e.className||""}`,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function Ft({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:l,children:i}){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(Zi,{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,m)=>jsxRuntime.jsxs(wa__default.default.Fragment,{children:[m>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsxRuntime.jsx("a",{href:c.href,onClick:g=>{c.onClick&&(g.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})]},m))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,m)=>jsxRuntime.jsx(wa__default.default.Fragment,{children:c},m))}),i]})]})]}),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,m)=>jsxRuntime.jsxs(wa__default.default.Fragment,{children:[m===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},m))})]})]}),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(Zi,{back:n}),o&&jsxRuntime.jsx(Gc,{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,m)=>jsxRuntime.jsxs(wa__default.default.Fragment,{children:[m===0&&(t||m>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},m))}),i]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[l&&jsxRuntime.jsx(el,{actions:l}),s&&jsxRuntime.jsx(tl,{action:s})]})]}),(l||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(tl,{action:s}),l&&jsxRuntime.jsx(el,{actions:l})]})]})}var Jc={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 Dt({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=Jc[n],l=s?s.class:`kyro-badge-${n}`;return jsxRuntime.jsxs("span",{className:`kyro-badge ${l} ${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 ms({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 us({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let l="kyro-btn",i=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${l} ${i} ${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 vn({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(us,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(us,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}function fo(e,t,r){return r in t?t[r]:ys(e,t,r)}function ys(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=ys(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=ys(o.fields||[],a,r);if(n!==void 0)return n}}}}function gs({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let l=t||e.slug,{permissions:i}=Ur(),d=i?.collections?.[l]?.create!==false,c=i?.collections?.[l]?.delete!==false,m=i?.collections?.[l]?.update!==false,g=()=>{d&&(a?a():window.location.href=`${tt}/${l}/new`);},f=P=>{n?n(P):window.location.href=`${tt}/${l}/${P}`;},[b,v]=wa.useState(r),[x,y]=wa.useState(o),[u,h]=wa.useState(false),[R,S]=wa.useState(1),[w,C]=wa.useState(10),[p,D]=wa.useState(new Set),[M,I]=wa.useState(""),[B,F]=wa.useState([]),{confirm:oe,alert:me}=it(),O=()=>{F([...B,{field:"",operator:"equals",value:""}]);},K=()=>{I(""),F([]),Re(null);},se=P=>{F(B.filter((W,ae)=>ae!==P));},X=(P,W)=>{F(B.map((ae,sr)=>sr===P?{...ae,...W}:ae));},[G,Re]=wa.useState(null),[Ae,T]=wa.useState(false),[_,de]=wa.useState(false);function ke(P){let W=[];for(let ae of P||[])if(!(!ae.name||ae.hidden===true||ae.admin?.hidden||ae.name==="id"))if(ae.type==="tabs"&&ae.tabs)for(let sr of ae.tabs)sr.fields&&W.push(...ke(sr.fields));else (ae.type==="row"||ae.type==="collapsible")&&ae.fields?W.push(...ke(ae.fields)):W.push(ae);return W}let we=wa.useMemo(()=>ke(e.fields),[e.fields]),Ne=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:we.find(P=>P.type!=="group"&&typeof P.name=="string")?.name,[L,z]=wa.useState(()=>{let P;return e.admin?.defaultColumns?P=[...e.admin?.defaultColumns||[]]:P=we.slice(0,4).map(W=>W.name).filter(W=>!!W),Ne&&P.includes(Ne)&&(P=[Ne,...P.filter(W=>W!==Ne)]),P.includes("updatedAt")||P.push("updatedAt"),new Set(P)}),We=wa.useCallback(P=>{z(W=>{let ae=new Set(W);return ae.has(P)?ae.delete(P):ae.add(P),ae});},[]);function ye(P){let W=we.find(ae=>ae.name===P);return W&&W.type==="group"&&W.fields?.[0]?.name?`${P}.${W.fields[0].name}`:P}let Fe=wa.useCallback(P=>{let W=ye(P);Re(ae=>ae&&ae.field===W?{field:W,direction:ae.direction==="asc"?"desc":"asc"}:{field:W,direction:"asc"});},[]),pt=wa.useMemo(()=>{let P=we.filter(W=>!!W.name&&L.has(W.name));return L.has("status")&&P.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]}),P},[we,L]);function Rt(P){return !P.name||!Ne?false:P.name===Ne||P.type==="group"&&P.fields?.[0]?.name===Ne}function Jt(P,W){return W.name?fo(e.fields,P,W.name)??null:null}let vt=wa.useCallback(async()=>{h(true);try{let P=new URLSearchParams({page:R.toString(),limit:w.toString()});M&&P.append("search",M),G&&P.append("sort",G.field),G&&P.append("order",G.direction),B.length>0&&P.append("filters",JSON.stringify(B));let W=await Be(zr(`/api/${l}?${P}`),{autoToast:!1});v(W.docs||[]),y(W.totalDocs||0);}catch(P){console.error("Failed to load docs:",P);}finally{h(false);}},[l,R,w,M,G,B]);wa.useEffect(()=>{b.length===0&&o===0&&vt();},[]);let q=wa.useRef(true);wa.useEffect(()=>{if(q.current){q.current=false;return}vt();},[R,w,M,G,B]);let ee=()=>{p.size===b.length?D(new Set):D(new Set(b.map(P=>P.id)));},le=P=>{let W=new Set(p);W.has(P)?W.delete(P):W.add(P),D(W);},xe=()=>{oe({title:"Delete Documents",message:`Are you sure you want to delete ${p.size} document(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let P of Array.from(p))await ht(`/api/${l}/${P}`);D(new Set),vt(),E.success("Documents deleted");}catch(P){console.error("Bulk delete failed:",P),E.error("Failed to delete some documents");}}});},Ce=P=>{oe({title:"Delete Document",message:"Are you sure you want to delete this document? This cannot be undone.",variant:"danger",onConfirm:async()=>{try{await ht(`/api/${l}/${P}`),vt(),E.success("Document deleted");}catch(W){console.error("Delete failed:",W),E.error("Failed to delete document");}}});},et=Math.ceil(x/w),Ct=M||B.length>0||G;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Ft,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:x>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[x," documents"]},"count")]:void 0,action:d?{label:`Create ${e.singularLabel||e.label||l}`,onClick:g,icon:lucideReact.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(lucideReact.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:"Search...",value:M,onChange:P=>I(P.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:()=>T(!Ae),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${Ae||B.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(lucideReact.Filter,{className:"w-4 h-4"}),"Filters",B.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:B.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>de(!_),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(lucideReact.Columns3,{className:"w-4 h-4"}),"Columns"]}),_&&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:"Toggle Columns"})}),jsxRuntime.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:we.map(P=>P.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:L.has(P.name),onChange:()=>We(P.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:P.label||P.name})]},P.name):null)})]})]}),Ct&&jsxRuntime.jsx("button",{type:"button",onClick:K,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:"Clear All"})]})]}),Ae&&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:"Advanced Filters"}),jsxRuntime.jsxs("button",{type:"button",onClick:O,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(lucideReact.Plus,{className:"w-4 h-4"}),"Add Filter"]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[B.map((P,W)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:P.field,onChange:ae=>X(W,{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:we.map(ae=>jsxRuntime.jsx("option",{value:ae.name,children:ae.label||ae.name},ae.name))}),jsxRuntime.jsxs("select",{value:P.operator,onChange:ae=>X(W,{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:P.value,onChange:ae=>X(W,{value:ae.target.value}),placeholder:"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:()=>se(W),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]},W)),B.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:'No filters applied. Click "Add Filter" to create one.'})]})]}),p.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.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:[p.size," selected"]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[c&&jsxRuntime.jsxs("button",{type:"button",onClick:xe,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(lucideReact.Trash2,{className:"w-4 h-4"}),"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:"Cancel"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden",children:u?jsxRuntime.jsx("div",{className:"space-y-2 p-4",children:jsxRuntime.jsx($t,{variant:"table-row",count:8})}):b.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(lucideReact.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:"No documents found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:Ct?"Try adjusting your filters or search query.":`Get started by creating your first ${(e.singularLabel||e.label||l).toLowerCase()}.`}),!Ct&&d&&jsxRuntime.jsxs("button",{type:"button",onClick:g,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-4 h-4"}),"Create"," ",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:p.size===b.length&&b.length>0,onChange:ee,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),pt.map(P=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Fe(P.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[Zc(pt,P.type)??(P.label||P.name),G&&G.field===P.name&&jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4"})]})},P.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Created"}):null,e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Last Modified"}):null,jsxRuntime.jsx("th",{className:"px-4 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:b.map(P=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>f(P.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:W=>W.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:p.has(P.id),onChange:()=>le(P.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),pt.map(W=>{let ae=Jt(P,W),sr=W.type==="select"&&ae&&Array.isArray(W.options)?W.options.find(lo=>lo.value===ae)?.label||ae:Yc(ae,W.type);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${Rt(W)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:sr},W.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:P.createdAt?new Date(P.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:P.updatedAt?new Date(P.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:W=>W.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:()=>f(P.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?"Edit":"View",children:jsxRuntime.jsx(lucideReact.Pencil,{className:"w-4 h-4"})}),c&&jsxRuntime.jsx("button",{type:"button",onClick:()=>Ce(P.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:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"})})]})})]},P.id))})]})})}),jsxRuntime.jsx(vn,{page:R,totalPages:et,totalDocs:x,limit:w,onPageChange:S,onLimitChange:P=>{C(P),S(1);}})]})}function Yc(e,t){return e==null?"\u2014":typeof e=="boolean"?e?"Yes":"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(r=>r&&typeof r=="object"?r.title||r.name||r.email||r.filename||r.url||JSON.stringify(r).slice(0,30):String(r??"").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 Zc(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var vs=(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"},ll=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(lucideReact.Image,{className:t});case "video":return jsxRuntime.jsx(lucideReact.Film,{className:t});case "audio":return jsxRuntime.jsx(lucideReact.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(lucideReact.FileText,{className:t});default:return jsxRuntime.jsx(lucideReact.File,{className:t})}};function dr({field:e,value:t,onChange:r,disabled:o}){let a=wa.useRef(null),n=wa.useRef(null),[s,l]=wa.useState(false),[i,d]=wa.useState(false),[c,m]=wa.useState(false),[g,f]=wa.useState([]),[b,v]=wa.useState([]),[x,y]=wa.useState(""),[u,h]=wa.useState(false),[R,S]=wa.useState(""),[w,C]=wa.useState(false),[p,D]=wa.useState(""),[M,I]=wa.useState(""),[B,F]=wa.useState([]),oe=e?.label||e?.name||"File",me=e.maxCount??(e.hasMany?999:1),O=me>1,K=Array.isArray(t)?t:t?[t]:[],se=K.length<me;wa.useEffect(()=>{(async()=>{let z=K.filter(Fe=>typeof Fe=="string").map(Fe=>Fe),We=K.filter(Fe=>typeof Fe=="object"&&Fe!==null&&typeof Fe.id=="string"&&!Fe.url&&!Fe.filename&&!Fe.mimeType).map(Fe=>Fe.id),ye=[...z,...We];if(ye.length!==0)try{let Fe=await Promise.all(ye.map(Rt=>Be(`/api/media/${Rt}`))),pt=[...K];Fe.forEach(Rt=>{let Jt=Rt.id,vt=pt.findIndex(ee=>ee===Jt);if(vt!==-1){pt[vt]=Rt;return}let q=pt.findIndex(ee=>typeof ee=="object"&&ee!==null&&ee.id===Jt);q!==-1&&(pt[q]=Rt);}),r(O?pt:pt[0]);}catch(Fe){console.error("Failed to fetch media details:",Fe);}})();},[t]),wa.useEffect(()=>{i&&(X(),G());},[i,x]);let X=async()=>{try{let L=await Be(zr("/api/media/folders"));v(L.folders||[]);}catch{v([]);}},G=async()=>{h(true);try{let L=zr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");x&&(L+="&folder="+encodeURIComponent(x));let z=await Be(L);f(z.docs||[]);}catch{f([]);}finally{h(false);}},Re=async L=>{l(true);try{let z=new FormData;z.append("file",L),x&&z.append("folder",x);let We=await ga("/api/media/upload",z),ye={id:We.id,filename:We.filename,originalName:We.originalName??L.name,url:We.url,mimeType:L.type};r(O?[...K,ye]:ye),E.success(`Asset synchronized: ${ye.filename}`);}catch(z){console.error("Upload failed:",z),E.error(`Upload failed: ${z instanceof Error?z.message:"Unknown error"}`);}finally{l(false);}},Ae=async()=>{let L=p.trim();if(L){I("");try{let z=await at("/api/media/upload",{url:L}),We=(()=>{try{return new URL(L).pathname.split("/").pop()||z.originalName||"url-image"}catch{return z.originalName||"url-image"}})(),ye={id:z.id,filename:z.filename,originalName:We,url:z.url,mimeType:z.mimeType||"image/*"};r(O?[...K,ye]:ye),E.success(`URL asset established: ${ye.filename}`),D(""),C(!1);}catch(z){let We=z instanceof Error?z.message:"Invalid URL";I(We);}}},T=L=>({id:L.id,filename:L.filename,url:L.url,mimeType:L.mimeType}),_=L=>{O?F(z=>z.find(ye=>ye.id===L.id)?z.filter(ye=>ye.id!==L.id):[...z,L]):(r(T(L)),d(false),S(""));},de=()=>{if(B.length>0){let L=[...K,...B.map(T)];r(L);}F([]),d(false),S("");},ke=L=>{let z=[...K];z.splice(L,1),r(O?z:z[0]||null);},we=wa.useMemo(()=>g.filter(L=>!R||L.filename?.toLowerCase().includes(R.toLowerCase())||L.title?.toLowerCase().includes(R.toLowerCase())),[g,R]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let Ne=(L,z)=>{if(!L)return null;let We=vs(L.mimeType,L.filename||L.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:We==="image"?jsxRuntime.jsx("img",{src:fa(L.url),alt:L.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(ll,{type:We,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:L.originalName||L.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:oe})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>z!==void 0?ke(z):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(lucideReact.X,{className:"w-4 h-4"})})]},z)};return jsxRuntime.jsxs("div",{className:"space-y-2 relative",children:[jsxRuntime.jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:L=>{let z=L.target.files?.[0];z&&Re(z);},disabled:o,className:"hidden"}),K.length>0&&jsxRuntime.jsx("div",{className:O?"grid grid-cols-2 gap-2":"space-y-2",children:K.map((L,z)=>Ne(L,z))}),(!K.length||se)&&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 ",oe]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{F([]),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:()=>C(!w),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"})]}),w&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:p,onChange:L=>{D(L.target.value),I("");},onKeyDown:L=>L.key==="Enter"&&Ae(),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:Ae,disabled:o||!p.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"}),M&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:M})]}),i&&(c?reactDom.createPortal(jsxRuntime.jsx(il,{isFullscreen:true,isMultiple:O,selectedItems:B,pickerSearch:R,setPickerSearch:S,folders:b,selectedFolder:x,setSelectedFolder:y,mediaLoading:u,filteredMedia:we,selectFromLibrary:_,onDone:de,setIsPickerFullscreen:m,setShowPicker:d}),document.body):jsxRuntime.jsx(il,{isFullscreen:false,isMultiple:O,selectedItems:B,pickerSearch:R,setPickerSearch:S,folders:b,selectedFolder:x,setSelectedFolder:y,mediaLoading:u,filteredMedia:we,selectFromLibrary:_,onDone:de,setIsPickerFullscreen:m,setShowPicker:d}))]})}function il({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:l,mediaLoading:i,filteredMedia:d,selectFromLibrary:c,onDone:m,setIsPickerFullscreen:g,setShowPicker:f}){let b=v=>r.some(x=>x.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:"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:()=>l(""),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:()=>l(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:i?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 x=b(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 ${x?"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:vs(v.mimeType,v.filename)==="image"?jsxRuntime.jsx("img",{src:fa(v.thumbnailUrl||v.url),alt:v.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(ll,{type:vs(v.mimeType,v.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&x&&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(lucideReact.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:m,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:()=>g(!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),g(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function dt({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 cr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let l=wa.useRef(null),[i,d]=wa.useState(false);wa.useEffect(()=>{d(true);},[]),wa.useEffect(()=>{let m=g=>{g.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",m),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",m),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||!i?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:l,"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(lucideReact.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 Ca=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),react=require('@tiptap/react'),Dp=require('@tiptap/starter-kit'),Pp=require('@tiptap/extension-link'),Ip=require('@tiptap/extension-image'),Bp=require('@tiptap/extension-text-align'),Lp=require('@tiptap/extension-underline'),Mp=require('@tiptap/extension-highlight'),Ep=require('@tiptap/extension-task-list'),$p=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),Up=require('@tiptap/extension-color'),hp=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'),km=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Do=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),Zu=require('@uiw/react-codemirror'),langJson=require('@codemirror/lang-json');require('@kyro-cms/core');var yr=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}}var Ca__default=/*#__PURE__*/_interopDefault(Ca);var Dp__default=/*#__PURE__*/_interopDefault(Dp);var Pp__default=/*#__PURE__*/_interopDefault(Pp);var Ip__default=/*#__PURE__*/_interopDefault(Ip);var Bp__default=/*#__PURE__*/_interopDefault(Bp);var Lp__default=/*#__PURE__*/_interopDefault(Lp);var Mp__default=/*#__PURE__*/_interopDefault(Mp);var Ep__default=/*#__PURE__*/_interopDefault(Ep);var $p__default=/*#__PURE__*/_interopDefault($p);var Up__default=/*#__PURE__*/_interopDefault(Up);var hp__default=/*#__PURE__*/_interopDefault(hp);var km__default=/*#__PURE__*/_interopDefault(km);var Do__default=/*#__PURE__*/_interopDefault(Do);var Zu__default=/*#__PURE__*/_interopDefault(Zu);var yr__default=/*#__PURE__*/_interopDefault(yr);var Ge=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",br=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function tt(e){if(e.startsWith("http")||e.startsWith(br))return e;if(e.startsWith("/api/"))return br+e.slice(4);let t=e.startsWith("/")?"":"/";return `${br}${t}${e}`}function ss(e){return e.startsWith("http")||e.startsWith(Ge)?e:e.startsWith("/admin/")?Ge+e.slice(6):e.startsWith("/")?Ge+e:e}function ba(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var Yc={admin:Ge,api:br,resolveApi:tt,resolveAdmin:ss,resolveMedia:ba};var Ur=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 Kt=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:[]})})),M={success:e=>Kt.getState().addToast("success",e),error:e=>Kt.getState().addToast("error",e),warning:e=>Kt.getState().addToast("warning",e),info:e=>Kt.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 dt=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 Zc="/api/auth/refresh";async function vi(){try{return (await fetch(tt(Zc),{method:"POST",credentials:"include"})).ok}catch{return false}}async function at(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(tt(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await vi()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(tt(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 at(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&M.error(n),new Error(n)}return a.json()}async function nt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await at(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&M.error(s),new Error(s)}return n.json()}async function Gt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await at(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&M.error(s),new Error(s)}return n.json()}async function xt(e,t){let{autoToast:r=true,...o}={},a=await at(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let l=await a.json();l.error&&(s=l.error);}catch{}throw r&&M.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function zr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function Za(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function en(e,t,r){if(!r){let o=await at(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",tt(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?vi().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let l=new XMLHttpRequest;l.open("POST",tt(e)),l.withCredentials=true,l.upload.addEventListener("progress",i=>{i.lengthComputable&&r(Math.round(i.loaded/i.total*100));}),l.addEventListener("load",()=>{if(l.status>=200&&l.status<300)try{o(JSON.parse(l.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${l.status}`));}),l.addEventListener("error",()=>a(new Error("Network error"))),l.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function kr({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 Et({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 ol({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 tp({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(Ca__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 al({actions:e}){return Array.isArray(e)?jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>jsxRuntime.jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all shadow-lg shadow-[var(--kyro-primary)]/10 ${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||""}`,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function nl({action:e}){return jsxRuntime.jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:`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 shadow-lg shadow-[var(--kyro-primary)]/10 w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function Dt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:l,children:i}){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(ol,{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,m)=>jsxRuntime.jsxs(Ca__default.default.Fragment,{children:[m>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsxRuntime.jsx("a",{href:c.href,onClick:f=>{c.onClick&&(f.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})]},m))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,m)=>jsxRuntime.jsx(Ca__default.default.Fragment,{children:c},m))}),i]})]})]}),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,m)=>jsxRuntime.jsxs(Ca__default.default.Fragment,{children:[m===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},m))})]})]}),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(ol,{back:n}),o&&jsxRuntime.jsx(tp,{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,m)=>jsxRuntime.jsxs(Ca__default.default.Fragment,{children:[m===0&&(t||m>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},m))}),i]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[l&&jsxRuntime.jsx(al,{actions:l}),s&&jsxRuntime.jsx(nl,{action:s})]})]}),(l||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(nl,{action:s}),l&&jsxRuntime.jsx(al,{actions:l})]})]})}var op={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 Pt({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=op[n],l=s?s.class:`kyro-badge-${n}`;return jsxRuntime.jsxs("span",{className:`kyro-badge ${l} ${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 vs({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 gs({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let l="kyro-btn",i=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${l} ${i} ${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 il({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(gs,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(gs,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}function go(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 ks({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let l=t||e.slug,{permissions:i}=Ur(),d=i?.collections?.[l]?.create!==false,c=i?.collections?.[l]?.delete!==false,m=i?.collections?.[l]?.update!==false,f=()=>{d&&(a?a():window.location.href=`${Ge}/${l}/new`);},v=I=>{n?n(I):window.location.href=`${Ge}/${l}/${I}`;},[b,g]=Ca.useState(r),[x,u]=Ca.useState(o),[y,h]=Ca.useState(false),[R,P]=Ca.useState(1),[w,k]=Ca.useState(10),[p,T]=Ca.useState(new Set),[B,S]=Ca.useState(""),[F,A]=Ca.useState([]),{confirm:X,alert:K}=dt(),$=()=>{A([...F,{field:"",operator:"equals",value:""}]);},j=()=>{S(""),A([]),re(null);},ae=I=>{A(F.filter((W,ie)=>ie!==I));},ne=(I,W)=>{A(F.map((ie,sr)=>sr===I?{...ie,...W}:ie));},[H,re]=Ca.useState(null),[ve,L]=Ca.useState(false),[O,pe]=Ca.useState(false);function ge(I){let W=[];for(let ie of I||[])if(!(!ie.name||ie.hidden===true||ie.admin?.hidden||ie.name==="id"))if(ie.type==="tabs"&&ie.tabs)for(let sr of ie.tabs)sr.fields&&W.push(...ge(sr.fields));else (ie.type==="row"||ie.type==="collapsible")&&ie.fields?W.push(...ge(ie.fields)):W.push(ie);return W}let Se=Ca.useMemo(()=>ge(e.fields),[e.fields]),Ne=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:Se.find(I=>I.type!=="group"&&typeof I.name=="string")?.name,[U,Y]=Ca.useState(()=>{let I;return e.admin?.defaultColumns?I=[...e.admin?.defaultColumns||[]]:I=Se.slice(0,4).map(W=>W.name).filter(W=>!!W),Ne&&I.includes(Ne)&&(I=[Ne,...I.filter(W=>W!==Ne)]),I.includes("updatedAt")||I.push("updatedAt"),new Set(I)}),le=Ca.useCallback(I=>{Y(W=>{let ie=new Set(W);return ie.has(I)?ie.delete(I):ie.add(I),ie});},[]);function Re(I){let W=Se.find(ie=>ie.name===I);return W&&W.type==="group"&&W.fields?.[0]?.name?`${I}.${W.fields[0].name}`:I}let Ue=Ca.useCallback(I=>{let W=Re(I);re(ie=>ie&&ie.field===W?{field:W,direction:ie.direction==="asc"?"desc":"asc"}:{field:W,direction:"asc"});},[]),Ie=Ca.useMemo(()=>{let I=Se.filter(W=>!!W.name&&U.has(W.name));return U.has("status")&&I.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]}),I},[Se,U]);function et(I){return !I.name||!Ne?false:I.name===Ne||I.type==="group"&&I.fields?.[0]?.name===Ne}function Ct(I,W){return W.name?go(e.fields,I,W.name)??null:null}let St=Ca.useCallback(async()=>{h(true);try{let I=new URLSearchParams({page:R.toString(),limit:w.toString()});B&&I.append("search",B),H&&I.append("sort",H.field),H&&I.append("order",H.direction),F.length>0&&I.append("filters",JSON.stringify(F));let W=await Be(zr(`/api/${l}?${I}`),{autoToast:!1});g(W.docs||[]),u(W.totalDocs||0);}catch(I){console.error("Failed to load docs:",I);}finally{h(false);}},[l,R,w,B,H,F]);Ca.useEffect(()=>{b.length===0&&o===0&&St();},[]);let Q=Ca.useRef(true);Ca.useEffect(()=>{if(Q.current){Q.current=false;return}St();},[R,w,B,H,F]);let te=()=>{p.size===b.length?T(new Set):T(new Set(b.map(I=>I.id)));},ce=I=>{let W=new Set(p);W.has(I)?W.delete(I):W.add(I),T(W);},Te=()=>{X({title:"Delete Documents",message:`Are you sure you want to delete ${p.size} document(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let I of Array.from(p))await xt(`/api/${l}/${I}`);T(new Set),St(),M.success("Documents deleted");}catch(I){console.error("Bulk delete failed:",I),M.error("Failed to delete some documents");}}});},Fe=I=>{X({title:"Delete Document",message:"Are you sure you want to delete this document? This cannot be undone.",variant:"danger",onConfirm:async()=>{try{await xt(`/api/${l}/${I}`),St(),M.success("Document deleted");}catch(W){console.error("Delete failed:",W),M.error("Failed to delete document");}}});},lt=Math.ceil(x/w),Tt=B||F.length>0||H;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Dt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:x>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[x," documents"]},"count")]:void 0,action:d?{label:`Create ${e.singularLabel||e.label||l}`,onClick:f,icon:lucideReact.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(lucideReact.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:"Search...",value:B,onChange:I=>S(I.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(!ve),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${ve||F.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(lucideReact.Filter,{className:"w-4 h-4"}),"Filters",F.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:F.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>pe(!O),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(lucideReact.Columns3,{className:"w-4 h-4"}),"Columns"]}),O&&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:"Toggle Columns"})}),jsxRuntime.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:Se.map(I=>I.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:U.has(I.name),onChange:()=>le(I.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:I.label||I.name})]},I.name):null)})]})]}),Tt&&jsxRuntime.jsx("button",{type:"button",onClick:j,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:"Clear All"})]})]}),ve&&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:"Advanced Filters"}),jsxRuntime.jsxs("button",{type:"button",onClick:$,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(lucideReact.Plus,{className:"w-4 h-4"}),"Add Filter"]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[F.map((I,W)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:I.field,onChange:ie=>ne(W,{field:ie.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:Se.map(ie=>jsxRuntime.jsx("option",{value:ie.name,children:ie.label||ie.name},ie.name))}),jsxRuntime.jsxs("select",{value:I.operator,onChange:ie=>ne(W,{operator:ie.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:I.value,onChange:ie=>ne(W,{value:ie.target.value}),placeholder:"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:()=>ae(W),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]},W)),F.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:'No filters applied. Click "Add Filter" to create one.'})]})]}),p.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.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:[p.size," selected"]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[c&&jsxRuntime.jsxs("button",{type:"button",onClick:Te,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(lucideReact.Trash2,{className:"w-4 h-4"}),"Delete Selected"]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>T(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:"Cancel"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden",children:y?jsxRuntime.jsx("div",{className:"space-y-2 p-4",children:jsxRuntime.jsx(Et,{variant:"table-row",count:8})}):b.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(lucideReact.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:"No documents found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:Tt?"Try adjusting your filters or search query.":`Get started by creating your first ${(e.singularLabel||e.label||l).toLowerCase()}.`}),!Tt&&d&&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(lucideReact.Plus,{className:"w-4 h-4"}),"Create"," ",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:p.size===b.length&&b.length>0,onChange:te,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Ie.map(I=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Ue(I.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[lp(Ie,I.type)??(I.label||I.name),H&&H.field===I.name&&jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4"})]})},I.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Created"}):null,e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Last Modified"}):null,jsxRuntime.jsx("th",{className:"px-4 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:b.map(I=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>v(I.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:W=>W.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:p.has(I.id),onChange:()=>ce(I.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Ie.map(W=>{let ie=Ct(I,W),sr=W.type==="select"&&ie&&Array.isArray(W.options)?W.options.find(po=>po.value===ie)?.label||ie:ip(ie,W.type);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${et(W)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:sr},W.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:I.createdAt?new Date(I.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:I.updatedAt?new Date(I.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:W=>W.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:()=>v(I.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?"Edit":"View",children:jsxRuntime.jsx(lucideReact.Pencil,{className:"w-4 h-4"})}),c&&jsxRuntime.jsx("button",{type:"button",onClick:()=>Fe(I.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:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"})})]})})]},I.id))})]})})}),jsxRuntime.jsx(il,{page:R,totalPages:lt,totalDocs:x,limit:w,onPageChange:P,onLimitChange:I=>{k(I),P(1);}})]})}function ip(e,t){return e==null?"\u2014":typeof e=="boolean"?e?"Yes":"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(r=>r&&typeof r=="object"?r.title||r.name||r.email||r.filename||r.url||JSON.stringify(r).slice(0,30):String(r??"").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 lp(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var hs=(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"},ul=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(lucideReact.Image,{className:t});case "video":return jsxRuntime.jsx(lucideReact.Film,{className:t});case "audio":return jsxRuntime.jsx(lucideReact.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(lucideReact.FileText,{className:t});default:return jsxRuntime.jsx(lucideReact.File,{className:t})}};function lr({field:e,value:t,onChange:r,disabled:o}){let a=Ca.useRef(null),n=Ca.useRef(null),[s,l]=Ca.useState(false),[i,d]=Ca.useState(false),[c,m]=Ca.useState(false),[f,v]=Ca.useState([]),[b,g]=Ca.useState([]),[x,u]=Ca.useState(""),[y,h]=Ca.useState(false),[R,P]=Ca.useState(""),[w,k]=Ca.useState(false),[p,T]=Ca.useState(""),[B,S]=Ca.useState(""),[F,A]=Ca.useState([]),X=e?.label||e?.name||"File",K=e.maxCount??(e.hasMany?999:1),$=K>1,j=Array.isArray(t)?t:t?[t]:[],ae=j.length<K;Ca.useEffect(()=>{(async()=>{let Y=j.filter(Ue=>typeof Ue=="string").map(Ue=>Ue),le=j.filter(Ue=>typeof Ue=="object"&&Ue!==null&&typeof Ue.id=="string"&&!Ue.url&&!Ue.filename&&!Ue.mimeType).map(Ue=>Ue.id),Re=[...Y,...le];if(Re.length!==0)try{let Ue=await Promise.all(Re.map(et=>Be(`/api/media/${et}`))),Ie=[...j];Ue.forEach(et=>{let Ct=et.id,St=Ie.findIndex(te=>te===Ct);if(St!==-1){Ie[St]=et;return}let Q=Ie.findIndex(te=>typeof te=="object"&&te!==null&&te.id===Ct);Q!==-1&&(Ie[Q]=et);}),r($?Ie:Ie[0]);}catch(Ue){console.error("Failed to fetch media details:",Ue);}})();},[t]),Ca.useEffect(()=>{i&&(ne(),H());},[i,x]);let ne=async()=>{try{let U=await Be(zr("/api/media/folders"));g(U.folders||[]);}catch{g([]);}},H=async()=>{h(true);try{let U=zr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");x&&(U+="&folder="+encodeURIComponent(x));let Y=await Be(U);v(Y.docs||[]);}catch{v([]);}finally{h(false);}},re=async U=>{l(true);try{let Y=new FormData;Y.append("file",U),x&&Y.append("folder",x);let le=await en("/api/media/upload",Y),Re={id:le.id,filename:le.filename,originalName:le.originalName??U.name,url:le.url,mimeType:U.type};r($?[...j,Re]:Re),M.success(`Asset synchronized: ${Re.filename}`);}catch(Y){console.error("Upload failed:",Y),M.error(`Upload failed: ${Y instanceof Error?Y.message:"Unknown error"}`);}finally{l(false);}},ve=async()=>{let U=p.trim();if(U){S("");try{let Y=await nt("/api/media/upload",{url:U}),le=(()=>{try{return new URL(U).pathname.split("/").pop()||Y.originalName||"url-image"}catch{return Y.originalName||"url-image"}})(),Re={id:Y.id,filename:Y.filename,originalName:le,url:Y.url,mimeType:Y.mimeType||"image/*"};r($?[...j,Re]:Re),M.success(`URL asset established: ${Re.filename}`),T(""),k(!1);}catch(Y){let le=Y instanceof Error?Y.message:"Invalid URL";S(le);}}},L=U=>({id:U.id,filename:U.filename,url:U.url,mimeType:U.mimeType}),O=U=>{$?A(Y=>Y.find(Re=>Re.id===U.id)?Y.filter(Re=>Re.id!==U.id):[...Y,U]):(r(L(U)),d(false),P(""));},pe=()=>{if(F.length>0){let U=[...j,...F.map(L)];r(U);}A([]),d(false),P("");},ge=U=>{let Y=[...j];Y.splice(U,1),r($?Y:Y[0]||null);},Se=Ca.useMemo(()=>f.filter(U=>!R||U.filename?.toLowerCase().includes(R.toLowerCase())||U.title?.toLowerCase().includes(R.toLowerCase())),[f,R]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let Ne=(U,Y)=>{if(!U)return null;let le=hs(U.mimeType,U.filename||U.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:le==="image"?jsxRuntime.jsx("img",{src:ba(U.url),alt:U.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(ul,{type:le,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:U.originalName||U.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:X})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Y!==void 0?ge(Y):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(lucideReact.X,{className:"w-4 h-4"})})]},Y)};return jsxRuntime.jsxs("div",{className:"space-y-2 relative",children:[jsxRuntime.jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:U=>{let Y=U.target.files?.[0];Y&&re(Y);},disabled:o,className:"hidden"}),j.length>0&&jsxRuntime.jsx("div",{className:$?"grid grid-cols-2 gap-2":"space-y-2",children:j.map((U,Y)=>Ne(U,Y))}),(!j.length||ae)&&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 ",X]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{A([]),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(!w),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"})]}),w&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:p,onChange:U=>{T(U.target.value),S("");},onKeyDown:U=>U.key==="Enter"&&ve(),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:ve,disabled:o||!p.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"}),B&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:B})]}),i&&(c?reactDom.createPortal(jsxRuntime.jsx(ml,{isFullscreen:true,isMultiple:$,selectedItems:F,pickerSearch:R,setPickerSearch:P,folders:b,selectedFolder:x,setSelectedFolder:u,mediaLoading:y,filteredMedia:Se,selectFromLibrary:O,onDone:pe,setIsPickerFullscreen:m,setShowPicker:d}),document.body):jsxRuntime.jsx(ml,{isFullscreen:false,isMultiple:$,selectedItems:F,pickerSearch:R,setPickerSearch:P,folders:b,selectedFolder:x,setSelectedFolder:u,mediaLoading:y,filteredMedia:Se,selectFromLibrary:O,onDone:pe,setIsPickerFullscreen:m,setShowPicker:d}))]})}function ml({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:l,mediaLoading:i,filteredMedia:d,selectFromLibrary:c,onDone:m,setIsPickerFullscreen:f,setShowPicker:v}){let b=g=>r.some(x=>x.id===g);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:"Search media...",value:o,onChange:g=>a(g.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:()=>l(""),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(g=>jsxRuntime.jsx("button",{type:"button",onClick:()=>l(g.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===g.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:g.name},g.path))]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-2",children:i?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(g=>{let x=b(g.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(g),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${x?"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:hs(g.mimeType,g.filename)==="image"?jsxRuntime.jsx("img",{src:ba(g.thumbnailUrl||g.url),alt:g.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(ul,{type:hs(g.mimeType,g.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&x&&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(lucideReact.Check,{className:"w-3 h-3 text-white"})})]},g.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:m,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:()=>f(!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),f(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 dr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let l=Ca.useRef(null),[i,d]=Ca.useState(false);Ca.useEffect(()=>{d(true);},[]),Ca.useEffect(()=>{let m=f=>{f.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",m),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",m),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||!i?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:l,"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(lucideReact.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 Hr({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Vr({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function Ut({open:e,onClose:t,title:r,children:o,footer:a,size:n="md",variant:s="default"}){if(wa.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 l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",full:"w-full h-full max-w-none rounded-none border-0"},i=s==="lightbox";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",children:[jsxRuntime.jsx("div",{className:`absolute inset-0 transition-all duration-500 ${i?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxRuntime.jsxs("div",{className:`relative ${l[n]} ${i?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!i&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${i?"":"border"} ${s==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!i&&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(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:`flex-1 overflow-auto ${i?"":"px-8 py-8"}`,children:o}),a&&!i&&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 xs({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:s="Cancel",variant:l="default",loading:i=false}){return jsxRuntime.jsx(Ut,{open:e,onClose:t,title:o,size:"sm",footer:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:i,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:s}),jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:i,className:`kyro-btn kyro-btn-md ${l==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:i?"Loading...":n})]}),children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function cl({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,l]=wa.useState(n),i=d=>{d.preventDefault(),s.trim()&&(r(s.trim()),l(""),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(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:i,children:[jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsx("input",{type:"text",value:s,onChange:d=>l(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 go(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 kn(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 gp(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function vp(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 hn({onSelect:e,multiple:t=true,pickerMode:r=false}){let{permissions:o}=Ur(),a=o?.media?.create!==false,n=o?.media?.delete!==false,s=o?.media?.update!==false,[l,i]=wa.useState([]),[d,c]=wa.useState(true),[m,g]=wa.useState([]),[f,b]=wa.useState(""),[v,x]=wa.useState(""),[y,u]=wa.useState("all"),[h,R]=wa.useState("grid"),[S,w]=wa.useState(null),[C,p]=wa.useState(false),[D,M]=wa.useState(false),[I,B]=wa.useState(false),[F,oe]=wa.useState({}),[me,O]=wa.useState(false),[K,se]=wa.useState(false),[X,G]=wa.useState(null),[Re,Ae]=wa.useState(false),[T,_]=wa.useState(false),[de,ke]=wa.useState(1),[we,Ne]=wa.useState(0),[L,z]=wa.useState(1),We=40,[ye,Fe]=wa.useState(new Set),{confirm:pt,alert:Rt}=it(),[Jt,vt]=wa.useState(false),q=wa.useRef(null),[ee,le]=wa.useState(),xe=wa.useRef(null),Ce=wa.useCallback(async()=>{c(true);try{let N=new URLSearchParams({page:de.toString(),limit:We.toString()});f&&N.append("folder",f),v&&N.append("search",v),y!=="all"&&N.append("type",y);let ne=await Be(zr(`/api/media?${N}`));i((ne.docs||[]).map(Pe=>({...Pe,type:vp(Pe.mimeType)}))),Ne(ne.totalDocs||0),z(ne.totalPages||1);}catch(N){console.error("Failed to load media:",N);}finally{c(false);}},[de,f,v,y]),et=wa.useCallback(async()=>{try{let N=await Be(zr("/api/media/folders"));g(Array.isArray(N)?N:N.folders||[]);}catch(N){console.error("Failed to load folders:",N);}},[]),Ct=wa.useCallback(async()=>{try{let ne=!!(await Be("/api/globals/storage-settings"))?.data?.provider;G(ne);}catch{G(false);}},[]);wa.useEffect(()=>{r||Ct();},[Ct,r]),wa.useEffect(()=>{r||X===false&&!Re&&(Ae(true),_(true));},[r,X,Re]),wa.useEffect(()=>{Ce();},[Ce]),wa.useEffect(()=>{et();},[et]),wa.useEffect(()=>{if(r)return;let N=ne=>{let Pe=ne.clipboardData?.files;Pe&&Pe.length>0&&P(Pe);};return window.addEventListener("paste",N),()=>window.removeEventListener("paste",N)},[r,f,X]);let P=async N=>{if(!X){_(true);return}B(true);let ne=0,Pe=0;for(let qt=0;qt<N.length;qt++){let Bt=N[qt];try{let vr=new FormData;vr.append("file",Bt),f&&vr.append("folder",f),await ga("/api/media/upload",vr,ir=>{oe(ts=>({...ts,[Bt.name]:ir}));}),ne++;}catch(vr){console.error(`Upload failed for ${Bt.name}:`,vr),Pe++;}}B(false),oe({}),Ce(),et(),Pe>0&&E.error(`${Pe} file(s) failed to upload`),ne>0&&E.success(`${ne} file(s) uploaded successfully`);},W=()=>{pt({title:"Delete Media",message:`Are you sure you want to delete ${ye.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let N of Array.from(ye))await ht(`/api/media/${N}`);Fe(new Set),Ce(),E.success(`${ye.size} item(s) deleted`);}catch(N){console.error("Bulk delete failed:",N),E.error("Failed to delete some items");}}});},ae=(N,ne)=>{ne.stopPropagation();let Pe=new Set(ye);Pe.has(N)?Pe.delete(N):(t||Pe.clear(),Pe.add(N)),Fe(Pe);},sr=async N=>{try{await at("/api/media/folders",{name:N}),et(),O(!1),E.success(`Folder "${N}" created`);}catch(ne){console.error("Failed to create folder:",ne),E.error("Failed to create folder");}},lo=N=>{pt({title:"Delete Folder",message:`Are you sure you want to delete the folder "${N}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await ht(`/api/media/folders?path=${encodeURIComponent(N)}`),f===N&&b(""),et(),Ce(),E.success(`Folder "${N}" deleted`);}catch(ne){console.error("Failed to delete folder:",ne),E.error("Failed to delete folder");}}});},pa=async(N,ne)=>{try{let Pe=await Xt(`/api/media/${N}`,ne);i(qt=>qt.map(Bt=>Bt.id===N?Pe.doc:Bt)),S?.id===N&&w(Pe.doc),E.success("Metadata updated");}catch(Pe){console.error("Failed to update metadata:",Pe),E.error("Failed to update metadata");}},Wa=N=>{let{width:ne,height:Pe}=N.currentTarget,qt=mp.centerCrop(mp.makeAspectCrop({unit:"%",width:90},1,ne,Pe),ne,Pe);le(qt);},es=async()=>{if(!(!ee||!xe.current||!S)){B(true);try{let N=mp.convertToPixelCrop(ee,xe.current.width,xe.current.height),ne=document.createElement("canvas"),Pe=xe.current.naturalWidth/xe.current.width,qt=xe.current.naturalHeight/xe.current.height;ne.width=N.width,ne.height=N.height;let Bt=ne.getContext("2d");if(Bt){Bt.drawImage(xe.current,N.x*Pe,N.y*qt,N.width*Pe,N.height*qt,0,0,N.width,N.height);let vr=await new Promise(ir=>ne.toBlob(ir,S.mimeType));if(vr){let ir=new FormData;ir.append("file",vr,`cropped-${S.filename}`),f&&ir.append("folder",f),await ga("/api/media",ir),Ce(),M(!1),E.success("Cropped image saved");}}}catch(N){console.error("Crop failed:",N),E.error("Crop failed");}finally{B(false);}}},bt=wa.useMemo(()=>l.reduce((N,ne)=>(N.totalSize+=ne.fileSize||0,N),{totalSize:0}),[l]);return jsxRuntime.jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${Jt?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:N=>{N.preventDefault(),vt(true);},onDragLeave:()=>vt(false),onDrop:N=>{N.preventDefault(),vt(false),N.dataTransfer.files&&P(N.dataTransfer.files);}},children:[jsxRuntime.jsxs("div",{className:`flex flex-col lg:flex-row lg:items-center justify-between gap-6 border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 ${r?"p-2":"p-6 rounded-xl surface-tile"}`,children:[!r&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-3 mt-1",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[we," Items \xB7 ",kn(bt.totalSize)]})})]})}),jsxRuntime.jsxs("div",{className:`flex items-center gap-3 flex-wrap lg:flex-nowrap ${r?"w-full":""}`,children:[jsxRuntime.jsxs("div",{className:"relative group flex-1 min-w-[200px]",children:[jsxRuntime.jsx(lucideReact.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:"Search assets...",value:v,onChange:N=>x(N.target.value),className:"w-full pl-11 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"})]}),!r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[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)]",children:[jsxRuntime.jsx("button",{onClick:()=>R("grid"),className:`p-2 rounded-lg transition-all ${h==="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(lucideReact.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>R("list"),className:`p-2 rounded-lg transition-all ${h==="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(lucideReact.File,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("button",{onClick:()=>se(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(lucideReact.Filter,{className:"w-4 h-4"})})]}),a&&jsxRuntime.jsxs("button",{onClick:()=>q.current?.click(),className:"flex items-center gap-2 px-6 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(lucideReact.Maximize2,{className:"w-4 h-4"}),"Upload"]})]})]})]}),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(N=>jsxRuntime.jsxs("button",{onClick:()=>u(N),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${y===N?"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 ${y===N?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),N]},N))})]}),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:()=>O(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(lucideReact.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(lucideReact.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),m.map(N=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>b(N),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===N?"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(lucideReact.Folder,{fill:f===N?"currentColor":"none"})}),N]}),jsxRuntime.jsx("button",{onClick:ne=>{ne.stopPropagation(),lo(N);},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(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]},N))]})]})]})}),jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-[var(--kyro-bg)]",children:[jsxRuntime.jsx("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:d?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($t,{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(lucideReact.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&&a&&jsxRuntime.jsx("button",{onClick:()=>q.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"})]}):h==="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((N,ne)=>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 ${ye.has(N.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>w(N),onContextMenu:Pe=>{Pe.preventDefault(),ae(N.id,Pe);},children:[N.type==="image"?jsxRuntime.jsx("img",{src:N.url,alt:N.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:N.type==="video"?jsxRuntime.jsx(lucideReact.Film,{className:"w-8 h-8"}):N.type==="audio"?jsxRuntime.jsx(lucideReact.Music,{className:"w-8 h-8"}):N.type==="document"?jsxRuntime.jsx(lucideReact.FileText,{className:"w-8 h-8"}):N.type==="archive"?jsxRuntime.jsx(lucideReact.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(lucideReact.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:N.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:N.filename}),jsxRuntime.jsx("div",{className:"flex gap-1",children:jsxRuntime.jsx("button",{onClick:Pe=>ae(N.id,Pe),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${ye.has(N.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})})})]})}),ye.has(N.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(lucideReact.Check,{className:"w-4 h-4"})})]},N.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:ye.size===l.length,onChange:N=>{N.target.checked?Fe(new Set(l.map(ne=>ne.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(N=>jsxRuntime.jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${ye.has(N.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>w(N),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:ne=>ne.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:ye.has(N.id),onChange:ne=>ae(N.id,ne),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:N.type==="image"?jsxRuntime.jsx("img",{src:N.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(lucideReact.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:N.title||N.filename}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:N.filename})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsx(Dt,{variant:"outline",className:"text-[9px]",children:N.mimeType})}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:kn(N.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:gp(N.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:ne=>{ne.stopPropagation(),ae(N.id,ne);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${ye.has(N.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(lucideReact.Grid3X3,{className:"w-4 h-4"})})})]},N.id))})]})})}),jsxRuntime.jsx(vn,{page:de,totalPages:L,onPageChange:ke})]})]}),!r&&I&&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(Pr,{})}),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(F).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(F).map(([N,ne])=>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:N}),jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)]",children:[ne,"%"]})]}),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:`${ne}%`}})})]},N))})]})}),ye.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:ye.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 N=l.filter(ne=>ye.has(ne.id));e(N);},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&&n&&jsxRuntime.jsx("button",{onClick:W,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(lucideReact.Trash2,{className:"w-5 h-5"})})]})]}),K&&!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:()=>se(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:()=>se(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(lucideReact.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(N=>jsxRuntime.jsx("button",{onClick:()=>{u(N),se(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${y===N?"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:N},N))})]}),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:()=>{O(true),se(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(lucideReact.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{b(""),se(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(lucideReact.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),m.map(N=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{b(N),se(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===N?"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(lucideReact.Folder,{fill:f===N?"currentColor":"none"})}),N]}),jsxRuntime.jsx("button",{onClick:ne=>{ne.stopPropagation(),lo(N),se(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(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]},N))]})]})]})]})]}),jsxRuntime.jsx(cr,{open:!!S,onClose:()=>w(null),title:"Asset Details",subtitle:S?.filename,children:S&&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:[S.type==="image"?jsxRuntime.jsx("img",{src:go(S.url),alt:"",className:"w-full h-full object-contain p-4"}):S.type==="video"?jsxRuntime.jsx("video",{src:go(S.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(lucideReact.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(Dt,{variant:"outline",className:"text-xs font-bold",children:S.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:()=>p(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(lucideReact.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:S.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:kn(S.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:go(S.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(go(S.url)),E.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(lucideReact.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:S.alt||"",onChange:N=>pa(S.id,{alt:N.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:"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:S.caption||"",onChange:N=>pa(S.id,{caption:N.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:"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 N=document.createElement("a");N.href=go(S.url),N.download=S.filename,N.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(lucideReact.Download,{className:"w-4 h-4"}),"Download"]}),S.type==="image"&&s&&jsxRuntime.jsx("button",{onClick:()=>M(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(lucideReact.Crop,{className:"w-4 h-4"})}),n&&jsxRuntime.jsx("button",{onClick:()=>{pt({title:"Delete Asset",message:`Are you sure you want to delete ${S.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await ht(`/api/media/${S.id}`),w(null),Ce();}catch(N){console.error("Delete failed:",N),E.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(lucideReact.Trash2,{className:"w-4 h-4"})})]})]})}),C&&S&&jsxRuntime.jsxs(Ut,{open:C,onClose:()=>p(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:S.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[kn(S.fileSize)," \xB7 ",S.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>p(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(lucideReact.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:S.type==="image"?jsxRuntime.jsx("img",{src:go(S.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):S.type==="video"?jsxRuntime.jsx("video",{src:go(S.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(lucideReact.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&&D&&S&&jsxRuntime.jsx(Ut,{open:D,onClose:()=>M(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-full p-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-8",children:[jsxRuntime.jsx("h3",{className:"text-white font-bold text-2xl tracking-tighter",children:"Crop Image"}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>M(false),className:"px-4 py-2 border border-white/20 text-white/80 hover:bg-white/10 rounded-lg font-bold text-sm transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",disabled:I,onClick:es,className:"px-4 py-2 bg-[var(--kyro-sidebar-active)] hover:opacity-90 text-[var(--kyro-sidebar-text-active)] rounded-lg font-bold text-sm transition-colors",children:I?"Saving...":"Save Crop"})]})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center overflow-auto",children:jsxRuntime.jsx(mp__default.default,{crop:ee,onChange:N=>le(N),children:jsxRuntime.jsx("img",{ref:xe,src:S.url,alt:"Crop preview",className:"max-h-[70vh] object-contain",onLoad:Wa})})})]})}),!r&&jsxRuntime.jsx(cl,{open:me,onClose:()=>O(false),onSubmit:sr,title:"Create New Folder",placeholder:"Folder name"}),!r&&jsxRuntime.jsx(Ut,{open:T,onClose:()=>_(false),title:"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(lucideReact.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:"/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:()=>{at("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{_(false),G(true),window.location.reload();}).catch(()=>{E.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:q,onChange:N=>{N.target.files&&P(N.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var Wp=[{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"}],hl=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let[a,n]=wa.useState(null),s=wa.useRef(null);if(wa.useEffect(()=>{function y(u){s.current&&!s.current.contains(u.target)&&n(null);}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),!e)return null;let l=()=>{o();},i=()=>{let y=e.getAttributes("link").href,u=window.prompt("URL",y);if(u!==null){if(u===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:u}).run();}},d=y=>{y==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(y).run(),n(null);},c=y=>{n(a===y?null:y);},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",g=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(lucideReact.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(lucideReact.AlignRight,{size:12}):jsxRuntime.jsx(lucideReact.AlignLeft,{size:12}),f=()=>e.isActive("orderedList")?jsxRuntime.jsx(lucideReact.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(lucideReact.CheckSquare,{size:12}):jsxRuntime.jsx(lucideReact.List,{size:12}),b=()=>e.isActive("codeBlock")?jsxRuntime.jsx(lucideReact.Terminal,{size:12}):jsxRuntime.jsx(lucideReact.Quote,{size:12}),v=({onClick:y,isActive:u=false,disabled:h=false,children:R,title:S})=>jsxRuntime.jsx("button",{type:"button",onClick:y,disabled:h,title:S,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
|
|
10
|
-
${
|
|
11
|
-
${h?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:R}),x=({onClick:
|
|
12
|
-
${
|
|
13
|
-
${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(
|
|
14
|
-
${e.isActive("heading",{level:
|
|
9
|
+
`})]}),document.body)}function Hr({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Vr({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function Ot({open:e,onClose:t,title:r,children:o,footer:a,size:n="md",variant:s="default"}){if(Ca.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 l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",full:"w-full h-full max-w-none rounded-none border-0"},i=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 ${i?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxRuntime.jsxs("div",{className:`relative ${l[n]} ${i?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!i&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${i?"":"border"} ${s==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!i&&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(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:`flex-1 overflow-auto ${i?"":"px-8 py-8"}`,children:o}),a&&!i&&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 Ns({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:s="Cancel",variant:l="default",loading:i=false}){return jsxRuntime.jsx(Ot,{open:e,onClose:t,title:o,size:"sm",footer:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:i,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:s}),jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:i,className:`kyro-btn kyro-btn-md ${l==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:i?"Loading...":n})]}),children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function fl({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,l]=Ca.useState(n),i=d=>{d.preventDefault(),s.trim()&&(r(s.trim()),l(""),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(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:i,children:[jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsx("input",{type:"text",value:s,onChange:d=>l(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 gl({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[s,l]=Ca.useState("crop"),[i,d]=Ca.useState(t?{unit:"%",...t}:void 0),[c,m]=Ca.useState(r||{x:40,y:40,width:20,height:20}),[f,v]=Ca.useState(!!r),b=Ca.useRef(null),g=Ca.useRef(null),[x,u]=Ca.useState(false),[y,h]=Ca.useState(null),R=Ca.useRef(null),P=(S,F)=>{s==="hotspot"&&(S.stopPropagation(),S.preventDefault(),F?h(F):u(true),R.current={x:S.clientX,y:S.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},w=Ca.useCallback(S=>{if(!R.current||!b.current)return;let F=b.current.getBoundingClientRect(),A=(S.clientX-R.current.x)/F.width*100,X=(S.clientY-R.current.y)/F.height*100,K=R.current;if(x){let $=K.hX+A,j=K.hY+X;$=Math.max(0,Math.min($,100-K.hW)),j=Math.max(0,Math.min(j,100-K.hH)),m(ae=>({...ae,x:$,y:j}));}else if(y){let $=K.hX,j=K.hY,ae=K.hW,ne=K.hH;y.includes("e")&&(ae=K.hW+A),y.includes("w")&&($=K.hX+A,ae=K.hW-A),y.includes("s")&&(ne=K.hH+X),y.includes("n")&&(j=K.hY+X,ne=K.hH-X),ae<5&&(ae=5,y.includes("w")&&($=K.hX+K.hW-5)),ne<5&&(ne=5,y.includes("n")&&(j=K.hY+K.hH-5)),$=Math.max(0,Math.min($,100-ae)),j=Math.max(0,Math.min(j,100-ne)),ae=Math.min(ae,100-$),ne=Math.min(ne,100-j),m({x:$,y:j,width:ae,height:ne});}},[x,y,c]),k=Ca.useCallback(()=>{u(false),h(null),R.current=null;},[]);return Ca.useEffect(()=>((x||y)&&(window.addEventListener("pointermove",w),window.addEventListener("pointerup",k)),()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",k);}),[x,y,w,k]),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:()=>l("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(lucideReact.Crop,{className:"w-4 h-4"}),"Crop"]}),jsxRuntime.jsxs("button",{onClick:()=>{l("hotspot"),f||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(lucideReact.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(void 0),v(false);},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(lucideReact.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:()=>{let S=i?.width&&i?.height?{x:i.x,y:i.y,width:i.width,height:i.height}:void 0;o(S,f?c:void 0);},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.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(hp__default.default,{crop:i,onChange:(S,F)=>d(F),locked:s==="hotspot",className:s==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsxRuntime.jsx("img",{ref:b,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:S=>{}})}),f&&b.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:b.current.width,height:b.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:S=>P(S),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:S=>P(S,"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:S=>P(S,"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:S=>P(S,"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:S=>P(S,"e")})]})]})})})]})}),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. This creates a bounding box for the image.":"Drag the circle to define the focal hotspot. This area will always remain visible when the image is resized."})]})}function Gr(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 wn(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 Sp(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Tp(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 Nn({onSelect:e,multiple:t=true,pickerMode:r=false}){let{permissions:o}=Ur(),a=o?.media?.create!==false,n=o?.media?.delete!==false,s=o?.media?.update!==false,[l,i]=Ca.useState([]),[d,c]=Ca.useState(true),[m,f]=Ca.useState(false),[v,b]=Ca.useState([]),[g,x]=Ca.useState(""),[u,y]=Ca.useState(""),[h,R]=Ca.useState("all"),[P,w]=Ca.useState("grid"),[k,p]=Ca.useState(null),[T,B]=Ca.useState(false),[S,F]=Ca.useState(false),[A,X]=Ca.useState(false),[K,$]=Ca.useState({}),[j,ae]=Ca.useState(false),[ne,H]=Ca.useState(false),[re,ve]=Ca.useState(null),[L,O]=Ca.useState(false),[pe,ge]=Ca.useState(false),[Se,Ne]=Ca.useState(1),[U,Y]=Ca.useState(0),[le,Re]=Ca.useState(1),Ue=40,[Ie,et]=Ca.useState(new Set),{confirm:Ct,alert:St}=dt(),[Q,te]=Ca.useState(false),ce=Ca.useRef(null),Te=Ca.useCallback(async C=>{C===1?c(true):f(true);try{let me=new URLSearchParams({page:C.toString(),limit:Ue.toString()});g&&me.append("folder",g),u&&me.append("search",u),h!=="all"&&me.append("type",h);let De=await Be(zr(`/api/media?${me}`)),qt=(De.docs||[]).map(Rt=>({...Rt,type:Tp(Rt.mimeType)}));i(Rt=>C===1?qt:[...Rt,...qt]),Y(De.totalDocs||0),Re(De.totalPages||1);}catch(me){console.error("Failed to load media:",me);}finally{c(false),f(false);}},[g,u,h,Ue]),Fe=Ca.useCallback(async()=>{try{let C=await Be(zr("/api/media/folders"));b(Array.isArray(C)?C:C.folders||[]);}catch(C){console.error("Failed to load folders:",C);}},[]),lt=Ca.useCallback(async()=>{try{let me=!!(await Be("/api/globals/storage-settings"))?.data?.provider;ve(me);}catch{ve(false);}},[]);Ca.useEffect(()=>{r||lt();},[lt,r]),Ca.useEffect(()=>{r||re===false&&!L&&(O(true),ge(true));},[r,re,L]),Ca.useEffect(()=>{Ne(1),Te(1);},[g,u,h,Te]);let Tt=()=>{if(m||Se>=le)return;let C=Se+1;Ne(C),Te(C);};Ca.useEffect(()=>{Fe();},[Fe]),Ca.useEffect(()=>{if(r)return;let C=me=>{let De=me.clipboardData?.files;De&&De.length>0&&I(De);};return window.addEventListener("paste",C),()=>window.removeEventListener("paste",C)},[r,g,re]);let I=async C=>{if(!re){ge(true);return}X(true);let me=0,De=0;for(let qt=0;qt<C.length;qt++){let Rt=C[qt];try{let fr=new FormData;fr.append("file",Rt),g&&fr.append("folder",g),await en("/api/media/upload",fr,os=>{$(Po=>({...Po,[Rt.name]:os}));}),me++;}catch(fr){console.error(`Upload failed for ${Rt.name}:`,fr),De++;}}X(false),$({}),Ne(1),Te(1),Fe(),De>0&&M.error(`${De} file(s) failed to upload`),me>0&&M.success(`${me} file(s) uploaded successfully`);},W=()=>{Ct({title:"Delete Media",message:`Are you sure you want to delete ${Ie.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let C of Array.from(Ie))await xt(`/api/media/${C}`);et(new Set),Ne(1),Te(1),M.success(`${Ie.size} item(s) deleted`);}catch(C){console.error("Bulk delete failed:",C),M.error("Failed to delete some items");}}});},ie=(C,me)=>{me.stopPropagation();let De=new Set(Ie);De.has(C)?De.delete(C):(t||De.clear(),De.add(C)),et(De);},sr=async C=>{try{await nt("/api/media/folders",{name:C}),Fe(),ae(!1),M.success(`Folder "${C}" created`);}catch(me){console.error("Failed to create folder:",me),M.error("Failed to create folder");}},po=C=>{Ct({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 xt(`/api/media/folders?path=${encodeURIComponent(C)}`),g===C&&x(""),Fe(),Ne(1),Te(1),M.success(`Folder "${C}" deleted`);}catch(me){console.error("Failed to delete folder:",me),M.error("Failed to delete folder");}}});},ya=async(C,me)=>{try{let De=await Gt(`/api/media/${C}`,me);i(qt=>qt.map(Rt=>Rt.id===C?De.doc:Rt)),k?.id===C&&p(De.doc),M.success("Metadata updated");}catch(De){console.error("Failed to update metadata:",De),M.error("Failed to update metadata");}},qa=async(C,me)=>{if(k)try{X(!0);let De={...k.metadata,crop:C,hotspot:me},qt=await Gt(`/api/media/${k.id}`,{metadata:De});i(Rt=>Rt.map(fr=>fr.id===k.id?qt.doc:fr)),p(qt.doc),F(!1),M.success("Focal metadata saved");}catch(De){console.error("Save failed:",De),M.error("Failed to save focal metadata");}finally{X(false);}},rs=Ca.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 ${Q?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:C=>{C.preventDefault(),te(true);},onDragLeave:()=>te(false),onDrop:C=>{C.preventDefault(),te(false),C.dataTransfer.files&&I(C.dataTransfer.files);}},children:[jsxRuntime.jsxs("div",{className:`flex flex-col lg:flex-row lg:items-center justify-between gap-6 border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 ${r?"p-2":"p-6 rounded-xl surface-tile"}`,children:[!r&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-3 mt-1",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[U," Items \xB7 ",wn(rs.totalSize)]})})]})}),jsxRuntime.jsxs("div",{className:`flex items-center gap-3 flex-wrap lg:flex-nowrap ${r?"w-full":""}`,children:[jsxRuntime.jsxs("div",{className:"relative group flex-1 min-w-[200px]",children:[jsxRuntime.jsx(lucideReact.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:"Search assets...",value:u,onChange:C=>y(C.target.value),className:"w-full pl-11 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"})]}),!r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[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)]",children:[jsxRuntime.jsx("button",{onClick:()=>w("grid"),className:`p-2 rounded-lg transition-all ${P==="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(lucideReact.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>w("list"),className:`p-2 rounded-lg transition-all ${P==="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(lucideReact.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(lucideReact.Filter,{className:"w-4 h-4"})})]}),a&&jsxRuntime.jsxs("button",{onClick:()=>ce.current?.click(),className:"flex items-center gap-2 px-6 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(lucideReact.Maximize2,{className:"w-4 h-4"}),"Upload"]})]})]})]}),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:()=>R(C),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${h===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 ${h===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:()=>ae(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(lucideReact.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>x(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===""?"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(lucideReact.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),v.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>x(C),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===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(lucideReact.Folder,{fill:g===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),po(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(lucideReact.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:[d?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(Et,{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(lucideReact.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&&a&&jsxRuntime.jsx("button",{onClick:()=>ce.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"})]}):P==="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 ${Ie.has(C.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>p(C),onContextMenu:De=>{De.preventDefault(),ie(C.id,De);},children:[C.type==="image"?jsxRuntime.jsx("img",{src: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(lucideReact.Film,{className:"w-8 h-8"}):C.type==="audio"?jsxRuntime.jsx(lucideReact.Music,{className:"w-8 h-8"}):C.type==="document"?jsxRuntime.jsx(lucideReact.FileText,{className:"w-8 h-8"}):C.type==="archive"?jsxRuntime.jsx(lucideReact.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(lucideReact.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:De=>ie(C.id,De),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${Ie.has(C.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})})})]})}),Ie.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(lucideReact.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:Ie.size===l.length,onChange:C=>{C.target.checked?et(new Set(l.map(me=>me.id))):et(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 ${Ie.has(C.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>p(C),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:me=>me.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:Ie.has(C.id),onChange:me=>ie(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:C.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(lucideReact.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(Pt,{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:wn(C.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Sp(C.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),ie(C.id,me);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${Ie.has(C.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(lucideReact.Grid3X3,{className:"w-4 h-4"})})})]},C.id))})]})}),!d&&Se<le&&jsxRuntime.jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsxRuntime.jsx("button",{onClick:Tt,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(kr,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&A&&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(kr,{})}),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(K).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(K).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))})]})}),Ie.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:Ie.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:()=>et(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=>Ie.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&&n&&jsxRuntime.jsx("button",{onClick:W,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(lucideReact.Trash2,{className:"w-5 h-5"})})]})]}),ne&&!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(lucideReact.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:()=>{R(C),H(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${h===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:()=>{ae(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(lucideReact.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{x(""),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===""?"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(lucideReact.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),v.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{x(C),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===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(lucideReact.Folder,{fill:g===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),po(C),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(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]},C))]})]})]})]})]}),jsxRuntime.jsx(dr,{open:!!k,onClose:()=>p(null),title:"Asset Details",subtitle:k?.filename,children:k&&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:[k.type==="image"?jsxRuntime.jsx("img",{src:Gr(k.url),alt:"",className:"w-full h-full object-contain p-4"}):k.type==="video"?jsxRuntime.jsx("video",{src:Gr(k.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(lucideReact.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(Pt,{variant:"outline",className:"text-xs font-bold",children:k.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:()=>B(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(lucideReact.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:k.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:wn(k.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:Gr(k.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(Gr(k.url)),M.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(lucideReact.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:k.alt||"",onChange:C=>ya(k.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:"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:k.caption||"",onChange:C=>ya(k.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:"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=Gr(k.url),C.download=k.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(lucideReact.Download,{className:"w-4 h-4"}),"Download"]}),k.type==="image"&&s&&jsxRuntime.jsx("button",{onClick:()=>F(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(lucideReact.Crop,{className:"w-4 h-4"})}),n&&jsxRuntime.jsx("button",{onClick:()=>{Ct({title:"Delete Asset",message:`Are you sure you want to delete ${k.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await xt(`/api/media/${k.id}`),p(null),Te();}catch(C){console.error("Delete failed:",C),M.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(lucideReact.Trash2,{className:"w-4 h-4"})})]})]})}),T&&k&&jsxRuntime.jsxs(Ot,{open:T,onClose:()=>B(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:k.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[wn(k.fileSize)," \xB7 ",k.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>B(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(lucideReact.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:k.type==="image"?jsxRuntime.jsx("img",{src:Gr(k.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):k.type==="video"?jsxRuntime.jsx("video",{src:Gr(k.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(lucideReact.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&&S&&k&&jsxRuntime.jsx(Ot,{open:S,onClose:()=>F(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsx(gl,{url:Gr(k.url),initialCrop:k.metadata?.crop,initialHotspot:k.metadata?.hotspot,onSave:qa,onCancel:()=>F(false),isSaving:A})}),!r&&jsxRuntime.jsx(fl,{open:j,onClose:()=>ae(false),onSubmit:sr,title:"Create New Folder",placeholder:"Folder name"}),!r&&jsxRuntime.jsx(Ot,{open:pe,onClose:()=>ge(false),title:"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(lucideReact.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:"/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:()=>{nt("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{ge(false),ve(true),window.location.reload();}).catch(()=>{M.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:ce,onChange:C=>{C.target.files&&I(C.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var tm=[{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"}],Al=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let[a,n]=Ca.useState(null),s=Ca.useRef(null);if(Ca.useEffect(()=>{function u(y){s.current&&!s.current.contains(y.target)&&n(null);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]),!e)return null;let l=()=>{o();},i=()=>{let u=e.getAttributes("link").href,y=window.prompt("URL",u);if(y!==null){if(y===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:y}).run();}},d=u=>{u==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(u).run(),n(null);},c=u=>{n(a===u?null:u);},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",f=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(lucideReact.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(lucideReact.AlignRight,{size:12}):jsxRuntime.jsx(lucideReact.AlignLeft,{size:12}),v=()=>e.isActive("orderedList")?jsxRuntime.jsx(lucideReact.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(lucideReact.CheckSquare,{size:12}):jsxRuntime.jsx(lucideReact.List,{size:12}),b=()=>e.isActive("codeBlock")?jsxRuntime.jsx(lucideReact.Terminal,{size:12}):jsxRuntime.jsx(lucideReact.Quote,{size:12}),g=({onClick:u,isActive:y=false,disabled:h=false,children:R,title:P})=>jsxRuntime.jsx("button",{type:"button",onClick:u,disabled:h,title:P,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
|
|
10
|
+
${y?"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
|
+
${h?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:R}),x=({onClick:u,isActive:y,children:h,title:R})=>jsxRuntime.jsxs("button",{type:"button",onClick:u,title:R,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
|
+
${y?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[h,jsxRuntime.jsx(lucideReact.ChevronDown,{size:10,className:"opacity-60"})]});return jsxRuntime.jsxs("div",{ref:s,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(g,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().chain().focus().undo().run(),title:"Undo (Ctrl+Z)",children:jsxRuntime.jsx(lucideReact.Undo,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().chain().focus().redo().run(),title:"Redo (Ctrl+Y)",children:jsxRuntime.jsx(lucideReact.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(g,{onClick:()=>e.chain().focus().toggleBold().run(),disabled:!e.can().chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:"Bold (Ctrl+B)",children:jsxRuntime.jsx(lucideReact.Bold,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleItalic().run(),disabled:!e.can().chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:"Italic (Ctrl+I)",children:jsxRuntime.jsx(lucideReact.Italic,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleUnderline().run(),disabled:!e.can().chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:"Underline (Ctrl+U)",children:jsxRuntime.jsx(lucideReact.Underline,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleStrike().run(),disabled:!e.can().chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:"Strikethrough",children:jsxRuntime.jsx(lucideReact.Strikethrough,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleCode().run(),disabled:!e.can().chain().focus().toggleCode().run(),isActive:e.isActive("code"),title:"Inline Code",children:jsxRuntime.jsx(lucideReact.Code,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:"Highlight Text",children:jsxRuntime.jsx(lucideReact.Highlighter,{size:12})}),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center",children:[jsxRuntime.jsx(g,{onClick:()=>c("color"),title:"Text Color",isActive:a==="color"||e.isActive("textStyle"),children:jsxRuntime.jsx(lucideReact.Palette,{size:12})}),a==="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:tm.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>d(u.value),title:u.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:u.value==="inherit"?"transparent":u.value},children:u.value==="inherit"&&jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] text-[var(--kyro-text)] font-semibold",children:"\u2205"})},u.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(x,{onClick:()=>c("heading"),isActive:a==="heading",title:"Heading hierarchy",children:jsxRuntime.jsx("span",{className:"font-medium text-[11px] leading-none min-w-[70px] text-left",children:m()})}),a==="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(),n(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(u=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:u}).run(),n(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:u})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",u]},u))]})]}),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(x,{onClick:()=>c("lists"),isActive:a==="lists",title:"List Types",children:v()}),a==="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(),n(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
15
|
${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.List,{size:12}),"Bullet List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleOrderedList().run(),n(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
16
|
${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.ListOrdered,{size:12}),"Ordered List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleTaskList().run(),n(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
17
|
${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.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(x,{onClick:()=>c("blocks"),isActive:a==="blocks",title:"Structural Blocks",children:b()}),a==="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(),n(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
18
|
${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.Quote,{size:12}),"Blockquote"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleCodeBlock().run(),n(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(lucideReact.Terminal,{size:12}),"Code Block"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),n(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(lucideReact.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(x,{onClick:()=>c("align"),isActive:a==="align",title:"Alignment",children:
|
|
19
|
+
${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.Terminal,{size:12}),"Code Block"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),n(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(lucideReact.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(x,{onClick:()=>c("align"),isActive:a==="align",title:"Alignment",children:f()}),a==="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(),n(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
20
|
${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.AlignLeft,{size:12}),"Align Left"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("center").run(),n(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
21
|
${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.AlignCenter,{size:12}),"Align Center"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("right").run(),n(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(lucideReact.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(
|
|
22
|
+
${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.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(g,{onClick:i,isActive:e.isActive("link"),title:"Link",children:jsxRuntime.jsx(lucideReact.Link,{size:12})}),jsxRuntime.jsx(g,{onClick:l,title:"Add Image",children:jsxRuntime.jsx(lucideReact.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(g,{onClick:()=>r(!t),title:t?"Collapse Workspace":"Enlarge Workspace",children:t?jsxRuntime.jsx(lucideReact.Minimize2,{size:12}):jsxRuntime.jsx(lucideReact.Maximize2,{size:12})})})]})};function jo({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false);return Ca.useEffect(()=>{s(true);},[]),n?jsxRuntime.jsx(rm,{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
|
|
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 rm({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false),[l,i]=Ca.useState(0),[d,c]=Ca.useState(false);Ca.useEffect(()=>{if(!n){i(0);return}let f=document.querySelector('[data-kyro-slide-panel="true"]'),v=()=>{i(f?f.getBoundingClientRect().width:0);};v();let b=new MutationObserver(()=>{v();});f&&b.observe(f),window.addEventListener("resize",v);let g=setInterval(v,100);return ()=>{b&&b.disconnect(),window.removeEventListener("resize",v),clearInterval(g);}},[n]);let m=react.useEditor({extensions:[Dp__default.default.configure({codeBlock:true,link:false,underline:false}),Pp__default.default.configure({openOnClick:false}),Ip__default.default,Bp__default.default.configure({types:["heading","paragraph"]}),Lp__default.default,Mp__default.default.configure({multicolor:true}),Ep__default.default,$p__default.default.configure({nested:true}),extensionTextStyle.TextStyle,Up__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 Ca.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(pt,{field:e,error:o,children:[n?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:()=>s(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(
|
|
26
|
+
${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.jsx(Al,{editor:m,isExpanded:n,setIsExpanded:s,onOpenMediaPicker:()=>c(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px]",children:jsxRuntime.jsx(react.EditorContent,{editor:m})})]}),n&&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(Al,{editor:m,isExpanded:n,setIsExpanded:s,onOpenMediaPicker:()=>c(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:`
|
|
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
|
-
`}),d&&jsxRuntime.jsx(cr,{open:d,onClose:()=>c(false),title:"Select Image",width:"xl",children:jsxRuntime.jsx(hn,{pickerMode:true,multiple:false,onSelect:g=>{if(g&&g.length>0){let f=g[0];m.chain().focus().setImage({src:f.url,alt:f.alt||f.title||"",title:f.title||""}).run();}c(false);}})})]})}var Uo={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)"}},Ra={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 Aa(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 Sl=wa.createContext(null);function zo(){let e=wa.useContext(Sl);return e||{mode:"light",theme:Uo,lightTheme:Uo,darkTheme:Ra,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function Nl(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`,Cl(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Cl(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 Cl(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 wr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=wa.useState(t),[s,l]=wa.useState(r||{}),[i,d]=wa.useState(o||{}),c=Aa(Uo,s),m=Aa(Ra,i),g=wa.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?m:c:a==="dark"?m:c,[a,c,m]),[f,b]=wa.useState(g());wa.useEffect(()=>{let y=g();b(y),Nl(y);},[g]),wa.useEffect(()=>{if(a!=="system")return;let y=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>{let h=g();b(h),Nl(h);};return y.addEventListener("change",u),()=>y.removeEventListener("change",u)},[a,g]);let v=wa.useCallback(y=>{l(u=>({...u,...y})),d(u=>({...u,...y}));},[]),x=wa.useCallback(y=>`var(--kyro-${y})`,[]);return jsxRuntime.jsx(Sl.Provider,{value:{mode:a,theme:f,lightTheme:c,darkTheme:m,setMode:n,updateTheme:v,getCssVar:x},children:e})}var Cn=e=>jsxRuntime.jsx(wr,{defaultMode:"light",...e}),Sn=e=>jsxRuntime.jsx(wr,{defaultMode:"dark",...e});var tm=wa.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),rm=[{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"}],Rl={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())},Fa=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=wa.useState(false),[l,i]=wa.useState(false),[d,c]=wa.useState([]),[m,g]=wa.useState(false),[f,b]=wa.useState(false),[v,x]=wa.useState(false),{theme:y}=zo(),u=y.colors?.accent||y.colors?.primary||"#6366f1",h=e.language?.toLowerCase()||"javascript";wa.useEffect(()=>{s(true),i(document.documentElement.classList.contains("dark"));let M=new MutationObserver(()=>{i(document.documentElement.classList.contains("dark"));});return M.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>M.disconnect()},[]),wa.useEffect(()=>{if(!n)return;(async()=>{g(true);try{let B=await(Rl[h]||Rl.javascript)();c([B]);}catch(I){console.error("Failed to load language extension:",I),c([]);}finally{g(false);}})();},[h,n]);let R=wa.useCallback(M=>r?.(M),[r]),S=wa.useCallback(()=>{navigator.clipboard.writeText(t),b(true),setTimeout(()=>b(false),1500);},[t]),w=wa.useCallback(()=>{x(M=>!M),document.body.style.overflow=v?"":"hidden";},[v]),C=l?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,p=rm.find(M=>M.value===h)?.label||h,D=(M,I=1)=>{let B=parseInt(M.slice(1,3),16),F=parseInt(M.slice(3,5),16),oe=parseInt(M.slice(5,7),16);return `rgba(${B}, ${F}, ${oe}, ${I})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":u,"--accent-light":D(u,.1),"--accent-light-2":D(u,.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:m?"var(--kyro-surface-accent)":u,color:m?"var(--kyro-text-muted)":"white"},children:m?"...":p})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:S,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:w,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:v?"Exit":"Expand"})]})]}),jsxRuntime.jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${v?"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:u}}),jsxRuntime.jsx(wa.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:u,borderWidth:"2px"}})}),children:jsxRuntime.jsx(tm,{value:t??"",height:v?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:C,onChange:R,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:
|
|
82
|
+
`}),d&&jsxRuntime.jsx(dr,{open:d,onClose:()=>c(false),title:"Select Image",width:"xl",children:jsxRuntime.jsx(Nn,{pickerMode:true,multiple:false,onSelect:f=>{if(f&&f.length>0){let v=f[0];m.chain().focus().setImage({src:v.url,alt:v.alt||v.title||"",title:v.title||""}).run();}c(false);}})})]})}var _o={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)"}},Fa={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 Da(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 Il=Ca.createContext(null);function Ho(){let e=Ca.useContext(Il);return e||{mode:"light",theme:_o,lightTheme:_o,darkTheme:Fa,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function Dl(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`,Pl(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Pl(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 Pl(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 hr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=Ca.useState(t),[s,l]=Ca.useState(r||{}),[i,d]=Ca.useState(o||{}),c=Da(_o,s),m=Da(Fa,i),f=Ca.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?m:c:a==="dark"?m:c,[a,c,m]),[v,b]=Ca.useState(f());Ca.useEffect(()=>{let u=f();b(u),Dl(u);},[f]),Ca.useEffect(()=>{if(a!=="system")return;let u=window.matchMedia("(prefers-color-scheme: dark)"),y=()=>{let h=f();b(h),Dl(h);};return u.addEventListener("change",y),()=>u.removeEventListener("change",y)},[a,f]);let g=Ca.useCallback(u=>{l(y=>({...y,...u})),d(y=>({...y,...u}));},[]),x=Ca.useCallback(u=>`var(--kyro-${u})`,[]);return jsxRuntime.jsx(Il.Provider,{value:{mode:a,theme:v,lightTheme:c,darkTheme:m,setMode:n,updateTheme:g,getCssVar:x},children:e})}var Tn=e=>jsxRuntime.jsx(hr,{defaultMode:"light",...e}),Rn=e=>jsxRuntime.jsx(hr,{defaultMode:"dark",...e});var dm=Ca.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),cm=[{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"}],Ll={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())},Pa=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(false),[d,c]=Ca.useState([]),[m,f]=Ca.useState(false),[v,b]=Ca.useState(false),[g,x]=Ca.useState(false),{theme:u}=Ho(),y=u.colors?.accent||u.colors?.primary||"#6366f1",h=e.language?.toLowerCase()||"javascript";Ca.useEffect(()=>{s(true),i(document.documentElement.classList.contains("dark"));let B=new MutationObserver(()=>{i(document.documentElement.classList.contains("dark"));});return B.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>B.disconnect()},[]),Ca.useEffect(()=>{if(!n)return;(async()=>{f(true);try{let F=await(Ll[h]||Ll.javascript)();c([F]);}catch(S){console.error("Failed to load language extension:",S),c([]);}finally{f(false);}})();},[h,n]);let R=Ca.useCallback(B=>r?.(B),[r]),P=Ca.useCallback(()=>{navigator.clipboard.writeText(t),b(true),setTimeout(()=>b(false),1500);},[t]),w=Ca.useCallback(()=>{x(B=>!B),document.body.style.overflow=g?"":"hidden";},[g]),k=l?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,p=cm.find(B=>B.value===h)?.label||h,T=(B,S=1)=>{let F=parseInt(B.slice(1,3),16),A=parseInt(B.slice(3,5),16),X=parseInt(B.slice(5,7),16);return `rgba(${F}, ${A}, ${X}, ${S})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":y,"--accent-light":T(y,.1),"--accent-light-2":T(y,.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:m?"var(--kyro-surface-accent)":y,color:m?"var(--kyro-text-muted)":"white"},children:m?"...":p})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:P,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:w,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:y}}),jsxRuntime.jsx(Ca.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:y,borderWidth:"2px"}})}),children:jsxRuntime.jsx(dm,{value:t??"",height:g?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:k,onChange:R,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:y},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 ym(e){return e?e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").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 Fs=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(false);Ca.useEffect(()=>{i(true);},[]);let d=Ca.useCallback(f=>{r?.(f.target.value);},[r]),c=Ca.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:[c," 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:()=>s(false),className:`px-3 py-1 text-xs font-medium transition-colors ${n?"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:()=>s(true),className:`px-3 py-1 text-xs font-medium transition-colors ${n?"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:n?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:ym(t)}}):jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-muted)] italic",children:"Nothing to preview"})}):jsxRuntime.jsx("textarea",{value:t??"",onChange:d,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:`Enter markdown content...
|
|
84
84
|
|
|
85
85
|
# Heading 1
|
|
86
86
|
## Heading 2
|
|
@@ -96,16 +96,16 @@
|
|
|
96
96
|
|
|
97
97
|
\`\`\`
|
|
98
98
|
code block
|
|
99
|
-
\`\`\``})}),!n&&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 Tn({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=wa.useState(false),[l,i]=wa.useState(false),d=t??"",c=d.length>8?d.slice(0,-8)+"*".repeat(8):d,m=async()=>{if(d)try{await navigator.clipboard.writeText(d),s(!0),setTimeout(()=>s(!1),1800);}catch{let f=document.createElement("textarea");f.value=d,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.select(),document.execCommand("copy"),document.body.removeChild(f),s(true),setTimeout(()=>s(false),1800);}},g=()=>{if(l||a)return;i(true);let f=new Uint8Array(32);crypto.getRandomValues(f);let b=Array.from(f).map(v=>v.toString(16).padStart(2,"0")).join("");r?.(b),setTimeout(()=>i(false),400);};return jsxRuntime.jsx(dt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:"relative flex-1",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:c,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider pr-10 opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})}),jsxRuntime.jsx("button",{type:"button",onClick:m,disabled:!d||a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:n?"Copied!":"Copy full secret",children:n?jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 text-[var(--kyro-success)]"}):jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:g,disabled:a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-warning)] hover:bg-[var(--kyro-warning)]/10 transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:"Regenerate secret",children:jsxRuntime.jsx(lucideReact.RefreshCw,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})})}var Rn=null,Dl=false,Ss=async()=>(Rn&&Dl||(Rn=unstorage.createStorage({driver:mm__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),Dl=true),Rn),um=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Ss()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Ss()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Ss()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},Ee=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,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);JSON.stringify(o)!==JSON.stringify(a.lastSavedData[r])?n.add(r):n.delete(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},l=s;for(let i=0;i<n.length-1;i++)l[n[i]]===void 0&&(l[n[i]]={}),l[n[i]]={...l[n[i]]},l=l[n[i]];return l[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})),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,l]of Object.entries(a))o-new Date(l.draftUpdatedAt).getTime()<6048e5&&(n[s]=l);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(()=>um()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function An(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function Ho({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,s=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:i,setIsSlugLocked:d,formData:c}=Ee(),m=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",g=t==null?"":String(t),f={id:e.name,value:g,onChange:b=>r?.(b.target.value),placeholder:e.admin?.placeholder,disabled:a||n||l&&i,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||n||l&&i?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsxRuntime.jsx(dt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"relative",children:[s?jsxRuntime.jsx("textarea",{...f,rows:e.rows||4}):jsxRuntime.jsx("input",{type:m,...f,pattern:e.pattern}),l&&jsxRuntime.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!i&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r?.(An(c[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:"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:()=>d(!i),className:`p-1.5 rounded transition-colors ${i?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:i?"Unlock slug":"Lock slug",children:i?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:g.length>60?"text-red-500":g.length>=40?"text-green-500":"text-amber-600",children:[g.length," / 60 \u2014 ",g.length>60?"Too Long":g.length>=40?"Ideal":"Short"]})})]})})}function Fn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(dt,{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 Dn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(dt,{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:l=>r?.(l.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 Pn({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(dt,{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 Pa(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Bn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Ln(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Da(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 vo(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 vo(s.fields,n,r);if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&vo(i.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let i=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of s.blocks)if(c.slug===i&&c.fields&&Array.isArray(c.fields))return vo(c.fields,d,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?vo(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)&&vo(s.fields,t,r))return true;if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&vo(i.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,...l}=n;if(o.admin={...o.admin,...l},s&&o.fields&&Array.isArray(o.fields))for(let[i,d]of Object.entries(s))vo(o.fields,i,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 Da(t,Object.values(templates.mediaCollections)),Da(t,Object.values(templates.authCollections)),{collections:Bn(t),globals:Ln(r)}}function bm(e){let t=Pa(e.collections),r=Pa(e.globals);if(t.length===0&&r.length===0)return vm("kitchen-sink");let o=[];return Da(o,Object.values(templates.mediaCollections)),Da(o,Object.values(templates.authCollections)),Da(o,t),{collections:Bn(o),globals:Ln(r)}}var In=null;function xm(){if(In)return In;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Do__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return In=JSON.parse(Do__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),In}catch{}return null}var _l=xm()||{collections:[],globals:[]},Hl=bm(_l);gm(Hl.collections,_l.collectionOverrides);var Vl=Hl,Vo=Vl.collections,Kl=Vl.globals,As=["users","audit_logs"];Object.values(Vo).filter(e=>!As.includes(e.slug)&&e.admin?.hidden!==true);function Mn({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,m]=wa.useState(null),g=JSON.stringify(n||{}),f=JSON.stringify(s||{});wa.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let x=setTimeout(async()=>{try{let y="";if(l)y=`${kr}/${l}/dynamic-options/${e.name}`;else if(i)y=`${kr}/globals/${i}/dynamic-options/${e.name}`;else return;let u=await ot(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(g),siblingData:JSON.parse(f)})});if(u.ok){let h=await u.json();h.options&&m(h.options);}}catch(y){console.error("Failed to fetch dynamic options:",y);}},300);return ()=>clearTimeout(x)},[g,f,e.name,e.options,l,i]);let b=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?b=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(b=e.options)),e.dynamicOptions==="collections"&&(b=Object.keys(Vo).filter(v=>v!=="media").map(v=>({label:Vo[v]?.label||v,value:v}))),jsxRuntime.jsx(dt,{field:e,error:o,children:jsxRuntime.jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:v=>{if(e.hasMany){let x=Array.from(v.target.selectedOptions,y=>y.value);r?.(x);}else r?.(v.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),b.map(v=>jsxRuntime.jsx("option",{value:v.value,children:v.label},v.value))]})})}function En({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 Ls(e){let t=e?.mainTabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function Bm({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:l,transform:i,transition:d,isDragging:c}=sortable.useSortable({id:e}),m={transform:utilities.CSS.Transform.toString(i),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxRuntime.jsxs("span",{ref:l,style:m,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(lucideReact.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(lucideReact.X,{className:"w-3 h-3"})})]})}function Lm({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=wa.useState(false),[l,i]=wa.useState(""),[d,c]=wa.useState([]),[m,g]=wa.useState(false),[f,b]=wa.useState([]),v=wa.useRef(new Set),x=wa.useRef(null),y=wa.useRef(()=>{});y.current=r||(()=>{});let u=e.hasMany,h=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],R=h.length>1,[S,w]=wa.useState(h[0]||""),C=wa.useCallback(()=>t?(u?Array.isArray(t)?t:[]:t?[t]:[]).map(K=>typeof K=="object"&&K!==null?K.value||K.id||"":String(K)).filter(Boolean):[],[t,u]),p=wa.useCallback(O=>{O.length!==0&&O.forEach(K=>{if(v.current.has(K))return;v.current.add(K);let se=R?(()=>{if(!t)return S;let G=(u?Array.isArray(t)?t:[]:[t]).find(Re=>typeof Re=="object"&&Re!==null?Re.value===K||Re.id===K:false);return G&&typeof G=="object"&&G.relationTo||S})():S;Be(`/api/${se}/${K}`).then(X=>{let G=X.data||X;!G||typeof G!="object"||b(Re=>Re.some(Ae=>Ae.id===K)?Re:[...Re,{...G,id:String(G.id),relationTo:se}]);}).catch(()=>{});});},[R,t,S,u]);wa.useEffect(()=>{let O=C();p(O);},[C,p]);let D=wa.useCallback((O="")=>{g(true);let se=`/api/${S}?${Qa(O,["title","name","label","email"])}`;Be(se).then(X=>{c(G=>{let Re=new Set(G.map(T=>T.id)),Ae=(X.docs||[]).filter(T=>!Re.has(T.id)).map(T=>({...T,id:T.id}));return [...G,...Ae]}),g(false);}).catch(()=>{g(false);});},[S]);wa.useEffect(()=>{n&&(c([]),D(l));},[n,S]),wa.useEffect(()=>{let O=K=>{x.current&&!x.current.contains(K.target)&&s(false);};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);let M=O=>typeof O=="object"&&O!==null?O.value||O.id||"":String(O),I=O=>{let K=O.id;return t?u&&Array.isArray(t)?t.some(se=>M(se)===K):M(t)===K:false},B=O=>{let K=O.id;if(u){let se=Array.isArray(t)?t:[];if(I(O))y.current?.(se.filter(X=>M(X)!==K));else {let X=R?{relationTo:S,value:K}:K;y.current?.([...se,X]);}}else if(I(O))y.current?.(null);else {let se=R?{relationTo:S,value:K}:K;y.current?.(se),s(false),i("");}},F=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),oe=O=>{let{active:K,over:se}=O;if(!se||K.id===se.id)return;let X=u?Array.isArray(t)?t:[]:[],G=X.findIndex(Ae=>M(Ae)===K.id),Re=X.findIndex(Ae=>M(Ae)===se.id);if(G!==-1&&Re!==-1){let Ae=[...X],[T]=Ae.splice(G,1);Ae.splice(Re,0,T),y.current?.(Ae);}},me=()=>{if(!t)return null;let O=u?Array.isArray(t)?t:[]:t?[t]:[],K=O.map(se=>M(se));return u&&O.length>1?jsxRuntime.jsx(core.DndContext,{sensors:F,collisionDetection:core.closestCenter,onDragEnd:oe,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:K,strategy:sortable.horizontalListSortingStrategy,children:O.map(se=>{let X=M(se),G=f.find(T=>T.id===X),Re=G?Ls(G):X.slice(0,12),Ae=R&&G?G.relationTo:null;return jsxRuntime.jsx(Bm,{id:X,label:Re,relation:Ae,onRemove:()=>{let T=O.filter(_=>M(_)!==X);y.current?.(T);},disabled:a},X)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:O.map(se=>{let X=M(se),G=f.find(T=>T.id===X),Re=G?Ls(G):X.slice(0,12),Ae=R&&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:[Ae&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[Ae,":"]}),Re,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let T=O.filter(_=>M(_)!==X);y.current?.(u?T:T[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},X)})})};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:x,className:"relative",children:[R&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:h.map(O=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{w(O),c([]),i("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${S===O?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:O},O))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.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:O=>{i(O.target.value),s(true),D(O.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${S}...`,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(lucideReact.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${n?"rotate-180":""}`})})]}),n&&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..."}):d.length===0?jsxRuntime.jsx(En,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:d.map(O=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>B(O),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${I(O)?"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:Ls(O)}),I(O)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in O&&typeof O.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:O.slug})]},O.id))})}),me()]}),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 Ia=Lm;var bo=wa.createContext(null);function Wl(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=Ms(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=Go(a),{blocks:l}=o(),i=[...l];n!==void 0?i.splice(n,0,s):i.push(s),r({blocks:i});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:s}=o(),l=Ba(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=[...i];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),s=Ba(n,l=>{let i=l.filter(d=>d.id!==a);return i.length!==l.length?{newList:i,found:true}:{newList:l,found:false}});if(s!==n){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}},moveBlock:(a,n)=>{let{blocks:s}=o(),l=Ba(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<i.length){let m=[...i];return [m[d],m[c]]=[m[c],m[d]],{newList:m,found:true}}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}}}))}function Ms(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=Ms(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?Ms(o.children):o.children}))}),r}):[]}function Go(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":{heading:"",subheading:""},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 Ue(e){let t=wa.useContext(bo);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 l=o(s.children);if(l)return l}}}};return o(r.blocks)})}function Le(){let e=wa.useContext(bo);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 Ba(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(s=>{let l={...s},i=false;if(s.children&&s.children.length>0){let d=Ba(s.children,t);d!==s.children&&(l.children=d,i=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 m=Ba(c.children,t);if(m!==c.children)return {...c,children:m}}return c});d.some((c,m)=>c!==s.data.columnData[m])&&(l.data={...l.data,columnData:d},i=true);}return i&&(a=true),i?l:s});return a?n:e}function Ma({open:e,onClose:t,onSelect:r,children:o}){return e?jsxRuntime.jsxs(cr,{open:e,onClose:t,title:"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]}):null}function Jl({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 $s=({text:e="",onChange:t,compact:r=false})=>jsxRuntime.jsx("div",{className:r?"":"space-y-3",children:jsxRuntime.jsx("input",{type:"text",value:e,onChange:a=>t("text",a.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:"Enter heading text..."})});var xo=({id:e,type:t,label:r,children:o,className:a=""})=>{let{moveBlock:n,removeBlock:s}=Le();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:()=>n(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var Ql=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(xo,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx($s,{text:a.text||"",onChange:n,compact:true})})};var Zl=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(xo,{id:e.id,type:"paragraph",label:"Paragraph",children:jsxRuntime.jsx("textarea",{value:a.text||"",onChange:s=>n("text",s.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:"Enter paragraph text..."})})};var ed=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Remove",children:jsxRuntime.jsx(lucideReact.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(dr,{field:{label:"Image Asset",name:"src",maxCount:1},value:s.src,onChange:i=>l("src",i)})]}),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:s.alt||"",onChange:i=>l("alt",i.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:"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:s.caption||"",onChange:i=>l("caption",i.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:"Image caption..."})]})]})]})};var Us=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{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:s=>r("src",s.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:s=>r("title",s.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:"Video title (optional)..."})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(dr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(s=>r("src",s))}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsxRuntime.jsx("input",{type:"url",value:e,onChange:s=>r("src",s.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:s=>r("title",s.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:"Video title (optional)..."})]})};var rd=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Us,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:i=>l("src",i),compact:true})]})};function qm({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:l,isDragging:i}=sortable.useSortable({id:e}),d={transform:utilities.CSS.Transform.toString(s),transition:l,zIndex:i?10:1,opacity:i?.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 ${i?"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(lucideReact.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 Ea=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=wa__default.default.useState(""),[n,s]=wa__default.default.useState([]);wa__default.default.useEffect(()=>{let f=n.map(b=>b.text);JSON.stringify(f)!==JSON.stringify(e)&&s(e.map((b,v)=>({id:`${b}-${v}-${Math.random().toString(36).substr(2,4)}`,text:b})));},[e]);let l=()=>{o.trim()&&(t([...e,o.trim()]),a(""));},i=f=>{f.key==="Enter"&&(f.preventDefault(),l());},d=f=>{t(e.filter((b,v)=>v!==f));},c=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),m=f=>{let{active:b,over:v}=f;if(!v||b.id===v.id)return;let x=n.findIndex(u=>u.id===b.id),y=n.findIndex(u=>u.id===v.id);if(x!==-1&&y!==-1){let u=[...e],[h]=u.splice(x,1);u.splice(y,0,h),t(u);}},g=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:c,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:n.map(f=>f.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:n.map((f,b)=>jsxRuntime.jsx(qm,{id:f.id,text:f.text,onRemove:()=>d(b)},f.id))})}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:f=>a(f.target.value),onKeyDown:i,className:g,placeholder:"Type and press Enter to add..."})]})})};var od=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=Array.isArray(s.items)?s.items:[];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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ea,{items:l,onChange:d=>{o(e.id,{data:{...s,items:d}});},compact:true})]})};var ad=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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(lucideReact.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 ",s.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:()=>n(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:"Move up",children:jsxRuntime.jsx(lucideReact.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:()=>a(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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Fa,{field:{type:"code",name:"code",label:"Source Code",language:s.language||"javascript"},value:s.code||"",onChange:i=>l("code",i)}),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:s.language||"javascript",onChange:i=>l("language",i.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(lucideReact.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 nd=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(dr,{field:{label:"File",name:"file",maxCount:1},value:s.file,onChange:i=>l("file",i)})]})};var Ks=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=wa__default.default.useState(0),n=(m,g)=>{let f=[...e];f[m]={...f[m],title:g},t(f);},s=(m,g)=>{let f=[...e];f[m]={...f[m],content:g},t(f);},l=m=>{let g=e.filter((f,b)=>b!==m);t(g),o===m?a(null):o!==null&&o>m&&a(o-1);},i=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},d="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",c="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:[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,g)=>{let f=o===g;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(f?null:g),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 ${g+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(g);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5"})}),f?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),f&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:b=>n(g,b.target.value),onClick:b=>b.stopPropagation(),className:c,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:b=>s(g,b.target.value),onClick:b=>b.stopPropagation(),className:`${c} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},g)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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(lucideReact.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"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. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((m,g)=>{let f=o===g;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(f?null:g),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 ${g+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(g);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})}),f?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),f&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:b=>n(g,b.target.value),className:d,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:b=>s(g,b.target.value),className:`${d} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},g)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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(lucideReact.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var sd=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],i=d=>{o(e.id,{data:{...s,items:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ks,{items:l,onChange:i,compact:true})]})};var id=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=i=>{o(e.id,{data:{...s,content:i}});};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(lucideReact.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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Oo,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var Gs=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let s=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:i=>a("heading",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subheading",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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:i=>a("heading",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subheading",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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 Un({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("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)] mb-6 border-b border-[var(--kyro-border)] pb-2 inline-block",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 nu=new Set(["text","number","checkbox","select","radio","color","email","password"]);function su(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>nu.has(r.type))}function pd({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:l,onRemove:i,disabled:d,compact:c,getItemLabel:m}){let{attributes:g,listeners:f,setNodeRef:b,transform:v,transition:x,isDragging:y}=sortable.useSortable({id:e}),u={transform:utilities.CSS.Transform.toString(v),transition:x,zIndex:y?10:1,opacity:y?.8:1};return c?jsxRuntime.jsxs("div",{ref:b,style:u,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 ${y?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...g,...f,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(lucideReact.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(h=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(h,a,l)},h.name))}),jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:i,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:"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:b,style:u,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${y?"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",{...g,...f,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(lucideReact.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.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:m(a)||`Item ${t+1}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:h=>{h.stopPropagation(),i();},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(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.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(h=>s(h,a,l))})]})}function zn({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=e.fields||[],l=s[0],i=l?.name||"user",d=l?.type==="relationship",[c,m]=wa__default.default.useState(0);wa__default.default.useEffect(()=>{let y=false,u=n.filter(h=>typeof h!="object"||h===null?(y=true,false):true).map(h=>!h.id&&!h._key?(y=true,{...h,id:Math.random().toString(36).substr(2,9)}):h);y&&r(u);},[t,r]);function g(y){for(let u of ["label","title","name"]){let h=y[u];if(h&&typeof h=="string")return h}for(let u of s){if(u.type==="text"||u.type==="textarea"){let h=y[u.name];if(h&&typeof h=="string")return h}if(u.type==="group"&&u.fields){for(let h of u.fields)if(h.type==="text"||h.type==="textarea"){let S=y[u.name]?.[h.name];if(S&&typeof S=="string")return S}}}return ""}let f=su(e),b=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),v=y=>{let{active:u,over:h}=y;if(!h||u.id===h.id)return;let R=n.findIndex(w=>(w.id||w._key)===u.id),S=n.findIndex(w=>(w.id||w._key)===h.id);if(R!==-1&&S!==-1){let w=[...n],[C]=w.splice(R,1);w.splice(S,0,C),r(w);}},x=wa__default.default.useMemo(()=>n.map(y=>y?.id||y?._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(Ia,{field:{name:i,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(y=>y[i]).filter(Boolean),onChange:y=>{let u=(y||[]).map(h=>({[i]:h,id:Math.random().toString(36).substr(2,9)}));r(u);},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:b,collisionDetection:core.closestCenter,onDragEnd:v,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:x,strategy:sortable.verticalListSortingStrategy,children:n.map((y,u)=>jsxRuntime.jsx(pd,{id:y.id||y._key||`idx-${u}`,index:u,isOpen:false,setOpenIndex:()=>{},item:y,field:e,renderField:o,onChangeItem:h=>{let R=[...n];R[u]=h,r(R);},onRemove:()=>r(n.filter((h,R)=>R!==u)),disabled:a,compact:true,getItemLabel:g},y.id||y._key||u))}),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:x,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((y,u)=>{let h=c===u;return jsxRuntime.jsx(pd,{id:y.id||y._key||`idx-${u}`,index:u,isOpen:h,setOpenIndex:m,item:y,field:e,renderField:o,onChangeItem:R=>{let S=[...n];S[u]=R,r(S);},onRemove:()=>r(n.filter((R,S)=>S!==u)),disabled:a,compact:false,getItemLabel:g},y.id||y._key||u)})})}),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 y=Math.random().toString(36).substr(2,9);r([...n,{id:y}]),m(n.length);},children:"+ Add Item"})]})})]})}var md="other";function ud(){return md}function jn(e){md=e;}var ho=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{jn("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(Ho,{field:e,value:t,onChange:d,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(Ho,{field:{...e,variant:"textarea"},value:t,onChange:d,error:o,disabled:a});case "password":return jsxRuntime.jsx(Ho,{field:{...e,variant:"password"},value:t,onChange:d,error:o,disabled:a});case "secret":return jsxRuntime.jsx(Tn,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Fn,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(Dn,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx(Mn,{field:e,value:t,onChange:d,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i});case "date":return jsxRuntime.jsx(Pn,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(Oo,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(Cs,{field:e,value:t,onChange:d,disabled:a,error:o});case "code":return jsxRuntime.jsx(Fa,{field:e,value:t,onChange:d,disabled:a,error:o});case "image":case "upload":return jsxRuntime.jsx(dt,{field:e,error:o,children:jsxRuntime.jsx(dr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx(Ia,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(dt,{field:e,error:o,children:jsxRuntime.jsx(Ea,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(zn,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,m,g)=>{let f=m[c.name];return jsxRuntime.jsx(ho,{field:c,value:f,onChange:b=>{g({...m,[c.name]:b});},disabled:a,error:o},c.name)}});case "blocks":return jsxRuntime.jsx(Js,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsxRuntime.jsx(Un,{field:e,value:t,onChange:r,renderField:(c,m,g)=>{let f=m[c.name];return jsxRuntime.jsx(ho,{field:c,value:f,onChange:b=>{g({...m,[c.name]:b});},disabled:a,error:o,collectionSlug:l,globalSlug:i},c.name)}});case "color":return jsxRuntime.jsx(dt,{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 qo=({block:e,blockSchema:t,onClose:r})=>{let o=Ue(e.id),{updateBlock:a}=Le(),n=o?.data||e.data||{},s=o?.children||e.children||[],l=(m,g)=>{a(e.id,{data:{...n,[m]:g}});},i=m=>{a(e.id,{children:m});},d=()=>t&&Array.isArray(t.fields)?jsxRuntime.jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(m=>{if(m.admin?.condition){if(typeof m.admin.condition=="function")try{let f={values:n,...n};if(!m.admin.condition(f,f))return null}catch(f){console.warn(`Condition error for field ${m.name}:`,f);}else if(typeof m.admin.condition=="object")try{let f=m.admin.condition,b=f.field,v=n[b],x=!0;if("equals"in f?x=v===f.equals:"notEquals"in f?x=v!==f.notEquals:"in"in f&&Array.isArray(f.in)&&(x=f.in.includes(v)),!x)return null}catch(f){console.warn(`Declarative condition error for field ${m.name}:`,f);}}let g=n[m.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(ho,{field:m,value:g,onChange:f=>l(m.name,f)})},m.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=Ie[e.type]||Ie.default;return jsxRuntime.jsxs(cr,{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(Yr,{blockId:e.id,children:s,onUpdateChildren:i})]})]}),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 iu=6,Yr=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=iu})=>{let[n,s]=wa.useState(false),[l,i]=wa.useState(new Set),[d,c]=wa.useState(null),[m,g]=wa.useState(null),f=wa.useContext(bo);if(!f)throw new Error("ChildBlocksTree must be used within a BlocksContext");let b=zustand.useStore(f,p=>p.dynamicCategories),v=zustand.useStore(f,p=>p.allowedBlocks),x=o<a,y=16,u=p=>{let D=Go(p);r([...t,D]),c(D.id);},h=p=>{let D=t.filter(M=>M.id!==p);r(D);},S=(p,D)=>{let M=t.map(I=>I.id===p?{...I,children:D}:I);r(M);},w=p=>{i(D=>{let M=new Set(D);return M.has(p)?M.delete(p):M.add(p),M});},C=p=>{let D=p.children&&p.children.length>0,M=l.has(p.id);qs(p.type);let B=D,F=d===p.id,oe=v.find(me=>me.slug===p.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 ${F?"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"} ${x?"cursor-pointer":""}`,style:{marginLeft:o*y},onClick:()=>{x&&c(F?null:p.id);},children:[B?jsxRuntime.jsx("button",{type:"button",onClick:me=>{me.stopPropagation(),w(p.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:M?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),jt[p.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[p.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:[Ua(p),p.data?.text?` - ${p.data.text.slice(0,30)}`:"",p.data?.heading?` - ${p.data.heading.slice(0,30)}`:""]}),oe?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:oe.admin.description})]}),D&&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:[p.children.length," nested"]}),m===p.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:me=>me.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(p.id),g(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>g(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:me=>{me.stopPropagation(),g(p.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),F&&jsxRuntime.jsx(qo,{block:p,onClose:()=>c(null)}),D&&M&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(gd,{parentId:p.id,children:p.children,onUpdateChildren:me=>S(p.id,me),depth:o+1,maxDepth:a})})]},p.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(C)}),x&&jsxRuntime.jsxs("div",{style:{marginLeft:o*y},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(lucideReact.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(Ma,{open:n,onClose:()=>s(false),onSelect:u,children:b.map(p=>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:p.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:p.blocks.map(D=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{u(D.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[D.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:D.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:D.admin?.description||""})]})]},D.slug))})]},p.title))})]}),t.length===0&&x&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*y},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*y},children:["Maximum nesting level (",a,") reached"]})]})},gd=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=wa.useState(false),[l,i]=wa.useState(new Set),[d,c]=wa.useState(null),[m,g]=wa.useState(null),f=wa.useContext(bo);if(!f)throw new Error("NestedChildBlocks must be used within a BlocksContext");let b=zustand.useStore(f,p=>p.dynamicCategories),v=zustand.useStore(f,p=>p.allowedBlocks),x=o<a,y=16,u=p=>{let D=Go(p);r([...t,D]),c(D.id);},h=p=>{let D=t.filter(M=>M.id!==p);r(D);},S=(p,D)=>{let M=t.map(I=>I.id===p?{...I,children:D}:I);r(M);},w=p=>{i(D=>{let M=new Set(D);return M.has(p)?M.delete(p):M.add(p),M});},C=p=>{let D=p.children&&p.children.length>0,M=l.has(p.id);qs(p.type);let B=D,F=d===p.id,oe=v.find(me=>me.slug===p.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 ${F?"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"} ${x?"cursor-pointer":""}`,style:{marginLeft:o*y},onClick:()=>{x&&c(F?null:p.id);},children:[B?jsxRuntime.jsx("button",{type:"button",onClick:me=>{me.stopPropagation(),w(p.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:M?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),jt[p.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[p.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:[Ua(p),p.data?.text?` - ${p.data.text.slice(0,30)}`:"",p.data?.heading?` - ${p.data.heading.slice(0,30)}`:""]}),oe?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:oe.admin.description})]}),D&&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:[p.children.length," nested"]}),m===p.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:me=>me.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(p.id),g(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>g(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:me=>{me.stopPropagation(),g(p.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),F&&jsxRuntime.jsx(qo,{block:p,onClose:()=>c(null)}),D&&M&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(gd,{parentId:p.id,children:p.children,onUpdateChildren:me=>S(p.id,me),depth:o+1,maxDepth:a})})]},p.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(C)}),x&&jsxRuntime.jsxs("div",{style:{marginLeft:o*y},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(lucideReact.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(Ma,{open:n,onClose:()=>s(false),onSelect:u,children:b.map(p=>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:p.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:p.blocks.map(D=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{u(D.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[D.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:D.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:D.admin?.description||""})]})]},D.slug))})]},p.title))})]}),t.length===0&&x&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*y},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*y},children:["Maximum nesting level (",a,") reached"]})]})};var vd=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=r?.children??e.children??[],i=(d,c)=>{o(e.id,{data:{...s,[d]:c}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Gs,{heading:s.heading||"",subheading:s.subheading||"",ctaText:s.ctaText||"",ctaUrl:s.ctaUrl||"",onChange:i,compact:true}),jsxRuntime.jsx(dr,{field:{label:"Background",name:"bgImage",maxCount:1},value:s.bgImage,onChange:d=>i("bgImage",d)}),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(Yr,{blockId:e.id,children:l,onUpdateChildren:d=>o(e.id,{children:d})})]})]})]})};var Xs=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:s=false})=>{let 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",i=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:d=>n("title",d.target.value),className:`${l} font-bold text-base`,placeholder:"Card title..."}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>n("description",d.target.value),className:i,placeholder:"Card description..."}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>n("icon",d.target.value),className:l,placeholder:"Icon (emoji or name)..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:d=>n("linkText",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:"Link text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>n("link",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://..."})]})]})};var kd=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(xo,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(Xs,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var hd=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le();r?.data??e.data??{};let l=r?.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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(Yr,{blockId:e.id,children:l,onUpdateChildren:i=>o(e.id,{children:i})})})]})};var ja=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let[l,i]=wa.useState(false),[d,c]=wa.useState(""),[m,g]=wa.useState([]),[f,b]=wa.useState(false),[v,x]=wa.useState([]),[y,u]=wa.useState(true);wa.useEffect(()=>{Be("/api/collections").then(I=>{x((I.collections||[]).map(B=>B.slug||B.name||B)),u(false);}).catch(()=>u(false));},[]);let h=(I="")=>{b(true);let B=`/api/${e}?${Qa(I,[a],20)}`;Be(B).then(F=>{g(F.docs||[]),b(false);}).catch(()=>b(false));};wa.useEffect(()=>{l&&h(d);},[l,d,e,a]);let R=I=>I?.[a]||I?.title||I?.name||I?.label||I?.filename||I?.slug||I?.id||"Untitled",S=t?r:o?[o]:[],w=I=>{t?S.includes(I.id)?n("selectedIds",S.filter(B=>B!==I.id)):n("selectedIds",[...S,I.id]):(n("selectedId",I.id),n("selectedIds",[I.id]),i(false));},C=I=>S.includes(I),p=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",M=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:[!M&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:y?jsxRuntime.jsx("div",{className:D+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:I=>n("relationTo",I.target.value),className:D,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),v.map(I=>jsxRuntime.jsx("option",{value:I,children:I},I))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:I=>n("hasMany",I.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(lucideReact.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:d,onChange:I=>{c(I.target.value),i(true);},onFocus:()=>i(true),onBlur:()=>setTimeout(()=>i(false),200),placeholder:`Search ${e}...`,className:`${p} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:f&&jsxRuntime.jsx(lucideReact.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:f?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):m.length===0?jsxRuntime.jsx(En,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:m.map(I=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:B=>B.preventDefault(),onClick:()=>w(I),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${C(I.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:R(I)}),C(I.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},I.id))})})]}),S.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:S.map(I=>{let B=m.find(F=>F.id===I)||{id:I};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:[R(B),jsxRuntime.jsx("button",{type:"button",onMouseDown:F=>F.preventDefault(),onClick:()=>{t?n("selectedIds",S.filter(F=>F!==I)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},I)})})]})};var Nd=({block:e,index:t})=>{let r=Ue(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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 ",s.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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(ja,{relationTo:s.relationTo||"pages",hasMany:s.hasMany||false,selectedIds:Array.isArray(s.selectedIds)?s.selectedIds:[],selectedId:s.selectedId,labelField:s.labelField||"title",onChange:l,compact:true})]})};var du={heading:Ql,paragraph:Zl,image:ed,video:rd,list:od,code:ad,file:nd,accordion:sd,richtext:id,hero:vd,card:kd,array:hd,relationship:Nd},Ie={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(lucideReact.Heading1,{className:`w-4 h-4 ${Ie.default.text}`}),paragraph:jsxRuntime.jsx(lucideReact.AlignLeft,{className:`w-4 h-4 ${Ie.default.text}`}),image:jsxRuntime.jsx(lucideReact.Image,{className:`w-4 h-4 ${Ie.default.text}`}),video:jsxRuntime.jsx(lucideReact.Video,{className:`w-4 h-4 ${Ie.default.text}`}),list:jsxRuntime.jsx(lucideReact.List,{className:`w-4 h-4 ${Ie.default.text}`}),code:jsxRuntime.jsx(lucideReact.Code,{className:`w-4 h-4 ${Ie.default.text}`}),file:jsxRuntime.jsx(lucideReact.File,{className:`w-4 h-4 ${Ie.default.text}`}),accordion:jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 ${Ie.default.text}`}),richtext:jsxRuntime.jsx(lucideReact.AlignLeft,{className:`w-4 h-4 ${Ie.default.text}`}),hero:jsxRuntime.jsx(lucideReact.Star,{className:`w-4 h-4 ${Ie.hero.text}`}),card:jsxRuntime.jsx(lucideReact.Box,{className:`w-4 h-4 ${Ie.card.text}`}),array:jsxRuntime.jsx(lucideReact.ListOrdered,{className:`w-4 h-4 ${Ie.default.text}`}),relationship:jsxRuntime.jsx(lucideReact.Link2,{className:`w-4 h-4 ${Ie.default.text}`}),featureSplit:jsxRuntime.jsx(lucideReact.Columns3,{className:`w-4 h-4 ${Ie.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(lucideReact.Blocks,{className:`w-4 h-4 ${Ie.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(lucideReact.Sparkles,{className:`w-4 h-4 ${Ie.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(lucideReact.Users,{className:`w-4 h-4 ${Ie.testimonials.text}`}),faq:jsxRuntime.jsx(lucideReact.CircleHelp,{className:`w-4 h-4 ${Ie.faq.text}`}),stats:jsxRuntime.jsx(lucideReact.Activity,{className:`w-4 h-4 ${Ie.stats.text}`}),logoCloud:jsxRuntime.jsx(lucideReact.Image,{className:`w-4 h-4 ${Ie.logoCloud.text}`}),pricing:jsxRuntime.jsx(lucideReact.Tag,{className:`w-4 h-4 ${Ie.pricing.text}`}),team:jsxRuntime.jsx(lucideReact.Users,{className:`w-4 h-4 ${Ie.team.text}`}),recentFeed:jsxRuntime.jsx(lucideReact.Database,{className:`w-4 h-4 ${Ie.recentFeed.text}`}),processSteps:jsxRuntime.jsx(lucideReact.Clock,{className:`w-4 h-4 ${Ie.processSteps.text}`}),formEmbed:jsxRuntime.jsx(lucideReact.Mail,{className:`w-4 h-4 ${Ie.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(lucideReact.Video,{className:`w-4 h-4 ${Ie.videoShowcase.text}`})};function qs(e){return du[e]||null}function Qs(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 Ua(e){let t=e.name;return t&&t.trim()?t.trim():Qs(e.type)}function Nu(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.heading||e.title||e.text||e.name||e.label||e.sectionTitle||""}var Cu=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{attributes:l,listeners:i,setNodeRef:d,transform:c,transition:m,isDragging:g}=sortable.useSortable({id:e.id}),{removeBlock:f,updateBlock:b}=Le(),v=o===e.id,[x,y]=wa.useState(false),[u,h]=wa.useState(false),[R,S]=wa.useState(e.name||""),w=wa.useRef(null);wa.useEffect(()=>{u&&w.current&&(w.current.focus(),w.current.select());},[u]);let C=wa.useCallback(()=>{h(false);let B=R.trim();B!==(e.name||"").trim()&&b(e.id,{name:B||""});},[R,e.name,e.id,b]),p={transform:utilities.CSS.Transform.toString(c),transition:m,zIndex:g?10:1,opacity:g?.8:1},D=Ua(e),M=e.data||{},I=Nu(M,r);return s?jsxRuntime.jsxs("div",{ref:d,style:p,className:"relative group",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-1 pl-5 pr-1.5 py-1 bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-xs whitespace-nowrap ${v?`${(Ie[e.type]||Ie.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-0.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,...i,onClick:B=>B.stopPropagation(),children:jsxRuntime.jsx(lucideReact.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]}),u?jsxRuntime.jsx("input",{ref:w,value:R,onChange:B=>S(B.target.value),onBlur:C,onKeyDown:B=>{B.key==="Enter"&&C(),B.key==="Escape"&&(S(e.name||""),h(false));},onClick:B=>B.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)] truncate max-w-[120px] transition-colors",children:D}),x?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:B=>B.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{f(e.id),y(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:()=>y(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:B=>{B.stopPropagation(),S(e.name||""),h(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"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:B=>{B.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate",children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),y(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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),v&&jsxRuntime.jsx(qo,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:d,style:p,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?`${(Ie[e.type]||Ie.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,...i,onClick:B=>B.stopPropagation(),children:jsxRuntime.jsx(lucideReact.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:[u?jsxRuntime.jsx("input",{ref:w,value:R,onChange:B=>S(B.target.value),onBlur:C,onKeyDown:B=>{B.key==="Enter"&&C(),B.key==="Escape"&&(S(e.name||""),h(false));},onClick:B=>B.stopPropagation(),placeholder:Qs(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:[D,I&&typeof I=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",I.length>40?`${I.slice(0,40)}...`:I]})]}),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"]}),x?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:B=>B.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{f(e.id),y(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:()=>y(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:B=>{B.stopPropagation(),S(e.name||""),h(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"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:B=>{B.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate Block",children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),y(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:"Remove Block",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5"})})]})]}),v&&jsxRuntime.jsx(qo,{block:e,blockSchema:r,onClose:()=>a(null)})]})},Su=wa__default.default.memo(Cu),Js=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:l})=>{let[i,d]=wa.useState(false),[c,m]=wa.useState(false),g=wa.useRef(null),f=e.admin?.pickerMode||"drawer",b=e.blocks||[],v=b.reduce((T,_)=>{let de=_.admin?.group||"Custom Blocks";return T[de]||(T[de]=[]),T[de].push(_),T},{}),x=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],y=Object.entries(v).sort(([T],[_])=>{let de=x.indexOf(T),ke=x.indexOf(_);return de!==-1&&ke!==-1?de-ke:de!==-1?-1:ke!==-1?1:T.localeCompare(_)}).map(([T,_])=>({title:T,blocks:_})),u=wa.useRef(null);u.current||(u.current=Wl(b,y));let h=u.current,R=zustand.useStore(h,T=>T.blocks),[S,w]=wa.useState(null),[C,p]=wa.useState(null),D=wa.useRef(R.length),M=wa.useRef(new Set(R.map(T=>T.id))),I=wa.useRef(false);wa.useEffect(()=>{if(I.current&&R.length>D.current){let T=R.find(_=>_.id&&!M.current.has(_.id));T&&p(T.id);}D.current=R.length,M.current=new Set(R.map(T=>T.id));},[R]),wa.useEffect(()=>(o&&h.getState().setOnBlocksChange(o),()=>{h.getState().setOnBlocksChange(()=>{});}),[o,h]);let B=wa.useRef(null);wa.useEffect(()=>{let T=Array.isArray(t)?t:[],_=B.current||[];if(JSON.stringify(T)!==JSON.stringify(_)){let de=[...T];D.current=de.length,M.current=new Set(de.map(ke=>ke.id)),h.getState().setBlocks(de),B.current=de,I.current=true;}else T.length===0&&!I.current&&(I.current=true,B.current=[]);},[t,e.name,h]);let F=wa.useRef(r);F.current=r,wa.useEffect(()=>{if(!F.current)return;let T=B.current;T&&JSON.stringify(R)!==JSON.stringify(T)&&(B.current=[...R],F.current(R));},[R]);let me=wa.useCallback(T=>{h.getState().addBlock(T);},[h]),O=wa.useCallback(T=>{let _=R.findIndex(L=>L.id===T);if(_===-1)return;let de=R[_],ke=L=>{let z=Math.random().toString(36).substr(2,9);return {...L,id:z,children:L.children?L.children.map(We=>ke(We)):L.children,data:L.data?JSON.parse(JSON.stringify(L.data)):L.data}},we=ke(de),Ne=[...R];Ne.splice(_+1,0,we),h.getState().setBlocks(Ne);},[R,h]),K=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),se=T=>{w(T.active);},X=T=>{let{active:_,over:de}=T;if(w(null),!!de){if(_.id.toString().startsWith("drawer-")){let ke=_.id.toString().replace("drawer-","");if(de.id.toString().startsWith("container-")){let we=de.id.toString().replace("container-",""),Ne=R.find(L=>L.id===we);if(Ne){let L=Go(ke);h.getState().updateBlock(we,{children:[...Ne.children||[],L]});}}else {let we=R.findIndex(Ne=>Ne.id===de.id);we!==-1?h.getState().addBlock(ke,we):me(ke);}return}if(_.id!==de.id){let ke=R.findIndex(Ne=>Ne.id===_.id),we=R.findIndex(Ne=>Ne.id===de.id);if(ke!==-1&&we!==-1){let Ne=[...R],[L]=Ne.splice(ke,1);Ne.splice(we,0,L),h.getState().setBlocks(Ne);}}}},G=S?y.flatMap(T=>T.blocks).find(T=>`drawer-${T.type}`===S.id)||R.find(T=>T.id===S.id):null;G?"label"in G?G.label:G.type:"Block";return wa.useEffect(()=>{if(!c)return;let T=_=>{g.current&&!g.current.contains(_.target)&&m(false);};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[c]),jsxRuntime.jsx(bo.Provider,{value:u.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",children:[jsxRuntime.jsxs(core.DndContext,{sensors:K,collisionDetection:core.closestCenter,onDragStart:se,onDragEnd:X,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),f==="dropdown"?jsxRuntime.jsxs("div",{ref:g,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(!c),disabled:n,className:"flex items-center gap-1.5 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.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Element",jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3.5 h-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full mt-1 w-56 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:y.map(T=>jsxRuntime.jsxs("div",{children:[y.length>1&&jsxRuntime.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:T.title}),T.blocks.map(_=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{me(_.slug),m(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[_.slug]||jsxRuntime.jsx(lucideReact.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:_.label}),_.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:_.admin.description})]})]},_.slug))]},T.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(lucideReact.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx(Ma,{open:i,onClose:()=>d(false),onSelect:me,children:jsxRuntime.jsx("div",{className:"space-y-4",children:y.map(T=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:T.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:T.blocks.map(_=>jsxRuntime.jsx(Jl,{block:{type:_.slug,label:_.label,description:_.admin?.description||"",icon:null},onSelect:me,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[_.slug]||jsxRuntime.jsx(lucideReact.Box,{className:"w-4 h-4"})})})},_.slug))})]},T.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:R.map(T=>T.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:f==="dropdown"?"flex flex-wrap gap-1.5":"space-y-4",children:[R.map((T,_)=>{let de=e.blocks?.find(ke=>ke.slug===T.type);return jsxRuntime.jsx(Su,{block:T,index:_,blockSchema:de,editingBlockId:C,setEditingBlockId:p,onDuplicate:O,compact:f==="dropdown"},T.id||_)}),R.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:S&&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 ur(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(ur);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]=ur(t[s]);return n}return e}function Sd(){let e=wa.useRef([]),t=wa.useRef(false);return {queueTask:wa.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(l){console.error("Error in queued function:",l);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function Td({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:l}){let i=Ee(),{confirm:d}=it(),{formData:c,setFormData:m,setField:g,lastSavedData:f,setLastSavedData:b,setHasUnsavedChanges:v,isSlugLocked:x,loadDocument:y,setIsAutoSaving:u,setAutoSaveStatus:h,setVersions:R,setLoadingVersions:S,sidebarCollapsed:w,setSidebarCollapsed:C,getDraftCache:p,setDraftCache:D,clearDraftCache:M,resetForm:I}=i,B=!!e.versions,F=o||t?.id||a||r,oe=wa.useRef(false);!o&&F&&c&&Object.keys(c).length>0&&c.id!==F&&(oe.current=true),wa.useEffect(()=>{oe.current&&(oe.current=false,I());},[I]);let me=wa.useRef(null),O=wa.useRef(null),K=wa.useRef(null),se=wa.useRef(typeof navigator<"u"?navigator.onLine:true),X=wa.useRef(0),G=wa.useRef(false),Re=wa.useRef(null),Ae=wa.useRef(""),T=wa.useRef(""),{queueTask:_}=Sd(),de=wa.useCallback(q=>o?`global:${o}`:r&&q?`${r}:${q}`:null,[r,o]),ke=wa.useCallback((q,ee,le)=>{D(q,{data:ee,baseUpdatedAt:f.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:le?.lastSyncedAt??null});},[f.updatedAt,D]),we=wa.useCallback(async()=>{let q=o?Ye(`/api/globals/${o}/versions`):r&&c.id?Ye(`/api/${r}/${c.id}/versions`):null;if(q){S(true);try{let le=await(await ot(q)).json();R(le.docs||[]);}catch(ee){console.error("Failed to fetch versions:",ee);}finally{S(false);}}},[c.id,r,o,S,R]),Ne=wa.useCallback(()=>{let q=Ee.getState(),ee=q.formData;if(G.current||!r||!ee.id||!q.hasDirtyFields())return;let le=de(ee.id);le&&ke(le,ee);},[r,de,ke]),L=wa.useCallback(async q=>{let ee=Ee.getState(),le=ee.formData,xe=ee.lastSavedData;if(G.current||!B&&o||!o&&(!r||!le.id)||!ee.hasDirtyFields())return;let Ce=de(le.id);if(Ce&&ke(Ce,le),!se.current){h("offline");return}u(true),h("saving"),ee.setBackgroundProcessing(true);try{let et=o?Ye(`/api/globals/${o}?autosave=true`):Ye(`/api/${r}/${le.id}?autosave=true`),Ct=await ot(et,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:q?.keepalive,body:JSON.stringify({...ur(le),baseUpdatedAt:xe.updatedAt??null})});if(Ct.ok)X.current=Date.now(),ee.setRetryCount(0),ee.setLastSavedAt(Date.now()),K.current&&clearTimeout(K.current),Ce&&D(Ce,{data:le,baseUpdatedAt:xe.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await Ct.clone().json()).data?.updatedAt||new Date().toISOString()}),h("success"),setTimeout(()=>{Ee.getState().autoSaveStatus==="success"&&h("idle");},2e3);else if(Ct.status===409)h("conflict");else throw new Error(`Draft auto-save failed with status ${Ct.status}`)}catch(et){console.error("Auto-save failed:",et);let Ct=Ee.getState(),P=Ct.retryCount;if(P<5){Ct.setRetryCount(P+1),h("retrying");let W=Math.min(1e3*Math.pow(2,P),6e4);K.current&&clearTimeout(K.current),K.current=setTimeout(()=>z(q),W);}else h("offline");}finally{u(false),Ee.getState().setBackgroundProcessing(false);}},[r,de,o,ke,h,D,u,B]),z=wa.useCallback(q=>{_(()=>L(q),{beforeProcess:()=>true,afterProcess:()=>{}});},[L,_]),We=wa.useCallback(async(q,ee=true)=>{let le=Ee.getState(),xe=q||le.formData,Ce=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${xe.id}`),et=await ot(Ce,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(ee)},body:JSON.stringify({...ur(xe),baseUpdatedAt:le.lastSavedData.updatedAt??null})});return et.status===409&&h("conflict"),et},[r,o,h]);wa.useEffect(()=>{let q=()=>{C(!w);};return window.addEventListener("toggle-sidebar",q),()=>window.removeEventListener("toggle-sidebar",q)},[w,C]);let ye=wa.useRef(null),Fe=wa.useRef(""),pt=wa.useRef(false);wa.useEffect(()=>{let q=o||t?.id,ee=JSON.stringify(t);pt.current&&ye.current===q&&Fe.current===ee||(y(t||{},t||{}),pt.current=true,ye.current=q,Fe.current=ee);},[r,c.id,o,t,y]),wa.useEffect(()=>{if(!r||!t?.id)return;let q=de(t.id);if(!q||Re.current===q)return;let ee=false;return (async()=>{if(!B)return;let xe=p(q);if(xe){if(JSON.stringify(xe.data)===JSON.stringify(t)){M(q);return}Re.current=q,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(ee)return;let et={...Ee.getState().formData,...xe.data};m(et),s?.("Recovered autosaved draft");},onCancel:async()=>{M(q);}});}})(),()=>{ee=true;}},[M,r,d,de,p,t,s,m,B]);function Rt(q,ee){for(let le of q){if(le.name===ee&&le.admin?.autoGenerate==="title")return le;if(le.type==="tabs"&&"tabs"in le)for(let xe of le.tabs){let Ce=Rt(xe.fields,ee);if(Ce)return Ce}if((le.type==="group"||le.type==="collapsible")&&"fields"in le){let xe=Rt(le.fields,ee);if(xe)return xe}}}wa.useEffect(()=>{let q=e.fields;if(!Rt(q,"metaTitle"))return;let le=fo(q,c,"title"),xe=le?String(le):"";xe&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&g("metaTitle",xe);},[c,e.fields,g]),wa.useEffect(()=>{let q=e.fields,ee=q.find(Ce=>Ce.name==="slug"&&Ce.admin?.autoGenerate);if(!ee?.admin?.autoGenerate)return;let le=ee.admin.autoGenerate,xe=fo(q,c,le);if(x&&xe){let Ce=An(xe);Ce!==c.slug&&g("slug",Ce);}},[c,x,e.fields,g]),wa.useEffect(()=>{if(w||!o&&(!r||!c.id)||!Ee.getState().hasDirtyFields()||ud()!=="keystroke")return;jn("other");let ee=JSON.stringify(c);ee!==Ae.current&&(me.current&&clearTimeout(me.current),me.current=setTimeout(Ne,1500),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{Ae.current=ee,z();},8e3));},[c,w,r,o,Ne,z]),wa.useEffect(()=>{if(!o&&(!r||!c.id))return;let q=()=>{G.current||!Ee.getState().hasDirtyFields()||z({keepalive:true});},ee=()=>{document.hidden&&q();},le=()=>{se.current=true,q();},xe=()=>{se.current=false;let Ce=Ee.getState();Ce.hasDirtyFields()&&Ce.setAutoSaveStatus("offline");};return window.addEventListener("blur",q),window.addEventListener("pagehide",q),window.addEventListener("online",le),window.addEventListener("offline",xe),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("blur",q),window.removeEventListener("pagehide",q),window.removeEventListener("online",le),window.removeEventListener("offline",xe),document.removeEventListener("visibilitychange",ee);}},[r,o,c.id,z]),wa.useEffect(()=>{let q=JSON.stringify(c);if(q===T.current)return;T.current=q;let ee=document.getElementById("form-data");ee&&(ee.value=q),n?.(c);},[c,n]),wa.useEffect(()=>{(o||c.id)&&we();},[c.id,o,we]);let Jt=!c.id&&!o?"draft":B&&c.status||"published",vt=(!!c.id||!!o)&&Jt==="draft";return {...i,fetchVersions:we,performAutoSave:z,saveDocument:We,autoSaveSkipRef:G,lastAutoSaveTimeRef:X,documentStatus:Jt,hasUnpublishedChanges:vt,versionsEnabled:B}}function Co({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=wa.useState(false),s=wa.useRef(null);return wa.useEffect(()=>{let l=i=>{s.current&&!s.current.contains(i.target)&&n(false);};return a&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[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 _t({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 Ha(){return jsxRuntime.jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function To({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:s="down"}){let l=e==="published"&&!r&&t!=="saving"&&t!=="error",i=n||t==="saving"||l,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-success)] border-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)]`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:l?`${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)]`,m="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",g=()=>t==="saving"?`${m} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${m} bg-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-success)]`:t==="error"?`${m} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:l?`${m} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${m} 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 \u2713":t==="error"?"Retry":l?"Published":"Publish Changes";return jsxRuntime.jsxs("div",{className:"inline-flex items-center",children:[jsxRuntime.jsxs("button",{type:"button",onClick:o,disabled:i,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(Pr,{size:"sm",className:"inline mr-1.5"}),l&&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(Co,{trigger:jsxRuntime.jsx("button",{type:"button",className:g(),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 Fd=({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 Pd({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=wa.useState(0),s=e.tabs||[],l=s[a]||s[0],i=e.name?t[e.name]||{}:t;return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2 border-b border-[var(--kyro-border)] mb-6 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:l?.fields.map(d=>o(d,i,r))}),l?.label==="SEO"&&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(Fd,{title:String((typeof i.metaTitle=="object"?"":i.metaTitle)||(typeof i.title=="object"?"":i.title)||"Untitled"),description:String((typeof i.metaDescription=="object"?"":i.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function Ld({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,handleCreateNew:n,handleDuplicate:s,handleUnpublish:l,handleDelete:i,handlePublish:d,handleSchedulePublish:c}){let[m,g]=wa.useState(Date.now()),[f,b]=wa.useState(false),v=wa.useRef(null),{formData:x,hasUnsavedChanges:y,autoSaveStatus:u,lastSavedAt:h,retryCount:R,view:S,setView:w,showPreview:C,setShowPreview:p,setFormData:D,markSaved:M,lastSavedData:I}=Ee(),B=!x.id;wa.useEffect(()=>{let T=setInterval(()=>g(Date.now()),1e4);return ()=>clearInterval(T)},[]),wa.useEffect(()=>{let T=_=>{v.current&&!v.current.contains(_.target)&&b(false);};if(f)return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[f]);let F=String(x.mainTabs?.title||(typeof x.title=="object"?"":x.title)||(typeof x.name=="object"?"":x.name)||"Untitled"),oe=x.updatedAt?new Date(x.updatedAt).toLocaleString():"Just now",me=x.createdAt?new Date(x.createdAt).toLocaleString():"Just now",O=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",K=o?"Unpublished":r==="published"?"Published":"Draft",se=r==="published"&&!y?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",X=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",G=(T=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u==="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"})]}),T?"Saving\u2026":"Saving draft..."]}),u==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 shrink-0"}),T?"Saved":h?`Saved ${Math.floor((Date.now()-h)/6e4)}m ago`:"Draft saved"]}),u==="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"})]}),T?`Retry ${R}/5`:`Retrying save (${R}/5)`]}),u==="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"})]}),T?"Offline":"Offline \u2014 cached locally"]}),u==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:T?"Failed":"Draft save failed"}),u==="conflict"&&(T?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:async()=>{},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"})]}))]}),Re=()=>!B&&jsxRuntime.jsxs(Co,{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:"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:[!t&&jsxRuntime.jsx(_t,{onClick:n,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(_t,{onClick:s,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:"Duplicate"}),jsxRuntime.jsx(_t,{onClick:()=>b(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(_t,{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(Ha,{}),jsxRuntime.jsx(_t,{onClick:i,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=()=>f&&jsxRuntime.jsx("div",{ref:v,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:()=>b(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let T=document.getElementById("schedule-datetime")?.value;T&&c(T);},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)] 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:`${tt}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(lucideReact.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:F}),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 ${X}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${se}`}),K]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(To,{status:r,saveStatus:a,hasChanges:y,onPublish:d,disabled:a==="saving"}),Re(),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(T=>jsxRuntime.jsx("button",{type:"button",onClick:()=>w(T),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${S===T?"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:T==="edit"?"Edit":T==="version"?"History":"API"},T))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[G(true),y&&u!=="saving"&&u!=="retrying"&&u!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{D(I),M();},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:()=>p(!C),className:`p-1.5 rounded-lg transition-all ${C?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(lucideReact.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)] 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:`${tt}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:F}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${X}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${se}`}),O]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[G(false),y&&u!=="saving"&&u!=="retrying"&&u!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{D(I),M();},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),h&&u!=="saving"&&u!=="retrying"&&u!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let T=m-h,_=Math.floor(T/6e4),de=Math.floor(T/1e3);return _>=1?`${_}m ago`:de>=5?`${de}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 ",me]})]})]}),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(T=>jsxRuntime.jsx("button",{type:"button",onClick:()=>w(T),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${S===T?"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:T.toUpperCase()},T))}),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:()=>p(!C),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${C?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:"Live Preview",children:[jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-4 h-4"}),C&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),Re(),Ae(),jsxRuntime.jsx(To,{status:r,saveStatus:a,hasChanges:y,onPublish:d,disabled:a==="saving"})]})]})]})]})}function Md({config:e,layout:t,collectionSlug:r,renderField:o}){let{showPreview:a,sidebarCollapsed:n,formData:s}=Ee();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(d=>o(d))})});let i=e.fields.some(d=>d.admin?.position==="sidebar")&&!a;return jsxRuntime.jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${a?"grid-cols-1 lg:grid-cols-2":n||!i?"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(d=>!d.admin?.position||d.admin.position==="main").map(d=>o(d))})}),a?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:`/${r}/${s.slug||s.id}?preview=true`,className:"w-full h-full border-none",title:"Live Preview"}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):n?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(d=>d.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(d=>d.admin?.position==="sidebar").map(d=>o(d))]})})]})}function Ed({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:l,setCompareDiffs:i,loadingDiffs:d,loadingVersions:c,versions:m}=Ee();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`:`${m.length} snapshot${m.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([]),i([]);},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"})]})]}),l.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:[l.length," change",l.length!==1?"s":""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:l.map((g,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:g.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof g.oldValue=="object"?JSON.stringify(g.oldValue):String(g.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 g.newValue=="object"?JSON.stringify(g.newValue):String(g.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"})}):m.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:m.map((g,f)=>{let b=n.includes(g.id),v=(g.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(g.id):void 0,className:`transition-all ${o?b?"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 ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:m.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:[g.changeDescription||"Snapshot",v&&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(g.createdAt||g.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:g.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${g.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${g.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),g.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:g.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(g.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 ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(lucideReact.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:m.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:[g.changeDescription||"Snapshot",v&&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(g.createdAt||g.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),g.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 ${g.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${g.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),g.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:g.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(g.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"})]})]},g.id)})})]})})}function $d({collectionSlug:e,globalSlug:t}){let{formData:r}=Ee();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(r,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()`:r.id?`kyro.collection('${e}').get('${r.id}')`:"Not saved yet"})]}),r.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(r.id)}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(r.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:"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 Od={};function Ka({config:e,data:t=Od,errors:r=Od,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:l,documentName:i,layout:d="split",onActionSuccess:c,onActionError:m,justSaved:g}){let f=e||(s?Kl[s]:n?Vo[n]:null),[b,v]=wa.useState(f);wa.useEffect(()=>{s==="storage-settings"?Be("/api/kyro/schema").then(A=>{A?.globals?.["storage-settings"]&&v(A.globals["storage-settings"]);}).catch(A=>console.error("[AutoForm] Failed to fetch dynamic schema",A)):v(f);},[s,f]);let x=b||f,{confirm:y}=it(),{formData:u,hasUnsavedChanges:R,autoSaveStatus:C,lastSavedAt:p,view:O,setView:K,setShowPreview:T,isMenuOpen:_,setIsMenuOpen:de,loadingFields:ke,setLoadingFields:we,compareSelected:z,setCompareSelected:We,setCompareDiffs:Fe,setLoadingDiffs:Rt,setField:Jt,setFormData:vt,setLastSavedData:ee,setAutoSaveStatus:le,fetchVersions:xe,saveDocument:Ce,autoSaveSkipRef:et,lastAutoSaveTimeRef:Ct,documentStatus:P,hasUnpublishedChanges:W,versionsEnabled:ae}=Td({config:x,initialData:t,collectionSlug:n,globalSlug:s,documentId:l,onChange:o,onActionSuccess:c,onActionError:m}),sr=wa.useRef(null),lo=wa.useRef(null),[pa,Wa]=wa.useState(false),[es,bt]=wa.useState("idle"),[N,ne]=wa.useState(Date.now()),Pe=a,[qt,Bt]=wa.useState(false),[vr,ir]=wa.useState(false),[ts,Fc]=wa.useState(0),di=wa.useRef(new Map),Dc=3e4;wa.useEffect(()=>{let A=s?`global:${s}`:`${n}:${l}`;if(!(s||n&&l&&l!=="new")||t&&Object.keys(t).length>0)return;let Se=di.current.get(A),Te=Se&&Date.now()-Se.ts<Dc,xt=Se&&!Te;if(Te){Ee.getState().loadDocument(Se.data,Se.data);return}xt&&Ee.getState().loadDocument(Se.data,Se.data);let kt=new AbortController;ir(false),Se||Bt(true);let Lt=s?`/api/globals/${s}`:`/api/${n}/${l}`;return Be(Lt,{autoToast:false,signal:kt.signal}).then(mt=>{let co=mt.data||{};di.current.set(A,{data:co,ts:Date.now()}),Ee.getState().loadDocument(co,co),Bt(false);}).catch(mt=>{mt.name!=="AbortError"&&(Bt(false),Se||ir(true));}),()=>kt.abort()},[n,l,s,t,ts]),wa.useEffect(()=>{let A=setInterval(()=>ne(Date.now()),1e4);return ()=>clearInterval(A)},[]);let ci=(A,Q)=>{if(typeof A=="function")try{return A(u,Q)}catch(Se){return console.warn("Error evaluating admin runtime flag:",Se),false}return !!A},Pc=A=>{y({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let Q=s?Ye(`/api/globals/${s}/versions/${A}/restore`):Ye(`/api/${n}/${u.id}/versions/${A}/restore`),Se=await ot(Q,{method:"POST"});!Se.ok&&n&&(Se=await ot(Ye(`/api/${n}/${u.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:A,action:"restore"})}));let Te=await Se.json();if(Te.data){let{updatedAt:xt,createdAt:kt,...Lt}=Te.data,mt={...u,...Lt};vt(mt),Ee.getState().loadDocument(mt,mt),c?.("Version restored successfully"),xe(),K("edit");}else E.error(Te.error||"Failed to restore version");}catch(Q){console.error("Failed to restore version:",Q),E.error("Failed to restore version");}}});},Ic=async()=>{if(z.length===2){Rt(true);try{let Q=await(await ot(Ye(`/api/${n}/${u.id}/versions?compareA=${z[0]}&compareB=${z[1]}`))).json();Fe(Q.diffs||[]);}catch(A){console.error("Compare failed:",A),Fe([]);}finally{Rt(false);}}},Bc=A=>{We(Q=>Q.includes(A)?Q.filter(Se=>Se!==A):Q.length>=2?[Q[1],A]:[...Q,A]);};wa.useEffect(()=>{let A=Q=>{(Q.metaKey||Q.ctrlKey)&&Q.key==="s"&&(Q.preventDefault(),pi()),(Q.metaKey||Q.ctrlKey)&&Q.shiftKey&&(Q.key==="P"||Q.key==="p")&&(Q.preventDefault(),document.getElementById("btn-publish")?.click()),(Q.metaKey||Q.ctrlKey)&&!Q.shiftKey&&Q.key==="p"&&(Q.preventDefault(),T(Se=>!Se)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(Q.key==="1"&&K("edit"),Q.key==="2"&&K("version"),Q.key==="3"&&K("api"));};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[]),wa.useEffect(()=>{let A=()=>K("version");return window.addEventListener("kyro:show-version-history",A),()=>window.removeEventListener("kyro:show-version-history",A)},[]),wa.useEffect(()=>{let A=Q=>{sr.current&&!sr.current.contains(Q.target)&&de(false);};if(_)return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[_]),wa.useEffect(()=>{let A=Q=>{lo.current&&!lo.current.contains(Q.target)&&Wa(false);};if(pa)return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[pa]);let Lc=()=>{R?y({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await pi(),await new Promise(A=>setTimeout(A,1e3)),window.location.href=`${tt}/${n}/new`;}}):window.location.href=`${tt}/${n}/new`;},Mc=()=>{y({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{try{let{id:A,createdAt:Q,updatedAt:Se,...Te}=u,xt=ur(Te),kt=await ot(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...xt,title:`${Te.title||Te.name||"Copy"} (Copy)`,slug:`${Te.slug||"copy"}-${Date.now()}`,status:"draft"})});if(kt.ok){let Lt=await kt.json();c?.("Document duplicated successfully"),Lt.data?.id&&(window.location.href=`${tt}/${n}/${Lt.data.id}`);}else {let Lt=await kt.json();E.error(Lt.error||"Failed to duplicate document");}}catch{E.error("Failed to duplicate document");}}});},Ec=()=>{y({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{try{await ht(`/api/${n}/${u.id}`),window.location.href=`${tt}/${n}`;}catch(A){E.error(A.message||"Failed to delete document");}}});},$c=()=>{y({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{try{let A=await Ce({...u,status:"draft"},!1);if(A?.ok)c?.("Document unpublished successfully"),Ee.getState().loadDocument({...u,status:"draft"},{...u,status:"draft"});else {let Q=await A?.json().catch(()=>({}));E.error(Q?.error||"Failed to unpublish");}}catch{E.error("Failed to unpublish");}}});},pi=async()=>{let A=!u.id;et.current=true,bt("saving");try{let Q=ur({...u}),Se=A&&!s,Te=Se?await ot(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}):await Ce(Q);if(Te.ok){let kt=(await Te.json()).data||Q;vt({...u,...kt}),ee({...u,...kt}),Ct.current=Date.now(),le("success"),bt("saved"),ae&&xe(),setTimeout(()=>{le("idle"),bt("idle");},2e3),c?.(Se?"Document created successfully":"Changes saved"),Se&&setTimeout(()=>{window.location.href=`${tt}/${n}`;},800);}else {let xt=await Te.json();Te.status===409&&le("conflict"),bt("error"),E.error(xt.error||"Failed to save"),setTimeout(()=>bt("idle"),3e3);}}catch{bt("error"),E.error("Failed to save document"),setTimeout(()=>bt("idle"),3e3);}finally{et.current=false;}},Oc=async()=>{let A=!u.id;et.current=true,bt("saving");try{let Q={...u};if(A&&!s){let xt=ur({...u}),kt=await ot(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xt)});if(!kt.ok){let co=await kt.json().catch(()=>({}));kt.status===409&&le("conflict"),bt("error"),E.error(co.error||"Failed to create document"),setTimeout(()=>bt("idle"),3e3);return}let mt=(await kt.json()).data||xt;vt({...u,...mt}),ee({...u,...mt}),Q={...u,...mt};}let Se=ur(Q),Te=await Ce(Se,!1);if(Te?.ok)bt("saved"),c?.("Published successfully");else {let xt=await Te?.json().catch(()=>({}));Te?.status===409&&le("conflict"),bt("error"),E.error(xt?.error||"Failed to publish"),setTimeout(()=>bt("idle"),3e3);}}catch{bt("error"),E.error("Failed to publish"),setTimeout(()=>bt("idle"),3e3);}finally{et.current=false;}},Uc=async A=>{let Q=!u.id;et.current=true;try{let Se={...ur({...u}),_schedulePublishAt:A};if(Q&&!s){let Te=await ot(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Se)});if(!Te.ok){let xt=await Te.json().catch(()=>({}));E.error(xt.error||"Failed to schedule publish");return}}else {let Te=await Ce(Se);if(!Te.ok){let xt=await Te.json().catch(()=>({}));E.error(xt.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(A).toLocaleString()}`),Wa(!1);}catch{E.error("Failed to schedule publish");}finally{et.current=false;}},zc=(A,Q)=>{Jt(A,Q);},ma=(A,Q,Se)=>{let Te=Q!==void 0?Q:u;if(ci(A.hidden!==void 0?A.hidden:A.admin?.hidden,Te))return null;let kt=ci(A.readOnly!==void 0?A.readOnly:A.admin?.readOnly,Te),Lt=!!(Pe||kt);if(A.admin?.condition){if(typeof A.admin.condition=="function")try{let $e={values:u||{},...u||{}};if(!A.admin.condition($e,Te))return null}catch($e){console.warn(`Condition error for field ${A.name}:`,$e);}else if(typeof A.admin.condition=="object")try{let $e=A.admin.condition,je=$e.field,Vt=Te&&Te[je]!==void 0?Te[je]:u&&u[je]!==void 0?u[je]:void 0,Ar=!0;if("equals"in $e?Ar=Vt===$e.equals:"notEquals"in $e?Ar=Vt!==$e.notEquals:"in"in $e&&Array.isArray($e.in)&&(Ar=$e.in.includes(Vt)),!Ar)return null}catch($e){console.warn(`Declarative condition error for field ${A.name}:`,$e);}}let mt=Te[A.name],co=r[A.name],Ja=$e=>{Se?Se({...Te,[A.name]:$e}):zc(A.name,$e);};if(A.type==="row"&&"fields"in A){let $e=A.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:$e?.map(je=>{let Vt=je.admin||{},Ar=Vt?.action;if((je.type==="button"||je.type==="action")&&Ar){let br=$e?.find(ua=>ua.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let ua=A.name,qa=br?.name,Xa=qa?u[qa]:void 0;if(!Xa&&ua&&typeof ua=="string"&&qa&&(Xa=u[ua]?.[qa]),!!Xa){we(xr=>({...xr,[je.name]:true}));try{let xr=await ot(Ye(Ar),{method:Vt.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Xa})}),ya={};try{ya=await xr.json();}catch{ya={};}if(xr.ok&&ya.success)c?.(ya.message||"Action completed successfully");else {let jc=ya.error||`Request failed (${xr.status})`;m?.(jc);}}catch(xr){m?.(xr instanceof Error?xr.message:"Error connecting to server");}finally{we(xr=>({...xr,[je.name]:false}));}}},disabled:ke[je.name]||Lt,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:ke[je.name]?"Sending...":je.label||"Click"})},je.name)}return jsxRuntime.jsx("div",{className:je.type==="button"||je.type==="action"?"flex-shrink-0":"flex-1",style:Vt?.width?{width:Vt.width,flex:"none"}:{},children:ma(je,Q,Se)},je.name)})},A.name||`row-${Math.random()}`)}switch(A.type){case "tabs":return jsxRuntime.jsx(Pd,{field:A,formData:u,onTabDataChange:$e=>{Jt(A.name,$e);},renderField:($e,je,Vt)=>ma($e,je,Vt)},A.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(Un,{field:A,value:mt,onChange:Ja,renderField:ma},A.name);case "array":return jsxRuntime.jsx(zn,{field:A,value:mt,onChange:Ja,renderField:ma,disabled:Lt},A.name);case "button":case "action":{let $e=A.name,je=ke[$e];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:je||Lt,onClick:async()=>{let Vt=A.admin?.action||A.action,Ar=A.admin?.method||A.method||"POST";if(Vt){we(br=>({...br,[$e]:true}));try{let br=await ot(Vt,{method:Ar,headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});await br.json(),br.ok;}catch(br){console.error("Error executing action:",br);}finally{we(br=>({...br,[$e]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${je?"opacity-70 cursor-not-allowed":""}`,children:[je&&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"})]}),je?"Processing...":A.label||"Click"]})},$e)}case "relationship-block":return jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[A.label||A.name,A.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx(ja,{relationTo:A.relationTo,hasMany:A.hasMany,selectedIds:Array.isArray(mt)?mt:mt?[mt]:[],onChange:($e,je)=>{Ja(je);},compact:true}),A.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(A.admin?.description)}):null]},A.name);default:return jsxRuntime.jsx(ho,{field:A,value:mt,onChange:Ja,error:co,disabled:Lt,formData:u,siblingData:Te,collectionSlug:n,globalSlug:s},A.name||Math.random().toString())}};return qt?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx($t,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx($t,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx($t,{variant:"rect",count:4})})]}):vr?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(lucideReact.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:()=>{ir(false),Bt(true),Fc(A=>A+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(Ld,{collectionSlug:n,globalSlug:s,documentStatus:P||"draft",hasUnpublishedChanges:W,localSaveStatus:es,handleCreateNew:Lc,handleDuplicate:Mc,handleUnpublish:$c,handleDelete:Ec,handlePublish:Oc,handleSchedulePublish:Uc}),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:[C==="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..."]}),C==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"}),p?`Saved ${Math.floor((Date.now()-p)/6e4)}m ago`:"Saved"]}),C==="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..."]}),C==="offline"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),C==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),C==="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),R&&C!=="saving"&&C!=="retrying"&&C!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!R&&C!=="success"&&C!=="saving"&&C!=="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:u.updatedAt?`Modified ${new Date(u.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()=>{try{let A=await Ce(u);if(A.ok){let Se=(await A.json()).data||u;vt({...u,...Se}),ee({...u,...Se}),c?.("Changes saved");}}catch(A){console.error("Save error exception:",A),m?.("Save failed: "+A.message);}}})]}),jsxRuntime.jsxs("main",{className:"w-full pt-6 md:pt-0",children:[O==="edit"&&jsxRuntime.jsx(Md,{config:x,layout:d,collectionSlug:n,renderField:ma}),O==="version"&&jsxRuntime.jsx(Ed,{handleRestoreVersion:Pc,handleCompareVersions:Ic,toggleCompareSelection:Bc}),O==="api"&&jsxRuntime.jsx($d,{collectionSlug:n,globalSlug:s})]})]})}var Ud={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function ti({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:s,onViewHistory:l,onPreview:i,onDelete:d,onBack:c,onToggleSidebar:m,publishedAt:g,updatedAt:f}){let b=Ee(C=>C.view)||"edit",v=Ee(C=>C.setView),[x,y]=wa.useState(false),u=wa.useRef(null);wa.useEffect(()=>{let C=p=>{u.current&&!u.current.contains(p.target)&&y(false);};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);let h=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,R=["edit","version","api"],S=h(),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 ${Ud[e]||"bg-[var(--kyro-text-muted)]"}`}),S&&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(Pr,{size:"sm",className:"inline mr-0.5"}),S]}),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:R.map(C=>jsxRuntime.jsx("button",{type:"button",onClick:()=>v(C),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${b===C?"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:C==="edit"?"Edit":C==="version"?"Ver":"API"},C))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${w} max-md:hidden`,title:"Preview",children:jsxRuntime.jsx(lucideReact.Eye,{className:"w-3.5 h-3.5"})}),l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${w} max-md:hidden`,title:"View History",children:jsxRuntime.jsx(lucideReact.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${w} max-md:hidden`,title:"Duplicate",children:jsxRuntime.jsx(lucideReact.Copy,{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:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})}),m&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:`${w} max-md:hidden`,title:"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:u,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>y(!x),className:w,title:"More",children:jsxRuntime.jsx(lucideReact.EllipsisVertical,{className:"w-3.5 h-3.5"})}),x&&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:[S&&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 ${Ud[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(Pr,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:S})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:R.map(C=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(C),y(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${b===C?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:C==="edit"?"Edit":C==="version"?"Ver":"API"},C))}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),y(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(lucideReact.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),y(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(lucideReact.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),y(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(lucideReact.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(),y(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(lucideReact.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(lucideReact.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(lucideReact.Undo,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxRuntime.jsxs(To,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[s&&jsxRuntime.jsx(_t,{icon:jsxRuntime.jsx(lucideReact.Copy,{className:"w-4 h-4"}),children:"Duplicate"}),l&&jsxRuntime.jsx(_t,{icon:jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4"}),children:"View History"}),i&&jsxRuntime.jsx(_t,{icon:jsxRuntime.jsx(lucideReact.Eye,{className:"w-4 h-4"}),children:"Preview"}),(s||l||i)&&jsxRuntime.jsx(Ha,{}),d&&jsxRuntime.jsx(_t,{onClick:d,danger:true,icon:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function oi({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:l,mode:i="collection"}){let{confirm:d,alert:c}=it(),[m,g]=wa.useState({}),[f,b]=wa.useState({}),[v,x]=wa.useState(true),[y,u]=wa.useState(false),[h,R]=wa.useState("idle"),[S,w]=wa.useState(false),[C,p]=wa.useState("draft"),[D,M]=wa.useState(null),[I,B]=wa.useState(null),[F,oe]=wa.useState(null),[me,O]=wa.useState(false),K=r?.fields||t?.fields||[],se=r?.label||t?.label||"Document",X=r?.slug||t?.slug||"",G=JSON.stringify(m)!==JSON.stringify(f);wa.useEffect(()=>{G&&C==="published"&&p("draft");},[G,C]),wa.useEffect(()=>{G&&h==="saved"&&R("idle");},[G,h]),wa.useEffect(()=>{i==="global"?Ae():o&&Re();},[o,i,X]);let Re=async()=>{try{x(!0);let L=await Be(`/api/${X}/${o}`,{autoToast:!1}),z=L.data||{};g(z),b(z),p(z?.status||L.status||"draft"),M(L.createdAt||z.createdAt||null),B(L.updatedAt||z.updatedAt||null),oe(L.publishedAt||z.publishedAt||null);}catch{l("Failed to load document");}finally{x(false);}},Ae=async()=>{try{x(!0);let L=await Be(`/api/globals/${X}`,{autoToast:!1}),z=L.data||{};g(z),b(z),M(L.createdAt||null),B(L.updatedAt||null);}catch{l("Failed to load global");}finally{x(false);}},T=wa.useCallback(async(L=false)=>{try{R("saving");let z=i==="global"?`/api/globals/${X}`:`/api/${X}/${o}`,We=C==="draft"||m?.status==="draft",ye=await Xt(z,m,{autoToast:!1,headers:{"X-Draft":String(We)}}),Fe=ye&&(ye.data||ye)||m;L||(b(Fe),n()),g(Fe),p(Fe?.status||C),R("saved"),B(new Date().toISOString()),O(!0),setTimeout(()=>O(!1),3e3),L||(C==="draft"||Fe?.status==="draft"?E.warning("Draft saved"):E.success("Updated")),setTimeout(()=>{R("idle");},2e3);}catch{R("error"),L||(l("Failed to save changes"),E.error("Failed to save changes"));}finally{u(false);}},[m,i,X,o,C,n,l]),_=async()=>{try{u(!0),await Xt(`/api/${X}/${o}`,m,{autoToast:!1,headers:{"X-Draft":"false"}}),p("published"),oe(new Date().toISOString()),E.success("Published successfully"),n();}catch{l("Failed to publish"),E.error("Failed to publish");}finally{u(false);}},de=async()=>{try{u(!0),await Xt(`/api/${X}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),p("draft"),E.warning("Document unpublished"),n();}catch{l("Failed to unpublish"),E.error("Failed to unpublish");}finally{u(false);}},ke=async()=>{try{u(!0),await at(`/api/${X}/${o}/duplicate`,void 0,{autoToast:!1}),E.success("Document duplicated");}catch(L){let z=L instanceof Error?L.message:"Failed to duplicate document";l(z),E.error(z);}finally{u(false);}},we=()=>{d({title:`Delete ${se}?`,message:"This action cannot be undone.",variant:"danger",onConfirm:async()=>{try{w(!0),await ht(`/api/${X}/${o}`,{autoToast:!1}),s?.(),E.error("Document deleted");}catch(L){let z=L instanceof Error?L.message:"Failed to delete document";E.error(z);}finally{w(false);}}});};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($t,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx($t,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx($t,{variant:"rect",count:4})})]})});let Ne=i==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Ft,{back:{onClick:a},breadcrumbs:[{label:i==="global"?"Globals":"Collections"},{label:se,href:i==="collection"?`${tt}/${X}`:void 0},{label:i==="global"||o?"Edit":"New"}],title:i==="global"?se:fo(t?.fields,m,t?.admin?.useAsTitle||"title")||m.name||o||`New ${t?.singularLabel||se}`,metadata:[jsxRuntime.jsx(Dt,{variant:C==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:C},"status")]}),jsxRuntime.jsx(ti,{status:C,saveStatus:h,hasChanges:G,onSave:()=>T(false),onPublish:_,onUnpublish:C==="published"?de:void 0,onDuplicate:ke,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:()=>window.open(`/preview/${X}/${o}`,"_blank"),onDelete:we,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:F,updatedAt:I}),jsxRuntime.jsxs("div",{className:Ne?"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",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:"Core Configuration"}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(Ka,{config:t?{...t,fields:K}:{slug:"unknown",fields:K},data:m,onChange:g,layout:Ne?"single":"split",globalSlug:i==="global"?X:void 0,collectionSlug:i==="collection"?X:void 0,onActionSuccess:L=>E.success(L),onActionError:L=>E.error(L),documentStatus:C,justSaved:me}),Ne&&jsxRuntime.jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[i==="collection"&&o&&jsxRuntime.jsx("button",{type:"button",onClick:we,className:"kyro-btn kyro-btn-lg kyro-btn-ghost text-[var(--kyro-error)]",children:"Delete"}),jsxRuntime.jsx(To,{status:C,saveStatus:y?"saving":"idle",hasChanges:G,onPublish:()=>T(false),disabled:y})]})]})}),!Ne&&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:"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:"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 ${C==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:C||"draft"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Date Created"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:D?new Date(D).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"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:"Last Modified"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:I?new Date(I).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"Just now"})]}),F&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Public At"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(F).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:"Quick Links"}),jsxRuntime.jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:ke,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:"Duplicate Document"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(`/preview/${X}/${o}`,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:"View Public Page"}),jsxRuntime.jsx("button",{type:"button",onClick:we,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:"Delete Entry"})]})]})]})]})]})}function ai({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=wa.useState({}),[l,i]=wa.useState(false),d=t.fields||[],c=t.label||t.slug,m=async g=>{try{i(!0),await at(`/api/${t.slug}`,n),E.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(f){a(f instanceof Error?f.message:"Failed to create");}finally{i(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Ft,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${tt}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:l?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>m()}}),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(Ka,{config:{...t,fields:d},data:n,onChange:s})})})})})]})}function jd({type:e,message:t,onClose:r}){let[o,a]=wa__default.default.useState(false),n=wa__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},l=()=>{n.current&&clearTimeout(n.current);};wa__default.default.useEffect(()=>(o?l():s(),l),[o,r]);let i={success:lucideReact.CircleCheck,error:lucideReact.ShieldAlert,warning:lucideReact.TriangleAlert,info:lucideReact.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(i,{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(lucideReact.X,{className:"w-3.5 h-3.5"})})]})}function O3({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function U3(){let e=Kt(o=>o.addToast),t=Kt(o=>o.removeToast);return {toasts:Kt(o=>o.toasts),addToast:e,removeToast:t}}function Wn(){let e=Kt(r=>r.toasts),t=Kt(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(jd,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function ii({onAuth:e,theme:t="light"}){let[r,o]=wa.useState("login"),[a,n]=wa.useState(""),[s,l]=wa.useState(""),[i,d]=wa.useState(""),[c,m]=wa.useState(false),[g,f]=wa.useState(false),b=Kt(y=>y.addToast);wa.useEffect(()=>{v();},[]);let v=async()=>{try{await Be("/api/users");}catch{f(true),o("register");}};return jsxRuntime.jsx(wr,{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:g?"Create Admin Account":r==="login"?"Sign In":"Create Account"}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:g?"Set up your admin account to get started":r==="login"?"Enter your credentials to access the admin":"Create an account to access the admin"})]}),jsxRuntime.jsxs("form",{onSubmit:async y=>{y.preventDefault(),m(true);try{let u=r==="login"?"/api/auth/login":"/api/auth/register",h={email:a,password:s};r==="register"&&(h.confirmPassword=i);let R=await at(u,h);R.isFirstUser&&f(!0),localStorage.setItem("kyro_user",JSON.stringify(R.user)),b("success",r==="login"?"Welcome back!":"Account created!"),e(R.token,R.user);}catch{b("error","Connection failed");}finally{m(false);}},className:"kyro-login-form",children:[jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"email",children:"Email"}),jsxRuntime.jsx("input",{id:"email",type:"email",value:a,onChange:y=>n(y.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:"Password"}),jsxRuntime.jsx("input",{id:"password",type:"password",value:s,onChange:y=>l(y.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:r==="login"?"current-password":"new-password"})]}),r==="register"&&jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"confirmPassword",children:"Confirm Password"}),jsxRuntime.jsx("input",{id:"confirmPassword",type:"password",value:i,onChange:y=>d(y.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:c,children:c?r==="login"?"Signing in...":"Creating account...":r==="login"?"Sign In":"Create Account"})]}),!g&&jsxRuntime.jsx("div",{className:"kyro-login-footer",children:jsxRuntime.jsx("p",{children:r==="login"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Don't have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("register"),children:"Sign up"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Already have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("login"),children:"Sign in"})]})})})]}),jsxRuntime.jsx(Wn,{})]})})}function Vd({collections:e,onNavigate:t,user:r}){let{permissions:o}=Ur(),[a,n]=wa.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[s,l]=wa.useState(true);wa.useEffect(()=>{let d=setTimeout(()=>{n({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(d)},[]);let i=Object.entries(e).filter(([d])=>!As.includes(d)&&o?.collections?.[d]?.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(Ft,{title:`Welcome back, ${r?.email?.split("@")[0]||"Admin"}`,description:"Everything looks great in your command center today.",action:i.length>0&&o?.collections?.[i[0]?.[0]]?.create!==false?{label:"New Document",onClick:()=>t("create",i[0]?.[0]),icon:lucideReact.Plus}:void 0}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:"Total Content",value:a.totalDocs,icon:lucideReact.FileText,color:"text-blue-500"},{label:"Media Assets",value:a.totalMedia,icon:lucideReact.Image,color:"text-purple-500"},{label:"Active Users",value:a.totalUsers,icon:lucideReact.Users,color:"text-green-500"},{label:"System Health",value:"100%",icon:lucideReact.Activity,color:"text-amber-500"}].map((d,c)=>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:d.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:s?jsxRuntime.jsx($t,{variant:"text",className:"w-16"}):d.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${d.color}`,children:jsxRuntime.jsx(d.icon,{className:"w-6 h-6"})})]},c))}),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(lucideReact.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),"Content Growth"]}),jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:"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:"Mon"}),jsxRuntime.jsx("span",{children:"Tue"}),jsxRuntime.jsx("span",{children:"Wed"}),jsxRuntime.jsx("span",{children:"Thu"}),jsxRuntime.jsx("span",{children:"Fri"}),jsxRuntime.jsx("span",{children:"Sat"}),jsxRuntime.jsx("span",{children:"Sun"})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:i.map(([d,c])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",d),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:c.label||d}),jsxRuntime.jsx(lucideReact.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:c.admin?.description||`Manage ${d} content.`})]},d))})]}),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(lucideReact.Plus,{className:"w-5 h-5"}),"Quick Links"]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[i.filter(([d])=>o?.collections?.[d]?.create!==false).map(([d])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",d),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.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:["New ",e[d]?.singularLabel||e[d]?.label||d]}),jsxRuntime.jsx(lucideReact.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},d)),i.every(([d])=>o?.collections?.[d]?.create===false)&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:"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:"Media Library"}),jsxRuntime.jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:"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:["Open Assets"," ",jsxRuntime.jsx(lucideReact.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(lucideReact.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(lucideReact.Clock,{className:"w-5 h-5 opacity-40"}),"Recent Activity"]}),jsxRuntime.jsx("div",{className:"space-y-6",children:a.recentActivity.map(d=>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:d.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:d.user})," ",d.type==="create"?"created":d.type==="edit"?"edited":d.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',d.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:d.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:d.time})]})]},d.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:"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(lucideReact.Activity,{className:"w-5 h-5 opacity-40"}),"System Status"]}),jsxRuntime.jsx("div",{className:"space-y-4",children:[{label:"Cloud API",status:"Optimal",pulse:"bg-green-500"},{label:"Database Node",status:"Healthy",pulse:"bg-green-500"},{label:"Media CDN",status:"Active",pulse:"bg-blue-500"},{label:"Auth Service",status:"Secure",pulse:"bg-green-500"}].map((d,c)=>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:d.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:d.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${d.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},c))})]})]})]})]})}function Gd(){let[e,t]=wa.useState([]),[r,o]=wa.useState(true),[a,n]=wa.useState(""),[s,l]=wa.useState(false),[i,d]=wa.useState({name:"",email:"",password:"",role:"customer"}),[c,m]=wa.useState(""),[g,f]=wa.useState(false),{confirm:b,alert:v}=it();wa.useEffect(()=>{x();},[]);let x=async()=>{try{o(!0);let w=await Be("/api/users");t(w.docs||[]);}catch(w){console.error("Failed to load users:",w);}finally{o(false);}},y=w=>{let C=!w.locked;b({title:C?"Lock User Account?":"Unlock User Account?",message:C?`Are you sure you want to lock ${w.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${w.email}?`,variant:C?"danger":"success",onConfirm:async()=>{try{await Xt(`/api/users/${w.id}`,{locked:C}),t(p=>p.map(D=>D.id===w.id?{...D,locked:C}:D)),E.success(C?`Account locked: ${w.email}`:`Account restored: ${w.email}`);}catch(p){console.error("Failed to toggle user lock:",p),E.error("Failed to update account status");}}});},u=w=>{b({title:"Destroy User Account",message:`You are about to permanently delete ${w.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await ht(`/api/users/${w.id}`),t(C=>C.filter(p=>p.id!==w.id)),E.success(`Identity purged: ${w.email}`);}catch(C){console.error("Failed to delete user:",C),E.error("Failed to delete user");}}});},h=async()=>{if(!i.email.trim()||!i.password.trim()){m("Email and password are required");return}f(true),m("");try{await at("/api/users",{name:i.name.trim()||void 0,email:i.email.trim(),password:i.password,role:i.role}),l(!1),d({name:"",email:"",password:"",role:"customer"}),E.success("User created successfully"),x();}catch(w){let C=w instanceof Error?w.message:"Failed to create user";m(C),E.error(C);}finally{f(false);}},R=["super_admin","admin","editor","author","customer","guest"],S=e.filter(w=>w.email.toLowerCase().includes(a.toLowerCase())||w.name?.toLowerCase().includes(a.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(Ft,{title:"Identity & Access",description:"Manage the core administrative team and security permissions.",icon:lucideReact.Users,action:{label:"New User",onClick:()=>{d({name:"",email:"",password:"",role:"customer"}),m(""),l(true);},icon:lucideReact.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(lucideReact.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:"Search by identity or email...",value:a,onChange:w=>n(w.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:r?Array.from({length:6}).map((w,C)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},C)):S.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"})})}):S.map(w=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${w.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(_u,{user:w}),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:w.name||w.email.split("@")[0]}),w.tenantId&&jsxRuntime.jsx(Dt,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:w.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:w.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:w.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(Dt,{variant:w.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:w.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(lucideReact.Clock,{className:"w-3 h-3"}),w.lastLogin?new Date(w.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:()=>y(w),className:`p-1.5 rounded-lg border transition-all ${w.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:w.locked?"Restore Access":"Restrict Access",children:w.locked?jsxRuntime.jsx(lucideReact.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(lucideReact.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>u(w),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:"Delete User",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]})})]},w.id))})]})}),jsxRuntime.jsxs(Ut,{open:s,onClose:()=>l(false),title:"Create User",size:"lg",children:[jsxRuntime.jsx(Hr,{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:i.name,onChange:w=>d({...i,name:w.target.value}),placeholder:"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:i.email,onChange:w=>d({...i,email:w.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:i.password,onChange:w=>d({...i,password:w.target.value}),placeholder:"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:i.role,onChange:w=>d({...i,role:w.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:R.map(w=>jsxRuntime.jsx("option",{value:w,children:w},w))})]}),c&&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(lucideReact.TriangleAlert,{className:"w-4 h-4"}),c]})]})}),jsxRuntime.jsxs(Vr,{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:h,disabled:g,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:g?"Creating...":"Create User"})]})]})]})}function _u({user:e}){let[t,r]=wa.useState(null);return wa.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 Wd(){let[e,t]=wa.useState("Kyro CMS"),[r,o]=wa.useState("Command Center"),[a,n]=wa.useState("#6366f1"),[s,l]=wa.useState("Welcome back to your Command Center."),[i,d]=wa.useState(false),[c,m]=wa.useState(false);return wa.useEffect(()=>{(async()=>{try{let v=await Be("/api/globals/site-settings"),x=v.data||v;x&&Object.keys(x).length>0&&(x.siteName&&t(x.siteName),x.adminTitle&&o(x.adminTitle),x.primaryColor&&n(x.primaryColor),x.dashboardGreeting&&l(x.dashboardGreeting));}catch(v){console.error("Failed to load branding:",v);}})();},[]),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:async()=>{d(true);try{await Xt("/api/globals/site-settings",{siteName:e,adminTitle:r,primaryColor:a,dashboardGreeting:s}),m(!0),E.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",a),setTimeout(()=>window.location.reload(),800);}catch(b){E.error("Failed to save branding"),console.error(b);}finally{d(false);}},disabled:i,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${c?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[i?jsxRuntime.jsx(lucideReact.RefreshCcw,{className:"w-4 h-4 animate-spin"}):c?jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.Save,{className:"w-4 h-4"}),i?"Saving...":c?"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(lucideReact.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:e,onChange:b=>t(b.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:r,onChange:b=>o(b.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:s,onChange:b=>l(b.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:"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(lucideReact.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:[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}].map(b=>jsxRuntime.jsx("button",{type:"button",onClick:()=>n(b.hex),className:`aspect-square rounded-xl transition-all border-4 ${a===b.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:b.hex},title:b.name},b.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(lucideReact.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(lucideReact.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:[r," Online"]})]}),jsxRuntime.jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",e,"."]}),jsxRuntime.jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:s})]}),jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
99
|
+
\`\`\``})}),!n&&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 An({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false),[l,i]=Ca.useState(false),d=t??"",c=d.length>8?d.slice(0,-8)+"*".repeat(8):d,m=async()=>{if(d)try{await navigator.clipboard.writeText(d),s(!0),setTimeout(()=>s(!1),1800);}catch{let v=document.createElement("textarea");v.value=d,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v),s(true),setTimeout(()=>s(false),1800);}},f=()=>{if(l||a)return;i(true);let v=new Uint8Array(32);crypto.getRandomValues(v);let b=Array.from(v).map(g=>g.toString(16).padStart(2,"0")).join("");r?.(b),setTimeout(()=>i(false),400);};return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:"relative flex-1",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:c,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider pr-10 opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})}),jsxRuntime.jsx("button",{type:"button",onClick:m,disabled:!d||a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:n?"Copied!":"Copy full secret",children:n?jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 text-[var(--kyro-success)]"}):jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:f,disabled:a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-warning)] hover:bg-[var(--kyro-warning)]/10 transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:"Regenerate secret",children:jsxRuntime.jsx(lucideReact.RefreshCw,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})})}var Fn=null,$l=false,Ds=async()=>(Fn&&$l||(Fn=unstorage.createStorage({driver:km__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),$l=true),Fn),hm=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Ds()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Ds()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Ds()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},$e=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,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);JSON.stringify(o)!==JSON.stringify(a.lastSavedData[r])?n.add(r):n.delete(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},l=s;for(let i=0;i<n.length-1;i++)l[n[i]]===void 0&&(l[n[i]]={}),l[n[i]]={...l[n[i]]},l=l[n[i]];return l[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})),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,l]of Object.entries(a))o-new Date(l.draftUpdatedAt).getTime()<6048e5&&(n[s]=l);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(()=>hm()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function Dn(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function Go({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,s=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:i,setIsSlugLocked:d,formData:c}=$e(),m=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",f=t==null?"":String(t),v={id:e.name,value:f,onChange:b=>r?.(b.target.value),placeholder:e.admin?.placeholder,disabled:a||n||l&&i,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||n||l&&i?"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:[s?jsxRuntime.jsx("textarea",{...v,rows:e.rows||4}):jsxRuntime.jsx("input",{type:m,...v,pattern:e.pattern}),l&&jsxRuntime.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!i&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r?.(Dn(c[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:"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:()=>d(!i),className:`p-1.5 rounded transition-colors ${i?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:i?"Unlock slug":"Lock slug",children:i?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 Pn({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 In({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:l=>r?.(l.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 Bn({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 Ba(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Mn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function En(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Ia(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 Nm={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function bo(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 bo(s.fields,n,r);if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&bo(i.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let i=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of s.blocks)if(c.slug===i&&c.fields&&Array.isArray(c.fields))return bo(c.fields,d,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?bo(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)&&bo(s.fields,t,r))return true;if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&bo(i.fields,t,r))return true}}}return false}function Cm(e,t){for(let[r,o]of Object.entries(e)){let a=Nm[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:s,...l}=n;if(o.admin={...o.admin,...l},s&&o.fields&&Array.isArray(o.fields))for(let[i,d]of Object.entries(s))bo(o.fields,i,d);}}}function Sm(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 Ia(t,Object.values(templates.mediaCollections)),Ia(t,Object.values(templates.authCollections)),{collections:Mn(t),globals:En(r)}}function Tm(e){let t=Ba(e.collections),r=Ba(e.globals);if(t.length===0&&r.length===0)return Sm("kitchen-sink");let o=[];return Ia(o,Object.values(templates.mediaCollections)),Ia(o,Object.values(templates.authCollections)),Ia(o,t),{collections:Mn(o),globals:En(r)}}var Ln=null;function Rm(){if(Ln)return Ln;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Do__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return Ln=JSON.parse(Do__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),Ln}catch{}return null}var ql=Rm()||{collections:[],globals:[]},Xl=Tm(ql);Cm(Xl.collections,ql.collectionOverrides);var Yl=Xl,Wo=Yl.collections,Ql=Yl.globals,Bs=["users","audit_logs"];Object.values(Wo).filter(e=>!Bs.includes(e.slug)&&e.admin?.hidden!==true);function $n({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,m]=Ca.useState(null),f=JSON.stringify(n||{}),v=JSON.stringify(s||{});Ca.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let x=setTimeout(async()=>{try{let u="";if(l)u=`${br}/${l}/dynamic-options/${e.name}`;else if(i)u=`${br}/globals/${i}/dynamic-options/${e.name}`;else return;let y=await at(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(f),siblingData:JSON.parse(v)})});if(y.ok){let h=await y.json();h.options&&m(h.options);}}catch(u){console.error("Failed to fetch dynamic options:",u);}},300);return ()=>clearTimeout(x)},[f,v,e.name,e.options,l,i]);let b=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?b=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(b=e.options)),e.dynamicOptions==="collections"&&(b=Object.keys(Wo).filter(g=>g!=="media").map(g=>({label:Wo[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 x=Array.from(g.target.selectedOptions,u=>u.value);r?.(x);}else r?.(g.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),b.map(g=>jsxRuntime.jsx("option",{value:g.value,children:g.label},g.value))]})})}function On({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 Us(e){let t=e?.mainTabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function jm({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:l,transform:i,transition:d,isDragging:c}=sortable.useSortable({id:e}),m={transform:utilities.CSS.Transform.toString(i),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxRuntime.jsxs("span",{ref:l,style:m,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(lucideReact.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(lucideReact.X,{className:"w-3 h-3"})})]})}function _m({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false),[l,i]=Ca.useState(""),[d,c]=Ca.useState([]),[m,f]=Ca.useState(false),[v,b]=Ca.useState([]),g=Ca.useRef(new Set),x=Ca.useRef(null),u=Ca.useRef(()=>{});u.current=r||(()=>{});let y=e.hasMany,h=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],R=h.length>1,[P,w]=Ca.useState(h[0]||""),k=Ca.useCallback(()=>t?(y?Array.isArray(t)?t:[]:t?[t]:[]).map(j=>typeof j=="object"&&j!==null?j.value||j.id||"":String(j)).filter(Boolean):[],[t,y]),p=Ca.useCallback($=>{$.length!==0&&$.forEach(j=>{if(g.current.has(j))return;g.current.add(j);let ae=R?(()=>{if(!t)return P;let H=(y?Array.isArray(t)?t:[]:[t]).find(re=>typeof re=="object"&&re!==null?re.value===j||re.id===j:false);return H&&typeof H=="object"&&H.relationTo||P})():P;Be(`/api/${ae}/${j}`).then(ne=>{let H=ne.data||ne;!H||typeof H!="object"||b(re=>re.some(ve=>ve.id===j)?re:[...re,{...H,id:String(H.id),relationTo:ae}]);}).catch(()=>{});});},[R,t,P,y]);Ca.useEffect(()=>{let $=k();p($);},[k,p]);let T=Ca.useCallback(($="")=>{f(true);let ae=`/api/${P}?${Za($,["title","name","label","email"])}`;Be(ae).then(ne=>{c(H=>{let re=new Set(H.map(L=>L.id)),ve=(ne.docs||[]).filter(L=>!re.has(L.id)).map(L=>({...L,id:L.id}));return [...H,...ve]}),f(false);}).catch(()=>{f(false);});},[P]);Ca.useEffect(()=>{n&&(c([]),T(l));},[n,P]),Ca.useEffect(()=>{let $=j=>{x.current&&!x.current.contains(j.target)&&s(false);};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);let B=$=>typeof $=="object"&&$!==null?$.value||$.id||"":String($),S=$=>{let j=$.id;return t?y&&Array.isArray(t)?t.some(ae=>B(ae)===j):B(t)===j:false},F=$=>{let j=$.id;if(y){let ae=Array.isArray(t)?t:[];if(S($))u.current?.(ae.filter(ne=>B(ne)!==j));else {let ne=R?{relationTo:P,value:j}:j;u.current?.([...ae,ne]);}}else if(S($))u.current?.(null);else {let ae=R?{relationTo:P,value:j}:j;u.current?.(ae),s(false),i("");}},A=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),X=$=>{let{active:j,over:ae}=$;if(!ae||j.id===ae.id)return;let ne=y?Array.isArray(t)?t:[]:[],H=ne.findIndex(ve=>B(ve)===j.id),re=ne.findIndex(ve=>B(ve)===ae.id);if(H!==-1&&re!==-1){let ve=[...ne],[L]=ve.splice(H,1);ve.splice(re,0,L),u.current?.(ve);}},K=()=>{if(!t)return null;let $=y?Array.isArray(t)?t:[]:t?[t]:[],j=$.map(ae=>B(ae));return y&&$.length>1?jsxRuntime.jsx(core.DndContext,{sensors:A,collisionDetection:core.closestCenter,onDragEnd:X,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:j,strategy:sortable.horizontalListSortingStrategy,children:$.map(ae=>{let ne=B(ae),H=v.find(L=>L.id===ne),re=H?Us(H):ne.slice(0,12),ve=R&&H?H.relationTo:null;return jsxRuntime.jsx(jm,{id:ne,label:re,relation:ve,onRemove:()=>{let L=$.filter(O=>B(O)!==ne);u.current?.(L);},disabled:a},ne)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:$.map(ae=>{let ne=B(ae),H=v.find(L=>L.id===ne),re=H?Us(H):ne.slice(0,12),ve=R&&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:[ve&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[ve,":"]}),re,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let L=$.filter(O=>B(O)!==ne);u.current?.(y?L:L[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},ne)})})};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:x,className:"relative",children:[R&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:h.map($=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{w($),c([]),i("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${P===$?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:$},$))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.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:$=>{i($.target.value),s(true),T($.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${P}...`,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(lucideReact.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${n?"rotate-180":""}`})})]}),n&&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..."}):d.length===0?jsxRuntime.jsx(On,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:d.map($=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>F($),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${S($)?"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:Us($)}),S($)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in $&&typeof $.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:$.slug})]},$.id))})}),K()]}),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 La=_m;var xo=Ca.createContext(null);function ed(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=zs(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=qo(a),{blocks:l}=o(),i=[...l];n!==void 0?i.splice(n,0,s):i.push(s),r({blocks:i});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:s}=o(),l=Ma(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=[...i];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),s=Ma(n,l=>{let i=l.filter(d=>d.id!==a);return i.length!==l.length?{newList:i,found:true}:{newList:l,found:false}});if(s!==n){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}},moveBlock:(a,n)=>{let{blocks:s}=o(),l=Ma(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<i.length){let m=[...i];return [m[d],m[c]]=[m[c],m[d]],{newList:m,found:true}}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}}}))}function zs(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=zs(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?zs(o.children):o.children}))}),r}):[]}function qo(e){let t=Gm(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 Gm(e){return {heading:{level:1,text:""},"heading-subheading":{heading:"",subheading:""},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 je(e){let t=Ca.useContext(xo);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 l=o(s.children);if(l)return l}}}};return o(r.blocks)})}function Le(){let e=Ca.useContext(xo);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 Ma(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(s=>{let l={...s},i=false;if(s.children&&s.children.length>0){let d=Ma(s.children,t);d!==s.children&&(l.children=d,i=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 m=Ma(c.children,t);if(m!==c.children)return {...c,children:m}}return c});d.some((c,m)=>c!==s.data.columnData[m])&&(l.data={...l.data,columnData:d},i=true);}return i&&(a=true),i?l:s});return a?n:e}function $a({open:e,onClose:t,onSelect:r,children:o}){return e?jsxRuntime.jsxs(dr,{open:e,onClose:t,title:"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]}):null}function td({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 _s=({text:e="",onChange:t,compact:r=false})=>jsxRuntime.jsx("div",{className:r?"":"space-y-3",children:jsxRuntime.jsx("input",{type:"text",value:e,onChange:a=>t("text",a.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:"Enter heading text..."})});var ko=({id:e,type:t,label:r,children:o,className:a=""})=>{let{moveBlock:n,removeBlock:s}=Le();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:()=>n(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var ad=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(ko,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx(_s,{text:a.text||"",onChange:n,compact:true})})};var sd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(ko,{id:e.id,type:"paragraph",label:"Paragraph",children:jsxRuntime.jsx("textarea",{value:a.text||"",onChange:s=>n("text",s.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:"Enter paragraph text..."})})};var id=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Remove",children:jsxRuntime.jsx(lucideReact.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(lr,{field:{label:"Image Asset",name:"src",maxCount:1},value:s.src,onChange:i=>l("src",i)})]}),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:s.alt||"",onChange:i=>l("alt",i.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:"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:s.caption||"",onChange:i=>l("caption",i.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:"Image caption..."})]})]})]})};var Vs=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{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:s=>r("src",s.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:s=>r("title",s.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:"Video title (optional)..."})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(lr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(s=>r("src",s))}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsxRuntime.jsx("input",{type:"url",value:e,onChange:s=>r("src",s.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:s=>r("title",s.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:"Video title (optional)..."})]})};var dd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Vs,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:i=>l("src",i),compact:true})]})};function ou({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:l,isDragging:i}=sortable.useSortable({id:e}),d={transform:utilities.CSS.Transform.toString(s),transition:l,zIndex:i?10:1,opacity:i?.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 ${i?"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(lucideReact.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 Oa=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ca__default.default.useState(""),[n,s]=Ca__default.default.useState([]);Ca__default.default.useEffect(()=>{let v=n.map(b=>b.text);JSON.stringify(v)!==JSON.stringify(e)&&s(e.map((b,g)=>({id:`${b}-${g}-${Math.random().toString(36).substr(2,4)}`,text:b})));},[e]);let l=()=>{o.trim()&&(t([...e,o.trim()]),a(""));},i=v=>{v.key==="Enter"&&(v.preventDefault(),l());},d=v=>{t(e.filter((b,g)=>g!==v));},c=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),m=v=>{let{active:b,over:g}=v;if(!g||b.id===g.id)return;let x=n.findIndex(y=>y.id===b.id),u=n.findIndex(y=>y.id===g.id);if(x!==-1&&u!==-1){let y=[...e],[h]=y.splice(x,1);y.splice(u,0,h),t(y);}},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:c,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:n.map(v=>v.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:n.map((v,b)=>jsxRuntime.jsx(ou,{id:v.id,text:v.text,onRemove:()=>d(b)},v.id))})}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:v=>a(v.target.value),onKeyDown:i,className:f,placeholder:"Type and press Enter to add..."})]})})};var cd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=Array.isArray(s.items)?s.items:[];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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Oa,{items:l,onChange:d=>{o(e.id,{data:{...s,items:d}});},compact:true})]})};var pd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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(lucideReact.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 ",s.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:()=>n(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:"Move up",children:jsxRuntime.jsx(lucideReact.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:()=>a(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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Pa,{field:{type:"code",name:"code",label:"Source Code",language:s.language||"javascript"},value:s.code||"",onChange:i=>l("code",i)}),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:s.language||"javascript",onChange:i=>l("language",i.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(lucideReact.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 md=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(lr,{field:{label:"File",name:"file",maxCount:1},value:s.file,onChange:i=>l("file",i)})]})};var Xs=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ca__default.default.useState(0),n=(m,f)=>{let v=[...e];v[m]={...v[m],title:f},t(v);},s=(m,f)=>{let v=[...e];v[m]={...v[m],content:f},t(v);},l=m=>{let f=e.filter((v,b)=>b!==m);t(f),o===m?a(null):o!==null&&o>m&&a(o-1);},i=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},d="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",c="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:[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,f)=>{let v=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(v?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:m.title||`Item ${f+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5"})}),v?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),v&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:b=>n(f,b.target.value),onClick:b=>b.stopPropagation(),className:c,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:b=>s(f,b.target.value),onClick:b=>b.stopPropagation(),className:`${c} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},f)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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(lucideReact.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"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. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((m,f)=>{let v=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(v?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:m.title||`Item ${f+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})}),v?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),v&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:b=>n(f,b.target.value),className:d,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:b=>s(f,b.target.value),className:`${d} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},f)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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(lucideReact.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var ud=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],i=d=>{o(e.id,{data:{...s,items:d}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Xs,{items:l,onChange:i,compact:true})]})};var yd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=i=>{o(e.id,{data:{...s,content:i}});};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(lucideReact.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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(jo,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var Ys=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let s=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:i=>a("heading",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subheading",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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:i=>a("heading",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subheading",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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 jn({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("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)] mb-6 border-b border-[var(--kyro-border)] pb-2 inline-block",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 uu=new Set(["text","number","checkbox","select","radio","color","email","password"]);function yu(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>uu.has(r.type))}function bd({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:l,onRemove:i,disabled:d,compact:c,getItemLabel:m}){let{attributes:f,listeners:v,setNodeRef:b,transform:g,transition:x,isDragging:u}=sortable.useSortable({id:e}),y={transform:utilities.CSS.Transform.toString(g),transition:x,zIndex:u?10:1,opacity:u?.8:1};return c?jsxRuntime.jsxs("div",{ref:b,style:y,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 ${u?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...f,...v,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(lucideReact.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(h=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(h,a,l)},h.name))}),jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:i,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:"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:b,style:y,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${u?"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,...v,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(lucideReact.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.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:m(a)||`Item ${t+1}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:h=>{h.stopPropagation(),i();},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(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.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(h=>s(h,a,l))})]})}function _n({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=e.fields||[],l=s[0],i=l?.name||"user",d=l?.type==="relationship",[c,m]=Ca__default.default.useState(0);Ca__default.default.useEffect(()=>{let u=false,y=n.filter(h=>typeof h!="object"||h===null?(u=true,false):true).map(h=>!h.id&&!h._key?(u=true,{...h,id:Math.random().toString(36).substr(2,9)}):h);u&&r(y);},[t,r]);function f(u){for(let y of ["label","title","name"]){let h=u[y];if(h&&typeof h=="string")return h}for(let y of s){if(y.type==="text"||y.type==="textarea"){let h=u[y.name];if(h&&typeof h=="string")return h}if(y.type==="group"&&y.fields){for(let h of y.fields)if(h.type==="text"||h.type==="textarea"){let P=u[y.name]?.[h.name];if(P&&typeof P=="string")return P}}}return ""}let v=yu(e),b=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),g=u=>{let{active:y,over:h}=u;if(!h||y.id===h.id)return;let R=n.findIndex(w=>(w.id||w._key)===y.id),P=n.findIndex(w=>(w.id||w._key)===h.id);if(R!==-1&&P!==-1){let w=[...n],[k]=w.splice(R,1);w.splice(P,0,k),r(w);}},x=Ca__default.default.useMemo(()=>n.map(u=>u?.id||u?._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(La,{field:{name:i,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(u=>u[i]).filter(Boolean),onChange:u=>{let y=(u||[]).map(h=>({[i]:h,id:Math.random().toString(36).substr(2,9)}));r(y);},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:b,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:x,strategy:sortable.verticalListSortingStrategy,children:n.map((u,y)=>jsxRuntime.jsx(bd,{id:u.id||u._key||`idx-${y}`,index:y,isOpen:false,setOpenIndex:()=>{},item:u,field:e,renderField:o,onChangeItem:h=>{let R=[...n];R[y]=h,r(R);},onRemove:()=>r(n.filter((h,R)=>R!==y)),disabled:a,compact:true,getItemLabel:f},u.id||u._key||y))}),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:x,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((u,y)=>{let h=c===y;return jsxRuntime.jsx(bd,{id:u.id||u._key||`idx-${y}`,index:y,isOpen:h,setOpenIndex:m,item:u,field:e,renderField:o,onChangeItem:R=>{let P=[...n];P[y]=R,r(P);},onRemove:()=>r(n.filter((R,P)=>P!==y)),disabled:a,compact:false,getItemLabel:f},u.id||u._key||y)})})}),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 u=Math.random().toString(36).substr(2,9);r([...n,{id:u}]),m(n.length);},children:"+ Add Item"})]})})]})}var xd="other";function kd(){return xd}function Hn(e){xd=e;}var wo=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{Hn("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(Go,{field:e,value:t,onChange:d,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(Go,{field:{...e,variant:"textarea"},value:t,onChange:d,error:o,disabled:a});case "password":return jsxRuntime.jsx(Go,{field:{...e,variant:"password"},value:t,onChange:d,error:o,disabled:a});case "secret":return jsxRuntime.jsx(An,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Pn,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(In,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx($n,{field:e,value:t,onChange:d,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i});case "date":return jsxRuntime.jsx(Bn,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(jo,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(Fs,{field:e,value:t,onChange:d,disabled:a,error:o});case "code":return jsxRuntime.jsx(Pa,{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(lr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx(La,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx(Oa,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(_n,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,m,f)=>{let v=m[c.name];return jsxRuntime.jsx(wo,{field:c,value:v,onChange:b=>{f({...m,[c.name]:b});},disabled:a,error:o},c.name)}});case "blocks":return jsxRuntime.jsx(Zs,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsxRuntime.jsx(jn,{field:e,value:t,onChange:r,renderField:(c,m,f)=>{let v=m[c.name];return jsxRuntime.jsx(wo,{field:c,value:v,onChange:b=>{f({...m,[c.name]:b});},disabled:a,error:o,collectionSlug:l,globalSlug:i},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 Qo=({block:e,blockSchema:t,onClose:r})=>{let o=je(e.id),{updateBlock:a}=Le(),n=o?.data||e.data||{},s=o?.children||e.children||[],l=(m,f)=>{a(e.id,{data:{...n,[m]:f}});},i=m=>{a(e.id,{children:m});},d=()=>t&&Array.isArray(t.fields)?jsxRuntime.jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(m=>{if(m.admin?.condition){if(typeof m.admin.condition=="function")try{let v={values:n,...n};if(!m.admin.condition(v,v))return null}catch(v){console.warn(`Condition error for field ${m.name}:`,v);}else if(typeof m.admin.condition=="object")try{let v=m.admin.condition,b=v.field,g=n[b],x=!0;if("equals"in v?x=g===v.equals:"notEquals"in v?x=g!==v.notEquals:"in"in v&&Array.isArray(v.in)&&(x=v.in.includes(g)),!x)return null}catch(v){console.warn(`Declarative condition error for field ${m.name}:`,v);}}let f=n[m.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(wo,{field:m,value:f,onChange:v=>l(m.name,v)})},m.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=Pe[e.type]||Pe.default;return jsxRuntime.jsxs(dr,{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(Zr,{blockId:e.id,children:s,onUpdateChildren:i})]})]}),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 fu=6,Zr=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=fu})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(new Set),[d,c]=Ca.useState(null),[m,f]=Ca.useState(null),v=Ca.useContext(xo);if(!v)throw new Error("ChildBlocksTree must be used within a BlocksContext");let b=zustand.useStore(v,p=>p.dynamicCategories),g=zustand.useStore(v,p=>p.allowedBlocks),x=o<a,u=16,y=p=>{let T=qo(p);r([...t,T]),c(T.id);},h=p=>{let T=t.filter(B=>B.id!==p);r(T);},P=(p,T)=>{let B=t.map(S=>S.id===p?{...S,children:T}:S);r(B);},w=p=>{i(T=>{let B=new Set(T);return B.has(p)?B.delete(p):B.add(p),B});},k=p=>{let T=p.children&&p.children.length>0,B=l.has(p.id);ei(p.type);let F=T,A=d===p.id,X=g.find(K=>K.slug===p.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 ${A?"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"} ${x?"cursor-pointer":""}`,style:{marginLeft:o*u},onClick:()=>{x&&c(A?null:p.id);},children:[F?jsxRuntime.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),w(p.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:B?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),zt[p.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:zt[p.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:[ja(p),p.data?.text?` - ${p.data.text.slice(0,30)}`:"",p.data?.heading?` - ${p.data.heading.slice(0,30)}`:""]}),X?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:X.admin.description})]}),T&&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:[p.children.length," nested"]}),m===p.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:K=>K.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(p.id),f(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f(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:K=>{K.stopPropagation(),f(p.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),A&&jsxRuntime.jsx(Qo,{block:p,onClose:()=>c(null)}),T&&B&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Nd,{parentId:p.id,children:p.children,onUpdateChildren:K=>P(p.id,K),depth:o+1,maxDepth:a})})]},p.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),x&&jsxRuntime.jsxs("div",{style:{marginLeft:o*u},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(lucideReact.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx($a,{open:n,onClose:()=>s(false),onSelect:y,children:b.map(p=>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:p.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:p.blocks.map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{y(T.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:zt[T.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:T.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:T.admin?.description||""})]})]},T.slug))})]},p.title))})]}),t.length===0&&x&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*u},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*u},children:["Maximum nesting level (",a,") reached"]})]})},Nd=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(new Set),[d,c]=Ca.useState(null),[m,f]=Ca.useState(null),v=Ca.useContext(xo);if(!v)throw new Error("NestedChildBlocks must be used within a BlocksContext");let b=zustand.useStore(v,p=>p.dynamicCategories),g=zustand.useStore(v,p=>p.allowedBlocks),x=o<a,u=16,y=p=>{let T=qo(p);r([...t,T]),c(T.id);},h=p=>{let T=t.filter(B=>B.id!==p);r(T);},P=(p,T)=>{let B=t.map(S=>S.id===p?{...S,children:T}:S);r(B);},w=p=>{i(T=>{let B=new Set(T);return B.has(p)?B.delete(p):B.add(p),B});},k=p=>{let T=p.children&&p.children.length>0,B=l.has(p.id);ei(p.type);let F=T,A=d===p.id,X=g.find(K=>K.slug===p.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 ${A?"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"} ${x?"cursor-pointer":""}`,style:{marginLeft:o*u},onClick:()=>{x&&c(A?null:p.id);},children:[F?jsxRuntime.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),w(p.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:B?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),zt[p.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:zt[p.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:[ja(p),p.data?.text?` - ${p.data.text.slice(0,30)}`:"",p.data?.heading?` - ${p.data.heading.slice(0,30)}`:""]}),X?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:X.admin.description})]}),T&&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:[p.children.length," nested"]}),m===p.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:K=>K.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(p.id),f(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f(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:K=>{K.stopPropagation(),f(p.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),A&&jsxRuntime.jsx(Qo,{block:p,onClose:()=>c(null)}),T&&B&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Nd,{parentId:p.id,children:p.children,onUpdateChildren:K=>P(p.id,K),depth:o+1,maxDepth:a})})]},p.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),x&&jsxRuntime.jsxs("div",{style:{marginLeft:o*u},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(lucideReact.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx($a,{open:n,onClose:()=>s(false),onSelect:y,children:b.map(p=>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:p.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:p.blocks.map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{y(T.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:zt[T.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:T.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:T.admin?.description||""})]})]},T.slug))})]},p.title))})]}),t.length===0&&x&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*u},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*u},children:["Maximum nesting level (",a,") reached"]})]})};var Cd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=r?.children??e.children??[],i=(d,c)=>{o(e.id,{data:{...s,[d]:c}});};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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Ys,{heading:s.heading||"",subheading:s.subheading||"",ctaText:s.ctaText||"",ctaUrl:s.ctaUrl||"",onChange:i,compact:true}),jsxRuntime.jsx(lr,{field:{label:"Background",name:"bgImage",maxCount:1},value:s.bgImage,onChange:d=>i("bgImage",d)}),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(Zr,{blockId:e.id,children:l,onUpdateChildren:d=>o(e.id,{children:d})})]})]})]})};var ti=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:s=false})=>{let 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",i=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:d=>n("title",d.target.value),className:`${l} font-bold text-base`,placeholder:"Card title..."}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>n("description",d.target.value),className:i,placeholder:"Card description..."}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>n("icon",d.target.value),className:l,placeholder:"Icon (emoji or name)..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:d=>n("linkText",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:"Link text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>n("link",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://..."})]})]})};var Rd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(ko,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(ti,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Ad=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le();r?.data??e.data??{};let l=r?.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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(Zr,{blockId:e.id,children:l,onUpdateChildren:i=>o(e.id,{children:i})})})]})};var Ha=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let[l,i]=Ca.useState(false),[d,c]=Ca.useState(""),[m,f]=Ca.useState([]),[v,b]=Ca.useState(false),[g,x]=Ca.useState([]),[u,y]=Ca.useState(true);Ca.useEffect(()=>{Be("/api/collections").then(S=>{x((S.collections||[]).map(F=>F.slug||F.name||F)),y(false);}).catch(()=>y(false));},[]);let h=(S="")=>{b(true);let F=`/api/${e}?${Za(S,[a],20)}`;Be(F).then(A=>{f(A.docs||[]),b(false);}).catch(()=>b(false));};Ca.useEffect(()=>{l&&h(d);},[l,d,e,a]);let R=S=>S?.[a]||S?.title||S?.name||S?.label||S?.filename||S?.slug||S?.id||"Untitled",P=t?r:o?[o]:[],w=S=>{t?P.includes(S.id)?n("selectedIds",P.filter(F=>F!==S.id)):n("selectedIds",[...P,S.id]):(n("selectedId",S.id),n("selectedIds",[S.id]),i(false));},k=S=>P.includes(S),p=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",T=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",B=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:[!B&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:u?jsxRuntime.jsx("div",{className:T+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:S=>n("relationTo",S.target.value),className:T,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),g.map(S=>jsxRuntime.jsx("option",{value:S,children:S},S))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:S=>n("hasMany",S.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(lucideReact.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:d,onChange:S=>{c(S.target.value),i(true);},onFocus:()=>i(true),onBlur:()=>setTimeout(()=>i(false),200),placeholder:`Search ${e}...`,className:`${p} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:v&&jsxRuntime.jsx(lucideReact.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:v?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):m.length===0?jsxRuntime.jsx(On,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:m.map(S=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:F=>F.preventDefault(),onClick:()=>w(S),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${k(S.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:R(S)}),k(S.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},S.id))})})]}),P.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(S=>{let F=m.find(A=>A.id===S)||{id:S};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:[R(F),jsxRuntime.jsx("button",{type:"button",onMouseDown:A=>A.preventDefault(),onClick:()=>{t?n("selectedIds",P.filter(A=>A!==S)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},S)})})]})};var Dd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};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 ",s.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:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ha,{relationTo:s.relationTo||"pages",hasMany:s.hasMany||false,selectedIds:Array.isArray(s.selectedIds)?s.selectedIds:[],selectedId:s.selectedId,labelField:s.labelField||"title",onChange:l,compact:true})]})};var gu={heading:ad,paragraph:sd,image:id,video:dd,list:cd,code:pd,file:md,accordion:ud,richtext:yd,hero:Cd,card:Rd,array:Ad,relationship:Dd},Pe={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"}},zt={heading:jsxRuntime.jsx(lucideReact.Heading1,{className:`w-4 h-4 ${Pe.default.text}`}),paragraph:jsxRuntime.jsx(lucideReact.AlignLeft,{className:`w-4 h-4 ${Pe.default.text}`}),image:jsxRuntime.jsx(lucideReact.Image,{className:`w-4 h-4 ${Pe.default.text}`}),video:jsxRuntime.jsx(lucideReact.Video,{className:`w-4 h-4 ${Pe.default.text}`}),list:jsxRuntime.jsx(lucideReact.List,{className:`w-4 h-4 ${Pe.default.text}`}),code:jsxRuntime.jsx(lucideReact.Code,{className:`w-4 h-4 ${Pe.default.text}`}),file:jsxRuntime.jsx(lucideReact.File,{className:`w-4 h-4 ${Pe.default.text}`}),accordion:jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 ${Pe.default.text}`}),richtext:jsxRuntime.jsx(lucideReact.AlignLeft,{className:`w-4 h-4 ${Pe.default.text}`}),hero:jsxRuntime.jsx(lucideReact.Star,{className:`w-4 h-4 ${Pe.hero.text}`}),card:jsxRuntime.jsx(lucideReact.Box,{className:`w-4 h-4 ${Pe.card.text}`}),array:jsxRuntime.jsx(lucideReact.ListOrdered,{className:`w-4 h-4 ${Pe.default.text}`}),relationship:jsxRuntime.jsx(lucideReact.Link2,{className:`w-4 h-4 ${Pe.default.text}`}),featureSplit:jsxRuntime.jsx(lucideReact.Columns3,{className:`w-4 h-4 ${Pe.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(lucideReact.Blocks,{className:`w-4 h-4 ${Pe.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(lucideReact.Sparkles,{className:`w-4 h-4 ${Pe.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(lucideReact.Users,{className:`w-4 h-4 ${Pe.testimonials.text}`}),faq:jsxRuntime.jsx(lucideReact.CircleHelp,{className:`w-4 h-4 ${Pe.faq.text}`}),stats:jsxRuntime.jsx(lucideReact.Activity,{className:`w-4 h-4 ${Pe.stats.text}`}),logoCloud:jsxRuntime.jsx(lucideReact.Image,{className:`w-4 h-4 ${Pe.logoCloud.text}`}),pricing:jsxRuntime.jsx(lucideReact.Tag,{className:`w-4 h-4 ${Pe.pricing.text}`}),team:jsxRuntime.jsx(lucideReact.Users,{className:`w-4 h-4 ${Pe.team.text}`}),recentFeed:jsxRuntime.jsx(lucideReact.Database,{className:`w-4 h-4 ${Pe.recentFeed.text}`}),processSteps:jsxRuntime.jsx(lucideReact.Clock,{className:`w-4 h-4 ${Pe.processSteps.text}`}),formEmbed:jsxRuntime.jsx(lucideReact.Mail,{className:`w-4 h-4 ${Pe.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(lucideReact.Video,{className:`w-4 h-4 ${Pe.videoShowcase.text}`})};function ei(e){return gu[e]||null}function ri(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 ja(e){let t=e.name;return t&&t.trim()?t.trim():ri(e.type)}function Pu(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.heading||e.title||e.text||e.name||e.label||e.sectionTitle||""}var Iu=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{attributes:l,listeners:i,setNodeRef:d,transform:c,transition:m,isDragging:f}=sortable.useSortable({id:e.id}),{removeBlock:v,updateBlock:b}=Le(),g=o===e.id,[x,u]=Ca.useState(false),[y,h]=Ca.useState(false),[R,P]=Ca.useState(e.name||""),w=Ca.useRef(null);Ca.useEffect(()=>{y&&w.current&&(w.current.focus(),w.current.select());},[y]);let k=Ca.useCallback(()=>{h(false);let F=R.trim();F!==(e.name||"").trim()&&b(e.id,{name:F||""});},[R,e.name,e.id,b]),p={transform:utilities.CSS.Transform.toString(c),transition:m,zIndex:f?10:1,opacity:f?.8:1},T=ja(e),B=e.data||{},S=Pu(B,r);return s?jsxRuntime.jsxs("div",{ref:d,style:p,className:"relative group",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-1 pl-5 pr-1.5 py-1 bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-xs whitespace-nowrap ${g?`${(Pe[e.type]||Pe.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-0.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,...i,onClick:F=>F.stopPropagation(),children:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-2.5 h-2.5"})}),zt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:zt[e.type]}),y?jsxRuntime.jsx("input",{ref:w,value:R,onChange:F=>P(F.target.value),onBlur:k,onKeyDown:F=>{F.key==="Enter"&&k(),F.key==="Escape"&&(P(e.name||""),h(false));},onClick:F=>F.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)] truncate max-w-[120px] transition-colors",children:T}),x?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:F=>F.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(e.id),u(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:()=>u(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:F=>{F.stopPropagation(),P(e.name||""),h(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"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:F=>{F.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate",children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),u(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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),g&&jsxRuntime.jsx(Qo,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:d,style:p,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 ${g?`${(Pe[e.type]||Pe.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,...i,onClick:F=>F.stopPropagation(),children:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-4 h-4"})}),zt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:zt[e.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[y?jsxRuntime.jsx("input",{ref:w,value:R,onChange:F=>P(F.target.value),onBlur:k,onKeyDown:F=>{F.key==="Enter"&&k(),F.key==="Escape"&&(P(e.name||""),h(false));},onClick:F=>F.stopPropagation(),placeholder:ri(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:[T,S&&typeof S=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",S.length>40?`${S.slice(0,40)}...`:S]})]}),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"]}),x?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:F=>F.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(e.id),u(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:()=>u(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:F=>{F.stopPropagation(),P(e.name||""),h(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"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:F=>{F.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate Block",children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),u(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:"Remove Block",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5"})})]})]}),g&&jsxRuntime.jsx(Qo,{block:e,blockSchema:r,onClose:()=>a(null)})]})},Bu=Ca__default.default.memo(Iu),Zs=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:l})=>{let[i,d]=Ca.useState(false),[c,m]=Ca.useState(false),f=Ca.useRef(null),v=e.admin?.pickerMode||"drawer",b=e.blocks||[],g=b.reduce((L,O)=>{let pe=O.admin?.group||"Custom Blocks";return L[pe]||(L[pe]=[]),L[pe].push(O),L},{}),x=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],u=Object.entries(g).sort(([L],[O])=>{let pe=x.indexOf(L),ge=x.indexOf(O);return pe!==-1&&ge!==-1?pe-ge:pe!==-1?-1:ge!==-1?1:L.localeCompare(O)}).map(([L,O])=>({title:L,blocks:O})),y=Ca.useRef(null);y.current||(y.current=ed(b,u));let h=y.current,R=zustand.useStore(h,L=>L.blocks),[P,w]=Ca.useState(null),[k,p]=Ca.useState(null),T=Ca.useRef(R.length),B=Ca.useRef(new Set(R.map(L=>L.id))),S=Ca.useRef(false);Ca.useEffect(()=>{if(S.current&&R.length>T.current){let L=R.find(O=>O.id&&!B.current.has(O.id));L&&p(L.id);}T.current=R.length,B.current=new Set(R.map(L=>L.id));},[R]),Ca.useEffect(()=>(o&&h.getState().setOnBlocksChange(o),()=>{h.getState().setOnBlocksChange(()=>{});}),[o,h]);let F=Ca.useRef(null);Ca.useEffect(()=>{let L=Array.isArray(t)?t:[],O=F.current||[];if(JSON.stringify(L)!==JSON.stringify(O)){let pe=[...L];T.current=pe.length,B.current=new Set(pe.map(ge=>ge.id)),h.getState().setBlocks(pe),F.current=pe,S.current=true;}else L.length===0&&!S.current&&(S.current=true,F.current=[]);},[t,e.name,h]);let A=Ca.useRef(r);A.current=r,Ca.useEffect(()=>{if(!A.current)return;let L=F.current;L&&JSON.stringify(R)!==JSON.stringify(L)&&(F.current=[...R],A.current(R));},[R]);let K=Ca.useCallback(L=>{h.getState().addBlock(L);},[h]),$=Ca.useCallback(L=>{let O=R.findIndex(U=>U.id===L);if(O===-1)return;let pe=R[O],ge=U=>{let Y=Math.random().toString(36).substr(2,9);return {...U,id:Y,children:U.children?U.children.map(le=>ge(le)):U.children,data:U.data?JSON.parse(JSON.stringify(U.data)):U.data}},Se=ge(pe),Ne=[...R];Ne.splice(O+1,0,Se),h.getState().setBlocks(Ne);},[R,h]),j=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),ae=L=>{w(L.active);},ne=L=>{let{active:O,over:pe}=L;if(w(null),!!pe){if(O.id.toString().startsWith("drawer-")){let ge=O.id.toString().replace("drawer-","");if(pe.id.toString().startsWith("container-")){let Se=pe.id.toString().replace("container-",""),Ne=R.find(U=>U.id===Se);if(Ne){let U=qo(ge);h.getState().updateBlock(Se,{children:[...Ne.children||[],U]});}}else {let Se=R.findIndex(Ne=>Ne.id===pe.id);Se!==-1?h.getState().addBlock(ge,Se):K(ge);}return}if(O.id!==pe.id){let ge=R.findIndex(Ne=>Ne.id===O.id),Se=R.findIndex(Ne=>Ne.id===pe.id);if(ge!==-1&&Se!==-1){let Ne=[...R],[U]=Ne.splice(ge,1);Ne.splice(Se,0,U),h.getState().setBlocks(Ne);}}}},H=P?u.flatMap(L=>L.blocks).find(L=>`drawer-${L.type}`===P.id)||R.find(L=>L.id===P.id):null;H?"label"in H?H.label:H.type:"Block";return Ca.useEffect(()=>{if(!c)return;let L=O=>{f.current&&!f.current.contains(O.target)&&m(false);};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[c]),jsxRuntime.jsx(xo.Provider,{value:y.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",children:[jsxRuntime.jsxs(core.DndContext,{sensors:j,collisionDetection:core.closestCenter,onDragStart:ae,onDragEnd:ne,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),v==="dropdown"?jsxRuntime.jsxs("div",{ref:f,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(!c),disabled:n,className:"flex items-center gap-1.5 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.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Element",jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3.5 h-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full mt-1 w-56 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:u.map(L=>jsxRuntime.jsxs("div",{children:[u.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(O=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{K(O.slug),m(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:zt[O.slug]||jsxRuntime.jsx(lucideReact.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:O.label}),O.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:O.admin.description})]})]},O.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(lucideReact.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx($a,{open:i,onClose:()=>d(false),onSelect:K,children:jsxRuntime.jsx("div",{className:"space-y-4",children:u.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(O=>jsxRuntime.jsx(td,{block:{type:O.slug,label:O.label,description:O.admin?.description||"",icon:null},onSelect:K,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:zt[O.slug]||jsxRuntime.jsx(lucideReact.Box,{className:"w-4 h-4"})})})},O.slug))})]},L.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:R.map(L=>L.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:v==="dropdown"?"flex flex-wrap gap-1.5":"space-y-4",children:[R.map((L,O)=>{let pe=e.blocks?.find(ge=>ge.slug===L.type);return jsxRuntime.jsx(Bu,{block:L,index:O,blockSchema:pe,editingBlockId:k,setEditingBlockId:p,onDuplicate:$,compact:v==="dropdown"},L.id||O)}),R.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:P&&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 Sr(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(Sr);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]=Sr(t[s]);return n}return e}function Id(){let e=Ca.useRef([]),t=Ca.useRef(false);return {queueTask:Ca.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(l){console.error("Error in queued function:",l);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function Bd({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:l}){let i=$e(),{confirm:d}=dt(),{formData:c,setFormData:m,setField:f,lastSavedData:v,setLastSavedData:b,setHasUnsavedChanges:g,isSlugLocked:x,loadDocument:u,setIsAutoSaving:y,setAutoSaveStatus:h,setVersions:R,setLoadingVersions:P,sidebarCollapsed:w,setSidebarCollapsed:k,getDraftCache:p,setDraftCache:T,clearDraftCache:B,resetForm:S}=i,F=!!e.versions,A=o||t?.id||a||r,X=Ca.useRef(false);!o&&A&&c&&Object.keys(c).length>0&&c.id!==A&&(X.current=true),Ca.useEffect(()=>{X.current&&(X.current=false,S());},[S]);let K=Ca.useRef(null),$=Ca.useRef(null),j=Ca.useRef(null),ae=Ca.useRef(typeof navigator<"u"?navigator.onLine:true),ne=Ca.useRef(0),H=Ca.useRef(false),re=Ca.useRef(null),ve=Ca.useRef(""),L=Ca.useRef(""),{queueTask:O}=Id(),pe=Ca.useCallback(Q=>o?`global:${o}`:r&&Q?`${r}:${Q}`:null,[r,o]),ge=Ca.useCallback((Q,te,ce)=>{T(Q,{data:te,baseUpdatedAt:v.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:ce?.lastSyncedAt??null});},[v.updatedAt,T]),Se=Ca.useCallback(async()=>{let Q=o?tt(`/api/globals/${o}/versions`):r&&c.id?tt(`/api/${r}/${c.id}/versions`):null;if(Q){P(true);try{let ce=await(await at(Q)).json();R(ce.docs||[]);}catch(te){console.error("Failed to fetch versions:",te);}finally{P(false);}}},[c.id,r,o,P,R]),Ne=Ca.useCallback(()=>{let Q=$e.getState(),te=Q.formData;if(H.current||!r||!te.id||!Q.hasDirtyFields())return;let ce=pe(te.id);ce&&ge(ce,te);},[r,pe,ge]),U=Ca.useCallback(async Q=>{let te=$e.getState(),ce=te.formData,Te=te.lastSavedData;if(H.current||!F&&o||!o&&(!r||!ce.id)||!te.hasDirtyFields())return;let Fe=pe(ce.id);if(Fe&&ge(Fe,ce),!ae.current){h("offline");return}y(true),h("saving"),te.setBackgroundProcessing(true);try{let lt=o?tt(`/api/globals/${o}?autosave=true`):tt(`/api/${r}/${ce.id}?autosave=true`),Tt=await at(lt,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:Q?.keepalive,body:JSON.stringify({...Sr(ce),baseUpdatedAt:Te.updatedAt??null})});if(Tt.ok)ne.current=Date.now(),te.setRetryCount(0),te.setLastSavedAt(Date.now()),j.current&&clearTimeout(j.current),Fe&&T(Fe,{data:ce,baseUpdatedAt:Te.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await Tt.clone().json()).data?.updatedAt||new Date().toISOString()}),h("success"),setTimeout(()=>{$e.getState().autoSaveStatus==="success"&&h("idle");},2e3);else if(Tt.status===409)h("conflict");else throw new Error(`Draft auto-save failed with status ${Tt.status}`)}catch(lt){console.error("Auto-save failed:",lt);let Tt=$e.getState(),I=Tt.retryCount;if(I<5){Tt.setRetryCount(I+1),h("retrying");let W=Math.min(1e3*Math.pow(2,I),6e4);j.current&&clearTimeout(j.current),j.current=setTimeout(()=>Y(Q),W);}else h("offline");}finally{y(false),$e.getState().setBackgroundProcessing(false);}},[r,pe,o,ge,h,T,y,F]),Y=Ca.useCallback(Q=>{O(()=>U(Q),{beforeProcess:()=>true,afterProcess:()=>{}});},[U,O]),le=Ca.useCallback(async(Q,te=true)=>{let ce=$e.getState(),Te=Q||ce.formData,Fe=o?tt(`/api/globals/${o}`):tt(`/api/${r}/${Te.id}`),lt=await at(Fe,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(te)},body:JSON.stringify({...Sr(Te),baseUpdatedAt:ce.lastSavedData.updatedAt??null})});return lt.status===409&&h("conflict"),lt},[r,o,h]);Ca.useEffect(()=>{let Q=()=>{k(!w);};return window.addEventListener("toggle-sidebar",Q),()=>window.removeEventListener("toggle-sidebar",Q)},[w,k]);let Re=Ca.useRef(null),Ue=Ca.useRef(""),Ie=Ca.useRef(false);Ca.useEffect(()=>{let Q=o||t?.id,te=JSON.stringify(t);Ie.current&&Re.current===Q&&Ue.current===te||(u(t||{},t||{}),Ie.current=true,Re.current=Q,Ue.current=te);},[r,c.id,o,t,u]),Ca.useEffect(()=>{if(!r||!t?.id)return;let Q=pe(t.id);if(!Q||re.current===Q)return;let te=false;return (async()=>{if(!F)return;let Te=p(Q);if(Te){if(JSON.stringify(Te.data)===JSON.stringify(t)){B(Q);return}re.current=Q,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(te)return;let lt={...$e.getState().formData,...Te.data};m(lt),s?.("Recovered autosaved draft");},onCancel:async()=>{B(Q);}});}})(),()=>{te=true;}},[B,r,d,pe,p,t,s,m,F]);function et(Q,te){for(let ce of Q){if(ce.name===te&&ce.admin?.autoGenerate==="title")return ce;if(ce.type==="tabs"&&"tabs"in ce)for(let Te of ce.tabs){let Fe=et(Te.fields,te);if(Fe)return Fe}if((ce.type==="group"||ce.type==="collapsible")&&"fields"in ce){let Te=et(ce.fields,te);if(Te)return Te}}}Ca.useEffect(()=>{let Q=e.fields;if(!et(Q,"metaTitle"))return;let ce=go(Q,c,"title"),Te=ce?String(ce):"";Te&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&f("metaTitle",Te);},[c,e.fields,f]),Ca.useEffect(()=>{let Q=e.fields,te=Q.find(Fe=>Fe.name==="slug"&&Fe.admin?.autoGenerate);if(!te?.admin?.autoGenerate)return;let ce=te.admin.autoGenerate,Te=go(Q,c,ce);if(x&&Te){let Fe=Dn(Te);Fe!==c.slug&&f("slug",Fe);}},[c,x,e.fields,f]),Ca.useEffect(()=>{if(w||!o&&(!r||!c.id)||!$e.getState().hasDirtyFields()||kd()!=="keystroke")return;Hn("other");let te=JSON.stringify(c);te!==ve.current&&(K.current&&clearTimeout(K.current),K.current=setTimeout(Ne,1500),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{ve.current=te,Y();},8e3));},[c,w,r,o,Ne,Y]),Ca.useEffect(()=>{if(!o&&(!r||!c.id))return;let Q=()=>{H.current||!$e.getState().hasDirtyFields()||Y({keepalive:true});},te=()=>{document.hidden&&Q();},ce=()=>{ae.current=true,Q();},Te=()=>{ae.current=false;let Fe=$e.getState();Fe.hasDirtyFields()&&Fe.setAutoSaveStatus("offline");};return window.addEventListener("blur",Q),window.addEventListener("pagehide",Q),window.addEventListener("online",ce),window.addEventListener("offline",Te),document.addEventListener("visibilitychange",te),()=>{window.removeEventListener("blur",Q),window.removeEventListener("pagehide",Q),window.removeEventListener("online",ce),window.removeEventListener("offline",Te),document.removeEventListener("visibilitychange",te);}},[r,o,c.id,Y]),Ca.useEffect(()=>{let Q=JSON.stringify(c);if(Q===L.current)return;L.current=Q;let te=document.getElementById("form-data");te&&(te.value=Q),n?.(c);},[c,n]),Ca.useEffect(()=>{(o||c.id)&&Se();},[c.id,o,Se]);let Ct=!c.id&&!o?"draft":F&&c.status||"published",St=(!!c.id||!!o)&&Ct==="draft";return {...i,fetchVersions:Se,performAutoSave:Y,saveDocument:le,autoSaveSkipRef:H,lastAutoSaveTimeRef:ne,documentStatus:Ct,hasUnpublishedChanges:St,versionsEnabled:F}}function So({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=Ca.useState(false),s=Ca.useRef(null);return Ca.useEffect(()=>{let l=i=>{s.current&&!s.current.contains(i.target)&&n(false);};return a&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[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 jt({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 Ka(){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 l=e==="published"&&!r&&t!=="saving"&&t!=="error",i=n||t==="saving"||l,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-success)] border-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)]`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:l?`${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)]`,m="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",f=()=>t==="saving"?`${m} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${m} bg-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-success)]`:t==="error"?`${m} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:l?`${m} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${m} 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 \u2713":t==="error"?"Retry":l?"Published":"Publish Changes";return jsxRuntime.jsxs("div",{className:"inline-flex items-center",children:[jsxRuntime.jsxs("button",{type:"button",onClick:o,disabled:i,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(kr,{size:"sm",className:"inline mr-1.5"}),l&&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(So,{trigger:jsxRuntime.jsx("button",{type:"button",className:f(),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 Ed=({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 Od({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=Ca.useState(0),s=e.tabs||[],l=s[a]||s[0],i=e.name?t[e.name]||{}:t;return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2 border-b border-[var(--kyro-border)] mb-6 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:l?.fields.map(d=>o(d,i,r))}),l?.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(Ed,{title:String((typeof i.metaTitle=="object"?"":i.metaTitle)||(typeof i.title=="object"?"":i.title)||"Untitled"),description:String((typeof i.metaDescription=="object"?"":i.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function jd({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:s,handleDuplicate:l,handleUnpublish:i,handleDelete:d,handlePublish:c,handleSchedulePublish:m}){let[f,v]=Ca.useState(Date.now()),[b,g]=Ca.useState(false),x=Ca.useRef(null),{formData:u,hasUnsavedChanges:y,autoSaveStatus:h,lastSavedAt:R,retryCount:P,view:w,setView:k,showPreview:p,setShowPreview:T,setFormData:B,markSaved:S,lastSavedData:F}=$e(),A=!u.id;Ca.useEffect(()=>{let O=setInterval(()=>v(Date.now()),1e4);return ()=>clearInterval(O)},[]),Ca.useEffect(()=>{let O=pe=>{x.current&&!x.current.contains(pe.target)&&g(false);};if(b)return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[b]);let X=String(u.mainTabs?.title||(typeof u.title=="object"?"":u.title)||(typeof u.name=="object"?"":u.name)||"Untitled"),K=u.updatedAt?new Date(u.updatedAt).toLocaleString():"Just now",$=u.createdAt?new Date(u.createdAt).toLocaleString():"Just now",j=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",ae=o?"Unpublished":r==="published"?"Published":"Draft",ne=r==="published"&&!y?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",H=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",re=(O=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[h==="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"})]}),O?"Saving\u2026":"Saving draft..."]}),h==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 shrink-0"}),O?"Saved":R?`Saved ${Math.floor((Date.now()-R)/6e4)}m ago`:"Draft saved"]}),h==="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"})]}),O?`Retry ${P}/5`:`Retrying save (${P}/5)`]}),h==="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"})]}),O?"Offline":"Offline \u2014 cached locally"]}),h==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:O?"Failed":"Draft save failed"}),h==="conflict"&&(O?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:async()=>{},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"})]}))]}),ve=()=>!A&&jsxRuntime.jsxs(So,{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:"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:[!t&&jsxRuntime.jsx(jt,{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(jt,{onClick:l,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(jt,{onClick:()=>g(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(jt,{onClick:i,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(Ka,{}),jsxRuntime.jsx(jt,{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"})]})]}),L=()=>b&&jsxRuntime.jsx("div",{ref:x,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:()=>g(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let O=document.getElementById("schedule-datetime")?.value;O&&m(O);},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)] 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:`${Ge}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(lucideReact.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:X}),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 ${H}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ne}`}),ae]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:y,onPublish:c,disabled:a==="saving"}),ve(),L()]})]}),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(O=>jsxRuntime.jsx("button",{type:"button",onClick:()=>k(O),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${w===O?"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:O==="edit"?"Edit":O==="version"?"History":"API"},O))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[re(true),y&&h!=="saving"&&h!=="retrying"&&h!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{B(F),S();},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:()=>T(!p),className:`p-1.5 rounded-lg transition-all ${p?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(lucideReact.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:`${Ge}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:X}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${H}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ne}`}),j]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[re(false),y&&h!=="saving"&&h!=="retrying"&&h!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{B(F),S();},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),R&&h!=="saving"&&h!=="retrying"&&h!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let O=f-R,pe=Math.floor(O/6e4),ge=Math.floor(O/1e3);return pe>=1?`${pe}m ago`:ge>=5?`${ge}s ago`:"just now"})()]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",K]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",$]})]})]}),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(O=>jsxRuntime.jsx("button",{type:"button",onClick:()=>k(O),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${w===O?"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:O.toUpperCase()},O))}),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:()=>T(!p),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${p?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:"Live Preview",children:[jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-4 h-4"}),p&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),ve(),L(),jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:y,onPublish:c,disabled:a==="saving"})]})]})]})]})}function _d({config:e,layout:t,collectionSlug:r,renderField:o}){let{showPreview:a,sidebarCollapsed:n,formData:s}=$e();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(d=>o(d))})});let i=e.fields.some(d=>d.admin?.position==="sidebar")&&!a;return jsxRuntime.jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${a?"grid-cols-1 lg:grid-cols-2":n||!i?"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(d=>!d.admin?.position||d.admin.position==="main").map(d=>o(d))})}),a?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:`/${r}/${s.slug||s.id}?preview=true`,className:"w-full h-full border-none",title:"Live Preview"}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):n?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(d=>d.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(d=>d.admin?.position==="sidebar").map(d=>o(d))]})})]})}function Hd({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:l,setCompareDiffs:i,loadingDiffs:d,loadingVersions:c,versions:m}=$e();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`:`${m.length} snapshot${m.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([]),i([]);},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"})]})]}),l.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:[l.length," change",l.length!==1?"s":""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:l.map((f,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:f.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof f.oldValue=="object"?JSON.stringify(f.oldValue):String(f.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 f.newValue=="object"?JSON.stringify(f.newValue):String(f.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"})}):m.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:m.map((f,v)=>{let b=n.includes(f.id),g=(f.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(f.id):void 0,className:`transition-all ${o?b?"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 ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:m.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:[f.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(f.createdAt||f.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:f.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${f.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),f.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:f.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(f.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 ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(lucideReact.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:m.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:[f.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(f.createdAt||f.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),f.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 ${f.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${f.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),f.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:f.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(f.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"})]})]},f.id)})})]})})}function Vd({collectionSlug:e,globalSlug:t}){let{formData:r}=$e();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(r,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()`:r.id?`kyro.collection('${e}').get('${r.id}')`:"Not saved yet"})]}),r.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(r.id)}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(r.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:"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 Kd={};function Wa({config:e,data:t=Kd,errors:r=Kd,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:l,documentName:i,layout:d="split",onActionSuccess:c,onActionError:m,justSaved:f}){let v=e||(s?Ql[s]:n?Wo[n]:null),[b,g]=Ca.useState(v);Ca.useEffect(()=>{s==="storage-settings"?Be("/api/kyro/schema").then(D=>{D?.globals?.["storage-settings"]&&g(D.globals["storage-settings"]);}).catch(D=>console.error("[AutoForm] Failed to fetch dynamic schema",D)):g(v);},[s,v]);let x=b||v,{confirm:u}=dt(),{formData:y,hasUnsavedChanges:R,autoSaveStatus:k,lastSavedAt:p,view:$,setView:j,setShowPreview:L,isMenuOpen:O,setIsMenuOpen:pe,loadingFields:ge,setLoadingFields:Se,compareSelected:Y,setCompareSelected:le,setCompareDiffs:Ue,setLoadingDiffs:et,setField:Ct,setFormData:St,setLastSavedData:te,setAutoSaveStatus:ce,fetchVersions:Te,saveDocument:Fe,autoSaveSkipRef:lt,lastAutoSaveTimeRef:Tt,documentStatus:I,hasUnpublishedChanges:W,versionsEnabled:ie}=Bd({config:x,initialData:t,collectionSlug:n,globalSlug:s,documentId:l,onChange:o,onActionSuccess:c,onActionError:m}),sr=Ca.useRef(null),po=Ca.useRef(null),[ya,qa]=Ca.useState(false),[rs,C]=Ca.useState("idle"),[me,De]=Ca.useState(false),[qt,Rt]=Ca.useState(Date.now()),fr=a,[os,Po]=Ca.useState(false),[Ec,as]=Ca.useState(false),[$c,Oc]=Ca.useState(0),yi=Ca.useRef(new Map),Uc=3e4;Ca.useEffect(()=>{let D=s?`global:${s}`:`${n}:${l}`;if(!(s||n&&l&&l!=="new")||t&&Object.keys(t).length>0)return;let be=yi.current.get(D),Ee=be&&Date.now()-be.ts<Uc,At=be&&!Ee;if(Ee){$e.getState().loadDocument(be.data,be.data);return}At&&$e.getState().loadDocument(be.data,be.data);let Ht=new AbortController;as(false),be||Po(true);let Ar=s?`/api/globals/${s}`:`/api/${n}/${l}`;return Be(Ar,{autoToast:false,signal:Ht.signal}).then(ut=>{let mo=ut.data||{};yi.current.set(D,{data:mo,ts:Date.now()}),$e.getState().loadDocument(mo,mo),Po(false);}).catch(ut=>{ut.name!=="AbortError"&&(Po(false),be||as(true));}),()=>Ht.abort()},[n,l,s,t,$c]),Ca.useEffect(()=>{let D=setInterval(()=>Rt(Date.now()),1e4);return ()=>clearInterval(D)},[]);let fi=(D,J)=>{if(typeof D=="function")try{return D(y,J)}catch(be){return console.warn("Error evaluating admin runtime flag:",be),false}return !!D},zc=D=>{u({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let J=s?tt(`/api/globals/${s}/versions/${D}/restore`):tt(`/api/${n}/${y.id}/versions/${D}/restore`),be=await at(J,{method:"POST"});!be.ok&&n&&(be=await at(tt(`/api/${n}/${y.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:D,action:"restore"})}));let Ee=await be.json();if(Ee.data){let{updatedAt:At,createdAt:Ht,...Ar}=Ee.data,ut={...y,...Ar};St(ut),$e.getState().loadDocument(ut,ut),c?.("Version restored successfully"),Te(),j("edit");}else M.error(Ee.error||"Failed to restore version");}catch(J){console.error("Failed to restore version:",J),M.error("Failed to restore version");}}});},jc=async()=>{if(Y.length===2){et(true);try{let J=await(await at(tt(`/api/${n}/${y.id}/versions?compareA=${Y[0]}&compareB=${Y[1]}`))).json();Ue(J.diffs||[]);}catch(D){console.error("Compare failed:",D),Ue([]);}finally{et(false);}}},_c=D=>{le(J=>J.includes(D)?J.filter(be=>be!==D):J.length>=2?[J[1],D]:[...J,D]);};Ca.useEffect(()=>{let D=J=>{(J.metaKey||J.ctrlKey)&&J.key==="s"&&(J.preventDefault(),ns()),(J.metaKey||J.ctrlKey)&&J.shiftKey&&(J.key==="P"||J.key==="p")&&(J.preventDefault(),document.getElementById("btn-publish")?.click()),(J.metaKey||J.ctrlKey)&&!J.shiftKey&&J.key==="p"&&(J.preventDefault(),L(be=>!be)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(J.key==="1"&&j("edit"),J.key==="2"&&j("version"),J.key==="3"&&j("api"));};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[]),Ca.useEffect(()=>{let D=()=>j("version");return window.addEventListener("kyro:show-version-history",D),()=>window.removeEventListener("kyro:show-version-history",D)},[]),Ca.useEffect(()=>{let D=J=>{sr.current&&!sr.current.contains(J.target)&&pe(false);};if(O)return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[O]),Ca.useEffect(()=>{let D=J=>{po.current&&!po.current.contains(J.target)&&qa(false);};if(ya)return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[ya]);let Hc=()=>{R?u({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await ns(),await new Promise(D=>setTimeout(D,1e3)),window.location.href=`${Ge}/${n}/new`;}}):window.location.href=`${Ge}/${n}/new`;},Vc=()=>{if(!y.id){M.error("Please save the document before duplicating.");return}let D=async()=>{try{De(!0);let J=await at(`/api/${n}/${y.id}/duplicate`,{method:"POST"});if(J.ok){let be=await J.json();c?.("Document duplicated successfully"),be.data?.id?window.location.href=`${Ge}/${n}/${be.data.id}`:window.location.href=`${Ge}/${n}`;}else {let be=await J.json();M.error(be.error||"Failed to duplicate");}}catch{M.error("Failed to duplicate document");}finally{De(false);}};if(R){u({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await ns(),await D();}});return}u({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await D();}});},Kc=()=>{u({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{try{await xt(`/api/${n}/${y.id}`),window.location.href=`${Ge}/${n}`;}catch(D){M.error(D.message||"Failed to delete document");}}});},Gc=()=>{u({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{try{let D=await Fe({...y,status:"draft"},!1);if(D?.ok)c?.("Document unpublished successfully"),$e.getState().loadDocument({...y,status:"draft"},{...y,status:"draft"});else {let J=await D?.json().catch(()=>({}));M.error(J?.error||"Failed to unpublish");}}catch{M.error("Failed to unpublish");}}});},ns=async()=>{let D=!y.id;lt.current=true,C("saving");try{let J=Sr({...y}),be=D&&!s,Ee=be?await at(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}):await Fe(J);if(Ee.ok){let Ht=(await Ee.json()).data||J;St({...y,...Ht}),te({...y,...Ht}),Tt.current=Date.now(),ce("success"),C("saved"),ie&&Te(),setTimeout(()=>{ce("idle"),C("idle");},2e3),c?.(be?"Document created successfully":"Changes saved"),be&&setTimeout(()=>{window.location.href=`${Ge}/${n}`;},800);}else {let At=await Ee.json();Ee.status===409&&ce("conflict"),C("error"),M.error(At.error||"Failed to save"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),M.error("Failed to save document"),setTimeout(()=>C("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),lt.current=false;}},Wc=async()=>{let D=!y.id;lt.current=true,C("saving");try{let J={...y};if(D&&!s){let At=Sr({...y}),Ht=await at(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(At)});if(!Ht.ok){let mo=await Ht.json().catch(()=>({}));Ht.status===409&&ce("conflict"),C("error"),M.error(mo.error||"Failed to create document"),setTimeout(()=>C("idle"),3e3);return}let ut=(await Ht.json()).data||At;St({...y,...ut}),te({...y,...ut}),J={...y,...ut};}let be=Sr(J),Ee=await Fe(be,!1);if(Ee?.ok)C("saved"),c?.("Published successfully");else {let At=await Ee?.json().catch(()=>({}));Ee?.status===409&&ce("conflict"),C("error"),M.error(At?.error||"Failed to publish"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),M.error("Failed to publish"),setTimeout(()=>C("idle"),3e3);}finally{lt.current=false;}},Jc=async D=>{let J=!y.id;lt.current=true;try{let be={...Sr({...y}),_schedulePublishAt:D};if(J&&!s){let Ee=await at(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)});if(!Ee.ok){let At=await Ee.json().catch(()=>({}));M.error(At.error||"Failed to schedule publish");return}}else {let Ee=await Fe(be);if(!Ee.ok){let At=await Ee.json().catch(()=>({}));M.error(At.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(D).toLocaleString()}`),qa(!1);}catch{M.error("Failed to schedule publish");}finally{lt.current=false;}},qc=(D,J)=>{Ct(D,J);},fa=(D,J,be)=>{let Ee=J!==void 0?J:y;if(fi(D.hidden!==void 0?D.hidden:D.admin?.hidden,Ee))return null;let Ht=fi(D.readOnly!==void 0?D.readOnly:D.admin?.readOnly,Ee),Ar=!!(fr||Ht);if(D.admin?.condition){if(typeof D.admin.condition=="function")try{let Oe={values:y||{},...y||{}};if(!D.admin.condition(Oe,Ee))return null}catch(Oe){console.warn(`Condition error for field ${D.name}:`,Oe);}else if(typeof D.admin.condition=="object")try{let Oe=D.admin.condition,He=Oe.field,Vt=Ee&&Ee[He]!==void 0?Ee[He]:y&&y[He]!==void 0?y[He]:void 0,Fr=!0;if("equals"in Oe?Fr=Vt===Oe.equals:"notEquals"in Oe?Fr=Vt!==Oe.notEquals:"in"in Oe&&Array.isArray(Oe.in)&&(Fr=Oe.in.includes(Vt)),!Fr)return null}catch(Oe){console.warn(`Declarative condition error for field ${D.name}:`,Oe);}}let ut=Ee[D.name],mo=r[D.name],Xa=Oe=>{be?be({...Ee,[D.name]:Oe}):qc(D.name,Oe);};if(D.type==="row"&&"fields"in D){let Oe=D.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:Oe?.map(He=>{let Vt=He.admin||{},Fr=Vt?.action;if((He.type==="button"||He.type==="action")&&Fr){let vr=Oe?.find(va=>va.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let va=D.name,Ya=vr?.name,Qa=Ya?y[Ya]:void 0;if(!Qa&&va&&typeof va=="string"&&Ya&&(Qa=y[va]?.[Ya]),!!Qa){Se(gr=>({...gr,[He.name]:true}));try{let gr=await at(tt(Fr),{method:Vt.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Qa})}),ga={};try{ga=await gr.json();}catch{ga={};}if(gr.ok&&ga.success)c?.(ga.message||"Action completed successfully");else {let Xc=ga.error||`Request failed (${gr.status})`;m?.(Xc);}}catch(gr){m?.(gr instanceof Error?gr.message:"Error connecting to server");}finally{Se(gr=>({...gr,[He.name]:false}));}}},disabled:ge[He.name]||Ar,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:ge[He.name]?"Sending...":He.label||"Click"})},He.name)}return jsxRuntime.jsx("div",{className:He.type==="button"||He.type==="action"?"flex-shrink-0":"flex-1",style:Vt?.width?{width:Vt.width,flex:"none"}:{},children:fa(He,J,be)},He.name)})},D.name||`row-${Math.random()}`)}switch(D.type){case "tabs":return jsxRuntime.jsx(Od,{field:D,formData:y,onTabDataChange:Oe=>{Ct(D.name,Oe);},renderField:(Oe,He,Vt)=>fa(Oe,He,Vt)},D.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(jn,{field:D,value:ut,onChange:Xa,renderField:fa},D.name);case "array":return jsxRuntime.jsx(_n,{field:D,value:ut,onChange:Xa,renderField:fa,disabled:Ar},D.name);case "button":case "action":{let Oe=D.name,He=ge[Oe];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:He||Ar,onClick:async()=>{let Vt=D.admin?.action||D.action,Fr=D.admin?.method||D.method||"POST";if(Vt){Se(vr=>({...vr,[Oe]:true}));try{let vr=await at(Vt,{method:Fr,headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});await vr.json(),vr.ok;}catch(vr){console.error("Error executing action:",vr);}finally{Se(vr=>({...vr,[Oe]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${He?"opacity-70 cursor-not-allowed":""}`,children:[He&&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"})]}),He?"Processing...":D.label||"Click"]})},Oe)}case "relationship-block":return jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[D.label||D.name,D.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx(Ha,{relationTo:D.relationTo,hasMany:D.hasMany,selectedIds:Array.isArray(ut)?ut:ut?[ut]:[],onChange:(Oe,He)=>{Xa(He);},compact:true}),D.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(D.admin?.description)}):null]},D.name);default:return jsxRuntime.jsx(wo,{field:D,value:ut,onChange:Xa,error:mo,disabled:Ar,formData:y,siblingData:Ee,collectionSlug:n,globalSlug:s},D.name||Math.random().toString())}};return os?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Et,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Et,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Et,{variant:"rect",count:4})})]}):Ec?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(lucideReact.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:()=>{as(false),Po(true),Oc(D=>D+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(jd,{collectionSlug:n,globalSlug:s,documentStatus:I||"draft",hasUnpublishedChanges:W,localSaveStatus:rs,isDuplicating:me,handleCreateNew:Hc,handleDuplicate:Vc,handleUnpublish:Gc,handleDelete:Kc,handlePublish:Wc,handleSchedulePublish:Jc}),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(lucideReact.Check,{className:"w-4 h-4"}),p?`Saved ${Math.floor((Date.now()-p)/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"}),R&&k!=="saving"&&k!=="retrying"&&k!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!R&&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:y.updatedAt?`Modified ${new Date(y.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()=>{try{let D=await Fe(y);if(D.ok){let be=(await D.json()).data||y;St({...y,...be}),te({...y,...be}),c?.("Changes saved");}}catch(D){console.error("Save error exception:",D),m?.("Save failed: "+D.message);}}})]}),jsxRuntime.jsxs("main",{className:"w-full pt-6 md:pt-0",children:[$==="edit"&&jsxRuntime.jsx(_d,{config:x,layout:d,collectionSlug:n,renderField:fa}),$==="version"&&jsxRuntime.jsx(Hd,{handleRestoreVersion:zc,handleCompareVersions:jc,toggleCompareSelection:_c}),$==="api"&&jsxRuntime.jsx(Vd,{collectionSlug:n,globalSlug:s})]})]})}var Gd={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:l,onPreview:i,onDelete:d,onBack:c,onToggleSidebar:m,publishedAt:f,updatedAt:v}){let b=$e(k=>k.view)||"edit",g=$e(k=>k.setView),[x,u]=Ca.useState(false),y=Ca.useRef(null);Ca.useEffect(()=>{let k=p=>{y.current&&!y.current.contains(p.target)&&u(false);};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);let h=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,R=["edit","version","api"],P=h(),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 ${Gd[e]||"bg-[var(--kyro-text-muted)]"}`}),P&&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(kr,{size:"sm",className:"inline mr-0.5"}),P]}),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:R.map(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>g(k),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${b===k?"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:k==="edit"?"Edit":k==="version"?"Ver":"API"},k))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${w} max-md:hidden`,title:"Preview",children:jsxRuntime.jsx(lucideReact.Eye,{className:"w-3.5 h-3.5"})}),l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${w} max-md:hidden`,title:"View History",children:jsxRuntime.jsx(lucideReact.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${w} max-md:hidden`,title:"Duplicate",children:jsxRuntime.jsx(lucideReact.Copy,{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:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})}),m&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:`${w} max-md:hidden`,title:"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:y,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>u(!x),className:w,title:"More",children:jsxRuntime.jsx(lucideReact.EllipsisVertical,{className:"w-3.5 h-3.5"})}),x&&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:[P&&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 ${Gd[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(kr,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:P})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:R.map(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{g(k),u(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${b===k?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:k==="edit"?"Edit":k==="version"?"Ver":"API"},k))}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),u(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(lucideReact.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),u(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(lucideReact.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),u(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(lucideReact.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(),u(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(lucideReact.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(lucideReact.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(lucideReact.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(jt,{icon:jsxRuntime.jsx(lucideReact.Copy,{className:"w-4 h-4"}),children:"Duplicate"}),l&&jsxRuntime.jsx(jt,{icon:jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4"}),children:"View History"}),i&&jsxRuntime.jsx(jt,{icon:jsxRuntime.jsx(lucideReact.Eye,{className:"w-4 h-4"}),children:"Preview"}),(s||l||i)&&jsxRuntime.jsx(Ka,{}),d&&jsxRuntime.jsx(jt,{onClick:d,danger:true,icon:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function li({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:l,mode:i="collection"}){let{confirm:d,alert:c}=dt(),[m,f]=Ca.useState({}),[v,b]=Ca.useState({}),[g,x]=Ca.useState(true),[u,y]=Ca.useState(false),[h,R]=Ca.useState(false),[P,w]=Ca.useState(false),[k,p]=Ca.useState("idle"),[T,B]=Ca.useState("draft"),[S,F]=Ca.useState(null),[A,X]=Ca.useState(null),[K,$]=Ca.useState(null),[j,ae]=Ca.useState(false),ne=r?.fields||t?.fields||[],H=r?.label||t?.label||"Document",re=r?.slug||t?.slug||"",ve=JSON.stringify(m)!==JSON.stringify(v);Ca.useEffect(()=>{ve&&T==="published"&&B("draft");},[ve,T]),Ca.useEffect(()=>{ve&&k==="saved"&&p("idle");},[ve,k]),Ca.useEffect(()=>{i==="global"?O():o&&L();},[o,i,re]);let L=async()=>{try{x(!0);let le=await Be(`/api/${re}/${o}`,{autoToast:!1}),Re=le.data||{};f(Re),b(Re),B(Re?.status||le.status||"draft"),F(le.createdAt||Re.createdAt||null),X(le.updatedAt||Re.updatedAt||null),$(le.publishedAt||Re.publishedAt||null);}catch{l("Failed to load document");}finally{x(false);}},O=async()=>{try{x(!0);let le=await Be(`/api/globals/${re}`,{autoToast:!1}),Re=le.data||{};f(Re),b(Re),F(le.createdAt||null),X(le.updatedAt||null);}catch{l("Failed to load global");}finally{x(false);}},pe=Ca.useCallback(async(le=false)=>{try{p("saving");let Re=i==="global"?`/api/globals/${re}`:`/api/${re}/${o}`,Ue=T==="draft"||m?.status==="draft",Ie=await Gt(Re,m,{autoToast:!1,headers:{"X-Draft":String(Ue)}}),et=Ie&&(Ie.data||Ie)||m;le||(b(et),n()),f(et),B(et?.status||T),p("saved"),X(new Date().toISOString()),ae(!0),setTimeout(()=>ae(!1),3e3),le||(T==="draft"||et?.status==="draft"?M.warning("Draft saved"):M.success("Updated")),setTimeout(()=>{p("idle");},2e3);}catch{p("error"),le||(l("Failed to save changes"),M.error("Failed to save changes"));}finally{y(false);}},[m,i,re,o,T,n,l]),ge=async()=>{try{y(!0),await Gt(`/api/${re}/${o}`,m,{autoToast:!1,headers:{"X-Draft":"false"}}),B("published"),$(new Date().toISOString()),M.success("Published successfully"),n();}catch{l("Failed to publish"),M.error("Failed to publish");}finally{y(false);}},Se=async()=>{try{y(!0),await Gt(`/api/${re}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),B("draft"),M.warning("Document unpublished"),n();}catch{l("Failed to unpublish"),M.error("Failed to unpublish");}finally{y(false);}},Ne=async()=>{try{R(!0);let le=await nt(`/api/${re}/${o}/duplicate`,void 0,{autoToast:!1});M.success("Document duplicated"),le?.data?.id?window.location.href=`${Ge}/${re}/${le.data.id}`:window.location.href=`${Ge}/${re}`;}catch(le){M.error(le.message||"Failed to duplicate document");}finally{R(false);}},U=()=>{d({title:`Delete ${H}?`,message:"This action cannot be undone.",variant:"danger",onConfirm:async()=>{try{w(!0),await xt(`/api/${re}/${o}`),window.location.href=`${Ge}/${re}`;}catch{w(false);}}});};if(g)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(Et,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Et,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Et,{variant:"rect",count:4})})]})});let Y=i==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Dt,{back:{onClick:a},breadcrumbs:[{label:i==="global"?"Globals":"Collections"},{label:H,href:i==="collection"?`${Ge}/${re}`:void 0},{label:i==="global"||o?"Edit":"New"}],title:i==="global"?H:go(t?.fields,m,t?.admin?.useAsTitle||"title")||m.name||o||`New ${t?.singularLabel||H}`,metadata:[jsxRuntime.jsx(Pt,{variant:T==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:T},"status")]}),jsxRuntime.jsx(si,{status:T,saveStatus:k,hasChanges:ve,onSave:()=>pe(false),onPublish:ge,onUnpublish:T==="published"?Se:void 0,onDuplicate:Ne,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:()=>window.open(`/preview/${re}/${o}`,"_blank"),onDelete:U,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:K,updatedAt:A}),jsxRuntime.jsxs("div",{className:Y?"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",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:"Core Configuration"}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(Wa,{config:t?{...t,fields:ne}:{slug:"unknown",fields:ne},data:m,onChange:f,layout:Y?"single":"split",globalSlug:i==="global"?re:void 0,collectionSlug:i==="collection"?re:void 0,onActionSuccess:le=>M.success(le),onActionError:le=>M.error(le),documentStatus:T,justSaved:j}),Y&&jsxRuntime.jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[i==="collection"&&o&&jsxRuntime.jsx("button",{type:"button",onClick:U,disabled:P||u,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:P?"Deleting...":"Delete Document"}),jsxRuntime.jsx(Ro,{status:T,saveStatus:u?"saving":"idle",hasChanges:ve,onPublish:()=>pe(false),disabled:u})]})]})}),!Y&&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:"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:"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 ${T==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:T||"draft"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Date Created"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:S?new Date(S).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"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:"Last Modified"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:A?new Date(A).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"Just now"})]}),K&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Public At"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(K).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:"Quick Links"}),jsxRuntime.jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:Ne,disabled:h||u,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:h?"Duplicating...":"Duplicate Document"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(`/preview/${re}/${o}`,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:"View Public Page"}),jsxRuntime.jsx("button",{type:"button",onClick:U,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:"Delete Entry"})]})]})]})]})]})}function di({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=Ca.useState({}),[l,i]=Ca.useState(false),d=t.fields||[],c=t.label||t.slug,m=async f=>{try{i(!0),await nt(`/api/${t.slug}`,n),M.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(v){a(v instanceof Error?v.message:"Failed to create");}finally{i(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Dt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${Ge}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:l?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>m(),disabled:l}}),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(Wa,{config:{...t,fields:d},data:n,onChange:s})})})})})]})}function Jd({type:e,message:t,onClose:r}){let[o,a]=Ca__default.default.useState(false),n=Ca__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},l=()=>{n.current&&clearTimeout(n.current);};Ca__default.default.useEffect(()=>(o?l():s(),l),[o,r]);let i={success:lucideReact.CircleCheck,error:lucideReact.ShieldAlert,warning:lucideReact.TriangleAlert,info:lucideReact.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(i,{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(lucideReact.X,{className:"w-3.5 h-3.5"})})]})}function X3({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function Y3(){let e=Kt(o=>o.addToast),t=Kt(o=>o.removeToast);return {toasts:Kt(o=>o.toasts),addToast:e,removeToast:t}}function qn(){let e=Kt(r=>r.toasts),t=Kt(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(Jd,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function mi({onAuth:e,theme:t="light"}){let[r,o]=Ca.useState("login"),[a,n]=Ca.useState(""),[s,l]=Ca.useState(""),[i,d]=Ca.useState(""),[c,m]=Ca.useState(false),[f,v]=Ca.useState(false),b=Kt(u=>u.addToast);Ca.useEffect(()=>{g();},[]);let g=async()=>{try{await Be("/api/users");}catch{v(true),o("register");}};return jsxRuntime.jsx(hr,{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?"Create Admin Account":r==="login"?"Sign In":"Create Account"}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:f?"Set up your admin account to get started":r==="login"?"Enter your credentials to access the admin":"Create an account to access the admin"})]}),jsxRuntime.jsxs("form",{onSubmit:async u=>{u.preventDefault(),m(true);try{let y=r==="login"?"/api/auth/login":"/api/auth/register",h={email:a,password:s};r==="register"&&(h.confirmPassword=i);let R=await nt(y,h);R.isFirstUser&&v(!0),localStorage.setItem("kyro_user",JSON.stringify(R.user)),b("success",r==="login"?"Welcome back!":"Account created!"),e(R.token,R.user);}catch{b("error","Connection failed");}finally{m(false);}},className:"kyro-login-form",children:[jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"email",children:"Email"}),jsxRuntime.jsx("input",{id:"email",type:"email",value:a,onChange:u=>n(u.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:"Password"}),jsxRuntime.jsx("input",{id:"password",type:"password",value:s,onChange:u=>l(u.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:r==="login"?"current-password":"new-password"})]}),r==="register"&&jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"confirmPassword",children:"Confirm Password"}),jsxRuntime.jsx("input",{id:"confirmPassword",type:"password",value:i,onChange:u=>d(u.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:c,children:c?r==="login"?"Signing in...":"Creating account...":r==="login"?"Sign In":"Create Account"})]}),!f&&jsxRuntime.jsx("div",{className:"kyro-login-footer",children:jsxRuntime.jsx("p",{children:r==="login"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Don't have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("register"),children:"Sign up"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Already have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("login"),children:"Sign in"})]})})})]}),jsxRuntime.jsx(qn,{})]})})}function Yd({collections:e,onNavigate:t,user:r}){let{permissions:o}=Ur(),[a,n]=Ca.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[s,l]=Ca.useState(true);Ca.useEffect(()=>{let d=setTimeout(()=>{n({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(d)},[]);let i=Object.entries(e).filter(([d])=>!Bs.includes(d)&&o?.collections?.[d]?.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(Dt,{title:`Welcome back, ${r?.email?.split("@")[0]||"Admin"}`,description:"Everything looks great in your command center today.",action:i.length>0&&o?.collections?.[i[0]?.[0]]?.create!==false?{label:"New Document",onClick:()=>t("create",i[0]?.[0]),icon:lucideReact.Plus}:void 0}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:"Total Content",value:a.totalDocs,icon:lucideReact.FileText,color:"text-blue-500"},{label:"Media Assets",value:a.totalMedia,icon:lucideReact.Image,color:"text-purple-500"},{label:"Active Users",value:a.totalUsers,icon:lucideReact.Users,color:"text-green-500"},{label:"System Health",value:"100%",icon:lucideReact.Activity,color:"text-amber-500"}].map((d,c)=>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:d.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:s?jsxRuntime.jsx(Et,{variant:"text",className:"w-16"}):d.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${d.color}`,children:jsxRuntime.jsx(d.icon,{className:"w-6 h-6"})})]},c))}),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(lucideReact.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),"Content Growth"]}),jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:"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:"Mon"}),jsxRuntime.jsx("span",{children:"Tue"}),jsxRuntime.jsx("span",{children:"Wed"}),jsxRuntime.jsx("span",{children:"Thu"}),jsxRuntime.jsx("span",{children:"Fri"}),jsxRuntime.jsx("span",{children:"Sat"}),jsxRuntime.jsx("span",{children:"Sun"})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:i.map(([d,c])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",d),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:c.label||d}),jsxRuntime.jsx(lucideReact.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:c.admin?.description||`Manage ${d} content.`})]},d))})]}),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(lucideReact.Plus,{className:"w-5 h-5"}),"Quick Links"]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[i.filter(([d])=>o?.collections?.[d]?.create!==false).map(([d])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",d),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.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:["New ",e[d]?.singularLabel||e[d]?.label||d]}),jsxRuntime.jsx(lucideReact.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},d)),i.every(([d])=>o?.collections?.[d]?.create===false)&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:"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:"Media Library"}),jsxRuntime.jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:"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:["Open Assets"," ",jsxRuntime.jsx(lucideReact.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(lucideReact.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(lucideReact.Clock,{className:"w-5 h-5 opacity-40"}),"Recent Activity"]}),jsxRuntime.jsx("div",{className:"space-y-6",children:a.recentActivity.map(d=>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:d.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:d.user})," ",d.type==="create"?"created":d.type==="edit"?"edited":d.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',d.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:d.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:d.time})]})]},d.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:"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(lucideReact.Activity,{className:"w-5 h-5 opacity-40"}),"System Status"]}),jsxRuntime.jsx("div",{className:"space-y-4",children:[{label:"Cloud API",status:"Optimal",pulse:"bg-green-500"},{label:"Database Node",status:"Healthy",pulse:"bg-green-500"},{label:"Media CDN",status:"Active",pulse:"bg-blue-500"},{label:"Auth Service",status:"Secure",pulse:"bg-green-500"}].map((d,c)=>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:d.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:d.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${d.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},c))})]})]})]})]})}function Zd(){let[e,t]=Ca.useState([]),[r,o]=Ca.useState(true),[a,n]=Ca.useState(""),[s,l]=Ca.useState(false),[i,d]=Ca.useState({name:"",email:"",password:"",role:"customer"}),[c,m]=Ca.useState(""),[f,v]=Ca.useState(false),{confirm:b,alert:g}=dt();Ca.useEffect(()=>{x();},[]);let x=async()=>{try{o(!0);let w=await Be("/api/users");t(w.docs||[]);}catch(w){console.error("Failed to load users:",w);}finally{o(false);}},u=w=>{let k=!w.locked;b({title:k?"Lock User Account?":"Unlock User Account?",message:k?`Are you sure you want to lock ${w.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${w.email}?`,variant:k?"danger":"success",onConfirm:async()=>{try{await Gt(`/api/users/${w.id}`,{locked:k}),t(p=>p.map(T=>T.id===w.id?{...T,locked:k}:T)),M.success(k?`Account locked: ${w.email}`:`Account restored: ${w.email}`);}catch(p){console.error("Failed to toggle user lock:",p),M.error("Failed to update account status");}}});},y=w=>{b({title:"Destroy User Account",message:`You are about to permanently delete ${w.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await xt(`/api/users/${w.id}`),t(k=>k.filter(p=>p.id!==w.id)),M.success(`Identity purged: ${w.email}`);}catch(k){console.error("Failed to delete user:",k),M.error("Failed to delete user");}}});},h=async()=>{if(!i.email.trim()||!i.password.trim()){m("Email and password are required");return}v(true),m("");try{await nt("/api/users",{name:i.name.trim()||void 0,email:i.email.trim(),password:i.password,role:i.role}),l(!1),d({name:"",email:"",password:"",role:"customer"}),M.success("User created successfully"),x();}catch(w){let k=w instanceof Error?w.message:"Failed to create user";m(k),M.error(k);}finally{v(false);}},R=["super_admin","admin","editor","author","customer","guest"],P=e.filter(w=>w.email.toLowerCase().includes(a.toLowerCase())||w.name?.toLowerCase().includes(a.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(Dt,{title:"Identity & Access",description:"Manage the core administrative team and security permissions.",icon:lucideReact.Users,action:{label:"New User",onClick:()=>{d({name:"",email:"",password:"",role:"customer"}),m(""),l(true);},icon:lucideReact.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(lucideReact.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:"Search by identity or email...",value:a,onChange:w=>n(w.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:r?Array.from({length:6}).map((w,k)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},k)):P.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"})})}):P.map(w=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${w.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(Xu,{user:w}),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:w.name||w.email.split("@")[0]}),w.tenantId&&jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:w.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:w.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:w.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(Pt,{variant:w.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:w.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(lucideReact.Clock,{className:"w-3 h-3"}),w.lastLogin?new Date(w.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:()=>u(w),className:`p-1.5 rounded-lg border transition-all ${w.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:w.locked?"Restore Access":"Restrict Access",children:w.locked?jsxRuntime.jsx(lucideReact.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(lucideReact.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>y(w),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:"Delete User",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]})})]},w.id))})]})}),jsxRuntime.jsxs(Ot,{open:s,onClose:()=>l(false),title:"Create User",size:"lg",children:[jsxRuntime.jsx(Hr,{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:i.name,onChange:w=>d({...i,name:w.target.value}),placeholder:"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:i.email,onChange:w=>d({...i,email:w.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:i.password,onChange:w=>d({...i,password:w.target.value}),placeholder:"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:i.role,onChange:w=>d({...i,role:w.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:R.map(w=>jsxRuntime.jsx("option",{value:w,children:w},w))})]}),c&&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(lucideReact.TriangleAlert,{className:"w-4 h-4"}),c]})]})}),jsxRuntime.jsxs(Vr,{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:h,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 Xu({user:e}){let[t,r]=Ca.useState(null);return Ca.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 ec(){let[e,t]=Ca.useState("Kyro CMS"),[r,o]=Ca.useState("Command Center"),[a,n]=Ca.useState("#6366f1"),[s,l]=Ca.useState("Welcome back to your Command Center."),[i,d]=Ca.useState(false),[c,m]=Ca.useState(false);return Ca.useEffect(()=>{(async()=>{try{let g=await Be("/api/globals/site-settings"),x=g.data||g;x&&Object.keys(x).length>0&&(x.siteName&&t(x.siteName),x.adminTitle&&o(x.adminTitle),x.primaryColor&&n(x.primaryColor),x.dashboardGreeting&&l(x.dashboardGreeting));}catch(g){console.error("Failed to load branding:",g);}})();},[]),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:async()=>{d(true);try{await Gt("/api/globals/site-settings",{siteName:e,adminTitle:r,primaryColor:a,dashboardGreeting:s}),m(!0),M.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",a),setTimeout(()=>window.location.reload(),800);}catch(b){M.error("Failed to save branding"),console.error(b);}finally{d(false);}},disabled:i,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${c?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[i?jsxRuntime.jsx(lucideReact.RefreshCcw,{className:"w-4 h-4 animate-spin"}):c?jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.Save,{className:"w-4 h-4"}),i?"Saving...":c?"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(lucideReact.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:e,onChange:b=>t(b.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:r,onChange:b=>o(b.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:s,onChange:b=>l(b.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:"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(lucideReact.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:[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}].map(b=>jsxRuntime.jsx("button",{type:"button",onClick:()=>n(b.hex),className:`aspect-square rounded-xl transition-all border-4 ${a===b.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:b.hex},title:b.name},b.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(lucideReact.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(lucideReact.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:[r," Online"]})]}),jsxRuntime.jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",e,"."]}),jsxRuntime.jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:s})]}),jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
100
100
|
:root {
|
|
101
101
|
--kyro-primary-temp: ${a};
|
|
102
102
|
}
|
|
103
103
|
.preview-btn {
|
|
104
104
|
background-color: var(--kyro-primary-temp);
|
|
105
105
|
}
|
|
106
|
-
`}})]})]})]})}var Ju=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Jd({collections:e}){let[t,r]=wa.useState([]),[o,a]=wa.useState(false),[n,s]=wa.useState(null),[l,i]=wa.useState(""),[d,c]=wa.useState(null),[m,g]=wa.useState(false),{confirm:f,alert:b}=it(),[v,x]=wa.useState(false),[y,u]=wa.useState(""),h=async()=>{try{let p=await Be("/api/keys");r(p);}catch(p){console.error(p);}};wa.useEffect(()=>{h();},[]);let R=async()=>{u(""),x(true);},S=async()=>{if(y.trim())try{await at("/api/keys",{name:y}),h(),x(!1),u(""),E.success("API key generated");}catch(p){console.error(p),E.error("Failed to generate API key");}},w=p=>{f({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 ht(`/api/keys/${p}`),h(),E.success("API key revoked");}catch(D){console.error(D),E.error("Failed to revoke API key");}}});},C=async()=>{if(l){g(true);try{let D=await(await fetch(Ye(`/api/${l}`))).json();c(D);}catch{c({error:"Failed to fetch. Ensure the endpoint exists."});}finally{g(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(Ft,{title:"Developer Center",description:"Provision access keys and explore the headless API ecosystem.",icon:lucideReact.CodeXml,actions:[{label:"Generate Key",onClick:R,icon:lucideReact.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:t.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(lucideReact.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."})]}):t.map(p=>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(lucideReact.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:p.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:n===p.id?p.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:()=>s(n===p.id?null:p.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:n===p.id?jsxRuntime.jsx(lucideReact.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.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(p.key),E.success("API key copied to clipboard");},children:jsxRuntime.jsx(lucideReact.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(p.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:()=>w(p.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:"Revoke Key",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-5 h-5"})})]})},p.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(lucideReact.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(lucideReact.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(lucideReact.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(Dt,{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(lucideReact.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(Dt,{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(lucideReact.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(lucideReact.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(lucideReact.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 ",Ju,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:p=>i(p.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:C,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(lucideReact.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),d?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(Dt,{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(Ku__default.default,{value:JSON.stringify(d,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(lucideReact.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(Ut,{open:v,onClose:()=>x(false),title:"Generate Access Token",size:"lg",children:[jsxRuntime.jsx(Hr,{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:y,onChange:p=>u(p.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:p=>p.key==="Enter"&&S()})]})]})}),jsxRuntime.jsxs(Vr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(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:S,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 qd(e){let[t,r]=wa.useState([]),[o,a]=wa.useState(false),[n,s]=wa.useState(null),[l,i]=wa.useState(false),{confirm:d}=it(),c=wa.useCallback(async()=>{a(true),s(null);try{let b=await Be(e.endpoint),v=Array.isArray(b)?b:b.docs||[],x=e.transformLoad?e.transformLoad(v):v;r(x),e.onSuccess?.("load",x);}catch(b){let v=b instanceof Error?b.message:"Failed to load resources";s(v),e.onError?.("load",b);}finally{a(false);}},[e.endpoint,e.transformLoad]);wa.useEffect(()=>{c();},[c]);let m=wa.useCallback((b,v="item")=>{d({title:`Delete ${v}`,message:`Are you sure you want to delete this ${v.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await ht(`${e.endpoint}/${b}`),r(x=>x.filter(y=>y.id!==b)),e.onSuccess?.("delete",b),E.success(`${v} deleted`);}catch(x){let y=x instanceof Error?x.message:`Failed to delete ${v}`;E.error(y),e.onError?.("delete",x);}}});},[e.endpoint,d]),g=wa.useCallback(async b=>{s(null);try{let v=await at(e.endpoint,b);return r(x=>[v,...x]),i(!1),e.onSuccess?.("create",v),v}catch(v){let x=v instanceof Error?v.message:"Failed to create resource";throw s(x),e.onError?.("create",v),v}},[e.endpoint]),f=wa.useCallback(async(b,v)=>{s(null);try{let x=await Xt(`${e.endpoint}/${b}`,v);return r(y=>y.map(u=>u.id===b?x:u)),e.onSuccess?.("update",x),x}catch(x){let y=x instanceof Error?x.message:"Failed to update resource";throw s(y),e.onError?.("update",x),x}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:m,create:g,update:f,isCreateModalOpen:l,setIsCreateModalOpen:i}}function Xd(){let{items:e,loading:t,create:r,remove:o,update:a,isCreateModalOpen:n,setIsCreateModalOpen:s}=qd({endpoint:"/api/webhooks"}),{confirm:l}=it(),[i,d]=wa.useState(false),[c,m]=wa.useState(false),[g,f]=wa.useState(null),[b,v]=wa.useState(null),[x,y]=wa.useState({name:"",url:"",events:[],secret:""}),[u,h]=wa.useState(""),R=async()=>{if(!x.name.trim()||!x.url.trim()){h("Name and URL are required");return}try{await r(x),y({name:"",url:"",events:[],secret:""}),E.success(`Webhook established: ${x.name}`);}catch{h("Failed to create webhook"),E.error("Failed to create webhook");}},S=async p=>{v(p),f(null),d(true);try{let D=await at(`/api/webhooks/${p}/test`);f({success:!0,message:D.message||"Webhook triggered successfully"}),E.success("Dispatch verified: Remote endpoint responded");}catch{f({success:false,message:"Failed to trigger webhook"});}},w=async(p,D)=>{try{let M=D==="active"?"paused":"active";await a(p,{status:M}),E.success(M==="active"?"Signals resumed":"Dispatcher paused");}catch(M){console.error(M),E.error("Failed to toggle webhook status");}},C=[{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"}];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(Ft,{title:"Webhooks",description:"Receive real-time notifications when your content changes.",icon:lucideReact.Webhook,actions:[{label:"Create Webhook",onClick:()=>{y({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:""}),h(""),s(true);},icon:lucideReact.Plus},{label:"Guide",onClick:()=>m(true),icon:lucideReact.Info,variant:"outline"}]}),jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[2rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-surface)] to-[var(--kyro-surface-accent)] p-8",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.03] pointer-events-none",children:jsxRuntime.jsx(lucideReact.Zap,{className:"w-64 h-64 rotate-12"})}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-8 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-5 bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/50 rounded-[1.5rem] shadow-xl shadow-[var(--kyro-primary)]/20",children:jsxRuntime.jsx(lucideReact.Zap,{className:"w-8 h-8 text-white"})}),jsxRuntime.jsxs("div",{className:"flex-1 text-center md:text-left",children:[jsxRuntime.jsx("h3",{className:"text-xl font-bold mb-2",children:"Real-time Event Synchronization"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Webhooks allow your application to receive instant HTTP notifications when events happen in your CMS. Eliminate polling and build responsive, event-driven architectures with ease."})]}),jsxRuntime.jsxs("div",{className:"flex gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center px-4 py-2 bg-[var(--kyro-surface)]/50 border border-[var(--kyro-border)] rounded-2xl",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 uppercase tracking-tighter",children:"Collections"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-primary)]",children:"Triggered"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center px-4 py-2 bg-[var(--kyro-surface)]/50 border border-[var(--kyro-border)] rounded-2xl",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 uppercase tracking-tighter",children:"Latency"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-primary)]",children:"<200ms"})]})]})]})]}),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 tracking-[0.2em] opacity-40",children:"ACTIVE ENDPOINTS"})]}),jsxRuntime.jsxs("div",{className:"text-[10px] font-bold opacity-40 uppercase",children:[e.length," Hook",e.length!==1&&"s"]})]}),t?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 surface-tile rounded-3xl opacity-50 italic",children:"Connecting to dispatcher..."}):e.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 mx-auto mb-6 bg-gradient-to-tr from-[var(--kyro-surface)] to-[var(--kyro-surface-accent)] rounded-3xl flex items-center justify-center shadow-xl border border-[var(--kyro-border)]",children:jsxRuntime.jsx(lucideReact.Webhook,{className:"w-10 h-10 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-2xl font-bold mb-3",children:"No Webhooks Found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-8 max-w-sm mx-auto",children:"Your CMS is currently silent. Create a webhook to start broadcasting events to your external services."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"kyro-btn kyro-btn-primary inline-flex items-center gap-3 px-8 py-4 rounded-2xl font-bold hover:scale-[1.05] transition-all shadow-xl shadow-[var(--kyro-primary)]/10",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-5 h-5"}),"Configure Webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:e.map(p=>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 lg:flex-row lg:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",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(lucideReact.Webhook,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors",children:p.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-2 h-2 rounded-full ${p.status==="active"?"bg-green-500 animate-pulse":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-bold uppercase tracking-wider ${p.status==="active"?"text-green-500":"text-amber-500"}`,children:p.status})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6 pt-2",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs opacity-60 truncate max-w-[200px]",title:p.url,children:p.url})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-4 sm:pt-0 sm:pl-6 mt-4 sm:mt-0",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[p.events.slice(0,2).map(D=>jsxRuntime.jsx(Dt,{variant:"outline",className:"text-[8px] font-bold px-1.5 opacity-60",children:D},D)),p.events.length>2&&jsxRuntime.jsxs("span",{className:"text-[8px] font-bold opacity-30",children:["+",p.events.length-2," more"]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-4 sm:pt-0 sm:pl-6 mt-4 sm:mt-0",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] font-bold opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3 h-3"}),p.lastTriggered?`Last triggered: ${new Date(p.lastTriggered).toLocaleDateString()}`:"Never triggered"]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 lg:bg-[var(--kyro-surface-accent)]/50 lg:p-2 lg:rounded-2xl lg:opacity-0 group-hover:opacity-100 transition-all duration-300 lg:translate-x-4 group-hover:translate-x-0",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>S(p.id),className:"flex-1 lg:flex-none p-3 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl hover:border-[var(--kyro-primary)] transition-all flex items-center justify-center gap-2",title:"Send test request",children:[jsxRuntime.jsx(lucideReact.Send,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Test"})]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-1 hidden lg:block"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>w(p.id,p.status),className:`p-3 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl hover:border-[var(--kyro-primary)] transition-all group/toggle ${p.status==="active"?"text-amber-500/50 hover:text-amber-500":"text-green-500/50 hover:text-green-500"}`,title:p.status==="active"?"Pause webhook":"Activate webhook",children:p.status==="active"?jsxRuntime.jsx(lucideReact.Pause,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.Play,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(p.id,"Webhook"),className:"p-3 bg-red-500/5 border border-red-500/10 rounded-xl hover:bg-red-500/10 hover:border-red-500/30 transition-all group/delete",title:"Delete webhook",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4 text-red-500/50 group-hover/delete:text-red-500"})})]})]})},p.id))})]}),jsxRuntime.jsxs(Ut,{open:n,onClose:()=>s(false),title:"Register Webhook",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",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:"Webhook Name"}),jsxRuntime.jsx("input",{type:"text",value:x.name,onChange:p=>y({...x,name:p.target.value}),placeholder:"e.g., Slack Notifications",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:"Payload URL"}),jsxRuntime.jsx("input",{type:"url",value:x.url,onChange:p=>y({...x,url:p.target.value}),placeholder:"https://your-server.com/webhook",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:"Signing Secret"}),jsxRuntime.jsx("input",{type:"text",value:x.secret,onChange:p=>y({...x,secret:p.target.value}),placeholder:"Optional secret for verification",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",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Subscribed Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:C.map(p=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let D=x.events.includes(p.value)?x.events.filter(M=>M!==p.value):[...x.events,p.value];y({...x,events:D});},className:`flex items-center gap-3 p-3 rounded-lg border transition-all text-left ${x.events.includes(p.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"bg-[var(--kyro-surface-accent)]/50 border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30"}`,children:[jsxRuntime.jsx("div",{className:`w-4 h-4 rounded flex items-center justify-center border transition-all ${x.events.includes(p.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x.events.includes(p.value)&&jsxRuntime.jsx(lucideReact.CircleCheck,{className:"w-3 h-3 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-bold",children:p.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-50",children:p.description})]})]},p.value))})]})]}),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(lucideReact.TriangleAlert,{className:"w-4 h-4"}),u]})]})}),jsxRuntime.jsxs(Vr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(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:R,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",children:"Create Webhook"})]})]}),jsxRuntime.jsxs(Ut,{open:i,onClose:()=>d(false),title:"Webhook Test Dispatcher",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsx("div",{className:"p-8 rounded-[2rem] bg-[var(--kyro-surface-accent)]/30 border border-[var(--kyro-border)] text-center",children:g?jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx("div",{className:`w-16 h-16 mx-auto rounded-2xl flex items-center justify-center shadow-xl ${g.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:g.success?jsxRuntime.jsx(lucideReact.CircleCheck,{className:"w-8 h-8"}):jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"w-8 h-8"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xl font-bold mb-2",children:g.success?"Dispatch Successful":"Dispatch Failed"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70",children:g.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-6 py-4",children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"w-12 h-12 text-[var(--kyro-primary)] animate-spin mx-auto opacity-50"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xl font-bold mb-1",children:"Synthesizing Payload"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50 italic",children:"Dispatching to remote endpoint..."})]})]})})}),jsxRuntime.jsx(Vr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>d(false),className:"w-full py-3 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-all",children:"Acknowledge"})})]}),jsxRuntime.jsxs(Ut,{open:c,onClose:()=>m(false),title:"Webhook Integration Guide",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[jsxRuntime.jsxs("div",{className:"p-6 rounded-3xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"font-bold mb-3 flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),"Request Context"]}),jsxRuntime.jsxs("p",{className:"text-sm text-[var(--kyro-text-secondary)] leading-relaxed",children:["When an event triggers, Kyro sends a standard ",jsxRuntime.jsx("span",{className:"font-bold text-[var(--kyro-text-primary)]",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-6 rounded-3xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"font-bold mb-3 flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Shield,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),"Security Verification"]}),jsxRuntime.jsxs("p",{className:"text-sm text-[var(--kyro-text-secondary)] leading-relaxed",children:["If a secret is provided, each request includes an ",jsxRuntime.jsx("span",{className:"font-mono text-[var(--kyro-primary)]",children:"X-Kyro-Signature"})," header. Always verify this signature in production environments."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("h4",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Payload Architecture"}),jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-[var(--kyro-primary)]/20 to-transparent rounded-2xl blur opacity-25 group-hover:opacity-50 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] rounded-2xl border border-[var(--kyro-border)] p-6 font-mono text-sm overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-4 border-b border-[var(--kyro-border)] pb-4 opacity-30",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500/50"}),jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-500/50"}),jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500/50"}),jsxRuntime.jsx("span",{className:"text-[10px] ml-2 tracking-tighter",children:"payload.json"})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:"{"}),jsxRuntime.jsxs("div",{className:"pl-4",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-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"products"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"id"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"prod_8273"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-05-14T02:53:22Z"'})]}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:"}"})]})]})]})]})]})}),jsxRuntime.jsx(Vr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"kyro-btn kyro-btn-primary w-full py-3 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/20",children:"I Understand"})})]})]})}function Zd({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{user:n,permissions:s}=Ur(),[l,i]=wa.useState(""),[d,c]=wa.useState(0),[m,g]=wa.useState(false),[f,b]=wa.useState([]),v=wa.useRef(null),x=wa.useRef(null);wa.useEffect(()=>{e&&(i(""),c(0),b([]),g(false),setTimeout(()=>v.current?.focus(),100));},[e]);let y=wa.useCallback(async F=>{if(!F||F.length<2){b([]);return}g(true);try{let me=await(await fetch(Ye(`/api/search?q=${encodeURIComponent(F)}&limit=15`))).json();me.results&&b(me.results);}catch(oe){console.error("Search error:",oe),b([]);}finally{g(false);}},[]);if(wa.useEffect(()=>(x.current&&clearTimeout(x.current),l.length>=2?x.current=setTimeout(()=>y(l),300):b([]),()=>{x.current&&clearTimeout(x.current);}),[l,y]),!e)return null;let u=Object.entries(r).filter(([F])=>s?.collections?.[F]?.read!==false).map(([F,oe])=>({id:`col-${F}`,label:oe.label||F,type:"collection",slug:F,icon:lucideReact.FileText})),h=Object.entries(o).filter(([F])=>s?.globals?.[F]?.read!==false).map(([F,oe])=>({id:`global-${F}`,label:oe.label||F,type:"global",slug:F,icon:lucideReact.Settings})),R=typeof document<"u"&&document.documentElement.classList.contains("dark"),S=n?.role==="admin",w=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:lucideReact.Image,visible:s?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:lucideReact.Clock,visible:S},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:lucideReact.File,visible:S},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:lucideReact.Shield,visible:S},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:lucideReact.Database,visible:S},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:lucideReact.Hexagon,visible:S},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:lucideReact.Network,visible:S},{id:"action-theme",label:R?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:R?lucideReact.Sun:lucideReact.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:lucideReact.LogOut,visible:true}].filter(F=>F.visible),C=f.map((F,oe)=>({id:`doc-${F.collection}-${F.id}`,label:F.title,type:"document",collection:F.collection,label2:F.label,docId:F.id,icon:lucideReact.File,doc:F.doc})),p=l.length>=2?[...w,...u,...h,...C]:[...w,...u,...h],D=l===""?p:p.filter(F=>F.label.toLowerCase().includes(l.toLowerCase())),M=F=>{if(F.key==="ArrowDown")F.preventDefault(),c(oe=>(oe+1)%D.length);else if(F.key==="ArrowUp")F.preventDefault(),c(oe=>(oe-1+D.length)%D.length);else if(F.key==="Enter"){let oe=D[d];oe&&I(oe);}else F.key==="Escape"&&t();},I=F=>{F.type==="collection"?F.slug==="users"?a(F.slug,F.slug):a("list",F.slug):F.type==="global"?a("settings",F.slug):F.type==="document"?F.collection==="users"?a("users","users",F.docId):a("edit",F.collection,F.docId):F.type==="action"&&(F.view==="users"?a("users","users"):F.view==="media"?a("media","media"):a(F.view,F.view)),t();},B=()=>l===""?"Quick Actions & Collections":f.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(lucideReact.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(lucideReact.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:v,placeholder:"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:F=>i(F.target.value),onKeyDown:M}),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:B()}),D.map((F,oe)=>jsxRuntime.jsxs("div",{onClick:()=>I(F),onMouseEnter:()=>c(oe),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${oe===d?"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 ${oe===d?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(F.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:F.label}),F.type==="document"&&F.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${oe===d?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:F.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${oe===d?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:F.type}),oe===d&&jsxRuntime.jsx(lucideReact.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},F.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 ec(){let{modal:e,closeModal:t}=it(),[r,o]=wa.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(l){console.error("Modal confirm action failed:",l);}finally{o(false),t();}else t();},s=()=>{a.onCancel&&a.onCancel(),t();};return jsxRuntime.jsx(xs,{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 Zu({config:e,theme:t="light",onThemeChange:r}){let[o,a]=wa.useState(false),[n,s]=wa.useState(null),l=wa.useMemo(()=>Bn(Pa(e.collections)),[e.collections]),i=wa.useMemo(()=>Ln(Pa(e.globals)),[e.globals]),[d,c]=wa.useState(null),[m,g]=wa.useState(null),[f,b]=wa.useState("list"),[v,x]=wa.useState(null),[y,u]=wa.useState(false);wa.useEffect(()=>{(async()=>{try{let C=await fetch("/api/users/me");if(C.ok){let p=await C.json();s(p),a(!0);}}catch(C){console.error("Auth check failed",C);}})();},[]),wa.useEffect(()=>{if(o&&!d){let w=Object.keys(l)[0];w&&c(w);}},[o,l,d]);let h=(w,C=null,p=null)=>{b(w),C&&c(C),p&&x(p),u(false);};wa.useEffect(()=>{let w=C=>{(C.metaKey||C.ctrlKey)&&C.key==="k"&&(C.preventDefault(),u(p=>!p));};return window.addEventListener("keydown",w),window.openCommandPalette=()=>u(true),()=>{window.removeEventListener("keydown",w),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(wr,{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(Zd,{isOpen:y,onClose:()=>u(false),collections:l,globals:i,onNavigate:h}),(()=>{let w=d?l[d]:null;switch(f){case "create":return w?jsxRuntime.jsx(ai,{config:e,collection:w,onSuccess:()=>b("list"),onCancel:()=>b("list"),onError:C=>E.error(C)}):null;case "detail":return w&&v?jsxRuntime.jsx(oi,{config:e,collection:w,documentId:v,onBack:()=>b("list"),onSave:()=>{},onError:C=>E.error(C)}):null;case "users":return jsxRuntime.jsx(Gd,{});case "media":return jsxRuntime.jsx(hn,{});case "branding":return jsxRuntime.jsx(Wd,{});case "developer":return jsxRuntime.jsx(Jd,{collections:l});case "webhooks":return jsxRuntime.jsx(Xd,{});default:return w?jsxRuntime.jsx(gs,{config:e,collection:w,onCreate:()=>b("create"),onEdit:C=>h("detail",d,C)}):jsxRuntime.jsx(Vd,{onNavigate:h,collections:l,user:n})}})()]})})}),jsxRuntime.jsx(ec,{}),jsxRuntime.jsx(Wn,{})]})}):jsxRuntime.jsx(ii,{onAuth:(w,C)=>{s(C),a(true);},theme:t})}function ey({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(ms,{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(Co,{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(_t,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function ly({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:l=false}){let i=c=>{if(!c)return "Unknown date";let m=new Date(c);if(isNaN(m.getTime())){let g=Date.parse(c);return isNaN(g)?"Invalid date":new Date(g).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"})},d=c=>{if(!c)return "Unknown date";let m=new Date(c);if(isNaN(m.getTime()))return i(c);let f=new Date().getTime()-m.getTime();if(f<0)return "Just now";let b=Math.floor(f/6e4),v=Math.floor(f/36e5),x=Math.floor(f/864e5);return b<1?"Just now":b<60?`${b}m ago`:v<24?`${v}h ago`:x<7?`${x}d ago`:i(c)};return jsxRuntime.jsx(cr,{open:e,onClose:t,title:"Version History",width:"md",children:l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12",children:jsxRuntime.jsx(Pr,{})}):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(lucideReact.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(c=>{let m=c.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 ${c.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:[c.status==="published"&&jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"w-3 h-3"}),c.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",c.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(lucideReact.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),d(c.createdAt)]}),c.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(lucideReact.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:c.createdBy.name||c.createdBy.email})]}),c.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:['"',c.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(c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Preview this version",children:jsxRuntime.jsx(lucideReact.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(c,r.find(g=>g.id===o)||c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Compare with current",children:jsxRuntime.jsx(lucideReact.GitCompare,{className:"w-4 h-4"})}),!m&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(c),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:"Restore this version",children:jsxRuntime.jsx(lucideReact.Undo2,{className:"w-4 h-4"})})]})]})]},c.id)})})})}function nA({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 nr={ready:[],beforeDeploy:[],afterDeploy:[]};function Zn(e){return nr.ready.push(e),()=>{nr.ready=nr.ready.filter(t=>t!==e);}}function oc(e){return nr.beforeDeploy.push(e),()=>{nr.beforeDeploy=nr.beforeDeploy.filter(t=>t!==e);}}function ac(e){return nr.afterDeploy.push(e),()=>{nr.afterDeploy=nr.afterDeploy.filter(t=>t!==e);}}async function nc(e){let t=[];for(let r of nr.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 sc(e){let t=[];for(let r of nr.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 ic(e,t){for(let r of nr.afterDeploy)try{await r(e,t);}catch{}}function dc(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function cc(e,t={}){let[r,o]=wa.useState(null),[a,n]=wa.useState(true),[s,l]=wa.useState(null),i=wa.useCallback(async()=>{n(true),l(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=`${dc(`/api/${e}`)}?${d.toString()}`,m=await fetch(c,{credentials:"include"});if(!m.ok)throw new Error(`HTTP ${m.status}: ${m.statusText}`);let g=await m.json();o(g.data??g);}catch(d){l(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return wa.useEffect(()=>{i();},[i]),{data:r,loading:a,error:s,refetch:i}}function pc(e,t="POST"){let[r,o]=wa.useState(false),[a,n]=wa.useState(null);return {mutate:wa.useCallback(async l=>{o(true),n(null);try{let i=dc(`/api/${e}`),d=await fetch(i,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:l?JSON.stringify(l):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(i){return n(i instanceof Error?i.message:String(i)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var na=new Map;function sa(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");na.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),na.set(e.name,e),e.apply&&e.apply({});}function mc(e){na.delete(e);}function uc(e){return na.get(e)}function yc(){return Array.from(na.values())}function fc(e){return Array.from(na.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var cy={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};sa(cy);var py={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};sa(py);var ia=new Map;function la(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");ia.set(e.id,e);}function gc(e){ia.delete(e);}function vc(e){return ia.get(e)}function bc(){return Array.from(ia.values())}function xc(e){return Array.from(ia.values()).filter(t=>t.category===e)}function kc(e){let t=ia.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var my=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)})]})},uy={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:my};la(uy);var fy=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)})]})},gy={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:fy};la(gy);var da=new Map;function ca(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");da.set(e.id,e);}function Nc(e){da.delete(e);}function Cc(e){return da.get(e)}function Sc(){return Array.from(da.values())}function Tc(e){return Array.from(da.values()).find(t=>t.type===e)}function Rc(e,t){let r=da.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var xy=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample text"}),ky={id:"sample-text",type:"text",label:"Sample Text",editor:xy};ca(ky);var wy=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample textarea"}),Ny={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:wy};ca(Ny);var Ac=gr__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");gr__default.default.join(Ac,"use-sync-external-store.js");gr__default.default.join(Ac,"use-sync-external-store-with-selector.js");function Fy(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:l})=>{l.info(`Kyro Admin mounted at ${t} (API: ${r})`);let i=gr__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=gr__default.default.resolve(a.root.pathname,"..",o),c=gr__default.default.resolve(a.root.pathname,o),m=Do__default.default.existsSync(d)?d:Do__default.default.existsSync(c)?c:i;m!==i?l.info(`Loaded config from ${m}`):l.warn("Config file not found. Using defaults.");let g=gr__default.default.join(gr__default.default.dirname(m),".kyro-admin-config.json"),f="";try{let v=gr__default.default.join(gr__default.default.dirname(m),".env");Do__default.default.existsSync(v)&&dotenv.config({path:v});let x=await esbuild.build({entryPoints:[m],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=m.replace(/\.ts$/,".admin.mjs"),Do__default.default.writeFileSync(f,x.outputFiles[0].text,"utf8");let y=`
|
|
106
|
+
`}})]})]})]})}var ry=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function tc({collections:e}){let[t,r]=Ca.useState([]),[o,a]=Ca.useState(false),[n,s]=Ca.useState(null),[l,i]=Ca.useState(""),[d,c]=Ca.useState(null),[m,f]=Ca.useState(false),{confirm:v,alert:b}=dt(),[g,x]=Ca.useState(false),[u,y]=Ca.useState(""),h=async()=>{try{let p=await Be("/api/keys");r(p);}catch(p){console.error(p);}};Ca.useEffect(()=>{h();},[]);let R=async()=>{y(""),x(true);},P=async()=>{if(u.trim())try{await nt("/api/keys",{name:u}),h(),x(!1),y(""),M.success("API key generated");}catch(p){console.error(p),M.error("Failed to generate API key");}},w=p=>{v({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 xt(`/api/keys/${p}`),h(),M.success("API key revoked");}catch(T){console.error(T),M.error("Failed to revoke API key");}}});},k=async()=>{if(l){f(true);try{let T=await(await fetch(tt(`/api/${l}`))).json();c(T);}catch{c({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(Dt,{title:"Developer Center",description:"Provision access keys and explore the headless API ecosystem.",icon:lucideReact.CodeXml,actions:[{label:"Generate Key",onClick:R,icon:lucideReact.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:t.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(lucideReact.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."})]}):t.map(p=>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(lucideReact.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:p.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:n===p.id?p.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:()=>s(n===p.id?null:p.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:n===p.id?jsxRuntime.jsx(lucideReact.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.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(p.key),M.success("API key copied to clipboard");},children:jsxRuntime.jsx(lucideReact.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(p.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:()=>w(p.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:"Revoke Key",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-5 h-5"})})]})},p.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(lucideReact.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(lucideReact.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(lucideReact.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(Pt,{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(lucideReact.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(Pt,{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(lucideReact.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(lucideReact.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(lucideReact.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 ",ry,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:p=>i(p.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:k,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(lucideReact.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),d?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(Pt,{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(Zu__default.default,{value:JSON.stringify(d,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(lucideReact.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(Ot,{open:g,onClose:()=>x(false),title:"Generate Access Token",size:"lg",children:[jsxRuntime.jsx(Hr,{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:u,onChange:p=>y(p.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:p=>p.key==="Enter"&&P()})]})]})}),jsxRuntime.jsxs(Vr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(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:P,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 rc(e){let[t,r]=Ca.useState([]),[o,a]=Ca.useState(false),[n,s]=Ca.useState(null),[l,i]=Ca.useState(false),{confirm:d}=dt(),c=Ca.useCallback(async()=>{a(true),s(null);try{let b=await Be(e.endpoint),g=Array.isArray(b)?b:b.docs||[],x=e.transformLoad?e.transformLoad(g):g;r(x),e.onSuccess?.("load",x);}catch(b){let g=b instanceof Error?b.message:"Failed to load resources";s(g),e.onError?.("load",b);}finally{a(false);}},[e.endpoint,e.transformLoad]);Ca.useEffect(()=>{c();},[c]);let m=Ca.useCallback((b,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 xt(`${e.endpoint}/${b}`),r(x=>x.filter(u=>u.id!==b)),e.onSuccess?.("delete",b),M.success(`${g} deleted`);}catch(x){let u=x instanceof Error?x.message:`Failed to delete ${g}`;M.error(u),e.onError?.("delete",x);}}});},[e.endpoint,d]),f=Ca.useCallback(async b=>{s(null);try{let g=await nt(e.endpoint,b);return r(x=>[g,...x]),i(!1),e.onSuccess?.("create",g),g}catch(g){let x=g instanceof Error?g.message:"Failed to create resource";throw s(x),e.onError?.("create",g),g}},[e.endpoint]),v=Ca.useCallback(async(b,g)=>{s(null);try{let x=await Gt(`${e.endpoint}/${b}`,g);return r(u=>u.map(y=>y.id===b?x:y)),e.onSuccess?.("update",x),x}catch(x){let u=x instanceof Error?x.message:"Failed to update resource";throw s(u),e.onError?.("update",x),x}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:m,create:f,update:v,isCreateModalOpen:l,setIsCreateModalOpen:i}}function oc(){let{items:e,loading:t,create:r,remove:o,update:a,isCreateModalOpen:n,setIsCreateModalOpen:s}=rc({endpoint:"/api/webhooks"}),{confirm:l}=dt(),[i,d]=Ca.useState(false),[c,m]=Ca.useState(false),[f,v]=Ca.useState(null),[b,g]=Ca.useState(null),[x,u]=Ca.useState({name:"",url:"",events:[],secret:""}),[y,h]=Ca.useState(""),R=async()=>{if(!x.name.trim()||!x.url.trim()){h("Name and URL are required");return}try{await r(x),u({name:"",url:"",events:[],secret:""}),M.success(`Webhook established: ${x.name}`);}catch{h("Failed to create webhook"),M.error("Failed to create webhook");}},P=async p=>{g(p),v(null),d(true);try{let T=await nt(`/api/webhooks/${p}/test`);v({success:!0,message:T.message||"Webhook triggered successfully"}),M.success("Dispatch verified: Remote endpoint responded");}catch{v({success:false,message:"Failed to trigger webhook"});}},w=async(p,T)=>{try{let B=T==="active"?"paused":"active";await a(p,{status:B}),M.success(B==="active"?"Signals resumed":"Dispatcher paused");}catch(B){console.error(B),M.error("Failed to toggle webhook status");}},k=[{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"}];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(Dt,{title:"Webhooks",description:"Receive real-time notifications when your content changes.",icon:lucideReact.Webhook,actions:[{label:"Create Webhook",onClick:()=>{u({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:""}),h(""),s(true);},icon:lucideReact.Plus},{label:"Guide",onClick:()=>m(true),icon:lucideReact.Info,variant:"outline"}]}),jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[2rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-surface)] to-[var(--kyro-surface-accent)] p-8",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.03] pointer-events-none",children:jsxRuntime.jsx(lucideReact.Zap,{className:"w-64 h-64 rotate-12"})}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-8 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-5 bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/50 rounded-[1.5rem] shadow-xl shadow-[var(--kyro-primary)]/20",children:jsxRuntime.jsx(lucideReact.Zap,{className:"w-8 h-8 text-white"})}),jsxRuntime.jsxs("div",{className:"flex-1 text-center md:text-left",children:[jsxRuntime.jsx("h3",{className:"text-xl font-bold mb-2",children:"Real-time Event Synchronization"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Webhooks allow your application to receive instant HTTP notifications when events happen in your CMS. Eliminate polling and build responsive, event-driven architectures with ease."})]}),jsxRuntime.jsxs("div",{className:"flex gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center px-4 py-2 bg-[var(--kyro-surface)]/50 border border-[var(--kyro-border)] rounded-2xl",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 uppercase tracking-tighter",children:"Collections"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-primary)]",children:"Triggered"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center px-4 py-2 bg-[var(--kyro-surface)]/50 border border-[var(--kyro-border)] rounded-2xl",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 uppercase tracking-tighter",children:"Latency"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-primary)]",children:"<200ms"})]})]})]})]}),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 tracking-[0.2em] opacity-40",children:"ACTIVE ENDPOINTS"})]}),jsxRuntime.jsxs("div",{className:"text-[10px] font-bold opacity-40 uppercase",children:[e.length," Hook",e.length!==1&&"s"]})]}),t?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 surface-tile rounded-3xl opacity-50 italic",children:"Connecting to dispatcher..."}):e.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 mx-auto mb-6 bg-gradient-to-tr from-[var(--kyro-surface)] to-[var(--kyro-surface-accent)] rounded-3xl flex items-center justify-center shadow-xl border border-[var(--kyro-border)]",children:jsxRuntime.jsx(lucideReact.Webhook,{className:"w-10 h-10 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-2xl font-bold mb-3",children:"No Webhooks Found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-8 max-w-sm mx-auto",children:"Your CMS is currently silent. Create a webhook to start broadcasting events to your external services."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"kyro-btn kyro-btn-primary inline-flex items-center gap-3 px-8 py-4 rounded-2xl font-bold hover:scale-[1.05] transition-all shadow-xl shadow-[var(--kyro-primary)]/10",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-5 h-5"}),"Configure Webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:e.map(p=>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 lg:flex-row lg:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",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(lucideReact.Webhook,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors",children:p.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-2 h-2 rounded-full ${p.status==="active"?"bg-green-500 animate-pulse":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-bold uppercase tracking-wider ${p.status==="active"?"text-green-500":"text-amber-500"}`,children:p.status})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6 pt-2",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs opacity-60 truncate max-w-[200px]",title:p.url,children:p.url})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-4 sm:pt-0 sm:pl-6 mt-4 sm:mt-0",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[p.events.slice(0,2).map(T=>jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[8px] font-bold px-1.5 opacity-60",children:T},T)),p.events.length>2&&jsxRuntime.jsxs("span",{className:"text-[8px] font-bold opacity-30",children:["+",p.events.length-2," more"]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-4 sm:pt-0 sm:pl-6 mt-4 sm:mt-0",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] font-bold opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3 h-3"}),p.lastTriggered?`Last triggered: ${new Date(p.lastTriggered).toLocaleDateString()}`:"Never triggered"]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 lg:bg-[var(--kyro-surface-accent)]/50 lg:p-2 lg:rounded-2xl lg:opacity-0 group-hover:opacity-100 transition-all duration-300 lg:translate-x-4 group-hover:translate-x-0",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>P(p.id),className:"flex-1 lg:flex-none p-3 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl hover:border-[var(--kyro-primary)] transition-all flex items-center justify-center gap-2",title:"Send test request",children:[jsxRuntime.jsx(lucideReact.Send,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Test"})]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-1 hidden lg:block"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>w(p.id,p.status),className:`p-3 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl hover:border-[var(--kyro-primary)] transition-all group/toggle ${p.status==="active"?"text-amber-500/50 hover:text-amber-500":"text-green-500/50 hover:text-green-500"}`,title:p.status==="active"?"Pause webhook":"Activate webhook",children:p.status==="active"?jsxRuntime.jsx(lucideReact.Pause,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.Play,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(p.id,"Webhook"),className:"p-3 bg-red-500/5 border border-red-500/10 rounded-xl hover:bg-red-500/10 hover:border-red-500/30 transition-all group/delete",title:"Delete webhook",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4 text-red-500/50 group-hover/delete:text-red-500"})})]})]})},p.id))})]}),jsxRuntime.jsxs(Ot,{open:n,onClose:()=>s(false),title:"Register Webhook",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",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:"Webhook Name"}),jsxRuntime.jsx("input",{type:"text",value:x.name,onChange:p=>u({...x,name:p.target.value}),placeholder:"e.g., Slack Notifications",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:"Payload URL"}),jsxRuntime.jsx("input",{type:"url",value:x.url,onChange:p=>u({...x,url:p.target.value}),placeholder:"https://your-server.com/webhook",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:"Signing Secret"}),jsxRuntime.jsx("input",{type:"text",value:x.secret,onChange:p=>u({...x,secret:p.target.value}),placeholder:"Optional secret for verification",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",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Subscribed Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:k.map(p=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let T=x.events.includes(p.value)?x.events.filter(B=>B!==p.value):[...x.events,p.value];u({...x,events:T});},className:`flex items-center gap-3 p-3 rounded-lg border transition-all text-left ${x.events.includes(p.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"bg-[var(--kyro-surface-accent)]/50 border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30"}`,children:[jsxRuntime.jsx("div",{className:`w-4 h-4 rounded flex items-center justify-center border transition-all ${x.events.includes(p.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x.events.includes(p.value)&&jsxRuntime.jsx(lucideReact.CircleCheck,{className:"w-3 h-3 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-bold",children:p.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-50",children:p.description})]})]},p.value))})]})]}),y&&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(lucideReact.TriangleAlert,{className:"w-4 h-4"}),y]})]})}),jsxRuntime.jsxs(Vr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(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:R,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",children:"Create Webhook"})]})]}),jsxRuntime.jsxs(Ot,{open:i,onClose:()=>d(false),title:"Webhook Test Dispatcher",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsx("div",{className:"p-8 rounded-[2rem] bg-[var(--kyro-surface-accent)]/30 border border-[var(--kyro-border)] text-center",children:f?jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx("div",{className:`w-16 h-16 mx-auto rounded-2xl flex items-center justify-center shadow-xl ${f.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:f.success?jsxRuntime.jsx(lucideReact.CircleCheck,{className:"w-8 h-8"}):jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"w-8 h-8"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xl font-bold mb-2",children:f.success?"Dispatch Successful":"Dispatch Failed"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70",children:f.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-6 py-4",children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"w-12 h-12 text-[var(--kyro-primary)] animate-spin mx-auto opacity-50"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xl font-bold mb-1",children:"Synthesizing Payload"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50 italic",children:"Dispatching to remote endpoint..."})]})]})})}),jsxRuntime.jsx(Vr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>d(false),className:"w-full py-3 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-all",children:"Acknowledge"})})]}),jsxRuntime.jsxs(Ot,{open:c,onClose:()=>m(false),title:"Webhook Integration Guide",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[jsxRuntime.jsxs("div",{className:"p-6 rounded-3xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"font-bold mb-3 flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),"Request Context"]}),jsxRuntime.jsxs("p",{className:"text-sm text-[var(--kyro-text-secondary)] leading-relaxed",children:["When an event triggers, Kyro sends a standard ",jsxRuntime.jsx("span",{className:"font-bold text-[var(--kyro-text-primary)]",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-6 rounded-3xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"font-bold mb-3 flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Shield,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),"Security Verification"]}),jsxRuntime.jsxs("p",{className:"text-sm text-[var(--kyro-text-secondary)] leading-relaxed",children:["If a secret is provided, each request includes an ",jsxRuntime.jsx("span",{className:"font-mono text-[var(--kyro-primary)]",children:"X-Kyro-Signature"})," header. Always verify this signature in production environments."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("h4",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Payload Architecture"}),jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-[var(--kyro-primary)]/20 to-transparent rounded-2xl blur opacity-25 group-hover:opacity-50 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] rounded-2xl border border-[var(--kyro-border)] p-6 font-mono text-sm overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-4 border-b border-[var(--kyro-border)] pb-4 opacity-30",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500/50"}),jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-500/50"}),jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500/50"}),jsxRuntime.jsx("span",{className:"text-[10px] ml-2 tracking-tighter",children:"payload.json"})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:"{"}),jsxRuntime.jsxs("div",{className:"pl-4",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-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"products"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"id"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"prod_8273"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-05-14T02:53:22Z"'})]}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:"}"})]})]})]})]})]})}),jsxRuntime.jsx(Vr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"kyro-btn kyro-btn-primary w-full py-3 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/20",children:"I Understand"})})]})]})}function sc({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{user:n,permissions:s}=Ur(),[l,i]=Ca.useState(""),[d,c]=Ca.useState(0),[m,f]=Ca.useState(false),[v,b]=Ca.useState([]),g=Ca.useRef(null),x=Ca.useRef(null);Ca.useEffect(()=>{e&&(i(""),c(0),b([]),f(false),setTimeout(()=>g.current?.focus(),100));},[e]);let u=Ca.useCallback(async A=>{if(!A||A.length<2){b([]);return}f(true);try{let K=await(await fetch(tt(`/api/search?q=${encodeURIComponent(A)}&limit=15`))).json();K.results&&b(K.results);}catch(X){console.error("Search error:",X),b([]);}finally{f(false);}},[]);if(Ca.useEffect(()=>(x.current&&clearTimeout(x.current),l.length>=2?x.current=setTimeout(()=>u(l),300):b([]),()=>{x.current&&clearTimeout(x.current);}),[l,u]),!e)return null;let y=Object.entries(r).filter(([A])=>s?.collections?.[A]?.read!==false).map(([A,X])=>({id:`col-${A}`,label:X.label||A,type:"collection",slug:A,icon:lucideReact.FileText})),h=Object.entries(o).filter(([A])=>s?.globals?.[A]?.read!==false).map(([A,X])=>({id:`global-${A}`,label:X.label||A,type:"global",slug:A,icon:lucideReact.Settings})),R=typeof document<"u"&&document.documentElement.classList.contains("dark"),P=n?.role==="admin",w=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:lucideReact.Image,visible:s?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:lucideReact.Clock,visible:P},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:lucideReact.File,visible:P},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:lucideReact.Shield,visible:P},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:lucideReact.Database,visible:P},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:lucideReact.Hexagon,visible:P},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:lucideReact.Network,visible:P},{id:"action-theme",label:R?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:R?lucideReact.Sun:lucideReact.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:lucideReact.LogOut,visible:true}].filter(A=>A.visible),k=v.map((A,X)=>({id:`doc-${A.collection}-${A.id}`,label:A.title,type:"document",collection:A.collection,label2:A.label,docId:A.id,icon:lucideReact.File,doc:A.doc})),p=l.length>=2?[...w,...y,...h,...k]:[...w,...y,...h],T=l===""?p:p.filter(A=>A.label.toLowerCase().includes(l.toLowerCase())),B=A=>{if(A.key==="ArrowDown")A.preventDefault(),c(X=>(X+1)%T.length);else if(A.key==="ArrowUp")A.preventDefault(),c(X=>(X-1+T.length)%T.length);else if(A.key==="Enter"){let X=T[d];X&&S(X);}else A.key==="Escape"&&t();},S=A=>{A.type==="collection"?A.slug==="users"?a(A.slug,A.slug):a("list",A.slug):A.type==="global"?a("settings",A.slug):A.type==="document"?A.collection==="users"?a("users","users",A.docId):a("edit",A.collection,A.docId):A.type==="action"&&(A.view==="users"?a("users","users"):A.view==="media"?a("media","media"):a(A.view,A.view)),t();},F=()=>l===""?"Quick Actions & Collections":v.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(lucideReact.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(lucideReact.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:g,placeholder:"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:A=>i(A.target.value),onKeyDown:B}),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:T.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:F()}),T.map((A,X)=>jsxRuntime.jsxs("div",{onClick:()=>S(A),onMouseEnter:()=>c(X),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${X===d?"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 ${X===d?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(A.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:A.label}),A.type==="document"&&A.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${X===d?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:A.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${X===d?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:A.type}),X===d&&jsxRuntime.jsx(lucideReact.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},A.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}=dt(),[r,o]=Ca.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(l){console.error("Modal confirm action failed:",l);}finally{o(false),t();}else t();},s=()=>{a.onCancel&&a.onCancel(),t();};return jsxRuntime.jsx(Ns,{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 iy({config:e,theme:t="light",onThemeChange:r}){let[o,a]=Ca.useState(false),[n,s]=Ca.useState(null),l=Ca.useMemo(()=>Mn(Ba(e.collections)),[e.collections]),i=Ca.useMemo(()=>En(Ba(e.globals)),[e.globals]),[d,c]=Ca.useState(null),[m,f]=Ca.useState(null),[v,b]=Ca.useState("list"),[g,x]=Ca.useState(null),[u,y]=Ca.useState(false);Ca.useEffect(()=>{(async()=>{try{let k=await fetch("/api/users/me");if(k.ok){let p=await k.json();s(p),a(!0);}}catch(k){console.error("Auth check failed",k);}})();},[]),Ca.useEffect(()=>{if(o&&!d){let w=Object.keys(l)[0];w&&c(w);}},[o,l,d]);let h=(w,k=null,p=null)=>{b(w),k&&c(k),p&&x(p),y(false);};Ca.useEffect(()=>{let w=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),y(p=>!p));};return window.addEventListener("keydown",w),window.openCommandPalette=()=>y(true),()=>{window.removeEventListener("keydown",w),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(hr,{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(sc,{isOpen:u,onClose:()=>y(false),collections:l,globals:i,onNavigate:h}),(()=>{let w=d?l[d]:null;switch(v){case "create":return w?jsxRuntime.jsx(di,{config:e,collection:w,onSuccess:()=>b("list"),onCancel:()=>b("list"),onError:k=>M.error(k)}):null;case "detail":return w&&g?jsxRuntime.jsx(li,{config:e,collection:w,documentId:g,onBack:()=>b("list"),onSave:()=>{},onError:k=>M.error(k)}):null;case "users":return jsxRuntime.jsx(Zd,{});case "media":return jsxRuntime.jsx(Nn,{});case "branding":return jsxRuntime.jsx(ec,{});case "developer":return jsxRuntime.jsx(tc,{collections:l});case "webhooks":return jsxRuntime.jsx(oc,{});default:return w?jsxRuntime.jsx(ks,{config:e,collection:w,onCreate:()=>b("create"),onEdit:k=>h("detail",d,k)}):jsxRuntime.jsx(Yd,{onNavigate:h,collections:l,user:n})}})()]})})}),jsxRuntime.jsx(ic,{}),jsxRuntime.jsx(qn,{})]})}):jsxRuntime.jsx(mi,{onAuth:(w,k)=>{s(k),a(true);},theme:t})}function ly({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(vs,{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(So,{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(jt,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function vy({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:l=false}){let i=c=>{if(!c)return "Unknown date";let m=new Date(c);if(isNaN(m.getTime())){let f=Date.parse(c);return isNaN(f)?"Invalid date":new Date(f).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"})},d=c=>{if(!c)return "Unknown date";let m=new Date(c);if(isNaN(m.getTime()))return i(c);let v=new Date().getTime()-m.getTime();if(v<0)return "Just now";let b=Math.floor(v/6e4),g=Math.floor(v/36e5),x=Math.floor(v/864e5);return b<1?"Just now":b<60?`${b}m ago`:g<24?`${g}h ago`:x<7?`${x}d ago`:i(c)};return jsxRuntime.jsx(dr,{open:e,onClose:t,title:"Version History",width:"md",children:l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12",children:jsxRuntime.jsx(kr,{})}):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(lucideReact.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(c=>{let m=c.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 ${c.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:[c.status==="published"&&jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"w-3 h-3"}),c.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",c.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(lucideReact.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),d(c.createdAt)]}),c.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(lucideReact.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:c.createdBy.name||c.createdBy.email})]}),c.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:['"',c.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(c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Preview this version",children:jsxRuntime.jsx(lucideReact.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(c,r.find(f=>f.id===o)||c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Compare with current",children:jsxRuntime.jsx(lucideReact.GitCompare,{className:"w-4 h-4"})}),!m&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(c),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:"Restore this version",children:jsxRuntime.jsx(lucideReact.Undo2,{className:"w-4 h-4"})})]})]})]},c.id)})})})}function gA({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 nr={ready:[],beforeDeploy:[],afterDeploy:[]};function ts(e){return nr.ready.push(e),()=>{nr.ready=nr.ready.filter(t=>t!==e);}}function cc(e){return nr.beforeDeploy.push(e),()=>{nr.beforeDeploy=nr.beforeDeploy.filter(t=>t!==e);}}function pc(e){return nr.afterDeploy.push(e),()=>{nr.afterDeploy=nr.afterDeploy.filter(t=>t!==e);}}async function mc(e){let t=[];for(let r of nr.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 uc(e){let t=[];for(let r of nr.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 yc(e,t){for(let r of nr.afterDeploy)try{await r(e,t);}catch{}}function vc(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function gc(e,t={}){let[r,o]=Ca.useState(null),[a,n]=Ca.useState(true),[s,l]=Ca.useState(null),i=Ca.useCallback(async()=>{n(true),l(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=`${vc(`/api/${e}`)}?${d.toString()}`,m=await fetch(c,{credentials:"include"});if(!m.ok)throw new Error(`HTTP ${m.status}: ${m.statusText}`);let f=await m.json();o(f.data??f);}catch(d){l(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return Ca.useEffect(()=>{i();},[i]),{data:r,loading:a,error:s,refetch:i}}function bc(e,t="POST"){let[r,o]=Ca.useState(false),[a,n]=Ca.useState(null);return {mutate:Ca.useCallback(async l=>{o(true),n(null);try{let i=vc(`/api/${e}`),d=await fetch(i,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:l?JSON.stringify(l):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(i){return n(i instanceof Error?i.message:String(i)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var la=new Map;function da(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");la.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),la.set(e.name,e),e.apply&&e.apply({});}function xc(e){la.delete(e);}function kc(e){return la.get(e)}function hc(){return Array.from(la.values())}function wc(e){return Array.from(la.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var by={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};da(by);var xy={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};da(xy);var ca=new Map;function pa(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");ca.set(e.id,e);}function Nc(e){ca.delete(e);}function Cc(e){return ca.get(e)}function Sc(){return Array.from(ca.values())}function Tc(e){return Array.from(ca.values()).filter(t=>t.category===e)}function Rc(e){let t=ca.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var ky=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)})]})},hy={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:ky};pa(hy);var Ny=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)})]})},Cy={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:Ny};pa(Cy);var ma=new Map;function ua(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");ma.set(e.id,e);}function Dc(e){ma.delete(e);}function Pc(e){return ma.get(e)}function Ic(){return Array.from(ma.values())}function Bc(e){return Array.from(ma.values()).find(t=>t.type===e)}function Lc(e,t){let r=ma.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var Ry=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample text"}),Ay={id:"sample-text",type:"text",label:"Sample Text",editor:Ry};ua(Ay);var Dy=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample textarea"}),Py={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:Dy};ua(Py);var Mc=yr__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");yr__default.default.join(Mc,"use-sync-external-store.js");yr__default.default.join(Mc,"use-sync-external-store-with-selector.js");function $y(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:l})=>{l.info(`Kyro Admin mounted at ${t} (API: ${r})`);let i=yr__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=yr__default.default.resolve(a.root.pathname,"..",o),c=yr__default.default.resolve(a.root.pathname,o),m=Do__default.default.existsSync(d)?d:Do__default.default.existsSync(c)?c:i;m!==i?l.info(`Loaded config from ${m}`):l.warn("Config file not found. Using defaults.");let f=yr__default.default.join(yr__default.default.dirname(m),".kyro-admin-config.json"),v="";try{let g=yr__default.default.join(yr__default.default.dirname(m),".env");Do__default.default.existsSync(g)&&dotenv.config({path:g});let x=await esbuild.build({entryPoints:[m],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=m.replace(/\.ts$/,".admin.mjs"),Do__default.default.writeFileSync(v,x.outputFiles[0].text,"utf8");let u=`
|
|
107
107
|
import { parentPort } from 'worker_threads';
|
|
108
|
-
import('${url.pathToFileURL(
|
|
108
|
+
import('${url.pathToFileURL(v).href}').then(mod => {
|
|
109
109
|
const cfg = mod.default || mod;
|
|
110
110
|
const serialize = (obj, key) => {
|
|
111
111
|
if (obj === null || obj === undefined) return obj;
|
|
@@ -132,7 +132,7 @@ code block
|
|
|
132
132
|
}).catch(err => {
|
|
133
133
|
parentPort.postMessage({ error: err.message });
|
|
134
134
|
});
|
|
135
|
-
`,
|
|
135
|
+
`,y=new worker_threads.Worker(u,{eval:!0,env:{...process.env,NODE_OPTIONS:""}}),h=await new Promise((P,w)=>{y.on("message",P),y.on("error",w);let k=setTimeout(()=>{y.terminate(),w(new Error("Config loading timed out"));},3e4);});if(y.terminate(),h.error)throw new Error(h.error);let R=[{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 P of h.collections||[])if(P.seo){let w=P.fields?.find(k=>k.type==="tabs"&&k.name==="mainTabs");w?.tabs&&(w.tabs.find(k=>k.label==="SEO Settings")||w.tabs.push({label:"SEO Settings",fields:R}));}Do__default.default.writeFileSync(f,JSON.stringify(h,null,2),"utf8"),l.info("Project config loaded for admin");}catch(g){l.error(`Could not load project config: ${g.message}`);}finally{if(v&&Do__default.default.existsSync(v))try{Do__default.default.unlinkSync(v);}catch{}}n({vite:{plugins:[{name:"kyro-admin-tsx-loader",enforce:"pre",config(g){let x=g.esbuild,u=x?.exclude,y=/\/node_modules\/(?!.*@kyro-cms\/(admin|core))/;return {esbuild:{...x||{},exclude:u?Array.isArray(u)?[...u,y]:[u,y]:y}}}},{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 `
|
|
136
136
|
import React from "react";
|
|
137
137
|
export function c(size) {
|
|
138
138
|
const internals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
@@ -141,7 +141,7 @@ export function c(size) {
|
|
|
141
141
|
}
|
|
142
142
|
return internals.H.useMemoCache(size);
|
|
143
143
|
}
|
|
144
|
-
`;if(
|
|
144
|
+
`;if(g==="\0debug-browser")return `
|
|
145
145
|
function debug(namespace) {
|
|
146
146
|
function d(...args) {
|
|
147
147
|
if (typeof localStorage !== "undefined" && localStorage.getItem("DEBUG")) {
|
|
@@ -154,4 +154,4 @@ debug.enable = function() {};
|
|
|
154
154
|
debug.disable = function() {};
|
|
155
155
|
debug.enabled = function() { return false; };
|
|
156
156
|
export default debug;
|
|
157
|
-
`}}],resolve:{alias:{"kyro:config":m}},optimizeDeps:{include:["@kyro-cms/admin"],exclude:["debug","react/compiler-runtime"]},define:{__KYRO_ADMIN_PATH__:JSON.stringify(t),__KYRO_API_PATH__:JSON.stringify(r),__KYRO_ADMIN_CONFIG_FILE__:JSON.stringify(
|
|
157
|
+
`}}],resolve:{alias:{"kyro:config":m}},optimizeDeps:{include:["@kyro-cms/admin"],exclude:["debug","react/compiler-runtime"]},define:{__KYRO_ADMIN_PATH__:JSON.stringify(t),__KYRO_API_PATH__:JSON.stringify(r),__KYRO_ADMIN_CONFIG_FILE__:JSON.stringify(f)},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 b=[{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:"/[collection]",entrypoint:"./pages/[collection]/index.astro"},{pattern:"/[collection]/[id]",entrypoint:"./pages/[collection]/[id].astro"}];for(let g of b){let x=`${t}${g.pattern}`.replace(/\/$/,"");s({pattern:x||"/",entrypoint:yr__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=iy;exports.AutoForm=Wa;exports.Badge=Pt;exports.BulkActionsBar=ly;exports.Button=gs;exports.ConfirmModal=Ns;exports.CountBadge=vs;exports.CreateView=di;exports.DARK_THEME=Fa;exports.DarkThemeProvider=Rn;exports.DetailView=li;exports.Dropdown=So;exports.DropdownItem=jt;exports.DropdownSeparator=Ka;exports.ExtDarkThemeProvider=Rn;exports.ExtLightThemeProvider=Tn;exports.ExtThemeProvider=hr;exports.Header=gA;exports.LIGHT_THEME=_o;exports.LightThemeProvider=Tn;exports.ListView=ks;exports.LoginPage=mi;exports.Modal=Ot;exports.PageHeader=Dt;exports.SlidePanel=dr;exports.Spinner=kr;exports.ThemeProvider=hr;exports.Toast=Jd;exports.ToastProvider=X3;exports.VersionHistoryPanel=vy;exports.adminPath=Ge;exports.afterDeploy=pc;exports.apiPath=br;exports.beforeDeploy=cc;exports.emitAdminReady=mc;exports.emitAfterDeploy=yc;exports.emitBeforeDeploy=uc;exports.getBlock=Cc;exports.getBlocks=Sc;exports.getBlocksByCategory=Tc;exports.getField=Pc;exports.getFieldByType=Bc;exports.getFields=Ic;exports.getPlugin=kc;exports.getPlugins=hc;exports.getPluginsWithHook=wc;exports.kyroAdmin=$y;exports.mergeThemes=Da;exports.onAdminReady=ts;exports.paths=Yc;exports.registerBlock=pa;exports.registerField=ua;exports.registerPlugin=da;exports.resolveAdmin=ss;exports.resolveApi=tt;exports.unregisterBlock=Nc;exports.unregisterField=Dc;exports.unregisterPlugin=xc;exports.useBlockRenderer=Rc;exports.useExtTheme=Ho;exports.useFieldRenderer=Lc;exports.useKyroMutation=bc;exports.useKyroQuery=gc;exports.useTheme=Ho;exports.useToast=Y3;
|