var{defineProperty:J,getOwnPropertyNames:X,getOwnPropertyDescriptor:Y}=Object,Z=Object.prototype.hasOwnProperty;function _(j){return this[j]}var y=(j)=>{var A=(L??=new WeakMap).get(j),C;if(A)return A;if(A=J({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var B of X(j))if(!Z.call(A,B))J(A,B,{get:_.bind(j,B),enumerable:!(C=Y(j,B))||C.enumerable})}return L.set(j,A),A},L;var $=(j)=>j;function K(j,A){this[j]=$.bind(null,A)}var g=(j,A)=>{for(var C in A)J(j,C,{get:A[C],enumerable:!0,configurable:!0,set:K.bind(A,C)})};var w=(j,A)=>()=>(j&&(A=j(j=0)),A);import{z as q}from"zod";var F=q.enum(["template","workflow","integration","knowledge","blueprint","ui","script","library"]),I=q.enum(["public","internal","experimental"]),R=q.enum(["playground","specs","builder","markdown","evolution"]),D=q.enum(["idea","in_creation","experimental","beta","stable","deprecated"]),N=q.object({rootDocId:q.string().optional(),goalDocId:q.string().optional(),usageDocId:q.string().optional(),referenceDocId:q.string().optional(),constraintsDocId:q.string().optional()}),M=q.object({enabled:q.boolean(),modes:q.array(R)}),P=q.object({enabled:q.boolean(),installable:q.boolean()}),V=q.object({enabled:q.boolean()}),O=q.object({templates:q.boolean(),sandbox:M,studio:P,mcp:V}),Q=q.object({packageName:q.string().min(1),feature:q.string().optional(),blueprint:q.string().optional(),presentations:q.string().optional(),contracts:q.string().optional(),handlers:q.string().optional(),ui:q.string().optional(),docs:q.string().optional()}),T=q.object({version:q.string(),key:q.string().min(1),title:q.string().optional(),description:q.string().min(1),domain:q.string().optional(),stability:D,owners:q.array(q.string()),tags:q.array(q.string()),docId:q.array(q.string()).optional(),kind:F,visibility:I,summary:q.string().optional()}),b=q.object({key:q.string().min(1),version:q.string().optional()}),v=q.object({key:q.string().min(1)}),U=q.object({meta:T,docs:N.optional(),surfaces:O,entrypoints:Q,blueprint:q.union([q.record(q.string(),q.unknown()),b]).optional(),features:q.array(q.union([q.record(q.string(),q.unknown()),v])).optional()});function E(j){return U.parse(j)}function W(j){return U.safeParse(j)}function d(j){return T.parse(j)}function S(j){return O.parse(j)}function o(j){return Q.parse(j)}function i(j){return N.parse(j)}function k(j){let A=[],C=[],B=W(j);if(!B.success){for(let H of B.error.issues)A.push({exampleKey:j?.meta?.key,message:H.message,path:H.path.join("."),code:H.code});return{valid:!1,errors:A,warnings:C}}let G=B.data;return f(G,A,C),{valid:A.length===0,errors:A,warnings:C}}function f(j,A,C){let B=j.meta.key;if(!j.entrypoints.packageName.startsWith("@"))C.push({exampleKey:B,message:"Package name should be scoped (e.g., @contractspec/example.name)",path:"entrypoints.packageName"});if(j.surfaces.studio.installable&&!j.surfaces.studio.enabled)A.push({exampleKey:B,message:"Studio installable requires studio.enabled to be true",path:"surfaces.studio",code:"STUDIO_INSTALLABLE_REQUIRES_ENABLED"});if(j.surfaces.sandbox.enabled&&j.surfaces.sandbox.modes.length===0)C.push({exampleKey:B,message:"Sandbox is enabled but has no modes configured",path:"surfaces.sandbox.modes"});if(j.features&&j.features.length>0&&!j.entrypoints.feature)C.push({exampleKey:B,message:"Example has features but no feature entrypoint in entrypoints.feature",path:"entrypoints.feature"});if(j.blueprint&&!j.entrypoints.blueprint)C.push({exampleKey:B,message:"Example has blueprint but no blueprint entrypoint in entrypoints.blueprint",path:"entrypoints.blueprint"});if(j.meta.visibility==="public"&&j.meta.stability==="idea")C.push({exampleKey:B,message:'Public examples should not be in "idea" stability',path:"meta.stability"})}function x(j){let A=[],C=new Set,B=[];for(let G of j){if(C.has(G.meta.key)){A.push({exampleKey:G.meta.key,message:`Duplicate example key: ${G.meta.key}`,code:"DUPLICATE_KEY"});continue}C.add(G.meta.key);let H=k(G);if(!H.valid)A.push(...H.errors);else B.push(G)}if(A.length>0)return{ok:!1,errors:A};return{ok:!0,examples:B}}function n(j,A){let C=[],B=[],G=j.meta.key;if(A.packageNames&&!A.packageNames.has(j.entrypoints.packageName))B.push({exampleKey:G,message:`Package "${j.entrypoints.packageName}" not found in workspace`,path:"entrypoints.packageName"});if(j.features&&A.featureKeys){for(let H of j.features)if("key"in H&&!("meta"in H)){if(!A.featureKeys.has(H.key))B.push({exampleKey:G,message:`Feature "${H.key}" not found in registry`,path:"features"})}}if(j.blueprint&&A.blueprintKeys){if("key"in j.blueprint&&!("meta"in j.blueprint)){if(!A.blueprintKeys.has(j.blueprint.key))B.push({exampleKey:G,message:`Blueprint "${j.blueprint.key}" not found in registry`,path:"blueprint"})}}return{valid:C.length===0,errors:C,warnings:B}}export{x as validateExamples,n as validateExampleReferences,k as validateExample};
