// @bun
var{defineProperty:I,getOwnPropertyNames:K,getOwnPropertyDescriptor:Q}=Object,X=Object.prototype.hasOwnProperty;function Z(S){return this[S]}var f=(S)=>{var A=(L??=new WeakMap).get(S),E;if(A)return A;if(A=I({},"__esModule",{value:!0}),S&&typeof S==="object"||typeof S==="function"){for(var N of K(S))if(!X.call(A,N))I(A,N,{get:Z.bind(S,N),enumerable:!(E=Q(S,N))||E.enumerable})}return L.set(S,A),A},L;var $=(S)=>S;function d(S,A){this[S]=$.bind(null,A)}var V=(S,A)=>{for(var E in A)I(S,E,{get:A[E],enumerable:!0,configurable:!0,set:d.bind(A,E)})};var B=(S,A)=>()=>(S&&(A=S(S=0)),A);var w={};V(w,{groupByToArray:()=>C,groupByMultiple:()=>G,groupBy:()=>_,getUniqueTags:()=>b,getUniqueOwners:()=>U,getUniqueDomains:()=>q,filterBy:()=>h,GroupingStrategies:()=>T});function h(S,A){return S.filter((E)=>{if(A.tags?.length){if(!A.tags.some((R)=>E.meta.tags?.includes(R)))return!1}if(A.owners?.length){if(!A.owners.some((R)=>E.meta.owners?.includes(R)))return!1}if(A.stability?.length){if(!A.stability.includes(E.meta.stability??"stable"))return!1}if(A.domain){if(T.byDomain(E)!==A.domain)return!1}if(A.keyPattern){let N=E.meta.key??E.meta.key??"",R=A.keyPattern.replace(/\*/g,".*").replace(/\?/g,".");if(!new RegExp(`^${R}$`,"i").test(N))return!1}return!0})}function _(S,A){let E=new Map;for(let N of S){let R=A(N),H=E.get(R);if(H)H.push(N);else E.set(R,[N])}return E}function C(S,A){let E=_(S,A);return Array.from(E.entries()).map(([N,R])=>({key:N,items:R}))}function G(S,A){let E=new Map;for(let N of S){let R=A(N);for(let H of R){let M=E.get(H);if(M)M.push(N);else E.set(H,[N])}}return E}function b(S){let A=new Set;for(let E of S)for(let N of E.meta.tags??[])A.add(N);return Array.from(A).sort()}function U(S){let A=new Set;for(let E of S)for(let N of E.meta.owners??[])A.add(N);return Array.from(A).sort()}function q(S){let A=new Set;for(let E of S)A.add(T.byDomain(E));return Array.from(A).sort()}var T;var W=B(()=>{T={byTag:(S)=>S.meta.tags?.[0]??"untagged",byAllTags:(S)=>S.meta.tags?.length?S.meta.tags:["untagged"],byOwner:(S)=>S.meta.owners?.[0]??"unowned",byDomain:(S)=>{return(S.meta.key??S.meta.key??"").split(".")[0]??"default"},byStability:(S)=>S.meta.stability??"stable",byUrlPath:(S)=>(A)=>{if(!A.path)return"root";return A.path.split("/").filter(Boolean).slice(0,S).join("/")||"root"}}});var Y={Idea:"idea",InCreation:"in_creation",Experimental:"experimental",Beta:"beta",Stable:"stable",Deprecated:"deprecated"},F={PlatformCore:"platform.core",PlatformSigil:"platform.sigil",PlatformMarketplace:"platform.marketplace",PlatformMessaging:"platform.messaging",PlatformContent:"platform.content",PlatformFeatureFlags:"platform.featureflags",PlatformFinance:"platform.finance"},n=F,x={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=x;W();import{compareVersions as u}from"compare-versions";var l=(S)=>`${S.meta.key}.v${S.meta.version}`;class D{contractType;items=new Map;constructor(S,A){this.contractType=S;if(A)A.forEach((E)=>this.register(E))}register(S){let A=l(S);if(this.items.has(A))throw Error(`Duplicate contract \`${this.contractType}\` ${A}`);return this.items.set(A,S),this}count(){return this.items.size}list(){return[...this.items.values()]}get(S,A){if(A!=null)return this.items.get(`${S}.v${A}`);let E;for(let[N,R]of this.items.entries()){if(!N.startsWith(`${S}.v`))continue;if(!E||u(R.meta.version,E.meta.version)>0)E=R}return E}has(S,A){return!!this.get(S,A)}filter(S){return h(this.list(),S)}listByTag(S){return this.list().filter((A)=>A.meta.tags?.includes(S))}listByOwner(S){return this.list().filter((A)=>A.meta.owners?.includes(S))}groupBy(S){return _(this.list(),S)}getUniqueTags(){return b(this.list())}}function a(S){return S}var t=(S,A)=>`${S}.v${A}`;class v extends D{constructor(S){super("event",S)}}var j="harness",J=["platform.harness"],P=[x.Automation,"harness","evidence","evaluation"],z=Y.Experimental;import{ScalarTypeEnum as O,SchemaModel as p}from"@contractspec/lib.schema";var c=new p({name:"HarnessRunFailedPayload",fields:{runId:{type:O.ID(),isOptional:!1},failedAt:{type:O.DateTime(),isOptional:!1},reason:{type:O.String_unsecure(),isOptional:!1},problem:{type:O.JSONObject(),isOptional:!0}}}),RS=a({meta:{key:"harness.run.failed",version:"1.0.0",description:"Emitted when a harness run fails.",domain:j,owners:J,tags:[...P,"run","failed"],stability:z},payload:c});export{c as HarnessRunFailedPayload,RS as HarnessRunFailedEvent};
