@graphrefly/graphrefly 0.35.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/{chunk-CD4CB6S7.js → chunk-3U7IIQB2.js} +1 -1
  2. package/dist/{chunk-PIIUJIF7.js → chunk-44QWWUA3.js} +1 -1
  3. package/dist/{chunk-3OT7K33Q.js → chunk-5CZ3KIRJ.js} +1 -1
  4. package/dist/{chunk-6SVKZ7VI.js → chunk-5RTZ6DXG.js} +1 -1
  5. package/dist/{chunk-T7GWBGOO.js → chunk-5Z3AFBN7.js} +1 -1
  6. package/dist/{chunk-XMDNNSMK.js → chunk-7LYIKMW5.js} +1 -1
  7. package/dist/{chunk-W2ZU226Q.js → chunk-AACJX2L7.js} +1 -1
  8. package/dist/{chunk-BGEY3PXH.js → chunk-AQC53OWG.js} +1 -1
  9. package/dist/{chunk-CUQFO6MT.js → chunk-CGA5RXO6.js} +1 -1
  10. package/dist/{chunk-RRFOCAH6.js → chunk-DBPFMCVH.js} +1 -1
  11. package/dist/{chunk-UAMWD4GG.js → chunk-F36TA3ET.js} +1 -1
  12. package/dist/{chunk-5XZRCS2M.js → chunk-I57VSGRB.js} +1 -1
  13. package/dist/{chunk-PVUTRA5K.js → chunk-K5ZXJPWU.js} +1 -1
  14. package/dist/{chunk-2Y3DKIZL.js → chunk-KCE6WWJE.js} +1 -1
  15. package/dist/{chunk-53XJ2S6D.js → chunk-KL7CILPL.js} +1 -1
  16. package/dist/{chunk-RLMYS3XZ.js → chunk-KUVDFOJH.js} +1 -1
  17. package/dist/{chunk-ZGVA2SR5.js → chunk-LO3LO2TO.js} +1 -1
  18. package/dist/{chunk-M5UC63ZI.js → chunk-N2GCKKKH.js} +1 -1
  19. package/dist/{chunk-EUE7ELFQ.js → chunk-PYEIPRSZ.js} +1 -1
  20. package/dist/{chunk-U347KVM4.js → chunk-QKUWS7CO.js} +1 -1
  21. package/dist/{chunk-YV2A2VWG.js → chunk-TQSTS3BY.js} +1 -1
  22. package/dist/{chunk-E5YSBQSF.js → chunk-YBA5N4XY.js} +1 -1
  23. package/dist/compat/index.d.cts +4 -4
  24. package/dist/compat/index.d.ts +4 -4
  25. package/dist/compat/index.js +1 -1
  26. package/dist/compat/nestjs/index.d.cts +3 -3
  27. package/dist/compat/nestjs/index.d.ts +3 -3
  28. package/dist/compat/nestjs/index.js +1 -1
  29. package/dist/extra/index.cjs +15 -15
  30. package/dist/extra/index.d.cts +2 -2
  31. package/dist/extra/index.d.ts +2 -2
  32. package/dist/extra/index.js +1 -1
  33. package/dist/extra/reactive.cjs +1 -1
  34. package/dist/extra/reactive.d.cts +1 -1
  35. package/dist/extra/reactive.d.ts +1 -1
  36. package/dist/extra/reactive.js +1 -1
  37. package/dist/{index-zK_mN1D-.d.cts → index-2URa-V4S.d.cts} +1 -1
  38. package/dist/{index-B3Dfl5sS.d.cts → index-33mF4XyU.d.cts} +1 -1
  39. package/dist/{index-CfOSES72.d.cts → index-BC-xjOrd.d.cts} +4 -4
  40. package/dist/{index-hXKhbfh-.d.ts → index-BTJxM-wZ.d.ts} +12 -7
  41. package/dist/{index-CzC0G0C3.d.cts → index-BVNGEX7d.d.cts} +1 -1
  42. package/dist/{index-D6JRP-1_.d.cts → index-C4ig7whw.d.cts} +1 -1
  43. package/dist/{index-KNAMYngu.d.ts → index-CVhBdCMf.d.ts} +1 -1
  44. package/dist/{index-DwNNufVa.d.ts → index-CZAixNU3.d.ts} +2 -2
  45. package/dist/{index-Qq-G9B6g.d.cts → index-Cjrpx2Mg.d.cts} +1 -1
  46. package/dist/{index-BF-ssbJB.d.ts → index-CsD0fqnO.d.ts} +1 -1
  47. package/dist/{index-DeyzuqAi.d.cts → index-CvUrRb4m.d.cts} +1 -1
  48. package/dist/{index-BkbawFkI.d.cts → index-DHv2M7s8.d.cts} +3 -3
  49. package/dist/{index-DSD6xnbT.d.ts → index-DLyQC5Ww.d.ts} +1 -1
  50. package/dist/{index-Bilohojo.d.ts → index-DSSsxS7B.d.ts} +1 -1
  51. package/dist/{index-BEvsFlfH.d.ts → index-DtSVSKnd.d.ts} +1 -1
  52. package/dist/{index-C9xF16gc.d.ts → index-DxxvGTXp.d.ts} +1 -1
  53. package/dist/{index-CGKs5ixV.d.cts → index-DzCQt2FJ.d.cts} +12 -7
  54. package/dist/{index-BpFwRAf9.d.cts → index-EfPb77rT.d.cts} +1 -1
  55. package/dist/{index-D7r_vd0b.d.cts → index-HCp5ua_i.d.cts} +2 -2
  56. package/dist/{index-DBmBtqAN.d.ts → index-KeBhbNg3.d.ts} +1 -1
  57. package/dist/{index-Dp69u0ym.d.ts → index-Pu1Wa7en.d.ts} +3 -3
  58. package/dist/{index-DXZsXxtU.d.cts → index-RJIY7QVW.d.cts} +1 -1
  59. package/dist/{index-C40wA8zt.d.ts → index-isdlyeeO.d.ts} +4 -4
  60. package/dist/{index-DzgS5uYi.d.ts → index-jA_OwwNg.d.ts} +1 -1
  61. package/dist/{index-BtY2QVDf.d.cts → index-k67aNfqC.d.cts} +1 -1
  62. package/dist/{index-CAIhFfws.d.ts → index-kBUQj-rT.d.ts} +1 -1
  63. package/dist/index.cjs +1 -1
  64. package/dist/index.d.cts +15 -15
  65. package/dist/index.d.ts +15 -15
  66. package/dist/index.js +1 -1
  67. package/dist/patterns/ai/index.d.cts +4 -4
  68. package/dist/patterns/ai/index.d.ts +4 -4
  69. package/dist/patterns/ai/index.js +1 -1
  70. package/dist/patterns/audit/index.d.cts +3 -3
  71. package/dist/patterns/audit/index.d.ts +3 -3
  72. package/dist/patterns/audit/index.js +1 -1
  73. package/dist/patterns/cqrs/index.d.cts +2 -2
  74. package/dist/patterns/cqrs/index.d.ts +2 -2
  75. package/dist/patterns/cqrs/index.js +1 -1
  76. package/dist/patterns/domain-templates/index.js +1 -1
  77. package/dist/patterns/graphspec/index.js +1 -1
  78. package/dist/patterns/guarded-execution/index.d.cts +4 -4
  79. package/dist/patterns/guarded-execution/index.d.ts +4 -4
  80. package/dist/patterns/guarded-execution/index.js +1 -1
  81. package/dist/patterns/harness/index.d.cts +6 -6
  82. package/dist/patterns/harness/index.d.ts +6 -6
  83. package/dist/patterns/harness/index.js +1 -1
  84. package/dist/patterns/job-queue/index.d.cts +2 -2
  85. package/dist/patterns/job-queue/index.d.ts +2 -2
  86. package/dist/patterns/job-queue/index.js +1 -1
  87. package/dist/patterns/lens/index.js +1 -1
  88. package/dist/patterns/messaging/index.d.cts +2 -2
  89. package/dist/patterns/messaging/index.d.ts +2 -2
  90. package/dist/patterns/messaging/index.js +1 -1
  91. package/dist/patterns/orchestration/index.d.cts +2 -2
  92. package/dist/patterns/orchestration/index.d.ts +2 -2
  93. package/dist/patterns/orchestration/index.js +1 -1
  94. package/dist/patterns/process/index.d.cts +3 -3
  95. package/dist/patterns/process/index.d.ts +3 -3
  96. package/dist/patterns/process/index.js +1 -1
  97. package/dist/patterns/reduction/index.js +1 -1
  98. package/dist/patterns/refine-loop/index.d.cts +3 -3
  99. package/dist/patterns/refine-loop/index.d.ts +3 -3
  100. package/dist/patterns/refine-loop/index.js +1 -1
  101. package/dist/patterns/resilient-pipeline/index.js +1 -1
  102. package/dist/patterns/surface/index.js +1 -1
  103. package/dist/{pipeline-graph-B85HUrWg.d.cts → pipeline-graph-BlLBWSZ2.d.cts} +1 -1
  104. package/dist/{pipeline-graph-HOTU4UG0.d.ts → pipeline-graph-DdBoRu37.d.ts} +1 -1
  105. package/dist/{reactive-log-CgbNqksB.d.cts → reactive-log-ScpWyqny.d.cts} +11 -3
  106. package/dist/{reactive-log-ByBb8g6A.d.ts → reactive-log-jirQsxMY.d.ts} +11 -3
  107. package/package.json +1 -1
@@ -1 +1 @@
1
- import{a as M,c as re,d as se}from"./chunk-CUQFO6MT.js";import{c as ae}from"./chunk-O32GJOUJ.js";import{j as ne}from"./chunk-5KPIYVCC.js";import{b as J}from"./chunk-RLMYS3XZ.js";import{C as z}from"./chunk-MQZWA3DF.js";import{D as ee,E as te,G as j,m as Y,p as R,t as D}from"./chunk-LYCLF26R.js";import{b as X}from"./chunk-CK2E7BTU.js";import{b as ge}from"./chunk-QYADASLV.js";var fe={};ge(fe,{CqrsGraph:()=>G,cqrs:()=>ve,cqrsEventKeyOf:()=>ue,dispatchKeyOf:()=>pe,sagaInvocationKeyOf:()=>he});var x=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},B=class extends x{constructor(n,t){super(`Duplicate ${n} registration: "${t}"`);this.kind=n;this.registrationName=t}},N=class extends x{constructor(n,t,r){super(`Command "${n}" emitted undeclared event "${t}". Declared emits: [${r.join(", ")}]`);this.commandName=n;this.eventName=t;this.declaredEmits=r}},K=class extends x{constructor(n,t,r){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${t}, got ${r}`);this.aggregateId=n;this.expected=t;this.actual=r}},H=class extends x{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},O=class extends x{constructor(n,t){super(`Command handler "${n}" threw: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.commandName=n}};var P=class extends x{constructor(n,t){super(`Projection "${n}" rebuild failed: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.projectionName=n}};var ce=D((a,e)=>{a("write"),a("signal"),e("observe")}),le=D((a,e)=>{a("observe"),a("signal"),e("write")}),oe=D((a,e)=>{a("observe"),a("signal"),e("write")});function $(a,e){return ae("cqrs",a,e)}function Z(a){if(a===null||typeof a!="object"||Object.isFrozen(a))return a;for(let e of Object.keys(a))Z(a[e]);return Object.freeze(a)}var ue=a=>`${a.type}::${a.aggregateId??"__default__"}`,pe=a=>a.commandName,he=a=>a.eventType,G=class extends ne{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=M({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=M({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=re(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let t=n.indexOf("::");if(t<0)continue;let r=n.slice(0,t),s=n.slice(t+2),o=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let i=this._eventLogsByAggregate.get(r);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(r)),this.aggregateEvictions.append({aggregateId:s,type:r,lastVersion:o,t_ns:R()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,t]of this._eventLogs){let r=t.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(r)}for(let[n,t]of this._eventLogsByAggregate)for(let[r,s]of t){let o=`${n}::${r}`,i=s.log.attachStorage(e),c=this._attachedTierDisposers.get(o);c||(c=[],this._attachedTierDisposers.set(o,c)),c.push(i)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let t=this._attachedTierDisposers.get(e);t||(t=[],this._attachedTierDisposers.set(e,t));for(let r of this._attachedEventTiers)t.push(n.attachStorage(r))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let t=this._eventLogs.get(e);if(t)return t.node;let r=J([],{name:e,versioning:0,maxSize:this._retainedLimit});r.withLatest();let s=r.entries,o=j([s],([i])=>i,{name:e,describeKind:"state",meta:$("event",{event_name:e}),guard:oe,initial:s.cache});return this.add(o,{name:e}),this._keepaliveDisposers.push(z(o)),this._eventLogs.set(e,{log:r,node:o}),this._autoWireStreamStorage(e,r),o}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let t=this._eventLogsByAggregate.get(e);t||(t=new Map,this._eventLogsByAggregate.set(e,t));let r=`${e}::${n}`;this._touchAggregate(r);let s=t.get(n);if(s)return s;let o=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=J([],{name:o,versioning:0,maxSize:this._retainedLimit});i.withLatest();let c=i.entries,h=j([c],([p])=>p,{name:o,describeKind:"state",meta:$("event_aggregate",{event_name:e,aggregate_id:n}),guard:oe,initial:c.cache}),l=o,m=0;for(;this.nameOf(this.resolveOptional(l)??h)===l&&(m+=1,l=`${o}_${m}`,this.resolveOptional(l)!==void 0););try{this.add(h,{name:l})}catch{}this._keepaliveDisposers.push(z(h));let u={log:i,node:h};return t.set(n,u),this._autoWireStreamStorage(`${e}::${n}`,i),this._enforceAggregateLru(),u}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,t){let r=this._eventLogs.get(e);if(r||(this.event(e),r=this._eventLogs.get(e)),r.node.status==="completed"||r.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${r.node.status}).`);let s,o;if(t?.aggregateId!==void 0){let l=`${e}::${t.aggregateId}`;s=(this._aggregateVersions.get(l)??0)+1,this._aggregateVersions.set(l,s),o=this._ensureAggregateStream(e,t.aggregateId)}let i=r.log.entries.v,c=this._freezeEventPayload?Z(n):n,h={type:e,payload:c,timestampNs:R(),seq:++this._seq,...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...t?.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return r.log.append(h),o&&o.log.append(h),h}command(e,n){if(this._commandRegs.has(e))throw new B("command",e);let t=typeof n=="function"?{handler:n}:n,r=te(void 0,{name:e,describeKind:"state",meta:{...$("command",{command_name:e}),error:null},guard:ce});if(this.add(r,{name:e}),this._commandRegs.set(e,{handler:t.handler,...t.emits!==void 0?{emits:t.emits}:{},...t.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{}}),t.emits)for(let s of t.emits)this._eventLogs.has(s)||this.event(s);return r}dispatch(e,n,t){let r=this._commandRegs.get(e);if(!r)throw new H(e);if(t?.aggregateId!==void 0&&t.expectedAggregateVersion!==void 0&&r.emits!==void 0){let u=0;for(let p of r.emits){let _=this._aggregateVersions.get(`${p}::${t.aggregateId}`);_!==void 0&&_>u&&(u=_)}if(u!==t.expectedAggregateVersion)throw new K(t.aggregateId,t.expectedAggregateVersion,u)}let s=this.resolve(e),o=this._freezeCommandPayload?Z(n):n,i=[],c=R(),h=0,l,m=!1;try{Y(()=>{h=this._bumpDispatchSeq(),s.emit(o,{internal:!0});try{r.handler(o,{emit:(u,p)=>{if(r.emits!==void 0&&!r.emits.includes(u))throw new N(e,u,r.emits);i.push(u),this._appendEvent(u,p,{...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:o,status:"success",emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}catch(u){throw l=u,m=!0,u}})}catch(u){if(m){s.meta.error.emit(l,{internal:!0});let p=l instanceof Error?l.name:typeof l,_=l instanceof O?l:new O(e,l);this.dispatches.append({commandName:e,payload:o,status:"failed",error:_,errorType:p,emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}throw m?l:u}}projection(e){let{name:n,events:t,reducer:r,initial:s}=e,o=e.mode??"scan",i=e.freezeInputs??!0,c=e.snapshot,h=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node));function l(d){d.sort((g,v)=>g.timestampNs-v.timestampNs||g.seq-v.seq||(g.aggregateId??"").localeCompare(v.aggregateId??""))}function m(d){let g=[];for(let v of d)g.push(...v);return l(g),g}let u=h.map(d=>d.cache??[]),p=m(u),_=i?Object.freeze(p):p,C=0,y=s;o==="scan"&&p.length>0&&(y=r(s,_),C=p.length);let q=o==="replay"?r(s,_):y,V=c?.saveDebounceMs??1e3,A=c?.saveEvery??1e3,E,L=0;function U(d){if(c?.save){if(L+=1,L>=A){L=0,E!==void 0&&(clearTimeout(E),E=void 0);let g=c.save(d);g instanceof Promise&&g.catch(()=>{});return}E!==void 0&&clearTimeout(E),E=setTimeout(()=>{E=void 0,L=0;let g=c.save(d);g instanceof Promise&&g.catch(()=>{})},V)}}let S=j(h,d=>{let g=m(d),v;if(o==="replay"){let w=i?Object.freeze(g):g;v=r(s,w)}else{let w=g.slice(C);C=g.length;let f=i?Object.freeze(w):w;v=r(y,f),y=v}return U(v),v},{name:n,describeKind:"derived",meta:$("projection",{projection_name:n,source_events:t}),guard:le,initial:q});return this.add(S,{name:n}),this._keepaliveDisposers.push(z(S)),this._keepaliveDisposers.push(()=>{E!==void 0&&(clearTimeout(E),E=void 0)}),this._projections.add(n),{node:S,rebuild:async d=>{try{let g=d?.pageSize??1e3,v=d?.fromTier??this._attachedEventTiers[0]?.[0],w=m(h.map(T=>T.cache??[])).length,f=s;if(c?.load){let T=await c.load();T!==void 0&&(f=T)}if(!v||!v.loadEntries){let T=m(h.map(I=>I.cache??[])),b=i?Object.freeze(T):T;f=r(f,b)}else{let T=new Set(t),b,I=!1;for(;!I;){let F=await v.loadEntries({cursor:b,pageSize:g}),W=[...F.entries].filter(de=>T.has(de.type));l(W);let ie=i?Object.freeze(W):W;f=r(f,ie),b=F.cursor,I=!b||F.entries.length===0}}if(o==="scan"){let T=m(h.map(I=>I.cache??[])),b=T.slice(w);if(b.length>0){let I=i?Object.freeze(b):b;f=r(f,I)}y=f,C=T.length}return S.emit(f,{internal:!0}),f}catch(g){throw new P(n,g)}},reset:async()=>{try{let d=s;if(c?.load){let f=await c.load();f!==void 0&&(d=f)}let g=m(h.map(f=>f.cache??[])),v=i?Object.freeze(g):g,w=r(d,v);return o==="scan"&&(y=w,C=g.length),S.emit(w,{internal:!0}),w}catch(d){throw new P(n,d)}}}}saga(e,n,t,r={}){let s=n.map(p=>(this._eventLogs.has(p)||this.event(p),this._eventLogs.get(p).node)),o=se(this,`${e}_cursor`,n,0),i=M({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),c=r.aggregateId,h=r.errorPolicy??"advance",l=new Map;for(let p of n){let _=o[p];l.set(p,_.cache??0);let C=_.subscribe(y=>{for(let q of y)q[0]===X&&l.set(p,q[1])});this._keepaliveDisposers.push(C)}let m={},u=ee(s,(p,_)=>{let C=m.n.meta.error;for(let y=0;y<p.length;y++){let q=p[y];if(q==null||q.length===0)continue;let V=q.at(-1);if(!V)continue;let A=n[y],E=o[A],L=l.get(A)??0;if(V.length>L){let U=V.slice(L),S=L;for(let Q of U){let k=Q;if(c!==void 0&&k.aggregateId!==c){S+=1;continue}try{t(k),C.emit(null,{internal:!0}),i.append({eventType:A,status:"success",aggregateId:k.aggregateId,event:k,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),S+=1}catch(d){if(C.emit(d,{internal:!0}),i.append({eventType:A,status:"failed",error:d,errorType:d instanceof Error?d.name:typeof d,aggregateId:k.aggregateId,event:k,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),h==="hold")break;S+=1}}E.emit(S)}}},{name:e,describeKind:"effect",meta:{...$("saga",{saga_name:e,source_events:n}),error:null}});return m.n=u,this.add(u,{name:e}),this._keepaliveDisposers.push(z(u)),this._sagas.add(e),{node:u,invocations:i,audit:i,cursors:o}}};function ve(a,e){return new G(a,e)}export{ue as a,pe as b,he as c,G as d,ve as e,fe as f};
1
+ import{a as M,c as re,d as se}from"./chunk-CGA5RXO6.js";import{c as ae}from"./chunk-O32GJOUJ.js";import{b as J}from"./chunk-KUVDFOJH.js";import{j as ne}from"./chunk-5KPIYVCC.js";import{C as z}from"./chunk-MQZWA3DF.js";import{D as ee,E as te,G as j,m as Y,p as R,t as D}from"./chunk-LYCLF26R.js";import{b as X}from"./chunk-CK2E7BTU.js";import{b as ge}from"./chunk-QYADASLV.js";var fe={};ge(fe,{CqrsGraph:()=>G,cqrs:()=>ve,cqrsEventKeyOf:()=>ue,dispatchKeyOf:()=>pe,sagaInvocationKeyOf:()=>he});var x=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},B=class extends x{constructor(n,t){super(`Duplicate ${n} registration: "${t}"`);this.kind=n;this.registrationName=t}},N=class extends x{constructor(n,t,r){super(`Command "${n}" emitted undeclared event "${t}". Declared emits: [${r.join(", ")}]`);this.commandName=n;this.eventName=t;this.declaredEmits=r}},K=class extends x{constructor(n,t,r){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${t}, got ${r}`);this.aggregateId=n;this.expected=t;this.actual=r}},H=class extends x{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},O=class extends x{constructor(n,t){super(`Command handler "${n}" threw: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.commandName=n}};var P=class extends x{constructor(n,t){super(`Projection "${n}" rebuild failed: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.projectionName=n}};var ce=D((a,e)=>{a("write"),a("signal"),e("observe")}),le=D((a,e)=>{a("observe"),a("signal"),e("write")}),oe=D((a,e)=>{a("observe"),a("signal"),e("write")});function $(a,e){return ae("cqrs",a,e)}function Z(a){if(a===null||typeof a!="object"||Object.isFrozen(a))return a;for(let e of Object.keys(a))Z(a[e]);return Object.freeze(a)}var ue=a=>`${a.type}::${a.aggregateId??"__default__"}`,pe=a=>a.commandName,he=a=>a.eventType,G=class extends ne{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=M({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=M({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=re(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let t=n.indexOf("::");if(t<0)continue;let r=n.slice(0,t),s=n.slice(t+2),o=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let i=this._eventLogsByAggregate.get(r);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(r)),this.aggregateEvictions.append({aggregateId:s,type:r,lastVersion:o,t_ns:R()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,t]of this._eventLogs){let r=t.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(r)}for(let[n,t]of this._eventLogsByAggregate)for(let[r,s]of t){let o=`${n}::${r}`,i=s.log.attachStorage(e),c=this._attachedTierDisposers.get(o);c||(c=[],this._attachedTierDisposers.set(o,c)),c.push(i)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let t=this._attachedTierDisposers.get(e);t||(t=[],this._attachedTierDisposers.set(e,t));for(let r of this._attachedEventTiers)t.push(n.attachStorage(r))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let t=this._eventLogs.get(e);if(t)return t.node;let r=J([],{name:e,versioning:0,maxSize:this._retainedLimit});r.withLatest();let s=r.entries,o=j([s],([i])=>i,{name:e,describeKind:"state",meta:$("event",{event_name:e}),guard:oe,initial:s.cache});return this.add(o,{name:e}),this._keepaliveDisposers.push(z(o)),this._eventLogs.set(e,{log:r,node:o}),this._autoWireStreamStorage(e,r),o}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let t=this._eventLogsByAggregate.get(e);t||(t=new Map,this._eventLogsByAggregate.set(e,t));let r=`${e}::${n}`;this._touchAggregate(r);let s=t.get(n);if(s)return s;let o=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=J([],{name:o,versioning:0,maxSize:this._retainedLimit});i.withLatest();let c=i.entries,h=j([c],([p])=>p,{name:o,describeKind:"state",meta:$("event_aggregate",{event_name:e,aggregate_id:n}),guard:oe,initial:c.cache}),l=o,m=0;for(;this.nameOf(this.resolveOptional(l)??h)===l&&(m+=1,l=`${o}_${m}`,this.resolveOptional(l)!==void 0););try{this.add(h,{name:l})}catch{}this._keepaliveDisposers.push(z(h));let u={log:i,node:h};return t.set(n,u),this._autoWireStreamStorage(`${e}::${n}`,i),this._enforceAggregateLru(),u}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,t){let r=this._eventLogs.get(e);if(r||(this.event(e),r=this._eventLogs.get(e)),r.node.status==="completed"||r.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${r.node.status}).`);let s,o;if(t?.aggregateId!==void 0){let l=`${e}::${t.aggregateId}`;s=(this._aggregateVersions.get(l)??0)+1,this._aggregateVersions.set(l,s),o=this._ensureAggregateStream(e,t.aggregateId)}let i=r.log.entries.v,c=this._freezeEventPayload?Z(n):n,h={type:e,payload:c,timestampNs:R(),seq:++this._seq,...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...t?.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return r.log.append(h),o&&o.log.append(h),h}command(e,n){if(this._commandRegs.has(e))throw new B("command",e);let t=typeof n=="function"?{handler:n}:n,r=te(void 0,{name:e,describeKind:"state",meta:{...$("command",{command_name:e}),error:null},guard:ce});if(this.add(r,{name:e}),this._commandRegs.set(e,{handler:t.handler,...t.emits!==void 0?{emits:t.emits}:{},...t.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{}}),t.emits)for(let s of t.emits)this._eventLogs.has(s)||this.event(s);return r}dispatch(e,n,t){let r=this._commandRegs.get(e);if(!r)throw new H(e);if(t?.aggregateId!==void 0&&t.expectedAggregateVersion!==void 0&&r.emits!==void 0){let u=0;for(let p of r.emits){let _=this._aggregateVersions.get(`${p}::${t.aggregateId}`);_!==void 0&&_>u&&(u=_)}if(u!==t.expectedAggregateVersion)throw new K(t.aggregateId,t.expectedAggregateVersion,u)}let s=this.resolve(e),o=this._freezeCommandPayload?Z(n):n,i=[],c=R(),h=0,l,m=!1;try{Y(()=>{h=this._bumpDispatchSeq(),s.emit(o,{internal:!0});try{r.handler(o,{emit:(u,p)=>{if(r.emits!==void 0&&!r.emits.includes(u))throw new N(e,u,r.emits);i.push(u),this._appendEvent(u,p,{...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:o,status:"success",emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}catch(u){throw l=u,m=!0,u}})}catch(u){if(m){s.meta.error.emit(l,{internal:!0});let p=l instanceof Error?l.name:typeof l,_=l instanceof O?l:new O(e,l);this.dispatches.append({commandName:e,payload:o,status:"failed",error:_,errorType:p,emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}throw m?l:u}}projection(e){let{name:n,events:t,reducer:r,initial:s}=e,o=e.mode??"scan",i=e.freezeInputs??!0,c=e.snapshot,h=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node));function l(d){d.sort((g,v)=>g.timestampNs-v.timestampNs||g.seq-v.seq||(g.aggregateId??"").localeCompare(v.aggregateId??""))}function m(d){let g=[];for(let v of d)g.push(...v);return l(g),g}let u=h.map(d=>d.cache??[]),p=m(u),_=i?Object.freeze(p):p,C=0,y=s;o==="scan"&&p.length>0&&(y=r(s,_),C=p.length);let q=o==="replay"?r(s,_):y,V=c?.saveDebounceMs??1e3,A=c?.saveEvery??1e3,E,L=0;function U(d){if(c?.save){if(L+=1,L>=A){L=0,E!==void 0&&(clearTimeout(E),E=void 0);let g=c.save(d);g instanceof Promise&&g.catch(()=>{});return}E!==void 0&&clearTimeout(E),E=setTimeout(()=>{E=void 0,L=0;let g=c.save(d);g instanceof Promise&&g.catch(()=>{})},V)}}let S=j(h,d=>{let g=m(d),v;if(o==="replay"){let w=i?Object.freeze(g):g;v=r(s,w)}else{let w=g.slice(C);C=g.length;let f=i?Object.freeze(w):w;v=r(y,f),y=v}return U(v),v},{name:n,describeKind:"derived",meta:$("projection",{projection_name:n,source_events:t}),guard:le,initial:q});return this.add(S,{name:n}),this._keepaliveDisposers.push(z(S)),this._keepaliveDisposers.push(()=>{E!==void 0&&(clearTimeout(E),E=void 0)}),this._projections.add(n),{node:S,rebuild:async d=>{try{let g=d?.pageSize??1e3,v=d?.fromTier??this._attachedEventTiers[0]?.[0],w=m(h.map(T=>T.cache??[])).length,f=s;if(c?.load){let T=await c.load();T!==void 0&&(f=T)}if(!v||!v.loadEntries){let T=m(h.map(I=>I.cache??[])),b=i?Object.freeze(T):T;f=r(f,b)}else{let T=new Set(t),b,I=!1;for(;!I;){let F=await v.loadEntries({cursor:b,pageSize:g}),W=[...F.entries].filter(de=>T.has(de.type));l(W);let ie=i?Object.freeze(W):W;f=r(f,ie),b=F.cursor,I=!b||F.entries.length===0}}if(o==="scan"){let T=m(h.map(I=>I.cache??[])),b=T.slice(w);if(b.length>0){let I=i?Object.freeze(b):b;f=r(f,I)}y=f,C=T.length}return S.emit(f,{internal:!0}),f}catch(g){throw new P(n,g)}},reset:async()=>{try{let d=s;if(c?.load){let f=await c.load();f!==void 0&&(d=f)}let g=m(h.map(f=>f.cache??[])),v=i?Object.freeze(g):g,w=r(d,v);return o==="scan"&&(y=w,C=g.length),S.emit(w,{internal:!0}),w}catch(d){throw new P(n,d)}}}}saga(e,n,t,r={}){let s=n.map(p=>(this._eventLogs.has(p)||this.event(p),this._eventLogs.get(p).node)),o=se(this,`${e}_cursor`,n,0),i=M({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),c=r.aggregateId,h=r.errorPolicy??"advance",l=new Map;for(let p of n){let _=o[p];l.set(p,_.cache??0);let C=_.subscribe(y=>{for(let q of y)q[0]===X&&l.set(p,q[1])});this._keepaliveDisposers.push(C)}let m={},u=ee(s,(p,_)=>{let C=m.n.meta.error;for(let y=0;y<p.length;y++){let q=p[y];if(q==null||q.length===0)continue;let V=q.at(-1);if(!V)continue;let A=n[y],E=o[A],L=l.get(A)??0;if(V.length>L){let U=V.slice(L),S=L;for(let Q of U){let k=Q;if(c!==void 0&&k.aggregateId!==c){S+=1;continue}try{t(k),C.emit(null,{internal:!0}),i.append({eventType:A,status:"success",aggregateId:k.aggregateId,event:k,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),S+=1}catch(d){if(C.emit(d,{internal:!0}),i.append({eventType:A,status:"failed",error:d,errorType:d instanceof Error?d.name:typeof d,aggregateId:k.aggregateId,event:k,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),h==="hold")break;S+=1}}E.emit(S)}}},{name:e,describeKind:"effect",meta:{...$("saga",{saga_name:e,source_events:n}),error:null}});return m.n=u,this.add(u,{name:e}),this._keepaliveDisposers.push(z(u)),this._sagas.add(e),{node:u,invocations:i,audit:i,cursors:o}}};function ve(a,e){return new G(a,e)}export{ue as a,pe as b,he as c,G as d,ve as e,fe as f};
@@ -1 +1 @@
1
- import{a as $}from"./chunk-BGEY3PXH.js";import{c as O}from"./chunk-O32GJOUJ.js";import{a as C}from"./chunk-T6RPUERH.js";import{j as A}from"./chunk-5KPIYVCC.js";import{b as x}from"./chunk-RLMYS3XZ.js";import{C as R}from"./chunk-MQZWA3DF.js";import{C as T,E as N,G as E,o as b,p as w,u as P,w as S}from"./chunk-LYCLF26R.js";import{b as v}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var J={};M(J,{AuditTrailGraph:()=>k,PolicyEnforcerGraph:()=>G,auditTrail:()=>z,complianceSnapshot:()=>F,policyEnforcer:()=>K,reactiveExplainPath:()=>q});function V(i,t){return O("audit",i,t)}var L=new Set(["data","error","complete","teardown"]),k=class extends A{entries;count;_log;_target;constructor(t,n){super(n.name??`${t.name}_audit`,n.graph),this._target=t,this._log=x([],{name:"entries",...n.maxSize!=null?{maxSize:n.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=E([this.entries],([c])=>c.length,{name:"count",describeKind:"derived",meta:V("count")}),this.add(this.count,{name:"count"}),this.addDisposer(R(this.count));let o=n.includeTypes!=null?new Set(n.includeTypes):L,u=n.filter,a=0,h=t.observe({timeline:!0,structured:!0}),m=h.onEvent(c=>{if(c.type==="derived")return;let e=c.type;if(!o.has(e))return;let d=c.path??"",r={seq:a++,timestamp_ns:c.timestamp_ns??b(),wall_clock_ns:w(),path:d,type:e},f=(d?D(t,d):void 0)?.lastMutation;f!=null&&(r.actor=f.actor),e==="data"&&(r.value=c.data),e==="error"&&(r.error=c.data);let l=d?U(t,d):void 0;l!=null&&(r.annotation=l),!(u!=null&&!u(r))&&this._log.append(r)});this.addDisposer(()=>{m(),h.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(t){return this.all().filter(n=>n.path===t)}byActor(t){return this.all().filter(n=>n.actor?.id===t)}byActorType(t){return this.all().filter(n=>n.actor?.type===t)}byTimeRange(t,n){return this.all().filter(o=>!(o.timestamp_ns<t||n!=null&&o.timestamp_ns>=n))}get target(){return this._target}};function z(i,t={}){return new k(i,t)}var G=class extends A{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(t,n,o){super(o.name??`${t.name}_policy`,o.graph),this._target=t,this._mode=o.mode??"audit";let u=I(n)?n:N(n,{name:"policies"});this.policies=u,this.add(this.policies,{name:"policies"}),this.violations=new $("violations",{retainedLimit:o.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=E([this.violations.events],([e])=>e.length,{name:"violationCount",describeKind:"derived",meta:V("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(R(this.violationCount));let h=u.cache??[];this._currentGuard=P(h);let m=u.subscribe(e=>{for(let d of e)d[0]===v&&(h=d[1]??[],this._currentGuard=P(h))});this.addDisposer(m);let c=o.paths!=null?[...o.paths]:j(t);if(this._mode==="enforce"){let e=new Map,d=r=>{if(e.has(r))return;let s=D(t,r);if(!(s instanceof T))return;let f=(l,p)=>{let y=this._currentGuard(l,p);return y||this._publishViolation(l,p,r,"blocked"),y};e.set(r,s._pushGuard(f))};for(let r of c)d(r);if(o.paths==null){let r=C(t,(s,f,l)=>{if(s.kind==="added")if(s.nodeKind==="node")d(`${l}${s.name}`);else{let p=f._mounts.get(s.name);if(!(p instanceof A))return;let y=`${l}${s.name}::`,_=j(p);for(let g of _)d(g===""?`${l}${s.name}`:`${y}${g}`)}else if(s.kind==="removed")if(s.nodeKind==="node"){let p=`${l}${s.name}`,y=e.get(p);y!=null&&(y(),e.delete(p))}else{let p=`${l}${s.name}`,y=`${p}::`;for(let[_,g]of e)(_===p||_.startsWith(y))&&(g(),e.delete(_))}});this.addDisposer(r)}else{let r=t.topology.subscribe(s=>{for(let f of s){if(f[0]!==v)continue;let l=f[1];if(l.kind!=="removed"||l.nodeKind!=="node")continue;let p=e.get(l.name);p!=null&&(p(),e.delete(l.name))}});this.addDisposer(r)}this.addDisposer(()=>{for(let r of e.values())r();e.clear()})}else{let e=t.observe({timeline:!0,structured:!0}),d=e.onEvent(r=>{if(r.type!=="data"&&r.type!=="error")return;let s=r.path??"";if(!s||o.paths!=null&&!o.paths.includes(s))return;let f=r.actor??D(t,s)?.lastMutation?.actor;if(f==null)return;let l="write";this._currentGuard(f,l)||this._publishViolation(f,l,s,"observed")});this.addDisposer(()=>{d(),e.dispose()})}}_publishViolation(t,n,o,u){this.violations.publish({timestamp_ns:b(),wall_clock_ns:w(),path:o,actor:t,action:n,mode:this._mode,result:u})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(i,t,n={}){return new G(i,t,n)}function q(i,t,n,o){return i.explain(t,n,{reactive:!0,...o})}function F(i,t={}){let n={format_version:1,timestamp_ns:b(),wall_clock_ns:w(),graph:i.snapshot()};if(t.actor!=null&&(n.actor=t.actor),t.audit!=null){let u=[...t.audit.all()];n.audit={count:u.length,entries:u}}if(t.policies!=null){let u=t.policies.policies.cache??[];n.policies={mode:t.policies.mode,rules:u,violations:[...t.policies.all()]}}let o=B(n);return{...n,fingerprint:o}}function I(i){return typeof i=="object"&&i!==null&&"subscribe"in i}function D(i,t){try{return i.node(t)}catch{return}}function U(i,t){try{return i.annotation(t)}catch{return}}function j(i){let t=i.describe({detail:"minimal"});return Object.keys(t.nodes)}function B(i){return S(JSON.stringify(H(i)))}function H(i){let t=new Set,n=o=>{if(o===void 0)return{__undefined:!0};if(o===null)return null;let u=typeof o;if(u==="bigint")return{__bigint:o.toString()};if(u!=="object")return o;let a=o;if(t.has(a))return{__circular:!0};t.add(a);try{if(Array.isArray(a))return a.map(n);if(a instanceof Date)return{__date:a.toISOString()};if(a instanceof RegExp)return{__regexp:{source:a.source,flags:a.flags}};if(a instanceof Map)return{__map:[...a.entries()].map(([c,e])=>[n(c),n(e)])};if(a instanceof Set)return{__set:[...a].map(n)};if(ArrayBuffer.isView(a)){let m=a,c=new Array(m.length);for(let e=0;e<m.length;e++)c[e]=m[e]??0;return{__typed_array:{ctor:a.constructor.name,data:c}}}let h={};for(let m of Object.keys(a).sort())h[m]=n(a[m]);return h}finally{t.delete(a)}};return n(i)}export{k as a,z as b,G as c,K as d,q as e,F as f,J as g};
1
+ import{a as $}from"./chunk-AQC53OWG.js";import{c as O}from"./chunk-O32GJOUJ.js";import{a as C}from"./chunk-T6RPUERH.js";import{b as x}from"./chunk-KUVDFOJH.js";import{j as A}from"./chunk-5KPIYVCC.js";import{C as R}from"./chunk-MQZWA3DF.js";import{C as T,E as N,G as E,o as b,p as w,u as P,w as S}from"./chunk-LYCLF26R.js";import{b as v}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var J={};M(J,{AuditTrailGraph:()=>k,PolicyEnforcerGraph:()=>G,auditTrail:()=>z,complianceSnapshot:()=>F,policyEnforcer:()=>K,reactiveExplainPath:()=>q});function V(i,t){return O("audit",i,t)}var L=new Set(["data","error","complete","teardown"]),k=class extends A{entries;count;_log;_target;constructor(t,n){super(n.name??`${t.name}_audit`,n.graph),this._target=t,this._log=x([],{name:"entries",...n.maxSize!=null?{maxSize:n.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=E([this.entries],([c])=>c.length,{name:"count",describeKind:"derived",meta:V("count")}),this.add(this.count,{name:"count"}),this.addDisposer(R(this.count));let o=n.includeTypes!=null?new Set(n.includeTypes):L,u=n.filter,a=0,h=t.observe({timeline:!0,structured:!0}),m=h.onEvent(c=>{if(c.type==="derived")return;let e=c.type;if(!o.has(e))return;let d=c.path??"",r={seq:a++,timestamp_ns:c.timestamp_ns??b(),wall_clock_ns:w(),path:d,type:e},f=(d?D(t,d):void 0)?.lastMutation;f!=null&&(r.actor=f.actor),e==="data"&&(r.value=c.data),e==="error"&&(r.error=c.data);let l=d?U(t,d):void 0;l!=null&&(r.annotation=l),!(u!=null&&!u(r))&&this._log.append(r)});this.addDisposer(()=>{m(),h.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(t){return this.all().filter(n=>n.path===t)}byActor(t){return this.all().filter(n=>n.actor?.id===t)}byActorType(t){return this.all().filter(n=>n.actor?.type===t)}byTimeRange(t,n){return this.all().filter(o=>!(o.timestamp_ns<t||n!=null&&o.timestamp_ns>=n))}get target(){return this._target}};function z(i,t={}){return new k(i,t)}var G=class extends A{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(t,n,o){super(o.name??`${t.name}_policy`,o.graph),this._target=t,this._mode=o.mode??"audit";let u=I(n)?n:N(n,{name:"policies"});this.policies=u,this.add(this.policies,{name:"policies"}),this.violations=new $("violations",{retainedLimit:o.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=E([this.violations.events],([e])=>e.length,{name:"violationCount",describeKind:"derived",meta:V("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(R(this.violationCount));let h=u.cache??[];this._currentGuard=P(h);let m=u.subscribe(e=>{for(let d of e)d[0]===v&&(h=d[1]??[],this._currentGuard=P(h))});this.addDisposer(m);let c=o.paths!=null?[...o.paths]:j(t);if(this._mode==="enforce"){let e=new Map,d=r=>{if(e.has(r))return;let s=D(t,r);if(!(s instanceof T))return;let f=(l,p)=>{let y=this._currentGuard(l,p);return y||this._publishViolation(l,p,r,"blocked"),y};e.set(r,s._pushGuard(f))};for(let r of c)d(r);if(o.paths==null){let r=C(t,(s,f,l)=>{if(s.kind==="added")if(s.nodeKind==="node")d(`${l}${s.name}`);else{let p=f._mounts.get(s.name);if(!(p instanceof A))return;let y=`${l}${s.name}::`,_=j(p);for(let g of _)d(g===""?`${l}${s.name}`:`${y}${g}`)}else if(s.kind==="removed")if(s.nodeKind==="node"){let p=`${l}${s.name}`,y=e.get(p);y!=null&&(y(),e.delete(p))}else{let p=`${l}${s.name}`,y=`${p}::`;for(let[_,g]of e)(_===p||_.startsWith(y))&&(g(),e.delete(_))}});this.addDisposer(r)}else{let r=t.topology.subscribe(s=>{for(let f of s){if(f[0]!==v)continue;let l=f[1];if(l.kind!=="removed"||l.nodeKind!=="node")continue;let p=e.get(l.name);p!=null&&(p(),e.delete(l.name))}});this.addDisposer(r)}this.addDisposer(()=>{for(let r of e.values())r();e.clear()})}else{let e=t.observe({timeline:!0,structured:!0}),d=e.onEvent(r=>{if(r.type!=="data"&&r.type!=="error")return;let s=r.path??"";if(!s||o.paths!=null&&!o.paths.includes(s))return;let f=r.actor??D(t,s)?.lastMutation?.actor;if(f==null)return;let l="write";this._currentGuard(f,l)||this._publishViolation(f,l,s,"observed")});this.addDisposer(()=>{d(),e.dispose()})}}_publishViolation(t,n,o,u){this.violations.publish({timestamp_ns:b(),wall_clock_ns:w(),path:o,actor:t,action:n,mode:this._mode,result:u})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(i,t,n={}){return new G(i,t,n)}function q(i,t,n,o){return i.explain(t,n,{reactive:!0,...o})}function F(i,t={}){let n={format_version:1,timestamp_ns:b(),wall_clock_ns:w(),graph:i.snapshot()};if(t.actor!=null&&(n.actor=t.actor),t.audit!=null){let u=[...t.audit.all()];n.audit={count:u.length,entries:u}}if(t.policies!=null){let u=t.policies.policies.cache??[];n.policies={mode:t.policies.mode,rules:u,violations:[...t.policies.all()]}}let o=B(n);return{...n,fingerprint:o}}function I(i){return typeof i=="object"&&i!==null&&"subscribe"in i}function D(i,t){try{return i.node(t)}catch{return}}function U(i,t){try{return i.annotation(t)}catch{return}}function j(i){let t=i.describe({detail:"minimal"});return Object.keys(t.nodes)}function B(i){return S(JSON.stringify(H(i)))}function H(i){let t=new Set,n=o=>{if(o===void 0)return{__undefined:!0};if(o===null)return null;let u=typeof o;if(u==="bigint")return{__bigint:o.toString()};if(u!=="object")return o;let a=o;if(t.has(a))return{__circular:!0};t.add(a);try{if(Array.isArray(a))return a.map(n);if(a instanceof Date)return{__date:a.toISOString()};if(a instanceof RegExp)return{__regexp:{source:a.source,flags:a.flags}};if(a instanceof Map)return{__map:[...a.entries()].map(([c,e])=>[n(c),n(e)])};if(a instanceof Set)return{__set:[...a].map(n)};if(ArrayBuffer.isView(a)){let m=a,c=new Array(m.length);for(let e=0;e<m.length;e++)c[e]=m[e]??0;return{__typed_array:{ctor:a.constructor.name,data:c}}}let h={};for(let m of Object.keys(a).sort())h[m]=n(a[m]);return h}finally{t.delete(a)}};return n(i)}export{k as a,z as b,G as c,K as d,q as e,F as f,J as g};
@@ -1 +1 @@
1
- import{a as L,b as _}from"./chunk-CUQFO6MT.js";import{c as z}from"./chunk-O32GJOUJ.js";import{j as F}from"./chunk-5KPIYVCC.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as te}from"./chunk-QYADASLV.js";var ie={};te(ie,{PipelineGraph:()=>x,decisionKeyOf:()=>$,pipelineGraph:()=>q});function N(y,t){return z("orchestration",y,t)}var $=y=>y.action,x=class extends F{constructor(t,s){super(t,s)}task(t,s,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,s,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,s,e,a={}){let p=this._resolveStep(s),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,s,e={}){let a=Object.keys(s),p=a.map(d=>this._resolveStep(s[d])),c=D(p,d=>{let f={};for(let i=0;i<a.length;i++)f[a[i]]=d[i];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}gate(t,s,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("gate: maxPending must be >= 1");let p=e.startOpen??!1;typeof s!="string"&&this.nameOf(s)===void 0&&this.add(s,{name:`${t}/source`});let c=this._resolveStep(s),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),i=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),h=G(0,{name:"droppedCount"}),u=L({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(i,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(h,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,O=p,W=i.subscribe(n=>{for(let o of n)o[0]===P&&(O=o[1])});this.addDisposer(W);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function M(n){if(l.push(n),l.length>a){let o=l.shift();h.emit(h.cache+1),C("drop",[o])}A()}function w(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let T=r.terminalDeps[0];if(T!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(T===!0?[[I]]:[[K,T]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)O?o.emit(g):(M(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(i.emit(!0),O=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let T of r){if(T[0]!==P)continue;let m=!!T[1];if(m&&!O){if(e.onceOnly){if(k)continue;k=!0}E(()=>{i.emit(!0);let g=w(l.length);C("open",g);for(let oe of g){if(v)break;b.emit(oe)}})}else if(!m&&O){if(e.onceOnly&&k)continue;E(()=>{i.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`gate: ${n}() called after gate was torn down`)},U=(n=1)=>{V("approve");let o=w(n);for(let r of o){if(v)break;b.emit(r)}},Y=(n=1)=>{V("reject"),w(n)},H=(n,o=1)=>{V("modify");let r=[...l],T=w(o);for(let m=0;m<T.length&&!v;m++)b.emit(n(T[m],m,r))},J=()=>{V("open"),i.emit(!0);let n=w(l.length);for(let o of n){if(v)break;b.emit(o)}},Q=()=>{V("close"),!(e.onceOnly&&k)&&i.emit(!1)},X=_(U,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:i,droppedCount:h,decisions:u,audit:u,approve:X,reject:Z,modify:ee,open:ne,close:re}}approval(t,s,e,a={}){return this.gate(t,s,{...a,approver:e,maxPending:1})}catch(t,s,e,a={}){let p=this._resolveStep(s),c=a.on??"error",d=j([p],(f,i,R)=>{let h=R.terminalDeps[0];if(h!==void 0){let l=h===!0?{kind:"complete"}:{kind:"error",error:h};if(c==="terminal"||c===l.kind){i.emit(e(l,i));return}i.down(l.kind==="complete"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){i.down([[S]]);return}for(let l of u)i.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="complete"||c==="terminal"),errorWhenDepsError:!(c==="error"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function q(y,t){return new x(y,t)}export{$ as a,x as b,q as c,ie as d};
1
+ import{a as L,b as _}from"./chunk-CGA5RXO6.js";import{c as z}from"./chunk-O32GJOUJ.js";import{j as F}from"./chunk-5KPIYVCC.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as te}from"./chunk-QYADASLV.js";var ie={};te(ie,{PipelineGraph:()=>x,decisionKeyOf:()=>$,pipelineGraph:()=>q});function N(y,t){return z("orchestration",y,t)}var $=y=>y.action,x=class extends F{constructor(t,s){super(t,s)}task(t,s,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,s,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,s,e,a={}){let p=this._resolveStep(s),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,s,e={}){let a=Object.keys(s),p=a.map(d=>this._resolveStep(s[d])),c=D(p,d=>{let f={};for(let i=0;i<a.length;i++)f[a[i]]=d[i];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}gate(t,s,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("gate: maxPending must be >= 1");let p=e.startOpen??!1;typeof s!="string"&&this.nameOf(s)===void 0&&this.add(s,{name:`${t}/source`});let c=this._resolveStep(s),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),i=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),h=G(0,{name:"droppedCount"}),u=L({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(i,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(h,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,O=p,W=i.subscribe(n=>{for(let o of n)o[0]===P&&(O=o[1])});this.addDisposer(W);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function M(n){if(l.push(n),l.length>a){let o=l.shift();h.emit(h.cache+1),C("drop",[o])}A()}function w(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let T=r.terminalDeps[0];if(T!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(T===!0?[[I]]:[[K,T]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)O?o.emit(g):(M(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(i.emit(!0),O=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let T of r){if(T[0]!==P)continue;let m=!!T[1];if(m&&!O){if(e.onceOnly){if(k)continue;k=!0}E(()=>{i.emit(!0);let g=w(l.length);C("open",g);for(let oe of g){if(v)break;b.emit(oe)}})}else if(!m&&O){if(e.onceOnly&&k)continue;E(()=>{i.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`gate: ${n}() called after gate was torn down`)},U=(n=1)=>{V("approve");let o=w(n);for(let r of o){if(v)break;b.emit(r)}},Y=(n=1)=>{V("reject"),w(n)},H=(n,o=1)=>{V("modify");let r=[...l],T=w(o);for(let m=0;m<T.length&&!v;m++)b.emit(n(T[m],m,r))},J=()=>{V("open"),i.emit(!0);let n=w(l.length);for(let o of n){if(v)break;b.emit(o)}},Q=()=>{V("close"),!(e.onceOnly&&k)&&i.emit(!1)},X=_(U,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:i,droppedCount:h,decisions:u,audit:u,approve:X,reject:Z,modify:ee,open:ne,close:re}}approval(t,s,e,a={}){return this.gate(t,s,{...a,approver:e,maxPending:1})}catch(t,s,e,a={}){let p=this._resolveStep(s),c=a.on??"error",d=j([p],(f,i,R)=>{let h=R.terminalDeps[0];if(h!==void 0){let l=h===!0?{kind:"complete"}:{kind:"error",error:h};if(c==="terminal"||c===l.kind){i.emit(e(l,i));return}i.down(l.kind==="complete"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){i.down([[S]]);return}for(let l of u)i.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="complete"||c==="terminal"),errorWhenDepsError:!(c==="error"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function q(y,t){return new x(y,t)}export{$ as a,x as b,q as c,ie as d};
@@ -1 +1 @@
1
- import{t as A,x as v}from"./chunk-JJTF75VS.js";import{b as I}from"./chunk-TZQPPQEQ.js";import{m as p,s as y}from"./chunk-MQZWA3DF.js";import{E as R,G as w,m as h}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";function z(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function F(t,a,e){let r=p(t),i=r.v!=null,g=R(e?.initialVerified??null,{...i?{meta:{sourceVersion:null}}:{}}),x=e?.trigger!==void 0&&e.trigger!==null,s=null;if(x&&e?.autoVerify?s=A(p(e.trigger),r):x?s=p(e.trigger):e?.autoVerify&&(s=r),s!==null){let d;if(s===r)d=v(r,c=>a(c));else{let c=r.cache;r.subscribe(f=>{for(let M of f)M[0]===b&&(c=M[1])}),d=v(s,()=>a(c))}y(d,c=>{h(()=>{if(g.down([[b,c]]),i){let f=r.v;f!=null&&g.meta.sourceVersion.down([[b,{id:f.id,version:f.version}]])}})})}return{node:r,verified:g,trigger:s}}function E(t){t.subscribe(()=>{})}function k(t){return t instanceof Map?t:new Map}function B(t,a){if(!Array.isArray(a.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:r}of a.upsert)t.set(e,r);for(let e of a.remove??[])t.delete(e)})}function G(t,a,e){let r=p(t),i=I(e.mapOptions??{}),g=e.budget??2e3,s=e.context!==void 0&&e.context!==null?p(e.context):R(null),d=k(i.entries.cache);i.entries.subscribe(o=>{for(let u of o)u[0]===b&&(d=k(u[1]))});let c=v(r,o=>a(o,d));if(y(c,o=>{B(i,o)}),e.evict){let o=new Map,u=w([i.entries],([l])=>{let m=[],N=k(l);for(let n of o.keys())N.has(n)||(o.get(n)(),o.delete(n));for(let[n,T]of N){let V=e.evict(n,T);if(z(V)){if(!o.has(n)){let S=y(V,D=>{D===!0&&i.has(n)&&i.delete(n)});o.set(n,S)}continue}if(typeof V=="boolean"){V&&m.push(n);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});y(u,l=>{for(let m of l)i.delete(m)})}let f=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&f){let o=p(e.consolidateTrigger),u=v(o,()=>e.consolidate(d));y(u,l=>{B(i,l)})}let M=w([i.entries,s],([o,u])=>{let l=[...k(o).entries()].map(([n,T])=>({key:n,value:T,score:e.score(T,u),cost:e.cost(T)}));l.sort((n,T)=>T.score-n.score);let m=[],N=g;for(let n of l)n.cost<=N&&(m.push({key:n.key,value:n.value,score:n.score}),N-=n.cost);return m}),O=w([i.entries],([o])=>k(o).size);return E(M),E(O),{store:i,compact:M,size:O}}export{F as a,G as b};
1
+ import{b as I}from"./chunk-TZQPPQEQ.js";import{t as A,x as v}from"./chunk-JJTF75VS.js";import{m as p,s as y}from"./chunk-MQZWA3DF.js";import{E as R,G as w,m as h}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";function z(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function F(t,a,e){let r=p(t),i=r.v!=null,g=R(e?.initialVerified??null,{...i?{meta:{sourceVersion:null}}:{}}),x=e?.trigger!==void 0&&e.trigger!==null,s=null;if(x&&e?.autoVerify?s=A(p(e.trigger),r):x?s=p(e.trigger):e?.autoVerify&&(s=r),s!==null){let d;if(s===r)d=v(r,c=>a(c));else{let c=r.cache;r.subscribe(f=>{for(let M of f)M[0]===b&&(c=M[1])}),d=v(s,()=>a(c))}y(d,c=>{h(()=>{if(g.down([[b,c]]),i){let f=r.v;f!=null&&g.meta.sourceVersion.down([[b,{id:f.id,version:f.version}]])}})})}return{node:r,verified:g,trigger:s}}function E(t){t.subscribe(()=>{})}function k(t){return t instanceof Map?t:new Map}function B(t,a){if(!Array.isArray(a.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:r}of a.upsert)t.set(e,r);for(let e of a.remove??[])t.delete(e)})}function G(t,a,e){let r=p(t),i=I(e.mapOptions??{}),g=e.budget??2e3,s=e.context!==void 0&&e.context!==null?p(e.context):R(null),d=k(i.entries.cache);i.entries.subscribe(o=>{for(let u of o)u[0]===b&&(d=k(u[1]))});let c=v(r,o=>a(o,d));if(y(c,o=>{B(i,o)}),e.evict){let o=new Map,u=w([i.entries],([l])=>{let m=[],N=k(l);for(let n of o.keys())N.has(n)||(o.get(n)(),o.delete(n));for(let[n,T]of N){let V=e.evict(n,T);if(z(V)){if(!o.has(n)){let S=y(V,D=>{D===!0&&i.has(n)&&i.delete(n)});o.set(n,S)}continue}if(typeof V=="boolean"){V&&m.push(n);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});y(u,l=>{for(let m of l)i.delete(m)})}let f=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&f){let o=p(e.consolidateTrigger),u=v(o,()=>e.consolidate(d));y(u,l=>{B(i,l)})}let M=w([i.entries,s],([o,u])=>{let l=[...k(o).entries()].map(([n,T])=>({key:n,value:T,score:e.score(T,u),cost:e.cost(T)}));l.sort((n,T)=>T.score-n.score);let m=[],N=g;for(let n of l)n.cost<=N&&(m.push({key:n.key,value:n.value,score:n.score}),N-=n.cost);return m}),O=w([i.entries],([o])=>k(o).size);return E(M),E(O),{store:i,compact:M,size:O}}export{F as a,G as b};
@@ -1 +1 @@
1
- import{e as P}from"./chunk-PIIUJIF7.js";import{c as S}from"./chunk-O32GJOUJ.js";import{a as w}from"./chunk-T6RPUERH.js";import{j as O,l as R}from"./chunk-5KPIYVCC.js";import{b as _}from"./chunk-TZQPPQEQ.js";import{C as T}from"./chunk-MQZWA3DF.js";import{E as k,G as x,o as H}from"./chunk-LYCLF26R.js";import{b as M}from"./chunk-QYADASLV.js";var B={};M(B,{LensGraph:()=>C,graphLens:()=>N,watchTopologyTree:()=>w});function v(e){return S("lens",e)}function E(e){let t=Object.keys(e.nodes),o=new Map,n=new Map;for(let s of t){let a=e.nodes[s]?.deps??[];o.set(s,a);for(let h of a)n.has(h)||n.set(h,new Set),n.get(h).add(s)}let r=[],c=[];for(let s of t)(o.get(s)??[]).length===0&&r.push(s),n.has(s)||c.push(s);r.sort(),c.sort();let p=e.edges.length,f=0,m=1,g=2,d=new Map;for(let s of t)d.set(s,f);let y=!1,l=new Map,u=s=>{let a=d.get(s)??f;if(a===m)return y=!0,0;if(a===g)return l.get(s)??0;d.set(s,m);let h=0,b=n.get(s);if(b!=null)for(let F of b){let G=u(F);G+1>h&&(h=G+1)}return d.set(s,g),l.set(s,h),h},i=0;for(let s of r){let a=u(s);a>i&&(i=a)}for(let s of t)d.get(s)===f&&u(s);return{nodeCount:t.length,edgeCount:p,subgraphCount:e.subgraphs.length,sources:r,sinks:c,depth:i,hasCycles:y}}function $(e){let t=[];for(let[o,n]of Object.entries(e.nodes)){if(n.status!=="errored")continue;let r={path:o,status:"errored"},c=R(e,o,"upstream",{});for(let p of c)if(p!==o&&e.nodes[p]?.status==="errored"){r.upstreamCause=p;break}t.push(r)}return t.sort((o,n)=>o.path<n.path?-1:o.path>n.path?1:0),{ok:t.length===0,problems:t}}function q(e,t){return e.nodeCount===t.nodeCount&&e.edgeCount===t.edgeCount&&e.subgraphCount===t.subgraphCount&&e.depth===t.depth&&e.hasCycles===t.hasCycles&&D(e.sources,t.sources)&&D(e.sinks,t.sinks)}function L(e,t){if(e.ok!==t.ok||e.problems.length!==t.problems.length)return!1;for(let o=0;o<e.problems.length;o++){let n=e.problems[o],r=t.problems[o];if(n.path!==r.path||n.status!==r.status||n.upstreamCause!==r.upstreamCause)return!1}return!0}function D(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var C=class extends O{stats;health;flow;_target;constructor(t,o={}){super(o.name??`${t.name}_lens`,o.graph),this._target=t;let n=0,r=0,c=k(0,{name:"stats_tick"}),p=k(0,{name:"health_tick"});this.add(c,{name:"stats_tick"}),this.add(p,{name:"health_tick"});let f={name:"flow"};o.maxFlowPaths!=null&&(f.maxSize=o.maxFlowPaths),this.flow=_(f),this.add(this.flow.entries,{name:"flow"});let m=o.pathFilter,g=w(t,(l,u,i)=>{if(n+=1,c.emit(n),r+=1,p.emit(r),l.kind==="removed")if(l.nodeKind==="node"){let s=`${i}${l.name}`;this.flow.delete(s)}else{let s=`${i}${l.name}::`,a=[];for(let h of l.audit.nodes){let b=h===""?`${i}${l.name}`:`${s}${h}`;a.push(b)}a.length>0&&this.flow.deleteMany(a)}});this.addDisposer(g);let d=t.observe({timeline:!0,structured:!0}),y=d.onEvent(l=>{let u=l.type;if((u==="error"||u==="complete"||u==="data"||u==="teardown")&&(r+=1,p.emit(r)),u==="data"){let i=l.path??"";if(!i||m!=null&&!m(i))return;let s=this.flow.get(i),a=s!=null?s.count+1:1;this.flow.set(i,{path:i,count:a,lastUpdate_ns:H()})}});this.addDisposer(()=>{y(),d.dispose()}),this.stats=x([c],()=>E(t.describe({detail:"minimal"})),{name:"stats",describeKind:"derived",equals:q,meta:v("stats")}),this.add(this.stats,{name:"stats"}),this.addDisposer(T(this.stats)),this.health=x([p],()=>$(t.describe({detail:"standard"})),{name:"health",describeKind:"derived",equals:L,meta:v("health")}),this.add(this.health,{name:"health"}),this.addDisposer(T(this.health))}why(t,o,n){let r=P(this._target,t,o,n);return this.addDisposer(r.dispose),r}get target(){return this._target}};function N(e,t){return new C(e,t)}export{C as a,N as b,B as c};
1
+ import{e as P}from"./chunk-44QWWUA3.js";import{c as S}from"./chunk-O32GJOUJ.js";import{a as w}from"./chunk-T6RPUERH.js";import{b as _}from"./chunk-TZQPPQEQ.js";import{j as O,l as R}from"./chunk-5KPIYVCC.js";import{C as T}from"./chunk-MQZWA3DF.js";import{E as k,G as x,o as H}from"./chunk-LYCLF26R.js";import{b as M}from"./chunk-QYADASLV.js";var B={};M(B,{LensGraph:()=>C,graphLens:()=>N,watchTopologyTree:()=>w});function v(e){return S("lens",e)}function E(e){let t=Object.keys(e.nodes),o=new Map,n=new Map;for(let s of t){let a=e.nodes[s]?.deps??[];o.set(s,a);for(let h of a)n.has(h)||n.set(h,new Set),n.get(h).add(s)}let r=[],c=[];for(let s of t)(o.get(s)??[]).length===0&&r.push(s),n.has(s)||c.push(s);r.sort(),c.sort();let p=e.edges.length,f=0,m=1,g=2,d=new Map;for(let s of t)d.set(s,f);let y=!1,l=new Map,u=s=>{let a=d.get(s)??f;if(a===m)return y=!0,0;if(a===g)return l.get(s)??0;d.set(s,m);let h=0,b=n.get(s);if(b!=null)for(let F of b){let G=u(F);G+1>h&&(h=G+1)}return d.set(s,g),l.set(s,h),h},i=0;for(let s of r){let a=u(s);a>i&&(i=a)}for(let s of t)d.get(s)===f&&u(s);return{nodeCount:t.length,edgeCount:p,subgraphCount:e.subgraphs.length,sources:r,sinks:c,depth:i,hasCycles:y}}function $(e){let t=[];for(let[o,n]of Object.entries(e.nodes)){if(n.status!=="errored")continue;let r={path:o,status:"errored"},c=R(e,o,"upstream",{});for(let p of c)if(p!==o&&e.nodes[p]?.status==="errored"){r.upstreamCause=p;break}t.push(r)}return t.sort((o,n)=>o.path<n.path?-1:o.path>n.path?1:0),{ok:t.length===0,problems:t}}function q(e,t){return e.nodeCount===t.nodeCount&&e.edgeCount===t.edgeCount&&e.subgraphCount===t.subgraphCount&&e.depth===t.depth&&e.hasCycles===t.hasCycles&&D(e.sources,t.sources)&&D(e.sinks,t.sinks)}function L(e,t){if(e.ok!==t.ok||e.problems.length!==t.problems.length)return!1;for(let o=0;o<e.problems.length;o++){let n=e.problems[o],r=t.problems[o];if(n.path!==r.path||n.status!==r.status||n.upstreamCause!==r.upstreamCause)return!1}return!0}function D(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var C=class extends O{stats;health;flow;_target;constructor(t,o={}){super(o.name??`${t.name}_lens`,o.graph),this._target=t;let n=0,r=0,c=k(0,{name:"stats_tick"}),p=k(0,{name:"health_tick"});this.add(c,{name:"stats_tick"}),this.add(p,{name:"health_tick"});let f={name:"flow"};o.maxFlowPaths!=null&&(f.maxSize=o.maxFlowPaths),this.flow=_(f),this.add(this.flow.entries,{name:"flow"});let m=o.pathFilter,g=w(t,(l,u,i)=>{if(n+=1,c.emit(n),r+=1,p.emit(r),l.kind==="removed")if(l.nodeKind==="node"){let s=`${i}${l.name}`;this.flow.delete(s)}else{let s=`${i}${l.name}::`,a=[];for(let h of l.audit.nodes){let b=h===""?`${i}${l.name}`:`${s}${h}`;a.push(b)}a.length>0&&this.flow.deleteMany(a)}});this.addDisposer(g);let d=t.observe({timeline:!0,structured:!0}),y=d.onEvent(l=>{let u=l.type;if((u==="error"||u==="complete"||u==="data"||u==="teardown")&&(r+=1,p.emit(r)),u==="data"){let i=l.path??"";if(!i||m!=null&&!m(i))return;let s=this.flow.get(i),a=s!=null?s.count+1:1;this.flow.set(i,{path:i,count:a,lastUpdate_ns:H()})}});this.addDisposer(()=>{y(),d.dispose()}),this.stats=x([c],()=>E(t.describe({detail:"minimal"})),{name:"stats",describeKind:"derived",equals:q,meta:v("stats")}),this.add(this.stats,{name:"stats"}),this.addDisposer(T(this.stats)),this.health=x([p],()=>$(t.describe({detail:"standard"})),{name:"health",describeKind:"derived",equals:L,meta:v("health")}),this.add(this.health,{name:"health"}),this.addDisposer(T(this.health))}why(t,o,n){let r=P(this._target,t,o,n);return this.addDisposer(r.dispose),r}get target(){return this._target}};function N(e,t){return new C(e,t)}export{C as a,N as b,B as c};
@@ -1 +1 @@
1
- import{d as n}from"./chunk-PIIUJIF7.js";import{j as a}from"./chunk-5KPIYVCC.js";import{b as c}from"./chunk-QYADASLV.js";var s={};c(s,{GuardedExecutionGraph:()=>o,guardedExecution:()=>p});var o=class extends a{enforcer;violations;_target;_defaultActor;constructor(r,e){super(e.name??`${r.name}_guarded`,e.graph),this._target=r,this._defaultActor=e.actor;let t={mode:e.mode??"enforce",name:"enforcer"};e.violationsLimit!=null&&(t.violationsLimit=e.violationsLimit),this.enforcer=n(r,e.policies,t),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer)}scopedDescribe(r){let e=r?.actor??this._defaultActor,t={...r,...e!=null?{actor:e}:{}};return this._target.describe(t)}get target(){return this._target}};function p(i,r){return new o(i,r)}export{o as a,p as b,s as c};
1
+ import{d as n}from"./chunk-44QWWUA3.js";import{j as a}from"./chunk-5KPIYVCC.js";import{b as c}from"./chunk-QYADASLV.js";var s={};c(s,{GuardedExecutionGraph:()=>o,guardedExecution:()=>p});var o=class extends a{enforcer;violations;_target;_defaultActor;constructor(r,e){super(e.name??`${r.name}_guarded`,e.graph),this._target=r,this._defaultActor=e.actor;let t={mode:e.mode??"enforce",name:"enforcer"};e.violationsLimit!=null&&(t.violationsLimit=e.violationsLimit),this.enforcer=n(r,e.policies,t),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer)}scopedDescribe(r){let e=r?.actor??this._defaultActor,t={...r,...e!=null?{actor:e}:{}};return this._target.describe(t)}get target(){return this._target}};function p(i,r){return new o(i,r)}export{o as a,p as b,s as c};
@@ -1 +1 @@
1
- import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-2Y3DKIZL.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-6G5YD37E.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
1
+ import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-KCE6WWJE.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-6G5YD37E.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
@@ -1 +1 @@
1
- import{c as S}from"./chunk-O32GJOUJ.js";import{j as l}from"./chunk-5KPIYVCC.js";import{b as M}from"./chunk-RLMYS3XZ.js";import{C as o}from"./chunk-MQZWA3DF.js";import{D as P,E as v,G as _,m as N}from"./chunk-LYCLF26R.js";import{b as L,i as I}from"./chunk-CK2E7BTU.js";import{b as C}from"./chunk-QYADASLV.js";var U={};C(U,{MessagingHubGraph:()=>w,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>y,TopicGraph:()=>m,TopicRegistry:()=>O,messagingHub:()=>H,subscription:()=>D,topic:()=>z,topicBridge:()=>F});var R=256;function c(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function a(i,e){return S("messaging",i,e)}var B=1024,m=class extends l{_log;events;latest;hasLatest;constructor(e,s={}){super(e,s.graph),this._log=M([],{name:"events",maxSize:s.retainedLimit??B}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=_([this.events],([t])=>{let n=t;return n.length===0?null:n[n.length-1]},{name:"latest",describeKind:"derived",meta:a("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(o(this.latest)),this.hasLatest=_([this.events],([t])=>t.length>0,{name:"hasLatest",describeKind:"derived",meta:a("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(o(this.hasLatest)),this.addDisposer(()=>{this.events.down([[I]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._log.append(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},T=class extends l{cursor;available;topic;_disposed=!1;constructor(e,s,t={}){super(e,t.graph),this.topic=s;let n;if(t.from!==void 0?t.from==="retained"?n=0:t.from==="now"?n=s.events.cache.length:n=c(t.from,"subscription from"):n=c(t.cursor??0,"subscription cursor"),this.cursor=v(n,{name:"cursor",describeKind:"state",meta:a("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=s._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(o(this.available)),t.advanceOn!==void 0){let r=t.advanceOn,b=!1,d=P([r],()=>{if(!b){b=!0;return}if(this._disposed)return;let p=this.available.cache;if(p.length===0)return;let g=this.cursor.cache+p.length;this.cursor.emit(g)},{name:"advancePump",describeKind:"effect",meta:a("subscription_advance_pump")});this.add(d,{name:"advancePump"}),this.addDisposer(o(d))}}ack(e){if(this._disposed)return this.cursor.cache;let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription ack count"),n=Math.min(t,s.length);if(n<=0)return this.cursor.cache;let r=this.cursor.cache+n;return this.cursor.emit(r),r}pull(e){if(this._disposed)return[];let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pull limit");return s.slice(0,t)}pullAndAck(e){if(this._disposed)return{items:[],cursor:this.cursor.cache};let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pullAndAck limit"),n=s.slice(0,t);if(n.length===0)return{items:n,cursor:this.cursor.cache};let r=this.cursor.cache+n.length;return this.cursor.emit(r),{items:n,cursor:r}}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[I]]),this.destroy())}},y=class extends l{_sourceSub;bridgedCount;output;constructor(e,s,t,n={}){super(e,n.graph),this._sourceSub=D(`${e}-subscription`,s,{cursor:n.cursor}),this.mount("subscription",this._sourceSub);let r=Math.max(1,c(n.maxPerPump??R,"topic bridge maxPerPump")),b=n.map??(u=>u);this.output=_([this._sourceSub.available],([u])=>{let f=u,h=[],k=Math.min(f.length,r);for(let x=0;x<k;x++){let A=b(f[x]);A!==void 0&&h.push(A)}return h},{name:"output",describeKind:"derived",meta:a("topic_bridge_output",{targetRef:t.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(o(this.output)),this.bridgedCount=v(0,{name:"bridgedCount",describeKind:"state",meta:a("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(o(this.bridgedCount));let d=this.output,p=this._sourceSub,g=this.bridgedCount,G=P([d],()=>{let u=d.cache;if(u.length===0)return;let f=p.available.cache.length,h=Math.min(f,r);if(h>0){p.ack(h);let k=g.cache??0;g.emit(k+u.length)}},{name:"ackPump",describeKind:"effect",meta:a("topic_bridge_ack_pump")});this.add(G,{name:"ackPump"}),this.addDisposer(o(G));let E=K(this.output,t);this.addDisposer(E)}};function K(i,e){return i.subscribe(s=>{for(let t of s){if(t[0]!==L)continue;let n=t[1];n.length!==0&&N(()=>{for(let r of n)e.publish(r)})}})}var O=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,s){this._map.set(e,s)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},w=class extends l{_registry;version;_defaultTopicOptions;constructor(e,s={}){super(e,s.graph);let t=v(0,{name:"version",describeKind:"state",meta:a("hub_version")});this.add(t,{name:"version"}),this.version=t,this._registry=new O(t),this._defaultTopicOptions={...s.defaultTopicOptions??{}}}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,s){let t=this._registry.get(e);if(t===void 0){let n={...this._defaultTopicOptions,...s??{}};t=new m(e,n),this._registry.set(e,t),this.mount(e,t);let r=this.version.cache??0;this.version.emit(r+1)}return t}publish(e,s){this.topic(e).publish(s)}publishMany(e){N(()=>{for(let[s,t]of e)this.topic(s).publish(t)})}subscribe(e,s,t){let n=this.topic(s);return new T(e,n,t)}removeTopic(e){if(!this._registry.has(e))return!1;try{this.remove(e)}finally{this._registry.delete(e);let s=this.version.cache??0;this.version.emit(s+1)}return!0}};function z(i,e){return new m(i,e)}function H(i,e){return new w(i,e)}function D(i,e,s){return new T(i,e,s)}function F(i,e,s,t){return new y(i,e,s,t)}export{m as a,T as b,y as c,O as d,w as e,z as f,H as g,D as h,F as i,U as j};
1
+ import{c as S}from"./chunk-O32GJOUJ.js";import{b as M}from"./chunk-KUVDFOJH.js";import{j as l}from"./chunk-5KPIYVCC.js";import{C as o}from"./chunk-MQZWA3DF.js";import{D as P,E as v,G as _,m as N}from"./chunk-LYCLF26R.js";import{b as L,i as I}from"./chunk-CK2E7BTU.js";import{b as C}from"./chunk-QYADASLV.js";var U={};C(U,{MessagingHubGraph:()=>w,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>y,TopicGraph:()=>m,TopicRegistry:()=>O,messagingHub:()=>H,subscription:()=>D,topic:()=>z,topicBridge:()=>F});var R=256;function c(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function a(i,e){return S("messaging",i,e)}var B=1024,m=class extends l{_log;events;latest;hasLatest;constructor(e,s={}){super(e,s.graph),this._log=M([],{name:"events",maxSize:s.retainedLimit??B}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=_([this.events],([t])=>{let n=t;return n.length===0?null:n[n.length-1]},{name:"latest",describeKind:"derived",meta:a("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(o(this.latest)),this.hasLatest=_([this.events],([t])=>t.length>0,{name:"hasLatest",describeKind:"derived",meta:a("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(o(this.hasLatest)),this.addDisposer(()=>{this.events.down([[I]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._log.append(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},T=class extends l{cursor;available;topic;_disposed=!1;constructor(e,s,t={}){super(e,t.graph),this.topic=s;let n;if(t.from!==void 0?t.from==="retained"?n=0:t.from==="now"?n=s.events.cache.length:n=c(t.from,"subscription from"):n=c(t.cursor??0,"subscription cursor"),this.cursor=v(n,{name:"cursor",describeKind:"state",meta:a("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=s._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(o(this.available)),t.advanceOn!==void 0){let r=t.advanceOn,b=!1,d=P([r],()=>{if(!b){b=!0;return}if(this._disposed)return;let p=this.available.cache;if(p.length===0)return;let g=this.cursor.cache+p.length;this.cursor.emit(g)},{name:"advancePump",describeKind:"effect",meta:a("subscription_advance_pump")});this.add(d,{name:"advancePump"}),this.addDisposer(o(d))}}ack(e){if(this._disposed)return this.cursor.cache;let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription ack count"),n=Math.min(t,s.length);if(n<=0)return this.cursor.cache;let r=this.cursor.cache+n;return this.cursor.emit(r),r}pull(e){if(this._disposed)return[];let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pull limit");return s.slice(0,t)}pullAndAck(e){if(this._disposed)return{items:[],cursor:this.cursor.cache};let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pullAndAck limit"),n=s.slice(0,t);if(n.length===0)return{items:n,cursor:this.cursor.cache};let r=this.cursor.cache+n.length;return this.cursor.emit(r),{items:n,cursor:r}}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[I]]),this.destroy())}},y=class extends l{_sourceSub;bridgedCount;output;constructor(e,s,t,n={}){super(e,n.graph),this._sourceSub=D(`${e}-subscription`,s,{cursor:n.cursor}),this.mount("subscription",this._sourceSub);let r=Math.max(1,c(n.maxPerPump??R,"topic bridge maxPerPump")),b=n.map??(u=>u);this.output=_([this._sourceSub.available],([u])=>{let f=u,h=[],k=Math.min(f.length,r);for(let x=0;x<k;x++){let A=b(f[x]);A!==void 0&&h.push(A)}return h},{name:"output",describeKind:"derived",meta:a("topic_bridge_output",{targetRef:t.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(o(this.output)),this.bridgedCount=v(0,{name:"bridgedCount",describeKind:"state",meta:a("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(o(this.bridgedCount));let d=this.output,p=this._sourceSub,g=this.bridgedCount,G=P([d],()=>{let u=d.cache;if(u.length===0)return;let f=p.available.cache.length,h=Math.min(f,r);if(h>0){p.ack(h);let k=g.cache??0;g.emit(k+u.length)}},{name:"ackPump",describeKind:"effect",meta:a("topic_bridge_ack_pump")});this.add(G,{name:"ackPump"}),this.addDisposer(o(G));let E=K(this.output,t);this.addDisposer(E)}};function K(i,e){return i.subscribe(s=>{for(let t of s){if(t[0]!==L)continue;let n=t[1];n.length!==0&&N(()=>{for(let r of n)e.publish(r)})}})}var O=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,s){this._map.set(e,s)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},w=class extends l{_registry;version;_defaultTopicOptions;constructor(e,s={}){super(e,s.graph);let t=v(0,{name:"version",describeKind:"state",meta:a("hub_version")});this.add(t,{name:"version"}),this.version=t,this._registry=new O(t),this._defaultTopicOptions={...s.defaultTopicOptions??{}}}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,s){let t=this._registry.get(e);if(t===void 0){let n={...this._defaultTopicOptions,...s??{}};t=new m(e,n),this._registry.set(e,t),this.mount(e,t);let r=this.version.cache??0;this.version.emit(r+1)}return t}publish(e,s){this.topic(e).publish(s)}publishMany(e){N(()=>{for(let[s,t]of e)this.topic(s).publish(t)})}subscribe(e,s,t){let n=this.topic(s);return new T(e,n,t)}removeTopic(e){if(!this._registry.has(e))return!1;try{this.remove(e)}finally{this._registry.delete(e);let s=this.version.cache??0;this.version.emit(s+1)}return!0}};function z(i,e){return new m(i,e)}function H(i,e){return new w(i,e)}function D(i,e,s){return new T(i,e,s)}function F(i,e,s,t){return new y(i,e,s,t)}export{m as a,T as b,y as c,O as d,w as e,z as f,H as g,D as h,F as i,U as j};
@@ -1 +1 @@
1
- import{j as h}from"./chunk-5KPIYVCC.js";import{b as A}from"./chunk-RLMYS3XZ.js";import{E as p,m as b,p as y,t as T}from"./chunk-LYCLF26R.js";import{b as f,c as R}from"./chunk-CK2E7BTU.js";var L=T((e,r)=>{e("observe"),e("signal"),r("write")});function V(e){let r=A([],{name:e.name,maxSize:e.retainedLimit??1024,guard:e.guard??L,...e.versioning!=null?{versioning:e.versioning}:{}});return r.withLatest(),e.graph&&e.graph.add(r.entries,{name:e.name}),r}function x(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let r of Object.keys(e))x(e[r]);return Object.freeze(e)}function k(e){let n=(e.cache??0)+1;return e.down([[R],[f,n]]),n}function z(e,r){let n=r.freeze??!0;return function(...d){let o=n?d.map(x):d,s=y(),i,u,c=!1,m;try{b(()=>{r.seq&&(m=k(r.seq));try{if(i=e(...o),r.onSuccess){let t=r.onSuccess(o,i,{t_ns:s,seq:m});if(t!==void 0){let g=r.handlerVersion!=null?{...t,handlerVersion:r.handlerVersion}:t;r.audit.append(g)}}}catch(t){throw u=t,c=!0,t}})}catch(t){if(c&&r.onFailure){let g=u instanceof Error?u.name:typeof u,l=r.onFailure(o,u,{t_ns:s,seq:m,errorType:g});if(l!==void 0){let w=r.handlerVersion!=null?{...l,handlerVersion:r.handlerVersion}:l;r.audit.append(w)}}throw c?u:t}return i}}function S(e,r,n=0){let a=p(n,{name:r,describeKind:"state"});return e.add(a,{name:r}),a}function q(e,r,n,a=0){let d={},o=new h(r);for(let s of n){let i=p(a,{name:s,describeKind:"state"});o.add(i,{name:s}),d[s]=i}return e.mount(r,o),d}export{V as a,z as b,S as c,q as d};
1
+ import{b as A}from"./chunk-KUVDFOJH.js";import{j as h}from"./chunk-5KPIYVCC.js";import{E as p,m as b,p as y,t as T}from"./chunk-LYCLF26R.js";import{b as f,c as R}from"./chunk-CK2E7BTU.js";var L=T((e,r)=>{e("observe"),e("signal"),r("write")});function V(e){let r=A([],{name:e.name,maxSize:e.retainedLimit??1024,guard:e.guard??L,...e.versioning!=null?{versioning:e.versioning}:{}});return r.withLatest(),e.graph&&e.graph.add(r.entries,{name:e.name}),r}function x(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let r of Object.keys(e))x(e[r]);return Object.freeze(e)}function k(e){let n=(e.cache??0)+1;return e.down([[R],[f,n]]),n}function z(e,r){let n=r.freeze??!0;return function(...d){let o=n?d.map(x):d,s=y(),i,u,c=!1,m;try{b(()=>{r.seq&&(m=k(r.seq));try{if(i=e(...o),r.onSuccess){let t=r.onSuccess(o,i,{t_ns:s,seq:m});if(t!==void 0){let g=r.handlerVersion!=null?{...t,handlerVersion:r.handlerVersion}:t;r.audit.append(g)}}}catch(t){throw u=t,c=!0,t}})}catch(t){if(c&&r.onFailure){let g=u instanceof Error?u.name:typeof u,l=r.onFailure(o,u,{t_ns:s,seq:m,errorType:g});if(l!==void 0){let w=r.handlerVersion!=null?{...l,handlerVersion:r.handlerVersion}:l;r.audit.append(w)}}throw c?u:t}return i}}function S(e,r,n=0){let a=p(n,{name:r,describeKind:"state"});return e.add(a,{name:r}),a}function q(e,r,n,a=0){let d={},o=new h(r);for(let s of n){let i=p(a,{name:s,describeKind:"state"});o.add(i,{name:s}),d[s]=i}return e.mount(r,o),d}export{V as a,z as b,S as c,q as d};
@@ -1 +1 @@
1
- import{a as Qr,b as Xr}from"./chunk-6SVKZ7VI.js";import{$ as Hr,A as hr,B as vr,C as xr,D as Tr,E as wr,F as Er,G as Nr,H as Mr,I as Sr,J as Rr,K as Wr,L as Or,M as Br,N as Ir,O as Lr,P as jr,Q as Cr,R as Vr,S as Pr,T as Ar,U as zr,V as Kr,W as Dr,X as Ur,Y as _r,Z as $r,_ as Fr,a as rn,aa as qr,b as tn,ba as nt,c as Jn,d as Qn,e as Xn,f as Yn,g as Zn,h as er,i as nr,j as rr,k as tr,l as or,m as sr,n as ir,o as ar,p as cr,q as dr,r as fr,s as ur,t as pr,u as lr,v as mr,w as gr,x as br,y as yr,z as kr}from"./chunk-MYFR67PY.js";import{a as Z,b as ee,c as ne,d as re,e as te,f as oe,g as se,h as ie,i as ae,j as ce,k as de}from"./chunk-A5HZZYRK.js";import{b as Yr,c as Zr,d as et,e as it,f as at}from"./chunk-Q7EUZ6NN.js";import{a as xt}from"./chunk-JUJEPZOI.js";import{a as ge,b as Ye}from"./chunk-5QDBSZBV.js";import{a as Y}from"./chunk-ESMPEKEV.js";import{a as ft,b as ut,c as pt,d as lt,e as mt,f as gt,g as bt,h as yt,i as kt,j as ht,k as vt}from"./chunk-D5RFJOZ2.js";import{a as ct,b as dt}from"./chunk-CE72X3WO.js";import{A as Sn,B as Rn,C as Wn,D as On,E as Bn,F as In,G as Ln,I as jn,J as Cn,K as Vn,L as Pn,M as An,N as zn,O as Kn,P as Dn,Q as Un,R as _n,S as $n,T as Fn,U as Hn,V as qn,W as Gn,a as U,b as J,c as on,d as sn,e as an,f as cn,g as dn,h as fn,i as Q,j as un,k as pn,l as ln,m as mn,n as gn,o as bn,p as yn,q as kn,r as hn,s as vn,t as X,u as xn,v as Tn,w as wn,x as En,y as Nn,z as Mn}from"./chunk-JJTF75VS.js";import{c as ke,d as he,e as ve,f as xe,g as Te,h as we,i as Ee}from"./chunk-4VVTGLXJ.js";import{a as rt,b as tt}from"./chunk-NNKJUORL.js";import{a as ot,b as st}from"./chunk-KGKJCHEK.js";import{a as Gr,b as Jr}from"./chunk-TZQPPQEQ.js";import{a as Ze,b as en,c as nn}from"./chunk-RLMYS3XZ.js";import{A as Ge,B as Je,C as Qe,D as Xe,a as be,b as ye,c as Ne,d as Me,e as Se,f as G,g as Re,h as We,i as Oe,j as Be,k as Ie,l as Le,m as je,n as Ce,o as Ve,p as Pe,q as Ae,r as ze,s as Ke,t as De,u as Ue,v as _e,w as $e,x as Fe,y as He,z as qe}from"./chunk-MQZWA3DF.js";import{A as K,D as j,E as O,H as D,m as B}from"./chunk-LYCLF26R.js";import{b as h,e as $,f as F,g as H,h as S,i as q,j as W}from"./chunk-CK2E7BTU.js";import{b as me}from"./chunk-QYADASLV.js";var Rt={};me(Rt,{CircuitOpenError:()=>ee,ContentAddressedMissError:()=>Yr,NS_PER_MS:()=>NS_PER_MS,NS_PER_SEC:()=>NS_PER_SEC,NativeIndexBackend:()=>rt,NativeListBackend:()=>ot,NativeLogBackend:()=>Ze,NativeMapBackend:()=>Gr,NativePubSubBackend:()=>_,RateLimiterOverflowError:()=>oe,ResettableTimer:()=>Y,TimeoutError:()=>ae,appendLogStorage:()=>mt,audit:()=>Ln,awaitSettled:()=>qe,buffer:()=>jn,bufferCount:()=>Cn,bufferTime:()=>Pn,cached:()=>$e,canonicalJson:()=>Zr,cascadingCache:()=>Tt,catchError:()=>Gn,checkpointToRedis:()=>Dr,checkpointToS3:()=>Kr,circuitBreaker:()=>ne,combine:()=>hn,combineLatest:()=>Fn,concat:()=>Tn,concatMap:()=>Mn,constant:()=>ke,contentAddressedStorage:()=>et,createTransport:()=>L,createWatermarkController:()=>Ye,csvRows:()=>Tr,debounce:()=>On,debounceTime:()=>Hn,decorrelatedJitter:()=>Te,defer:()=>ze,delay:()=>Wn,deserializeError:()=>A,dictKv:()=>ht,dictSnapshot:()=>vt,distill:()=>Xr,distinctUntilChanged:()=>yn,elementAt:()=>ln,empty:()=>Ve,escapeRegexChar:()=>Ne,exhaustMap:()=>Nn,exponential:()=>ve,externalBundle:()=>tn,externalProducer:()=>rn,fallback:()=>ce,fibonacci:()=>xe,filter:()=>J,find:()=>pn,first:()=>Q,firstValueFrom:()=>Fe,firstWhere:()=>He,flatMap:()=>Rn,forEach:()=>Ke,fromAny:()=>je,fromAsyncIter:()=>Le,fromCSV:()=>xr,fromClickHouseWatch:()=>Nr,fromCron:()=>We,fromDrizzle:()=>Hr,fromEvent:()=>Oe,fromHTTP:()=>Yn,fromHTTPPoll:()=>ir,fromHTTPStream:()=>sr,fromIter:()=>Be,fromKafka:()=>yr,fromKysely:()=>qr,fromMCP:()=>dr,fromNATS:()=>Rr,fromNDJSON:()=>Er,fromOTel:()=>fr,fromPrisma:()=>Fr,fromPrometheus:()=>gr,fromPromise:()=>Ie,fromPulsar:()=>Mr,fromRabbitMQ:()=>Or,fromRaf:()=>Re,fromRedisStream:()=>hr,fromSSE:()=>or,fromSqlite:()=>Ur,fromSqliteCursor:()=>_r,fromStatsD:()=>lr,fromSyslog:()=>ur,fromTimer:()=>G,fromWebSocket:()=>Qn,fromWebSocketReconnect:()=>cr,fromWebhook:()=>Xn,globToRegExp:()=>Me,interval:()=>Kn,jsonCodec:()=>ft,jsonCodecFor:()=>ut,keepalive:()=>Qe,kvStorage:()=>gt,last:()=>un,linear:()=>he,lru:()=>fe,makeHttpError:()=>nt,map:()=>U,matchesAnyPattern:()=>Se,matchesCron:()=>ye,memoryAppendLog:()=>yt,memoryBackend:()=>pt,memoryKv:()=>kt,memorySnapshot:()=>bt,merge:()=>X,mergeMap:()=>Sn,mergeReactiveLogs:()=>nn,nameToSignal:()=>V,ndjsonRows:()=>wr,never:()=>Pe,nodeSignal:()=>Ge,of:()=>Ce,onFirstData:()=>gn,pairwise:()=>kn,parseCron:()=>be,parsePrometheusText:()=>br,parseSSEStream:()=>tr,parseStatsD:()=>mr,parseSyslog:()=>pr,pausable:()=>Un,pubsub:()=>wt,race:()=>wn,rateLimiter:()=>se,reactiveCounter:()=>Xe,reactiveIndex:()=>tt,reactiveList:()=>st,reactiveLog:()=>en,reactiveMap:()=>Jr,reactiveSink:()=>Jn,reduce:()=>sn,repeat:()=>Dn,replay:()=>_e,rescue:()=>_n,resolveBackoffPreset:()=>Ee,retry:()=>Z,sample:()=>In,scan:()=>on,serializeError:()=>P,share:()=>Ue,shareReplay:()=>Je,signalToName:()=>I,singleFromAny:()=>it,singleNodeFromAny:()=>at,skip:()=>cn,snapshotStorage:()=>lt,sortJsonValue:()=>ct,stableJsonString:()=>dt,stratify:()=>xt,switchMap:()=>En,take:()=>an,takeUntil:()=>fn,takeWhile:()=>dn,tap:()=>mn,tapFirst:()=>bn,throttle:()=>Bn,throttleTime:()=>qn,throwError:()=>Ae,timeout:()=>de,toArray:()=>De,toCSV:()=>Lr,toClickHouse:()=>jr,toFile:()=>Ir,toHTTP:()=>Zn,toKafka:()=>kr,toLoki:()=>Ar,toMongo:()=>Pr,toNATS:()=>Wr,toObservable:()=>ge,toPostgres:()=>Vr,toPulsar:()=>Sr,toRabbitMQ:()=>Br,toReadableStream:()=>rr,toRedisStream:()=>vr,toS3:()=>Cr,toSSE:()=>er,toSSEBytes:()=>nr,toSqlite:()=>$r,toTempo:()=>zr,toWebSocket:()=>ar,tokenBucket:()=>te,valve:()=>$n,verifiable:()=>Qr,window:()=>zn,windowCount:()=>Vn,windowTime:()=>An,withBreaker:()=>re,withLatestFrom:()=>vn,withMaxAttempts:()=>we,withStatus:()=>ie,workerBridge:()=>pe,workerSelf:()=>le,zip:()=>xn});function fe(){let e=new Map,t=null,n=null;function p(r){r.prev?r.prev.next=r.next:t=r.next,r.next?r.next.prev=r.prev:n=r.prev,r.prev=null,r.next=null}function l(r){r.next=t,r.prev=null,t&&(t.prev=r),t=r,n===null&&(n=r)}return{insert(r){if(e.has(r)){this.touch(r);return}let f={key:r,prev:null,next:null};e.set(r,f),l(f)},touch(r){let f=e.get(r);f&&(p(f),l(f))},delete(r){let f=e.get(r);f&&(p(f),e.delete(r))},evict(r){let f=[];for(let v=0;v<r&&n!==null;v++){let N=n;f.push(N.key),p(N),e.delete(N.key)}return f},size(){return e.size}}}function ue(e){return e!=null&&typeof e.then=="function"}function C(e){ue(e)&&e.catch(()=>{})}function Tt(e,t){let n=new Map,p=t?.maxSize??0,l=p>0?t?.eviction??fe():null,r=t?.writeThrough??!1;function f(o,u,m){for(let g=0;g<m;g++)try{C(e[g].save(o,u))}catch{}}function v(o,u,m=0){for(let g=m;g<e.length;g++){let w;try{w=e[g].load(o)}catch{continue}if(ue(w)){let T=g;w.then(M=>{M!==void 0?(u.down([[h,M]]),f(o,M,T)):v(o,u,T+1)},()=>{v(o,u,T+1)});return}if(w!==void 0){u.down([[h,w]]),f(o,w,g);return}}}function N(){if(!(!l||p<=0))for(;l.size()>=p;){let o=l.evict(1);if(o.length===0)break;for(let u of o){let m=n.get(u);if(m){let g=m.cache;if(m.status!=="sentinel"&&e.length>0){let w=e.length-1;try{C(e[w].save(u,g))}catch{}for(let T=0;T<w;T++)try{let M=e[T].delete;M&&C(M.call(e[T],u))}catch{}}m.down([[S]])}n.delete(u)}}}return{load(o){let u=n.get(o);if(u)return l?.touch(o),u;l&&p>0&&l.size()>=p&&N();let m=O(void 0);return n.set(o,m),l?.insert(o),v(o,m),m},save(o,u){if(r)for(let g of e)try{C(g.save(o,u))}catch{}else if(e[0])try{C(e[0].save(o,u))}catch{}let m=n.get(o);if(m)m.down([[h,u]]),l?.touch(o);else{l&&p>0&&l.size()>=p&&N();let g=O(u);n.set(o,g),l?.insert(o)}},invalidate(o){let u=n.get(o);u&&v(o,u)},delete(o){l?.delete(o);let u=n.get(o);u&&u.down([[S]]),n.delete(o);for(let m of e)try{let g=m.delete;g&&C(g.call(m,o))}catch{}},has(o){return n.has(o)},get size(){return n.size}}}var _=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(t){return this._topics.has(t)}topicNames(){return this._topics.values()}createTopic(t){return this._topics.has(t)?!1:(this._topics.add(t),this._version+=1,!0)}removeTopic(t){let n=this._topics.delete(t);return n&&(this._version+=1),n}};function wt(e={}){let{backend:t}=e,n=t??new _,p=new Map;function l(r){let f=p.get(r);return f===void 0&&(f=j({describeKind:"state"}),p.set(r,f),n.createTopic(r)),f}return{topic(r){return l(r)},publish(r,f){l(r).emit(f)},publishMany(r){B(()=>{for(let[f,v]of r)l(f).emit(v)})},removeTopic(r){let f=p.get(r);return f===void 0?!1:(p.delete(r),n.removeTopic(r),f.down([[S]]),!0)},has(r){return n.hasTopic(r)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}var Et=new Map([[$,"INVALIDATE"],[F,"PAUSE"],[H,"RESUME"],[S,"TEARDOWN"],[q,"COMPLETE"],[W,"ERROR"]]),Nt=new Map([["INVALIDATE",$],["PAUSE",F],["RESUME",H],["TEARDOWN",S],["COMPLETE",q],["ERROR",W]]);function I(e){let t=Et.get(e);return t||(Symbol.keyFor(e)??"UNKNOWN")}function V(e){let t=Nt.get(e);if(t)return t;if(e&&e!=="UNKNOWN")return Symbol.for(e)}function P(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e),name:"Error"}}function A(e){let t=new Error(e.message);return t.name=e.name,e.stack&&(t.stack=e.stack),t}function L(e){if(typeof MessagePort<"u"&&e instanceof MessagePort)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=p=>t(p.data);return e.addEventListener("message",n),e.start(),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof SharedWorker<"u"&&e instanceof SharedWorker)return L(e.port);if(typeof Worker<"u"&&e instanceof Worker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=p=>t(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.terminate()}};if(typeof BroadcastChannel<"u"&&e instanceof BroadcastChannel)return{post(t,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),e.postMessage(t)},listen(t){let n=p=>t(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof ServiceWorker<"u"&&e instanceof ServiceWorker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=p=>{p.source===e&&t(p.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function Mt(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function pe(e,t){let n=Mt(e)?e:L(e),p=t.name??"workerBridge",l=Object.entries(t.expose??{}),r=t.import??[],f=t.transfer??{},v=O("connecting",{name:`${p}::meta::status`}),N=O(null,{name:`${p}::meta::error`}),o=new Map,u=new Map;for(let c of r){let a=O(void 0,{name:`${p}::${c}`});o.set(c,a)}let m;if(l.length>0){let c=l.map(([,d])=>d),a=j(c,(d,i)=>{let k={};for(let y=0;y<l.length;y++){let[R]=l[y],E=d[y];E!=null&&E.length>0&&(k[R]=E.at(-1))}Object.keys(k).length!==0&&i.emit(k)},{name:`${p}::aggregated`,partial:!0});m=D([a],d=>{let i=d[0];if(i==null||Object.keys(i).length===0)return;let k=[];for(let E of Object.keys(i)){let z=f[E];z&&k.push(...z(i[E]))}let y;for(let[E,z]of l)E in i&&z.v!=null&&(y==null&&(y={}),y[E]=z.v.version);let R={t:"b",u:i,...y?{v:y}:{}};try{n.post(R,k.length>0?k:void 0)}catch(E){N.down([[h,E instanceof Error?E:new Error(String(E))]])}}).subscribe(()=>{})}let g=!1,w=n.listen(c=>{if(g)return;let a=c;switch(a.t){case"r":{B(()=>{for(let[d,i]of Object.entries(a.stores)){let k=o.get(d);k&&k.down([[h,i]])}}),v.down([[h,"connected"]]);let s={};for(let[d,i]of l)s[d]=i.cache;n.post({t:"i",stores:s});break}case"v":{let s=o.get(a.s);s&&s.down([[h,a.d]]);break}case"b":{B(()=>{for(let[s,d]of Object.entries(a.u)){let i=a.v?.[s];if(i!=null){let y=u.get(s);if(y!=null&&i<=y)continue;u.set(s,i)}let k=o.get(s);k&&k.down([[h,d]])}});break}case"e":{let s=o.get(a.s);s&&s.down([[W,A(a.err)]]);break}case"s":{let s=V(a.sig);if(!s)break;let d=a.s==="*"?[...o.values()]:o.has(a.s)?[o.get(a.s)]:[];for(let i of d)i.down(a.d===void 0?[[s]]:[[s,a.d]]);break}}}),T=[];for(let[c,a]of l){let s=a.subscribe((d=>{if(!g)for(let i of d){let k=i[0];k!==h&&(K.isLocalOnly(k)||(k===W?n.post({t:"e",s:c,err:P(i[1])}):n.post({t:"s",s:c,sig:I(k),d:i.length>1?i[1]:void 0})))}}));T.push(s)}let M;if(t.timeoutMs!=null&&t.timeoutMs>0){let c=G(t.timeoutMs),a=J(v,d=>d==="connected");M=Q(X(U(c,()=>"timeout"),U(a,()=>"ready"))).subscribe(d=>{for(let i of d)i[0]===h&&i[1]==="timeout"&&(N.down([[h,new Error("Worker bridge handshake timeout")]]),x())})}function x(){if(!g){g=!0,M?.(),n.post({t:"s",s:"*",sig:I(S)}),m&&m();for(let c of T)c();T.length=0,w(),v.down([[h,"closed"]]),u.clear(),o.clear()}}let b={meta:{status:v,error:N},destroy:x};for(let[c,a]of o)b[c]=a;return b}function St(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function le(e,t){let n=St(e)?e:L(e),p=t.import??[],l=t.transfer??{},r=new Map,f=new Map,v={};for(let x of p){let b=O(void 0,{name:`worker::${x}`});r.set(x,b),v[x]=b}let N=t.expose(v),o=Object.entries(N),u,m=!1;if(o.length>0){let x=o.map(([,a])=>a),b=j(x,(a,s)=>{let d={};for(let i=0;i<o.length;i++){let[k]=o[i],y=a[i];y!=null&&y.length>0&&(d[k]=y.at(-1))}Object.keys(d).length!==0&&s.emit(d)},{name:"workerSelf::aggregated",partial:!0});u=D([b],a=>{if(m)return;let s=a[0];if(s==null||Object.keys(s).length===0)return;let d=[];for(let y of Object.keys(s)){let R=l[y];R&&d.push(...R(s[y]))}let i;for(let[y,R]of o)y in s&&R.v!=null&&(i==null&&(i={}),i[y]=R.v.version);let k={t:"b",u:s,...i?{v:i}:{}};try{n.post(k,d.length>0?d:void 0)}catch{}}).subscribe(()=>{})}let g=[];for(let[x,b]of o){let c=b.subscribe((a=>{if(!m)for(let s of a){let d=s[0];d!==h&&(K.isLocalOnly(d)||(d===W?n.post({t:"e",s:x,err:P(s[1])}):n.post({t:"s",s:x,sig:I(d),d:s.length>1?s[1]:void 0})))}}));g.push(c)}let w=n.listen(x=>{if(m)return;let b=x;switch(b.t){case"i":{B(()=>{for(let[c,a]of Object.entries(b.stores)){let s=r.get(c);s&&s.down([[h,a]])}});break}case"v":{let c=r.get(b.s);c&&c.down([[h,b.d]]);break}case"b":{B(()=>{for(let[c,a]of Object.entries(b.u)){let s=b.v?.[c];if(s!=null){let i=f.get(c);if(i!=null&&s<=i)continue;f.set(c,s)}let d=r.get(c);d&&d.down([[h,a]])}});break}case"e":{let c=r.get(b.s);c&&c.down([[W,A(b.err)]]);break}case"s":{let c=V(b.sig);if(!c)break;if(c===S&&b.s==="*"){M();return}let a=b.s==="*"?[...r.values()]:r.has(b.s)?[r.get(b.s)]:[];for(let s of a)s.down(b.d===void 0?[[c]]:[[c,b.d]]);break}}}),T={};for(let[x,b]of o)T[x]=b.cache;n.post({t:"r",stores:T});function M(){if(!m){m=!0,u&&u();for(let x of g)x();g.length=0,w(),n.terminate?.(),f.clear(),r.clear()}}return{destroy:M}}export{fe as a,Tt as b,_ as c,wt as d,I as e,V as f,P as g,A as h,L as i,pe as j,le as k,Rt as l};
1
+ import{a as Qr,b as Xr}from"./chunk-5RTZ6DXG.js";import{$ as Hr,A as hr,B as vr,C as xr,D as Tr,E as wr,F as Er,G as Nr,H as Mr,I as Sr,J as Rr,K as Wr,L as Or,M as Br,N as Ir,O as Lr,P as jr,Q as Cr,R as Vr,S as Pr,T as Ar,U as zr,V as Kr,W as Dr,X as Ur,Y as _r,Z as $r,_ as Fr,a as rn,aa as qr,b as tn,ba as nt,c as Jn,d as Qn,e as Xn,f as Yn,g as Zn,h as er,i as nr,j as rr,k as tr,l as or,m as sr,n as ir,o as ar,p as cr,q as dr,r as fr,s as ur,t as pr,u as lr,v as mr,w as gr,x as br,y as yr,z as kr}from"./chunk-MYFR67PY.js";import{a as Z,b as ee,c as ne,d as re,e as te,f as oe,g as se,h as ie,i as ae,j as ce,k as de}from"./chunk-A5HZZYRK.js";import{b as Yr,c as Zr,d as et,e as it,f as at}from"./chunk-Q7EUZ6NN.js";import{a as xt}from"./chunk-JUJEPZOI.js";import{a as rt,b as tt}from"./chunk-NNKJUORL.js";import{a as ot,b as st}from"./chunk-KGKJCHEK.js";import{a as Gr,b as Jr}from"./chunk-TZQPPQEQ.js";import{a as ge,b as Ye}from"./chunk-5QDBSZBV.js";import{a as Ze,b as en,c as nn}from"./chunk-KUVDFOJH.js";import{a as Y}from"./chunk-ESMPEKEV.js";import{a as ft,b as ut,c as pt,d as lt,e as mt,f as gt,g as bt,h as yt,i as kt,j as ht,k as vt}from"./chunk-D5RFJOZ2.js";import{a as ct,b as dt}from"./chunk-CE72X3WO.js";import{A as Sn,B as Rn,C as Wn,D as On,E as Bn,F as In,G as Ln,I as jn,J as Cn,K as Vn,L as Pn,M as An,N as zn,O as Kn,P as Dn,Q as Un,R as _n,S as $n,T as Fn,U as Hn,V as qn,W as Gn,a as U,b as J,c as on,d as sn,e as an,f as cn,g as dn,h as fn,i as Q,j as un,k as pn,l as ln,m as mn,n as gn,o as bn,p as yn,q as kn,r as hn,s as vn,t as X,u as xn,v as Tn,w as wn,x as En,y as Nn,z as Mn}from"./chunk-JJTF75VS.js";import{c as ke,d as he,e as ve,f as xe,g as Te,h as we,i as Ee}from"./chunk-4VVTGLXJ.js";import{A as Ge,B as Je,C as Qe,D as Xe,a as be,b as ye,c as Ne,d as Me,e as Se,f as G,g as Re,h as We,i as Oe,j as Be,k as Ie,l as Le,m as je,n as Ce,o as Ve,p as Pe,q as Ae,r as ze,s as Ke,t as De,u as Ue,v as _e,w as $e,x as Fe,y as He,z as qe}from"./chunk-MQZWA3DF.js";import{A as K,D as j,E as O,H as D,m as B}from"./chunk-LYCLF26R.js";import{b as h,e as $,f as F,g as H,h as S,i as q,j as W}from"./chunk-CK2E7BTU.js";import{b as me}from"./chunk-QYADASLV.js";var Rt={};me(Rt,{CircuitOpenError:()=>ee,ContentAddressedMissError:()=>Yr,NS_PER_MS:()=>NS_PER_MS,NS_PER_SEC:()=>NS_PER_SEC,NativeIndexBackend:()=>rt,NativeListBackend:()=>ot,NativeLogBackend:()=>Ze,NativeMapBackend:()=>Gr,NativePubSubBackend:()=>_,RateLimiterOverflowError:()=>oe,ResettableTimer:()=>Y,TimeoutError:()=>ae,appendLogStorage:()=>mt,audit:()=>Ln,awaitSettled:()=>qe,buffer:()=>jn,bufferCount:()=>Cn,bufferTime:()=>Pn,cached:()=>$e,canonicalJson:()=>Zr,cascadingCache:()=>Tt,catchError:()=>Gn,checkpointToRedis:()=>Dr,checkpointToS3:()=>Kr,circuitBreaker:()=>ne,combine:()=>hn,combineLatest:()=>Fn,concat:()=>Tn,concatMap:()=>Mn,constant:()=>ke,contentAddressedStorage:()=>et,createTransport:()=>L,createWatermarkController:()=>Ye,csvRows:()=>Tr,debounce:()=>On,debounceTime:()=>Hn,decorrelatedJitter:()=>Te,defer:()=>ze,delay:()=>Wn,deserializeError:()=>A,dictKv:()=>ht,dictSnapshot:()=>vt,distill:()=>Xr,distinctUntilChanged:()=>yn,elementAt:()=>ln,empty:()=>Ve,escapeRegexChar:()=>Ne,exhaustMap:()=>Nn,exponential:()=>ve,externalBundle:()=>tn,externalProducer:()=>rn,fallback:()=>ce,fibonacci:()=>xe,filter:()=>J,find:()=>pn,first:()=>Q,firstValueFrom:()=>Fe,firstWhere:()=>He,flatMap:()=>Rn,forEach:()=>Ke,fromAny:()=>je,fromAsyncIter:()=>Le,fromCSV:()=>xr,fromClickHouseWatch:()=>Nr,fromCron:()=>We,fromDrizzle:()=>Hr,fromEvent:()=>Oe,fromHTTP:()=>Yn,fromHTTPPoll:()=>ir,fromHTTPStream:()=>sr,fromIter:()=>Be,fromKafka:()=>yr,fromKysely:()=>qr,fromMCP:()=>dr,fromNATS:()=>Rr,fromNDJSON:()=>Er,fromOTel:()=>fr,fromPrisma:()=>Fr,fromPrometheus:()=>gr,fromPromise:()=>Ie,fromPulsar:()=>Mr,fromRabbitMQ:()=>Or,fromRaf:()=>Re,fromRedisStream:()=>hr,fromSSE:()=>or,fromSqlite:()=>Ur,fromSqliteCursor:()=>_r,fromStatsD:()=>lr,fromSyslog:()=>ur,fromTimer:()=>G,fromWebSocket:()=>Qn,fromWebSocketReconnect:()=>cr,fromWebhook:()=>Xn,globToRegExp:()=>Me,interval:()=>Kn,jsonCodec:()=>ft,jsonCodecFor:()=>ut,keepalive:()=>Qe,kvStorage:()=>gt,last:()=>un,linear:()=>he,lru:()=>fe,makeHttpError:()=>nt,map:()=>U,matchesAnyPattern:()=>Se,matchesCron:()=>ye,memoryAppendLog:()=>yt,memoryBackend:()=>pt,memoryKv:()=>kt,memorySnapshot:()=>bt,merge:()=>X,mergeMap:()=>Sn,mergeReactiveLogs:()=>nn,nameToSignal:()=>V,ndjsonRows:()=>wr,never:()=>Pe,nodeSignal:()=>Ge,of:()=>Ce,onFirstData:()=>gn,pairwise:()=>kn,parseCron:()=>be,parsePrometheusText:()=>br,parseSSEStream:()=>tr,parseStatsD:()=>mr,parseSyslog:()=>pr,pausable:()=>Un,pubsub:()=>wt,race:()=>wn,rateLimiter:()=>se,reactiveCounter:()=>Xe,reactiveIndex:()=>tt,reactiveList:()=>st,reactiveLog:()=>en,reactiveMap:()=>Jr,reactiveSink:()=>Jn,reduce:()=>sn,repeat:()=>Dn,replay:()=>_e,rescue:()=>_n,resolveBackoffPreset:()=>Ee,retry:()=>Z,sample:()=>In,scan:()=>on,serializeError:()=>P,share:()=>Ue,shareReplay:()=>Je,signalToName:()=>I,singleFromAny:()=>it,singleNodeFromAny:()=>at,skip:()=>cn,snapshotStorage:()=>lt,sortJsonValue:()=>ct,stableJsonString:()=>dt,stratify:()=>xt,switchMap:()=>En,take:()=>an,takeUntil:()=>fn,takeWhile:()=>dn,tap:()=>mn,tapFirst:()=>bn,throttle:()=>Bn,throttleTime:()=>qn,throwError:()=>Ae,timeout:()=>de,toArray:()=>De,toCSV:()=>Lr,toClickHouse:()=>jr,toFile:()=>Ir,toHTTP:()=>Zn,toKafka:()=>kr,toLoki:()=>Ar,toMongo:()=>Pr,toNATS:()=>Wr,toObservable:()=>ge,toPostgres:()=>Vr,toPulsar:()=>Sr,toRabbitMQ:()=>Br,toReadableStream:()=>rr,toRedisStream:()=>vr,toS3:()=>Cr,toSSE:()=>er,toSSEBytes:()=>nr,toSqlite:()=>$r,toTempo:()=>zr,toWebSocket:()=>ar,tokenBucket:()=>te,valve:()=>$n,verifiable:()=>Qr,window:()=>zn,windowCount:()=>Vn,windowTime:()=>An,withBreaker:()=>re,withLatestFrom:()=>vn,withMaxAttempts:()=>we,withStatus:()=>ie,workerBridge:()=>pe,workerSelf:()=>le,zip:()=>xn});function fe(){let e=new Map,t=null,n=null;function p(r){r.prev?r.prev.next=r.next:t=r.next,r.next?r.next.prev=r.prev:n=r.prev,r.prev=null,r.next=null}function l(r){r.next=t,r.prev=null,t&&(t.prev=r),t=r,n===null&&(n=r)}return{insert(r){if(e.has(r)){this.touch(r);return}let f={key:r,prev:null,next:null};e.set(r,f),l(f)},touch(r){let f=e.get(r);f&&(p(f),l(f))},delete(r){let f=e.get(r);f&&(p(f),e.delete(r))},evict(r){let f=[];for(let v=0;v<r&&n!==null;v++){let N=n;f.push(N.key),p(N),e.delete(N.key)}return f},size(){return e.size}}}function ue(e){return e!=null&&typeof e.then=="function"}function C(e){ue(e)&&e.catch(()=>{})}function Tt(e,t){let n=new Map,p=t?.maxSize??0,l=p>0?t?.eviction??fe():null,r=t?.writeThrough??!1;function f(o,u,m){for(let g=0;g<m;g++)try{C(e[g].save(o,u))}catch{}}function v(o,u,m=0){for(let g=m;g<e.length;g++){let w;try{w=e[g].load(o)}catch{continue}if(ue(w)){let T=g;w.then(M=>{M!==void 0?(u.down([[h,M]]),f(o,M,T)):v(o,u,T+1)},()=>{v(o,u,T+1)});return}if(w!==void 0){u.down([[h,w]]),f(o,w,g);return}}}function N(){if(!(!l||p<=0))for(;l.size()>=p;){let o=l.evict(1);if(o.length===0)break;for(let u of o){let m=n.get(u);if(m){let g=m.cache;if(m.status!=="sentinel"&&e.length>0){let w=e.length-1;try{C(e[w].save(u,g))}catch{}for(let T=0;T<w;T++)try{let M=e[T].delete;M&&C(M.call(e[T],u))}catch{}}m.down([[S]])}n.delete(u)}}}return{load(o){let u=n.get(o);if(u)return l?.touch(o),u;l&&p>0&&l.size()>=p&&N();let m=O(void 0);return n.set(o,m),l?.insert(o),v(o,m),m},save(o,u){if(r)for(let g of e)try{C(g.save(o,u))}catch{}else if(e[0])try{C(e[0].save(o,u))}catch{}let m=n.get(o);if(m)m.down([[h,u]]),l?.touch(o);else{l&&p>0&&l.size()>=p&&N();let g=O(u);n.set(o,g),l?.insert(o)}},invalidate(o){let u=n.get(o);u&&v(o,u)},delete(o){l?.delete(o);let u=n.get(o);u&&u.down([[S]]),n.delete(o);for(let m of e)try{let g=m.delete;g&&C(g.call(m,o))}catch{}},has(o){return n.has(o)},get size(){return n.size}}}var _=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(t){return this._topics.has(t)}topicNames(){return this._topics.values()}createTopic(t){return this._topics.has(t)?!1:(this._topics.add(t),this._version+=1,!0)}removeTopic(t){let n=this._topics.delete(t);return n&&(this._version+=1),n}};function wt(e={}){let{backend:t}=e,n=t??new _,p=new Map;function l(r){let f=p.get(r);return f===void 0&&(f=j({describeKind:"state"}),p.set(r,f),n.createTopic(r)),f}return{topic(r){return l(r)},publish(r,f){l(r).emit(f)},publishMany(r){B(()=>{for(let[f,v]of r)l(f).emit(v)})},removeTopic(r){let f=p.get(r);return f===void 0?!1:(p.delete(r),n.removeTopic(r),f.down([[S]]),!0)},has(r){return n.hasTopic(r)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}var Et=new Map([[$,"INVALIDATE"],[F,"PAUSE"],[H,"RESUME"],[S,"TEARDOWN"],[q,"COMPLETE"],[W,"ERROR"]]),Nt=new Map([["INVALIDATE",$],["PAUSE",F],["RESUME",H],["TEARDOWN",S],["COMPLETE",q],["ERROR",W]]);function I(e){let t=Et.get(e);return t||(Symbol.keyFor(e)??"UNKNOWN")}function V(e){let t=Nt.get(e);if(t)return t;if(e&&e!=="UNKNOWN")return Symbol.for(e)}function P(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e),name:"Error"}}function A(e){let t=new Error(e.message);return t.name=e.name,e.stack&&(t.stack=e.stack),t}function L(e){if(typeof MessagePort<"u"&&e instanceof MessagePort)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=p=>t(p.data);return e.addEventListener("message",n),e.start(),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof SharedWorker<"u"&&e instanceof SharedWorker)return L(e.port);if(typeof Worker<"u"&&e instanceof Worker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=p=>t(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.terminate()}};if(typeof BroadcastChannel<"u"&&e instanceof BroadcastChannel)return{post(t,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),e.postMessage(t)},listen(t){let n=p=>t(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof ServiceWorker<"u"&&e instanceof ServiceWorker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=p=>{p.source===e&&t(p.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function Mt(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function pe(e,t){let n=Mt(e)?e:L(e),p=t.name??"workerBridge",l=Object.entries(t.expose??{}),r=t.import??[],f=t.transfer??{},v=O("connecting",{name:`${p}::meta::status`}),N=O(null,{name:`${p}::meta::error`}),o=new Map,u=new Map;for(let c of r){let a=O(void 0,{name:`${p}::${c}`});o.set(c,a)}let m;if(l.length>0){let c=l.map(([,d])=>d),a=j(c,(d,i)=>{let k={};for(let y=0;y<l.length;y++){let[R]=l[y],E=d[y];E!=null&&E.length>0&&(k[R]=E.at(-1))}Object.keys(k).length!==0&&i.emit(k)},{name:`${p}::aggregated`,partial:!0});m=D([a],d=>{let i=d[0];if(i==null||Object.keys(i).length===0)return;let k=[];for(let E of Object.keys(i)){let z=f[E];z&&k.push(...z(i[E]))}let y;for(let[E,z]of l)E in i&&z.v!=null&&(y==null&&(y={}),y[E]=z.v.version);let R={t:"b",u:i,...y?{v:y}:{}};try{n.post(R,k.length>0?k:void 0)}catch(E){N.down([[h,E instanceof Error?E:new Error(String(E))]])}}).subscribe(()=>{})}let g=!1,w=n.listen(c=>{if(g)return;let a=c;switch(a.t){case"r":{B(()=>{for(let[d,i]of Object.entries(a.stores)){let k=o.get(d);k&&k.down([[h,i]])}}),v.down([[h,"connected"]]);let s={};for(let[d,i]of l)s[d]=i.cache;n.post({t:"i",stores:s});break}case"v":{let s=o.get(a.s);s&&s.down([[h,a.d]]);break}case"b":{B(()=>{for(let[s,d]of Object.entries(a.u)){let i=a.v?.[s];if(i!=null){let y=u.get(s);if(y!=null&&i<=y)continue;u.set(s,i)}let k=o.get(s);k&&k.down([[h,d]])}});break}case"e":{let s=o.get(a.s);s&&s.down([[W,A(a.err)]]);break}case"s":{let s=V(a.sig);if(!s)break;let d=a.s==="*"?[...o.values()]:o.has(a.s)?[o.get(a.s)]:[];for(let i of d)i.down(a.d===void 0?[[s]]:[[s,a.d]]);break}}}),T=[];for(let[c,a]of l){let s=a.subscribe((d=>{if(!g)for(let i of d){let k=i[0];k!==h&&(K.isLocalOnly(k)||(k===W?n.post({t:"e",s:c,err:P(i[1])}):n.post({t:"s",s:c,sig:I(k),d:i.length>1?i[1]:void 0})))}}));T.push(s)}let M;if(t.timeoutMs!=null&&t.timeoutMs>0){let c=G(t.timeoutMs),a=J(v,d=>d==="connected");M=Q(X(U(c,()=>"timeout"),U(a,()=>"ready"))).subscribe(d=>{for(let i of d)i[0]===h&&i[1]==="timeout"&&(N.down([[h,new Error("Worker bridge handshake timeout")]]),x())})}function x(){if(!g){g=!0,M?.(),n.post({t:"s",s:"*",sig:I(S)}),m&&m();for(let c of T)c();T.length=0,w(),v.down([[h,"closed"]]),u.clear(),o.clear()}}let b={meta:{status:v,error:N},destroy:x};for(let[c,a]of o)b[c]=a;return b}function St(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function le(e,t){let n=St(e)?e:L(e),p=t.import??[],l=t.transfer??{},r=new Map,f=new Map,v={};for(let x of p){let b=O(void 0,{name:`worker::${x}`});r.set(x,b),v[x]=b}let N=t.expose(v),o=Object.entries(N),u,m=!1;if(o.length>0){let x=o.map(([,a])=>a),b=j(x,(a,s)=>{let d={};for(let i=0;i<o.length;i++){let[k]=o[i],y=a[i];y!=null&&y.length>0&&(d[k]=y.at(-1))}Object.keys(d).length!==0&&s.emit(d)},{name:"workerSelf::aggregated",partial:!0});u=D([b],a=>{if(m)return;let s=a[0];if(s==null||Object.keys(s).length===0)return;let d=[];for(let y of Object.keys(s)){let R=l[y];R&&d.push(...R(s[y]))}let i;for(let[y,R]of o)y in s&&R.v!=null&&(i==null&&(i={}),i[y]=R.v.version);let k={t:"b",u:s,...i?{v:i}:{}};try{n.post(k,d.length>0?d:void 0)}catch{}}).subscribe(()=>{})}let g=[];for(let[x,b]of o){let c=b.subscribe((a=>{if(!m)for(let s of a){let d=s[0];d!==h&&(K.isLocalOnly(d)||(d===W?n.post({t:"e",s:x,err:P(s[1])}):n.post({t:"s",s:x,sig:I(d),d:s.length>1?s[1]:void 0})))}}));g.push(c)}let w=n.listen(x=>{if(m)return;let b=x;switch(b.t){case"i":{B(()=>{for(let[c,a]of Object.entries(b.stores)){let s=r.get(c);s&&s.down([[h,a]])}});break}case"v":{let c=r.get(b.s);c&&c.down([[h,b.d]]);break}case"b":{B(()=>{for(let[c,a]of Object.entries(b.u)){let s=b.v?.[c];if(s!=null){let i=f.get(c);if(i!=null&&s<=i)continue;f.set(c,s)}let d=r.get(c);d&&d.down([[h,a]])}});break}case"e":{let c=r.get(b.s);c&&c.down([[W,A(b.err)]]);break}case"s":{let c=V(b.sig);if(!c)break;if(c===S&&b.s==="*"){M();return}let a=b.s==="*"?[...r.values()]:r.has(b.s)?[r.get(b.s)]:[];for(let s of a)s.down(b.d===void 0?[[c]]:[[c,b.d]]);break}}}),T={};for(let[x,b]of o)T[x]=b.cache;n.post({t:"r",stores:T});function M(){if(!m){m=!0,u&&u();for(let x of g)x();g.length=0,w(),n.terminate?.(),f.clear(),r.clear()}}return{destroy:M}}export{fe as a,Tt as b,_ as c,wt as d,I as e,V as f,P as g,A as h,L as i,pe as j,le as k,Rt as l};
@@ -1 +1 @@
1
- import{a as O}from"./chunk-CUQFO6MT.js";import{f as B,m as K}from"./chunk-MQZWA3DF.js";import{p as k}from"./chunk-LYCLF26R.js";import{b as M,i as A,j as L}from"./chunk-CK2E7BTU.js";import{b as H}from"./chunk-QYADASLV.js";var Y={};H(Y,{processInstanceKeyOf:()=>J,processManager:()=>X});var J=i=>i.correlationId;function V(i){if(i==null)return Promise.resolve(void 0);let y=K(i);return new Promise((s,v)=>{let u=!1,f,r=()=>{f&&f()};f=y.subscribe(a=>{if(!u)for(let o of a){if(o[0]===M){u=!0,Promise.resolve().then(r),s(o[1]);return}if(o[0]===L){u=!0,Promise.resolve().then(r),v(o[1]);return}if(o[0]===A){u=!0,Promise.resolve().then(r),s(void 0);return}}})})}async function Q(i,y,s,v,u){let f;for(let r=0;r<=v;r++){if(r>0){let a=u[Math.min(r-1,u.length-1)]??0;a>0&&await new Promise(o=>setTimeout(o,a))}try{return await V(i(y,s))}catch(a){f=a}}return{kind:"fail",error:f}}function X(i,y,s){let v=s.retryMax??0,u=s.backoffMs??[0],f=1024,r=new Map,a=new Set,o=new Map,b=O({name:`${y}_process_instances`,retainedLimit:f,graph:i}),j=0;function $(){return++j}function S(e,t,n){C(e,t,n,void 0)}function C(e,t,n,d){let c=k(),g={correlationId:e,state:t,status:n,startedAt:o.get(e)??c,updatedAt:c,t_ns:c,seq:$(),...s.handlerVersion!==void 0?{handlerVersion:s.handlerVersion}:{},...d!==void 0?{reason:d}:{}};b.append(g)}let _=`_process_${y}_started`;i.event(_),s.persistence?.eventStorage&&i.attachEventStorage(s.persistence.eventStorage);async function x(e,t,n,d){if(a.delete(e),r.delete(e),o.delete(e),s.compensate)try{await V(s.compensate(t,n)),C(e,t,"compensated",d)}catch{S(e,t,"failed")}else S(e,t,"failed")}async function D(e,t){if(a.has(e)){if(t.kind==="fail"){let n=r.get(e)??s.initial;await x(e,n,t.error);return}if(t.kind==="continue"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}if(S(e,t.state,"running"),s.isTerminal?.(t.state)){a.delete(e),r.delete(e),o.delete(e),S(e,t.state,"terminated");return}if(t.schedule){let{afterMs:n,eventType:d}=t.schedule,c,g=B(n),l=p=>{for(let T of p)if(T[0]===M){if(c?c():queueMicrotask(()=>c?.()),!a.has(e))return;let E=r.get(e);if(E===void 0)return;let m=s.steps[d];if(!m)return;let w={type:d,payload:null,timestampNs:k(),seq:Number.NaN,correlationId:e,aggregateId:e};q(e,m,E,w)}};c=g.subscribe(l)}return}if(t.kind==="terminate"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}a.delete(e),r.delete(e),o.delete(e),S(e,t.state,"terminated")}}}let h=new Map;function q(e,t,n,d){let g=(h.get(e)??Promise.resolve()).then(async()=>{let l=r.get(e);if(l===void 0||!a.has(e))return;let p;try{p=await Q(t,l,d,v,u)}catch(T){await x(e,r.get(e)??s.initial,T);return}await D(e,p)});h.set(e,g),g.finally(()=>{h.get(e)===g&&h.delete(e)})}let P=!1,R=[];for(let e of s.watching){let t=i.event(e),n=0;n=(t.cache??[]).length;let c=t.subscribe(g=>{for(let l of g){if(l[0]!==M)continue;let p=l[1];if(p.length<=n)continue;let T=p.slice(n);n=p.length;for(let E of T){let m=E.correlationId;if(m===void 0||!a.has(m))continue;let w=s.steps[e];if(!w)continue;let N=r.get(m);N!==void 0&&q(m,w,N,E)}}});R.push(c)}function W(e,t){if(P||a.has(e))return;let n=k();o.set(e,n),r.set(e,s.initial),a.add(e);try{i._appendEvent(_,t??null,{correlationId:e,aggregateId:e})}catch{}S(e,s.initial,"running")}function F(e,t){if(P||!a.has(e))return;let n=r.get(e)??s.initial;x(e,n,new Error(`cancelled: ${t??"no reason given"}`),t)}function U(e){return r.get(e)}function z(){if(!P){P=!0;for(let e of R)try{e()}catch{}R.length=0}}return{instances:b,audit:b,start:W,cancel:F,getState:U,dispose:z}}export{J as a,X as b,Y as c};
1
+ import{a as O}from"./chunk-CGA5RXO6.js";import{f as B,m as K}from"./chunk-MQZWA3DF.js";import{p as k}from"./chunk-LYCLF26R.js";import{b as M,i as A,j as L}from"./chunk-CK2E7BTU.js";import{b as H}from"./chunk-QYADASLV.js";var Y={};H(Y,{processInstanceKeyOf:()=>J,processManager:()=>X});var J=i=>i.correlationId;function V(i){if(i==null)return Promise.resolve(void 0);let y=K(i);return new Promise((s,v)=>{let u=!1,f,r=()=>{f&&f()};f=y.subscribe(a=>{if(!u)for(let o of a){if(o[0]===M){u=!0,Promise.resolve().then(r),s(o[1]);return}if(o[0]===L){u=!0,Promise.resolve().then(r),v(o[1]);return}if(o[0]===A){u=!0,Promise.resolve().then(r),s(void 0);return}}})})}async function Q(i,y,s,v,u){let f;for(let r=0;r<=v;r++){if(r>0){let a=u[Math.min(r-1,u.length-1)]??0;a>0&&await new Promise(o=>setTimeout(o,a))}try{return await V(i(y,s))}catch(a){f=a}}return{kind:"fail",error:f}}function X(i,y,s){let v=s.retryMax??0,u=s.backoffMs??[0],f=1024,r=new Map,a=new Set,o=new Map,b=O({name:`${y}_process_instances`,retainedLimit:f,graph:i}),j=0;function $(){return++j}function S(e,t,n){C(e,t,n,void 0)}function C(e,t,n,d){let c=k(),g={correlationId:e,state:t,status:n,startedAt:o.get(e)??c,updatedAt:c,t_ns:c,seq:$(),...s.handlerVersion!==void 0?{handlerVersion:s.handlerVersion}:{},...d!==void 0?{reason:d}:{}};b.append(g)}let _=`_process_${y}_started`;i.event(_),s.persistence?.eventStorage&&i.attachEventStorage(s.persistence.eventStorage);async function x(e,t,n,d){if(a.delete(e),r.delete(e),o.delete(e),s.compensate)try{await V(s.compensate(t,n)),C(e,t,"compensated",d)}catch{S(e,t,"failed")}else S(e,t,"failed")}async function D(e,t){if(a.has(e)){if(t.kind==="fail"){let n=r.get(e)??s.initial;await x(e,n,t.error);return}if(t.kind==="continue"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}if(S(e,t.state,"running"),s.isTerminal?.(t.state)){a.delete(e),r.delete(e),o.delete(e),S(e,t.state,"terminated");return}if(t.schedule){let{afterMs:n,eventType:d}=t.schedule,c,g=B(n),l=p=>{for(let T of p)if(T[0]===M){if(c?c():queueMicrotask(()=>c?.()),!a.has(e))return;let E=r.get(e);if(E===void 0)return;let m=s.steps[d];if(!m)return;let w={type:d,payload:null,timestampNs:k(),seq:Number.NaN,correlationId:e,aggregateId:e};q(e,m,E,w)}};c=g.subscribe(l)}return}if(t.kind==="terminate"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}a.delete(e),r.delete(e),o.delete(e),S(e,t.state,"terminated")}}}let h=new Map;function q(e,t,n,d){let g=(h.get(e)??Promise.resolve()).then(async()=>{let l=r.get(e);if(l===void 0||!a.has(e))return;let p;try{p=await Q(t,l,d,v,u)}catch(T){await x(e,r.get(e)??s.initial,T);return}await D(e,p)});h.set(e,g),g.finally(()=>{h.get(e)===g&&h.delete(e)})}let P=!1,R=[];for(let e of s.watching){let t=i.event(e),n=0;n=(t.cache??[]).length;let c=t.subscribe(g=>{for(let l of g){if(l[0]!==M)continue;let p=l[1];if(p.length<=n)continue;let T=p.slice(n);n=p.length;for(let E of T){let m=E.correlationId;if(m===void 0||!a.has(m))continue;let w=s.steps[e];if(!w)continue;let N=r.get(m);N!==void 0&&q(m,w,N,E)}}});R.push(c)}function W(e,t){if(P||a.has(e))return;let n=k();o.set(e,n),r.set(e,s.initial),a.add(e);try{i._appendEvent(_,t??null,{correlationId:e,aggregateId:e})}catch{}S(e,s.initial,"running")}function F(e,t){if(P||!a.has(e))return;let n=r.get(e)??s.initial;x(e,n,new Error(`cancelled: ${t??"no reason given"}`),t)}function U(e){return r.get(e)}function z(){if(!P){P=!0;for(let e of R)try{e()}catch{}R.length=0}}return{instances:b,audit:b,start:W,cancel:F,getState:U,dispose:z}}export{J as a,X as b,Y as c};
@@ -1 +1 @@
1
- import{b as G,d as F}from"./chunk-ZGVA2SR5.js";import{c as E}from"./chunk-O32GJOUJ.js";import{a as A}from"./chunk-JUJEPZOI.js";import{j as I}from"./chunk-5KPIYVCC.js";import{b as q}from"./chunk-RLMYS3XZ.js";import{C as M}from"./chunk-MQZWA3DF.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function s(u,a){return E("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:s("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:s("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:s("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:s("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:s("observability",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:s("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:s("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:s("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:s("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:s("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:s("issue_tracker",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=r=>({label:"review",confidence:.5,original:r}),m=a.classify??h,y=o([a.source],r=>m(r[0]),{meta:s("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:r=>r.label==="safe"},{name:"review",classify:r=>r.label==="review"},{name:"block",classify:r=>r.label==="block"}]);n.mount("stratify",c);let k=q([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],r=>{let e=r[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:s("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],r=>r[0]?.confidence??0),v=o([y],r=>{let e=r[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],r=>({classification:r[0],priority:r[1]}),{meta:s("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],r=>{let e=r[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:s("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:s("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:s("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:s("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:s("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:s("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:s("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:s("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:s("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
1
+ import{b as G,d as F}from"./chunk-LO3LO2TO.js";import{c as E}from"./chunk-O32GJOUJ.js";import{a as A}from"./chunk-JUJEPZOI.js";import{b as q}from"./chunk-KUVDFOJH.js";import{j as I}from"./chunk-5KPIYVCC.js";import{C as M}from"./chunk-MQZWA3DF.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function s(u,a){return E("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:s("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:s("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:s("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:s("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:s("observability",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:s("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:s("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:s("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:s("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:s("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:s("issue_tracker",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=r=>({label:"review",confidence:.5,original:r}),m=a.classify??h,y=o([a.source],r=>m(r[0]),{meta:s("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:r=>r.label==="safe"},{name:"review",classify:r=>r.label==="review"},{name:"block",classify:r=>r.label==="block"}]);n.mount("stratify",c);let k=q([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],r=>{let e=r[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:s("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],r=>r[0]?.confidence??0),v=o([y],r=>{let e=r[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],r=>({classification:r[0],priority:r[1]}),{meta:s("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],r=>{let e=r[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:s("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:s("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:s("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:s("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:s("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:s("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:s("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:s("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:s("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
@@ -1,4 +1,4 @@
1
- import{f as F,g as j,h as A}from"./chunk-U347KVM4.js";import{h as b,j as x}from"./chunk-5KPIYVCC.js";import{p as _}from"./chunk-LYCLF26R.js";import{b as C,d as $,i as T,j as N}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var Y={};J(Y,{SNAPSHOT_WIRE_VERSION:()=>v,SurfaceError:()=>o,asSurfaceError:()=>K,createGraph:()=>R,deleteSnapshot:()=>L,diffSnapshots:()=>V,listSnapshots:()=>W,restoreSnapshot:()=>U,runReduction:()=>D,saveSnapshot:()=>M});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function K(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
1
+ import{f as F,g as j,h as A}from"./chunk-QKUWS7CO.js";import{h as b,j as x}from"./chunk-5KPIYVCC.js";import{p as _}from"./chunk-LYCLF26R.js";import{b as C,d as $,i as T,j as N}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var Y={};J(Y,{SNAPSHOT_WIRE_VERSION:()=>v,SurfaceError:()=>o,asSurfaceError:()=>K,createGraph:()=>R,deleteSnapshot:()=>L,diffSnapshots:()=>V,listSnapshots:()=>W,restoreSnapshot:()=>U,runReduction:()=>D,saveSnapshot:()=>M});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function K(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
2
2
  ${r.errors.join(`
3
3
  `)}`,{errors:r.errors});let n=t?.catalog??{},s=F(e,n);if(!s.valid)throw new o("catalog-error",`Catalog validation failed:
4
4
  ${s.errors.join(`
@@ -1,4 +1,4 @@
1
- import{e as ce}from"./chunk-CD4CB6S7.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-5KPIYVCC.js";import{f as ae,h as ie}from"./chunk-MQZWA3DF.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
1
+ import{e as ce}from"./chunk-3U7IIQB2.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-5KPIYVCC.js";import{f as ae,h as ie}from"./chunk-MQZWA3DF.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
2
2
 
3
3
  `),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
4
4
 
@@ -1 +1 @@
1
- import{a as L,c as D}from"./chunk-CUQFO6MT.js";import{c as Q}from"./chunk-O32GJOUJ.js";import{j as F}from"./chunk-5KPIYVCC.js";import{b as G}from"./chunk-KGKJCHEK.js";import{b as I}from"./chunk-TZQPPQEQ.js";import{b as M}from"./chunk-RLMYS3XZ.js";import{C as v,m as C}from"./chunk-MQZWA3DF.js";import{D as x,G as P,m as _,p as m}from"./chunk-LYCLF26R.js";import{b as N,j as A}from"./chunk-CK2E7BTU.js";import{b as V}from"./chunk-QYADASLV.js";var ee={};V(ee,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>Y,jobFlow:()=>Z,jobQueue:()=>z});var X=256,H=1024;function W(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function T(i,e){return Q("job_queue",i,e)}var Y=i=>i.action,y=class extends F{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;constructor(e,t={}){super(e,t.graph),this._pending=G([],{name:"pending"}),this._jobs=I({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=P([this.pending],([o])=>o.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(v(this.depth)),this.events=L({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=D(this,"seq",0)}_bumpSeq(){let t=(this._seqCursor.cache??0)+1;return this._seqCursor.emit(t),t}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,t={}){let o=this._bumpSeq(),n=t.id??`${this.name}-${o}`;if(this._jobs.get(n)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${n}"`);let p={id:n,payload:e,attempts:0,metadata:Object.freeze({...t.metadata??{}}),state:"queued"};return this._jobs.set(n,p),this._pending.append(n),this.events.append({action:"enqueue",id:n,payload:e,t_ns:m(),seq:o}),n}claim(e=1){let t=W(e,"job queue claim limit");if(t===0)return[];let o=[];for(;o.length<t&&this.pending.cache.length!==0;){let p=this._pending.pop(0),h=this._jobs.get(p);if(!h||h.state!=="queued")continue;let l={...h,state:"inflight",attempts:h.attempts+1};this._jobs.set(p,l),o.push(l),this.events.append({action:"claim",id:p,attempts:l.attempts,t_ns:m(),seq:this._bumpSeq()})}return o}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._jobs.delete(e),this.events.append({action:"ack",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}nack(e,t={}){let o=this._jobs.get(e);return!o||o.state!=="inflight"?!1:t.requeue??!0?(this._jobs.set(e,{...o,state:"queued"}),this._pending.append(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0):(this._jobs.delete(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}removeById(e){let t=this._jobs.get(e);if(!t)return!1;if(t.state==="queued"){let n=this.pending.cache.indexOf(e);n>=0&&this._pending.pop(n)}return this._jobs.delete(e),this.events.append({action:"remove",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0}consumeFrom(e,t){return e.subscribe(o=>{for(let n of o){if(n[0]!==N)continue;let p=n[1];this.enqueue(p,t?{metadata:t.metadata}:void 0)}})}},w=class extends F{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let o=t.stages??["incoming","processing","done"],n=[],p=new Map;for(let s of o){let r=typeof s=="string"?s.trim():s.name.trim();typeof s!="string"&&s.work&&p.set(r,s.work),n.push(r)}if(n.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(n).size!==n.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...n]),this._stageWorkFns=p;for(let s of this._stageNames){let r=z(`${e}-${s}`);this._queues.set(s,r),this.mount(s,r)}this._completed=M([],{name:"completed",maxSize:H}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=P([this.completed],([s])=>s.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(v(this.completedCount));let l=Math.max(1,W(t.maxPerPump??X,"job flow maxPerPump"));for(let s=0;s<this._stageNames.length;s+=1){let r=this._stageNames[s],d=this.queue(r),q=s+1<this._stageNames.length?this.queue(this._stageNames[s+1]):null,R=this._stageWorkFns.get(r),S=q===null;if(R){let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f;try{f=R(a)}catch{d.nack(a.id,{requeue:!1}),c+=1;continue}let k=C(f),E=!1,u;u=k.subscribe(K=>{if(!E){for(let J of K)if(J[0]===N){E=!0,u?u():Promise.resolve().then(()=>u?.());let O=J[1],$={...a.metadata,job_flow_path:j};if(S){let U={...a,payload:O,metadata:Object.freeze($)};_(()=>{d.ack(a.id),this._completed.append(U)})}else _(()=>{d.ack(a.id),q.enqueue(O,{metadata:$})});return}else if(J[0]===A){E=!0,u?u():Promise.resolve().then(()=>u?.()),d.nack(a.id,{requeue:!1});return}}}),c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!0})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}else{let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f={...a.metadata,job_flow_path:j};if(S){let k={...a,metadata:Object.freeze(f)};_(()=>{d.ack(a.id),this._completed.append(k)})}else _(()=>{d.ack(a.id),q.enqueue(a.payload,{metadata:f})});c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!1})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function z(i,e){return new y(i,e)}function Z(i,e){return new w(i,e)}export{Y as a,y as b,w as c,z as d,Z as e,ee as f};
1
+ import{a as L,c as D}from"./chunk-CGA5RXO6.js";import{c as Q}from"./chunk-O32GJOUJ.js";import{b as G}from"./chunk-KGKJCHEK.js";import{b as I}from"./chunk-TZQPPQEQ.js";import{b as M}from"./chunk-KUVDFOJH.js";import{j as F}from"./chunk-5KPIYVCC.js";import{C as v,m as C}from"./chunk-MQZWA3DF.js";import{D as x,G as P,m as _,p as m}from"./chunk-LYCLF26R.js";import{b as N,j as A}from"./chunk-CK2E7BTU.js";import{b as V}from"./chunk-QYADASLV.js";var ee={};V(ee,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>Y,jobFlow:()=>Z,jobQueue:()=>z});var X=256,H=1024;function W(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function T(i,e){return Q("job_queue",i,e)}var Y=i=>i.action,y=class extends F{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;constructor(e,t={}){super(e,t.graph),this._pending=G([],{name:"pending"}),this._jobs=I({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=P([this.pending],([o])=>o.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(v(this.depth)),this.events=L({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=D(this,"seq",0)}_bumpSeq(){let t=(this._seqCursor.cache??0)+1;return this._seqCursor.emit(t),t}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,t={}){let o=this._bumpSeq(),n=t.id??`${this.name}-${o}`;if(this._jobs.get(n)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${n}"`);let p={id:n,payload:e,attempts:0,metadata:Object.freeze({...t.metadata??{}}),state:"queued"};return this._jobs.set(n,p),this._pending.append(n),this.events.append({action:"enqueue",id:n,payload:e,t_ns:m(),seq:o}),n}claim(e=1){let t=W(e,"job queue claim limit");if(t===0)return[];let o=[];for(;o.length<t&&this.pending.cache.length!==0;){let p=this._pending.pop(0),h=this._jobs.get(p);if(!h||h.state!=="queued")continue;let l={...h,state:"inflight",attempts:h.attempts+1};this._jobs.set(p,l),o.push(l),this.events.append({action:"claim",id:p,attempts:l.attempts,t_ns:m(),seq:this._bumpSeq()})}return o}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._jobs.delete(e),this.events.append({action:"ack",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}nack(e,t={}){let o=this._jobs.get(e);return!o||o.state!=="inflight"?!1:t.requeue??!0?(this._jobs.set(e,{...o,state:"queued"}),this._pending.append(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0):(this._jobs.delete(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}removeById(e){let t=this._jobs.get(e);if(!t)return!1;if(t.state==="queued"){let n=this.pending.cache.indexOf(e);n>=0&&this._pending.pop(n)}return this._jobs.delete(e),this.events.append({action:"remove",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0}consumeFrom(e,t){return e.subscribe(o=>{for(let n of o){if(n[0]!==N)continue;let p=n[1];this.enqueue(p,t?{metadata:t.metadata}:void 0)}})}},w=class extends F{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let o=t.stages??["incoming","processing","done"],n=[],p=new Map;for(let s of o){let r=typeof s=="string"?s.trim():s.name.trim();typeof s!="string"&&s.work&&p.set(r,s.work),n.push(r)}if(n.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(n).size!==n.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...n]),this._stageWorkFns=p;for(let s of this._stageNames){let r=z(`${e}-${s}`);this._queues.set(s,r),this.mount(s,r)}this._completed=M([],{name:"completed",maxSize:H}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=P([this.completed],([s])=>s.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(v(this.completedCount));let l=Math.max(1,W(t.maxPerPump??X,"job flow maxPerPump"));for(let s=0;s<this._stageNames.length;s+=1){let r=this._stageNames[s],d=this.queue(r),q=s+1<this._stageNames.length?this.queue(this._stageNames[s+1]):null,R=this._stageWorkFns.get(r),S=q===null;if(R){let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f;try{f=R(a)}catch{d.nack(a.id,{requeue:!1}),c+=1;continue}let k=C(f),E=!1,u;u=k.subscribe(K=>{if(!E){for(let J of K)if(J[0]===N){E=!0,u?u():Promise.resolve().then(()=>u?.());let O=J[1],$={...a.metadata,job_flow_path:j};if(S){let U={...a,payload:O,metadata:Object.freeze($)};_(()=>{d.ack(a.id),this._completed.append(U)})}else _(()=>{d.ack(a.id),q.enqueue(O,{metadata:$})});return}else if(J[0]===A){E=!0,u?u():Promise.resolve().then(()=>u?.()),d.nack(a.id,{requeue:!1});return}}}),c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!0})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}else{let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f={...a.metadata,job_flow_path:j};if(S){let k={...a,metadata:Object.freeze(f)};_(()=>{d.ack(a.id),this._completed.append(k)})}else _(()=>{d.ack(a.id),q.enqueue(a.payload,{metadata:f})});c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!1})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function z(i,e){return new y(i,e)}function Z(i,e){return new w(i,e)}export{Y as a,y as b,w as c,z as d,Z as e,ee as f};
@@ -1 +1 @@
1
- import{C as O}from"./chunk-MQZWA3DF.js";import{D as H,E as A,G as N,m as D}from"./chunk-LYCLF26R.js";import{b as z,c as $,d as K,i as B,j as E}from"./chunk-CK2E7BTU.js";var C=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(n,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),n&&n.length>0){let s=Math.min(n.length,t),c=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[c+o];this._size=s}}else this._buf=n?[...n]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(n){if(!Number.isInteger(n))return;let t=n>=0?n:this._size+n;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(n){this._rawAppend(n),this._version+=1}appendMany(n){if(n.length===0)return;let t=this._maxSize!==void 0&&n.length>this._maxSize?n.length-this._maxSize:0;for(let s=t;s<n.length;s++)this._rawAppend(n[s]);this._version+=1}clear(){if(this._size===0)return 0;let n=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<n;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,n}trimHead(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return 0;let t=Math.min(n,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let s=0;s<t;s++)this._buf[(this._head+s)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(n,t){if(!Number.isInteger(n)||n<0)throw new RangeError(`slice: start must be a non-negative integer (got ${n})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let s=t===void 0?this._size:Math.min(Math.max(t,0),this._size),c=Math.min(n,this._size);if(c>=s)return[];let o=s-c;if(this._maxSize===void 0)return this._buf.slice(c,s);let p=new Array(o);for(let r=0;r<o;r++)p[r]=this._buf[(this._head+c+r)%this._maxSize];return p}tail(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`tail: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return[];let t=Math.min(n,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let n=new Array(this._size);for(let t=0;t<this._size;t++)n[t]=this._buf[(this._head+t)%this._maxSize];return n}snapshot(){return this.toArray()}restore(n){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<n.length;t++)this._buf.push(n[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let s=Math.min(n.length,t),c=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[c+o];this._size=s}this._version+=1}_rawAppend(n){if(this._maxSize===void 0){this._buf.push(n),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=n,this._size+=1):(this._buf[this._head]=n,this._head=(this._head+1)%this._maxSize)}};function k(g){return g.subscribe(()=>{})}var G=64;function Q(g,n={}){let{name:t,maxSize:s,versioning:c,guard:o,backend:p}=n,r=p??new C(g,s),m=A(r.toArray(),{name:t,describeKind:"state",equals:(e,i)=>e===i,...c!=null?{versioning:c}:{},...o!=null?{guard:o}:{}});function v(){let e=r.toArray();D(()=>{m.down([[$]],{internal:!0}),m.down([[z,e]],{internal:!0})})}let u=new Map,h=new Map,_=new Map;function M(e,i){return`${e}:${i===void 0?"END":i}`}function y(e){if(e.size<G)return;let i=e.keys().next();if(i.done)return;let d=e.get(i.value);d!==void 0&&d.dispose(),e.delete(i.value)}function x(e){let i=r.version;try{return e()}finally{r.version!==i&&v()}}function P(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);let i=u.get(e);if(i!==void 0)return u.delete(e),u.set(e,i),i.node;y(u);let d=N([m],([f])=>{let l=f;return e===0||l.length===0?[]:l.slice(Math.max(0,l.length-e))},{initial:r.tail(e),describeKind:"derived"}),a=k(d);return u.set(e,{node:d,dispose:a}),d}function j(e,i){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${i})`);let d=M(e,i),a=h.get(d);if(a!==void 0)return h.delete(d),h.set(d,a),a.node;y(h);let f=N([m],([b])=>{let T=b;return i===void 0?T.slice(e):T.slice(e,i)},{initial:r.slice(e,i),describeKind:"derived"}),l=k(f);return h.set(d,{node:f,dispose:l}),f}function q(e){let i=_.get(e);if(i!==void 0)return i.node;let d=N([m,e],([f,l])=>{let b=f,T=Math.max(0,Math.trunc(l??0));return b.slice(T)},{initial:[],describeKind:"derived"}),a=k(d);return _.set(e,{node:d,dispose:a}),d}let L,S;function R(){L===void 0&&(L=H([m],(e,i,d)=>{let a=e[0],l=a!=null&&a.length>0?a.at(-1):d.prevData[0];if(l==null||l.length===0){i.down([[K]]);return}i.emit(l[l.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:r.size===0?void 0:r.at(r.size-1)}),S=N([m],([e])=>e.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:r.size>0}),k(L),k(S))}let I={entries:m,get size(){return r.size},at(e){return r.at(e)},append(e){x(()=>r.append(e))},appendMany(e){e.length!==0&&x(()=>r.appendMany(e))},clear(){x(()=>r.clear())},trimHead(e){x(()=>r.trimHead(e))},withLatest(){return R(),m},get lastValue(){return R(),L},get hasLatest(){return R(),S},view(e){switch(e.kind){case"tail":return P(e.n);case"slice":return j(e.start,e.stop);case"fromCursor":return q(e.cursor)}},attach(e){let i=e.subscribe(d=>{for(let a of d)a[0]===z&&I.append(a[1])});return()=>i()},attachStorage(e){if(e.length===0)return()=>{};let i=new Map;for(let a of e)i.set(a,r.size);(async()=>{for(let a of e)if(typeof a.loadEntries=="function")try{let f=await Promise.resolve(a.loadEntries());f.entries.length>0&&r.size===0&&(r.restore(f.entries),i.set(a,f.entries.length),v());break}catch{}})();let d=m.subscribe(a=>{for(let f of a){if(f[0]!==z)continue;let l=f[1];for(let b of e){let T=i.get(b)??0;if(l.length<T){try{let w=b.appendEntries(l);w instanceof Promise&&w.catch(()=>{})}catch{}i.set(b,l.length);continue}if(l.length===T)continue;let F=l.slice(T);i.set(b,l.length);try{let w=b.appendEntries(F);w instanceof Promise&&w.catch(()=>{})}catch{}}}});return()=>d()},disposeAllViews(){for(let e of u.values())e.dispose();u.clear();for(let e of h.values())e.dispose();h.clear();for(let e of _.values())e.dispose();_.clear()},dispose(){for(let e of u.values())e.dispose();u.clear();for(let e of h.values())e.dispose();h.clear();for(let e of _.values())e.dispose();_.clear()}};return I}var V=new WeakMap;function Z(g){let n=V.get(g);if(n)return n;let t=g.map(u=>u.cache??[]),s=t.flat(),c=A(s,{name:"mergeReactiveLogs",describeKind:"state",equals:(u,h)=>u===h}),o=g.map((u,h)=>[...t[h]??[]]),p=[];for(let u=0;u<g.length;u++){let h=u,_=g[h].subscribe(M=>{for(let y of M)y[0]===z?(o[h]=[...y[1]],c.emit(o.flat())):y[0]===B?o[h]=[]:y[0]===E&&c.down([[E,y[1]]])});p.push(_)}let r=O(c),m=!1,v={node:c,dispose(){if(!m){m=!0;for(let u of p)u();p.length=0,r(),V.delete(g)}}};return V.set(g,v),v}export{C as a,Q as b,Z as c};
1
+ import{C as O}from"./chunk-MQZWA3DF.js";import{D as H,E as A,G as k,m as D}from"./chunk-LYCLF26R.js";import{b as N,c as $,d as K,i as B,j as E}from"./chunk-CK2E7BTU.js";var C=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(n,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),n&&n.length>0){let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}}else this._buf=n?[...n]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(n){if(!Number.isInteger(n))return;let t=n>=0?n:this._size+n;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(n){this._rawAppend(n),this._version+=1}appendMany(n){if(n.length===0)return;let t=this._maxSize!==void 0&&n.length>this._maxSize?n.length-this._maxSize:0;for(let s=t;s<n.length;s++)this._rawAppend(n[s]);this._version+=1}clear(){if(this._size===0)return 0;let n=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<n;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,n}trimHead(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return 0;let t=Math.min(n,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let s=0;s<t;s++)this._buf[(this._head+s)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(n,t){if(!Number.isInteger(n)||n<0)throw new RangeError(`slice: start must be a non-negative integer (got ${n})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let s=t===void 0?this._size:Math.min(Math.max(t,0),this._size),h=Math.min(n,this._size);if(h>=s)return[];let o=s-h;if(this._maxSize===void 0)return this._buf.slice(h,s);let b=new Array(o);for(let r=0;r<o;r++)b[r]=this._buf[(this._head+h+r)%this._maxSize];return b}tail(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`tail: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return[];let t=Math.min(n,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let n=new Array(this._size);for(let t=0;t<this._size;t++)n[t]=this._buf[(this._head+t)%this._maxSize];return n}snapshot(){return this.toArray()}restore(n){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<n.length;t++)this._buf.push(n[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}this._version+=1}_rawAppend(n){if(this._maxSize===void 0){this._buf.push(n),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=n,this._size+=1):(this._buf[this._head]=n,this._head=(this._head+1)%this._maxSize)}};function x(g){return g.subscribe(()=>{})}var G=64;function Q(g,n={}){let{name:t,maxSize:s,versioning:h,guard:o,backend:b}=n,r=b??new C(g,s),m=A(r.toArray(),{name:t,describeKind:"state",equals:(e,i)=>e===i,...h!=null?{versioning:h}:{},...o!=null?{guard:o}:{}});function w(){let e=r.toArray();D(()=>{m.down([[$]],{internal:!0}),m.down([[N,e]],{internal:!0})})}let u=new Map,l=new Map,_=new Map;function M(e,i){return`${e}:${i===void 0?"END":i}`}function y(e){if(e.size<G)return;let i=e.keys().next();if(i.done)return;let d=e.get(i.value);d!==void 0&&d.dispose(),e.delete(i.value)}function v(e){let i=r.version;try{return e()}finally{r.version!==i&&w()}}function P(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);let i=u.get(e);if(i!==void 0)return u.delete(e),u.set(e,i),i.node;y(u);let d=k([m],([f])=>{let c=f;return e===0||c.length===0?[]:c.slice(Math.max(0,c.length-e))},{initial:r.tail(e),describeKind:"derived"}),a=x(d);return u.set(e,{node:d,dispose:a}),d}function j(e,i){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${i})`);let d=M(e,i),a=l.get(d);if(a!==void 0)return l.delete(d),l.set(d,a),a.node;y(l);let f=k([m],([p])=>{let T=p;return i===void 0?T.slice(e):T.slice(e,i)},{initial:r.slice(e,i),describeKind:"derived"}),c=x(f);return l.set(d,{node:f,dispose:c}),f}function q(e){let i=_.get(e);if(i!==void 0)return i.node;let d=k([m,e],([f,c])=>{let p=f,T=Math.max(0,Math.trunc(c??0));return p.slice(T)},{initial:[],describeKind:"derived"}),a=x(d);return _.set(e,{node:d,dispose:a}),d}let L,S;function R(){L===void 0&&(L=H([m],(e,i,d)=>{let a=e[0],c=a!=null&&a.length>0?a.at(-1):d.prevData[0];if(c==null||c.length===0){i.down([[K]]);return}i.emit(c[c.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:r.size===0?void 0:r.at(r.size-1)}),S=k([m],([e])=>e.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:r.size>0}),x(L),x(S))}let I={entries:m,get size(){return r.size},at(e){return r.at(e)},append(e){v(()=>r.append(e))},appendMany(e){e.length!==0&&v(()=>r.appendMany(e))},clear(){v(()=>r.clear())},trimHead(e){v(()=>r.trimHead(e))},withLatest(){return R(),m},get lastValue(){return R(),L},get hasLatest(){return R(),S},view(e){switch(e.kind){case"tail":return P(e.n);case"slice":return j(e.start,e.stop);case"fromCursor":return q(e.cursor)}},attach(e){let i=e.subscribe(d=>{for(let a of d)a[0]===N&&I.append(a[1])});return()=>i()},attachStorage(e){if(e.length===0)return()=>{};let i=new Map;for(let a of e)i.set(a,r.size);(async()=>{for(let a of e)if(typeof a.loadEntries=="function")try{let f=await Promise.resolve(a.loadEntries());f.entries.length>0&&r.size===0&&(r.restore(f.entries),i.set(a,f.entries.length),w());break}catch{}})();let d=m.subscribe(a=>{for(let f of a){if(f[0]!==N)continue;let c=f[1];for(let p of e){let T=i.get(p)??0;if(c.length<T){try{let z=p.appendEntries(c);z instanceof Promise&&z.catch(()=>{})}catch{}i.set(p,c.length);continue}if(c.length===T)continue;let F=c.slice(T);i.set(p,c.length);try{let z=p.appendEntries(F);z instanceof Promise&&z.catch(()=>{})}catch{}}}});return()=>d()},disposeAllViews(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()},dispose(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()}};return I}var V=new WeakMap;function Z(g){let n=V.get(g);if(n)return n;let t=g.map(u=>u.cache??[]),s=t.flat(),h=A(s,{name:"mergeReactiveLogs",describeKind:"state",equals:(u,l)=>u===l}),o=g.map((u,l)=>[...t[l]??[]]),b=[];for(let u=0;u<g.length;u++){let l=u,_=g[l].subscribe(M=>{for(let y of M)if(y[0]===N)o[l]=[...y[1]],h.emit(o.flat());else if(y[0]===B){o[l]=[];let v=b[l];v!==void 0&&(b[l]=void 0,v())}else y[0]===E&&h.down([[E,y[1]]])});b.push(_)}let r=O(h),m=!1,w={node:h,dispose(){if(!m){m=!0;for(let u of b)u?.();b.length=0,r(),V.delete(g)}}};return V.set(g,w),w}export{C as a,Q as b,Z as c};
@@ -1 +1 @@
1
- import{b as F,c as G}from"./chunk-O32GJOUJ.js";import{j as _}from"./chunk-5KPIYVCC.js";import{t as B}from"./chunk-JJTF75VS.js";import{b as $}from"./chunk-TZQPPQEQ.js";import{C as N}from"./chunk-MQZWA3DF.js";import{D as x,E as I,G as S,H as M,m as A}from"./chunk-LYCLF26R.js";import{b as k,c as v,d as y,f as T,g as O,i as E,j as w}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var U={};K(U,{budgetGate:()=>C,effectivenessTracker:()=>L,feedback:()=>V,funnel:()=>P,scorer:()=>z});function R(u,t){return G("reduction",u,t)}function P(u,t,i,b){if(t.length===0)throw new RangeError("funnel requires at least one source");if(i.length===0)throw new RangeError("funnel requires at least one stage");let d=new _(u,b),s=t.length===1?t[0]:B(...t);d.add(s,{name:"merged"});let e="merged";for(let f=0;f<i.length;f++){let o=i[f],c=new _(o.name);o.build(c);try{c.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{c.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}d.mount(o.name,c);let l=d.resolve(e),m=`${o.name}::input`,g=d.resolve(m),a=`__bridge_${e}\u2192${o.name}_input`,p=M([l],([r])=>{g.emit(r)},{name:a});d.add(p,{name:a}),d.addDisposer(N(p)),e=`${o.name}::output`}return d}function V(u,t,i,b){let d=b?.maxIterations??10,s=`__feedback_${t}`,e=I(0,{meta:R("feedback_counter",{maxIterations:d,feedbackFrom:t,feedbackTo:i})});u.add(e,{name:s});let f=u.resolve(t),o=u.resolve(i),c=`__feedback_effect_${t}`,l=x([],(m,g)=>{let a=f.subscribe(p=>{for(let r of p){let n=r[0];if(n===k){let h=r[1];if(h==null)return;A(()=>{F(e,d)&&o.emit(h)})}else if(n===E||n===w){let h=n===w&&r.length>1?[w,r[1]]:[n];e.down([h])}}});return()=>a()},{name:c,describeKind:"effect",meta:{...R("feedback_effect",{feedbackFrom:t,feedbackTo:i}),_internal:!0}});return u.add(l,{name:c}),u.addDisposer(N(l)),u}function C(u,t,i){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let b=t.map(a=>a.node),d=[u,...b],s=[],e=!1,f=!1,o=Symbol("budget-gate"),c=new Array(t.length);function l(){return t.every((a,p)=>a.check(c[p]))}function m(a){for(;s.length>0&&l();){let p=s[0];s=s.slice(1),a.emit(p)}s.length===0&&f&&(f=!1,a.down([[y]]))}return x([],(a,p)=>{for(let n=0;n<t.length;n++)c[n]=t[n].node.cache;let r=[];for(let n=0;n<d.length;n++){let h=d[n];r.push(h.subscribe(q=>{for(let D of q)g(D,n,p)}))}return()=>{for(let n of r)n()}},{...i,describeKind:"derived",meta:R("budget_gate",i?.meta)});function g(a,p,r){let n=a[0];if(p===0){if(n===k)return l()&&s.length===0?r.emit(a[1]):(s.push(a[1]),e||(e=!0,r.up([[T,o]]))),!0;if(n===v)return r.down([[v]]),!0;if(n===y)return s.length===0?r.down([[y]]):f=!0,!0;if(n===E||n===w){for(let h of s)r.emit(h);return s=[],f=!1,e&&(e=!1,r.up([[O,o]])),r.down([a]),!0}return!1}return n===k&&(c[p-1]=a[1]),n===k||n===y?(l()&&s.length>0?(m(r),s.length===0&&e&&(e=!1,r.up([[O,o]]))):!l()&&!e&&s.length>0&&(e=!0,r.up([[T,o]])),!0):n===v?!0:n===w?(r.down([a]),!0):n===E}}function z(u,t,i){if(u.length===0)throw new RangeError("scorer requires at least one source");if(u.length!==t.length)throw new RangeError("scorer requires the same number of sources and weights");let b=[...u,...t],d=u.length,s=i?.scoreFns;return S(b,e=>{let f=e.slice(0,d),o=e.slice(d),c=[],l=0;for(let m=0;m<d;m++){let g=f[m]??0,a=o[m]??0,r=(s?.[m]?s[m](g):g)*a;c.push(r),l+=r}return{value:f,score:l,breakdown:c}},{...i?{equals:i.equals,resubscribable:i.resubscribable,resetOnTeardown:i.resetOnTeardown}:{},describeKind:"derived",meta:R("scorer",i?.meta)})}function L(u){let t=$({name:u?.name??"effectiveness-entries"}),i=S([t.entries],([e])=>new Map(e),{name:`${u?.name??"effectiveness"}-snapshot`,equals:(e,f)=>{let o=e,c=f;if(o.size!==c.size)return!1;for(let[l,m]of o){let g=c.get(l);if(!g||m.attempts!==g.attempts||m.successes!==g.successes)return!1}return!0}});function b(e,f){let o=t.get(e),c=(o?.attempts??0)+1,l=(o?.successes??0)+(f?1:0);t.set(e,{key:e,attempts:c,successes:l,successRate:l/c})}function d(e){return t.get(e)}let s=N(i);return{node:i,record:b,lookup:d,dispose:()=>s()}}export{P as a,V as b,C as c,z as d,L as e,U as f};
1
+ import{b as F,c as G}from"./chunk-O32GJOUJ.js";import{b as $}from"./chunk-TZQPPQEQ.js";import{j as _}from"./chunk-5KPIYVCC.js";import{t as B}from"./chunk-JJTF75VS.js";import{C as N}from"./chunk-MQZWA3DF.js";import{D as x,E as I,G as S,H as M,m as A}from"./chunk-LYCLF26R.js";import{b as k,c as v,d as y,f as T,g as O,i as E,j as w}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var U={};K(U,{budgetGate:()=>C,effectivenessTracker:()=>L,feedback:()=>V,funnel:()=>P,scorer:()=>z});function R(u,t){return G("reduction",u,t)}function P(u,t,i,b){if(t.length===0)throw new RangeError("funnel requires at least one source");if(i.length===0)throw new RangeError("funnel requires at least one stage");let d=new _(u,b),s=t.length===1?t[0]:B(...t);d.add(s,{name:"merged"});let e="merged";for(let f=0;f<i.length;f++){let o=i[f],c=new _(o.name);o.build(c);try{c.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{c.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}d.mount(o.name,c);let l=d.resolve(e),m=`${o.name}::input`,g=d.resolve(m),a=`__bridge_${e}\u2192${o.name}_input`,p=M([l],([r])=>{g.emit(r)},{name:a});d.add(p,{name:a}),d.addDisposer(N(p)),e=`${o.name}::output`}return d}function V(u,t,i,b){let d=b?.maxIterations??10,s=`__feedback_${t}`,e=I(0,{meta:R("feedback_counter",{maxIterations:d,feedbackFrom:t,feedbackTo:i})});u.add(e,{name:s});let f=u.resolve(t),o=u.resolve(i),c=`__feedback_effect_${t}`,l=x([],(m,g)=>{let a=f.subscribe(p=>{for(let r of p){let n=r[0];if(n===k){let h=r[1];if(h==null)return;A(()=>{F(e,d)&&o.emit(h)})}else if(n===E||n===w){let h=n===w&&r.length>1?[w,r[1]]:[n];e.down([h])}}});return()=>a()},{name:c,describeKind:"effect",meta:{...R("feedback_effect",{feedbackFrom:t,feedbackTo:i}),_internal:!0}});return u.add(l,{name:c}),u.addDisposer(N(l)),u}function C(u,t,i){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let b=t.map(a=>a.node),d=[u,...b],s=[],e=!1,f=!1,o=Symbol("budget-gate"),c=new Array(t.length);function l(){return t.every((a,p)=>a.check(c[p]))}function m(a){for(;s.length>0&&l();){let p=s[0];s=s.slice(1),a.emit(p)}s.length===0&&f&&(f=!1,a.down([[y]]))}return x([],(a,p)=>{for(let n=0;n<t.length;n++)c[n]=t[n].node.cache;let r=[];for(let n=0;n<d.length;n++){let h=d[n];r.push(h.subscribe(q=>{for(let D of q)g(D,n,p)}))}return()=>{for(let n of r)n()}},{...i,describeKind:"derived",meta:R("budget_gate",i?.meta)});function g(a,p,r){let n=a[0];if(p===0){if(n===k)return l()&&s.length===0?r.emit(a[1]):(s.push(a[1]),e||(e=!0,r.up([[T,o]]))),!0;if(n===v)return r.down([[v]]),!0;if(n===y)return s.length===0?r.down([[y]]):f=!0,!0;if(n===E||n===w){for(let h of s)r.emit(h);return s=[],f=!1,e&&(e=!1,r.up([[O,o]])),r.down([a]),!0}return!1}return n===k&&(c[p-1]=a[1]),n===k||n===y?(l()&&s.length>0?(m(r),s.length===0&&e&&(e=!1,r.up([[O,o]]))):!l()&&!e&&s.length>0&&(e=!0,r.up([[T,o]])),!0):n===v?!0:n===w?(r.down([a]),!0):n===E}}function z(u,t,i){if(u.length===0)throw new RangeError("scorer requires at least one source");if(u.length!==t.length)throw new RangeError("scorer requires the same number of sources and weights");let b=[...u,...t],d=u.length,s=i?.scoreFns;return S(b,e=>{let f=e.slice(0,d),o=e.slice(d),c=[],l=0;for(let m=0;m<d;m++){let g=f[m]??0,a=o[m]??0,r=(s?.[m]?s[m](g):g)*a;c.push(r),l+=r}return{value:f,score:l,breakdown:c}},{...i?{equals:i.equals,resubscribable:i.resubscribable,resetOnTeardown:i.resetOnTeardown}:{},describeKind:"derived",meta:R("scorer",i?.meta)})}function L(u){let t=$({name:u?.name??"effectiveness-entries"}),i=S([t.entries],([e])=>new Map(e),{name:`${u?.name??"effectiveness"}-snapshot`,equals:(e,f)=>{let o=e,c=f;if(o.size!==c.size)return!1;for(let[l,m]of o){let g=c.get(l);if(!g||m.attempts!==g.attempts||m.successes!==g.successes)return!1}return!0}});function b(e,f){let o=t.get(e),c=(o?.attempts??0)+1,l=(o?.successes??0)+(f?1:0);t.set(e,{key:e,attempts:c,successes:l,successRate:l/c})}function d(e){return t.get(e)}let s=N(i);return{node:i,record:b,lookup:d,dispose:()=>s()}}export{P as a,V as b,C as c,z as d,L as e,U as f};
@@ -1,4 +1,4 @@
1
- import{a as $e}from"./chunk-EUE7ELFQ.js";import{d as _e}from"./chunk-53XJ2S6D.js";import{u as X}from"./chunk-E5YSBQSF.js";import{a as Me}from"./chunk-GWOKTENT.js";import{c as Ce}from"./chunk-3OT7K33Q.js";import{g as we,i as ue}from"./chunk-BGEY3PXH.js";import{b as ie,d as U}from"./chunk-O32GJOUJ.js";import{f as ke,j as Se}from"./chunk-5KPIYVCC.js";import{b as A,s as q,t as Ae,x as _}from"./chunk-JJTF75VS.js";import{b as Oe}from"./chunk-TZQPPQEQ.js";import{m as z}from"./chunk-MQZWA3DF.js";import{D as Ne,E as S,F as Q,G as N,H as $,o as V}from"./chunk-LYCLF26R.js";import{b as P,i as F,j as W}from"./chunk-CK2E7BTU.js";import{b as Xe}from"./chunk-QYADASLV.js";var kt={};Xe(kt,{DEFAULT_DECAY_RATE:()=>D,DEFAULT_EXECUTE_PROMPT:()=>ce,DEFAULT_QUEUE_CONFIGS:()=>Z,DEFAULT_SEVERITY_WEIGHTS:()=>L,DEFAULT_TRIAGE_PROMPT:()=>le,DEFAULT_VERIFY_PROMPT:()=>de,HarnessGraph:()=>te,QUEUE_NAMES:()=>b,actuatorExecutor:()=>nt,affectedTaskFilter:()=>lt,autoSolidify:()=>ot,beforeAfterCompare:()=>ut,codeChangeBridge:()=>ct,createIntakeBridge:()=>st,defaultErrorClassifier:()=>ee,defaultLlmExecutor:()=>je,defaultLlmVerifier:()=>Ge,evalIntakeBridge:()=>at,evalSource:()=>it,evalVerifier:()=>Pe,harnessEvalPair:()=>Tt,harnessLoop:()=>vt,harnessProfile:()=>ht,harnessTrace:()=>bt,notifyEffect:()=>dt,priorityScore:()=>Et,refineExecutor:()=>pe,resolvePromptFn:()=>B,strategyKey:()=>j,strategyModel:()=>fe});function Ze(e,t){return{outcome:"success",detail:`actuator applied ${t.intervention} for ${rt(t.summary)}`,artifact:e}}function et(e,t){let n=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${t.intervention}: ${n}`}}function tt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function rt(e,t=80){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function nt(e){let t=e.name??"actuator-executor",n=e.toOutput??Ze,r=e.onError??et,o=e.skipDetail??tt;return d=>{let s=A(d,i=>i!=null,{name:`${t}/gate-in`}),a=_(s,i=>e.shouldApply&&!e.shouldApply(i)?Q(c=>(c.down([[P,{outcome:"failure",detail:o(i)}],[F]]),()=>{}),{name:`${t}/skip`}):Q(c=>{let m=new AbortController,f=!1,l=null,g=R=>{f||(f=!0,c.down([[P,R],[F]]),l?.(),l=null)},y;try{let R=e.apply(i,{signal:m.signal});y=z(R,{signal:m.signal})}catch(R){return g(r(R,i)),()=>{m.abort()}}return l=y.subscribe(R=>{for(let E of R){if(f)return;if(E[0]===P){g(n(E[1],i));return}if(E[0]===W){g(r(E[1],i));return}if(E[0]===F){g(r(new Error("actuator inner completed without emitting DATA"),i));return}}}),f&&l&&(l(),l=null),()=>{m.abort(),l?.(),l=null}},{name:`${t}/inner`}),{name:t});return A(a,i=>i!=null,{name:`${t}/gate-out`})}}function ot(e){let t=e.name??"auto-solidify",n=e.extract??(o=>o.execution.artifact??null),r=e.predicate??(()=>!0);return Q(o=>{let d=null,s=!1,a=()=>{s||(s=!0,d?.(),d=null)},i=c=>{s||(o.down([[W,c]]),a())};return d=e.verifyResults.subscribe(c=>{if(!s)for(let m of c){if(s)return;if(m[0]!==P){if(m[0]===F){o.down([[F]]),a();return}continue}let f=m[1];if(f==null||!f.verified)continue;let l;try{l=r(f)}catch(y){i(y);return}if(!l)continue;let g;try{g=n(f)}catch(y){i(y);return}if(g!=null){try{e.write(g,f)}catch(y){i(y);return}o.down([[P,g]])}}}),s&&d&&(d(),d=null),()=>{a()}},{name:t})}function st(e,t,n,r){return $([e],([o])=>{if(o==null)return;let d=n(o);for(let s of d)t.publish(s)},{name:r?.name??"intake-bridge"})}function at(e,t,n){let r=n?.defaultSeverity??"medium";return $([e],([o])=>{if(o==null)return;let d=Array.isArray(o)?o:[o];for(let s of d)for(let a of s.tasks)if(!(a.valid&&a.judge_scores?.every(i=>i.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){t.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${s.model})`,evidence:`Run ${s.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r});continue}if(a.judge_scores)for(let i of a.judge_scores)i.pass||t.publish({source:"eval",summary:`${a.task_id}: ${i.claim} (model: ${s.model})`,evidence:i.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r})}},{name:n?.name??"eval-intake-bridge"})}function it(e,t){return _(e,()=>z(t()))}function ut(e,t){return N([e,t],([n,r])=>{let o=n,d=r,s=new Map(o.tasks.map(l=>[l.task_id,l])),a=new Map(d.tasks.map(l=>[l.task_id,l])),i=new Set([...s.keys(),...a.keys()]),c=[],m=[],f=[];for(let l of i){let g=s.get(l),y=a.get(l),R=g?.valid??!1,E=y?.valid??!1,I=g?.judge_scores?g.judge_scores.filter(w=>w.pass).length:void 0,k=y?.judge_scores?y.judge_scores.filter(w=>w.pass).length:void 0,O=I!==void 0&&k!==void 0?k-I:void 0;c.push({taskId:l,before:R,after:E,scoreDiff:O}),R&&!E&&m.push(l),!R&&E&&f.push(l)}return{newFailures:m,resolved:f,taskDeltas:c,overallImproved:f.length>m.length}},{name:"eval-delta"})}function lt(e,t){let n=t==null?null:Array.isArray(t)?S(t):t,r=[e];return n&&r.push(n),N(r,o=>{let d=o[0],s=n?new Set(o[1]):null,a=new Set;for(let i of d)for(let c of i.affectsEvalTasks??[])(s==null||s.has(c))&&a.add(c);return[...a].sort()},{name:"affected-task-filter"})}function ct(e,t,n,r){let o=r?.defaultSeverity??"high";function d(a){let i=[];for(let c of a.lintErrors??[])i.push({source:"code-change",summary:`Lint: ${c.rule} in ${c.file}:${c.line}`,evidence:c.message,affectsAreas:[c.file],severity:o});for(let c of a.testFailures??[])i.push({source:"test",summary:`Test failure: ${c.testId}`,evidence:c.message,affectsAreas:[c.file],affectsEvalTasks:[c.testId],severity:o});return i}let s=n??d;return $([e],([a])=>{if(a!=null)for(let i of s(a))t.publish(i)},{name:r?.name??"code-change-bridge"})}function dt(e,t,n){return $([e.latest],([r])=>{r!=null&&t(r)},{name:n?.name??"notify-effect"})}var b=["auto-fix","needs-decision","investigation","backlog"],Z={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},L={critical:100,high:70,medium:40,low:10},D=Math.LN2/(168*3600);function j(e,t){return`${e}\u2192${t}`}var pt=/\b(parse|json|config|validation|syntax)\b/i,ee=e=>pt.test(e.detail)?"self-correctable":"structural",le=`You are a triage classifier for a reactive collaboration harness.
1
+ import{a as $e}from"./chunk-PYEIPRSZ.js";import{d as _e}from"./chunk-KL7CILPL.js";import{u as X}from"./chunk-YBA5N4XY.js";import{a as Me}from"./chunk-GWOKTENT.js";import{c as Ce}from"./chunk-5CZ3KIRJ.js";import{g as we,i as ue}from"./chunk-AQC53OWG.js";import{b as ie,d as U}from"./chunk-O32GJOUJ.js";import{b as Oe}from"./chunk-TZQPPQEQ.js";import{f as ke,j as Se}from"./chunk-5KPIYVCC.js";import{b as A,s as q,t as Ae,x as _}from"./chunk-JJTF75VS.js";import{m as z}from"./chunk-MQZWA3DF.js";import{D as Ne,E as S,F as Q,G as N,H as $,o as V}from"./chunk-LYCLF26R.js";import{b as P,i as F,j as W}from"./chunk-CK2E7BTU.js";import{b as Xe}from"./chunk-QYADASLV.js";var kt={};Xe(kt,{DEFAULT_DECAY_RATE:()=>D,DEFAULT_EXECUTE_PROMPT:()=>ce,DEFAULT_QUEUE_CONFIGS:()=>Z,DEFAULT_SEVERITY_WEIGHTS:()=>L,DEFAULT_TRIAGE_PROMPT:()=>le,DEFAULT_VERIFY_PROMPT:()=>de,HarnessGraph:()=>te,QUEUE_NAMES:()=>b,actuatorExecutor:()=>nt,affectedTaskFilter:()=>lt,autoSolidify:()=>ot,beforeAfterCompare:()=>ut,codeChangeBridge:()=>ct,createIntakeBridge:()=>st,defaultErrorClassifier:()=>ee,defaultLlmExecutor:()=>je,defaultLlmVerifier:()=>Ge,evalIntakeBridge:()=>at,evalSource:()=>it,evalVerifier:()=>Pe,harnessEvalPair:()=>Tt,harnessLoop:()=>vt,harnessProfile:()=>ht,harnessTrace:()=>bt,notifyEffect:()=>dt,priorityScore:()=>Et,refineExecutor:()=>pe,resolvePromptFn:()=>B,strategyKey:()=>j,strategyModel:()=>fe});function Ze(e,t){return{outcome:"success",detail:`actuator applied ${t.intervention} for ${rt(t.summary)}`,artifact:e}}function et(e,t){let n=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${t.intervention}: ${n}`}}function tt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function rt(e,t=80){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function nt(e){let t=e.name??"actuator-executor",n=e.toOutput??Ze,r=e.onError??et,o=e.skipDetail??tt;return d=>{let s=A(d,i=>i!=null,{name:`${t}/gate-in`}),a=_(s,i=>e.shouldApply&&!e.shouldApply(i)?Q(c=>(c.down([[P,{outcome:"failure",detail:o(i)}],[F]]),()=>{}),{name:`${t}/skip`}):Q(c=>{let m=new AbortController,f=!1,l=null,g=R=>{f||(f=!0,c.down([[P,R],[F]]),l?.(),l=null)},y;try{let R=e.apply(i,{signal:m.signal});y=z(R,{signal:m.signal})}catch(R){return g(r(R,i)),()=>{m.abort()}}return l=y.subscribe(R=>{for(let E of R){if(f)return;if(E[0]===P){g(n(E[1],i));return}if(E[0]===W){g(r(E[1],i));return}if(E[0]===F){g(r(new Error("actuator inner completed without emitting DATA"),i));return}}}),f&&l&&(l(),l=null),()=>{m.abort(),l?.(),l=null}},{name:`${t}/inner`}),{name:t});return A(a,i=>i!=null,{name:`${t}/gate-out`})}}function ot(e){let t=e.name??"auto-solidify",n=e.extract??(o=>o.execution.artifact??null),r=e.predicate??(()=>!0);return Q(o=>{let d=null,s=!1,a=()=>{s||(s=!0,d?.(),d=null)},i=c=>{s||(o.down([[W,c]]),a())};return d=e.verifyResults.subscribe(c=>{if(!s)for(let m of c){if(s)return;if(m[0]!==P){if(m[0]===F){o.down([[F]]),a();return}continue}let f=m[1];if(f==null||!f.verified)continue;let l;try{l=r(f)}catch(y){i(y);return}if(!l)continue;let g;try{g=n(f)}catch(y){i(y);return}if(g!=null){try{e.write(g,f)}catch(y){i(y);return}o.down([[P,g]])}}}),s&&d&&(d(),d=null),()=>{a()}},{name:t})}function st(e,t,n,r){return $([e],([o])=>{if(o==null)return;let d=n(o);for(let s of d)t.publish(s)},{name:r?.name??"intake-bridge"})}function at(e,t,n){let r=n?.defaultSeverity??"medium";return $([e],([o])=>{if(o==null)return;let d=Array.isArray(o)?o:[o];for(let s of d)for(let a of s.tasks)if(!(a.valid&&a.judge_scores?.every(i=>i.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){t.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${s.model})`,evidence:`Run ${s.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r});continue}if(a.judge_scores)for(let i of a.judge_scores)i.pass||t.publish({source:"eval",summary:`${a.task_id}: ${i.claim} (model: ${s.model})`,evidence:i.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r})}},{name:n?.name??"eval-intake-bridge"})}function it(e,t){return _(e,()=>z(t()))}function ut(e,t){return N([e,t],([n,r])=>{let o=n,d=r,s=new Map(o.tasks.map(l=>[l.task_id,l])),a=new Map(d.tasks.map(l=>[l.task_id,l])),i=new Set([...s.keys(),...a.keys()]),c=[],m=[],f=[];for(let l of i){let g=s.get(l),y=a.get(l),R=g?.valid??!1,E=y?.valid??!1,I=g?.judge_scores?g.judge_scores.filter(w=>w.pass).length:void 0,k=y?.judge_scores?y.judge_scores.filter(w=>w.pass).length:void 0,O=I!==void 0&&k!==void 0?k-I:void 0;c.push({taskId:l,before:R,after:E,scoreDiff:O}),R&&!E&&m.push(l),!R&&E&&f.push(l)}return{newFailures:m,resolved:f,taskDeltas:c,overallImproved:f.length>m.length}},{name:"eval-delta"})}function lt(e,t){let n=t==null?null:Array.isArray(t)?S(t):t,r=[e];return n&&r.push(n),N(r,o=>{let d=o[0],s=n?new Set(o[1]):null,a=new Set;for(let i of d)for(let c of i.affectsEvalTasks??[])(s==null||s.has(c))&&a.add(c);return[...a].sort()},{name:"affected-task-filter"})}function ct(e,t,n,r){let o=r?.defaultSeverity??"high";function d(a){let i=[];for(let c of a.lintErrors??[])i.push({source:"code-change",summary:`Lint: ${c.rule} in ${c.file}:${c.line}`,evidence:c.message,affectsAreas:[c.file],severity:o});for(let c of a.testFailures??[])i.push({source:"test",summary:`Test failure: ${c.testId}`,evidence:c.message,affectsAreas:[c.file],affectsEvalTasks:[c.testId],severity:o});return i}let s=n??d;return $([e],([a])=>{if(a!=null)for(let i of s(a))t.publish(i)},{name:r?.name??"code-change-bridge"})}function dt(e,t,n){return $([e.latest],([r])=>{r!=null&&t(r)},{name:n?.name??"notify-effect"})}var b=["auto-fix","needs-decision","investigation","backlog"],Z={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},L={critical:100,high:70,medium:40,low:10},D=Math.LN2/(168*3600);function j(e,t){return`${e}\u2192${t}`}var pt=/\b(parse|json|config|validation|syntax)\b/i,ee=e=>pt.test(e.detail)?"self-correctable":"structural",le=`You are a triage classifier for a reactive collaboration harness.
2
2
 
3
3
  Given an intake item, classify it and output JSON:
4
4
  {