// @bun
var{defineProperty:y,getOwnPropertyNames:B,getOwnPropertyDescriptor:C}=Object,F=Object.prototype.hasOwnProperty;function G(b){return this[b]}var K=(b)=>{var f=(A??=new WeakMap).get(b),j;if(f)return f;if(f=y({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var k of B(b))if(!F.call(f,k))y(f,k,{get:G.bind(b,k),enumerable:!(j=C(b,k))||j.enumerable})}return A.set(b,f),f},A;var H=(b)=>b;function I(b,f){this[b]=H.bind(null,f)}var M=(b,f)=>{for(var j in f)y(b,j,{get:f[j],enumerable:!0,configurable:!0,set:I.bind(f,j)})};var N=(b,f)=>()=>(b&&(f=b(b=0)),f);class J{eventEmitter;constructor(b){this.eventEmitter=b}check(b,f){let j=f.definition.sla;if(!j)return;let k=new Date().getTime();if(j.totalDurationMs){let v=k-b.createdAt.getTime();if(v>j.totalDurationMs){if(b.status==="running"||b.status==="paused"||b.status==="waiting")this.eventEmitter("workflow.sla_breach",{workflowId:b.workflowId,workflowName:b.workflowName,type:"workflow_duration",expectedMs:j.totalDurationMs,actualMs:v,breachedAt:new Date})}}if(j.stepDurationMs){if(b.status==="running"&&b.currentStep){let v=b.history.find((q)=>q.stepId===b.currentStep&&q.status==="running");if(v){let q=j.stepDurationMs[b.currentStep];if(q){let z=k-v.startedAt.getTime();if(z>q)this.eventEmitter("workflow.sla_breach",{workflowId:b.workflowId,workflowName:b.workflowName,type:"step_duration",stepId:b.currentStep,expectedMs:q,actualMs:z,breachedAt:new Date})}}}}}}export{J as SLAMonitor};
