@kyro-cms/core 0.10.12 → 0.10.13

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.
@@ -1,6 +1,6 @@
1
- 'use strict';var chunk65G73T7Z_cjs=require('./chunk-65G73T7Z.cjs'),chunkCVVW4LXZ_cjs=require('./chunk-CVVW4LXZ.cjs'),chunkCIE3XMLH_cjs=require('./chunk-CIE3XMLH.cjs'),chunkDAW5ZMWQ_cjs=require('./chunk-DAW5ZMWQ.cjs'),chunkISWMETHJ_cjs=require('./chunk-ISWMETHJ.cjs'),chunkNY47CFVP_cjs=require('./chunk-NY47CFVP.cjs'),chunkF7SR5IDT_cjs=require('./chunk-F7SR5IDT.cjs'),chunk6CLRVJPP_cjs=require('./chunk-6CLRVJPP.cjs'),chunkMIOMMB23_cjs=require('./chunk-MIOMMB23.cjs'),chunkDV4LFLPL_cjs=require('./chunk-DV4LFLPL.cjs'),zod=require('zod'),graphqlYoga=require('graphql-yoga'),module$1=require('module'),crypto=require('crypto');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function O(n,e){for(let t of n){if(t.name===e)return true;if("tabs"in t&&t.tabs){for(let s of t.tabs)if(O(s.fields,e))return true}if("fields"in t&&t.fields&&O(t.fields,e))return true}return false}var K=class extends Error{errors;constructor(e){super(`Configuration validation failed:
1
+ 'use strict';var chunk65G73T7Z_cjs=require('./chunk-65G73T7Z.cjs'),chunkCVVW4LXZ_cjs=require('./chunk-CVVW4LXZ.cjs'),chunkCIE3XMLH_cjs=require('./chunk-CIE3XMLH.cjs'),chunkPDSHJVCT_cjs=require('./chunk-PDSHJVCT.cjs'),chunkISWMETHJ_cjs=require('./chunk-ISWMETHJ.cjs'),chunkNY47CFVP_cjs=require('./chunk-NY47CFVP.cjs'),chunkF7SR5IDT_cjs=require('./chunk-F7SR5IDT.cjs'),chunk6CLRVJPP_cjs=require('./chunk-6CLRVJPP.cjs'),chunkMIOMMB23_cjs=require('./chunk-MIOMMB23.cjs'),chunkDV4LFLPL_cjs=require('./chunk-DV4LFLPL.cjs'),zod=require('zod'),graphqlYoga=require('graphql-yoga'),module$1=require('module'),crypto=require('crypto');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function O(n,e){for(let t of n){if(t.name===e)return true;if("tabs"in t&&t.tabs){for(let s of t.tabs)if(O(s.fields,e))return true}if("fields"in t&&t.fields&&O(t.fields,e))return true}return false}var K=class extends Error{errors;constructor(e){super(`Configuration validation failed:
2
2
  ${e.join(`
3
- `)}`),this.name="ConfigValidationError",this.errors=e;}};function V(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Collection slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Collection is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Collection "${n.slug}" has no fields defined`);else {let t=x(n.fields,n.slug);e.push(...t);}if(n.access)for(let[t,s]of Object.entries(n.access))typeof s!="boolean"&&typeof s!="function"&&e.push(`Collection "${n.slug}" has invalid access.${t} (must be boolean or function)`);if(n.admin?.useAsTitle&&(O(n.fields,n.admin.useAsTitle)||e.push(`Collection "${n.slug}" admin.useAsTitle references unknown field "${n.admin.useAsTitle}"`)),n.admin?.defaultColumns)for(let t of n.admin.defaultColumns)O(n.fields,t)||e.push(`Collection "${n.slug}" admin.defaultColumns references unknown field "${t}"`);if(n.upload&&n.upload.fileSize&&n.upload.fileSize<=0&&e.push(`Collection "${n.slug}" upload.fileSize must be positive`),n.versions&&n.versions.maxPerDoc&&n.versions.maxPerDoc<=0&&e.push(`Collection "${n.slug}" versions.maxPerDoc must be positive`),n.auth){let t=n.fields.some(a=>a.name==="email"),s=n.fields.some(a=>a.name==="password");t||e.push(`Collection "${n.slug}" with auth enabled requires an "email" field`),s||e.push(`Collection "${n.slug}" with auth enabled requires a "password" field`);}return e}function B(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Global slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Global is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Global "${n.slug}" has no fields defined`);else {let t=x(n.fields,`global:${n.slug}`);e.push(...t);}return e}function x(n,e){let t=[],s=new Set;for(let a=0;a<n.length;a++){let o=n[a];if(o.type==="row"||o.type==="collapsible"||o.type==="tabs"){if("fields"in o&&o.fields){let r=x(o.fields,e);t.push(...r);}else if("tabs"in o)for(let r of o.tabs){let c=x(r.fields,e);t.push(...c);}continue}let i=o.name;if(!i){t.push(`${e}: Field at index ${a} is missing a "name" property`);continue}if(s.has(i)&&t.push(`${e}: Duplicate field name "${i}"`),s.add(i),/^[a-zA-Z][a-zA-Z0-9_]*$/.test(i)||t.push(`${e}: Field name "${i}" must be alphanumeric with underscores`),!o.type){t.push(`${e}: Field "${i}" is missing a "type" property`);continue}switch(o.type){case "relationship":o.relationTo||t.push(`${e}: Relationship field "${i}" is missing "relationTo"`);break;case "array":if(!o.fields||o.fields.length===0)t.push(`${e}: Array field "${i}" has no fields defined`);else {let r=x(o.fields,`${e}.${i}`);t.push(...r);}break;case "group":if(!o.fields||o.fields.length===0)t.push(`${e}: Group field "${i}" has no fields defined`);else {let r=x(o.fields,`${e}.${i}`);t.push(...r);}break;case "blocks":if(!o.blocks||o.blocks.length===0)t.push(`${e}: Blocks field "${i}" has no blocks defined`);else {let r=ve(o.blocks,`${e}.${i}`);t.push(...r);}break;case "select":case "radio":if((!o.options||o.options.length===0)&&!o.dynamicOptions)t.push(`${e}: ${o.type} field "${i}" has no options defined`);else if(o.options){let r=o.options.map(d=>d.value),c=new Set(r);r.length!==c.size&&t.push(`${e}: ${o.type} field "${i}" has duplicate option values`);}break;case "upload":o.relationTo||t.push(`${e}: Upload field "${i}" is missing "relationTo"`);break}"min"in o&&"max"in o&&o.min>o.max&&t.push(`${e}: Field "${i}" has min greater than max`),"minLength"in o&&"maxLength"in o&&o.minLength>o.maxLength&&t.push(`${e}: Field "${i}" has minLength greater than maxLength`),"minRows"in o&&"maxRows"in o&&o.minRows>o.maxRows&&t.push(`${e}: Field "${i}" has minRows greater than maxRows`);}return t}function ve(n,e){let t=[],s=new Set;for(let a of n){if(!a.slug){t.push(`${e}: Block is missing a "slug" property`);continue}if(s.has(a.slug)&&t.push(`${e}: Duplicate block slug "${a.slug}"`),s.add(a.slug),a.label||t.push(`${e}: Block "${a.slug}" is missing a "label" property`),!a.fields||a.fields.length===0)t.push(`${e}: Block "${a.slug}" has no fields defined`);else {let o=x(a.fields,`${e}.${a.slug}`);t.push(...o);}}return t}function pe(n,e=[]){let t=[],s=new Set;for(let a of n)s.has(a.slug)&&t.push(`Duplicate collection slug "${a.slug}"`),s.add(a.slug);for(let a of e)s.has(a.slug)&&t.push(`Duplicate global slug "${a.slug}"`),s.add(a.slug);for(let a of n){let o=V(a);t.push(...o);}for(let a of e){let o=B(a);t.push(...o);}for(let a of n){let o=$(a.fields,n);t.push(...o);}if(t.length>0)throw new K(t)}function $(n,e){let t=[],s=new Set(e.map(a=>a.slug));for(let a of n){if(a.type==="relationship"){let o=Array.isArray(a.relationTo)?a.relationTo:[a.relationTo];for(let i of o)s.has(i)||console.warn(`[Kyro Config Warning]: Relationship field "${a.name}" references unknown collection "${i}". Select options will not be available until this collection is registered.`);}if(a.type==="upload"){let o=Array.isArray(a.relationTo)?a.relationTo:[a.relationTo];for(let i of o)s.has(i)||t.push(`Upload field "${a.name}" references unknown collection "${i}"`);}if("fields"in a&&a.fields){let o=$(a.fields,e);t.push(...o);}if("tabs"in a)for(let o of a.tabs){let i=$(o.fields,e);t.push(...i);}if("blocks"in a)for(let o of a.blocks){let i=$(o.fields,e);t.push(...i);}}return t}function C(n){switch(n.type){case "text":return De(n);case "number":return we(n);case "checkbox":return Fe(n);case "date":return Ie(n);case "email":return $e(n);case "password":return Oe(n);case "textarea":return Pe(n);case "select":return Le(n);case "radio":return ke(n);case "color":return _e(n);case "richtext":return je(n);case "json":return Ze(n);case "code":return qe(n);case "upload":return fe(n);case "image":return fe(n);case "markdown":return Ue(n);case "relationship":return ye(n);case "relationship-block":return ye(n);case "array":return Ge(n);case "list":return Ke(n);case "group":return Ve(n);case "blocks":return Be(n);case "row":return Me(n);case "collapsible":return ze(n);case "tabs":return We(n);default:return zod.z.any()}}function De(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.pattern&&(e=e.regex(new RegExp(n.pattern))),n.variant==="email"&&(e=e.email()),n.variant==="url"&&(e=e.url()),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function we(n){let e=n.integer?zod.z.coerce.number().int():zod.z.coerce.number();return n.min!==void 0&&(e=e.min(n.min)),n.max!==void 0&&(e=e.max(n.max)),n.step&&(e=e.refine(t=>Number.isInteger(t/n.step),`Value must be divisible by ${n.step}`)),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Fe(n){let e=zod.z.boolean();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ie(n){let e=zod.z.string().refine(t=>!isNaN(Date.parse(t)),"Invalid date format");return n.minDate&&(e=e.refine(t=>new Date(t)>=new Date(n.minDate),`Date must be after ${n.minDate}`)),n.maxDate&&(e=e.refine(t=>new Date(t)<=new Date(n.maxDate),`Date must be before ${n.maxDate}`)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function $e(n){let e=zod.z.string().email("Invalid email");return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Oe(n){let e=zod.z.string().min(6,"Password must be at least 6 characters");return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Pe(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Le(n){let e;if(n.options&&n.options.length>0){let t=n.options.map(s=>s.value);n.hasMany?e=zod.z.array(zod.z.enum(t)):e=zod.z.enum(t);}else e=n.hasMany?zod.z.array(zod.z.string()):zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function ke(n){let e=n.options.map(s=>s.value),t=zod.z.enum(e);return n.required||(t=t.optional().nullable()),n.validate&&(t=b(t,n.validate)),t}function _e(n){let e=zod.z.string();return n.format==="hex"&&(e=e.regex(/^#[0-9A-Fa-f]{6}$/)),n.format==="rgb"&&(e=e.regex(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/)),n.format==="hsl"&&(e=e.regex(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function je(n){let e=zod.z.array(zod.z.record(zod.z.any()));return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ze(n){let e=zod.z.union([zod.z.record(zod.z.any()),zod.z.array(zod.z.any())]);return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function qe(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function fe(n){let e;if(n.relationTo){let t=zod.z.object({id:zod.z.string(),url:zod.z.string().optional(),filename:zod.z.string().optional(),mimeType:zod.z.string().optional()});e=zod.z.union([zod.z.string(),t]);}else e=zod.z.string();return n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ue(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function ye(n){let e;return Array.isArray(n.relationTo)?e=zod.z.object({relationTo:zod.z.enum(n.relationTo),value:zod.z.string()}):e=zod.z.union([zod.z.string(),zod.z.object({relationTo:zod.z.string(),value:zod.z.string()})]),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ge(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(s=>s.name).map(s=>[s.name,C(s)]))),t=zod.z.array(e);return n.minRows&&(t=t.min(n.minRows)),n.maxRows&&(t=t.max(n.maxRows)),n.required||(t=t.optional().nullable()),n.validate&&(t=b(t,n.validate)),t}function Ke(n){let e=zod.z.array(zod.z.string());return n.required||(e=e.optional().nullable()),e}function Ve(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,C(t)])));return n.required?e:e.optional().nullable()}function Be(n){let e=n.blocks||[];e.map(o=>zod.z.object({blockType:zod.z.literal(o.slug),...Object.fromEntries(o.fields.filter(i=>i.name).map(i=>[i.name,C(i)]))}));let s=e.map(o=>o.slug),a;if(s.length>0){let o=zod.z.object({blockType:zod.z.enum(s)}).catchall(zod.z.any()),i=zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any());a=zod.z.array(zod.z.union([o,i,zod.z.record(zod.z.any())]));}else a=zod.z.array(zod.z.union([zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any()),zod.z.record(zod.z.any())]));return n.minRows&&(a=a.min(n.minRows)),n.maxRows&&(a=a.max(n.maxRows)),n.required||(a=a.optional().nullable()),n.validate&&(a=b(a,n.validate)),a}function Me(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,C(t)])))}function ze(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,C(t)])))}function We(n){let e={};for(let t of n.tabs)for(let s of t.fields)s.name&&(e[s.name]=C(s));return zod.z.object(e).passthrough().optional()}function b(n,e){return n.refine(async t=>await e(t,{required:false})===true,{message:"Custom validation failed"})}function R(n){let e={};for(let t of n)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs){let o=R(a.fields);Object.assign(s,o);}e[t.name]=zod.z.object(s).passthrough().optional();}else if(t.type==="row"&&"fields"in t){let s=R(t.fields);Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(R(t.fields)).passthrough().optional():e[t.name]=C(t);return e}function E(n){let e={};for(let t of n)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs){let o=E(a.fields);Object.assign(s,o);}e[t.name]=zod.z.object(s).passthrough().optional().nullable();}else if(t.type==="row"&&"fields"in t){let s=E(t.fields);Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).passthrough().optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).passthrough().optional().nullable():e[t.name]=C(t).optional().nullable();return e}function he(n){let e=R(n.fields);return n.timestamps&&(e.createdAt=zod.z.string().optional(),e.updatedAt=zod.z.string().optional()),n.tenantScoped&&(e.tenantID=zod.z.string().optional()),e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function ge(n){let e=R(n.fields);return zod.z.object(e).passthrough()}function me(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs)for(let o of a.fields)o.name&&(s[o.name]=C(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else if(t.type==="row"&&"fields"in t){let s={};for(let a of t.fields)a.name&&(s[a.name]=C(a).optional().nullable());Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():e[t.name]=C(t).optional().nullable();return zod.z.object(e).passthrough()}function be(n){let e={};for(let t of n.fields)t.name&&(e[t.name]=zod.z.object({equals:zod.z.any().optional(),not_equals:zod.z.any().optional(),in:zod.z.array(zod.z.any()).optional(),not_in:zod.z.array(zod.z.any()).optional(),greater_than:zod.z.number().optional(),greater_than_equal:zod.z.number().optional(),less_than:zod.z.number().optional(),less_than_equal:zod.z.number().optional(),like:zod.z.string().optional(),not_like:zod.z.string().optional(),contains:zod.z.string().optional(),exists:zod.z.boolean().optional()}).optional());return e.AND=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),e.OR=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),zod.z.object(e).optional()}function Te(n){let e=R(n.fields);return e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function Ce(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs)for(let o of a.fields)o.name&&(s[o.name]=C(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():e[t.name]=C(t).optional().nullable();return zod.z.object(e).passthrough()}var w=class{storageProviders=chunkDAW5ZMWQ_cjs.f();collections=new Map;globals=new Map;plugins=[];schemaCache=new Map;initialized=false;addCollection(e){if(this.initialized)throw new Error("Cannot add collections after Registry has been initialized");if(this.collections.has(e.slug)){console.warn(`[Registry] Duplicate collection slug "${e.slug}" \u2014 skipping`);return}let t={...e};for(let a of this.plugins)a.extendCollection&&(t=a.extendCollection(t.slug,t));t.fields=this.applyFieldDefaults(t);let s=V(t);if(s.length>0)throw new Error(`Invalid collection config: ${s.join(", ")}`);this.collections.set(t.slug,t),this.clearSchemaCache(t.slug);}addCollections(e){for(let t of e)this.addCollection(t);}getCollection(e){return this.collections.get(e)}getCollections(){return Array.from(this.collections.values())}getCollectionSlugs(){return Array.from(this.collections.keys())}hasCollection(e){return this.collections.has(e)}removeCollection(e){if(this.initialized)throw new Error("Cannot remove collections after Registry has been initialized");return this.clearSchemaCache(e),this.collections.delete(e)}addGlobal(e){if(this.initialized)throw new Error("Cannot add globals after Registry has been initialized");this._addGlobalUnsafe(e);}addGlobalPostInit(e){this.globals.has(e.slug)&&this.globals.delete(e.slug),this._addGlobalUnsafe(e);}_addGlobalUnsafe(e){if(this.globals.has(e.slug)){console.warn(`[Registry] Duplicate global slug "${e.slug}" \u2014 skipping`);return}let t=B(e);if(t.length>0)throw new Error(`Invalid global config: ${t.join(", ")}`);let s={...e};for(let a of this.plugins)a.extendGlobal&&(s=a.extendGlobal(s.slug,s));this.globals.set(s.slug,s),this.clearSchemaCache(`global:${s.slug}`);}addGlobals(e){for(let t of e)this.addGlobal(t);}getGlobal(e){return this.globals.get(e)}getGlobals(){return Array.from(this.globals.values())}getGlobalSlugs(){return Array.from(this.globals.keys())}hasGlobal(e){return this.globals.has(e)}removeGlobal(e){if(this.initialized)throw new Error("Cannot remove globals after Registry has been initialized");return this.clearSchemaCache(`global:${e}`),this.globals.delete(e)}addPlugin(e){if(this.initialized)throw new Error("Cannot add plugins after Registry has been initialized");this.plugins.push(e);}getPlugins(){return [...this.plugins]}getZodSchema(e){let t=this.schemaCache.get(e);if(t)return t;let s=this.collections.get(e);if(s){let o=he(s);return this.schemaCache.set(e,o),o}let a=this.globals.get(e);if(a){let o=Te(a);return this.schemaCache.set(`global:${e}`,o),o}throw new Error(`No collection or global found with slug "${e}"`)}getCreateZodSchema(e){let t=`${e}:create`,s=this.schemaCache.get(t);if(s)return s;let a=this.collections.get(e);if(a){let o=ge(a);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getUpdateZodSchema(e){let t=`${e}:update`,s=this.schemaCache.get(t);if(s)return s;let a=this.collections.get(e);if(a){let i=me(a);return this.schemaCache.set(t,i),i}let o=this.globals.get(e);if(o){let i=Ce(o);return this.schemaCache.set(`global:${e}:update`,i),i}throw new Error(`No collection or global found with slug "${e}"`)}getWhereZodSchema(e){let t=`${e}:where`,s=this.schemaCache.get(t);if(s)return s;let a=this.collections.get(e);if(a){let o=be(a);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getFieldZodSchema(e){return C(e)}clearSchemaCache(e){this.schemaCache.delete(e),this.schemaCache.delete(`${e}:create`),this.schemaCache.delete(`${e}:update`),this.schemaCache.delete(`${e}:where`);}applyFieldDefaults(e){let t=[...e.fields];return t.some(s=>s.name==="id")||t.unshift({name:"id",type:"text",admin:{readOnly:true,hidden:true}}),e.tenantScoped&&!t.some(s=>s.name==="tenantID")&&t.push({name:"tenantID",type:"text",required:true,admin:{readOnly:true,hidden:true}}),e.timestamps&&!t.some(s=>s.name==="createdAt")&&(t.push({name:"createdAt",type:"date",admin:{readOnly:true,hidden:true}}),t.push({name:"updatedAt",type:"date",admin:{readOnly:true,hidden:true}})),e.versions?.drafts&&!t.some(s=>s.name==="status")&&t.push({name:"status",type:"select",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}],admin:{readOnly:true,hidden:true}}),e.auth&&!t.some(s=>s.name==="password")&&t.push({name:"password",type:"password",required:true,admin:{hidden:true}}),t}getFields(e){let t=this.collections.get(e);if(t)return t.fields;let s=this.globals.get(e);if(s)return s.fields;throw new Error(`No collection or global found with slug "${e}"`)}getFieldMap(e){let t=this.getFields(e),s=new Map,a=o=>{for(let i of o){if(i.name&&s.set(i.name,i),"fields"in i&&i.fields&&a(i.fields),"tabs"in i)for(let r of i.tabs)a(r.fields);if("blocks"in i)for(let r of i.blocks)a(r.fields);}};return a(t),s}getVisibleFields(e){return this.getFields(e).filter(s=>!s.admin?.hidden)}validate(){let e=this.getCollections(),t=this.getGlobals();pe(e,t);}async init(e){this.validate();for(let t of this.plugins)t.init&&await t.init(e||this);this.initialized=true;}isInitialized(){return this.initialized}getPaginationDefaults(e){let t=this.collections.get(e);return {defaultLimit:t?.admin?.pagination?.defaultLimit||10,limits:t?.admin?.pagination?.limits||[10,25,50,100]}}getDefaultSort(e){let s=this.collections.get(e)?.admin?.useAsTitle;return s||"createdAt"}getDefaultColumns(e){let t=this.collections.get(e);return t?.admin?.defaultColumns?t.admin.defaultColumns:this.getVisibleFields(e).slice(0,4).map(a=>a.name)}getAdminTitle(e){let t=this.collections.get(e);return t?.label||t?.admin?.description||e}getAdminLabel(e){let t=this.collections.get(e);return t?.singularLabel||t?.label||e}getAdminGroup(e){return this.collections.get(e)?.admin?.group}getStats(){let e=0;for(let t of this.collections.values())e+=t.fields.length;for(let t of this.globals.values())e+=t.fields.length;return {collections:this.collections.size,globals:this.globals.size,plugins:this.plugins.length,fields:e}}toJSON(){return {collections:this.getCollections(),globals:this.getGlobals()}}},v=null;function Xe(){return v||(v=new w),v}function Je(){v=null;}function M(){return v=new w,v}var He={aws:{type:"aws",configKey:"s3",displayName:"S3 Compatible (AWS, Backblaze, Wasabi, etc.)",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1",admin:{placeholder:"us-east-1"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"endpoint",type:"text",label:"Endpoint URL",admin:{placeholder:"https://s3.custom.com"}},{name:"cdnUrl",type:"text",label:"CDN URL",admin:{placeholder:"https://cdn.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}]},r2:{type:"r2",configKey:"r2",displayName:"Cloudflare R2",configFields:[{name:"accountId",type:"text",label:"Account ID",required:true,admin:{placeholder:"Your Cloudflare Account ID"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"publicDevUrl",type:"text",label:"Public Dev URL ID",admin:{placeholder:"pub-xxxxxxxxxxxxxxxx",description:"Enter ONLY the ID (e.g., pub-b8d8c4cc8bcf4d868ddd95efc1b305aa). Do NOT include https:// or the full URL. Found in R2 Dashboard \u2192 Public Dev URL."}},{name:"cdnUrl",type:"text",label:"Custom CDN URL",admin:{placeholder:"https://assets.example.com (optional)"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads (optional)",description:"Optional prefix for all object keys. Do not use '/' as prefix."}}]},gcs:{type:"gcs",configKey:"gcs",displayName:"Google Cloud Storage",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"projectId",type:"text",label:"Project ID"},{name:"clientEmail",type:"text",label:"Client Email"},{name:"privateKey",type:"password",label:"Private Key"},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},digitalocean:{type:"digitalocean",configKey:"digitalocean",displayName:"DigitalOcean Spaces",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"nyc3"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},backblaze:{type:"backblaze",configKey:"backblaze",displayName:"Backblaze B2",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"accountId",type:"text",label:"Account ID"},{name:"applicationKeyId",type:"text",label:"Application Key ID",required:true},{name:"applicationKey",type:"password",label:"Application Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},wasabi:{type:"wasabi",configKey:"wasabi",displayName:"Wasabi",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]}};function Ye(n,e){switch(n){case "r2":return e?.endpoint||`https://${e?.accountId||""}.r2.cloudflarestorage.com`;case "digitalocean":return e?.endpoint||`https://${e?.region||"nyc3"}.digitaloceanspaces.com`;case "backblaze":return e?.endpoint||"https://s3.backblazeb2.com";case "wasabi":return e?.endpoint||`https://s3.${e?.region||"us-east-1"}.wasabisys.com`;default:return e?.endpoint}}function Ae(n,e){return {provider:n,bucket:e?.bucket||"",region:e?.region||"us-east-1",accessKeyId:e?.accessKeyId||e?.clientEmail||e?.applicationKeyId||"",secretAccessKey:e?.secretAccessKey||e?.privateKey||e?.applicationKey||"",endpoint:Ye(n,e),cdnUrl:e?.cdnUrl,prefix:e?.prefix,accountId:e?.accountId,publicDevUrl:e?.publicDevUrl}}function Qe(n,e,t){let s=t[e.configKey]||{};return Ae(n,s)}function et(n,e,t){let s=t?.[e.configKey]||t;return Ae(n,s)}var Se={name:"@kyro-cms/storage-s3",version:"1.0.0",description:"S3-compatible storage (AWS R2 GCS DigitalOcean Backblaze Wasabi)",init:n=>{let e=n.registry?.storageProviders;if(!e)return;let t="@kyro-cms/storage-s3";for(let s of Object.values(He))e.register({type:s.type,displayName:s.displayName,pluginName:t,configKey:s.configKey,configFields:s.configFields,extractConfig:a=>Qe(s.type,s,a),extractRawConfig:a=>et(s.type,s,a),factory:a=>chunkDAW5ZMWQ_cjs.a(a)});}};var Ee={name:"@kyro-cms/storage-cloudinary",version:"1.0.0",description:"Cloudinary image and video storage",init:n=>{let e=n.registry?.storageProviders;e&&e.register({type:"cloudinary",displayName:"Cloudinary",pluginName:"@kyro-cms/storage-cloudinary",configKey:"cloudinary",configFields:[{name:"cloudName",type:"text",label:"Cloud Name",required:true},{name:"apiKey",type:"text",label:"API Key",required:true},{name:"apiSecret",type:"password",label:"API Secret",required:true},{name:"folder",type:"text",label:"Folder",admin:{placeholder:"Optional folder path"}},{name:"uploadPreset",type:"text",label:"Upload Preset (optional)",admin:{placeholder:"Leave empty for signed uploads",description:"If not set, uploads will be signed with API Secret"}}],extractConfig:t=>({cloudName:t.cloudinary?.cloudName||"",apiKey:t.cloudinary?.apiKey||"",apiSecret:t.cloudinary?.apiSecret||"",folder:t.cloudinary?.folder,uploadPreset:t.cloudinary?.uploadPreset}),extractRawConfig:t=>{let s=t?.cloudinary||t;return {cloudName:s?.cloudName||"",apiKey:s?.apiKey||"",apiSecret:s?.apiSecret||"",folder:s?.folder,uploadPreset:s?.uploadPreset}},factory:t=>chunkDAW5ZMWQ_cjs.b(t)});}};var xe={name:"@kyro-cms/storage-ftp",version:"1.0.0",description:"FTP/SFTP storage provider",init:n=>{let e=n.registry?.storageProviders;e&&e.register({type:"ftp",displayName:"FTP",pluginName:"@kyro-cms/storage-ftp",configKey:"ftp",configFields:[{name:"host",type:"text",label:"Host",required:true,admin:{placeholder:"ftp.example.com"}},{name:"port",type:"number",label:"Port",defaultValue:21,admin:{placeholder:"21 for FTP"}},{name:"user",type:"text",label:"Username",required:true},{name:"password",type:"password",label:"Password",required:true},{name:"secure",type:"checkbox",label:"Use TLS/SSL",defaultValue:false,admin:{description:"Enable TLS/SSL for secure connections (FTP only)"}},{name:"baseUrl",type:"text",label:"Base URL",required:true,admin:{placeholder:"https://files.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}],extractConfig:t=>({host:t.ftp?.host||"",port:t.ftp?.port||21,user:t.ftp?.user||"",password:t.ftp?.password||"",secure:t.ftp?.secure||false,baseUrl:t.ftp?.baseUrl||"",prefix:t.ftp?.prefix,type:"ftp"}),extractRawConfig:t=>{let s=t?.ftp||t;return {host:s?.host||"",port:s?.port||21,user:s?.user||"",password:s?.password||"",secure:s?.secure||false,baseUrl:s?.baseUrl||"",prefix:s?.prefix,type:"ftp"}},factory:t=>chunkDAW5ZMWQ_cjs.c(t)});}};var nt=[Se,Ee,xe];function z(n,e,t){let s=e.split(".");if(s.length===0)return false;let a=s[0],o=s.slice(1).join(".");for(let i of n)if(i.name===a)return o?i.fields&&Array.isArray(i.fields)||i.type==="array"&&i.fields&&Array.isArray(i.fields)?z(i.fields,o,t):false:(Object.assign(i,t),true);return false}function st(n,e){if(e)for(let t of n){let s=e[t.slug];if(s){let{fields:a,...o}=s;if(t.admin={...t.admin,...o},a&&t.fields&&Array.isArray(t.fields))for(let[i,r]of Object.entries(a))z(t.fields,i,r);}}}var W=class{registry;db;pubsub;webhookService;settings;wsServer;config;constructor(e){this.config=e,this.registry=M(),this.db=e.adapter,this.pubsub=new chunkF7SR5IDT_cjs.b(this.registry),this.webhookService=chunkISWMETHJ_cjs.n(this.db);for(let t of nt)this.registry.addPlugin(t);if(e.plugins)for(let t of e.plugins)this.registry.addPlugin(t);e.collections&&e.admin?.collectionOverrides&&st(e.collections,e.admin.collectionOverrides),e.collections&&this.registry.addCollections(e.collections),e.globals&&this.registry.addGlobals(e.globals);}async init(){await this.registry.init(this),this.registry.addGlobalPostInit(chunk65G73T7Z_cjs.a);let e={slug:"plugin-settings",admin:{hidden:true},fields:[{name:"states",type:"json"}]};if(this.registry.addGlobalPostInit(e),!this.db)throw new Error("Database adapter is null \u2014 failed to load at startup. Check the server console for the exact error.");let t={slug:chunkNY47CFVP_cjs.d,fields:[{name:"userId",type:"text",required:true},{name:"name",type:"text",required:true},{name:"key",type:"text",required:true},{name:"keyPrefix",type:"text",required:true},{name:"permissions",type:"json"},{name:"lastUsedAt",type:"date"},{name:"expiresAt",type:"date"}]},s={slug:chunkISWMETHJ_cjs.e,fields:[{name:"name",type:"text",required:true},{name:"url",type:"text",required:true},{name:"events",type:"json",required:true},{name:"status",type:"text",required:true},{name:"secret",type:"text"},{name:"headers",type:"json"},{name:"lastTriggered",type:"date"},{name:"lastError",type:"text"}]},a={slug:chunkISWMETHJ_cjs.f,fields:[{name:"webhookId",type:"text",required:true},{name:"event",type:"text",required:true},{name:"payload",type:"json",required:true},{name:"attempt",type:"number",required:true},{name:"status",type:"text",required:true},{name:"responseStatus",type:"number"},{name:"responseBody",type:"text"},{name:"error",type:"text"},{name:"duration",type:"number"},{name:"deliveredAt",type:"date"},{name:"nextRetryAt",type:"date"}]},o=this.registry.getGlobals();if(this.db instanceof chunk6CLRVJPP_cjs.c&&this.db.dialect==="postgres"){let i=this.db,r=chunkNY47CFVP_cjs.d.replace(/-/g,"_");i.schema[r]||(i.schema[r]=chunkMIOMMB23_cjs.g);}await this.db.init([...this.registry.getCollections(),t,s,a],o),await this.loadPluginState(),this.pubsub.autoRegisterHooks();}async loadSettings(){if(this.settings)return this.settings;try{let e=await this.db.findOne({collection:"_globals_access-settings",where:{},draft:!0});e&&(this.settings={access:e});}catch{}return this.settings||{}}async loadPluginState(){let e=this.registry.storageProviders,t=e.getAllPluginNames(),s={};try{let a=await this.db.findOne({collection:"_globals_plugin-settings",where:{},draft:!0});a&&a.states&&(s=a.states);}catch{}for(let a of t)s[a]!==void 0&&e.setPluginEnabled(a,s[a]);}getREST(e){let t=typeof this.config.auth=="object"?this.config.auth:null,s=t?.secret,a=t?.checkSession!==false;return chunkDAW5ZMWQ_cjs.s({registry:this.registry,db:this.db,authSecret:s,authAdapter:this.config.authAdapter,checkSession:a,...e,cors:this.config.cors,webhookService:this.webhookService,settings:this.settings})}getGraphQL(e){let t=chunkCIE3XMLH_cjs.c({registry:this.registry,db:this.db,settings:this.settings});return {fetch:graphqlYoga.createYoga({schema:t,context:async({request:a})=>{let o=chunkNY47CFVP_cjs.f(a),i,r;if(o&&this.db){let d=await chunkNY47CFVP_cjs.e(o,this.db);d.user&&(i=d.user,r=chunkNY47CFVP_cjs.g(d));}let c=e?.tenantID;return {db:this.db,registry:this.registry,user:i,req:a,tenantID:c,apiKey:r,relationLoader:new chunkCIE3XMLH_cjs.a({db:this.db,tenantID:c,user:i})}},graphiql:this.config.graphQL?.disablePlayground!==true,plugins:[]}).fetch,schema:t}}getTRPC(e){return {fetch:async(t,s)=>{let o=new URL(t.url).pathname.replace(/^\/api\/trpc\//,""),[i,...r]=o.split("."),c=r.join(".");if(c=c.replace(/\.(query|mutate|subscribe)$/,""),!i||!c)return new Response(JSON.stringify({error:{message:"Invalid tRPC path",code:-32600,data:{code:"BAD_REQUEST",httpStatus:400}}}),{status:400,headers:{"Content-Type":"application/json"}});let d=await chunkCVVW4LXZ_cjs.a({db:this.db,registry:this.registry,req:t,user:e?.user,tenantID:e?.tenantID,settings:this.settings}),h=chunkCVVW4LXZ_cjs.i(d)[i];if(!h)return new Response(JSON.stringify({error:{message:`Collection '${i}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});let g=h[c];if(typeof g!="function")return new Response(JSON.stringify({error:{message:`Procedure '${c}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});try{let p={};if(t.method==="POST"||t.method==="PATCH")p=await t.json().catch(()=>({}));else {let S=new URL(t.url).searchParams.get("input");if(S)try{p=JSON.parse(decodeURIComponent(S));}catch{}}let f=p?.["0"]??p,m=await g({...f,collection:i});return new Response(JSON.stringify({result:{data:m}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(p){let f=p.message||"Internal error",m=f.includes("not found")?404:f.includes("denied")||f.includes("authentication required")?403:f.includes("conflict")?409:500,S=m===404?-32601:m===403?-32001:m===409?-32002:-32603;return new Response(JSON.stringify({error:{message:f,code:S,data:{code:"INTERNAL_SERVER_ERROR",httpStatus:m}}}),{status:m,headers:{"Content-Type":"application/json"}})}},router:null}}getWS(){return this.wsServer}async startWebSocket(e){let t=this.settings?.access?.apiAccess;if(t?.wsEnabled===false)return null;let s=async a=>{let o=await chunkNY47CFVP_cjs.e(a,this.db);if(!o.valid)throw new Error(o.error||"Invalid API key");if(!o.user)throw new Error("API key has no associated user");return o.user};return this.wsServer=chunkF7SR5IDT_cjs.d({pubsub:this.pubsub,port:e?.port||8080,requireAuth:e?.requireAuth??t?.requireAuth,verifyToken:e?.verifyToken||s}),this.wsServer}async shutdown(){this.wsServer&&await this.wsServer.close(),await this.db.disconnect();}};function Mt(n){return new W(n)}var it=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-ZWT5MX7S.cjs', document.baseURI).href))),ot="node:sqlite",{DatabaseSync:rt}=it(ot);function N(n){let e=[];for(let t of n)if(t.type==="tabs"&&"tabs"in t)for(let s of t.tabs)e.push(...N(s.fields));else t.type==="row"&&"fields"in t?e.push(...N(t.fields)):t.type==="collapsible"&&"fields"in t?e.push(...N(t.fields)):e.push(t);return e}function ct(n,e){let t=e,s=n[t.name];if(t.type==="json"||t.type==="richtext"||t.type==="array"||t.type==="group"||t.type==="blocks"||t.type==="list"||t.type==="relationship-block")try{s=s?JSON.parse(s):null;}catch{s=null;}if(t.type==="checkbox"&&(s=!!s),t.type==="date"&&s)try{let a=new Date(s);isNaN(a.getTime())?s=null:s=a.toISOString();}catch{s=null;}if((t.type==="upload"||t.type==="image")&&s)try{let a=JSON.parse(s);Array.isArray(a)?s=a.map(o=>typeof o=="object"&&o!==null?o:{id:o}):s=typeof a=="object"?a:{id:a};}catch{s={id:s};}if(t.type==="relationship"&&s)try{let a=JSON.parse(s);Array.isArray(a),s=a;}catch{s={relationTo:Array.isArray(t.relationTo)?t.relationTo[0]:t.relationTo,value:s};}if(t.type==="list"&&s)try{let a=JSON.parse(s);s=Array.isArray(a)?a:[];}catch{s=[];}if(t.type==="relationship-block"&&s)try{let a=JSON.parse(s);s=Array.isArray(a)?a:[];}catch{s=[];}return s}function X(n,e){try{return n.prepare(`PRAGMA table_info(${e})`).all().map(s=>s.name)}catch{return []}}var J=class extends chunkDV4LFLPL_cjs.a{db;path;migrations=new Map;versionsTableName="kyro_versions";constructor(e){super(),this.path=e.path,e.db?this.db=e.db:this.db=null;}async connect(){if(this.db||(this.db=new rt(this.path||":memory:")),this.db&&typeof this.db.prepare=="function"&&!this.db.prepare.__wrapped){let e=this.db.prepare.bind(this.db),t=s=>{let a=e(s),o=i=>typeof i=="boolean"?i?1:0:i===void 0?null:i;return new Proxy(a,{get(i,r,c){if(r==="all")return (...u)=>i.all(...u.map(o));if(r==="get")return (...u)=>i.get(...u.map(o));if(r==="run")return (...u)=>i.run(...u.map(o));let d=Reflect.get(i,r,c);return typeof d=="function"?d.bind(i):d}})};t.__wrapped=true,this.db.prepare=t;}this.db.exec("PRAGMA journal_mode = WAL"),this.db.exec("PRAGMA foreign_keys = ON"),this.connected=true;}async disconnect(){this.db&&this.db.close(),this.connected=false;}ensureTable(e,t){let s=t||this.getTableNameFor(e.slug),a=["id TEXT PRIMARY KEY"];for(let i of N(e.fields)){if(!i.name||i.name==="id")continue;let r=this.fieldToSQL(i);r&&a.push(r);}a.push(`${this.col("createdAt")} TEXT DEFAULT (datetime('now'))`),a.push(`${this.col("updatedAt")} TEXT DEFAULT (datetime('now'))`),a.push("status TEXT DEFAULT 'draft'"),a.push("hasDraft INTEGER DEFAULT 0"),e.tenantScoped&&a.push("tenant_id TEXT NOT NULL");let o=X(this.db,s);if(o.length===0){let i=`CREATE TABLE IF NOT EXISTS ${s} (${a.join(", ")})`;this.db.exec(i),this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_status ON ${s}(status)`);for(let r of N(e.fields))r.name&&r.indexed&&this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_${r.name} ON ${s}(${this.col(r.name)})`),r.name&&r.unique&&this.db.exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_${s}_${r.name}_unique ON ${s}(${this.col(r.name)})`);}else {let i=new Set(o);for(let r of a){let c=r.split(" ")[0].replace(/^"/,"").replace(/"$/,"");if(!i.has(c)&&c!=="id")try{c==="status"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(c)} TEXT DEFAULT 'published'`):c==="hasDraft"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(c)} INTEGER DEFAULT 0`):this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(c)} TEXT`);}catch{}}}this.migrations.set(s,true);}ensureVersionsTable(){this.db.exec(`
3
+ `)}`),this.name="ConfigValidationError",this.errors=e;}};function V(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Collection slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Collection is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Collection "${n.slug}" has no fields defined`);else {let t=x(n.fields,n.slug);e.push(...t);}if(n.access)for(let[t,s]of Object.entries(n.access))typeof s!="boolean"&&typeof s!="function"&&e.push(`Collection "${n.slug}" has invalid access.${t} (must be boolean or function)`);if(n.admin?.useAsTitle&&(O(n.fields,n.admin.useAsTitle)||e.push(`Collection "${n.slug}" admin.useAsTitle references unknown field "${n.admin.useAsTitle}"`)),n.admin?.defaultColumns)for(let t of n.admin.defaultColumns)O(n.fields,t)||e.push(`Collection "${n.slug}" admin.defaultColumns references unknown field "${t}"`);if(n.upload&&n.upload.fileSize&&n.upload.fileSize<=0&&e.push(`Collection "${n.slug}" upload.fileSize must be positive`),n.versions&&n.versions.maxPerDoc&&n.versions.maxPerDoc<=0&&e.push(`Collection "${n.slug}" versions.maxPerDoc must be positive`),n.auth){let t=n.fields.some(a=>a.name==="email"),s=n.fields.some(a=>a.name==="password");t||e.push(`Collection "${n.slug}" with auth enabled requires an "email" field`),s||e.push(`Collection "${n.slug}" with auth enabled requires a "password" field`);}return e}function B(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Global slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Global is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Global "${n.slug}" has no fields defined`);else {let t=x(n.fields,`global:${n.slug}`);e.push(...t);}return e}function x(n,e){let t=[],s=new Set;for(let a=0;a<n.length;a++){let o=n[a];if(o.type==="row"||o.type==="collapsible"||o.type==="tabs"){if("fields"in o&&o.fields){let r=x(o.fields,e);t.push(...r);}else if("tabs"in o)for(let r of o.tabs){let c=x(r.fields,e);t.push(...c);}continue}let i=o.name;if(!i){t.push(`${e}: Field at index ${a} is missing a "name" property`);continue}if(s.has(i)&&t.push(`${e}: Duplicate field name "${i}"`),s.add(i),/^[a-zA-Z][a-zA-Z0-9_]*$/.test(i)||t.push(`${e}: Field name "${i}" must be alphanumeric with underscores`),!o.type){t.push(`${e}: Field "${i}" is missing a "type" property`);continue}switch(o.type){case "relationship":o.relationTo||t.push(`${e}: Relationship field "${i}" is missing "relationTo"`);break;case "array":if(!o.fields||o.fields.length===0)t.push(`${e}: Array field "${i}" has no fields defined`);else {let r=x(o.fields,`${e}.${i}`);t.push(...r);}break;case "group":if(!o.fields||o.fields.length===0)t.push(`${e}: Group field "${i}" has no fields defined`);else {let r=x(o.fields,`${e}.${i}`);t.push(...r);}break;case "blocks":if(!o.blocks||o.blocks.length===0)t.push(`${e}: Blocks field "${i}" has no blocks defined`);else {let r=ve(o.blocks,`${e}.${i}`);t.push(...r);}break;case "select":case "radio":if((!o.options||o.options.length===0)&&!o.dynamicOptions)t.push(`${e}: ${o.type} field "${i}" has no options defined`);else if(o.options){let r=o.options.map(d=>d.value),c=new Set(r);r.length!==c.size&&t.push(`${e}: ${o.type} field "${i}" has duplicate option values`);}break;case "upload":o.relationTo||t.push(`${e}: Upload field "${i}" is missing "relationTo"`);break}"min"in o&&"max"in o&&o.min>o.max&&t.push(`${e}: Field "${i}" has min greater than max`),"minLength"in o&&"maxLength"in o&&o.minLength>o.maxLength&&t.push(`${e}: Field "${i}" has minLength greater than maxLength`),"minRows"in o&&"maxRows"in o&&o.minRows>o.maxRows&&t.push(`${e}: Field "${i}" has minRows greater than maxRows`);}return t}function ve(n,e){let t=[],s=new Set;for(let a of n){if(!a.slug){t.push(`${e}: Block is missing a "slug" property`);continue}if(s.has(a.slug)&&t.push(`${e}: Duplicate block slug "${a.slug}"`),s.add(a.slug),a.label||t.push(`${e}: Block "${a.slug}" is missing a "label" property`),!a.fields||a.fields.length===0)t.push(`${e}: Block "${a.slug}" has no fields defined`);else {let o=x(a.fields,`${e}.${a.slug}`);t.push(...o);}}return t}function pe(n,e=[]){let t=[],s=new Set;for(let a of n)s.has(a.slug)&&t.push(`Duplicate collection slug "${a.slug}"`),s.add(a.slug);for(let a of e)s.has(a.slug)&&t.push(`Duplicate global slug "${a.slug}"`),s.add(a.slug);for(let a of n){let o=V(a);t.push(...o);}for(let a of e){let o=B(a);t.push(...o);}for(let a of n){let o=$(a.fields,n);t.push(...o);}if(t.length>0)throw new K(t)}function $(n,e){let t=[],s=new Set(e.map(a=>a.slug));for(let a of n){if(a.type==="relationship"){let o=Array.isArray(a.relationTo)?a.relationTo:[a.relationTo];for(let i of o)s.has(i)||console.warn(`[Kyro Config Warning]: Relationship field "${a.name}" references unknown collection "${i}". Select options will not be available until this collection is registered.`);}if(a.type==="upload"){let o=Array.isArray(a.relationTo)?a.relationTo:[a.relationTo];for(let i of o)s.has(i)||t.push(`Upload field "${a.name}" references unknown collection "${i}"`);}if("fields"in a&&a.fields){let o=$(a.fields,e);t.push(...o);}if("tabs"in a)for(let o of a.tabs){let i=$(o.fields,e);t.push(...i);}if("blocks"in a)for(let o of a.blocks){let i=$(o.fields,e);t.push(...i);}}return t}function C(n){switch(n.type){case "text":return De(n);case "number":return we(n);case "checkbox":return Fe(n);case "date":return Ie(n);case "email":return $e(n);case "password":return Oe(n);case "textarea":return Pe(n);case "select":return Le(n);case "radio":return ke(n);case "color":return _e(n);case "richtext":return je(n);case "json":return Ze(n);case "code":return qe(n);case "upload":return fe(n);case "image":return fe(n);case "markdown":return Ue(n);case "relationship":return ye(n);case "relationship-block":return ye(n);case "array":return Ge(n);case "list":return Ke(n);case "group":return Ve(n);case "blocks":return Be(n);case "row":return Me(n);case "collapsible":return ze(n);case "tabs":return We(n);default:return zod.z.any()}}function De(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.pattern&&(e=e.regex(new RegExp(n.pattern))),n.variant==="email"&&(e=e.email()),n.variant==="url"&&(e=e.url()),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function we(n){let e=n.integer?zod.z.coerce.number().int():zod.z.coerce.number();return n.min!==void 0&&(e=e.min(n.min)),n.max!==void 0&&(e=e.max(n.max)),n.step&&(e=e.refine(t=>Number.isInteger(t/n.step),`Value must be divisible by ${n.step}`)),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Fe(n){let e=zod.z.boolean();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ie(n){let e=zod.z.string().refine(t=>!isNaN(Date.parse(t)),"Invalid date format");return n.minDate&&(e=e.refine(t=>new Date(t)>=new Date(n.minDate),`Date must be after ${n.minDate}`)),n.maxDate&&(e=e.refine(t=>new Date(t)<=new Date(n.maxDate),`Date must be before ${n.maxDate}`)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function $e(n){let e=zod.z.string().email("Invalid email");return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Oe(n){let e=zod.z.string().min(6,"Password must be at least 6 characters");return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Pe(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Le(n){let e;if(n.options&&n.options.length>0){let t=n.options.map(s=>s.value);n.hasMany?e=zod.z.array(zod.z.enum(t)):e=zod.z.enum(t);}else e=n.hasMany?zod.z.array(zod.z.string()):zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function ke(n){let e=n.options.map(s=>s.value),t=zod.z.enum(e);return n.required||(t=t.optional().nullable()),n.validate&&(t=b(t,n.validate)),t}function _e(n){let e=zod.z.string();return n.format==="hex"&&(e=e.regex(/^#[0-9A-Fa-f]{6}$/)),n.format==="rgb"&&(e=e.regex(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/)),n.format==="hsl"&&(e=e.regex(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function je(n){let e=zod.z.array(zod.z.record(zod.z.any()));return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ze(n){let e=zod.z.union([zod.z.record(zod.z.any()),zod.z.array(zod.z.any())]);return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function qe(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function fe(n){let e;if(n.relationTo){let t=zod.z.object({id:zod.z.string(),url:zod.z.string().optional(),filename:zod.z.string().optional(),mimeType:zod.z.string().optional()});e=zod.z.union([zod.z.string(),t]);}else e=zod.z.string();return n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ue(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function ye(n){let e;return Array.isArray(n.relationTo)?e=zod.z.object({relationTo:zod.z.enum(n.relationTo),value:zod.z.string()}):e=zod.z.union([zod.z.string(),zod.z.object({relationTo:zod.z.string(),value:zod.z.string()})]),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=b(e,n.validate)),e}function Ge(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(s=>s.name).map(s=>[s.name,C(s)]))),t=zod.z.array(e);return n.minRows&&(t=t.min(n.minRows)),n.maxRows&&(t=t.max(n.maxRows)),n.required||(t=t.optional().nullable()),n.validate&&(t=b(t,n.validate)),t}function Ke(n){let e=zod.z.array(zod.z.string());return n.required||(e=e.optional().nullable()),e}function Ve(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,C(t)])));return n.required?e:e.optional().nullable()}function Be(n){let e=n.blocks||[];e.map(o=>zod.z.object({blockType:zod.z.literal(o.slug),...Object.fromEntries(o.fields.filter(i=>i.name).map(i=>[i.name,C(i)]))}));let s=e.map(o=>o.slug),a;if(s.length>0){let o=zod.z.object({blockType:zod.z.enum(s)}).catchall(zod.z.any()),i=zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any());a=zod.z.array(zod.z.union([o,i,zod.z.record(zod.z.any())]));}else a=zod.z.array(zod.z.union([zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any()),zod.z.record(zod.z.any())]));return n.minRows&&(a=a.min(n.minRows)),n.maxRows&&(a=a.max(n.maxRows)),n.required||(a=a.optional().nullable()),n.validate&&(a=b(a,n.validate)),a}function Me(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,C(t)])))}function ze(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,C(t)])))}function We(n){let e={};for(let t of n.tabs)for(let s of t.fields)s.name&&(e[s.name]=C(s));return zod.z.object(e).passthrough().optional()}function b(n,e){return n.refine(async t=>await e(t,{required:false})===true,{message:"Custom validation failed"})}function R(n){let e={};for(let t of n)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs){let o=R(a.fields);Object.assign(s,o);}e[t.name]=zod.z.object(s).passthrough().optional();}else if(t.type==="row"&&"fields"in t){let s=R(t.fields);Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(R(t.fields)).passthrough().optional():e[t.name]=C(t);return e}function E(n){let e={};for(let t of n)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs){let o=E(a.fields);Object.assign(s,o);}e[t.name]=zod.z.object(s).passthrough().optional().nullable();}else if(t.type==="row"&&"fields"in t){let s=E(t.fields);Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).passthrough().optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).passthrough().optional().nullable():e[t.name]=C(t).optional().nullable();return e}function he(n){let e=R(n.fields);return n.timestamps&&(e.createdAt=zod.z.string().optional(),e.updatedAt=zod.z.string().optional()),n.tenantScoped&&(e.tenantID=zod.z.string().optional()),e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function ge(n){let e=R(n.fields);return zod.z.object(e).passthrough()}function me(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs)for(let o of a.fields)o.name&&(s[o.name]=C(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else if(t.type==="row"&&"fields"in t){let s={};for(let a of t.fields)a.name&&(s[a.name]=C(a).optional().nullable());Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():e[t.name]=C(t).optional().nullable();return zod.z.object(e).passthrough()}function be(n){let e={};for(let t of n.fields)t.name&&(e[t.name]=zod.z.object({equals:zod.z.any().optional(),not_equals:zod.z.any().optional(),in:zod.z.array(zod.z.any()).optional(),not_in:zod.z.array(zod.z.any()).optional(),greater_than:zod.z.number().optional(),greater_than_equal:zod.z.number().optional(),less_than:zod.z.number().optional(),less_than_equal:zod.z.number().optional(),like:zod.z.string().optional(),not_like:zod.z.string().optional(),contains:zod.z.string().optional(),exists:zod.z.boolean().optional()}).optional());return e.AND=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),e.OR=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),zod.z.object(e).optional()}function Te(n){let e=R(n.fields);return e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function Ce(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let a of t.tabs)for(let o of a.fields)o.name&&(s[o.name]=C(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(E(t.fields)).optional().nullable():e[t.name]=C(t).optional().nullable();return zod.z.object(e).passthrough()}var w=class{storageProviders=chunkPDSHJVCT_cjs.f();collections=new Map;globals=new Map;plugins=[];schemaCache=new Map;initialized=false;addCollection(e){if(this.initialized)throw new Error("Cannot add collections after Registry has been initialized");if(this.collections.has(e.slug)){console.warn(`[Registry] Duplicate collection slug "${e.slug}" \u2014 skipping`);return}let t={...e};for(let a of this.plugins)a.extendCollection&&(t=a.extendCollection(t.slug,t));t.fields=this.applyFieldDefaults(t);let s=V(t);if(s.length>0)throw new Error(`Invalid collection config: ${s.join(", ")}`);this.collections.set(t.slug,t),this.clearSchemaCache(t.slug);}addCollections(e){for(let t of e)this.addCollection(t);}getCollection(e){return this.collections.get(e)}getCollections(){return Array.from(this.collections.values())}getCollectionSlugs(){return Array.from(this.collections.keys())}hasCollection(e){return this.collections.has(e)}removeCollection(e){if(this.initialized)throw new Error("Cannot remove collections after Registry has been initialized");return this.clearSchemaCache(e),this.collections.delete(e)}addGlobal(e){if(this.initialized)throw new Error("Cannot add globals after Registry has been initialized");this._addGlobalUnsafe(e);}addGlobalPostInit(e){this.globals.has(e.slug)&&this.globals.delete(e.slug),this._addGlobalUnsafe(e);}_addGlobalUnsafe(e){if(this.globals.has(e.slug)){console.warn(`[Registry] Duplicate global slug "${e.slug}" \u2014 skipping`);return}let t=B(e);if(t.length>0)throw new Error(`Invalid global config: ${t.join(", ")}`);let s={...e};for(let a of this.plugins)a.extendGlobal&&(s=a.extendGlobal(s.slug,s));this.globals.set(s.slug,s),this.clearSchemaCache(`global:${s.slug}`);}addGlobals(e){for(let t of e)this.addGlobal(t);}getGlobal(e){return this.globals.get(e)}getGlobals(){return Array.from(this.globals.values())}getGlobalSlugs(){return Array.from(this.globals.keys())}hasGlobal(e){return this.globals.has(e)}removeGlobal(e){if(this.initialized)throw new Error("Cannot remove globals after Registry has been initialized");return this.clearSchemaCache(`global:${e}`),this.globals.delete(e)}addPlugin(e){if(this.initialized)throw new Error("Cannot add plugins after Registry has been initialized");this.plugins.push(e);}getPlugins(){return [...this.plugins]}getZodSchema(e){let t=this.schemaCache.get(e);if(t)return t;let s=this.collections.get(e);if(s){let o=he(s);return this.schemaCache.set(e,o),o}let a=this.globals.get(e);if(a){let o=Te(a);return this.schemaCache.set(`global:${e}`,o),o}throw new Error(`No collection or global found with slug "${e}"`)}getCreateZodSchema(e){let t=`${e}:create`,s=this.schemaCache.get(t);if(s)return s;let a=this.collections.get(e);if(a){let o=ge(a);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getUpdateZodSchema(e){let t=`${e}:update`,s=this.schemaCache.get(t);if(s)return s;let a=this.collections.get(e);if(a){let i=me(a);return this.schemaCache.set(t,i),i}let o=this.globals.get(e);if(o){let i=Ce(o);return this.schemaCache.set(`global:${e}:update`,i),i}throw new Error(`No collection or global found with slug "${e}"`)}getWhereZodSchema(e){let t=`${e}:where`,s=this.schemaCache.get(t);if(s)return s;let a=this.collections.get(e);if(a){let o=be(a);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getFieldZodSchema(e){return C(e)}clearSchemaCache(e){this.schemaCache.delete(e),this.schemaCache.delete(`${e}:create`),this.schemaCache.delete(`${e}:update`),this.schemaCache.delete(`${e}:where`);}applyFieldDefaults(e){let t=[...e.fields];return t.some(s=>s.name==="id")||t.unshift({name:"id",type:"text",admin:{readOnly:true,hidden:true}}),e.tenantScoped&&!t.some(s=>s.name==="tenantID")&&t.push({name:"tenantID",type:"text",required:true,admin:{readOnly:true,hidden:true}}),e.timestamps&&!t.some(s=>s.name==="createdAt")&&(t.push({name:"createdAt",type:"date",admin:{readOnly:true,hidden:true}}),t.push({name:"updatedAt",type:"date",admin:{readOnly:true,hidden:true}})),e.versions?.drafts&&!t.some(s=>s.name==="status")&&t.push({name:"status",type:"select",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}],admin:{readOnly:true,hidden:true}}),e.auth&&!t.some(s=>s.name==="password")&&t.push({name:"password",type:"password",required:true,admin:{hidden:true}}),t}getFields(e){let t=this.collections.get(e);if(t)return t.fields;let s=this.globals.get(e);if(s)return s.fields;throw new Error(`No collection or global found with slug "${e}"`)}getFieldMap(e){let t=this.getFields(e),s=new Map,a=o=>{for(let i of o){if(i.name&&s.set(i.name,i),"fields"in i&&i.fields&&a(i.fields),"tabs"in i)for(let r of i.tabs)a(r.fields);if("blocks"in i)for(let r of i.blocks)a(r.fields);}};return a(t),s}getVisibleFields(e){return this.getFields(e).filter(s=>!s.admin?.hidden)}validate(){let e=this.getCollections(),t=this.getGlobals();pe(e,t);}async init(e){this.validate();for(let t of this.plugins)t.init&&await t.init(e||this);this.initialized=true;}isInitialized(){return this.initialized}getPaginationDefaults(e){let t=this.collections.get(e);return {defaultLimit:t?.admin?.pagination?.defaultLimit||10,limits:t?.admin?.pagination?.limits||[10,25,50,100]}}getDefaultSort(e){let s=this.collections.get(e)?.admin?.useAsTitle;return s||"createdAt"}getDefaultColumns(e){let t=this.collections.get(e);return t?.admin?.defaultColumns?t.admin.defaultColumns:this.getVisibleFields(e).slice(0,4).map(a=>a.name)}getAdminTitle(e){let t=this.collections.get(e);return t?.label||t?.admin?.description||e}getAdminLabel(e){let t=this.collections.get(e);return t?.singularLabel||t?.label||e}getAdminGroup(e){return this.collections.get(e)?.admin?.group}getStats(){let e=0;for(let t of this.collections.values())e+=t.fields.length;for(let t of this.globals.values())e+=t.fields.length;return {collections:this.collections.size,globals:this.globals.size,plugins:this.plugins.length,fields:e}}toJSON(){return {collections:this.getCollections(),globals:this.getGlobals()}}},v=null;function Xe(){return v||(v=new w),v}function Je(){v=null;}function M(){return v=new w,v}var He={aws:{type:"aws",configKey:"s3",displayName:"S3 Compatible (AWS, Backblaze, Wasabi, etc.)",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1",admin:{placeholder:"us-east-1"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"endpoint",type:"text",label:"Endpoint URL",admin:{placeholder:"https://s3.custom.com"}},{name:"cdnUrl",type:"text",label:"CDN URL",admin:{placeholder:"https://cdn.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}]},r2:{type:"r2",configKey:"r2",displayName:"Cloudflare R2",configFields:[{name:"accountId",type:"text",label:"Account ID",required:true,admin:{placeholder:"Your Cloudflare Account ID"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"publicDevUrl",type:"text",label:"Public Dev URL ID",admin:{placeholder:"pub-xxxxxxxxxxxxxxxx",description:"Enter ONLY the ID (e.g., pub-b8d8c4cc8bcf4d868ddd95efc1b305aa). Do NOT include https:// or the full URL. Found in R2 Dashboard \u2192 Public Dev URL."}},{name:"cdnUrl",type:"text",label:"Custom CDN URL",admin:{placeholder:"https://assets.example.com (optional)"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads (optional)",description:"Optional prefix for all object keys. Do not use '/' as prefix."}}]},gcs:{type:"gcs",configKey:"gcs",displayName:"Google Cloud Storage",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"projectId",type:"text",label:"Project ID"},{name:"clientEmail",type:"text",label:"Client Email"},{name:"privateKey",type:"password",label:"Private Key"},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},digitalocean:{type:"digitalocean",configKey:"digitalocean",displayName:"DigitalOcean Spaces",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"nyc3"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},backblaze:{type:"backblaze",configKey:"backblaze",displayName:"Backblaze B2",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"accountId",type:"text",label:"Account ID"},{name:"applicationKeyId",type:"text",label:"Application Key ID",required:true},{name:"applicationKey",type:"password",label:"Application Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},wasabi:{type:"wasabi",configKey:"wasabi",displayName:"Wasabi",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]}};function Ye(n,e){switch(n){case "r2":return e?.endpoint||`https://${e?.accountId||""}.r2.cloudflarestorage.com`;case "digitalocean":return e?.endpoint||`https://${e?.region||"nyc3"}.digitaloceanspaces.com`;case "backblaze":return e?.endpoint||"https://s3.backblazeb2.com";case "wasabi":return e?.endpoint||`https://s3.${e?.region||"us-east-1"}.wasabisys.com`;default:return e?.endpoint}}function Ae(n,e){return {provider:n,bucket:e?.bucket||"",region:e?.region||"us-east-1",accessKeyId:e?.accessKeyId||e?.clientEmail||e?.applicationKeyId||"",secretAccessKey:e?.secretAccessKey||e?.privateKey||e?.applicationKey||"",endpoint:Ye(n,e),cdnUrl:e?.cdnUrl,prefix:e?.prefix,accountId:e?.accountId,publicDevUrl:e?.publicDevUrl}}function Qe(n,e,t){let s=t[e.configKey]||{};return Ae(n,s)}function et(n,e,t){let s=t?.[e.configKey]||t;return Ae(n,s)}var Se={name:"@kyro-cms/storage-s3",version:"1.0.0",description:"S3-compatible storage (AWS R2 GCS DigitalOcean Backblaze Wasabi)",init:n=>{let e=n.registry?.storageProviders;if(!e)return;let t="@kyro-cms/storage-s3";for(let s of Object.values(He))e.register({type:s.type,displayName:s.displayName,pluginName:t,configKey:s.configKey,configFields:s.configFields,extractConfig:a=>Qe(s.type,s,a),extractRawConfig:a=>et(s.type,s,a),factory:a=>chunkPDSHJVCT_cjs.a(a)});}};var Ee={name:"@kyro-cms/storage-cloudinary",version:"1.0.0",description:"Cloudinary image and video storage",init:n=>{let e=n.registry?.storageProviders;e&&e.register({type:"cloudinary",displayName:"Cloudinary",pluginName:"@kyro-cms/storage-cloudinary",configKey:"cloudinary",configFields:[{name:"cloudName",type:"text",label:"Cloud Name",required:true},{name:"apiKey",type:"text",label:"API Key",required:true},{name:"apiSecret",type:"password",label:"API Secret",required:true},{name:"folder",type:"text",label:"Folder",admin:{placeholder:"Optional folder path"}},{name:"uploadPreset",type:"text",label:"Upload Preset (optional)",admin:{placeholder:"Leave empty for signed uploads",description:"If not set, uploads will be signed with API Secret"}}],extractConfig:t=>({cloudName:t.cloudinary?.cloudName||"",apiKey:t.cloudinary?.apiKey||"",apiSecret:t.cloudinary?.apiSecret||"",folder:t.cloudinary?.folder,uploadPreset:t.cloudinary?.uploadPreset}),extractRawConfig:t=>{let s=t?.cloudinary||t;return {cloudName:s?.cloudName||"",apiKey:s?.apiKey||"",apiSecret:s?.apiSecret||"",folder:s?.folder,uploadPreset:s?.uploadPreset}},factory:t=>chunkPDSHJVCT_cjs.b(t)});}};var xe={name:"@kyro-cms/storage-ftp",version:"1.0.0",description:"FTP/SFTP storage provider",init:n=>{let e=n.registry?.storageProviders;e&&e.register({type:"ftp",displayName:"FTP",pluginName:"@kyro-cms/storage-ftp",configKey:"ftp",configFields:[{name:"host",type:"text",label:"Host",required:true,admin:{placeholder:"ftp.example.com"}},{name:"port",type:"number",label:"Port",defaultValue:21,admin:{placeholder:"21 for FTP"}},{name:"user",type:"text",label:"Username",required:true},{name:"password",type:"password",label:"Password",required:true},{name:"secure",type:"checkbox",label:"Use TLS/SSL",defaultValue:false,admin:{description:"Enable TLS/SSL for secure connections (FTP only)"}},{name:"baseUrl",type:"text",label:"Base URL",required:true,admin:{placeholder:"https://files.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}],extractConfig:t=>({host:t.ftp?.host||"",port:t.ftp?.port||21,user:t.ftp?.user||"",password:t.ftp?.password||"",secure:t.ftp?.secure||false,baseUrl:t.ftp?.baseUrl||"",prefix:t.ftp?.prefix,type:"ftp"}),extractRawConfig:t=>{let s=t?.ftp||t;return {host:s?.host||"",port:s?.port||21,user:s?.user||"",password:s?.password||"",secure:s?.secure||false,baseUrl:s?.baseUrl||"",prefix:s?.prefix,type:"ftp"}},factory:t=>chunkPDSHJVCT_cjs.c(t)});}};var nt=[Se,Ee,xe];function z(n,e,t){let s=e.split(".");if(s.length===0)return false;let a=s[0],o=s.slice(1).join(".");for(let i of n)if(i.name===a)return o?i.fields&&Array.isArray(i.fields)||i.type==="array"&&i.fields&&Array.isArray(i.fields)?z(i.fields,o,t):false:(Object.assign(i,t),true);return false}function st(n,e){if(e)for(let t of n){let s=e[t.slug];if(s){let{fields:a,...o}=s;if(t.admin={...t.admin,...o},a&&t.fields&&Array.isArray(t.fields))for(let[i,r]of Object.entries(a))z(t.fields,i,r);}}}var W=class{registry;db;pubsub;webhookService;settings;wsServer;config;constructor(e){this.config=e,this.registry=M(),this.db=e.adapter,this.pubsub=new chunkF7SR5IDT_cjs.b(this.registry),this.webhookService=chunkISWMETHJ_cjs.n(this.db);for(let t of nt)this.registry.addPlugin(t);if(e.plugins)for(let t of e.plugins)this.registry.addPlugin(t);e.collections&&e.admin?.collectionOverrides&&st(e.collections,e.admin.collectionOverrides),e.collections&&this.registry.addCollections(e.collections),e.globals&&this.registry.addGlobals(e.globals);}async init(){await this.registry.init(this),this.registry.addGlobalPostInit(chunk65G73T7Z_cjs.a);let e={slug:"plugin-settings",admin:{hidden:true},fields:[{name:"states",type:"json"}]};if(this.registry.addGlobalPostInit(e),!this.db)throw new Error("Database adapter is null \u2014 failed to load at startup. Check the server console for the exact error.");let t={slug:chunkNY47CFVP_cjs.d,fields:[{name:"userId",type:"text",required:true},{name:"name",type:"text",required:true},{name:"key",type:"text",required:true},{name:"keyPrefix",type:"text",required:true},{name:"permissions",type:"json"},{name:"lastUsedAt",type:"date"},{name:"expiresAt",type:"date"}]},s={slug:chunkISWMETHJ_cjs.e,fields:[{name:"name",type:"text",required:true},{name:"url",type:"text",required:true},{name:"events",type:"json",required:true},{name:"status",type:"text",required:true},{name:"secret",type:"text"},{name:"headers",type:"json"},{name:"lastTriggered",type:"date"},{name:"lastError",type:"text"}]},a={slug:chunkISWMETHJ_cjs.f,fields:[{name:"webhookId",type:"text",required:true},{name:"event",type:"text",required:true},{name:"payload",type:"json",required:true},{name:"attempt",type:"number",required:true},{name:"status",type:"text",required:true},{name:"responseStatus",type:"number"},{name:"responseBody",type:"text"},{name:"error",type:"text"},{name:"duration",type:"number"},{name:"deliveredAt",type:"date"},{name:"nextRetryAt",type:"date"}]},o=this.registry.getGlobals();if(this.db instanceof chunk6CLRVJPP_cjs.c&&this.db.dialect==="postgres"){let i=this.db,r=chunkNY47CFVP_cjs.d.replace(/-/g,"_");i.schema[r]||(i.schema[r]=chunkMIOMMB23_cjs.g);}await this.db.init([...this.registry.getCollections(),t,s,a],o),await this.loadPluginState(),this.pubsub.autoRegisterHooks();}async loadSettings(){if(this.settings)return this.settings;try{let e=await this.db.findOne({collection:"_globals_access-settings",where:{},draft:!0});e&&(this.settings={access:e});}catch{}return this.settings||{}}async loadPluginState(){let e=this.registry.storageProviders,t=e.getAllPluginNames(),s={};try{let a=await this.db.findOne({collection:"_globals_plugin-settings",where:{},draft:!0});a&&a.states&&(s=a.states);}catch{}for(let a of t)s[a]!==void 0&&e.setPluginEnabled(a,s[a]);}getREST(e){let t=typeof this.config.auth=="object"?this.config.auth:null,s=t?.secret,a=t?.checkSession!==false;return chunkPDSHJVCT_cjs.s({registry:this.registry,db:this.db,authSecret:s,authAdapter:this.config.authAdapter,checkSession:a,...e,cors:this.config.cors,webhookService:this.webhookService,settings:this.settings})}getGraphQL(e){let t=chunkCIE3XMLH_cjs.c({registry:this.registry,db:this.db,settings:this.settings});return {fetch:graphqlYoga.createYoga({schema:t,context:async({request:a})=>{let o=chunkNY47CFVP_cjs.f(a),i,r;if(o&&this.db){let d=await chunkNY47CFVP_cjs.e(o,this.db);d.user&&(i=d.user,r=chunkNY47CFVP_cjs.g(d));}let c=e?.tenantID;return {db:this.db,registry:this.registry,user:i,req:a,tenantID:c,apiKey:r,relationLoader:new chunkCIE3XMLH_cjs.a({db:this.db,tenantID:c,user:i})}},graphiql:this.config.graphQL?.disablePlayground!==true,plugins:[]}).fetch,schema:t}}getTRPC(e){return {fetch:async(t,s)=>{let o=new URL(t.url).pathname.replace(/^\/api\/trpc\//,""),[i,...r]=o.split("."),c=r.join(".");if(c=c.replace(/\.(query|mutate|subscribe)$/,""),!i||!c)return new Response(JSON.stringify({error:{message:"Invalid tRPC path",code:-32600,data:{code:"BAD_REQUEST",httpStatus:400}}}),{status:400,headers:{"Content-Type":"application/json"}});let d=await chunkCVVW4LXZ_cjs.a({db:this.db,registry:this.registry,req:t,user:e?.user,tenantID:e?.tenantID,settings:this.settings}),h=chunkCVVW4LXZ_cjs.i(d)[i];if(!h)return new Response(JSON.stringify({error:{message:`Collection '${i}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});let g=h[c];if(typeof g!="function")return new Response(JSON.stringify({error:{message:`Procedure '${c}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});try{let p={};if(t.method==="POST"||t.method==="PATCH")p=await t.json().catch(()=>({}));else {let S=new URL(t.url).searchParams.get("input");if(S)try{p=JSON.parse(decodeURIComponent(S));}catch{}}let f=p?.["0"]??p,m=await g({...f,collection:i});return new Response(JSON.stringify({result:{data:m}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(p){let f=p.message||"Internal error",m=f.includes("not found")?404:f.includes("denied")||f.includes("authentication required")?403:f.includes("conflict")?409:500,S=m===404?-32601:m===403?-32001:m===409?-32002:-32603;return new Response(JSON.stringify({error:{message:f,code:S,data:{code:"INTERNAL_SERVER_ERROR",httpStatus:m}}}),{status:m,headers:{"Content-Type":"application/json"}})}},router:null}}getWS(){return this.wsServer}async startWebSocket(e){let t=this.settings?.access?.apiAccess;if(t?.wsEnabled===false)return null;let s=async a=>{let o=await chunkNY47CFVP_cjs.e(a,this.db);if(!o.valid)throw new Error(o.error||"Invalid API key");if(!o.user)throw new Error("API key has no associated user");return o.user};return this.wsServer=chunkF7SR5IDT_cjs.d({pubsub:this.pubsub,port:e?.port||8080,requireAuth:e?.requireAuth??t?.requireAuth,verifyToken:e?.verifyToken||s}),this.wsServer}async shutdown(){this.wsServer&&await this.wsServer.close(),await this.db.disconnect();}};function Mt(n){return new W(n)}var it=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-IGLFKSXH.cjs', document.baseURI).href))),ot="node:sqlite",{DatabaseSync:rt}=it(ot);function N(n){let e=[];for(let t of n)if(t.type==="tabs"&&"tabs"in t)for(let s of t.tabs)e.push(...N(s.fields));else t.type==="row"&&"fields"in t?e.push(...N(t.fields)):t.type==="collapsible"&&"fields"in t?e.push(...N(t.fields)):e.push(t);return e}function ct(n,e){let t=e,s=n[t.name];if(t.type==="json"||t.type==="richtext"||t.type==="array"||t.type==="group"||t.type==="blocks"||t.type==="list"||t.type==="relationship-block")try{s=s?JSON.parse(s):null;}catch{s=null;}if(t.type==="checkbox"&&(s=!!s),t.type==="date"&&s)try{let a=new Date(s);isNaN(a.getTime())?s=null:s=a.toISOString();}catch{s=null;}if((t.type==="upload"||t.type==="image")&&s)try{let a=JSON.parse(s);Array.isArray(a)?s=a.map(o=>typeof o=="object"&&o!==null?o:{id:o}):s=typeof a=="object"?a:{id:a};}catch{s={id:s};}if(t.type==="relationship"&&s)try{let a=JSON.parse(s);Array.isArray(a),s=a;}catch{s={relationTo:Array.isArray(t.relationTo)?t.relationTo[0]:t.relationTo,value:s};}if(t.type==="list"&&s)try{let a=JSON.parse(s);s=Array.isArray(a)?a:[];}catch{s=[];}if(t.type==="relationship-block"&&s)try{let a=JSON.parse(s);s=Array.isArray(a)?a:[];}catch{s=[];}return s}function X(n,e){try{return n.prepare(`PRAGMA table_info(${e})`).all().map(s=>s.name)}catch{return []}}var J=class extends chunkDV4LFLPL_cjs.a{db;path;migrations=new Map;versionsTableName="kyro_versions";constructor(e){super(),this.path=e.path,e.db?this.db=e.db:this.db=null;}async connect(){if(this.db||(this.db=new rt(this.path||":memory:")),this.db&&typeof this.db.prepare=="function"&&!this.db.prepare.__wrapped){let e=this.db.prepare.bind(this.db),t=s=>{let a=e(s),o=i=>typeof i=="boolean"?i?1:0:i===void 0?null:i;return new Proxy(a,{get(i,r,c){if(r==="all")return (...u)=>i.all(...u.map(o));if(r==="get")return (...u)=>i.get(...u.map(o));if(r==="run")return (...u)=>i.run(...u.map(o));let d=Reflect.get(i,r,c);return typeof d=="function"?d.bind(i):d}})};t.__wrapped=true,this.db.prepare=t;}this.db.exec("PRAGMA journal_mode = WAL"),this.db.exec("PRAGMA foreign_keys = ON"),this.connected=true;}async disconnect(){this.db&&this.db.close(),this.connected=false;}ensureTable(e,t){let s=t||this.getTableNameFor(e.slug),a=["id TEXT PRIMARY KEY"];for(let i of N(e.fields)){if(!i.name||i.name==="id")continue;let r=this.fieldToSQL(i);r&&a.push(r);}a.push(`${this.col("createdAt")} TEXT DEFAULT (datetime('now'))`),a.push(`${this.col("updatedAt")} TEXT DEFAULT (datetime('now'))`),a.push("status TEXT DEFAULT 'draft'"),a.push("hasDraft INTEGER DEFAULT 0"),e.tenantScoped&&a.push("tenant_id TEXT NOT NULL");let o=X(this.db,s);if(o.length===0){let i=`CREATE TABLE IF NOT EXISTS ${s} (${a.join(", ")})`;this.db.exec(i),this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_status ON ${s}(status)`);for(let r of N(e.fields))r.name&&r.indexed&&this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_${r.name} ON ${s}(${this.col(r.name)})`),r.name&&r.unique&&this.db.exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_${s}_${r.name}_unique ON ${s}(${this.col(r.name)})`);}else {let i=new Set(o);for(let r of a){let c=r.split(" ")[0].replace(/^"/,"").replace(/"$/,"");if(!i.has(c)&&c!=="id")try{c==="status"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(c)} TEXT DEFAULT 'published'`):c==="hasDraft"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(c)} INTEGER DEFAULT 0`):this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(c)} TEXT`);}catch{}}}this.migrations.set(s,true);}ensureVersionsTable(){this.db.exec(`
4
4
  CREATE TABLE IF NOT EXISTS ${this.versionsTableName} (
5
5
  id TEXT PRIMARY KEY,
6
6
  collection_slug TEXT NOT NULL,
@@ -0,0 +1,3 @@
1
+ 'use strict';var chunk65G73T7Z_cjs=require('./chunk-65G73T7Z.cjs'),chunkGFU7AOI3_cjs=require('./chunk-GFU7AOI3.cjs');var h={};var v={};var T={},oe=[];var k={},ie=[];var F={};var _={slug:"media",label:"Media Library",admin:{useAsTitle:"title",defaultColumns:["thumbnailUrl","title","type","fileSize","createdAt"],group:"content"},access:{read:()=>true,create:()=>true,update:()=>true,delete:()=>true},fields:[{name:"title",type:"text",label:"Title",required:true,admin:{description:"Descriptive title for the file"}},{name:"filename",type:"text",label:"Filename",required:true,admin:{readOnly:true,description:"System filename (auto-generated)"}},{name:"originalName",type:"text",label:"Original Name",admin:{readOnly:true}},{name:"alt",type:"text",label:"Alt Text",admin:{description:"Alternative text for images (accessibility)"}},{name:"caption",type:"richtext",label:"Caption",admin:{description:"Optional caption or description"}},{name:"type",type:"select",label:"File Type",required:true,defaultValue:"document",options:[{label:"Image",value:"image"},{label:"Video",value:"video"},{label:"Audio",value:"audio"},{label:"Document",value:"document"},{label:"Archive",value:"archive"},{label:"Other",value:"other"}],admin:{readOnly:true}},{name:"mimeType",type:"text",label:"MIME Type",admin:{readOnly:true}},{name:"url",type:"text",label:"URL",required:true,admin:{readOnly:true,description:"Public URL of the file"}},{name:"thumbnailUrl",type:"text",label:"Thumbnail URL",admin:{readOnly:true}},{name:"width",type:"number",label:"Width",admin:{readOnly:true,description:"Width in pixels (for images/videos)"}},{name:"height",type:"number",label:"Height",admin:{readOnly:true,description:"Height in pixels (for images/videos)"}},{name:"fileSize",type:"number",label:"File Size",admin:{readOnly:true,description:"Size in bytes"}},{name:"folder",type:"text",label:"Folder",admin:{description:"Folder path for organization (e.g., /products, /blog)"}},{name:"tags",type:"array",label:"Tags",fields:[{name:"tag",type:"text",label:"Tag"}]},{name:"focalPoint",type:"group",label:"Focal Point",admin:{description:"Point of interest for cropping"},fields:[{name:"x",type:"number",label:"X",defaultValue:50},{name:"y",type:"number",label:"Y",defaultValue:50}]},{name:"metadata",type:"json",label:"Metadata",admin:{readOnly:true,description:"Additional file metadata (EXIF, etc.)"}},{name:"provider",type:"select",label:"Storage Provider",defaultValue:"local",options:[{label:"Local",value:"local"},{label:"AWS S3",value:"s3"},{label:"Cloudinary",value:"cloudinary"},{label:"Imgix",value:"imgix"}],admin:{readOnly:true}},{name:"status",type:"select",label:"Status",defaultValue:"active",options:[{label:"Active",value:"active"},{label:"Archived",value:"archived"}]},{name:"createdAt",type:"date",label:"Created",admin:{readOnly:true}},{name:"updatedAt",type:"date",label:"Last Modified",admin:{readOnly:true}}]},P=[_];var K={slug:"menu",label:"Menu",singularLabel:"Menu Item",admin:{useAsTitle:"title",defaultColumns:["title","menu_location"]},fields:[{name:"title",type:"text",label:"Title",required:true},{name:"menu_location",type:"select",label:"Menu Location",options:[{label:"Header",value:"header"},{label:"Footer",value:"footer"},{label:"Sidebar",value:"sidebar"},{label:"Primary",value:"primary"},{label:"Secondary",value:"secondary"}],required:true,admin:{position:"sidebar"}},{name:"order",type:"number",label:"Order",admin:{position:"sidebar"}},{name:"menu",type:"group",fields:[{name:"menu_item",label:"Menu Item",type:"array",fields:[{name:"link_type",type:"select",label:"Link Type",options:[{label:"Internal",value:"internal"},{label:"External",value:"external"}]},{name:"internal_target",type:"relationship",label:"Internal Target",relationTo:["pages","posts"],admin:{condition:{field:"link_type",equals:"internal"}}},{name:"external_url",type:"text",label:"External URL",admin:{condition:{field:"link_type",equals:"external"}}}]}]}]},V={menu:K};var z={slug:"posts",label:"Posts",labelPlural:"Posts",singularLabel:"Post",admin:{useAsTitle:"title",defaultColumns:["title","slug","status","createdAt","updatedAt"],description:"Blog posts and articles"},fields:[{name:"mainTabs",type:"tabs",tabs:[{label:"Content",fields:[{name:"title",type:"text",required:true,label:"Title",admin:{description:"The main title of the post as it will appear publicly."}},{name:"content",type:"richtext",label:"Content"}]},{label:"Meta",fields:[{name:"category",type:"relationship",label:"Category",relationTo:"categories",admin:{description:"Select the primary category this post belongs to."}},{name:"relatedPosts",type:"array",label:"Related Posts",fields:[{name:"post",type:"relationship",relationTo:"posts",label:"Post"}],admin:{description:"Select posts related to this one."}}]},{label:"SEO",fields:[{name:"metaTitle",type:"text",label:"Meta Title",admin:{autoGenerate:"title",description:"The title used for SEO and social sharing (recommended < 60 chars)."}},{name:"metaDescription",type:"textarea",label:"Meta Description",admin:{autoGenerate:"content",description:"A brief summary for search engines (recommended < 160 chars)."}},{name:"ogImage",type:"upload",label:"OG Image",relationTo:"media",admin:{description:"The image shown when the post is shared on social media."}}]}]},{name:"slug",type:"text",required:true,label:"Slug",admin:{description:"The URL-friendly identifier for the post.",position:"sidebar",autoGenerate:"title"}},{name:"tags",type:"list",label:"Tags",admin:{description:"Add keywords to help categorize your post.",position:"sidebar"}},{name:"authors",type:"array",label:"Authors",fields:[{name:"user",type:"relationship",label:"User",relationTo:"users"}],admin:{description:"Select one or more authors for this post.",position:"sidebar"}},{name:"featuredImage",type:"upload",label:"Featured Image",relationTo:"media",admin:{description:"The primary visual used to represent this post.",position:"sidebar"}}],timestamps:true,versions:{drafts:true,maxPerDoc:10}},w={posts:z};function a(e){return {...e,fields:[...[{name:"anchorId",type:"text",admin:{hidden:true},hooks:{beforeChange:[({value:l,siblingData:f})=>f.name&&typeof f.name=="string"?f.name.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,""):l||null]}}],...e.fields,...ye]}}var ne=[{name:"text",type:"text",label:"Button Label"},{name:"url",type:"text",label:"Button Redirection URL"}],c={name:"buttons",type:"array",label:"Action Buttons",fields:ne},re={slug:"heading-element",label:"Heading",admin:{group:"Basic Content Elements",description:"Section heading"},fields:[{name:"content",type:"text",label:"Content"}]},se={slug:"text-element",label:"Text",admin:{group:"Basic Content Elements",description:"Plain text paragraph"},fields:[{name:"content",type:"textarea",label:"Content"}]},me={slug:"image-element",label:"Image",admin:{group:"Basic Content Elements",description:"Single image"},fields:[{name:"image",type:"upload",label:"Image",relationTo:"media"}]},pe={slug:"richtext-element",label:"Rich Text",admin:{group:"Basic Content Elements",description:"Formatted rich text content"},fields:[{name:"content",type:"richtext",label:"Content"}]},de={slug:"button-element",label:"Button",admin:{group:"Basic Content Elements",description:"Call-to-action button"},fields:[{name:"buttonData",type:"group",label:"Button",admin:{inline:true},fields:[{name:"text",type:"text",label:"Label"},{name:"url",type:"text",label:"URL"}]}]},ue={slug:"video-element",label:"Video",admin:{group:"Basic Content Elements",description:"Embedded video player"},fields:[{name:"url",type:"text",label:"Video URL"},{name:"file",type:"upload",label:"Video File",relationTo:"media"},{name:"caption",type:"text",label:"Caption"}]},ce={slug:"list-element",label:"List",admin:{group:"Basic Content Elements",description:"Bulleted or numbered list"},fields:[{name:"items",type:"array",label:"Items",fields:[{name:"text",type:"text",label:"Item Text"}]}]},be=[re,se,me,pe,de,ue,ce],ge={name:"elements",type:"blocks",label:"Extra Content Elements",blocks:be,admin:{pickerMode:"dropdown"}},ye=[ge],fe=a({slug:"hero",admin:{group:"Structural Sections",description:"Primary landing section with heading, text, media & CTA"},label:"Hero Section",fields:[{name:"isMultiScreen",type:"checkbox",label:"Enable Multi-Screen Slides (Carousel)",defaultValue:false},{name:"multiSlides",type:"group",label:"Multi Slides",admin:{condition:{field:"isMultiScreen",equals:true}},fields:[{name:"multiSlides",type:"array",label:"Hero Slides",fields:[{name:"heading",type:"text",label:"Slide Heading"},{name:"subheading",type:"textarea",label:"Slide Subheading"},{name:"backgroundImage",type:"upload",label:"Slide Background Image",relationTo:"media"},c]}]},{name:"singleSlide",type:"group",label:"Single Slide",admin:{condition:{field:"isMultiScreen",equals:false}},fields:[{name:"heading",type:"text",label:"Heading"},{name:"subheading",type:"textarea",label:"Subheading"},{name:"backgroundImage",type:"upload",label:"Background Image",relationTo:"media"},c]}]}),xe=a({slug:"card",admin:{group:"Structural Sections",description:"Modular card block featuring title, text, and optional media"},label:"Card Block",fields:[{name:"isMultiCard",type:"checkbox",label:"Enable Multicard Layout",defaultValue:false},{name:"multiCards",type:"group",label:"Multi Cards",admin:{condition:{field:"isMultiCard",equals:true}},fields:[{name:"cards",type:"array",label:"Cards List",fields:[{name:"title",type:"text",label:"Card Title"},{name:"description",type:"textarea",label:"Card Description"},{name:"image",type:"upload",label:"Card Image",relationTo:"media"},{name:"icon",type:"text",label:"Card Icon (Emoji or Name)"},{name:"linkText",type:"text",label:"Link Label Text"},{name:"link",type:"text",label:"Link Redirection URL"}]}]},{name:"singleCard",type:"group",label:"Single Card",admin:{condition:{field:"isMultiCard",equals:false}},fields:[{name:"title",type:"text",label:"Title"},{name:"description",type:"textarea",label:"Description"},{name:"image",type:"upload",label:"Image",relationTo:"media"},{name:"icon",type:"text",label:"Icon (Emoji or Name)"},{name:"linkText",type:"text",label:"Link Label Text"},{name:"link",type:"text",label:"Link Redirection URL"}]}]});a({slug:"text",admin:{group:"Basic Content Elements",description:"Rich text content"},label:"Text Block",fields:[{name:"content",type:"richtext",label:"Content"}]});a({slug:"image",admin:{group:"Basic Content Elements",description:"Image upload container"},label:"Image",fields:[{name:"image",type:"upload",label:"Image",relationTo:"media"},{name:"caption",type:"text",label:"Caption"},{name:"alt",type:"text",label:"Alt Text"},{name:"aspectRatio",type:"select",label:"Aspect Ratio",defaultValue:"original",options:[{label:"Original",value:"original"},{label:"16:9 Landscape",value:"16-9"},{label:"4:3 Classic",value:"4-3"},{label:"1:1 Square",value:"1-1"},{label:"2:3 Portrait",value:"2-3"}]},{name:"enableLightbox",type:"checkbox",label:"Enable Zoom / Lightbox",defaultValue:false}]});var Ce=a({slug:"feature-split",admin:{group:"Structural Sections",description:"Side-by-side text and media layout"},label:"Feature Split (Text & Media)",fields:[{name:"title",type:"text",label:"Title"},{name:"description",type:"richtext",label:"Description"},{name:"checkpoints",type:"array",label:"Value Checkpoints",fields:[{name:"title",type:"text",label:"Checkpoint Title"},{name:"description",type:"textarea",label:"Checkpoint Description"},{name:"icon",type:"text",label:"Icon Name"},{name:"image",type:"upload",label:"Image",relationTo:"media"},{name:"itemUrl",type:"text",label:"Link URL"}]},{name:"images",type:"array",label:"Images",fields:[{name:"image",type:"upload",label:"Image",relationTo:"media"}]},c]}),Se=a({slug:"feature-grid",admin:{group:"Marketing Grids",description:"Multi-column grid showcasing features or services"},label:"Feature Grid",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"sectionSubtitle",type:"textarea",label:"Section Subtitle"},{name:"features",type:"array",label:"Features List",fields:[{name:"title",type:"text",label:"Title"},{name:"description",type:"textarea",label:"Description"},{name:"icon",type:"text",label:"Icon Name"},{name:"image",type:"upload",label:"Feature Image",relationTo:"media"},{name:"itemUrl",type:"text",label:"Card Redirection URL"}]}]}),he=a({slug:"cta-banner",admin:{group:"Structural Sections",description:"High-impact call-to-action banner"},label:"CTA Banner",fields:[{name:"headline",type:"text",label:"Headline"},{name:"subheading",type:"textarea",label:"Subheading"},{name:"backgroundImage",type:"upload",label:"Background Image",relationTo:"media"},c]}),ve=a({slug:"testimonials",admin:{group:"Marketing Grids",description:"Customer reviews and quotes carousel"},label:"Testimonials",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"items",type:"array",label:"Testimonials",fields:[{name:"quote",type:"textarea",label:"Quote"},{name:"rating",type:"select",label:"Star Rating",defaultValue:"5",options:[{label:"5 Stars",value:"5"},{label:"4 Stars",value:"4"},{label:"3 Stars",value:"3"},{label:"2 Stars",value:"2"},{label:"1 Star",value:"1"}]},{name:"authorName",type:"text",label:"Author Name"},{name:"authorRole",type:"text",label:"Author Role"},{name:"avatar",type:"upload",label:"Avatar",relationTo:"media"},{name:"companyLogo",type:"upload",label:"Company Logo",relationTo:"media"}]}]}),Te=a({slug:"faq",admin:{group:"Lead Capture & Interactive",description:"Expandable list of frequently asked questions"},label:"FAQ Section",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"items",type:"array",label:"Questions List",fields:[{name:"tag",type:"text",label:"Category Tag (e.g. billing, account)"},{name:"question",type:"text",label:"Question"},{name:"answer",type:"richtext",label:"Answer"}]},{name:"footerHeading",type:"text",label:"Footer Heading (e.g. Still have questions?)"},{name:"footerCtaUrl",type:"text",label:"Footer CTA Redirection URL"}]}),ke=a({slug:"stats",admin:{group:"Marketing Grids",description:"Grid displaying key numerical metrics and stats"},label:"Stats / Metrics",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"items",type:"array",label:"Stats List",fields:[{name:"prefix",type:"text",label:"Value Prefix (e.g. + or $)"},{name:"value",type:"text",label:"Value (e.g. 99.9 or 5M)"},{name:"suffix",type:"text",label:"Value Suffix (e.g. % or users)"},{name:"label",type:"text",label:"Label (e.g. Uptime)"},{name:"description",type:"textarea",label:"Context Description"}]}]}),Pe=a({slug:"logo-cloud",admin:{group:"Structural Sections",description:"Showcase for partner and client company logos"},label:"Logo Cloud / Partners",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"logos",type:"array",label:"Logos List",fields:[{name:"name",type:"text",label:"Company Name"},{name:"logo",type:"upload",label:"Logo Image",relationTo:"media"},{name:"url",type:"text",label:"Website URL"}]}]}),Ae=a({slug:"pricing",admin:{group:"Marketing Grids",description:"Tiered pricing plans with feature comparisons"},label:"Pricing Plans",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"sectionSubtitle",type:"textarea",label:"Section Subtitle"},{name:"annualDiscount",type:"text",label:"Annual Promo Tag (e.g. Save 20%)"},{name:"plans",type:"array",label:"Pricing Plans",fields:[{name:"popularBadgeText",type:"text",label:"Plan Badge (e.g. MOST POPULAR)"},{name:"name",type:"text",label:"Plan Name"},{name:"description",type:"textarea",label:"Plan Description"},{name:"currency",type:"text",label:"Plan Currency (e.g. $)",defaultValue:"$"},{name:"price",type:"text",label:"Price (e.g. 29)"},{name:"billingPeriod",type:"text",label:"Billing Period (e.g. /mo)"},{name:"features",type:"list",label:"Features Checklist"},c,{name:"footnote",type:"text",label:"Footnote note (e.g. *cancel anytime)"},{name:"isFeatured",type:"checkbox",label:"Highlight Plan (Featured)",defaultValue:false}]}]}),Ge=a({slug:"team",admin:{group:"Marketing Grids",description:"Showcase of team members with photos and roles"},label:"Team Showcase",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"sectionSubtitle",type:"textarea",label:"Section Subtitle"},{name:"members",type:"array",label:"Team Members",fields:[{name:"name",type:"text",label:"Member Name"},{name:"role",type:"text",label:"Role / Position"},{name:"department",type:"text",label:"Department / Team tag (e.g. engineering, design)"},{name:"avatar",type:"upload",label:"Avatar Image",relationTo:"media"},{name:"bio",type:"textarea",label:"Brief Bio"},{name:"twitterUrl",type:"text",label:"Twitter URL"},{name:"linkedinUrl",type:"text",label:"LinkedIn URL"},{name:"githubUrl",type:"text",label:"GitHub URL"},{name:"websiteUrl",type:"text",label:"Website URL"}]}]}),Le=a({slug:"recent-feed",admin:{group:"Dynamic Content",description:"Dynamic feed of recent blog posts or articles"},label:"Recent Posts Feed",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"sectionSubtitle",type:"textarea",label:"Section Subtitle"},{name:"collectionType",type:"select",label:"Feed Source Collection",dynamicOptions:"collections"},{name:"categoryFilter",type:"text",label:"Filter results by category slug / tag"},{name:"limit",type:"number",label:"Max Items to Show",defaultValue:3},c]}),Ee=a({slug:"process-steps",admin:{group:"Lead Capture & Interactive",description:"Numbered sequence illustrating a process or workflow"},label:"Process Steps / Timeline",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"sectionSubtitle",type:"textarea",label:"Section Subtitle"},{name:"steps",type:"array",label:"Steps",fields:[{name:"stepNumber",type:"text",label:"Step Number (e.g. 01)"},{name:"icon",type:"upload",label:"Step Icon / Image",relationTo:"media"},{name:"title",type:"text",label:"Step Title"},{name:"description",type:"textarea",label:"Description"}]}]}),Me=a({slug:"form-embed",admin:{group:"Lead Capture & Interactive",description:"Embeddable interactive forms for lead capture"},label:"Form Embed",fields:[{name:"title",type:"text",label:"Form Title"},{name:"subtitle",type:"textarea",label:"Form Subtitle"},{name:"form",type:"relationship",relationTo:"forms",label:"Form",required:true}]}),Ie=a({slug:"video-showcase",admin:{group:"Structural Sections",description:"Cinematic video player with custom thumbnail"},label:"Cinematic Video Showcase",fields:[{name:"sectionTitle",type:"text",label:"Section Heading"},{name:"sectionSubtitle",type:"textarea",label:"Section Subtitle"},{name:"coverImage",type:"upload",label:"Cinematic Cover Image (Thumbnail)",relationTo:"media"},{name:"videoUrl",type:"text",label:"Video Embed URL (YouTube / Vimeo / MP4)"},{name:"videoTitle",type:"text",label:"Video Title (for accessibility & hover text)"},{name:"durationBadge",type:"text",label:"Duration Badge (e.g. '\u25B6 2:34')"},{name:"isLightbox",type:"checkbox",label:"Open in Cinematic Lightbox Modal",defaultValue:true},{name:"autoplay",type:"checkbox",label:"Autoplay Video (muted)",defaultValue:false}]}),W=[fe,xe,Ce,Se,he,ve,Te,ke,Pe,Ae,Ge,Le,Ee,Me,Ie];var Y={slug:"pages",label:"Pages",labelPlural:"Pages",singularLabel:"Page",admin:{useAsTitle:"title",defaultColumns:["title","slug","status","updatedAt"],description:"Static pages"},fields:[{name:"mainTabs",type:"tabs",tabs:[{label:"Content",fields:[{name:"title",type:"text",required:true,label:"Title",admin:{description:"The main title of the page as it will appear publicly."}},{name:"content",type:"blocks",label:"Content",blocks:W}]},{label:"Meta",fields:[]},{label:"SEO",fields:[{name:"metaTitle",type:"text",label:"Meta Title",admin:{autoGenerate:"title"}},{name:"metaDescription",type:"textarea",label:"Meta Description",admin:{autoGenerate:"content"}},{name:"ogImage",type:"upload",label:"OG Image",relationTo:"media"}]}]},{name:"slug",type:"text",required:true,label:"Slug",admin:{position:"sidebar",autoGenerate:"title"}},{name:"featuredImage",type:"upload",label:"Featured Image",relationTo:"media",admin:{position:"sidebar"}}],timestamps:true,versions:{drafts:true,maxPerDoc:10}},O={pages:Y};var X={slug:"categories",label:"Categories",labelPlural:"Categories",singularLabel:"Category",admin:{useAsTitle:"name",defaultColumns:["name","slug"],description:"Post categories",layout:"split"},fields:[{name:"name",type:"text",required:true,label:"Name"},{name:"description",type:"textarea",label:"Description"},{name:"slug",type:"text",required:true,label:"Slug",admin:{position:"sidebar",autoGenerate:"name"}},{name:"icon",type:"upload",label:"Icon",relationTo:"media",admin:{position:"sidebar"}},{name:"parent",type:"relationship",label:"Parent Category",relationTo:"categories",admin:{position:"sidebar"}},{name:"order",type:"number",label:"Order",defaultValue:0,admin:{position:"sidebar"}}],timestamps:true,versions:{drafts:true,maxPerDoc:5}},q={categories:X},J={slug:"product-categories",label:"Product Categories",labelPlural:"Product Categories",singularLabel:"Product Category",admin:{useAsTitle:"name",defaultColumns:["name","slug"],description:"Product categories for organizing your catalog"},fields:[{name:"name",type:"text",required:true,label:"Name"},{name:"slug",type:"text",required:true,label:"Slug",admin:{position:"sidebar",autoGenerate:"name"}},{name:"description",type:"textarea",label:"Description"},{name:"image",type:"text",label:"Image URL"},{name:"parent",type:"relationship",label:"Parent Category",relationTo:"product-categories",admin:{position:"sidebar"}}],timestamps:true,versions:{drafts:true,maxPerDoc:5}},A={"product-categories":J};var Q={slug:"products",label:"Products",labelPlural:"Products",singularLabel:"Product",admin:{useAsTitle:"title",defaultColumns:["title","slug","price","status","inventory","updatedAt"],description:"Product catalog"},fields:[{name:"title",type:"text",required:true,label:"Title"},{name:"slug",type:"text",required:true,label:"Slug",admin:{position:"sidebar",autoGenerate:"title"}},{name:"description",type:"richtext",label:"Description"},{name:"price",type:"number",required:true,label:"Price"},{name:"compareAtPrice",type:"number",label:"Compare at Price",admin:{description:"Original price for sale display"}},{name:"costPrice",type:"number",label:"Cost Price",admin:{description:"For profit calculation"}},{name:"sku",type:"text",required:true,label:"SKU"},{name:"barcode",type:"text",label:"Barcode"},{name:"images",type:"array",label:"Images",fields:[{name:"url",type:"text",label:"URL"},{name:"alt",type:"text",label:"Alt Text"}]},{name:"category",type:"relationship",label:"Category",relationTo:"product-categories"},{name:"inventory",type:"number",label:"Inventory",defaultValue:0}],timestamps:true,versions:{drafts:true,maxPerDoc:10}},G={products:Q};var $={slug:"customers",label:"Customers",labelPlural:"Customers",singularLabel:"Customer",admin:{useAsTitle:"email",defaultColumns:["email","firstName","lastName","createdAt","updatedAt"],description:"Customer accounts"},fields:[{name:"email",type:"email",required:true,label:"Email"},{name:"firstName",type:"text",label:"First Name"},{name:"lastName",type:"text",label:"Last Name"},{name:"phone",type:"text",label:"Phone"},{name:"addresses",type:"array",label:"Addresses",fields:[{name:"type",type:"text",label:"Type"},{name:"line1",type:"text",label:"Address Line 1"},{name:"line2",type:"text",label:"Address Line 2"},{name:"city",type:"text",label:"City"},{name:"state",type:"text",label:"State"},{name:"postalCode",type:"text",label:"Postal Code"},{name:"country",type:"text",label:"Country"}]},{name:"slug",type:"text",required:true,label:"Slug",admin:{position:"sidebar",autoGenerate:"email"}}],timestamps:true,versions:{drafts:true,maxPerDoc:5}},L={customers:$};var Z={slug:"orders",label:"Orders",labelPlural:"Orders",singularLabel:"Order",admin:{useAsTitle:"orderNumber",defaultColumns:["orderNumber","customer","status","total","createdAt","updatedAt"],description:"Customer orders"},fields:[{name:"orderNumber",type:"text",required:true,label:"Order Number"},{name:"customer",type:"relationship",required:true,label:"Customer",relationTo:"customers"},{name:"paymentStatus",type:"select",label:"Payment Status",options:[{label:"Pending",value:"pending"},{label:"Paid",value:"paid"},{label:"Failed",value:"failed"},{label:"Refunded",value:"refunded"}],defaultValue:"pending"},{name:"items",type:"array",label:"Items",fields:[{name:"product",type:"text",label:"Product"},{name:"quantity",type:"number",label:"Quantity"},{name:"unitPrice",type:"number",label:"Unit Price"},{name:"total",type:"number",label:"Total"}]},{name:"subtotal",type:"number",required:true,label:"Subtotal"},{name:"tax",type:"number",label:"Tax"},{name:"shipping",type:"number",label:"Shipping"},{name:"discount",type:"number",label:"Discount"},{name:"total",type:"number",required:true,label:"Total"},{name:"notes",type:"richtext",label:"Notes"},{name:"slug",type:"text",required:true,label:"Slug",admin:{position:"sidebar",autoGenerate:"orderNumber"}}],timestamps:true,versions:{drafts:true,maxPerDoc:10}},E={orders:Z};var ee={slug:"coupons",label:"Coupons",labelPlural:"Coupons",singularLabel:"Coupon",admin:{useAsTitle:"code",defaultColumns:["code","type","value","active","expiresAt"],description:"Discount codes and promotions"},fields:[{name:"code",type:"text",required:true,label:"Code"},{name:"type",type:"select",required:true,label:"Type",options:[{label:"Percentage",value:"percentage"},{label:"Fixed Amount",value:"fixed"},{label:"Free Shipping",value:"freeShipping"}]},{name:"value",type:"number",label:"Value"},{name:"minPurchase",type:"number",label:"Minimum Purchase"},{name:"maxDiscount",type:"number",label:"Max Discount"},{name:"usageLimit",type:"number",label:"Usage Limit"},{name:"usedCount",type:"number",defaultValue:0,label:"Used Count"},{name:"startsAt",type:"date",label:"Starts At"},{name:"expiresAt",type:"date",label:"Expires At"},{name:"active",type:"checkbox",defaultValue:true,label:"Active"}],timestamps:true,versions:{drafts:true,maxPerDoc:5}},M={coupons:ee};var te={slug:"forms",label:"Forms",labelPlural:"Forms",singularLabel:"Form",admin:{useAsTitle:"name",defaultColumns:["name","slug","updatedAt"],description:"Reusable form definitions"},fields:[{name:"name",type:"text",required:true,label:"Name"},{name:"subtitle",type:"textarea",label:"Subtitle"},{name:"slug",type:"text",required:true,label:"Slug",admin:{position:"sidebar",autoGenerate:"name"}},{name:"submitButtonText",type:"text",label:"Submit Button Text",defaultValue:"Submit",admin:{position:"sidebar"}},{name:"consentCheckboxText",type:"text",label:"Consent Agreement label (e.g. I agree to terms)",admin:{position:"sidebar"}},{name:"redirectUrl",type:"text",label:"Success Redirect URL",admin:{position:"sidebar"}},{name:"fields",type:"array",label:"Form Fields",fields:[{name:"fieldName",type:"text",label:"Field API Name (e.g. company)"},{name:"inputType",type:"select",label:"Input Type",defaultValue:"text",options:[{label:"Text input",value:"text"},{label:"Email input",value:"email"},{label:"Phone number input",value:"tel"},{label:"Multi-line textarea",value:"textarea"},{label:"Checkbox selector",value:"checkbox"}]},{name:"placeholder",type:"text",label:"Input Placeholder Text"},{name:"isRequired",type:"checkbox",label:"Make this field required",defaultValue:false}]},{name:"entries",type:"relationship",relationTo:"form-entries",hasMany:true,label:"Entries",admin:{description:"Form submissions linked to this form."}}],timestamps:true,versions:{drafts:true,maxPerDoc:5}},D={forms:te};var ae={slug:"form-entries",label:"Form Entries",labelPlural:"Form Entries",singularLabel:"Form Entry",admin:{useAsTitle:"id",defaultColumns:["id","form","createdAt","ipAddress"],description:"Form submission entries"},fields:[{name:"form",type:"relationship",relationTo:"forms",required:true,label:"Form",admin:{position:"sidebar",readOnly:true,description:"The form this entry belongs to."}},{name:"data",type:"json",label:"Submitted Data",admin:{readOnly:true,description:"All field values submitted with this entry."}},{name:"ipAddress",type:"text",label:"IP Address",admin:{position:"sidebar",readOnly:true,description:"The IP address of the submitter."}}],timestamps:true},U={"form-entries":ae};var o={slug:"site-settings",label:"Site Settings",admin:{group:"settings"},access:{read:()=>true,update:()=>true},fields:[{name:"siteName",type:"text",label:"Site Name",required:true,admin:{}},{name:"siteDescription",type:"textarea",label:"Site Description",admin:{placeholder:"Enter a brief description of your site for SEO and search results."}},{name:"siteLogo",type:"upload",label:"Site Logo",relationTo:"media"},{name:"siteFavicon",type:"upload",label:"Favicon",relationTo:"media"},{name:"siteOgImage",type:"upload",label:"Default OG Image",relationTo:"media"},{name:"siteUrl",type:"text",label:"Site URL",admin:{}},{name:"maintenanceEnabled",type:"checkbox",label:"Enable Maintenance Mode",defaultValue:false,admin:{description:"When enabled, the public site will show a maintenance page."}},{name:"maintenance",type:"group",label:"Maintenance Configuration",admin:{condition:e=>e.maintenanceEnabled===true},fields:[{name:"message",type:"textarea",label:"Maintenance Message",admin:{placeholder:"We'll be back soon! We're performing scheduled maintenance."}},{name:"bypassToken",type:"text",label:"Bypass Token",admin:{description:"Append ?bypass=YOUR_TOKEN to URL to view the site while in maintenance mode."}}]},{name:"enableI18n",type:"checkbox",label:"Enable Internationalization (i18n)",defaultValue:false,admin:{description:"Enable support for multiple languages."}},{name:"i18n",type:"group",label:"Localization",admin:{condition:e=>e.enableI18n===true},fields:[{name:"language",type:"select",label:"Default Language",defaultValue:"en",options:[{label:"English",value:"en"},{label:"Spanish",value:"es"},{label:"French",value:"fr"},{label:"German",value:"de"},{label:"Portuguese",value:"pt"},{label:"Italian",value:"it"},{label:"Dutch",value:"nl"},{label:"Russian",value:"ru"},{label:"Japanese",value:"ja"},{label:"Chinese",value:"zh"},{label:"Korean",value:"ko"},{label:"Arabic",value:"ar"}]},{name:"timezone",type:"text",label:"Timezone",defaultValue:"UTC"}]},{name:"logo",type:"group",label:"Logo Display Settings",fields:[{name:"width",type:"number",label:"Max Width (px)"},{name:"height",type:"number",label:"Max Height (px)"},{name:"altText",type:"text",label:"Alt Text"}]},{name:"analyticsEnabled",type:"checkbox",label:"Enable Analytics & Tracking",defaultValue:false},{name:"analytics",type:"group",label:"Tracking Configurations",admin:{condition:e=>e.analyticsEnabled===true},fields:[{name:"googleAnalyticsId",type:"text",label:"Google Analytics ID"},{name:"googleTagManagerId",type:"text",label:"Google Tag Manager ID"},{name:"plausibleDomain",type:"text",label:"Plausible Domain"},{name:"mixpanelToken",type:"password",label:"Mixpanel Token"}]}]};var i={slug:"seo-settings",label:"SEO Settings",admin:{group:"settings"},access:{read:()=>true,update:()=>true},fields:[{name:"seoMode",type:"select",label:"Visibility Mode",defaultValue:"simple",options:[{label:"Simple (Basic Meta)",value:"simple"},{label:"Advanced (Full Technical SEO)",value:"advanced"}],admin:{description:"Switch to advanced mode to control robots.txt, canonical URLs, and deep metadata."}},{name:"defaultTitle",type:"text",label:"Default Title",admin:{}},{name:"defaultDescription",type:"textarea",label:"Default Description",admin:{}},{name:"titleTemplate",type:"text",label:"Title Template",defaultValue:"{{title}} | {{siteName}}",admin:{}},{name:"siteNameInTitle",type:"checkbox",label:"Include Site Name in Title",defaultValue:true},{name:"separator",type:"text",label:"Title Separator",defaultValue:" | ",admin:{}},{name:"meta",type:"group",label:"Technical Meta Settings",admin:{condition:e=>e.seoMode==="advanced"},fields:[{name:"robots",type:"text",label:"Robots Meta",defaultValue:"index, follow"},{name:"canonicalUrl",type:"text",label:"Canonical URL"},{name:"ogType",type:"select",label:"Default OG Type",defaultValue:"website",options:[{label:"Website",value:"website"},{label:"Article",value:"article"},{label:"Product",value:"product"},{label:"Book",value:"book"},{label:"Music",value:"music"},{label:"Video",value:"video"}]}]},{name:"enableSitemap",type:"checkbox",label:"Enable XML Sitemap",defaultValue:true},{name:"sitemap",type:"group",label:"Sitemap Configuration",admin:{condition:e=>e.enableSitemap===true&&e.seoMode==="advanced"},fields:[{name:"sitemapUrls",type:"number",label:"Sitemap URL Limit",defaultValue:5e4}]},{name:"robotsTxt",type:"textarea",label:"Custom robots.txt",admin:{condition:e=>e.seoMode==="advanced"}},{name:"social",type:"group",label:"Social Media",fields:[{name:"twitterHandle",type:"text",label:"Twitter/X Handle",admin:{}},{name:"twitterCardType",type:"select",label:"Twitter Card Type",defaultValue:"summary_large_image",options:[{label:"Summary",value:"summary"},{label:"Summary with Large Image",value:"summary_large_image"},{label:"App",value:"app"},{label:"Player",value:"player"}]},{name:"fbAppId",type:"text",label:"Facebook App ID"}]},{name:"advanced",type:"group",label:"Advanced",fields:[{name:"jsonLdEnabled",type:"checkbox",label:"Enable JSON-LD",defaultValue:true,admin:{}},{name:"breadcrumbsEnabled",type:"checkbox",label:"Enable Breadcrumbs",defaultValue:true},{name:"paginationSize",type:"number",label:"Default Pagination Size",defaultValue:10}]}]};var r={slug:"social-settings",label:"Social Media",admin:{group:"settings"},access:{read:()=>true,update:()=>true},fields:[{name:"showAll",type:"checkbox",label:"Show All Platforms",defaultValue:false,admin:{description:"Toggle to show niche or secondary social platforms."}},{name:"facebook",type:"text",label:"Facebook"},{name:"twitter",type:"text",label:"Twitter/X"},{name:"instagram",type:"text",label:"Instagram"},{name:"linkedin",type:"text",label:"LinkedIn"},{name:"youtube",type:"text",label:"YouTube"},{name:"tiktok",type:"text",label:"TikTok",admin:{condition:e=>e.showAll===true}},{name:"pinterest",type:"text",label:"Pinterest",admin:{condition:e=>e.showAll===true}},{name:"discord",type:"text",label:"Discord",admin:{condition:e=>e.showAll===true}},{name:"twitch",type:"text",label:"Twitch",admin:{condition:e=>e.showAll===true}},{name:"github",type:"text",label:"GitHub",admin:{condition:e=>e.showAll===true}},{name:"mastodon",type:"text",label:"Mastodon",admin:{condition:e=>e.showAll===true}}]};var s={slug:"email-settings",label:"Email Settings",admin:{group:"settings"},access:{read:()=>true,update:()=>true},fields:[{name:"fromName",type:"text",label:"From Name",admin:{}},{name:"fromEmail",type:"email",label:"From Email",required:true,admin:{}},{name:"replyTo",type:"email",label:"Reply-To Email",admin:{}},{name:"provider",type:"select",label:"Email Provider",defaultValue:"smtp",options:[{label:"SMTP (Standard)",value:"smtp"},{label:"Resend",value:"resend"},{label:"SendGrid",value:"sendgrid"},{label:"Mailgun",value:"mailgun"},{label:"AWS SES",value:"ses"}]},{name:"smtp",type:"group",label:"SMTP Settings",admin:{condition:e=>e.provider==="smtp"},fields:[{name:"smtpService",type:"select",label:"SMTP Service",defaultValue:"custom",options:[{label:"Custom SMTP",value:"custom"},{label:"Gmail",value:"gmail"},{label:"Outlook / Office 365",value:"outlook"},{label:"Brevo (Sendinblue)",value:"brevo"},{label:"Mailgun (SMTP)",value:"mailgun-smtp"},{label:"SendGrid (SMTP)",value:"sendgrid-smtp"},{label:"Mandrill / Mailchimp",value:"mandrill"}],admin:{description:"Selecting a known service will pre-configure host and port settings."}},{name:"host",type:"text",label:"Host",admin:{condition:(e,t)=>t.smtpService==="custom",placeholder:"smtp.example.com"}},{name:"port",type:"number",label:"Port",defaultValue:587,admin:{condition:(e,t)=>t.smtpService==="custom"}},{name:"username",type:"text",label:"Username"},{name:"password",type:"password",label:"Password"},{name:"secure",type:"checkbox",label:"Use TLS/SSL",defaultValue:true}]},{name:"resend",type:"group",label:"Resend Settings",admin:{condition:e=>e.provider==="resend"},fields:[{name:"apiKey",type:"password",label:"API Key",required:true}]},{name:"sendgrid",type:"group",label:"SendGrid Settings",admin:{condition:e=>e.provider==="sendgrid"},fields:[{name:"apiKey",type:"password",label:"API Key",required:true}]},{name:"mailgun",type:"group",label:"Mailgun Settings",admin:{condition:e=>e.provider==="mailgun"},fields:[{name:"apiKey",type:"password",label:"API Key",required:true},{name:"domain",type:"text",label:"Domain",required:true},{name:"region",type:"select",label:"Region",defaultValue:"us",options:[{label:"US (United States)",value:"us"},{label:"EU (Europe)",value:"eu"}]}]},{name:"ses",type:"group",label:"AWS SES Settings",admin:{condition:e=>e.provider==="ses"},fields:[{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1",admin:{placeholder:"us-east-1"}}]},{name:"testEmailSection",type:"row",label:"Test Email",admin:{description:"Enter an email address to send a test email."},fields:[{name:"testEmail",type:"email",label:"Email",admin:{width:"300px"}},{name:"sendTestEmail",type:"action",label:"Send Test Email",admin:{action:"/api/globals/email-settings/test",method:"POST"}}]}]};var m={slug:"access-settings",label:"Access Control",admin:{group:"settings"},access:{read:()=>true,update:()=>true},fields:[{name:"enablePublicAccess",type:"checkbox",label:"Enable Public Access",defaultValue:true,admin:{}},{name:"defaultCollectionAccess",type:"select",label:"Default Collection Access",defaultValue:"read",options:[{label:"Read Only",value:"read"},{label:"Read & Create",value:"create"},{label:"Read & Create & Update",value:"update"},{label:"Full Access",value:"admin"},{label:"No Access",value:"none"}],admin:{}},{name:"apiAccess",type:"group",label:"API Access",fields:[{name:"graphqlEnabled",type:"checkbox",label:"Enable GraphQL",defaultValue:false},{name:"trpcEnabled",type:"checkbox",label:"Enable tRPC",defaultValue:false},{name:"wsEnabled",type:"checkbox",label:"Enable WebSocket",defaultValue:false},{name:"requireAuth",type:"checkbox",label:"Require Authentication",defaultValue:false},{name:"cors",type:"group",label:"CORS Settings",admin:{condition:e=>e.apiAccess?.graphqlEnabled===true},fields:[{name:"allowedOrigins",type:"textarea",label:"Allowed Origins (one per line)",admin:{placeholder:`https://example.com
2
+ https://app.example.com`}}]}]},{name:"rateLimiting",type:"group",label:"Rate Limiting Configuration",admin:{condition:e=>e.rateLimiting?.enabled===true},fields:[{name:"enabled",type:"checkbox",label:"Enable Global Rate Limiting",defaultValue:true},{name:"maxRequests",type:"number",label:"Max Requests",defaultValue:100,admin:{condition:(e,t)=>t.enabled===true}},{name:"windowMs",type:"number",label:"Window (ms)",defaultValue:6e4,admin:{condition:(e,t)=>t.enabled===true}}]}]};var Re=[{label:"United States",value:"US"},{label:"United Kingdom",value:"GB"},{label:"Canada",value:"CA"},{label:"Australia",value:"AU"},{label:"Germany",value:"DE"},{label:"France",value:"FR"},{label:"Netherlands",value:"NL"},{label:"Belgium",value:"BE"},{label:"Spain",value:"ES"},{label:"Italy",value:"IT"},{label:"Portugal",value:"PT"},{label:"Sweden",value:"SE"},{label:"Norway",value:"NO"},{label:"Denmark",value:"DK"},{label:"Finland",value:"FI"},{label:"Austria",value:"AT"},{label:"Switzerland",value:"CH"},{label:"Japan",value:"JP"},{label:"South Korea",value:"KR"},{label:"China",value:"CN"},{label:"India",value:"IN"},{label:"Brazil",value:"BR"},{label:"Mexico",value:"MX"}],b={slug:"store-settings",label:"Store Settings",admin:{group:"settings"},access:{read:()=>true,update:()=>true},fields:[{name:"storeName",type:"text",label:"Store Name",required:true},{name:"storeEmail",type:"email",label:"Contact Email",required:true},{name:"storePhone",type:"text",label:"Phone Number"},{name:"address",type:"group",label:"Store Address",fields:[{name:"street",type:"text",label:"Street Address"},{name:"city",type:"text",label:"City"},{name:"state",type:"text",label:"State/Province"},{name:"postalCode",type:"text",label:"Postal Code"},{name:"country",type:"select",label:"Country",options:Re}]},{name:"currency",type:"group",label:"Currency",fields:[{name:"code",type:"select",label:"Currency Code",defaultValue:"USD",options:[{label:"USD - US Dollar",value:"USD"},{label:"EUR - Euro",value:"EUR"},{label:"GBP - British Pound",value:"GBP"},{label:"CAD - Canadian Dollar",value:"CAD"},{label:"AUD - Australian Dollar",value:"AUD"},{label:"JPY - Japanese Yen",value:"JPY"},{label:"CNY - Chinese Yuan",value:"CNY"},{label:"INR - Indian Rupee",value:"INR"},{label:"BRL - Brazilian Real",value:"BRL"},{label:"MXN - Mexican Peso",value:"MXN"}]},{name:"symbol",type:"text",label:"Symbol",defaultValue:"$"},{name:"position",type:"select",label:"Symbol Position",defaultValue:"before",options:[{label:"Before amount",value:"before"},{label:"After amount",value:"after"}]},{name:"decimals",type:"number",label:"Decimal Places",defaultValue:2}]},{name:"tax",type:"group",label:"Tax Logistics",admin:{condition:e=>e.tax?.enabled===true},fields:[{name:"enabled",type:"checkbox",label:"Enable Tax",defaultValue:true},{name:"rate",type:"number",label:"Tax Rate (%)",admin:{placeholder:"10",condition:(e,t)=>t.enabled===true}},{name:"includedInPrice",type:"checkbox",label:"Tax Included in Prices",admin:{condition:(e,t)=>t.enabled===true}},{name:"taxId",type:"text",label:"Tax ID / VAT Number",admin:{condition:(e,t)=>t.enabled===true}}]},{name:"shipping",type:"group",label:"Shipping Logic",admin:{condition:e=>e.shipping?.enableLocalPickup===true||e.shipping?.flatRate>0},fields:[{name:"enableLocalPickup",type:"checkbox",label:"Enable Local Pickup",defaultValue:true},{name:"flatRate",type:"number",label:"Flat Rate Shipping Fee",admin:{}},{name:"freeShippingThreshold",type:"number",label:"Free Shipping Minimum",admin:{condition:(e,t)=>t.flatRate>0}}]},{name:"orders",type:"group",label:"Orders",fields:[{name:"orderNumberPrefix",type:"text",label:"Order Number Prefix",defaultValue:"ORD",admin:{}},{name:"allowGuestCheckout",type:"checkbox",label:"Allow Guest Checkout",defaultValue:true},{name:"requirePhone",type:"checkbox",label:"Require Phone Number",defaultValue:true}]}]};var g={slug:"payment-settings",label:"Payment Settings",admin:{group:"settings"},access:{read:()=>true,update:()=>true},fields:[{name:"testMode",type:"checkbox",label:"Test Mode",defaultValue:true,admin:{}},{name:"provider",type:"select",label:"Primary Payment Provider",defaultValue:"stripe",options:[{label:"Stripe",value:"stripe"},{label:"PayPal",value:"paypal"},{label:"Square",value:"square"},{label:"Manual Methods Only",value:"manual"}]},{name:"stripe",type:"group",label:"Stripe",admin:{condition:e=>e.provider==="stripe"},fields:[{name:"enabled",type:"checkbox",label:"Enable Stripe",defaultValue:false},{name:"publishableKey",type:"text",label:"Publishable Key",admin:{placeholder:"pk_live_..."}},{name:"secretKey",type:"password",label:"Secret Key"},{name:"webhookSecret",type:"password",label:"Webhook Secret",admin:{}}]},{name:"paypal",type:"group",label:"PayPal",admin:{condition:e=>e.provider==="paypal"},fields:[{name:"enabled",type:"checkbox",label:"Enable PayPal",defaultValue:false},{name:"clientId",type:"text",label:"Client ID"},{name:"clientSecret",type:"password",label:"Client Secret"},{name:"mode",type:"select",label:"Mode",defaultValue:"sandbox",options:[{label:"Sandbox (Test)",value:"sandbox"},{label:"Live",value:"live"}]}]},{name:"square",type:"group",label:"Square",admin:{condition:e=>e.provider==="square"},fields:[{name:"enabled",type:"checkbox",label:"Enable Square",defaultValue:false},{name:"applicationId",type:"text",label:"Application ID"},{name:"accessToken",type:"password",label:"Access Token"},{name:"locationId",type:"text",label:"Location ID"}]},{name:"methods",type:"group",label:"Manual Payment Methods",fields:[{name:"cod",type:"checkbox",label:"Cash on Delivery",defaultValue:true},{name:"bankTransfer",type:"checkbox",label:"Bank Transfer",defaultValue:true},{name:"cash",type:"checkbox",label:"Cash (Local Pickup)",defaultValue:true},{name:"check",type:"checkbox",label:"Check",defaultValue:false}]},{name:"bankTransfer",type:"group",label:"Bank Transfer Details",admin:{},fields:[{name:"bankName",type:"text",label:"Bank Name"},{name:"accountName",type:"text",label:"Account Name"},{name:"accountNumber",type:"text",label:"Account Number"},{name:"routingNumber",type:"text",label:"Routing/Sort Code"},{name:"iban",type:"text",label:"IBAN"},{name:"swift",type:"text",label:"SWIFT/BIC"}]}]};var p={slug:"system",label:"System",admin:{group:"settings",description:"Core system configuration and secrets"},access:{read:()=>true,update:()=>true},fields:[{name:"appSecret",type:"secret",label:"App Secret",required:false,admin:{description:"Auto-generated master secret used for encryption and auth. Auto-created if empty on load.",readOnly:true}},{name:"encryptionKey",type:"text",label:"Encryption Key",required:false,admin:{description:"Auto-generated key for data encryption at rest.",readOnly:true}},{name:"sessionMaxAge",type:"number",label:"Session Max Age (days)",required:false,defaultValue:7,admin:{description:"Maximum session duration in days"}},{name:"maxSessionsPerUser",type:"number",label:"Max Sessions Per User",required:false,defaultValue:3,admin:{description:"Maximum concurrent sessions allowed per user"}}]};var d={slug:"header-settings",label:"Header Settings",admin:{group:"Header Configuration",description:"Manage global header settings like the logo and navigation."},access:{read:()=>true,update:()=>true},fields:[{name:"site_logo",type:"upload",relationTo:"media",label:"Site Logo"},{name:"site_menu",type:"relationship",relationTo:"menu",label:"Site Menu"},{name:"header_text",type:"richtext",label:"Header Text"},{name:"header_buttons",type:"array",label:"Header Buttons",fields:[{name:"button",type:"group",label:"Button",fields:[{name:"text",type:"text",label:"Button Text"},{name:"url",type:"text",label:"Button URL"}]}]}]};var u={slug:"footer-settings",label:"Footer Settings",admin:{group:"Footer Configuration",description:"Manage global footer settings like the logo, text, and links."},access:{read:()=>true,update:()=>true},fields:[{name:"footer_logo",type:"upload",relationTo:"media",label:"Footer Logo"},{name:"footer_text",type:"richtext",label:"Footer Text"},{name:"footer_address",type:"text",label:"Footer Address"},{name:"footer_phone",type:"text",label:"Footer Phone"},{name:"footer_email",type:"text",label:"Footer Email"},{name:"footer_hours",type:"array",label:"Footer Hours",fields:[{name:"hour",type:"text",label:"Hour"}]},{name:"footer_menu",type:"array",label:"Footer Menu",fields:[{name:"menu",type:"relationship",relationTo:"menu"}]},{name:"footer_buttons",type:"array",label:"Footer Buttons",fields:[{name:"button",type:"group",label:"Button",fields:[{name:"text",type:"text",label:"Button Text"},{name:"url",type:"text",label:"Button URL"}]}]},{name:"footer_form",type:"relationship",relationTo:"forms",label:"Footer Form"}]};var I=[o,i,r,s,chunk65G73T7Z_cjs.a,m,b,g,p,d,u],y=[o,i,r,s,chunk65G73T7Z_cjs.a,m,p,d,u],N={[o.slug]:o,[i.slug]:i,[r.slug]:r,[s.slug]:s,[chunk65G73T7Z_cjs.a.slug]:chunk65G73T7Z_cjs.a,[m.slug]:m,[b.slug]:b,[g.slug]:g,[p.slug]:p,[d.slug]:d,[u.slug]:u};function j(e){switch(e){case "minimal":return [o,i];case "starter":case "blog":return y;case "ecommerce":case "kitchen-sink":return I;default:return y}}function x(e){let t=new Map;for(let l of e)t.has(l.slug)||t.set(l.slug,l);return Array.from(t.values())}var le=[...Object.values(w),...Object.values(O),...Object.values(q),...Object.values(D),...Object.values(U)],R=[...le,...P,...Object.values(chunkGFU7AOI3_cjs.b),...Object.values(V)],ma={minimal:x([...Object.values(h),...le]),starter:x([...Object.values(v),...R]),blog:x([...Object.values(T),...R]),ecommerce:x([...Object.values(k),...Object.values(G),...Object.values(L),...Object.values(E),...Object.values(M),...Object.values(A),...R]),"kitchen-sink":x([...Object.values(h),...Object.values(v),...Object.values(T),...Object.values(k),...Object.values(F),...Object.values(G),...Object.values(L),...Object.values(E),...Object.values(M),...Object.values(A),...R])};function da(e){let t=e.collections?[...e.collections]:[],l=e.globals?[...e.globals]:[];e.includeMedia!==false&&t.push(...P);let f=e.template?j(e.template):y;if(e.includeSettings){if(e.includeSettings==="all")l.push(...I);else if(e.includeSettings==="core")l.push(...y);else if(Array.isArray(e.includeSettings))for(let C of e.includeSettings){let S=N[C];S&&l.push(S);}}else (!e.globals||e.globals.length===0)&&l.push(...f);if(e.excludeSettings&&e.excludeSettings.length>0){let C=new Set(e.excludeSettings),S=l.filter(H=>!C.has(H.slug)&&!C.has(H.label?.toLowerCase().replace(/\s+/g,"-")||""));l.length=0,l.push(...S);}return {collections:t.length>0?t:void 0,globals:l.length>0?l:void 0}}
3
+ exports.A=M;exports.B=te;exports.C=D;exports.D=ae;exports.E=U;exports.F=o;exports.G=i;exports.H=r;exports.I=s;exports.J=m;exports.K=b;exports.L=g;exports.M=p;exports.N=d;exports.O=u;exports.P=I;exports.Q=y;exports.R=N;exports.S=j;exports.T=ma;exports.U=da;exports.a=h;exports.b=v;exports.c=T;exports.d=oe;exports.e=k;exports.f=ie;exports.g=F;exports.h=_;exports.i=P;exports.j=K;exports.k=V;exports.l=z;exports.m=w;exports.n=Y;exports.o=O;exports.p=X;exports.q=q;exports.r=J;exports.s=A;exports.t=Q;exports.u=G;exports.v=$;exports.w=L;exports.x=Z;exports.y=E;exports.z=ee;
@@ -1 +1 @@
1
- import {q as q$1,r}from'./chunk-QMMMQQNI.js';import {d}from'./chunk-FO3HLBC7.js';import {a as a$1}from'./chunk-2W4FK6CJ.js';import {c}from'./chunk-VKXQUYYV.js';import {a}from'./chunk-RHCWCG3O.js';import {a as a$2}from'./chunk-G6A7OSIG.js';import {a as a$3}from'./chunk-P7CESLDJ.js';import A from'kyro:config';var t=null,n=null;async function g(){if(!t)try{let e=A.default||A;t=q$1(e),await t.init(),await t.loadSettings();let a$4=t.db,r$1;if(a$4 instanceof c){if(a$4.dialect==="postgres")r$1=new a({db:a$4.client});else if(a$4.dialect==="sqlite"){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";r$1=new a$1({path:s});}}else if(a$4 instanceof r){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";r$1=new a$1({path:s});}else a$4 instanceof a$2&&(r$1=new a$3({db:a$4.db}));r$1?.connect&&await r$1.connect(),(await d(r$1))?.success,typeof t.startWebSocket=="function"&&t.startWebSocket().catch(s=>{console.error("[Kyro] WebSocket auto-start failed:",s);}),globalThis.__KYRO_INSTANCE__=t;}catch(e){throw t=null,n=null,console.error("[Kyro API] Init failed, will retry:",e),e}}async function q(){n||(n=g()),await n;}var w={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function b(e){try{return (await t.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.[e]??w[e]??!0}catch{return true}}var v=async e=>{if(!t){n||(n=g());try{await Promise.race([n,new Promise((l,o)=>setTimeout(()=>o(new Error("Initialization timeout")),3e4))]);}catch{return new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}}let r=new URL(e.request.url).pathname,i=__KYRO_API_PATH__;if(r===`${i}/graphql`&&typeof t.getGraphQL=="function"){if(!await b("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await t.getGraphQL().fetch(e.request,e.locals);return new Response(o.body,o)}if(r.startsWith(`${i}/trpc/`)&&typeof t.getTRPC=="function"){if(!await b("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await t.getTRPC().fetch(e.request,e.locals);return new Response(o.body,o)}return t.getREST().fetch(e.request,e.locals)};export{t as a,q as b,v as c};
1
+ import {q as q$1,r}from'./chunk-SB33D472.js';import {d}from'./chunk-FO3HLBC7.js';import {a as a$1}from'./chunk-2W4FK6CJ.js';import {c}from'./chunk-VKXQUYYV.js';import {a}from'./chunk-RHCWCG3O.js';import {a as a$2}from'./chunk-G6A7OSIG.js';import {a as a$3}from'./chunk-P7CESLDJ.js';import A from'kyro:config';var t=null,n=null;async function g(){if(!t)try{let e=A.default||A;t=q$1(e),await t.init(),await t.loadSettings();let a$4=t.db,r$1;if(a$4 instanceof c){if(a$4.dialect==="postgres")r$1=new a({db:a$4.client});else if(a$4.dialect==="sqlite"){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";r$1=new a$1({path:s});}}else if(a$4 instanceof r){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";r$1=new a$1({path:s});}else a$4 instanceof a$2&&(r$1=new a$3({db:a$4.db}));r$1?.connect&&await r$1.connect(),(await d(r$1))?.success,typeof t.startWebSocket=="function"&&t.startWebSocket().catch(s=>{console.error("[Kyro] WebSocket auto-start failed:",s);}),globalThis.__KYRO_INSTANCE__=t;}catch(e){throw t=null,n=null,console.error("[Kyro API] Init failed, will retry:",e),e}}async function q(){n||(n=g()),await n;}var w={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function b(e){try{return (await t.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.[e]??w[e]??!0}catch{return true}}var v=async e=>{if(!t){n||(n=g());try{await Promise.race([n,new Promise((l,o)=>setTimeout(()=>o(new Error("Initialization timeout")),3e4))]);}catch{return new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}}let r=new URL(e.request.url).pathname,i=__KYRO_API_PATH__;if(r===`${i}/graphql`&&typeof t.getGraphQL=="function"){if(!await b("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await t.getGraphQL().fetch(e.request,e.locals);return new Response(o.body,o)}if(r.startsWith(`${i}/trpc/`)&&typeof t.getTRPC=="function"){if(!await b("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await t.getTRPC().fetch(e.request,e.locals);return new Response(o.body,o)}return t.getREST().fetch(e.request,e.locals)};export{t as a,q as b,v as c};