@kyro-cms/admin 0.12.4 → 0.12.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 +64 -26
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +64 -26
- package/package.json +9 -3
- package/src/components/ActionBar.tsx +16 -16
- package/src/components/ApiHealth.tsx +522 -0
- package/src/components/ApiKeysManager.tsx +6 -4
- package/src/components/AuditLogsPage.tsx +4 -2
- package/src/components/AutoForm.tsx +10 -7
- package/src/components/BrandingHub.tsx +3 -1
- package/src/components/Dashboard.tsx +44 -37
- package/src/components/DashboardMetrics.tsx +168 -58
- package/src/components/DetailView.tsx +41 -38
- package/src/components/DeveloperCenter.tsx +5 -3
- package/src/components/GraphQLPlayground.tsx +10 -8
- package/src/components/ListView.tsx +66 -45
- package/src/components/LoginPage.tsx +21 -19
- package/src/components/MarketplaceManager.tsx +3 -1
- package/src/components/MediaGallery.tsx +12 -9
- package/src/components/PluginsManager.tsx +6 -4
- package/src/components/RestPlayground.tsx +8 -6
- package/src/components/SessionsManager.tsx +3 -1
- package/src/components/Sidebar.astro +180 -92
- package/src/components/UserManagement.tsx +8 -6
- package/src/components/UserMenu.tsx +19 -17
- package/src/components/VersionHistoryPanel.tsx +6 -4
- package/src/components/WebhookManager.tsx +11 -10
- package/src/components/autoform/AutoFormApiView.tsx +3 -1
- package/src/components/autoform/AutoFormEditView.tsx +3 -1
- package/src/components/autoform/AutoFormHeader.tsx +6 -6
- package/src/components/blocks/AccordionBlock.tsx +5 -3
- package/src/components/blocks/ArrayBlock.tsx +5 -3
- package/src/components/blocks/BlockWrapper.tsx +5 -3
- package/src/components/blocks/CodeBlock.tsx +4 -2
- package/src/components/blocks/FileBlock.tsx +5 -3
- package/src/components/blocks/HeroBlock.tsx +5 -3
- package/src/components/blocks/ImageBlock.tsx +6 -4
- package/src/components/blocks/ListBlock.tsx +5 -3
- package/src/components/blocks/ParagraphBlock.tsx +3 -1
- package/src/components/blocks/RelationshipBlock.tsx +5 -3
- package/src/components/blocks/RichTextBlock.tsx +5 -3
- package/src/components/blocks/VideoBlock.tsx +5 -3
- package/src/components/fields/AccordionField.tsx +10 -51
- package/src/components/fields/ArrayField.tsx +9 -7
- package/src/components/fields/ArrayLayout.tsx +3 -1
- package/src/components/fields/BlocksField.tsx +24 -75
- package/src/components/fields/ButtonField.tsx +3 -1
- package/src/components/fields/CardField.tsx +6 -4
- package/src/components/fields/GroupLayout.tsx +2 -49
- package/src/components/fields/HeadingField.tsx +3 -1
- package/src/components/fields/HeadingSubheadingField.tsx +4 -2
- package/src/components/fields/HeroField.tsx +8 -6
- package/src/components/fields/JSONField.tsx +9 -10
- package/src/components/fields/LinkField.tsx +4 -2
- package/src/components/fields/ListField.tsx +3 -1
- package/src/components/fields/MarkdownField.tsx +3 -17
- package/src/components/fields/RelationshipBlockField.tsx +7 -5
- package/src/components/fields/RelationshipField.tsx +3 -1
- package/src/components/fields/RichTextField.tsx +19 -16
- package/src/components/fields/SecretField.tsx +9 -69
- package/src/components/fields/SelectField.tsx +11 -6
- package/src/components/fields/TabsLayout.tsx +2 -48
- package/src/components/fields/TextField.tsx +9 -7
- package/src/components/fields/UploadField.tsx +3 -1
- package/src/components/fields/VideoField.tsx +6 -4
- package/src/components/ui/BlockDrawer.tsx +3 -1
- package/src/components/ui/CommandPalette.tsx +9 -7
- package/src/components/ui/CommandPaletteWrapper.tsx +3 -1
- package/src/components/ui/IconPickerModal.tsx +4 -2
- package/src/components/ui/PageHeader.tsx +48 -19
- package/src/components/users/UserDetail.tsx +3 -1
- package/src/components/users/UserForm.tsx +5 -3
- package/src/fields/examples/sample-field-2.tsx +3 -1
- package/src/fields/examples/sample-field.tsx +3 -1
- package/src/hooks/useAutoFormState.ts +19 -11
- package/src/integration.ts +21 -0
- package/src/layouts/AdminLayout.astro +252 -189
- package/src/layouts/AuthLayout.astro +52 -31
- package/src/lib/api.ts +7 -7
- package/src/lib/deep-equal.ts +3 -3
- package/src/lib/i18n.ts +44 -0
- package/src/lib/vite-shim-plugin.ts +3 -0
- package/src/locales/de.json +163 -0
- package/src/locales/en.json +163 -0
- package/src/locales/es.json +163 -0
- package/src/locales/fr.json +163 -0
- package/src/locales/pt.json +163 -0
- package/src/pages/403.astro +2 -1
- package/src/pages/[collection]/[id].astro +23 -10
- package/src/pages/[collection]/index.astro +48 -34
- package/src/pages/audit/index.astro +2 -1
- package/src/pages/graphql-explorer.astro +2 -1
- package/src/pages/graphql.astro +2 -1
- package/src/pages/health.astro +9 -0
- package/src/pages/index.astro +6 -5
- package/src/pages/keys.astro +2 -1
- package/src/pages/marketplace.astro +2 -1
- package/src/pages/media.astro +2 -1
- package/src/pages/plugins.astro +2 -1
- package/src/pages/rest-playground.astro +2 -1
- package/src/pages/roles/index.astro +16 -52
- package/src/pages/sessions.astro +2 -1
- package/src/pages/settings/[slug].astro +45 -30
- package/src/pages/users/[id].astro +1 -0
- package/src/pages/users/index.astro +2 -1
- package/src/pages/users/new.astro +2 -1
- package/src/pages/webhooks.astro +2 -1
- package/src/pages/index_ALT.astro +0 -3
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var Da=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),ql=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),react=require('@tiptap/react'),sm=require('@tiptap/starter-kit'),im=require('@tiptap/extension-link'),lm=require('@tiptap/extension-image'),dm=require('@tiptap/extension-text-align'),cm=require('@tiptap/extension-underline'),pm=require('@tiptap/extension-highlight'),mm=require('@tiptap/extension-task-list'),um=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),fm=require('@tiptap/extension-color'),Xp=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'),eu=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Oo=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),Ly=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}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Da__default=/*#__PURE__*/_interopDefault(Da);var ql__namespace=/*#__PURE__*/_interopNamespace(ql);var sm__default=/*#__PURE__*/_interopDefault(sm);var im__default=/*#__PURE__*/_interopDefault(im);var lm__default=/*#__PURE__*/_interopDefault(lm);var dm__default=/*#__PURE__*/_interopDefault(dm);var cm__default=/*#__PURE__*/_interopDefault(cm);var pm__default=/*#__PURE__*/_interopDefault(pm);var mm__default=/*#__PURE__*/_interopDefault(mm);var um__default=/*#__PURE__*/_interopDefault(um);var fm__default=/*#__PURE__*/_interopDefault(fm);var Xp__default=/*#__PURE__*/_interopDefault(Xp);var eu__default=/*#__PURE__*/_interopDefault(eu);var Oo__default=/*#__PURE__*/_interopDefault(Oo);var Ly__default=/*#__PURE__*/_interopDefault(Ly);var gr__default=/*#__PURE__*/_interopDefault(gr);var ze=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",wr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Je(e){if(e.startsWith("http")||e.startsWith(wr))return e;if(e.startsWith("/api/"))return wr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${wr}${t}${e}`}function Cs(e){return e.startsWith("http")||e.startsWith(ze)?e:e.startsWith("/admin/")?ze+e.slice(6):e.startsWith("/")?ze+e:e}function Aa(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var Sp={admin:ze,api:wr,resolveApi:Je,resolveAdmin:Cs,resolveMedia:Aa};var Kr=zustand.create(e=>({user:null,permissions:null,isAuthenticated:false,isLoading:true,error:null,setUser:(t,r=null)=>e({user:t,permissions:r,isAuthenticated:!!t,isLoading:false,error:null}),setLoading:t=>e({isLoading:t}),setError:t=>e({error:t,isLoading:false,isAuthenticated:false,user:null,permissions:null}),logout:()=>e({user:null,permissions:null,isAuthenticated:false,isLoading:false,error:null})}));var Xt=zustand.create(e=>({toasts:[],addToast:(t,r)=>{let o=Math.random().toString(36).substring(7);e(a=>({toasts:[...a.toasts,{id:o,type:t,message:r}]}));},removeToast:t=>e(r=>({toasts:r.toasts.filter(o=>o.id!==t)})),clearToasts:()=>e({toasts:[]})})),U={success:e=>Xt.getState().addToast("success",e),error:e=>Xt.getState().addToast("error",e),warning:e=>Xt.getState().addToast("warning",e),info:e=>Xt.getState().addToast("info",e)};zustand.create()(middleware.persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var ft=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 Ap="/api/auth/refresh";async function Ei(){try{return (await fetch(Je(Ap),{method:"POST",credentials:"include"})).ok}catch{return false}}async function lt(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(Je(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await Ei()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(Je(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function De(e,t){let{autoToast:r=true,...o}=t||{},a=await lt(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&U.error(n),new Error(n)}return a.json()}async function dt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await lt(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&U.error(s),new Error(s)}return n.json()}async function Yt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await lt(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&U.error(s),new Error(s)}return n.json()}async function Tt(e,t){let{autoToast:r=true,...o}={},a=await lt(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let l=await a.json();l.error&&(s=l.error);}catch{}throw r&&U.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function Gr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function pn(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function mn(e,t,r){if(!r){let o=await lt(e,{method:"POST",body:t});if(!o.ok)throw new Error(`Upload Error: ${o.status}`);return o.json()}return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("POST",Je(e)),n.withCredentials=true,n.upload.addEventListener("progress",s=>{s.lengthComputable&&r(Math.round(s.loaded/s.total*100));}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{o(JSON.parse(n.responseText));}catch{a(new Error("Invalid JSON response"));}else n.status===401?Ei().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let l=new XMLHttpRequest;l.open("POST",Je(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 ar({size:e="md",className:t=""}){return jsxRuntime.jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}function Vt({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 wl({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 Pp({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(Da__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 Nl({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 ${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 Cl({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 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 $t({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:l,children:i}){let c=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(wl,{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:c?.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((d,m)=>jsxRuntime.jsxs(Da__default.default.Fragment,{children:[m>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),d.href||d.onClick?jsxRuntime.jsx("a",{href:d.href,onClick:x=>{d.onClick&&(x.preventDefault(),d.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:d.label}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d.label})]},m))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((d,m)=>jsxRuntime.jsx(Da__default.default.Fragment,{children:d},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((d,m)=>jsxRuntime.jsxs(Da__default.default.Fragment,{children:[m===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),d]},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(wl,{back:n}),o&&jsxRuntime.jsx(Pp,{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((d,m)=>jsxRuntime.jsxs(Da__default.default.Fragment,{children:[m===0&&(t||m>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),d]},m))}),i]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[l&&jsxRuntime.jsx(Nl,{actions:l}),s&&jsxRuntime.jsx(Cl,{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(Cl,{action:s}),l&&jsxRuntime.jsx(Nl,{actions:l})]})]})}var Dp={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 It({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=Dp[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 Ls({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 Ms({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let l="kyro-btn",i=`kyro-btn-${e}`,c=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${l} ${i} ${c} ${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 Tl({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(Ms,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(Ms,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}function No(e,t,r){return r in t?t[r]:Es(e,t,r)}function Es(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=Es(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=Es(o.fields||[],a,r);if(n!==void 0)return n}}}}function Os({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let l=t||e.slug,{permissions:i}=Kr(),c=i?.collections?.[l]?.create!==false,d=i?.collections?.[l]?.delete!==false,m=i?.collections?.[l]?.update!==false,x=()=>{c&&(a?a():window.location.href=`${ze}/${l}/new`);},b=B=>{n?n(B):window.location.href=`${ze}/${l}/${B}`;},[k,f]=Da.useState(r),[g,p]=Da.useState(o),[u,v]=Da.useState(false),[R,P]=Da.useState(1),[h,w]=Da.useState(10),[y,S]=Da.useState(new Set),[O,L]=Da.useState(""),[K,C]=Da.useState([]),{confirm:G,alert:z}=ft(),j=()=>{C([...K,{field:"",operator:"equals",value:""}]);},_=()=>{L(""),C([]),de(null);},se=B=>{C(K.filter((ee,ce)=>ce!==B));},te=(B,ee)=>{C(K.map((ce,br)=>br===B?{...ce,...ee}:ce));},[J,de]=Da.useState(null),[ve,Te]=Da.useState(false),[Ve,M]=Da.useState(false);function E(B){let ee=[];for(let ce of B||[])if(!(!ce.name||ce.hidden===true||ce.admin?.hidden||ce.name==="id"))if(ce.type==="tabs"&&ce.tabs)for(let br of ce.tabs)br.fields&&ee.push(...E(br.fields));else (ce.type==="row"||ce.type==="collapsible")&&ce.fields?ee.push(...E(ce.fields)):ee.push(ce);return ee}let ne=Da.useMemo(()=>E(e.fields),[e.fields]),ue=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:ne.find(B=>B.type!=="group"&&typeof B.name=="string")?.name,[$e,A]=Da.useState(()=>{let B;return e.admin?.defaultColumns?B=[...e.admin?.defaultColumns||[]]:B=ne.slice(0,4).map(ee=>ee.name).filter(ee=>!!ee),ue&&B.includes(ue)&&(B=[ue,...B.filter(ee=>ee!==ue)]),B.includes("updatedAt")||B.push("updatedAt"),new Set(B)}),$=Da.useCallback(B=>{A(ee=>{let ce=new Set(ee);return ce.has(B)?ce.delete(B):ce.add(B),ce});},[]);function Z(B){let ee=ne.find(ce=>ce.name===B);return ee&&ee.type==="group"&&ee.fields?.[0]?.name?`${B}.${ee.fields[0].name}`:B}let Ke=Da.useCallback(B=>{let ee=Z(B);de(ce=>ce&&ce.field===ee?{field:ee,direction:ce.direction==="asc"?"desc":"asc"}:{field:ee,direction:"asc"});},[]),fe=Da.useMemo(()=>{let B=ne.filter(ee=>!!ee.name&&$e.has(ee.name));return $e.has("status")&&B.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]}),B},[ne,$e]);function We(B){return !B.name||!ue?false:B.name===ue||B.type==="group"&&B.fields?.[0]?.name===ue}function Fe(B,ee){return ee.name?No(e.fields,B,ee.name)??null:null}let yt=Da.useCallback(async()=>{v(true);try{let B=new URLSearchParams({page:R.toString(),limit:h.toString()});O&&B.append("search",O),J&&B.append("sort",J.field),J&&B.append("order",J.direction),K.length>0&&B.append("filters",JSON.stringify(K));let ee=await De(Gr(`/api/${l}?${B}`),{autoToast:!1});f(ee.docs||[]),p(ee.totalDocs||0);}catch(B){console.error("Failed to load docs:",B);}finally{v(false);}},[l,R,h,O,J,K]);Da.useEffect(()=>{k.length===0&&o===0&&yt();},[]);let wt=Da.useRef(true);Da.useEffect(()=>{if(wt.current){wt.current=false;return}yt();},[R,h,O,J,K]);let I=()=>{y.size===k.length?S(new Set):S(new Set(k.map(B=>B.id)));},H=B=>{let ee=new Set(y);ee.has(B)?ee.delete(B):ee.add(B),S(ee);},q=()=>{G({title:"Delete Documents",message:`Are you sure you want to delete ${y.size} document(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let B of Array.from(y))await Tt(`/api/${l}/${B}`);S(new Set),yt(),U.success("Documents deleted");}catch(B){console.error("Bulk delete failed:",B),U.error("Failed to delete some documents");}}});},xe=B=>{G({title:"Delete Document",message:"Are you sure you want to delete this document? This cannot be undone.",variant:"danger",onConfirm:async()=>{try{await Tt(`/api/${l}/${B}`),yt(),U.success("Document deleted");}catch(ee){console.error("Delete failed:",ee),U.error("Failed to delete document");}}});},Re=Math.ceil(g/h),Ue=O||K.length>0||J;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx($t,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:g>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[g," documents"]},"count")]:void 0,action:c?{label:`Create ${e.singularLabel||e.label||l}`,onClick:x,icon:ql.Plus}:void 0}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsxRuntime.jsx(ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search...",value:O,onChange:B=>L(B.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-sm font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Te(!ve),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${ve||K.length>0?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(ql.Filter,{className:"w-4 h-4"}),"Filters",K.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:K.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>M(!Ve),className:"flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",children:[jsxRuntime.jsx(ql.Columns3,{className:"w-4 h-4"}),"Columns"]}),Ve&&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:ne.map(B=>B.name?jsxRuntime.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:$e.has(B.name),onChange:()=>$(B.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:B.label||B.name})]},B.name):null)})]})]}),Ue&&jsxRuntime.jsx("button",{type:"button",onClick:_,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:j,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-bold text-[var(--kyro-sidebar-active)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all",children:[jsxRuntime.jsx(ql.Plus,{className:"w-4 h-4"}),"Add Filter"]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[K.map((B,ee)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:B.field,onChange:ce=>te(ee,{field:ce.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:ne.map(ce=>jsxRuntime.jsx("option",{value:ce.name,children:ce.label||ce.name},ce.name))}),jsxRuntime.jsxs("select",{value:B.operator,onChange:ce=>te(ee,{operator:ce.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("option",{value:"equals",children:"Equals"}),jsxRuntime.jsx("option",{value:"contains",children:"Contains"}),jsxRuntime.jsx("option",{value:"gt",children:"Greater than"}),jsxRuntime.jsx("option",{value:"lt",children:"Less than"}),jsxRuntime.jsx("option",{value:"gte",children:"Greater or equal"}),jsxRuntime.jsx("option",{value:"lte",children:"Less or equal"})]}),jsxRuntime.jsx("input",{type:"text",value:B.value,onChange:ce=>te(ee,{value:ce.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(ee),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(ql.X,{className:"w-4 h-4"})})]},ee)),K.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:'No filters applied. Click "Add Filter" to create one.'})]})]}),y.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:[y.size," selected"]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[d&&jsxRuntime.jsxs("button",{type:"button",onClick:q,className:"flex items-center gap-2 px-4 py-2 bg-red-500 text-white rounded-lg font-bold text-sm hover:bg-red-600 transition-all",children:[jsxRuntime.jsx(ql.Trash2,{className:"w-4 h-4"}),"Delete Selected"]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>S(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(Vt,{variant:"table-row",count:8})}):k.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsxRuntime.jsx(ql.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:"No documents found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:Ue?"Try adjusting your filters or search query.":`Get started by creating your first ${(e.singularLabel||e.label||l).toLowerCase()}.`}),!Ue&&c&&jsxRuntime.jsxs("button",{type:"button",onClick:x,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsxRuntime.jsx(ql.Plus,{className:"w-4 h-4"}),"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:y.size===k.length&&k.length>0,onChange:I,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),fe.map(B=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Ke(B.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[Ep(fe,B.type)??(B.label||B.name),J&&J.field===B.name&&jsxRuntime.jsx(ql.ChevronUp,{className:"w-4 h-4"})]})},B.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"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:k.map(B=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>b(B.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:ee=>ee.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:y.has(B.id),onChange:()=>H(B.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),fe.map(ee=>{let ce=Fe(B,ee),br=ee.type==="select"&&ce&&Array.isArray(ee.options)?ee.options.find(go=>go.value===ce)?.label||ce:Mp(ce,ee.type);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${We(ee)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:br},ee.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:B.createdAt?new Date(B.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:B.updatedAt?new Date(B.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:ee=>ee.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:()=>b(B.id),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",title:m?"Edit":"View",children:jsxRuntime.jsx(ql.Pencil,{className:"w-4 h-4"})}),d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>xe(B.id),className:"inline-flex items-center justify-center w-8 h-8 rounded-md text-[var(--kyro-text-muted)] hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-500/10 transition-colors",title:"Delete",children:jsxRuntime.jsx(ql.Trash2,{className:"w-4 h-4"})})]})})]},B.id))})]})})}),jsxRuntime.jsx(Tl,{page:R,totalPages:Re,totalDocs:g,limit:h,onPageChange:P,onLimitChange:B=>{w(B),P(1);}})]})}function Mp(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 Ep(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var Us=(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"},Il=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(ql.Image,{className:t});case "video":return jsxRuntime.jsx(ql.Film,{className:t});case "audio":return jsxRuntime.jsx(ql.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(ql.FileText,{className:t});default:return jsxRuntime.jsx(ql.File,{className:t})}};function mr({field:e,value:t,onChange:r,disabled:o}){let a=Da.useRef(null),n=Da.useRef(null),[s,l]=Da.useState(false),[i,c]=Da.useState(false),[d,m]=Da.useState(false),[x,b]=Da.useState([]),[k,f]=Da.useState([]),[g,p]=Da.useState(""),[u,v]=Da.useState(false),[R,P]=Da.useState(""),[h,w]=Da.useState(false),[y,S]=Da.useState(""),[O,L]=Da.useState(""),[K,C]=Da.useState([]),G=e?.label||e?.name||"File",z=e.maxCount??(e.hasMany?999:1),j=z>1,_=Array.isArray(t)?t:t?[t]:[],se=_.length<z,[te,J]=Da.useState({});Da.useEffect(()=>{(async()=>{let Z=_.filter(Fe=>typeof Fe=="string").map(Fe=>Fe),Ke=_.filter(Fe=>typeof Fe=="object"&&Fe!==null&&typeof Fe.id=="string"&&!Fe.url&&!Fe.filename&&!Fe.mimeType).map(Fe=>Fe.id),We=[...Z,...Ke].filter(Fe=>!te[Fe]);if(We.length!==0)try{let Fe=await Promise.all(We.map(yt=>De(`/api/media/${yt}`)));J(yt=>{let wt={...yt};return Fe.forEach(I=>{I&&I.id&&(wt[I.id]=I);}),wt});}catch(Fe){console.error("Failed to fetch media details:",Fe);}})();},[t,te]),Da.useEffect(()=>{i&&(de(),ve());},[i,g]);let de=async()=>{try{let $=await De(Gr("/api/media/folders"));f($.folders||[]);}catch{f([]);}},ve=async()=>{v(true);try{let $=Gr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");g&&($+="&folder="+encodeURIComponent(g));let Z=await De($);b(Z.docs||[]);}catch{b([]);}finally{v(false);}},Te=async $=>{l(true);try{let Z=new FormData;Z.append("file",$),g&&Z.append("folder",g);let Ke=await mn("/api/media/upload",Z),fe=Ke.data||Ke.doc||Ke,We={...fe,id:fe.id,filename:fe.filename,originalName:fe.originalName??$.name,url:fe.url,mimeType:fe.mimeType||$.type};r(j?[..._,We]:We),U.success(`Asset synchronized: ${We.filename}`);}catch(Z){console.error("Upload failed:",Z),U.error(`Upload failed: ${Z instanceof Error?Z.message:"Unknown error"}`);}finally{l(false);}},Ve=async()=>{let $=y.trim();if($){L("");try{let Z=await dt("/api/media/upload",{url:$}),Ke=(()=>{try{return new URL($).pathname.split("/").pop()||Z.originalName||"url-image"}catch{return Z.originalName||"url-image"}})(),fe={id:Z.id,filename:Z.filename,originalName:Ke,url:Z.url,mimeType:Z.mimeType||"image/*"};r(j?[..._,fe]:fe),U.success(`URL asset established: ${fe.filename}`),S(""),w(!1);}catch(Z){let Ke=Z instanceof Error?Z.message:"Invalid URL";L(Ke);}}},M=$=>({id:$.id,filename:$.filename,url:$.url,mimeType:$.mimeType}),E=$=>{j?C(Z=>Z.find(fe=>fe.id===$.id)?Z.filter(fe=>fe.id!==$.id):[...Z,$]):(r(M($)),c(false),P(""));},ne=()=>{if(K.length>0){let $=[..._,...K.map(M)];r($);}C([]),c(false),P("");},ue=$=>{let Z=[..._];Z.splice($,1),r(j?Z:Z[0]||null);},$e=Da.useMemo(()=>x.filter($=>!R||$.filename?.toLowerCase().includes(R.toLowerCase())||$.title?.toLowerCase().includes(R.toLowerCase())),[x,R]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let A=($,Z)=>{if(!$)return null;let Ke=typeof $=="string"?$:$.id,fe=te[Ke]||(typeof $=="object"?$:{}),We=Us(fe.mimeType,fe.filename||fe.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:Aa(fe.url),alt:fe.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(Il,{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:fe.originalName||fe.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:G})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Z!==void 0?ue(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(ql.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:$=>{let Z=$.target.files?.[0];Z&&Te(Z);},disabled:o,className:"hidden"}),_.length>0&&jsxRuntime.jsx("div",{className:j?"grid grid-cols-2 gap-2":"space-y-2",children:_.map(($,Z)=>A($,Z))}),(!_.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 ",G]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{C([]),c(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:()=>w(!h),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"})]}),h&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:y,onChange:$=>{S($.target.value),L("");},onKeyDown:$=>$.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||!y.trim(),className:"kyro-btn kyro-btn-primary px-3 py-1.5 text-xs rounded cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50",children:"Add"}),O&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:O})]}),i&&(d?reactDom.createPortal(jsxRuntime.jsx(Dl,{isFullscreen:true,isMultiple:j,selectedItems:K,pickerSearch:R,setPickerSearch:P,folders:k,selectedFolder:g,setSelectedFolder:p,mediaLoading:u,filteredMedia:$e,selectFromLibrary:E,onDone:ne,setIsPickerFullscreen:m,setShowPicker:c}),document.body):jsxRuntime.jsx(Dl,{isFullscreen:false,isMultiple:j,selectedItems:K,pickerSearch:R,setPickerSearch:P,folders:k,selectedFolder:g,setSelectedFolder:p,mediaLoading:u,filteredMedia:$e,selectFromLibrary:E,onDone:ne,setIsPickerFullscreen:m,setShowPicker:c}))]})}function Dl({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:l,mediaLoading:i,filteredMedia:c,selectFromLibrary:d,onDone:m,setIsPickerFullscreen:x,setShowPicker:b}){let k=f=>r.some(g=>g.id===f);return jsxRuntime.jsxs("div",{className:`${e?"fixed inset-0 z-[9999]":"relative z-[9999] w-[360px] max-h-[400px] mt-1 rounded-lg shadow-lg"} overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex flex-col`,children:[jsxRuntime.jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsxRuntime.jsx("input",{type:"text",placeholder:"Search media...",value:o,onChange:f=>a(f.target.value),className:"w-full px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),n.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>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(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>l(f.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===f.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:f.name},f.path))]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-2",children:i?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):c.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:c.map(f=>{let g=k(f.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>d(f),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${g?"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:Us(f.mimeType,f.filename)==="image"?jsxRuntime.jsx("img",{src:Aa(f.thumbnailUrl||f.url),alt:f.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(Il,{type:Us(f.mimeType,f.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&g&&jsxRuntime.jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsxRuntime.jsx(ql.Check,{className:"w-3 h-3 text-white"})})]},f.id)})})}),jsxRuntime.jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[c.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:()=>x(!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:()=>{b(false),x(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function ct({field:e,error:t,children:r,hideLabel:o=false}){return jsxRuntime.jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsxRuntime.jsx("div",{className:"flex justify-between items-end mb-1",children:jsxRuntime.jsxs("label",{className:"block text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 group-focus-within:opacity-100 group-focus-within:text-[var(--kyro-primary)] transition-all duration-300",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsxRuntime.jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsxRuntime.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin.description}),t&&jsxRuntime.jsxs("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-error)] font-bold flex items-center gap-2 animate-in fade-in slide-in-from-top-1 duration-300",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function ur({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let l=Da.useRef(null),[i,c]=Da.useState(false);Da.useEffect(()=>{c(true);},[]),Da.useEffect(()=>{let m=x=>{x.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 d={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] ${d[a]} bg-[var(--kyro-surface)] ${s?`border-l-2 ${s}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1.5 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors",children:jsxRuntime.jsx(ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsxRuntime.jsx("style",{children:`
|
|
1
|
+
'use strict';var Ta=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),Ql=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),reactI18next=require('react-i18next'),$u=require('i18next'),Ou=require('i18next-browser-languagedetector'),reactDom=require('react-dom'),react=require('@tiptap/react'),gp=require('@tiptap/starter-kit'),vp=require('@tiptap/extension-link'),bp=require('@tiptap/extension-image'),xp=require('@tiptap/extension-text-align'),kp=require('@tiptap/extension-underline'),hp=require('@tiptap/extension-highlight'),wp=require('@tiptap/extension-task-list'),Np=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),Sp=require('@tiptap/extension-color'),np=require('react-image-crop');require('react-image-crop/dist/ReactCrop.css');var codemirrorThemeGithub=require('@uiw/codemirror-theme-github'),codemirrorThemeAura=require('@uiw/codemirror-theme-aura'),unstorage=require('unstorage'),um=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Mo=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),Af=require('@uiw/react-codemirror'),langJson=require('@codemirror/lang-json');require('@kyro-cms/core');var br=require('path'),url=require('url'),esbuild=require('esbuild'),dotenv=require('dotenv'),worker_threads=require('worker_threads');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Ta__default=/*#__PURE__*/_interopDefault(Ta);var Ql__namespace=/*#__PURE__*/_interopNamespace(Ql);var $u__default=/*#__PURE__*/_interopDefault($u);var Ou__default=/*#__PURE__*/_interopDefault(Ou);var gp__default=/*#__PURE__*/_interopDefault(gp);var vp__default=/*#__PURE__*/_interopDefault(vp);var bp__default=/*#__PURE__*/_interopDefault(bp);var xp__default=/*#__PURE__*/_interopDefault(xp);var kp__default=/*#__PURE__*/_interopDefault(kp);var hp__default=/*#__PURE__*/_interopDefault(hp);var wp__default=/*#__PURE__*/_interopDefault(wp);var Np__default=/*#__PURE__*/_interopDefault(Np);var Sp__default=/*#__PURE__*/_interopDefault(Sp);var np__default=/*#__PURE__*/_interopDefault(np);var um__default=/*#__PURE__*/_interopDefault(um);var Mo__default=/*#__PURE__*/_interopDefault(Mo);var Af__default=/*#__PURE__*/_interopDefault(Af);var br__default=/*#__PURE__*/_interopDefault(br);var Ue=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",wr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function qe(e){if(e.startsWith("http")||e.startsWith(wr))return e;if(e.startsWith("/api/"))return wr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${wr}${t}${e}`}function hs(e){return e.startsWith("http")||e.startsWith(Ue)?e:e.startsWith("/admin/")?Ue+e.slice(6):e.startsWith("/")?Ue+e:e}function Ca(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var Nu={admin:Ue,api:wr,resolveApi:qe,resolveAdmin:hs,resolveMedia:Ca};var _r=zustand.create(e=>({user:null,permissions:null,isAuthenticated:false,isLoading:true,error:null,setUser:(t,r=null)=>e({user:t,permissions:r,isAuthenticated:!!t,isLoading:false,error:null}),setLoading:t=>e({isLoading:t}),setError:t=>e({error:t,isLoading:false,isAuthenticated:false,user:null,permissions:null}),logout:()=>e({user:null,permissions:null,isAuthenticated:false,isLoading:false,error:null})}));var Xt=zustand.create(e=>({toasts:[],addToast:(t,r)=>{let o=Math.random().toString(36).substring(7);e(a=>({toasts:[...a.toasts,{id:o,type:t,message:r}]}));},removeToast:t=>e(r=>({toasts:r.toasts.filter(o=>o.id!==t)})),clearToasts:()=>e({toasts:[]})})),V={success:e=>Xt.getState().addToast("success",e),error:e=>Xt.getState().addToast("error",e),warning:e=>Xt.getState().addToast("warning",e),info:e=>Xt.getState().addToast("info",e)};zustand.create()(middleware.persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var yt=zustand.create(e=>({sidebarOpen:true,toggleSidebar:()=>e(t=>({sidebarOpen:!t.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),modal:{open:false,config:null},confirm:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default"}}}),alert:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default",confirmLabel:t.confirmLabel||"OK",onConfirm:()=>e(r=>({modal:{...r.modal,open:false}}))}}}),closeModal:()=>e(t=>({modal:{...t.modal,open:false},activeModal:null})),activeModal:null,openModal:t=>e({activeModal:t})}));zustand.create(e=>({editor:null,setEditor:t=>e({editor:t}),blockDrawerOpen:false,openBlockDrawer:t=>e({blockDrawerOpen:true,pendingInsert:{pos:null,column:t?.targetColumn??null}}),closeBlockDrawer:()=>e({blockDrawerOpen:false,pendingInsert:{pos:null,column:null}}),toggleBlockDrawer:()=>e(t=>({blockDrawerOpen:!t.blockDrawerOpen})),selectedBlock:null,setSelectedBlock:t=>e({selectedBlock:t}),pendingInsert:{pos:null,column:null},setPendingInsert:(t,r)=>e({pendingInsert:{pos:t,column:r??null}}),clearPendingInsert:()=>e({pendingInsert:{pos:null,column:null}})}));zustand.create((e,t)=>({cache:{},setCache:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:o,loading:false,error:null,lastFetch:Date.now()}}})),setLoading:(r,o)=>e(a=>({cache:{...a.cache,[r]:{...a.cache[r],loading:o,error:null}}})),setError:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:null,loading:false,error:o,lastFetch:null}}})),getCache:r=>t().cache[r]||null,invalidateCache:r=>e(o=>{if(r){let{[r]:a,...n}=o.cache;return {cache:n}}return {cache:{}}})}));var Su="/api/auth/refresh";async function Ei(){try{return (await fetch(qe(Su),{method:"POST",credentials:"include"})).ok}catch{return false}}async function lt(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(qe(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await Ei()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(qe(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function Ee(e,t){let{autoToast:r=true,...o}=t||{},a=await lt(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&V.error(n),new Error(n)}return a.json()}async function dt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await lt(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let i=await n.json();i.error&&(s=i.error);}catch{}throw o&&V.error(s),new Error(s)}return n.json()}async function Yt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await lt(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let i=await n.json();i.error&&(s=i.error);}catch{}throw o&&V.error(s),new Error(s)}return n.json()}async function At(e,t){let{autoToast:r=true,...o}={},a=await lt(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let i=await a.json();i.error&&(s=i.error);}catch{}throw r&&V.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function Kr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function nn(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function sn(e,t,r){if(!r){let o=await lt(e,{method:"POST",body:t});if(!o.ok)throw new Error(`Upload Error: ${o.status}`);return o.json()}return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("POST",qe(e)),n.withCredentials=true,n.upload.addEventListener("progress",s=>{s.lengthComputable&&r(Math.round(s.loaded/s.total*100));}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{o(JSON.parse(n.responseText));}catch{a(new Error("Invalid JSON response"));}else n.status===401?Ei().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let i=new XMLHttpRequest;i.open("POST",qe(e)),i.withCredentials=true,i.upload.addEventListener("progress",l=>{l.lengthComputable&&r(Math.round(l.loaded/l.total*100));}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{o(JSON.parse(i.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${i.status}`));}),i.addEventListener("error",()=>a(new Error("Network error"))),i.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function ar({size:e="md",className:t=""}){return jsxRuntime.jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}function jt({variant:e,count:t=1,className:r=""}){let o={text:"h-3 rounded-md",circle:"size-10 rounded-full",rect:"h-10 rounded-xl",card:"h-32 rounded-2xl","table-row":"h-14 rounded-xl","media-card":"aspect-square rounded-2xl","stat-card":"h-24 rounded-2xl"};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:Array.from({length:t}).map((a,n)=>jsxRuntime.jsx("div",{className:`kyro-shimmer ${o[e]} ${r}`},n))})}function bl({back:e}){return e.href?jsxRuntime.jsx("a",{href:e.href,onClick:t=>{e.onClick&&(t.preventDefault(),e.onClick());},className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}):jsxRuntime.jsx("button",{type:"button",onClick:e.onClick,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})})}function Du({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[r>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),t.href||t.onClick?jsxRuntime.jsx("a",{href:t.href,onClick:o=>{t.onClick&&(o.preventDefault(),t.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:t.label}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:t.label})]},r))}function xl({actions:e}){return Array.isArray(e)?jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>{let o=`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all ${t.variant==="outline"?"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":t.variant==="ghost"?"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] shadow-none":"kyro-btn-primary hover:opacity-90"} ${t.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${t.className||""}`;return t.href&&!t.disabled?jsxRuntime.jsxs("a",{href:t.href,className:o,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r):jsxRuntime.jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:o,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r)})}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function kl({action:e}){let t=`kyro-btn kyro-btn-primary flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`;return e.href&&!e.disabled?jsxRuntime.jsxs("a",{href:e.href,className:t,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]}):jsxRuntime.jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:t,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function Lt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:i,children:l}){let d=o?.[o.length-1];return jsxRuntime.jsxs("div",{className:"surface-tile px-3 md:px-6 py-3 md:pt-4 mb-4 md:mb-8",children:[jsxRuntime.jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n&&jsxRuntime.jsx(bl,{back:n}),jsxRuntime.jsxs("details",{className:"group [&::-webkit-details-marker]:hidden flex-1 min-w-0",children:[jsxRuntime.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[jsxRuntime.jsx("span",{className:"flex-1 text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] truncate",children:d?.label||""}),jsxRuntime.jsx("svg",{className:"w-3 h-3 text-[var(--kyro-text-secondary)] opacity-40 group-open:rotate-180 transition-transform",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--kyro-border)] space-y-2",children:[o&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o.map((c,u)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[u>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsxRuntime.jsx("a",{href:c.href,onClick:m=>{c.onClick&&(m.preventDefault(),c.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:c.label}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:c.label})]},u))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,u)=>jsxRuntime.jsx(Ta__default.default.Fragment,{children:c},u))}),l]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r&&jsxRuntime.jsx(r,{className:"w-5 h-5 text-[var(--kyro-primary)] shrink-0"}),e&&jsxRuntime.jsx("h1",{className:"text-lg font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e}),a&&!t&&jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full bg-[var(--kyro-primary)] shrink-0"})]}),t&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0 text-xs",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[u===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))})]})]}),jsxRuntime.jsxs("div",{className:"hidden md:flex md:flex-row md:items-center justify-between gap-6",children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n&&jsxRuntime.jsx(bl,{back:n}),o&&jsxRuntime.jsx(Du,{breadcrumbs:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[r&&jsxRuntime.jsx(r,{className:"w-6 h-6 text-[var(--kyro-primary)]"}),e&&jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e})]}),(t||a)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-1",children:[t&&jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[u===0&&(t||u>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))}),l]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[i&&jsxRuntime.jsx(xl,{actions:i}),s&&jsxRuntime.jsx(kl,{action:s})]})]}),(i||s)&&jsxRuntime.jsxs("div",{className:"md:hidden flex items-center gap-2 mt-3 pt-3 border-t border-[var(--kyro-border)]",children:[s&&jsxRuntime.jsx(kl,{action:s}),i&&jsxRuntime.jsx(xl,{actions:i})]})]})}var Pu={draft:{class:"bg-gray-100 text-gray-600",label:"Draft"},published:{class:"bg-green-100 text-green-700",label:"Published"},scheduled:{class:"bg-blue-100 text-blue-700",label:"Scheduled"},archived:{class:"bg-yellow-100 text-yellow-700",label:"Archived"},active:{class:"bg-green-100 text-green-700",label:"Active"},inactive:{class:"bg-gray-100 text-gray-600",label:"Inactive"},pending:{class:"bg-yellow-100 text-yellow-700",label:"Pending"},completed:{class:"bg-green-100 text-green-700",label:"Completed"},cancelled:{class:"bg-red-100 text-red-700",label:"Cancelled"}};function Rt({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=Pu[n],i=s?s.class:`kyro-badge-${n}`;return jsxRuntime.jsxs("span",{className:`kyro-badge ${i} ${r}`,children:[a&&jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1.5 opacity-60"}),o||s?.label||n]})}function Rs({count:e,max:t=99}){return e===0?null:jsxRuntime.jsx("span",{className:"inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 text-xs font-medium bg-gray-200 text-gray-700 rounded-full",children:e>t?`${t}+`:e})}function Is({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let i="kyro-btn",l=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${i} ${l} ${d} ${a}`,disabled:n||r,...s,children:[r?jsxRuntime.jsx("span",{className:"kyro-btn-loading",children:jsxRuntime.jsx("svg",{className:"kyro-btn-spinner",viewBox:"0 0 24 24",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"60 30"})})}):null,jsxRuntime.jsx("span",{className:r?"kyro-btn-text-hidden":"",children:o})]})}function wl({page:e,totalPages:t,totalDocs:r,limit:o,onPageChange:a,onLimitChange:n}){return t<=1?null:jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 px-4 py-3 border-t border-[var(--kyro-border)]",children:[r!==void 0&&o?jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Showing ",(e-1)*o+1," to ",Math.min(e*o,r)," of ",r]}):jsxRuntime.jsx("span",{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[n&&jsxRuntime.jsxs("select",{value:o,onChange:s=>n(Number(s.target.value)),className:"text-xs border border-[var(--kyro-border)] rounded-lg px-2 py-1 bg-[var(--kyro-bg)] text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("option",{value:10,children:"10/page"}),jsxRuntime.jsx("option",{value:25,children:"25/page"}),jsxRuntime.jsx("option",{value:50,children:"50/page"}),jsxRuntime.jsx("option",{value:100,children:"100/page"})]}),jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Page ",e," of ",t]}),jsxRuntime.jsxs("div",{className:"flex gap-1",children:[jsxRuntime.jsx(Is,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(Is,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}var Nl={actions:{cancel:"Cancel",create:"Create {{item}}",delete:"Delete",deleteDocument:"Delete Document",deleteEntry:"Delete Entry",deleting:"Deleting...",duplicateDocument:"Duplicate Document",duplicating:"Duplicating...",edit:"Edit",new:"New",newDocument:"New Document",signOut:"Sign Out",view:"View"},common:{na:"N/A",no:"No",yes:"Yes"},dashboard:{activeUsers:"Active Users",authService:"Auth Service",cloudApi:"Cloud API",contentGrowth:"Content Growth",contentGrowthDesc:"Snapshot of document velocity over the last 7 days",dbNode:"Database Node",description:"Everything looks great in your command center today.",mediaAssets:"Media Assets",mediaCdn:"Media CDN",mediaLibrary:"Media Library",mediaLibraryDesc:"Manage high-fidelity assets with our liquid masonry gallery.",newAction:"New {{item}}",noCollections:"No collections available for creation.",openAssets:"Open Assets",quickLinks:"Quick Links",recentActivity:"Recent Activity",statusActive:"Active",statusHealthy:"Healthy",statusOptimal:"Optimal",statusSecure:"Secure",systemHealth:"System Health",systemStatus:"System Status",totalContent:"Total Content",viewAuditLogs:"View Audit Logs",welcome:"Welcome back, {{name}}"},days:{fri:"Fri",mon:"Mon",sat:"Sat",sun:"Sun",thu:"Thu",tue:"Tue",wed:"Wed"},detailView:{collections:"Collections",coreConfiguration:"Core Configuration",dateCreated:"Date Created",deleteMessage:"This action cannot be undone.",deleteTitle:"Delete {{label}}?",dynamicStatus:"Dynamic Status",generatingPreview:"Generating preview URL...",globals:"Globals",justNow:"Just now",lastModified:"Last Modified",metadata:"Metadata",newDocument:"New {{label}}",openPreview:"Open Preview in New Tab",publicAt:"Public At",quickLinks:"Quick Links"},listView:{actionsCol:"Actions",addFilter:"Add Filter",advancedFilters:"Advanced Filters",clearAll:"Clear All",columns:"Columns",createdCol:"Created",deleteBulkMessage_one:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkMessage_other:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkTitle:"Delete Documents",deleteMessage:"Are you sure you want to delete this document? This cannot be undone.",deleteSelected:"Delete Selected",deleteTitle:"Delete Document",filters:"Filters",getStartedCreate:"Get started by creating your first {{item}}.",lastModifiedCol:"Last Modified",noDocuments:"No documents found",noFilters:'No filters applied. Click "Add Filter" to create one.',searchPlaceholder:"Search...",selectedCount_one:"{{count}} selected",selectedCount_other:"{{count}} selected",toggleColumns:"Toggle Columns",tryAdjustingFilters:"Try adjusting your filters or search query."},login:{confirmPassword:"Confirm Password",createAccount:"Create Account",createAccountDesc:"Create an account to access the admin",createAdminAccount:"Create Admin Account",creatingAccount:"Creating account...",email:"Email",enterCredentials:"Enter your credentials to access the admin",hasAccount:"Already have an account?",noAccount:"Don't have an account?",password:"Password",setupAdmin:"Set up your admin account to get started",signIn:"Sign In",signInAction:"Sign in",signingIn:"Signing in...",signUp:"Sign up"},nav:{dashboard:"Dashboard",media:"Media",users:"Users",plugins:"Plugins",settings:"Settings",content:"Content",developer:"Developer",resources:"Resources"},sidebar:{darkMode:"Dark Mode",lightMode:"Light Mode"},toast:{accountCreated:"Account created!",connectionFailed:"Connection failed",copyError:"Failed to copy document data",dataCopied:"Document data copied to clipboard",dataPasted:"Document data pasted",draftSaved:"Draft saved",duplicated:"Document duplicated",duplicateError:"Failed to duplicate document",pasteError:"Clipboard does not contain valid document JSON",published:"Published successfully",publishError:"Failed to publish",saveError:"Failed to save changes",unpublished:"Document unpublished",unpublishError:"Failed to unpublish",updated:"Updated",welcomeBack:"Welcome back!"},userMenu:{account:"Account",apiExplorer:"API Explorer",apiKeys:"API Keys",auditLogs:"Audit Logs",developer:"Developer",documentation:"Documentation",getSupport:"Get Support",graphqlPlayground:"GraphQL Playground",permissions:"Permissions",profileSettings:"Profile Settings",resources:"Resources",sessions:"Sessions",webHooks:"Web Hooks"}};var Cl={actions:{cancel:"Annuler",create:"Cr\xE9er {{item}}",delete:"Supprimer",deleteDocument:"Supprimer le document",deleteEntry:"Supprimer l'entr\xE9e",deleting:"Suppression...",duplicateDocument:"Dupliquer le document",duplicating:"Duplication...",edit:"Modifier",new:"Nouveau",newDocument:"Nouveau Document",signOut:"D\xE9connexion",view:"Voir"},common:{na:"N/D",no:"Non",yes:"Oui"},dashboard:{activeUsers:"Utilisateurs Actifs",authService:"Service d'Authentification",cloudApi:"API Cloud",contentGrowth:"Croissance du Contenu",contentGrowthDesc:"Aper\xE7u de la vitesse des documents sur les 7 derniers jours",dbNode:"N\u0153ud de Base de Donn\xE9es",description:"Tout semble parfait dans votre centre de contr\xF4le aujourd'hui.",mediaAssets:"Ressources Multim\xE9dias",mediaCdn:"CDN Multim\xE9dia",mediaLibrary:"M\xE9diath\xE8que",mediaLibraryDesc:"G\xE9rez des ressources haute fid\xE9lit\xE9 avec notre galerie fluide.",newAction:"Nouveau {{item}}",noCollections:"Aucune collection disponible \xE0 cr\xE9er.",openAssets:"Ouvrir les Ressources",quickLinks:"Liens Rapides",recentActivity:"Activit\xE9 R\xE9cente",statusActive:"Actif",statusHealthy:"Sain",statusOptimal:"Optimal",statusSecure:"S\xE9curis\xE9",systemHealth:"Sant\xE9 du Syst\xE8me",systemStatus:"\xC9tat du Syst\xE8me",totalContent:"Contenu Total",viewAuditLogs:"Voir les Journaux d'Audit",welcome:"Bon retour, {{name}}"},days:{fri:"Ven",mon:"Lun",sat:"Sam",sun:"Dim",thu:"Jeu",tue:"Mar",wed:"Mer"},detailView:{collections:"Collections",coreConfiguration:"Configuration Principale",dateCreated:"Date de Cr\xE9ation",deleteMessage:"Cette action est irr\xE9versible.",deleteTitle:"Supprimer {{label}} ?",dynamicStatus:"Statut Dynamique",generatingPreview:"G\xE9n\xE9ration de l'URL d'aper\xE7u...",globals:"Variables Globales",justNow:"\xC0 l'instant",lastModified:"Derni\xE8re Modification",metadata:"M\xE9tadonn\xE9es",newDocument:"Nouveau {{label}}",openPreview:"Ouvrir l'Aper\xE7u",publicAt:"Public \xE0",quickLinks:"Liens Rapides"},listView:{actionsCol:"Actions",addFilter:"Ajouter un Filtre",advancedFilters:"Filtres Avanc\xE9s",clearAll:"Tout Effacer",columns:"Colonnes",createdCol:"Cr\xE9\xE9",deleteBulkMessage_one:"Voulez-vous vraiment supprimer {{count}} document ? C'est irr\xE9versible.",deleteBulkMessage_other:"Voulez-vous vraiment supprimer {{count}} documents ? C'est irr\xE9versible.",deleteBulkTitle:"Supprimer des Documents",deleteMessage:"Voulez-vous vraiment supprimer ce document ? C'est irr\xE9versible.",deleteSelected:"Supprimer la S\xE9lection",deleteTitle:"Supprimer le Document",filters:"Filtres",getStartedCreate:"Commencez par cr\xE9er votre premier {{item}}.",lastModifiedCol:"Derni\xE8re Modification",noDocuments:"Aucun document trouv\xE9",noFilters:'Aucun filtre appliqu\xE9. Cliquez sur "Ajouter un Filtre" pour en cr\xE9er un.',searchPlaceholder:"Rechercher...",selectedCount_one:"{{count}} s\xE9lectionn\xE9",selectedCount_other:"{{count}} s\xE9lectionn\xE9s",toggleColumns:"Afficher/Masquer les Colonnes",tryAdjustingFilters:"Essayez de modifier vos filtres ou votre requ\xEAte de recherche."},login:{confirmPassword:"Confirmer le Mot de Passe",createAccount:"Cr\xE9er un Compte",createAccountDesc:"Cr\xE9ez un compte pour acc\xE9der \xE0 l'administration",createAdminAccount:"Cr\xE9er un Compte Administrateur",creatingAccount:"Cr\xE9ation du compte...",email:"Email",enterCredentials:"Entrez vos identifiants pour acc\xE9der \xE0 l'administration",hasAccount:"Vous avez d\xE9j\xE0 un compte ?",noAccount:"Vous n'avez pas de compte ?",password:"Mot de Passe",setupAdmin:"Configurez votre compte administrateur pour commencer",signIn:"Se Connecter",signInAction:"Se connecter",signingIn:"Connexion...",signUp:"S'inscrire"},nav:{content:"Contenu",dashboard:"Tableau de Bord",developer:"D\xE9veloppeur",media:"M\xE9dias",plugins:"Extensions",resources:"Ressources",settings:"Param\xE8tres",users:"Utilisateurs"},sidebar:{darkMode:"Mode Sombre",lightMode:"Mode Clair"},toast:{accountCreated:"Compte cr\xE9\xE9 !",connectionFailed:"\xC9chec de la connexion",copyError:"\xC9chec de la copie des donn\xE9es",dataCopied:"Donn\xE9es copi\xE9es dans le presse-papiers",dataPasted:"Donn\xE9es coll\xE9es",draftSaved:"Brouillon enregistr\xE9",duplicated:"Document dupliqu\xE9",duplicateError:"\xC9chec de la duplication du document",pasteError:"Le presse-papiers ne contient pas de JSON valide",published:"Publi\xE9 avec succ\xE8s",publishError:"\xC9chec de la publication",saveError:"\xC9chec de l'enregistrement",unpublished:"Document d\xE9publi\xE9",unpublishError:"\xC9chec de la d\xE9publication",updated:"Mise \xE0 jour r\xE9ussie",welcomeBack:"Bon retour !"},userMenu:{account:"Compte",apiExplorer:"Explorateur d'API",apiKeys:"Cl\xE9s d'API",auditLogs:"Journaux d'Audit",developer:"D\xE9veloppeur",documentation:"Documentation",getSupport:"Obtenir de l'Aide",graphqlPlayground:"Playground GraphQL",permissions:"Permissions",profileSettings:"Param\xE8tres du Profil",resources:"Ressources",sessions:"Sessions",webHooks:"Webhooks"}};var Sl={actions:{cancel:"Cancelar",create:"Crear {{item}}",delete:"Eliminar",deleteDocument:"Eliminar Documento",deleteEntry:"Eliminar Entrada",deleting:"Eliminando...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Nuevo",newDocument:"Nuevo Documento",signOut:"Cerrar Sesi\xF3n",view:"Ver"},common:{na:"N/D",no:"No",yes:"S\xED"},dashboard:{activeUsers:"Usuarios Activos",authService:"Servicio de Autenticaci\xF3n",cloudApi:"API en la Nube",contentGrowth:"Crecimiento de Contenido",contentGrowthDesc:"Instant\xE1nea de la velocidad de los documentos en los \xFAltimos 7 d\xEDas",dbNode:"Nodo de Base de Datos",description:"Todo se ve genial en tu centro de comando hoy.",mediaAssets:"Recursos Multimedia",mediaCdn:"CDN Multimedia",mediaLibrary:"Biblioteca Multimedia",mediaLibraryDesc:"Administre recursos de alta fidelidad con nuestra galer\xEDa fluida.",newAction:"Nuevo {{item}}",noCollections:"No hay colecciones disponibles para crear.",openAssets:"Abrir Recursos",quickLinks:"Enlaces R\xE1pidos",recentActivity:"Actividad Reciente",statusActive:"Activo",statusHealthy:"Saludable",statusOptimal:"\xD3ptimo",statusSecure:"Seguro",systemHealth:"Salud del Sistema",systemStatus:"Estado del Sistema",totalContent:"Contenido Total",viewAuditLogs:"Ver Registros de Auditor\xEDa",welcome:"Bienvenido, {{name}}"},days:{fri:"Vie",mon:"Lun",sat:"S\xE1b",sun:"Dom",thu:"Jue",tue:"Mar",wed:"Mi\xE9"},detailView:{collections:"Colecciones",coreConfiguration:"Configuraci\xF3n Principal",dateCreated:"Fecha de Creaci\xF3n",deleteMessage:"Esta acci\xF3n no se puede deshacer.",deleteTitle:"\xBFEliminar {{label}}?",dynamicStatus:"Estado Din\xE1mico",generatingPreview:"Generando URL de vista previa...",globals:"Variables Globales",justNow:"Justo ahora",lastModified:"\xDAltima Modificaci\xF3n",metadata:"Metadatos",newDocument:"Nuevo {{label}}",openPreview:"Abrir Vista Previa",publicAt:"P\xFAblico a las",quickLinks:"Enlaces R\xE1pidos"},listView:{actionsCol:"Acciones",addFilter:"A\xF1adir Filtro",advancedFilters:"Filtros Avanzados",clearAll:"Borrar Todo",columns:"Columnas",createdCol:"Creado",deleteBulkMessage_one:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documento? Esto no se puede deshacer.",deleteBulkMessage_other:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documentos? Esto no se puede deshacer.",deleteBulkTitle:"Eliminar Documentos",deleteMessage:"\xBFEst\xE1s seguro de que quieres eliminar este documento? Esto no se puede deshacer.",deleteSelected:"Eliminar Selecci\xF3n",deleteTitle:"Eliminar Documento",filters:"Filtros",getStartedCreate:"Comienza creando tu primer {{item}}.",lastModifiedCol:"\xDAltima Modificaci\xF3n",noDocuments:"No se encontraron documentos",noFilters:'No hay filtros aplicados. Haz clic en "A\xF1adir Filtro" para crear uno.',searchPlaceholder:"Buscar...",selectedCount_one:"{{count}} seleccionado",selectedCount_other:"{{count}} seleccionados",toggleColumns:"Mostrar/Ocultar Columnas",tryAdjustingFilters:"Intenta ajustar tus filtros o consulta de b\xFAsqueda."},login:{confirmPassword:"Confirmar Contrase\xF1a",createAccount:"Crear Cuenta",createAccountDesc:"Crea una cuenta para acceder a la administraci\xF3n",createAdminAccount:"Crear Cuenta de Administrador",creatingAccount:"Creando cuenta...",email:"Correo Electr\xF3nico",enterCredentials:"Ingresa tus credenciales para acceder a la administraci\xF3n",hasAccount:"\xBFYa tienes una cuenta?",noAccount:"\xBFNo tienes una cuenta?",password:"Contrase\xF1a",setupAdmin:"Configura tu cuenta de administrador para empezar",signIn:"Iniciar Sesi\xF3n",signInAction:"Iniciar sesi\xF3n",signingIn:"Iniciando sesi\xF3n...",signUp:"Registrarse"},nav:{content:"Contenido",dashboard:"Panel de Control",developer:"Desarrollador",media:"Multimedia",plugins:"Complementos",resources:"Recursos",settings:"Ajustes",users:"Usuarios"},sidebar:{darkMode:"Modo Oscuro",lightMode:"Modo Claro"},toast:{accountCreated:"\xA1Cuenta creada!",connectionFailed:"Error de conexi\xF3n",copyError:"Error al copiar los datos del documento",dataCopied:"Datos del documento copiados al portapapeles",dataPasted:"Datos del documento pegados",draftSaved:"Borrador guardado",duplicated:"Documento duplicado",duplicateError:"Error al duplicar el documento",pasteError:"El portapapeles no contiene un JSON de documento v\xE1lido",published:"Publicado con \xE9xito",publishError:"Error al publicar",saveError:"Error al guardar los cambios",unpublished:"Documento despublicado",unpublishError:"Error al despublicar",updated:"Actualizado",welcomeBack:"\xA1Bienvenido de nuevo!"},userMenu:{account:"Cuenta",apiExplorer:"Explorador de API",apiKeys:"Claves de API",auditLogs:"Registros de Auditor\xEDa",developer:"Desarrollador",documentation:"Documentaci\xF3n",getSupport:"Obtener Soporte",graphqlPlayground:"Playground de GraphQL",permissions:"Permisos",profileSettings:"Ajustes de Perfil",resources:"Recursos",sessions:"Sesiones",webHooks:"Webhooks"}};var Al={actions:{cancel:"Abbrechen",create:"{{item}} Erstellen",delete:"L\xF6schen",deleteDocument:"Dokument L\xF6schen",deleteEntry:"Eintrag L\xF6schen",deleting:"Wird gel\xF6scht...",duplicateDocument:"Dokument Duplizieren",duplicating:"Wird dupliziert...",edit:"Bearbeiten",new:"Neu",newDocument:"Neues Dokument",signOut:"Abmelden",view:"Ansehen"},common:{na:"k.A.",no:"Nein",yes:"Ja"},dashboard:{activeUsers:"Aktive Benutzer",authService:"Authentifizierungsdienst",cloudApi:"Cloud API",contentGrowth:"Inhaltswachstum",contentGrowthDesc:"\xDCbersicht der Dokumentgeschwindigkeit in den letzten 7 Tagen",dbNode:"Datenbankknoten",description:"Alles sieht in Ihrer Kommandozentrale heute gro\xDFartig aus.",mediaAssets:"Medieninhalte",mediaCdn:"Medien CDN",mediaLibrary:"Mediathek",mediaLibraryDesc:"Verwalten Sie hochaufl\xF6sende Assets mit unserer fl\xFCssigen Galerie.",newAction:"Neues {{item}}",noCollections:"Keine Sammlungen zur Erstellung verf\xFCgbar.",openAssets:"Assets \xD6ffnen",quickLinks:"Schnellzugriff",recentActivity:"Letzte Aktivit\xE4ten",statusActive:"Aktiv",statusHealthy:"Gesund",statusOptimal:"Optimal",statusSecure:"Sicher",systemHealth:"Systemgesundheit",systemStatus:"Systemstatus",totalContent:"Gesamter Inhalt",viewAuditLogs:"Audit-Protokolle ansehen",welcome:"Willkommen zur\xFCck, {{name}}"},days:{fri:"Fr",mon:"Mo",sat:"Sa",sun:"So",thu:"Do",tue:"Di",wed:"Mi"},detailView:{collections:"Sammlungen",coreConfiguration:"Kernkonfiguration",dateCreated:"Erstellungsdatum",deleteMessage:"Diese Aktion kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteTitle:"{{label}} l\xF6schen?",dynamicStatus:"Dynamischer Status",generatingPreview:"Vorschau-URL wird generiert...",globals:"Globale Variablen",justNow:"Gerade eben",lastModified:"Zuletzt Ge\xE4ndert",metadata:"Metadaten",newDocument:"Neues {{label}}",openPreview:"Vorschau in neuem Tab \xF6ffnen",publicAt:"\xD6ffentlich um",quickLinks:"Schnellzugriff"},listView:{actionsCol:"Aktionen",addFilter:"Filter hinzuf\xFCgen",advancedFilters:"Erweiterte Filter",clearAll:"Alles l\xF6schen",columns:"Spalten",createdCol:"Erstellt",deleteBulkMessage_one:"Sind Sie sicher, dass Sie {{count}} Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkMessage_other:"Sind Sie sicher, dass Sie {{count}} Dokumente l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkTitle:"Dokumente L\xF6schen",deleteMessage:"Sind Sie sicher, dass Sie dieses Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteSelected:"Auswahl l\xF6schen",deleteTitle:"Dokument l\xF6schen",filters:"Filter",getStartedCreate:"Beginnen Sie mit der Erstellung Ihres ersten {{item}}.",lastModifiedCol:"Zuletzt Ge\xE4ndert",noDocuments:"Keine Dokumente gefunden",noFilters:'Keine Filter angewendet. Klicken Sie auf "Filter hinzuf\xFCgen", um einen zu erstellen.',searchPlaceholder:"Suchen...",selectedCount_one:"{{count}} ausgew\xE4hlt",selectedCount_other:"{{count}} ausgew\xE4hlt",toggleColumns:"Spalten umschalten",tryAdjustingFilters:"Versuchen Sie, Ihre Filter oder die Suchanfrage anzupassen."},login:{confirmPassword:"Passwort best\xE4tigen",createAccount:"Konto erstellen",createAccountDesc:"Erstellen Sie ein Konto, um auf die Verwaltung zuzugreifen",createAdminAccount:"Admin-Konto erstellen",creatingAccount:"Konto wird erstellt...",email:"E-Mail",enterCredentials:"Geben Sie Ihre Anmeldedaten ein, um auf die Verwaltung zuzugreifen",hasAccount:"Haben Sie bereits ein Konto?",noAccount:"Sie haben noch kein Konto?",password:"Passwort",setupAdmin:"Richten Sie Ihr Admin-Konto ein, um loszulegen",signIn:"Anmelden",signInAction:"Anmelden",signingIn:"Wird angemeldet...",signUp:"Registrieren"},nav:{content:"Inhalt",dashboard:"Dashboard",developer:"Entwickler",media:"Medien",plugins:"Plugins",resources:"Ressourcen",settings:"Einstellungen",users:"Benutzer"},sidebar:{darkMode:"Dunkler Modus",lightMode:"Heller Modus"},toast:{accountCreated:"Konto erstellt!",connectionFailed:"Verbindung fehlgeschlagen",copyError:"Fehler beim Kopieren der Dokumentdaten",dataCopied:"Dokumentdaten in die Zwischenablage kopiert",dataPasted:"Dokumentdaten eingef\xFCgt",draftSaved:"Entwurf gespeichert",duplicated:"Dokument dupliziert",duplicateError:"Fehler beim Duplizieren des Dokuments",pasteError:"Die Zwischenablage enth\xE4lt kein g\xFCltiges Dokument-JSON",published:"Erfolgreich ver\xF6ffentlicht",publishError:"Fehler beim Ver\xF6ffentlichen",saveError:"Fehler beim Speichern der \xC4nderungen",unpublished:"Ver\xF6ffentlichung r\xFCckg\xE4ngig gemacht",unpublishError:"Fehler beim R\xFCckg\xE4ngigmachen der Ver\xF6ffentlichung",updated:"Aktualisiert",welcomeBack:"Willkommen zur\xFCck!"},userMenu:{account:"Konto",apiExplorer:"API Explorer",apiKeys:"API-Schl\xFCssel",auditLogs:"Audit-Protokolle",developer:"Entwickler",documentation:"Dokumentation",getSupport:"Hilfe erhalten",graphqlPlayground:"GraphQL Playground",permissions:"Berechtigungen",profileSettings:"Profileinstellungen",resources:"Ressourcen",sessions:"Sitzungen",webHooks:"Webhooks"}};var Dl={actions:{cancel:"Cancelar",create:"Criar {{item}}",delete:"Excluir",deleteDocument:"Excluir Documento",deleteEntry:"Excluir Entrada",deleting:"Excluindo...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Novo",newDocument:"Novo Documento",signOut:"Sair",view:"Ver"},common:{na:"N/A",no:"N\xE3o",yes:"Sim"},dashboard:{activeUsers:"Usu\xE1rios Ativos",authService:"Servi\xE7o de Autentica\xE7\xE3o",cloudApi:"API em Nuvem",contentGrowth:"Crescimento de Conte\xFAdo",contentGrowthDesc:"Vis\xE3o geral da velocidade dos documentos nos \xFAltimos 7 dias",dbNode:"N\xF3 de Banco de Dados",description:"Tudo parece \xF3timo no seu centro de comando hoje.",mediaAssets:"Ativos de M\xEDdia",mediaCdn:"CDN de M\xEDdia",mediaLibrary:"Biblioteca de M\xEDdia",mediaLibraryDesc:"Gerencie ativos de alta fidelidade com nossa galeria fluida.",newAction:"Novo {{item}}",noCollections:"Nenhuma cole\xE7\xE3o dispon\xEDvel para cria\xE7\xE3o.",openAssets:"Abrir Ativos",quickLinks:"Links R\xE1pidos",recentActivity:"Atividade Recente",statusActive:"Ativo",statusHealthy:"Saud\xE1vel",statusOptimal:"Ideal",statusSecure:"Seguro",systemHealth:"Sa\xFAde do Sistema",systemStatus:"Status do Sistema",totalContent:"Conte\xFAdo Total",viewAuditLogs:"Ver Registros de Auditoria",welcome:"Bem-vindo de volta, {{name}}"},days:{fri:"Sex",mon:"Seg",sat:"S\xE1b",sun:"Dom",thu:"Qui",tue:"Ter",wed:"Qua"},detailView:{collections:"Cole\xE7\xF5es",coreConfiguration:"Configura\xE7\xE3o Principal",dateCreated:"Data de Cria\xE7\xE3o",deleteMessage:"Esta a\xE7\xE3o n\xE3o pode ser desfeita.",deleteTitle:"Excluir {{label}}?",dynamicStatus:"Status Din\xE2mico",generatingPreview:"Gerando URL de visualiza\xE7\xE3o...",globals:"Vari\xE1veis Globais",justNow:"Agora mesmo",lastModified:"\xDAltima Modifica\xE7\xE3o",metadata:"Metadados",newDocument:"Novo {{label}}",openPreview:"Abrir Visualiza\xE7\xE3o em Nova Guia",publicAt:"P\xFAblico \xE0s",quickLinks:"Links R\xE1pidos"},listView:{actionsCol:"A\xE7\xF5es",addFilter:"Adicionar Filtro",advancedFilters:"Filtros Avan\xE7ados",clearAll:"Limpar Tudo",columns:"Colunas",createdCol:"Criado",deleteBulkMessage_one:"Tem certeza de que deseja excluir {{count}} documento? Isso n\xE3o pode ser desfeito.",deleteBulkMessage_other:"Tem certeza de que deseja excluir {{count}} documentos? Isso n\xE3o pode ser desfeito.",deleteBulkTitle:"Excluir Documentos",deleteMessage:"Tem certeza de que deseja excluir este documento? Isso n\xE3o pode ser desfeito.",deleteSelected:"Excluir Selecionados",deleteTitle:"Excluir Documento",filters:"Filtros",getStartedCreate:"Comece criando seu primeiro {{item}}.",lastModifiedCol:"\xDAltima Modifica\xE7\xE3o",noDocuments:"Nenhum documento encontrado",noFilters:'Nenhum filtro aplicado. Clique em "Adicionar Filtro" para criar um.',searchPlaceholder:"Pesquisar...",selectedCount_one:"{{count}} selecionado",selectedCount_other:"{{count}} selecionados",toggleColumns:"Alternar Colunas",tryAdjustingFilters:"Tente ajustar seus filtros ou a consulta de pesquisa."},login:{confirmPassword:"Confirmar Senha",createAccount:"Criar Conta",createAccountDesc:"Crie uma conta para acessar a administra\xE7\xE3o",createAdminAccount:"Criar Conta de Administrador",creatingAccount:"Criando conta...",email:"E-mail",enterCredentials:"Insira suas credenciais para acessar a administra\xE7\xE3o",hasAccount:"J\xE1 tem uma conta?",noAccount:"N\xE3o tem uma conta?",password:"Senha",setupAdmin:"Configure sua conta de administrador para come\xE7ar",signIn:"Entrar",signInAction:"Entrar",signingIn:"Entrando...",signUp:"Inscrever-se"},nav:{content:"Conte\xFAdo",dashboard:"Painel de Controle",developer:"Desenvolvedor",media:"M\xEDdia",plugins:"Plugins",resources:"Recursos",settings:"Configura\xE7\xF5es",users:"Usu\xE1rios"},sidebar:{darkMode:"Modo Escuro",lightMode:"Modo Claro"},toast:{accountCreated:"Conta criada!",connectionFailed:"Falha na conex\xE3o",copyError:"Falha ao copiar os dados do documento",dataCopied:"Dados do documento copiados para a \xE1rea de transfer\xEAncia",dataPasted:"Dados do documento colados",draftSaved:"Rascunho salvo",duplicated:"Documento duplicado",duplicateError:"Falha ao duplicar documento",pasteError:"A \xE1rea de transfer\xEAncia n\xE3o cont\xE9m um JSON de documento v\xE1lido",published:"Publicado com sucesso",publishError:"Falha ao publicar",saveError:"Falha ao salvar as altera\xE7\xF5es",unpublished:"Documento despublicado",unpublishError:"Falha ao despublicar",updated:"Atualizado",welcomeBack:"Bem-vindo de volta!"},userMenu:{account:"Conta",apiExplorer:"Explorador de API",apiKeys:"Chaves de API",auditLogs:"Registros de Auditoria",developer:"Desenvolvedor",documentation:"Documenta\xE7\xE3o",getSupport:"Obter Suporte",graphqlPlayground:"Playground GraphQL",permissions:"Permiss\xF5es",profileSettings:"Configura\xE7\xF5es de Perfil",resources:"Recursos",sessions:"Sess\xF5es",webHooks:"Webhooks"}};var zu={en:{translation:Nl},fr:{translation:Cl},es:{translation:Sl},de:{translation:Al},pt:{translation:Dl}},Tl=typeof window<"u"&&window.KYRO_LANG?window.KYRO_LANG:"en";$u__default.default.use(Ou__default.default).use(reactI18next.initReactI18next).init({resources:zu,fallbackLng:Tl,lng:Tl,interpolation:{escapeValue:false}});function ho(e,t,r){return r in t?t[r]:Bs(e,t,r)}function Bs(e,t,r){for(let o of e)if(o.name){if(o.type==="tabs"&&"tabs"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Bs(o.tabs?.flatMap(s=>s.fields||[])||[],a,r);if(n!==void 0)return n}}if((o.type==="group"||o.type==="collapsible")&&"fields"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Bs(o.fields||[],a,r);if(n!==void 0)return n}}}}function Ms({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let{t:i}=reactI18next.useTranslation(),l=t||e.slug,{permissions:d}=_r(),c=d?.collections?.[l]?.create!==false,u=d?.collections?.[l]?.delete!==false,m=d?.collections?.[l]?.update!==false,v=()=>{if(c)if(a)a();else {let B=`${Ue}/${l}/new`;import('astro:transitions/client').then(({navigate:X})=>{X(B);}).catch(()=>{window.location.href=B;});}},x=B=>{if(n)n(B);else {let X=`${Ue}/${l}/${B}`;import('astro:transitions/client').then(({navigate:ae})=>{ae(X);}).catch(()=>{window.location.href=X;});}},[g,f]=Ta.useState(r),[b,p]=Ta.useState(o),[h,A]=Ta.useState(false),[$,T]=Ta.useState(1),[k,y]=Ta.useState(10),[w,D]=Ta.useState(new Set),[U,O]=Ta.useState(""),[z,P]=Ta.useState([]),{confirm:R,alert:Ae}=yt(),E=()=>{P([...z,{field:"",operator:"equals",value:""}]);},oe=()=>{O(""),P([]),ye(null);},ie=B=>{P(z.filter((X,ae)=>ae!==B));},ee=(B,X)=>{P(z.map((ae,Jt)=>Jt===B?{...ae,...X}:ae));},[G,ye]=Ta.useState(null),[De,L]=Ta.useState(false),[W,re]=Ta.useState(false);function H(B){let X=[];for(let ae of B||[])if(!(!ae.name||ae.hidden===true||ae.admin?.hidden||ae.name==="id"))if(ae.type==="tabs"&&ae.tabs)for(let Jt of ae.tabs)Jt.fields&&X.push(...H(Jt.fields));else (ae.type==="row"||ae.type==="collapsible")&&ae.fields?X.push(...H(ae.fields)):X.push(ae);return X}let Te=Ta.useMemo(()=>H(e.fields),[e.fields]),fe=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:Te.find(B=>B.type!=="group"&&typeof B.name=="string")?.name,[we,S]=Ta.useState(()=>{let B;return e.admin?.defaultColumns?B=[...e.admin?.defaultColumns||[]]:B=Te.slice(0,4).map(X=>X.name).filter(X=>!!X),fe&&B.includes(fe)&&(B=[fe,...B.filter(X=>X!==fe)]),B.includes("updatedAt")||B.push("updatedAt"),new Set(B)}),j=Ta.useCallback(B=>{S(X=>{let ae=new Set(X);return ae.has(B)?ae.delete(B):ae.add(B),ae});},[]);function xe(B){let X=Te.find(ae=>ae.name===B);return X&&X.type==="group"&&X.fields?.[0]?.name?`${B}.${X.fields[0].name}`:B}let Le=Ta.useCallback(B=>{let X=xe(B);ye(ae=>ae&&ae.field===X?{field:X,direction:ae.direction==="asc"?"desc":"asc"}:{field:X,direction:"asc"});},[]),Be=Ta.useMemo(()=>{let B=[];for(let X of Array.from(we))if(X==="status")B.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]});else {let ae=Te.find(Jt=>Jt.name===X);ae&&ae.name&&B.push(ae);}return B},[Te,we]);function Pe(B){return !B.name||!fe?false:B.name===fe||B.type==="group"&&B.fields?.[0]?.name===fe}function ft(B,X){return X.name?ho(e.fields,B,X.name)??null:null}let qt=Ta.useCallback(async()=>{A(true);try{let B=new URLSearchParams({page:$.toString(),limit:k.toString()});U&&B.append("search",U),G&&B.append("sort",G.field),G&&B.append("order",G.direction),z.length>0&&B.append("filters",JSON.stringify(z));let X=await Ee(Kr(`/api/${l}?${B}`),{autoToast:!1});f(X.docs||[]),p(X.totalDocs||0);}catch(B){console.error("Failed to load docs:",B);}finally{A(false);}},[l,$,k,U,G,z]);Ta.useEffect(()=>{g.length===0&&o===0&&qt();},[]);let J=Ta.useRef(true);Ta.useEffect(()=>{if(J.current){J.current=false;return}qt();},[$,k,U,G,z]);let M=()=>{w.size===g.length?D(new Set):D(new Set(g.map(B=>B.id)));},K=B=>{let X=new Set(w);X.has(B)?X.delete(B):X.add(B),D(X);},le=()=>{R({title:i("listView.deleteBulkTitle",{defaultValue:"Delete Documents"}),message:i("listView.deleteBulkMessage",{defaultValue:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",count:w.size}),variant:"danger",onConfirm:async()=>{try{for(let B of Array.from(w))await At(`/api/${l}/${B}`);D(new Set),qt(),V.success("Documents deleted");}catch(B){console.error("Bulk delete failed:",B),V.error("Failed to delete some documents");}}});},Fe=B=>{R({title:i("listView.deleteTitle",{defaultValue:"Delete Document"}),message:i("listView.deleteMessage",{defaultValue:"Are you sure you want to delete this document? This cannot be undone."}),variant:"danger",onConfirm:async()=>{try{await At(`/api/${l}/${B}`),qt(),V.success("Document deleted");}catch(X){console.error("Delete failed:",X),V.error("Failed to delete document");}}});},Oe=Math.ceil(b/k),gt=U||z.length>0||G;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Lt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:b>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[b," documents"]},"count")]:void 0,action:c?{label:i("actions.create",{defaultValue:"Create {{item}}",item:e.singularLabel||e.label||l}),href:a?void 0:`${Ue}/${l}/new`,onClick:a?v:void 0,icon:Ql.Plus}:void 0}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:i("listView.searchPlaceholder",{defaultValue:"Search..."}),value:U,onChange:B=>O(B.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-sm font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>L(!De),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${De||z.length>0?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Ql.Filter,{className:"w-4 h-4"}),i("listView.filters",{defaultValue:"Filters"}),z.length>0&&jsxRuntime.jsx("span",{className:"ml-1 px-1.5 py-0.5 bg-[var(--kyro-sidebar-text-active)] text-[var(--kyro-sidebar-active)] rounded-full text-xs",children:z.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>re(!W),className:"flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",children:[jsxRuntime.jsx(Ql.Columns3,{className:"w-4 h-4"}),i("listView.columns",{defaultValue:"Columns"})]}),W&&jsxRuntime.jsxs("div",{className:"absolute right-0 top-full mt-2 w-56 surface-tile border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 overflow-hidden",children:[jsxRuntime.jsx("div",{className:"p-3 border-b border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-xs font-bold tracking-wider text-[var(--kyro-text-secondary)]",children:i("listView.toggleColumns",{defaultValue:"Toggle Columns"})})}),jsxRuntime.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:Te.map(B=>B.name?jsxRuntime.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:we.has(B.name),onChange:()=>j(B.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:B.label||B.name})]},B.name):null)})]})]}),gt&&jsxRuntime.jsx("button",{type:"button",onClick:oe,className:"px-4 py-2 rounded-xl font-bold text-sm text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 transition-all",children:i("listView.clearAll",{defaultValue:"Clear All"})})]})]}),De&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("h3",{className:"font-medium text-[var(--kyro-text-primary)]",children:i("listView.advancedFilters",{defaultValue:"Advanced Filters"})}),jsxRuntime.jsxs("button",{type:"button",onClick:E,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-bold text-[var(--kyro-sidebar-active)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),i("listView.addFilter",{defaultValue:"Add Filter"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[z.map((B,X)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:B.field,onChange:ae=>ee(X,{field:ae.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:Te.map(ae=>jsxRuntime.jsx("option",{value:ae.name,children:ae.label||ae.name},ae.name))}),jsxRuntime.jsxs("select",{value:B.operator,onChange:ae=>ee(X,{operator:ae.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("option",{value:"equals",children:"Equals"}),jsxRuntime.jsx("option",{value:"contains",children:"Contains"}),jsxRuntime.jsx("option",{value:"gt",children:"Greater than"}),jsxRuntime.jsx("option",{value:"lt",children:"Less than"}),jsxRuntime.jsx("option",{value:"gte",children:"Greater or equal"}),jsxRuntime.jsx("option",{value:"lte",children:"Less or equal"})]}),jsxRuntime.jsx("input",{type:"text",value:B.value,onChange:ae=>ee(X,{value:ae.target.value}),placeholder:i("fields.value",{defaultValue:"Value..."}),className:"flex-1 min-w-[150px] px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>ie(X),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]},X)),z.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:i("listView.noFilters",{defaultValue:'No filters applied. Click "Add Filter" to create one.'})})]})]}),w.size>0&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex items-center justify-between border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:i("listView.selectedCount",{defaultValue:"{{count}} selected",count:w.size})}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[u&&jsxRuntime.jsxs("button",{type:"button",onClick:le,className:"flex items-center gap-2 px-4 py-2 bg-red-500 text-white rounded-lg font-bold text-sm hover:bg-red-600 transition-all",children:[jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"}),i("listView.deleteSelected",{defaultValue:"Delete Selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>D(new Set),className:"px-4 py-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] font-bold text-sm transition-all",children:i("actions.cancel",{defaultValue:"Cancel"})})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden",children:h?jsxRuntime.jsx("div",{className:"space-y-2 p-4",children:jsxRuntime.jsx(jt,{variant:"table-row",count:8})}):g.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsxRuntime.jsx(Ql.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:i("listView.noDocuments",{defaultValue:"No documents found"})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:gt?i("listView.tryAdjustingFilters",{defaultValue:"Try adjusting your filters or search query."}):i("listView.getStartedCreate",{defaultValue:"Get started by creating your first {{item}}.",item:(e.singularLabel||e.label||l).toLowerCase()})}),!gt&&c&&jsxRuntime.jsxs("button",{type:"button",onClick:v,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),i("actions.create",{defaultValue:"Create {{item}}",item:String(e.singularLabel||e.label||l)})]})]}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[10px] tracking-[0.3em] border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-4 py-4 w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:w.size===g.length&&g.length>0,onChange:M,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Be.map(B=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Le(B.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[_u(Be,B.type)??(B.label||B.name),G&&G.field===B.name&&jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4"})]})},B.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:i("listView.createdCol",{defaultValue:"Created"})}):null,e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:i("listView.lastModifiedCol",{defaultValue:"Last Modified"})}):null,jsxRuntime.jsx("th",{className:"px-4 py-4 text-right",children:i("listView.actionsCol",{defaultValue:"Actions"})})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:g.map(B=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>x(B.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:X=>X.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:w.has(B.id),onChange:()=>K(B.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Be.map(X=>{let ae=ft(B,X),Jt=X.type==="select"&&ae&&Array.isArray(X.options)?X.options.find(fo=>fo.value===ae)?.label||ae:Hu(ae,X.type,i);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${Pe(X)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:Jt},X.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:B.createdAt?new Date(B.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:B.updatedAt?new Date(B.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:X=>X.stopPropagation(),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(B.id),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",title:m?i("actions.edit",{defaultValue:"Edit"}):i("actions.view",{defaultValue:"View"}),children:jsxRuntime.jsx(Ql.Pencil,{className:"w-4 h-4"})}),u&&jsxRuntime.jsx("button",{type:"button",onClick:()=>Fe(B.id),className:"inline-flex items-center justify-center w-8 h-8 rounded-md text-[var(--kyro-text-muted)] hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-500/10 transition-colors",title:i("actions.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"})})]})})]},B.id))})]})})}),jsxRuntime.jsx(wl,{page:$,totalPages:Oe,totalDocs:b,limit:k,onPageChange:T,onLimitChange:B=>{y(B),T(1);}})]})}function Hu(e,t,r){return e==null?"\u2014":typeof e=="boolean"?e?r?r("common.yes",{defaultValue:"Yes"}):"Yes":r?r("common.no",{defaultValue:"No"}):"No":t==="number"||t==="price"?String(e):t==="date"||t==="datetime"?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):Array.isArray(e)?e.map(o=>o&&typeof o=="object"?o.title||o.name||o.email||o.filename||o.url||JSON.stringify(o).slice(0,30):String(o??"").slice(0,30)).filter(Boolean).join(", "):typeof e=="object"?e.title?e.title:e.name?e.name:e.email?e.email:JSON.stringify(e).slice(0,50):String(e).slice(0,60)}function _u(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var Ls=(e,t)=>{let r=e?.toLowerCase()||"",o=t?.toLowerCase()||"";return r.startsWith("image/")||o.match(/\.(jpe?g|png|gif|webp|avif|svg)$/i)?"image":r.startsWith("video/")||o.match(/\.(mp4|webm|ogg|mov)$/i)?"video":r.startsWith("audio/")||o.match(/\.(mp3|wav|ogg|m4a)$/i)?"audio":r.includes("pdf")||o.endsWith(".pdf")?"pdf":o.match(/\.(doc|docx|txt|rtf|odt)$/i)?"document":o.match(/\.(xls|xlsx|csv)$/i)?"spreadsheet":o.match(/\.(zip|tar|gz|7z|rar)$/i)?"archive":"other"},El=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(Ql.Image,{className:t});case "video":return jsxRuntime.jsx(Ql.Film,{className:t});case "audio":return jsxRuntime.jsx(Ql.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(Ql.FileText,{className:t});default:return jsxRuntime.jsx(Ql.File,{className:t})}};function mr({field:e,value:t,onChange:r,disabled:o}){let a=Ta.useRef(null),n=Ta.useRef(null),[s,i]=Ta.useState(false),[l,d]=Ta.useState(false),[c,u]=Ta.useState(false),[m,v]=Ta.useState([]),[x,g]=Ta.useState([]),[f,b]=Ta.useState(""),[p,h]=Ta.useState(false),[A,$]=Ta.useState(""),[T,k]=Ta.useState(false),[y,w]=Ta.useState(""),[D,U]=Ta.useState(""),[O,z]=Ta.useState([]),P=e?.label||e?.name||"File",R=e.maxCount??(e.hasMany?999:1),Ae=R>1,E=Array.isArray(t)?t:t?[t]:[],oe=E.length<R,[ie,ee]=Ta.useState({});Ta.useEffect(()=>{(async()=>{let j=E.filter(Pe=>typeof Pe=="string").map(Pe=>Pe),xe=E.filter(Pe=>typeof Pe=="object"&&Pe!==null&&typeof Pe.id=="string"&&!Pe.url&&!Pe.filename&&!Pe.mimeType).map(Pe=>Pe.id),Be=[...j,...xe].filter(Pe=>!ie[Pe]);if(Be.length!==0)try{let Pe=await Promise.all(Be.map(ft=>Ee(`/api/media/${ft}`)));ee(ft=>{let qt={...ft};return Pe.forEach(J=>{J&&J.id&&(qt[J.id]=J);}),qt});}catch(Pe){console.error("Failed to fetch media details:",Pe);}})();},[t,ie]),Ta.useEffect(()=>{l&&(G(),ye());},[l,f]);let G=async()=>{try{let S=await Ee(Kr("/api/media/folders"));g(S.folders||[]);}catch{g([]);}},ye=async()=>{h(true);try{let S=Kr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");f&&(S+="&folder="+encodeURIComponent(f));let j=await Ee(S);v(j.docs||[]);}catch{v([]);}finally{h(false);}},De=async S=>{i(true);try{let j=new FormData;j.append("file",S),f&&j.append("folder",f);let xe=await sn("/api/media/upload",j),Le=xe.data||xe.doc||xe,Be={...Le,id:Le.id,filename:Le.filename,originalName:Le.originalName??S.name,url:Le.url,mimeType:Le.mimeType||S.type};r(Ae?[...E,Be]:Be),V.success(`Asset synchronized: ${Be.filename}`);}catch(j){console.error("Upload failed:",j),V.error(`Upload failed: ${j instanceof Error?j.message:"Unknown error"}`);}finally{i(false);}},L=async()=>{let S=y.trim();if(S){U("");try{let j=await dt("/api/media/upload",{url:S}),xe=(()=>{try{return new URL(S).pathname.split("/").pop()||j.originalName||"url-image"}catch{return j.originalName||"url-image"}})(),Le={id:j.id,filename:j.filename,originalName:xe,url:j.url,mimeType:j.mimeType||"image/*"};r(Ae?[...E,Le]:Le),V.success(`URL asset established: ${Le.filename}`),w(""),k(!1);}catch(j){let xe=j instanceof Error?j.message:"Invalid URL";U(xe);}}},W=S=>({id:S.id,filename:S.filename,url:S.url,mimeType:S.mimeType}),re=S=>{Ae?z(j=>j.find(Le=>Le.id===S.id)?j.filter(Le=>Le.id!==S.id):[...j,S]):(r(W(S)),d(false),$(""));},H=()=>{if(O.length>0){let S=[...E,...O.map(W)];r(S);}z([]),d(false),$("");},Te=S=>{let j=[...E];j.splice(S,1),r(Ae?j:j[0]||null);},fe=Ta.useMemo(()=>m.filter(S=>!A||S.filename?.toLowerCase().includes(A.toLowerCase())||S.title?.toLowerCase().includes(A.toLowerCase())),[m,A]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let we=(S,j)=>{if(!S)return null;let xe=typeof S=="string"?S:S.id,Le=ie[xe]||(typeof S=="object"?S:{}),Be=Ls(Le.mimeType,Le.filename||Le.url);return jsxRuntime.jsxs("div",{className:"flex items-center gap-3 p-2.5 bg-[var(--kyro-surface-accent)] rounded-lg border border-[var(--kyro-border)] group",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 rounded-md overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex items-center justify-center flex-shrink-0",children:Be==="image"?jsxRuntime.jsx("img",{src:Ca(Le.url),alt:Le.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(El,{type:Be,className:"w-5 h-5 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-[11px] font-medium truncate text-[var(--kyro-text-primary)]",children:Le.originalName||Le.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:P})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>j!==void 0?Te(j):r(null),disabled:o,className:"p-1.5 rounded-md text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)] transition-all opacity-0 group-hover:opacity-100",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]},j)};return jsxRuntime.jsxs("div",{className:"space-y-2 relative",children:[jsxRuntime.jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:S=>{let j=S.target.files?.[0];j&&De(j);},disabled:o,className:"hidden"}),E.length>0&&jsxRuntime.jsx("div",{className:Ae?"grid grid-cols-2 gap-2":"space-y-2",children:E.map((S,j)=>we(S,j))}),(!E.length||oe)&&jsxRuntime.jsxs("div",{className:"flex gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a.current?.click(),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:["+ Upload ",P]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{z([]),d(true);},disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"Library"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>k(!T),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"URL"})]}),T&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:y,onChange:S=>{w(S.target.value),U("");},onKeyDown:S=>S.key==="Enter"&&L(),disabled:o,className:"flex-1 px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),jsxRuntime.jsx("button",{type:"button",onClick:L,disabled:o||!y.trim(),className:"kyro-btn kyro-btn-primary px-3 py-1.5 text-xs rounded cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50",children:"Add"}),D&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:D})]}),l&&(c?reactDom.createPortal(jsxRuntime.jsx(Bl,{isFullscreen:true,isMultiple:Ae,selectedItems:O,pickerSearch:A,setPickerSearch:$,folders:x,selectedFolder:f,setSelectedFolder:b,mediaLoading:p,filteredMedia:fe,selectFromLibrary:re,onDone:H,setIsPickerFullscreen:u,setShowPicker:d}),document.body):jsxRuntime.jsx(Bl,{isFullscreen:false,isMultiple:Ae,selectedItems:O,pickerSearch:A,setPickerSearch:$,folders:x,selectedFolder:f,setSelectedFolder:b,mediaLoading:p,filteredMedia:fe,selectFromLibrary:re,onDone:H,setIsPickerFullscreen:u,setShowPicker:d}))]})}function Bl({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:i,mediaLoading:l,filteredMedia:d,selectFromLibrary:c,onDone:u,setIsPickerFullscreen:m,setShowPicker:v}){let{t:x}=reactI18next.useTranslation(),g=f=>r.some(b=>b.id===f);return jsxRuntime.jsxs("div",{className:`${e?"fixed inset-0 z-[9999]":"relative z-[9999] w-[360px] max-h-[400px] mt-1 rounded-lg shadow-lg"} overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex flex-col`,children:[jsxRuntime.jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsxRuntime.jsx("input",{type:"text",placeholder:x("fields.searchMedia",{defaultValue:"Search media..."}),value:o,onChange:f=>a(f.target.value),className:"w-full px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),n.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(""),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===""?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:"All"}),n.slice(0,6).map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(f.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===f.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:f.name},f.path))]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-2",children:l?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"No media found"}):jsxRuntime.jsx("div",{className:`grid gap-1 ${e?"grid-cols-[repeat(auto-fill,minmax(140px,1fr))]":"grid-cols-3"}`,children:d.map(f=>{let b=g(f.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(f),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${b?"border-[var(--kyro-primary)] ring-2 ring-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]"}`,children:[jsxRuntime.jsx("div",{className:`w-full flex items-center justify-center bg-[var(--kyro-surface-accent)] ${e?"h-[120px]":"h-[80px]"}`,children:Ls(f.mimeType,f.filename)==="image"?jsxRuntime.jsx("img",{src:Ca(f.thumbnailUrl||f.url),alt:f.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(El,{type:Ls(f.mimeType,f.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&b&&jsxRuntime.jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsxRuntime.jsx(Ql.Check,{className:"w-3 h-3 text-white"})})]},f.id)})})}),jsxRuntime.jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[d.length," items"]}),jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[t&&jsxRuntime.jsxs("button",{type:"button",onClick:u,className:"kyro-btn kyro-btn-primary px-3 py-1 text-xs font-semibold rounded cursor-pointer hover:opacity-90 transition-opacity",children:["Done",r.length>0?` (${r.length})`:""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(!e),className:"p-1.5 rounded text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",title:e?"Exit fullscreen":"Fullscreen",children:e?jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})}):jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(false),m(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function ct({field:e,error:t,children:r,hideLabel:o=false}){return jsxRuntime.jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsxRuntime.jsx("div",{className:"flex justify-between items-end mb-1",children:jsxRuntime.jsxs("label",{className:"block text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 group-focus-within:opacity-100 group-focus-within:text-[var(--kyro-primary)] transition-all duration-300",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsxRuntime.jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsxRuntime.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin.description}),t&&jsxRuntime.jsxs("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-error)] font-bold flex items-center gap-2 animate-in fade-in slide-in-from-top-1 duration-300",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function yr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let i=Ta.useRef(null),[l,d]=Ta.useState(false);Ta.useEffect(()=>{d(true);},[]),Ta.useEffect(()=>{let u=m=>{m.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",u),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",u),document.body.style.overflow="";}},[e,t]);let c={sm:"w-full sm:w-[320px]",md:"w-full sm:w-[400px]",lg:"w-full sm:w-[550px]",xl:"w-full sm:w-[700px]"};return !e||!l?null:reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-[99998] bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{ref:i,"data-kyro-slide-panel":"true","data-kyro-slide-width":a,className:`fixed right-0 top-0 bottom-0 z-[99999] ${c[a]} bg-[var(--kyro-surface)] ${s?`border-l-2 ${s}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1.5 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsxRuntime.jsx("style",{children:`
|
|
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 Sr({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Er({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function St({open:e,onClose:t,title:r,children:o,footer:a,size:n="lg",variant:s="default"}){if(Da.useEffect(()=>{let c=d=>{d.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",c),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",c),document.body.style.overflow="";}},[e,t]),!e)return null;let l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl",full:"w-full h-full max-w-none rounded-none border-0"},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(ql.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 js({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(St,{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 Ll({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,l]=Da.useState(n),i=c=>{c.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(ql.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:c=>l(c.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 El({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[s,l]=Da.useState("crop"),[i,c]=Da.useState(t?{unit:"%",...t}:void 0),[d,m]=Da.useState(r||{x:40,y:40,width:20,height:20}),[x,b]=Da.useState(!!r),k=Da.useRef(null),f=Da.useRef(null),[g,p]=Da.useState(false),[u,v]=Da.useState(null),R=Da.useRef(null),P=(C,G)=>{s==="hotspot"&&(C.stopPropagation(),C.preventDefault(),G?v(G):p(true),R.current={x:C.clientX,y:C.clientY,hX:d.x,hY:d.y,hW:d.width,hH:d.height});},h=Da.useCallback(C=>{if(!R.current||!k.current)return;let G=k.current.getBoundingClientRect(),z=(C.clientX-R.current.x)/G.width*100,j=(C.clientY-R.current.y)/G.height*100,_=R.current;if(g){let se=_.hX+z,te=_.hY+j;se=Math.max(0,Math.min(se,100-_.hW)),te=Math.max(0,Math.min(te,100-_.hH)),m(J=>({...J,x:se,y:te}));}else if(u){let se=_.hX,te=_.hY,J=_.hW,de=_.hH;u.includes("e")&&(J=_.hW+z),u.includes("w")&&(se=_.hX+z,J=_.hW-z),u.includes("s")&&(de=_.hH+j),u.includes("n")&&(te=_.hY+j,de=_.hH-j),J<5&&(J=5,u.includes("w")&&(se=_.hX+_.hW-5)),de<5&&(de=5,u.includes("n")&&(te=_.hY+_.hH-5)),se=Math.max(0,Math.min(se,100-J)),te=Math.max(0,Math.min(te,100-de)),J=Math.min(J,100-se),de=Math.min(de,100-te),m({x:se,y:te,width:J,height:de});}},[g,u,d]),w=Da.useCallback(()=>{p(false),v(null),R.current=null;},[]);Da.useEffect(()=>((g||u)&&(window.addEventListener("pointermove",h),window.addEventListener("pointerup",w)),()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",w);}),[g,u,h,w]);let y=C=>{},S=()=>{let C=i?.width&&i?.height?{x:i.x,y:i.y,width:i.width,height:i.height}:void 0;o(C,x?d:void 0);},O=()=>{c(void 0),b(false);},L=Da.useMemo(()=>{if(!i||!i.width||!i.height)return null;let C=new URLSearchParams({url:e});return C.set("cx",String(i.x)),C.set("cy",String(i.y)),C.set("cw",String(i.width)),C.set("ch",String(i.height)),`/api/media/resize?${C.toString()}`},[e,i]),K=i?.width&&i.height;return jsxRuntime.jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("button",{onClick:()=>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(ql.Crop,{className:"w-4 h-4"}),"Crop"]}),jsxRuntime.jsxs("button",{onClick:()=>{l("hotspot"),x||b(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(ql.MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("button",{onClick:O,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:[jsxRuntime.jsx(ql.RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{onClick:S,disabled:n,className:"flex items-center justify-center min-w-[120px] px-6 py-2 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] text-sm font-bold rounded-lg shadow-lg hover:opacity-90 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",children:n?jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4 text-current",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):"Save Edits"})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxRuntime.jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:f,children:[jsxRuntime.jsx(Xp__default.default,{crop:i,onChange:(C,G)=>c(G),locked:s==="hotspot",className:s==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsxRuntime.jsx("img",{ref:k,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:y})}),x&&k.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:k.current.width,height:k.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:`${d.x}%`,top:`${d.y}%`,width:`${d.width}%`,height:`${d.height}%`,borderRadius:"50%"},onPointerDown:C=>P(C),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:C=>P(C,"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:C=>P(C,"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:C=>P(C,"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:C=>P(C,"e")})]})]})})})]})}),K&&jsxRuntime.jsxs("div",{className:"w-[280px] border-l border-[var(--kyro-border)] bg-[var(--kyro-surface)] flex flex-col overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx(ql.Eye,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)] tracking-wide uppercase",children:"Preview"})]}),jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-hidden",children:L&&jsxRuntime.jsx("img",{src:L,alt:"Crop preview",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg border border-[var(--kyro-border)]"})}),jsxRuntime.jsxs("div",{className:"px-4 py-3 border-t border-[var(--kyro-border)] text-[10px] text-[var(--kyro-text-secondary)] font-mono",children:[jsxRuntime.jsxs("div",{children:["x: ",i?.x?.toFixed(1),"% y: ",i?.y?.toFixed(1),"%"]}),jsxRuntime.jsxs("div",{children:["w: ",i?.width?.toFixed(1),"% h: ",i?.height?.toFixed(1),"%"]})]})]})]}),jsxRuntime.jsx("div",{className:"p-4 text-center bg-[var(--kyro-surface-accent)] border-t border-[var(--kyro-border)] text-sm text-[var(--kyro-text-secondary)]",children:s==="crop"?"Drag to define the crop area. The preview panel shows the result in real-time.":"Drag the circle to define the focal hotspot. This area will always remain visible when the image is resized."})]})}function $r(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 Mn(e,t){if(!e.metadata?.crop)return null;let{x:r,y:o,width:a,height:n}=e.metadata.crop;if(!a||!n||!$r(e.url))return null;let l=new URLSearchParams({url:e.url});l.set("cx",String(r)),l.set("cy",String(o)),l.set("cw",String(a)),l.set("ch",String(n)),t&&l.set("w",String(t));let i=`/api/media/resize?${l.toString()}`;return typeof window>"u"?i:`${window.location.origin}${i}`}function En(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 em(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function tm(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 $n({onSelect:e,multiple:t=true,pickerMode:r=false}){let{permissions:o}=Kr(),a=o?.media?.create!==false,n=o?.media?.delete!==false,s=o?.media?.update!==false,[l,i]=Da.useState([]),[c,d]=Da.useState(true),[m,x]=Da.useState(false),[b,k]=Da.useState([]),[f,g]=Da.useState(""),[p,u]=Da.useState(""),[v,R]=Da.useState("all"),[P,h]=Da.useState("grid"),[w,y]=Da.useState(null),[S,O]=Da.useState(false),[L,K]=Da.useState(false),[C,G]=Da.useState(false),[z,j]=Da.useState({}),[_,se]=Da.useState(false),[te,J]=Da.useState(false),[de,ve]=Da.useState(null),[Te,Ve]=Da.useState(false),[M,E]=Da.useState(false),[ne,ue]=Da.useState(1),[$e,A]=Da.useState(0),[$,Z]=Da.useState(1),Ke=40,[fe,We]=Da.useState(new Set),{confirm:Fe,alert:yt}=ft(),[wt,I]=Da.useState(false),H=Da.useRef(null),q=Da.useCallback(async T=>{T===1?d(true):x(true);try{let ae=new URLSearchParams({page:T.toString(),limit:Ke.toString()});f&&ae.append("folder",f),p&&ae.append("search",p),v!=="all"&&ae.append("type",v);let Le=await De(Gr(`/api/media?${ae}`)),zt=(Le.docs||[]).map(jt=>({...jt,type:tm(jt.mimeType)}));i(jt=>T===1?zt:[...jt,...zt]),A(Le.totalDocs||0),Z(Le.totalPages||1);}catch(ae){console.error("Failed to load media:",ae);}finally{d(false),x(false);}},[f,p,v,Ke]),xe=Da.useCallback(async()=>{try{let T=await De(Gr("/api/media/folders"));k(Array.isArray(T)?T:T.folders||[]);}catch(T){console.error("Failed to load folders:",T);}},[]),Re=Da.useCallback(async()=>{try{let ae=!!(await De("/api/globals/storage-settings"))?.data?.provider;ve(ae);}catch{ve(false);}},[]);Da.useEffect(()=>{r||Re();},[Re,r]),Da.useEffect(()=>{r||de===false&&!Te&&(Ve(true),E(true));},[r,de,Te]),Da.useEffect(()=>{ue(1),q(1);},[f,p,v,q]);let Ue=()=>{if(m||ne>=$)return;let T=ne+1;ue(T),q(T);};Da.useEffect(()=>{xe();},[xe]),Da.useEffect(()=>{if(r)return;let T=ae=>{let Le=ae.clipboardData?.files;Le&&Le.length>0&&B(Le);};return window.addEventListener("paste",T),()=>window.removeEventListener("paste",T)},[r,f,de]);let B=async T=>{if(!de){E(true);return}G(true);let ae=0,Le=0;for(let zt=0;zt<T.length;zt++){let jt=T[zt];try{let xr=new FormData;xr.append("file",jt),f&&xr.append("folder",f),await mn("/api/media/upload",xr,hs=>{j(ws=>({...ws,[jt.name]:hs}));}),ae++;}catch(xr){console.error(`Upload failed for ${jt.name}:`,xr),Le++;}}G(false),j({}),ue(1),q(1),xe(),Le>0&&U.error(`${Le} file(s) failed to upload`),ae>0&&U.success(`${ae} file(s) uploaded successfully`);},ee=()=>{Fe({title:"Delete Media",message:`Are you sure you want to delete ${fe.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let T of Array.from(fe))await Tt(`/api/media/${T}`);We(new Set),ue(1),q(1),U.success(`${fe.size} item(s) deleted`);}catch(T){console.error("Bulk delete failed:",T),U.error("Failed to delete some items");}}});},ce=(T,ae)=>{ae.stopPropagation();let Le=new Set(fe);Le.has(T)?Le.delete(T):(t||Le.clear(),Le.add(T)),We(Le);},br=async T=>{try{await dt("/api/media/folders",{name:T}),xe(),se(!1),U.success(`Folder "${T}" created`);}catch(ae){console.error("Failed to create folder:",ae),U.error("Failed to create folder");}},go=T=>{Fe({title:"Delete Folder",message:`Are you sure you want to delete the folder "${T}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await Tt(`/api/media/folders?path=${encodeURIComponent(T)}`),f===T&&g(""),xe(),ue(1),q(1),U.success(`Folder "${T}" deleted`);}catch(ae){console.error("Failed to delete folder:",ae),U.error("Failed to delete folder");}}});},Na=async(T,ae)=>{try{let Le=await Yt(`/api/media/${T}`,ae);i(zt=>zt.map(jt=>jt.id===T?Le.doc:jt)),w?.id===T&&y(Le.doc),U.success("Metadata updated");}catch(Le){console.error("Failed to update metadata:",Le),U.error("Failed to update metadata");}},rn=async(T,ae)=>{if(w)try{G(!0);let Le={...w.metadata,crop:T,hotspot:ae},zt=await Yt(`/api/media/${w.id}`,{metadata:Le});i(jt=>jt.map(xr=>xr.id===w.id?zt.doc:xr)),y(zt.doc),K(!1),U.success("Crop & hotspot saved");}catch(Le){console.error("Save failed:",Le),U.error("Failed to save focal metadata");}finally{G(false);}},on=Da.useMemo(()=>l.reduce((T,ae)=>(T.totalSize+=ae.fileSize||0,T),{totalSize:0}),[l]);return jsxRuntime.jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${wt?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:T=>{T.preventDefault(),I(true);},onDragLeave:()=>I(false),onDrop:T=>{T.preventDefault(),I(false),T.dataTransfer.files&&B(T.dataTransfer.files);}},children:[jsxRuntime.jsxs("div",{className:`flex flex-col ${r?"gap-2 p-2":"gap-4 md:gap-6 p-4 md:p-6 rounded-md md:rounded-t-xl surface-tile"} border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 z-10`,children:[!r&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg md:text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[$e," Items ",jsxRuntime.jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",En(on.totalSize)]})]})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)] hidden sm:flex",children:[jsxRuntime.jsx("button",{onClick:()=>h("grid"),className:`p-1.5 md: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(ql.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>h("list"),className:`p-1.5 md: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(ql.File,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("button",{onClick:()=>J(true),className:"md:hidden p-2 rounded-xl bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:jsxRuntime.jsx(ql.Filter,{className:"w-4 h-4"})}),a&&jsxRuntime.jsxs("button",{onClick:()=>H.current?.click(),className:"flex items-center justify-center gap-2 px-3 md:px-6 py-2 md:py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg active:scale-95 transition-all",children:[jsxRuntime.jsx("span",{className:"md:hidden text-lg leading-none",children:"+"}),jsxRuntime.jsx(ql.Maximize2,{className:"w-4 h-4 hidden md:block"}),jsxRuntime.jsx("span",{className:"hidden md:inline",children:"Upload"})]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center w-full",children:jsxRuntime.jsxs("div",{className:"relative group flex-1",children:[jsxRuntime.jsx(ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search assets...",value:p,onChange:T=>u(T.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsxRuntime.jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxRuntime.jsxs("div",{className:"p-6 space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(T=>jsxRuntime.jsxs("button",{onClick:()=>R(T),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${v===T?"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 ${v===T?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),T]},T))})]}),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:()=>se(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(ql.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>g(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(ql.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),b.map(T=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>g(T),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(ql.Folder,{fill:f===T?"currentColor":"none"})}),T]}),jsxRuntime.jsx("button",{onClick:ae=>{ae.stopPropagation(),go(T);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(ql.Trash2,{className:"w-3.5 h-3.5"})})]},T))]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxRuntime.jsxs("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${r?"px-2 py-4":"py-4 px-2 md:py-8 md:px-4"}`,children:[c?jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsxRuntime.jsx(Vt,{variant:"media-card",count:12})}):l.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsxRuntime.jsx("div",{className:"w-24 h-24 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-8 rotate-12 group-hover:rotate-0 transition-transform duration-500",children:jsxRuntime.jsx(ql.Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsxRuntime.jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-2 max-w-xs mx-auto text-sm font-medium leading-relaxed",children:"Upload your first file or create a folder to organize your media assets."}),!r&&a&&jsxRuntime.jsx("button",{onClick:()=>H.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((T,ae)=>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 ${fe.has(T.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>y(T),onContextMenu:Le=>{Le.preventDefault(),ce(T.id,Le);},children:[T.type==="image"?jsxRuntime.jsx("img",{src:Mn(T,400)||T.url,alt:T.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:T.type==="video"?jsxRuntime.jsx(ql.Film,{className:"w-8 h-8"}):T.type==="audio"?jsxRuntime.jsx(ql.Music,{className:"w-8 h-8"}):T.type==="document"?jsxRuntime.jsx(ql.FileText,{className:"w-8 h-8"}):T.type==="archive"?jsxRuntime.jsx(ql.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(ql.File,{className:"w-8 h-8"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:T.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:T.filename}),jsxRuntime.jsx("div",{className:"flex gap-1",children:jsxRuntime.jsx("button",{onClick:Le=>ce(T.id,Le),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${fe.has(T.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(ql.Check,{className:"w-4 h-4"})})})]})}),fe.has(T.id)&&jsxRuntime.jsx("div",{className:"absolute top-3 left-3 w-6 h-6 rounded-lg bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center shadow-lg border-2 border-white/20 animate-in zoom-in duration-300",children:jsxRuntime.jsx(ql.Check,{className:"w-4 h-4"})})]},T.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:fe.size===l.length,onChange:T=>{T.target.checked?We(new Set(l.map(ae=>ae.id))):We(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(T=>jsxRuntime.jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${fe.has(T.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>y(T),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:ae=>ae.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:fe.has(T.id),onChange:ae=>ce(T.id,ae),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:T.type==="image"?jsxRuntime.jsx("img",{src:Mn(T,96)||T.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(ql.File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[jsxRuntime.jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:T.title||T.filename}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:T.filename})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsx(It,{variant:"outline",className:"text-[9px]",children:T.mimeType})}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:En(T.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:em(T.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:ae=>{ae.stopPropagation(),ce(T.id,ae);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${fe.has(T.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(ql.Grid3X3,{className:"w-4 h-4"})})})]},T.id))})]})}),!c&&ne<$&&jsxRuntime.jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsxRuntime.jsx("button",{onClick:Ue,disabled:m,className:"px-8 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs hover:scale-105 active:scale-95 transition-all shadow-xl disabled:opacity-50 flex items-center gap-2",children:m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ar,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&C&&jsxRuntime.jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-[2rem] shadow-2xl p-6 ring-1 ring-white/10 animate-in slide-in-from-bottom-12 duration-700",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center animate-pulse",children:jsxRuntime.jsx(ar,{})}),jsxRuntime.jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(z).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(z).map(([T,ae])=>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:T}),jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)]",children:[ae,"%"]})]}),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:`${ae}%`}})})]},T))})]})}),fe.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:fe.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:()=>We(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 T=l.filter(ae=>fe.has(ae.id));e(T);},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:ee,className:"p-3 bg-red-500/10 text-red-500 hover:bg-red-500 hover:text-white rounded-full transition-all active:scale-90",children:jsxRuntime.jsx(ql.Trash2,{className:"w-5 h-5"})})]})]}),te&&!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:()=>J(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:()=>J(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("div",{className:"p-6 space-y-8",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(T=>jsxRuntime.jsx("button",{onClick:()=>{R(T),J(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${v===T?"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:T},T))})]}),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:()=>{se(true),J(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(ql.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{g(""),J(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(ql.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),b.map(T=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{g(T),J(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(ql.Folder,{fill:f===T?"currentColor":"none"})}),T]}),jsxRuntime.jsx("button",{onClick:ae=>{ae.stopPropagation(),go(T),J(false);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(ql.Trash2,{className:"w-3.5 h-3.5"})})]},T))]})]})]})]})]}),jsxRuntime.jsx(ur,{open:!!w,onClose:()=>y(null),title:"Asset Details",subtitle:w?.filename,children:w&&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:[w.type==="image"?jsxRuntime.jsx("img",{src:Mn(w)||$r(w.url),alt:"",className:"w-full h-full object-contain p-4"}):w.type==="video"?jsxRuntime.jsx("video",{src:$r(w.url),controls:true,className:"w-full h-full"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsxRuntime.jsx(ql.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(It,{variant:"outline",className:"text-xs font-bold",children:w.mimeType})]}),jsxRuntime.jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsxRuntime.jsx("button",{onClick:()=>O(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(ql.Maximize2,{className:"w-4 h-4"})})})]}),jsxRuntime.jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:w.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:En(w.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:$r(w.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($r(w.url)),U.success("URL copied to clipboard");},className:"p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] border border-[var(--kyro-border)] rounded-xl transition-all",children:jsxRuntime.jsx(ql.Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsxRuntime.jsx("textarea",{value:w.alt||"",onChange:T=>Na(w.id,{alt:T.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:w.caption||"",onChange:T=>Na(w.id,{caption:T.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 T=document.createElement("a");T.href=$r(w.url),T.download=w.filename,T.click();},className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg hover:opacity-90 transition-all",children:[jsxRuntime.jsx(ql.Download,{className:"w-4 h-4"}),"Download"]}),w.type==="image"&&s&&jsxRuntime.jsx("button",{onClick:()=>K(true),className:"p-3 border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:jsxRuntime.jsx(ql.Crop,{className:"w-4 h-4"})}),n&&jsxRuntime.jsx("button",{onClick:()=>{Fe({title:"Delete Asset",message:`Are you sure you want to delete ${w.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Tt(`/api/media/${w.id}`),y(null),q();}catch(T){console.error("Delete failed:",T),U.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsxRuntime.jsx(ql.Trash2,{className:"w-4 h-4"})})]})]})}),S&&w&&jsxRuntime.jsxs(St,{open:S,onClose:()=>O(false),title:"",size:"full",variant:"lightbox",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:w.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[En(w.fileSize)," \xB7 ",w.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>O(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(ql.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:w.type==="image"?jsxRuntime.jsx("img",{src:Mn(w)||$r(w.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):w.type==="video"?jsxRuntime.jsx("video",{src:$r(w.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxRuntime.jsxs("div",{className:"text-white text-center",children:[jsxRuntime.jsx(ql.File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsxRuntime.jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&L&&w&&jsxRuntime.jsx(St,{open:L,onClose:()=>K(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsx(El,{url:$r(w.url),initialCrop:w.metadata?.crop,initialHotspot:w.metadata?.hotspot,onSave:rn,onCancel:()=>K(false),isSaving:C})}),!r&&jsxRuntime.jsx(Ll,{open:_,onClose:()=>se(false),onSubmit:br,title:"Create New Folder",placeholder:"Folder name"}),!r&&jsxRuntime.jsx(St,{open:M,onClose:()=>E(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(ql.Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mb-6 text-sm",children:"Before uploading media, you need to configure your storage settings. Choose where files should be stored and how URLs are generated."}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsx("a",{href:"/settings/storage-settings",className:"flex-1 px-4 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-center hover:opacity-90 transition-colors",children:"Configure Storage"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{dt("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{E(false),ve(true),window.location.reload();}).catch(()=>{U.error("Failed to configure storage");});},className:"flex-1 px-4 py-3 border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded-xl font-bold hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Use Defaults"})]})]})}),!r&&jsxRuntime.jsx("input",{type:"file",ref:H,onChange:T=>{T.target.files&&B(T.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var Dm=[{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"}],Gl=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let[a,n]=Da.useState(null),s=Da.useRef(null);if(Da.useEffect(()=>{function p(u){s.current&&!s.current.contains(u.target)&&n(null);}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]),!e)return null;let l=()=>{o();},i=()=>{let p=e.getAttributes("link").href,u=window.prompt("URL",p);if(u!==null){if(u===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:u}).run();}},c=p=>{p==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(p).run(),n(null);},d=p=>{n(a===p?null:p);},m=()=>e.isActive("heading",{level:1})?"Heading 1":e.isActive("heading",{level:2})?"Heading 2":e.isActive("heading",{level:3})?"Heading 3":e.isActive("heading",{level:4})?"Heading 4":"Normal Text",x=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(ql.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(ql.AlignRight,{size:12}):jsxRuntime.jsx(ql.AlignLeft,{size:12}),b=()=>e.isActive("orderedList")?jsxRuntime.jsx(ql.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(ql.CheckSquare,{size:12}):jsxRuntime.jsx(ql.List,{size:12}),k=()=>e.isActive("codeBlock")?jsxRuntime.jsx(ql.Terminal,{size:12}):jsxRuntime.jsx(ql.Quote,{size:12}),f=({onClick:p,isActive:u=false,disabled:v=false,children:R,title:P})=>jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:v,title:P,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
|
|
10
|
-
${
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(p=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:p}).run(),
|
|
14
|
-
${e.isActive("heading",{level:p})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",p]},p))]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(
|
|
15
|
-
${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
16
|
-
${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
17
|
-
${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
18
|
-
${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
19
|
-
${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
20
|
-
${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
21
|
-
${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
22
|
-
${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(
|
|
9
|
+
`})]}),document.body)}function Cr({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Mr({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function St({open:e,onClose:t,title:r,children:o,footer:a,size:n="lg",variant:s="default"}){if(Ta.useEffect(()=>{let d=c=>{c.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="";}},[e,t]),!e)return null;let i={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl",full:"w-full h-full max-w-none rounded-none border-0"},l=s==="lightbox";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[jsxRuntime.jsx("div",{className:`absolute inset-0 transition-all duration-500 ${l?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxRuntime.jsxs("div",{className:`relative ${i[n]} ${l?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!l&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${l?"":"border"} ${s==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!l&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-8 py-6 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50 backdrop-blur-md",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-2 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-xl hover:bg-[var(--kyro-surface)] transition-all duration-200",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:`flex-1 overflow-auto ${l?"":"px-8 py-8"}`,children:o}),a&&!l&&jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 px-8 py-6 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50",children:a})]})]}),document.body)}function Vs({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:s="Cancel",variant:i="default",loading:l=false}){return jsxRuntime.jsx(St,{open:e,onClose:t,title:o,size:"sm",footer:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:l,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:s}),jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:l,className:`kyro-btn kyro-btn-md ${i==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:l?"Loading...":n})]}),children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function Ll({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,i]=Ta.useState(n),l=d=>{d.preventDefault(),s.trim()&&(r(s.trim()),i(""),t());};return e?reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-[var(--kyro-surface)] rounded-lg shadow-2xl animate-in fade-in zoom-in-95 duration-200 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-[var(--kyro-text-primary)]",children:o}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-lg hover:bg-[var(--kyro-surface-accent)] transition-colors",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:l,children:[jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsx("input",{type:"text",value:s,onChange:d=>i(d.target.value),placeholder:a,autoFocus:true,className:"w-full px-3 py-2 border border-[var(--kyro-input-border)] rounded-lg bg-[var(--kyro-input-bg)] text-[var(--kyro-text-primary)] placeholder-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] rounded-b-lg",children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-lg font-medium text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",disabled:!s.trim(),className:"px-4 py-2 rounded-lg font-medium text-sm bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] hover:opacity-90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Confirm"})]})]})]})]}),document.body):null}function Vl({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[s,i]=Ta.useState("crop"),[l,d]=Ta.useState(t?{unit:"%",...t}:void 0),[c,u]=Ta.useState(r||{x:40,y:40,width:20,height:20}),[m,v]=Ta.useState(!!r),x=Ta.useRef(null),g=Ta.useRef(null),[f,b]=Ta.useState(false),[p,h]=Ta.useState(null),A=Ta.useRef(null),$=(z,P)=>{s==="hotspot"&&(z.stopPropagation(),z.preventDefault(),P?h(P):b(true),A.current={x:z.clientX,y:z.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},T=Ta.useCallback(z=>{if(!A.current||!x.current)return;let P=x.current.getBoundingClientRect(),R=(z.clientX-A.current.x)/P.width*100,Ae=(z.clientY-A.current.y)/P.height*100,E=A.current;if(f){let oe=E.hX+R,ie=E.hY+Ae;oe=Math.max(0,Math.min(oe,100-E.hW)),ie=Math.max(0,Math.min(ie,100-E.hH)),u(ee=>({...ee,x:oe,y:ie}));}else if(p){let oe=E.hX,ie=E.hY,ee=E.hW,G=E.hH;p.includes("e")&&(ee=E.hW+R),p.includes("w")&&(oe=E.hX+R,ee=E.hW-R),p.includes("s")&&(G=E.hH+Ae),p.includes("n")&&(ie=E.hY+Ae,G=E.hH-Ae),ee<5&&(ee=5,p.includes("w")&&(oe=E.hX+E.hW-5)),G<5&&(G=5,p.includes("n")&&(ie=E.hY+E.hH-5)),oe=Math.max(0,Math.min(oe,100-ee)),ie=Math.max(0,Math.min(ie,100-G)),ee=Math.min(ee,100-oe),G=Math.min(G,100-ie),u({x:oe,y:ie,width:ee,height:G});}},[f,p,c]),k=Ta.useCallback(()=>{b(false),h(null),A.current=null;},[]);Ta.useEffect(()=>((f||p)&&(window.addEventListener("pointermove",T),window.addEventListener("pointerup",k)),()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",k);}),[f,p,T,k]);let y=z=>{},w=()=>{let z=l?.width&&l?.height?{x:l.x,y:l.y,width:l.width,height:l.height}:void 0;o(z,m?c:void 0);},D=()=>{d(void 0),v(false);},U=Ta.useMemo(()=>{if(!l||!l.width||!l.height)return null;let z=new URLSearchParams({url:e});return z.set("cx",String(l.x)),z.set("cy",String(l.y)),z.set("cw",String(l.width)),z.set("ch",String(l.height)),`/api/media/resize?${z.toString()}`},[e,l]),O=l?.width&&l.height;return jsxRuntime.jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("button",{onClick:()=>i("crop"),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="crop"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Ql.Crop,{className:"w-4 h-4"}),"Crop"]}),jsxRuntime.jsxs("button",{onClick:()=>{i("hotspot"),m||v(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Ql.MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("button",{onClick:D,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:[jsxRuntime.jsx(Ql.RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{onClick:w,disabled:n,className:"flex items-center justify-center min-w-[120px] px-6 py-2 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] text-sm font-bold rounded-lg shadow-lg hover:opacity-90 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",children:n?jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4 text-current",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):"Save Edits"})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxRuntime.jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:g,children:[jsxRuntime.jsx(np__default.default,{crop:l,onChange:(z,P)=>d(P),locked:s==="hotspot",className:s==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsxRuntime.jsx("img",{ref:x,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:y})}),m&&x.current&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"relative",style:{width:x.current.width,height:x.current.height},children:jsxRuntime.jsxs("div",{className:`absolute border-2 shadow-2xl transition-colors duration-200 ${s==="hotspot"?"border-blue-500 bg-blue-500/20 cursor-move pointer-events-auto shadow-blue-500/50":"border-blue-500/50 bg-blue-500/10 pointer-events-none"}`,style:{left:`${c.x}%`,top:`${c.y}%`,width:`${c.width}%`,height:`${c.height}%`,borderRadius:"50%"},onPointerDown:z=>$(z),children:[jsxRuntime.jsx("div",{className:"absolute top-1/2 left-1/2 w-2 h-2 -ml-1 -mt-1 bg-blue-500 rounded-full"}),s==="hotspot"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-1/2 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:z=>$(z,"n")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-1/2 w-4 h-4 -ml-2 -mb-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:z=>$(z,"s")}),jsxRuntime.jsx("div",{className:"absolute top-1/2 left-0 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:z=>$(z,"w")}),jsxRuntime.jsx("div",{className:"absolute top-1/2 right-0 w-4 h-4 -mr-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:z=>$(z,"e")})]})]})})})]})}),O&&jsxRuntime.jsxs("div",{className:"w-[280px] border-l border-[var(--kyro-border)] bg-[var(--kyro-surface)] flex flex-col overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)] tracking-wide uppercase",children:"Preview"})]}),jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-hidden",children:U&&jsxRuntime.jsx("img",{src:U,alt:"Crop preview",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg border border-[var(--kyro-border)]"})}),jsxRuntime.jsxs("div",{className:"px-4 py-3 border-t border-[var(--kyro-border)] text-[10px] text-[var(--kyro-text-secondary)] font-mono",children:[jsxRuntime.jsxs("div",{children:["x: ",l?.x?.toFixed(1),"% y: ",l?.y?.toFixed(1),"%"]}),jsxRuntime.jsxs("div",{children:["w: ",l?.width?.toFixed(1),"% h: ",l?.height?.toFixed(1),"%"]})]})]})]}),jsxRuntime.jsx("div",{className:"p-4 text-center bg-[var(--kyro-surface-accent)] border-t border-[var(--kyro-border)] text-sm text-[var(--kyro-text-secondary)]",children:s==="crop"?"Drag to define the crop area. The preview panel shows the result in real-time.":"Drag the circle to define the focal hotspot. This area will always remain visible when the image is resized."})]})}function Lr(e){if(typeof e!="string"||!e)return "";if(typeof window>"u"||e.startsWith("http")||e.startsWith("blob:"))return e;let t=e.replace(/^\/+/,"/");return `${window.location.origin}${t}`}function In(e,t){if(!e.metadata?.crop)return null;let{x:r,y:o,width:a,height:n}=e.metadata.crop;if(!a||!n||!Lr(e.url))return null;let i=new URLSearchParams({url:e.url});i.set("cx",String(r)),i.set("cy",String(o)),i.set("cw",String(a)),i.set("ch",String(n)),t&&i.set("w",String(t));let l=`/api/media/resize?${i.toString()}`;return typeof window>"u"?l:`${window.location.origin}${l}`}function Bn(e){if(e===0)return "0 B";let t=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,o)).toFixed(1))+" "+r[o]}function cp(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function up(e){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.includes("zip")||e.includes("tar")||e.includes("archive")?"archive":e.includes("pdf")||e.includes("doc")||e.includes("text")?"document":"other"}function En({onSelect:e,multiple:t=true,pickerMode:r=false}){let{t:o}=reactI18next.useTranslation(),{permissions:a}=_r(),n=a?.media?.create!==false,s=a?.media?.delete!==false,i=a?.media?.update!==false,[l,d]=Ta.useState([]),[c,u]=Ta.useState(true),[m,v]=Ta.useState(false),[x,g]=Ta.useState([]),[f,b]=Ta.useState(""),[p,h]=Ta.useState(""),[A,$]=Ta.useState("all"),[T,k]=Ta.useState("grid"),[y,w]=Ta.useState(null),[D,U]=Ta.useState(false),[O,z]=Ta.useState(false),[P,R]=Ta.useState(false),[Ae,E]=Ta.useState({}),[oe,ie]=Ta.useState(false),[ee,G]=Ta.useState(false),[ye,De]=Ta.useState(null),[L,W]=Ta.useState(false),[re,H]=Ta.useState(false),[Te,fe]=Ta.useState(1),[we,S]=Ta.useState(0),[j,xe]=Ta.useState(1),Le=40,[Be,Pe]=Ta.useState(new Set),{confirm:ft,alert:qt}=yt(),[J,M]=Ta.useState(false),K=Ta.useRef(null),le=Ta.useCallback(async C=>{C===1?u(true):v(true);try{let me=new URLSearchParams({page:C.toString(),limit:Le.toString()});f&&me.append("folder",f),p&&me.append("search",p),A!=="all"&&me.append("type",A);let $e=await Ee(Kr(`/api/media?${me}`)),tr=($e.docs||[]).map(Et=>({...Et,type:up(Et.mimeType)}));d(Et=>C===1?tr:[...Et,...tr]),S($e.totalDocs||0),xe($e.totalPages||1);}catch(me){console.error("Failed to load media:",me);}finally{u(false),v(false);}},[f,p,A,Le]),Fe=Ta.useCallback(async()=>{try{let C=await Ee(Kr("/api/media/folders"));g(Array.isArray(C)?C:C.folders||[]);}catch(C){console.error("Failed to load folders:",C);}},[]),Oe=Ta.useCallback(async()=>{try{let me=!!(await Ee("/api/globals/storage-settings"))?.data?.provider;De(me);}catch{De(false);}},[]);Ta.useEffect(()=>{r||Oe();},[Oe,r]),Ta.useEffect(()=>{r||ye===false&&!L&&(W(true),H(true));},[r,ye,L]),Ta.useEffect(()=>{fe(1),le(1);},[f,p,A,le]);let gt=()=>{if(m||Te>=j)return;let C=Te+1;fe(C),le(C);};Ta.useEffect(()=>{Fe();},[Fe]),Ta.useEffect(()=>{if(r)return;let C=me=>{let $e=me.clipboardData?.files;$e&&$e.length>0&&B($e);};return window.addEventListener("paste",C),()=>window.removeEventListener("paste",C)},[r,f,ye]);let B=async C=>{if(!ye){H(true);return}R(true);let me=0,$e=0;for(let tr=0;tr<C.length;tr++){let Et=C[tr];try{let xr=new FormData;xr.append("file",Et),f&&xr.append("folder",f),await sn("/api/media/upload",xr,xs=>{E(Lo=>({...Lo,[Et.name]:xs}));}),me++;}catch(xr){console.error(`Upload failed for ${Et.name}:`,xr),$e++;}}R(false),E({}),fe(1),le(1),Fe(),$e>0&&V.error(`${$e} file(s) failed to upload`),me>0&&V.success(`${me} file(s) uploaded successfully`);},X=()=>{ft({title:"Delete Media",message:`Are you sure you want to delete ${Be.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let C of Array.from(Be))await At(`/api/media/${C}`);Pe(new Set),fe(1),le(1),V.success(`${Be.size} item(s) deleted`);}catch(C){console.error("Bulk delete failed:",C),V.error("Failed to delete some items");}}});},ae=(C,me)=>{me.stopPropagation();let $e=new Set(Be);$e.has(C)?$e.delete(C):(t||$e.clear(),$e.add(C)),Pe($e);},Jt=async C=>{try{await dt("/api/media/folders",{name:C}),Fe(),ie(!1),V.success(`Folder "${C}" created`);}catch(me){console.error("Failed to create folder:",me),V.error("Failed to create folder");}},fo=C=>{ft({title:"Delete Folder",message:`Are you sure you want to delete the folder "${C}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await At(`/api/media/folders?path=${encodeURIComponent(C)}`),f===C&&b(""),Fe(),fe(1),le(1),V.success(`Folder "${C}" deleted`);}catch(me){console.error("Failed to delete folder:",me),V.error("Failed to delete folder");}}});},ka=async(C,me)=>{try{let $e=await Yt(`/api/media/${C}`,me);d(tr=>tr.map(Et=>Et.id===C?$e.doc:Et)),y?.id===C&&w($e.doc),V.success("Metadata updated");}catch($e){console.error("Failed to update metadata:",$e),V.error("Failed to update metadata");}},Za=async(C,me)=>{if(y)try{R(!0);let $e={...y.metadata,crop:C,hotspot:me},tr=await Yt(`/api/media/${y.id}`,{metadata:$e});d(Et=>Et.map(xr=>xr.id===y.id?tr.doc:xr)),w(tr.doc),z(!1),V.success("Crop & hotspot saved");}catch($e){console.error("Save failed:",$e),V.error("Failed to save focal metadata");}finally{R(false);}},bs=Ta.useMemo(()=>l.reduce((C,me)=>(C.totalSize+=me.fileSize||0,C),{totalSize:0}),[l]);return jsxRuntime.jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${J?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:C=>{C.preventDefault(),M(true);},onDragLeave:()=>M(false),onDrop:C=>{C.preventDefault(),M(false),C.dataTransfer.files&&B(C.dataTransfer.files);}},children:[jsxRuntime.jsxs("div",{className:`flex flex-col ${r?"gap-2 p-2":"gap-4 md:gap-6 p-4 md:p-6 rounded-md md:rounded-t-xl surface-tile"} border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 z-10`,children:[!r&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg md:text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[we," Items ",jsxRuntime.jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",Bn(bs.totalSize)]})]})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)] hidden sm:flex",children:[jsxRuntime.jsx("button",{onClick:()=>k("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${T==="grid"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Ql.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>k("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${T==="list"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Ql.File,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("button",{onClick:()=>G(true),className:"md:hidden p-2 rounded-xl bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:jsxRuntime.jsx(Ql.Filter,{className:"w-4 h-4"})}),n&&jsxRuntime.jsxs("button",{onClick:()=>K.current?.click(),className:"flex items-center justify-center gap-2 px-3 md:px-6 py-2 md:py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg active:scale-95 transition-all",children:[jsxRuntime.jsx("span",{className:"md:hidden text-lg leading-none",children:"+"}),jsxRuntime.jsx(Ql.Maximize2,{className:"w-4 h-4 hidden md:block"}),jsxRuntime.jsx("span",{className:"hidden md:inline",children:"Upload"})]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center w-full",children:jsxRuntime.jsxs("div",{className:"relative group flex-1",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:o("fields.searchAssets",{defaultValue:"Search assets..."}),value:p,onChange:C=>h(C.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsxRuntime.jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxRuntime.jsxs("div",{className:"p-6 space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(C=>jsxRuntime.jsxs("button",{onClick:()=>$(C),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${A===C?"text-[var(--kyro-text-primary)] bg-[var(--kyro-surface-accent)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${A===C?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),C]},C))})]}),jsxRuntime.jsxs("div",{className:"pt-6 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>ie(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Ql.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>b(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Ql.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),x.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>b(C),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===C?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Ql.Folder,{fill:f===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),fo(C);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})})]},C))]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxRuntime.jsxs("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${r?"px-2 py-4":"py-4 px-2 md:py-8 md:px-4"}`,children:[c?jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsxRuntime.jsx(jt,{variant:"media-card",count:12})}):l.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsxRuntime.jsx("div",{className:"w-24 h-24 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-8 rotate-12 group-hover:rotate-0 transition-transform duration-500",children:jsxRuntime.jsx(Ql.Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsxRuntime.jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-2 max-w-xs mx-auto text-sm font-medium leading-relaxed",children:"Upload your first file or create a folder to organize your media assets."}),!r&&n&&jsxRuntime.jsx("button",{onClick:()=>K.current?.click(),className:"mt-8 px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-2xl font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Start Uploading"})]}):T==="grid"?jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-1",children:l.map((C,me)=>jsxRuntime.jsxs("div",{className:`group relative aspect-square rounded-lg overflow-hidden bg-[var(--kyro-surface-accent)] border-2 transition-all duration-300 cursor-pointer ${Be.has(C.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>w(C),onContextMenu:$e=>{$e.preventDefault(),ae(C.id,$e);},children:[C.type==="image"?jsxRuntime.jsx("img",{src:In(C,400)||C.url,alt:C.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 gap-4",children:[jsxRuntime.jsx("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface)] shadow-inner text-[var(--kyro-text-secondary)] group-hover:scale-110 transition-transform duration-500",children:C.type==="video"?jsxRuntime.jsx(Ql.Film,{className:"w-8 h-8"}):C.type==="audio"?jsxRuntime.jsx(Ql.Music,{className:"w-8 h-8"}):C.type==="document"?jsxRuntime.jsx(Ql.FileText,{className:"w-8 h-8"}):C.type==="archive"?jsxRuntime.jsx(Ql.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(Ql.File,{className:"w-8 h-8"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:C.title})]}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-[10px] truncate max-w-[120px]",children:C.filename}),jsxRuntime.jsx("div",{className:"flex gap-1",children:jsxRuntime.jsx("button",{onClick:$e=>ae(C.id,$e),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${Be.has(C.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})})})]})}),Be.has(C.id)&&jsxRuntime.jsx("div",{className:"absolute top-3 left-3 w-6 h-6 rounded-lg bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center shadow-lg border-2 border-white/20 animate-in zoom-in duration-300",children:jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})})]},C.id))}):jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden animate-in fade-in duration-500",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-12",children:jsxRuntime.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]",checked:Be.size===l.length,onChange:C=>{C.target.checked?Pe(new Set(l.map(me=>me.id))):Pe(new Set);}})}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Asset"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Type"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Size"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Date"}),jsxRuntime.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:l.map(C=>jsxRuntime.jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${Be.has(C.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>w(C),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:me=>me.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:Be.has(C.id),onChange:me=>ae(C.id,me),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]"})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 rounded-xl bg-[var(--kyro-bg)] overflow-hidden border border-[var(--kyro-border)] flex-shrink-0 flex items-center justify-center",children:C.type==="image"?jsxRuntime.jsx("img",{src:In(C,96)||C.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(Ql.File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[jsxRuntime.jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:C.title||C.filename}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:C.filename})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px]",children:C.mimeType})}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Bn(C.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:cp(C.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),ae(C.id,me);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${Be.has(C.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(Ql.Grid3X3,{className:"w-4 h-4"})})})]},C.id))})]})}),!c&&Te<j&&jsxRuntime.jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsxRuntime.jsx("button",{onClick:gt,disabled:m,className:"px-8 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs hover:scale-105 active:scale-95 transition-all shadow-xl disabled:opacity-50 flex items-center gap-2",children:m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ar,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&P&&jsxRuntime.jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-[2rem] shadow-2xl p-6 ring-1 ring-white/10 animate-in slide-in-from-bottom-12 duration-700",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center animate-pulse",children:jsxRuntime.jsx(ar,{})}),jsxRuntime.jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(Ae).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(Ae).map(([C,me])=>jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] font-bold",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:C}),jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)]",children:[me,"%"]})]}),jsxRuntime.jsx("div",{className:"h-1.5 w-full bg-[var(--kyro-surface-accent)] rounded-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)] transition-all duration-300 rounded-full",style:{width:`${me}%`}})})]},C))})]})}),Be.size>0&&jsxRuntime.jsxs("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-full shadow-2xl px-2 py-2 flex items-center gap-12 animate-in slide-in-from-bottom-12 duration-700 ring-1 ring-white/10 backdrop-blur-xl",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-5 border-r border-[var(--kyro-border)] ",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center text-lg font-bold shadow-inner",children:Be.size}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsxRuntime.jsx("button",{onClick:()=>Pe(new Set),className:"text-[10px] font-bold text-[var(--kyro-primary)] hover:underline opacity-80",children:"Clear all"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[e&&jsxRuntime.jsx("button",{onClick:()=>{let C=l.filter(me=>Be.has(me.id));e(C);},className:"px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-full font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Confirm Selection"}),!r&&s&&jsxRuntime.jsx("button",{onClick:X,className:"p-3 bg-red-500/10 text-red-500 hover:bg-red-500 hover:text-white rounded-full transition-all active:scale-90",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-5 h-5"})})]})]}),ee&&!r&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[70] md:hidden",children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>G(false)}),jsxRuntime.jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-[var(--kyro-surface)] rounded-t-3xl shadow-2xl max-h-[70vh] overflow-y-auto animate-in slide-in-from-bottom-12 duration-300",children:[jsxRuntime.jsxs("div",{className:"sticky top-0 bg-[var(--kyro-surface)] z-10 flex items-center justify-between p-6 pb-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Filters"}),jsxRuntime.jsx("button",{onClick:()=>G(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("div",{className:"p-6 space-y-8",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(C=>jsxRuntime.jsx("button",{onClick:()=>{$(C),G(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${A===C?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] border-transparent":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] border-[var(--kyro-border)] hover:border-[var(--kyro-text-muted)]"}`,children:C},C))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>{ie(true),G(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Ql.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{b(""),G(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Ql.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),x.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{b(C),G(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${f===C?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Ql.Folder,{fill:f===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),fo(C),G(false);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})})]},C))]})]})]})]})]}),jsxRuntime.jsx(yr,{open:!!y,onClose:()=>w(null),title:o("tooltips.assetDetails",{defaultValue:"Asset Details"}),subtitle:y?.filename,children:y&&jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"aspect-video w-full rounded-2xl bg-[var(--kyro-bg)] border border-[var(--kyro-border)] overflow-hidden relative group",children:[y.type==="image"?jsxRuntime.jsx("img",{src:In(y)||Lr(y.url),alt:"",className:"w-full h-full object-contain p-4"}):y.type==="video"?jsxRuntime.jsx("video",{src:Lr(y.url),controls:true,className:"w-full h-full"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsxRuntime.jsx(Ql.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-xs font-bold",children:y.mimeType})]}),jsxRuntime.jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsxRuntime.jsx("button",{onClick:()=>U(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(Ql.Maximize2,{className:"w-4 h-4"})})})]}),jsxRuntime.jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:y.type==="image"?"Original Resolution":"N/A"})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"File Size"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:Bn(y.fileSize)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Public Link"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{type:"text",readOnly:true,value:Lr(y.url),className:"flex-1 px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-[10px] font-bold font-mono focus:outline-none"}),jsxRuntime.jsx("button",{onClick:()=>{navigator.clipboard.writeText(Lr(y.url)),V.success("URL copied to clipboard");},className:"p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] border border-[var(--kyro-border)] rounded-xl transition-all",children:jsxRuntime.jsx(Ql.Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsxRuntime.jsx("textarea",{value:y.alt||"",onChange:C=>ka(y.id,{alt:C.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.describeThisAsset",{defaultValue:"Describe this asset..."})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Caption"}),jsxRuntime.jsx("textarea",{value:y.caption||"",onChange:C=>ka(y.id,{caption:C.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.addACaption",{defaultValue:"Add a caption..."})})]})]})]})]}),!r&&jsxRuntime.jsxs("div",{className:"pt-8 border-t border-[var(--kyro-border)] mt-8 flex gap-3 pb-8",children:[jsxRuntime.jsxs("button",{onClick:()=>{let C=document.createElement("a");C.href=Lr(y.url),C.download=y.filename,C.click();},className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg hover:opacity-90 transition-all",children:[jsxRuntime.jsx(Ql.Download,{className:"w-4 h-4"}),"Download"]}),y.type==="image"&&i&&jsxRuntime.jsx("button",{onClick:()=>z(true),className:"p-3 border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:jsxRuntime.jsx(Ql.Crop,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{onClick:()=>{ft({title:"Delete Asset",message:`Are you sure you want to delete ${y.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await At(`/api/media/${y.id}`),w(null),le(1);}catch(C){console.error("Delete failed:",C),V.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"})})]})]})}),D&&y&&jsxRuntime.jsxs(St,{open:D,onClose:()=>U(false),title:"",size:"full",variant:"lightbox",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:y.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[Bn(y.fileSize)," \xB7 ",y.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>U(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(Ql.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:y.type==="image"?jsxRuntime.jsx("img",{src:In(y)||Lr(y.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):y.type==="video"?jsxRuntime.jsx("video",{src:Lr(y.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxRuntime.jsxs("div",{className:"text-white text-center",children:[jsxRuntime.jsx(Ql.File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsxRuntime.jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&O&&y&&jsxRuntime.jsx(St,{open:O,onClose:()=>z(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsx(Vl,{url:Lr(y.url),initialCrop:y.metadata?.crop,initialHotspot:y.metadata?.hotspot,onSave:Za,onCancel:()=>z(false),isSaving:P})}),!r&&jsxRuntime.jsx(Ll,{open:oe,onClose:()=>ie(false),onSubmit:Jt,title:o("tooltips.createNewFolder",{defaultValue:"Create New Folder"}),placeholder:o("fields.folderName",{defaultValue:"Folder name"})}),!r&&jsxRuntime.jsx(St,{open:re,onClose:()=>H(false),title:o("tooltips.storageNotConfigured",{defaultValue:"Storage Not Configured"}),size:"md",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--kyro-sidebar-active)] flex items-center justify-center",children:jsxRuntime.jsx(Ql.Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mb-6 text-sm",children:"Before uploading media, you need to configure your storage settings. Choose where files should be stored and how URLs are generated."}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsx("a",{href:`${Ue}/settings/storage-settings`,className:"flex-1 px-4 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-center hover:opacity-90 transition-colors",children:"Configure Storage"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{dt("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{H(false),De(true),window.location.reload();}).catch(()=>{V.error("Failed to configure storage");});},className:"flex-1 px-4 py-3 border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded-xl font-bold hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Use Defaults"})]})]})}),!r&&jsxRuntime.jsx("input",{type:"file",ref:K,onChange:C=>{C.target.files&&B(C.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var Up=[{name:"Default",value:"inherit"},{name:"Red",value:"#ef4444"},{name:"Orange",value:"#f97316"},{name:"Amber",value:"#f59e0b"},{name:"Emerald",value:"#10b981"},{name:"Blue",value:"#3b82f6"},{name:"Indigo",value:"#6366f1"},{name:"Violet",value:"#8b5cf6"},{name:"Rose",value:"#f43f5e"},{name:"Slate",value:"#64748b"}],ql=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let{t:a}=reactI18next.useTranslation(),[n,s]=Ta.useState(null),i=Ta.useRef(null);if(Ta.useEffect(()=>{function p(h){i.current&&!i.current.contains(h.target)&&s(null);}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]),!e)return null;let l=()=>{o();},d=()=>{let p=e.getAttributes("link").href,h=window.prompt("URL",p);if(h!==null){if(h===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:h}).run();}},c=p=>{p==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(p).run(),s(null);},u=p=>{s(n===p?null:p);},m=()=>e.isActive("heading",{level:1})?"Heading 1":e.isActive("heading",{level:2})?"Heading 2":e.isActive("heading",{level:3})?"Heading 3":e.isActive("heading",{level:4})?"Heading 4":"Normal Text",v=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(Ql.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(Ql.AlignRight,{size:12}):jsxRuntime.jsx(Ql.AlignLeft,{size:12}),x=()=>e.isActive("orderedList")?jsxRuntime.jsx(Ql.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(Ql.CheckSquare,{size:12}):jsxRuntime.jsx(Ql.List,{size:12}),g=()=>e.isActive("codeBlock")?jsxRuntime.jsx(Ql.Terminal,{size:12}):jsxRuntime.jsx(Ql.Quote,{size:12}),f=({onClick:p,isActive:h=false,disabled:A=false,children:$,title:T})=>jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:A,title:T,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
|
|
10
|
+
${h?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xs scale-95":"text-[var(--kyro-text)] hover:bg-[var(--kyro-bg-hover)]"}
|
|
11
|
+
${A?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:$}),b=({onClick:p,isActive:h,children:A,title:$})=>jsxRuntime.jsxs("button",{type:"button",onClick:p,title:$,className:`px-2 py-1 rounded flex items-center gap-1 transition-all duration-150 text-xs border border-transparent hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] active:scale-98
|
|
12
|
+
${h?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[A,jsxRuntime.jsx(Ql.ChevronDown,{size:10,className:"opacity-60"})]});return jsxRuntime.jsxs("div",{ref:i,className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg select-none",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().chain().focus().undo().run(),title:a("tooltips.undoCtrlz",{defaultValue:"Undo (Ctrl+Z)"}),children:jsxRuntime.jsx(Ql.Undo,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().chain().focus().redo().run(),title:a("tooltips.redoCtrly",{defaultValue:"Redo (Ctrl+Y)"}),children:jsxRuntime.jsx(Ql.Redo,{size:12})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleBold().run(),disabled:!e.can().chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:a("tooltips.boldCtrlb",{defaultValue:"Bold (Ctrl+B)"}),children:jsxRuntime.jsx(Ql.Bold,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleItalic().run(),disabled:!e.can().chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:a("tooltips.italicCtrli",{defaultValue:"Italic (Ctrl+I)"}),children:jsxRuntime.jsx(Ql.Italic,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleUnderline().run(),disabled:!e.can().chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:a("tooltips.underlineCtrlu",{defaultValue:"Underline (Ctrl+U)"}),children:jsxRuntime.jsx(Ql.Underline,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleStrike().run(),disabled:!e.can().chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:a("tooltips.strikethrough",{defaultValue:"Strikethrough"}),children:jsxRuntime.jsx(Ql.Strikethrough,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleCode().run(),disabled:!e.can().chain().focus().toggleCode().run(),isActive:e.isActive("code"),title:a("tooltips.inlineCode",{defaultValue:"Inline Code"}),children:jsxRuntime.jsx(Ql.Code,{size:12})}),jsxRuntime.jsx(f,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:a("tooltips.highlightText",{defaultValue:"Highlight Text"}),children:jsxRuntime.jsx(Ql.Highlighter,{size:12})}),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center",children:[jsxRuntime.jsx(f,{onClick:()=>u("color"),title:a("tooltips.textColor",{defaultValue:"Text Color"}),isActive:n==="color"||e.isActive("textStyle"),children:jsxRuntime.jsx(Ql.Palette,{size:12})}),n==="color"&&jsxRuntime.jsx("div",{className:"absolute top-full left-0 mt-1.5 p-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 flex flex-wrap gap-1 w-44 animate-in fade-in slide-in-from-top-1 duration-150",children:Up.map(p=>jsxRuntime.jsx("button",{type:"button",onClick:()=>c(p.value),title:p.name,className:"w-6 h-6 rounded-full border border-[var(--kyro-border)] transition-transform hover:scale-115 active:scale-95 cursor-pointer relative",style:{backgroundColor:p.value==="inherit"?"transparent":p.value},children:p.value==="inherit"&&jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] text-[var(--kyro-text)] font-semibold",children:"\u2205"})},p.name))})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("heading"),isActive:n==="heading",title:a("tooltips.headingHierarchy",{defaultValue:"Heading hierarchy"}),children:jsxRuntime.jsx("span",{className:"font-medium text-[11px] leading-none min-w-[70px] text-left",children:m()})}),n==="heading"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{e.chain().focus().setParagraph().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
|
|
13
|
+
${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(p=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:p}).run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
|
|
14
|
+
${e.isActive("heading",{level:p})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",p]},p))]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("lists"),isActive:n==="lists",title:a("tooltips.listTypes",{defaultValue:"List Types"}),children:x()}),n==="lists"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBulletList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
15
|
+
${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.List,{size:12}),"Bullet List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleOrderedList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
16
|
+
${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.ListOrdered,{size:12}),"Ordered List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleTaskList().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
17
|
+
${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.CheckSquare,{size:12}),"Task Checklist"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("blocks"),isActive:n==="blocks",title:a("tooltips.structuralBlocks",{defaultValue:"Structural Blocks"}),children:g()}),n==="blocks"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBlockquote().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
18
|
+
${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.Quote,{size:12}),"Blockquote"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleCodeBlock().run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
19
|
+
${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.Terminal,{size:12}),"Code Block"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),s(null);},className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors",children:[jsxRuntime.jsx(Ql.Minus,{size:12}),"Horizontal Rule"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(b,{onClick:()=>u("align"),isActive:n==="align",title:a("tooltips.alignment",{defaultValue:"Alignment"}),children:v()}),n==="align"&&jsxRuntime.jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-32 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("left").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
20
|
+
${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.AlignLeft,{size:12}),"Align Left"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("center").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
21
|
+
${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.AlignCenter,{size:12}),"Align Center"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("right").run(),s(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
22
|
+
${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Ql.AlignRight,{size:12}),"Align Right"]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(f,{onClick:d,isActive:e.isActive("link"),title:a("tooltips.link",{defaultValue:"Link"}),children:jsxRuntime.jsx(Ql.Link,{size:12})}),jsxRuntime.jsx(f,{onClick:l,title:a("tooltips.addImage",{defaultValue:"Add Image"}),children:jsxRuntime.jsx(Ql.Image,{size:12})})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs ml-auto",children:jsxRuntime.jsx(f,{onClick:()=>r(!t),title:t?"Collapse Workspace":"Enlarge Workspace",children:t?jsxRuntime.jsx(Ql.Minimize2,{size:12}):jsxRuntime.jsx(Ql.Maximize2,{size:12})})})]})};function Wo({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false);return Ta.useEffect(()=>{s(true);},[]),n?jsxRuntime.jsx(jp,{field:e,value:t,onChange:r,error:o,disabled:a}):jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
|
|
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 jp({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=reactI18next.useTranslation(),[s,i]=Ta.useState(false),[l,d]=Ta.useState(0),[c,u]=Ta.useState(false);Ta.useEffect(()=>{if(!s){d(0);return}let v=document.querySelector('[data-kyro-slide-panel="true"]'),x=()=>{d(v?v.getBoundingClientRect().width:0);};x();let g=new MutationObserver(()=>{x();});v&&g.observe(v),window.addEventListener("resize",x);let f=setInterval(x,100);return ()=>{g&&g.disconnect(),window.removeEventListener("resize",x),clearInterval(f);}},[s]);let m=react.useEditor({extensions:[gp__default.default.configure({codeBlock:true,link:false,underline:false}),vp__default.default.configure({openOnClick:false}),bp__default.default,xp__default.default.configure({types:["heading","paragraph"]}),kp__default.default,hp__default.default.configure({multicolor:true}),wp__default.default,Np__default.default.configure({nested:true}),extensionTextStyle.TextStyle,Sp__default.default],content:Array.isArray(t)?{type:"doc",content:t}:t||{type:"doc",content:[]},editable:!a,onUpdate:({editor:v})=>{r(v.getJSON());},editorProps:{attributes:{class:"prose prose-sm dark:prose-invert focus:outline-none min-h-[160px] p-4 max-w-none kyro-richtext text-[0.875rem] leading-relaxed"}}});return Ta.useEffect(()=>{m&&t&&JSON.stringify(t)!==JSON.stringify(m.getJSON())&&m.commands.setContent(Array.isArray(t)?{type:"doc",content:t}:t);},[t,m]),jsxRuntime.jsxs(ct,{field:e,error:o,children:[s?jsxRuntime.jsxs("div",{className:"border rounded-lg bg-[var(--kyro-bg-secondary)] border-[var(--kyro-border)] p-4 text-center text-xs text-[var(--kyro-text-muted)] flex items-center justify-center gap-3 h-20 transition-all duration-200 shadow-inner",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Rich text editor workspace is currently maximized."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(false),className:"px-2.5 py-1 bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] text-xs rounded-md shadow-sm font-medium hover:scale-102 active:scale-98 transition-transform cursor-pointer",children:"Minimize Workspace"})]}):jsxRuntime.jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
|
|
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(ql,{editor:m,isExpanded:s,setIsExpanded:i,onOpenMediaPicker:()=>u(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px]",children:jsxRuntime.jsx(react.EditorContent,{editor:m})})]}),s&&typeof document<"u"&&reactDom.createPortal(jsxRuntime.jsxs("div",{style:{position:"fixed",top:"16px",bottom:"16px",left:"16px",right:l>0?`${l+16}px`:"16px",zIndex:9999},className:"flex flex-col bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-200 transition-all duration-300",children:[jsxRuntime.jsx(ql,{editor:m,isExpanded:s,setIsExpanded:i,onOpenMediaPicker:()=>u(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1 h-[calc(100vh-140px)] bg-[var(--kyro-bg)]",children:jsxRuntime.jsx(react.EditorContent,{editor:m})})]}),document.body),jsxRuntime.jsx("style",{children:`
|
|
27
27
|
.kyro-richtext ul[data-type="taskList"] {
|
|
28
28
|
list-style: none !important;
|
|
29
29
|
padding: 0 !important;
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
font-style: italic !important;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
`}),c&&jsxRuntime.jsx(ur,{open:c,onClose:()=>d(false),title:"Select Image",width:"xl",children:jsxRuntime.jsx($n,{pickerMode:true,multiple:false,onSelect:x=>{if(x&&x.length>0){let b=x[0];m.chain().focus().setImage({src:b.url,alt:b.alt||b.title||"",title:b.title||""}).run();}d(false);}})})]})}var Wl=Object.keys(ql__namespace).filter(e=>/^[A-Z]/.test(e)&&e!=="LucideProps"&&e!=="Icon");function Xl({open:e,onClose:t,onSelect:r}){let[o,a]=Da.useState(""),n=Da.useMemo(()=>{if(!o)return Wl;let s=o.toLowerCase();return Wl.filter(l=>l.toLowerCase().includes(s))},[o]);return jsxRuntime.jsx(St,{open:e,onClose:t,title:"Select an Icon",size:"xl",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-[60vh]",children:[jsxRuntime.jsxs("div",{className:"relative mb-6",children:[jsxRuntime.jsx(ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search icons...",value:o,onChange:s=>a(s.target.value),className:"w-full pl-10 pr-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all text-sm font-bold"})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 custom-scrollbar pr-2",children:n.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-[var(--kyro-text-secondary)] font-medium",children:"No icons found"}):jsxRuntime.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-3 pb-8",children:n.map(s=>{let l=ql__namespace[s],i=s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i),t();},className:"flex flex-col items-center justify-center p-3 gap-2 rounded-md border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group",title:s,children:jsxRuntime.jsx(l,{className:"w-6 h-6 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors",strokeWidth:1.5})},s)})})})]})})}function Un({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Da.useState(false),l=t==null?"":String(t),i=Da.useMemo(()=>l?l.split("-").map(m=>m.charAt(0).toUpperCase()+m.slice(1)).join(""):"",[l]),c=ql__namespace[i],d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsxs(ct,{field:e,error:o,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"flex-1 relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:l,onChange:m=>r?.(m.target.value),placeholder:e.admin?.placeholder||"e.g., activity",disabled:a||d,required:e.required,className:`kyro-form-input ${a||d?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`})}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),disabled:a||d,className:"flex items-center gap-2 h-10 px-4 shrink-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-sm font-bold text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[c?jsxRuntime.jsx(c,{className:"w-5 h-5",strokeWidth:2}):jsxRuntime.jsx(ql__namespace.Search,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),"Browse"]})]}),n&&jsxRuntime.jsx(Xl,{open:n,onClose:()=>s(false),onSelect:m=>{r?.(m);}})]})}var Yo={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)"}},$a={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 Oa(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 ed=Da.createContext(null);function Qo(){let e=Da.useContext(ed);return e||{mode:"light",theme:Yo,lightTheme:Yo,darkTheme:$a,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function Ql(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`,Zl(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Zl(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 Zl(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 Tr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=Da.useState(t),[s,l]=Da.useState(r||{}),[i,c]=Da.useState(o||{}),d=Oa(Yo,s),m=Oa($a,i),x=Da.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?m:d:a==="dark"?m:d,[a,d,m]),[b,k]=Da.useState(x());Da.useEffect(()=>{let p=x();k(p),Ql(p);},[x]),Da.useEffect(()=>{if(a!=="system")return;let p=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>{let v=x();k(v),Ql(v);};return p.addEventListener("change",u),()=>p.removeEventListener("change",u)},[a,x]);let f=Da.useCallback(p=>{l(u=>({...u,...p})),c(u=>({...u,...p}));},[]),g=Da.useCallback(p=>`var(--kyro-${p})`,[]);return jsxRuntime.jsx(ed.Provider,{value:{mode:a,theme:b,lightTheme:d,darkTheme:m,setMode:n,updateTheme:f,getCssVar:g},children:e})}var jn=e=>jsxRuntime.jsx(Tr,{defaultMode:"light",...e}),_n=e=>jsxRuntime.jsx(Tr,{defaultMode:"dark",...e});var Hm=Da.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),Vm=[{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"}],rd={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())},Ua=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Da.useState(false),[l,i]=Da.useState(false),[c,d]=Da.useState([]),[m,x]=Da.useState(false),[b,k]=Da.useState(false),[f,g]=Da.useState(false),{theme:p}=Qo(),u=p.colors?.accent||p.colors?.primary||"#6366f1",v=e.language?.toLowerCase()||"javascript";Da.useEffect(()=>{s(true),i(document.documentElement.classList.contains("dark"));let O=new MutationObserver(()=>{i(document.documentElement.classList.contains("dark"));});return O.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>O.disconnect()},[]),Da.useEffect(()=>{if(!n)return;(async()=>{x(true);try{let K=await(rd[v]||rd.javascript)();d([K]);}catch(L){console.error("Failed to load language extension:",L),d([]);}finally{x(false);}})();},[v,n]);let R=Da.useCallback(O=>r?.(O),[r]),P=Da.useCallback(()=>{navigator.clipboard.writeText(t),k(true),setTimeout(()=>k(false),1500);},[t]),h=Da.useCallback(()=>{g(O=>!O),document.body.style.overflow=f?"":"hidden";},[f]),w=l?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,y=Vm.find(O=>O.value===v)?.label||v,S=(O,L=1)=>{let K=parseInt(O.slice(1,3),16),C=parseInt(O.slice(3,5),16),G=parseInt(O.slice(5,7),16);return `rgba(${K}, ${C}, ${G}, ${L})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":u,"--accent-light":S(u,.1),"--accent-light-2":S(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?"...":y})]}),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:b?"var(--kyro-success)":"var(--kyro-surface-accent)",color:b?"white":"var(--kyro-text-secondary)"},children:b?"Copied":"Copy"}),jsxRuntime.jsx("button",{type:"button",onClick:h,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:f?"Exit":"Expand"})]})]}),jsxRuntime.jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${f?"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(Da.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(Hm,{value:t??"",height:f?"calc(100vh - 100px)":"280px",width:"100%",extensions:c,theme:w,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
|
+
`}),c&&jsxRuntime.jsx(yr,{open:c,onClose:()=>u(false),title:n("tooltips.selectImage",{defaultValue:"Select Image"}),width:"xl",children:jsxRuntime.jsx(En,{pickerMode:true,multiple:false,onSelect:v=>{if(v&&v.length>0){let x=v[0];m.chain().focus().setImage({src:x.url,alt:x.alt||x.title||"",title:x.title||""}).run();}u(false);}})})]})}var Xl=Object.keys(Ql__namespace).filter(e=>/^[A-Z]/.test(e)&&e!=="LucideProps"&&e!=="Icon");function Zl({open:e,onClose:t,onSelect:r}){let{t:o}=reactI18next.useTranslation(),[a,n]=Ta.useState(""),s=Ta.useMemo(()=>{if(!a)return Xl;let i=a.toLowerCase();return Xl.filter(l=>l.toLowerCase().includes(i))},[a]);return jsxRuntime.jsx(St,{open:e,onClose:t,title:o("tooltips.selectAnIcon",{defaultValue:"Select an Icon"}),size:"xl",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-[60vh]",children:[jsxRuntime.jsxs("div",{className:"relative mb-6",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:o("fields.searchIcons",{defaultValue:"Search icons..."}),value:a,onChange:i=>n(i.target.value),className:"w-full pl-10 pr-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all text-sm font-bold"})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 custom-scrollbar pr-2",children:s.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-[var(--kyro-text-secondary)] font-medium",children:"No icons found"}):jsxRuntime.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-3 pb-8",children:s.map(i=>{let l=Ql__namespace[i],d=i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(d),t();},className:"flex flex-col items-center justify-center p-3 gap-2 rounded-md border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group",title:i,children:jsxRuntime.jsx(l,{className:"w-6 h-6 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors",strokeWidth:1.5})},i)})})})]})})}function Ln({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false),i=t==null?"":String(t),l=Ta.useMemo(()=>i?i.split("-").map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(""):"",[i]),d=Ql__namespace[l],c=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsxs(ct,{field:e,error:o,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"flex-1 relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:i,onChange:u=>r?.(u.target.value),placeholder:e.admin?.placeholder||"e.g., activity",disabled:a||c,required:e.required,className:`kyro-form-input ${a||c?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`})}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),disabled:a||c,className:"flex items-center gap-2 h-10 px-4 shrink-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-sm font-bold text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[d?jsxRuntime.jsx(d,{className:"w-5 h-5",strokeWidth:2}):jsxRuntime.jsx(Ql__namespace.Search,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),"Browse"]})]}),n&&jsxRuntime.jsx(Zl,{open:n,onClose:()=>s(false),onSelect:u=>{r?.(u);}})]})}var qo={id:"light",label:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",background:"#f8fafc",surface:"#ffffff",text:"#0f172a",textMuted:"#64748b",border:"#e2e8f0",success:"#22c55e",error:"#ef4444",warning:"#f59e0b",info:"#06b6d4"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1)"}},Ea={id:"dark",label:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",background:"#0b1222",surface:"#1e293b",text:"#f1f5f9",textMuted:"#94a3b8",border:"#334155",success:"#4ade80",error:"#f87171",warning:"#fbbf24",info:"#22d3ee"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.5)"}};function Ma(e,t){return {...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows},blocks:e.blocks?{...e.blocks,...t.blocks}:t.blocks,fields:e.fields?{...e.fields,...t.fields}:t.fields}}var od=Ta.createContext(null);function Jo(){let e=Ta.useContext(od);return e||{mode:"light",theme:qo,lightTheme:qo,darkTheme:Ea,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function td(e){let t=document.documentElement;t&&(e.colors&&Object.entries(e.colors).forEach(([r,o])=>{o&&(t.style.setProperty(`--kyro-${r}`,o),t.style.setProperty(`--kyro-${r}-light`,rd(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,rd(o,.8)));}),e.typography&&(e.typography.fontFamily&&t.style.setProperty("--kyro-font-family",e.typography.fontFamily),e.typography.fontFamilyMono&&t.style.setProperty("--kyro-font-mono",e.typography.fontFamilyMono)),e.spacing&&Object.entries(e.spacing).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-spacing-${r}`,o);}),e.borderRadius&&Object.entries(e.borderRadius).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-radius-${r}`,o);}),e.shadows&&Object.entries(e.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-shadow-${r}`,o);}),e.blocks&&(e.blocks.card&&Object.entries(e.blocks.card).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-card-${r}`,o);}),e.blocks.hero?.background&&t.style.setProperty("--kyro-block-hero-bg",e.blocks.hero.background),e.blocks.code&&Object.entries(e.blocks.code).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-code-${r}`,o);})),e.fields&&(e.fields.input&&Object.entries(e.fields.input).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-field-input-${r}`,o);}),e.fields.upload&&e.fields.upload.dropzoneBackground&&t.style.setProperty("--kyro-field-upload-dropzone-bg",e.fields.upload.dropzoneBackground)));}function rd(e,t){if(!e.startsWith("#"))return e;let r=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16),n=s=>Math.round(s*t).toString(16).padStart(2,"0");return `#${n(r)}${n(o)}${n(a)}`}function Sr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=Ta.useState(t),[s,i]=Ta.useState(r||{}),[l,d]=Ta.useState(o||{}),c=Ma(qo,s),u=Ma(Ea,l),m=Ta.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?u:c:a==="dark"?u:c,[a,c,u]),[v,x]=Ta.useState(m());Ta.useEffect(()=>{let b=m();x(b),td(b);},[m]),Ta.useEffect(()=>{if(a!=="system")return;let b=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{let h=m();x(h),td(h);};return b.addEventListener("change",p),()=>b.removeEventListener("change",p)},[a,m]);let g=Ta.useCallback(b=>{i(p=>({...p,...b})),d(p=>({...p,...b}));},[]),f=Ta.useCallback(b=>`var(--kyro-${b})`,[]);return jsxRuntime.jsx(od.Provider,{value:{mode:a,theme:v,lightTheme:c,darkTheme:u,setMode:n,updateTheme:g,getCssVar:f},children:e})}var Vn=e=>jsxRuntime.jsx(Sr,{defaultMode:"light",...e}),On=e=>jsxRuntime.jsx(Sr,{defaultMode:"dark",...e});var em=Ta.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),tm=[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"json",label:"JSON"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"sql",label:"SQL"},{value:"python",label:"Python"},{value:"rust",label:"Rust"},{value:"java",label:"Java"},{value:"php",label:"PHP"},{value:"markdown",label:"Markdown"}],nd={javascript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),typescript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),js:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),jsx:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),ts:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({typescript:true})),json:()=>import('@codemirror/lang-json').then(e=>e.json()),css:()=>import('@codemirror/lang-css').then(e=>e.css()),sql:()=>import('@codemirror/lang-sql').then(e=>e.sql()),python:()=>import('@codemirror/lang-python').then(e=>e.python()),html:()=>import('@codemirror/lang-html').then(e=>e.html()),rust:()=>import('@codemirror/lang-rust').then(e=>e.rust()),java:()=>import('@codemirror/lang-java').then(e=>e.java()),cpp:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),c:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),php:()=>import('@codemirror/lang-php').then(e=>e.php()),markdown:()=>import('@codemirror/lang-markdown').then(e=>e.markdown()),py:()=>import('@codemirror/lang-python').then(e=>e.python())},La=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ta.useState(false),[i,l]=Ta.useState(false),[d,c]=Ta.useState([]),[u,m]=Ta.useState(false),[v,x]=Ta.useState(false),[g,f]=Ta.useState(false),{theme:b}=Jo(),p=b.colors?.accent||b.colors?.primary||"#6366f1",h=e.language?.toLowerCase()||"javascript";Ta.useEffect(()=>{s(true),l(document.documentElement.classList.contains("dark"));let D=new MutationObserver(()=>{l(document.documentElement.classList.contains("dark"));});return D.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>D.disconnect()},[]),Ta.useEffect(()=>{if(!n)return;(async()=>{m(true);try{let O=await(nd[h]||nd.javascript)();c([O]);}catch(U){console.error("Failed to load language extension:",U),c([]);}finally{m(false);}})();},[h,n]);let A=Ta.useCallback(D=>r?.(D),[r]),$=Ta.useCallback(()=>{navigator.clipboard.writeText(t),x(true),setTimeout(()=>x(false),1500);},[t]),T=Ta.useCallback(()=>{f(D=>!D),document.body.style.overflow=g?"":"hidden";},[g]),k=i?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,y=tm.find(D=>D.value===h)?.label||h,w=(D,U=1)=>{let O=parseInt(D.slice(1,3),16),z=parseInt(D.slice(3,5),16),P=parseInt(D.slice(5,7),16);return `rgba(${O}, ${z}, ${P}, ${U})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":p,"--accent-light":w(p,.1),"--accent-light-2":w(p,.05)},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsxRuntime.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold transition-colors",style:{backgroundColor:u?"var(--kyro-surface-accent)":p,color:u?"var(--kyro-text-muted)":"white"},children:u?"...":y})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:$,className:"text-[10px] px-2 py-0.5 rounded font-medium transition-all",style:{backgroundColor:v?"var(--kyro-success)":"var(--kyro-surface-accent)",color:v?"white":"var(--kyro-text-secondary)"},children:v?"Copied":"Copy"}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"text-[10px] px-2 py-0.5 rounded font-medium bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] transition-all",style:{color:"var(--kyro-text-secondary)"},children:g?"Exit":"Expand"})]})]}),jsxRuntime.jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${g?"fixed inset-4 z-50":""}`,style:{backgroundColor:"var(--kyro-surface)",borderColor:o?"var(--kyro-error)":"var(--kyro-border)",borderWidth:"1px"},children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 transition-all duration-200",style:{backgroundColor:p}}),jsxRuntime.jsx(Ta.Suspense,{fallback:jsxRuntime.jsx("div",{className:"h-[280px] flex items-center justify-center",style:{backgroundColor:"var(--kyro-surface)"},children:jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full animate-spin",style:{borderColor:"var(--kyro-border)",borderTopColor:p,borderWidth:"2px"}})}),children:jsxRuntime.jsx(em,{value:t??"",height:g?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:k,onChange:A,editable:!a,basicSetup:{lineNumbers:true,highlightActiveLine:true,bracketMatching:true,closeBrackets:true,autocompletion:true,foldGutter:true},style:{fontSize:"13px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"}})}),o&&jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 right-0 px-3 py-2 text-xs font-medium",style:{backgroundColor:"var(--kyro-danger-bg)",color:"var(--kyro-error)"},children:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px]",style:{color:"var(--kyro-text-muted)"},children:[jsxRuntime.jsxs("span",{children:[t.split(`
|
|
83
|
+
`).length," lines"]}),jsxRuntime.jsx("span",{style:{color:p},children:"CodeMirror"})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-5 w-24 rounded bg-[var(--kyro-surface-accent)] animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-16 rounded bg-[var(--kyro-surface-accent)] animate-pulse"})]}),jsxRuntime.jsx("div",{className:"h-[280px] rounded-xl bg-[var(--kyro-surface-accent)] animate-pulse"})]})};function sm(e){return e?e.replace(/&/g,"&").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 Gs=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let{t:n}=reactI18next.useTranslation(),[s,i]=Ta.useState(false),[l,d]=Ta.useState(false);Ta.useEffect(()=>{d(true);},[]);let c=Ta.useCallback(v=>{r?.(v.target.value);},[r]),u=Ta.useMemo(()=>t?t.trim().split(/\s+/).filter(Boolean).length:0,[t]),m=t?.length||0;return l?jsxRuntime.jsxs("div",{className:"kyro-form-field",style:{position:"relative",zIndex:10,pointerEvents:"auto"},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[u," words \u2022 ",m," chars"]}),jsxRuntime.jsxs("div",{className:"flex rounded-md overflow-hidden border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(false),className:`px-3 py-1 text-xs font-medium transition-colors ${s?"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"}`,children:"Write"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(true),className:`px-3 py-1 text-xs font-medium transition-colors ${s?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:"Preview"})]})]})]}),jsxRuntime.jsx("div",{style:{pointerEvents:"auto",position:"relative",zIndex:50},className:`border border-[var(--kyro-border)] rounded-md overflow-hidden ${a?"opacity-50 cursor-not-allowed":""} ${o?"border-[var(--kyro-error)]":""}`,children:s?jsxRuntime.jsx("div",{className:"p-6 min-h-[300px] overflow-auto bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",children:t?jsxRuntime.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:sm(t)}}):jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-muted)] italic",children:"Nothing to preview"})}):jsxRuntime.jsx("textarea",{value:t??"",onChange:c,disabled:a,rows:12,style:{pointerEvents:"auto",cursor:"text",zIndex:100},className:"w-full p-4 font-mono text-sm resize-y focus:outline-none bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",placeholder:n("fields.enterMarkdownContentHeading",{defaultValue:`Enter markdown content...
|
|
84
84
|
|
|
85
85
|
# Heading 1
|
|
86
86
|
## Heading 2
|
|
@@ -96,16 +96,54 @@
|
|
|
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 Hn({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Da.useState(false),[l,i]=Da.useState(false),c=t??"",d=c.length>8?c.slice(0,-8)+"*".repeat(8):c,m=async()=>{if(c)try{await navigator.clipboard.writeText(c),s(!0),setTimeout(()=>s(!1),1800);}catch{let b=document.createElement("textarea");b.value=c,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),s(true),setTimeout(()=>s(false),1800);}},x=()=>{if(l||a)return;i(true);let b=new Uint8Array(32);crypto.getRandomValues(b);let k=Array.from(b).map(f=>f.toString(16).padStart(2,"0")).join("");r?.(k),setTimeout(()=>i(false),400);};return jsxRuntime.jsx(ct,{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:d,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:!c||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(ql.Check,{className:"w-3.5 h-3.5 text-[var(--kyro-success)]"}):jsxRuntime.jsx(ql.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:x,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(ql.RefreshCw,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})})}function Co(e,t){if(e===t)return true;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return false;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!Co(e[a],t[a]))return false;return true}if(Array.isArray(e)||Array.isArray(t))return false;let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return false;for(let a of r)if(!Object.prototype.hasOwnProperty.call(t,a)||!Co(e[a],t[a]))return false;return true}function Xs(e){if(e==null||e===""||e===false)return true;if(Array.isArray(e))return e.length===0;if(typeof e=="object"){if(Object.keys(e).length===0)return true;if(e.type==="doc"&&Array.isArray(e.content))return e.content.length===0||e.content.length===1&&e.content[0].type==="paragraph"&&!e.content[0].content}return false}function Wt(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(Wt);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]=Wt(t[s]);return n}return e}var Vn=null,nd=false,Ys=async()=>(Vn&&nd||(Vn=unstorage.createStorage({driver:eu__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),nd=true),Vn),tu=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Ys()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Ys()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Ys()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},Ce=zustand.create()(middleware.persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,previewUrl:null,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields),s=Wt(o),l=Wt(a.lastSavedData[r]);Xs(s)&&Xs(l)||Co(s,l)?n.delete(r):n.add(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),s={...a.formData},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})),setPreviewUrl:r=>e({previewUrl:r}),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[s,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(()=>tu()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function Kn(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function ta({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:c,formData:d}=Ce(),m=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",x=t==null?"":String(t),b={id:e.name,value:x,onChange:k=>r?.(k.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(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"relative",children:[s?jsxRuntime.jsx("textarea",{...b,rows:e.rows||4}):jsxRuntime.jsx("input",{type:m,...b,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?.(Kn(d[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:()=>c(!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:x.length>60?"text-red-500":x.length>=40?"text-green-500":"text-amber-600",children:[x.length," / 60 \u2014 ",x.length>60?"Too Long":x.length>=40?"Ideal":"Short"]})})]})})}function Gn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("input",{type:"number",id:e.name,value:t??"",onChange:s=>r?.(parseFloat(s.target.value)||0),placeholder:e.admin?.placeholder,disabled:a||n,min:e.min,max:e.max,step:e.step||(e.integer?1:"any"),required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Wn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,hideLabel:true,children:jsxRuntime.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t??false,onChange: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 Jn({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:s=>r?.(s.target.value),disabled:a||n,min:e.minDate,max:e.maxDate,required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function ja(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Xn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Yn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function za(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 ou={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function So(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 So(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)&&So(i.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let i=n.split(".")[0],c=n.split(".").slice(1).join(".");if(!c)return false;for(let d of s.blocks)if(d.slug===i&&d.fields&&Array.isArray(d.fields))return So(d.fields,c,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?So(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)&&So(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)&&So(i.fields,t,r))return true}}}return false}function au(e,t){for(let[r,o]of Object.entries(e)){let a=ou[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,c]of Object.entries(s))So(o.fields,i,c);}}}function nu(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 za(t,Object.values(templates.mediaCollections)),za(t,Object.values(templates.authCollections)),{collections:Xn(t),globals:Yn(r)}}function su(e){let t=ja(e.collections),r=ja(e.globals);if(t.length===0&&r.length===0)return nu("kitchen-sink");let o=[];return za(o,Object.values(templates.mediaCollections)),za(o,Object.values(templates.authCollections)),za(o,t),{collections:Xn(o),globals:Yn(r)}}var qn=null;function iu(){if(qn)return qn;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Oo__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return qn=JSON.parse(Oo__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),qn}catch{}return null}var gd=iu()||{collections:[],globals:[]},bd=su(gd);au(bd.collections,gd.collectionOverrides);var xd=bd,ra=xd.collections,kd=xd.globals,ei=["users","audit_logs"];Object.values(ra).filter(e=>!ei.includes(e.slug)&&e.admin?.hidden!==true);function Qn({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i}){let c=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[d,m]=Da.useState(null),x=JSON.stringify(n||{}),b=JSON.stringify(s||{});Da.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let g=setTimeout(async()=>{try{let p="";if(l)p=`${wr}/${l}/dynamic-options/${e.name}`;else if(i)p=`${wr}/globals/${i}/dynamic-options/${e.name}`;else return;let u=await lt(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(x),siblingData:JSON.parse(b)})});if(u.ok){let v=await u.json();v.options&&m(v.options);}}catch(p){console.error("Failed to fetch dynamic options:",p);}},300);return ()=>clearTimeout(g)},[x,b,e.name,e.options,l,i]);let k=d||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?k=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(k=e.options)),e.dynamicOptions==="collections"&&(k=Object.keys(ra).filter(f=>f!=="media").map(f=>({label:ra[f]?.label||f,value:f}))),jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:f=>{if(e.hasMany){let g=Array.from(f.target.selectedOptions,p=>p.value);r?.(g);}else r?.(f.target.value||void 0);},multiple:e.hasMany,disabled:a||c,required:e.required,className:`kyro-form-input ${a||c?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),k.map(f=>jsxRuntime.jsx("option",{value:f.value,children:f.label},f.value))]})})}function Zn({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 si(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function hu({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:l,transform:i,transition:c,isDragging:d}=sortable.useSortable({id:e}),m={transform:utilities.CSS.Transform.toString(i),transition:c,zIndex:d?10:1,opacity:d?.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 ${d?"border-[var(--kyro-primary)] shadow-sm bg-[var(--kyro-sidebar-active)]/20":""}`,children:[!a&&jsxRuntime.jsx("div",{...n,...s,className:"cursor-grab active:cursor-grabbing hover:bg-[var(--kyro-sidebar-active)]/20 rounded p-0.5 text-[var(--kyro-sidebar-active)] opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(ql.GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsxRuntime.jsx(ql.X,{className:"w-3 h-3"})})]})}function wu({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Da.useState(false),[l,i]=Da.useState(""),[c,d]=Da.useState([]),[m,x]=Da.useState(false),[b,k]=Da.useState([]),f=Da.useRef(new Set),g=Da.useRef(null),p=Da.useRef(()=>{});p.current=r||(()=>{});let u=e.hasMany,v=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],R=v.length>1,[P,h]=Da.useState(v[0]||""),w=Da.useCallback(()=>t?(u?Array.isArray(t)?t:[]:t?[t]:[]).map(_=>typeof _=="object"&&_!==null?_.value||_.id||"":String(_)).filter(Boolean):[],[t,u]),y=Da.useCallback(j=>{j.length!==0&&j.forEach(_=>{if(f.current.has(_))return;f.current.add(_);let se=R?(()=>{if(!t)return P;let J=(u?Array.isArray(t)?t:[]:[t]).find(de=>typeof de=="object"&&de!==null?de.value===_||de.id===_:false);return J&&typeof J=="object"&&J.relationTo||P})():P;De(`/api/${se}/${_}`).then(te=>{let J=te.data||te;!J||typeof J!="object"||k(de=>de.some(ve=>ve.id===_)?de:[...de,{...J,id:String(J.id),relationTo:se}]);}).catch(()=>{});});},[R,t,P,u]);Da.useEffect(()=>{let j=w();y(j);},[w,y]);let S=Da.useCallback((j="")=>{x(true);let se=`/api/${P}?${pn(j,["title","name","label","email"])}`;De(se).then(te=>{d(J=>{let de=new Set(J.map(Te=>Te.id)),ve=(te.docs||[]).filter(Te=>!de.has(Te.id)).map(Te=>({...Te,id:Te.id}));return [...J,...ve]}),x(false);}).catch(()=>{x(false);});},[P]);Da.useEffect(()=>{n&&(d([]),S(l));},[n,P]),Da.useEffect(()=>{let j=_=>{g.current&&!g.current.contains(_.target)&&s(false);};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);let O=j=>typeof j=="object"&&j!==null?j.value||j.id||"":String(j),L=j=>{let _=j.id;return t?u&&Array.isArray(t)?t.some(se=>O(se)===_):O(t)===_:false},K=j=>{let _=j.id;if(u){let se=Array.isArray(t)?t:[];if(L(j))p.current?.(se.filter(te=>O(te)!==_));else {let te=R?{relationTo:P,value:_}:_;p.current?.([...se,te]);}}else if(L(j))p.current?.(null);else {let se=R?{relationTo:P,value:_}:_;p.current?.(se),s(false),i("");}},C=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),G=j=>{let{active:_,over:se}=j;if(!se||_.id===se.id)return;let te=u?Array.isArray(t)?t:[]:[],J=te.findIndex(ve=>O(ve)===_.id),de=te.findIndex(ve=>O(ve)===se.id);if(J!==-1&&de!==-1){let ve=[...te],[Te]=ve.splice(J,1);ve.splice(de,0,Te),p.current?.(ve);}},z=()=>{if(!t)return null;let j=u?Array.isArray(t)?t:[]:t?[t]:[],_=j.map(se=>O(se));return u&&j.length>1?jsxRuntime.jsx(core.DndContext,{sensors:C,collisionDetection:core.closestCenter,onDragEnd:G,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:_,strategy:sortable.horizontalListSortingStrategy,children:j.map(se=>{let te=O(se),J=b.find(Te=>Te.id===te),de=J?si(J):te.slice(0,12),ve=R&&J?J.relationTo:null;return jsxRuntime.jsx(hu,{id:te,label:de,relation:ve,onRemove:()=>{let Te=j.filter(Ve=>O(Ve)!==te);p.current?.(Te);},disabled:a},te)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:j.map(se=>{let te=O(se),J=b.find(Te=>Te.id===te),de=J?si(J):te.slice(0,12),ve=R&&J?J.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,":"]}),de,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let Te=j.filter(Ve=>O(Ve)!==te);p.current?.(u?Te:Te[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(ql.X,{className:"w-3 h-3"})})]},te)})})};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:g,className:"relative",children:[R&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:v.map(j=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(j),d([]),i("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${P===j?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:j},j))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:j=>{i(j.target.value),s(true),S(j.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(ql.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(ql.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${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..."}):c.length===0?jsxRuntime.jsx(Zn,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:c.map(j=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>K(j),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${L(j)?"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:si(j)}),L(j)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in j&&typeof j.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:j.slug})]},j.id))})}),z()]}),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 _a=wu;var To=Da.createContext(null);function wd(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=ii(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=aa(a),{blocks:l}=o(),i=[...l];n!==void 0?i.splice(n,0,s):i.push(s),r({blocks:i});let{onBlocksChange:c}=o();c&&c();},updateBlock:(a,n)=>{let{blocks:s}=o(),l=Ha(s,i=>{let c=i.findIndex(d=>d.id===a);if(c!==-1){let d=[...i];return d[c]={...d[c],...n},{newList:d,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=Ha(n,l=>{let i=l.filter(c=>c.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=Ha(s,i=>{let c=i.findIndex(d=>d.id===a);if(c!==-1){let d=n==="up"?c-1:c+1;if(d>=0&&d<i.length){let m=[...i];return [m[c],m[d]]=[m[d],m[c]],{newList:m,found:true}}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}}}))}function ii(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=ii(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?ii(o.children):o.children}))}),r}):[]}function aa(e){let t=Tu(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 Tu(e){return {heading:{level:1,text:""},"heading-subheading":{title:"",subtitle:""},hero:{isMultiScreen:false},card:{title:"",description:"",icon:"",link:"",linkText:"",isMultiCard:false},paragraph:{text:""},divider:{},callout:{text:"",variant:"info"},image:{src:"",alt:"",caption:""},video:{src:"",title:""},list:{type:"unordered",items:""},code:{language:"plaintext",code:""},link:{url:"",text:""},table:{rows:3,columns:3,content:""},quote:{text:"",author:""},file:{filename:"",url:""},columns:{columns:2,direction:"horizontal"},vstack:{direction:"vertical",gap:"md"},container:{options:{backgroundColor:"transparent",padding:"md",width:"full",margin:"none",minHeight:"none",borderRadius:"none"},children:[]},button:{text:"Button",url:"",variant:"primary",size:"md"},accordion:{title:"Accordion Item",content:""},gallery:{images:[]},tabs:{tabs:[{label:"Tab 1",content:""}]}}[e]||{}}function _e(e){let t=Da.useContext(To);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 Me(){let e=Da.useContext(To);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 Ha(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 c=Ha(s.children,t);c!==s.children&&(l.children=c,i=true);}if(s.data?.columnData&&Array.isArray(s.data.columnData)){let c=s.data.columnData.map(d=>{if(d.children&&d.children.length>0){let m=Ha(d.children,t);if(m!==d.children)return {...d,children:m}}return d});c.some((d,m)=>d!==s.data.columnData[m])&&(l.data={...l.data,columnData:c},i=true);}return i&&(a=true),i?l:s});return a?n:e}function Ka({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let[n,s]=Da__default.default.useState(null),l=async()=>{try{s(null);let i=await navigator.clipboard.readText(),c=JSON.parse(i);c.__kyro_block?o&&o(c):s("Clipboard does not contain a valid Kyro block.");}catch(i){s("Failed to read block from clipboard."),console.error(i);}};return e?jsxRuntime.jsxs(ur,{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&&jsxRuntime.jsxs("div",{className:"mb-6 pb-6 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 py-2 px-4 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] text-sm font-semibold transition-all hover:bg-[var(--kyro-primary)]/5",children:[jsxRuntime.jsx(ql.ClipboardPaste,{className:"w-4 h-4"}),"Paste Block from Clipboard"]}),n&&jsxRuntime.jsx("p",{className:"text-xs text-red-500 mt-2 text-center font-medium",children:n})]}),a]}):null}function Nd({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 li=({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 Ro=({id:e,type:t,label:r,children:o,className:a=""})=>{let{moveBlock:n,removeBlock:s}=Me();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(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var Td=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o}=Me(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(Ro,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx(li,{text:a.text||"",onChange:n,compact:true})})};var Rd=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o}=Me(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(Ro,{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 Pd=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),s=r?.data||e.data||{},l=(i,c)=>{o(e.id,{data:{...s,[i]:c}});};return jsxRuntime.jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsxRuntime.jsx(mr,{field:{label:"Image Asset",name:"src",maxCount:1},value: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 ci=({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(mr,{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=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),s=r?.data??e.data??{},l=(i,c)=>{o(e.id,{data:{...s,[i]:c}});};return jsxRuntime.jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(ci,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:i=>l("src",i),compact:true})]})};function Uu({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:l,isDragging:i}=sortable.useSortable({id:e}),c={transform:utilities.CSS.Transform.toString(s),transition:l,zIndex:i?10:1,opacity:i?.8:1};return jsxRuntime.jsxs("div",{ref:n,style:c,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:d=>d.stopPropagation(),children:jsxRuntime.jsx(ql.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:"opacity-0 group-hover/item:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",children:"\xD7"})]})}var Ga=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Da__default.default.useState(""),[n,s]=Da__default.default.useState([]);Da__default.default.useEffect(()=>{let b=n.map(k=>k.text);JSON.stringify(b)!==JSON.stringify(e)&&s(e.map((k,f)=>({id:`${k}-${f}-${Math.random().toString(36).substr(2,4)}`,text:k})));},[e]);let l=()=>{o.trim()&&(t([...e,o.trim()]),a(""));},i=b=>{b.key==="Enter"&&(b.preventDefault(),l());},c=b=>{t(e.filter((k,f)=>f!==b));},d=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),m=b=>{let{active:k,over:f}=b;if(!f||k.id===f.id)return;let g=n.findIndex(u=>u.id===k.id),p=n.findIndex(u=>u.id===f.id);if(g!==-1&&p!==-1){let u=[...e],[v]=u.splice(g,1);u.splice(p,0,v),t(u);}},x=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:d,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(b=>b.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:n.map((b,k)=>jsxRuntime.jsx(Uu,{id:b.id,text:b.text,onRemove:()=>c(k)},b.id))})}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:b=>a(b.target.value),onKeyDown:i,className:x,placeholder:"Type and press Enter to add..."})]})})};var Id=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),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(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ga,{items:l,onChange:c=>{o(e.id,{data:{...s,items:c}});},compact:true})]})};var Bd=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),s=r?.data??e.data??{},l=(i,c)=>{o(e.id,{data:{...s,[i]:c}});};return jsxRuntime.jsxs("div",{className:"group/block relative border border-[var(--kyro-border)] rounded-2xl p-6 mb-6 transition-all duration-300 bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/20",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-9 h-9 rounded-xl bg-[var(--kyro-primary)]/10 flex items-center justify-center text-[var(--kyro-primary)] transition-transform group-hover/block:scale-110",children:jsxRuntime.jsx(ql.CodeXml,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxRuntime.jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",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(ql.ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsxRuntime.jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>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(ql.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Ua,{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(ql.ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsxRuntime.jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var Ld=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),s=r?.data??e.data??{},l=(i,c)=>{o(e.id,{data:{...s,[i]:c}});};return jsxRuntime.jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(mr,{field:{label:"File",name:"file",maxCount:1},value:s.file,onChange:i=>l("file",i)})]})};var vi=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Da.useState(0),[n,s]=Da.useState(false),l=Da.useCallback(async g=>{g.preventDefault(),g.stopPropagation();try{let p=JSON.stringify({__kyro_accordion:!0,items:e});await navigator.clipboard.writeText(p),s(!0),setTimeout(()=>s(!1),2e3);}catch(p){console.error("Failed to copy",p);}},[e]),i=Da.useCallback(async g=>{g.preventDefault(),g.stopPropagation();try{let p=await navigator.clipboard.readText(),u=JSON.parse(p);u&&u.__kyro_accordion&&Array.isArray(u.items)&&t([...e,...u.items]);}catch(p){console.error("Failed to paste",p);}},[e,t]),c=jsxRuntime.jsxs("div",{className:"flex justify-end gap-1 mb-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:l,className:"p-1.5 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors rounded hover:bg-[var(--kyro-surface)]",title:"Copy Items",children:n?jsxRuntime.jsx(ql.Check,{className:"w-3.5 h-3.5 text-green-500"}):jsxRuntime.jsx(ql.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:i,className:"p-1.5 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors rounded hover:bg-[var(--kyro-surface)]",title:"Paste Items",children:jsxRuntime.jsx(ql.ClipboardPaste,{className:"w-3.5 h-3.5"})})]}),d=(g,p)=>{let u=[...e];u[g]={...u[g],title:p},t(u);},m=(g,p)=>{let u=[...e];u[g]={...u[g],content:p},t(u);},x=g=>{let p=e.filter((u,v)=>v!==g);t(p),o===g?a(null):o!==null&&o>g&&a(o-1);},b=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},k="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",f="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:[c,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((g,p)=>{let u=o===p;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(u?null:p),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:g.title||`Item ${p+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),x(p);},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(ql.X,{className:"w-3.5 h-3.5"})}),u?jsxRuntime.jsx(ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),u&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:g.title||"",onChange:v=>d(p,v.target.value),onClick:v=>v.stopPropagation(),className:f,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:g.content||"",onChange:v=>m(p,v.target.value),onClick:v=>v.stopPropagation(),className:`${f} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},p)})}),jsxRuntime.jsxs("button",{type:"button",onClick:b,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(ql.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[c,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((g,p)=>{let u=o===p;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(u?null:p),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:g.title||`Item ${p+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),x(p);},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(ql.X,{className:"w-4 h-4"})}),u?jsxRuntime.jsx(ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),u&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:g.title||"",onChange:v=>d(p,v.target.value),className:k,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:g.content||"",onChange:v=>m(p,v.target.value),className:`${k} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},p)})}),jsxRuntime.jsxs("button",{type:"button",onClick:b,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(ql.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var $d=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),s=r?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],i=c=>{o(e.id,{data:{...s,items:c}});};return jsxRuntime.jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(vi,{items:l,onChange:i,compact:true})]})};var Od=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),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(ql.AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Xo,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var gi=({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("title",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subtitle",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("title",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subtitle",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 rs({field:e,value:t,onChange:r,renderField:o}){let a=t||{},[n,s]=Da.useState(false),l=Da.useCallback(async c=>{c.preventDefault(),c.stopPropagation();try{let d=JSON.stringify({__kyro_container:!0,value:a});await navigator.clipboard.writeText(d),s(!0),setTimeout(()=>s(!1),2e3);}catch(d){console.error("Failed to copy",d);}},[a]),i=Da.useCallback(async c=>{c.preventDefault(),c.stopPropagation();try{let d=await navigator.clipboard.readText(),m=JSON.parse(d);m&&(m.__kyro_group||m.__kyro_container)&&m.value&&r({...a,...m.value});}catch(d){console.error("Failed to paste",d);}},[a,r]);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.jsxs("div",{className:"flex items-center justify-between mb-6 border-b border-[var(--kyro-border)] pb-2",children:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:l,className:"p-1.5 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors rounded hover:bg-[var(--kyro-surface)]",title:"Copy Group Data",children:n?jsxRuntime.jsx(ql.Check,{className:"w-4 h-4 text-green-500"}):jsxRuntime.jsx(ql.Copy,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:i,className:"p-1.5 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors rounded hover:bg-[var(--kyro-surface)]",title:"Paste Group Data",children:jsxRuntime.jsx(ql.ClipboardPaste,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields.map(c=>o(c,a,r))})]})}var Ju=new Set(["text","number","checkbox","select","radio","color","email","password"]);function qu(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>Ju.has(r.type))}function _d({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:l,onRemove:i,disabled:c,compact:d,getItemLabel:m}){let{attributes:x,listeners:b,setNodeRef:k,transform:f,transition:g,isDragging:p}=sortable.useSortable({id:e}),u={transform:utilities.CSS.Transform.toString(f),transition:g,zIndex:p?10:1,opacity:p?.8:1};return d?jsxRuntime.jsxs("div",{ref:k,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 ${p?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...x,...b,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 mt-1",children:jsxRuntime.jsx(ql.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsxRuntime.jsx("div",{className:`flex-1 min-w-0 ${(n.fields||[]).length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:(n.fields||[]).map(v=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(v,a,l)},v.name))}),jsxRuntime.jsx("button",{type:"button",disabled:c,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:k,style:u,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${p?"border-[var(--kyro-primary)] shadow-md":""}`,children:[jsxRuntime.jsxs("div",{className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[jsxRuntime.jsx("div",{...x,...b,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",children:jsxRuntime.jsx(ql.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.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:c,onClick:v=>{v.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(ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsxRuntime.jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:(n.fields||[]).map(v=>s(v,a,l))})]})}function os({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",c=l?.type==="relationship",[d,m]=Da__default.default.useState(0);Da__default.default.useEffect(()=>{let p=false,u=n.filter(v=>typeof v!="object"||v===null?(p=true,false):true).map(v=>!v.id&&!v._key?(p=true,{...v,id:Math.random().toString(36).substr(2,9)}):v);p&&r(u);},[t,r]);function x(p){for(let u of ["label","title","name"]){let v=p[u];if(v&&typeof v=="string")return v}for(let u of s){if(u.type==="text"||u.type==="textarea"){let v=p[u.name];if(v&&typeof v=="string")return v}if(u.type==="group"&&u.fields){for(let v of u.fields)if(v.type==="text"||v.type==="textarea"){let P=p[u.name]?.[v.name];if(P&&typeof P=="string")return P}}}return ""}let b=qu(e),k=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),f=p=>{let{active:u,over:v}=p;if(!v||u.id===v.id)return;let R=n.findIndex(h=>(h.id||h._key)===u.id),P=n.findIndex(h=>(h.id||h._key)===v.id);if(R!==-1&&P!==-1){let h=[...n],[w]=h.splice(R,1);h.splice(P,0,w),r(h);}},g=Da__default.default.useMemo(()=>n.map(p=>p?.id||p?._key||""),[n]);return c?jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(_a,{field:{name:i,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(p=>p[i]).filter(Boolean),onChange:p=>{let u=(p||[]).map(v=>({[i]:v,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:k,collisionDetection:core.closestCenter,onDragEnd:f,children:b?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:g,strategy:sortable.verticalListSortingStrategy,children:n.map((p,u)=>jsxRuntime.jsx(_d,{id:p.id||p._key||`idx-${u}`,index:u,isOpen:false,setOpenIndex:()=>{},item:p,field:e,renderField:o,onChangeItem:v=>{let R=[...n];R[u]=v,r(R);},onRemove:()=>r(n.filter((v,R)=>R!==u)),disabled:a,compact:true,getItemLabel:x},p.id||p._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:g,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((p,u)=>{let v=d===u;return jsxRuntime.jsx(_d,{id:p.id||p._key||`idx-${u}`,index:u,isOpen:v,setOpenIndex:m,item:p,field:e,renderField:o,onChangeItem:R=>{let P=[...n];P[u]=R,r(P);},onRemove:()=>r(n.filter((R,P)=>P!==u)),disabled:a,compact:false,getItemLabel:x},p.id||p._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 p=Math.random().toString(36).substr(2,9);r([...n,{id:p}]),m(n.length);},children:"+ Add Item"})]})})]})}var Hd="other";function Vd(){return Hd}function as(e){Hd=e;}var Do=({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 c=d=>{as("keystroke"),r(d);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(ta,{field:e,value:t,onChange:c,error:o,disabled:a});case "icon":return jsxRuntime.jsx(Un,{field:e,value:t,onChange:c,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(ta,{field:{...e,variant:"textarea"},value:t,onChange:c,error:o,disabled:a});case "password":return jsxRuntime.jsx(ta,{field:{...e,variant:"password"},value:t,onChange:c,error:o,disabled:a});case "secret":return jsxRuntime.jsx(Hn,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Gn,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(Wn,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx(Qn,{field:e,value:t,onChange:c,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i});case "date":return jsxRuntime.jsx(Jn,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(Xo,{field:e,value:t,onChange:c,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(qs,{field:e,value:t,onChange:c,disabled:a,error:o});case "code":return jsxRuntime.jsx(Ua,{field:e,value:t,onChange:c,disabled:a,error:o});case "image":case "upload":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx(mr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx(_a,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx(Ga,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(os,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(d,m,x)=>{let b=m[d.name];return jsxRuntime.jsx(Do,{field:d,value:b,onChange:k=>{x({...m,[d.name]:k});},disabled:a,error:o},d.name)}});case "blocks":return jsxRuntime.jsx(ki,{field:e,value:t,onChange:c,disabled:a,error:o});case "group":return jsxRuntime.jsx(rs,{field:e,value:t,onChange:r,renderField:(d,m,x)=>{let b=m[d.name];return jsxRuntime.jsx(Do,{field:d,value:b,onChange:k=>{x({...m,[d.name]:k});},disabled:a,error:o,collectionSlug:l,globalSlug:i},d.name)}});case "color":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("input",{type:"color",value:t||"#000000",onChange:d=>r(d.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:d=>r(d.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 ia=({block:e,blockSchema:t,onClose:r})=>{let o=_e(e.id),{updateBlock:a}=Me(),n=o?.data||e.data||{},s=o?.children||e.children||[],l=(m,x)=>{a(e.id,{data:{...n,[m]:x}});},i=m=>{a(e.id,{children:m});},c=()=>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 b={values:n,...n};if(!m.admin.condition(b,b))return null}catch(b){console.warn(`Condition error for field ${m.name}:`,b);}else if(typeof m.admin.condition=="object")try{let b=m.admin.condition,k=b.field,f=n[k],g=!0;if("equals"in b?g=f===b.equals:"notEquals"in b?g=f!==b.notEquals:"in"in b&&Array.isArray(b.in)&&(g=b.in.includes(f)),!g)return null}catch(b){console.warn(`Declarative condition error for field ${m.name}:`,b);}}let x=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(Do,{field:m,value:x,onChange:b=>l(m.name,b)})},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,'"']}),d=Be[e.type]||Be.default;return jsxRuntime.jsxs(ur,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:d.border,children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[c(),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(oo,{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 Xu=6,oo=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Xu})=>{let[n,s]=Da.useState(false),[l,i]=Da.useState(new Set),[c,d]=Da.useState(null),[m,x]=Da.useState(null),b=Da.useContext(To);if(!b)throw new Error("ChildBlocksTree must be used within a BlocksContext");let k=zustand.useStore(b,y=>y.dynamicCategories),f=zustand.useStore(b,y=>y.allowedBlocks),g=o<a,p=16,u=y=>{let S=aa(y);r([...t,S]),d(S.id);},v=y=>{let S=t.filter(O=>O.id!==y);r(S);},P=(y,S)=>{let O=t.map(L=>L.id===y?{...L,children:S}:L);r(O);},h=y=>{i(S=>{let O=new Set(S);return O.has(y)?O.delete(y):O.add(y),O});},w=y=>{let S=y.children&&y.children.length>0,O=l.has(y.id);hi(y.type);let K=S,C=c===y.id,G=f.find(z=>z.slug===y.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${C?"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"} ${g?"cursor-pointer":""}`,style:{marginLeft:o*p},onClick:()=>{g&&d(C?null:y.id);},children:[K?jsxRuntime.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),h(y.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:O?jsxRuntime.jsx(ql.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(ql.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Jt[y.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Jt[y.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[qa(y),y.data?.text?` - ${y.data.text.slice(0,30)}`:"",y.data?.heading?` - ${y.data.heading.slice(0,30)}`:""]}),G?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:G.admin.description})]}),S&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[y.children.length," nested"]}),m===y.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(y.id),x(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>x(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:z=>{z.stopPropagation(),x(y.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(ql.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),C&&jsxRuntime.jsx(ia,{block:y,onClose:()=>d(null)}),S&&O&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Wd,{parentId:y.id,children:y.children,onUpdateChildren:z=>P(y.id,z),depth:o+1,maxDepth:a})})]},y.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(w)}),g&&jsxRuntime.jsxs("div",{style:{marginLeft:o*p},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(ql.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(Ka,{open:n,onClose:()=>s(false),onSelect:u,children:k.map(y=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:y.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.blocks.map(S=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{u(S.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[S.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:S.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:S.admin?.description||""})]})]},S.slug))})]},y.title))})]}),t.length===0&&g&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*p},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*p},children:["Maximum nesting level (",a,") reached"]})]})},Wd=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=Da.useState(false),[l,i]=Da.useState(new Set),[c,d]=Da.useState(null),[m,x]=Da.useState(null),b=Da.useContext(To);if(!b)throw new Error("NestedChildBlocks must be used within a BlocksContext");let k=zustand.useStore(b,y=>y.dynamicCategories),f=zustand.useStore(b,y=>y.allowedBlocks),g=o<a,p=16,u=y=>{let S=aa(y);r([...t,S]),d(S.id);},v=y=>{let S=t.filter(O=>O.id!==y);r(S);},P=(y,S)=>{let O=t.map(L=>L.id===y?{...L,children:S}:L);r(O);},h=y=>{i(S=>{let O=new Set(S);return O.has(y)?O.delete(y):O.add(y),O});},w=y=>{let S=y.children&&y.children.length>0,O=l.has(y.id);hi(y.type);let K=S,C=c===y.id,G=f.find(z=>z.slug===y.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${C?"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"} ${g?"cursor-pointer":""}`,style:{marginLeft:o*p},onClick:()=>{g&&d(C?null:y.id);},children:[K?jsxRuntime.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),h(y.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:O?jsxRuntime.jsx(ql.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(ql.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Jt[y.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Jt[y.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[qa(y),y.data?.text?` - ${y.data.text.slice(0,30)}`:"",y.data?.heading?` - ${y.data.heading.slice(0,30)}`:""]}),G?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:G.admin.description})]}),S&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[y.children.length," nested"]}),m===y.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(y.id),x(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>x(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:z=>{z.stopPropagation(),x(y.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(ql.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),C&&jsxRuntime.jsx(ia,{block:y,onClose:()=>d(null)}),S&&O&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Wd,{parentId:y.id,children:y.children,onUpdateChildren:z=>P(y.id,z),depth:o+1,maxDepth:a})})]},y.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(w)}),g&&jsxRuntime.jsxs("div",{style:{marginLeft:o*p},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(ql.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(Ka,{open:n,onClose:()=>s(false),onSelect:u,children:k.map(y=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:y.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.blocks.map(S=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{u(S.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[S.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:S.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:S.admin?.description||""})]})]},S.slug))})]},y.title))})]}),t.length===0&&g&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*p},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*p},children:["Maximum nesting level (",a,") reached"]})]})};var Jd=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),s=r?.data??e.data??{},l=r?.children??e.children??[],i=(c,d)=>{o(e.id,{data:{...s,[c]:d}});};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(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(gi,{heading:s.title||"",subheading:s.subtitle||"",ctaText:s.ctaText||"",ctaUrl:s.ctaUrl||"",onChange:i,compact:true}),jsxRuntime.jsx(mr,{field:{label:"Background",name:"bgImage",maxCount:1},value:s.bgImage,onChange:c=>i("bgImage",c)}),jsxRuntime.jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsxRuntime.jsx(oo,{blockId:e.id,children:l,onUpdateChildren:c=>o(e.id,{children:c})})]})]})]})};var wi=({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:c=>n("title",c.target.value),className:`${l} font-bold text-base`,placeholder:"Card title..."}),jsxRuntime.jsx("textarea",{value:t,onChange:c=>n("description",c.target.value),className:i,placeholder:"Card description..."}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:c=>n("icon",c.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:c=>n("linkText",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:"Link text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:c=>n("link",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var Yd=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o}=Me(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(Ro,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(wi,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Qd=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me();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(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(oo,{blockId:e.id,children:l,onUpdateChildren:i=>o(e.id,{children:i})})})]})};var Ya=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let[l,i]=Da.useState(false),[c,d]=Da.useState(""),[m,x]=Da.useState([]),[b,k]=Da.useState(false),[f,g]=Da.useState([]),[p,u]=Da.useState(true);Da.useEffect(()=>{De("/api/collections").then(L=>{g((L.collections||[]).map(K=>K.slug||K.name||K)),u(false);}).catch(()=>u(false));},[]);let v=(L="")=>{k(true);let K=`/api/${e}?${pn(L,[a],20)}`;De(K).then(C=>{x(C.docs||[]),k(false);}).catch(()=>k(false));};Da.useEffect(()=>{l&&v(c);},[l,c,e,a]);let R=L=>L?.[a]||L?.title||L?.name||L?.label||L?.filename||L?.slug||L?.id||"Untitled",P=t?r:o?[o]:[],h=L=>{t?P.includes(L.id)?n("selectedIds",P.filter(K=>K!==L.id)):n("selectedIds",[...P,L.id]):(n("selectedId",L.id),n("selectedIds",[L.id]),i(false));},w=L=>P.includes(L),y=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",S=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",O=e&&typeof e=="string"&&e.length>0;return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-4",children:[jsxRuntime.jsxs("div",{className:s?"flex items-center gap-2":"space-y-3",children:[!O&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:p?jsxRuntime.jsx("div",{className:S+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:L=>n("relationTo",L.target.value),className:S,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),f.map(L=>jsxRuntime.jsx("option",{value:L,children:L},L))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:L=>n("hasMany",L.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsxRuntime.jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:c,onChange:L=>{d(L.target.value),i(true);},onFocus:()=>i(true),onBlur:()=>setTimeout(()=>i(false),200),placeholder:`Search ${e}...`,className:`${y} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:b&&jsxRuntime.jsx(ql.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsxRuntime.jsx("div",{className:"absolute z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-48 overflow-auto",children:b?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):m.length===0?jsxRuntime.jsx(Zn,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:m.map(L=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:K=>K.preventDefault(),onClick:()=>h(L),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${w(L.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:R(L)}),w(L.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},L.id))})})]}),P.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(L=>{let K=m.find(C=>C.id===L)||{id:L};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(K),jsxRuntime.jsx("button",{type:"button",onMouseDown:C=>C.preventDefault(),onClick:()=>{t?n("selectedIds",P.filter(C=>C!==L)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(ql.X,{className:"w-3 h-3"})})]},L)})})]})};var ec=({block:e,index:t})=>{let r=_e(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Me(),s=r?.data??e.data??{},l=(i,c)=>{o(e.id,{data:{...s,[i]:c}});};return jsxRuntime.jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",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(ql.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(ql.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(ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ya,{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 Qu={heading:Td,paragraph:Rd,image:Pd,video:Dd,list:Id,code:Bd,file:Ld,accordion:$d,richtext:Od,hero:Jd,card:Yd,array:Qd,relationship:ec},Be={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(ql.Heading1,{className:`w-4 h-4 ${Be.default.text}`}),paragraph:jsxRuntime.jsx(ql.AlignLeft,{className:`w-4 h-4 ${Be.default.text}`}),image:jsxRuntime.jsx(ql.Image,{className:`w-4 h-4 ${Be.default.text}`}),video:jsxRuntime.jsx(ql.Video,{className:`w-4 h-4 ${Be.default.text}`}),list:jsxRuntime.jsx(ql.List,{className:`w-4 h-4 ${Be.default.text}`}),code:jsxRuntime.jsx(ql.Code,{className:`w-4 h-4 ${Be.default.text}`}),file:jsxRuntime.jsx(ql.File,{className:`w-4 h-4 ${Be.default.text}`}),accordion:jsxRuntime.jsx(ql.ChevronDown,{className:`w-4 h-4 ${Be.default.text}`}),richtext:jsxRuntime.jsx(ql.AlignLeft,{className:`w-4 h-4 ${Be.default.text}`}),hero:jsxRuntime.jsx(ql.Star,{className:`w-4 h-4 ${Be.hero.text}`}),card:jsxRuntime.jsx(ql.Box,{className:`w-4 h-4 ${Be.card.text}`}),array:jsxRuntime.jsx(ql.ListOrdered,{className:`w-4 h-4 ${Be.default.text}`}),relationship:jsxRuntime.jsx(ql.Link2,{className:`w-4 h-4 ${Be.default.text}`}),featureSplit:jsxRuntime.jsx(ql.Columns3,{className:`w-4 h-4 ${Be.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(ql.Blocks,{className:`w-4 h-4 ${Be.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(ql.Sparkles,{className:`w-4 h-4 ${Be.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(ql.Users,{className:`w-4 h-4 ${Be.testimonials.text}`}),faq:jsxRuntime.jsx(ql.CircleHelp,{className:`w-4 h-4 ${Be.faq.text}`}),stats:jsxRuntime.jsx(ql.Activity,{className:`w-4 h-4 ${Be.stats.text}`}),logoCloud:jsxRuntime.jsx(ql.Image,{className:`w-4 h-4 ${Be.logoCloud.text}`}),pricing:jsxRuntime.jsx(ql.Tag,{className:`w-4 h-4 ${Be.pricing.text}`}),team:jsxRuntime.jsx(ql.Users,{className:`w-4 h-4 ${Be.team.text}`}),recentFeed:jsxRuntime.jsx(ql.Database,{className:`w-4 h-4 ${Be.recentFeed.text}`}),processSteps:jsxRuntime.jsx(ql.Clock,{className:`w-4 h-4 ${Be.processSteps.text}`}),formEmbed:jsxRuntime.jsx(ql.Mail,{className:`w-4 h-4 ${Be.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(ql.Video,{className:`w-4 h-4 ${Be.videoShowcase.text}`})};function hi(e){return Qu[e]||null}function Ni(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 qa(e){let t=e.name;return t&&t.trim()?t.trim():Ni(e.type)}function my(e,t){if(t?.fields){for(let r of t.fields)if(r.type==="text"||r.type==="textarea"){let o=e[r.name];if(o&&typeof o=="string")return o}}return e.title||e.text||e.name||e.label||""}var uy=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{attributes:l,listeners:i,setNodeRef:c,transform:d,transition:m,isDragging:x}=sortable.useSortable({id:e.id}),{removeBlock:b,updateBlock:k}=Me(),f=o===e.id,[g,p]=Da.useState(false),[u,v]=Da.useState(false),[R,P]=Da.useState(e.name||""),h=Da.useRef(null),[w,y]=Da.useState(false),S=Da.useCallback(async z=>{z.stopPropagation();try{let{id:j,..._}=e,se=JSON.stringify({__kyro_block:!0,type:e.type,blockProps:_});await navigator.clipboard.writeText(se),y(!0),setTimeout(()=>y(!1),2e3);}catch(j){console.error("Failed to copy block",j);}},[e]);Da.useEffect(()=>{u&&h.current&&(h.current.focus(),h.current.select());},[u]);let O=Da.useCallback(()=>{v(false);let z=R.trim();z!==(e.name||"").trim()&&k(e.id,{name:z||""});},[R,e.name,e.id,k]),L={transform:utilities.CSS.Transform.toString(d),transition:m,zIndex:x?10:1,opacity:x?.8:1},K=qa(e),C=e.data||{},G=my(C,r);return s?jsxRuntime.jsxs("div",{ref:c,style:L,className:"relative group w-full",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-2 pl-7 pr-2 py-2 w-full bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-sm ${f?`${(Be[e.type]||Be.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 p-0.5 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] opacity-0 group-hover:opacity-100 transition-opacity hover:bg-[var(--kyro-surface-accent)] rounded touch-none",...l,...i,onClick:z=>z.stopPropagation(),children:jsxRuntime.jsx(ql.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:h,value:R,onChange:z=>P(z.target.value),onBlur:O,onKeyDown:z=>{z.key==="Enter"&&O(),z.key==="Escape"&&(P(e.name||""),v(false));},onClick:z=>z.stopPropagation(),className:"flex-1 min-w-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-1.5 py-0.5 text-[10px] font-medium text-[var(--kyro-text-primary)] outline-none"}):jsxRuntime.jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] flex-1 min-w-0 truncate transition-colors text-left",children:K}),g?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{b(e.id),p(false);},className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P(e.name||""),v(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:z=>{z.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate in place",children:jsxRuntime.jsx(ql.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:S,className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Copy Block to Clipboard",children:w?jsxRuntime.jsx(ql.Check,{className:"w-3 h-3 text-green-500"}):jsxRuntime.jsx(ql.ClipboardCopy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),p(true);},className:"p-0.5 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:"Remove",children:jsxRuntime.jsx(ql.X,{className:"w-3 h-3"})})]})]}),f&&jsxRuntime.jsx(ia,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:c,style:L,className:"relative group mb-2",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-3 p-3 bg-[var(--kyro-bg-secondary)] rounded-lg border transition-colors cursor-pointer ${f?`${(Be[e.type]||Be.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:z=>z.stopPropagation(),children:jsxRuntime.jsx(ql.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:h,value:R,onChange:z=>P(z.target.value),onBlur:O,onKeyDown:z=>{z.key==="Enter"&&O(),z.key==="Escape"&&(P(e.name||""),v(false));},onClick:z=>z.stopPropagation(),placeholder:Ni(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:[K,G&&typeof G=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",G.length>40?`${G.slice(0,40)}...`:G]})]}),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"]}),g?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:z=>z.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{b(e.id),p(false);},className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P(e.name||""),v(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:z=>{z.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(ql.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:S,className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Copy Block to Clipboard",children:w?jsxRuntime.jsx(ql.Check,{className:"w-3.5 h-3.5 text-green-500"}):jsxRuntime.jsx(ql.ClipboardCopy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),p(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:"Remove Block",children:jsxRuntime.jsx(ql.X,{className:"w-3.5 h-3.5"})})]})]}),f&&jsxRuntime.jsx(ia,{block:e,blockSchema:r,onClose:()=>a(null)})]})},yy=Da__default.default.memo(uy),ki=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:l})=>{let[i,c]=Da.useState(false),[d,m]=Da.useState(false),x=Da.useRef(null),b=e.admin?.pickerMode||"drawer",k=e.blocks||[],f=k.reduce((M,E)=>{let ne=E.admin?.group||"Custom Blocks";return M[ne]||(M[ne]=[]),M[ne].push(E),M},{}),g=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],p=Object.entries(f).sort(([M],[E])=>{let ne=g.indexOf(M),ue=g.indexOf(E);return ne!==-1&&ue!==-1?ne-ue:ne!==-1?-1:ue!==-1?1:M.localeCompare(E)}).map(([M,E])=>({title:M,blocks:E})),u=Da.useRef(null);u.current||(u.current=wd(k,p));let v=u.current,R=zustand.useStore(v,M=>M.blocks),[P,h]=Da.useState(null),[w,y]=Da.useState(null),S=Da.useRef(R.length),O=Da.useRef(new Set(R.map(M=>M.id))),L=Da.useRef(false);Da.useEffect(()=>{if(L.current&&R.length>S.current){let M=R.find(E=>E.id&&!O.current.has(E.id));M&&y(M.id);}S.current=R.length,O.current=new Set(R.map(M=>M.id));},[R]),Da.useEffect(()=>(o&&v.getState().setOnBlocksChange(o),()=>{v.getState().setOnBlocksChange(()=>{});}),[o,v]);let K=Da.useRef(null);Da.useEffect(()=>{let M=Array.isArray(t)?t:[],E=K.current||[];if(Co(M,E))M.length===0&&!L.current&&(L.current=true,K.current=[]);else {let ne=[...M];S.current=ne.length,O.current=new Set(ne.map(ue=>ue.id)),v.getState().setBlocks(ne),K.current=ne,L.current=true;}},[t,e.name,v]);let C=Da.useRef(r);C.current=r,Da.useEffect(()=>{if(!C.current)return;let M=K.current;M&&(Co(R,M)||(K.current=[...R],C.current(R)));},[R]);let z=Da.useCallback(M=>{v.getState().addBlock(M);},[v]),j=Da.useCallback(M=>{if(!(e.blocks||[]).some(A=>A.slug===M.type)){alert(`The block type "${M.type}" is not allowed in this collection.`);return}let ue=Math.random().toString(36).substring(2,11),$e={...M.blockProps||{},id:ue,type:M.type};v.getState().setBlocks([...R,$e]),c(false);},[e.blocks,R,v]),_=Da.useCallback(M=>{let E=document.activeElement;if(E&&(E.tagName==="INPUT"||E.tagName==="TEXTAREA"||E.getAttribute("contenteditable")==="true"))return;let ne=M.clipboardData?.getData("text");if(ne)try{let ue=JSON.parse(ne);ue&&ue.__kyro_block&&(M.preventDefault(),M.stopPropagation(),j(ue),U.success(`Block pasted: ${ue.type}`));}catch{}},[j]),se=Da.useCallback(M=>{let E=R.findIndex($=>$.id===M);if(E===-1)return;let ne=R[E],ue=$=>{let Z=Math.random().toString(36).substr(2,9);return {...$,id:Z,children:$.children?$.children.map(Ke=>ue(Ke)):$.children,data:$.data?JSON.parse(JSON.stringify($.data)):$.data}},$e=ue(ne),A=[...R];A.splice(E+1,0,$e),v.getState().setBlocks(A);},[R,v]),te=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),J=M=>{h(M.active);},de=M=>{let{active:E,over:ne}=M;if(h(null),!!ne){if(E.id.toString().startsWith("drawer-")){let ue=E.id.toString().replace("drawer-","");if(ne.id.toString().startsWith("container-")){let $e=ne.id.toString().replace("container-",""),A=R.find($=>$.id===$e);if(A){let $=aa(ue);v.getState().updateBlock($e,{children:[...A.children||[],$]});}}else {let $e=R.findIndex(A=>A.id===ne.id);$e!==-1?v.getState().addBlock(ue,$e):z(ue);}return}if(E.id!==ne.id){let ue=R.findIndex(A=>A.id===E.id),$e=R.findIndex(A=>A.id===ne.id);if(ue!==-1&&$e!==-1){let A=[...R],[$]=A.splice(ue,1);A.splice($e,0,$),v.getState().setBlocks(A);}}}},ve=P?p.flatMap(M=>M.blocks).find(M=>`drawer-${M.type}`===P.id)||R.find(M=>M.id===P.id):null;ve?"label"in ve?ve.label:ve.type:"Block";return Da.useEffect(()=>{if(!d)return;let M=E=>{x.current&&!x.current.contains(E.target)&&m(false);};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[d]),jsxRuntime.jsx(To.Provider,{value:u.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",onPaste:_,tabIndex:0,style:{outline:"none"},children:[jsxRuntime.jsxs(core.DndContext,{sensors:te,collisionDetection:core.closestCenter,onDragStart:J,onDragEnd:de,children:[jsxRuntime.jsxs("div",{className:b==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:`kyro-form-label ${b==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),b==="dropdown"?jsxRuntime.jsxs("div",{ref:x,className:"relative w-full",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(!d),disabled:n,className:"flex w-full items-center justify-between px-3 py-2 text-sm text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)] rounded-md transition-colors disabled:opacity-50",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ql.Plus,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Select an element to add..."})]}),jsxRuntime.jsx(ql.ChevronDown,{className:`w-4 h-4 transition-transform ${d?"rotate-180 text-[var(--kyro-primary)]":"opacity-50"}`})]}),d&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full mt-1 w-full bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:p.map(M=>jsxRuntime.jsxs("div",{children:[p.length>1&&jsxRuntime.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:M.title}),M.blocks.map(E=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{z(E.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[E.slug]||jsxRuntime.jsx(ql.Box,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"text-xs font-semibold truncate",children:E.label}),E.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:E.admin.description})]})]},E.slug))]},M.title))})]}):jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(true),disabled:n,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)]/30 rounded-md transition-colors disabled:opacity-50 font-semibold",children:[jsxRuntime.jsx(ql.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx(Ka,{open:i,onClose:()=>c(false),onSelect:z,onPasteBlock:j,children:jsxRuntime.jsx("div",{className:"space-y-4",children:p.map(M=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:M.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:M.blocks.map(E=>jsxRuntime.jsx(Nd,{block:{type:E.slug,label:E.label,description:E.admin?.description||"",icon:null},onSelect:z,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[E.slug]||jsxRuntime.jsx(ql.Box,{className:"w-4 h-4"})})})},E.slug))})]},M.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:R.map(M=>M.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:b==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[R.map((M,E)=>{let ne=e.blocks?.find(ue=>ue.slug===M.type);return jsxRuntime.jsx(yy,{block:M,index:E,blockSchema:ne,editingBlockId:w,setEditingBlockId:y,onDuplicate:se,compact:b==="dropdown"},M.id||E)}),R.length===0&&jsxRuntime.jsx("div",{className:b==="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:b==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsxRuntime.jsx(core.DragOverlay,{children:P&&ve&&jsxRuntime.jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:ve.label||ve.type||"Block"})})]}),a&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:a})]})})};function ac(){let e=Da.useRef([]),t=Da.useRef(false);return {queueTask:Da.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 nc({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:l}){let i=Ce(),{confirm:c}=ft(),{formData:d,setFormData:m,setField:x,lastSavedData:b,setLastSavedData:k,setHasUnsavedChanges:f,isSlugLocked:g,loadDocument:p,setIsAutoSaving:u,setAutoSaveStatus:v,setVersions:R,setLoadingVersions:P,sidebarCollapsed:h,setSidebarCollapsed:w,getDraftCache:y,setDraftCache:S,clearDraftCache:O,resetForm:L}=i,K=!!e.versions,C=o||t?.id||a||r,G=Da.useRef(false);!o&&C&&d&&Object.keys(d).length>0&&d.id!==C&&(G.current=true),Da.useEffect(()=>{G.current&&(G.current=false,L());},[L]);let z=Da.useRef(null),j=Da.useRef(null),_=Da.useRef(null),se=Da.useRef(typeof navigator<"u"?navigator.onLine:true),te=Da.useRef(0),J=Da.useRef(false),de=Da.useRef(null),ve=Da.useRef(""),Te=Da.useRef(""),{queueTask:Ve}=ac(),M=Da.useCallback(I=>o?`global:${o}`:r&&I?`${r}:${I}`:null,[r,o]),E=Da.useCallback((I,H,q)=>{S(I,{data:H,baseUpdatedAt:b.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:q?.lastSyncedAt??null});},[b.updatedAt,S]),ne=Da.useCallback(async()=>{let I=o?Je(`/api/globals/${o}/versions`):r&&d.id?Je(`/api/${r}/${d.id}/versions`):null;if(I){P(true);try{let q=await(await lt(I)).json();R(q.docs||[]);}catch(H){console.error("Failed to fetch versions:",H);}finally{P(false);}}},[d.id,r,o,P,R]),ue=Da.useCallback(()=>{let I=Ce.getState(),H=I.formData;if(J.current||!r||!H.id||!I.hasDirtyFields())return;let q=M(H.id);q&&E(q,H);},[r,M,E]),$e=Da.useCallback(async I=>{let H=Ce.getState(),q=H.formData,xe=H.lastSavedData;if(J.current||!o&&(!r||!q.id)||!H.hasDirtyFields())return;let Re=M(q.id);if(Re&&E(Re,q),!se.current){v("offline");return}u(true),v("saving"),H.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let Ue=o?Je(`/api/globals/${o}?autosave=true`):Je(`/api/${r}/${q.id}?autosave=true`),B=await lt(Ue,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:I?.keepalive,body:JSON.stringify({...Wt(q),baseUpdatedAt:xe.updatedAt??null})});if(B.ok)te.current=Date.now(),H.setRetryCount(0),H.setLastSavedAt(Date.now()),_.current&&clearTimeout(_.current),Re&&S(Re,{data:q,baseUpdatedAt:xe.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await B.clone().json()).data?.updatedAt||new Date().toISOString()}),v("success"),setTimeout(()=>{Ce.getState().autoSaveStatus==="success"&&v("idle");},2e3);else if(B.status===409)v("conflict");else throw new Error(`Draft auto-save failed with status ${B.status}`)}catch(Ue){console.error("Auto-save failed:",Ue);let B=Ce.getState(),ee=B.retryCount;if(ee<5){B.setRetryCount(ee+1),v("retrying");let ce=Math.min(1e3*Math.pow(2,ee),6e4);_.current&&clearTimeout(_.current),_.current=setTimeout(()=>A(I),ce);}else v("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),u(false),Ce.getState().setBackgroundProcessing(false);}},[r,M,o,E,v,S,u,K]),A=Da.useCallback(I=>{Ve(()=>$e(I),{beforeProcess:()=>true,afterProcess:()=>{}});},[$e,Ve]),$=Da.useCallback(async(I,H=true)=>{let q=Ce.getState(),xe=I||q.formData,Re=o?Je(`/api/globals/${o}`):Je(`/api/${r}/${xe.id}`),Ue=await lt(Re,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(H)},body:JSON.stringify({...Wt(xe),baseUpdatedAt:q.lastSavedData.updatedAt??null})});return Ue.status===409&&v("conflict"),Ue},[r,o,v]),Z=Da.useCallback(async(I=true)=>{let H=Ce.getState(),q=H.formData,xe=o?Je(`/api/globals/${o}`):Je(`/api/${r}/${q.id}`),Re=await lt(xe,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(I)},body:JSON.stringify({...Wt(q)})});if(Re.ok){let B=(await Re.json()).data||q;H.setFormData({...q,...B}),H.setLastSavedData({...q,...B}),v("success"),setTimeout(()=>{Ce.getState().autoSaveStatus==="success"&&v("idle");},2e3);}return Re},[r,o,v]);Da.useEffect(()=>{let I=()=>{w(!h);};return window.addEventListener("toggle-sidebar",I),()=>window.removeEventListener("toggle-sidebar",I)},[h,w]);let Ke=Da.useRef(null),fe=Da.useRef(""),We=Da.useRef(false);Da.useEffect(()=>{let I=o||t?.id,H=JSON.stringify(t);We.current&&Ke.current===I&&fe.current===H||(p(t||{},t||{}),We.current=true,Ke.current=I,fe.current=H);},[r,d.id,o,t,p]),Da.useEffect(()=>{if(!r||!t?.id)return;let I=M(t.id);if(!I||de.current===I)return;let H=false;return (async()=>{if(!K)return;let xe=y(I);if(xe){if(JSON.stringify(xe.data)===JSON.stringify(t)){O(I);return}de.current=I,c({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(H)return;let Ue={...Ce.getState().formData,...xe.data};m(Ue),s?.("Recovered autosaved draft");},onCancel:async()=>{O(I);}});}})(),()=>{H=true;}},[O,r,c,M,y,t,s,m,K]);function Fe(I,H){for(let q of I){if(q.name===H&&q.admin?.autoGenerate==="title")return q;if(q.type==="tabs"&&"tabs"in q)for(let xe of q.tabs){let Re=Fe(xe.fields,H);if(Re)return Re}if((q.type==="group"||q.type==="collapsible")&&"fields"in q){let xe=Fe(q.fields,H);if(xe)return xe}}}Da.useEffect(()=>{let I=e.fields;if(!Fe(I,"metaTitle"))return;let q=No(I,d,"title"),xe=q?String(q):"";xe&&(!d.metaTitle||d.metaTitle===d._lastMetaTitle)&&x("metaTitle",xe);},[d,e.fields,x]),Da.useEffect(()=>{let I=e.fields,H=I.find(Re=>Re.name==="slug"&&Re.admin?.autoGenerate);if(!H?.admin?.autoGenerate)return;let q=H.admin.autoGenerate,xe=No(I,d,q);if(g&&xe){let Re=Kn(xe);Re!==d.slug&&x("slug",Re);}},[d,g,e.fields,x]),Da.useEffect(()=>{if(h||!o&&(!r||!d.id)||!Ce.getState().hasDirtyFields()||Vd()!=="keystroke")return;as("other");let H=JSON.stringify(d);H!==ve.current&&(z.current&&clearTimeout(z.current),z.current=setTimeout(ue,1500),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{ve.current=H,A();},8e3));},[d,h,r,o,ue,A]),Da.useEffect(()=>{if(!o&&(!r||!d.id))return;let I=()=>{J.current||!Ce.getState().hasDirtyFields()||A({keepalive:true});},H=()=>{document.hidden&&I();},q=()=>{se.current=true,I();},xe=()=>{se.current=false;let Re=Ce.getState();Re.hasDirtyFields()&&Re.setAutoSaveStatus("offline");};return window.addEventListener("blur",I),window.addEventListener("pagehide",I),window.addEventListener("online",q),window.addEventListener("offline",xe),document.addEventListener("visibilitychange",H),()=>{window.removeEventListener("blur",I),window.removeEventListener("pagehide",I),window.removeEventListener("online",q),window.removeEventListener("offline",xe),document.removeEventListener("visibilitychange",H);}},[r,o,d.id,A]),Da.useEffect(()=>{let I=JSON.stringify(d);if(I===Te.current)return;Te.current=I;let H=document.getElementById("form-data");H&&(H.value=I),n?.(d);},[d,n]),Da.useEffect(()=>{(o||d.id)&&ne();},[d.id,o,ne]);let yt=!d.id&&!o?"draft":K&&d.status||"published",wt=(!!d.id||!!o)&&yt==="draft";return {...i,fetchVersions:ne,performAutoSave:A,saveDocument:$,forceSave:Z,autoSaveSkipRef:J,lastAutoSaveTimeRef:te,documentStatus:yt,hasUnpublishedChanges:wt,versionsEnabled:K}}function Io({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=Da.useState(false),s=Da.useRef(null);return Da.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 Pt({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsxRuntime.jsx("div",{className:"px-1.5",children:jsxRuntime.jsxs("button",{type:"button",onClick:t,disabled:a,className:`w-full flex items-center gap-3 px-3 py-2.5 text-[11px] font-medium tracking-wide text-left transition-all rounded-xl ${o?"text-red-500 hover:bg-red-500/10":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]"} ${a?"opacity-50 cursor-not-allowed":""} ${n}`,children:[r&&jsxRuntime.jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsxRuntime.jsx("span",{className:"flex-1",children:e})]})})}function Za(){return jsxRuntime.jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Lo({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||t==="saved",c="kyro-btn kyro-btn-sm text-[11px] font-regular tracking-widest transition-all duration-300 rounded-lg",d=()=>t==="saving"?`${c} bg-[var(--kyro-primary)]/70 border-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] cursor-wait`:t==="saved"?`${c} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:t==="error"?`${c} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:l?`${c} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:`${c} 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",x=()=>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-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`: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)]`,b=()=>t==="saving"?"Publishing...":t==="saved"?"Published":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:`${d()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline mr-1.5"}),(l||t==="saved")&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),b()]}),a&&jsxRuntime.jsx(Io,{trigger:jsxRuntime.jsx("button",{type:"button",className:x(),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 lc=({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 pc({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=Da.useState(0),s=e.tabs||[],l=s[a]||s[0],i=e.name?t[e.name]||{}:t,[c,d]=Da.useState(false),m=Da.useCallback(async b=>{b.preventDefault(),b.stopPropagation();try{let k=JSON.stringify({__kyro_container:!0,value:i});await navigator.clipboard.writeText(k),d(!0),setTimeout(()=>d(!1),2e3);}catch(k){console.error("Failed to copy",k);}},[i]),x=Da.useCallback(async b=>{b.preventDefault(),b.stopPropagation();try{let k=await navigator.clipboard.readText(),f=JSON.parse(k);f&&(f.__kyro_group||f.__kyro_container)&&f.value&&r({...i,...f.value});}catch(k){console.error("Failed to paste",k);}},[i,r]);return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--kyro-border)] mb-6",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2 overflow-x-auto hide-scrollbar",children:s.map((b,k)=>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===k?"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(k),children:b.label},k))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 pr-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:m,className:"p-1.5 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors rounded hover:bg-[var(--kyro-surface)]",title:"Copy Tab Data",children:c?jsxRuntime.jsx(ql.Check,{className:"w-4 h-4 text-green-500"}):jsxRuntime.jsx(ql.Copy,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:x,className:"p-1.5 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors rounded hover:bg-[var(--kyro-surface)]",title:"Paste Tab Data",children:jsxRuntime.jsx(ql.ClipboardPaste,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:l?.fields.map(b=>o(b,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(lc,{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 yc({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:s,handleDuplicate:l,handleUnpublish:i,handleDelete:c,handlePublish:d,handleSaveDraft:m,handleSchedulePublish:x,handleConflictOverride:b}){let[k,f]=Da.useState(Date.now()),[g,p]=Da.useState(false),u=Da.useRef(null),{formData:v,hasUnsavedChanges:R,autoSaveStatus:P,lastSavedAt:h,retryCount:w,view:y,setView:S,showPreview:O,setShowPreview:L,setFormData:K,markSaved:C,lastSavedData:G}=Ce(),z=!v.id;Da.useEffect(()=>{let E=setInterval(()=>f(Date.now()),1e4);return ()=>clearInterval(E)},[]),Da.useEffect(()=>{let E=ne=>{u.current&&!u.current.contains(ne.target)&&p(false);};if(g)return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[g]);let j=String(v.tabs?.title||(typeof v.title=="object"?"":v.title)||(typeof v.name=="object"?"":v.name)||"Untitled"),_=v.updatedAt?new Date(v.updatedAt).toLocaleString():"Just now",se=v.createdAt?new Date(v.createdAt).toLocaleString():"Just now",te=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",J=o?"Unpublished":r==="published"?"Published":"Draft",de=r==="published"&&!R?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",ve=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",Te=(E=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[P==="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"})]}),E?"Saving\u2026":"Saving draft..."]}),P==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(ql.Check,{className:"w-3.5 h-3.5 shrink-0"}),E?"Saved":h?`Saved ${Math.floor((Date.now()-h)/6e4)}m ago`:"Draft saved"]}),P==="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"})]}),E?`Retry ${w}/5`:`Retrying save (${w}/5)`]}),P==="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"})]}),E?"Offline":"Offline \u2014 cached locally"]}),P==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:E?"Failed":"Draft save failed"}),P==="conflict"&&(E?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:()=>b?.(),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=()=>!z&&jsxRuntime.jsxs(Io,{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:[jsxRuntime.jsx(Pt,{onClick:m,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsxRuntime.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsxRuntime.jsx("polyline",{points:"7 3 7 8 15 8"})]}),children:"Save Draft"}),!t&&jsxRuntime.jsx(Pt,{onClick:s,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsxRuntime.jsx(Pt,{onClick: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(Pt,{onClick:()=>p(true),icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsxRuntime.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsxRuntime.jsx(Pt,{onClick: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(Za,{}),jsxRuntime.jsx(Pt,{onClick:c,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"})]})]}),M=()=>g&&jsxRuntime.jsx("div",{ref:u,className:"relative",children:jsxRuntime.jsxs("div",{className:"absolute right-0 top-2 p-4 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] shadow-2xl z-50 min-w-[260px]",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsxRuntime.jsx("input",{type:"datetime-local",id:"schedule-datetime",className:"kyro-form-input text-xs mb-3 w-full",min:new Date().toISOString().slice(0,16)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let E=document.getElementById("schedule-datetime")?.value;E&&x(E);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] z-50 bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsxRuntime.jsx("a",{href:`${ze}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(ql.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:j}),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 ${ve}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${de}`}),J]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(Lo,{status:r,saveStatus:a,hasChanges:R,onPublish:d,disabled:a==="saving"}),Ve(),M()]})]}),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(E=>jsxRuntime.jsx("button",{type:"button",onClick:()=>S(E),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${y===E?"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:E==="edit"?"Edit":E==="version"?"History":"API"},E))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[Te(true),R&&P!=="saving"&&P!=="retrying"&&P!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{K(G),C();},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:()=>L(!O),className:`p-1.5 rounded-lg transition-all ${O?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(ql.ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxRuntime.jsxs("header",{className:"hidden md:flex surface-tile px-8 py-6 items-center justify-between sticky top-0 border-b border-[var(--kyro-border)] mb-8 bg-[var(--kyro-surface)] z-50 backdrop-blur-md",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsxRuntime.jsx("a",{href:`${ze}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(ql.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:j}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${ve}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${de}`}),te]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[Te(false),R&&P!=="saving"&&P!=="retrying"&&P!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{K(G),C();},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),h&&P!=="saving"&&P!=="retrying"&&P!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let E=k-h,ne=Math.floor(E/6e4),ue=Math.floor(E/1e3);return ne>=1?`${ne}m ago`:ue>=5?`${ue}s ago`:"just now"})()]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",_]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",se]})]})]}),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(E=>jsxRuntime.jsx("button",{type:"button",onClick:()=>S(E),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${y===E?"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:E.toUpperCase()},E))}),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:()=>L(!O),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${O?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:"Live Preview",children:[jsxRuntime.jsx(ql.ExternalLink,{className:"w-4 h-4"}),O&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),Ve(),M(),jsxRuntime.jsx(Lo,{status:r,saveStatus:a,hasChanges:R,onPublish:d,disabled:a==="saving"})]})]})]})]})}function fc({config:e,layout:t,collectionSlug:r,renderField:o}){let{showPreview:a,sidebarCollapsed:n,formData:s,previewUrl:l}=Ce();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 c=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||!c?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsxRuntime.jsx("div",{className:"space-y-6 md:space-y-8 animate-in fade-in slide-in-from-left-4 duration-500",children:e.tabs?o({type:"tabs",tabs:e.tabs}):jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(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:l||"",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 vc({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:l,setCompareDiffs:i,loadingDiffs:c,loadingVersions:d,versions:m}=Ce();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:c,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:c?"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(ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:l.map((x,b)=>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:x.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof x.oldValue=="object"?JSON.stringify(x.oldValue):String(x.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 x.newValue=="object"?JSON.stringify(x.newValue):String(x.newValue??"null")]})]},b))})]}),d?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((x,b)=>{let k=n.includes(x.id),f=(x.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(x.id):void 0,className:`transition-all ${o?k?"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 ${k?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:k&&jsxRuntime.jsx(ql.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:m.length-b})}),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:[x.changeDescription||"Snapshot",f&&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(x.createdAt||x.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:x.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${x.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${x.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),x.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:x.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(x.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 ${k?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:k&&jsxRuntime.jsx(ql.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:m.length-b})}),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:[x.changeDescription||"Snapshot",f&&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(x.createdAt||x.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),x.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 ${x.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${x.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),x.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:x.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(x.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"})]})]},x.id)})})]})})}function gc({collectionSlug:e,globalSlug:t}){let{formData:r}=Ce();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 ms=class extends Da.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("[ErrorBoundary] Caught:",t,r),this.setState({errorInfo:r.componentStack||null});}handleCopyToClipboard=()=>{let{error:t,errorInfo:r}=this.state,o=Ce.getState().formData,a={error:t?.message,stack:t?.stack,componentStack:r,formData:o,timestamp:new Date().toISOString()};navigator.clipboard.writeText(JSON.stringify(a,null,2)).then(()=>{U.success("Crash details copied to clipboard");});};handleReload=()=>{window.location.reload();};render(){return this.state.hasError?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:jsxRuntime.jsx(ql.TriangleAlert,{className:"w-8 h-8 text-red-500"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold text-[var(--kyro-text-primary)]",children:this.props.fallbackTitle||"Something went wrong"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] text-center max-w-md",children:"The form encountered an unexpected error. Your unsaved changes may still be recoverable."}),this.state.error&&jsxRuntime.jsx("p",{className:"text-xs font-mono text-red-500/70 bg-red-500/5 px-4 py-2 rounded-lg max-w-full overflow-auto",children:this.state.error.message}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[jsxRuntime.jsxs("button",{type:"button",onClick:this.handleReload,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(ql.RefreshCw,{className:"w-4 h-4"}),"Reload Page"]}),jsxRuntime.jsxs("button",{type:"button",onClick:this.handleCopyToClipboard,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/20 transition-colors",children:[jsxRuntime.jsx(ql.Copy,{className:"w-4 h-4"}),"Copy Details"]})]})]}):this.props.children}};function bc(e,t){if(!(!e||typeof t!="string"))return t.split(".").reduce((r,o)=>r&&r[o]!==void 0?r[o]:void 0,e)}function Ti(e,t,r){if(!e)return true;if(Array.isArray(e.and))return e.and.every(o=>Ti(o,t,r));if(Array.isArray(e.or))return e.or.some(o=>Ti(o,t,r));if(e.field){let o=e.field,a=bc(t,o);return a===void 0&&(a=bc(r,o)),"equals"in e?a===e.equals:"notEquals"in e?a!==e.notEquals:"in"in e&&Array.isArray(e.in)?e.in.includes(a):"greaterThan"in e?typeof a=="number"&&a>e.greaterThan:!!a}return true}var xc={};function en({config:e,data:t=xc,errors:r=xc,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:l,documentName:i,layout:c="split",onActionSuccess:d,onActionError:m,justSaved:x}){let b=e||(s?kd[s]:n?ra[n]:null),[k,f]=Da.useState(b);Da.useEffect(()=>{s==="storage-settings"?De("/api/kyro/schema").then(D=>{D?.globals?.["storage-settings"]&&f(D.globals["storage-settings"]);}).catch(D=>console.error("[AutoForm] Failed to fetch dynamic schema",D)):f(b);},[s,b]);let g=k||b,{confirm:p}=ft(),{formData:u,hasUnsavedChanges:R,autoSaveStatus:w,lastSavedAt:y,view:j,setView:_,setShowPreview:Te,isMenuOpen:Ve,setIsMenuOpen:M,loadingFields:E,setLoadingFields:ne,compareSelected:A,setCompareSelected:$,setCompareDiffs:Ke,setLoadingDiffs:We,setField:Fe,setFormData:yt,markSaved:wt,setLastSavedData:I,setAutoSaveStatus:H,fetchVersions:q,saveDocument:xe,forceSave:Re,autoSaveSkipRef:Ue,lastAutoSaveTimeRef:B,documentStatus:ee,hasUnpublishedChanges:ce,versionsEnabled:br}=nc({config:g,initialData:t,collectionSlug:n,globalSlug:s,documentId:l,onChange:o,onActionSuccess:d,onActionError:m}),go=Da.useRef(null),Na=Da.useRef(null),[rn,on]=Da.useState(false),[T,ae]=Da.useState("idle"),[Le,zt]=Da.useState(false),[jt,xr]=Da.useState(Date.now()),hs=a,[ws,an]=Da.useState(false),[cp,Ns]=Da.useState(false),[pp,mp]=Da.useState(0),Li=Da.useRef(new Map),up=3e4;Da.useEffect(()=>{let D=s?`global:${s}`:`${n}:${l}`;if(!(s||n&&l&&l!=="new")||t&&Object.keys(t).length>0)return;let ke=Li.current.get(D),Oe=ke&&Date.now()-ke.ts<up,Nt=ke&&!Oe;if(Oe){Ce.getState().loadDocument(ke.data,ke.data);return}Nt&&Ce.getState().loadDocument(ke.data,ke.data);let Dt=new AbortController;Ns(false),ke||an(true);let Br=s?`/api/globals/${s}`:`/api/${n}/${l}`;return De(Br,{autoToast:false,signal:Dt.signal}).then(Ct=>{let bo=Ct.data||{};Li.current.set(D,{data:bo,ts:Date.now()}),Ce.getState().loadDocument(bo,bo),an(false);}).catch(Ct=>{Ct.name!=="AbortError"&&(an(false),ke||Ns(true));}),()=>Dt.abort()},[n,l,s,t,pp]),Da.useEffect(()=>{let D=setInterval(()=>xr(Date.now()),1e4);return ()=>clearInterval(D)},[]);let Mi=(D,Q)=>{if(typeof D=="function")try{return D(u,Q)}catch(ke){return console.warn("Error evaluating admin runtime flag:",ke),false}return !!D},yp=D=>{p({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?Je(`/api/globals/${s}/versions/${D}/restore`):Je(`/api/${n}/${u.id}/versions/${D}/restore`),ke=await lt(Q,{method:"POST"});!ke.ok&&n&&(ke=await lt(Je(`/api/${n}/${u.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:D,action:"restore"})}));let Oe=await ke.json();if(Oe.data){let{updatedAt:Nt,createdAt:Dt,...Br}=Oe.data,Ct={...u,...Br};yt(Ct),Ce.getState().loadDocument(Ct,Ct),d?.("Version restored successfully"),q(),_("edit");}else U.error(Oe.error||"Failed to restore version");}catch(Q){console.error("Failed to restore version:",Q),U.error("Failed to restore version");}}});},fp=async()=>{if(A.length===2){We(true);try{let Q=await(await lt(Je(`/api/${n}/${u.id}/versions?compareA=${A[0]}&compareB=${A[1]}`))).json();Ke(Q.diffs||[]);}catch(D){console.error("Compare failed:",D),Ke([]);}finally{We(false);}}},vp=D=>{$(Q=>Q.includes(D)?Q.filter(ke=>ke!==D):Q.length>=2?[Q[1],D]:[...Q,D]);};Da.useEffect(()=>{let D=Q=>{(Q.metaKey||Q.ctrlKey)&&Q.key==="s"&&(Q.preventDefault(),nn()),(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(),Te(ke=>!ke)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(Q.key==="1"&&_("edit"),Q.key==="2"&&_("version"),Q.key==="3"&&_("api"));};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[]),Da.useEffect(()=>{let D=()=>_("version");return window.addEventListener("kyro:show-version-history",D),()=>window.removeEventListener("kyro:show-version-history",D)},[]),Da.useEffect(()=>{let D=Q=>{go.current&&!go.current.contains(Q.target)&&M(false);};if(Ve)return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[Ve]),Da.useEffect(()=>{let D=Q=>{Na.current&&!Na.current.contains(Q.target)&&on(false);};if(rn)return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[rn]);let gp=()=>{R?p({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await nn(),await new Promise(D=>setTimeout(D,1e3)),window.location.href=`${ze}/${n}/new`;}}):window.location.href=`${ze}/${n}/new`;},bp=()=>{if(!u.id){U.error("Please save the document before duplicating.");return}let D=async()=>{try{zt(!0);let Q=await lt(`/api/${n}/${u.id}/duplicate`,{method:"POST"});if(Q.ok){let ke=await Q.json();d?.("Document duplicated successfully"),ke.data?.id?window.location.href=`${ze}/${n}/${ke.data.id}`:window.location.href=`${ze}/${n}`;}else {let ke=await Q.json();U.error(ke.error||"Failed to duplicate");}}catch{U.error("Failed to duplicate document");}finally{zt(false);}};if(R){p({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await nn(),await D();}});return}p({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await D();}});},xp=()=>{p({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{Ue.current=true;try{await Tt(`/api/${n}/${u.id}`),window.location.href=`${ze}/${n}`;}catch(D){U.error(D.message||"Failed to delete document");}finally{Ue.current=false;}}});},kp=()=>{p({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{Ue.current=true;try{let D=await xe({...u,status:"draft"},!1);if(D?.ok)d?.("Document unpublished successfully"),Ce.getState().loadDocument({...u,status:"draft"},{...u,status:"draft"});else {let Q=await D?.json().catch(()=>({}));U.error(Q?.error||"Failed to unpublish");}}catch{U.error("Failed to unpublish");}finally{Ue.current=false;}}});},nn=async()=>{let D=!u.id;Ue.current=true,ae("saving");try{let Q=Wt({...u}),ke=D&&!s,Oe=ke?await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}):await xe(Q);if(Oe.ok){let Nt=await Oe.json(),Dt=Nt.data||Q;yt({...u,...Dt}),wt(),B.current=Date.now(),H("success"),ae("saved"),br&&q(),setTimeout(()=>{H("idle"),ae("idle");},2e3),d?.(ke?"Document created successfully":"Changes saved"),ke&&setTimeout(()=>{window.location.href=`${ze}/${n}/${Nt.data.id}`;},800);}else {let Nt=await Oe.json();Oe.status===409&&H("conflict"),ae("error"),U.error(Nt.error||"Failed to save"),setTimeout(()=>ae("idle"),3e3);}}catch{ae("error"),U.error("Failed to save document"),setTimeout(()=>ae("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),Ue.current=false;}},hp=async()=>{let D=!u.id;Ue.current=true,ae("saving");try{let Q={...u};if(D&&!s){let Nt=Wt({...u}),Dt=await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Nt)});if(!Dt.ok){let bo=await Dt.json().catch(()=>({}));Dt.status===409&&H("conflict"),ae("error"),U.error(bo.error||"Failed to create document"),setTimeout(()=>ae("idle"),3e3);return}let Ct=(await Dt.json()).data||Nt;yt({...u,...Ct}),wt(),Q={...u,...Ct};}let ke=Wt(Q),Oe=await xe(ke,!1);if(Oe?.ok){let Dt=(await Oe.json().catch(()=>({}))).data||ke;yt({...u,...Dt}),wt(),ae("saved"),d?.("Published successfully"),setTimeout(()=>{ae("idle");},2e3),D&&!s&&Q.id&&setTimeout(()=>{window.location.href=`${ze}/${n}/${Q.id}`;},800);}else {if(D&&!s&&Q.id){let Dt=await Oe?.json().catch(()=>({}));U.warning("Document saved as draft. Publishing failed: "+(Dt?.error||"Unknown error")),setTimeout(()=>{window.location.href=`${ze}/${n}/${Q.id}`;},1200);return}let Nt=await Oe?.json().catch(()=>({}));Oe?.status===409&&H("conflict"),ae("error"),U.error(Nt?.error||"Failed to publish"),setTimeout(()=>ae("idle"),3e3);}}catch{ae("error"),U.error("Failed to publish"),setTimeout(()=>ae("idle"),3e3);}finally{Ue.current=false;}},wp=async D=>{let Q=!u.id;Ue.current=true;try{let ke={...Wt({...u}),_schedulePublishAt:D};if(Q&&!s){let Oe=await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ke)});if(!Oe.ok){let Nt=await Oe.json().catch(()=>({}));U.error(Nt.error||"Failed to schedule publish");return}}else {let Oe=await xe(ke);if(!Oe.ok){let Nt=await Oe.json().catch(()=>({}));U.error(Nt.error||"Failed to schedule publish");return}}d?.(`Scheduled publish for ${new Date(D).toLocaleString()}`),on(!1);}catch{U.error("Failed to schedule publish");}finally{Ue.current=false;}},Np=(D,Q)=>{Fe(D,Q);},Ca=(D,Q,ke)=>{let Oe=Q!==void 0?Q:u;if(Mi(D.hidden!==void 0?D.hidden:D.admin?.hidden,Oe))return null;let Dt=Mi(D.readOnly!==void 0?D.readOnly:D.admin?.readOnly,Oe),Br=!!(hs||Dt);if(D.admin?.condition){if(typeof D.admin.condition=="function")try{let it={values:u||{},...u||{}};if(!D.admin.condition(it,Oe))return null}catch(it){console.warn(`Condition error for field ${D.name}:`,it);}else if(typeof D.admin.condition=="object")try{if(!Ti(D.admin.condition,Oe,u))return null}catch(it){console.warn(`Declarative condition error for field ${D.name}:`,it);}}let Ct=Oe[D.name],bo=r[D.name],sn=it=>{ke?ke({...Oe,[D.name]:it}):Np(D.name,it);};if(D.type==="row"&&"fields"in D){let it=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:it?.map(at=>{let Lr=at.admin||{},ln=Lr?.action;if((at.type==="button"||at.type==="action")&&ln){let kr=it?.find(Sa=>Sa.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let Sa=D.name,dn=kr?.name,cn=dn?u[dn]:void 0;if(!cn&&Sa&&typeof Sa=="string"&&dn&&(cn=u[Sa]?.[dn]),!!cn){ne(hr=>({...hr,[at.name]:true}));try{let hr=await lt(Je(ln),{method:Lr.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:cn})}),Ta={};try{Ta=await hr.json();}catch{Ta={};}if(hr.ok&&Ta.success)d?.(Ta.message||"Action completed successfully");else {let Cp=Ta.error||`Request failed (${hr.status})`;m?.(Cp);}}catch(hr){m?.(hr instanceof Error?hr.message:"Error connecting to server");}finally{ne(hr=>({...hr,[at.name]:false}));}}},disabled:E[at.name]||Br,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:E[at.name]?"Sending...":at.label||"Click"})},at.name)}return jsxRuntime.jsx("div",{className:at.type==="button"||at.type==="action"?"flex-shrink-0":"flex-1",style:Lr?.width?{width:Lr.width,flex:"none"}:{},children:Ca(at,Q,ke)},at.name)})},D.name||`row-${Math.random()}`)}switch(D.type){case "tabs":return jsxRuntime.jsx(pc,{field:D,formData:u,onTabDataChange:it=>{Fe(D.name,it);},renderField:(it,at,Lr)=>Ca(it,at,Lr)},D.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(rs,{field:D,value:Ct,onChange:sn,renderField:Ca},D.name);case "array":return jsxRuntime.jsx(os,{field:D,value:Ct,onChange:sn,renderField:Ca,disabled:Br},D.name);case "button":case "action":{let it=D.name,at=E[it];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:at||Br,onClick:async()=>{let Lr=D.admin?.action||D.action,ln=D.admin?.method||D.method||"POST";if(Lr){ne(kr=>({...kr,[it]:true}));try{let kr=await lt(Lr,{method:ln,headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});await kr.json(),kr.ok;}catch(kr){console.error("Error executing action:",kr);}finally{ne(kr=>({...kr,[it]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${at?"opacity-70 cursor-not-allowed":""}`,children:[at&&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"})]}),at?"Processing...":D.label||"Click"]})},it)}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(Ya,{relationTo:D.relationTo,hasMany:D.hasMany,selectedIds:Array.isArray(Ct)?Ct:Ct?[Ct]:[],onChange:(it,at)=>{sn(at);},compact:true}),D.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(D.admin?.description)}):null]},D.name);default:return jsxRuntime.jsx(Do,{field:D,value:Ct,onChange:sn,error:bo,disabled:Br,formData:u,siblingData:Oe,collectionSlug:n,globalSlug:s},D.name||Math.random().toString())}};return ws?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Vt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Vt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Vt,{variant:"rect",count:4})})]}):cp?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(ql.TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{Ns(false),an(true),mp(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:[c!=="single"&&jsxRuntime.jsx(yc,{collectionSlug:n,globalSlug:s,documentStatus:ee||"draft",hasUnpublishedChanges:ce,localSaveStatus:T,isDuplicating:Le,handleCreateNew:gp,handleDuplicate:bp,handleUnpublish:kp,handleDelete:xp,handlePublish:hp,handleSaveDraft:nn,handleSchedulePublish:wp,handleConflictOverride:()=>Re()}),c==="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:[w==="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..."]}),w==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(ql.Check,{className:"w-4 h-4"}),y?`Saved ${Math.floor((Date.now()-y)/6e4)}m ago`:"Saved"]}),w==="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..."]}),w==="offline"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),w==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),w==="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),R&&w!=="saving"&&w!=="retrying"&&w!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!R&&w!=="success"&&w!=="saving"&&w!=="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()=>{Ue.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let D=await xe(u);if(D.ok){let ke=(await D.json()).data||u;yt({...u,...ke}),I({...u,...ke}),d?.("Changes saved");}}catch(D){console.error("Save error exception:",D),m?.("Save failed: "+D.message);}finally{Ue.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsxRuntime.jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxRuntime.jsxs(ms,{children:[j==="edit"&&jsxRuntime.jsx(fc,{config:g,layout:c,collectionSlug:n,renderField:Ca}),j==="version"&&jsxRuntime.jsx(vc,{handleRestoreVersion:yp,handleCompareVersions:fp,toggleCompareSelection:vp}),j==="api"&&jsxRuntime.jsx(gc,{collectionSlug:n,globalSlug:s})]})})]})}var kc={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function Ai({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:s,onViewHistory:l,onPreview:i,onDelete:c,onBack:d,onToggleSidebar:m,publishedAt:x,updatedAt:b,onCopyData:k,onPasteData:f}){let g=Ce(S=>S.view)||"edit",p=Ce(S=>S.setView),[u,v]=Da.useState(false),R=Da.useRef(null);Da.useEffect(()=>{let S=O=>{R.current&&!R.current.contains(O.target)&&v(false);};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);let P=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,h=["edit","version","api"],w=P(),y="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:[d&&jsxRuntime.jsx("button",{type:"button",onClick:d,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 ${kc[e]||"bg-[var(--kyro-text-muted)]"}`}),w&&jsxRuntime.jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline mr-0.5"}),w]}),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:h.map(S=>jsxRuntime.jsx("button",{type:"button",onClick:()=>p(S),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${g===S?"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:S==="edit"?"Edit":S==="version"?"Ver":"API"},S))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${y} max-md:hidden`,title:"Preview",children:jsxRuntime.jsx(ql.Eye,{className:"w-3.5 h-3.5"})}),l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${y} max-md:hidden`,title:"View History",children:jsxRuntime.jsx(ql.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${y} max-md:hidden`,title:"Duplicate",children:jsxRuntime.jsx(ql.Copy,{className:"w-3.5 h-3.5"})}),k&&jsxRuntime.jsx("button",{type:"button",onClick:k,className:`${y} max-md:hidden`,title:"Copy Data",children:jsxRuntime.jsx(ql.ClipboardCopy,{className:"w-3.5 h-3.5"})}),f&&jsxRuntime.jsx("button",{type:"button",onClick:f,className:`${y} max-md:hidden`,title:"Paste Data",children:jsxRuntime.jsx(ql.ClipboardPaste,{className:"w-3.5 h-3.5"})}),c&&jsxRuntime.jsx("button",{type:"button",onClick:c,className:`${y} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:"Delete",children:jsxRuntime.jsx(ql.Trash2,{className:"w-3.5 h-3.5"})}),m&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:`${y} 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:R,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>v(!u),className:y,title:"More",children:jsxRuntime.jsx(ql.EllipsisVertical,{className:"w-3.5 h-3.5"})}),u&&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:[w&&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 ${kc[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:w})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:h.map(S=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{p(S),v(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${g===S?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:S==="edit"?"Edit":S==="version"?"Ver":"API"},S))}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),v(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(ql.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),v(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(ql.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),k&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{k(),v(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(ql.ClipboardCopy,{className:"w-3.5 h-3.5"})," Copy Data"]}),f&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{f(),v(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(ql.ClipboardPaste,{className:"w-3.5 h-3.5"})," Paste Data"]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),v(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(ql.Eye,{className:"w-3.5 h-3.5"})," Preview"]}),c&&jsxRuntime.jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>{c(),v(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger-bg)] transition-colors",children:[jsxRuntime.jsx(ql.Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxRuntime.jsxs("button",{type:"button",onClick:a,disabled:t==="saving",className:"kyro-btn kyro-btn-primary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(ql.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxRuntime.jsxs("button",{type:"button",onClick:n,disabled:t==="saving",className:"kyro-btn kyro-btn-secondary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(ql.Undo,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxRuntime.jsxs(Lo,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[s&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(ql.Copy,{className:"w-4 h-4"}),onClick:s,children:"Duplicate"}),k&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(ql.ClipboardCopy,{className:"w-4 h-4"}),onClick:k,children:"Copy Data"}),f&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(ql.ClipboardPaste,{className:"w-4 h-4"}),onClick:f,children:"Paste Data"}),l&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(ql.Clock,{className:"w-4 h-4"}),onClick:l,children:"View History"}),i&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(ql.Eye,{className:"w-4 h-4"}),onClick:i,children:"Preview"}),(s||k||f||l||i)&&jsxRuntime.jsx(Za,{}),c&&jsxRuntime.jsx(Pt,{onClick:c,danger:true,icon:jsxRuntime.jsx(ql.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function Ri({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:l,mode:i="collection"}){let{confirm:c,alert:d}=ft(),[m,x]=Da.useState({}),[b,k]=Da.useState({}),[f,g]=Da.useState(true),[p,u]=Da.useState(false),[v,R]=Da.useState(false),[P,h]=Da.useState(false),[w,y]=Da.useState("idle"),[S,O]=Da.useState("draft"),[L,K]=Da.useState(null),[C,G]=Da.useState(null),[z,j]=Da.useState(null),[_,se]=Da.useState(false),te=Ce(I=>I.showPreview),J=Ce(I=>I.setShowPreview),de=Ce(I=>I.previewUrl),ve=Ce(I=>I.setPreviewUrl),Te=r?.fields||t?.fields||[],Ve=r?.label||t?.label||"Document",M=r?.slug||t?.slug||"",E=JSON.stringify(m)!==JSON.stringify(b);Da.useEffect(()=>{E&&S==="published"&&O("draft");},[E,S]),Da.useEffect(()=>{E&&w==="saved"&&y("idle");},[E,w]),Da.useEffect(()=>{i==="global"?ue():o&&ne();},[o,i,M]);let ne=async()=>{try{g(!0);let I=await De(`/api/${M}/${o}`,{autoToast:!1}),H=I.data||{};x(H),k(H),O(H?.status||I.status||"draft"),K(I.createdAt||H.createdAt||null),G(I.updatedAt||H.updatedAt||null),j(I.publishedAt||H.publishedAt||null);}catch{l("Failed to load document");}finally{g(false);}},ue=async()=>{try{g(!0);let I=await De(`/api/globals/${M}`,{autoToast:!1}),H=I.data||{};x(H),k(H),K(I.createdAt||null),G(I.updatedAt||null);}catch{l("Failed to load global");}finally{g(false);}},$e=Da.useCallback(async(I=false)=>{try{y("saving");let H=i==="global"?`/api/globals/${M}`:`/api/${M}/${o}`,q=S==="draft"||m?.status==="draft",xe=await Yt(H,m,{autoToast:!1,headers:{"X-Draft":String(q)}}),Re=xe&&(xe.data||xe)||m;I||(k(Re),n()),x(Re),O(Re?.status||S),y("saved"),G(new Date().toISOString()),se(!0),setTimeout(()=>se(!1),3e3),I||(S==="draft"||Re?.status==="draft"?U.warning("Draft saved"):U.success("Updated")),setTimeout(()=>{y("idle");},2e3),te&&Fe(Re);}catch{y("error"),I||(l("Failed to save changes"),U.error("Failed to save changes"));}finally{u(false);}},[m,i,M,o,S,n,l]),A=async()=>{try{u(!0),await Yt(`/api/${M}/${o}`,m,{autoToast:!1,headers:{"X-Draft":"false"}}),O("published"),j(new Date().toISOString()),U.success("Published successfully"),n();}catch{l("Failed to publish"),U.error("Failed to publish");}finally{u(false);}},$=async()=>{try{u(!0),await Yt(`/api/${M}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),O("draft"),U.warning("Document unpublished"),n();}catch{l("Failed to unpublish"),U.error("Failed to unpublish");}finally{u(false);}},Z=async()=>{try{R(!0);let I=await dt(`/api/${M}/${o}/duplicate`,void 0,{autoToast:!1});U.success("Document duplicated"),I?.data?.id?window.location.href=`${ze}/${M}/${I.data.id}`:window.location.href=`${ze}/${M}`;}catch(I){U.error(I.message||"Failed to duplicate document");}finally{R(false);}},Ke=async()=>{try{let I={...m};delete I.id,delete I.createdAt,delete I.updatedAt,delete I.status,await navigator.clipboard.writeText(JSON.stringify(I)),U.success("Document data copied to clipboard");}catch{U.error("Failed to copy document data");}},fe=async()=>{try{let I=await navigator.clipboard.readText(),H=JSON.parse(I);if(typeof H!="object"||H===null)throw new Error("Invalid format");x(q=>({...q,...H,id:q.id,createdAt:q.createdAt,updatedAt:q.updatedAt,status:q.status})),U.success("Document data pasted");}catch{U.error("Clipboard does not contain valid document JSON");}},We=()=>{c({title:`Delete ${Ve}?`,message:"This action cannot be undone.",variant:"danger",onConfirm:async()=>{try{h(!0),await Tt(`/api/${M}/${o}`),window.location.href=`${ze}/${M}`;}catch{h(false);}}});},Fe=async(I=m)=>{try{let H=i==="global"?`/api/globals/${M}/preview-url`:`/api/${M}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",H,"with data keys:",Object.keys(I||{}),"documentId:",o);let q=await dt(H,{...I,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(q)),q&&q.url?(console.log("[Kyro Preview] Setting previewUrl:",q.url),ve(q.url)):console.warn("[Kyro Preview] No url in response:",q);}catch(H){console.error("[Kyro Preview] Error:",H.message,H),U.error(H.message||"Failed to generate preview URL");}};Da.useEffect(()=>{te&&Fe(m);},[te]);let yt=()=>{let I=!te;J(I),I&&Fe(m);};if(f)return jsxRuntime.jsx("div",{className:"kyro-detail",children:jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Vt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Vt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Vt,{variant:"rect",count:4})})]})});let wt=i==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx($t,{back:{onClick:a},breadcrumbs:[{label:i==="global"?"Globals":"Collections"},{label:Ve,href:i==="collection"?`${ze}/${M}`:void 0},{label:i==="global"||o?"Edit":"New"}],title:i==="global"?Ve:No(t?.fields,m,t?.admin?.useAsTitle||"title")||m.name||o||`New ${t?.singularLabel||Ve}`,metadata:[jsxRuntime.jsx(It,{variant:S==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:S},"status")]}),jsxRuntime.jsx(Ai,{status:S,saveStatus:w,hasChanges:E,onSave:()=>$e(false),onPublish:A,onUnpublish:S==="published"?$:void 0,onDuplicate:Z,onCopyData:Ke,onPasteData:fe,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:yt,onDelete:We,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:z,updatedAt:C}),jsxRuntime.jsxs("div",{className:te?"w-full mx-auto grid grid-cols-1 lg:grid-cols-2 gap-4 md:gap-8 pt-4 md:pt-0 h-[calc(100vh-140px)]":wt?"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 ${te?"overflow-y-auto pr-2 pb-20":""}`,children:jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsxRuntime.jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Core Configuration"}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(en,{config:t?{...t,fields:Te}:{slug:"unknown",fields:Te},data:m,onChange:x,layout:wt?"single":"split",globalSlug:i==="global"?M:void 0,collectionSlug:i==="collection"?M:void 0,onActionSuccess:I=>U.success(I),onActionError:I=>U.error(I),documentStatus:S,justSaved:_}),wt&&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,disabled:P||p,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(Lo,{status:S,saveStatus:p?"saving":"idle",hasChanges:E,onPublish:()=>$e(false),disabled:p})]})]})}),te&&jsxRuntime.jsxs("div",{className:"surface-tile flex flex-col overflow-hidden h-full border border-[var(--kyro-border)] rounded-xl animate-in fade-in slide-in-from-right-4 duration-500 shadow-xl bg-white dark:bg-black",children:[jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface-accent)] border-b border-[var(--kyro-border)] p-2 flex items-center justify-between shrink-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-2",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-red-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-green-400/80"})]}),jsxRuntime.jsx("div",{className:"text-[10px] font-mono opacity-50 truncate max-w-[60%] bg-[var(--kyro-bg)] px-3 py-1 rounded",children:de||"Generating preview URL..."}),jsxRuntime.jsx("div",{className:"w-16"})]}),jsxRuntime.jsx("div",{className:"flex-1 bg-white relative",children:de?jsxRuntime.jsx("iframe",{src:de,className:"w-full h-full border-0 bg-white",title:"Preview",sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"}):jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx(ar,{className:"w-6 h-6 text-[var(--kyro-primary)]"})})})]}),!wt&&!te&&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 ${S==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:S||"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:L?new Date(L).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:C?new Date(C).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"Just now"})]}),z&&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(z).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:Z,disabled:v||p,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:v?"Duplicating...":"Duplicate Document"}),de&&jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(de,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:"Open Preview in New Tab"}),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 Pi({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=Da.useState({}),[l,i]=Da.useState(false),c=t.fields||[],d=t.label||t.slug,m=async x=>{try{i(!0),await dt(`/api/${t.slug}`,n),U.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(b){a(b instanceof Error?b.message:"Failed to create");}finally{i(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx($t,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:d,href:`${ze}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||d}`,action:{label:l?"Creating...":`Create ${t.singularLabel||d}`,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(en,{config:{...t,fields:c},data:n,onChange:s})})})})})]})}function wc({type:e,message:t,onClose:r}){let[o,a]=Da__default.default.useState(false),n=Da__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},l=()=>{n.current&&clearTimeout(n.current);};Da__default.default.useEffect(()=>(o?l():s(),l),[o,r]);let i={success:ql.CircleCheck,error:ql.ShieldAlert,warning:ql.TriangleAlert,info:ql.Info}[e];return jsxRuntime.jsxs("div",{className:`kyro-toast kyro-toast-${e} group animate-in fade-in slide-in-from-right-4 duration-300`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),children:[jsxRuntime.jsx("div",{className:"kyro-toast-accent"}),jsxRuntime.jsx("div",{className:"kyro-toast-icon-container",children:jsxRuntime.jsx(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(ql.X,{className:"w-3.5 h-3.5"})})]})}function dA({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function cA(){let e=Xt(o=>o.addToast),t=Xt(o=>o.removeToast);return {toasts:Xt(o=>o.toasts),addToast:e,removeToast:t}}function ys(){let e=Xt(r=>r.toasts),t=Xt(r=>r.removeToast);return jsxRuntime.jsx("div",{className:"kyro-toasts-container",style:{position:"fixed",bottom:"24px",right:"24px",display:"flex",flexDirection:"column",gap:"12px",zIndex:1e5,pointerEvents:"none"},children:e.map(r=>jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:jsxRuntime.jsx(wc,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Ii({onAuth:e,theme:t="light"}){let[r,o]=Da.useState("login"),[a,n]=Da.useState(""),[s,l]=Da.useState(""),[i,c]=Da.useState(""),[d,m]=Da.useState(false),[x,b]=Da.useState(false),k=Xt(p=>p.addToast);Da.useEffect(()=>{f();},[]);let f=async()=>{try{await De("/api/users");}catch{b(true),o("register");}};return jsxRuntime.jsx(Tr,{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:x?"Create Admin Account":r==="login"?"Sign In":"Create Account"}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:x?"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 p=>{p.preventDefault(),m(true);try{let u=r==="login"?"/api/auth/login":"/api/auth/register",v={email:a,password:s};r==="register"&&(v.confirmPassword=i);let R=await dt(u,v);R.isFirstUser&&b(!0),localStorage.setItem("kyro_user",JSON.stringify(R.user)),k("success",r==="login"?"Welcome back!":"Account created!"),e(R.token,R.user);}catch{k("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:p=>n(p.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:"Password"}),jsxRuntime.jsx("input",{id:"password",type:"password",value:s,onChange:p=>l(p.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:p=>c(p.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsxRuntime.jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:d,children:d?r==="login"?"Signing in...":"Creating account...":r==="login"?"Sign In":"Create Account"})]}),!x&&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(ys,{})]})})}function Sc({collections:e,onNavigate:t,user:r}){let{permissions:o}=Kr(),[a,n]=Da.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[s,l]=Da.useState(true);Da.useEffect(()=>{let c=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(c)},[]);let i=Object.entries(e).filter(([c])=>!ei.includes(c)&&o?.collections?.[c]?.read!==false);return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsxRuntime.jsx($t,{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:ql.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:ql.FileText,color:"text-blue-500"},{label:"Media Assets",value:a.totalMedia,icon:ql.Image,color:"text-purple-500"},{label:"Active Users",value:a.totalUsers,icon:ql.Users,color:"text-green-500"},{label:"System Health",value:"100%",icon:ql.Activity,color:"text-amber-500"}].map((c,d)=>jsxRuntime.jsxs("div",{className:"surface-tile p-6 flex items-center justify-between group hover:border-[var(--kyro-primary)] transition-all duration-500 cursor-default",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:c.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:s?jsxRuntime.jsx(Vt,{variant:"text",className:"w-16"}):c.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${c.color}`,children:jsxRuntime.jsx(c.icon,{className:"w-6 h-6"})})]},d))}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxRuntime.jsxs("div",{className:"space-y-8 min-w-0",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(ql.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),"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(([c,d])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",c),className:"p-6 rounded-2xl border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-bg-secondary)] hover:bg-[var(--kyro-surface)] transition-all cursor-pointer group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:d.label||c}),jsxRuntime.jsx(ql.ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsxRuntime.jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:d.admin?.description||`Manage ${c} content.`})]},c))})]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-4",children:jsxRuntime.jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(ql.Plus,{className:"w-5 h-5"}),"Quick Links"]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[i.filter(([c])=>o?.collections?.[c]?.create!==false).map(([c])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",c),className:"w-full flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group/btn",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:["New ",e[c]?.singularLabel||e[c]?.label||c]}),jsxRuntime.jsx(ql.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},c)),i.every(([c])=>o?.collections?.[c]?.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(ql.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(ql.Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(ql.Clock,{className:"w-5 h-5 opacity-40"}),"Recent Activity"]}),jsxRuntime.jsx("div",{className:"space-y-6",children:a.recentActivity.map(c=>jsxRuntime.jsxs("div",{className:"flex gap-4 group",children:[jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-bg-secondary)] flex items-center justify-center border border-[var(--kyro-border)] group-hover:bg-[var(--kyro-primary)] transition-colors",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold",children:c.user[0]})})}),jsxRuntime.jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxRuntime.jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsxRuntime.jsx("span",{className:"font-bold",children:c.user})," ",c.type==="create"?"created":c.type==="edit"?"edited":c.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',c.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:c.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:c.time})]})]},c.id))}),jsxRuntime.jsx("button",{type:"button",className:"w-full mt-6 py-3 text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors border-t border-[var(--kyro-border)] pt-6",children:"View Audit Logs"})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(ql.Activity,{className:"w-5 h-5 opacity-40"}),"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((c,d)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:c.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:c.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${c.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},d))})]})]})]})]})}function Ac(){let[e,t]=Da.useState([]),[r,o]=Da.useState(true),[a,n]=Da.useState(""),[s,l]=Da.useState(false),[i,c]=Da.useState({name:"",email:"",password:"",role:"customer"}),[d,m]=Da.useState(""),[x,b]=Da.useState(false),{confirm:k,alert:f}=ft();Da.useEffect(()=>{g();},[]);let g=async()=>{try{o(!0);let h=await De("/api/users");t(h.docs||[]);}catch(h){console.error("Failed to load users:",h);}finally{o(false);}},p=h=>{let w=!h.locked;k({title:w?"Lock User Account?":"Unlock User Account?",message:w?`Are you sure you want to lock ${h.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${h.email}?`,variant:w?"danger":"success",onConfirm:async()=>{try{await Yt(`/api/users/${h.id}`,{locked:w}),t(y=>y.map(S=>S.id===h.id?{...S,locked:w}:S)),U.success(w?`Account locked: ${h.email}`:`Account restored: ${h.email}`);}catch(y){console.error("Failed to toggle user lock:",y),U.error("Failed to update account status");}}});},u=h=>{k({title:"Destroy User Account",message:`You are about to permanently delete ${h.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await Tt(`/api/users/${h.id}`),t(w=>w.filter(y=>y.id!==h.id)),U.success(`Identity purged: ${h.email}`);}catch(w){console.error("Failed to delete user:",w),U.error("Failed to delete user");}}});},v=async()=>{if(!i.email.trim()||!i.password.trim()){m("Email and password are required");return}b(true),m("");try{await dt("/api/users",{name:i.name.trim()||void 0,email:i.email.trim(),password:i.password,role:i.role}),l(!1),c({name:"",email:"",password:"",role:"customer"}),U.success("User created successfully"),g();}catch(h){let w=h instanceof Error?h.message:"Failed to create user";m(w),U.error(w);}finally{b(false);}},R=["super_admin","admin","editor","author","customer","guest"],P=e.filter(h=>h.email.toLowerCase().includes(a.toLowerCase())||h.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($t,{title:"Identity & Access",description:"Manage the core administrative team and security permissions.",icon:ql.Users,action:{label:"New User",onClick:()=>{c({name:"",email:"",password:"",role:"customer"}),m(""),l(true);},icon:ql.UserPlus}}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 group",children:[jsxRuntime.jsx(ql.Search,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-secondary)] opacity-40 group-focus-within:opacity-100 transition-opacity"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search by identity or email...",value:a,onChange:h=>n(h.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((h,w)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},w)):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(h=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${h.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(Dy,{user:h}),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:h.name||h.email.split("@")[0]}),h.tenantId&&jsxRuntime.jsx(It,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:h.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:h.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ql.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:h.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(It,{variant:h.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:h.locked?"Restricted":"Authorized"})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsxRuntime.jsx(ql.Clock,{className:"w-3 h-3"}),h.lastLogin?new Date(h.lastLogin).toLocaleDateString():"Never"]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsxRuntime.jsx("button",{onClick:()=>p(h),className:`p-1.5 rounded-lg border transition-all ${h.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:h.locked?"Restore Access":"Restrict Access",children:h.locked?jsxRuntime.jsx(ql.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(ql.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>u(h),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(ql.Trash2,{className:"w-3.5 h-3.5"})})]})})]},h.id))})]})}),jsxRuntime.jsxs(St,{open:s,onClose:()=>l(false),title:"Create User",size:"lg",children:[jsxRuntime.jsx(Sr,{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:h=>c({...i,name:h.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:h=>c({...i,email:h.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:h=>c({...i,password:h.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:h=>c({...i,role:h.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(h=>jsxRuntime.jsx("option",{value:h,children:h},h))})]}),d&&jsxRuntime.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl flex items-center gap-2 text-red-500 text-xs font-bold",children:[jsxRuntime.jsx(ql.TriangleAlert,{className:"w-4 h-4"}),d]})]})}),jsxRuntime.jsxs(Er,{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:v,disabled:x,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:x?"Creating...":"Create User"})]})]})]})}function Dy({user:e}){let[t,r]=Da.useState(null);return Da.useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&De(`/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 Rc(){let[e,t]=Da.useState("Kyro CMS"),[r,o]=Da.useState("Command Center"),[a,n]=Da.useState("#6366f1"),[s,l]=Da.useState("Welcome back to your Command Center."),[i,c]=Da.useState(false),[d,m]=Da.useState(false);return Da.useEffect(()=>{(async()=>{try{let f=await De("/api/globals/site-settings"),g=f.data||f;g&&Object.keys(g).length>0&&(g.siteName&&t(g.siteName),g.adminTitle&&o(g.adminTitle),g.primaryColor&&n(g.primaryColor),g.dashboardGreeting&&l(g.dashboardGreeting));}catch(f){console.error("Failed to load branding:",f);}})();},[]),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()=>{c(true);try{await Yt("/api/globals/site-settings",{siteName:e,adminTitle:r,primaryColor:a,dashboardGreeting:s}),m(!0),U.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",a),setTimeout(()=>window.location.reload(),800);}catch(k){U.error("Failed to save branding"),console.error(k);}finally{c(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 ${d?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[i?jsxRuntime.jsx(ql.RefreshCcw,{className:"w-4 h-4 animate-spin"}):d?jsxRuntime.jsx(ql.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(ql.Save,{className:"w-4 h-4"}),i?"Saving...":d?"Identity Updated":"Publish Branding"]})})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(ql.Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsxRuntime.jsx("input",{type:"text",value:e,onChange:k=>t(k.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:k=>o(k.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:k=>l(k.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(ql.Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsxRuntime.jsx("div",{className:"grid grid-cols-6 gap-3",children:[{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(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>n(k.hex),className:`aspect-square rounded-xl transition-all border-4 ${a===k.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:k.hex},title:k.name},k.name))})]}),jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.jsxs("div",{className:"w-20 h-20 rounded-2xl bg-[var(--kyro-bg-secondary)] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-primary)] hover:text-[var(--kyro-primary)] cursor-pointer transition-all",children:[jsxRuntime.jsx(ql.Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsxRuntime.jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsxRuntime.jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsxRuntime.jsx(ql.Sparkles,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxRuntime.jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-2 bg-[var(--kyro-bg-secondary)] rounded-full border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[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
|
+
\`\`\``})})}),!s&&jsxRuntime.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx("span",{children:"**bold**"}),jsxRuntime.jsx("span",{children:"*italic*"}),jsxRuntime.jsx("span",{children:"`code`"}),jsxRuntime.jsx("span",{children:"[link](url)"}),jsxRuntime.jsx("span",{children:"# heading"})]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"kyro-form-help",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:o})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx("div",{className:"h-[200px] bg-[var(--kyro-surface)] animate-pulse rounded-md border border-[var(--kyro-border)]"})]})};function zn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=t??"",s=n.length>8?n.slice(0,-8)+"*".repeat(8):n;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:s,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})})})}function wo(e,t){if(e===t)return true;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return false;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!wo(e[a],t[a]))return false;return true}if(Array.isArray(e)||Array.isArray(t))return false;let r=Object.keys(e).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id"),o=Object.keys(t).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id");if(r.length!==o.length)return false;for(let a of r)if(!o.includes(a)||!wo(e[a],t[a]))return false;return true}function qs(e){if(e==null||e===""||e===false)return true;if(Array.isArray(e))return e.length===0;if(typeof e=="object"){if(Object.keys(e).length===0)return true;if(e.type==="doc"&&Array.isArray(e.content))return e.content.length===0||e.content.length===1&&e.content[0].type==="paragraph"&&!e.content[0].content}return false}function Kt(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(Kt);if(typeof e=="object"){let t=e,r=Object.keys(t),o="id"in t&&(typeof t.id=="string"||t.id===null),a="url"in t&&("filename"in t||"mimeType"in t);if(o&&a&&r.length<=25)return t.id;let n={};for(let s of r)n[s]=Kt(t[s]);return n}return e}var Un=null,id=false,Js=async()=>(Un&&id||(Un=unstorage.createStorage({driver:um__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),id=true),Un),pm=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Js()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Js()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Js()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},ge=zustand.create()(middleware.persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,previewUrl:null,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields),s=Kt(o),i=Kt(a.lastSavedData[r]);qs(s)&&qs(i)||wo(s,i)?n.delete(r):n.add(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),s={...a.formData},i=s;for(let l=0;l<n.length-1;l++)i[n[l]]===void 0&&(i[n[l]]={}),i[n[l]]={...i[n[l]]},i=i[n[l]];return i[n[n.length-1]]=o,{formData:s}});},setActiveTab:r=>e({activeTab:r}),setIsSlugLocked:r=>e(o=>({isSlugLocked:typeof r=="function"?r(o.isSlugLocked):r})),setView:r=>e({view:r}),setIsDropdownOpen:r=>e(o=>({isDropdownOpen:typeof r=="function"?r(o.isDropdownOpen):r})),setVersions:r=>e({versions:r}),setLoadingVersions:r=>e({loadingVersions:r}),setShowPreview:r=>e(o=>({showPreview:typeof r=="function"?r(o.showPreview):r})),setPreviewUrl:r=>e({previewUrl:r}),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[s,i]of Object.entries(a))o-new Date(i.draftUpdatedAt).getTime()<6048e5&&(n[s]=i);e({draftCache:n});},setDraftCache:(r,o)=>e(a=>({draftCache:{...a.draftCache,[r]:o}})),getDraftCache:r=>t().draftCache[r]||null,clearDraftCache:r=>e(o=>{let a={...o.draftCache};return delete a[r],{draftCache:a}})}),{name:"kyro-autoform-storage",storage:middleware.createJSONStorage(()=>pm()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function jn(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function Qo({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=reactI18next.useTranslation(),s=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,i=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:d,setIsSlugLocked:c,formData:u}=ge(),m=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",v=t==null?"":String(t),x={id:e.name,value:v,onChange:g=>r?.(g.target.value),placeholder:e.admin?.placeholder,disabled:a||s||l&&d,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||s||l&&d?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"relative",children:[i?jsxRuntime.jsx("textarea",{...x,rows:e.admin?.rows||4}):jsxRuntime.jsx("input",{type:m,...x,pattern:e.pattern}),l&&jsxRuntime.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r?.(jn(u[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:n("tooltips.regenerateSlug",{defaultValue:"Regenerate slug"}),children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),jsxRuntime.jsx("path",{d:"M21 3v5h-5"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>c(!d),className:`p-1.5 rounded transition-colors ${d?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:d?"Unlock slug":"Lock slug",children:d?jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})})]}),e.name?.toLowerCase().includes("metatitle")&&jsxRuntime.jsx("div",{className:"flex items-center justify-between mt-1 text-[10px] font-bold tracking-wider",children:jsxRuntime.jsxs("span",{className:v.length>60?"text-red-500":v.length>=40?"text-green-500":"text-amber-600",children:[v.length," / 60 \u2014 ",v.length>60?"Too Long":v.length>=40?"Ideal":"Short"]})})]})})}function Hn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("input",{type:"number",id:e.name,value:t??"",onChange:s=>r?.(parseFloat(s.target.value)||0),placeholder:e.admin?.placeholder,disabled:a||n,min:e.min,max:e.max,step:e.step||(e.integer?1:"any"),required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function _n({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,hideLabel:true,children:jsxRuntime.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t??false,onChange:i=>r?.(i.target.checked),disabled:a||n,className:`w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)] transition-all ${a||n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`}),jsxRuntime.jsxs("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)] tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})]})})}function Kn({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:s=>r?.(s.target.value),disabled:a||n,min:e.minDate,max:e.maxDate,required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Va(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Wn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function qn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function $a(e,t){let r=new Set(e.map(o=>o.slug));for(let o of t)r.has(o.slug)||(e.push(o),r.add(o.slug));}var fm={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function No(e,t,r){let o=t.split(".");if(o.length===0)return false;let a=o[0],n=o.slice(1).join(".");for(let s of e){if(s.name===a)if(n){if(s.fields&&Array.isArray(s.fields))return No(s.fields,n,r);if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let l of s.tabs)if(l.fields&&Array.isArray(l.fields)&&No(l.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let l=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of s.blocks)if(c.slug===l&&c.fields&&Array.isArray(c.fields))return No(c.fields,d,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?No(s.fields,n,r):false}else return Object.assign(s,r),true;if(!s.name||s.type==="tabs"||s.type==="row"||s.type==="collapsible"){if(s.fields&&Array.isArray(s.fields)&&No(s.fields,t,r))return true;if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let l of s.tabs)if(l.fields&&Array.isArray(l.fields)&&No(l.fields,t,r))return true}}}return false}function gm(e,t){for(let[r,o]of Object.entries(e)){let a=fm[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:s,...i}=n;if(o.admin={...o.admin,...i},s&&o.fields&&Array.isArray(o.fields))for(let[l,d]of Object.entries(s))No(o.fields,l,d);}}}function vm(e="blog"){let t=[],r=[];switch(e){case "minimal":t.push(...Object.values(templates.minimalCollections)),r.push(...templates.coreSettingsGlobals);break;case "starter":t.push(...Object.values(templates.starterCollections)),r.push(...templates.coreSettingsGlobals);break;case "blog":t.push(...Object.values(templates.blogCollections)),r.push(...templates.coreSettingsGlobals);break;case "ecommerce":t.push(...Object.values(templates.ecommerceCollections)),r.push(...templates.allSettingsGlobals);break;case "kitchen-sink":t.push(...Object.values(templates.minimalCollections),...Object.values(templates.starterCollections),...Object.values(templates.blogCollections),...Object.values(templates.ecommerceCollections),...Object.values(templates.kitchenSinkCollections)),r.push(...templates.allSettingsGlobals);break}return $a(t,Object.values(templates.mediaCollections)),$a(t,Object.values(templates.authCollections)),{collections:Wn(t),globals:qn(r)}}function bm(e){let t=Va(e.collections),r=Va(e.globals);if(t.length===0&&r.length===0)return vm("kitchen-sink");let o=[];return $a(o,Object.values(templates.mediaCollections)),$a(o,Object.values(templates.authCollections)),$a(o,t),{collections:Wn(o),globals:qn(r)}}var Gn=null;function xm(){if(Gn)return Gn;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Mo__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return Gn=JSON.parse(Mo__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),Gn}catch{}return null}var xd=xm()||{collections:[],globals:[]},kd=bm(xd);gm(kd.collections,xd.collectionOverrides);var hd=kd,Zo=hd.collections,wd=hd.globals,Qs=["users","audit_logs"];Object.values(Zo).filter(e=>!Qs.includes(e.slug)&&e.admin?.hidden!==true);function Jn({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,u]=Ta.useState(null),m=JSON.stringify(n||{}),v=JSON.stringify(s||{});Ta.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let f=setTimeout(async()=>{try{let b="";if(i)b=`${wr}/${i}/dynamic-options/${e.name}`;else if(l)b=`${wr}/globals/${l}/dynamic-options/${e.name}`;else return;let p=await lt(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(m),siblingData:JSON.parse(v)})});if(p.ok){let h=await p.json();h.options&&u(h.options);}}catch(b){console.error("Failed to fetch dynamic options:",b);}},300);return ()=>clearTimeout(f)},[m,v,e.name,e.options,i,l]);let x=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?x=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(x=e.options)),e.dynamicOptions==="collections"&&(x=Object.keys(Zo).filter(g=>g!=="media").map(g=>({label:Zo[g]?.label||g,value:g}))),jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:g=>{if(e.hasMany){let f=Array.from(g.target.selectedOptions,b=>b.value);r?.(f);}else r?.(g.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,style:{color:e.hasMany?void 0:x.find(g=>g.value===t)?.color||void 0},className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),x.map(g=>jsxRuntime.jsx("option",{value:g.value,style:{color:g.color||void 0,fontWeight:g.color?"bold":"normal"},children:g.label},g.value))]})})}function Xn({icon:e,title:t,description:r,action:o}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 justify-center py-16 px-8",children:[e&&jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:e}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:t}),r&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:r}),o]})}function ai(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function Em({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:i,transform:l,transition:d,isDragging:c}=sortable.useSortable({id:e}),u={transform:utilities.CSS.Transform.toString(l),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxRuntime.jsxs("span",{ref:i,style:u,className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)] border border-transparent ${c?"border-[var(--kyro-primary)] shadow-sm bg-[var(--kyro-sidebar-active)]/20":""}`,children:[!a&&jsxRuntime.jsx("div",{...n,...s,className:"cursor-grab active:cursor-grabbing hover:bg-[var(--kyro-sidebar-active)]/20 rounded p-0.5 text-[var(--kyro-sidebar-active)] opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})}function Mm({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=reactI18next.useTranslation(),[s,i]=Ta.useState(false),[l,d]=Ta.useState(""),[c,u]=Ta.useState([]),[m,v]=Ta.useState(false),[x,g]=Ta.useState([]),f=Ta.useRef(new Set),b=Ta.useRef(null),p=Ta.useRef(()=>{});p.current=r||(()=>{});let h=e.hasMany,A=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],$=A.length>1,[T,k]=Ta.useState(A[0]||""),y=Ta.useCallback(()=>t?(h?Array.isArray(t)?t:[]:t?[t]:[]).map(oe=>typeof oe=="object"&&oe!==null?oe.value||oe.id||"":String(oe)).filter(Boolean):[],[t,h]),w=Ta.useCallback(E=>{E.length!==0&&E.forEach(oe=>{if(f.current.has(oe))return;f.current.add(oe);let ie=$?(()=>{if(!t)return T;let G=(h?Array.isArray(t)?t:[]:[t]).find(ye=>typeof ye=="object"&&ye!==null?ye.value===oe||ye.id===oe:false);return G&&typeof G=="object"&&G.relationTo||T})():T;Ee(`/api/${ie}/${oe}`).then(ee=>{let G=ee.data||ee;!G||typeof G!="object"||g(ye=>ye.some(De=>De.id===oe)?ye:[...ye,{...G,id:String(G.id),relationTo:ie}]);}).catch(()=>{});});},[$,t,T,h]);Ta.useEffect(()=>{let E=y();w(E);},[y,w]);let D=Ta.useCallback((E="")=>{v(true);let ie=`/api/${T}?${nn(E,["title","name","label","email"])}`;Ee(ie).then(ee=>{u(G=>{let ye=new Set(G.map(L=>L.id)),De=(ee.docs||[]).filter(L=>!ye.has(L.id)).map(L=>({...L,id:L.id}));return [...G,...De]}),v(false);}).catch(()=>{v(false);});},[T]);Ta.useEffect(()=>{s&&(u([]),D(l));},[s,T]),Ta.useEffect(()=>{let E=oe=>{b.current&&!b.current.contains(oe.target)&&i(false);};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);let U=E=>typeof E=="object"&&E!==null?E.value||E.id||"":String(E),O=E=>{let oe=E.id;return t?h&&Array.isArray(t)?t.some(ie=>U(ie)===oe):U(t)===oe:false},z=E=>{let oe=E.id;if(h){let ie=Array.isArray(t)?t:[];if(O(E))p.current?.(ie.filter(ee=>U(ee)!==oe));else {let ee=$?{relationTo:T,value:oe}:oe;p.current?.([...ie,ee]);}}else if(O(E))p.current?.(null);else {let ie=$?{relationTo:T,value:oe}:oe;p.current?.(ie),i(false),d("");}},P=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),R=E=>{let{active:oe,over:ie}=E;if(!ie||oe.id===ie.id)return;let ee=h?Array.isArray(t)?t:[]:[],G=ee.findIndex(De=>U(De)===oe.id),ye=ee.findIndex(De=>U(De)===ie.id);if(G!==-1&&ye!==-1){let De=[...ee],[L]=De.splice(G,1);De.splice(ye,0,L),p.current?.(De);}},Ae=()=>{if(!t)return null;let E=h?Array.isArray(t)?t:[]:t?[t]:[],oe=E.map(ie=>U(ie));return h&&E.length>1?jsxRuntime.jsx(core.DndContext,{sensors:P,collisionDetection:core.closestCenter,onDragEnd:R,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:oe,strategy:sortable.horizontalListSortingStrategy,children:E.map(ie=>{let ee=U(ie),G=x.find(L=>L.id===ee),ye=G?ai(G):ee.slice(0,12),De=$&&G?G.relationTo:null;return jsxRuntime.jsx(Em,{id:ee,label:ye,relation:De,onRemove:()=>{let L=E.filter(W=>U(W)!==ee);p.current?.(L);},disabled:a},ee)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:E.map(ie=>{let ee=U(ie),G=x.find(L=>L.id===ee),ye=G?ai(G):ee.slice(0,12),De=$&&G?G.relationTo:null;return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[De&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[De,":"]}),ye,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let L=E.filter(W=>U(W)!==ee);p.current?.(h?L:L[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]},ee)})})};return jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[e.label&&jsxRuntime.jsxs("label",{className:"block text-sm font-medium text-[var(--kyro-text-primary)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]}),jsxRuntime.jsxs("div",{ref:b,className:"relative",children:[$&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:A.map(E=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{k(E),u([]),d("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${T===E?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:E},E))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:E=>{d(E.target.value),i(true),D(E.target.value);},onFocus:()=>i(true),placeholder:e.admin?.placeholder||`Search ${T}...`,disabled:a||(typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly),className:"w-full pl-9 pr-10 py-2 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent disabled:opacity-50"}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:m?jsxRuntime.jsx(Ql.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(Ql.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${s?"rotate-180":""}`})})]}),s&&jsxRuntime.jsx("div",{className:"relative z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-64 overflow-auto",children:m?jsxRuntime.jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):c.length===0?jsxRuntime.jsx(Xn,{title:n("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsxRuntime.jsx("div",{className:"py-1",children:c.map(E=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>z(E),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${O(E)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:ai(E)}),O(E)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in E&&typeof E.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:E.slug})]},E.id))})}),Ae()]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-muted)]",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-error)]",children:o})]})}var Oa=Mm;var Co=Ta.createContext(null);function Cd(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=ni(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=ta(a),{blocks:i}=o(),l=[...i];n!==void 0?l.splice(n,0,s):l.push(s),r({blocks:l});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:s}=o(),i=za(s,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=[...l];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:l,found:false}});if(i!==s){r({blocks:i});let{onBlocksChange:l}=o();l&&l();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),s=za(n,i=>{let l=i.filter(d=>d.id!==a);return l.length!==i.length?{newList:l,found:true}:{newList:i,found:false}});if(s!==n){r({blocks:s});let{onBlocksChange:i}=o();i&&i();}},moveBlock:(a,n)=>{let{blocks:s}=o(),i=za(s,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<l.length){let u=[...l];return [u[d],u[c]]=[u[c],u[d]],{newList:u,found:true}}}return {newList:l,found:false}});if(i!==s){r({blocks:i});let{onBlocksChange:l}=o();l&&l();}}}))}function ni(e){return Array.isArray(e)?e.map(t=>{let r={...t,id:t.id||Math.random().toString(36).substr(2,9)};return r.children&&Array.isArray(r.children)&&(r.children=ni(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?ni(o.children):o.children}))}),r}):[]}function ta(e){let t=Om(e),{options:r,children:o,...a}=t;return {id:Math.random().toString(36).substr(2,9),type:e,name:"",data:a,options:r,children:o,order:Date.now()}}function Om(e){return {heading:{level:1,text:""},"heading-subheading":{title:"",subtitle:""},hero:{isMultiScreen:false},card:{title:"",description:"",icon:"",link:"",linkText:"",isMultiCard:false},paragraph:{text:""},divider:{},callout:{text:"",variant:"info"},image:{src:"",alt:"",caption:""},video:{src:"",title:""},list:{type:"unordered",items:""},code:{language:"plaintext",code:""},link:{url:"",text:""},table:{rows:3,columns:3,content:""},quote:{text:"",author:""},file:{filename:"",url:""},columns:{columns:2,direction:"horizontal"},vstack:{direction:"vertical",gap:"md"},container:{options:{backgroundColor:"transparent",padding:"md",width:"full",margin:"none",minHeight:"none",borderRadius:"none"},children:[]},button:{text:"Button",url:"",variant:"primary",size:"md"},accordion:{title:"Accordion Item",content:""},gallery:{images:[]},tabs:{tabs:[{label:"Tab 1",content:""}]}}[e]||{}}function Ke(e){let t=Ta.useContext(Co);if(t)return zustand.useStore(t,r=>{let o=a=>{for(let n of a){if(n.id===e)return n;if(n.children&&n.children.length>0){let s=o(n.children);if(s)return s}if(n.data?.columnData){for(let s of n.data.columnData)if(s&&s.children&&s.children.length>0){let i=o(s.children);if(i)return i}}}};return o(r.blocks)})}function ze(){let e=Ta.useContext(Co);if(!e)throw new Error("useBlockActions must be used within a BlocksContext.Provider");return {updateBlock:(t,r)=>e.getState().updateBlock(t,r),removeBlock:t=>e.getState().removeBlock(t),moveBlock:(t,r)=>e.getState().moveBlock(t,r)}}function za(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(s=>{let i={...s},l=false;if(s.children&&s.children.length>0){let d=za(s.children,t);d!==s.children&&(i.children=d,l=true);}if(s.data?.columnData&&Array.isArray(s.data.columnData)){let d=s.data.columnData.map(c=>{if(c.children&&c.children.length>0){let u=za(c.children,t);if(u!==c.children)return {...c,children:u}}return c});d.some((c,u)=>c!==s.data.columnData[u])&&(i.data={...i.data,columnData:d},l=true);}return l&&(a=true),l?i:s});return a?n:e}function ja({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let{t:n}=reactI18next.useTranslation(),[s,i]=Ta__default.default.useState(null),l=async()=>{try{i(null);let d=await navigator.clipboard.readText(),c=JSON.parse(d);c.__kyro_block?o&&o(c):i("Clipboard does not contain a valid Kyro block.");}catch(d){i("Failed to read block from clipboard."),console.error(d);}};return e?jsxRuntime.jsxs(yr,{open:e,onClose:t,title:n("tooltips.insertBlock",{defaultValue:"Insert Block"}),width:"md",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)] mb-4",children:"Drag blocks into the editor or click to insert"}),o&&jsxRuntime.jsxs("div",{className:"mb-6 pb-6 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 py-2 px-4 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] text-sm font-semibold transition-all hover:bg-[var(--kyro-primary)]/5",children:[jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-4 h-4"}),"Paste Block from Clipboard"]}),s&&jsxRuntime.jsx("p",{className:"text-xs text-red-500 mt-2 text-center font-medium",children:s})]}),a]}):null}function Sd({block:e,onSelect:t,children:r}){let{attributes:o,listeners:a,setNodeRef:n,isDragging:s}=core.useDraggable({id:`drawer-${e.type}`,data:{source:"drawer",blockType:e.type}});return jsxRuntime.jsxs("div",{ref:n,...a,...o,onClick:()=>t(e.type),className:`flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group ${s?"opacity-50 border-[var(--kyro-primary)]":""}`,style:{opacity:s?.5:1},children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:r||jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)] leading-tight",children:e.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 leading-tight",children:e.description})]})]})}var si=({text:e="",onChange:t,compact:r=false})=>{let{t:o}=reactI18next.useTranslation();return jsxRuntime.jsx("div",{className:r?"":"space-y-3",children:jsxRuntime.jsx("input",{type:"text",value:e,onChange:n=>t("text",n.target.value),className:r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.enterHeadingText",{defaultValue:"Enter heading text..."})})})};var Ao=({id:e,type:t,label:r,children:o,className:a=""})=>{let{t:n}=reactI18next.useTranslation(),{moveBlock:s,removeBlock:i}=ze();return jsxRuntime.jsxs("div",{className:`block-${t} border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group bg-[var(--kyro-surface)] transition-all hover:border-[var(--kyro-primary)]/30 ${a}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] tracking-wider",children:r||t}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:n("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var Td=({block:e,index:t})=>{let r=Ke(e.id),{updateBlock:o}=ze(),a=r?.data||e.data||{},n=(s,i)=>{o(e.id,{data:{...a,[s]:i}});};return jsxRuntime.jsx(Ao,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx(si,{text:a.text||"",onChange:n,compact:true})})};var Fd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a}=ze(),n=o?.data||e.data||{},s=(i,l)=>{a(e.id,{data:{...n,[i]:l}});};return jsxRuntime.jsx(Ao,{id:e.id,type:"paragraph",label:"Paragraph",children:jsxRuntime.jsx("textarea",{value:n.text||"",onChange:i=>s("text",i.target.value),className:"w-full px-3 py-3 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm min-h-[100px] resize-none",placeholder:r("fields.enterParagraphText",{defaultValue:"Enter paragraph text..."})})})};var Rd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsxRuntime.jsx(mr,{field:{label:"Image Asset",name:"src",maxCount:1},value:i.src,onChange:d=>l("src",d)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Alt Text"}),jsxRuntime.jsx("input",{type:"text",value:i.alt||"",onChange:d=>l("alt",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.alternativeText",{defaultValue:"Alternative text..."})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Caption"}),jsxRuntime.jsx("input",{type:"text",value:i.caption||"",onChange:d=>l("caption",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.imageCaption",{defaultValue:"Image caption..."})})]})]})]})};var li=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{let {t:n}=reactI18next.useTranslation();e.includes("youtube.com")||e.includes("vimeo.com")||e.includes("youtu.be");return a?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"url",value:e,onChange:i=>r("src",i.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:i=>r("title",i.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(mr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(i=>r("src",i))}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsxRuntime.jsx("input",{type:"url",value:e,onChange:i=>r("src",i.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:i=>r("title",i.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]})};var Bd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(li,{src:i.src||"",title:i.title||"",onChange:l,onUploadChange:d=>l("src",d),compact:true})]})};function sy({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:i,isDragging:l}=sortable.useSortable({id:e}),d={transform:utilities.CSS.Transform.toString(s),transition:i,zIndex:l?10:1,opacity:l?.8:1};return jsxRuntime.jsxs("div",{ref:n,style:d,className:`flex items-center gap-2 group/item p-1.5 hover:bg-[var(--kyro-surface-accent)]/50 rounded-md transition-colors ${l?"bg-[var(--kyro-surface-accent)] shadow-sm":""}`,children:[jsxRuntime.jsx("div",{...o,...a,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",onClick:c=>c.stopPropagation(),children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:"opacity-0 group-hover/item:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",children:"\xD7"})]})}var Ha=({items:e=[],onChange:t,compact:r=false})=>{let{t:o}=reactI18next.useTranslation(),[a,n]=Ta__default.default.useState(""),[s,i]=Ta__default.default.useState([]);Ta__default.default.useEffect(()=>{let x=s.map(g=>g.text);JSON.stringify(x)!==JSON.stringify(e)&&i(e.map((g,f)=>({id:`${g}-${f}-${Math.random().toString(36).substr(2,4)}`,text:g})));},[e]);let l=()=>{a.trim()&&(t([...e,a.trim()]),n(""));},d=x=>{x.key==="Enter"&&(x.preventDefault(),l());},c=x=>{t(e.filter((g,f)=>f!==x));},u=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),m=x=>{let{active:g,over:f}=x;if(!f||g.id===f.id)return;let b=s.findIndex(h=>h.id===g.id),p=s.findIndex(h=>h.id===f.id);if(b!==-1&&p!==-1){let h=[...e],[A]=h.splice(b,1);h.splice(p,0,A),t(h);}},v=r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxRuntime.jsx(core.DndContext,{sensors:u,collisionDetection:core.closestCenter,onDragEnd:m,children:jsxRuntime.jsxs("div",{className:r?"space-y-1.5":"space-y-2",children:[e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:"No items. Type below to add."}):jsxRuntime.jsx(sortable.SortableContext,{items:s.map(x=>x.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:s.map((x,g)=>jsxRuntime.jsx(sy,{id:x.id,text:x.text,onRemove:()=>c(g)},x.id))})}),jsxRuntime.jsx("input",{type:"text",value:a,onChange:x=>n(x.target.value),onKeyDown:d,className:v,placeholder:o("fields.typeAndPressEnter",{defaultValue:"Type and press Enter to add..."})})]})})};var Ed=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=Array.isArray(i.items)?i.items:[],d=c=>{a(e.id,{data:{...i,items:c}});};return jsxRuntime.jsxs("div",{className:"block-list border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"List"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ha,{items:l,onChange:d,compact:true})]})};var Md=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"group/block relative border border-[var(--kyro-border)] rounded-2xl p-6 mb-6 transition-all duration-300 bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/20",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-9 h-9 rounded-xl bg-[var(--kyro-primary)]/10 flex items-center justify-center text-[var(--kyro-primary)] transition-transform group-hover/block:scale-110",children:jsxRuntime.jsx(Ql.CodeXml,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxRuntime.jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",i.language||"javascript"]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-1.5 opacity-0 group-hover/block:opacity-100 transition-all translate-x-2 group-hover/block:translate-x-0",children:jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)]/50 p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1.5 hover:bg-[var(--kyro-surface)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsxRuntime.jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(La,{field:{type:"code",name:"code",label:"Source Code",language:i.language||"javascript"},value:i.code||"",onChange:d=>l("code",d)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 bg-[var(--kyro-surface-accent)]/20 p-4 rounded-xl border border-[var(--kyro-border)]/50",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2 block",children:"Syntax Highlighting"}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("select",{value:i.language||"javascript",onChange:d=>l("language",d.target.value),className:"w-full pl-4 pr-10 py-2.5 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl text-xs font-medium text-[var(--kyro-text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)]/20 focus:border-[var(--kyro-primary)] transition-all appearance-none cursor-pointer",children:[jsxRuntime.jsx("option",{value:"plaintext",children:"Plain Text"}),jsxRuntime.jsx("option",{value:"javascript",children:"JavaScript"}),jsxRuntime.jsx("option",{value:"typescript",children:"TypeScript"}),jsxRuntime.jsx("option",{value:"python",children:"Python"}),jsxRuntime.jsx("option",{value:"json",children:"JSON"}),jsxRuntime.jsx("option",{value:"html",children:"HTML"}),jsxRuntime.jsx("option",{value:"css",children:"CSS"}),jsxRuntime.jsx("option",{value:"sql",children:"SQL"}),jsxRuntime.jsx("option",{value:"rust",children:"Rust"}),jsxRuntime.jsx("option",{value:"markdown",children:"Markdown"})]}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsxRuntime.jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var Ld=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(mr,{field:{label:"File",name:"file",maxCount:1},value:i.file,onChange:d=>l("file",d)})]})};var yi=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ta.useState(0),n=jsxRuntime.jsx("div",{className:"flex justify-end gap-1 mb-2"}),s=(m,v)=>{let x=[...e];x[m]={...x[m],title:v},t(x);},i=(m,v)=>{let x=[...e];x[m]={...x[m],content:v},t(x);},l=m=>{let v=e.filter((x,g)=>g!==m);t(v),o===m?a(null):o!==null&&o>m&&a(o-1);},d=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},c="w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",u="w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return r?jsxRuntime.jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-1.5",children:e.map((m,v)=>{let{t:x}=reactI18next.useTranslation(),g=o===v;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:v),className:"w-full flex items-center justify-between p-2.5 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:m.title||`Item ${v+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),l(v);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:x("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5"})}),g?jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:f=>s(v,f.target.value),onClick:f=>f.stopPropagation(),className:u,placeholder:x("fields.itemTitle",{defaultValue:"Item title..."})}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:f=>i(v,f.target.value),onClick:f=>f.stopPropagation(),className:`${u} min-h-[60px] resize-none`,placeholder:x("fields.itemContent",{defaultValue:"Item content..."})})]})]},v)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsxRuntime.jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((m,v)=>{let{t:x}=reactI18next.useTranslation(),g=o===v;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:v),className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:m.title||`Item ${v+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),l(v);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:x("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})}),g?jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:f=>s(v,f.target.value),className:c,placeholder:x("fields.itemTitle",{defaultValue:"Item title..."})}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:f=>i(v,f.target.value),className:`${c} min-h-[60px] resize-none`,placeholder:x("fields.itemContent",{defaultValue:"Item content..."})})]})]},v)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var Vd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=Array.isArray(i.items)?i.items:[],d=c=>{a(e.id,{data:{...i,items:c}});};return jsxRuntime.jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(yi,{items:l,onChange:d,compact:true})]})};var Od=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data||e.data||{},l=d=>{a(e.id,{data:{...i,content:d}});};return jsxRuntime.jsxs("div",{className:"block-richtext border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Ql.AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Wo,{field:{name:"content",label:"Content",type:"richtext"},value:i.content,onChange:l})]})};var fi=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let{t:s}=reactI18next.useTranslation(),i=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",l=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return n?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${i} font-bold text-base`,placeholder:s("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:s("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.ctaText",{defaultValue:"CTA text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${i} font-bold text-base`,placeholder:s("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:s("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.ctaText",{defaultValue:"CTA text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};function Zn({field:e,value:t,onChange:r,renderField:o}){let a=t||{};return jsxRuntime.jsxs("div",{className:"kyro-form-group border border-[var(--kyro-border)] rounded-[var(--kyro-radius-lg)] p-6 bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-6 border-b border-[var(--kyro-border)] pb-2",children:jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)]",children:e.label||e.name})}),jsxRuntime.jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields.map(n=>o(n,a,r))})]})}var Ny=new Set(["text","number","checkbox","select","radio","color","email","password"]);function Cy(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>Ny.has(r.type))}function jd({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:i,onRemove:l,disabled:d,compact:c,getItemLabel:u}){let{t:m}=reactI18next.useTranslation(),{attributes:v,listeners:x,setNodeRef:g,transform:f,transition:b,isDragging:p}=sortable.useSortable({id:e}),h={transform:utilities.CSS.Transform.toString(f),transition:b,zIndex:p?10:1,opacity:p?.8:1};return c?jsxRuntime.jsxs("div",{ref:g,style:h,className:`flex items-start gap-2 px-3 py-1.5 border-b border-[var(--kyro-border)] last:border-b-0 hover:bg-[var(--kyro-sidebar-active)]/5 transition-colors ${p?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...v,...x,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 mt-1",children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsxRuntime.jsx("div",{className:`flex-1 min-w-0 ${(n.fields||[]).length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:(n.fields||[]).map(A=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(A,a,i)},A.name))}),jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:l,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-0.5 mt-1.5 flex-shrink-0",title:m("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsxRuntime.jsxs("div",{ref:g,style:h,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${p?"border-[var(--kyro-primary)] shadow-md":""}`,children:[jsxRuntime.jsxs("div",{className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[jsxRuntime.jsx("div",{...v,...x,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),o(r?null:t));},className:"text-xs font-bold tracking-widest text-[var(--kyro-text-muted)] truncate cursor-pointer flex-1 py-1 text-left",children:u(a)||`Item ${t+1}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:A=>{A.stopPropagation(),l();},className:"text-[11px] font-bold text-[var(--kyro-error)] opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-30 hover:bg-[var(--kyro-danger-bg)] rounded px-1.5 py-0.5",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(r?null:t),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",children:r?jsxRuntime.jsx(Ql.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsxRuntime.jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:(n.fields||[]).map(A=>s(A,a,i))})]})}function es({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=e.fields||[],i=s[0],l=i?.name||"user",d=i?.type==="relationship",[c,u]=Ta__default.default.useState(0);Ta__default.default.useEffect(()=>{let b=false,p=n.filter(h=>typeof h!="object"||h===null?(b=true,false):true).map(h=>!h.id&&!h._key?(b=true,{...h,id:Math.random().toString(36).substr(2,9)}):h);b&&r(p);},[t,r]);function m(b){for(let p of ["label","title","name"]){let h=b[p];if(h&&typeof h=="string")return h}for(let p of s){if(p.type==="text"||p.type==="textarea"){let h=b[p.name];if(h&&typeof h=="string")return h}if(p.type==="group"&&p.fields){for(let h of p.fields)if(h.type==="text"||h.type==="textarea"){let $=b[p.name]?.[h.name];if($&&typeof $=="string")return $}}}return ""}let v=Cy(e),x=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),g=b=>{let{active:p,over:h}=b;if(!h||p.id===h.id)return;let A=n.findIndex(T=>(T.id||T._key)===p.id),$=n.findIndex(T=>(T.id||T._key)===h.id);if(A!==-1&&$!==-1){let T=[...n],[k]=T.splice(A,1);T.splice($,0,k),r(T);}},f=Ta__default.default.useMemo(()=>n.map(b=>b?.id||b?._key||""),[n]);return d?jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(Oa,{field:{name:l,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(b=>b[l]).filter(Boolean),onChange:b=>{let p=(b||[]).map(h=>({[l]:h,id:Math.random().toString(36).substr(2,9)}));r(p);},disabled:a})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(core.DndContext,{sensors:x,collisionDetection:core.closestCenter,onDragEnd:g,children:v?jsxRuntime.jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md overflow-hidden",children:[jsxRuntime.jsx(sortable.SortableContext,{items:f,strategy:sortable.verticalListSortingStrategy,children:n.map((b,p)=>jsxRuntime.jsx(jd,{id:b.id||b._key||`idx-${p}`,index:p,isOpen:false,setOpenIndex:()=>{},item:b,field:e,renderField:o,onChangeItem:h=>{let A=[...n];A[p]=h,r(A);},onRemove:()=>r(n.filter((h,A)=>A!==p)),disabled:a,compact:true,getItemLabel:m},b.id||b._key||p))}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-2 border-2 border-dashed border-[var(--kyro-border)] rounded-none text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>r([...n,{id:Math.random().toString(36).substr(2,9)}]),children:"+ Add Item"})]}):jsxRuntime.jsxs("div",{className:"kyro-form-array border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md p-3 space-y-4",children:[jsxRuntime.jsx(sortable.SortableContext,{items:f,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((b,p)=>{let h=c===p;return jsxRuntime.jsx(jd,{id:b.id||b._key||`idx-${p}`,index:p,isOpen:h,setOpenIndex:u,item:b,field:e,renderField:o,onChangeItem:A=>{let $=[...n];$[p]=A,r($);},onRemove:()=>r(n.filter((A,$)=>$!==p)),disabled:a,compact:false,getItemLabel:m},b.id||b._key||p)})})}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-3 border-2 border-dashed border-[var(--kyro-border)] rounded-lg text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>{let b=Math.random().toString(36).substr(2,9);r([...n,{id:b}]),u(n.length);},children:"+ Add Item"})]})})]})}var Hd="other";function _d(){return Hd}function ts(e){Hd=e;}var To=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{ts("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(Qo,{field:e,value:t,onChange:d,error:o,disabled:a});case "icon":return jsxRuntime.jsx(Ln,{field:e,value:t,onChange:d,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(Qo,{field:{...e,variant:"textarea"},value:t,onChange:d,error:o,disabled:a});case "password":return jsxRuntime.jsx(Qo,{field:{...e,variant:"password"},value:t,onChange:d,error:o,disabled:a});case "secret":return jsxRuntime.jsx(zn,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Hn,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(_n,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx(Jn,{field:e,value:t,onChange:d,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:i,globalSlug:l});case "date":return jsxRuntime.jsx(Kn,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(Wo,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(Gs,{field:e,value:t,onChange:d,disabled:a,error:o});case "code":return jsxRuntime.jsx(La,{field:e,value:t,onChange:d,disabled:a,error:o});case "image":case "upload":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx(mr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx(Oa,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsx(Ha,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(es,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,u,m)=>{let v=u[c.name];return jsxRuntime.jsx(To,{field:c,value:v,onChange:x=>{m({...u,[c.name]:x});},disabled:a,error:o},c.name)}});case "blocks":return jsxRuntime.jsx(bi,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsxRuntime.jsx(Zn,{field:e,value:t,onChange:r,renderField:(c,u,m)=>{let v=u[c.name];return jsxRuntime.jsx(To,{field:c,value:v,onChange:x=>{m({...u,[c.name]:x});},disabled:a,error:o,collectionSlug:i,globalSlug:l},c.name)}});case "color":return jsxRuntime.jsx(ct,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("input",{type:"color",value:t||"#000000",onChange:c=>r(c.target.value),disabled:a,className:"h-10 w-14 p-1 cursor-pointer bg-[var(--kyro-input-bg)] border border-[var(--kyro-input-border)] rounded-lg"}),jsxRuntime.jsx("input",{type:"text",className:"kyro-form-input font-mono ",value:t||"",onChange:c=>r(c.target.value),disabled:a,placeholder:"#000000"})]})});default:return jsxRuntime.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg text-amber-800 text-xs italic",children:['Field type "',e.type,'" is not yet supported in this renderer.']})}};var aa=({block:e,blockSchema:t,onClose:r})=>{let o=Ke(e.id),{updateBlock:a}=ze(),n=o?.data||e.data||{},s=o?.children||e.children||[],i=(u,m)=>{a(e.id,{data:{...n,[u]:m}});},l=u=>{a(e.id,{children:u});},d=()=>t&&Array.isArray(t.fields)?jsxRuntime.jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(u=>{if(u.admin?.condition){if(typeof u.admin.condition=="function")try{let v={values:n,...n};if(!u.admin.condition(v,v))return null}catch(v){console.warn(`Condition error for field ${u.name}:`,v);}else if(typeof u.admin.condition=="object")try{let v=u.admin.condition,x=v.field,g=n[x],f=!0;if("equals"in v?f=g===v.equals:"notEquals"in v?f=g!==v.notEquals:"in"in v&&Array.isArray(v.in)&&(f=v.in.includes(g)),!f)return null}catch(v){console.warn(`Declarative condition error for field ${u.name}:`,v);}}let m=n[u.name];return jsxRuntime.jsx("div",{className:"kyro-block-field-row border-b border-[var(--kyro-border)]/30 pb-3 last:border-b-0 last:pb-0",children:jsxRuntime.jsx(To,{field:u,value:m,onChange:v=>i(u.name,v)})},u.name)})}):jsxRuntime.jsxs("div",{className:"text-center py-8 text-[var(--kyro-text-muted)] text-sm italic",children:['No schema defined for block type "',e.type,'"']}),c=Ve[e.type]||Ve.default;return jsxRuntime.jsxs(yr,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:c.border,children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[d(),s.length>0&&jsxRuntime.jsxs("div",{className:"pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",s.length,")"]}),jsxRuntime.jsx(to,{blockId:e.id,children:s,onUpdateChildren:l})]})]}),jsxRuntime.jsx("div",{className:"mt-6 pt-4 border-t border-[var(--kyro-border)]",children:jsxRuntime.jsx("button",{type:"button",onClick:r,className:"w-full py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-lg font-medium hover:opacity-90 transition-opacity",children:"Done"})})]})};var Sy=6,to=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Sy})=>{let[n,s]=Ta.useState(false),[i,l]=Ta.useState(new Set),[d,c]=Ta.useState(null),[u,m]=Ta.useState(null),v=Ta.useContext(Co);if(!v)throw new Error("ChildBlocksTree must be used within a BlocksContext");let x=zustand.useStore(v,y=>y.dynamicCategories),g=zustand.useStore(v,y=>y.allowedBlocks),f=o<a,b=16,p=y=>{let w=ta(y);r([...t,w]),c(w.id);},h=y=>{let w=t.filter(D=>D.id!==y);r(w);},$=(y,w)=>{let D=t.map(U=>U.id===y?{...U,children:w}:U);r(D);},T=y=>{l(w=>{let D=new Set(w);return D.has(y)?D.delete(y):D.add(y),D});},k=y=>{let w=y.children&&y.children.length>0,D=i.has(y.id);xi(y.type);let O=w,z=d===y.id,P=g.find(R=>R.slug===y.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${z?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${f?"cursor-pointer":""}`,style:{marginLeft:o*b},onClick:()=>{f&&c(z?null:y.id);},children:[O?jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(y.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:D?jsxRuntime.jsx(Ql.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Gt[y.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Gt[y.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[Ga(y),y.data?.text?` - ${y.data.text.slice(0,30)}`:"",y.data?.heading?` - ${y.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),w&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[y.children.length," nested"]}),u===y.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(y.id),m(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),m(y.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),z&&jsxRuntime.jsx(aa,{block:y,onClose:()=>c(null)}),w&&D&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Wd,{parentId:y.id,children:y.children,onUpdateChildren:R=>$(y.id,R),depth:o+1,maxDepth:a})})]},y.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),f&&jsxRuntime.jsxs("div",{style:{marginLeft:o*b},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(ja,{open:n,onClose:()=>s(false),onSelect:p,children:x.map(y=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:y.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.blocks.map(w=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{p(w.slug),s(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Gt[w.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:w.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:w.admin?.description||""})]})]},w.slug))})]},y.title))})]}),t.length===0&&f&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*b},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*b},children:["Maximum nesting level (",a,") reached"]})]})},Wd=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=Ta.useState(false),[i,l]=Ta.useState(new Set),[d,c]=Ta.useState(null),[u,m]=Ta.useState(null),v=Ta.useContext(Co);if(!v)throw new Error("NestedChildBlocks must be used within a BlocksContext");let x=zustand.useStore(v,y=>y.dynamicCategories),g=zustand.useStore(v,y=>y.allowedBlocks),f=o<a,b=16,p=y=>{let w=ta(y);r([...t,w]),c(w.id);},h=y=>{let w=t.filter(D=>D.id!==y);r(w);},$=(y,w)=>{let D=t.map(U=>U.id===y?{...U,children:w}:U);r(D);},T=y=>{l(w=>{let D=new Set(w);return D.has(y)?D.delete(y):D.add(y),D});},k=y=>{let w=y.children&&y.children.length>0,D=i.has(y.id);xi(y.type);let O=w,z=d===y.id,P=g.find(R=>R.slug===y.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${z?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${f?"cursor-pointer":""}`,style:{marginLeft:o*b},onClick:()=>{f&&c(z?null:y.id);},children:[O?jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(y.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:D?jsxRuntime.jsx(Ql.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Gt[y.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Gt[y.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[Ga(y),y.data?.text?` - ${y.data.text.slice(0,30)}`:"",y.data?.heading?` - ${y.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),w&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[y.children.length," nested"]}),u===y.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(y.id),m(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>m(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),m(y.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),z&&jsxRuntime.jsx(aa,{block:y,onClose:()=>c(null)}),w&&D&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Wd,{parentId:y.id,children:y.children,onUpdateChildren:R=>$(y.id,R),depth:o+1,maxDepth:a})})]},y.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),f&&jsxRuntime.jsxs("div",{style:{marginLeft:o*b},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(ja,{open:n,onClose:()=>s(false),onSelect:p,children:x.map(y=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:y.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.blocks.map(w=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{p(w.slug),s(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Gt[w.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:w.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:w.admin?.description||""})]})]},w.slug))})]},y.title))})]}),t.length===0&&f&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*b},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*b},children:["Maximum nesting level (",a,") reached"]})]})};var qd=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=o?.children??e.children??[],d=(c,u)=>{a(e.id,{data:{...i,[c]:u}});};return jsxRuntime.jsxs("div",{className:"block-hero border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Hero Section"})}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(fi,{heading:i.title||"",subheading:i.subtitle||"",ctaText:i.ctaText||"",ctaUrl:i.ctaUrl||"",onChange:d,compact:true}),jsxRuntime.jsx(mr,{field:{label:"Background",name:"bgImage",maxCount:1},value:i.bgImage,onChange:c=>d("bgImage",c)}),jsxRuntime.jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsxRuntime.jsx(to,{blockId:e.id,children:l,onUpdateChildren:c=>a(e.id,{children:c})})]})]})]})};var ki=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:s=false})=>{let{t:i}=reactI18next.useTranslation(),l=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",d=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:c=>n("title",c.target.value),className:`${l} font-bold text-base`,placeholder:i("fields.cardTitle",{defaultValue:"Card title..."})}),jsxRuntime.jsx("textarea",{value:t,onChange:c=>n("description",c.target.value),className:d,placeholder:i("fields.cardDescription",{defaultValue:"Card description..."})}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:c=>n("icon",c.target.value),className:l,placeholder:i("fields.iconEmojiOrName",{defaultValue:"Icon (emoji or name)..."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:c=>n("linkText",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:i("fields.linkText",{defaultValue:"Link text..."})}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:c=>n("link",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var Yd=({block:e,index:t})=>{let r=Ke(e.id),{updateBlock:o}=ze(),a=r?.data||e.data||{},n=(s,i)=>{o(e.id,{data:{...a,[s]:i}});};return jsxRuntime.jsx(Ao,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(ki,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Qd=({block:e,index:t})=>{let {t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze();o?.data??e.data??{};let l=o?.children??e.children??[];return jsxRuntime.jsxs("div",{className:"block-array border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Repeater"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(to,{blockId:e.id,children:l,onUpdateChildren:d=>a(e.id,{children:d})})})]})};var qa=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let{t:i}=reactI18next.useTranslation(),[l,d]=Ta.useState(false),[c,u]=Ta.useState(""),[m,v]=Ta.useState([]),[x,g]=Ta.useState(false),[f,b]=Ta.useState([]),[p,h]=Ta.useState(true);Ta.useEffect(()=>{Ee("/api/collections").then(O=>{b((O.collections||[]).map(z=>z.slug||z.name||z)),h(false);}).catch(()=>h(false));},[]);let A=(O="")=>{g(true);let z=`/api/${e}?${nn(O,[a],20)}`;Ee(z).then(P=>{v(P.docs||[]),g(false);}).catch(()=>g(false));};Ta.useEffect(()=>{l&&A(c);},[l,c,e,a]);let $=O=>O?.[a]||O?.title||O?.name||O?.label||O?.filename||O?.slug||O?.id||"Untitled",T=t?r:o?[o]:[],k=O=>{t?T.includes(O.id)?n("selectedIds",T.filter(z=>z!==O.id)):n("selectedIds",[...T,O.id]):(n("selectedId",O.id),n("selectedIds",[O.id]),d(false));},y=O=>T.includes(O),w=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",D=s?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",U=e&&typeof e=="string"&&e.length>0;return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-4",children:[jsxRuntime.jsxs("div",{className:s?"flex items-center gap-2":"space-y-3",children:[!U&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:p?jsxRuntime.jsx("div",{className:D+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:O=>n("relationTo",O.target.value),className:D,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),f.map(O=>jsxRuntime.jsx("option",{value:O,children:O},O))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:O=>n("hasMany",O.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsxRuntime.jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:c,onChange:O=>{u(O.target.value),d(true);},onFocus:()=>d(true),onBlur:()=>setTimeout(()=>d(false),200),placeholder:`Search ${e}...`,className:`${w} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:x&&jsxRuntime.jsx(Ql.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsxRuntime.jsx("div",{className:"absolute z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-48 overflow-auto",children:x?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):m.length===0?jsxRuntime.jsx(Xn,{title:i("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsxRuntime.jsx("div",{className:"py-1",children:m.map(O=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:z=>z.preventDefault(),onClick:()=>k(O),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${y(O.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:$(O)}),y(O.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},O.id))})})]}),T.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:T.map(O=>{let z=m.find(P=>P.id===O)||{id:O};return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[$(z),jsxRuntime.jsx("button",{type:"button",onMouseDown:P=>P.preventDefault(),onClick:()=>{t?n("selectedIds",T.filter(P=>P!==O)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]},O)})})]})};var ec=({block:e,index:t})=>{let{t:r}=reactI18next.useTranslation(),o=Ke(e.id),{updateBlock:a,removeBlock:n,moveBlock:s}=ze(),i=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...i,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",i.relationTo||"pages"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(qa,{relationTo:i.relationTo||"pages",hasMany:i.hasMany||false,selectedIds:Array.isArray(i.selectedIds)?i.selectedIds:[],selectedId:i.selectedId,labelField:i.labelField||"title",onChange:l,compact:true})]})};var Iy={heading:Td,paragraph:Fd,image:Rd,video:Bd,list:Ed,code:Md,file:Ld,accordion:Vd,richtext:Od,hero:qd,card:Yd,array:Qd,relationship:ec},Ve={featureSplit:{text:"text-indigo-500",border:"border-indigo-500",borderLeft:"border-l-indigo-500"},featureGrid:{text:"text-blue-500",border:"border-blue-500",borderLeft:"border-l-blue-500"},ctaBanner:{text:"text-amber-500",border:"border-amber-500",borderLeft:"border-l-amber-500"},testimonials:{text:"text-emerald-500",border:"border-emerald-500",borderLeft:"border-l-emerald-500"},faq:{text:"text-orange-500",border:"border-orange-500",borderLeft:"border-l-orange-500"},stats:{text:"text-rose-500",border:"border-rose-500",borderLeft:"border-l-rose-500"},logoCloud:{text:"text-cyan-500",border:"border-cyan-500",borderLeft:"border-l-cyan-500"},pricing:{text:"text-green-500",border:"border-green-500",borderLeft:"border-l-green-500"},team:{text:"text-violet-500",border:"border-violet-500",borderLeft:"border-l-violet-500"},recentFeed:{text:"text-sky-500",border:"border-sky-500",borderLeft:"border-l-sky-500"},processSteps:{text:"text-fuchsia-500",border:"border-fuchsia-500",borderLeft:"border-l-fuchsia-500"},formEmbed:{text:"text-pink-500",border:"border-pink-500",borderLeft:"border-l-pink-500"},videoShowcase:{text:"text-red-500",border:"border-red-500",borderLeft:"border-l-red-500"},hero:{text:"text-yellow-500",border:"border-yellow-500",borderLeft:"border-l-yellow-500"},card:{text:"text-teal-500",border:"border-teal-500",borderLeft:"border-l-teal-500"},default:{text:"text-zinc-400",border:"border-zinc-400",borderLeft:"border-l-zinc-400"}},Gt={heading:jsxRuntime.jsx(Ql.Heading1,{className:`w-4 h-4 ${Ve.default.text}`}),paragraph:jsxRuntime.jsx(Ql.AlignLeft,{className:`w-4 h-4 ${Ve.default.text}`}),image:jsxRuntime.jsx(Ql.Image,{className:`w-4 h-4 ${Ve.default.text}`}),video:jsxRuntime.jsx(Ql.Video,{className:`w-4 h-4 ${Ve.default.text}`}),list:jsxRuntime.jsx(Ql.List,{className:`w-4 h-4 ${Ve.default.text}`}),code:jsxRuntime.jsx(Ql.Code,{className:`w-4 h-4 ${Ve.default.text}`}),file:jsxRuntime.jsx(Ql.File,{className:`w-4 h-4 ${Ve.default.text}`}),accordion:jsxRuntime.jsx(Ql.ChevronDown,{className:`w-4 h-4 ${Ve.default.text}`}),richtext:jsxRuntime.jsx(Ql.AlignLeft,{className:`w-4 h-4 ${Ve.default.text}`}),hero:jsxRuntime.jsx(Ql.Star,{className:`w-4 h-4 ${Ve.hero.text}`}),card:jsxRuntime.jsx(Ql.Box,{className:`w-4 h-4 ${Ve.card.text}`}),array:jsxRuntime.jsx(Ql.ListOrdered,{className:`w-4 h-4 ${Ve.default.text}`}),relationship:jsxRuntime.jsx(Ql.Link2,{className:`w-4 h-4 ${Ve.default.text}`}),featureSplit:jsxRuntime.jsx(Ql.Columns3,{className:`w-4 h-4 ${Ve.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(Ql.Blocks,{className:`w-4 h-4 ${Ve.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(Ql.Sparkles,{className:`w-4 h-4 ${Ve.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(Ql.Users,{className:`w-4 h-4 ${Ve.testimonials.text}`}),faq:jsxRuntime.jsx(Ql.CircleHelp,{className:`w-4 h-4 ${Ve.faq.text}`}),stats:jsxRuntime.jsx(Ql.Activity,{className:`w-4 h-4 ${Ve.stats.text}`}),logoCloud:jsxRuntime.jsx(Ql.Image,{className:`w-4 h-4 ${Ve.logoCloud.text}`}),pricing:jsxRuntime.jsx(Ql.Tag,{className:`w-4 h-4 ${Ve.pricing.text}`}),team:jsxRuntime.jsx(Ql.Users,{className:`w-4 h-4 ${Ve.team.text}`}),recentFeed:jsxRuntime.jsx(Ql.Database,{className:`w-4 h-4 ${Ve.recentFeed.text}`}),processSteps:jsxRuntime.jsx(Ql.Clock,{className:`w-4 h-4 ${Ve.processSteps.text}`}),formEmbed:jsxRuntime.jsx(Ql.Mail,{className:`w-4 h-4 ${Ve.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(Ql.Video,{className:`w-4 h-4 ${Ve.videoShowcase.text}`})};function xi(e){return Iy[e]||null}function hi(e){return {paragraph:"Paragraph",heading:"Heading",image:"Image",video:"Video",list:"List",code:"Code",file:"File",accordion:"Accordion",array:"Repeater",relationship:"Relationship",richtext:"Rich Text",hero:"Hero Section",card:"Card Block",featureSplit:"Feature Split",featureGrid:"Feature Grid",ctaBanner:"CTA Banner",testimonials:"Testimonials Stack",faq:"FAQ Section",stats:"Stats & Metrics",logoCloud:"Logo Cloud",pricing:"Pricing Grid / Plan",team:"Team Profiles Showcase",recentFeed:"Dynamic Content Feed",processSteps:"Process Timeline / Steps",formEmbed:"Lead Intake Form",videoShowcase:"Cinematic Video Showcase",headingElement:"Heading",textElement:"Text",imageElement:"Image",richtextElement:"Rich Text",buttonElement:"Button",videoElement:"Video",listElement:"List"}[e]||e}function Ga(e){let t=e.name;return t&&t.trim()?t.trim():hi(e.type)}function Wy(e,t){if(t?.fields){for(let r of t.fields)if(r.type==="text"||r.type==="textarea"){let o=e[r.name];if(o&&typeof o=="string")return o}}return e.title||e.text||e.name||e.label||""}var qy=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{t:i}=reactI18next.useTranslation(),{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:m,isDragging:v}=sortable.useSortable({id:e.id}),{removeBlock:x,updateBlock:g}=ze(),f=o===e.id,[b,p]=Ta.useState(false),[h,A]=Ta.useState(false),[$,T]=Ta.useState(e.name||""),k=Ta.useRef(null),[y,w]=Ta.useState(false);Ta.useEffect(()=>{h&&k.current&&(k.current.focus(),k.current.select());},[h]);let D=Ta.useCallback(()=>{A(false);let R=$.trim();R!==(e.name||"").trim()&&g(e.id,{name:R||""});},[$,e.name,e.id,g]),U={transform:utilities.CSS.Transform.toString(u),transition:m,zIndex:v?10:1,opacity:v?.8:1},O=Ga(e),z=e.data||{},P=Wy(z,r);return s?jsxRuntime.jsxs("div",{ref:c,style:U,className:"relative group w-full",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-2 pl-7 pr-2 py-2 w-full bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-sm ${f?`${(Ve[e.type]||Ve.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 p-0.5 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] opacity-0 group-hover:opacity-100 transition-opacity hover:bg-[var(--kyro-surface-accent)] rounded touch-none",...l,...d,onClick:R=>R.stopPropagation(),children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-2.5 h-2.5"})}),Gt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:Gt[e.type]}),h?jsxRuntime.jsx("input",{ref:k,value:$,onChange:R=>T(R.target.value),onBlur:D,onKeyDown:R=>{R.key==="Enter"&&D(),R.key==="Escape"&&(T(e.name||""),A(false));},onClick:R=>R.stopPropagation(),className:"flex-1 min-w-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-1.5 py-0.5 text-[10px] font-medium text-[var(--kyro-text-primary)] outline-none"}):jsxRuntime.jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] flex-1 min-w-0 truncate transition-colors text-left",children:O}),b?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{x(e.id),p(false);},className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(e.name||""),A(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.rename",{defaultValue:"Rename"}),children:jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.duplicateInPlace",{defaultValue:"Duplicate in place"}),children:jsxRuntime.jsx(Ql.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),p(true);},className:"p-0.5 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:i("tooltips.remove",{defaultValue:"Remove"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3 h-3"})})]})]}),f&&jsxRuntime.jsx(aa,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:c,style:U,className:"relative group mb-2",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-3 p-3 bg-[var(--kyro-bg-secondary)] rounded-lg border transition-colors cursor-pointer ${f?`${(Ve[e.type]||Ve.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 touch-none",...l,...d,onClick:R=>R.stopPropagation(),children:jsxRuntime.jsx(Ql.GripVertical,{className:"w-4 h-4"})}),Gt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:Gt[e.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[h?jsxRuntime.jsx("input",{ref:k,value:$,onChange:R=>T(R.target.value),onBlur:D,onKeyDown:R=>{R.key==="Enter"&&D(),R.key==="Escape"&&(T(e.name||""),A(false));},onClick:R=>R.stopPropagation(),placeholder:hi(e.type),className:"w-full max-w-[150px] sm:max-w-[250px] md:max-w-[400px] bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-2 py-0.5 text-xs font-semibold text-[var(--kyro-text-primary)] outline-none"}):jsxRuntime.jsxs("div",{className:"text-xs font-semibold text-[var(--kyro-text-secondary)] truncate transition-colors",children:[O,P&&typeof P=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",P.length>40?`${P.slice(0,40)}...`:P]})]}),!!r?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:r.admin.description})]}),!!e.children&&Array.isArray(e.children)&&e.children.length>0&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[e.children.length," nested"]}),b?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:R=>R.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{x(e.id),p(false);},className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(e.name||""),A(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.renameBlock",{defaultValue:"Rename Block"}),children:jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:i("tooltips.duplicateBlock",{defaultValue:"Duplicate Block"}),children:jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),p(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:i("tooltips.removeBlock",{defaultValue:"Remove Block"}),children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5"})})]})]}),f&&jsxRuntime.jsx(aa,{block:e,blockSchema:r,onClose:()=>a(null)})]})},Jy=Ta__default.default.memo(qy),bi=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:i})=>{let[l,d]=Ta.useState(false),[c,u]=Ta.useState(false),m=Ta.useRef(null),v=e.admin?.pickerMode||"drawer",x=e.blocks||[],g=x.reduce((L,W)=>{let re=W.admin?.group||"Custom Blocks";return L[re]||(L[re]=[]),L[re].push(W),L},{}),f=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],b=Object.entries(g).sort(([L],[W])=>{let re=f.indexOf(L),H=f.indexOf(W);return re!==-1&&H!==-1?re-H:re!==-1?-1:H!==-1?1:L.localeCompare(W)}).map(([L,W])=>({title:L,blocks:W})),p=Ta.useRef(null);p.current||(p.current=Cd(x,b));let h=p.current,A=zustand.useStore(h,L=>L.blocks),[$,T]=Ta.useState(null),[k,y]=Ta.useState(null),w=Ta.useRef(A.length),D=Ta.useRef(new Set(A.map(L=>L.id))),U=Ta.useRef(false);Ta.useEffect(()=>{if(U.current&&A.length>w.current){let L=A.find(W=>W.id&&!D.current.has(W.id));L&&y(L.id);}w.current=A.length,D.current=new Set(A.map(L=>L.id));},[A]),Ta.useEffect(()=>(o&&h.getState().setOnBlocksChange(o),()=>{h.getState().setOnBlocksChange(()=>{});}),[o,h]);let O=Ta.useRef(null);Ta.useEffect(()=>{let L=Array.isArray(t)?t:[],W=O.current||[];if(wo(L,W))L.length===0&&!U.current&&(U.current=true,O.current=[]);else {let re=[...L];w.current=re.length,D.current=new Set(re.map(H=>H.id)),h.getState().setBlocks(re),O.current=re,U.current=true;}},[t,e.name,h]);let z=Ta.useRef(r);z.current=r,Ta.useEffect(()=>{if(!z.current)return;let L=O.current;L&&(wo(A,L)||(O.current=[...A],z.current(A)));},[A]);let R=Ta.useCallback(L=>{h.getState().addBlock(L);},[h]),Ae=Ta.useCallback(L=>{if(!(e.blocks||[]).some(fe=>fe.slug===L.type)){alert(`The block type "${L.type}" is not allowed in this collection.`);return}let H=Math.random().toString(36).substring(2,11),Te={...L.blockProps||{},id:H,type:L.type};h.getState().setBlocks([...A,Te]),d(false);},[e.blocks,A,h]),E=Ta.useCallback(L=>{let W=A.findIndex(we=>we.id===L);if(W===-1)return;let re=A[W],H=we=>{let S=Math.random().toString(36).substr(2,9);return {...we,id:S,children:we.children?we.children.map(j=>H(j)):we.children,data:we.data?JSON.parse(JSON.stringify(we.data)):we.data}},Te=H(re),fe=[...A];fe.splice(W+1,0,Te),h.getState().setBlocks(fe);},[A,h]),oe=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),ie=L=>{T(L.active);},ee=L=>{let{active:W,over:re}=L;if(T(null),!!re){if(W.id.toString().startsWith("drawer-")){let H=W.id.toString().replace("drawer-","");if(re.id.toString().startsWith("container-")){let Te=re.id.toString().replace("container-",""),fe=A.find(we=>we.id===Te);if(fe){let we=ta(H);h.getState().updateBlock(Te,{children:[...fe.children||[],we]});}}else {let Te=A.findIndex(fe=>fe.id===re.id);Te!==-1?h.getState().addBlock(H,Te):R(H);}return}if(W.id!==re.id){let H=A.findIndex(fe=>fe.id===W.id),Te=A.findIndex(fe=>fe.id===re.id);if(H!==-1&&Te!==-1){let fe=[...A],[we]=fe.splice(H,1);fe.splice(Te,0,we),h.getState().setBlocks(fe);}}}},G=$?b.flatMap(L=>L.blocks).find(L=>`drawer-${L.type}`===$.id)||A.find(L=>L.id===$.id):null;G?"label"in G?G.label:G.type:"Block";return Ta.useEffect(()=>{if(!c)return;let L=W=>{m.current&&!m.current.contains(W.target)&&u(false);};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[c]),jsxRuntime.jsx(Co.Provider,{value:p.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",tabIndex:0,style:{outline:"none"},children:[jsxRuntime.jsxs(core.DndContext,{sensors:oe,collisionDetection:core.closestCenter,onDragStart:ie,onDragEnd:ee,children:[jsxRuntime.jsxs("div",{className:v==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:`kyro-form-label ${v==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),v==="dropdown"?jsxRuntime.jsxs("div",{ref:m,className:"relative w-full",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>u(!c),disabled:n,className:"flex w-full items-center justify-between px-3 py-2 text-sm text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)] rounded-md transition-colors disabled:opacity-50",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Select an element to add..."})]}),jsxRuntime.jsx(Ql.ChevronDown,{className:`w-4 h-4 transition-transform ${c?"rotate-180 text-[var(--kyro-primary)]":"opacity-50"}`})]}),c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full mt-1 w-full bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:b.map(L=>jsxRuntime.jsxs("div",{children:[b.length>1&&jsxRuntime.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:L.title}),L.blocks.map(W=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{R(W.slug),u(false);},className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50 transition-colors text-left",children:[jsxRuntime.jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center text-[var(--kyro-text-muted)]",children:Gt[W.slug]||jsxRuntime.jsx(Ql.Box,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"text-xs font-semibold truncate",children:W.label}),W.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:W.admin.description})]})]},W.slug))]},L.title))})]}):jsxRuntime.jsxs("button",{type:"button",onClick:()=>d(true),disabled:n,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)]/30 rounded-md transition-colors disabled:opacity-50 font-semibold",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx(ja,{open:l,onClose:()=>d(false),onSelect:R,onPasteBlock:Ae,children:jsxRuntime.jsx("div",{className:"space-y-4",children:b.map(L=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:L.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:L.blocks.map(W=>jsxRuntime.jsx(Sd,{block:{type:W.slug,label:W.label,description:W.admin?.description||"",icon:null},onSelect:R,children:jsxRuntime.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:Gt[W.slug]||jsxRuntime.jsx(Ql.Box,{className:"w-4 h-4"})})})},W.slug))})]},L.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:A.map(L=>L.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:v==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[A.map((L,W)=>{let re=e.blocks?.find(H=>H.slug===L.type);return jsxRuntime.jsx(Jy,{block:L,index:W,blockSchema:re,editingBlockId:k,setEditingBlockId:y,onDuplicate:E,compact:v==="dropdown"},L.id||W)}),A.length===0&&jsxRuntime.jsx("div",{className:v==="dropdown"?"text-xs text-[var(--kyro-text-muted)] italic py-1":"text-center py-12 text-[var(--kyro-text-muted)] border-2 border-dashed border-[var(--kyro-border)] rounded-lg",children:v==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsxRuntime.jsx(core.DragOverlay,{children:$&&G&&jsxRuntime.jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:G.label||G.type||"Block"})})]}),a&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:a})]})})};function rc(){let e=Ta.useRef([]),t=Ta.useRef(false);return {queueTask:Ta.useCallback((o,a)=>{e.current.push(o);async function n(){if(!t.current&&!(typeof a?.beforeProcess=="function"&&a.beforeProcess()===false))for(;e.current.length>0;){let s=e.current.pop();e.current=[],t.current=true;try{await s();}catch(i){console.error("Error in queued function:",i);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function oc({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:i}){let l=ge(),{confirm:d}=yt(),{formData:c,setFormData:u,setField:m,lastSavedData:v,setLastSavedData:x,setHasUnsavedChanges:g,isSlugLocked:f,loadDocument:b,setIsAutoSaving:p,setAutoSaveStatus:h,setVersions:A,setLoadingVersions:$,sidebarCollapsed:T,setSidebarCollapsed:k,getDraftCache:y,setDraftCache:w,clearDraftCache:D,resetForm:U}=l,O=!!e.versions,z=o||t?.id||a||r,P=Ta.useRef(false);!o&&z&&c&&Object.keys(c).length>0&&c.id!==z&&(P.current=true),Ta.useEffect(()=>{P.current&&(P.current=false,U());},[U]);let R=Ta.useRef(null),Ae=Ta.useRef(null),E=Ta.useRef(null),oe=Ta.useRef(typeof navigator<"u"?navigator.onLine:true),ie=Ta.useRef(0),ee=Ta.useRef(false),G=Ta.useRef(null),ye=Ta.useRef(""),De=Ta.useRef(""),{queueTask:L}=rc(),W=Ta.useCallback(J=>o?`global:${o}`:r&&J?`${r}:${J}`:null,[r,o]),re=Ta.useCallback((J,M,K)=>{w(J,{data:M,baseUpdatedAt:v.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:K?.lastSyncedAt??null});},[v.updatedAt,w]),H=Ta.useCallback(async()=>{let J=o?qe(`/api/globals/${o}/versions`):r&&c.id?qe(`/api/${r}/${c.id}/versions`):null;if(J){$(true);try{let K=await(await lt(J)).json();A(K.docs||[]);}catch(M){console.error("Failed to fetch versions:",M);}finally{$(false);}}},[c.id,r,o,$,A]),Te=Ta.useCallback(()=>{let J=ge.getState(),M=J.formData;if(ee.current||!r||!M.id||!J.hasDirtyFields())return;let K=W(M.id);K&&re(K,M);},[r,W,re]),fe=Ta.useCallback(async J=>{let M=ge.getState(),K=M.formData,le=M.lastSavedData;if(ee.current||!o&&(!r||!K.id)||!M.hasDirtyFields())return;let Fe=W(K.id);if(Fe&&re(Fe,K),!oe.current){h("offline");return}p(true),h("saving"),M.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let Oe=o?qe(`/api/globals/${o}?autosave=true`):qe(`/api/${r}/${K.id}?autosave=true`),gt=await lt(Oe,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:J?.keepalive,body:JSON.stringify({...Kt(K),baseUpdatedAt:le.updatedAt??null})});if(gt.ok)ie.current=Date.now(),M.setRetryCount(0),M.setLastSavedAt(Date.now()),E.current&&clearTimeout(E.current),Fe&&w(Fe,{data:K,baseUpdatedAt:le.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await gt.clone().json()).data?.updatedAt||new Date().toISOString()}),h("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&h("idle");},2e3);else if(gt.status===409)h("conflict");else throw new Error(`Draft auto-save failed with status ${gt.status}`)}catch(Oe){console.error("Auto-save failed:",Oe);let gt=ge.getState(),B=gt.retryCount;if(B<5){gt.setRetryCount(B+1),h("retrying");let X=Math.min(1e3*Math.pow(2,B),6e4);E.current&&clearTimeout(E.current),E.current=setTimeout(()=>we(J),X);}else h("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),p(false),ge.getState().setBackgroundProcessing(false);}},[r,W,o,re,h,w,p,O]),we=Ta.useCallback(J=>{L(()=>fe(J),{beforeProcess:()=>true,afterProcess:()=>{}});},[fe,L]),S=Ta.useCallback(async(J,M=true)=>{let K=ge.getState(),le=J||K.formData,Fe=o?qe(`/api/globals/${o}`):qe(`/api/${r}/${le.id}`),Oe=await lt(Fe,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(M)},body:JSON.stringify({...Kt(le),baseUpdatedAt:K.lastSavedData.updatedAt??null})});return Oe.status===409&&h("conflict"),Oe},[r,o,h]),j=Ta.useCallback(async(J=true)=>{let M=ge.getState(),K=M.formData,le=o?qe(`/api/globals/${o}`):qe(`/api/${r}/${K.id}`),Fe=await lt(le,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(J)},body:JSON.stringify({...Kt(K)})});if(Fe.ok){let gt=(await Fe.json()).data||K;M.loadDocument(gt,gt),h("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&h("idle");},2e3);}return Fe},[r,o,h]);Ta.useEffect(()=>{let J=()=>{k(!T);};return window.addEventListener("toggle-sidebar",J),()=>window.removeEventListener("toggle-sidebar",J)},[T,k]);let xe=Ta.useRef(null),Le=Ta.useRef(""),Be=Ta.useRef(false);Ta.useEffect(()=>{let J=o||t?.id,M=JSON.stringify(t);Be.current&&xe.current===J&&Le.current===M||(b(t||{},t||{}),Be.current=true,xe.current=J,Le.current=M);},[r,c.id,o,t,b]),Ta.useEffect(()=>{if(!r||!t?.id)return;let J=W(c.id);if(!J||G.current===J)return;let M=false;return (async()=>{if(!O)return;let le=y(J);if(le){if(JSON.stringify(le.data)===JSON.stringify(t)){D(J);return}G.current=J,d({title:"Restore draft?",message:"A newer autosaved draft was found for this document. Restore it or discard it and continue with the saved version.",confirmLabel:"Restore draft",cancelLabel:"Discard draft",onConfirm:async()=>{if(M)return;let Oe={...ge.getState().formData,...le.data};u(Oe),s?.("Recovered autosaved draft");},onCancel:async()=>{D(J);}});}})(),()=>{M=true;}},[D,r,d,W,y,t,s,u,O]);function Pe(J,M){for(let K of J){if(K.name===M&&K.admin?.autoGenerate==="title")return K;if(K.type==="tabs"&&"tabs"in K)for(let le of K.tabs){let Fe=Pe(le.fields,M);if(Fe)return Fe}if((K.type==="group"||K.type==="collapsible")&&"fields"in K){let le=Pe(K.fields,M);if(le)return le}}}Ta.useEffect(()=>{let J=e.fields;if(!Pe(J,"metaTitle"))return;let K=ho(J,c,"title"),le=K?String(K):"";le&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&m("metaTitle",le);},[c,e.fields,m]),Ta.useEffect(()=>{let J=e.fields,M=J.find(Fe=>Fe.name==="slug"&&Fe.admin?.autoGenerate);if(!M?.admin?.autoGenerate)return;let K=M.admin.autoGenerate,le=ho(J,c,K);if(f&&le){let Fe=jn(le);Fe!==c.slug&&m("slug",Fe);}},[c,f,e.fields,m]),Ta.useEffect(()=>{if(T||!o&&(!r||!c.id)||!ge.getState().hasDirtyFields()||_d()!=="keystroke")return;ts("other");let M=JSON.stringify(c);M!==ye.current&&(R.current&&clearTimeout(R.current),R.current=setTimeout(Te,1500),Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(()=>{ye.current=M,we();},8e3));},[c,T,r,o,Te,we]),Ta.useEffect(()=>{if(!o&&(!r||!c.id))return;let J=()=>{ee.current||!ge.getState().hasDirtyFields()||we({keepalive:true});},M=()=>{document.hidden&&J();},K=()=>{oe.current=true,J();},le=()=>{oe.current=false;let Fe=ge.getState();Fe.hasDirtyFields()&&Fe.setAutoSaveStatus("offline");};return window.addEventListener("blur",J),window.addEventListener("pagehide",J),window.addEventListener("online",K),window.addEventListener("offline",le),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("blur",J),window.removeEventListener("pagehide",J),window.removeEventListener("online",K),window.removeEventListener("offline",le),document.removeEventListener("visibilitychange",M);}},[r,o,c.id,we]),Ta.useEffect(()=>{let J=JSON.stringify(c);if(J===De.current)return;De.current=J;let M=document.getElementById("form-data");M&&(M.value=J),n?.(c);},[c,n]),Ta.useEffect(()=>{(o||c.id)&&H();},[c.id,o,H]);let ft=!c.id&&!o?"draft":O&&c.status||"published",qt=(!!c.id||!!o)&&ft==="draft";return {...l,fetchVersions:H,performAutoSave:we,saveDocument:S,forceSave:j,autoSaveSkipRef:ee,lastAutoSaveTimeRef:ie,documentStatus:ft,hasUnpublishedChanges:qt,versionsEnabled:O}}function Po({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=Ta.useState(false),s=Ta.useRef(null);return Ta.useEffect(()=>{let i=l=>{s.current&&!s.current.contains(l.target)&&n(false);};return a&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),jsxRuntime.jsxs("div",{className:"relative",ref:s,children:[jsxRuntime.jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&jsxRuntime.jsx("div",{className:`absolute z-[100] min-w-[200px] py-2 bg-[var(--kyro-surface)] rounded-2xl shadow-2xl border border-[var(--kyro-border)] animate-in fade-in zoom-in-95 duration-100 ${r==="right"?"right-0":"left-0"} ${o==="down"?"top-full mt-2":"bottom-full mb-2"}`,onClick:()=>n(false),children:t})]})}function Pt({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsxRuntime.jsx("div",{className:"px-1.5",children:jsxRuntime.jsxs("button",{type:"button",onClick:t,disabled:a,className:`w-full flex items-center gap-3 px-3 py-2.5 text-[11px] font-medium tracking-wide text-left transition-all rounded-xl ${o?"text-red-500 hover:bg-red-500/10":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]"} ${a?"opacity-50 cursor-not-allowed":""} ${n}`,children:[r&&jsxRuntime.jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsxRuntime.jsx("span",{className:"flex-1",children:e})]})})}function Xa(){return jsxRuntime.jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Ro({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:s="down"}){let i=e==="published"&&!r&&t!=="saving"&&t!=="error",l=n||t==="saving"||i||t==="saved",d="kyro-btn kyro-btn-sm text-[11px] font-regular tracking-widest transition-all duration-300 rounded-lg",c=()=>t==="saving"?`${d} bg-[var(--kyro-primary)]/70 border-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] cursor-wait`:t==="saved"?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:i?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:`${d} bg-[var(--kyro-primary)] border-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] hover:bg-[var(--kyro-primary-hover)]`,u="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",m=()=>t==="saving"?`${u} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:t==="error"?`${u} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:i?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${u} bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-hover)]`,v=()=>t==="saving"?"Publishing...":t==="saved"?"Published":t==="error"?"Retry":i?"Published":"Publish Changes";return jsxRuntime.jsxs("div",{className:"inline-flex items-center",children:[jsxRuntime.jsxs("button",{type:"button",onClick:o,disabled:l,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline mr-1.5"}),(i||t==="saved")&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),v()]}),a&&jsxRuntime.jsx(Po,{trigger:jsxRuntime.jsx("button",{type:"button",className:m(),disabled:t==="saving",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}),direction:s,children:a})]})}var sc=({title:e,description:t,slug:r})=>jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg p-6 max-w-2xl shadow-sm transition-colors duration-300",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("div",{className:"w-7 h-7 bg-[var(--kyro-bg-secondary)] rounded-full flex items-center justify-center text-[10px] text-[var(--kyro-text-primary)] font-medium border border-[var(--kyro-border)]",children:"K"}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-tight",children:"kyro-cms.com"}),jsxRuntime.jsxs("span",{className:"text-[12px] text-[var(--kyro-text-secondary)] leading-tight opacity-80",children:["https://kyro-cms.com \u203A posts \u203A ",r]})]})]}),jsxRuntime.jsx("h3",{className:"text-[20px] text-[#2563eb] dark:text-[#60a5fa] font-medium hover:underline cursor-pointer mb-1 leading-tight transition-colors",children:e}),jsxRuntime.jsx("p",{className:"text-[14px] text-[var(--kyro-text-secondary)] leading-relaxed line-clamp-2",children:t})]});function lc({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=Ta.useState(0),s=e.tabs||[],i=s[a]||s[0],l=e.name?t[e.name]||{}:t;return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-[var(--kyro-border)] mb-6",children:jsxRuntime.jsx("div",{className:"flex items-center gap-2 overflow-x-auto hide-scrollbar",children:s.map((d,c)=>jsxRuntime.jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${a===c?"border-[var(--kyro-primary)] text-[var(--kyro-primary)]":"border-transparent text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] opacity-60 hover:opacity-100"}`,onClick:()=>n(c),children:d.label},c))})}),jsxRuntime.jsx("div",{className:"space-y-6",children:i?.fields.map(d=>o(d,l,r))}),i?.label==="SEO Settings"&&jsxRuntime.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold text-[var(--kyro-text-secondary)] tracking-[0.2em] mb-6 opacity-50",children:"Live Google Preview"}),jsxRuntime.jsx(sc,{title:String((typeof l.metaTitle=="object"?"":l.metaTitle)||(typeof l.title=="object"?"":l.title)||"Untitled"),description:String((typeof l.metaDescription=="object"?"":l.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function uc({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:s,handleDuplicate:i,handleUnpublish:l,handleDelete:d,handlePublish:c,handleSaveDraft:u,handleSchedulePublish:m,handleConflictOverride:v}){let{t:x}=reactI18next.useTranslation(),[g,f]=Ta.useState(Date.now()),[b,p]=Ta.useState(false),h=Ta.useRef(null),{formData:A,hasUnsavedChanges:$,autoSaveStatus:T,lastSavedAt:k,retryCount:y,view:w,setView:D,showPreview:U,setShowPreview:O,setFormData:z,markSaved:P,lastSavedData:R}=ge(),Ae=!A.id;Ta.useEffect(()=>{let H=setInterval(()=>f(Date.now()),1e4);return ()=>clearInterval(H)},[]),Ta.useEffect(()=>{let H=Te=>{h.current&&!h.current.contains(Te.target)&&p(false);};if(b)return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[b]);let E=String(A.tabs?.title||(typeof A.title=="object"?"":A.title)||(typeof A.name=="object"?"":A.name)||"Untitled"),oe=A.updatedAt?new Date(A.updatedAt).toLocaleString():"Just now",ie=A.createdAt?new Date(A.createdAt).toLocaleString():"Just now",ee=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",G=o?"Unpublished":r==="published"?"Published":"Draft",ye=r==="published"&&!$?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",De=r==="published"&&!o?"bg-[var(--kyro-success)]/10 text-[var(--kyro-success)] border-[var(--kyro-success)]/20":o?"bg-[var(--kyro-warning)]/10 text-[var(--kyro-warning)] border-[var(--kyro-warning)]/20":"bg-[var(--kyro-text-muted)]/10 text-[var(--kyro-text-muted)] border-[var(--kyro-text-muted)]/20",L=(H=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[T==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),H?"Saving\u2026":"Saving draft..."]}),T==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Ql.Check,{className:"w-3.5 h-3.5 shrink-0"}),H?"Saved":k?`Saved ${Math.floor((Date.now()-k)/6e4)}m ago`:"Draft saved"]}),T==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),H?`Retry ${y}/5`:`Retrying save (${y}/5)`]}),T==="offline"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[jsxRuntime.jsx("path",{d:"M10.61 10.61a3 3 0 0 0 4.24 4.24"}),jsxRuntime.jsx("path",{d:"M13.36 13.36a3 3 0 0 0-4.24-4.24"}),jsxRuntime.jsx("path",{d:"m2 2 20 20"}),jsxRuntime.jsx("path",{d:"M18.36 5.64a9 9 0 0 0-12.72 0"}),jsxRuntime.jsx("path",{d:"M22.61 1.39a15 15 0 0 0-21.22 0"})]}),H?"Offline":"Offline \u2014 cached locally"]}),T==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:H?"Failed":"Draft save failed"}),T==="conflict"&&(H?jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict"}):jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict detected"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>v?.(),className:"text-[var(--kyro-primary)] hover:underline",children:"Keep my changes"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"|"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-[var(--kyro-danger)] hover:underline",children:"Reload server version"})]}))]}),W=()=>!Ae&&jsxRuntime.jsxs(Po,{trigger:jsxRuntime.jsx("button",{type:"button",className:"kyro-btn p-2 md:p-2.5 rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)] transition-all",title:x("tooltips.moreActions",{defaultValue:"More actions"}),children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})}),direction:"down",children:[jsxRuntime.jsx(Pt,{onClick:u,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsxRuntime.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsxRuntime.jsx("polyline",{points:"7 3 7 8 15 8"})]}),children:"Save Draft"}),!t&&jsxRuntime.jsx(Pt,{onClick:s,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsxRuntime.jsx(Pt,{onClick:i,disabled:n,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),children:n?"Duplicating...":"Duplicate"}),jsxRuntime.jsx(Pt,{onClick:()=>p(true),icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsxRuntime.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsxRuntime.jsx(Pt,{onClick:l,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),jsxRuntime.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),children:"Unpublish"}),!t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xa,{}),jsxRuntime.jsx(Pt,{onClick:d,danger:true,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),children:"Delete"})]})]}),re=()=>b&&jsxRuntime.jsx("div",{ref:h,className:"relative",children:jsxRuntime.jsxs("div",{className:"absolute right-0 top-2 p-4 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] shadow-2xl z-50 min-w-[260px]",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsxRuntime.jsx("input",{type:"datetime-local",id:"schedule-datetime",className:"kyro-form-input text-xs mb-3 w-full",min:new Date().toISOString().slice(0,16)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>p(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let H=document.getElementById("schedule-datetime")?.value;H&&m(H);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] z-50 bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsxRuntime.jsx("a",{href:`${Ue}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:E}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-medium border ${De}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ye}`}),G]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:$,onPublish:c,disabled:a==="saving"}),W(),re()]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-[var(--kyro-border)]/50 bg-[var(--kyro-bg-secondary)]/30",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)]/50",children:["edit","version","api"].map(H=>jsxRuntime.jsx("button",{type:"button",onClick:()=>D(H),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${w===H?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 active:opacity-100"}`,children:H==="edit"?"Edit":H==="version"?"History":"API"},H))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[L(true),$&&T!=="saving"&&T!=="retrying"&&T!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument(R,R);},className:"text-[var(--kyro-primary)] text-[10px] font-medium hover:underline",children:"Revert"}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>O(!U),className:`p-1.5 rounded-lg transition-all ${U?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(Ql.ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxRuntime.jsxs("header",{className:"hidden md:flex surface-tile px-8 py-6 items-center justify-between sticky top-0 border-b border-[var(--kyro-border)] mb-8 bg-[var(--kyro-surface)] z-50 backdrop-blur-md",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsxRuntime.jsx("a",{href:`${Ue}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Ql.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:E}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${De}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ye}`}),ee]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[L(false),$&&T!=="saving"&&T!=="retrying"&&T!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument(R,R);},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),k&&T!=="saving"&&T!=="retrying"&&T!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let H=g-k,Te=Math.floor(H/6e4),fe=Math.floor(H/1e3);return Te>=1?`${Te}m ago`:fe>=5?`${fe}s ago`:"just now"})()]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",oe]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",ie]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-1 bg-[var(--kyro-bg-secondary)] p-1 rounded-xl border border-[var(--kyro-border)]",children:["edit","version","api"].map(H=>jsxRuntime.jsx("button",{type:"button",onClick:()=>D(H),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${w===H?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:H.toUpperCase()},H))}),jsxRuntime.jsx("div",{className:"h-8 w-px bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>O(!U),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${U?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:x("tooltips.livePreview",{defaultValue:"Live Preview"}),children:[jsxRuntime.jsx(Ql.ExternalLink,{className:"w-4 h-4"}),U&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),W(),re(),jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:$,onPublish:c,disabled:a==="saving"})]})]})]})]})}function pc({config:e,layout:t,collectionSlug:r,renderField:o}){let{t:a}=reactI18next.useTranslation(),{showPreview:n,sidebarCollapsed:s,formData:i,previewUrl:l}=ge();if(t==="single")return jsxRuntime.jsx("div",{className:"w-full space-y-6 md:space-y-8",children:jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.map(u=>o(u))})});let c=e.fields.some(u=>u.admin?.position==="sidebar")&&!n;return jsxRuntime.jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${n?"grid-cols-1 lg:grid-cols-2":s||!c?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsxRuntime.jsx("div",{className:"space-y-6 md:space-y-8 animate-in fade-in slide-in-from-left-4 duration-500",children:e.tabs?o({type:"tabs",tabs:e.tabs}):jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(u=>!u.admin?.position||u.admin.position==="main").map(u=>o(u))})}),n?jsxRuntime.jsx("div",{className:"sticky top-36 h-[calc(100vh-280px)] animate-in fade-in slide-in-from-right-10 duration-700",children:jsxRuntime.jsxs("div",{className:"w-full h-full rounded-3xl border border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] shadow-2xl overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-white/60",children:"Live Preview Mode"})]}),jsxRuntime.jsx("iframe",{src:l||"",className:"w-full h-full border-none",title:a("tooltips.livePreview",{defaultValue:"Live Preview"})}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):s?null:jsxRuntime.jsx("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:e.fields.some(u=>u.admin?.position==="sidebar")&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-6 space-y-4 md:space-y-6",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Settings"}),e.fields.filter(u=>u.admin?.position==="sidebar").map(u=>o(u))]})})]})}function mc({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:i,setCompareDiffs:l,loadingDiffs:d,loadingVersions:c,versions:u}=ge();return jsxRuntime.jsx("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 pb-12",children:jsxRuntime.jsxs("div",{className:"surface-tile p-0 overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"px-4 md:px-6 py-3 md:py-4 border-b border-[var(--kyro-border)] flex flex-col md:flex-row md:items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-base md:text-lg font-bold text-[var(--kyro-text-primary)]",children:"Version History"}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-muted)] mt-0.5",children:o?`Select 2 versions \xB7 ${n.length}/2 chosen`:`${u.length} snapshot${u.length!==1?"s":""} \xB7 Auto-saved`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&n.length===2&&jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:d,className:"kyro-btn kyro-btn-primary px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider hover:opacity-90 disabled:opacity-50",children:d?"Comparing...":"Compare"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{a(!o),s([]),l([]);},className:`px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider transition-all ${o?"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]":"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:o?"Done":"Compare"})]})]}),i.length>0&&jsxRuntime.jsxs("div",{className:"border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"px-6 py-3 flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold text-[var(--kyro-text-primary)] tracking-wider",children:[i.length," change",i.length!==1?"s":""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>l([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Ql.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:i.map((m,v)=>jsxRuntime.jsxs("div",{className:"flex flex-col md:grid md:grid-cols-4 gap-1 md:gap-3 px-4 md:px-6 py-2.5 text-[11px] font-mono border-t border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate font-semibold md:font-normal",children:m.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof m.oldValue=="object"?JSON.stringify(m.oldValue):String(m.oldValue??"null")}),jsxRuntime.jsxs("div",{className:"md:col-span-2 text-[var(--kyro-text-primary)] truncate",children:[jsxRuntime.jsx("span",{className:"md:hidden text-[var(--kyro-text-muted)]",children:"\u2192 "}),typeof m.newValue=="object"?JSON.stringify(m.newValue):String(m.newValue??"null")]})]},v))})]}),c?jsxRuntime.jsx("div",{className:"flex justify-center py-16",children:jsxRuntime.jsx("span",{className:"animate-spin text-[var(--kyro-primary)]",children:"\u231B"})}):u.length===0?jsxRuntime.jsx("div",{className:"text-center py-16 text-[var(--kyro-text-muted)] text-sm italic",children:"No versions yet."}):jsxRuntime.jsx("div",{className:"divide-y divide-[var(--kyro-border)]",children:u.map((m,v)=>{let x=n.includes(m.id),g=(m.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(m.id):void 0,className:`transition-all ${o?x?"bg-[var(--kyro-primary)]/5 cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)] cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"hidden md:grid grid-cols-12 gap-3 px-6 py-3 items-center",children:[jsxRuntime.jsx("div",{className:"col-span-1 flex items-center gap-2",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${x?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x&&jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:u.length-v})}),jsxRuntime.jsxs("div",{className:"col-span-4 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-2",children:[m.changeDescription||"Snapshot",g&&jsxRuntime.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider",children:"Auto"})]}),jsxRuntime.jsx("div",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(m.createdAt||m.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:m.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${m.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${m.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),m.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:m.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(m.id),className:"px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[11px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})})]}),jsxRuntime.jsxs("div",{className:"md:hidden flex items-start gap-3 px-4 py-3",children:[jsxRuntime.jsx("div",{className:"pt-0.5 shrink-0",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${x?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x&&jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:u.length-v})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-1.5",children:[m.changeDescription||"Snapshot",g&&jsxRuntime.jsx("span",{className:"text-[9px] px-1 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider shrink-0",children:"Auto"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(m.createdAt||m.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),m.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${m.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${m.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),m.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:m.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(m.id),className:"shrink-0 px-2.5 py-1 rounded-lg border border-[var(--kyro-border)] text-[10px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})]})]},m.id)})})]})})}function yc({collectionSlug:e,globalSlug:t}){let{t:r}=reactI18next.useTranslation(),{formData:o}=ge();return jsxRuntime.jsx("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] gap-8",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-8 min-w-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"Response Payload"}),jsxRuntime.jsx("div",{className:"bg-[#0f172a] p-6 rounded-2xl border border-white/5 overflow-x-auto max-h-[800px]",children:jsxRuntime.jsx("pre",{className:"text-blue-300 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(o,null,2)})})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsxs("div",{className:"surface-tile p-8 space-y-6",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"API Info"}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Reference Path"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg-secondary)] px-4 py-3 rounded-md border border-[var(--kyro-border)] text-[11px] font-mono break-all selection:bg-[var(--kyro-primary)]/20 text-[var(--kyro-text-primary)]",children:t?`kyro.globals('${t}').get()`:o.id?`kyro.collection('${e}').get('${o.id}')`:"Not saved yet"})]}),o.id&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Document ID"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:String(o.id)}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(o.id));},className:"p-1.5 hover:bg-[var(--kyro-bg-secondary)] rounded-lg transition-colors text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]",title:r("tooltips.copyId",{defaultValue:"Copy ID"}),children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),t&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Global Slug"}),jsxRuntime.jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:t})]})]})]})})]})})}var ds=class extends Ta.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("[ErrorBoundary] Caught:",t,r),this.setState({errorInfo:r.componentStack||null});}handleCopyToClipboard=()=>{let{error:t,errorInfo:r}=this.state,o=ge.getState().formData,a={error:t?.message,stack:t?.stack,componentStack:r,formData:o,timestamp:new Date().toISOString()};navigator.clipboard.writeText(JSON.stringify(a,null,2)).then(()=>{V.success("Crash details copied to clipboard");});};handleReload=()=>{window.location.reload();};render(){return this.state.hasError?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-8 h-8 text-red-500"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold text-[var(--kyro-text-primary)]",children:this.props.fallbackTitle||"Something went wrong"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] text-center max-w-md",children:"The form encountered an unexpected error. Your unsaved changes may still be recoverable."}),this.state.error&&jsxRuntime.jsx("p",{className:"text-xs font-mono text-red-500/70 bg-red-500/5 px-4 py-2 rounded-lg max-w-full overflow-auto",children:this.state.error.message}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[jsxRuntime.jsxs("button",{type:"button",onClick:this.handleReload,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.RefreshCw,{className:"w-4 h-4"}),"Reload Page"]}),jsxRuntime.jsxs("button",{type:"button",onClick:this.handleCopyToClipboard,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/20 transition-colors",children:[jsxRuntime.jsx(Ql.Copy,{className:"w-4 h-4"}),"Copy Details"]})]})]}):this.props.children}};function fc(e,t){if(!(!e||typeof t!="string"))return t.split(".").reduce((r,o)=>r&&r[o]!==void 0?r[o]:void 0,e)}function Ci(e,t,r){if(!e)return true;if(Array.isArray(e.and))return e.and.every(o=>Ci(o,t,r));if(Array.isArray(e.or))return e.or.some(o=>Ci(o,t,r));if(e.field){let o=e.field,a=fc(t,o);return a===void 0&&(a=fc(r,o)),"equals"in e?a===e.equals:"notEquals"in e?a!==e.notEquals:"in"in e&&Array.isArray(e.in)?e.in.includes(a):"greaterThan"in e?typeof a=="number"&&a>e.greaterThan:!!a}return true}var gc={};function Ya({config:e,data:t=gc,errors:r=gc,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:i,documentName:l,layout:d="split",onActionSuccess:c,onActionError:u,justSaved:m}){let v=e||(s?wd[s]:n?Zo[n]:null),[x,g]=Ta.useState(v);Ta.useEffect(()=>{s==="storage-settings"?Ee("/api/kyro/schema").then(I=>{I?.globals?.["storage-settings"]&&g(I.globals["storage-settings"]);}).catch(I=>console.error("[AutoForm] Failed to fetch dynamic schema",I)):g(v);},[s,v]);let f=x||v,{confirm:b}=yt(),{formData:p,hasUnsavedChanges:A,autoSaveStatus:k,lastSavedAt:y,view:Ae,setView:E,setShowPreview:De,isMenuOpen:L,setIsMenuOpen:W,loadingFields:re,setLoadingFields:H,compareSelected:we,setCompareSelected:S,setCompareDiffs:xe,setLoadingDiffs:Be,setField:Pe,setFormData:ft,setLastSavedData:J,setAutoSaveStatus:M,fetchVersions:K,saveDocument:le,forceSave:Fe,autoSaveSkipRef:Oe,lastAutoSaveTimeRef:gt,documentStatus:B,hasUnpublishedChanges:X,versionsEnabled:ae}=oc({config:f,initialData:t,collectionSlug:n,globalSlug:s,documentId:i,onChange:o,onActionSuccess:c,onActionError:u}),Jt=Ta.useRef(null),fo=Ta.useRef(null),[ka,Za]=Ta.useState(false),[bs,C]=Ta.useState("idle"),[me,$e]=Ta.useState(false),[tr,Et]=Ta.useState(Date.now()),xr=a,[xs,Lo]=Ta.useState(false),[lu,ks]=Ta.useState(false),[du,cu]=Ta.useState(0),Ii=Ta.useRef(new Map),uu=3e4;Ta.useEffect(()=>{let I=s?`global:${s}`:`${n}:${i}`;if(!(s||n&&i&&i!=="new")||t&&Object.keys(t).length>0)return;let he=Ii.current.get(I),He=he&&Date.now()-he.ts<uu,Nt=he&&!He;if(He){ge.getState().loadDocument(he.data,he.data);return}Nt&&ge.getState().loadDocument(he.data,he.data);let Ct=new AbortController;ks(false),he||Lo(true);let Rr=s?`/api/globals/${s}`:`/api/${n}/${i}`;return Ee(Rr,{autoToast:false,signal:Ct.signal}).then(vt=>{let go=vt.data||{};Ii.current.set(I,{data:go,ts:Date.now()}),ge.getState().loadDocument(go,go),Lo(false);}).catch(vt=>{vt.name!=="AbortError"&&(Lo(false),he||ks(true));}),()=>Ct.abort()},[n,i,s,t,du]),Ta.useEffect(()=>{let I=setInterval(()=>Et(Date.now()),1e4);return ()=>clearInterval(I)},[]);let Bi=(I,Z)=>{if(typeof I=="function")try{return I(p,Z)}catch(he){return console.warn("Error evaluating admin runtime flag:",he),false}return !!I},pu=I=>{b({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let Z=s?qe(`/api/globals/${s}/versions/${I}/restore`):qe(`/api/${n}/${p.id}/versions/${I}/restore`),he=await lt(Z,{method:"POST"});!he.ok&&n&&(he=await lt(qe(`/api/${n}/${p.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:I,action:"restore"})}));let He=await he.json();if(He.data){let{updatedAt:Nt,createdAt:Ct,...Rr}=He.data,vt={...p,...Rr};ft(vt),ge.getState().loadDocument(vt,vt),c?.("Version restored successfully"),K(),E("edit");}else V.error(He.error||"Failed to restore version");}catch(Z){console.error("Failed to restore version:",Z),V.error("Failed to restore version");}}});},mu=async()=>{if(we.length===2){Be(true);try{let Z=await(await lt(qe(`/api/${n}/${p.id}/versions?compareA=${we[0]}&compareB=${we[1]}`))).json();xe(Z.diffs||[]);}catch(I){console.error("Compare failed:",I),xe([]);}finally{Be(false);}}},yu=I=>{S(Z=>Z.includes(I)?Z.filter(he=>he!==I):Z.length>=2?[Z[1],I]:[...Z,I]);};Ta.useEffect(()=>{let I=Z=>{(Z.metaKey||Z.ctrlKey)&&Z.key==="s"&&(Z.preventDefault(),en()),(Z.metaKey||Z.ctrlKey)&&Z.shiftKey&&(Z.key==="P"||Z.key==="p")&&(Z.preventDefault(),document.getElementById("btn-publish")?.click()),(Z.metaKey||Z.ctrlKey)&&!Z.shiftKey&&Z.key==="p"&&(Z.preventDefault(),De(he=>!he)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(Z.key==="1"&&E("edit"),Z.key==="2"&&E("version"),Z.key==="3"&&E("api"));};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[]),Ta.useEffect(()=>{let I=()=>E("version");return window.addEventListener("kyro:show-version-history",I),()=>window.removeEventListener("kyro:show-version-history",I)},[]),Ta.useEffect(()=>{let I=Z=>{Jt.current&&!Jt.current.contains(Z.target)&&W(false);};if(L)return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[L]),Ta.useEffect(()=>{let I=Z=>{fo.current&&!fo.current.contains(Z.target)&&Za(false);};if(ka)return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[ka]);let fu=()=>{A?b({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await en(),await new Promise(I=>setTimeout(I,1e3)),window.location.href=`${Ue}/${n}/new`;}}):window.location.href=`${Ue}/${n}/new`;},gu=()=>{if(!p.id){V.error("Please save the document before duplicating.");return}let I=async()=>{try{$e(!0);let Z=await lt(`/api/${n}/${p.id}/duplicate`,{method:"POST"});if(Z.ok){let he=await Z.json();c?.("Document duplicated successfully"),he.data?.id?window.location.href=`${Ue}/${n}/${he.data.id}`:window.location.href=`${Ue}/${n}`;}else {let he=await Z.json();V.error(he.error||"Failed to duplicate");}}catch{V.error("Failed to duplicate document");}finally{$e(false);}};if(A){b({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await en(),await I();}});return}b({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await I();}});},vu=()=>{b({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{Oe.current=true;try{await At(`/api/${n}/${p.id}`),window.location.href=`${Ue}/${n}`;}catch(I){V.error(I.message||"Failed to delete document");}finally{Oe.current=false;}}});},bu=()=>{b({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{Oe.current=true;try{let I=await le({...p,status:"draft"},!1);if(I?.ok)c?.("Document unpublished successfully"),ge.getState().loadDocument({...p,status:"draft"},{...p,status:"draft"});else {let Z=await I?.json().catch(()=>({}));V.error(Z?.error||"Failed to unpublish");}}catch{V.error("Failed to unpublish");}finally{Oe.current=false;}}});},en=async()=>{let I=!p.id;Oe.current=true,C("saving");try{let Z=Kt({...p}),he=I&&!s,He=he?await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}):await le(Z);if(He.ok){let Nt=await He.json(),Ct=Nt.data||Z;ge.getState().loadDocument(Ct,Ct),gt.current=Date.now(),M("success"),C("saved"),ae&&K(),setTimeout(()=>{M("idle"),C("idle");},2e3),c?.(he?"Document created successfully":"Changes saved"),s&&window.dispatchEvent(new Event("kyro:soft-reload")),he&&setTimeout(()=>{window.location.href=`${Ue}/${n}/${Nt.data.id}`;},800);}else {let Nt=await He.json();He.status===409&&M("conflict"),C("error"),V.error(Nt.error||"Failed to save"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),V.error("Failed to save document"),setTimeout(()=>C("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),Oe.current=false;}},xu=async()=>{let I=!p.id;Oe.current=true,C("saving");try{let Z={...p};if(I&&!s){let Nt=Kt({...p}),Ct=await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Nt)});if(!Ct.ok){let go=await Ct.json().catch(()=>({}));Ct.status===409&&M("conflict"),C("error"),V.error(go.error||"Failed to create document"),setTimeout(()=>C("idle"),3e3);return}let vt=(await Ct.json()).data||Nt;ge.getState().loadDocument(vt,vt),Z=vt;}let he=Kt(Z),He=await le(he,!1);if(He?.ok){let Ct=(await He.json().catch(()=>({}))).data||he;ge.getState().loadDocument(Ct,Ct),C("saved"),c?.("Published successfully"),setTimeout(()=>{C("idle");},2e3),I&&!s&&Z.id&&setTimeout(()=>{window.location.href=`${Ue}/${n}/${Z.id}`;},800);}else {if(I&&!s&&Z.id){let Ct=await He?.json().catch(()=>({}));V.warning("Document saved as draft. Publishing failed: "+(Ct?.error||"Unknown error")),setTimeout(()=>{window.location.href=`${Ue}/${n}/${Z.id}`;},1200);return}let Nt=await He?.json().catch(()=>({}));He?.status===409&&M("conflict"),C("error"),V.error(Nt?.error||"Failed to publish"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),V.error("Failed to publish"),setTimeout(()=>C("idle"),3e3);}finally{Oe.current=false;}},ku=async I=>{let Z=!p.id;Oe.current=true;try{let he={...Kt({...p}),_schedulePublishAt:I};if(Z&&!s){let He=await lt(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!He.ok){let Nt=await He.json().catch(()=>({}));V.error(Nt.error||"Failed to schedule publish");return}}else {let He=await le(he);if(!He.ok){let Nt=await He.json().catch(()=>({}));V.error(Nt.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(I).toLocaleString()}`),Za(!1);}catch{V.error("Failed to schedule publish");}finally{Oe.current=false;}},hu=(I,Z)=>{Pe(I,Z);},ha=(I,Z,he)=>{let He=Z!==void 0?Z:p;if(Bi(I.hidden!==void 0?I.hidden:I.admin?.hidden,He))return null;let Ct=Bi(I.readOnly!==void 0?I.readOnly:I.admin?.readOnly,He),Rr=!!(xr||Ct);if(I.admin?.condition){if(typeof I.admin.condition=="function")try{let it={values:p||{},...p||{}};if(!I.admin.condition(it,He))return null}catch(it){console.warn(`Condition error for field ${I.name}:`,it);}else if(typeof I.admin.condition=="object")try{if(!Ci(I.admin.condition,He,p))return null}catch(it){console.warn(`Declarative condition error for field ${I.name}:`,it);}}let vt=He[I.name],go=r[I.name],tn=it=>{he?he({...He,[I.name]:it}):hu(I.name,it);};if(I.type==="row"&&"fields"in I){let it=I.fields;return jsxRuntime.jsx("div",{className:"kyro-form-row flex flex-col md:flex-row gap-4 md:gap-6 items-start md:items-end w-full",children:it?.map(ot=>{let Ir=ot.admin||{},rn=Ir?.action;if((ot.type==="button"||ot.type==="action")&&rn){let kr=it?.find(wa=>wa.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let wa=I.name,on=kr?.name,an=on?p[on]:void 0;if(!an&&wa&&typeof wa=="string"&&on&&(an=p[wa]?.[on]),!!an){H(hr=>({...hr,[ot.name]:true}));try{let hr=await lt(qe(rn),{method:Ir.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:an})}),Na={};try{Na=await hr.json();}catch{Na={};}if(hr.ok&&Na.success)c?.(Na.message||"Action completed successfully");else {let wu=Na.error||`Request failed (${hr.status})`;u?.(wu);}}catch(hr){u?.(hr instanceof Error?hr.message:"Error connecting to server");}finally{H(hr=>({...hr,[ot.name]:false}));}}},disabled:re[ot.name]||Rr,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:re[ot.name]?"Sending...":ot.label||"Click"})},ot.name)}return jsxRuntime.jsx("div",{className:ot.type==="button"||ot.type==="action"?"flex-shrink-0":"flex-1",style:Ir?.width?{width:Ir.width,flex:"none"}:{},children:ha(ot,Z,he)},ot.name)})},I.name||`row-${Math.random()}`)}switch(I.type){case "tabs":return jsxRuntime.jsx(lc,{field:I,formData:p,onTabDataChange:it=>{Pe(I.name,it);},renderField:(it,ot,Ir)=>ha(it,ot,Ir)},I.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(Zn,{field:I,value:vt,onChange:tn,renderField:ha},I.name);case "array":return jsxRuntime.jsx(es,{field:I,value:vt,onChange:tn,renderField:ha,disabled:Rr},I.name);case "button":case "action":{let it=I.name,ot=re[it];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:ot||Rr,onClick:async()=>{let Ir=I.admin?.action||I.action,rn=I.admin?.method||I.method||"POST";if(Ir){H(kr=>({...kr,[it]:true}));try{let kr=await lt(Ir,{method:rn,headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});await kr.json(),kr.ok;}catch(kr){console.error("Error executing action:",kr);}finally{H(kr=>({...kr,[it]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${ot?"opacity-70 cursor-not-allowed":""}`,children:[ot&&jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),ot?"Processing...":I.label||"Click"]})},it)}case "relationship-block":return jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[I.label||I.name,I.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx(qa,{relationTo:I.relationTo,hasMany:I.hasMany,selectedIds:Array.isArray(vt)?vt:vt?[vt]:[],onChange:(it,ot)=>{tn(ot);},compact:true}),I.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(I.admin?.description)}):null]},I.name);default:return jsxRuntime.jsx(To,{field:I,value:vt,onChange:tn,error:go,disabled:Rr,formData:p,siblingData:He,collectionSlug:n,globalSlug:s},I.name||Math.random().toString())}};return xs?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(jt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(jt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(jt,{variant:"rect",count:4})})]}):lu?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{ks(false),Lo(true),cu(I=>I+1);},className:"kyro-btn kyro-btn-primary px-6 py-2 rounded-xl text-sm font-bold",children:"Retry"})]}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[d!=="single"&&jsxRuntime.jsx(uc,{collectionSlug:n,globalSlug:s,documentStatus:B||"draft",hasUnpublishedChanges:X,localSaveStatus:bs,isDuplicating:me,handleCreateNew:fu,handleDuplicate:gu,handleUnpublish:bu,handleDelete:vu,handlePublish:xu,handleSaveDraft:en,handleSchedulePublish:ku,handleConflictOverride:()=>Fe()}),d==="single"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium",children:[k==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Saving..."]}),k==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"}),y?`Saved ${Math.floor((Date.now()-y)/6e4)}m ago`:"Saved"]}),k==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Retrying..."]}),k==="offline"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),k==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),k==="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),A&&k!=="saving"&&k!=="retrying"&&k!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!A&&k!=="success"&&k!=="saving"&&k!=="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-success)]",children:"All changes saved"})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)] opacity-60",children:p.updatedAt?`Modified ${new Date(p.updatedAt).toLocaleString()}`:""})]}),jsxRuntime.jsx("button",{id:"btn-save",type:"button",style:{width:0,height:0,opacity:0,padding:0,margin:0,border:"none",position:"absolute"},onClick:async()=>{Oe.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let I=await le(p);if(I.ok){let he=(await I.json()).data||p;ft({...p,...he}),J({...p,...he}),c?.("Changes saved"),s&&window.dispatchEvent(new Event("kyro:soft-reload"));}}catch(I){console.error("Save error exception:",I),u?.("Save failed: "+I.message);}finally{Oe.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsxRuntime.jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxRuntime.jsxs(ds,{children:[Ae==="edit"&&jsxRuntime.jsx(pc,{config:f,layout:d,collectionSlug:n,renderField:ha}),Ae==="version"&&jsxRuntime.jsx(mc,{handleRestoreVersion:pu,handleCompareVersions:mu,toggleCompareSelection:yu}),Ae==="api"&&jsxRuntime.jsx(yc,{collectionSlug:n,globalSlug:s})]})})]})}var vc={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function Si({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:s,onViewHistory:i,onPreview:l,onDelete:d,onBack:c,onToggleSidebar:u,publishedAt:m,updatedAt:v,onCopyData:x,onPasteData:g}){let{t:f}=reactI18next.useTranslation(),b=ge(D=>D.view)||"edit",p=ge(D=>D.setView),[h,A]=Ta.useState(false),$=Ta.useRef(null);Ta.useEffect(()=>{let D=U=>{$.current&&!$.current.contains(U.target)&&A(false);};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);let T=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,k=["edit","version","api"],y=T(),w="p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] transition-all shrink-0";return jsxRuntime.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 bg-[var(--kyro-surface)] border-b border-[var(--kyro-border)] w-full overflow-x-auto",children:[c&&jsxRuntime.jsx("button",{type:"button",onClick:c,className:"p-1 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all shrink-0",children:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${vc[e]||"bg-[var(--kyro-text-muted)]"}`}),y&&jsxRuntime.jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline mr-0.5"}),y]}),jsxRuntime.jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)] shrink-0 max-md:hidden",children:k.map(D=>jsxRuntime.jsx("button",{type:"button",onClick:()=>p(D),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${b===D?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:D==="edit"?"Edit":D==="version"?"Ver":"API"},D))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${w} max-md:hidden`,title:f("tooltips.preview",{defaultValue:"Preview"}),children:jsxRuntime.jsx(Ql.Eye,{className:"w-3.5 h-3.5"})}),i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${w} max-md:hidden`,title:f("tooltips.viewHistory",{defaultValue:"View History"}),children:jsxRuntime.jsx(Ql.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${w} max-md:hidden`,title:f("tooltips.duplicate",{defaultValue:"Duplicate"}),children:jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5"})}),x&&jsxRuntime.jsx("button",{type:"button",onClick:x,className:`${w} max-md:hidden`,title:f("tooltips.copyData",{defaultValue:"Copy Data"}),children:jsxRuntime.jsx(Ql.ClipboardCopy,{className:"w-3.5 h-3.5"})}),g&&jsxRuntime.jsx("button",{type:"button",onClick:g,className:`${w} max-md:hidden`,title:f("tooltips.pasteData",{defaultValue:"Paste Data"}),children:jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsxRuntime.jsx("button",{type:"button",onClick:d,className:`${w} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:f("tooltips.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})}),u&&jsxRuntime.jsx("button",{type:"button",onClick:u,className:`${w} max-md:hidden`,title:f("tooltips.toggleSidebar",{defaultValue:"Toggle Sidebar"}),children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),jsxRuntime.jsxs("div",{ref:$,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>A(!h),className:w,title:f("tooltips.more",{defaultValue:"More"}),children:jsxRuntime.jsx(Ql.EllipsisVertical,{className:"w-3.5 h-3.5"})}),h&&jsxRuntime.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-1 max-h-[70vh] overflow-y-auto",children:[y&&jsxRuntime.jsxs("div",{className:"px-3 py-2 text-[10px] text-[var(--kyro-text-muted)] border-b border-[var(--kyro-border)] flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${vc[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(ar,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:y})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:k.map(D=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{p(D),A(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${b===D?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:D==="edit"?"Edit":D==="version"?"Ver":"API"},D))}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),x&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{x(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.ClipboardCopy,{className:"w-3.5 h-3.5"})," Copy Data"]}),g&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{g(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-3.5 h-3.5"})," Paste Data"]}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsxRuntime.jsx(Ql.Eye,{className:"w-3.5 h-3.5"})," Preview"]}),d&&jsxRuntime.jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>{d(),A(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger-bg)] transition-colors",children:[jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxRuntime.jsxs("button",{type:"button",onClick:a,disabled:t==="saving",className:"kyro-btn kyro-btn-primary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(Ql.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxRuntime.jsxs("button",{type:"button",onClick:n,disabled:t==="saving",className:"kyro-btn kyro-btn-secondary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsxRuntime.jsx(Ql.Undo,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxRuntime.jsxs(Ro,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[s&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.Copy,{className:"w-4 h-4"}),onClick:s,children:"Duplicate"}),x&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.ClipboardCopy,{className:"w-4 h-4"}),onClick:x,children:"Copy Data"}),g&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.ClipboardPaste,{className:"w-4 h-4"}),onClick:g,children:"Paste Data"}),i&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.Clock,{className:"w-4 h-4"}),onClick:i,children:"View History"}),l&&jsxRuntime.jsx(Pt,{icon:jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4"}),onClick:l,children:"Preview"}),(s||x||g||i||l)&&jsxRuntime.jsx(Xa,{}),d&&jsxRuntime.jsx(Pt,{onClick:d,danger:true,icon:jsxRuntime.jsx(Ql.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function Ai({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:i,mode:l="collection"}){let{t:d}=reactI18next.useTranslation(),{confirm:c,alert:u}=yt(),[m,v]=Ta.useState({}),[x,g]=Ta.useState({}),[f,b]=Ta.useState(true),[p,h]=Ta.useState(false),[A,$]=Ta.useState(false),[T,k]=Ta.useState(false),[y,w]=Ta.useState("idle"),[D,U]=Ta.useState("draft"),[O,z]=Ta.useState(null),[P,R]=Ta.useState(null),[Ae,E]=Ta.useState(null),[oe,ie]=Ta.useState(false),ee=ge(M=>M.showPreview),G=ge(M=>M.setShowPreview),ye=ge(M=>M.previewUrl),De=ge(M=>M.setPreviewUrl),L=r?.fields||t?.fields||[],W=r?.label||t?.label||"Document",re=r?.slug||t?.slug||"",H=JSON.stringify(m)!==JSON.stringify(x);Ta.useEffect(()=>{H&&D==="published"&&U("draft");},[H,D]),Ta.useEffect(()=>{H&&y==="saved"&&w("idle");},[H,y]),Ta.useEffect(()=>{l==="global"?fe():o&&Te();},[o,l,re]);let Te=async()=>{try{b(!0);let M=await Ee(`/api/${re}/${o}`,{autoToast:!1}),K=M.data||{};v(K),g(K),U(K?.status||M.status||"draft"),z(M.createdAt||K.createdAt||null),R(M.updatedAt||K.updatedAt||null),E(M.publishedAt||K.publishedAt||null);}catch{i("Failed to load document");}finally{b(false);}},fe=async()=>{try{b(!0);let M=await Ee(`/api/globals/${re}`,{autoToast:!1}),K=M.data||{};v(K),g(K),z(M.createdAt||null),R(M.updatedAt||null);}catch{i("Failed to load global");}finally{b(false);}},we=Ta.useCallback(async(M=false)=>{try{w("saving");let K=l==="global"?`/api/globals/${re}`:`/api/${re}/${o}`,le=D==="draft"||m?.status==="draft",Fe=await Yt(K,m,{autoToast:!1,headers:{"X-Draft":String(le)}}),Oe=Fe&&(Fe.data||Fe)||m;M||(g(Oe),n()),v(Oe),U(Oe?.status||D),w("saved"),R(new Date().toISOString()),ie(!0),setTimeout(()=>ie(!1),3e3),M||(D==="draft"||Oe?.status==="draft"?V.warning(d("toast.draftSaved",{defaultValue:"Draft saved"})):V.success(d("toast.updated",{defaultValue:"Updated"}))),setTimeout(()=>{w("idle");},2e3),ee&&ft(Oe);}catch{w("error"),M||(i(d("toast.saveError",{defaultValue:"Failed to save changes"})),V.error(d("toast.saveError",{defaultValue:"Failed to save changes"})));}finally{h(false);}},[m,l,re,o,D,n,i]),S=async()=>{try{h(!0),await Yt(`/api/${re}/${o}`,m,{autoToast:!1,headers:{"X-Draft":"false"}}),U("published"),E(new Date().toISOString()),V.success(d("toast.published",{defaultValue:"Published successfully"})),n();}catch{i(d("toast.publishError",{defaultValue:"Failed to publish"})),V.error(d("toast.publishError",{defaultValue:"Failed to publish"}));}finally{h(false);}},j=async()=>{try{h(!0),await Yt(`/api/${re}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),U("draft"),V.warning(d("toast.unpublished",{defaultValue:"Document unpublished"})),n();}catch{i(d("toast.unpublishError",{defaultValue:"Failed to unpublish"})),V.error(d("toast.unpublishError",{defaultValue:"Failed to unpublish"}));}finally{h(false);}},xe=async()=>{try{$(!0);let M=await dt(`/api/${re}/${o}/duplicate`,void 0,{autoToast:!1});V.success(d("toast.duplicated",{defaultValue:"Document duplicated"})),M?.data?.id?window.location.href=`${Ue}/${re}/${M.data.id}`:window.location.href=`${Ue}/${re}`;}catch(M){V.error(M.message||d("toast.duplicateError",{defaultValue:"Failed to duplicate document"}));}finally{$(false);}},Le=async()=>{try{let M={...m};delete M.id,delete M.createdAt,delete M.updatedAt,delete M.status,await navigator.clipboard.writeText(JSON.stringify(M)),V.success(d("toast.dataCopied",{defaultValue:"Document data copied to clipboard"}));}catch{V.error(d("toast.copyError",{defaultValue:"Failed to copy document data"}));}},Be=async()=>{try{let M=await navigator.clipboard.readText(),K=JSON.parse(M);if(typeof K!="object"||K===null)throw new Error("Invalid format");v(le=>({...le,...K,id:le.id,createdAt:le.createdAt,updatedAt:le.updatedAt,status:le.status})),V.success(d("toast.dataPasted",{defaultValue:"Document data pasted"}));}catch{V.error(d("toast.pasteError",{defaultValue:"Clipboard does not contain valid document JSON"}));}},Pe=()=>{c({title:d("detailView.deleteTitle",{defaultValue:"Delete {{label}}?",label:W}),message:d("detailView.deleteMessage",{defaultValue:"This action cannot be undone."}),variant:"danger",onConfirm:async()=>{try{k(!0),await At(`/api/${re}/${o}`),window.location.href=`${Ue}/${re}`;}catch{k(false);}}});},ft=async(M=m)=>{try{let K=l==="global"?`/api/globals/${re}/preview-url`:`/api/${re}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",K,"with data keys:",Object.keys(M||{}),"documentId:",o);let le=await dt(K,{...M,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(le)),le&&le.url?(console.log("[Kyro Preview] Setting previewUrl:",le.url),De(le.url)):console.warn("[Kyro Preview] No url in response:",le);}catch(K){console.error("[Kyro Preview] Error:",K.message,K),V.error(K.message||"Failed to generate preview URL");}};Ta.useEffect(()=>{ee&&ft(m);},[ee]);let qt=()=>{let M=!ee;G(M),M&&ft(m);};if(f)return jsxRuntime.jsx("div",{className:"kyro-detail",children:jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(jt,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(jt,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(jt,{variant:"rect",count:4})})]})});let J=l==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Lt,{back:{onClick:a},breadcrumbs:[{label:l==="global"?d("detailView.globals",{defaultValue:"Globals"}):d("detailView.collections",{defaultValue:"Collections"})},{label:W,href:l==="collection"?`${Ue}/${re}`:void 0},{label:l==="global"?d("actions.edit",{defaultValue:"Edit"}):o?d("actions.edit",{defaultValue:"Edit"}):d("actions.new",{defaultValue:"New"})}],title:l==="global"?W:ho(t?.fields,m,t?.admin?.useAsTitle||"title")||m.name||o||d("detailView.newDocument",{defaultValue:"New {{label}}",label:t?.singularLabel||W}),metadata:[jsxRuntime.jsx(Rt,{variant:D==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:d(`status.${D}`,{defaultValue:D})},"status")]}),jsxRuntime.jsx(Si,{status:D,saveStatus:y,hasChanges:H,onSave:()=>we(false),onPublish:S,onUnpublish:D==="published"?j:void 0,onDuplicate:xe,onCopyData:Le,onPasteData:Be,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:t?.admin?.disablePreview||r?.admin?.disablePreview?void 0:qt,onDelete:Pe,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:Ae,updatedAt:P}),jsxRuntime.jsxs("div",{className:ee?"w-full mx-auto grid grid-cols-1 lg:grid-cols-2 gap-4 md:gap-8 pt-4 md:pt-0 h-[calc(100vh-140px)]":J?"w-full pt-4 md:pt-8":"w-full mx-auto grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-4 md:gap-8 pt-4 md:pt-0",children:[jsxRuntime.jsx("div",{className:`space-y-4 md:space-y-8 min-w-0 ${ee?"overflow-y-auto pr-2 pb-20":""}`,children:jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsxRuntime.jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:d("detailView.coreConfiguration",{defaultValue:"Core Configuration"})}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(Ya,{config:t?{...t,fields:L}:{slug:"unknown",fields:L},data:m,onChange:v,layout:J?"single":"split",globalSlug:l==="global"?re:void 0,collectionSlug:l==="collection"?re:void 0,onActionSuccess:M=>V.success(M),onActionError:M=>V.error(M),documentStatus:D,justSaved:oe}),J&&jsxRuntime.jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[l==="collection"&&o&&jsxRuntime.jsx("button",{type:"button",onClick:Pe,disabled:T||p,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:T?d("actions.deleting",{defaultValue:"Deleting..."}):d("actions.deleteDocument",{defaultValue:"Delete Document"})}),jsxRuntime.jsx(Ro,{status:D,saveStatus:p?"saving":"idle",hasChanges:H,onPublish:()=>we(false),disabled:p})]})]})}),ee&&jsxRuntime.jsxs("div",{className:"surface-tile flex flex-col overflow-hidden h-full border border-[var(--kyro-border)] rounded-xl animate-in fade-in slide-in-from-right-4 duration-500 shadow-xl bg-white dark:bg-black",children:[jsxRuntime.jsxs("div",{className:"bg-[var(--kyro-surface-accent)] border-b border-[var(--kyro-border)] p-2 flex items-center justify-between shrink-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 pl-2",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-red-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/80"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-green-400/80"})]}),jsxRuntime.jsx("div",{className:"text-[10px] font-mono opacity-50 truncate max-w-[60%] bg-[var(--kyro-bg)] px-3 py-1 rounded",children:ye||d("detailView.generatingPreview",{defaultValue:"Generating preview URL..."})}),jsxRuntime.jsx("div",{className:"w-16"})]}),jsxRuntime.jsx("div",{className:"flex-1 bg-white relative",children:ye?jsxRuntime.jsx("iframe",{src:ye,className:"w-full h-full border-0 bg-white",title:d("tooltips.preview",{defaultValue:"Preview"}),sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"}):jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx(ar,{className:"w-6 h-6 text-[var(--kyro-primary)]"})})})]}),!J&&!ee&&jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4 md:mb-6",children:d("detailView.metadata",{defaultValue:"Metadata"})}),jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dynamicStatus",{defaultValue:"Dynamic Status"})}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-[9px] font-bold tracking-widest ${D==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:D||"draft"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dateCreated",{defaultValue:"Date Created"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:O?new Date(O).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("common.na",{defaultValue:"N/A"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.lastModified",{defaultValue:"Last Modified"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:P?new Date(P).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("detailView.justNow",{defaultValue:"Just now"})})]}),Ae&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.publicAt",{defaultValue:"Public At"})}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(Ae).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})})]})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8 bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-3 md:mb-4",children:d("detailView.quickLinks",{defaultValue:"Quick Links"})}),jsxRuntime.jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:xe,disabled:A||p,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:A?d("actions.duplicating",{defaultValue:"Duplicating..."}):d("actions.duplicateDocument",{defaultValue:"Duplicate Document"})}),ye&&jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(ye,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:d("detailView.openPreview",{defaultValue:"Open Preview in New Tab"})}),jsxRuntime.jsx("button",{type:"button",onClick:Pe,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:d("actions.deleteEntry",{defaultValue:"Delete Entry"})})]})]})]})]})]})}function Di({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=Ta.useState({}),[i,l]=Ta.useState(false),d=t.fields||[],c=t.label||t.slug,u=async m=>{try{l(!0),await dt(`/api/${t.slug}`,n),V.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(v){a(v instanceof Error?v.message:"Failed to create");}finally{l(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Lt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${Ue}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:i?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>u(),disabled:i}}),jsxRuntime.jsx("div",{className:"kyro-detail-body",children:jsxRuntime.jsx("div",{className:"kyro-card",children:jsxRuntime.jsx("div",{className:"kyro-card-content",children:jsxRuntime.jsx("form",{children:jsxRuntime.jsx(Ya,{config:{...t,fields:d},data:n,onChange:s})})})})})]})}function xc({type:e,message:t,onClose:r}){let[o,a]=Ta__default.default.useState(false),n=Ta__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},i=()=>{n.current&&clearTimeout(n.current);};Ta__default.default.useEffect(()=>(o?i():s(),i),[o,r]);let l={success:Ql.CircleCheck,error:Ql.ShieldAlert,warning:Ql.TriangleAlert,info:Ql.Info}[e];return jsxRuntime.jsxs("div",{className:`kyro-toast kyro-toast-${e} group animate-in fade-in slide-in-from-right-4 duration-300`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),children:[jsxRuntime.jsx("div",{className:"kyro-toast-accent"}),jsxRuntime.jsx("div",{className:"kyro-toast-icon-container",children:jsxRuntime.jsx(l,{className:"w-4 h-4"})}),jsxRuntime.jsx("div",{className:"kyro-toast-content",children:jsxRuntime.jsx("p",{className:"kyro-toast-message",children:t})}),jsxRuntime.jsx("button",{type:"button",className:"kyro-toast-close group-hover:opacity-100 opacity-40 transition-opacity",onClick:r,children:jsxRuntime.jsx(Ql.X,{className:"w-3.5 h-3.5"})})]})}function uF({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function pF(){let e=Xt(o=>o.addToast),t=Xt(o=>o.removeToast);return {toasts:Xt(o=>o.toasts),addToast:e,removeToast:t}}function us(){let e=Xt(r=>r.toasts),t=Xt(r=>r.removeToast);return jsxRuntime.jsx("div",{className:"kyro-toasts-container",style:{position:"fixed",bottom:"24px",right:"24px",display:"flex",flexDirection:"column",gap:"12px",zIndex:1e5,pointerEvents:"none"},children:e.map(r=>jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:jsxRuntime.jsx(xc,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Fi({onAuth:e,theme:t="light"}){let{t:r}=reactI18next.useTranslation(),[o,a]=Ta.useState("login"),[n,s]=Ta.useState(""),[i,l]=Ta.useState(""),[d,c]=Ta.useState(""),[u,m]=Ta.useState(false),[v,x]=Ta.useState(false),g=Xt(p=>p.addToast);Ta.useEffect(()=>{f();},[]);let f=async()=>{try{await Ee("/api/users");}catch{x(true),a("register");}},b=async p=>{p.preventDefault(),m(true);try{let h=o==="login"?"/api/auth/login":"/api/auth/register",A={email:n,password:i};o==="register"&&(A.confirmPassword=d);let $=await dt(h,A);$.isFirstUser&&x(!0),localStorage.setItem("kyro_user",JSON.stringify($.user)),g("success",o==="login"?r("toast.welcomeBack",{defaultValue:"Welcome back!"}):r("toast.accountCreated",{defaultValue:"Account created!"})),e($.token,$.user);}catch{g("error",r("toast.connectionFailed",{defaultValue:"Connection failed"}));}finally{m(false);}};return jsxRuntime.jsx(Sr,{defaultMode:t,children:jsxRuntime.jsxs("div",{className:"kyro-login-page",children:[jsxRuntime.jsxs("div",{className:"kyro-login-container",children:[jsxRuntime.jsxs("div",{className:"kyro-login-header",children:[jsxRuntime.jsx("h1",{className:"kyro-login-title",children:v?r("login.createAdminAccount",{defaultValue:"Create Admin Account"}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:v?r("login.setupAdmin",{defaultValue:"Set up your admin account to get started"}):o==="login"?r("login.enterCredentials",{defaultValue:"Enter your credentials to access the admin"}):r("login.createAccountDesc",{defaultValue:"Create an account to access the admin"})})]}),jsxRuntime.jsxs("form",{onSubmit:b,className:"kyro-login-form",children:[jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"email",children:r("login.email",{defaultValue:"Email"})}),jsxRuntime.jsx("input",{id:"email",type:"email",value:n,onChange:p=>s(p.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:r("login.password",{defaultValue:"Password"})}),jsxRuntime.jsx("input",{id:"password",type:"password",value:i,onChange:p=>l(p.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:o==="login"?"current-password":"new-password"})]}),o==="register"&&jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"confirmPassword",children:r("login.confirmPassword",{defaultValue:"Confirm Password"})}),jsxRuntime.jsx("input",{id:"confirmPassword",type:"password",value:d,onChange:p=>c(p.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsxRuntime.jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:u,children:u?o==="login"?r("login.signingIn",{defaultValue:"Signing in..."}):r("login.creatingAccount",{defaultValue:"Creating account..."}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})})]}),!v&&jsxRuntime.jsx("div",{className:"kyro-login-footer",children:jsxRuntime.jsx("p",{children:o==="login"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("login.noAccount",{defaultValue:"Don't have an account?"})," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("register"),children:r("login.signUp",{defaultValue:"Sign up"})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("login.hasAccount",{defaultValue:"Already have an account?"})," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("login"),children:r("login.signInAction",{defaultValue:"Sign in"})})]})})})]}),jsxRuntime.jsx(us,{})]})})}function wc({collections:e,onNavigate:t,user:r}){let{t:o}=reactI18next.useTranslation(),{permissions:a}=_r(),[n,s]=Ta.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[i,l]=Ta.useState(true);Ta.useEffect(()=>{let c=setTimeout(()=>{s({totalDocs:124,totalMedia:856,totalUsers:12,recentActivity:[{id:1,type:"edit",user:"Daniel Dozie",doc:"Getting Started with Kyro",collection:"posts",time:"2m ago"},{id:2,type:"create",user:"Jane Smith",doc:"New Product Launch",collection:"products",time:"15m ago"},{id:3,type:"upload",user:"Daniel Dozie",doc:"hero-banner.jpg",collection:"media",time:"1h ago"},{id:4,type:"publish",user:"System",doc:"Weekly Update",collection:"posts",time:"3h ago"}]}),l(false);},800);return ()=>clearTimeout(c)},[]);let d=Object.entries(e).filter(([c])=>!Qs.includes(c)&&a?.collections?.[c]?.read!==false);return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsxRuntime.jsx(Lt,{title:o("dashboard.welcome",{defaultValue:"Welcome back, {{name}}",name:r?.email?.split("@")[0]||"Admin"}),description:o("dashboard.description",{defaultValue:"Everything looks great in your command center today."}),action:d.length>0&&a?.collections?.[d[0]?.[0]]?.create!==false?{label:o("actions.newDocument",{defaultValue:"New Document"}),onClick:()=>t("create",d[0]?.[0]),icon:Ql.Plus}:void 0}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:o("dashboard.totalContent",{defaultValue:"Total Content"}),value:n.totalDocs,icon:Ql.FileText,color:"text-blue-500"},{label:o("dashboard.mediaAssets",{defaultValue:"Media Assets"}),value:n.totalMedia,icon:Ql.Image,color:"text-purple-500"},{label:o("dashboard.activeUsers",{defaultValue:"Active Users"}),value:n.totalUsers,icon:Ql.Users,color:"text-green-500"},{label:o("dashboard.systemHealth",{defaultValue:"System Health"}),value:"100%",icon:Ql.Activity,color:"text-amber-500"}].map((c,u)=>jsxRuntime.jsxs("div",{className:"surface-tile p-6 flex items-center justify-between group hover:border-[var(--kyro-primary)] transition-all duration-500 cursor-default",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:c.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:i?jsxRuntime.jsx(jt,{variant:"text",className:"w-16"}):c.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${c.color}`,children:jsxRuntime.jsx(c.icon,{className:"w-6 h-6"})})]},u))}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxRuntime.jsxs("div",{className:"space-y-8 min-w-0",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Ql.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),o("dashboard.contentGrowth",{defaultValue:"Content Growth"})]}),jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:o("dashboard.contentGrowthDesc",{defaultValue:"Snapshot of document velocity over the last 7 days"})}),jsxRuntime.jsxs("div",{className:"h-48 w-full relative mb-12",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1000 200",preserveAspectRatio:"none",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"chartGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"var(--kyro-primary)",stopOpacity:"0.3"}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"var(--kyro-primary)",stopOpacity:"0"})]})}),jsxRuntime.jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60 L1000,200 L0,200 Z",fill:"url(#chartGradient)",className:"animate-pulse duration-[4s]"}),jsxRuntime.jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60",fill:"none",stroke:"var(--kyro-primary)",strokeWidth:"4",strokeLinecap:"round",vectorEffect:"non-scaling-stroke",className:"filter drop-shadow-[0_0_8px_var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-4 text-[10px] font-bold opacity-30 tracking-widest ",children:[jsxRuntime.jsx("span",{children:o("days.mon",{defaultValue:"Mon"})}),jsxRuntime.jsx("span",{children:o("days.tue",{defaultValue:"Tue"})}),jsxRuntime.jsx("span",{children:o("days.wed",{defaultValue:"Wed"})}),jsxRuntime.jsx("span",{children:o("days.thu",{defaultValue:"Thu"})}),jsxRuntime.jsx("span",{children:o("days.fri",{defaultValue:"Fri"})}),jsxRuntime.jsx("span",{children:o("days.sat",{defaultValue:"Sat"})}),jsxRuntime.jsx("span",{children:o("days.sun",{defaultValue:"Sun"})})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:d.map(([c,u])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",c),className:"p-6 rounded-2xl border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-bg-secondary)] hover:bg-[var(--kyro-surface)] transition-all cursor-pointer group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:u.label||c}),jsxRuntime.jsx(Ql.ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsxRuntime.jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:u.admin?.description||`Manage ${c} content.`})]},c))})]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-4",children:jsxRuntime.jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-5 h-5"}),o("dashboard.quickLinks",{defaultValue:"Quick Links"})]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[d.filter(([c])=>a?.collections?.[c]?.create!==false).map(([c])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",c),className:"w-full flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group/btn",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:o("dashboard.newAction",{defaultValue:"New {{item}}",item:e[c]?.singularLabel||e[c]?.label||c})}),jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},c)),d.every(([c])=>a?.collections?.[c]?.create===false)&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:o("dashboard.noCollections",{defaultValue:"No collections available for creation."})})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-8 bg-[#0f172a] text-white border-none shadow-2xl shadow-blue-500/10 overflow-hidden relative group cursor-pointer",children:[jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("h3",{className:"text-2xl font-bold tracking-tighter mb-2",children:o("dashboard.mediaLibrary",{defaultValue:"Media Library"})}),jsxRuntime.jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:o("dashboard.mediaLibraryDesc",{defaultValue:"Manage high-fidelity assets with our liquid masonry gallery."})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-bold text-xs tracking-widest text-blue-400",children:[o("dashboard.openAssets",{defaultValue:"Open Assets"})," ",jsxRuntime.jsx(Ql.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(Ql.Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-5 h-5 opacity-40"}),o("dashboard.recentActivity",{defaultValue:"Recent Activity"})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:n.recentActivity.map(c=>jsxRuntime.jsxs("div",{className:"flex gap-4 group",children:[jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-bg-secondary)] flex items-center justify-center border border-[var(--kyro-border)] group-hover:bg-[var(--kyro-primary)] transition-colors",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold",children:c.user[0]})})}),jsxRuntime.jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxRuntime.jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsxRuntime.jsx("span",{className:"font-bold",children:c.user})," ",c.type==="create"?"created":c.type==="edit"?"edited":c.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',c.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:c.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:c.time})]})]},c.id))}),jsxRuntime.jsx("button",{type:"button",className:"w-full mt-6 py-3 text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors border-t border-[var(--kyro-border)] pt-6",children:o("dashboard.viewAuditLogs",{defaultValue:"View Audit Logs"})})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Activity,{className:"w-5 h-5 opacity-40"}),o("dashboard.systemStatus",{defaultValue:"System Status"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:[{label:o("dashboard.cloudApi",{defaultValue:"Cloud API"}),status:o("dashboard.statusOptimal",{defaultValue:"Optimal"}),pulse:"bg-green-500"},{label:o("dashboard.dbNode",{defaultValue:"Database Node"}),status:o("dashboard.statusHealthy",{defaultValue:"Healthy"}),pulse:"bg-green-500"},{label:o("dashboard.mediaCdn",{defaultValue:"Media CDN"}),status:o("dashboard.statusActive",{defaultValue:"Active"}),pulse:"bg-blue-500"},{label:o("dashboard.authService",{defaultValue:"Auth Service"}),status:o("dashboard.statusSecure",{defaultValue:"Secure"}),pulse:"bg-green-500"}].map((c,u)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:c.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:c.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${c.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},u))})]})]})]})]})}function Cc(){let{t:e}=reactI18next.useTranslation(),[t,r]=Ta.useState([]),[o,a]=Ta.useState(true),[n,s]=Ta.useState(""),[i,l]=Ta.useState(false),[d,c]=Ta.useState({name:"",email:"",password:"",role:"customer"}),[u,m]=Ta.useState(""),[v,x]=Ta.useState(false),{confirm:g,alert:f}=yt();Ta.useEffect(()=>{b();},[]);let b=async()=>{try{a(!0);let k=await Ee("/api/users");r(k.docs||[]);}catch(k){console.error("Failed to load users:",k);}finally{a(false);}},p=k=>{let y=!k.locked;g({title:y?"Lock User Account?":"Unlock User Account?",message:y?`Are you sure you want to lock ${k.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${k.email}?`,variant:y?"danger":"success",onConfirm:async()=>{try{await Yt(`/api/users/${k.id}`,{locked:y}),r(w=>w.map(D=>D.id===k.id?{...D,locked:y}:D)),V.success(y?`Account locked: ${k.email}`:`Account restored: ${k.email}`);}catch(w){console.error("Failed to toggle user lock:",w),V.error("Failed to update account status");}}});},h=k=>{g({title:"Destroy User Account",message:`You are about to permanently delete ${k.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await At(`/api/users/${k.id}`),r(y=>y.filter(w=>w.id!==k.id)),V.success(`Identity purged: ${k.email}`);}catch(y){console.error("Failed to delete user:",y),V.error("Failed to delete user");}}});},A=async()=>{if(!d.email.trim()||!d.password.trim()){m("Email and password are required");return}x(true),m("");try{await dt("/api/users",{name:d.name.trim()||void 0,email:d.email.trim(),password:d.password,role:d.role}),l(!1),c({name:"",email:"",password:"",role:"customer"}),V.success("User created successfully"),b();}catch(k){let y=k instanceof Error?k.message:"Failed to create user";m(y),V.error(y);}finally{x(false);}},$=["super_admin","admin","editor","author","customer","guest"],T=t.filter(k=>k.email.toLowerCase().includes(n.toLowerCase())||k.name?.toLowerCase().includes(n.toLowerCase()));return jsxRuntime.jsxs("div",{className:"w-full space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-700 px-4 md:px-8 pb-12",children:[jsxRuntime.jsx(Lt,{title:e("tooltips.identityAccess",{defaultValue:"Identity & Access"}),description:"Manage the core administrative team and security permissions.",icon:Ql.Users,action:{label:"New User",onClick:()=>{c({name:"",email:"",password:"",role:"customer"}),m(""),l(true);},icon:Ql.UserPlus}}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 group",children:[jsxRuntime.jsx(Ql.Search,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-secondary)] opacity-40 group-focus-within:opacity-100 transition-opacity"}),jsxRuntime.jsx("input",{type:"text",placeholder:e("fields.searchByIdentityOr",{defaultValue:"Search by identity or email..."}),value:n,onChange:k=>s(k.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest bg-[var(--kyro-surface)] shadow-sm rounded-lg border border-[var(--kyro-border)]",children:"ALL"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"ADMINS"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"LOCKED"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[9px] tracking-[0.2em] uppercase border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-64",children:"Member Identity"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Administrative Role"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Security Status"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Last Activity"}),jsxRuntime.jsx("th",{className:"px-6 py-4 w-32 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:o?Array.from({length:6}).map((k,y)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},y)):T.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-20 text-center",children:jsxRuntime.jsx("p",{className:"text-xs font-bold opacity-30 tracking-widest uppercase italic",children:"No identity matches found"})})}):T.map(k=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${k.locked?"opacity-50 grayscale":""}`,children:[jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(wf,{user:k}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs font-bold text-[var(--kyro-text-primary)] truncate",children:k.name||k.email.split("@")[0]}),k.tenantId&&jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:k.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:k.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:k.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(Rt,{variant:k.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:k.locked?"Restricted":"Authorized"})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3 h-3"}),k.lastLogin?new Date(k.lastLogin).toLocaleDateString():"Never"]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsxRuntime.jsx("button",{onClick:()=>p(k),className:`p-1.5 rounded-lg border transition-all ${k.locked?"bg-green-500/10 text-green-500 border-green-500/20 hover:bg-green-500/20":"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20"}`,title:k.locked?"Restore Access":"Restrict Access",children:k.locked?jsxRuntime.jsx(Ql.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Ql.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>h(k),className:"p-1.5 rounded-lg border border-red-500/20 bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-all",title:e("tooltips.deleteUser",{defaultValue:"Delete User"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5"})})]})})]},k.id))})]})}),jsxRuntime.jsxs(St,{open:i,onClose:()=>l(false),title:e("tooltips.createUser",{defaultValue:"Create User"}),size:"lg",children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Name (optional)"}),jsxRuntime.jsx("input",{type:"text",value:d.name,onChange:k=>c({...d,name:k.target.value}),placeholder:e("fields.johnDoe",{defaultValue:"John Doe"}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Email Address"}),jsxRuntime.jsx("input",{type:"email",value:d.email,onChange:k=>c({...d,email:k.target.value}),placeholder:"user@example.com",required:true,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Password"}),jsxRuntime.jsx("input",{type:"password",value:d.password,onChange:k=>c({...d,password:k.target.value}),placeholder:e("fields.minimum12Characters",{defaultValue:"Minimum 12 characters"}),required:true,minLength:12,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Role"}),jsxRuntime.jsx("select",{value:d.role,onChange:k=>c({...d,role:k.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]",children:$.map(k=>jsxRuntime.jsx("option",{value:k,children:k},k))})]}),u&&jsxRuntime.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl flex items-center gap-2 text-red-500 text-xs font-bold",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-4 h-4"}),u]})]})}),jsxRuntime.jsxs(Mr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>l(false),className:"px-6 py-2.5 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:A,disabled:v,className:"kyro-btn kyro-btn-primary px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/10 disabled:opacity-50",children:v?"Creating...":"Create User"})]})]})]})}function wf({user:e}){let[t,r]=Ta.useState(null);return Ta.useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Ee(`/api/media/${o}`).then(a=>r(a?.thumbnailUrl||a?.url||null)).catch(()=>r(null));},[e.avatar]),t?jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border border-[var(--kyro-border)] flex-shrink-0",children:jsxRuntime.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"})}):jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] flex items-center justify-center text-xs font-bold text-[var(--kyro-primary)] flex-shrink-0",children:e.name?e.name[0]:e.email[0].toUpperCase()})}function Sc(){let{t:e}=reactI18next.useTranslation(),[t,r]=Ta.useState("Kyro CMS"),[o,a]=Ta.useState("Command Center"),[n,s]=Ta.useState("#6366f1"),[i,l]=Ta.useState("Welcome back to your Command Center."),[d,c]=Ta.useState(false),[u,m]=Ta.useState(false);Ta.useEffect(()=>{(async()=>{try{let f=await Ee("/api/globals/site-settings"),b=f.data||f;b&&Object.keys(b).length>0&&(b.siteName&&r(b.siteName),b.adminTitle&&a(b.adminTitle),b.primaryColor&&s(b.primaryColor),b.dashboardGreeting&&l(b.dashboardGreeting));}catch(f){console.error("Failed to load branding:",f);}})();},[]);let v=async()=>{c(true);try{await Yt("/api/globals/site-settings",{siteName:t,adminTitle:o,primaryColor:n,dashboardGreeting:i}),m(!0),V.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",n),setTimeout(()=>window.location.reload(),800);}catch(g){V.error("Failed to save branding"),console.error(g);}finally{c(false);}},x=[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}];return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 pt-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:["Branding ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Hub"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-1 font-medium opacity-60",children:"Customize the identity and aesthetic of your administrative ecosystem."})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:jsxRuntime.jsxs("button",{type:"button",onClick:v,disabled:d,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${u?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[d?jsxRuntime.jsx(Ql.RefreshCcw,{className:"w-4 h-4 animate-spin"}):u?jsxRuntime.jsx(Ql.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(Ql.Save,{className:"w-4 h-4"}),d?"Saving...":u?"Identity Updated":"Publish Branding"]})})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Ql.Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsxRuntime.jsx("input",{type:"text",value:t,onChange:g=>r(g.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Acme Corp CMS"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Admin Dashboard Title"}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:g=>a(g.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Command Center"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"System Greeting"}),jsxRuntime.jsx("textarea",{value:i,onChange:g=>l(g.target.value),rows:3,className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all resize-none",placeholder:e("fields.greetingTextForThe",{defaultValue:"Greeting text for the dashboard..."})})]})]})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Ql.Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsxRuntime.jsx("div",{className:"grid grid-cols-6 gap-3",children:x.map(g=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(g.hex),className:`aspect-square rounded-xl transition-all border-4 ${n===g.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:g.hex},title:g.name},g.name))})]}),jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.jsxs("div",{className:"w-20 h-20 rounded-2xl bg-[var(--kyro-bg-secondary)] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-primary)] hover:text-[var(--kyro-primary)] cursor-pointer transition-all",children:[jsxRuntime.jsx(Ql.Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsxRuntime.jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsxRuntime.jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsxRuntime.jsx(Ql.Sparkles,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxRuntime.jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-2 bg-[var(--kyro-bg-secondary)] rounded-full border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[o," Online"]})]}),jsxRuntime.jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",t,"."]}),jsxRuntime.jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:i})]}),jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
100
100
|
:root {
|
|
101
|
-
--kyro-primary-temp: ${
|
|
101
|
+
--kyro-primary-temp: ${n};
|
|
102
102
|
}
|
|
103
103
|
.preview-btn {
|
|
104
104
|
background-color: var(--kyro-primary-temp);
|
|
105
105
|
}
|
|
106
|
-
`}})]})]})]})}var $y=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Pc({collections:e}){let[t,r]=Da.useState([]),[o,a]=Da.useState(false),[n,s]=Da.useState(null),[l,i]=Da.useState(""),[c,d]=Da.useState(null),[m,x]=Da.useState(false),{confirm:b,alert:k}=ft(),[f,g]=Da.useState(false),[p,u]=Da.useState(""),v=async()=>{try{let y=await De("/api/keys");r(y);}catch(y){console.error(y);}};Da.useEffect(()=>{v();},[]);let R=async()=>{u(""),g(true);},P=async()=>{if(p.trim())try{await dt("/api/keys",{name:p}),v(),g(!1),u(""),U.success("API key generated");}catch(y){console.error(y),U.error("Failed to generate API key");}},h=y=>{b({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 Tt(`/api/keys/${y}`),v(),U.success("API key revoked");}catch(S){console.error(S),U.error("Failed to revoke API key");}}});},w=async()=>{if(l){x(true);try{let S=await(await fetch(Je(`/api/${l}`))).json();d(S);}catch{d({error:"Failed to fetch. Ensure the endpoint exists."});}finally{x(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($t,{title:"Developer Center",description:"Provision access keys and explore the headless API ecosystem.",icon:ql.CodeXml,actions:[{label:"Generate Key",onClick:R,icon:ql.Key}]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxRuntime.jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children: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(ql.Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):t.map(y=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-3xl p-6 hover:border-[var(--kyro-primary)]/50 transition-all duration-300",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsxRuntime.jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsxRuntime.jsx(ql.Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:y.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===y.id?y.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===y.id?null:y.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:n===y.id?jsxRuntime.jsx(ql.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(ql.Eye,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",onClick:()=>{navigator.clipboard.writeText(y.key),U.success("API key copied to clipboard");},children:jsxRuntime.jsx(ql.Copy,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Issued:"}),jsxRuntime.jsx("span",{children:new Date(y.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:()=>h(y.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(ql.Trash2,{className:"w-5 h-5"})})]})},y.id))})]}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/80 p-8 group shadow-2xl shadow-[var(--kyro-primary)]/20",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.1] pointer-events-none group-hover:scale-110 transition-transform duration-700",children:jsxRuntime.jsx(ql.Terminal,{className:"w-48 h-48 rotate-12"})}),jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsxRuntime.jsx(ql.Terminal,{className:"w-6 h-6 text-white"})}),jsxRuntime.jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsxRuntime.jsx("p",{className:"text-white/80 text-sm font-medium leading-relaxed mb-8",children:"Kyro CMS is built for high-performance content delivery. Use these endpoints to power your headless frontends."}),jsxRuntime.jsxs("button",{type:"button",className:"w-full py-4 bg-white text-[var(--kyro-primary)] rounded-[1.2rem] font-bold text-xs uppercase tracking-widest hover:shadow-xl transition-all flex items-center justify-center gap-2 active:scale-[0.98]",children:["Full API Documentation",jsxRuntime.jsx(ql.ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxRuntime.jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsxRuntime.jsx(It,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-[var(--kyro-primary)]/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsxRuntime.jsx(ql.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://api.kyro.io/v1")})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsxRuntime.jsx(It,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-amber-500/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsxRuntime.jsx(ql.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://preview.kyro.io/v1")})]})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"xl:col-span-3 rounded-[3rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-10 space-y-10 overflow-hidden relative",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsxRuntime.jsx(ql.CirclePlay,{className:"w-96 h-96"})}),jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxRuntime.jsxs("div",{className:"max-w-xl",children:[jsxRuntime.jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(ql.CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] text-sm font-medium opacity-60 leading-relaxed",children:"Test your collection endpoints and analyze live response payloads. Enter a collection slug to fetch its latest documents."})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 flex-1 lg:max-w-2xl bg-[var(--kyro-bg)] p-2 rounded-[2rem] border border-[var(--kyro-border)] shadow-2xl",children:[jsxRuntime.jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",$y,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:y=>i(y.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:w,disabled:m||!l,className:"kyro-btn kyro-btn-primary px-8 py-4 rounded-[1.5rem] font-bold text-sm shadow-xl disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] transition-all flex items-center gap-3 shrink-0",children:[m?jsxRuntime.jsx(ql.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(ql.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),c?jsxRuntime.jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsxRuntime.jsx(It,{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(Ly__default.default,{value:JSON.stringify(c,null,2),height:"450px",theme:codemirrorThemeAura.aura,extensions:[langJson.json()],editable:false,className:"text-sm"})]})]}):jsxRuntime.jsxs("div",{className:"h-80 rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center bg-[var(--kyro-surface-accent)]/20 transition-all duration-700",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 bg-[var(--kyro-surface)] rounded-3xl flex items-center justify-center shadow-lg border border-[var(--kyro-border)] mb-6 opacity-20",children:jsxRuntime.jsx(ql.CodeXml,{className:"w-10 h-10"})}),jsxRuntime.jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxRuntime.jsxs(St,{open:f,onClose:()=>g(false),title:"Generate Access Token",size:"lg",children:[jsxRuntime.jsx(Sr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 leading-relaxed",children:"Define a name for this API key to identify its integration context. Keys are encrypted at rest and should be treated with extreme caution."}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsxRuntime.jsx("input",{type:"text",value:p,onChange:y=>u(y.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:y=>y.key==="Enter"&&P()})]})]})}),jsxRuntime.jsxs(Er,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>g(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 Fc(e){let[t,r]=Da.useState([]),[o,a]=Da.useState(false),[n,s]=Da.useState(null),[l,i]=Da.useState(false),{confirm:c}=ft(),d=Da.useCallback(async()=>{a(true),s(null);try{let k=await De(e.endpoint),f=Array.isArray(k)?k:k.docs||[],g=e.transformLoad?e.transformLoad(f):f;r(g),e.onSuccess?.("load",g);}catch(k){let f=k instanceof Error?k.message:"Failed to load resources";s(f),e.onError?.("load",k);}finally{a(false);}},[e.endpoint,e.transformLoad]);Da.useEffect(()=>{d();},[d]);let m=Da.useCallback((k,f="item")=>{c({title:`Delete ${f}`,message:`Are you sure you want to delete this ${f.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Tt(`${e.endpoint}/${k}`),r(g=>g.filter(p=>p.id!==k)),e.onSuccess?.("delete",k),U.success(`${f} deleted`);}catch(g){let p=g instanceof Error?g.message:`Failed to delete ${f}`;U.error(p),e.onError?.("delete",g);}}});},[e.endpoint,c]),x=Da.useCallback(async k=>{s(null);try{let f=await dt(e.endpoint,k);return r(g=>[f,...g]),i(!1),e.onSuccess?.("create",f),f}catch(f){let g=f instanceof Error?f.message:"Failed to create resource";throw s(g),e.onError?.("create",f),f}},[e.endpoint]),b=Da.useCallback(async(k,f)=>{s(null);try{let g=await Yt(`${e.endpoint}/${k}`,f);return r(p=>p.map(u=>u.id===k?g:u)),e.onSuccess?.("update",g),g}catch(g){let p=g instanceof Error?g.message:"Failed to update resource";throw s(p),e.onError?.("update",g),g}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:d,remove:m,create:x,update:b,isCreateModalOpen:l,setIsCreateModalOpen:i}}var zy={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function Dc(){let{items:e,loading:t,create:r,remove:o,update:a,isCreateModalOpen:n,setIsCreateModalOpen:s}=Fc({endpoint:"/api/webhooks"}),{confirm:l}=ft(),[i,c]=Da.useState(false),[d,m]=Da.useState(false),[x,b]=Da.useState(null),[k,f]=Da.useState(null),[g,p]=Da.useState({}),[u,v]=Da.useState(true),[R,P]=Da.useState("action"),[h,w]=Da.useState("generic"),[y,S]=Da.useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[O,L]=Da.useState(""),[K,C]=Da.useState(false),[G,z]=Da.useState(null),[j,_]=Da.useState([]),[se,te]=Da.useState(false);Da.useEffect(()=>{J();},[]);let J=async()=>{try{let A=await De("/api/webhooks/actions");p(A.actions);}catch(A){console.error("Failed to load webhook actions:",A);}finally{v(false);}},de=()=>{P("action"),w("generic"),S({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),L("");},ve=A=>{w(A),S($=>({...$,action:A,config:{}})),P("config");},Te=(A,$)=>{S(Z=>({...Z,config:{...Z.config,[A]:$}}));},Ve=async()=>{if(!y.name.trim()){L("Name is required");return}if(h==="generic"&&!y.url.trim()){L("URL is required for custom webhooks");return}let A=g[h];if(A){for(let $ of A.configFields)if($.required&&!y.config[$.name]?.trim()){L(`${$.label} is required`);return}}try{await r(y),de(),U.success(`Webhook created: ${y.name}`);}catch($){let Z=$.message||"Failed to create webhook";L(Z),U.error(Z);}},M=async A=>{f(A),b(null),c(true);try{let $=await dt(`/api/webhooks/${A}/test`);b({success:!0,message:$.message||"Webhook triggered successfully"}),U.success("Test delivered successfully");}catch{b({success:false,message:"Failed to trigger webhook"});}},E=async(A,$)=>{try{let Z=$==="active"?"paused":"active";await a(A,{status:Z}),U.success(Z==="active"?"Webhook activated":"Webhook paused");}catch(Z){console.error(Z),U.error("Failed to toggle webhook status");}},ne=async A=>{z(A),C(true),te(true);try{let $=await De(`/api/webhooks/${A}/history`);_($.docs||[]);}catch($){console.error("Failed to load history:",$),U.error("Failed to load delivery history");}finally{te(false);}},ue=[{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"}],$e=A=>g[A||"generic"]?.label||"Custom URL";return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx($t,{title:"Webhooks",description:"Get notified when your content changes.",icon:ql.Webhook,actions:[{label:"New webhook",onClick:()=>{de(),s(true);},icon:ql.Plus},{label:"Guide",onClick:()=>m(true),icon:ql.Info,variant:"outline"}]}),jsxRuntime.jsx("div",{className:"relative overflow-hidden rounded-2xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-3 bg-[var(--kyro-primary)]/10 rounded-xl",children:jsxRuntime.jsx(ql.Zap,{className:"w-6 h-6 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("div",{className:"flex-1 text-center md:text-left",children:jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Receive instant HTTP notifications when events happen in your CMS. Choose a platform preset or point to any custom endpoint."})})]})}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium text-[var(--kyro-text-secondary)]",children:"Endpoints"})]}),jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:[e.length," hook",e.length!==1&&"s"]})]}),t?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 opacity-50 text-sm text-[var(--kyro-text-secondary)]",children:"Loading webhooks..."}):e.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-2xl border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-5 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(ql.Webhook,{className:"w-8 h-8 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold mb-2",children:"No webhooks yet"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-6 max-w-sm mx-auto",children:"Create a webhook to get notified when your content changes."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{de(),s(true);},className:"kyro-btn kyro-btn-primary inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-medium",children:[jsxRuntime.jsx(ql.Plus,{className:"w-4 h-4"}),"Create webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:e.map(A=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-2xl p-5 hover:border-[var(--kyro-primary)]/30 transition-all duration-200",children:jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-5 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[jsxRuntime.jsx("div",{className:"p-2 bg-[var(--kyro-surface-accent)] rounded-lg",children:jsxRuntime.jsx(ql.Webhook,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:A.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${A.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-medium ${A.status==="active"?"text-green-500":"text-amber-500"}`,children:A.status}),jsxRuntime.jsx(It,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:$e(A.action)})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-1",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs text-[var(--kyro-text-secondary)] opacity-60 truncate max-w-[200px]",title:A.url,children:A.url||`${$e(A.action)} webhook`})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[A.events.slice(0,3).map($=>jsxRuntime.jsx(It,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:$},$)),A.events.length>3&&jsxRuntime.jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",A.events.length-3]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(ql.Clock,{className:"w-3 h-3"}),A.lastTriggered?`Last triggered ${new Date(A.lastTriggered).toLocaleDateString()}`:"Never triggered"]}),A.lastError&&jsxRuntime.jsxs("div",{className:"text-[10px] text-red-500/80 flex items-center gap-1.5 mt-1",children:[jsxRuntime.jsx(ql.XCircle,{className:"w-3 h-3"}),jsxRuntime.jsx("span",{className:"truncate max-w-[150px]",title:A.lastError,children:A.lastError})]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 lg:opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>ne(A.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:"View delivery history",children:[jsxRuntime.jsx(ql.Activity,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium hidden sm:inline",children:"History"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>M(A.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:"Send test request",children:[jsxRuntime.jsx(ql.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium",children:"Test"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>E(A.id,A.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${A.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:A.status==="active"?"Pause":"Activate",children:A.status==="active"?jsxRuntime.jsx(ql.Pause,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(ql.Play,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(A.id,"Webhook"),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-red-500/30 hover:bg-red-500/5 transition-colors",title:"Delete",children:jsxRuntime.jsx(ql.Trash2,{className:"w-3.5 h-3.5 text-red-500/50 hover:text-red-500"})})]})]})},A.id))})]}),jsxRuntime.jsx(St,{open:n&&R==="action",onClose:()=>s(false),title:"New webhook",children:jsxRuntime.jsx(Sr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:u?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(ql.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(g).map(([A,$])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>ve(A),className:"flex flex-col items-start p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/40 transition-all text-left group",children:[jsxRuntime.jsx("div",{className:"text-lg mb-2",children:zy[A]||"\u{1F517}"}),jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-0.5 group-hover:text-[var(--kyro-primary)] transition-colors",children:$.label}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] opacity-50 leading-relaxed",children:$.description}),$.envVars.length>0&&jsxRuntime.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:$.envVars.map(Z=>jsxRuntime.jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:Z},Z))})]},A))})})})}),jsxRuntime.jsxs(St,{open:n&&R==="config",onClose:()=>s(false),title:g[h]?.label||"Webhook",children:[jsxRuntime.jsx(Sr,{children:jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-5",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Name"}),jsxRuntime.jsx("input",{type:"text",value:y.name,onChange:A=>S({...y,name:A.target.value}),placeholder:"e.g., Deploy on content update",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),h==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"URL"}),jsxRuntime.jsx("input",{type:"url",value:y.url,onChange:A=>S({...y,url:A.target.value}),placeholder:"https://your-server.com/webhook",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),h!=="generic"&&g[h]?.configFields.map(A=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[A.label," ",A.required&&jsxRuntime.jsx("span",{className:"text-red-500",children:"*"})]}),jsxRuntime.jsx("input",{type:"text",value:y.config[A.name]||"",onChange:$=>Te(A.name,$.target.value),placeholder:A.placeholder,className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]},A.name)),h==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Signing secret"}),jsxRuntime.jsx("input",{type:"text",value:y.secret,onChange:A=>S({...y,secret:A.target.value}),placeholder:"Optional",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]})]}),h!=="generic"&&g[h]?.envVars.length>0&&jsxRuntime.jsxs("div",{className:"p-3 rounded-lg bg-amber-500/5 border border-amber-500/15",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[jsxRuntime.jsx(ql.TriangleAlert,{className:"w-3.5 h-3.5 text-amber-500"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-amber-600",children:"Environment variables required"})]}),jsxRuntime.jsxs("p",{className:"text-[11px] text-amber-600/60 mb-2",children:["Add these to your ",jsxRuntime.jsx("code",{className:"font-mono bg-amber-500/10 px-1 py-0.5 rounded text-[10px]",children:".env"})," file:"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:g[h].envVars.map(A=>jsxRuntime.jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[A,"=..."]},A))})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium text-[var(--kyro-text-secondary)]",children:"Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ue.map(A=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let $=y.events.includes(A.value)?y.events.filter(Z=>Z!==A.value):[...y.events,A.value];S({...y,events:$});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${y.events.includes(A.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/20"}`,children:[jsxRuntime.jsx("div",{className:`w-3.5 h-3.5 rounded flex items-center justify-center border transition-all ${y.events.includes(A.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:y.events.includes(A.value)&&jsxRuntime.jsx(ql.CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-medium",children:A.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-40",children:A.description})]})]},A.value))})]})]}),O&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-red-500 text-xs",children:[jsxRuntime.jsx(ql.TriangleAlert,{className:"w-3.5 h-3.5"}),O]})]})}),jsxRuntime.jsxs(Er,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>P("action"),className:"px-4 py-2 rounded-lg text-sm font-medium border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:Ve,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg text-sm font-medium",children:"Create webhook"})]})]}),jsxRuntime.jsxs(St,{open:i,onClose:()=>c(false),title:"Test webhook",children:[jsxRuntime.jsx(Sr,{children:jsxRuntime.jsx("div",{className:"p-6 rounded-xl bg-[var(--kyro-surface)] border border-[var(--kyro-border)] text-center",children:x?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${x.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:x.success?jsxRuntime.jsx(ql.CircleCheck,{className:"w-6 h-6"}):jsxRuntime.jsx(ql.TriangleAlert,{className:"w-6 h-6"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:x.success?"Delivered":"Failed"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:x.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-4 py-4",children:[jsxRuntime.jsx(ql.RefreshCw,{className:"w-8 h-8 text-[var(--kyro-primary)] animate-spin mx-auto opacity-40"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:"Sending test payload"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:"Dispatching..."})]})]})})}),jsxRuntime.jsx(Er,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>c(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]}),jsxRuntime.jsxs(St,{open:d,onClose:()=>m(false),title:"How webhooks work",children:[jsxRuntime.jsx(Sr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(ql.ExternalLink,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Request format"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["When an event triggers, Kyro sends a ",jsxRuntime.jsx("span",{className:"font-medium",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(ql.Shield,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Signature verification"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["If a secret is set, each request includes an ",jsxRuntime.jsx("span",{className:"font-mono text-[10px] bg-[var(--kyro-surface-accent)] px-1 py-0.5 rounded",children:"X-Webhook-Signature"})," header with an HMAC-SHA256 signature. Verify it in production."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] opacity-50",children:"Example payload"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg)] rounded-md border border-[var(--kyro-border)] p-4 font-mono text-xs overflow-hidden",children:jsxRuntime.jsxs("div",{className:"space-y-0.5 text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("div",{children:"{"}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"posts"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-06-28T12:00:00Z"'})]}),jsxRuntime.jsx("div",{children:"}"})]})})]})]})}),jsxRuntime.jsx(Er,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"kyro-btn kyro-btn-primary w-full py-2.5 rounded-lg text-sm font-medium",children:"Got it"})})]}),jsxRuntime.jsxs(St,{open:K,onClose:()=>C(false),title:"Delivery History",children:[jsxRuntime.jsx(Sr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:se?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(ql.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):j.length===0?jsxRuntime.jsx("div",{className:"text-center p-8 text-[var(--kyro-text-secondary)] opacity-60 text-sm",children:"No delivery history available for this webhook."}):jsxRuntime.jsx("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:j.map(A=>jsxRuntime.jsxs("div",{className:"p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-sm",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[A.status==="success"?jsxRuntime.jsx(ql.CircleCheck,{className:"w-4 h-4 text-green-500"}):jsxRuntime.jsx(ql.XCircle,{className:"w-4 h-4 text-red-500"}),jsxRuntime.jsx("span",{className:"font-medium",children:A.event})]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:new Date(A.createdAt).toLocaleString()})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs text-[var(--kyro-text-secondary)] mb-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Status: "}),jsxRuntime.jsx("span",{className:`font-medium ${A.status==="success"?"text-green-500":"text-red-500"}`,children:A.responseStatus||A.status})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Duration: "}),A.duration?`${A.duration}ms`:"-"]})]}),A.error&&jsxRuntime.jsx("div",{className:"text-xs text-red-500 bg-red-500/5 p-2 rounded border border-red-500/10 font-mono break-all mb-2",children:A.error}),A.responseBody&&jsxRuntime.jsx("div",{className:"text-[10px] font-mono bg-[var(--kyro-bg)] p-2 rounded border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] opacity-70 max-h-24 overflow-y-auto break-all",children:A.responseBody})]},A.id))})})}),jsxRuntime.jsx(Er,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>C(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]})]})}function Lc({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{user:n,permissions:s}=Kr(),[l,i]=Da.useState(""),[c,d]=Da.useState(0),[m,x]=Da.useState(false),[b,k]=Da.useState([]),f=Da.useRef(null),g=Da.useRef(null);Da.useEffect(()=>{e&&(i(""),d(0),k([]),x(false),setTimeout(()=>f.current?.focus(),100));},[e]);let p=Da.useCallback(async C=>{if(!C||C.length<2){k([]);return}x(true);try{let z=await(await fetch(Je(`/api/search?q=${encodeURIComponent(C)}&limit=15`))).json();z.results&&k(z.results);}catch(G){console.error("Search error:",G),k([]);}finally{x(false);}},[]);if(Da.useEffect(()=>(g.current&&clearTimeout(g.current),l.length>=2?g.current=setTimeout(()=>p(l),300):k([]),()=>{g.current&&clearTimeout(g.current);}),[l,p]),!e)return null;let u=Object.entries(r).filter(([C])=>s?.collections?.[C]?.read!==false).map(([C,G])=>({id:`col-${C}`,label:G.label||C,type:"collection",slug:C,icon:ql.FileText})),v=Object.entries(o).filter(([C])=>s?.globals?.[C]?.read!==false).map(([C,G])=>({id:`global-${C}`,label:G.label||C,type:"global",slug:C,icon:ql.Settings})),R=typeof document<"u"&&document.documentElement.classList.contains("dark"),P=n?.role==="admin",h=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:ql.Image,visible:s?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:ql.Clock,visible:P},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:ql.File,visible:P},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:ql.Shield,visible:P},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:ql.Database,visible:P},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:ql.Hexagon,visible:P},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:ql.Network,visible:P},{id:"action-theme",label:R?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:R?ql.Sun:ql.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:ql.LogOut,visible:true}].filter(C=>C.visible),w=b.map((C,G)=>({id:`doc-${C.collection}-${C.id}`,label:C.title,type:"document",collection:C.collection,label2:C.label,docId:C.id,icon:ql.File,doc:C.doc})),y=l.length>=2?[...h,...u,...v,...w]:[...h,...u,...v],S=l===""?y:y.filter(C=>C.label.toLowerCase().includes(l.toLowerCase())),O=C=>{if(C.key==="ArrowDown")C.preventDefault(),d(G=>(G+1)%S.length);else if(C.key==="ArrowUp")C.preventDefault(),d(G=>(G-1+S.length)%S.length);else if(C.key==="Enter"){let G=S[c];G&&L(G);}else C.key==="Escape"&&t();},L=C=>{C.type==="collection"?C.slug==="users"?a(C.slug,C.slug):a("list",C.slug):C.type==="global"?a("settings",C.slug):C.type==="document"?C.collection==="users"?a("users","users",C.docId):a("edit",C.collection,C.docId):C.type==="action"&&(C.view==="users"?a("users","users"):C.view==="media"?a("media","media"):a(C.view,C.view)),t();},K=()=>l===""?"Quick Actions & Collections":b.length>0?"Documents":m?"Searching...":"Search Results";return jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxRuntime.jsxs("div",{className:"relative w-full max-w-2xl bg-[var(--kyro-surface)] rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 fade-in duration-300 ring-1 ring-white/10 border border-white/5",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[m?jsxRuntime.jsx(ql.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(ql.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:f,placeholder:"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:C=>i(C.target.value),onKeyDown:O}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-2 py-1 bg-[var(--kyro-bg-secondary)] rounded-lg border border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:S.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:K()}),S.map((C,G)=>jsxRuntime.jsxs("div",{onClick:()=>L(C),onMouseEnter:()=>d(G),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${G===c?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xl shadow-[var(--kyro-primary)]":"hover:bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:`p-2 rounded-xl ${G===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(C.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:C.label}),C.type==="document"&&C.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${G===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:C.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${G===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:C.type}),G===c&&jsxRuntime.jsx(ql.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},C.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 Mc(){let{modal:e,closeModal:t}=ft(),[r,o]=Da.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(js,{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 Vy({config:e,theme:t="light",onThemeChange:r}){let[o,a]=Da.useState(false),[n,s]=Da.useState(null),l=Da.useMemo(()=>Xn(ja(e.collections)),[e.collections]),i=Da.useMemo(()=>Yn(ja(e.globals)),[e.globals]),[c,d]=Da.useState(null),[m,x]=Da.useState(null),[b,k]=Da.useState("list"),[f,g]=Da.useState(null),[p,u]=Da.useState(false);Da.useEffect(()=>{(async()=>{try{let w=await fetch("/api/users/me");if(w.ok){let y=await w.json();s(y),a(!0);}}catch(w){console.error("Auth check failed",w);}})();},[]),Da.useEffect(()=>{if(o&&!c){let h=Object.keys(l)[0];h&&d(h);}},[o,l,c]);let v=(h,w=null,y=null)=>{k(h),w&&d(w),y&&g(y),u(false);};Da.useEffect(()=>{let h=w=>{(w.metaKey||w.ctrlKey)&&w.key==="k"&&(w.preventDefault(),u(y=>!y));};return window.addEventListener("keydown",h),window.openCommandPalette=()=>u(true),()=>{window.removeEventListener("keydown",h),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(Tr,{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(Lc,{isOpen:p,onClose:()=>u(false),collections:l,globals:i,onNavigate:v}),(()=>{let h=c?l[c]:null;switch(b){case "create":return h?jsxRuntime.jsx(Pi,{config:e,collection:h,onSuccess:()=>k("list"),onCancel:()=>k("list"),onError:w=>U.error(w)}):null;case "detail":return h&&f?jsxRuntime.jsx(Ri,{config:e,collection:h,documentId:f,onBack:()=>k("list"),onSave:()=>{},onError:w=>U.error(w)}):null;case "users":return jsxRuntime.jsx(Ac,{});case "media":return jsxRuntime.jsx($n,{});case "branding":return jsxRuntime.jsx(Rc,{});case "developer":return jsxRuntime.jsx(Pc,{collections:l});case "webhooks":return jsxRuntime.jsx(Dc,{});default:return h?jsxRuntime.jsx(Os,{config:e,collection:h,onCreate:()=>k("create"),onEdit:w=>v("detail",c,w)}):jsxRuntime.jsx(Sc,{onNavigate:v,collections:l,user:n})}})()]})})}),jsxRuntime.jsx(Mc,{}),jsxRuntime.jsx(ys,{})]})}):jsxRuntime.jsx(Ii,{onAuth:(h,w)=>{s(w),a(true);},theme:t})}function Ky({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(Ls,{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(Io,{trigger:jsxRuntime.jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsxRuntime.jsx(Pt,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function Zy({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:l=false}){let i=d=>{if(!d)return "Unknown date";let m=new Date(d);if(isNaN(m.getTime())){let x=Date.parse(d);return isNaN(x)?"Invalid date":new Date(x).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}return m.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})},c=d=>{if(!d)return "Unknown date";let m=new Date(d);if(isNaN(m.getTime()))return i(d);let b=new Date().getTime()-m.getTime();if(b<0)return "Just now";let k=Math.floor(b/6e4),f=Math.floor(b/36e5),g=Math.floor(b/864e5);return k<1?"Just now":k<60?`${k}m ago`:f<24?`${f}h ago`:g<7?`${g}d ago`:i(d)};return jsxRuntime.jsx(ur,{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(ar,{})}):r.length===0?jsxRuntime.jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx(ql.History,{className:"w-12 h-12 mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsxRuntime.jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsxRuntime.jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(d=>{let m=d.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 ${d.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:[d.status==="published"&&jsxRuntime.jsx(ql.CheckCircle2,{className:"w-3 h-3"}),d.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",d.version]}),m&&jsxRuntime.jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsxRuntime.jsx(ql.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),c(d.createdAt)]}),d.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(ql.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:d.createdBy.name||d.createdBy.email})]}),d.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:['"',d.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(d),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(ql.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(d,r.find(x=>x.id===o)||d),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(ql.GitCompare,{className:"w-4 h-4"})}),!m&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(d),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:"Restore this version",children:jsxRuntime.jsx(ql.Undo2,{className:"w-4 h-4"})})]})]})]},d.id)})})})}function RP({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 cr={ready:[],beforeDeploy:[],afterDeploy:[]};function ks(e){return cr.ready.push(e),()=>{cr.ready=cr.ready.filter(t=>t!==e);}}function Oc(e){return cr.beforeDeploy.push(e),()=>{cr.beforeDeploy=cr.beforeDeploy.filter(t=>t!==e);}}function Uc(e){return cr.afterDeploy.push(e),()=>{cr.afterDeploy=cr.afterDeploy.filter(t=>t!==e);}}async function zc(e){let t=[];for(let r of cr.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 jc(e){let t=[];for(let r of cr.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 _c(e,t){for(let r of cr.afterDeploy)try{await r(e,t);}catch{}}function Vc(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function Kc(e,t={}){let[r,o]=Da.useState(null),[a,n]=Da.useState(true),[s,l]=Da.useState(null),i=Da.useCallback(async()=>{n(true),l(null);try{let c=new URLSearchParams;t.page&&c.set("page",String(t.page)),t.limit&&c.set("limit",String(t.limit)),t.sort&&c.set("sort",t.sort),t.order&&c.set("order",t.order);let d=`${Vc(`/api/${e}`)}?${c.toString()}`,m=await fetch(d,{credentials:"include"});if(!m.ok)throw new Error(`HTTP ${m.status}: ${m.statusText}`);let x=await m.json();o(x.data??x);}catch(c){l(c instanceof Error?c.message:String(c));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return Da.useEffect(()=>{i();},[i]),{data:r,loading:a,error:s,refetch:i}}function Gc(e,t="POST"){let[r,o]=Da.useState(false),[a,n]=Da.useState(null);return {mutate:Da.useCallback(async l=>{o(true),n(null);try{let i=Vc(`/api/${e}`),c=await fetch(i,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:l?JSON.stringify(l):void 0});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);let d=await c.json();return d.data??d}catch(i){return n(i instanceof Error?i.message:String(i)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var ga=new Map;function ba(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");ga.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),ga.set(e.name,e),e.apply&&e.apply({});}function Wc(e){ga.delete(e);}function Jc(e){return ga.get(e)}function qc(){return Array.from(ga.values())}function Xc(e){return Array.from(ga.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var tf={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};ba(tf);var rf={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};ba(rf);var xa=new Map;function ka(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");xa.set(e.id,e);}function Yc(e){xa.delete(e);}function Qc(e){return xa.get(e)}function Zc(){return Array.from(xa.values())}function ep(e){return Array.from(xa.values()).filter(t=>t.category===e)}function tp(e){let t=xa.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var of=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)})]})},af={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:of};ka(af);var sf=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)})]})},lf={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:sf};ka(lf);var ha=new Map;function wa(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");ha.set(e.id,e);}function ap(e){ha.delete(e);}function np(e){return ha.get(e)}function sp(){return Array.from(ha.values())}function ip(e){return Array.from(ha.values()).find(t=>t.type===e)}function lp(e,t){let r=ha.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var pf=({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"}),mf={id:"sample-text",type:"text",label:"Sample Text",editor:pf};wa(mf);var yf=({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"}),ff={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:yf};wa(ff);var dp=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(dp,"use-sync-external-store.js");gr__default.default.join(dp,"use-sync-external-store-with-selector.js");function hf(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"),c=gr__default.default.resolve(a.root.pathname,"..",o),d=gr__default.default.resolve(a.root.pathname,o),m=Oo__default.default.existsSync(c)?c:Oo__default.default.existsSync(d)?d:i;m!==i?l.info(`Loaded config from ${m}`):l.warn("Config file not found. Using defaults.");let x=gr__default.default.join(gr__default.default.dirname(m),".kyro-admin-config.json"),b="";try{let f=gr__default.default.join(gr__default.default.dirname(m),".env");Oo__default.default.existsSync(f)&&dotenv.config({path:f});let g=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/*"]});b=m.replace(/\.ts$/,".admin.mjs"),Oo__default.default.writeFileSync(b,g.outputFiles[0].text,"utf8");let p=`
|
|
106
|
+
`}})]})]})]})}var Ff=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Ac({collections:e}){let{t}=reactI18next.useTranslation(),[r,o]=Ta.useState([]),[a,n]=Ta.useState(false),[s,i]=Ta.useState(null),[l,d]=Ta.useState(""),[c,u]=Ta.useState(null),[m,v]=Ta.useState(false),{confirm:x,alert:g}=yt(),[f,b]=Ta.useState(false),[p,h]=Ta.useState(""),A=async()=>{try{let w=await Ee("/api/keys");o(w);}catch(w){console.error(w);}};Ta.useEffect(()=>{A();},[]);let $=async()=>{h(""),b(true);},T=async()=>{if(p.trim())try{await dt("/api/keys",{name:p}),A(),b(!1),h(""),V.success("API key generated");}catch(w){console.error(w),V.error("Failed to generate API key");}},k=w=>{x({title:"Revoke API Key",message:"Are you sure you want to revoke this key? Any integrations using it will stop working.",variant:"danger",onConfirm:async()=>{try{await At(`/api/keys/${w}`),A(),V.success("API key revoked");}catch(D){console.error(D),V.error("Failed to revoke API key");}}});},y=async()=>{if(l){v(true);try{let D=await(await fetch(qe(`/api/${l}`))).json();u(D);}catch{u({error:"Failed to fetch. Ensure the endpoint exists."});}finally{v(false);}}};return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Lt,{title:t("tooltips.developerCenter",{defaultValue:"Developer Center"}),description:"Provision access keys and explore the headless API ecosystem.",icon:Ql.CodeXml,actions:[{label:"Generate Key",onClick:$,icon:Ql.Key}]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxRuntime.jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:r.length===0?jsxRuntime.jsxs("div",{className:"p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx(Ql.Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):r.map(w=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-3xl p-6 hover:border-[var(--kyro-primary)]/50 transition-all duration-300",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsxRuntime.jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsxRuntime.jsx(Ql.Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:w.name})]}),jsxRuntime.jsxs("div",{className:"flex-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl px-4 py-3 flex items-center justify-between group/key overflow-hidden",children:[jsxRuntime.jsx("code",{className:"text-xs font-mono opacity-80 truncate mr-4",children:s===w.id?w.key:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>i(s===w.id?null:w.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:s===w.id?jsxRuntime.jsx(Ql.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",onClick:()=>{navigator.clipboard.writeText(w.key),V.success("API key copied to clipboard");},children:jsxRuntime.jsx(Ql.Copy,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Issued:"}),jsxRuntime.jsx("span",{children:new Date(w.createdAt).toLocaleDateString()})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Status:"}),jsxRuntime.jsx("span",{className:"text-green-500",children:"Active"})]})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>k(w.id),className:"p-3.5 bg-red-500/5 text-red-500 rounded-2xl hover:bg-red-500/10 transition-all border border-transparent hover:border-red-500/30 self-start md:self-center",title:t("tooltips.revokeKey",{defaultValue:"Revoke Key"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-5 h-5"})})]})},w.id))})]}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/80 p-8 group shadow-2xl shadow-[var(--kyro-primary)]/20",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.1] pointer-events-none group-hover:scale-110 transition-transform duration-700",children:jsxRuntime.jsx(Ql.Terminal,{className:"w-48 h-48 rotate-12"})}),jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsxRuntime.jsx(Ql.Terminal,{className:"w-6 h-6 text-white"})}),jsxRuntime.jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsxRuntime.jsx("p",{className:"text-white/80 text-sm font-medium leading-relaxed mb-8",children:"Kyro CMS is built for high-performance content delivery. Use these endpoints to power your headless frontends."}),jsxRuntime.jsxs("button",{type:"button",className:"w-full py-4 bg-white text-[var(--kyro-primary)] rounded-[1.2rem] font-bold text-xs uppercase tracking-widest hover:shadow-xl transition-all flex items-center justify-center gap-2 active:scale-[0.98]",children:["Full API Documentation",jsxRuntime.jsx(Ql.ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxRuntime.jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-[var(--kyro-primary)]/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://api.kyro.io/v1")})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-amber-500/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsxRuntime.jsx(Ql.Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://preview.kyro.io/v1")})]})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"xl:col-span-3 rounded-[3rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-10 space-y-10 overflow-hidden relative",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsxRuntime.jsx(Ql.CirclePlay,{className:"w-96 h-96"})}),jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxRuntime.jsxs("div",{className:"max-w-xl",children:[jsxRuntime.jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Ql.CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] text-sm font-medium opacity-60 leading-relaxed",children:"Test your collection endpoints and analyze live response payloads. Enter a collection slug to fetch its latest documents."})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 flex-1 lg:max-w-2xl bg-[var(--kyro-bg)] p-2 rounded-[2rem] border border-[var(--kyro-border)] shadow-2xl",children:[jsxRuntime.jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",Ff,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:w=>d(w.target.value),placeholder:"collection-slug",className:"w-full py-4 bg-transparent focus:outline-none font-mono text-sm font-bold text-[var(--kyro-primary)]"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:y,disabled:m||!l,className:"kyro-btn kyro-btn-primary px-8 py-4 rounded-[1.5rem] font-bold text-sm shadow-xl disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] transition-all flex items-center gap-3 shrink-0",children:[m?jsxRuntime.jsx(Ql.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(Ql.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),c?jsxRuntime.jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px] font-mono px-3",children:"200 OK"})]}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden border border-[var(--kyro-border)] shadow-2xl bg-[#090b10]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-6 py-4 bg-[#11141d] border-b border-[var(--kyro-border)]/50",children:[jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/20"})]}),jsxRuntime.jsx(Af__default.default,{value:JSON.stringify(c,null,2),height:"450px",theme:codemirrorThemeAura.aura,extensions:[langJson.json()],editable:false,className:"text-sm"})]})]}):jsxRuntime.jsxs("div",{className:"h-80 rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center bg-[var(--kyro-surface-accent)]/20 transition-all duration-700",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 bg-[var(--kyro-surface)] rounded-3xl flex items-center justify-center shadow-lg border border-[var(--kyro-border)] mb-6 opacity-20",children:jsxRuntime.jsx(Ql.CodeXml,{className:"w-10 h-10"})}),jsxRuntime.jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxRuntime.jsxs(St,{open:f,onClose:()=>b(false),title:t("tooltips.generateAccessToken",{defaultValue:"Generate Access Token"}),size:"lg",children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 leading-relaxed",children:"Define a name for this API key to identify its integration context. Keys are encrypted at rest and should be treated with extreme caution."}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsxRuntime.jsx("input",{type:"text",value:p,onChange:w=>h(w.target.value),placeholder:"e.g., Mobile App SDK, Production Server",className:"w-full px-6 py-4 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)] shadow-sm transition-all",onKeyDown:w=>w.key==="Enter"&&T()})]})]})}),jsxRuntime.jsxs(Mr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>b(false),className:"px-6 py-3 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"kyro-btn kyro-btn-primary px-8 py-3 rounded-xl font-bold text-sm hover:opacity-90 shadow-lg shadow-[var(--kyro-primary)]/20 transition-all",children:"Generate Token"})]})]})]})}function Dc(e){let[t,r]=Ta.useState([]),[o,a]=Ta.useState(false),[n,s]=Ta.useState(null),[i,l]=Ta.useState(false),{confirm:d}=yt(),c=Ta.useCallback(async()=>{a(true),s(null);try{let x=await Ee(e.endpoint),g=Array.isArray(x)?x:x.docs||[],f=e.transformLoad?e.transformLoad(g):g;r(f),e.onSuccess?.("load",f);}catch(x){let g=x instanceof Error?x.message:"Failed to load resources";s(g),e.onError?.("load",x);}finally{a(false);}},[e.endpoint,e.transformLoad]);Ta.useEffect(()=>{c();},[c]);let u=Ta.useCallback((x,g="item")=>{d({title:`Delete ${g}`,message:`Are you sure you want to delete this ${g.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await At(`${e.endpoint}/${x}`),r(f=>f.filter(b=>b.id!==x)),e.onSuccess?.("delete",x),V.success(`${g} deleted`);}catch(f){let b=f instanceof Error?f.message:`Failed to delete ${g}`;V.error(b),e.onError?.("delete",f);}}});},[e.endpoint,d]),m=Ta.useCallback(async x=>{s(null);try{let g=await dt(e.endpoint,x);return r(f=>[g,...f]),l(!1),e.onSuccess?.("create",g),g}catch(g){let f=g instanceof Error?g.message:"Failed to create resource";throw s(f),e.onError?.("create",g),g}},[e.endpoint]),v=Ta.useCallback(async(x,g)=>{s(null);try{let f=await Yt(`${e.endpoint}/${x}`,g);return r(b=>b.map(p=>p.id===x?f:p)),e.onSuccess?.("update",f),f}catch(f){let b=f instanceof Error?f.message:"Failed to update resource";throw s(b),e.onError?.("update",f),f}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:u,create:m,update:v,isCreateModalOpen:i,setIsCreateModalOpen:l}}var Ef={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function Tc(){let{t:e}=reactI18next.useTranslation(),{items:t,loading:r,create:o,remove:a,update:n,isCreateModalOpen:s,setIsCreateModalOpen:i}=Dc({endpoint:"/api/webhooks"}),{confirm:l}=yt(),[d,c]=Ta.useState(false),[u,m]=Ta.useState(false),[v,x]=Ta.useState(null),[g,f]=Ta.useState(null),[b,p]=Ta.useState({}),[h,A]=Ta.useState(true),[$,T]=Ta.useState("action"),[k,y]=Ta.useState("generic"),[w,D]=Ta.useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[U,O]=Ta.useState(""),[z,P]=Ta.useState(false),[R,Ae]=Ta.useState(null),[E,oe]=Ta.useState([]),[ie,ee]=Ta.useState(false);Ta.useEffect(()=>{G();},[]);let G=async()=>{try{let S=await Ee("/api/webhooks/actions");p(S.actions);}catch(S){console.error("Failed to load webhook actions:",S);}finally{A(false);}},ye=()=>{T("action"),y("generic"),D({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),O("");},De=S=>{y(S),D(j=>({...j,action:S,config:{}})),T("config");},L=(S,j)=>{D(xe=>({...xe,config:{...xe.config,[S]:j}}));},W=async()=>{if(!w.name.trim()){O("Name is required");return}if(k==="generic"&&!w.url.trim()){O("URL is required for custom webhooks");return}let S=b[k];if(S){for(let j of S.configFields)if(j.required&&!w.config[j.name]?.trim()){O(`${j.label} is required`);return}}try{await o(w),ye(),V.success(`Webhook created: ${w.name}`);}catch(j){let xe=j.message||"Failed to create webhook";O(xe),V.error(xe);}},re=async S=>{f(S),x(null),c(true);try{let j=await dt(`/api/webhooks/${S}/test`);x({success:!0,message:j.message||"Webhook triggered successfully"}),V.success("Test delivered successfully");}catch{x({success:false,message:"Failed to trigger webhook"});}},H=async(S,j)=>{try{let xe=j==="active"?"paused":"active";await n(S,{status:xe}),V.success(xe==="active"?"Webhook activated":"Webhook paused");}catch(xe){console.error(xe),V.error("Failed to toggle webhook status");}},Te=async S=>{Ae(S),P(true),ee(true);try{let j=await Ee(`/api/webhooks/${S}/history`);oe(j.docs||[]);}catch(j){console.error("Failed to load history:",j),V.error("Failed to load delivery history");}finally{ee(false);}},fe=[{label:"Create",value:"create",description:"When a new document is created"},{label:"Update",value:"update",description:"When a document is updated"},{label:"Delete",value:"delete",description:"When a document is deleted"},{label:"Auth",value:"auth",description:"User login/logout events"}],we=S=>b[S||"generic"]?.label||"Custom URL";return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Lt,{title:e("tooltips.webhooks",{defaultValue:"Webhooks"}),description:"Get notified when your content changes.",icon:Ql.Webhook,actions:[{label:"New webhook",onClick:()=>{ye(),i(true);},icon:Ql.Plus},{label:"Guide",onClick:()=>m(true),icon:Ql.Info,variant:"outline"}]}),jsxRuntime.jsx("div",{className:"relative overflow-hidden rounded-2xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-3 bg-[var(--kyro-primary)]/10 rounded-xl",children:jsxRuntime.jsx(Ql.Zap,{className:"w-6 h-6 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("div",{className:"flex-1 text-center md:text-left",children:jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Receive instant HTTP notifications when events happen in your CMS. Choose a platform preset or point to any custom endpoint."})})]})}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium text-[var(--kyro-text-secondary)]",children:"Endpoints"})]}),jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:[t.length," hook",t.length!==1&&"s"]})]}),r?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 opacity-50 text-sm text-[var(--kyro-text-secondary)]",children:"Loading webhooks..."}):t.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-2xl border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-5 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Ql.Webhook,{className:"w-8 h-8 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold mb-2",children:"No webhooks yet"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-6 max-w-sm mx-auto",children:"Create a webhook to get notified when your content changes."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{ye(),i(true);},className:"kyro-btn kyro-btn-primary inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-medium",children:[jsxRuntime.jsx(Ql.Plus,{className:"w-4 h-4"}),"Create webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:t.map(S=>jsxRuntime.jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-2xl p-5 hover:border-[var(--kyro-primary)]/30 transition-all duration-200",children:jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-5 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[jsxRuntime.jsx("div",{className:"p-2 bg-[var(--kyro-surface-accent)] rounded-lg",children:jsxRuntime.jsx(Ql.Webhook,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:S.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-medium ${S.status==="active"?"text-green-500":"text-amber-500"}`,children:S.status}),jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:we(S.action)})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-1",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs text-[var(--kyro-text-secondary)] opacity-60 truncate max-w-[200px]",title:S.url,children:S.url||`${we(S.action)} webhook`})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[S.events.slice(0,3).map(j=>jsxRuntime.jsx(Rt,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:j},j)),S.events.length>3&&jsxRuntime.jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",S.events.length-3]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3 h-3"}),S.lastTriggered?`Last triggered ${new Date(S.lastTriggered).toLocaleDateString()}`:"Never triggered"]}),S.lastError&&jsxRuntime.jsxs("div",{className:"text-[10px] text-red-500/80 flex items-center gap-1.5 mt-1",children:[jsxRuntime.jsx(Ql.XCircle,{className:"w-3 h-3"}),jsxRuntime.jsx("span",{className:"truncate max-w-[150px]",title:S.lastError,children:S.lastError})]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 lg:opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Te(S.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.viewDeliveryHistory",{defaultValue:"View delivery history"}),children:[jsxRuntime.jsx(Ql.Activity,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium hidden sm:inline",children:"History"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>re(S.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.sendTestRequest",{defaultValue:"Send test request"}),children:[jsxRuntime.jsx(Ql.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium",children:"Test"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>H(S.id,S.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${S.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:S.status==="active"?"Pause":"Activate",children:S.status==="active"?jsxRuntime.jsx(Ql.Pause,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Ql.Play,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(S.id,"Webhook"),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-red-500/30 hover:bg-red-500/5 transition-colors",title:e("tooltips.delete",{defaultValue:"Delete"}),children:jsxRuntime.jsx(Ql.Trash2,{className:"w-3.5 h-3.5 text-red-500/50 hover:text-red-500"})})]})]})},S.id))})]}),jsxRuntime.jsx(St,{open:s&&$==="action",onClose:()=>i(false),title:e("tooltips.newWebhook",{defaultValue:"New webhook"}),children:jsxRuntime.jsx(Cr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:h?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(Ql.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(b).map(([S,j])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>De(S),className:"flex flex-col items-start p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/40 transition-all text-left group",children:[jsxRuntime.jsx("div",{className:"text-lg mb-2",children:Ef[S]||"\u{1F517}"}),jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-0.5 group-hover:text-[var(--kyro-primary)] transition-colors",children:j.label}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] opacity-50 leading-relaxed",children:j.description}),j.envVars.length>0&&jsxRuntime.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:j.envVars.map(xe=>jsxRuntime.jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:xe},xe))})]},S))})})})}),jsxRuntime.jsxs(St,{open:s&&$==="config",onClose:()=>i(false),title:b[k]?.label||"Webhook",children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-5",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Name"}),jsxRuntime.jsx("input",{type:"text",value:w.name,onChange:S=>D({...w,name:S.target.value}),placeholder:"e.g., Deploy on content update",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"URL"}),jsxRuntime.jsx("input",{type:"url",value:w.url,onChange:S=>D({...w,url:S.target.value}),placeholder:"https://your-server.com/webhook",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k!=="generic"&&b[k]?.configFields.map(S=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[S.label," ",S.required&&jsxRuntime.jsx("span",{className:"text-red-500",children:"*"})]}),jsxRuntime.jsx("input",{type:"text",value:w.config[S.name]||"",onChange:j=>L(S.name,j.target.value),placeholder:S.placeholder,className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]},S.name)),k==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Signing secret"}),jsxRuntime.jsx("input",{type:"text",value:w.secret,onChange:S=>D({...w,secret:S.target.value}),placeholder:e("fields.optional",{defaultValue:"Optional"}),className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]})]}),k!=="generic"&&b[k]?.envVars.length>0&&jsxRuntime.jsxs("div",{className:"p-3 rounded-lg bg-amber-500/5 border border-amber-500/15",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-3.5 h-3.5 text-amber-500"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-amber-600",children:"Environment variables required"})]}),jsxRuntime.jsxs("p",{className:"text-[11px] text-amber-600/60 mb-2",children:["Add these to your ",jsxRuntime.jsx("code",{className:"font-mono bg-amber-500/10 px-1 py-0.5 rounded text-[10px]",children:".env"})," file:"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:b[k].envVars.map(S=>jsxRuntime.jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[S,"=..."]},S))})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium text-[var(--kyro-text-secondary)]",children:"Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:fe.map(S=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let j=w.events.includes(S.value)?w.events.filter(xe=>xe!==S.value):[...w.events,S.value];D({...w,events:j});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${w.events.includes(S.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/20"}`,children:[jsxRuntime.jsx("div",{className:`w-3.5 h-3.5 rounded flex items-center justify-center border transition-all ${w.events.includes(S.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:w.events.includes(S.value)&&jsxRuntime.jsx(Ql.CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-medium",children:S.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-40",children:S.description})]})]},S.value))})]})]}),U&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-red-500 text-xs",children:[jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-3.5 h-3.5"}),U]})]})}),jsxRuntime.jsxs(Mr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>T("action"),className:"px-4 py-2 rounded-lg text-sm font-medium border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:W,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg text-sm font-medium",children:"Create webhook"})]})]}),jsxRuntime.jsxs(St,{open:d,onClose:()=>c(false),title:e("tooltips.testWebhook",{defaultValue:"Test webhook"}),children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsx("div",{className:"p-6 rounded-xl bg-[var(--kyro-surface)] border border-[var(--kyro-border)] text-center",children:v?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${v.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:v.success?jsxRuntime.jsx(Ql.CircleCheck,{className:"w-6 h-6"}):jsxRuntime.jsx(Ql.TriangleAlert,{className:"w-6 h-6"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:v.success?"Delivered":"Failed"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:v.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-4 py-4",children:[jsxRuntime.jsx(Ql.RefreshCw,{className:"w-8 h-8 text-[var(--kyro-primary)] animate-spin mx-auto opacity-40"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:"Sending test payload"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:"Dispatching..."})]})]})})}),jsxRuntime.jsx(Mr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>c(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]}),jsxRuntime.jsxs(St,{open:u,onClose:()=>m(false),title:e("tooltips.howWebhooksWork",{defaultValue:"How webhooks work"}),children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Ql.ExternalLink,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Request format"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["When an event triggers, Kyro sends a ",jsxRuntime.jsx("span",{className:"font-medium",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Ql.Shield,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Signature verification"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["If a secret is set, each request includes an ",jsxRuntime.jsx("span",{className:"font-mono text-[10px] bg-[var(--kyro-surface-accent)] px-1 py-0.5 rounded",children:"X-Webhook-Signature"})," header with an HMAC-SHA256 signature. Verify it in production."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] opacity-50",children:"Example payload"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg)] rounded-md border border-[var(--kyro-border)] p-4 font-mono text-xs overflow-hidden",children:jsxRuntime.jsxs("div",{className:"space-y-0.5 text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("div",{children:"{"}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"posts"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-06-28T12:00:00Z"'})]}),jsxRuntime.jsx("div",{children:"}"})]})})]})]})}),jsxRuntime.jsx(Mr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"kyro-btn kyro-btn-primary w-full py-2.5 rounded-lg text-sm font-medium",children:"Got it"})})]}),jsxRuntime.jsxs(St,{open:z,onClose:()=>P(false),title:e("tooltips.deliveryHistory",{defaultValue:"Delivery History"}),children:[jsxRuntime.jsx(Cr,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:ie?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(Ql.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):E.length===0?jsxRuntime.jsx("div",{className:"text-center p-8 text-[var(--kyro-text-secondary)] opacity-60 text-sm",children:"No delivery history available for this webhook."}):jsxRuntime.jsx("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:E.map(S=>jsxRuntime.jsxs("div",{className:"p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-sm",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[S.status==="success"?jsxRuntime.jsx(Ql.CircleCheck,{className:"w-4 h-4 text-green-500"}):jsxRuntime.jsx(Ql.XCircle,{className:"w-4 h-4 text-red-500"}),jsxRuntime.jsx("span",{className:"font-medium",children:S.event})]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:new Date(S.createdAt).toLocaleString()})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs text-[var(--kyro-text-secondary)] mb-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Status: "}),jsxRuntime.jsx("span",{className:`font-medium ${S.status==="success"?"text-green-500":"text-red-500"}`,children:S.responseStatus||S.status})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"opacity-50",children:"Duration: "}),S.duration?`${S.duration}ms`:"-"]})]}),S.error&&jsxRuntime.jsx("div",{className:"text-xs text-red-500 bg-red-500/5 p-2 rounded border border-red-500/10 font-mono break-all mb-2",children:S.error}),S.responseBody&&jsxRuntime.jsx("div",{className:"text-[10px] font-mono bg-[var(--kyro-bg)] p-2 rounded border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] opacity-70 max-h-24 overflow-y-auto break-all",children:S.responseBody})]},S.id))})})}),jsxRuntime.jsx(Mr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>P(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]})]})}function Rc({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{t:n}=reactI18next.useTranslation(),{user:s,permissions:i}=_r(),[l,d]=Ta.useState(""),[c,u]=Ta.useState(0),[m,v]=Ta.useState(false),[x,g]=Ta.useState([]),f=Ta.useRef(null),b=Ta.useRef(null);Ta.useEffect(()=>{e&&(d(""),u(0),g([]),v(false),setTimeout(()=>f.current?.focus(),100));},[e]);let p=Ta.useCallback(async P=>{if(!P||P.length<2){g([]);return}v(true);try{let Ae=await(await fetch(qe(`/api/search?q=${encodeURIComponent(P)}&limit=15`))).json();Ae.results&&g(Ae.results);}catch(R){console.error("Search error:",R),g([]);}finally{v(false);}},[]);if(Ta.useEffect(()=>(b.current&&clearTimeout(b.current),l.length>=2?b.current=setTimeout(()=>p(l),300):g([]),()=>{b.current&&clearTimeout(b.current);}),[l,p]),!e)return null;let h=Object.entries(r).filter(([P])=>i?.collections?.[P]?.read!==false).map(([P,R])=>({id:`col-${P}`,label:R.label||P,type:"collection",slug:P,icon:Ql.FileText})),A=Object.entries(o).filter(([P])=>i?.globals?.[P]?.read!==false).map(([P,R])=>({id:`global-${P}`,label:R.label||P,type:"global",slug:P,icon:Ql.Settings})),$=typeof document<"u"&&document.documentElement.classList.contains("dark"),T=s?.role==="admin",k=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:Ql.Image,visible:i?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:Ql.Clock,visible:T},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:Ql.File,visible:T},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Ql.Shield,visible:T},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Ql.Database,visible:T},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Ql.Hexagon,visible:T},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Ql.Network,visible:T},{id:"action-theme",label:$?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:$?Ql.Sun:Ql.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:Ql.LogOut,visible:true}].filter(P=>P.visible),y=x.map((P,R)=>({id:`doc-${P.collection}-${P.id}`,label:P.title,type:"document",collection:P.collection,label2:P.label,docId:P.id,icon:Ql.File,doc:P.doc})),w=l.length>=2?[...k,...h,...A,...y]:[...k,...h,...A],D=l===""?w:w.filter(P=>P.label.toLowerCase().includes(l.toLowerCase())),U=P=>{if(P.key==="ArrowDown")P.preventDefault(),u(R=>(R+1)%D.length);else if(P.key==="ArrowUp")P.preventDefault(),u(R=>(R-1+D.length)%D.length);else if(P.key==="Enter"){let R=D[c];R&&O(R);}else P.key==="Escape"&&t();},O=P=>{P.type==="collection"?P.slug==="users"?a(P.slug,P.slug):a("list",P.slug):P.type==="global"?a("settings",P.slug):P.type==="document"?P.collection==="users"?a("users","users",P.docId):a("edit",P.collection,P.docId):P.type==="action"&&(P.view==="users"?a("users","users"):P.view==="media"?a("media","media"):a(P.view,P.view)),t();},z=()=>l===""?"Quick Actions & Collections":x.length>0?"Documents":m?"Searching...":"Search Results";return jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxRuntime.jsxs("div",{className:"relative w-full max-w-2xl bg-[var(--kyro-surface)] rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 fade-in duration-300 ring-1 ring-white/10 border border-white/5",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[m?jsxRuntime.jsx(Ql.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(Ql.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:f,placeholder:n("fields.searchAnything",{defaultValue:"Search anything..."}),className:"flex-1 bg-transparent border-none focus:outline-none text-lg font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)]",value:l,onChange:P=>d(P.target.value),onKeyDown:U}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-2 py-1 bg-[var(--kyro-bg-secondary)] rounded-lg border border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:D.length>0?jsxRuntime.jsxs("div",{className:"space-y-1 px-4",children:[jsxRuntime.jsx("p",{className:"px-4 text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4",children:z()}),D.map((P,R)=>jsxRuntime.jsxs("div",{onClick:()=>O(P),onMouseEnter:()=>u(R),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${R===c?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xl shadow-[var(--kyro-primary)]":"hover:bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:`p-2 rounded-xl ${R===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(P.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:P.label}),P.type==="document"&&P.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${R===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:P.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${R===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:P.type}),R===c&&jsxRuntime.jsx(Ql.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},P.id))]}):jsxRuntime.jsx("div",{className:"py-12 text-center",children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] italic opacity-60",children:l.length>=2&&!m?`No results found for "${l}"`:"Start typing to search..."})})}),jsxRuntime.jsxs("div",{className:"px-8 py-4 bg-[var(--kyro-bg-secondary)] border-t border-[var(--kyro-border)] flex items-center justify-between text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-60",children:[jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u2191\u2193 Navigate"}),jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u23CE Select"})]}),jsxRuntime.jsx("div",{children:"Kyro Universal Search"})]})]})]})}function Ic(){let{modal:e,closeModal:t}=yt(),[r,o]=Ta.useState(false);if(!e.open||!e.config)return null;let{config:a}=e,n=async()=>{if(a.onConfirm)try{o(!0),await a.onConfirm();}catch(i){console.error("Modal confirm action failed:",i);}finally{o(false),t();}else t();},s=()=>{a.onCancel&&a.onCancel(),t();};return jsxRuntime.jsx(Vs,{open:e.open,onClose:s,onConfirm:n,title:a.title,message:a.message,confirmLabel:a.confirmLabel,cancelLabel:a.cancelLabel,variant:a.variant==="danger"?"danger":"default",loading:r})}function Of({config:e,theme:t="light",onThemeChange:r}){let[o,a]=Ta.useState(false),[n,s]=Ta.useState(null),i=Ta.useMemo(()=>Wn(Va(e.collections)),[e.collections]),l=Ta.useMemo(()=>qn(Va(e.globals)),[e.globals]),[d,c]=Ta.useState(null),[u,m]=Ta.useState(null),[v,x]=Ta.useState("list"),[g,f]=Ta.useState(null),[b,p]=Ta.useState(false);Ta.useEffect(()=>{(async()=>{try{let k=await fetch("/api/users/me");if(k.ok){let y=await k.json();s(y),a(!0);}}catch(k){console.error("Auth check failed",k);}})();},[]),Ta.useEffect(()=>{if(o&&!d){let T=Object.keys(i)[0];T&&c(T);}},[o,i,d]);let h=(T,k=null,y=null)=>{x(T),k&&c(k),y&&f(y),p(false);};Ta.useEffect(()=>{let T=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),p(y=>!y));};return window.addEventListener("keydown",T),window.openCommandPalette=()=>p(true),()=>{window.removeEventListener("keydown",T),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(Sr,{mode:t,onChange:r,children:jsxRuntime.jsxs("div",{className:"kyro-admin min-h-screen bg-[var(--kyro-bg)] text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("div",{className:"flex h-screen overflow-hidden",children:jsxRuntime.jsx("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsxRuntime.jsx(Rc,{isOpen:b,onClose:()=>p(false),collections:i,globals:l,onNavigate:h}),(()=>{let T=d?i[d]:null;switch(v){case "create":return T?jsxRuntime.jsx(Di,{config:e,collection:T,onSuccess:()=>x("list"),onCancel:()=>x("list"),onError:k=>V.error(k)}):null;case "detail":return T&&g?jsxRuntime.jsx(Ai,{config:e,collection:T,documentId:g,onBack:()=>x("list"),onSave:()=>{},onError:k=>V.error(k)}):null;case "users":return jsxRuntime.jsx(Cc,{});case "media":return jsxRuntime.jsx(En,{});case "branding":return jsxRuntime.jsx(Sc,{});case "developer":return jsxRuntime.jsx(Ac,{collections:i});case "webhooks":return jsxRuntime.jsx(Tc,{});default:return T?jsxRuntime.jsx(Ms,{config:e,collection:T,onCreate:()=>x("create"),onEdit:k=>h("detail",d,k)}):jsxRuntime.jsx(wc,{onNavigate:h,collections:i,user:n})}})()]})})}),jsxRuntime.jsx(Ic,{}),jsxRuntime.jsx(us,{})]})}):jsxRuntime.jsx(Fi,{onAuth:(T,k)=>{s(k),a(true);},theme:t})}function zf({selectedCount:e,onClearSelection:t,actions:r,onSelectAll:o}){return e===0?null:jsxRuntime.jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-gray-50 border-b border-gray-200",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Rs,{count:e}),jsxRuntime.jsx("span",{className:"text-sm text-gray-600",children:"selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-sm text-gray-500 hover:text-gray-700",children:"Clear selection"}),o&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Select all"})]}),jsxRuntime.jsx(Po,{trigger:jsxRuntime.jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsxRuntime.jsx(Pt,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function Jf({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:i=false}){let{t:l}=reactI18next.useTranslation(),d=u=>{if(!u)return "Unknown date";let m=new Date(u);if(isNaN(m.getTime())){let v=Date.parse(u);return isNaN(v)?"Invalid date":new Date(v).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}return m.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})},c=u=>{if(!u)return "Unknown date";let m=new Date(u);if(isNaN(m.getTime()))return d(u);let x=new Date().getTime()-m.getTime();if(x<0)return "Just now";let g=Math.floor(x/6e4),f=Math.floor(x/36e5),b=Math.floor(x/864e5);return g<1?"Just now":g<60?`${g}m ago`:f<24?`${f}h ago`:b<7?`${b}d ago`:d(u)};return jsxRuntime.jsx(yr,{open:e,onClose:t,title:l("tooltips.versionHistory",{defaultValue:"Version History"}),width:"md",children:i?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12",children:jsxRuntime.jsx(ar,{})}):r.length===0?jsxRuntime.jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx(Ql.History,{className:"w-12 h-12 mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsxRuntime.jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsxRuntime.jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(u=>{let m=u.id===o;return jsxRuntime.jsxs("div",{className:`p-4 rounded-xl border transition-all duration-200 group relative overflow-hidden ${m?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]/5 shadow-sm":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30 hover:bg-[var(--kyro-surface-accent)] hover:shadow-sm bg-[var(--kyro-surface)]"}`,children:[m&&jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-[var(--kyro-primary)] shadow-[0_0_8px_var(--kyro-primary)]"}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide uppercase ${u.status==="published"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-zinc-500/10 text-zinc-600 dark:text-zinc-400"}`,children:[u.status==="published"&&jsxRuntime.jsx(Ql.CheckCircle2,{className:"w-3 h-3"}),u.status==="published"?"Published":"Draft"]}),jsxRuntime.jsxs("span",{className:"text-xs font-semibold text-[var(--kyro-text)] px-2 py-0.5 rounded-md bg-[var(--kyro-surface-accent)]",children:["v",u.version]}),m&&jsxRuntime.jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsxRuntime.jsx(Ql.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),c(u.createdAt)]}),u.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(Ql.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:u.createdBy.name||u.createdBy.email})]}),u.changelog&&jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] mt-2 italic border-l-2 border-[var(--kyro-border)] pl-2",children:['"',u.changelog,'"']})]}),jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-1.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a(u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.previewThisVersion",{defaultValue:"Preview this version"}),children:jsxRuntime.jsx(Ql.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u,r.find(v=>v.id===o)||u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.compareWithCurrent",{defaultValue:"Compare with current"}),children:jsxRuntime.jsx(Ql.GitCompare,{className:"w-4 h-4"})}),!m&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(u),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:l("tooltips.restoreThisVersion",{defaultValue:"Restore this version"}),children:jsxRuntime.jsx(Ql.Undo2,{className:"w-4 h-4"})})]})]})]},u.id)})})})}function VR({title:e,onMenuClick:t,actions:r}){return jsxRuntime.jsxs("header",{className:"kyro-header",children:[jsxRuntime.jsxs("div",{className:"kyro-header-left",children:[jsxRuntime.jsx("button",{type:"button",className:"kyro-header-menu",onClick:t,"aria-label":"Toggle menu",children:jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M3 12h18M3 6h18M3 18h18"})})}),jsxRuntime.jsx("h1",{className:"kyro-header-title",children:e})]}),jsxRuntime.jsxs("div",{className:"kyro-header-right",children:[r,jsxRuntime.jsx("div",{className:"kyro-header-user",children:jsxRuntime.jsx("button",{type:"button",className:"kyro-header-user-btn",children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"8",r:"4"}),jsxRuntime.jsx("path",{d:"M4 20c0-4 4-6 8-6s8 2 8 6"})]})})})]})]})}var ur={ready:[],beforeDeploy:[],afterDeploy:[]};function vs(e){return ur.ready.push(e),()=>{ur.ready=ur.ready.filter(t=>t!==e);}}function Mc(e){return ur.beforeDeploy.push(e),()=>{ur.beforeDeploy=ur.beforeDeploy.filter(t=>t!==e);}}function Lc(e){return ur.afterDeploy.push(e),()=>{ur.afterDeploy=ur.afterDeploy.filter(t=>t!==e);}}async function $c(e){let t=[];for(let r of ur.ready)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function Vc(e){let t=[];for(let r of ur.beforeDeploy)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function Oc(e,t){for(let r of ur.afterDeploy)try{await r(e,t);}catch{}}function Uc(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function jc(e,t={}){let[r,o]=Ta.useState(null),[a,n]=Ta.useState(true),[s,i]=Ta.useState(null),l=Ta.useCallback(async()=>{n(true),i(null);try{let d=new URLSearchParams;t.page&&d.set("page",String(t.page)),t.limit&&d.set("limit",String(t.limit)),t.sort&&d.set("sort",t.sort),t.order&&d.set("order",t.order);let c=`${Uc(`/api/${e}`)}?${d.toString()}`,u=await fetch(c,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);let m=await u.json();o(m.data??m);}catch(d){i(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return Ta.useEffect(()=>{l();},[l]),{data:r,loading:a,error:s,refetch:l}}function Hc(e,t="POST"){let[r,o]=Ta.useState(false),[a,n]=Ta.useState(null);return {mutate:Ta.useCallback(async i=>{o(true),n(null);try{let l=Uc(`/api/${e}`),d=await fetch(l,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:i?JSON.stringify(i):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(l){return n(l instanceof Error?l.message:String(l)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var ya=new Map;function fa(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");ya.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),ya.set(e.name,e),e.apply&&e.apply({});}function _c(e){ya.delete(e);}function Kc(e){return ya.get(e)}function Gc(){return Array.from(ya.values())}function Wc(e){return Array.from(ya.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var Yf={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};fa(Yf);var Qf={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};fa(Qf);var ga=new Map;function va(e){if(!e.id||typeof e.id!="string")throw new Error("Block must have a valid id");if(!e.label)throw new Error("Block must have a label");ga.set(e.id,e);}function qc(e){ga.delete(e);}function Jc(e){return ga.get(e)}function Xc(){return Array.from(ga.values())}function Yc(e){return Array.from(ga.values()).filter(t=>t.category===e)}function Qc(e){let t=ga.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var Zf=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"1px solid #ccc",padding:8,borderRadius:6},children:[jsxRuntime.jsx("strong",{children:"Sample Block"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},eg={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:Zf};va(eg);var rg=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"2px dashed #888",padding:10,borderRadius:8},children:[jsxRuntime.jsx("strong",{children:"Sample Block 2"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},og={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:rg};va(og);var ba=new Map;function xa(e){if(!e.id||typeof e.id!="string")throw new Error("Field must have a valid id");if(!e.type||typeof e.type!="string")throw new Error("Field must have a valid type");ba.set(e.id,e);}function tu(e){ba.delete(e);}function ru(e){return ba.get(e)}function ou(){return Array.from(ba.values())}function au(e){return Array.from(ba.values()).find(t=>t.type===e)}function nu(e,t){let r=ba.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var ig=({name:e,value:t,onChange:r})=>{let{t:o}=reactI18next.useTranslation();return jsxRuntime.jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleText",{defaultValue:"Sample text"})})},lg={id:"sample-text",type:"text",label:"Sample Text",editor:ig};xa(lg);var ug=({name:e,value:t,onChange:r})=>{let{t:o}=reactI18next.useTranslation();return jsxRuntime.jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleTextarea",{defaultValue:"Sample textarea"})})},pg={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:ug};xa(pg);function su(){let e="\0virtual:use-sync-external-store-shim",t="\0virtual:use-sync-external-store-shim-with-selector",r=new Set(["use-sync-external-store/shim","use-sync-external-store/shim/index.js","use-sync-external-store"]),o=new Set(["use-sync-external-store/shim/with-selector","use-sync-external-store/shim/with-selector.js","use-sync-external-store/with-selector","use-sync-external-store/with-selector.js"]);return {name:"use-sync-external-store-shim-fix",enforce:"pre",resolveId(a){if(r.has(a))return e;if(o.has(a))return t},load(a){if(a===e)return 'export { useSyncExternalStore } from "react";';if(a===t)return `
|
|
107
|
+
import { useSyncExternalStore, useRef, useMemo } from "react";
|
|
108
|
+
|
|
109
|
+
export function useSyncExternalStoreWithSelector(
|
|
110
|
+
subscribe,
|
|
111
|
+
getSnapshot,
|
|
112
|
+
getServerSnapshot,
|
|
113
|
+
selector,
|
|
114
|
+
isEqual
|
|
115
|
+
) {
|
|
116
|
+
const memoRef = useRef(null);
|
|
117
|
+
|
|
118
|
+
const memoizedSelector = useMemo(() => {
|
|
119
|
+
let lastSnapshot = undefined;
|
|
120
|
+
let lastSelection = undefined;
|
|
121
|
+
let hasMemo = false;
|
|
122
|
+
|
|
123
|
+
return (snapshot) => {
|
|
124
|
+
if (!hasMemo || !Object.is(lastSnapshot, snapshot)) {
|
|
125
|
+
const nextSelection = selector(snapshot);
|
|
126
|
+
if (!hasMemo || !(isEqual ? isEqual(lastSelection, nextSelection) : Object.is(lastSelection, nextSelection))) {
|
|
127
|
+
lastSnapshot = snapshot;
|
|
128
|
+
lastSelection = nextSelection;
|
|
129
|
+
hasMemo = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return lastSelection;
|
|
133
|
+
};
|
|
134
|
+
}, [selector, isEqual]);
|
|
135
|
+
|
|
136
|
+
const getSelection = () => memoizedSelector(getSnapshot());
|
|
137
|
+
const getServerSelection =
|
|
138
|
+
getServerSnapshot !== undefined && getServerSnapshot !== null
|
|
139
|
+
? () => memoizedSelector(getServerSnapshot())
|
|
140
|
+
: undefined;
|
|
141
|
+
|
|
142
|
+
return useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
143
|
+
}
|
|
144
|
+
`}}}var iu=br__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/shim");br__default.default.join(iu,"use-sync-external-store.js");br__default.default.join(iu,"use-sync-external-store-with-selector.js");function bg(e={}){let{basePath:t="/admin",apiPath:r="/api",configPath:o="kyro.config.ts"}=e;return {name:"@kyro-cms/admin",hooks:{"astro:config:setup":async({config:a,updateConfig:n,injectRoute:s,logger:i})=>{i.info(`Kyro Admin mounted at ${t} (API: ${r})`);let l=br__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/default-kyro-config.ts"),d=br__default.default.resolve(a.root.pathname,"..",o),c=br__default.default.resolve(a.root.pathname,o),u=Mo__default.default.existsSync(d)?d:Mo__default.default.existsSync(c)?c:l;u!==l?i.info(`Loaded config from ${u}`):i.warn("Config file not found. Using defaults.");let m=br__default.default.join(br__default.default.dirname(u),".kyro-admin-config.json"),v="";try{let g=br__default.default.join(br__default.default.dirname(u),".env");Mo__default.default.existsSync(g)&&dotenv.config({path:g});let f=await esbuild.build({entryPoints:[u],bundle:!0,format:"esm",platform:"node",target:"es2022",write:!1,sourcemap:!1,loader:{".ts":"ts",".tsx":"tsx"},resolveExtensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".json"],external:["@kyro-cms/*"]});v=u.replace(/\.ts$/,".admin.mjs"),Mo__default.default.writeFileSync(v,f.outputFiles[0].text,"utf8");let b=`
|
|
107
145
|
import { parentPort } from 'worker_threads';
|
|
108
|
-
import('${url.pathToFileURL(
|
|
146
|
+
import('${url.pathToFileURL(v).href}').then(mod => {
|
|
109
147
|
const cfg = mod.default || mod;
|
|
110
148
|
const serialize = (obj, key) => {
|
|
111
149
|
if (obj === null || obj === undefined) return obj;
|
|
@@ -132,7 +170,7 @@ code block
|
|
|
132
170
|
}).catch(err => {
|
|
133
171
|
parentPort.postMessage({ error: err.message });
|
|
134
172
|
});
|
|
135
|
-
`,
|
|
173
|
+
`,p=new worker_threads.Worker(b,{eval:!0,env:{...process.env,NODE_OPTIONS:""}}),h=await new Promise(($,T)=>{p.on("message",$),p.on("error",T);let k=setTimeout(()=>{p.terminate(),T(new Error("Config loading timed out"));},3e4);});if(p.terminate(),h.error)throw new Error(h.error);let A=[{name:"metaTitle",type:"text",label:"Meta Title",admin:{description:"The title used for search engines (recommended < 60 chars).",autoGenerate:"title"}},{name:"metaDescription",type:"textarea",label:"Meta Description",admin:{description:"A brief summary for search engines (recommended < 160 chars).",autoGenerate:"content"}},{name:"keywords",type:"text",label:"Keywords",admin:{description:"Comma-separated list of keywords for this page."}},{name:"ogImage",type:"upload",label:"OpenGraph Image",relationTo:"media",admin:{description:"The image shown when shared on social media."}},{name:"twitter",type:"group",label:"Twitter Card",fields:[{name:"title",type:"text",label:"Twitter Title"},{name:"description",type:"textarea",label:"Twitter Description"},{name:"image",type:"upload",label:"Twitter Image",relationTo:"media"}]},{name:"advanced",type:"group",label:"Advanced Search Settings",fields:[{name:"noindex",type:"checkbox",label:"Hide from search engines (noindex)",defaultValue:!1},{name:"nofollow",type:"checkbox",label:"Do not follow links (nofollow)",defaultValue:!1},{name:"canonicalUrl",type:"text",label:"Canonical URL Override",admin:{description:"Leave empty to use the default canonical URL."}},{name:"structuredData",type:"code",label:"JSON-LD Structured Data",admin:{description:"Custom JSON-LD schema for this specific page."}}]}];for(let $ of h.collections||[])if($.seo){let T=$.fields?.find(k=>k.type==="tabs"&&k.name==="tabs");T?.tabs&&(T.tabs.find(k=>k.label==="SEO Settings")||T.tabs.push({label:"SEO Settings",fields:A}));}Mo__default.default.writeFileSync(m,JSON.stringify(h,null,2),"utf8"),i.info("Project config loaded for admin");}catch(g){i.error(`Could not load project config: ${g.message}`);}finally{if(v&&Mo__default.default.existsSync(v))try{Mo__default.default.unlinkSync(v);}catch{}}n({vite:{plugins:[su(),{name:"kyro-admin-tsx-loader",enforce:"pre",config(g){let f=g.esbuild,b=f?.exclude,p=/\/node_modules\/(?!.*@kyro-cms\/(admin|core))/;return {esbuild:{...f||{},exclude:b?Array.isArray(b)?[...b,p]:[b,p]:p}}}},{name:"kyro-cjs-shim",enforce:"pre",resolveId(g){if(g.includes("react/compiler-runtime"))return "\0react-compiler-runtime";if(g==="debug"||g.includes("debug/src/browser.js"))return "\0debug-browser"},load(g){if(g==="\0react-compiler-runtime")return `
|
|
136
174
|
import React from "react";
|
|
137
175
|
export function c(size) {
|
|
138
176
|
const internals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
@@ -141,7 +179,7 @@ export function c(size) {
|
|
|
141
179
|
}
|
|
142
180
|
return internals.H.useMemoCache(size);
|
|
143
181
|
}
|
|
144
|
-
`;if(
|
|
182
|
+
`;if(g==="\0debug-browser")return `
|
|
145
183
|
function debug(namespace) {
|
|
146
184
|
function d(...args) {
|
|
147
185
|
if (typeof localStorage !== "undefined" && localStorage.getItem("DEBUG")) {
|
|
@@ -154,4 +192,4 @@ debug.enable = function() {};
|
|
|
154
192
|
debug.disable = function() {};
|
|
155
193
|
debug.enabled = function() { return false; };
|
|
156
194
|
export default debug;
|
|
157
|
-
`}}],resolve:{alias:{"kyro:config":
|
|
195
|
+
`}}],resolve:{alias:{"kyro:config":u}},optimizeDeps:{include:["@kyro-cms/admin","recharts","recharts > recharts-scale","recharts > recharts-scale > decimal.js-light","recharts > react-smooth","recharts > react-smooth > react-transition-group","use-sync-external-store","use-sync-external-store/with-selector.js","react-i18next > html-parse-stringify > void-elements","react-i18next > html-parse-stringify"],needsInterop:["decimal.js-light","use-sync-external-store","use-sync-external-store/with-selector.js","react-i18next > html-parse-stringify > void-elements","react-i18next > html-parse-stringify"],exclude:["debug","react/compiler-runtime"]},define:{__KYRO_ADMIN_PATH__:JSON.stringify(t),__KYRO_API_PATH__:JSON.stringify(r),__KYRO_ADMIN_CONFIG_FILE__:JSON.stringify(m)},ssr:{noExternal:["@kyro-cms/admin","@kyro-cms/core","@tiptap/core","@tiptap/react","@tiptap/pm","@tiptap/starter-kit","@tiptap/extension-link","@tiptap/extension-image","@tiptap/extension-text-align","@tiptap/extension-underline","@tiptap/extension-highlight","@tiptap/extension-task-list","@tiptap/extension-task-item","@tiptap/extension-text-style","@tiptap/extension-color","prosemirror-model","prosemirror-state","prosemirror-view","prosemirror-schema-list","prosemirror-commands","prosemirror-keymap","prosemirror-transform","prosemirror-inputrules"]}}}),globalThis.__KYRO_ADMIN_PROJECT_CONFIG__={collections:[],globals:[],adapter:null};let x=[{pattern:"",entrypoint:"./pages/index.astro"},{pattern:"/login",entrypoint:"./pages/auth/login.astro"},{pattern:"/register",entrypoint:"./pages/auth/register.astro"},{pattern:"/media",entrypoint:"./pages/media.astro"},{pattern:"/users",entrypoint:"./pages/users/index.astro"},{pattern:"/users/new",entrypoint:"./pages/users/new.astro"},{pattern:"/users/[id]",entrypoint:"./pages/users/[id].astro"},{pattern:"/roles",entrypoint:"./pages/roles/index.astro"},{pattern:"/settings",entrypoint:"./pages/settings/index.astro"},{pattern:"/settings/[slug]",entrypoint:"./pages/settings/[slug].astro"},{pattern:"/audit",entrypoint:"./pages/audit/index.astro"},{pattern:"/sessions",entrypoint:"./pages/sessions.astro"},{pattern:"/keys",entrypoint:"./pages/keys.astro"},{pattern:"/webhooks",entrypoint:"./pages/webhooks.astro"},{pattern:"/plugins",entrypoint:"./pages/plugins.astro"},{pattern:"/marketplace",entrypoint:"./pages/marketplace.astro"},{pattern:"/graphql",entrypoint:"./pages/graphql.astro"},{pattern:"/rest-playground",entrypoint:"./pages/rest-playground.astro"},{pattern:"/health",entrypoint:"./pages/health.astro"},{pattern:"/403",entrypoint:"./pages/403.astro"},{pattern:"/graphql-explorer",entrypoint:"./pages/graphql-explorer.astro"},{pattern:"/[collection]",entrypoint:"./pages/[collection]/index.astro"},{pattern:"/[collection]/[id]",entrypoint:"./pages/[collection]/[id].astro"}];for(let g of x){let f=`${t}${g.pattern}`.replace(/\/$/,"");s({pattern:f||"/",entrypoint:br__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,g.entrypoint)});}},"astro:build:done":({logger:a})=>{a.info("Kyro Admin build complete");}}}}exports.ActionBar=Si;exports.Admin=Of;exports.AutoForm=Ya;exports.Badge=Rt;exports.BulkActionsBar=zf;exports.Button=Is;exports.ConfirmModal=Vs;exports.CountBadge=Rs;exports.CreateView=Di;exports.DARK_THEME=Ea;exports.DarkThemeProvider=On;exports.DetailView=Ai;exports.Dropdown=Po;exports.DropdownItem=Pt;exports.DropdownSeparator=Xa;exports.ExtDarkThemeProvider=On;exports.ExtLightThemeProvider=Vn;exports.ExtThemeProvider=Sr;exports.Header=VR;exports.LIGHT_THEME=qo;exports.LightThemeProvider=Vn;exports.ListView=Ms;exports.LoginPage=Fi;exports.Modal=St;exports.PageHeader=Lt;exports.SlidePanel=yr;exports.Spinner=ar;exports.ThemeProvider=Sr;exports.Toast=xc;exports.ToastProvider=uF;exports.VersionHistoryPanel=Jf;exports.adminPath=Ue;exports.afterDeploy=Lc;exports.apiPath=wr;exports.beforeDeploy=Mc;exports.emitAdminReady=$c;exports.emitAfterDeploy=Oc;exports.emitBeforeDeploy=Vc;exports.getBlock=Jc;exports.getBlocks=Xc;exports.getBlocksByCategory=Yc;exports.getField=ru;exports.getFieldByType=au;exports.getFields=ou;exports.getPlugin=Kc;exports.getPlugins=Gc;exports.getPluginsWithHook=Wc;exports.kyroAdmin=bg;exports.mergeThemes=Ma;exports.onAdminReady=vs;exports.paths=Nu;exports.registerBlock=va;exports.registerField=xa;exports.registerPlugin=fa;exports.resolveAdmin=hs;exports.resolveApi=qe;exports.unregisterBlock=qc;exports.unregisterField=tu;exports.unregisterPlugin=_c;exports.useBlockRenderer=Qc;exports.useExtTheme=Jo;exports.useFieldRenderer=nu;exports.useKyroMutation=Hc;exports.useKyroQuery=jc;exports.useTheme=Jo;exports.useToast=pF;
|