var{defineProperty:G,getOwnPropertyNames:I,getOwnPropertyDescriptor:J}=Object,M=Object.prototype.hasOwnProperty;function N(q){return this[q]}var U=(q)=>{var z=(H??=new WeakMap).get(q),A;if(z)return z;if(z=G({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var j of I(q))if(!M.call(z,j))G(z,j,{get:N.bind(q,j),enumerable:!(A=J(q,j))||A.enumerable})}return H.set(q,z),z},H;var O=(q)=>q;function P(q,z){this[q]=O.bind(null,z)}var V=(q,z)=>{for(var A in z)G(q,A,{get:z[A],enumerable:!0,configurable:!0,set:P.bind(z,A)})};var W=(q,z)=>()=>(q&&(z=q(q=0)),z);function Y(q){let z=[],A=[];for(let j of q.capabilities.list()){let B=`${j.meta.key}.v${j.meta.version}`;for(let C of j.provides??[])if(!Q(q,C.surface,C.key))z.push({type:"missing_surface_spec",message:`Capability "${B}" provides ${C.surface} "${C.key}" but spec not found`,capabilityKey:B,surface:C.surface,specKey:C.key})}if(q.operations){for(let j of q.operations.list())if(j.capability){let B=q.capabilities.get(j.capability.key,j.capability.version);if(!B)z.push({type:"capability_not_found",message:`Operation "${j.meta.key}" references capability "${j.capability.key}.v${j.capability.version}" but capability not found`,specKey:j.meta.key,capabilityKey:`${j.capability.key}.v${j.capability.version}`,surface:"operation"});else if(!B.provides?.some((D)=>D.surface==="operation"&&D.key===j.meta.key))z.push({type:"surface_not_in_provides",message:`Operation "${j.meta.key}" claims capability "${j.capability.key}.v${j.capability.version}" but not in capability's provides`,specKey:j.meta.key,capabilityKey:`${j.capability.key}.v${j.capability.version}`,surface:"operation"})}}if(q.events){for(let j of q.events.list())if(j.capability){let B=q.capabilities.get(j.capability.key,j.capability.version);if(!B)z.push({type:"capability_not_found",message:`Event "${j.meta.key}" references capability "${j.capability.key}.v${j.capability.version}" but capability not found`,specKey:j.meta.key,capabilityKey:`${j.capability.key}.v${j.capability.version}`,surface:"event"});else if(!B.provides?.some((D)=>D.surface==="event"&&D.key===j.meta.key))z.push({type:"surface_not_in_provides",message:`Event "${j.meta.key}" claims capability "${j.capability.key}.v${j.capability.version}" but not in capability's provides`,specKey:j.meta.key,capabilityKey:`${j.capability.key}.v${j.capability.version}`,surface:"event"})}}if(q.presentations){for(let j of q.presentations.list())if(j.capability){let B=q.capabilities.get(j.capability.key,j.capability.version);if(!B)z.push({type:"capability_not_found",message:`Presentation "${j.meta.key}" references capability "${j.capability.key}.v${j.capability.version}" but capability not found`,specKey:j.meta.key,capabilityKey:`${j.capability.key}.v${j.capability.version}`,surface:"presentation"});else if(!B.provides?.some((D)=>D.surface==="presentation"&&D.key===j.meta.key))z.push({type:"surface_not_in_provides",message:`Presentation "${j.meta.key}" claims capability "${j.capability.key}.v${j.capability.version}" but not in capability's provides`,specKey:j.meta.key,capabilityKey:`${j.capability.key}.v${j.capability.version}`,surface:"presentation"})}}return{valid:z.length===0,errors:z,warnings:A}}function Q(q,z,A){switch(z){case"operation":return q.operations?.has(A)??!0;case"event":return q.events?.has(A)??!0;case"presentation":return q.presentations?.has(A)??!0;case"workflow":case"resource":return!0;default:return!0}}function Z(q){let z={operations:[],events:[],presentations:[]};if(q.operations){for(let A of q.operations.list())if(!A.capability)z.operations.push(A.meta.key)}if(q.events){for(let A of q.events.list())if(!A.capability)z.events.push(A.meta.key)}if(q.presentations){for(let A of q.presentations.list())if(!A.capability)z.presentations.push(A.meta.key)}return z}export{Y as validateCapabilityConsistency,Z as findOrphanSpecs};
