// @bun
var{defineProperty:C,getOwnPropertyNames:H,getOwnPropertyDescriptor:J}=Object,K=Object.prototype.hasOwnProperty;function Q(O){return this[O]}var n=(O)=>{var N=(b??=new WeakMap).get(O),L;if(N)return N;if(N=C({},"__esModule",{value:!0}),O&&typeof O==="object"||typeof O==="function"){for(var P of H(O))if(!K.call(N,P))C(N,P,{get:Q.bind(O,P),enumerable:!(L=J(O,P))||L.enumerable})}return b.set(O,N),N},b;var X=(O)=>O;function Z(O,N){this[O]=X.bind(null,N)}var $=(O,N)=>{for(var L in N)C(O,L,{get:N[L],enumerable:!0,configurable:!0,set:Z.bind(N,L)})};var d=(O,N)=>()=>(O&&(N=O(O=0)),N);var U={};$(U,{groupByToArray:()=>p,groupByMultiple:()=>V,groupBy:()=>E,getUniqueTags:()=>R,getUniqueOwners:()=>B,getUniqueDomains:()=>G,filterBy:()=>l,GroupingStrategies:()=>I});function l(O,N){return O.filter((L)=>{if(N.tags?.length){if(!N.tags.some((_)=>L.meta.tags?.includes(_)))return!1}if(N.owners?.length){if(!N.owners.some((_)=>L.meta.owners?.includes(_)))return!1}if(N.stability?.length){if(!N.stability.includes(L.meta.stability??"stable"))return!1}if(N.domain){if(I.byDomain(L)!==N.domain)return!1}if(N.keyPattern){let P=L.meta.key??L.meta.key??"",_=N.keyPattern.replace(/\*/g,".*").replace(/\?/g,".");if(!new RegExp(`^${_}$`,"i").test(P))return!1}return!0})}function E(O,N){let L=new Map;for(let P of O){let _=N(P),A=L.get(_);if(A)A.push(P);else L.set(_,[P])}return L}function p(O,N){let L=E(O,N);return Array.from(L.entries()).map(([P,_])=>({key:P,items:_}))}function V(O,N){let L=new Map;for(let P of O){let _=N(P);for(let A of _){let M=L.get(A);if(M)M.push(P);else L.set(A,[P])}}return L}function R(O){let N=new Set;for(let L of O)for(let P of L.meta.tags??[])N.add(P);return Array.from(N).sort()}function B(O){let N=new Set;for(let L of O)for(let P of L.meta.owners??[])N.add(P);return Array.from(N).sort()}function G(O){let N=new Set;for(let L of O)N.add(I.byDomain(L));return Array.from(N).sort()}var I;var W=d(()=>{I={byTag:(O)=>O.meta.tags?.[0]??"untagged",byAllTags:(O)=>O.meta.tags?.length?O.meta.tags:["untagged"],byOwner:(O)=>O.meta.owners?.[0]??"unowned",byDomain:(O)=>{return(O.meta.key??O.meta.key??"").split(".")[0]??"default"},byStability:(O)=>O.meta.stability??"stable",byUrlPath:(O)=>(N)=>{if(!N.path)return"root";return N.path.split("/").filter(Boolean).slice(0,O).join("/")||"root"}}});var Y={Idea:"idea",InCreation:"in_creation",Experimental:"experimental",Beta:"beta",Stable:"stable",Deprecated:"deprecated"},x={PlatformCore:"platform.core",PlatformSigil:"platform.sigil",PlatformMarketplace:"platform.marketplace",PlatformMessaging:"platform.messaging",PlatformContent:"platform.content",PlatformFeatureFlags:"platform.featureflags",PlatformFinance:"platform.finance"},f=x,D={Spots:"spots",Collectivity:"collectivity",Marketplace:"marketplace",Sellers:"sellers",Auth:"auth",Login:"login",Signup:"signup",Guide:"guide",Docs:"docs",I18n:"i18n",Incident:"incident",Automation:"automation",Hygiene:"hygiene"},y=D;W();import{compareVersions as q}from"compare-versions";var w=(O)=>`${O.meta.key}.v${O.meta.version}`;class S{contractType;items=new Map;constructor(O,N){this.contractType=O;if(N)N.forEach((L)=>this.register(L))}register(O){let N=w(O);if(this.items.has(N))throw Error(`Duplicate contract \`${this.contractType}\` ${N}`);return this.items.set(N,O),this}count(){return this.items.size}list(){return[...this.items.values()]}get(O,N){if(N!=null)return this.items.get(`${O}.v${N}`);let L;for(let[P,_]of this.items.entries()){if(!P.startsWith(`${O}.v`))continue;if(!L||q(_.meta.version,L.meta.version)>0)L=_}return L}has(O,N){return!!this.get(O,N)}filter(O){return l(this.list(),O)}listByTag(O){return this.list().filter((N)=>N.meta.tags?.includes(O))}listByOwner(O){return this.list().filter((N)=>N.meta.owners?.includes(O))}groupBy(O){return E(this.list(),O)}getUniqueTags(){return R(this.list())}}function h(O){return O}var t=(O,N)=>`${O}.v${N}`;class F extends S{constructor(O){super("event",O)}}var a="control-plane",j=[x.PlatformCore],o=[D.Automation,"control-plane","agent-runtime"],z=Y.Experimental;import{ScalarTypeEnum as T,SchemaModel as c}from"@contractspec/lib.schema";var u=new c({name:"ControlPlanePlanCompiledPayload",fields:{executionId:{type:T.ID(),isOptional:!1},planId:{type:T.ID(),isOptional:!1},compiledAt:{type:T.DateTime(),isOptional:!1},stepCount:{type:T.Int_unsecure(),isOptional:!1}}}),_O=h({meta:{key:"controlPlane.plan.compiled",version:"1.0.0",description:"Emitted when an intent is compiled into an executable plan.",domain:a,owners:j,tags:[...o,"plan"],stability:z},payload:u});export{u as ControlPlanePlanCompiledPayload,_O as ControlPlanePlanCompiledEvent};
