@graphrefly/graphrefly 0.31.0 → 0.32.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.
- package/dist/chunk-2JNT5NDF.js +61 -0
- package/dist/{chunk-KN4Q5MQO.js → chunk-2RH4QNDQ.js} +1 -1
- package/dist/chunk-4JBKKUCJ.js +7 -0
- package/dist/{chunk-WLPVGXQ6.js → chunk-4YGJ7KZ6.js} +1 -1
- package/dist/{chunk-3Q2WXM6X.js → chunk-5PBXUVHI.js} +1 -1
- package/dist/{chunk-WYJTXYWX.js → chunk-7EMUF2RY.js} +1 -1
- package/dist/chunk-7JZ3YORY.js +80 -0
- package/dist/{chunk-I4U3TPK2.js → chunk-7QS77X6G.js} +1 -1
- package/dist/{chunk-ZM7C2FUM.js → chunk-BU4SUZSA.js} +1 -1
- package/dist/{chunk-GF5T7PGC.js → chunk-CNXUW2CU.js} +1 -1
- package/dist/{chunk-Z3UWIJ3A.js → chunk-EIFHFDFD.js} +1 -1
- package/dist/{chunk-3JRKP4BH.js → chunk-JAHAJU4G.js} +1 -1
- package/dist/{chunk-4ZPO2EL5.js → chunk-JYMNVEH6.js} +1 -1
- package/dist/{chunk-4KAUNEKV.js → chunk-KD3IYBTD.js} +1 -1
- package/dist/{chunk-X2VHDT26.js → chunk-LG73TUF4.js} +2 -2
- package/dist/{chunk-JXRZXP3N.js → chunk-LJGPOJHS.js} +1 -1
- package/dist/{chunk-YQJPYEAL.js → chunk-M2VFLRPJ.js} +1 -1
- package/dist/{chunk-7EQPXQ7H.js → chunk-MFNOZ5E6.js} +1 -1
- package/dist/{chunk-YZ6VYLFD.js → chunk-PWKLZ2XU.js} +1 -1
- package/dist/{chunk-OKQUPJRY.js → chunk-TOCCHQI6.js} +1 -1
- package/dist/{chunk-PZP4MEXK.js → chunk-UXEB35L4.js} +1 -1
- package/dist/{chunk-EBQ6FXKW.js → chunk-VXJX3ZZP.js} +1 -1
- package/dist/{chunk-7EJTWGKW.js → chunk-WE32AFFA.js} +1 -1
- package/dist/{chunk-JMGGCSIC.js → chunk-WF3V5X2L.js} +1 -1
- package/dist/{chunk-YZKGGMPT.js → chunk-X4OOM6QU.js} +1 -1
- package/dist/{chunk-5LJAQTSS.js → chunk-ZWETYYQG.js} +1 -1
- package/dist/compat/index.cjs +1 -1
- package/dist/compat/index.d.cts +5 -5
- package/dist/compat/index.d.ts +5 -5
- package/dist/compat/index.js +1 -1
- package/dist/compat/nestjs/index.cjs +1 -1
- package/dist/compat/nestjs/index.d.cts +3 -3
- package/dist/compat/nestjs/index.d.ts +3 -3
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/zustand/index.cjs +1 -1
- package/dist/compat/zustand/index.d.cts +2 -2
- package/dist/compat/zustand/index.d.ts +2 -2
- package/dist/compat/zustand/index.js +1 -1
- package/dist/extra/index.cjs +1 -1
- package/dist/extra/index.d.cts +2 -2
- package/dist/extra/index.d.ts +2 -2
- package/dist/extra/index.js +1 -1
- package/dist/graph/index.cjs +1 -1
- package/dist/graph/index.d.cts +3 -3
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.js +1 -1
- package/dist/{graph-CWeI0aHd.d.ts → graph-BOhEGJ6E.d.ts} +10 -0
- package/dist/{graph-C4Uxwv0T.d.cts → graph-CdJeX7O7.d.cts} +10 -0
- package/dist/{index-B-z8WaSd.d.cts → index-BDLy6CQ9.d.cts} +1 -1
- package/dist/{index-iBp74eGU.d.cts → index-BJDXj9Wf.d.cts} +2 -2
- package/dist/{index-BBINVimG.d.ts → index-BUZPTPSQ.d.ts} +2 -2
- package/dist/{index-DnrZghBB.d.ts → index-BbcSZCAG.d.ts} +1 -1
- package/dist/{index-lKuLYmHO.d.cts → index-BiGeETJs.d.cts} +1 -1
- package/dist/{index-Dm3_D5Ta.d.cts → index-BmZb8fNF.d.cts} +2 -2
- package/dist/{index-Docdiu9a.d.ts → index-Bnmttu35.d.ts} +1 -1
- package/dist/{index-CZChc85Q.d.cts → index-BuN2wGJs.d.cts} +297 -22
- package/dist/{index-Cy7eFeIX.d.cts → index-BwdPDWI4.d.cts} +1 -1
- package/dist/{index-DylQCKEL.d.cts → index-BzxU4yhV.d.cts} +11 -2
- package/dist/{index-D9Y_u6BG.d.cts → index-C-Gsh-0a.d.cts} +2 -2
- package/dist/{index-DD7RhHNJ.d.cts → index-C22aTC1X.d.cts} +4 -4
- package/dist/{index-yIdWFo2b.d.cts → index-C4QTaDli.d.cts} +2 -2
- package/dist/{index-CJymKyzT.d.ts → index-C7RqYbOZ.d.ts} +1 -1
- package/dist/{index-C5Ghnp5B.d.ts → index-C9qCLIN4.d.ts} +2 -2
- package/dist/{index-DVNLe3pS.d.cts → index-CCdg0JLX.d.cts} +1 -1
- package/dist/{index-B5iVOD7w.d.ts → index-CEoU-r-g.d.ts} +2 -2
- package/dist/{index-CfFYyLR8.d.ts → index-CHfBm51k.d.ts} +11 -2
- package/dist/{index-BXzl1NDD.d.ts → index-CNyiYQWF.d.ts} +4 -4
- package/dist/{index-C6NBfXj-.d.ts → index-CVevMZ0n.d.ts} +2 -2
- package/dist/{index-DGb1awva.d.ts → index-CZUzi6Dy.d.ts} +2 -2
- package/dist/{index-FrYrV-Vf.d.ts → index-Ckl03Q0s.d.ts} +1 -1
- package/dist/{index-Bvi5uJxX.d.ts → index-CmSjld-4.d.ts} +1 -1
- package/dist/{index-9iguV3bF.d.cts → index-CnjUhRbs.d.cts} +2 -2
- package/dist/{index-C98oJsEs.d.cts → index-D3HcdZ4d.d.cts} +1 -1
- package/dist/{index-IZ3l_vQ9.d.ts → index-DD1czHj3.d.ts} +1 -1
- package/dist/{index-gJQqJTKx.d.cts → index-DNhTQReY.d.cts} +1 -1
- package/dist/{index-UZO988ox.d.cts → index-DSawGt8n.d.cts} +2 -2
- package/dist/{index-CcpEvuPl.d.cts → index-DUkuH3jP.d.cts} +1 -1
- package/dist/{index-CRAkoq-y.d.cts → index-DY2QbdoP.d.cts} +1 -1
- package/dist/{index-CvS9IuTG.d.ts → index-Dbmj0iYR.d.ts} +1 -1
- package/dist/{index-Bd6oFZqO.d.ts → index-DhlAMlm9.d.ts} +297 -22
- package/dist/{index-BMe3pCom.d.cts → index-DlGaEBW5.d.cts} +2 -2
- package/dist/{index-CotRMjtJ.d.ts → index-Dp_pS7Bw.d.ts} +1 -1
- package/dist/{index-DxMS0cHM.d.ts → index-Dxk-pUQI.d.ts} +2 -2
- package/dist/{index-DBQUKh59.d.cts → index-EGjF6iSY.d.cts} +3 -3
- package/dist/{index-D9HrBx2J.d.ts → index-LGzAYqdR.d.ts} +1 -1
- package/dist/{index-DR3gf_DG.d.cts → index-LzCJ0kMT.d.cts} +2 -2
- package/dist/{index-RQg6lTrN.d.ts → index-MV2yGIAq.d.ts} +2 -2
- package/dist/{index-Bs3-LC83.d.cts → index-_BXz9K7b.d.cts} +1 -1
- package/dist/{index-SSGqF8mI.d.cts → index-aBqZUx3B.d.cts} +1 -1
- package/dist/{index-CFW32Dy1.d.ts → index-eYHRkoK-.d.ts} +1 -1
- package/dist/{index-CwhcFzTA.d.ts → index-gXTVbSax.d.ts} +2 -2
- package/dist/{index-D-kHVedZ.d.cts → index-j33Lfb1G.d.cts} +22 -1
- package/dist/{index-BEpRsvhg.d.ts → index-lpGUhTBn.d.ts} +3 -3
- package/dist/{index-CcS0t-l2.d.ts → index-zMQIQuDu.d.ts} +22 -1
- package/dist/index.cjs +53 -50
- package/dist/index.d.cts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/index.js +1 -1
- package/dist/patterns/ai/index.cjs +21 -18
- package/dist/patterns/ai/index.d.cts +6 -6
- package/dist/patterns/ai/index.d.ts +6 -6
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/audit/index.cjs +1 -1
- package/dist/patterns/audit/index.d.cts +3 -3
- package/dist/patterns/audit/index.d.ts +3 -3
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +1 -1
- package/dist/patterns/cqrs/index.d.cts +2 -2
- package/dist/patterns/cqrs/index.d.ts +2 -2
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +1 -1
- package/dist/patterns/demo-shell/index.d.cts +3 -3
- package/dist/patterns/demo-shell/index.d.ts +3 -3
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.cjs +5 -5
- package/dist/patterns/domain-templates/index.d.cts +2 -2
- package/dist/patterns/domain-templates/index.d.ts +2 -2
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.cjs +27 -25
- package/dist/patterns/graphspec/index.d.cts +2 -2
- package/dist/patterns/graphspec/index.d.ts +2 -2
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +5 -5
- package/dist/patterns/guarded-execution/index.d.cts +4 -4
- package/dist/patterns/guarded-execution/index.d.ts +4 -4
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +12 -11
- package/dist/patterns/harness/index.d.cts +5 -5
- package/dist/patterns/harness/index.d.ts +5 -5
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +1 -1
- package/dist/patterns/job-queue/index.d.cts +2 -2
- package/dist/patterns/job-queue/index.d.ts +2 -2
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +1 -1
- package/dist/patterns/lens/index.d.cts +3 -3
- package/dist/patterns/lens/index.d.ts +3 -3
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +1 -1
- package/dist/patterns/memory/index.d.cts +2 -2
- package/dist/patterns/memory/index.d.ts +2 -2
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +1 -1
- package/dist/patterns/messaging/index.d.cts +2 -2
- package/dist/patterns/messaging/index.d.ts +2 -2
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +7 -7
- package/dist/patterns/orchestration/index.d.cts +2 -2
- package/dist/patterns/orchestration/index.d.ts +2 -2
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +1 -1
- package/dist/patterns/reactive-layout/index.d.cts +3 -3
- package/dist/patterns/reactive-layout/index.d.ts +3 -3
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.cjs +1 -1
- package/dist/patterns/reduction/index.d.cts +2 -2
- package/dist/patterns/reduction/index.d.ts +2 -2
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.cjs +3 -3
- package/dist/patterns/refine-loop/index.d.cts +3 -3
- package/dist/patterns/refine-loop/index.d.ts +3 -3
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.d.cts +3 -3
- package/dist/patterns/resilient-pipeline/index.d.ts +3 -3
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +15 -13
- package/dist/patterns/surface/index.d.cts +3 -3
- package/dist/patterns/surface/index.d.ts +3 -3
- package/dist/patterns/surface/index.js +1 -1
- package/dist/{reactive-layout-BAr6-_o5.d.ts → reactive-layout-Bq0rA2Wb.d.ts} +1 -1
- package/dist/{reactive-layout-5oEn8lHM.d.cts → reactive-layout-Dhhe54Oj.d.cts} +1 -1
- package/dist/{topology-tree-CVREibAc.d.cts → topology-tree-CpSjvIXp.d.cts} +1 -1
- package/dist/{topology-tree-CkjojcB6.d.ts → topology-tree-DAbCV2Yw.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-ASDKRNOJ.js +0 -60
- package/dist/chunk-PSQNYY72.js +0 -7
- package/dist/chunk-XEFAMCEA.js +0 -78
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as ce}from"./chunk-
|
|
1
|
+
import{c as ce}from"./chunk-EIFHFDFD.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-4JBKKUCJ.js";import{f as ae,h as ie}from"./chunk-UMH3HSP7.js";import{i as ne,j as U}from"./chunk-7AJKUA36.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{c as R}from"./chunk-K54OKWNY.js";import{b as N}from"./chunk-XRSHMHEG.js";import{j as k}from"./chunk-
|
|
1
|
+
import{c as R}from"./chunk-K54OKWNY.js";import{b as N}from"./chunk-XRSHMHEG.js";import{j as k}from"./chunk-4JBKKUCJ.js";import{B as g}from"./chunk-UMH3HSP7.js";import{D as T,E as S,G as y,m as q,p as w,t as u}from"./chunk-7AJKUA36.js";import{b as A}from"./chunk-QYADASLV.js";var P={};A(P,{CqrsGraph:()=>h,MemoryEventStore:()=>_,cqrs:()=>O});var j=u((i,e)=>{i("write"),i("signal"),e("observe")}),D=u((i,e)=>{i("observe"),i("signal"),e("write")}),H=u((i,e)=>{i("observe"),i("signal"),e("write")});function m(i,e){return R("cqrs",i,e)}var _=class{_store=new Map;persist(e){let t=this._store.get(e.type);t||(t=[],this._store.set(e.type,t)),t.push(e)}loadEvents(e,t){let n=this._store.get(e)??[],r=t?.timestampNs,s=t?.seq,o=r==null?[...n]:n.filter(d=>d.timestampNs>r||d.timestampNs===r&&d.seq>(s??-1)),a=o.length>0?o[o.length-1]:void 0;return{events:o,cursor:a?{timestampNs:a.timestampNs,seq:a.seq}:t}}clear(){this._store.clear()}},h=class extends k{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,t={}){super(e,t.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let t=this._eventLogs.get(e);if(t)return t.node;let n=N([],{name:e,versioning:0}),r=n.entries,s=y([r],([o])=>o,{name:e,describeKind:"state",meta:m("event",{event_name:e}),guard:H,initial:r.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(g(s)),this._eventLogs.set(e,{log:n,node:s}),s}_appendEvent(e,t){let n=this._eventLogs.get(e);if(n||(this.event(e),n=this._eventLogs.get(e)),n.node.status==="completed"||n.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${n.node.status}).`);let r=n.log.entries.v,s={type:e,payload:t,timestampNs:w(),seq:++this._seq,...r!=null?{v0:{id:r.id,version:r.version}}:{}};n.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,t){let n=S(void 0,{name:e,describeKind:"state",meta:{...m("command",{command_name:e}),error:null},guard:j});return this.add(n,{name:e}),this._commandHandlers.set(e,t),n}dispatch(e,t){let n=this._commandHandlers.get(e);if(!n)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let r=this.resolve(e);q(()=>{r.emit(t,{internal:!0});try{n(t,{emit:(s,o)=>this._appendEvent(s,o)}),r.meta.error.emit(null,{internal:!0})}catch(s){throw r.meta.error.emit(s,{internal:!0}),s}})}projection(e,t,n,r){let s=t.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),o=y(s,a=>{let d=[];for(let v of a){let p=v;d.push(...p)}return d.sort((v,p)=>v.timestampNs-p.timestampNs||v.seq-p.seq),n(r,d)},{name:e,describeKind:"derived",meta:m("projection",{projection_name:e,source_events:t}),guard:D,initial:r});return this.add(o,{name:e}),this._keepaliveDisposers.push(g(o)),this._projections.add(e),o}saga(e,t,n){let r=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node)),s=new Map,o={},a=T(r,(d,v)=>{let p=o.n.meta.error;for(let c=0;c<d.length;c++){let E=d[c];if(E==null||E.length===0)continue;let l=E.at(-1);if(!l)continue;let f=t[c],C=s.get(f)??0;if(l.length>C){let b=l.slice(C);for(let L of b)try{n(L),p.emit(null,{internal:!0})}catch(x){p.emit(x,{internal:!0})}s.set(f,l.length)}}},{name:e,describeKind:"effect",meta:{...m("saga",{saga_name:e,source_events:t}),error:null}});return o.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(g(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,t,n){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let r=[];for(let s of e){let o=await this._eventStore.loadEvents(s);r.push(...o.events)}return r.sort((s,o)=>s.timestampNs-o.timestampNs||s.seq-o.seq),t(n,r)}};function O(i,e){return new h(i,e)}export{_ as a,h as b,O as c,P as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n}from"./chunk-
|
|
1
|
+
import{d as n}from"./chunk-PWKLZ2XU.js";import{j as a}from"./chunk-4JBKKUCJ.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{j as f}from"./chunk-
|
|
1
|
+
import{j as f}from"./chunk-4JBKKUCJ.js";import{E as d}from"./chunk-7AJKUA36.js";import{b as S}from"./chunk-CK2E7BTU.js";import{b}from"./chunk-QYADASLV.js";var g={};b(g,{create:()=>v});var m=()=>!1;function v(l){let o=new f("zustand"),t=d(void 0,{name:"state",equals:m});o.add(t,{name:"state"});let r=()=>t.cache,n=(e,s)=>{let a=t.cache,i=typeof e=="function"?e(a):e;t.emit(s?i:{...a,...i})},c={getState:r,setState:n,getInitialState:()=>T,subscribe:e=>{let s=!0,a=t.cache;return t.subscribe(i=>{for(let[u,p]of i)if(u===S){if(s){s=!1;continue}e(p,a),a=p}})},destroy:o.destroy.bind(o)},T=l(n,r,c);return t.emit(T),Object.assign(o,c)}export{v as a,g as b};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{f as he}from"./chunk-
|
|
1
|
+
import{f as he}from"./chunk-VXJX3ZZP.js";import{j as fe}from"./chunk-4JBKKUCJ.js";import{x as ye}from"./chunk-WQ7I7JVU.js";import{D as be,E as T,G as v,H as q,m as ee,o as z}from"./chunk-7AJKUA36.js";import{b as P,j as Z}from"./chunk-CK2E7BTU.js";import{b as Ne}from"./chunk-QYADASLV.js";var we={};Ne(we,{blindVariation:()=>De,errorCritique:()=>Re,refineLoop:()=>Se});function Ie(n){if(typeof n!="object"||n===null)return!1;let l=n;return typeof l.subscribe=="function"&&typeof l.down=="function"&&typeof l.emit=="function"}function pe(n,l){if(n.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(n.length===1){let e=ne(l);return{best:n[0],bestScore:e}}if(l.some(e=>typeof e.candidateIndex=="number")){let e=new Array(n.length);for(let i=0;i<n.length;i++)e[i]={sum:0,count:0};for(let i of l){let d=i.candidateIndex;typeof d=="number"&&d>=0&&d<n.length&&(e[d].sum+=i.score,e[d].count+=1)}let s=n[0],o=e[0].count>0?e[0].sum/e[0].count:Number.NEGATIVE_INFINITY;for(let i=1;i<n.length;i++){let d=e[i].count>0?e[i].sum/e[i].count:Number.NEGATIVE_INFINITY;d>o&&(o=d,s=n[i])}return{best:s,bestScore:o}}let t=n[0],m=l[0]?.score??Number.NEGATIVE_INFINITY;for(let e=1;e<n.length;e++){let s=l[e]?.score??Number.NEGATIVE_INFINITY;s>m&&(m=s,t=n[e])}return{best:t,bestScore:m}}function ne(n){if(n.length===0)return Number.NEGATIVE_INFINITY;let l=0;for(let x of n)l+=x.score;return l/n.length}function Se(n,l,x,t){let m=t.name??"refine-loop",e=new fe(m,t.graph),s=Ie(t.dataset)?t.dataset:T(t.dataset,{name:"dataset"});e.add(s,{name:"dataset"});let o=T(0,{name:"iteration"});e.add(o,{name:"iteration"});let i=T(x,{name:"strategy",equals:()=>!1});e.add(i,{name:"strategy"});let d=T(null,{name:"lastFeedback"});e.add(d,{name:"lastFeedback"});let k=T([],{name:"prevCandidates"});e.add(k,{name:"prevCandidates"});let y=T(!1,{name:"paused"});e.add(y,{name:"paused"});let b=T("running",{name:"status"});e.add(b,{name:"status"});let E=T([],{name:"history",equals:()=>!1});e.add(E,{name:"history"});let h=T(null,{name:"best"});e.add(h,{name:"best"});let N=T(Number.NEGATIVE_INFINITY,{name:"score"});e.add(N,{name:"score"});let C=T(0,{name:"budget-used"});e.add(C,{name:"budget-used"});let R=he("stages");e.mount("stages",R);let A=R.topic("generate"),p=R.topic("evaluate"),G=R.topic("analyze"),te=R.topic("decide"),$=x,B=null,re=[];e.addDisposer(i.subscribe(r=>{for(let a of r)a[0]===P&&($=a[1])})),e.addDisposer(d.subscribe(r=>{for(let a of r)a[0]===P&&(B=a[1])})),e.addDisposer(k.subscribe(r=>{for(let a of r)a[0]===P&&(re=a[1])}));let I=ye(o,r=>{let a=$,c=r===0||B==null;return be([],(u,f)=>{let S=!1;try{let D=c?a.seed(n):a.generate(B,re);if(D instanceof Promise)return D.then(_=>{S||f.emit(_)},_=>{S||f.down([[Z,_]])}),()=>{S=!0};f.emit(D)}catch(D){S=!0,f.down([[Z,D]])}},{describeKind:"producer"})},{name:"candidates"});e.add(I,{name:"candidates"});let ae=q([I],(r,a,c)=>{let u=c.terminalDeps[0];u!==void 0&&u!==!0&&b.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});e.add(ae,{name:"error-watcher"}),e.addDisposer(ae.subscribe(()=>{}));let Y=v([I,o],([r,a])=>({iteration:a,candidates:r,timestamp_ns:z()}),{name:"generate-event"});e.add(Y,{name:"generate-event"}),e.addDisposer(Y.subscribe(()=>{}));let oe=q([Y],([r])=>{A.publish(r)},{name:"generate-publish"});e.add(oe,{name:"generate-publish"}),e.addDisposer(oe.subscribe(()=>{}));let ie=q([I],([r])=>{k.emit(r)},{name:"generate-mirror"});e.add(ie,{name:"generate-mirror"}),e.addDisposer(ie.subscribe(()=>{}));let V=l(I,s);e.add(V,{name:"scores"});let j=v([V,I,o],([r,a,c])=>({iteration:c,candidates:a,scores:r,timestamp_ns:z()}),{name:"evaluate-event"});e.add(j,{name:"evaluate-event"}),e.addDisposer(j.subscribe(()=>{}));let se=q([j],([r])=>{p.publish(r)},{name:"evaluate-publish"});e.add(se,{name:"evaluate-publish"}),e.addDisposer(se.subscribe(()=>{}));let L=v([V,I],([r,a])=>$.analyze(r,a),{name:"feedback"});e.add(L,{name:"feedback"});let M=v([L,I,o],([r,a,c])=>({iteration:c,candidates:a,feedback:r,timestamp_ns:z()}),{name:"analyze-event"});e.add(M,{name:"analyze-event"}),e.addDisposer(M.subscribe(()=>{}));let de=q([M],([r])=>{G.publish(r)},{name:"analyze-publish"});e.add(de,{name:"analyze-publish"}),e.addDisposer(de.subscribe(()=>{}));let H=v([E],([r])=>{let a=r;if(t.patience==null||a.length<=t.patience)return!1;let c=a.slice(-(t.patience+1)),u=c[0].bestScore;return c.slice(1).every(f=>f.bestScore<=u)},{name:"patience-check"});e.add(H,{name:"patience-check"});let W=v([N],([r])=>t.minScore!=null&&r>=t.minScore,{name:"min-score-check"});e.add(W,{name:"min-score-check"});let K=v([E],([r])=>{let a=r;if(t.minDelta==null||a.length<2)return!1;let c=a[a.length-2].bestScore,u=a[a.length-1].bestScore;return Math.abs(u-c)<t.minDelta},{name:"min-delta-check"});e.add(K,{name:"min-delta-check"});let U=v([C],([r])=>t.maxEvaluations!=null&&r>=t.maxEvaluations,{name:"max-evaluations-check"});e.add(U,{name:"max-evaluations-check"});let J=v([o],([r])=>t.maxIterations!=null&&r>=t.maxIterations,{name:"max-iterations-check"});e.add(J,{name:"max-iterations-check"});let le=v([C],([r])=>t.budget!=null&&r>=t.budget,{name:"budget-exhausted-check"});e.add(le,{name:"budget-exhausted-check"}),e.addDisposer(H.subscribe(()=>{})),e.addDisposer(W.subscribe(()=>{})),e.addDisposer(K.subscribe(()=>{})),e.addDisposer(U.subscribe(()=>{})),e.addDisposer(J.subscribe(()=>{})),e.addDisposer(le.subscribe(()=>{}));let ce=v([H,W,K,U,J],([r,a,c,u,f])=>r?{converged:!0,reason:"patience"}:a?{converged:!0,reason:"min-score"}:c?{converged:!0,reason:"min-delta"}:u?{converged:!0,reason:"max-evaluations"}:f?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});e.add(ce,{name:"converged"}),e.addDisposer(ce.subscribe(()=>{}));let ue=-1,me=q([L,V,I],([r,a,c])=>{let u=o.cache,f=r,S=c,D=a;if(u<=ue)return;ue=u;let{best:_,bestScore:ge}=pe(S,D),Te=E.cache,ve={n:u,candidates:S,scores:D,feedback:f,best:_,bestScore:ge,timestamp_ns:z()},F=[...Te,ve],Q=C.cache+S.length,g="continue",w,Ee=t.budget!=null&&Q>=t.budget,ke=y.cache;if(Ee)g="budget",w="budget";else if(t.minScore!=null&&f.score>=t.minScore)g="converged",w="min-score";else if(t.maxIterations!=null&&u>=t.maxIterations)g="converged",w="max-iterations";else if(t.maxEvaluations!=null&&Q>=t.maxEvaluations)g="converged",w="max-evaluations";else if(t.minDelta!=null&&F.length>=2){let O=F[F.length-2].bestScore,X=F[F.length-1].bestScore;Math.abs(X-O)<t.minDelta&&(g="converged",w="min-delta")}else if(t.patience!=null&&F.length>t.patience){let O=F.slice(-(t.patience+1)),X=O[0].bestScore;O.slice(1).every(xe=>xe.bestScore<=X)&&(g="converged",w="patience")}g==="continue"&&ke&&(g="paused"),ee(()=>{h.emit(_),N.emit(f.score),E.emit(F),C.emit(Q),d.emit(f),te.publish({iteration:u,decision:g,reason:w,timestamp_ns:z()}),g==="continue"?o.emit(u+1):b.emit(g==="converged"?"converged":g==="budget"?"budget":"paused")})},{name:"decide-bridge"});return e.add(me,{name:"decide-bridge"}),e.addDisposer(me.subscribe(()=>{})),Object.assign(e,{best:h,score:N,status:b,history:E,strategy:i,iteration:o,generate:A,evaluate:p,analyze:G,decide:te,setStrategy(r){i.emit(r)},pause(){y.emit(!0)},resume(){b.cache==="paused"&&ee(()=>{y.emit(!1),b.emit("running"),o.emit(o.cache+1)})}})}function De(n){let l=n.width??4;return{name:n.name??"blindVariation",seed(t){return[t]},analyze(t,m){let e=ne(t),s=null;for(let o of t)(!s||o.score<s.score)&&(s=o);return{summary:`blindVariation iteration: mean=${e.toFixed(3)}, n=${t.length}`,score:e,weakTasks:s?[s.taskId]:[]}},async generate(t,m){if(m.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let e=m[m.length-1],s=0,i={prior:e,reportCost:d=>{s+=d}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(i)));let d=[];for(let k=0;k<l;k++)d.push(await n.teacher(i));return d}finally{if(n.tokens!=null&&s>0){let d=n.tokens.cache??0;n.tokens.emit(d+s)}}}}}function Fe(n){return typeof n=="object"&&n!==null&&n.kind==="errorCritique"}function Ce(n,l){return n.length===0?`No task scored below the batch mean (${l.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
|
|
2
2
|
${n.map(t=>{let m=t.error!=null?` | error: ${t.error}`:"";return`- ${t.taskId} (score=${t.score.toFixed(3)})${m}`}).join(`
|
|
3
3
|
`)}`}function Re(n){let l=n.width??4,x=n.name??"errorCritique",t=n.maxFailureSamples??5,m=n.formatCritique??Ce;return{name:x,seed(e){return[e]},analyze(e,s){let o=ne(e),i=typeof n.failureThreshold=="function"?n.failureThreshold(e):n.failureThreshold,d=i===void 0&&!Number.isFinite(o),k=i??o,y=d?[...e].sort((p,G)=>p.score-G.score):e.filter(p=>p.score<k).slice().sort((p,G)=>p.score-G.score),b=y.slice(0,t),{best:E,bestScore:h}=pe(s,e),N={summary:"",score:o,weakTasks:b.map(p=>p.taskId)},C=m(b,N),R={kind:"errorCritique",best:E,failures:b,critiqueText:C},A=y.length>b.length?` (top ${b.length} retained)`:"";return{summary:`errorCritique iteration: mean=${o.toFixed(3)}, failures=${y.length}${A}/${e.length}, bestScore=${h.toFixed(3)}`,critique:R,weakTasks:b.map(p=>p.taskId),score:o}},async generate(e,s){if(s.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let o=Fe(e.critique)?e.critique:void 0,i=o!==void 0?o.best:s[s.length-1],d=o?.critiqueText??e.summary,k=o?.failures??[],y=0,E={prior:i,critique:d,failures:k,reportCost:h=>{y+=h}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(E)));let h=[];for(let N=0;N<l;N++)h.push(await n.teacher(E));return h}finally{if(n.tokens!=null&&y>0){let h=n.tokens.cache??0;n.tokens.emit(h+y)}}}}}export{Se as a,De as b,Re as c,we as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as me}from"./chunk-
|
|
1
|
+
import{a as me}from"./chunk-KD3IYBTD.js";import{u as Q}from"./chunk-2JNT5NDF.js";import{a as pe}from"./chunk-TOCCHQI6.js";import{e as fe}from"./chunk-ZWETYYQG.js";import{a as M}from"./chunk-VXJX3ZZP.js";import{b as J,d as K}from"./chunk-K54OKWNY.js";import{b as de}from"./chunk-LWGLBCMU.js";import{f as le,j as Y}from"./chunk-4JBKKUCJ.js";import{b as A,s as G,t as ce,x as $}from"./chunk-WQ7I7JVU.js";import{m as ue}from"./chunk-UMH3HSP7.js";import{D as ie,E as b,G as k,H as C,o as L}from"./chunk-7AJKUA36.js";import{b as Ie}from"./chunk-QYADASLV.js";var Ye={};Ie(Ye,{DEFAULT_DECAY_RATE:()=>X,DEFAULT_QUEUE_CONFIGS:()=>Z,DEFAULT_SEVERITY_WEIGHTS:()=>z,HarnessGraph:()=>U,QUEUE_NAMES:()=>N,affectedTaskFilter:()=>Oe,beforeAfterCompare:()=>we,codeChangeBridge:()=>Ce,createIntakeBridge:()=>be,defaultErrorClassifier:()=>W,defaultLlmExecutor:()=>ge,defaultLlmVerifier:()=>ye,evalIntakeBridge:()=>Ne,evalSource:()=>Se,evalVerifier:()=>Le,harnessLoop:()=>Fe,harnessProfile:()=>De,harnessTrace:()=>Be,notifyEffect:()=>_e,priorityScore:()=>Ge,refineExecutor:()=>Qe,strategyKey:()=>P,strategyModel:()=>ee});function be(t,e,r,n){return C([t],([a])=>{if(a==null)return;let d=r(a);for(let i of d)e.publish(i)},{name:n?.name??"intake-bridge"})}function Ne(t,e,r){let n=r?.defaultSeverity??"medium";return C([t],([a])=>{if(a==null)return;let d=Array.isArray(a)?a:[a];for(let i of d)for(let o of i.tasks)if(!(o.valid&&o.judge_scores?.every(s=>s.pass))){if(!o.valid&&(!o.judge_scores||o.judge_scores.length===0)){e.publish({source:"eval",summary:`Task ${o.task_id} invalid (model: ${i.model})`,evidence:`Run ${i.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[o.task_id],severity:n});continue}if(o.judge_scores)for(let s of o.judge_scores)s.pass||e.publish({source:"eval",summary:`${o.task_id}: ${s.claim} (model: ${i.model})`,evidence:s.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[o.task_id],severity:n})}},{name:r?.name??"eval-intake-bridge"})}function Se(t,e){return $(t,()=>ue(e()))}function we(t,e){return k([t,e],([r,n])=>{let a=r,d=n,i=new Map(a.tasks.map(c=>[c.task_id,c])),o=new Map(d.tasks.map(c=>[c.task_id,c])),s=new Set([...i.keys(),...o.keys()]),u=[],f=[],l=[];for(let c of s){let m=i.get(c),I=o.get(c),g=m?.valid??!1,E=I?.valid??!1,T=m?.judge_scores?m.judge_scores.filter(j=>j.pass).length:void 0,h=I?.judge_scores?I.judge_scores.filter(j=>j.pass).length:void 0,S=T!==void 0&&h!==void 0?h-T:void 0;u.push({taskId:c,before:g,after:E,scoreDiff:S}),g&&!E&&f.push(c),!g&&E&&l.push(c)}return{newFailures:f,resolved:l,taskDeltas:u,overallImproved:l.length>f.length}},{name:"eval-delta"})}function Oe(t,e){let r=e==null?null:Array.isArray(e)?b(e):e,n=[t];return r&&n.push(r),k(n,a=>{let d=a[0],i=r?new Set(a[1]):null,o=new Set;for(let s of d)for(let u of s.affectsEvalTasks??[])(i==null||i.has(u))&&o.add(u);return[...o].sort()},{name:"affected-task-filter"})}function Ce(t,e,r,n){let a=n?.defaultSeverity??"high";function d(o){let s=[];for(let u of o.lintErrors??[])s.push({source:"code-change",summary:`Lint: ${u.rule} in ${u.file}:${u.line}`,evidence:u.message,affectsAreas:[u.file],severity:a});for(let u of o.testFailures??[])s.push({source:"test",summary:`Test failure: ${u.testId}`,evidence:u.message,affectsAreas:[u.file],affectsEvalTasks:[u.testId],severity:a});return s}let i=r??d;return C([t],([o])=>{if(o!=null)for(let s of i(o))e.publish(s)},{name:n?.name??"code-change-bridge"})}function _e(t,e,r){return C([t.latest],([n])=>{n!=null&&e(n)},{name:r?.name??"notify-effect"})}function Ae(t){if(t.length===0)return Number.NEGATIVE_INFINITY;let e=0;for(let r of t)e+=r.score;return e/t.length}function $e(t){let{passCount:e,total:r,meanScore:n,threshold:a,missingArtifact:d}=t,i=Number.isFinite(n)?n.toFixed(3):String(n),o=!d&&r>0&&n>=a,s=d?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:o?[`${e}/${r} eval tasks passed; mean score ${i} \u2265 ${a}`]:r===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${e}/${r} eval tasks passed; mean score ${i} < threshold ${a}`];return o?{verified:!0,findings:s}:{verified:!1,findings:s,errorClass:"structural"}}function Ve(t){return t.artifact}function Le(t){let e=t.name??"eval-verifier",r=t.threshold??.5,n=t.toOutput??$e,a=t.extractArtifact??Ve;return d=>{let i=A(d,s=>s!=null&&s[0]!=null&&s[1]!=null),o=$(i,([s,u])=>{let f=a(s,u);if(f==null)return b(n({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:r,missingArtifact:!0}));let l=b([f],{name:`${e}/candidates`}),c=b(t.datasetFor(u),{name:`${e}/dataset`}),m=t.evaluator(l,c);return k([m],([I])=>{let g=I;if(g==null)return null;let E=Ae(g),T=g.filter(h=>h.score>=r).length;return n({scores:g,meanScore:E,passCount:T,total:g.length,threshold:r})},{name:`${e}/output`})},{name:e});return A(o,s=>s!=null)}}var N=["auto-fix","needs-decision","investigation","backlog"];function P(t,e){return`${t}\u2192${e}`}function W(t){let e=t.detail.toLowerCase();return e.includes("parse")||e.includes("json")||e.includes("config")||e.includes("validation")||e.includes("syntax")?"self-correctable":"structural"}var z={critical:100,high:70,medium:40,low:10},X=Math.LN2/(168*3600),Z={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1,startOpen:!1}};function ee(){let t=de({name:"strategy-entries"}),e=k([t.entries],([i])=>{let o=i;return new Map(o)},{name:"strategy-model",equals:(i,o)=>{let s=i,u=o;if(s.size!==u.size)return!1;for(let[f,l]of s){let c=u.get(f);if(!c||l.attempts!==c.attempts||l.successes!==c.successes)return!1}return!0}});function r(i,o,s){let u=P(i,o),f=t.get(u),l=(f?.attempts??0)+1,c=(f?.successes??0)+(s?1:0);t.set(u,{rootCause:i,intervention:o,attempts:l,successes:c,successRate:c/l})}function n(i,o){return t.get(P(i,o))}let a=e.subscribe(()=>{});function d(){a()}return{node:e,record:r,lookup:n,dispose:d}}function Ge(t,e,r,n,a){let d={...z,...a?.severityWeights},i=a?.decayRate??X,o=a?.effectivenessThreshold??.7,s=a?.effectivenessBoost??15,u=[t,e,r];return n&&u.push(n),k(u,f=>{let l=f[0],c=f[1],m=f[2],I=n?f[3]:0,g=d[l.severity??"medium"],E=(L()-m)/1e9,T=pe(g,E,i,0),h=P(l.rootCause,l.intervention),S=c.get(h);return S&&S.successRate>=o&&(T+=s),T+=I*20,T},{name:"priority-score"})}var Me=`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
|
{
|
|
@@ -39,5 +39,5 @@ Output JSON:
|
|
|
39
39
|
"verified": true/false,
|
|
40
40
|
"findings": ["<finding1>", ...],
|
|
41
41
|
"errorClass": "self-correctable" | "structural" // only if verified=false
|
|
42
|
-
}`;function ge(t,e){let r=e??(n=>Pe.replace("{{item}}",JSON.stringify(n)));return n=>Q(t,[n],r,{name:"execute",format:"json"
|
|
42
|
+
}`;function ge(t,e){let r=e??(n=>Pe.replace("{{item}}",JSON.stringify(n)));return n=>Q(t,[n],r,{name:"execute",format:"json"})}function ye(t,e){let r=e??(n=>{let[a,d]=n;return je.replace("{{execution}}",JSON.stringify(a)).replace("{{item}}",JSON.stringify(d))});return n=>Q(t,[n],r,{name:"verify",format:"json"})}var U=class extends Y{intake;queues;gates;strategy;verifyResults;totalRetries;totalReingestions;constructor(e,r,n,a,d,i,o,s){super(e),this.intake=r,this.queues=n,this.gates=a,this.strategy=d,this.verifyResults=i,this.totalRetries=o,this.totalReingestions=s}};function Fe(t,e){let r=e.adapter,n=e.maxRetries??2,a=e.retainedLimit??1e3,d=e.errorClassifier??W,i=new Map;for(let p of N)i.set(p,{...Z[p],...e.queues?.[p]});let o=new M("intake",{retainedLimit:a}),s=ee(),u=G(o.latest,s.node),f=Q(r,[u],e.triagePrompt??(p=>{let[x,R]=p;return x?Me.replace("{{strategy}}",JSON.stringify(Array.from(R.entries()))).replace("{{item}}",JSON.stringify(x)):""}),{name:"triage",format:"json"}),l=new Map;for(let p of N)l.set(p,new M(`queue/${p}`,{retainedLimit:a}));let c=G(f,u),I=C([c],([p])=>{if(p==null)return;let[x,R]=p;if(!x?.route)return;let _=R?.[0],w={...x,..._},D=l.get(w.route);D&&D.publish(w)}).subscribe(()=>{}),g=new Y("gates"),E=new Map;for(let p of N){let x=i.get(p),R=l.get(p);if(x.gated){g.add(R.latest,{name:`${p}/source`});let _=fe(g,`${p}/gate`,`${p}/source`,{maxPending:x.maxPending,startOpen:x.startOpen});E.set(p,_)}}let T=new M("retry-input",{retainedLimit:a}),h=[];for(let p of N)i.get(p).gated&&E.has(p)?h.push(E.get(p).node):h.push(l.get(p).latest);h.push(T.latest);let S=ce(...h),te=(e.executor??ge(r,e.executePrompt))(S),re=G(te,S),F=new M("verify-results",{retainedLimit:a}),ne=(e.verifier??ye(r,e.verifyPrompt))(re),xe=G(ne,re),oe=e.maxReingestions??1,Ee=Math.min(e.maxTotalRetries??n*10,100),Te=Math.min(e.maxTotalReingestions??oe*10,100),se=b(0),ae=b(0),he=ie([xe],(p,x)=>{let R=p[0];if(R==null||R.length===0)return;let _=R[R.length-1];if(_==null)return;let[w,D]=_,[B,y]=D??[null,null];if(!w||!y)return;let Re={item:y,outcome:B?.outcome??"failure",detail:B?.detail??"unknown",artifact:B?.artifact},O={item:y,execution:Re,verified:w.verified,findings:w.findings??[],errorClass:w.errorClass};if(O.verified){s.record(y.rootCause,y.intervention,!0),F.publish(O);return}let ke=O.errorClass??d({item:y,outcome:"failure",detail:O.findings.join("; ")}),q=y._retries??0;if(ke==="self-correctable"&&q<n&&J(se,Ee)){let V=K(y),H={...y,_retries:q+1,summary:`[RETRY ${q+1}/${n}] ${V} \u2014 Previous attempt failed: ${O.findings.join("; ")}`,relatedTo:[V]};T.publish(H)}else{s.record(y.rootCause,y.intervention,!1),F.publish(O);let V=K(y),H=y._reingestions??0;H<oe&&J(ae,Te)&&o.publish({source:"eval",summary:`Verification failed for: ${V}`,evidence:O.findings.join(`
|
|
43
43
|
`),affectsAreas:y.affectsAreas,affectsEvalTasks:y.affectsEvalTasks,severity:"high",relatedTo:[V],_reingestions:H+1})}}).subscribe(()=>{}),v=new U(t,o,l,E,s,F,se,ae);v.addDisposer(I),v.addDisposer(he),v.addDisposer(s.dispose),v.add(f,{name:"triage"}),v.add(te,{name:"execute"}),v.add(ne,{name:"verify"}),v.add(s.node,{name:"strategy"}),v.mount("intake",o);for(let[p,x]of l)v.mount(`queue/${p}`,x);return v.mount("gates",g),v.mount("retry-input",T),v.mount("verify-results",F),v}function De(t,e){let r=le(t,e),n={};for(let[a,d]of t.queues)n[a]=d.retained().length;return{...r,queueDepths:n,strategyEntries:t.strategy.node.cache?.size??0,totalRetries:t.totalRetries.cache??0,totalReingestions:t.totalReingestions.cache??0}}function He(t){let{best:e,score:r,status:n}=t,a=Number.isFinite(r)?r.toFixed(3):String(r);return n==="converged"?{outcome:"success",detail:`refineLoop converged at score ${a}`,artifact:e}:n==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${a}`,artifact:e}:{outcome:"failure",detail:`refineLoop errored (status=${n})`,artifact:e}}function Qe(t){let e=t.name??"refine-executor",r=t.toOutput??He;return n=>{let a=A(n,i=>i!=null),d=$(a,i=>{let o=me(t.seedFrom(i),t.evaluator,t.strategy,{...t.refine,dataset:t.datasetFor(i),name:`${e}/inner`});return k([o.status,o.best,o.score],([s,u,f])=>{let l=s;return l!=="converged"&&l!=="budget"&&l!=="errored"?null:r({best:u,score:f,status:l})},{name:`${e}/output`})},{name:e});return A(d,i=>i!=null)}}function Ue(t){let e={"intake::latest":"INTAKE",triage:"TRIAGE",execute:"EXECUTE","verify-results::latest":"VERIFY",strategy:"STRATEGY"};for(let r of N)e[`queue/${r}::latest`]="QUEUE";for(let[r]of t.gates)e[`gates::${r}/gate`]="GATE";return e}function Be(t,e){let r=e?.logger===null?null:e?.logger??console.log,n=e?.detail??"summary",a=L(),d=[],i=[],o=Ue(t);function s(){return(L()-a)/1e9}function u(f,l,c){let m={elapsed:s(),stage:f,type:l};n!=="summary"&&(m.summary=qe(c)),n==="full"&&(m.data=c),i.push(m)}for(let[f,l]of Object.entries(o))try{let c=t.observe(f,{format:"stage-log",stageLabels:o,logger:r?m=>r(m):()=>{},includeTypes:["data","error","complete"]});c.onEvent(m=>{m.type==="data"?u(l,"data",m.data):m.type==="error"?u(l,"error",m.data):m.type==="complete"&&u(l,"complete",void 0)}),d.push(c)}catch(c){let m=c instanceof Error?c.message:String(c);u(l,"error",`observe-unavailable: ${f} \u2014 ${m}`),r&&r(`[${s().toFixed(3)}s] ${l.padEnd(9)} \u2717 observe-unavailable: ${m}`)}return{get events(){return i},dispose(){for(let f of d)f.dispose();d.length=0}}}function qe(t){if(t==null)return"null";if(typeof t=="string")return ve(t,80);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return ve(e,120)}catch{return String(t)}}function ve(t,e){return t.length>e?`${t.slice(0,e-1)}\u2026`:t}export{be as a,Ne as b,Se as c,we as d,Oe as e,Ce as f,_e as g,Le as h,N as i,P as j,W as k,z as l,X as m,Z as n,ee as o,Ge as p,ge as q,ye as r,U as s,Fe as t,De as u,Qe as v,Be as w,Ye as x};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ut}from"./chunk-3Q2WXM6X.js";import{a as Jr,b as Qr}from"./chunk-7QMVU3IX.js";import{$ as Fr,A as kr,B as hr,C as vr,D as xr,E as Tr,F as wr,G as Er,H as Nr,I as Mr,J as Sr,K as Rr,L as Or,M as Wr,N as Br,O as Ir,P as Lr,Q as jr,R as Cr,S as Vr,T as Pr,U as Ar,V as zr,W as Kr,X as Dr,Y as Ur,Z as _r,_ as $r,a as nn,aa as Hr,b as rn,ba as et,c as Gn,d as Jn,e as Qn,f as Xn,g as Yn,h as Zn,i as er,j as nr,k as rr,l as tr,m as or,n as sr,o as ir,p as ar,q as cr,r as dr,s as fr,t as ur,u as pr,v as lr,w as mr,x as gr,y as br,z as yr}from"./chunk-Y26UN6J5.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,l as fe}from"./chunk-RWGJQQLT.js";import{b as Xr,c as Yr,d as Zr,e as st,f as it}from"./chunk-4VXL3UZK.js";import{a as nt,b as rt}from"./chunk-DWIAG62L.js";import{a as tt,b as ot}from"./chunk-4UUDNFYG.js";import{a as qr,b as Gr}from"./chunk-LWGLBCMU.js";import{a as be,b as Ye}from"./chunk-5QDBSZBV.js";import{a as Ze,b as en}from"./chunk-XRSHMHEG.js";import{a as Y}from"./chunk-ESMPEKEV.js";import{a as at,b as ct,c as dt,d as ft}from"./chunk-I6VIH3VA.js";import{A as Mn,B as Sn,C as Rn,D as On,E as Wn,F as Bn,G as In,I as Ln,J as jn,K as Cn,L as Vn,M as Pn,N as An,O as zn,P as Kn,Q as Dn,R as Un,S as _n,T as $n,U as Fn,V as Hn,W as qn,a as U,b as J,c as tn,d as on,e as sn,f as an,g as cn,h as dn,i as Q,j as fn,k as un,l as pn,m as ln,n as mn,o as gn,p as bn,q as yn,r as kn,s as hn,t as X,u as vn,v as xn,w as Tn,x as wn,y as En,z as Nn}from"./chunk-WQ7I7JVU.js";import{c as he,d as ve,e as xe,f as Te,g as we,h as Ee,i as Ne}from"./chunk-4VVTGLXJ.js";import{A as Je,B as Qe,C as Xe,a as ye,b as ke,c as Me,d as Se,e as Re,f as G,g as Oe,h as We,i as Be,j as Ie,k as Le,l as je,m as Ce,n as Ve,o as Pe,p as Ae,q as ze,r as Ke,s as De,t as Ue,u as _e,v as $e,w as Fe,x as He,y as qe,z as Ge}from"./chunk-UMH3HSP7.js";import{A as K,D as j,E as W,H as D,m as B}from"./chunk-7AJKUA36.js";import{b as h,e as $,f as F,g as H,h as S,i as q,j as O}from"./chunk-CK2E7BTU.js";import{b as ge}from"./chunk-QYADASLV.js";var kt={};ge(kt,{CircuitOpenError:()=>ne,ContentAddressedMissError:()=>Xr,NS_PER_MS:()=>NS_PER_MS,NS_PER_SEC:()=>NS_PER_SEC,NativeIndexBackend:()=>nt,NativeListBackend:()=>tt,NativeLogBackend:()=>Ze,NativeMapBackend:()=>qr,NativePubSubBackend:()=>_,RateLimiterOverflowError:()=>se,ResettableTimer:()=>Y,TimeoutError:()=>ce,audit:()=>In,awaitSettled:()=>qe,buffer:()=>Ln,bufferCount:()=>jn,bufferTime:()=>Vn,cached:()=>$e,canonicalJson:()=>Yr,cascadingCache:()=>pt,catchError:()=>qn,checkpointToRedis:()=>Kr,checkpointToS3:()=>zr,circuitBreaker:()=>re,combine:()=>kn,combineLatest:()=>$n,concat:()=>xn,concatMap:()=>Nn,constant:()=>he,contentAddressedStorage:()=>Zr,createTransport:()=>L,createWatermarkController:()=>Ye,csvRows:()=>xr,debounce:()=>On,debounceTime:()=>Fn,decorrelatedJitter:()=>we,delay:()=>Rn,deserializeError:()=>A,dictStorage:()=>ft,distill:()=>Qr,distinctUntilChanged:()=>bn,elementAt:()=>pn,empty:()=>Pe,escapeRegexChar:()=>Me,exhaustMap:()=>En,exponential:()=>xe,externalBundle:()=>rn,externalProducer:()=>nn,fallback:()=>de,fibonacci:()=>Te,filter:()=>J,find:()=>un,first:()=>Q,firstValueFrom:()=>Fe,firstWhere:()=>He,flatMap:()=>Sn,forEach:()=>Ke,fromAny:()=>Ce,fromAsyncIter:()=>je,fromCSV:()=>vr,fromClickHouseWatch:()=>Er,fromCron:()=>We,fromDrizzle:()=>Fr,fromEvent:()=>Be,fromHTTP:()=>Xn,fromHTTPPoll:()=>sr,fromHTTPStream:()=>or,fromIter:()=>Ie,fromKafka:()=>br,fromKysely:()=>Hr,fromMCP:()=>cr,fromNATS:()=>Sr,fromNDJSON:()=>wr,fromOTel:()=>dr,fromPrisma:()=>$r,fromPrometheus:()=>mr,fromPromise:()=>Le,fromPulsar:()=>Nr,fromRabbitMQ:()=>Or,fromRaf:()=>Oe,fromRedisStream:()=>kr,fromSSE:()=>tr,fromSqlite:()=>Dr,fromSqliteCursor:()=>Ur,fromStatsD:()=>pr,fromSyslog:()=>fr,fromTimer:()=>G,fromWebSocket:()=>Jn,fromWebSocketReconnect:()=>ar,fromWebhook:()=>Qn,globToRegExp:()=>Se,interval:()=>zn,keepalive:()=>Qe,last:()=>fn,linear:()=>ve,lru:()=>ue,makeHttpError:()=>et,map:()=>U,matchesAnyPattern:()=>Re,matchesCron:()=>ke,memoryStorage:()=>dt,merge:()=>X,mergeMap:()=>Mn,nameToSignal:()=>V,ndjsonRows:()=>Tr,never:()=>Ae,nodeSignal:()=>Ge,of:()=>Ve,onFirstData:()=>mn,pairwise:()=>yn,parseCron:()=>ye,parsePrometheusText:()=>gr,parseSSEStream:()=>rr,parseStatsD:()=>lr,parseSyslog:()=>ur,pausable:()=>Dn,pubsub:()=>lt,race:()=>Tn,rateLimiter:()=>ie,reactiveCounter:()=>Xe,reactiveIndex:()=>rt,reactiveList:()=>ot,reactiveLog:()=>en,reactiveMap:()=>Gr,reactiveSink:()=>Gn,reduce:()=>on,repeat:()=>Kn,replay:()=>_e,rescue:()=>Un,resolveBackoffPreset:()=>Ne,retry:()=>Z,retrySource:()=>ee,sample:()=>Bn,scan:()=>tn,serializeError:()=>P,share:()=>Ue,shareReplay:()=>Je,signalToName:()=>I,singleFromAny:()=>st,singleNodeFromAny:()=>it,skip:()=>an,sortJsonValue:()=>at,stableJsonString:()=>ct,stratify:()=>ut,switchMap:()=>wn,take:()=>sn,takeUntil:()=>dn,takeWhile:()=>cn,tap:()=>ln,tapFirst:()=>gn,throttle:()=>Wn,throttleTime:()=>Hn,throwError:()=>ze,timeout:()=>fe,toArray:()=>De,toCSV:()=>Ir,toClickHouse:()=>Lr,toFile:()=>Br,toHTTP:()=>Yn,toKafka:()=>yr,toLoki:()=>Pr,toMongo:()=>Vr,toNATS:()=>Rr,toObservable:()=>be,toPostgres:()=>Cr,toPulsar:()=>Mr,toRabbitMQ:()=>Wr,toReadableStream:()=>nr,toRedisStream:()=>hr,toS3:()=>jr,toSSE:()=>Zn,toSSEBytes:()=>er,toSqlite:()=>_r,toTempo:()=>Ar,toWebSocket:()=>ir,tokenBucket:()=>oe,valve:()=>_n,verifiable:()=>Jr,window:()=>An,windowCount:()=>Cn,windowTime:()=>Pn,withBreaker:()=>te,withLatestFrom:()=>hn,withMaxAttempts:()=>Ee,withStatus:()=>ae,workerBridge:()=>le,workerSelf:()=>me,zip:()=>vn});function ue(){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 M=n;f.push(M.key),p(M),e.delete(M.key)}return f},size(){return e.size}}}function pe(e){return e!=null&&typeof e.then=="function"}function C(e){pe(e)&&e.catch(()=>{})}function pt(e,t){let n=new Map,p=t?.maxSize??0,l=p>0?t?.eviction??ue():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(pe(w)){let T=g;w.then(E=>{E!=null?(u.down([[h,E]]),f(o,E,T)):v(o,u,T+1)},()=>{v(o,u,T+1)});return}if(w!=null){u.down([[h,w]]),f(o,w,g);return}}}function M(){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 E=e[T].clear;E&&C(E.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&&M();let m=W(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&&M();let g=W(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.clear;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 lt(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 mt=new Map([[$,"INVALIDATE"],[F,"PAUSE"],[H,"RESUME"],[S,"TEARDOWN"],[q,"COMPLETE"],[O,"ERROR"]]),gt=new Map([["INVALIDATE",$],["PAUSE",F],["RESUME",H],["TEARDOWN",S],["COMPLETE",q],["ERROR",O]]);function I(e){let t=mt.get(e);return t||(Symbol.keyFor(e)??"UNKNOWN")}function V(e){let t=gt.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 bt(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function le(e,t){let n=bt(e)?e:L(e),p=t.name??"workerBridge",l=Object.entries(t.expose??{}),r=t.import??[],f=t.transfer??{},v=W("connecting",{name:`${p}::meta::status`}),M=W(null,{name:`${p}::meta::error`}),o=new Map,u=new Map;for(let c of r){let a=W(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],N=d[y];N!=null&&N.length>0&&(k[R]=N.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 N of Object.keys(i)){let z=f[N];z&&k.push(...z(i[N]))}let y;for(let[N,z]of l)N in i&&z.v!=null&&(y==null&&(y={}),y[N]=z.v.version);let R={t:"b",u:i,...y?{v:y}:{}};try{n.post(R,k.length>0?k:void 0)}catch(N){M.down([[h,N instanceof Error?N:new Error(String(N))]])}}).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([[O,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===O?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 E;if(t.timeoutMs!=null&&t.timeoutMs>0){let c=G(t.timeoutMs),a=J(v,d=>d==="connected");E=Q(X(U(c,()=>"timeout"),U(a,()=>"ready"))).subscribe(d=>{for(let i of d)i[0]===h&&i[1]==="timeout"&&(M.down([[h,new Error("Worker bridge handshake timeout")]]),x())})}function x(){if(!g){g=!0,E?.(),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:M},destroy:x};for(let[c,a]of o)b[c]=a;return b}function yt(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function me(e,t){let n=yt(e)?e:L(e),p=t.import??[],l=t.transfer??{},r=new Map,f=new Map,v={};for(let x of p){let b=W(void 0,{name:`worker::${x}`});r.set(x,b),v[x]=b}let M=t.expose(v),o=Object.entries(M),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===O?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([[O,A(b.err)]]);break}case"s":{let c=V(b.sig);if(!c)break;if(c===S&&b.s==="*"){E();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 E(){if(!m){m=!0,u&&u();for(let x of g)x();g.length=0,w(),n.terminate?.(),f.clear(),r.clear()}}return{destroy:E}}export{ue as a,pt as b,_ as c,lt as d,I as e,V as f,P as g,A as h,L as i,le as j,me as k,kt as l};
|
|
1
|
+
import{a as ut}from"./chunk-5PBXUVHI.js";import{a as Jr,b as Qr}from"./chunk-7QMVU3IX.js";import{$ as Fr,A as kr,B as hr,C as vr,D as xr,E as Tr,F as wr,G as Er,H as Nr,I as Mr,J as Sr,K as Rr,L as Or,M as Wr,N as Br,O as Ir,P as Lr,Q as jr,R as Cr,S as Vr,T as Pr,U as Ar,V as zr,W as Kr,X as Dr,Y as Ur,Z as _r,_ as $r,a as nn,aa as Hr,b as rn,ba as et,c as Gn,d as Jn,e as Qn,f as Xn,g as Yn,h as Zn,i as er,j as nr,k as rr,l as tr,m as or,n as sr,o as ir,p as ar,q as cr,r as dr,s as fr,t as ur,u as pr,v as lr,w as mr,x as gr,y as br,z as yr}from"./chunk-Y26UN6J5.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,l as fe}from"./chunk-RWGJQQLT.js";import{b as Xr,c as Yr,d as Zr,e as st,f as it}from"./chunk-4VXL3UZK.js";import{a as nt,b as rt}from"./chunk-DWIAG62L.js";import{a as tt,b as ot}from"./chunk-4UUDNFYG.js";import{a as qr,b as Gr}from"./chunk-LWGLBCMU.js";import{a as be,b as Ye}from"./chunk-5QDBSZBV.js";import{a as Ze,b as en}from"./chunk-XRSHMHEG.js";import{a as Y}from"./chunk-ESMPEKEV.js";import{a as at,b as ct,c as dt,d as ft}from"./chunk-I6VIH3VA.js";import{A as Mn,B as Sn,C as Rn,D as On,E as Wn,F as Bn,G as In,I as Ln,J as jn,K as Cn,L as Vn,M as Pn,N as An,O as zn,P as Kn,Q as Dn,R as Un,S as _n,T as $n,U as Fn,V as Hn,W as qn,a as U,b as J,c as tn,d as on,e as sn,f as an,g as cn,h as dn,i as Q,j as fn,k as un,l as pn,m as ln,n as mn,o as gn,p as bn,q as yn,r as kn,s as hn,t as X,u as vn,v as xn,w as Tn,x as wn,y as En,z as Nn}from"./chunk-WQ7I7JVU.js";import{c as he,d as ve,e as xe,f as Te,g as we,h as Ee,i as Ne}from"./chunk-4VVTGLXJ.js";import{A as Je,B as Qe,C as Xe,a as ye,b as ke,c as Me,d as Se,e as Re,f as G,g as Oe,h as We,i as Be,j as Ie,k as Le,l as je,m as Ce,n as Ve,o as Pe,p as Ae,q as ze,r as Ke,s as De,t as Ue,u as _e,v as $e,w as Fe,x as He,y as qe,z as Ge}from"./chunk-UMH3HSP7.js";import{A as K,D as j,E as W,H as D,m as B}from"./chunk-7AJKUA36.js";import{b as h,e as $,f as F,g as H,h as S,i as q,j as O}from"./chunk-CK2E7BTU.js";import{b as ge}from"./chunk-QYADASLV.js";var kt={};ge(kt,{CircuitOpenError:()=>ne,ContentAddressedMissError:()=>Xr,NS_PER_MS:()=>NS_PER_MS,NS_PER_SEC:()=>NS_PER_SEC,NativeIndexBackend:()=>nt,NativeListBackend:()=>tt,NativeLogBackend:()=>Ze,NativeMapBackend:()=>qr,NativePubSubBackend:()=>_,RateLimiterOverflowError:()=>se,ResettableTimer:()=>Y,TimeoutError:()=>ce,audit:()=>In,awaitSettled:()=>qe,buffer:()=>Ln,bufferCount:()=>jn,bufferTime:()=>Vn,cached:()=>$e,canonicalJson:()=>Yr,cascadingCache:()=>pt,catchError:()=>qn,checkpointToRedis:()=>Kr,checkpointToS3:()=>zr,circuitBreaker:()=>re,combine:()=>kn,combineLatest:()=>$n,concat:()=>xn,concatMap:()=>Nn,constant:()=>he,contentAddressedStorage:()=>Zr,createTransport:()=>L,createWatermarkController:()=>Ye,csvRows:()=>xr,debounce:()=>On,debounceTime:()=>Fn,decorrelatedJitter:()=>we,delay:()=>Rn,deserializeError:()=>A,dictStorage:()=>ft,distill:()=>Qr,distinctUntilChanged:()=>bn,elementAt:()=>pn,empty:()=>Pe,escapeRegexChar:()=>Me,exhaustMap:()=>En,exponential:()=>xe,externalBundle:()=>rn,externalProducer:()=>nn,fallback:()=>de,fibonacci:()=>Te,filter:()=>J,find:()=>un,first:()=>Q,firstValueFrom:()=>Fe,firstWhere:()=>He,flatMap:()=>Sn,forEach:()=>Ke,fromAny:()=>Ce,fromAsyncIter:()=>je,fromCSV:()=>vr,fromClickHouseWatch:()=>Er,fromCron:()=>We,fromDrizzle:()=>Fr,fromEvent:()=>Be,fromHTTP:()=>Xn,fromHTTPPoll:()=>sr,fromHTTPStream:()=>or,fromIter:()=>Ie,fromKafka:()=>br,fromKysely:()=>Hr,fromMCP:()=>cr,fromNATS:()=>Sr,fromNDJSON:()=>wr,fromOTel:()=>dr,fromPrisma:()=>$r,fromPrometheus:()=>mr,fromPromise:()=>Le,fromPulsar:()=>Nr,fromRabbitMQ:()=>Or,fromRaf:()=>Oe,fromRedisStream:()=>kr,fromSSE:()=>tr,fromSqlite:()=>Dr,fromSqliteCursor:()=>Ur,fromStatsD:()=>pr,fromSyslog:()=>fr,fromTimer:()=>G,fromWebSocket:()=>Jn,fromWebSocketReconnect:()=>ar,fromWebhook:()=>Qn,globToRegExp:()=>Se,interval:()=>zn,keepalive:()=>Qe,last:()=>fn,linear:()=>ve,lru:()=>ue,makeHttpError:()=>et,map:()=>U,matchesAnyPattern:()=>Re,matchesCron:()=>ke,memoryStorage:()=>dt,merge:()=>X,mergeMap:()=>Mn,nameToSignal:()=>V,ndjsonRows:()=>Tr,never:()=>Ae,nodeSignal:()=>Ge,of:()=>Ve,onFirstData:()=>mn,pairwise:()=>yn,parseCron:()=>ye,parsePrometheusText:()=>gr,parseSSEStream:()=>rr,parseStatsD:()=>lr,parseSyslog:()=>ur,pausable:()=>Dn,pubsub:()=>lt,race:()=>Tn,rateLimiter:()=>ie,reactiveCounter:()=>Xe,reactiveIndex:()=>rt,reactiveList:()=>ot,reactiveLog:()=>en,reactiveMap:()=>Gr,reactiveSink:()=>Gn,reduce:()=>on,repeat:()=>Kn,replay:()=>_e,rescue:()=>Un,resolveBackoffPreset:()=>Ne,retry:()=>Z,retrySource:()=>ee,sample:()=>Bn,scan:()=>tn,serializeError:()=>P,share:()=>Ue,shareReplay:()=>Je,signalToName:()=>I,singleFromAny:()=>st,singleNodeFromAny:()=>it,skip:()=>an,sortJsonValue:()=>at,stableJsonString:()=>ct,stratify:()=>ut,switchMap:()=>wn,take:()=>sn,takeUntil:()=>dn,takeWhile:()=>cn,tap:()=>ln,tapFirst:()=>gn,throttle:()=>Wn,throttleTime:()=>Hn,throwError:()=>ze,timeout:()=>fe,toArray:()=>De,toCSV:()=>Ir,toClickHouse:()=>Lr,toFile:()=>Br,toHTTP:()=>Yn,toKafka:()=>yr,toLoki:()=>Pr,toMongo:()=>Vr,toNATS:()=>Rr,toObservable:()=>be,toPostgres:()=>Cr,toPulsar:()=>Mr,toRabbitMQ:()=>Wr,toReadableStream:()=>nr,toRedisStream:()=>hr,toS3:()=>jr,toSSE:()=>Zn,toSSEBytes:()=>er,toSqlite:()=>_r,toTempo:()=>Ar,toWebSocket:()=>ir,tokenBucket:()=>oe,valve:()=>_n,verifiable:()=>Jr,window:()=>An,windowCount:()=>Cn,windowTime:()=>Pn,withBreaker:()=>te,withLatestFrom:()=>hn,withMaxAttempts:()=>Ee,withStatus:()=>ae,workerBridge:()=>le,workerSelf:()=>me,zip:()=>vn});function ue(){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 M=n;f.push(M.key),p(M),e.delete(M.key)}return f},size(){return e.size}}}function pe(e){return e!=null&&typeof e.then=="function"}function C(e){pe(e)&&e.catch(()=>{})}function pt(e,t){let n=new Map,p=t?.maxSize??0,l=p>0?t?.eviction??ue():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(pe(w)){let T=g;w.then(E=>{E!=null?(u.down([[h,E]]),f(o,E,T)):v(o,u,T+1)},()=>{v(o,u,T+1)});return}if(w!=null){u.down([[h,w]]),f(o,w,g);return}}}function M(){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 E=e[T].clear;E&&C(E.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&&M();let m=W(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&&M();let g=W(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.clear;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 lt(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 mt=new Map([[$,"INVALIDATE"],[F,"PAUSE"],[H,"RESUME"],[S,"TEARDOWN"],[q,"COMPLETE"],[O,"ERROR"]]),gt=new Map([["INVALIDATE",$],["PAUSE",F],["RESUME",H],["TEARDOWN",S],["COMPLETE",q],["ERROR",O]]);function I(e){let t=mt.get(e);return t||(Symbol.keyFor(e)??"UNKNOWN")}function V(e){let t=gt.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 bt(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function le(e,t){let n=bt(e)?e:L(e),p=t.name??"workerBridge",l=Object.entries(t.expose??{}),r=t.import??[],f=t.transfer??{},v=W("connecting",{name:`${p}::meta::status`}),M=W(null,{name:`${p}::meta::error`}),o=new Map,u=new Map;for(let c of r){let a=W(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],N=d[y];N!=null&&N.length>0&&(k[R]=N.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 N of Object.keys(i)){let z=f[N];z&&k.push(...z(i[N]))}let y;for(let[N,z]of l)N in i&&z.v!=null&&(y==null&&(y={}),y[N]=z.v.version);let R={t:"b",u:i,...y?{v:y}:{}};try{n.post(R,k.length>0?k:void 0)}catch(N){M.down([[h,N instanceof Error?N:new Error(String(N))]])}}).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([[O,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===O?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 E;if(t.timeoutMs!=null&&t.timeoutMs>0){let c=G(t.timeoutMs),a=J(v,d=>d==="connected");E=Q(X(U(c,()=>"timeout"),U(a,()=>"ready"))).subscribe(d=>{for(let i of d)i[0]===h&&i[1]==="timeout"&&(M.down([[h,new Error("Worker bridge handshake timeout")]]),x())})}function x(){if(!g){g=!0,E?.(),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:M},destroy:x};for(let[c,a]of o)b[c]=a;return b}function yt(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function me(e,t){let n=yt(e)?e:L(e),p=t.import??[],l=t.transfer??{},r=new Map,f=new Map,v={};for(let x of p){let b=W(void 0,{name:`worker::${x}`});r.set(x,b),v[x]=b}let M=t.expose(v),o=Object.entries(M),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===O?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([[O,A(b.err)]]);break}case"s":{let c=V(b.sig);if(!c)break;if(c===S&&b.s==="*"){E();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 E(){if(!m){m=!0,u&&u();for(let x of g)x();g.length=0,w(),n.terminate?.(),f.clear(),r.clear()}}return{destroy:E}}export{ue as a,pt as b,_ as c,lt as d,I as e,V as f,P as g,A as h,L as i,le as j,me as k,kt as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O,b as H,c as j,d as E,e as W,f as ne}from"./chunk-
|
|
1
|
+
import{a as O,b as H,c as j,d as E,e as W,f as ne}from"./chunk-X4OOM6QU.js";import{a as N}from"./chunk-K54OKWNY.js";import{a as X,j as T}from"./chunk-4JBKKUCJ.js";import{D as I,E as y,G as L,o as S}from"./chunk-7AJKUA36.js";import{b as te}from"./chunk-QYADASLV.js";var ie={};te(ie,{CanvasMeasureAdapter:()=>$,CliMeasureAdapter:()=>D,ImageSizeAdapter:()=>J,NodeCanvasMeasureAdapter:()=>q,PrecomputedAdapter:()=>V,SvgBoundsAdapter:()=>z,analyzeAndMeasure:()=>O,carveTextLineSlots:()=>E,circleIntervalForBand:()=>Q,computeBlockFlow:()=>_,computeCharPositions:()=>W,computeFlowLines:()=>ee,computeLineBreaks:()=>H,computeTotalHeight:()=>U,layoutNextLine:()=>j,measureBlock:()=>Y,measureBlocks:()=>K,reactiveBlockLayout:()=>re,reactiveFlowLayout:()=>se,reactiveLayout:()=>ne,rectIntervalForBand:()=>Z});var D=class{cellPx;constructor(t){this.cellPx=t?.cellPx??8}measureSegment(t,n){return{width:X(t)*this.cellPx}}},G=class extends Error{name="KeyError"},V=class{metrics;fallback;constructor(t){this.metrics=t.metrics;let n=t.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(t.fallback)}`);this.fallback=n}measureSegment(t,n){let i=this.metrics[n];if(i){let o=i[t];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new G(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(t)} in font ${JSON.stringify(n)}`);let r=0;if(i)for(let o of t){let l=i[o];l!==void 0&&(r+=l)}return{width:r}}},$=class{ctx=null;currentFont="";emojiCorrection;constructor(t){this.emojiCorrection=t?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let i=this.getContext();n!==this.currentFont&&(i.font=n,this.currentFont=n);let r=i.measureText(t).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(t)&&(r*=this.emojiCorrection),{width:r}}clearCache(){this.currentFont=""}},q=class{ctx=null;currentFont="";canvasModule;constructor(t){this.canvasModule=t}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let i=this.getContext();return n!==this.currentFont&&(i.font=n,this.currentFont=n),{width:i.measureText(t).width}}clearCache(){this.currentFont=""}},z=class{measureSvg(t){let n=t.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let l=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(l)&&Number.isFinite(a)&&l>0&&a>0)return{width:l,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let i=t.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),r=t.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(i&&r){let o=Number.parseFloat(i[1]),l=Number.parseFloat(r[1]);if(Number.isFinite(o)&&Number.isFinite(l)&&o>0&&l>0)return{width:o,height:l};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},J=class{sizes;constructor(t){this.sizes=new Map(Object.entries(t))}measureImage(t){let n=this.sizes.get(t);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(t)}`);return{width:n.width,height:n.height}}};function Y(e,t,n,i,r,o,l){switch(e.type){case"text":{let a=e.font??r,m=e.lineHeight??o,d=O(e.text,a,n.text,i),w=H(d,t,n.text,a,i),v=W(w,d,m),B=w.lineCount*m,c=0;for(let x of w.lines)x.width>c&&(c=x.width);return{index:l,type:"text",width:Math.min(c,t),height:B,textSegments:d,textLineBreaks:w,textCharPositions:v}}case"image":{let a,m;if(e.naturalWidth!=null&&e.naturalHeight!=null)a=e.naturalWidth,m=e.naturalHeight;else if(n.image){let d=n.image.measureImage(e.src);a=d.width,m=d.height}else throw new Error(`Image block at index ${l} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return a>t&&(m=m*t/a,a=t),{index:l,type:"image",width:a,height:m}}case"svg":{let a,m;if(e.viewBox)a=e.viewBox.width,m=e.viewBox.height;else if(n.svg){let d=n.svg.measureSvg(e.content);a=d.width,m=d.height}else throw new Error(`SVG block at index ${l} has no viewBox and no SvgMeasurer adapter`);return a>t&&(m=m*t/a,a=t),{index:l,type:"svg",width:a,height:m}}}}function K(e,t,n,i,r,o){return e.map((l,a)=>Y(l,t,n,i,r,o,a))}function _(e,t){let n=[],i=0;for(let r=0;r<e.length;r++){let o=e[r];n.push({...o,x:0,y:i}),i+=o.height+(r<e.length-1?t:0)}return n}function U(e){if(e.length===0)return 0;let t=e[e.length-1];return t.y+t.height}function re(e){let{adapters:t,name:n="reactive-block-layout",defaultFont:i="16px sans-serif",defaultLineHeight:r=20}=e,o=new T(n),l=new Map,a=y(e.blocks??[],{name:"blocks"}),m=y(Math.max(0,e.maxWidth??800),{name:"max-width"}),d=y(e.gap??0,{name:"gap"}),w=I([a,m],(c,x,s)=>{let p=c[0]!=null&&c[0].length>0?c[0].at(-1):s.prevData[0],h=c[1]!=null&&c[1].length>0?c[1].at(-1):s.prevData[1],g=S(),u=K(p,h,t,l,i,r),f=S()-g,b=w.meta;b&&(N(b["block-count"],u.length),N(b["layout-time-ns"],f)),x.emit(u);let C=()=>{l.clear(),t.text.clearCache?.()};return{deactivate:C,invalidate:C}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(c,x)=>{let s=c,p=x;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++){let g=s[h],u=p[h];if(g.type!==u.type||g.width!==u.width||g.height!==u.height||g.index!==u.index)return!1}return!0}}),v=L([w,d],([c,x])=>_(c,x),{name:"block-flow",equals:(c,x)=>{let s=c,p=x;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++){let g=s[h],u=p[h];if(g.x!==u.x||g.y!==u.y||g.width!==u.width||g.height!==u.height)return!1}return!0}}),B=L([v],([c])=>U(c),{name:"total-height"});return o.add(a,{name:"blocks"}),o.add(m,{name:"max-width"}),o.add(d,{name:"gap"}),o.add(w,{name:"measured-blocks"}),o.add(v,{name:"block-flow"}),o.add(B,{name:"total-height"}),{graph:o,setBlocks:c=>o.set("blocks",c),setMaxWidth:c=>o.set("max-width",Math.max(0,c)),setGap:c=>o.set("gap",c),measuredBlocks:w,blockFlow:v,totalHeight:B}}function Q(e,t,n){let i=e.hPad??0,r=e.vPad??0,o=t-r,l=n+r;if(o>=e.cy+e.r||l<=e.cy-e.r)return null;let a=e.cy>=o&&e.cy<=l?0:e.cy<o?o-e.cy:e.cy-l;if(a>=e.r)return null;let m=Math.sqrt(e.r*e.r-a*a);return{left:e.cx-m-i,right:e.cx+m+i}}function Z(e,t,n){let i=e.hPad??0,r=e.vPad??0;return n<=e.y-r||t>=e.y+e.h+r?null:{left:e.x-i,right:e.x+e.w+i}}function oe(e,t,n){return e.kind==="circle"?Q(e,t,n):Z(e,t,n)}function ee(e,t,n,i,r,o,l){let a=l?.paragraphSpacing??r,m=[],d={segmentIndex:0,graphemeIndex:0};if(e.length===0||n.count<=0||r<=0)return{lines:m,cursor:d};let w=t.paddingX??0,v=t.paddingY??0,B=Math.max(0,t.width-w*2),c=Math.max(0,t.height-v*2),x=n.gap*Math.max(0,n.count-1),s=Math.max(0,(B-x)/n.count);if(s<=0)return{lines:m,cursor:d};e:for(let p=0;p<n.count;p++){let h=w+p*(s+n.gap),g=h+s,u=v;for(;u+r<=v+c;){let f=u+r,b=[];for(let k=0;k<i.length;k++){let M=oe(i[k],u,f);M!==null&&b.push(M)}let C=E({left:h,right:g},b,o);if(C.length===0){u+=r;continue}let P=!1;for(let k=0;k<C.length;k++){let M=C[k],R=M.right-M.left,F=j(e,d,R);if(F===null)return{lines:m,cursor:d};if(F.text.length===0&&F.width===0){d=F.end,P=!0;break}m.push({x:M.left,y:u,width:F.width,slotWidth:R,text:F.text,columnIndex:p,flushToRight:M.right<g-.5}),d=F.end}if(P){u+=a;continue}if(u+=r,d.segmentIndex>=e.length)break e}if(d.segmentIndex>=e.length)break}return{lines:m,cursor:d}}function se(e){let{adapter:t,name:n="reactive-flow-layout",minSlotWidth:i=20}=e,r=new T(n),o=new Map,l=y(e.text??"",{name:"text"}),a=y(e.font??"16px sans-serif",{name:"font"}),m=y(e.lineHeight??20,{name:"line-height"}),d=y(e.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),w=y(e.columns??{count:1,gap:0},{name:"columns"}),v=y(e.obstacles??[],{name:"obstacles"}),B=y(e.paragraphSpacing??null,{name:"paragraph-spacing"}),c=I([l,a],(s,p,h)=>{let g=s[0],u=g!=null&&g.length>0?g.at(-1):h.prevData[0],f=s[1],b=f!=null&&f.length>0?f.at(-1):h.prevData[1],C=O(u,b,t,o);p.emit(C);let P=()=>{o.clear(),t.clearCache?.()};return{deactivate:P,invalidate:P}},{name:"segments",describeKind:"derived"}),x=L([c,d,w,v,m,B],([s,p,h,g,u,f])=>{let b=s,C=S(),P=f??u,{lines:k,cursor:M}=ee(b,p,h,g,u,i,{paragraphSpacing:P}),R=S()-C,F=Math.max(0,b.length-M.segmentIndex),A=x.meta;return A&&(N(A["line-count"],k.length),N(A["layout-time-ns"],R),N(A["overflow-segments"],F)),k},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(s,p)=>{let h=s,g=p;if(h.length!==g.length)return!1;for(let u=0;u<h.length;u++){let f=h[u],b=g[u];if(f.x!==b.x||f.y!==b.y||f.width!==b.width||f.slotWidth!==b.slotWidth||f.text!==b.text||f.columnIndex!==b.columnIndex||f.flushToRight!==b.flushToRight)return!1}return!0}});return r.add(l,{name:"text"}),r.add(a,{name:"font"}),r.add(m,{name:"line-height"}),r.add(d,{name:"container"}),r.add(w,{name:"columns"}),r.add(v,{name:"obstacles"}),r.add(B,{name:"paragraph-spacing"}),r.add(c,{name:"segments"}),r.add(x,{name:"flow-lines"}),{graph:r,setText:s=>r.set("text",s),setFont:s=>r.set("font",s),setLineHeight:s=>r.set("line-height",s),setContainer:s=>r.set("container",s),setColumns:s=>r.set("columns",s),setObstacles:s=>r.set("obstacles",s),setParagraphSpacing:s=>r.set("paragraph-spacing",s),segments:c,flowLines:x}}export{D as a,V as b,$ as c,q as d,z as e,J as f,Y as g,K as h,_ as i,U as j,re as k,Q as l,Z as m,ee as n,se as o,ie as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as x,c as D,d as $,e as S,f as A,g as R,h as T,i as F,j as y,k as P,l as V}from"./chunk-
|
|
1
|
+
import{b as x,c as D,d as $,e as S,f as A,g as R,h as T,i as F,j as y,k as P,l as V}from"./chunk-4JBKKUCJ.js";import{a as m,b as g,c as k,d as v,e as O,f as G,g as E,h as C}from"./chunk-7AJKUA36.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as _}from"./chunk-QYADASLV.js";var j={};_(j,{ENVELOPE_VERSION:()=>v,GRAPH_META_SEGMENT:()=>R,Graph:()=>y,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>D,SIZEOF_SYMBOL:()=>$,SNAPSHOT_VERSION:()=>T,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>k,decodeEnvelope:()=>G,diffForWAL:()=>P,encodeEnvelope:()=>O,explainPath:()=>x,graphProfile:()=>A,mermaidLiveUrl:()=>F,reachable:()=>V,registerBuiltinCodecs:()=>E,replayWAL:()=>C,sizeof:()=>S,validateGraphObservability:()=>L,watchTopologyTree:()=>N});function N(p,n){let o=new Map,d=(s,a)=>{if(o.has(s))return;let c={off:()=>{},prefix:a};o.set(s,c);let f=s.topology.subscribe(l=>{for(let r of l){if(r[0]!==u)continue;let e=r[1];if(n(e,s,a),e.kind==="added"&&e.nodeKind==="mount"){let t=s._mounts.get(e.name);if(t instanceof y){let i=`${a}${e.name}::`;d(t,i)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let t=`${a}${e.name}::`;for(let[i,h]of Array.from(o.entries()))i!==p&&h.prefix.startsWith(t)&&(h.off(),o.delete(i))}}});c.off=f;for(let[l,r]of s._mounts)if(r instanceof y){let e=`${a}${l}::`;d(r,e)}};return d(p,""),()=>{for(let s of o.values())s.off();o.clear()}}function L(p,n={}){let o=[],d=n.requireFound??!0;if(n.skipDescribe!==!0)try{let r=p.describe(),e=new Set(Object.keys(r.nodes)),t=[];for(let[i,h]of Object.entries(r.nodes))for(let b of h.deps)b!==""&&!e.has(b)&&t.push(`${i} \u2192 ${b}`);for(let i of r.edges)e.has(i.from)||t.push(`edge.from: ${i.from}`),e.has(i.to)||t.push(`edge.to: ${i.to}`);t.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${t.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:t}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:r.edges.length})}catch(r){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${r instanceof Error?r.message:String(r)}`})}for(let r of n.formats??[])try{let e=p.describe({format:r});typeof e!="string"||e.length===0?o.push({kind:"describe-format",ok:!1,format:r,reason:`describe({ format: "${r}" }) returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:r,length:e.length})}catch(e){o.push({kind:"describe-format",ok:!1,format:r,reason:e instanceof Error?e.message:String(e)})}for(let r of n.paths??[])try{p.resolve(r),o.push({kind:"observe",ok:!0,path:r})}catch(e){o.push({kind:"observe",ok:!1,path:r,reason:e instanceof Error?e.message:String(e)})}for(let[r,e]of n.pairs??[])try{let t=p.explain(r,e);d&&t.found===!1?o.push({kind:"explain",ok:!1,from:r,to:e,reason:`explain(${r} \u2192 ${e}) found no path${t.reason?`: ${t.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:r,to:e,found:t.found,steps:t.steps.length})}catch(t){o.push({kind:"explain",ok:!1,from:r,to:e,reason:t instanceof Error?t.message:String(t)})}let s=o.filter(r=>!r.ok),a=s.length===0,c=n.paths?.length??0,f=n.pairs?.length??0,l=n.formats?.length??0;return{ok:a,checks:o,failures:s,summary(){let r=[n.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,c>0?`${c} observe path${c===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(t=>t!=null),e=r.length>0?r.join(", "):"describe-only";return a?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${s.length} failure(s) across ${e}`}}}export{N as a,L as b,j as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as $}from"./chunk-
|
|
1
|
+
import{a as $}from"./chunk-VXJX3ZZP.js";import{c as O}from"./chunk-K54OKWNY.js";import{a as C}from"./chunk-MFNOZ5E6.js";import{b as x}from"./chunk-XRSHMHEG.js";import{j as A}from"./chunk-4JBKKUCJ.js";import{B as R}from"./chunk-UMH3HSP7.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-7AJKUA36.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{j as C}from"./chunk-
|
|
1
|
+
import{j as C}from"./chunk-4JBKKUCJ.js";import{E as w,G as E,o as x}from"./chunk-7AJKUA36.js";import{b as z}from"./chunk-QYADASLV.js";var F={};z(F,{collection:()=>G,decay:()=>K,knowledgeGraph:()=>O,lightCollection:()=>S,vectorIndex:()=>L});function K(s,a,l,r=0){if(!Number.isFinite(s))return r;if(!Number.isFinite(a)||a<=0||!Number.isFinite(l)||l<=0)return Math.max(r,s);let y=s*Math.exp(-l*a);return Math.max(r,y)}function V(s){if(s!==void 0&&s<1)throw new RangeError("maxSize must be >= 1")}function M(s){return new Map(s)}function T(s){return s.cache??new Map}function N(s){return s.cache??[]}function I(s,a){let l=Math.max(s.length,a.length),r=0,y=0,p=0;for(let o=0;o<l;o+=1){let n=s[o]??0,e=a[o]??0;r+=n*e,y+=n*n,p+=e*e}return y===0||p===0?0:r/Math.sqrt(y*p)}function S(s={}){let a=s.maxSize,l=s.policy??"fifo";V(a);let r=w(new Map,{name:s.name,describeKind:"state"});function y(o){if(a!==void 0)for(;o.size>a;){let n;for(let e of o.values()){if(!n){n=e;continue}let i=l==="lru"?e.lastAccessNs:e.createdAtNs,t=l==="lru"?n.lastAccessNs:n.createdAtNs;i<t&&(n=e)}if(!n)break;o.delete(n.id)}}function p(o){r.emit(o)}return{entries:r,upsert(o,n){let e=x(),i=T(r),t=i.get(o),m=M(i);m.set(o,{id:o,value:n,createdAtNs:t?.createdAtNs??e,lastAccessNs:e}),y(m),p(m)},remove(o){let n=M(T(r));n.delete(o)&&p(n)},clear(){T(r).size!==0&&p(new Map)},get(o){let n=T(r),e=n.get(o);if(e){if(l==="lru"){let i=x(),t=M(n);t.set(o,{...e,lastAccessNs:i}),p(t)}return e.value}},has(o){return T(r).has(o)}}}function G(s,a={}){let l=a.maxSize,r=a.policy??"lru",y=a.decayRate??0,p=a.minScore??0,o=a.score??(()=>1);V(l);let n=new C(s),e=w(new Map,{name:"items",describeKind:"state"}),i=E([e],([c])=>{let d=c??new Map,u=x(),h=[...d.values()].map(f=>{let b=(u-f.lastAccessNs)/1e9;return{...f,score:K(f.baseScore,b,y,p)}});return h.sort((f,b)=>b.score-f.score||b.lastAccessNs-f.lastAccessNs),h},{name:"ranked",describeKind:"derived"}),t=E([e],([c])=>(c??new Map).size,{name:"size",describeKind:"derived",initial:0});i.subscribe(()=>{}),t.subscribe(()=>{}),n.add(e,{name:"items"}),n.add(i,{name:"ranked"}),n.add(t,{name:"size"});function m(c,d){let u=(d-c.lastAccessNs)/1e9;return K(c.baseScore,u,y,p)}function v(c){if(l!==void 0)for(;c.size>l;){let d=x(),u,h=Number.POSITIVE_INFINITY;for(let f of c.values()){let b=m(f,d);if(b<h){u=f,h=b;continue}if(b===h&&u){let A=r==="lru"?f.lastAccessNs:f.createdAtNs,R=r==="lru"?u.lastAccessNs:u.createdAtNs;A<R&&(u=f)}}if(!u)break;c.delete(u.id)}}function g(c){e.emit(c)}return Object.assign(n,{upsert(c,d,u){let h=x(),f=T(e),b=f.get(c),A=u?.score??o(d),R=M(f);R.set(c,{id:c,value:d,baseScore:A,createdAtNs:b?.createdAtNs??h,lastAccessNs:h}),v(R),g(R)},remove(c){let d=M(T(e));d.delete(c)&&g(d)},clear(){T(e).size!==0&&g(new Map)},getItem(c){let d=T(e),u=d.get(c);if(u){if(r==="lru"){let h=M(d);h.set(c,{...u,lastAccessNs:x()}),g(h)}return u}}})}function L(s={}){let a=s.backend??"flat",l=s.dimension,r;if(a==="hnsw"&&(r=s.hnswFactory?.(),!r))throw new Error('vectorIndex backend "hnsw" requires an optional dependency adapter; install your HNSW package and provide `hnswFactory`.');let y=w(new Map,{describeKind:"state",name:"vector-index"});function p(n){if(l!==void 0&&n.length!==l)throw new RangeError(`vector dimension mismatch: expected ${l}, got ${n.length}`)}function o(n){y.emit(n)}return{backend:a,entries:y,upsert(n,e,i){p(e);let t=M(T(y));t.set(n,{id:n,vector:[...e],meta:i}),a==="hnsw"&&r.upsert(n,e,i),o(t)},remove(n){let e=M(T(y));e.delete(n)&&(a==="hnsw"&&r.remove(n),o(e))},clear(){T(y).size!==0&&(a==="hnsw"&&r.clear(),o(new Map))},search(n,e=5){return p(n),e<=0?[]:a==="hnsw"?r.search(n,e):[...T(y).values()].map(t=>({id:t.id,score:I(n,t.vector),meta:t.meta})).sort((t,m)=>m.score-t.score).slice(0,e)}}}function O(s){let a=new C(s),l=w(new Map,{name:"entities",describeKind:"state"}),r=w([],{name:"edges",describeKind:"state"}),y=E([r],([e])=>{let i=e??[],t=new Map;for(let m of i){let v=t.get(m.from)??[];t.set(m.from,Object.freeze([...v,m]))}return t},{name:"adjacency",describeKind:"derived",initial:new Map});y.subscribe(()=>{}),a.add(l,{name:"entities"}),a.add(r,{name:"edges"}),a.add(y,{name:"adjacency"});function p(e){l.emit(e)}function o(e){r.emit(e)}return Object.assign(a,{upsertEntity(e,i){let t=M(T(l));t.set(e,i),p(t)},removeEntity(e){let i=M(T(l)),t=i.delete(e),m=N(r),v=m.filter(g=>g.from!==e&&g.to!==e);!t&&v.length===m.length||(p(i),o(v))},link(e,i,t,m=1){let v=`${e}\0${i}\0${t}`,g=N(r),k=new Set(g.map(d=>`${d.from}\0${d.to}\0${d.relation}`)),c=[...g];if(k.has(v))for(let d=0;d<c.length;d+=1){let u=c[d];if(u.from===e&&u.to===i&&u.relation===t){c[d]={...u,weight:m};break}}else c.push({from:e,to:i,relation:t,weight:m});o(c)},unlink(e,i,t){let m=N(r),v=m.filter(g=>t===void 0?!(g.from===e&&g.to===i):!(g.from===e&&g.to===i&&g.relation===t));v.length!==m.length&&o(v)},related(e,i){return N(r).filter(t=>(t.from===e||t.to===e)&&(i===void 0||t.relation===i))}})}export{K as a,S as b,G as c,L as d,O as e,F as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as G,d as F}from"./chunk-
|
|
1
|
+
import{b as G,d as F}from"./chunk-WF3V5X2L.js";import{c as E}from"./chunk-K54OKWNY.js";import{a as A}from"./chunk-5PBXUVHI.js";import{b as q}from"./chunk-XRSHMHEG.js";import{j as I}from"./chunk-4JBKKUCJ.js";import{B as M}from"./chunk-UMH3HSP7.js";import{E as d,G as o,H as O,m as S}from"./chunk-7AJKUA36.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 +1 @@
|
|
|
1
|
-
import{c as k}from"./chunk-K54OKWNY.js";import{b as I}from"./chunk-XRSHMHEG.js";import{j as h}from"./chunk-
|
|
1
|
+
import{c as k}from"./chunk-K54OKWNY.js";import{b as I}from"./chunk-XRSHMHEG.js";import{j as h}from"./chunk-4JBKKUCJ.js";import{B as p}from"./chunk-UMH3HSP7.js";import{D as w,E as f,G as d,m as x}from"./chunk-7AJKUA36.js";import{i as y}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var C={};M(C,{MessagingHubGraph:()=>v,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>g,TopicGraph:()=>l,messagingHub:()=>L,subscription:()=>G,topic:()=>P,topicBridge:()=>S});var N=2147483647;function m(n,t){if(!Number.isFinite(n)||!Number.isInteger(n)||n<0)throw new Error(`${t} must be a non-negative integer`);return n}function o(n,t){return k("messaging",n,t)}var l=class extends h{_log;events;latest;hasLatest;constructor(t,e={}){super(t,e.graph),this._log=I([],{name:"events",maxSize:e.retainedLimit}),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=d([this.events],([i])=>{let s=i;return s.length===0?null:s[s.length-1]},{name:"latest",describeKind:"derived",meta:o("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(p(this.latest)),this.hasLatest=d([this.events],([i])=>i.length>0,{name:"hasLatest",describeKind:"derived",meta:o("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(p(this.hasLatest)),this.addDisposer(()=>{this.events.down([[y]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(t){this._log.append(t)}retained(){return this.events.cache}},T=class extends h{source;cursor;available;topic;constructor(t,e,i={}){super(t,i.graph);let s=m(i.cursor??0,"subscription cursor");this.topic=e;let r=e.events;this.source=d([r],([u])=>u,{name:"source",describeKind:"derived",meta:o("subscription_source"),initial:r.cache}),this.add(this.source,{name:"source"}),this.cursor=f(s,{name:"cursor",describeKind:"state",meta:o("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=d([this.source,this.cursor],([u,b])=>{let a=u,c=Math.max(0,Math.trunc(b??0));return a.slice(c)},{name:"available",describeKind:"derived",meta:o("subscription_available"),initial:[]}),this.add(this.available,{name:"available"}),this.addDisposer(p(this.source)),this.addDisposer(p(this.available))}ack(t){let e=this.available.cache,i=t===void 0?e.length:m(t,"subscription ack count"),s=Math.min(i,e.length);if(s<=0)return this.cursor.cache;let r=this.cursor.cache+s;return this.cursor.emit(r),r}pull(t,e={}){let i=this.available.cache,s=t===void 0?i.length:m(t,"subscription pull limit"),r=i.slice(0,s);return e.ack&&r.length>0&&this.ack(r.length),r}},g=class extends h{_sourceSub;_target;bridgedCount;constructor(t,e,i,s={}){super(t,s.graph),this._sourceSub=G(`${t}-subscription`,e,{cursor:s.cursor}),this._target=i,this.mount("subscription",this._sourceSub),this.bridgedCount=f(0,{name:"bridgedCount",describeKind:"state",meta:o("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"});let r=Math.max(1,m(s.maxPerPump??N,"topic bridge maxPerPump")),u=s.map??(a=>a),b=w([this._sourceSub.available],()=>{let a=this._sourceSub.pull(r,{ack:!0});if(a.length===0)return;let c=0;for(let _ of a){let O=u(_);O!==void 0&&(this._target.publish(O),c+=1)}if(c>0){let _=this.bridgedCount.cache;this.bridgedCount.emit(_+c)}},{name:"pump",describeKind:"effect",meta:o("topic_bridge_pump")});this.add(b,{name:"pump"}),this.addDisposer(p(b))}},v=class extends h{_topics=new Map;_version=0;_defaultTopicOptions;constructor(t,e={}){super(t,e.graph),this._defaultTopicOptions={...e.defaultTopicOptions??{}}}get version(){return this._version}get size(){return this._topics.size}has(t){return this._topics.has(t)}topicNames(){return this._topics.keys()}topic(t,e){let i=this._topics.get(t);if(i===void 0){let s={...this._defaultTopicOptions,...e??{}};i=new l(t,s),this._topics.set(t,i),this.mount(t,i),this._version+=1}return i}publish(t,e){this.topic(t).publish(e)}publishMany(t){x(()=>{for(let[e,i]of t)this.topic(e).publish(i)})}subscribe(t,e,i){let s=this.topic(e);return new T(t,s,i)}removeTopic(t){if(!this._topics.has(t))return!1;try{this.remove(t)}finally{this._topics.delete(t),this._version+=1}return!0}};function P(n,t){return new l(n,t)}function L(n,t){return new v(n,t)}function G(n,t,e){return new T(n,t,e)}function S(n,t,e,i){return new g(n,t,e,i)}export{l as a,T as b,g as c,v as d,P as e,L as f,G as g,S as h,C as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H,b as T}from"./chunk-
|
|
1
|
+
import{a as H,b as T}from"./chunk-X4OOM6QU.js";import{j as q}from"./chunk-4JBKKUCJ.js";import{a as O,b as j}from"./chunk-N2KKISCE.js";import{E as d,G as o,H as x,m as A}from"./chunk-7AJKUA36.js";import{b as ae}from"./chunk-QYADASLV.js";var ie={};ae(ie,{demoShell:()=>re});function w(h){return Math.max(0,Math.min(1,h))}function re(h){let B=w(h?.mainRatio??.65),E=w(h?.sideSplit??.5),J=Math.max(0,h?.viewportWidth??1280),k=h?.nodeRegistry??new Map,p=h?.adapter??null,S=h?.layoutFont??"14px monospace",u=h?.onHighlight,t=new q("demo-shell"),F=d(B,{name:"pane/main-ratio"}),D=d(E,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(J,{name:"viewport/width"});t.add(F,{name:"pane/main-ratio"}),t.add(D,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let L=o([F,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),R=o([L,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),C=o([D,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),K=o([C,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(L,{name:"pane/main-width"}),t.add(R,{name:"pane/side-width"}),t.add(C,{name:"pane/graph-height-ratio"}),t.add(K,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),m=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(m,{name:"demo/graph-tick"});let Q=o([b,m],([e,a])=>{let n=e;return n?n.describe({format:"mermaid"}):""},{name:"graph/mermaid"}),z=o([b,m],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(Q,{name:"graph/mermaid"}),t.add(z,{name:"graph/describe"});let M=d(null,{name:"hover/target"});t.add(M,{name:"hover/target"});let P=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),W=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),N=o([M],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(P,{name:"highlight/code-scroll"}),t.add(W,{name:"highlight/visual"}),t.add(N,{name:"highlight/graph"}),u?.codeScroll){let e=u.codeScroll,a=x([P],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(u?.visual){let e=u.visual,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(u?.graph){let e=u.graph,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let _=d(null,{name:"inspect/selected-node"});t.add(_,{name:"inspect/selected-node"});let U=O("standard"),X=o([_,b,m],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=j(i,U);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Y=o([b,m],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(X,{name:"inspect/node-detail"}),t.add(Y,{name:"inspect/trace-log"});let I=d(!1,{name:"meta/debug"});t.add(I,{name:"meta/debug"});let Z=o([I,m],([e,a])=>e?t.describe({format:"mermaid"}):"",{name:"meta/shell-mermaid"});t.add(Z,{name:"meta/shell-mermaid"});let V=d("",{name:"layout/code-text"});if(t.add(V,{name:"layout/code-text"}),p){let e=new Map,a=o([z],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=H(c,S,p,e),v=T(f,1/0,p,S,e),y=v.lines.reduce((te,ne)=>Math.max(te,ne.width),0),ee=v.lineCount*20;s.set(c,{width:y,height:ee})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([V,R],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=H(s,S,p,e),f=i-40;return T(c,Math.max(100,f),p,S,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let $=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++$)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){A(e)},destroy(){t.destroy()}}}export{re as a,ie as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as F,c as G}from"./chunk-K54OKWNY.js";import{b as $}from"./chunk-LWGLBCMU.js";import{j as _}from"./chunk-
|
|
1
|
+
import{b as F,c as G}from"./chunk-K54OKWNY.js";import{b as $}from"./chunk-LWGLBCMU.js";import{j as _}from"./chunk-4JBKKUCJ.js";import{t as B}from"./chunk-WQ7I7JVU.js";import{B as N}from"./chunk-UMH3HSP7.js";import{D as x,E as I,G as S,H as M,m as A}from"./chunk-7AJKUA36.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,2 +1,2 @@
|
|
|
1
|
-
import{a as G}from"./chunk-K54OKWNY.js";import{j as z}from"./chunk-
|
|
1
|
+
import{a as G}from"./chunk-K54OKWNY.js";import{j as z}from"./chunk-4JBKKUCJ.js";import{D as H,E as M,G as N,o as R}from"./chunk-7AJKUA36.js";function q(t){for(let c of t){let m=c.codePointAt(0);if(m>=19968&&m<=40959||m>=13312&&m<=19903||m>=12288&&m<=12351||m>=12352&&m<=12447||m>=12448&&m<=12543||m>=44032&&m<=55215||m>=65280&&m<=65519)return!0}return!1}var E=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),F=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function D(t){return t.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function O(t){let c=new Intl.Segmenter(void 0,{granularity:"word"}),m=[];for(let f of c.segment(t)){let h=f.segment,w=f.isWordLike??!1,u=[],s=[],r=[],p="",n=null;for(let i of h){let S;i===" "?S="space":i==="\u200B"?S="zero-width-break":i==="\xAD"?S="soft-hyphen":i===`
|
|
2
2
|
`?S="hard-break":S="text",n!==null&&S===n?p+=i:(n!==null&&(u.push(p),s.push(n==="text"&&w),r.push(n)),p=i,n=S)}n!==null&&(u.push(p),s.push(n==="text"&&w),r.push(n)),m.push({texts:u,isWordLike:s,kinds:r})}return m}function V(t,c,m,f,h){let w=D(t);if(w.length===0)return[];let u=O(w),s=new Intl.Segmenter(void 0,{granularity:"grapheme"}),r=[],p=[],n=[];for(let g of u)for(let o=0;o<g.texts.length;o++)r.push(g.texts[o]),p.push(g.kinds[o]),n.push(g.isWordLike[o]);let i=[],S=[],B=[];for(let g=0;g<r.length;g++){let o=r[g],y=p[g],I=n[g];if(y==="text"&&!I&&i.length>0&&S[S.length-1]==="text"&&o.length===1&&(F.has(o)||E.has(o))){i[i.length-1]+=o;continue}if(o==="-"&&i.length>0&&S[S.length-1]==="text"&&B[B.length-1]){i[i.length-1]+=o;continue}i.push(o),S.push(y),B.push(I)}let l=f.get(c);l||(l=new Map,f.set(c,l));function b(g){let o=l.get(g);if(o===void 0){h&&(h.misses+=1);let y=m.measureSegment(g,c).width;o=Number.isFinite(y)&&y>=0?y:0,l.set(g,o)}else h&&(h.hits+=1);return o}let d=[];for(let g=0;g<i.length;g++){let o=i[g],y=S[g];if(y!=="text"){d.push({text:o,width:y==="space"?b(" ")*o.length:0,kind:y,graphemeWidths:null});continue}if(q(o)){let a="";for(let x of s.segment(o)){let k=x.segment;if(a.length>0&&E.has(k)){a+=k;continue}if(a.length>0){let L=b(a);d.push({text:a,width:L,kind:"text",graphemeWidths:null})}a=k}if(a.length>0){let x=b(a);d.push({text:a,width:x,kind:"text",graphemeWidths:null})}continue}let I=b(o),e=null;if(B[g]&&o.length>1){let a=[];for(let x of s.segment(o))a.push(b(x.segment));a.length>1&&(e=a)}d.push({text:o,width:I,kind:"text",graphemeWidths:e})}return d}function J(t,c,m,f,h){if(t.length===0)return{lines:[],lineCount:0};let w=[],u=0,s=!1,r=0,p=0,n=0,i=0,S=-1,B=0,l=h.get(f);l||(l=new Map,h.set(f,l));let b=l.get("-");b===void 0&&(b=m.measureSegment("-",f).width,l.set("-",b));function d(e=n,a=i,x=u){let k="";for(let L=r;L<e;L++){let W=t[L];if(!(W.kind==="soft-hyphen"||W.kind==="hard-break"))if(L===r&&p>0&&W.graphemeWidths){let P=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(W.text)].map(K=>K.segment);k+=P.slice(p).join("")}else k+=W.text}if(a>0&&e<t.length){let L=t[e],v=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(L.text)].map(K=>K.segment),P=r===e?p:0;k+=v.slice(P,a).join("")}e>0&&t[e-1]?.kind==="soft-hyphen"&&!(r===e&&p>0)&&(k+="-"),w.push({text:k,width:x,startSegment:r,startGrapheme:p,endSegment:e,endGrapheme:a}),u=0,s=!1,S=-1,B=0}function g(e){return e==="space"||e==="zero-width-break"||e==="soft-hyphen"}function o(e,a,x){s=!0,r=e,p=a,n=e+1,i=0,u=x}function y(e,a,x){s=!0,r=e,p=a,n=e,i=a+1,u=x}for(let e=0;e<t.length;e++){let a=t[e];if(a.kind==="hard-break"){s?d():w.push({text:"",width:0,startSegment:e,startGrapheme:0,endSegment:e,endGrapheme:0}),r=e+1,p=0;continue}let x=a.width;if(!s){x>c&&a.graphemeWidths?I(e,0,a.graphemeWidths):o(e,0,x),g(a.kind)&&(S=e+1,B=a.kind==="space"?u-x:u);continue}let k=u+x;if(k>c+.005){if(g(a.kind)){u+=x,n=e+1,i=0,d(e+1,0,a.kind==="space"?u-x:u);continue}if(S>=0){d(S,0,B),e--;continue}if(x>c&&a.graphemeWidths){d(),I(e,0,a.graphemeWidths);continue}d(),e--;continue}u=k,n=e+1,i=0,g(a.kind)&&(S=e+1,B=a.kind==="space"?u-x:u)}return s&&d(),{lines:w,lineCount:w.length};function I(e,a,x){for(let k=a;k<x.length;k++){let L=x[k];if(!s){y(e,k,L);continue}u+L>c+.005?(d(),y(e,k,L)):(u+=L,n=e,i=k+1)}s&&n===e&&i===x.length&&(n=e+1,i=0)}}function A(t){return t==="space"||t==="zero-width-break"||t==="soft-hyphen"}var T=null;function _(){return T===null&&(T=new Intl.Segmenter(void 0,{granularity:"grapheme"})),T}function j(t,c,m){if(c===0&&m<0)return t.text;let f=[..._().segment(t.text)].map(w=>w.segment),h=m<0?f.length:m;return f.slice(c,h).join("")}function C(t,c,m,f,h,w){let u="";for(let s=c;s<f;s++){let r=t[s];r.kind==="soft-hyphen"||r.kind==="hard-break"||(s===c&&m>0?u+=j(r,m,-1):u+=r.text)}if(h>0&&f<t.length){let s=t[f];u+=j(s,c===f?m:0,h)}return w&&(u+="-"),u}function $(t){if(!t?.adapter||!t.font)return 0;let c=t.cache;if(c){let m=c.get(t.font);m||(m=new Map,c.set(t.font,m));let f=m.get("-");return f===void 0&&(f=t.adapter.measureSegment("-",t.font).width,m.set("-",f)),f}return t.adapter.measureSegment("-",t.font).width}function te(t,c,m,f){let h=c.segmentIndex,w=c.graphemeIndex;if(h>=t.length)return null;if(w===0){for(;h<t.length;){let e=t[h];if(e.kind==="hard-break")return{text:"",width:0,start:{segmentIndex:c.segmentIndex,graphemeIndex:0},end:{segmentIndex:h+1,graphemeIndex:0}};if(e.kind==="space"||e.kind==="zero-width-break"||e.kind==="soft-hyphen"){h+=1;continue}break}if(h>=t.length)return null}let u=$(f),s=h,r=h===c.segmentIndex?w:0,p=0,n=s,i=0,S=!1,B=-1,l=0,b=0,d=!1,g=(e,a,x,k)=>{B=e,l=a,b=x,d=k==="soft-hyphen"},o=(e,a,x)=>{for(let k=a;k<x.length;k++){let L=x[k];if(!S){p=L,n=e,i=k+1,S=!0;continue}if(p+L>m+.005)return!0;p+=L,n=e,i=k+1}return n===e&&i===x.length&&(n=e+1,i=0),!1};if(r>0&&s<t.length){let e=t[s];if(e.graphemeWidths){if(o(s,r,e.graphemeWidths))return{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}};h=n}}for(;h<t.length;){let e=t[h];if(e.kind==="hard-break"){if(S){let k=n>0&&t[n-1]?.kind==="soft-hyphen";return{text:C(t,s,r,n,i,k),width:p+(k?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}return{text:"",width:0,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:h+1,graphemeIndex:0}}}let a=e.width;if(!S){if(a>m&&e.graphemeWidths){if(o(h,0,e.graphemeWidths))return{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}};h=n;continue}p=a,n=h+1,i=0,S=!0,A(e.kind)&&g(h+1,0,e.kind==="space"?p-a:p,e.kind),h+=1;continue}let x=p+a;if(x>m+.005){if(A(e.kind)){n=h+1,i=0;let L=e.kind==="soft-hyphen",W=e.kind==="space"?p:p+(L?u:0);return{text:C(t,s,r,n,i,L),width:W,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}return B>=0?{text:C(t,s,r,B,l,d),width:b+(d?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:B,graphemeIndex:l}}:a>m&&e.graphemeWidths?{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}:{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}p=x,n=h+1,i=0,A(e.kind)&&g(h+1,0,e.kind==="space"?p-a:p,e.kind),h+=1}if(!S)return null;let y=n>0&&t[n-1]?.kind==="soft-hyphen";return{text:C(t,s,r,n,i,y),width:p+(y?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}function ne(t,c,m=0){let f=[t];for(let h=0;h<c.length;h++){let w=c[h],u=[];for(let s=0;s<f.length;s++){let r=f[s];if(w.right<=r.left||w.left>=r.right){u.push(r);continue}w.left>r.left&&u.push({left:r.left,right:w.left}),w.right<r.right&&u.push({left:w.right,right:r.right})}f=u}return m>0?f.filter(h=>h.right-h.left>=m):f}function Q(t,c,m){let f=[],h=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(let w=0;w<t.lines.length;w++){let u=t.lines[w],s=w*m,r=0;for(let p=u.startSegment;p<c.length;p++){let n=c[p];if(n.kind==="soft-hyphen"||n.kind==="hard-break"){if(p>=u.endSegment&&u.endGrapheme===0)break;continue}let i=[...h.segment(n.text)].map(l=>l.segment);if(i.length===0)continue;let S=p===u.startSegment?u.startGrapheme:0,B;if(p<u.endSegment)B=i.length;else if(p===u.endSegment&&u.endGrapheme>0)B=u.endGrapheme;else break;for(let l=S;l<B;l++){let b=n.graphemeWidths?n.graphemeWidths[l]:n.width/i.length;f.push({x:r,y:s,width:b,height:m,line:w}),r+=b}}}return f}function re(t){let{adapter:c,name:m="reactive-layout"}=t,f=new z(m),h=new Map,w=M(t.text??"",{name:"text"}),u=M(t.font??"16px sans-serif",{name:"font"}),s=M(t.lineHeight??20,{name:"line-height"}),r=M(Math.max(0,t.maxWidth??800),{name:"max-width"});function p(l,b){if(l===null||b===null)return l===b;if(l.length!==b.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==b[d])return!1;return!0}let n=H([w,u],(l,b,d)=>{let g=l[0],o=g!=null&&g.length>0?g.at(-1):d.prevData[0],y=l[1],I=y!=null&&y.length>0?y.at(-1):d.prevData[1],e=R(),a={hits:0,misses:0},x=V(o,I,c,h,a),k=R()-e,L=a.hits+a.misses,W=L===0?1:a.hits/L,v=n.meta;v&&(G(v["cache-hit-rate"],W),G(v["segment-count"],x.length),G(v["layout-time-ns"],k)),b.emit(x);let P=()=>{h.clear(),c.clearCache?.()};return{deactivate:P,invalidate:P}},{name:"segments",describeKind:"derived",meta:{"cache-hit-rate":0,"segment-count":0,"layout-time-ns":0},equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.length!==g.length)return!1;for(let o=0;o<d.length;o++){let y=d[o],I=g[o];if(y.text!==I.text||y.width!==I.width||y.kind!==I.kind||!p(y.graphemeWidths??null,I.graphemeWidths??null))return!1}return!0}}),i=N([n,r,u],([l,b,d])=>J(l,b,c,d,h),{name:"line-breaks",equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.lineCount!==g.lineCount)return!1;for(let o=0;o<d.lines.length;o++){let y=d.lines[o],I=g.lines[o];if(y.text!==I.text||y.width!==I.width||y.startSegment!==I.startSegment||y.startGrapheme!==I.startGrapheme||y.endSegment!==I.endSegment||y.endGrapheme!==I.endGrapheme)return!1}return!0}}),S=N([i,s],([l,b])=>l.lineCount*b,{name:"height"}),B=N([i,n,s],([l,b,d])=>Q(l,b,d),{name:"char-positions",equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.length!==g.length)return!1;for(let o=0;o<d.length;o++)if(d[o].x!==g[o].x||d[o].y!==g[o].y||d[o].width!==g[o].width)return!1;return!0}});return f.add(w,{name:"text"}),f.add(u,{name:"font"}),f.add(s,{name:"line-height"}),f.add(r,{name:"max-width"}),f.add(n,{name:"segments"}),f.add(i,{name:"line-breaks"}),f.add(S,{name:"height"}),f.add(B,{name:"char-positions"}),{graph:f,setText:l=>f.set("text",l),setFont:l=>f.set("font",l),setLineHeight:l=>f.set("line-height",l),setMaxWidth:l=>f.set("max-width",Math.max(0,l)),segments:n,lineBreaks:i,height:S,charPositions:B}}export{V as a,J as b,te as c,ne as d,Q as e,re as f};
|