@synnaxlabs/pluto 0.32.0 → 0.33.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/{Animated-C_WGrQwR.cjs → Animated-BGm8tACN.cjs} +1 -1
- package/dist/{Animated-NyYe8Svx.js → Animated-Cg0ftviS.js} +2 -2
- package/dist/{Item-CcXMlZIY.js → Item-B8JWj3fN.js} +5 -5
- package/dist/{Item-DGKnKb6c.cjs → Item-C89uBEra.cjs} +1 -1
- package/dist/{Keyboard-87LPq07J.cjs → Keyboard-B1757gtH.cjs} +1 -1
- package/dist/{Keyboard-i5fqTDMP.js → Keyboard-BAU1UuVp.js} +2 -2
- package/dist/{LinePlot-CCzgiKg5.js → LinePlot-CgkhTRJT.js} +3531 -3360
- package/dist/LinePlot-oIHuM9Jz.cjs +66 -0
- package/dist/Link-BGZki0c9.cjs +1 -0
- package/dist/Link-Du1lxpym.js +14 -0
- package/dist/{List-BjRQA8wb.js → List-KmtaD0qw.js} +2 -2
- package/dist/{List-B3WCj8GQ.cjs → List-e1hOSGSX.cjs} +1 -1
- package/dist/{Pack-BrxYNh7B.js → Pack-CxtceW7N.js} +1 -1
- package/dist/{Pack-C_SrDA3a.cjs → Pack-uflj5a28.cjs} +1 -1
- package/dist/{Text-MNWCdS6X.js → Text-D1VocrR6.js} +5 -5
- package/dist/{Text-XcCNQVZj.cjs → Text-DWBEhfiF.cjs} +1 -1
- package/dist/{Toggle-C1k6Tnpo.js → Toggle-B96EPQ2x.js} +14463 -14342
- package/dist/Toggle-C5E2dVg4.cjs +143 -0
- package/dist/{Video-DR3tjTFZ.cjs → Video-DKosAU7v.cjs} +1 -1
- package/dist/{Video-DdIv_1Yq.js → Video-o34bcpwh.js} +1 -1
- package/dist/{aggregator-f5OfPmNc.js → aggregator-B36SA-20.js} +5061 -4512
- package/dist/aggregator-CU9VgdUJ.cjs +67 -0
- package/dist/align.cjs +1 -1
- package/dist/align.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/css-4MXuPP5v.cjs +1 -0
- package/dist/css-C8qHWSpT.js +1085 -0
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/dropdown.cjs +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +53 -51
- package/dist/{external-DLa89w3J.cjs → external-BHkFTefx.cjs} +1 -1
- package/dist/{external-CSyZPKK4.cjs → external-BRdQZoOL.cjs} +1 -1
- package/dist/external-BSHY-kgQ.cjs +1 -0
- package/dist/{external-CIvyZ-Hc.js → external-BSqwgq7l.js} +2 -2
- package/dist/external-BdZ8kC55.cjs +1 -0
- package/dist/{external-CDGv7k3p.js → external-BpIfVU6K.js} +12 -12
- package/dist/{external-DAQPXD3z.cjs → external-C-PNFpoV.cjs} +1 -1
- package/dist/{external-DmJZ_zIB.js → external-C2PoeTKJ.js} +2 -2
- package/dist/{external-Cl_evqYY.cjs → external-CPTY4-IY.cjs} +1 -1
- package/dist/{external-n_t7VfzS.js → external-Cc1Bqjmm.js} +1 -1
- package/dist/{external-FeE2ijEU.js → external-Ckdd7teZ.js} +14 -14
- package/dist/{external-BryXmBqR.js → external-CvTy-Tj3.js} +4 -4
- package/dist/external-CxatFj2t.js +1191 -0
- package/dist/{external-DfIxCAg2.js → external-CzrKYxlg.js} +2 -2
- package/dist/{external-DE4i3A2z.cjs → external-DDwIRENP.cjs} +1 -1
- package/dist/{external-BI9DOL9G.js → external-DWm3_4ZA.js} +28 -28
- package/dist/{external-CNrnZ1L5.js → external-DZhjjzue.js} +73 -73
- package/dist/{external-CmbBTupJ.js → external-Dk66psus.js} +20 -20
- package/dist/{external-i13duWIn.cjs → external-GtPAaR7c.cjs} +1 -1
- package/dist/external-Icf6LMl2.cjs +1 -0
- package/dist/{external-C2Ri5xWS.cjs → external-LyF1vgNR.cjs} +1 -1
- package/dist/{external-BUjAebk2.cjs → external-T318T5Xe.cjs} +1 -1
- package/dist/{external-CbjdO9a0.js → external-uvD747pL.js} +31 -31
- package/dist/{external-DjE3je-g.cjs → external-w5-jxIYn.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2261 -2166
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/src/aether/main.d.ts +1 -0
- package/dist/src/aether/main.d.ts.map +1 -1
- package/dist/src/button/Button.d.ts +8 -2
- package/dist/src/button/Button.d.ts.map +1 -1
- package/dist/src/button/Link.d.ts +2 -1
- package/dist/src/button/Link.d.ts.map +1 -1
- package/dist/src/button/Toggle.d.ts +1 -1
- package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/form/Form.d.ts +2 -2
- package/dist/src/form/Form.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/input/Numeric.d.ts.map +1 -1
- package/dist/src/input/types.d.ts +1 -1
- package/dist/src/input/types.d.ts.map +1 -1
- package/dist/src/memo/proxyMemo.d.ts +1 -1
- package/dist/src/memo/proxyMemo.d.ts.map +1 -1
- package/dist/src/modal/Modal.d.ts.map +1 -1
- package/dist/src/override/factory.d.ts +3 -0
- package/dist/src/override/factory.d.ts.map +1 -0
- package/dist/src/override/index.d.ts +2 -0
- package/dist/src/override/index.d.ts.map +1 -0
- package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
- package/dist/src/select/Button.d.ts +1 -1
- package/dist/src/select/Button.d.ts.map +1 -1
- package/dist/src/select/Multiple.d.ts.map +1 -1
- package/dist/src/select/Single.d.ts.map +1 -1
- package/dist/src/status/Aggregator.d.ts +2 -6
- package/dist/src/status/Aggregator.d.ts.map +1 -1
- package/dist/src/status/Circle.d.ts.map +1 -1
- package/dist/src/status/aether/aggregator.d.ts.map +1 -1
- package/dist/src/status/aether/types.d.ts.map +1 -1
- package/dist/src/tabs/Tabs.d.ts +8 -8
- package/dist/src/tabs/Tabs.d.ts.map +1 -1
- package/dist/src/telem/aether/convertSeries.d.ts +2 -2
- package/dist/src/telem/aether/convertSeries.d.ts.map +1 -1
- package/dist/src/telem/aether/noop.d.ts +2 -1
- package/dist/src/telem/aether/noop.d.ts.map +1 -1
- package/dist/src/telem/aether/remote.d.ts.map +1 -1
- package/dist/src/telem/aether/static.d.ts +2 -2
- package/dist/src/telem/client/cache/cache.d.ts +1 -1
- package/dist/src/telem/client/cache/cache.d.ts.map +1 -1
- package/dist/src/telem/client/cache/dynamic.d.ts +3 -3
- package/dist/src/telem/client/cache/dynamic.d.ts.map +1 -1
- package/dist/src/telem/client/cache/static.d.ts +1 -1
- package/dist/src/telem/client/cache/static.d.ts.map +1 -1
- package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
- package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
- package/dist/src/theming/Provider.d.ts.map +1 -1
- package/dist/src/theming/aether/provider.d.ts +5846 -3
- package/dist/src/theming/aether/provider.d.ts.map +1 -1
- package/dist/src/theming/core/fontString.d.ts +1 -1
- package/dist/src/theming/core/fontString.d.ts.map +1 -1
- package/dist/src/theming/core/theme.d.ts +9 -0
- package/dist/src/theming/core/theme.d.ts.map +1 -1
- package/dist/src/theming/css.d.ts.map +1 -1
- package/dist/src/triggers/hooks.d.ts +2 -1
- package/dist/src/triggers/hooks.d.ts.map +1 -1
- package/dist/src/vis/canvas/aether/canvas.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts +0 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
- package/dist/src/vis/draw2d/index.d.ts +2 -1
- package/dist/src/vis/draw2d/index.d.ts.map +1 -1
- package/dist/src/vis/eraser/aether/eraser.d.ts.map +1 -1
- package/dist/src/vis/line/aether/line.d.ts +3 -1
- package/dist/src/vis/line/aether/line.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +1 -1
- package/dist/src/vis/log/Log.d.ts +12 -0
- package/dist/src/vis/log/Log.d.ts.map +1 -0
- package/dist/src/vis/log/aether/Log.d.ts +556 -0
- package/dist/src/vis/log/aether/Log.d.ts.map +1 -0
- package/dist/src/vis/log/aether/index.d.ts +2 -0
- package/dist/src/vis/log/aether/index.d.ts.map +1 -0
- package/dist/src/vis/log/index.d.ts +2 -0
- package/dist/src/vis/log/index.d.ts.map +1 -0
- package/dist/src/vis/render/context.d.ts +3 -1
- package/dist/src/vis/render/context.d.ts.map +1 -1
- package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
- package/dist/src/vis/schematic/primitives/Primitives.d.ts +2 -2
- package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
- package/dist/src/vis/schematic/registry.d.ts.map +1 -1
- package/dist/src/vis/value/aether/value.d.ts +1 -0
- package/dist/src/vis/value/aether/value.d.ts.map +1 -1
- package/dist/src/vis/value/use.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/dist/{units-CnA_yWxx.js → units-CmWU_YzJ.js} +1 -1
- package/dist/{units-CMXTKjnN.cjs → units-DbfWaeE2.cjs} +1 -1
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +20 -22
- package/dist/LinePlot-BcVyfdeK.cjs +0 -66
- package/dist/Link-B83uKMKM.cjs +0 -1
- package/dist/Link-DlC5z0Wm.js +0 -10
- package/dist/Toggle-CIXrEiVA.cjs +0 -143
- package/dist/aggregator-q0CY7-QS.cjs +0 -67
- package/dist/css-B8RwzK24.js +0 -1042
- package/dist/css-LxkguM_s.cjs +0 -1
- package/dist/external-CDChKvhl.cjs +0 -1
- package/dist/external-CN-OhewX.cjs +0 -1
- package/dist/external-cIvhYaqB.cjs +0 -1
- package/dist/external-kSaQF2Vi.js +0 -1169
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";var Jh=Object.defineProperty;var Qh=(t,e,n)=>e in t?Jh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var m=(t,e,n)=>Qh(t,typeof e!="symbol"?e+"":e,n);const T=require("./aggregator-CU9VgdUJ.cjs"),b=require("zod"),f=require("./css-4MXuPP5v.cjs"),x=require("react");require("react-dom");var tf=Object.defineProperty,ef=(t,e,n)=>e in t?tf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Cr=(t,e,n)=>ef(t,typeof e!="symbol"?e+"":e,n);class nf{constructor(e,n){Cr(this,"handlers"),Cr(this,"transform"),Cr(this,"closer"),this.transform=e,this.handlers=n??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let n=e;if(this.transform!=null){const[r,s]=this.transform(e);if(!s)return;n=r}this.handlers.forEach((r,s)=>s(n))}setCloser(e){this.closer=e}async close(){var e;return await((e=this.closer)==null?void 0:e.call(this))}}class rf{constructor(e){Cr(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((n,r)=>r(e))}}const Do=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:rf,Observer:nf},Symbol.toStringTag,{value:"Module"})),sf=b.z.object({props:T.Zf.nullable(),state:T.Lf.connectivity.connectionStateZ.nullable()}),zo={synnax:null,state:T.Lf.connectivity.DEFAULT};var Qt;let Or=(Qt=class extends T.Composite{constructor(){super(...arguments);m(this,"schema",Qt.stateZ)}async afterUpdate(){var n;if(this.ctx.has(Lo)||Ys(this.ctx,zo),this.state.props==null){this.internal.synnax!=null&&(this.setState(r=>({...r,state:T.Lf.connectivity.DEFAULT})),(n=this.internal.synnax)==null||n.close(),this.internal.synnax=null),Ys(this.ctx,this.internal);return}this.prevState.props!=null&&T._.equal(this.state.props,this.prevState.props)&&this.internal.synnax!=null||(this.internal.synnax=new T.Lf(this.state.props),this.internal.synnax.connectivity.onChange(r=>this.setState(s=>({...s,state:r}))),Ys(this.ctx,this.internal))}},m(Qt,"TYPE","SynnaxProvider"),m(Qt,"stateZ",sf),Qt);const Lo="pluto-client-context",Ys=(t,e)=>t.set(Lo,e),sr=t=>t.get(Lo).synnax,oc={[Or.TYPE]:Or},of=Object.freeze(Object.defineProperty({__proto__:null,Provider:Or,REGISTRY:oc,ZERO_CONTEXT_VALUE:zo,use:sr},Symbol.toStringTag,{value:"Module"})),ic="pluto-telem-context",Ss=t=>t.get(ic),ac=(t,e)=>t.set(ic,e),cc=(t,e)=>Ss(t).registerFactory(e);class zi{constructor(e,n,r){m(this,"spec");m(this,"wrapped");m(this,"prevKey");this.wrapped=e,this.spec=r,this.prevKey=n.clusterKey}async value(){return await this.wrapped.value()}async cleanup(){var e,n;await((n=(e=this.wrapped).cleanup)==null?void 0:n.call(e))}onChange(e){return this.wrapped.onChange(e)}shouldUpdate(e,n){return this.prevKey!==e.clusterKey||!T._.equal(this.spec,n)}}class Li{constructor(e,n,r){m(this,"spec");m(this,"prov");m(this,"prevKey");m(this,"wrapped");this.wrapped=e,this.spec=r,this.prov=n,this.prevKey=n.clusterKey}async set(e){return await this.wrapped.set(e)}async cleanup(){var e,n;await((n=(e=this.wrapped).cleanup)==null?void 0:n.call(e))}shouldUpdate(e,n){return this.prevKey!==e.clusterKey||!T._.equal(this.spec,n)}}const At=async(t,e,n)=>{var s;const r=Ss(t);if(n instanceof zi){if(!n.shouldUpdate(r,e))return n;await((s=n.cleanup)==null?void 0:s.call(n))}return new zi(r.create(e),r,e)},or=async(t,e,n)=>{var s;const r=Ss(t);if(n instanceof Li){if(!n.shouldUpdate(r,e))return n;await((s=n.cleanup)==null?void 0:s.call(n))}return new Li(r.create(e),r,e)};class re extends Do.Observer{async cleanup(){}}class Dr extends re{async set(){return await Promise.resolve()}}m(Dr,"TYPE","noop-boolean-sink");const Es={type:Dr.TYPE,props:{},variant:"sink",valueType:"boolean"};class zr extends re{async set(){return await Promise.resolve()}}m(zr,"TYPE","noop-numeric-sink");const lc={type:zr.TYPE,props:{},variant:"sink",valueType:"number"};class Lr extends re{async value(){return await Promise.resolve(!1)}}m(Lr,"TYPE","noop-boolean-source");const Io={type:Lr.TYPE,props:{},variant:"source",valueType:"boolean"};class Ir extends re{async value(){return 0}}m(Ir,"TYPE","noop-numeric-source");const uc={type:Ir.TYPE,props:{},variant:"source",valueType:"number"};class $r extends re{async value(){return""}}m($r,"TYPE","noop-string-source");const hc={type:$r.TYPE,props:{},variant:"source",valueType:"string"};class Yr extends re{async value(){return{key:"noop",variant:"disabled",message:"unknown",time:T.m.now()}}}m(Yr,"TYPE","noop-status-source");const $o={type:Yr.TYPE,props:{},variant:"source",valueType:"status"};class Br extends re{async value(){return f.ZERO}}m(Br,"TYPE","noop-color-source");const fc={type:Br.TYPE,props:{},variant:"source",valueType:"color"};class qr extends re{async value(){return[f.G.ZERO,[]]}}m(qr,"TYPE","noop-series");const dc={type:qr.TYPE,props:{},variant:"source",valueType:"series"},af={[Dr.TYPE]:Dr,[zr.TYPE]:zr,[Lr.TYPE]:Lr,[Ir.TYPE]:Ir,[Yr.TYPE]:Yr,[Br.TYPE]:Br,[$r.TYPE]:$r,[qr.TYPE]:qr};class pc{constructor(){m(this,"type","noop")}create(e){const n=af[e.type];return n==null?null:new n}}const cf=b.z.instanceof(ArrayBuffer),ir=b.z.object({type:b.z.string(),variant:b.z.enum(["source","sink","source-transformer","sink-transformer"]),valueType:b.z.string(),props:b.z.any(),transfer:b.z.array(cf).optional()}),se=ir.extend({variant:b.z.literal("source")}),bs=ir.extend({variant:b.z.literal("sink")}),gc=ir.extend({variant:b.z.literal("source-transformer")}),mc=ir.extend({variant:b.z.literal("sink-transformer")}),Fr=se.extend({valueType:b.z.literal("series")}),Yo=se.extend({valueType:b.z.literal("boolean")}),Ts=bs.extend({valueType:b.z.literal("boolean")}),lf=mc.extend({valueType:b.z.literal("boolean")}),uf=gc.extend({valueType:b.z.literal("boolean")}),yc=se.extend({valueType:b.z.literal("number")}),wc=bs.extend({valueType:b.z.literal("number")}),xc=se.extend({valueType:b.z.literal("color")}),Bo=se.extend({valueType:b.z.literal("status")}),vc=se.extend({valueType:b.z.literal("string")});class _s extends Do.BaseObserver{constructor(n){super();m(this,"props_");m(this,"uProps_");m(this,"schema");this.uProps_=n}get props(){if(this.props_==null){const n=this._schema.safeParse(this.uProps_);if(n.success)this.props_=n.data;else throw new T.B$1(`[BaseTelem] - expected props to be valid, but found the following errors:
|
|
2
|
+
${n.error.message}`)}return this.props_}get _schema(){if(this.schema==null)throw new T.B$1(`[BaseTelem] - expected subclass to define props schema, but none was found.
|
|
3
|
+
Make sure to define a property 'schema' on the class.`);return this.schema}async cleanup(){}}class _t extends _s{}class Cs extends _s{}class ar extends _t{constructor(){super(...arguments);m(this,"sources",{})}get source(){const[n]=Object.values(this.sources);if(n==null)throw new T.B$1("[UnarySourceTransformer] - expected source to exist, but none was found.");return n}async value(){return this.transform(await this.source.value())}onChange(n){return this.source.onChange(()=>{this.source.value().then(r=>{this.shouldNotify(r)&&n()}).catch(console.error)})}setSources(n){this.sources=n}shouldNotify(n){return!0}transform(n){throw new T.B$1(`[UnarySourceTransformer] - expected subclass to define transform method, but none was found.
|
|
4
|
+
Make sure to define a method 'transform' on the class.`)}}class Sc extends _t{constructor(){super(...arguments);m(this,"sources",{})}async value(){const n=Object.fromEntries(await Promise.all(Object.entries(this.sources).map(async([r,s])=>[r,await s.value()])));return this.transform(n)}setSources(n){this.sources={...this.sources,...n}}transform(n){throw new T.B$1(`[MultiSourceTransformer] - expected subclass to define transform method, but none was found.
|
|
5
|
+
Make sure to define a method 'transform' on the class.`)}}class Ec extends _s{constructor(){super(...arguments);m(this,"sinks",{})}get sink(){const[n]=Object.values(this.sinks);if(n==null)throw new T.B$1("[UnarySinkTransformer] - expected sink to exist, but none was found.");return n}async set(n){return await this.sink.set(this.transform(n))}setSinks(n){this.sinks={...this.sinks,...n}}transform(n){throw new T.B$1(`[UnarySinkTransformer] - expected subclass to define transform method, but none was found.
|
|
6
|
+
Make sure to define a method 'transform' on the class.`)}}const bc=b.z.object({from:b.z.string(),to:b.z.string()}),qo=b.z.object({connections:b.z.array(bc),outlet:b.z.string(),segments:b.z.record(se)});class Tc{constructor(e){m(this,"type","pipeline");m(this,"factory");this.factory=e}create(e){switch(e.type){case zn.TYPE:return new zn(e.props,this.factory);case Ln.TYPE:return new Ln(e.props,this.factory);default:return null}}}class zn extends _t{constructor(n,r){super(n);m(this,"schema",qo);m(this,"sources",{});const{connections:s,segments:o}=this.props;Object.entries(o).forEach(([i,a])=>{const c=r.create(a);c!=null&&(this.sources[i]=c)}),s.forEach(({from:i,to:a})=>{const c=this.sources[i],l=this.sources[a];c==null||l==null||"setSources"in l&&l.setSources({[i]:c})})}get outlet(){const{outlet:n}=this.props,r=this.sources[n];if(r==null)throw new T.B$1(`[SourcePipeline] - expected source to exist at outlet '${n}', but none was found.`);return r}async value(){return await this.outlet.value()}onChange(n){return this.outlet.onChange(n)}async cleanup(){await Promise.all(Object.values(this.sources).map(async n=>{var r;return await((r=n.cleanup)==null?void 0:r.call(n))}))}}m(zn,"TYPE","source-pipeline");const _c=(t,e)=>({variant:"source",props:e,type:zn.TYPE,valueType:t}),Fo=b.z.object({connections:b.z.array(bc),inlet:b.z.string(),segments:b.z.record(bs)});class Ln extends Cs{constructor(n,r){super(n);m(this,"schema",Fo);m(this,"sinks",{});const{connections:s,segments:o}=this.props;Object.entries(o).forEach(([i,a])=>{const c=r.create(a);c!=null&&(this.sinks[i]=c)}),s.forEach(({from:i,to:a})=>{const c=this.sinks[i],l=this.sinks[a];c==null||l==null||"setSinks"in c&&c.setSinks({[a]:l})})}get inlet(){const{inlet:n}=this.props,r=this.sinks[n];if(r==null)throw new T.B$1(`[SinkPipeline] - expected source to exist at inlet '${n}', but none was found.`);return r}async set(n){return await this.inlet.set(n)}async cleanup(){await Promise.all(Object.values(this.sinks).map(async n=>{var r;return await((r=n.cleanup)==null?void 0:r.call(n))}))}}m(Ln,"TYPE","sink-pipeline");const Cc=(t,e)=>({variant:"sink",props:e,type:Ln.TYPE,valueType:t}),Zo=b.z.object({channel:b.z.number().or(b.z.string())});class In extends _t{constructor(n,r){super(r);m(this,"client");m(this,"removeStreamHandler",null);m(this,"channelKey",0);m(this,"schema",Zo);m(this,"leadingBuffer",null);m(this,"valid",!1);this.client=n}get testingOnlyLeadingBuffer(){return this.leadingBuffer}get testingOnlyValid(){return this.valid}async cleanup(){var n,r;await((n=this.removeStreamHandler)==null?void 0:n.call(this)),this.valid=!1,(r=this.leadingBuffer)==null||r.release(),this.leadingBuffer=null,this.removeStreamHandler=null}async value(){return T.w$1(this.props.channel)||(this.channelKey===0&&(this.channelKey=(await Uo(this.client,this.props.channel,!1)).key),this.valid||await this.read(),this.leadingBuffer==null||this.leadingBuffer.length===0)?0:this.leadingBuffer.at(-1,!0)}async read(){this.valid=!0,await this.updateStreamHandler()}async updateStreamHandler(){var r;await((r=this.removeStreamHandler)==null?void 0:r.call(this));const n=s=>{var a;const i=s[this.channelKey].data;if(i.length!==0){const c=i[i.length-1];c.acquire(),(a=this.leadingBuffer)==null||a.release(),this.leadingBuffer=c}this.notify()};this.removeStreamHandler=await this.client.stream(n,[this.channelKey])}}m(In,"TYPE","stream-channel-value");const Uo=async(t,e,n)=>{const r=await t.retrieveChannel(e);return!n||r.isIndex?{key:r.key,dataType:r.dataType,virtual:r.virtual}:{key:r.index,dataType:T.g.TIMESTAMP,virtual:!1}},hf=b.z.object({timeRange:T.E.z,channel:b.z.number().or(b.z.string()),useIndexOfChannel:b.z.boolean().optional().default(!1)});class $n extends _t{constructor(n,r){super(r);m(this,"client");m(this,"data",[]);m(this,"valid",!1);m(this,"schema",hf);this.client=n}async cleanup(){this.data.forEach(n=>n.release()),this.valid=!1}async value(){const{timeRange:n,channel:r,useIndexOfChannel:s}=this.props;if(n.isZero||r===0)return[f.G.ZERO,[]];const o=await Uo(this.client,r,s);this.valid||await this.readFixed(o.key);let i=f.G.max(this.data.map(a=>a.bounds));return o.dataType.equals(T.g.TIMESTAMP)&&(i={upper:Math.min(i.upper,Number(this.props.timeRange.end.valueOf())),lower:Math.max(i.lower,Number(this.props.timeRange.start.valueOf()))}),[i,this.data]}async readFixed(n){const s=(await this.client.read(this.props.timeRange,[n]))[n].data;s.forEach(o=>o.acquire()),this.data=s,this.valid=!0}}m($n,"TYPE","series-source");const ff=b.z.object({channel:b.z.number().or(b.z.string()),useIndexOfChannel:b.z.boolean().optional().default(!1),timeSpan:T.y.z,keepFor:T.y.z.optional()});class Yn extends _t{constructor(n,r){super(r);m(this,"client");m(this,"data",[]);m(this,"stopStreaming");m(this,"valid",!1);m(this,"schema",ff);this.client=n}async value(){const{channel:n,useIndexOfChannel:r,timeSpan:s}=this.props;if(n===0)return[f.G.ZERO,[]];const o=T.m.now(),i=await Uo(this.client,n,r);if(this.valid||await this.read(i),i.dataType.isVariable)return[f.G.ZERO,this.data];let a=f.G.max(this.data.filter(c=>c.timeRange.end.after(o.sub(s))).map(c=>c.bounds));return i.dataType.equals(T.g.TIMESTAMP)&&(a={upper:a.upper,lower:Math.max(a.lower,a.upper-Number(s.valueOf()))}),[a,this.data]}async read({key:n,virtual:r}){const s=T.m.now().spanRange(-this.props.timeSpan);if(!r){const i=(await this.client.read(s,[n]))[n].data;i.forEach(a=>a.acquire()),this.data.push(...i)}await this.updateStreamHandler(n),this.valid=!0}async updateStreamHandler(n){this.stopStreaming!=null&&await this.stopStreaming();const r=s=>{const o=s[n].data;o.forEach(i=>i.acquire()),this.data.push(...o),this.gcOutOfRangeData(),this.notify()};this.stopStreaming=await this.client.stream(r,[n])}gcOutOfRangeData(){const n=T.m.now().sub(this.props.keepFor??this.props.timeSpan),r=this.data.findIndex(s=>s.timeRange.end.before(n));r!==-1&&(this.data.splice(r,1).forEach(s=>s.release()),this.gcOutOfRangeData())}async cleanup(){var n;await((n=this.stopStreaming)==null?void 0:n.call(this)),this.stopStreaming=void 0,this.data.forEach(r=>r.release())}}m(Yn,"TYPE","dynamic-series-source");const df={[$n.TYPE]:$n,[Yn.TYPE]:Yn,[In.TYPE]:In};class Pc{constructor(e){m(this,"type","remote");m(this,"client");this.client=e}create(e){const n=df[e.type];return n==null?null:new n(this.client,e.props)}}const kc=t=>({type:$n.TYPE,props:t,variant:"source",valueType:"series"}),Rc=t=>({type:Yn.TYPE,props:t,variant:"source",valueType:"series"}),Mc=t=>({type:In.TYPE,props:t,variant:"source",valueType:"number"});class Ac{constructor(){m(this,"type","static")}create(e){switch(e.type){case Zr.TYPE:return new Zr(e.props);case Bn.TYPE:return new Bn(e.props);case qn.TYPE:return new qn(e.props);case Fn.TYPE:return new Fn(e.props);default:return null}}}const Ho=b.z.object({data:b.z.array(T.xt),offsets:b.z.array(b.z.number()).optional().default([])});class Zr extends _t{constructor(n){super(n);m(this,"data");m(this,"schema",Ho);this.data=this.props.data.map((r,s)=>new T.V({data:r,dataType:T.g.FLOAT32,timeRange:T.E.ZERO,sampleOffset:this.props.offsets[s]??0}))}async value(){return[f.G.max(this.data.map(r=>r.bounds)),this.data]}}m(Zr,"TYPE","static-series");const Nc=Ho.extend({rate:T.P.z,yOffset:b.z.number().optional().default(0),scroll:b.z.number().optional().default(0),startPosition:b.z.number().optional().default(0),scrollBounds:b.z.boolean().optional().default(!1)});class Bn extends _t{constructor(n){super(n);m(this,"schema",Nc);m(this,"position");m(this,"interval");m(this,"data");this.position=this.props.startPosition,this.start(this.props.rate),this.data=this.props.data.map((r,s)=>new T.V({data:r,dataType:T.g.FLOAT32,timeRange:T.E.ZERO,sampleOffset:this.props.offsets[s]??0}))}async value(){const n=this.data.map(s=>s.slice(0,this.position));if(this.props.scrollBounds){const s=n[0].data[this.position-this.props.scroll<0?0:this.position-this.props.scroll],o=n[0].data[this.position-1];return[{lower:Number(s),upper:Number(o)},n]}return[f.G.max(n.map(s=>s.bounds)),n]}start(n){this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{var r;(r=this.notify)==null||r.call(this),this.position++},n.period.milliseconds)}async cleanup(){clearInterval(this.interval),this.interval=void 0}}m(Bn,"TYPE","iterative-series");const Oc=b.z.number();class qn extends _t{constructor(){super(...arguments);m(this,"schema",Oc)}async value(){return this.props}}m(qn,"TYPE","static-numeric");const Dc=b.z.string();class Fn extends _t{constructor(){super(...arguments);m(this,"schema",Dc)}async value(){return this.props}}m(Fn,"TYPE","static-string");const pf=t=>({type:Zr.TYPE,props:t,variant:"source",valueType:"series"}),gf=t=>({type:Bn.TYPE,props:t,variant:"source",valueType:"series"}),mf=t=>({type:qn.TYPE,props:t,variant:"source",valueType:"number"}),yf=t=>({type:Fn.TYPE,props:t,variant:"source",valueType:"string"});class zc{constructor(){m(this,"type","transformer")}create(e){switch(e.type){case Ue.TYPE:return new Ue(e.props);case He.TYPE:return new He(e.props);case Ve.TYPE:return new Ve(e.props);case Ge.TYPE:return new Ge(e.props);case Xe.TYPE:return new Xe(e.props);case We.TYPE:return new We(e.props)}return null}}const wf=b.z.object({truthy:b.z.number().optional().default(1),falsy:b.z.number().optional().default(0)}),Lc=t=>({props:t,type:Ue.TYPE,variant:"sink",valueType:"boolean"}),kn=class kn extends Ec{constructor(){super(...arguments);m(this,"schema",kn.propsZ)}transform(n){return n?this.props.truthy:this.props.falsy}};m(kn,"TYPE","boolean-numeric-converter-sink"),m(kn,"propsZ",wf);let Ue=kn;const xf=b.z.object({trueBound:f.G.bounds}),Ic=t=>({props:t,type:He.TYPE,variant:"source",valueType:"boolean"}),Rn=class Rn extends ar{constructor(){super(...arguments);m(this,"schema",Rn.propsZ);m(this,"curr",null)}shouldNotify(n){const r=f.G.contains(this.props.trueBound,n)!==this.curr;return this.curr=f.G.contains(this.props.trueBound,n),r}transform(n){return this.curr=f.G.contains(this.props.trueBound,n),this.curr}};m(Rn,"TYPE","boolean-source"),m(Rn,"propsZ",xf);let He=Rn;const $c=b.z.object({}),Mn=class Mn extends Sc{constructor(){super(...arguments);m(this,"schema",Mn.propsZ)}transform(n){return Object.values(n).reduce((r,s)=>r+s,0)/Object.keys(n).length}};m(Mn,"TYPE","mean"),m(Mn,"propsZ",$c);let Ve=Mn;const vf=t=>({props:t,type:Ve.TYPE,variant:"source",valueType:"boolean"}),Yc=b.z.object({trueVariant:T.variantZ.optional().default("success")}),An=class An extends ar{constructor(){super(...arguments);m(this,"schema",An.propsZ)}transform(n){return n.variant===this.props.trueVariant}};m(An,"TYPE","boolean-status"),m(An,"propsZ",Yc);let Ge=An;const Sf=t=>({props:t,type:Ge.TYPE,variant:"source",valueType:"boolean"}),Vo=b.z.object({precision:b.z.number().optional().default(2),prefix:b.z.string().optional().default(""),suffix:b.z.string().optional().default("")}),Nn=class Nn extends ar{constructor(){super(...arguments);m(this,"schema",Nn.propsZ)}transform(n){return`${this.props.prefix}${n.toFixed(this.props.precision)}${this.props.suffix}`}};m(Nn,"TYPE","stringify-number"),m(Nn,"propsZ",Vo);let Xe=Nn;const Bc=t=>({props:t,type:Xe.TYPE,variant:"source",valueType:"string"}),Go=b.z.object({windowSize:b.z.number().optional().default(5)});class We extends ar{constructor(){super(...arguments);m(this,"schema",Go);m(this,"values",[])}transform(n){return this.props.windowSize<2?n:this.values.reduce((r,s)=>r+s,0)/this.values.length}shouldNotify(n){return this.props.windowSize<2?!0:(this.values.length>this.props.windowSize&&(this.values=[]),this.values.push(n),this.values.length===this.props.windowSize)}}m(We,"TYPE","rolling-average"),m(We,"propsZ",$c);const qc=t=>({props:t,type:We.TYPE,variant:"source",valueType:"number"});class Fc{constructor(e){m(this,"factories");m(this,"type","compound");this.factories=e}add(e){this.factories=[...this.factories.filter(n=>n.type!==e.type),e]}create(e){for(const n of this.factories){const r=n.create(e);if(r!=null)return r}return null}}const Zc=t=>{const e=[new zc,new Ac,new pc],n=new Fc(e);return t!=null&&n.add(new Pc(t)),n.add(new Tc(n)),n},Uc=b.z.object({include:b.z.string().array().optional(),exclude:b.z.string().array().optional(),level:b.z.enum(T.g$1.LOG_LEVELS).optional().default("info")}),ao="alamos-provider";var io;let co=(io=class extends T.Composite{constructor(){super(...arguments);m(this,"schema",Uc)}async afterUpdate(){if(this.ctx.getOptional(ao)!=null)return;const r=[],{include:s,exclude:o,level:i}=this.state;(s!=null||o!=null)&&r.push(T.g$1.logLevelKeyFiler({include:s,exclude:o})),i!=null&&r.push(T.g$1.logThresholdFilter(i)),r.length===0&&r.push(()=>!1),this.internal.ins=new T.g$1.Instrumentation({key:"aether",logger:new T.g$1.Logger({filters:r})}),this.ctx.set(ao,this.internal.ins)}},m(io,"TYPE","AlamosProvider"),io);const cr=(t,e)=>{const n=t.get(ao);if(n==null)throw new Error("No instrumentation provider");return e==null?n:n.child(e)},Ef={[co.TYPE]:co},Hc=(t,e)=>t.dataType.isVariable?t:(e==null&&t.dataType.equals(T.g.TIMESTAMP)&&(e=BigInt(t.data[0])),t.convert(T.g.FLOAT32,e)),Vc=()=>({purgedSeries:0,purgedBytes:T.x.bytes(0)}),Gc={instrumentation:T.g$1.NOOP,staleEntryThreshold:T.y.seconds(20)};class bf{constructor(e){m(this,"data",[]);m(this,"props");this.props={...Gc,...e}}write(e){e.length!==0&&(e.forEach(n=>this.writeOne(Hc(n))),this.checkIntegrity(e))}dirtyRead(e){const n=this.data.filter(({data:i})=>i.timeRange.overlapsWith(e)).map(({data:i})=>i);if(n.length===0)return{series:[],gaps:[e]};const r=n.map((i,a)=>a===0?T.E.ZERO:new T.E(n[a-1].timeRange.end,i.timeRange.start)).filter(i=>!i.isZero&&i.isValid),s=new T.E(e.start,n[0].timeRange.start),o=new T.E(n[n.length-1].timeRange.end,e.end);return s.isValid&&!s.isZero&&r.unshift(s),o.isValid&&!o.isZero&&r.push(o),{series:n,gaps:r}}gc(){const{staleEntryThreshold:e}=this.props,n=Vc(),r=this.data.filter(s=>{const o=s.data.refCount>0||T.m.since(s.addedAt).lessThan(e);return o||(n.purgedBytes=n.purgedBytes.add(s.data.byteCapacity)),o});return n.purgedSeries=this.data.length-r.length,this.data=r,n}close(){this.data=[]}writeOne(e){const{instrumentation:{L:n}}=this.props;if(e.length===0)return;const r=f.G.buildInsertionPlan(this.data.map(c=>c.data.alignmentBounds),e.alignmentBounds);if(r===null)return n.debug("Found no viable insertion plan",{inserting:e.digest,cacheContents:this.data.map(c=>c.data.digest)});const{removeBefore:s,removeAfter:o,insertInto:i,deleteInBetween:a}=r;e=e.slice(s,e.data.length-Number(o)),e.length!==0&&this.data.splice(i,a,{data:e,addedAt:T.m.now()})}checkIntegrity(e){const{instrumentation:{L:n}}=this.props,r=this.data.map(o=>o.data.alignmentBounds);if(r.some((o,i)=>r.some((a,c)=>i===c?!1:f.G.overlapsWith(o,a))))throw n.debug("Cache is in an invalid state - bounds overlap!",()=>({write:e.map(o=>o.digest),cacheContents:this.data.map(o=>o.data.digest)})),new Error("Invalid state")}}const Tf=100,_f=1e6,Cf=1e4,Pf=100,kf=40;class Rf{constructor(e){m(this,"props");m(this,"counter",0);m(this,"curr");m(this,"avgRate",0);m(this,"timeOfLastWrite");m(this,"totalWrites",0);m(this,"now",()=>T.m.now());this.props=e,this.curr=null,e.testingNow!=null&&(this.now=e.testingNow),this.timeOfLastWrite=this.now()}get length(){var e;return((e=this.curr)==null?void 0:e.length)??0}get leadingBuffer(){return this.curr}write(e){const n=e.flatMap(r=>this._write(r));return{flushed:n.flatMap(r=>r.flushed),allocated:n.flatMap(r=>r.allocated)}}allocate(e,n,r){this.counter++;const s=this.props.dataType.isVariable,o=this.props.dataType.equals(T.g.TIMESTAMP);return T.V.alloc({capacity:s?e*kf:e,dataType:s?this.props.dataType:T.g.FLOAT32,timeRange:r.range(T.m.MAX),sampleOffset:o?BigInt(r.valueOf()):0,glBufferUsage:"dynamic",alignment:n,key:`dynamic-${this.counter}`})}_write(e){const n=this.nextBufferSize(),r={flushed:[],allocated:[]};if(this.curr==null)this.curr=this.allocate(n,e.alignment,this.now()),r.allocated.push(this.curr);else if(Math.abs(Number(this.curr.alignment+BigInt(this.curr.length)-e.alignment))>1){const c=this.now();this.curr.timeRange.end=c,r.flushed.push(this.curr),this.curr=this.allocate(n,e.alignment,c),r.allocated.push(this.curr)}const s=Hc(e,this.curr.sampleOffset),o=this.curr.write(s);if(o===e.length)return this.updateAvgRate(e),r;const i=this.now();this.curr.timeRange.end=i,r.flushed.push(this.curr),this.curr=this.allocate(n,e.alignment+BigInt(o),i),r.allocated.push(this.curr);const a=this._write(e.slice(o));return r.flushed.push(...a.flushed),r.allocated.push(...a.allocated),r}updateAvgRate(e){if(typeof this.props.dynamicBufferSize=="number")return;const n=e.length/this.now().span(this.timeOfLastWrite).seconds;this.totalWrites>0&&isFinite(n)&&n>0&&(this.avgRate=(this.avgRate*(this.totalWrites-1)+n)/this.totalWrites),this.totalWrites++,this.timeOfLastWrite=this.now()}nextBufferSize(){const{dynamicBufferSize:e}=this.props;if(typeof e=="number")return e;if(this.totalWrites<Pf)return Cf;const n=f.W.roundToNearestMagnitude(this.avgRate*e.seconds);return Math.round(Math.max(Math.min(n,_f),Tf))}close(){this.curr=null}}class Mf{constructor(e){m(this,"channel");m(this,"closed",!1);m(this,"ins");m(this,"static");m(this,"dynamic");this.channel=e.channel,this.ins=e.instrumentation??T.g$1.NOOP,this.static=new bf(e),this.dynamic=new Rf({dynamicBufferSize:e.dynamicBufferSize,dataType:this.channel.dataType})}writeDynamic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted dynamic write to a closed cache for channel ${this.channel.name}`),[];const{flushed:n,allocated:r}=this.dynamic.write(e);return n.length>0&&this.static.write(n),r}get leadingBuffer(){return this.dynamic.leadingBuffer}writeStatic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted static write to a closed cache for channel ${this.channel.name}`);this.static.write(e)}read(e){return this.closed?(this.ins.L.warn(`Ignoring attempted dirty read from a closed cache for channel ${this.channel.name}`),{series:[],gaps:[]}):this.static.dirtyRead(e)}gc(){return this.closed?(this.ins.L.warn(`Ignoring attempted garbage collection on a closed cache for channel ${this.channel.name}`),{purgedSeries:0,purgedBytes:T.x.bytes(0)}):this.static.gc()}close(){this.closed=!0,this.dynamic.close(),this.static.close()}}const Af=T.k.seconds(60);class Nf{constructor(e){m(this,"props");m(this,"cache",new Map);m(this,"gcInterval");this.props={dynamicBufferSize:Af,gcInterval:T.k.seconds(30),...Gc,...e},this.gcInterval=setInterval(()=>this.gc(),this.props.gcInterval.milliseconds)}async populateMissing(e){const{instrumentation:n,channelRetriever:r,dynamicBufferSize:s}=this.props,o=[];for(const a of e)this.cache.has(a)||o.push(a);if(o.length===0)return;const i=await r.retrieve(o);for(const a of i){const c=new Mf({channel:a,dynamicBufferSize:s,instrumentation:n.child(`cache-${a.name}-${a.key}`)});this.cache.has(a.key)||this.cache.set(a.key,c)}}get(e){const n=this.cache.get(e);if(n!=null)return n;throw new T.Ce(`cache entry for ${e} not found`)}gc(){const{instrumentation:{L:e}}=this.props;e.info("starting garbage collection");const n=Vc();this.cache.forEach(r=>{const s=r.gc();n.purgedSeries+=s.purgedSeries,n.purgedBytes=n.purgedBytes.add(s.purgedBytes)}),e.info("garbage collection complete",{purgedSeries:n.purgedSeries,purgedBytes:n.purgedBytes.toString()},!0)}close(){clearInterval(this.gcInterval),this.cache.forEach(e=>e.close()),this.cache.clear()}}class Ur{constructor(e,n){m(this,"channel");m(this,"data");this.channel=e,this.data=n}get timeRange(){if(this.data.length===0)return T.V$1.ZERO;const e=this.data[0].timeRange,n=this.data[this.data.length-1].timeRange;return new T.V$1(e.start,n.end)}get digest(){return{channel:this.channel.key,timeRange:this.timeRange.toPrettyString(),series:this.data.map(e=>e.digest)}}}const Bs=t=>t.map(e=>e.digest);class Of{constructor(e){m(this,"props");m(this,"debouncedRead");m(this,"guarded",{mu:new T.Mutex,requests:new Map});this.props={instrumentation:T.g$1.NOOP,batchDebounce:T.y.milliseconds(50),...e},this.debouncedRead=T.o$1(()=>{this.batchRead()},this.props.batchDebounce.milliseconds)}async read(e,n){const{instrumentation:{L:r},cache:s}=this.props;r.debug("starting read",{tr:e.toPrettyString(),channels:n});const o=performance.now(),i=new Map,a={};await s.populateMissing(n);try{for(const u of n){const h=s.get(u),{series:d,gaps:p}=h.read(e);p.length===0&&(a[u]=new Ur(h.channel,d)),p.forEach(w=>{const y=i.get(w.toString());y==null?i.set(w.toString(),[w,new Set([u])]):i.set(w.toString(),[w,new Set([...y[1],u])])})}if(i.size===0)return r.debug("read satisfied by cache",()=>({tr:e.toPrettyString(),channels:n,responses:Bs(Object.values(a)),time:T.y.milliseconds(performance.now()-o).toString()})),a;r.debug("read cache miss",()=>({tr:e.toPrettyString(),channels:n,toFetch:Array.from(i.values()).map(([u,h])=>({timeRange:u.toPrettyString(),channels:h})),responses:Bs(Object.values(a))}));const{mu:c,requests:l}=this.guarded;for(const[,[u,h]]of i)await new Promise((d,p)=>{c.runExclusive(async()=>{l.set([u,h],{resolve:d,reject:p}),this.debouncedRead()})})}catch(c){throw r.error("read failed",{tr:e.toPrettyString(),channels:n,error:c}),c}for(const c of n){const l=s.get(c),{series:u}=l.read(e);a[c]=new Ur(l.channel,u)}return r.debug("read satisfied by fetch",()=>({tr:e.toPrettyString(),channels:n,responses:Bs(Object.values(a)),time:T.y.milliseconds(performance.now()-o).toString()})),a}async batchRead(){const{instrumentation:{L:e},readRemote:n,cache:r}=this.props,{mu:s,requests:o}=this.guarded;await s.runExclusive(async()=>{const i=[];try{o.forEach((a,c)=>{const[l,u]=c,h=i.find(([d])=>d.start.span(l.start).lessThan(T.y.milliseconds(5))&&d.end.span(l.end).lessThan(T.y.milliseconds(5)));h==null?i.push([l,u]):h[1]=new Set([...h[1],...u])}),e.debug("batch read",{toFetch:i.map(([a,c])=>({timeRange:a.toPrettyString(),channels:c}))});for(const[a,c]of i){const l=Array.from(c),u=await n(a,l);l.forEach(h=>{const d=r.get(h),p=u.get(h);d.writeStatic(p.series)})}o.forEach(a=>a.resolve())}catch(a){e.error("batch read failed",{error:a},!0),o.forEach(c=>c.reject(a))}finally{o.clear()}})}}class Df{constructor(e){m(this,"props");m(this,"mu",new T.Mutex);m(this,"listeners",new Map);m(this,"streamerRunLoop",null);m(this,"streamer",null);m(this,"closed",!1);this.props={instrumentation:T.g$1.NOOP,...e}}async stream(e,n){const{cache:r,instrumentation:{L:s}}=this.props;return await r.populateMissing(n),await this.mu.runExclusive(async()=>{s.debug("adding stream handler",{keys:n}),this.listeners.set(e,{valid:!0,keys:n});const o={};for(const i of n){const a=r.get(i),c=a.leadingBuffer!=null?[a.leadingBuffer]:[];o[i]=new Ur(a.channel,c)}return e(o),await this.updateStreamer(),async()=>await this.removeStreamHandler(e)})}async removeStreamHandler(e){const{instrumentation:{L:n}}=this.props;await this.mu.runExclusive(()=>{const r=this.listeners.get(e);r!=null&&(r.valid=!1)}),setTimeout(()=>{this.mu.runExclusive(async()=>{if(n.debug("removing stream handler"),this.listeners.delete(e))return await this.updateStreamer();n.warn("attempted to remove non-existent stream handler")})},5e3)}async updateStreamer(){var o,i;if(this.closed)return;const{instrumentation:{L:e},core:n}=this.props,r=new Set;if(this.listeners.forEach(a=>a.keys.forEach(c=>r.add(c))),r.size===0){e.info("no keys to stream, closing streamer"),(o=this.streamer)==null||o.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.streamer=null,e.info("streamer closed successfully");return}const s=Array.from(r);if(T.F.primitiveArrays(s,((i=this.streamer)==null?void 0:i.keys)??[])===T.F.EQUAL){e.debug("streamer keys unchanged",{keys:s});return}this.streamer==null&&(e.info("creating new streamer",{keys:s}),this.streamer=await n.openStreamer(s),this.streamerRunLoop=this.runStreamer(this.streamer)),e.debug("updating streamer",{prev:this.streamer.keys,next:s});try{await this.streamer.update(s)}catch(a){throw e.error("failed to update streamer",{error:a}),a}}async runStreamer(e){const{cache:n,instrumentation:{L:r}}=this.props;try{for await(const s of e){const o=[];for(const i of s.keys){const a=s.get(i),c=n.get(i),l=c.writeDynamic(a.series);o.push(new Ur(c.channel,l))}this.listeners.forEach((i,a)=>{if(!i.valid)return;const c=o.filter(u=>i.keys.includes(u.channel.key));if(c.length===0)return;const l=Object.fromEntries(c.map(u=>[u.channel.key,u]));a(l)})}}catch(s){throw r.error("streamer run loop failed",{error:s},!0),s}}async close(){var e;(e=this.streamer)==null||e.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.closed=!0}}class zf{constructor(){m(this,"key",T.Rt.id());m(this,"_client",null)}async swap(e){var n;this.key=T.Rt.id(),await((n=this._client)==null?void 0:n.close()),this._client=e}async retrieveChannel(e){return await this.client.retrieveChannel(e)}async read(e,n){return await this.client.read(e,n)}async stream(e,n){return await this.client.stream(e,n)}async close(){await this.client.close()}get client(){if(this._client==null)throw new T.re("No cluster has been connected");return this._client}}class Lf{constructor({instrumentation:e,core:n}){m(this,"key",T.Rt.id());m(this,"ins");m(this,"cache");m(this,"reader");m(this,"streamer");m(this,"channelRetriever");this.ins=e??T.g$1.NOOP,this.channelRetriever=n.channels.createDebouncedBatchRetriever(10),this.cache=new Nf({channelRetriever:this.channelRetriever,instrumentation:this.ins.child("cache")}),this.reader=new Of({cache:this.cache,readRemote:async(r,s)=>await n.read(r,s),instrumentation:this.ins.child("reader")}),this.streamer=new Df({cache:this.cache,core:n,instrumentation:this.ins.child("streamer")})}async retrieveChannel(e){const n=await this.channelRetriever.retrieve([e]);if(n.length===0)throw new T.re(`channel ${e} not found`);return n[0]}async read(e,n){return await this.reader.read(e,n)}async stream(e,n){return await this.streamer.stream(e,n)}async close(){this.ins.L.info("closing client",{key:this.key}),await this.streamer.close(),this.cache.close()}}const Xo=b.z.object({}),Ie=class Ie extends T.Composite{constructor(){super(...arguments);m(this,"client",new zf);m(this,"factory",Zc(this.client));m(this,"schema",Ie.stateZ);m(this,"prevClient",null)}create(n){const{instrumentation:r}=this.internal;r.L.debug("creating telem",{spec:n});const s=this.factory.create(n);if(s==null)throw new T.Ce(`Telemetry service could not find a source for type ${n.type}`);return s}get clusterKey(){return this.client.key}registerFactory(n){this.factory.add(n)}equals(n){return n instanceof Ie?this.client._client===n.client._client:!1}async afterUpdate(){const n=sr(this.ctx),r=cr(this.ctx,"telem");this.internal.instrumentation=r.child("provider"),n!==this.prevClient&&(r.L.info("swapping client",{client:n}),n==null?await this.client.swap(null):await this.client.swap(new Lf({core:n,instrumentation:r})),this.prevClient=n,ac(this.ctx,this))}};m(Ie,"TYPE","TelemProvider"),m(Ie,"stateZ",Xo);let Ke=Ie;const Xc={[Ke.TYPE]:Ke},If=Object.freeze(Object.defineProperty({__proto__:null,AbstractSink:Cs,AbstractSource:_t,Base:_s,BaseProvider:Ke,BooleanStatus:Ge,ChannelData:$n,CompoundTelemFactory:Fc,FixedNumber:qn,FixedString:Fn,IterativeSeries:Bn,Mean:Ve,MultiSourceTransformer:Sc,NoopFactory:pc,PipelineFactory:Tc,REGISTRY:Xc,RemoteFactory:Pc,RollingAverage:We,SetPoint:Ue,SinkPipeline:Ln,SourcePipeline:zn,StaticFactory:Ac,StreamChannelData:Yn,StreamChannelValue:In,StringifyNumber:Xe,TransformerFactory:zc,UnarySinkTransformer:Ec,UnarySourceTransformer:ar,WithinBounds:He,booleanSinkSpecZ:Ts,booleanSinkTransformerSpecZ:lf,booleanSourceSpecZ:Yo,booleanSourceTransformerSpecZ:uf,booleanStatus:Sf,booleanStatusProps:Yc,channelData:kc,colorSourceSpecZ:xc,factory:Zc,fixedArray:pf,fixedNumber:mf,fixedNumberPropsZ:Oc,fixedSeriesPropsZ:Ho,fixedString:yf,fixedStringPropsZ:Dc,iterativeArray:gf,iterativeSeriesPropsZ:Nc,mean:vf,noopBooleanSinkSpec:Es,noopBooleanSourceSpec:Io,noopColorSourceSpec:fc,noopNumericSinkSpec:lc,noopNumericSourceSpec:uc,noopSeriesSourceSpec:dc,noopStatusSourceSpec:$o,noopStringSourceSpec:hc,numberSinkSpecZ:wc,numberSourceSpecZ:yc,providerStateZ:Xo,registerFactory:cc,rollingAverage:qc,rollingAverageProps:Go,seriesSourceSpecZ:Fr,setProvider:ac,setpoint:Lc,sinkPipeline:Cc,sinkPipelinePropsZ:Fo,sinkSpecZ:bs,sinkTransformerSpecZ:mc,sourcePipeline:_c,sourcePipelinePropsZ:qo,sourceSpecZ:se,sourceTransformerSpecZ:gc,specZ:ir,statusSourceSpecZ:Bo,streamChannelData:Rc,streamChannelValue:Mc,streamChannelValuePropsZ:Zo,stringSourceSpecZ:vc,stringifyNumber:Bc,stringifyNumberProps:Vo,useProvider:Ss,useSink:or,useSource:At,withinBounds:Ic},Symbol.toStringTag,{value:"Module"})),Wc=b.z.object({key:b.z.string(),size:b.z.number(),order:b.z.number(),loc:f.J.outer});b.z.record(Wc);const de=(t,e)=>Object.values(e).filter(({loc:n})=>n===t).sort((n,r)=>r.order-n.order),$f=(t,e,n)=>{const r=e[t];if(r==null)return f.q.ZERO;const s=f.J.construct(r.loc),o=de(s,e),i=f.J.construct(f.g.swap(f.J.direction(s))),a=de(i,e),c=o.findIndex(({key:h})=>h===t),l=o.slice(0,c).reduce((h,{size:d})=>h+d,0),u=a.reduce((h,{size:d})=>h+d,0);switch(s){case"left":return f.q.translate(f.Eo.topLeft(n),[l,u]);case"right":return f.q.translate(f.Eo.topRight(n),[l-r.size,u]);case"top":return f.q.translate(f.Eo.topLeft(n),[u,l]);default:return f.q.translate(f.Eo.bottomLeft(n),[u,-l-r.size])}},Yf=(t,e)=>{const n=de("left",t),r=de("right",t),s=de("top",t),o=de("bottom",t),i=n.reduce((u,{size:h})=>u+h,0),a=r.reduce((u,{size:h})=>u+h,0),c=s.reduce((u,{size:h})=>u+h,0),l=o.reduce((u,{size:h})=>u+h,0);return f.Eo.construct(f.q.translate(f.Eo.topLeft(e),{x:i,y:c}),f.Eo.width(e)-i-a,f.Eo.height(e)-c-l)};function Pr(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Bf(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Wo(t){let e,n,r;t.length!==2?(e=Pr,n=(a,c)=>Pr(t(a),c),r=(a,c)=>t(a)-c):(e=t===Pr||t===Bf?t:qf,n=t,r=t);function s(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const h=l+u>>>1;n(a[h],c)<0?l=h+1:u=h}while(l<u)}return l}function o(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const h=l+u>>>1;n(a[h],c)<=0?l=h+1:u=h}while(l<u)}return l}function i(a,c,l=0,u=a.length){const h=s(a,c,l,u-1);return h>l&&r(a[h-1],c)>-r(a[h],c)?h-1:h}return{left:s,center:i,right:o}}function qf(){return 0}function Ff(t){return t===null?NaN:+t}const Zf=Wo(Pr),Uf=Zf.right;Wo(Ff).center;const Hf=Math.sqrt(50),Vf=Math.sqrt(10),Gf=Math.sqrt(2);function Hr(t,e,n){const r=(e-t)/Math.max(0,n),s=Math.floor(Math.log10(r)),o=r/Math.pow(10,s),i=o>=Hf?10:o>=Vf?5:o>=Gf?2:1;let a,c,l;return s<0?(l=Math.pow(10,-s)/i,a=Math.round(t*l),c=Math.round(e*l),a/l<t&&++a,c/l>e&&--c,l=-l):(l=Math.pow(10,s)*i,a=Math.round(t/l),c=Math.round(e/l),a*l<t&&++a,c*l>e&&--c),c<a&&.5<=n&&n<2?Hr(t,e,n*2):[a,c,l]}function Xf(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[s,o,i]=r?Hr(e,t,n):Hr(t,e,n);if(!(o>=s))return[];const a=o-s+1,c=new Array(a);if(r)if(i<0)for(let l=0;l<a;++l)c[l]=(o-l)/-i;else for(let l=0;l<a;++l)c[l]=(o-l)*i;else if(i<0)for(let l=0;l<a;++l)c[l]=(s+l)/-i;else for(let l=0;l<a;++l)c[l]=(s+l)*i;return c}function lo(t,e,n){return e=+e,t=+t,n=+n,Hr(t,e,n)[2]}function uo(t,e,n){e=+e,t=+t,n=+n;const r=e<t,s=r?lo(e,t,n):lo(t,e,n);return(r?-1:1)*(s<0?1/-s:s)}function Kc(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Ko(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function jc(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function lr(){}var Zn=.7,Vr=1/Zn,Be="\\s*([+-]?\\d+)\\s*",Un="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",It="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Wf=/^#([0-9a-f]{3,8})$/,Kf=new RegExp(`^rgb\\(${Be},${Be},${Be}\\)$`),jf=new RegExp(`^rgb\\(${It},${It},${It}\\)$`),Jf=new RegExp(`^rgba\\(${Be},${Be},${Be},${Un}\\)$`),Qf=new RegExp(`^rgba\\(${It},${It},${It},${Un}\\)$`),td=new RegExp(`^hsl\\(${Un},${It},${It}\\)$`),ed=new RegExp(`^hsla\\(${Un},${It},${It},${Un}\\)$`),Ii={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ko(lr,we,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:$i,formatHex:$i,formatHex8:nd,formatHsl:rd,formatRgb:Yi,toString:Yi});function $i(){return this.rgb().formatHex()}function nd(){return this.rgb().formatHex8()}function rd(){return Jc(this).formatHsl()}function Yi(){return this.rgb().formatRgb()}function we(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Wf.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Bi(e):n===3?new yt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?dr(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?dr(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Kf.exec(t))?new yt(e[1],e[2],e[3],1):(e=jf.exec(t))?new yt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Jf.exec(t))?dr(e[1],e[2],e[3],e[4]):(e=Qf.exec(t))?dr(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=td.exec(t))?Zi(e[1],e[2]/100,e[3]/100,1):(e=ed.exec(t))?Zi(e[1],e[2]/100,e[3]/100,e[4]):Ii.hasOwnProperty(t)?Bi(Ii[t]):t==="transparent"?new yt(NaN,NaN,NaN,0):null}function Bi(t){return new yt(t>>16&255,t>>8&255,t&255,1)}function dr(t,e,n,r){return r<=0&&(t=e=n=NaN),new yt(t,e,n,r)}function sd(t){return t instanceof lr||(t=we(t)),t?(t=t.rgb(),new yt(t.r,t.g,t.b,t.opacity)):new yt}function ho(t,e,n,r){return arguments.length===1?sd(t):new yt(t,e,n,r??1)}function yt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Ko(yt,ho,jc(lr,{brighter(t){return t=t==null?Vr:Math.pow(Vr,t),new yt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Zn:Math.pow(Zn,t),new yt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new yt(me(this.r),me(this.g),me(this.b),Gr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:qi,formatHex:qi,formatHex8:od,formatRgb:Fi,toString:Fi}));function qi(){return`#${pe(this.r)}${pe(this.g)}${pe(this.b)}`}function od(){return`#${pe(this.r)}${pe(this.g)}${pe(this.b)}${pe((isNaN(this.opacity)?1:this.opacity)*255)}`}function Fi(){const t=Gr(this.opacity);return`${t===1?"rgb(":"rgba("}${me(this.r)}, ${me(this.g)}, ${me(this.b)}${t===1?")":`, ${t})`}`}function Gr(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function me(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function pe(t){return t=me(t),(t<16?"0":"")+t.toString(16)}function Zi(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new kt(t,e,n,r)}function Jc(t){if(t instanceof kt)return new kt(t.h,t.s,t.l,t.opacity);if(t instanceof lr||(t=we(t)),!t)return new kt;if(t instanceof kt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,s=Math.min(e,n,r),o=Math.max(e,n,r),i=NaN,a=o-s,c=(o+s)/2;return a?(e===o?i=(n-r)/a+(n<r)*6:n===o?i=(r-e)/a+2:i=(e-n)/a+4,a/=c<.5?o+s:2-o-s,i*=60):a=c>0&&c<1?0:i,new kt(i,a,c,t.opacity)}function id(t,e,n,r){return arguments.length===1?Jc(t):new kt(t,e,n,r??1)}function kt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Ko(kt,id,jc(lr,{brighter(t){return t=t==null?Vr:Math.pow(Vr,t),new kt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Zn:Math.pow(Zn,t),new kt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,s=2*n-r;return new yt(qs(t>=240?t-240:t+120,s,r),qs(t,s,r),qs(t<120?t+240:t-120,s,r),this.opacity)},clamp(){return new kt(Ui(this.h),pr(this.s),pr(this.l),Gr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Gr(this.opacity);return`${t===1?"hsl(":"hsla("}${Ui(this.h)}, ${pr(this.s)*100}%, ${pr(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Ui(t){return t=(t||0)%360,t<0?t+360:t}function pr(t){return Math.max(0,Math.min(1,t||0))}function qs(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const jo=t=>()=>t;function ad(t,e){return function(n){return t+n*e}}function cd(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function ld(t){return(t=+t)==1?Qc:function(e,n){return n-e?cd(e,n,t):jo(isNaN(e)?n:e)}}function Qc(t,e){var n=e-t;return n?ad(t,n):jo(isNaN(t)?e:t)}const Xr=function t(e){var n=ld(e);function r(s,o){var i=n((s=ho(s)).r,(o=ho(o)).r),a=n(s.g,o.g),c=n(s.b,o.b),l=Qc(s.opacity,o.opacity);return function(u){return s.r=i(u),s.g=a(u),s.b=c(u),s.opacity=l(u),s+""}}return r.gamma=t,r}(1);function ud(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),s;return function(o){for(s=0;s<n;++s)r[s]=t[s]*(1-o)+e[s]*o;return r}}function hd(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function fd(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,s=new Array(r),o=new Array(n),i;for(i=0;i<r;++i)s[i]=Jo(t[i],e[i]);for(;i<n;++i)o[i]=e[i];return function(a){for(i=0;i<r;++i)o[i]=s[i](a);return o}}function dd(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Pt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function pd(t,e){var n={},r={},s;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(s in e)s in t?n[s]=Jo(t[s],e[s]):r[s]=e[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var fo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fs=new RegExp(fo.source,"g");function gd(t){return function(){return t}}function md(t){return function(e){return t(e)+""}}function tl(t,e){var n=fo.lastIndex=Fs.lastIndex=0,r,s,o,i=-1,a=[],c=[];for(t=t+"",e=e+"";(r=fo.exec(t))&&(s=Fs.exec(e));)(o=s.index)>n&&(o=e.slice(n,o),a[i]?a[i]+=o:a[++i]=o),(r=r[0])===(s=s[0])?a[i]?a[i]+=s:a[++i]=s:(a[++i]=null,c.push({i,x:Pt(r,s)})),n=Fs.lastIndex;return n<e.length&&(o=e.slice(n),a[i]?a[i]+=o:a[++i]=o),a.length<2?c[0]?md(c[0].x):gd(e):(e=c.length,function(l){for(var u=0,h;u<e;++u)a[(h=c[u]).i]=h.x(l);return a.join("")})}function Jo(t,e){var n=typeof e,r;return e==null||n==="boolean"?jo(e):(n==="number"?Pt:n==="string"?(r=we(e))?(e=r,Xr):tl:e instanceof we?Xr:e instanceof Date?dd:hd(e)?ud:Array.isArray(e)?fd:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?pd:Pt)(t,e)}function yd(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Hi=180/Math.PI,po={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function el(t,e,n,r,s,o){var i,a,c;return(i=Math.sqrt(t*t+e*e))&&(t/=i,e/=i),(c=t*n+e*r)&&(n-=t*c,r-=e*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),t*r<e*n&&(t=-t,e=-e,c=-c,i=-i),{translateX:s,translateY:o,rotate:Math.atan2(e,t)*Hi,skewX:Math.atan(c)*Hi,scaleX:i,scaleY:a}}var gr;function wd(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?po:el(e.a,e.b,e.c,e.d,e.e,e.f)}function xd(t){return t==null||(gr||(gr=document.createElementNS("http://www.w3.org/2000/svg","g")),gr.setAttribute("transform",t),!(t=gr.transform.baseVal.consolidate()))?po:(t=t.matrix,el(t.a,t.b,t.c,t.d,t.e,t.f))}function nl(t,e,n,r){function s(l){return l.length?l.pop()+" ":""}function o(l,u,h,d,p,w){if(l!==h||u!==d){var y=p.push("translate(",null,e,null,n);w.push({i:y-4,x:Pt(l,h)},{i:y-2,x:Pt(u,d)})}else(h||d)&&p.push("translate("+h+e+d+n)}function i(l,u,h,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:h.push(s(h)+"rotate(",null,r)-2,x:Pt(l,u)})):u&&h.push(s(h)+"rotate("+u+r)}function a(l,u,h,d){l!==u?d.push({i:h.push(s(h)+"skewX(",null,r)-2,x:Pt(l,u)}):u&&h.push(s(h)+"skewX("+u+r)}function c(l,u,h,d,p,w){if(l!==h||u!==d){var y=p.push(s(p)+"scale(",null,",",null,")");w.push({i:y-4,x:Pt(l,h)},{i:y-2,x:Pt(u,d)})}else(h!==1||d!==1)&&p.push(s(p)+"scale("+h+","+d+")")}return function(l,u){var h=[],d=[];return l=t(l),u=t(u),o(l.translateX,l.translateY,u.translateX,u.translateY,h,d),i(l.rotate,u.rotate,h,d),a(l.skewX,u.skewX,h,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,h,d),l=u=null,function(p){for(var w=-1,y=d.length,E;++w<y;)h[(E=d[w]).i]=E.x(p);return h.join("")}}}var vd=nl(wd,"px, ","px)","deg)"),Sd=nl(xd,", ",")",")"),Ed=1e-12;function Vi(t){return((t=Math.exp(t))+1/t)/2}function bd(t){return((t=Math.exp(t))-1/t)/2}function Td(t){return((t=Math.exp(2*t))-1)/(t+1)}const _d=function t(e,n,r){function s(o,i){var a=o[0],c=o[1],l=o[2],u=i[0],h=i[1],d=i[2],p=u-a,w=h-c,y=p*p+w*w,E,v;if(y<Ed)v=Math.log(d/l)/e,E=function(O){return[a+O*p,c+O*w,l*Math.exp(e*O*v)]};else{var R=Math.sqrt(y),_=(d*d-l*l+r*y)/(2*l*n*R),S=(d*d-l*l-r*y)/(2*d*n*R),M=Math.log(Math.sqrt(_*_+1)-_),C=Math.log(Math.sqrt(S*S+1)-S);v=(C-M)/e,E=function(O){var $=O*v,D=Vi(M),Z=l/(n*R)*(D*Td(e*$+M)-bd(M));return[a+Z*p,c+Z*w,l*D/Vi(e*$+M)]}}return E.duration=v*1e3*e/Math.SQRT2,E}return s.rho=function(o){var i=Math.max(.001,+o),a=i*i,c=a*a;return t(i,a,c)},s}(Math.SQRT2,2,4);function Cd(t){return function(){return t}}function Pd(t){return+t}var Gi=[0,1];function De(t){return t}function go(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Cd(isNaN(e)?NaN:.5)}function kd(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Rd(t,e,n){var r=t[0],s=t[1],o=e[0],i=e[1];return s<r?(r=go(s,r),o=n(i,o)):(r=go(r,s),o=n(o,i)),function(a){return o(r(a))}}function Md(t,e,n){var r=Math.min(t.length,e.length)-1,s=new Array(r),o=new Array(r),i=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++i<r;)s[i]=go(t[i],t[i+1]),o[i]=n(e[i],e[i+1]);return function(a){var c=Uf(t,a,1,r)-1;return o[c](s[c](a))}}function rl(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Ad(){var t=Gi,e=Gi,n=Jo,r,s,o,i=De,a,c,l;function u(){var d=Math.min(t.length,e.length);return i!==De&&(i=kd(t[0],t[d-1])),a=d>2?Md:Rd,c=l=null,h}function h(d){return d==null||isNaN(d=+d)?o:(c||(c=a(t.map(r),e,n)))(r(i(d)))}return h.invert=function(d){return i(s((l||(l=a(e,t.map(r),Pt)))(d)))},h.domain=function(d){return arguments.length?(t=Array.from(d,Pd),u()):t.slice()},h.range=function(d){return arguments.length?(e=Array.from(d),u()):e.slice()},h.rangeRound=function(d){return e=Array.from(d),n=yd,u()},h.clamp=function(d){return arguments.length?(i=d?!0:De,u()):i!==De},h.interpolate=function(d){return arguments.length?(n=d,u()):n},h.unknown=function(d){return arguments.length?(o=d,h):o},function(d,p){return r=d,s=p,u()}}function sl(){return Ad()(De,De)}function Nd(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Wr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function je(t){return t=Wr(Math.abs(t)),t?t[1]:NaN}function Od(t,e){return function(n,r){for(var s=n.length,o=[],i=0,a=t[0],c=0;s>0&&a>0&&(c+a+1>r&&(a=Math.max(1,r-c)),o.push(n.substring(s-=a,s+a)),!((c+=a+1)>r));)a=t[i=(i+1)%t.length];return o.reverse().join(e)}}function Dd(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var zd=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Kr(t){if(!(e=zd.exec(t)))throw new Error("invalid format: "+t);var e;return new Qo({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Kr.prototype=Qo.prototype;function Qo(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Qo.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Ld(t){t:for(var e=t.length,n=1,r=-1,s;n<e;++n)switch(t[n]){case".":r=s=n;break;case"0":r===0&&(r=n),s=n;break;default:if(!+t[n])break t;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(s+1):t}var ol;function Id(t,e){var n=Wr(t,e);if(!n)return t+"";var r=n[0],s=n[1],o=s-(ol=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,i=r.length;return o===i?r:o>i?r+new Array(o-i+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Wr(t,Math.max(0,e+o-1))[0]}function Xi(t,e){var n=Wr(t,e);if(!n)return t+"";var r=n[0],s=n[1];return s<0?"0."+new Array(-s).join("0")+r:r.length>s+1?r.slice(0,s+1)+"."+r.slice(s+1):r+new Array(s-r.length+2).join("0")}const Wi={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Nd,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Xi(t*100,e),r:Xi,s:Id,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Ki(t){return t}var ji=Array.prototype.map,Ji=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function $d(t){var e=t.grouping===void 0||t.thousands===void 0?Ki:Od(ji.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",s=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Ki:Dd(ji.call(t.numerals,String)),i=t.percent===void 0?"%":t.percent+"",a=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function l(h){h=Kr(h);var d=h.fill,p=h.align,w=h.sign,y=h.symbol,E=h.zero,v=h.width,R=h.comma,_=h.precision,S=h.trim,M=h.type;M==="n"?(R=!0,M="g"):Wi[M]||(_===void 0&&(_=12),S=!0,M="g"),(E||d==="0"&&p==="=")&&(E=!0,d="0",p="=");var C=y==="$"?n:y==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():"",O=y==="$"?r:/[%p]/.test(M)?i:"",$=Wi[M],D=/[defgprs%]/.test(M);_=_===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function Z(N){var U=C,Y=O,g,A,k;if(M==="c")Y=$(N)+Y,N="";else{N=+N;var z=N<0||1/N<0;if(N=isNaN(N)?c:$(Math.abs(N),_),S&&(N=Ld(N)),z&&+N==0&&w!=="+"&&(z=!1),U=(z?w==="("?w:a:w==="-"||w==="("?"":w)+U,Y=(M==="s"?Ji[8+ol/3]:"")+Y+(z&&w==="("?")":""),D){for(g=-1,A=N.length;++g<A;)if(k=N.charCodeAt(g),48>k||k>57){Y=(k===46?s+N.slice(g+1):N.slice(g))+Y,N=N.slice(0,g);break}}}R&&!E&&(N=e(N,1/0));var B=U.length+N.length+Y.length,P=B<v?new Array(v-B+1).join(d):"";switch(R&&E&&(N=e(P+N,P.length?v-Y.length:1/0),P=""),p){case"<":N=U+N+Y+P;break;case"=":N=U+P+N+Y;break;case"^":N=P.slice(0,B=P.length>>1)+U+N+Y+P.slice(B);break;default:N=P+U+N+Y;break}return o(N)}return Z.toString=function(){return h+""},Z}function u(h,d){var p=l((h=Kr(h),h.type="f",h)),w=Math.max(-8,Math.min(8,Math.floor(je(d)/3)))*3,y=Math.pow(10,-w),E=Ji[8+w/3];return function(v){return p(y*v)+E}}return{format:l,formatPrefix:u}}var mr,il,al;Yd({thousands:",",grouping:[3],currency:["$",""]});function Yd(t){return mr=$d(t),il=mr.format,al=mr.formatPrefix,mr}function Bd(t){return Math.max(0,-je(Math.abs(t)))}function qd(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(je(e)/3)))*3-je(Math.abs(t)))}function Fd(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,je(e)-je(t))+1}function Zd(t,e,n,r){var s=uo(t,e,n),o;switch(r=Kr(r??",f"),r.type){case"s":{var i=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(o=qd(s,i))&&(r.precision=o),al(r,i)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=Fd(s,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=Bd(s))&&(r.precision=o-(r.type==="%")*2);break}}return il(r)}function Ud(t){var e=t.domain;return t.ticks=function(n){var r=e();return Xf(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var s=e();return Zd(s[0],s[s.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),s=0,o=r.length-1,i=r[s],a=r[o],c,l,u=10;for(a<i&&(l=i,i=a,a=l,l=s,s=o,o=l);u-- >0;){if(l=lo(i,a,n),l===c)return r[s]=i,r[o]=a,e(r);if(l>0)i=Math.floor(i/l)*l,a=Math.ceil(a/l)*l;else if(l<0)i=Math.ceil(i*l)/l,a=Math.floor(a*l)/l;else break;c=l}return t},t}function cl(){var t=sl();return t.copy=function(){return rl(t,cl())},Kc.apply(t,arguments),Ud(t)}function Hd(t,e){t=t.slice();var n=0,r=t.length-1,s=t[n],o=t[r],i;return o<s&&(i=n,n=r,r=i,i=s,s=o,o=i),t[n]=e.floor(s),t[r]=e.ceil(o),t}const Zs=new Date,Us=new Date;function ut(t,e,n,r){function s(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return s.floor=o=>(t(o=new Date(+o)),o),s.ceil=o=>(t(o=new Date(o-1)),e(o,1),t(o),o),s.round=o=>{const i=s(o),a=s.ceil(o);return o-i<a-o?i:a},s.offset=(o,i)=>(e(o=new Date(+o),i==null?1:Math.floor(i)),o),s.range=(o,i,a)=>{const c=[];if(o=s.ceil(o),a=a==null?1:Math.floor(a),!(o<i)||!(a>0))return c;let l;do c.push(l=new Date(+o)),e(o,a),t(o);while(l<o&&o<i);return c},s.filter=o=>ut(i=>{if(i>=i)for(;t(i),!o(i);)i.setTime(i-1)},(i,a)=>{if(i>=i)if(a<0)for(;++a<=0;)for(;e(i,-1),!o(i););else for(;--a>=0;)for(;e(i,1),!o(i););}),n&&(s.count=(o,i)=>(Zs.setTime(+o),Us.setTime(+i),t(Zs),t(Us),Math.floor(n(Zs,Us))),s.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?s.filter(r?i=>r(i)%o===0:i=>s.count(0,i)%o===0):s)),s}const jr=ut(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);jr.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ut(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):jr);jr.range;const Zt=1e3,bt=Zt*60,Ut=bt*60,Vt=Ut*24,ti=Vt*7,Qi=Vt*30,Hs=Vt*365,ze=ut(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Zt)},(t,e)=>(e-t)/Zt,t=>t.getUTCSeconds());ze.range;const ei=ut(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Zt)},(t,e)=>{t.setTime(+t+e*bt)},(t,e)=>(e-t)/bt,t=>t.getMinutes());ei.range;const Vd=ut(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*bt)},(t,e)=>(e-t)/bt,t=>t.getUTCMinutes());Vd.range;const ni=ut(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Zt-t.getMinutes()*bt)},(t,e)=>{t.setTime(+t+e*Ut)},(t,e)=>(e-t)/Ut,t=>t.getHours());ni.range;const Gd=ut(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Ut)},(t,e)=>(e-t)/Ut,t=>t.getUTCHours());Gd.range;const ur=ut(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*bt)/Vt,t=>t.getDate()-1);ur.range;const ri=ut(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Vt,t=>t.getUTCDate()-1);ri.range;const Xd=ut(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Vt,t=>Math.floor(t/Vt));Xd.range;function Ee(t){return ut(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*bt)/ti)}const Ps=Ee(0),Jr=Ee(1),Wd=Ee(2),Kd=Ee(3),Je=Ee(4),jd=Ee(5),Jd=Ee(6);Ps.range;Jr.range;Wd.range;Kd.range;Je.range;jd.range;Jd.range;function be(t){return ut(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/ti)}const ll=be(0),Qr=be(1),Qd=be(2),tp=be(3),Qe=be(4),ep=be(5),np=be(6);ll.range;Qr.range;Qd.range;tp.range;Qe.range;ep.range;np.range;const si=ut(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());si.range;const rp=ut(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());rp.range;const Gt=ut(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Gt.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ut(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Gt.range;const xe=ut(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());xe.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ut(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});xe.range;function sp(t,e,n,r,s,o){const i=[[ze,1,Zt],[ze,5,5*Zt],[ze,15,15*Zt],[ze,30,30*Zt],[o,1,bt],[o,5,5*bt],[o,15,15*bt],[o,30,30*bt],[s,1,Ut],[s,3,3*Ut],[s,6,6*Ut],[s,12,12*Ut],[r,1,Vt],[r,2,2*Vt],[n,1,ti],[e,1,Qi],[e,3,3*Qi],[t,1,Hs]];function a(l,u,h){const d=u<l;d&&([l,u]=[u,l]);const p=h&&typeof h.range=="function"?h:c(l,u,h),w=p?p.range(l,+u+1):[];return d?w.reverse():w}function c(l,u,h){const d=Math.abs(u-l)/h,p=Wo(([,,E])=>E).right(i,d);if(p===i.length)return t.every(uo(l/Hs,u/Hs,h));if(p===0)return jr.every(Math.max(uo(l,u,h),1));const[w,y]=i[d/i[p-1][2]<i[p][2]/d?p-1:p];return w.every(y)}return[a,c]}const[op,ip]=sp(Gt,si,Ps,ur,ni,ei);function Vs(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Gs(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function mn(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function ap(t){var e=t.dateTime,n=t.date,r=t.time,s=t.periods,o=t.days,i=t.shortDays,a=t.months,c=t.shortMonths,l=yn(s),u=wn(s),h=yn(o),d=wn(o),p=yn(i),w=wn(i),y=yn(a),E=wn(a),v=yn(c),R=wn(c),_={a:z,A:B,b:P,B:L,c:null,d:oa,e:oa,f:Mp,g:Bp,G:Fp,H:Pp,I:kp,j:Rp,L:ul,m:Ap,M:Np,p:q,q:F,Q:ca,s:la,S:Op,u:Dp,U:zp,V:Lp,w:Ip,W:$p,x:null,X:null,y:Yp,Y:qp,Z:Zp,"%":aa},S={a:G,A:V,b:K,B:tt,c:null,d:ia,e:ia,f:Gp,g:rg,G:og,H:Up,I:Hp,j:Vp,L:fl,m:Xp,M:Wp,p:et,q:ot,Q:ca,s:la,S:Kp,u:jp,U:Jp,V:Qp,w:tg,W:eg,x:null,X:null,y:ng,Y:sg,Z:ig,"%":aa},M={a:Z,A:N,b:U,B:Y,c:g,d:ra,e:ra,f:bp,g:na,G:ea,H:sa,I:sa,j:xp,L:Ep,m:wp,M:vp,p:D,q:yp,Q:_p,s:Cp,S:Sp,u:fp,U:dp,V:pp,w:hp,W:gp,x:A,X:k,y:na,Y:ea,Z:mp,"%":Tp};_.x=C(n,_),_.X=C(r,_),_.c=C(e,_),S.x=C(n,S),S.X=C(r,S),S.c=C(e,S);function C(H,X){return function(j){var I=[],it=-1,J=0,nt=H.length,at,rt,W;for(j instanceof Date||(j=new Date(+j));++it<nt;)H.charCodeAt(it)===37&&(I.push(H.slice(J,it)),(rt=ta[at=H.charAt(++it)])!=null?at=H.charAt(++it):rt=at==="e"?" ":"0",(W=X[at])&&(at=W(j,rt)),I.push(at),J=it+1);return I.push(H.slice(J,it)),I.join("")}}function O(H,X){return function(j){var I=mn(1900,void 0,1),it=$(I,H,j+="",0),J,nt;if(it!=j.length)return null;if("Q"in I)return new Date(I.Q);if("s"in I)return new Date(I.s*1e3+("L"in I?I.L:0));if(X&&!("Z"in I)&&(I.Z=0),"p"in I&&(I.H=I.H%12+I.p*12),I.m===void 0&&(I.m="q"in I?I.q:0),"V"in I){if(I.V<1||I.V>53)return null;"w"in I||(I.w=1),"Z"in I?(J=Gs(mn(I.y,0,1)),nt=J.getUTCDay(),J=nt>4||nt===0?Qr.ceil(J):Qr(J),J=ri.offset(J,(I.V-1)*7),I.y=J.getUTCFullYear(),I.m=J.getUTCMonth(),I.d=J.getUTCDate()+(I.w+6)%7):(J=Vs(mn(I.y,0,1)),nt=J.getDay(),J=nt>4||nt===0?Jr.ceil(J):Jr(J),J=ur.offset(J,(I.V-1)*7),I.y=J.getFullYear(),I.m=J.getMonth(),I.d=J.getDate()+(I.w+6)%7)}else("W"in I||"U"in I)&&("w"in I||(I.w="u"in I?I.u%7:"W"in I?1:0),nt="Z"in I?Gs(mn(I.y,0,1)).getUTCDay():Vs(mn(I.y,0,1)).getDay(),I.m=0,I.d="W"in I?(I.w+6)%7+I.W*7-(nt+5)%7:I.w+I.U*7-(nt+6)%7);return"Z"in I?(I.H+=I.Z/100|0,I.M+=I.Z%100,Gs(I)):Vs(I)}}function $(H,X,j,I){for(var it=0,J=X.length,nt=j.length,at,rt;it<J;){if(I>=nt)return-1;if(at=X.charCodeAt(it++),at===37){if(at=X.charAt(it++),rt=M[at in ta?X.charAt(it++):at],!rt||(I=rt(H,j,I))<0)return-1}else if(at!=j.charCodeAt(I++))return-1}return I}function D(H,X,j){var I=l.exec(X.slice(j));return I?(H.p=u.get(I[0].toLowerCase()),j+I[0].length):-1}function Z(H,X,j){var I=p.exec(X.slice(j));return I?(H.w=w.get(I[0].toLowerCase()),j+I[0].length):-1}function N(H,X,j){var I=h.exec(X.slice(j));return I?(H.w=d.get(I[0].toLowerCase()),j+I[0].length):-1}function U(H,X,j){var I=v.exec(X.slice(j));return I?(H.m=R.get(I[0].toLowerCase()),j+I[0].length):-1}function Y(H,X,j){var I=y.exec(X.slice(j));return I?(H.m=E.get(I[0].toLowerCase()),j+I[0].length):-1}function g(H,X,j){return $(H,e,X,j)}function A(H,X,j){return $(H,n,X,j)}function k(H,X,j){return $(H,r,X,j)}function z(H){return i[H.getDay()]}function B(H){return o[H.getDay()]}function P(H){return c[H.getMonth()]}function L(H){return a[H.getMonth()]}function q(H){return s[+(H.getHours()>=12)]}function F(H){return 1+~~(H.getMonth()/3)}function G(H){return i[H.getUTCDay()]}function V(H){return o[H.getUTCDay()]}function K(H){return c[H.getUTCMonth()]}function tt(H){return a[H.getUTCMonth()]}function et(H){return s[+(H.getUTCHours()>=12)]}function ot(H){return 1+~~(H.getUTCMonth()/3)}return{format:function(H){var X=C(H+="",_);return X.toString=function(){return H},X},parse:function(H){var X=O(H+="",!1);return X.toString=function(){return H},X},utcFormat:function(H){var X=C(H+="",S);return X.toString=function(){return H},X},utcParse:function(H){var X=O(H+="",!0);return X.toString=function(){return H},X}}}var ta={"-":"",_:" ",0:"0"},ft=/^\s*\d+/,cp=/^%/,lp=/[\\^$*+?|[\]().{}]/g;function st(t,e,n){var r=t<0?"-":"",s=(r?-t:t)+"",o=s.length;return r+(o<n?new Array(n-o+1).join(e)+s:s)}function up(t){return t.replace(lp,"\\$&")}function yn(t){return new RegExp("^(?:"+t.map(up).join("|")+")","i")}function wn(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function hp(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function fp(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function dp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function pp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function gp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function ea(t,e,n){var r=ft.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function na(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function mp(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function yp(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function wp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ra(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function xp(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function sa(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function vp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Sp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Ep(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function bp(t,e,n){var r=ft.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Tp(t,e,n){var r=cp.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function _p(t,e,n){var r=ft.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Cp(t,e,n){var r=ft.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function oa(t,e){return st(t.getDate(),e,2)}function Pp(t,e){return st(t.getHours(),e,2)}function kp(t,e){return st(t.getHours()%12||12,e,2)}function Rp(t,e){return st(1+ur.count(Gt(t),t),e,3)}function ul(t,e){return st(t.getMilliseconds(),e,3)}function Mp(t,e){return ul(t,e)+"000"}function Ap(t,e){return st(t.getMonth()+1,e,2)}function Np(t,e){return st(t.getMinutes(),e,2)}function Op(t,e){return st(t.getSeconds(),e,2)}function Dp(t){var e=t.getDay();return e===0?7:e}function zp(t,e){return st(Ps.count(Gt(t)-1,t),e,2)}function hl(t){var e=t.getDay();return e>=4||e===0?Je(t):Je.ceil(t)}function Lp(t,e){return t=hl(t),st(Je.count(Gt(t),t)+(Gt(t).getDay()===4),e,2)}function Ip(t){return t.getDay()}function $p(t,e){return st(Jr.count(Gt(t)-1,t),e,2)}function Yp(t,e){return st(t.getFullYear()%100,e,2)}function Bp(t,e){return t=hl(t),st(t.getFullYear()%100,e,2)}function qp(t,e){return st(t.getFullYear()%1e4,e,4)}function Fp(t,e){var n=t.getDay();return t=n>=4||n===0?Je(t):Je.ceil(t),st(t.getFullYear()%1e4,e,4)}function Zp(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+st(e/60|0,"0",2)+st(e%60,"0",2)}function ia(t,e){return st(t.getUTCDate(),e,2)}function Up(t,e){return st(t.getUTCHours(),e,2)}function Hp(t,e){return st(t.getUTCHours()%12||12,e,2)}function Vp(t,e){return st(1+ri.count(xe(t),t),e,3)}function fl(t,e){return st(t.getUTCMilliseconds(),e,3)}function Gp(t,e){return fl(t,e)+"000"}function Xp(t,e){return st(t.getUTCMonth()+1,e,2)}function Wp(t,e){return st(t.getUTCMinutes(),e,2)}function Kp(t,e){return st(t.getUTCSeconds(),e,2)}function jp(t){var e=t.getUTCDay();return e===0?7:e}function Jp(t,e){return st(ll.count(xe(t)-1,t),e,2)}function dl(t){var e=t.getUTCDay();return e>=4||e===0?Qe(t):Qe.ceil(t)}function Qp(t,e){return t=dl(t),st(Qe.count(xe(t),t)+(xe(t).getUTCDay()===4),e,2)}function tg(t){return t.getUTCDay()}function eg(t,e){return st(Qr.count(xe(t)-1,t),e,2)}function ng(t,e){return st(t.getUTCFullYear()%100,e,2)}function rg(t,e){return t=dl(t),st(t.getUTCFullYear()%100,e,2)}function sg(t,e){return st(t.getUTCFullYear()%1e4,e,4)}function og(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Qe(t):Qe.ceil(t),st(t.getUTCFullYear()%1e4,e,4)}function ig(){return"+0000"}function aa(){return"%"}function ca(t){return+t}function la(t){return Math.floor(+t/1e3)}var Re,pl;ag({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function ag(t){return Re=ap(t),pl=Re.format,Re.parse,Re.utcFormat,Re.utcParse,Re}function cg(t){return new Date(t)}function lg(t){return t instanceof Date?+t:+new Date(+t)}function gl(t,e,n,r,s,o,i,a,c,l){var u=sl(),h=u.invert,d=u.domain,p=l(".%L"),w=l(":%S"),y=l("%I:%M"),E=l("%I %p"),v=l("%a %d"),R=l("%b %d"),_=l("%B"),S=l("%Y");function M(C){return(c(C)<C?p:a(C)<C?w:i(C)<C?y:o(C)<C?E:r(C)<C?s(C)<C?v:R:n(C)<C?_:S)(C)}return u.invert=function(C){return new Date(h(C))},u.domain=function(C){return arguments.length?d(Array.from(C,lg)):d().map(cg)},u.ticks=function(C){var O=d();return t(O[0],O[O.length-1],C??10)},u.tickFormat=function(C,O){return O==null?M:l(O)},u.nice=function(C){var O=d();return(!C||typeof C.range!="function")&&(C=e(O[0],O[O.length-1],C??10)),C?d(Hd(O,C)):u},u.copy=function(){return rl(u,gl(t,e,n,r,s,o,i,a,c,l))},u}function ug(){return Kc.apply(gl(op,ip,Gt,si,Ps,ur,ni,ei,ze,pl).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}const oi=b.z.enum(["linear","time"]),ii=b.z.object({tickSpacing:b.z.number().default(75),type:oi.optional().default("linear")}),mo=t=>{const e=ii.parse(t);return dg[e.type](e)};class hg{constructor(e){m(this,"props");this.props=e}generate({decimalToDataScale:e,size:n}){const r=[0,n],s=[new T.m(e.pos(0)).date(),new T.m(e.pos(1)).date()],o=ug().domain(s).range(r);return o.ticks(ml(n,this.props.tickSpacing)).map(a=>({label:this.tickLabel(a),position:o(a)}))}tickLabel(e){const n=new T.m(e).date();let r=`:${n.getSeconds()}`;if(n.getMilliseconds()!==0){const o=Math.round(n.getMilliseconds()).toString().padStart(3,"0").replace(/0+$/,"");r+=`.${o}`}return n.getSeconds()===0&&n.getMilliseconds()===0&&(r=`${n.getHours()}:${n.getMinutes().toString().padStart(2,"0")}`),r}}class fg{constructor(e){m(this,"props");this.props=e}generate({decimalToDataScale:e,size:n}){const r=[0,n],s=[e.pos(0),e.pos(1)],o=cl().domain(s).range(r),i=ml(n,this.props.tickSpacing);return o.ticks(i).map(c=>({label:this.tickLabel(c),position:o(c)}))}tickLabel(e){return e.toString()}}const ml=(t,e)=>{const n=Math.floor(t/e);return n>0?n:1},dg={linear:t=>new fg(t),time:t=>new hg(t)},ai=ii.extend({color:f.Color.z,type:oi.optional().default("linear"),font:b.z.string(),showGrid:b.z.boolean().optional().default(!0),location:f.J.outer,gridColor:f.Color.z}),Dt=4;let yl=class{constructor(e,n){m(this,"ctx");m(this,"state");m(this,"tickFactory");this.ctx=e,this.state=n,this.tickFactory=mo(this.state)}setState(e){this.state=T.prettyParse(ai,e),this.tickFactory=mo(e)}render(e){const{lower2d:n}=this.ctx;switch(n.font=this.state.font,n.fillStyle=this.state.color.hex,n.lineWidth=1,this.state.location){case"left":return this.drawLeft(e);case"right":return this.drawRight(e);case"top":return this.drawTop(e);default:return this.drawBottom(e)}}drawBottom(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.Eo.width(r),o=f.Eo.height(r),i=e.position,a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"x",l.position),f.q.translate(i,{x:l.position,y:-o})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"x",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x+u.position,i.y),n.lineTo(i.x+u.position,i.y+Dt),n.stroke(),n.fillText(u.label,i.x+u.position-l.width/2,i.y+5+l.height)}).height+Dt+6}}drawTop(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.Eo.width(r),o=f.Eo.height(r),i=f.q.translate(e.position,"y",e.size),a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"x",l.position),f.q.translate(i,{x:l.position,y:o})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"x",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x+u.position,i.y),n.lineTo(i.x+u.position,i.y-Dt),n.stroke(),n.fillText(u.label,i.x+u.position-l.width/2,i.y-5-l.height)}).height+Dt}}drawLeft(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.Eo.height(r),o=f.Eo.width(r),i=f.q.translate(e.position,"x",e.size),a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"y",l.position),f.q.translate(i,{x:o,y:l.position})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"y",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x,i.y+u.position),n.lineTo(i.x-Dt,i.y+u.position),n.stroke(),n.fillText(u.label,i.x-l.width-Dt*2,i.y+u.position+l.height/3)}).width+Dt*2}}drawRight(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.Eo.height(r),o=f.Eo.width(r),i=e.position,a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"y",l.position),f.q.translate(i,{x:-o,y:l.position})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"y",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x,i.y+u.position),n.lineTo(i.x+Dt,i.y+u.position),n.stroke(),n.fillText(u.label,i.x+Dt+2,i.y+u.position+l.height/3)}).width+Dt*2}}drawLine(e,n){const{lower2d:r}=this.ctx;r.beginPath(),r.moveTo(...f.q.couple(e)),r.lineTo(...f.q.couple(n)),r.stroke()}drawTicks(e,n){let r=f._$1.ZERO;return e.forEach(s=>{const o=T.dimensions(s.label,this.state.font,this.ctx.lower2d);r=f._$1.max([r,o]),n(o,s)}),r}maybeDrawGrid(e,n,r){const{showGrid:s,gridColor:o}=this.state;if(s){const i=f.G.construct(-1,1),a=f.G.construct(e-1,e+1);this.ctx.lower2d.strokeStyle=o.hex,n.filter(({position:c})=>!f.G.contains(i,c)&&!f.G.contains(a,c)).forEach(c=>this.drawLine(...r(c)))}}};const kr=(t,e)=>f.Eo.construct(f.Eo.left(t)-e.x,f.Eo.top(t)-e.y,f.Eo.width(t)+e.x*2,f.Eo.height(t)+e.y*2);class ts{constructor(e,n=f.k$2.XY.IDENTITY){m(this,"scale_");m(this,"wrapped");this.wrapped=e,this.scale_=n}get fontStretch(){return this.wrapped.fontStretch}set fontStretch(e){this.wrapped.fontStretch=e}get fontVariantCaps(){return this.wrapped.fontVariantCaps}set fontVariantCaps(e){this.wrapped.fontVariantCaps=e}isContextLost(){return this.wrapped.isContextLost()}get wordSpacing(){return this.wrapped.wordSpacing}set wordSpacing(e){this.wrapped.wordSpacing=e}get letterSpacing(){return this.wrapped.letterSpacing}set letterSpacing(e){this.wrapped.letterSpacing=e}get textRendering(){return this.wrapped.textRendering}set textRendering(e){this.wrapped.textRendering=e}reset(){this.wrapped.reset()}applyScale(e){return new ts(this,e)}get canvas(){return this.wrapped.canvas}get miterLimit(){return this.wrapped.miterLimit}set miterLimit(e){this.wrapped.miterLimit=this.scale_.x.dim(e)}get globalAlpha(){return this.wrapped.globalAlpha}set globalAlpha(e){this.wrapped.globalAlpha=e}get globalCompositeOperation(){return this.wrapped.globalCompositeOperation}set globalCompositeOperation(e){this.wrapped.globalCompositeOperation=e}get fillStyle(){return this.wrapped.fillStyle}set fillStyle(e){this.wrapped.fillStyle=e}get strokeStyle(){return this.wrapped.strokeStyle}set strokeStyle(e){this.wrapped.strokeStyle=e}drawImage(e,n,r,s,o,i,a,c,l){this.wrapped.drawImage(e,n,r,s,o,i,a,c,l)}beginPath(){this.wrapped.beginPath()}clip(e,n){this.wrapped.clip(e,n)}fill(e,n){if(e==null)return this.wrapped.fill();this.wrapped.fill(e,n)}isPointInPath(e,n,r,s){return this.wrapped.isPointInPath(e,n,r,s)}isPointInStroke(e,n,r){return this.wrapped.isPointInStroke(e,n,r)}stroke(e){if(e==null)return this.wrapped.stroke();this.wrapped.stroke(e)}createConicGradient(e,n,r){return this.wrapped.createConicGradient(e,n,r)}createLinearGradient(e,n,r,s){return this.wrapped.createLinearGradient(e,n,r,s)}createPattern(e,n){return this.wrapped.createPattern(e,n)}createRadialGradient(e,n,r,s,o,i){return this.wrapped.createRadialGradient(e,n,r,s,o,i)}get filter(){return this.wrapped.filter}set filter(e){this.wrapped.filter=e}createImageData(e,n,r){return this.wrapped.createImageData(e,n,r)}getImageData(e,n,r,s,o){return this.wrapped.getImageData(e,n,r,s,o)}putImageData(e,n,r,s,o,i,a){this.wrapped.putImageData(e,n,r,s,o,i,a)}get imageSmoothingEnabled(){return this.wrapped.imageSmoothingEnabled}set imageSmoothingEnabled(e){this.wrapped.imageSmoothingEnabled=e}get imageSmoothingQuality(){return this.wrapped.imageSmoothingQuality}set imageSmoothingQuality(e){this.wrapped.imageSmoothingQuality=e}arc(e,n,r,s,o,i){this.wrapped.arc(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),s,o,i)}arcTo(e,n,r,s,o){this.wrapped.arcTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s),this.scale_.x.dim(o))}bezierCurveTo(e,n,r,s,o,i){this.wrapped.bezierCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s),this.scale_.x.pos(o),this.scale_.y.pos(i))}closePath(){this.wrapped.closePath()}ellipse(e,n,r,s,o,i,a,c){this.wrapped.ellipse(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s),o,i,a,c)}lineTo(e,n){this.wrapped.lineTo(this.scale_.x.pos(e),this.scale_.y.pos(n))}moveTo(e,n){this.wrapped.moveTo(this.scale_.x.pos(e),this.scale_.y.pos(n))}quadraticCurveTo(e,n,r,s){this.wrapped.quadraticCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s))}rect(e,n,r,s){this.wrapped.rect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}roundRect(e,n,r,s,o){this.wrapped.roundRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s),typeof o=="number"?this.scale_.x.dim(o):o)}get lineCap(){return this.wrapped.lineCap}set lineCap(e){this.wrapped.lineCap=e}get lineDashOffset(){return this.wrapped.lineDashOffset}set lineDashOffset(e){this.wrapped.lineDashOffset=this.scale_.x.dim(e)}get lineJoin(){return this.wrapped.lineJoin}set lineJoin(e){this.wrapped.lineJoin=e}get lineWidth(){return this.wrapped.lineWidth}set lineWidth(e){this.wrapped.lineWidth=this.scale_.x.dim(e)}getLineDash(){return this.wrapped.getLineDash()}setLineDash(e){const n=Array.from(e).map(r=>this.scale_.x.dim(r));this.wrapped.setLineDash(n)}clearRect(e,n,r,s){this.wrapped.clearRect(e,n,r,s)}fillRect(e,n,r,s){this.wrapped.fillRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}strokeRect(e,n,r,s){this.wrapped.strokeRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}get shadowBlur(){return this.wrapped.shadowBlur}set shadowBlur(e){this.wrapped.shadowBlur=e}get shadowColor(){return this.wrapped.shadowColor}set shadowColor(e){this.wrapped.shadowColor=e}get shadowOffsetX(){return this.wrapped.shadowOffsetX}set shadowOffsetX(e){this.wrapped.shadowOffsetX=e}get shadowOffsetY(){return this.wrapped.shadowOffsetY}restore(){this.wrapped.restore()}save(){this.wrapped.save()}fillText(e,n,r,s){this.wrapped.fillText(e,this.scale_.x.pos(n),this.scale_.y.pos(r),s!=null?this.scale_.x.dim(s):void 0)}measureText(e){this.wrapped.font=Xs(this.wrapped.font,this.scale_.x.reverse());const n=this.wrapped.measureText(e);return this.wrapped.font=Xs(this.wrapped.font,this.scale_.x),n}strokeText(e,n,r,s){this.wrapped.strokeText(e,this.scale_.x.pos(n),this.scale_.y.pos(r),s!=null?this.scale_.x.dim(s):void 0)}get direction(){return this.wrapped.direction}set direction(e){this.wrapped.direction=e}get font(){return this.wrapped.font}set font(e){this.wrapped.font=Xs(e,this.scale_.x)}get fontKerning(){return this.wrapped.fontKerning}set fontKerning(e){this.wrapped.fontKerning=e}get textAlign(){return this.wrapped.textAlign}set textAlign(e){this.wrapped.textAlign=e}get textBaseline(){return this.wrapped.textBaseline}set textBaseline(e){this.wrapped.textBaseline=e}getTransform(){return this.wrapped.getTransform()}resetTransform(){this.wrapped.resetTransform()}rotate(e){this.wrapped.rotate(e)}scale(e,n){this.wrapped.scale(e,n)}scissor(e,n=f.q.ZERO){const r=new Path2D;return e=kr(e,n),r.rect(...f.q.couple(f.Eo.topLeft(e)),...f._$1.couple(f.Eo.dims(e))),this.save(),this.clip(r),()=>this.restore()}setTransform(e,n,r,s,o,i){this.wrapped.setTransform(e,n,r,s,o,i)}transform(e,n,r,s,o,i){this.wrapped.transform(e,n,r,s,o,i)}translate(e,n){this.wrapped.translate(e,n)}}const ua=/(\d+(\.\d+)?)px/,Xs=(t,e)=>{var s;const n=Number((s=t.match(ua))==null?void 0:s[1]);if(n==null)return t;const r=e.dim(n);return t.replace(ua,`${r}px`)},pg=`precision mediump float;
|
|
7
|
+
|
|
8
|
+
void main(void) {
|
|
9
|
+
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
10
|
+
}
|
|
11
|
+
`,gg=`attribute vec4 a_position;
|
|
12
|
+
|
|
13
|
+
void main(void) {
|
|
14
|
+
gl_Position = a_position;
|
|
15
|
+
}
|
|
16
|
+
`,ha=t=>new Error(`failed to compile webgl program: ${t}`),mg=new Error("null shader encountered");class ci{constructor(e,n,r){m(this,"ctx");m(this,"prog");m(this,"vertShader");m(this,"fragShader");m(this,"uniformLocCache",new Map);this.ctx=e;const s=e.gl.createProgram();if(s==null)throw ha("failed to create program");this.prog=s,this.vertShader=n,this.fragShader=r,this.compile()}setAsActive(){return this.ctx.gl.useProgram(this.prog),()=>this.ctx.gl.useProgram(null)}uniformXY(e,n){this.ctx.gl.uniform2fv(this.getUniformLoc(e),f.q.couple(f.q.construct(n)))}uniformColor(e,n){this.ctx.gl.uniform4fv(this.getUniformLoc(e),n.rgba1)}getUniformLoc(e){const n=this.uniformLocCache.get(e);if(n!=null)return n;const r=this.ctx.gl.getUniformLocation(this.prog,e);if(r==null)throw new Error(`unexpected missing uniform ${e}`);return this.uniformLocCache.set(e,r),r}compile(){const e=this.ctx.gl;this.compileShader(this.vertShader,e.VERTEX_SHADER),this.compileShader(this.fragShader,e.FRAGMENT_SHADER),e.linkProgram(this.prog)}compileShader(e,n){const r=this.ctx.gl,s=r.createShader(n);if(s==null)throw mg;if(r.shaderSource(s,e),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS)){const i=r.getShaderInfoLog(s);throw r.deleteShader(s),ha(i??"unknown")}r.attachShader(this.prog,s)}}const yg=new Float32Array([0,0,0,0,0,0]);class wg extends ci{constructor(n){super(n,gg,pg);m(this,"positionBuffer");const r=n.gl.createBuffer();if(r==null)throw new T.Ce("webgl: failed to create buffer");this.positionBuffer=r,n.gl.bindBuffer(n.gl.ARRAY_BUFFER,this.positionBuffer),n.gl.bufferData(n.gl.ARRAY_BUFFER,yg,n.gl.STATIC_DRAW)}exec(){const{gl:n}=this.ctx,r=n.getAttribLocation(this.prog,"a_position");n.bindBuffer(n.ARRAY_BUFFER,this.positionBuffer);const s=n.createVertexArray();n.bindVertexArray(s),n.enableVertexAttribArray(r),n.vertexAttribPointer(r,2,n.FLOAT,!1,0,0),this.setAsActive(),n.drawArrays(n.TRIANGLES,0,3)}}const fa={high:1,low:0};class wl{constructor(e){m(this,"mutex",new T.Mutex);m(this,"requests",new Map);m(this,"cleanup",new Map);m(this,"afterRender");this.start(),this.afterRender=e}async set(e){let n;e.priority==="high"&&(n=await this.mutex.acquire());const r=this.requests.get(e.key);if(r==null)this.requests.set(e.key,e);else{const s=fa[e.priority]>=fa[r.priority],o=e.canvases.length>=r.canvases.length;s&&o&&this.requests.set(e.key,e)}n==null||n()}async render(){await this.mutex.runExclusive(async()=>{var i;const e=performance.now();if(this.requests.size===0)return;const{requests:n,cleanup:r}=this;for(const[a,c]of r.entries()){const l=n.get(a);l!=null&&(await c(l),r.delete(a))}for(const a of n.values())try{const c=await a.render();c!=null&&this.cleanup.set(a.key,c)}catch(c){console.error(c)}const s=performance.now(),o=T.y.milliseconds(s-e);o.greaterThan(T.y.milliseconds(25))&&console.warn(`Render loop for ${this.requests.size} took longer than 16ms to execute: ${o.milliseconds}`),this.requests.clear(),(i=this.afterRender)==null||i.call(this)})}async start(){do{try{await this.render()}catch(e){console.error(e)}await this.sleep()}while(!0)}async sleep(){return await new Promise(requestAnimationFrame)}}var Mt;let pt=(Mt=class{constructor(e,n,r,s){m(this,"glCanvas");m(this,"upper2dCanvas");m(this,"lower2dCanvas");m(this,"gl");m(this,"lower2d");m(this,"upper2d");m(this,"region");m(this,"dpr");m(this,"loop");m(this,"clearProgram");m(this,"os");this.upper2dCanvas=r,this.lower2dCanvas=n,this.glCanvas=e,this.os=s;const o=this.lower2dCanvas.getContext("2d");if(o==null)throw new Error("Could not get 2D context");this.lower2d=new ts(o);const i=this.upper2dCanvas.getContext("2d");if(i==null)throw new Error("Could not get 2D context");this.upper2d=new ts(i);const a={preserveDrawingBuffer:!0,powerPreference:"high-performance",stencil:!1,depth:!1},c=this.glCanvas.getContext("webgl2",a);if(c==null)throw new Error("Could not get WebGL context");c.disable(c.DEPTH_TEST),c.disable(c.STENCIL_TEST),c.disable(c.CULL_FACE),c.disable(c.DITHER),this.gl=c,this.glCanvas.oncontextlost=console.log;const l=()=>{this.gl.flush(),this.gl.finish()};this.loop=new wl(l),this.region=f.Eo.ZERO,this.dpr=1,this.os==="Windows"&&(this.clearProgram=new wg(this))}static create(e,n,r,s,o){const i=new Mt(n,r,s,o);return e.set(Mt.CONTEXT_KEY,i),i}static useOptional(e){return e.getOptional(Mt.CONTEXT_KEY)}static use(e){return e.get(Mt.CONTEXT_KEY)}update(e){e.set(Mt.CONTEXT_KEY,this)}resize(e,n){f.Eo.equals(this.region,e)&&this.dpr===n||(this.region=e,this.dpr=n,this.resizeCanvas(this.glCanvas),this.resizeCanvas(this.upper2dCanvas),this.resizeCanvas(this.lower2dCanvas),this.lower2d.scale(this.dpr,this.dpr),this.upper2d.scale(this.dpr,this.dpr),this.gl.viewport(0,0,f.Eo.width(e)*n,f.Eo.height(e)*n))}resizeCanvas(e){e.width=f.Eo.width(this.region)*this.dpr,e.height=f.Eo.height(this.region)*this.dpr}get aspect(){return f.Eo.aspect(this.region)}scaleRegion(e){return new f.k$2.XY(f.k$2.Scale.scale(0,1).scale(f.Eo.width(e)).translate(f.Eo.left(e)).reBound(f.Eo.width(this.region)).scale(-1,1),f.k$2.Scale.scale(0,1).scale(f.Eo.height(e)).invert().translate(f.Eo.top(e)).reBound(f.Eo.height(this.region)).scale(-1,1).invert())}scissor(e,n=f.q.ZERO,r){const s=[];return r.includes("upper2d")&&s.push(this.upper2d.scissor(e,n)),r.includes("lower2d")&&s.push(this.lower2d.scissor(e,n)),r.includes("gl")&&s.push(this.scissorGL(e,n)),()=>s.forEach(o=>o())}scissorGL(e,n=f.q.ZERO){return this.gl.enable(this.gl.SCISSOR_TEST),e=kr(e,n),this.gl.scissor(f.Eo.left(e)*this.dpr,(f.Eo.height(this.region)-f.Eo.bottom(e))*this.dpr,f.Eo.width(e)*this.dpr,f.Eo.height(e)*this.dpr),()=>this.gl.disable(this.gl.SCISSOR_TEST)}erase(e,n=f.q.ZERO,...r){n=f.q.construct(n),r.length===0&&(r=["upper2d","lower2d","gl"]),r.includes("upper2d")&&this.eraseCanvas(this.upper2d,e,n),r.includes("lower2d")&&this.eraseCanvas(this.lower2d,e,n),r.includes("gl")&&this.eraseGL(e,n)}eraseGL(e,n=f.q.ZERO){var o;const{gl:r}=this,s=this.scissorGL(kr(e,n));r.clearColor(...f.ZERO.rgba1),r.clear(r.COLOR_BUFFER_BIT),this.os==="Windows"&&((o=this.clearProgram)==null||o.exec()),s()}eraseCanvas(e,n,r=f.q.ZERO){const s=kr(n,r);e.clearRect(...f.q.couple(f.Eo.topLeft(s)),...f._$1.couple(f.Eo.dims(s)))}},m(Mt,"CONTEXT_KEY",f.CSS.B("render-context")),Mt);const $t="layout",yo="data",Xt="tool";var Lt;let mt=(Lt=class{constructor(e){m(this,"f");this.f=e}static control(e,n){e.set(Lt.CONTEXT_KEY,new Lt(n),!1)}static useRequest(e){return e.get(Lt.CONTEXT_KEY).f}static useOptionalRequest(e){var n;return((n=e.getOptional(Lt.CONTEXT_KEY))==null?void 0:n.f)??null}static requestRender(e,n){this.useRequest(e)(n)}},m(Lt,"CONTEXT_KEY","pluto-vis-renderer"),Lt),xl=class{constructor(){m(this,"prevErase",f.Eo.ZERO)}erase(e,n,r,s,o){!f.Eo.equals(r,n)&&!f.Eo.equals(this.prevErase,r)?(e.erase(r,s,...o),this.prevErase=r):e.erase(n,s,...o)}};const hr=ai.extend({bounds:f.G.bounds.optional(),autoBounds:b.z.object({lower:b.z.boolean().optional().default(!0),upper:b.z.boolean().optional().default(!0)}).or(b.z.boolean().optional().default(!0)),autoBoundPadding:b.z.number().optional(),autoBoundUpdateInterval:T.y.z.optional().default(T.y.seconds(2)),size:b.z.number().optional().default(0),label:b.z.string().optional().default(""),labelSize:b.z.number().optional().default(0)}).partial({color:!0,font:!0,gridColor:!0}),xg=2,vg=7,vl=(t,e)=>f.G.contains({lower:t-vg,upper:t+xg},e),Sg=f.G.DECIMAL,da=T.m.now(),Eg={lower:Number(da.valueOf()),upper:Number(da.add(T.y.HOUR).valueOf())},Sl=t=>t==="linear"?Sg:Eg,bg=(t,e=.1,n)=>{const r=f.G.max(t.filter(f.G.isFinite));if(!f.G.isFinite(r))return Sl(n);const{lower:s,upper:o}=r;if(o===s)return{lower:s-1,upper:o+1};const i=(o-s)*e;return{lower:s-i,upper:o+i}},Tg=.01,_g=.1;class El extends T.Composite{async afterUpdate(){var n;this.internal.render=pt.use(this.ctx);const e=T.use(this.ctx);(n=this.state).autoBoundPadding??(n.autoBoundPadding=f.g.construct(this.state.location)==="x"?_g:Tg),this.internal.core=new yl(this.internal.render,{color:e.colors.gray.l8,font:T.fontString(e,"small"),gridColor:e.colors.gray.l1,...this.state}),mt.requestRender(this.ctx,$t),this.internal.updateBounds==null&&(this.internal.updateBounds=T.r(r=>this.setState(s=>({...s,bounds:r})),this.state.autoBoundUpdateInterval.milliseconds))}async afterDelete(){mt.requestRender(this.ctx,$t)}renderAxis(e,n){if(!e.canvases.includes("lower2d"))return;const{core:r}=this.internal,{grid:s,container:o}=e,i=$f(`${this.type}-${this.key}`,s,o),a={...e,position:i,decimalToDataScale:n,size:this.state.size+this.state.labelSize},{size:c}=r.render(a);vl(this.state.size,c)||this.setState(l=>({...l,size:c}))}async bounds(e,n){var l,u;if(e&&this.internal.boundSnapshot!=null)return[this.internal.boundSnapshot,null];const{lower:r,upper:s}=bl(this.state.autoBounds);if(!r&&!s&&this.state.bounds!=null)return this.internal.boundSnapshot=this.state.bounds,[this.state.bounds,null];const o=h=>({upper:s||this.state.bounds==null?h.upper:this.state.bounds.upper,lower:r||this.state.bounds==null?h.lower:this.state.bounds.lower});let i,a=null;try{const h=await n();i=bg(h,this.state.autoBoundPadding,this.state.type)}catch(h){i=Sl(this.state.type),a=h}const c=o(i);return this.internal.boundSnapshot=c,(this.state.bounds==null||r&&this.state.bounds.lower!==c.lower||s&&this.state.bounds.upper!==c.upper)&&((u=(l=this.internal).updateBounds)==null||u.call(l,c)),[c,a]}async dataToDecimalScale(e,n,r){const[s,o]=await this.bounds(e,n),i=f.g.swap(f.g.construct(this.state.location));return[f.k$2.Scale.scale(s).scale(1).translate(-f.Eo.root(r)[i]).magnify(1/f.Eo.dim(r,i)),o]}}const bl=t=>typeof t=="boolean"?{lower:t,upper:t}:{lower:(t==null?void 0:t.lower)??!0,upper:(t==null?void 0:t.upper)??!0},Cg=`precision lowp float;
|
|
17
|
+
uniform lowp vec4 u_color;
|
|
18
|
+
|
|
19
|
+
void main(void) {
|
|
20
|
+
gl_FragColor = u_color;
|
|
21
|
+
}
|
|
22
|
+
`,Pg=`attribute float a_x;
|
|
23
|
+
attribute float a_y;
|
|
24
|
+
attribute lowp vec2 a_translate;
|
|
25
|
+
|
|
26
|
+
uniform lowp vec2 u_scale_aggregate;
|
|
27
|
+
uniform lowp vec2 u_offset_aggregate;
|
|
28
|
+
|
|
29
|
+
void main(void) {
|
|
30
|
+
vec2 transformed = u_scale_aggregate * vec2(a_x,a_y) + u_offset_aggregate;
|
|
31
|
+
transformed = transformed + a_translate;
|
|
32
|
+
gl_Position = vec4(transformed, 0.0, 1.0);
|
|
33
|
+
}
|
|
34
|
+
`,pa=T.g.FLOAT32.density.valueOf(),Tl=b.z.object({x:Fr,y:Fr,label:b.z.string().optional(),color:f.Color.z,strokeWidth:b.z.number().default(1),downsample:b.z.number().min(1).max(50).optional().default(1)}),kg=(t,e,n)=>t===-1||e===-1||t>=n.length?NaN:Number(n[t].at(e)),Rg=T.y.milliseconds(2);f.q.NAN,f.q.NAN,f.ZERO;const $e=class $e extends ci{constructor(n){super(n,Pg,Cg);m(this,"translationBufferCache",new Map);this.translationBufferCache=new Map}bindState({strokeWidth:n,color:r}){return this.uniformColor("u_color",r),this.attrStrokeWidth(n)}bindScale(n,r){const s=f.q.scale(n.scale,r.scale),o=f.q.translate(f.q.scale(r.scale,n.offset),r.offset);this.uniformXY("u_scale_aggregate",s),this.uniformXY("u_offset_aggregate",o)}draw({x:n,y:r,count:s,downsample:o,xOffset:i,yOffset:a},c){const{gl:l}=this.ctx;this.bindAttrBuffer("x",n.glBuffer,o,i),this.bindAttrBuffer("y",r.glBuffer,o,a),l.drawArraysInstanced(l.LINE_STRIP,0,s/o,c)}static create(n){const r=pt.use(n),s=new $e(r);return n.set($e.CONTEXT_KEY,s),s}static use(n){return n.get($e.CONTEXT_KEY)}bindAttrBuffer(n,r,s,o=0){const{gl:i}=this.ctx;i.bindBuffer(i.ARRAY_BUFFER,r);const a=i.getAttribLocation(this.prog,`a_${n}`);i.vertexAttribPointer(a,1,i.FLOAT,!1,pa*s,pa*o),i.enableVertexAttribArray(a)}getAndBindTranslationBuffer(n){const{gl:r}=this.ctx,s=`${this.ctx.aspect}:${n}`,o=this.translationBufferCache.get(s);if(o!=null)return r.bindBuffer(r.ARRAY_BUFFER,o.glBuffer),o;const i=r.createBuffer();if(i==null)throw new T.Ce("Failed to create buffer from WebGL context");const a=Ag(this.ctx.aspect,n);r.bindBuffer(r.ARRAY_BUFFER,i),r.bufferData(r.ARRAY_BUFFER,a,r.DYNAMIC_DRAW);const c={glBuffer:i,jsBuffer:a};return this.translationBufferCache.set(s,c),c}attrStrokeWidth(n){const{gl:r}=this.ctx,{jsBuffer:s}=this.getAndBindTranslationBuffer(n),o=r.getAttribLocation(this.prog,"a_translate");return r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(o),r.vertexAttribDivisor(o,1),s.length/2}};m($e,"CONTEXT_KEY","pluto-line-gl-program");let es=$e;class Hn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Tl)}async afterUpdate(){var r,s;if(this.deleted)return;const{internal:n}=this;n.xTelem=await At(this.ctx,this.state.x,n.xTelem),n.yTelem=await At(this.ctx,this.state.y,n.yTelem),n.instrumentation=cr(this.ctx,"line"),n.prog=es.use(this.ctx),n.requestRender=mt.useRequest(this.ctx),(r=n.stopListeningXTelem)==null||r.call(n),(s=n.stopListeningYTelem)==null||s.call(n),n.stopListeningXTelem=n.xTelem.onChange(()=>n.requestRender(yo)),n.stopListeningYTelem=n.yTelem.onChange(()=>n.requestRender(yo)),n.requestRender($t)}async afterDelete(){var r,s,o,i;const{internal:n}=this;await((s=(r=n.xTelem).cleanup)==null?void 0:s.call(r)),await((i=(o=n.yTelem).cleanup)==null?void 0:i.call(o)),n.requestRender($t)}async xBounds(){return(await this.internal.xTelem.value())[0]}async yBounds(){return(await this.internal.yTelem.value())[0]}async findByXValue(n,r){const{xTelem:s,yTelem:o}=this.internal,[,i]=await s.value();let[a,c]=[-1,-1];i.find((v,R)=>{const _=v.binarySearch(r),S=_>=0&&_<v.length;return S&&([a,c]=[_,R]),S});const{key:l}=this,{color:u,label:h}=this.state,d={key:l,color:u,label:h,position:{x:0,y:0},value:{x:NaN,y:NaN}};if(a===-1||c===-1)return d;const p=i[c];d.value.x=kg(c,a,i);const[,w]=await o.value(),y=w.find(v=>f.G.contains(v.alignmentBounds,p.alignment+BigInt(a)));if(y==null)return d;const E=Number(y.alignment-p.alignment);return d.value.y=Number(y.at(a-E)),d.position={x:n.dataToDecimalScale.x.pos(d.value.x),y:n.dataToDecimalScale.y.pos(d.value.y)},d}async render(n){if(this.deleted)return;const{downsample:r}=this.state,{xTelem:s,yTelem:o,prog:i}=this.internal,{dataToDecimalScale:a,exposure:c}=n,[[,l],[,u]]=await Promise.all([s.value(),o.value()]);l.forEach(y=>y.updateGLBuffer(i.ctx.gl)),u.forEach(y=>y.updateGLBuffer(i.ctx.gl));const h=Ig(l,u,c,r,Rg);this.internal.instrumentation.L.debug("render",()=>({key:this.key,downsample:r,scale:f.k$2.xyScaleToTransform(a),props:n.region,ops:$g(h)}));const d=i.setAsActive(),p=i.bindState(this.state),w=f.k$2.xyScaleToTransform(i.ctx.scaleRegion(n.region));h.forEach(y=>{const E=f.k$2.xyScaleToTransform(zg(a,y));i.bindScale(E,w),i.draw(y,p)}),d()}}m(Hn,"TYPE","line");const Mg=5e3,Ag=(t,e)=>Dg(Og(t),e).map((n,r)=>Math.floor(r/Ng)*(1/(Mg*t))*n),Ng=5,Og=t=>new Float32Array([0,0,0,t,0,-t,1,0,-1,0]),Dg=(t,e)=>{const n=new Float32Array(t.length*e);for(let r=0;r<e;r++)n.set(t,r*t.length);return n},zg=(t,e)=>t.translate(t.x.dim(Number(e.x.sampleOffset)),t.y.dim(Number(e.y.sampleOffset))),Lg={[Hn.TYPE]:Hn},Ig=(t,e,n,r,s)=>{if(t.length===0||e.length===0)return[];const o=[];return t.forEach(i=>e.forEach(a=>{if(!Yg(i,a,s))return;let c=0,l=0;i.alignment<a.alignment?c=Number(a.alignment-i.alignment):a.alignment<i.alignment&&(l=Number(i.alignment-a.alignment));const u=Math.min(i.length-c,a.length-l);if(u===0)return;const h=f.j(Math.round(n*4*u),r,51);o.push({x:i,y:a,xOffset:c,yOffset:l,count:u,downsample:h})})),o},$g=t=>t.map(e=>({...e,x:e.x.digest,y:e.y.digest})),Yg=(t,e,n)=>{if(!(t._timeRange!=null&&e._timeRange!=null))throw new T.Ce(`Encountered series without time range in buildDrawOperations. X series present: ${t._timeRange!=null}, Y series present: ${e._timeRange!=null}`);const s=t.timeRange.overlapsWith(e.timeRange,n),o=f.G.overlapsWith(t.alignmentBounds,e.alignmentBounds);return s&&o};class un{constructor(e,n){m(this,"canvas");m(this,"theme");this.canvas=e,this.theme=n}rule({direction:e,region:n,position:r,...s}){return e==="x"?this.line({start:f.q.construct(f.Eo.left(n),r),end:f.q.construct(f.Eo.right(n),r),...s}):this.line({start:f.q.construct(r,f.Eo.top(n)),end:f.q.construct(r,f.Eo.bottom(n)),...s})}line({stroke:e,lineWidth:n,lineDash:r,start:s,end:o}){const i=this.canvas;i.strokeStyle=e.hex,i.lineWidth=n,i.setLineDash([r]),i.beginPath(),i.moveTo(...f.q.couple(s)),i.lineTo(...f.q.couple(o)),i.stroke()}circle({fill:e,radius:n,position:r}){const s=this.canvas;s.fillStyle=e.hex,s.beginPath(),s.arc(...f.q.couple(r),n,0,2*Math.PI),s.fill()}resolveColor(e,n){return e==null?this.resolveColor(n):typeof e=="function"?e(this.theme):new f.Color(e)}border({region:e,color:n,width:r,radius:s,location:o}){const i=this.canvas;i.strokeStyle=this.resolveColor(n,this.theme.colors.border).hex,i.lineWidth=r??this.theme.sizes.border.width,s??(s=this.theme.sizes.border.radius),o==null||o===!0?s>0?(i.roundRect(...f.q.couple(f.Eo.topLeft(e)),...f.q.couple(f.Eo.dims(e)),s),i.stroke()):(i.rect(...f.q.couple(f.Eo.topLeft(e)),...f.q.couple(f.Eo.dims(e))),i.stroke()):T.A(o).forEach(a=>{const[c,l]=f.Eo.edgePoints(e,a);i.beginPath(),i.moveTo(...f.q.couple(c)),i.lineTo(...f.q.couple(l)),i.stroke()})}container({region:e,bordered:n=!0,rounded:r=!0,borderColor:s,borderRadius:o,borderWidth:i,backgroundColor:a}){o==null&&(o=this.theme.sizes.border.radius),i==null&&(i=1);const c=this.canvas;c.fillStyle=this.resolveColor(a,this.theme.colors.gray.l1).hex,c.strokeStyle=this.resolveColor(s,this.theme.colors.border).hex,c.setLineDash([]),c.lineWidth=1,c.beginPath(),r?c.roundRect(...f.q.couple(f.Eo.topLeft(e)),...f.q.couple(f.Eo.dims(e)),o):c.rect(...f.q.couple(f.Eo.topLeft(e)),...f.q.couple(f.Eo.dims(e))),c.fill(),n&&this.border({region:e,color:s,radius:o,width:i,location:n})}textContainer(e){const[n,r]=this.spacedTextDrawF(e);n.width+=12,n.height+=12;const{root:s=f.J.TOP_LEFT,offset:o=f.q.ZERO}=e,i={...e.position};s.x==="right"?i.x-=n.width+o.x:i.x+=o.x,s.y==="bottom"?i.y-=n.height+o.y:i.y+=o.y,this.container({region:f.Eo.construct(i,n.width,n.height),...e}),this.canvas.filter="none",r(f.q.translate(i,[6,6]))}spacedTextDrawF({text:e,direction:n,spacing:r=1,level:s="p"}){const o=T.fontString(this.theme,s),i=e.map(l=>T.dimensions(l,o,this.canvas)),a=this.theme.sizes.base*r,c=Math.max(...i.map(l=>l[f.g.dimension(n)]))+a;return[{[f.g.dimension(f.g.swap(n))]:Math.max(...i.map(l=>l[f.g.dimension(f.g.swap(n))])),[f.g.dimension(n)]:c*e.length-a},l=>{const u=T.fontString(this.theme,s);this.canvas.font=u,this.canvas.fillStyle=this.theme.colors.text.hex,this.canvas.textBaseline="top",e.forEach((h,d)=>{this.canvas.fillText(h,l.x,l.y+c*d)})}]}drawTextInCenter({box:e,text:n,level:r}){const s=T.dimensions(n,this.canvas.font,this.canvas),o=f.Eo.positionInCenter(f.Eo.construct(f.q.ZERO,s),e);return this.text({text:n,position:f.Eo.topLeft(o),level:r})}text({text:e,position:n,level:r="p",weight:s,shade:o,maxWidth:i,code:a}){this.canvas.font=T.fontString(this.theme,r,s,a),o==null?this.canvas.fillStyle=this.theme.colors.text.hex:this.canvas.fillStyle=this.theme.colors.gray[`l${o}`].hex,this.canvas.textBaseline="top";let c;i!=null&&(c=this.canvas.scissor(f.Eo.construct(n,i,1e3))),this.canvas.fillText(e,n.x,n.y),c==null||c()}}const li=b.z.object({position:b.z.number().optional(),pixelPosition:b.z.number().optional(),dragging:b.z.boolean(),lineWidth:b.z.number().optional().default(1),lineDash:b.z.number().optional().default(20),color:f.Color.z});class tn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",li)}async afterUpdate(){this.internal.renderCtx=pt.use(this.ctx);const n=T.use(this.ctx);this.internal.draw=new un(this.internal.renderCtx.upper2d,n),mt.requestRender(this.ctx,Xt)}async afterDelete(){mt.requestRender(this.ctx,Xt)}updatePositions({decimalToDataScale:n,plot:r,container:s}){if(this.state.dragging&&this.state.pixelPosition!=null){const i=n.pos((this.state.pixelPosition-f.Eo.top(r)+f.Eo.top(s))/f.Eo.height(r));return this.setState(a=>({...a,position:i})),this.state.pixelPosition}if(this.state.position==null){const i=n.pos(.5);this.setState(a=>({...a,position:i}))}const o=n.reverse().pos(this.state.position)*f.Eo.height(r)+f.Eo.top(r)-f.Eo.top(s);return isNaN(o)||this.setState(i=>({...i,pixelPosition:o})),o}async render(n){if(this.deleted)return;const{renderCtx:r}=this.internal,{location:s,plot:o}=n,i=f.J.direction(s),{upper2d:a}=r,c=this.internal.draw;let l=this.updatePositions(n);l+=f.Eo.top(n.container),c.rule({stroke:this.state.color,lineWidth:this.state.lineWidth,lineDash:this.state.lineDash,direction:i,region:o,position:l}),a.fillStyle=this.state.color.hex,a.beginPath(),s==="left"?(a.moveTo(f.Eo.left(o),l),a.lineTo(f.Eo.left(o)-5,l-5),a.lineTo(f.Eo.left(o)-5,l+5)):s==="right"&&(a.moveTo(f.Eo.right(o),l),a.lineTo(f.Eo.right(o)+5,l-5),a.lineTo(f.Eo.right(o)+5,l+5)),a.closePath(),a.fill()}}m(tn,"TYPE","Rule");const _l={[tn.TYPE]:tn},Bg=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:_l,Rule:tn,ruleStateZ:li},Symbol.toStringTag,{value:"Module"})),qg=hr.extend({location:f.J.x.optional().default("left")});class Vn extends El{constructor(){super(...arguments);m(this,"schema",hr)}async xBounds(){return f.G.max(await Promise.all(this.lines.map(async n=>await n.xBounds())))}async render(n){if(this.deleted)return;const[r,s]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport),o=r.invert().reverse();if(this.renderAxis(n,o),await this.renderLines(n,r),await this.renderRules(n,o),s!=null)throw s}async renderLines({xDataToDecimalScale:n,plot:r,canvases:s,exposure:o},i){if(!s.includes("gl"))return;const a={region:r,dataToDecimalScale:new f.k$2.XY(n,i),exposure:o};await Promise.all(this.lines.map(async c=>await c.render(a)))}async renderRules({container:n,plot:r,canvases:s},o){if(!s.includes("upper2d"))return;const{location:i}=this.state,{render:a}=this.internal,c=f.Eo.construct(f.Eo.left(n),f.Eo.top(r),f.Eo.width(n),f.Eo.height(r)),l=a.scissor(c,f.q.ZERO,["upper2d"]),u={container:n,plot:r,decimalToDataScale:o,location:i};await Promise.all(this.rules.map(async h=>await h.render(u))),l()}async findByXValue({xDataToDecimalScale:n,plot:r,viewport:s,hold:o,exposure:i},a){const[c,l]=await this.dataToDecimalScale(o,this.dataBounds.bind(this),s);if(l!=null)throw l;const u=new f.k$2.XY(n,c),h={region:r,dataToDecimalScale:u,exposure:i};return(await Promise.all(this.lines.map(async d=>await d.findByXValue(h,a)))).map(d=>({...d,units:this.state.label}))}async dataBounds(){return await Promise.all(this.lines.map(async n=>await n.yBounds()))}get lines(){return this.childrenOfType(Hn.TYPE)}get rules(){return this.childrenOfType(tn.TYPE)}}m(Vn,"TYPE","YAxis");const Cl=b.z.object({start:T.m.z,end:T.m.z});class ns extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Cl)}async afterUpdate(){this.internal.render=pt.use(this.ctx),this.internal.draw=new un(this.internal.render.upper2d,T.use(this.ctx))}async render(){}}m(ns,"TYPE","range-annotation");const Pl=b.z.object({triggered:b.z.boolean(),status:T.specZ$1,sink:Ts.optional().default(Es),source:Bo.optional().default($o)});class rs extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Pl)}async afterUpdate(){var s,o,i;const{sink:n,source:r}=this.state;this.internal.source=await At(this.ctx,r,this.internal.source),this.internal.sink=await or(this.ctx,n,this.internal.sink),this.state.triggered&&!this.prevState.triggered&&this.internal.sink.set(((s=this.state.status.data)==null?void 0:s.authority)!==T.Kg.Absolute.valueOf()).catch(console.error),await this.updateEnabledState(),(i=(o=this.internal).stopListening)==null||i.call(o),this.internal.stopListening=this.internal.source.onChange(()=>{this.updateEnabledState()})}async updateEnabledState(){const n=await this.internal.source.value();n.time.equals(this.state.status.time)||this.setState(r=>({...r,status:n,triggered:!1}))}async afterDelete(){this.asyncAfterDelete().catch(console.error)}async asyncAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}render(){}}m(rs,"TYPE","Chip");const kl=b.z.object({}),ga="control-state-provider",Rl=T.Og.stateZ.extend({subjectColor:f.Color.z});class en extends T.Composite{constructor(){super(...arguments);m(this,"schema",kl);m(this,"colors",new Map);m(this,"tracker");m(this,"disconnectTrackerChange");m(this,"obs",new Do.Observer)}static use(n){return n.get(ga)}async afterUpdate(){const{internal:n}=this;n.instrumentation=cr(this.ctx,"control-state");const r=T.use(this.ctx);n.palette=r.colors.visualization.palettes.default,n.defaultColor=r.colors.gray.l6;const s=sr(this.ctx);n.client!=null&&s===n.client||(n.client=s,this.ctx.set(ga,this),await this.maybeCloseTracker(),n.client!=null&&(this.internal.instrumentation.L.debug("starting state tracker"),await this.openTracker(n.client)))}async maybeCloseTracker(){var n;this.tracker!=null&&(this.internal.instrumentation.L.debug("stopping state tracker"),(n=this.disconnectTrackerChange)==null||n.call(this),await this.tracker.close(),this.tracker=void 0)}async afterDelete(){await this.maybeCloseTracker()}onChange(n){return this.obs.onChange(n)}get(n){return Array.isArray(n)?T.n(n).map(r=>this.getOne(r)).filter(r=>r!=null):this.getOne(n)}getOne(n){if(this.tracker==null)return;const r=this.tracker.states.get(n);if(r!=null)return{...r,subjectColor:this.colors.get(r.subject.key)??this.internal.defaultColor}}async openTracker(n){var o;const{internal:r}=this,{instrumentation:s}=r;try{this.tracker=await n.control.openStateTracker()}catch{s.L.error("failed to open state tracker");return}(o=this.disconnectTrackerChange)==null||o.call(this),this.disconnectTrackerChange=this.tracker.onChange(i=>{if(s.L.debug("transfer",{transfers:i.map(a=>T.Og.transferString(a))}),this.tracker==null)throw new T.Ce("tracker is null inside it's own onChange callback!");this.updateColors(this.tracker),this.obs.notify(i)})}updateColors(n){const r=n.subjects(),s=r.map(a=>a.key),o=Array.from(this.colors.values());this.colors.forEach((a,c)=>!s.includes(c)&&this.colors.delete(c));const{palette:i}=this.internal;r.forEach(a=>{if(this.colors.has(a.key))return;const c=i.find(l=>!o.includes(l))??i[0];this.colors.set(a.key,c),o.push(c)})}}m(en,"TYPE","StateProvider");const Ml=["acquired","released","overridden","failed"],Al=b.z.enum(Ml),Nl=b.z.object({name:b.z.string(),authority:b.z.number().default(0),acquireTrigger:b.z.number(),status:Al.optional(),needsControlOf:T.dg.keyZ.array().optional().default([])});class ss extends T.Composite{constructor(){super(...arguments);m(this,"schema",Nl);m(this,"registry",new Map);m(this,"writer")}async afterUpdate(){this.internal.instrumentation=cr(this.ctx),(this.internal.prevTrigger==null||Math.abs(this.state.acquireTrigger-this.internal.prevTrigger)>1)&&(this.internal.prevTrigger=this.state.acquireTrigger);const n=sr(this.ctx),r=en.use(this.ctx);this.internal.client=n,this.internal.client==null&&await this.release(),this.internal.stateProv=r,cc(this.ctx,this),this.internal.addStatus=T.useAggregate(this.ctx),this.state.acquireTrigger>this.internal.prevTrigger?(this.acquire(),this.internal.prevTrigger=this.state.acquireTrigger):this.state.acquireTrigger<this.internal.prevTrigger&&(this.release(),this.internal.prevTrigger=this.state.acquireTrigger)}async afterDelete(){await this.release()}async updateNeedsControlOf(){if(this.internal.client==null)throw new T.Ce("No cluster connected but channelKeys were requested");const n=new Set([]);for(const s of this.registry.keys())(await s.needsControlOf(this.internal.client)).forEach(i=>i!==0&&n.add(i));const r=Array.from(n);T.F.unorderedPrimitiveArrays(this.state.needsControlOf,r)!==T.F.EQUAL&&this.setState(s=>({...s,needsControlOf:r}))}async acquire(){const{client:n,addStatus:r}=this.internal;if(n==null)return r({message:`Cannot acquire control on ${this.state.name} because no cluster has been connected.`,variant:"warning"});try{await this.updateNeedsControlOf();const s=this.state.needsControlOf;if(s.length===0)return r({message:`Cannot acquire control on ${this.state.name} because there are no channels to control.`,variant:"warning"});this.writer=await n.openWriter({start:T.I.now(),channels:s,controlSubject:{key:this.key,name:this.state.name},authorities:this.state.authority}),this.setState(o=>({...o,status:"acquired"}))}catch(s){this.setState(o=>({...o,status:"failed"})),r({message:`${this.state.name} failed to acquire control: ${s.message}`,variant:"error"})}}async release(){var n;try{await((n=this.writer)==null?void 0:n.close()),this.setState(r=>({...r,status:"released"}))}catch(r){this.internal.addStatus({message:`${this.state.name} failed to release control: ${r.message}`,variant:"error"})}finally{this.writer=void 0}}async set(n){var r;this.writer==null&&await this.acquire(),await((r=this.writer)==null?void 0:r.write(n))}async setAuthority(n,r){var s;this.writer==null&&await this.acquire(),await((s=this.writer)==null?void 0:s.setAuthority(Object.fromEntries(n.map(o=>[o,r]))))}async releaseAuthority(n){var r;this.writer==null&&await this.acquire(),await((r=this.writer)==null?void 0:r.setAuthority(Object.fromEntries(n.map(s=>[s,this.state.authority]))))}deleteTelem(n){this.registry.delete(n),this.updateNeedsControlOf()}create(n){const s=(()=>{switch(n.type){case Gn.TYPE:{const o=new Gn(this,n.props);return this.registry.set(o,null),o}case Wn.TYPE:{const o=new Wn(this,this.internal.stateProv,n.props);return this.registry.set(o,null),o}case Xn.TYPE:return new Xn(this,n.props);default:return null}})();return s!=null&&this.updateNeedsControlOf(),s}}m(ss,"TYPE","Controller");const Ol=b.z.object({channel:b.z.number()});class Gn extends Cs{constructor(n,r){super(r);m(this,"controller");m(this,"schema",Ol);this.controller=n}invalidate(){}async cleanup(){this.controller.deleteTelem(this)}async needsControlOf(n){if(this.props.channel===0)return[];const r=await n.channels.retrieve(this.props.channel),s=[r.key];return r.index!==0&&s.push(r.index),s}async set(n){const{client:r}=this.controller.internal;if(r==null)return;const s=await r.channels.retrieve(this.props.channel),o={[s.key]:n};if(s.index!==0){const i=await r.channels.retrieve(s.index);o[i.key]=T.I.now()}await this.controller.set(o)}}m(Gn,"TYPE","controlled-numeric-telem-sink");const Fg=t=>({type:Gn.TYPE,props:t,variant:"sink",valueType:"number"}),Dl=b.z.object({authority:b.z.number().default(T.Og.Authority.Absolute.valueOf()),channel:b.z.number()});class Xn extends Cs{constructor(n,r){super(r);m(this,"controller");m(this,"schema",Dl);this.controller=n}async cleanup(){this.controller.deleteTelem(this)}async needsControlOf(n){const r=await n.channels.retrieve(this.props.channel),s=[r.key];return r.index!==0&&s.push(r.index),s}async set(n){const{controller:r}=this,{client:s}=r.internal;if(s==null)return;const o=await s.channels.retrieve(this.props.channel),i=[o.key];o.index!==0&&i.push(o.index),n?await this.controller.setAuthority(i,this.props.authority):await this.controller.releaseAuthority(i)}}m(Xn,"TYPE","acquire-channel-control");const Zg=t=>({type:Xn.TYPE,props:t,variant:"sink",valueType:"boolean"}),zl=b.z.object({channel:b.z.number()});class Wn extends _t{constructor(n,r,s){super(s);m(this,"prov");m(this,"valid",!1);m(this,"stopListening");m(this,"controller");m(this,"schema",zl);this.prov=r,this.controller=n}async needsControlOf(){return[]}maybeRevalidate(){var s;if(this.valid)return;const{channel:n}=this.props;(s=this.stopListening)==null||s.call(this);const r=T.W.filterTransfersByChannelKey(n);this.stopListening=this.prov.onChange(o=>{var i;r(o).length!==0&&((i=this.notify)==null||i.call(this))}),this.valid=!0}async value(){this.maybeRevalidate();const n=T.I.now();if(this.props.channel===0)return{key:this.controller.key,variant:"disabled",message:"No Channel",time:n,data:{valid:!1,authority:0}};const r=this.prov.get(this.props.channel);return r==null?{key:this.controller.key,variant:"disabled",message:"Uncontrolled",time:n,data:{valid:!0,color:void 0,authority:0}}:{key:r.subject.key,variant:r.subject.key===this.controller.key?"success":"error",message:`Controlled by ${r.subject.name}`,time:n,data:{valid:!0,color:r.subjectColor,authority:r.authority}}}async cleanup(){var n;this.controller.deleteTelem(this),(n=this.stopListening)==null||n.call(this)}}m(Wn,"TYPE","controlled-status-source");const Ug=t=>({type:Wn.TYPE,props:t,variant:"source",valueType:"status"}),Ll=b.z.object({statusSource:Bo.optional().default($o),colorSource:xc.optional().default(fc),status:T.specZ$1,color:f.Color.z.optional()});class os extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Ll);m(this,"stopListeningStatus");m(this,"stopListeningColor")}async afterUpdate(){var r,s;const{internal:n}=this;n.statusSource=await At(this.ctx,this.state.statusSource,n.statusSource),n.colorSource=await At(this.ctx,this.state.colorSource,n.colorSource),await this.updateState(),(r=this.stopListeningStatus)==null||r.call(this),this.stopListeningStatus=n.statusSource.onChange(()=>{this.updateState()}),(s=this.stopListeningColor)==null||s.call(this),this.stopListeningColor=n.colorSource.onChange(()=>{this.updateState()})}async afterDelete(){this.internalAfterDelete().catch(console.error)}async internalAfterDelete(){var n,r,s,o;await((r=(n=this.internal.statusSource).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.colorSource).cleanup)==null?void 0:o.call(s))}async render(){}async updateState(){const n=await this.internal.colorSource.value(),r=await this.internal.statusSource.value();n.equals(this.state.color)&&r.message===this.state.status.message||this.setState(s=>({...s,color:n,status:r}))}}m(os,"TYPE","Indicator");const Il=b.z.object({needsControlOf:T.dg.keyZ.array(),states:Rl.array()});class is extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Il)}async afterUpdate(){var i;const{internal:n}=this;n.stateProv=en.use(this.ctx);const r=this.state.needsControlOf;(i=n.disconnectStateProv)==null||i.call(n);const s=T.W.filterTransfersByChannelKey(...r),o=n.stateProv.get(r);this.setState(a=>({...a,states:o})),n.disconnectStateProv=n.stateProv.onChange(a=>{if(s(a).length===0)return;const c=n.stateProv.get(r);this.setState(l=>({...l,states:c}))})}async afterDelete(){var r;const{internal:n}=this;(r=n.disconnectStateProv)==null||r.call(n)}async render(){}}m(is,"TYPE","Legend");const Hg={[ss.TYPE]:ss,[en.TYPE]:en,[os.TYPE]:os,[rs.TYPE]:rs,[is.TYPE]:is},$l=b.z.object({trigger:b.z.number(),sink:Ts.optional().default(Es)});class as extends T.Leaf{constructor(){super(...arguments);m(this,"schema",$l)}async afterUpdate(){const{sink:n}=this.state;this.internal.prevTrigger==null&&(this.internal.prevTrigger=this.state.trigger),this.internal.sink=await or(this.ctx,n,this.internal.sink);const r=this.internal.prevTrigger;this.internal.prevTrigger=this.state.trigger,!(this.state.trigger<=r)&&this.internal.sink.set(!0).catch(console.error)}render(){}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var r,s;const{internal:n}=this;await((s=(r=n.sink).cleanup)==null?void 0:s.call(r))}}m(as,"TYPE","Button");const Vg={[as.TYPE]:as},ui=b.z.object({dpr:b.z.number(),region:f.Eo.box,bootstrap:b.z.boolean().optional().default(!1),bootstrapped:b.z.boolean().optional().default(!1),glCanvas:b.z.any().optional(),upper2dCanvas:b.z.any().optional(),lower2dCanvas:b.z.any().optional(),os:T.w.osZ});class Kn extends T.Composite{constructor(){super(...arguments);m(this,"schema",ui);m(this,"renderContextSet",!1)}async afterUpdate(){let n=pt.useOptional(this.ctx);if(n==null){if(this.renderContextSet)throw new T.Ce("[vis.worker.Canvas] - expected render context to be set");if(!this.state.bootstrap)return;const{glCanvas:r,lower2dCanvas:s,upper2dCanvas:o,os:i}=this.state;if(r==null||s==null||o==null)throw new T.Ce("[vis.worker.Canvas] - expected render context bootstrap to include all canvases");n=pt.create(this.ctx,r,s,o,i),es.create(this.ctx),this.setState(a=>({...a,bootstrap:!1,bootstrapped:!0,glCanvas:void 0,lower2dCanvas:void 0,upper2dCanvas:void 0}))}else n.update(this.ctx);n.resize(this.state.region,this.state.dpr)}}m(Kn,"TYPE","Canvas");const Yl={[Kn.TYPE]:Kn},Gg=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Kn,REGISTRY:Yl,canvasStateZ:ui},Symbol.toStringTag,{value:"Module"}));function St(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=St(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var wo={exports:{}},Ws={},yr={exports:{}},Ks={};/**
|
|
35
|
+
* @license React
|
|
36
|
+
* use-sync-external-store-shim.production.min.js
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the MIT license found in the
|
|
41
|
+
* LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/var ma;function Xg(){if(ma)return Ks;ma=1;var t=x;function e(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,o=t.useLayoutEffect,i=t.useDebugValue;function a(h,d){var p=d(),w=r({inst:{value:p,getSnapshot:d}}),y=w[0].inst,E=w[1];return o(function(){y.value=p,y.getSnapshot=d,c(y)&&E({inst:y})},[h,p,d]),s(function(){return c(y)&&E({inst:y}),h(function(){c(y)&&E({inst:y})})},[h]),i(p),p}function c(h){var d=h.getSnapshot;h=h.value;try{var p=d();return!n(h,p)}catch{return!0}}function l(h,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Ks.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Ks}var js={};/**
|
|
43
|
+
* @license React
|
|
44
|
+
* use-sync-external-store-shim.development.js
|
|
45
|
+
*
|
|
46
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the MIT license found in the
|
|
49
|
+
* LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/var ya;function Wg(){return ya||(ya=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=x,e=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(_){{for(var S=arguments.length,M=new Array(S>1?S-1:0),C=1;C<S;C++)M[C-1]=arguments[C];r("error",_,M)}}function r(_,S,M){{var C=e.ReactDebugCurrentFrame,O=C.getStackAddendum();O!==""&&(S+="%s",M=M.concat([O]));var $=M.map(function(D){return String(D)});$.unshift("Warning: "+S),Function.prototype.apply.call(console[_],console,$)}}function s(_,S){return _===S&&(_!==0||1/_===1/S)||_!==_&&S!==S}var o=typeof Object.is=="function"?Object.is:s,i=t.useState,a=t.useEffect,c=t.useLayoutEffect,l=t.useDebugValue,u=!1,h=!1;function d(_,S,M){u||t.startTransition!==void 0&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var C=S();if(!h){var O=S();o(C,O)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),h=!0)}var $=i({inst:{value:C,getSnapshot:S}}),D=$[0].inst,Z=$[1];return c(function(){D.value=C,D.getSnapshot=S,p(D)&&Z({inst:D})},[_,C,S]),a(function(){p(D)&&Z({inst:D});var N=function(){p(D)&&Z({inst:D})};return _(N)},[_]),l(C),C}function p(_){var S=_.getSnapshot,M=_.value;try{var C=S();return!o(M,C)}catch{return!0}}function w(_,S,M){return S()}var y=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",E=!y,v=E?w:d,R=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:v;js.useSyncExternalStore=R,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),js}var wa;function Bl(){return wa||(wa=1,process.env.NODE_ENV==="production"?yr.exports=Xg():yr.exports=Wg()),yr.exports}/**
|
|
51
|
+
* @license React
|
|
52
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
53
|
+
*
|
|
54
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
55
|
+
*
|
|
56
|
+
* This source code is licensed under the MIT license found in the
|
|
57
|
+
* LICENSE file in the root directory of this source tree.
|
|
58
|
+
*/var xa;function Kg(){if(xa)return Ws;xa=1;var t=x,e=Bl();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,a=t.useMemo,c=t.useDebugValue;return Ws.useSyncExternalStoreWithSelector=function(l,u,h,d,p){var w=o(null);if(w.current===null){var y={hasValue:!1,value:null};w.current=y}else y=w.current;w=a(function(){function v(C){if(!R){if(R=!0,_=C,C=d(C),p!==void 0&&y.hasValue){var O=y.value;if(p(O,C))return S=O}return S=C}if(O=S,r(_,C))return O;var $=d(C);return p!==void 0&&p(O,$)?O:(_=C,S=$)}var R=!1,_,S,M=h===void 0?null:h;return[function(){return v(u())},M===null?void 0:function(){return v(M())}]},[u,h,d,p]);var E=s(l,w[0],w[1]);return i(function(){y.hasValue=!0,y.value=E},[E]),c(E),E},Ws}var Js={};/**
|
|
59
|
+
* @license React
|
|
60
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
61
|
+
*
|
|
62
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the MIT license found in the
|
|
65
|
+
* LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/var va;function jg(){return va||(va=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=x,e=Bl();function n(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,a=t.useMemo,c=t.useDebugValue;function l(u,h,d,p,w){var y=o(null),E;y.current===null?(E={hasValue:!1,value:null},y.current=E):E=y.current;var v=a(function(){var M=!1,C,O,$=function(U){if(!M){M=!0,C=U;var Y=p(U);if(w!==void 0&&E.hasValue){var g=E.value;if(w(g,Y))return O=g,g}return O=Y,Y}var A=C,k=O;if(r(A,U))return k;var z=p(U);return w!==void 0&&w(k,z)?k:(C=U,O=z,z)},D=d===void 0?null:d,Z=function(){return $(h())},N=D===null?void 0:function(){return $(D())};return[Z,N]},[h,d,p,w]),R=v[0],_=v[1],S=s(u,R,_);return i(function(){E.hasValue=!0,E.value=S},[S]),c(S),S}Js.useSyncExternalStoreWithSelector=l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Js}process.env.NODE_ENV==="production"?wo.exports=Kg():wo.exports=jg();var Jg=wo.exports;const Qg=T.getDefaultExportFromCjs(Jg),tm={BASE_URL:"/pluto/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Sa=t=>{let e;const n=new Set,r=(u,h)=>{const d=typeof u=="function"?u(e):u;if(!Object.is(d,e)){const p=e;e=h??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(w=>w(e,p))}},s=()=>e,c={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(tm?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=e=t(r,s,c);return c},em=t=>t?Sa(t):Sa,{useDebugValue:nm}=x,{useSyncExternalStoreWithSelector:rm}=Qg,sm=t=>t;function ql(t,e=sm,n){const r=rm(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return nm(r),r}const Ea=(t,e)=>{const n=em(t),r=(s,o=e)=>ql(n,s,o);return Object.assign(r,n),r},om=(t,e)=>t?Ea(t,e):Ea;function gt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,s]of t)if(!Object.is(s,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}var im={value:()=>{}};function ks(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Rr(n)}function Rr(t){this._=t}function am(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Rr.prototype=ks.prototype={constructor:Rr,on:function(t,e){var n=this._,r=am(t+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o<i;)if((s=(t=r[o]).type)&&(s=cm(n[s],t.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<i;)if(s=(t=r[o]).type)n[s]=ba(n[s],t.name,e);else if(e==null)for(s in n)n[s]=ba(n[s],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Rr(t)},call:function(t,e){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,s=o.length;r<s;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],s=0,o=r.length;s<o;++s)r[s].value.apply(e,n)}};function cm(t,e){for(var n=0,r=t.length,s;n<r;++n)if((s=t[n]).name===e)return s.value}function ba(t,e,n){for(var r=0,s=t.length;r<s;++r)if(t[r].name===e){t[r]=im,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var xo="http://www.w3.org/1999/xhtml";const Ta={svg:"http://www.w3.org/2000/svg",xhtml:xo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Rs(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Ta.hasOwnProperty(e)?{space:Ta[e],local:t}:t}function lm(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===xo&&e.documentElement.namespaceURI===xo?e.createElement(t):e.createElementNS(n,t)}}function um(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Fl(t){var e=Rs(t);return(e.local?um:lm)(e)}function hm(){}function hi(t){return t==null?hm:function(){return this.querySelector(t)}}function fm(t){typeof t!="function"&&(t=hi(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=new Array(i),c,l,u=0;u<i;++u)(c=o[u])&&(l=t.call(c,c.__data__,u,o))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new xt(r,this._parents)}function dm(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function pm(){return[]}function Zl(t){return t==null?pm:function(){return this.querySelectorAll(t)}}function gm(t){return function(){return dm(t.apply(this,arguments))}}function mm(t){typeof t=="function"?t=gm(t):t=Zl(t);for(var e=this._groups,n=e.length,r=[],s=[],o=0;o<n;++o)for(var i=e[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&(r.push(t.call(c,c.__data__,l,i)),s.push(c));return new xt(r,s)}function Ul(t){return function(){return this.matches(t)}}function Hl(t){return function(e){return e.matches(t)}}var ym=Array.prototype.find;function wm(t){return function(){return ym.call(this.children,t)}}function xm(){return this.firstElementChild}function vm(t){return this.select(t==null?xm:wm(typeof t=="function"?t:Hl(t)))}var Sm=Array.prototype.filter;function Em(){return Array.from(this.children)}function bm(t){return function(){return Sm.call(this.children,t)}}function Tm(t){return this.selectAll(t==null?Em:bm(typeof t=="function"?t:Hl(t)))}function _m(t){typeof t!="function"&&(t=Ul(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new xt(r,this._parents)}function Vl(t){return new Array(t.length)}function Cm(){return new xt(this._enter||this._groups.map(Vl),this._parents)}function cs(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}cs.prototype={constructor:cs,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Pm(t){return function(){return t}}function km(t,e,n,r,s,o){for(var i=0,a,c=e.length,l=o.length;i<l;++i)(a=e[i])?(a.__data__=o[i],r[i]=a):n[i]=new cs(t,o[i]);for(;i<c;++i)(a=e[i])&&(s[i]=a)}function Rm(t,e,n,r,s,o,i){var a,c,l=new Map,u=e.length,h=o.length,d=new Array(u),p;for(a=0;a<u;++a)(c=e[a])&&(d[a]=p=i.call(c,c.__data__,a,e)+"",l.has(p)?s[a]=c:l.set(p,c));for(a=0;a<h;++a)p=i.call(t,o[a],a,o)+"",(c=l.get(p))?(r[a]=c,c.__data__=o[a],l.delete(p)):n[a]=new cs(t,o[a]);for(a=0;a<u;++a)(c=e[a])&&l.get(d[a])===c&&(s[a]=c)}function Mm(t){return t.__data__}function Am(t,e){if(!arguments.length)return Array.from(this,Mm);var n=e?Rm:km,r=this._parents,s=this._groups;typeof t!="function"&&(t=Pm(t));for(var o=s.length,i=new Array(o),a=new Array(o),c=new Array(o),l=0;l<o;++l){var u=r[l],h=s[l],d=h.length,p=Nm(t.call(u,u&&u.__data__,l,r)),w=p.length,y=a[l]=new Array(w),E=i[l]=new Array(w),v=c[l]=new Array(d);n(u,h,y,E,v,p,e);for(var R=0,_=0,S,M;R<w;++R)if(S=y[R]){for(R>=_&&(_=R+1);!(M=E[_])&&++_<w;);S._next=M||null}}return i=new xt(i,r),i._enter=a,i._exit=c,i}function Nm(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Om(){return new xt(this._exit||this._groups.map(Vl),this._parents)}function Dm(t,e,n){var r=this.enter(),s=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(s=e(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function zm(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,s=n.length,o=r.length,i=Math.min(s,o),a=new Array(s),c=0;c<i;++c)for(var l=n[c],u=r[c],h=l.length,d=a[c]=new Array(h),p,w=0;w<h;++w)(p=l[w]||u[w])&&(d[w]=p);for(;c<s;++c)a[c]=n[c];return new xt(a,this._parents)}function Lm(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],s=r.length-1,o=r[s],i;--s>=0;)(i=r[s])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function Im(t){t||(t=$m);function e(h,d){return h&&d?t(h.__data__,d.__data__):!h-!d}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var i=n[o],a=i.length,c=s[o]=new Array(a),l,u=0;u<a;++u)(l=i[u])&&(c[u]=l);c.sort(e)}return new xt(s,this._parents).order()}function $m(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Ym(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Bm(){return Array.from(this)}function qm(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],s=0,o=r.length;s<o;++s){var i=r[s];if(i)return i}return null}function Fm(){let t=0;for(const e of this)++t;return t}function Zm(){return!this.node()}function Um(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var s=e[n],o=0,i=s.length,a;o<i;++o)(a=s[o])&&t.call(a,a.__data__,o,s);return this}function Hm(t){return function(){this.removeAttribute(t)}}function Vm(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Gm(t,e){return function(){this.setAttribute(t,e)}}function Xm(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Wm(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Km(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function jm(t,e){var n=Rs(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?Vm:Hm:typeof e=="function"?n.local?Km:Wm:n.local?Xm:Gm)(n,e))}function Gl(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Jm(t){return function(){this.style.removeProperty(t)}}function Qm(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ty(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ey(t,e,n){return arguments.length>1?this.each((e==null?Jm:typeof e=="function"?ty:Qm)(t,e,n??"")):nn(this.node(),t)}function nn(t,e){return t.style.getPropertyValue(e)||Gl(t).getComputedStyle(t,null).getPropertyValue(e)}function ny(t){return function(){delete this[t]}}function ry(t,e){return function(){this[t]=e}}function sy(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function oy(t,e){return arguments.length>1?this.each((e==null?ny:typeof e=="function"?sy:ry)(t,e)):this.node()[t]}function Xl(t){return t.trim().split(/^|\s+/)}function fi(t){return t.classList||new Wl(t)}function Wl(t){this._node=t,this._names=Xl(t.getAttribute("class")||"")}Wl.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Kl(t,e){for(var n=fi(t),r=-1,s=e.length;++r<s;)n.add(e[r])}function jl(t,e){for(var n=fi(t),r=-1,s=e.length;++r<s;)n.remove(e[r])}function iy(t){return function(){Kl(this,t)}}function ay(t){return function(){jl(this,t)}}function cy(t,e){return function(){(e.apply(this,arguments)?Kl:jl)(this,t)}}function ly(t,e){var n=Xl(t+"");if(arguments.length<2){for(var r=fi(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof e=="function"?cy:e?iy:ay)(n,e))}function uy(){this.textContent=""}function hy(t){return function(){this.textContent=t}}function fy(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function dy(t){return arguments.length?this.each(t==null?uy:(typeof t=="function"?fy:hy)(t)):this.node().textContent}function py(){this.innerHTML=""}function gy(t){return function(){this.innerHTML=t}}function my(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function yy(t){return arguments.length?this.each(t==null?py:(typeof t=="function"?my:gy)(t)):this.node().innerHTML}function wy(){this.nextSibling&&this.parentNode.appendChild(this)}function xy(){return this.each(wy)}function vy(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Sy(){return this.each(vy)}function Ey(t){var e=typeof t=="function"?t:Fl(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function by(){return null}function Ty(t,e){var n=typeof t=="function"?t:Fl(t),r=e==null?by:typeof e=="function"?e:hi(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function _y(){var t=this.parentNode;t&&t.removeChild(this)}function Cy(){return this.each(_y)}function Py(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ky(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ry(t){return this.select(t?ky:Py)}function My(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Ay(t){return function(e){t.call(this,e,this.__data__)}}function Ny(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Oy(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,s=e.length,o;n<s;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++r]=o;++r?e.length=r:delete this.__on}}}function Dy(t,e,n){return function(){var r=this.__on,s,o=Ay(e);if(r){for(var i=0,a=r.length;i<a;++i)if((s=r[i]).type===t.type&&s.name===t.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=e;return}}this.addEventListener(t.type,o,n),s={type:t.type,name:t.name,value:e,listener:o,options:n},r?r.push(s):this.__on=[s]}}function zy(t,e,n){var r=Ny(t+""),s,o=r.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(s=0,u=a[c];s<o;++s)if((i=r[s]).type===u.type&&i.name===u.name)return u.value}return}for(a=e?Dy:Oy,s=0;s<o;++s)this.each(a(r[s],e,n));return this}function Jl(t,e,n){var r=Gl(t),s=r.CustomEvent;typeof s=="function"?s=new s(e,n):(s=r.document.createEvent("Event"),n?(s.initEvent(e,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(e,!1,!1)),t.dispatchEvent(s)}function Ly(t,e){return function(){return Jl(this,t,e)}}function Iy(t,e){return function(){return Jl(this,t,e.apply(this,arguments))}}function $y(t,e){return this.each((typeof e=="function"?Iy:Ly)(t,e))}function*Yy(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],s=0,o=r.length,i;s<o;++s)(i=r[s])&&(yield i)}var Ql=[null];function xt(t,e){this._groups=t,this._parents=e}function fr(){return new xt([[document.documentElement]],Ql)}function By(){return this}xt.prototype=fr.prototype={constructor:xt,select:fm,selectAll:mm,selectChild:vm,selectChildren:Tm,filter:_m,data:Am,enter:Cm,exit:Om,join:Dm,merge:zm,selection:By,order:Lm,sort:Im,call:Ym,nodes:Bm,node:qm,size:Fm,empty:Zm,each:Um,attr:jm,style:ey,property:oy,classed:ly,text:dy,html:yy,raise:xy,lower:Sy,append:Ey,insert:Ty,remove:Cy,clone:Ry,datum:My,on:zy,dispatch:$y,[Symbol.iterator]:Yy};function Rt(t){return typeof t=="string"?new xt([[document.querySelector(t)]],[document.documentElement]):new xt([[t]],Ql)}function qy(t){let e;for(;e=t.sourceEvent;)t=e;return t}function zt(t,e){if(t=qy(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}}return[t.pageX,t.pageY]}const Fy={passive:!1},jn={capture:!0,passive:!1};function Qs(t){t.stopImmediatePropagation()}function qe(t){t.preventDefault(),t.stopImmediatePropagation()}function tu(t){var e=t.document.documentElement,n=Rt(t).on("dragstart.drag",qe,jn);"onselectstart"in e?n.on("selectstart.drag",qe,jn):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function eu(t,e){var n=t.document.documentElement,r=Rt(t).on("dragstart.drag",null);e&&(r.on("click.drag",qe,jn),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const wr=t=>()=>t;function vo(t,{sourceEvent:e,subject:n,target:r,identifier:s,active:o,x:i,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}vo.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Zy(t){return!t.ctrlKey&&!t.button}function Uy(){return this.parentNode}function Hy(t,e){return e??{x:t.x,y:t.y}}function Vy(){return navigator.maxTouchPoints||"ontouchstart"in this}function Gy(){var t=Zy,e=Uy,n=Hy,r=Vy,s={},o=ks("start","drag","end"),i=0,a,c,l,u,h=0;function d(S){S.on("mousedown.drag",p).filter(r).on("touchstart.drag",E).on("touchmove.drag",v,Fy).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(S,M){if(!(u||!t.call(this,S,M))){var C=_(this,e.call(this,S,M),S,M,"mouse");C&&(Rt(S.view).on("mousemove.drag",w,jn).on("mouseup.drag",y,jn),tu(S.view),Qs(S),l=!1,a=S.clientX,c=S.clientY,C("start",S))}}function w(S){if(qe(S),!l){var M=S.clientX-a,C=S.clientY-c;l=M*M+C*C>h}s.mouse("drag",S)}function y(S){Rt(S.view).on("mousemove.drag mouseup.drag",null),eu(S.view,l),qe(S),s.mouse("end",S)}function E(S,M){if(t.call(this,S,M)){var C=S.changedTouches,O=e.call(this,S,M),$=C.length,D,Z;for(D=0;D<$;++D)(Z=_(this,O,S,M,C[D].identifier,C[D]))&&(Qs(S),Z("start",S,C[D]))}}function v(S){var M=S.changedTouches,C=M.length,O,$;for(O=0;O<C;++O)($=s[M[O].identifier])&&(qe(S),$("drag",S,M[O]))}function R(S){var M=S.changedTouches,C=M.length,O,$;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),O=0;O<C;++O)($=s[M[O].identifier])&&(Qs(S),$("end",S,M[O]))}function _(S,M,C,O,$,D){var Z=o.copy(),N=zt(D||C,M),U,Y,g;if((g=n.call(S,new vo("beforestart",{sourceEvent:C,target:d,identifier:$,active:i,x:N[0],y:N[1],dx:0,dy:0,dispatch:Z}),O))!=null)return U=g.x-N[0]||0,Y=g.y-N[1]||0,function A(k,z,B){var P=N,L;switch(k){case"start":s[$]=A,L=i++;break;case"end":delete s[$],--i;case"drag":N=zt(B||z,M),L=i;break}Z.call(k,S,new vo(k,{sourceEvent:z,subject:g,target:d,identifier:$,active:L,x:N[0]+U,y:N[1]+Y,dx:N[0]-P[0],dy:N[1]-P[1],dispatch:Z}),O)}}return d.filter=function(S){return arguments.length?(t=typeof S=="function"?S:wr(!!S),d):t},d.container=function(S){return arguments.length?(e=typeof S=="function"?S:wr(S),d):e},d.subject=function(S){return arguments.length?(n=typeof S=="function"?S:wr(S),d):n},d.touchable=function(S){return arguments.length?(r=typeof S=="function"?S:wr(!!S),d):r},d.on=function(){var S=o.on.apply(o,arguments);return S===o?d:S},d.clickDistance=function(S){return arguments.length?(h=(S=+S)*S,d):Math.sqrt(h)},d}var rn=0,_n=0,xn=0,nu=1e3,ls,Cn,us=0,ve=0,Ms=0,Jn=typeof performance=="object"&&performance.now?performance:Date,ru=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function di(){return ve||(ru(Xy),ve=Jn.now()+Ms)}function Xy(){ve=0}function hs(){this._call=this._time=this._next=null}hs.prototype=su.prototype={constructor:hs,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?di():+n)+(e==null?0:+e),!this._next&&Cn!==this&&(Cn?Cn._next=this:ls=this,Cn=this),this._call=t,this._time=n,So()},stop:function(){this._call&&(this._call=null,this._time=1/0,So())}};function su(t,e,n){var r=new hs;return r.restart(t,e,n),r}function Wy(){di(),++rn;for(var t=ls,e;t;)(e=ve-t._time)>=0&&t._call.call(void 0,e),t=t._next;--rn}function _a(){ve=(us=Jn.now())+Ms,rn=_n=0;try{Wy()}finally{rn=0,jy(),ve=0}}function Ky(){var t=Jn.now(),e=t-us;e>nu&&(Ms-=e,us=t)}function jy(){for(var t,e=ls,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:ls=n);Cn=t,So(r)}function So(t){if(!rn){_n&&(_n=clearTimeout(_n));var e=t-ve;e>24?(t<1/0&&(_n=setTimeout(_a,t-Jn.now()-Ms)),xn&&(xn=clearInterval(xn))):(xn||(us=Jn.now(),xn=setInterval(Ky,nu)),rn=1,ru(_a))}}function Ca(t,e,n){var r=new hs;return e=e==null?0:+e,r.restart(s=>{r.stop(),t(s+e)},e,n),r}var Jy=ks("start","end","cancel","interrupt"),Qy=[],ou=0,Pa=1,Eo=2,Mr=3,ka=4,bo=5,Ar=6;function As(t,e,n,r,s,o){var i=t.__transition;if(!i)t.__transition={};else if(n in i)return;t0(t,n,{name:e,index:r,group:s,on:Jy,tween:Qy,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:ou})}function pi(t,e){var n=Nt(t,e);if(n.state>ou)throw new Error("too late; already scheduled");return n}function Yt(t,e){var n=Nt(t,e);if(n.state>Mr)throw new Error("too late; already running");return n}function Nt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function t0(t,e,n){var r=t.__transition,s;r[e]=n,n.timer=su(o,0,n.time);function o(l){n.state=Pa,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var u,h,d,p;if(n.state!==Pa)return c();for(u in r)if(p=r[u],p.name===n.name){if(p.state===Mr)return Ca(i);p.state===ka?(p.state=Ar,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=Ar,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(Ca(function(){n.state===Mr&&(n.state=ka,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Eo,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Eo){for(n.state=Mr,s=new Array(d=n.tween.length),u=0,h=-1;u<d;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(s[++h]=p);s.length=h+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=bo,1),h=-1,d=s.length;++h<d;)s[h].call(t,u);n.state===bo&&(n.on.call("end",t,t.__data__,n.index,n.group),c())}function c(){n.state=Ar,n.timer.stop(),delete r[e];for(var l in r)return;delete t.__transition}}function Nr(t,e){var n=t.__transition,r,s,o=!0,i;if(n){e=e==null?null:e+"";for(i in n){if((r=n[i]).name!==e){o=!1;continue}s=r.state>Eo&&r.state<bo,r.state=Ar,r.timer.stop(),r.on.call(s?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[i]}o&&delete t.__transition}}function e0(t){return this.each(function(){Nr(this,t)})}function n0(t,e){var n,r;return function(){var s=Yt(this,t),o=s.tween;if(o!==n){r=n=o;for(var i=0,a=r.length;i<a;++i)if(r[i].name===e){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function r0(t,e,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Yt(this,t),i=o.tween;if(i!==r){s=(r=i).slice();for(var a={name:e,value:n},c=0,l=s.length;c<l;++c)if(s[c].name===e){s[c]=a;break}c===l&&s.push(a)}o.tween=s}}function s0(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=Nt(this.node(),n).tween,s=0,o=r.length,i;s<o;++s)if((i=r[s]).name===t)return i.value;return null}return this.each((e==null?n0:r0)(n,t,e))}function gi(t,e,n){var r=t._id;return t.each(function(){var s=Yt(this,r);(s.value||(s.value={}))[e]=n.apply(this,arguments)}),function(s){return Nt(s,r).value[e]}}function iu(t,e){var n;return(typeof e=="number"?Pt:e instanceof we?Xr:(n=we(e))?(e=n,Xr):tl)(t,e)}function o0(t){return function(){this.removeAttribute(t)}}function i0(t){return function(){this.removeAttributeNS(t.space,t.local)}}function a0(t,e,n){var r,s=n+"",o;return function(){var i=this.getAttribute(t);return i===s?null:i===r?o:o=e(r=i,n)}}function c0(t,e,n){var r,s=n+"",o;return function(){var i=this.getAttributeNS(t.space,t.local);return i===s?null:i===r?o:o=e(r=i,n)}}function l0(t,e,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttribute(t):(i=this.getAttribute(t),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a)))}}function u0(t,e,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttributeNS(t.space,t.local):(i=this.getAttributeNS(t.space,t.local),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a)))}}function h0(t,e){var n=Rs(t),r=n==="transform"?Sd:iu;return this.attrTween(t,typeof e=="function"?(n.local?u0:l0)(n,r,gi(this,"attr."+t,e)):e==null?(n.local?i0:o0)(n):(n.local?c0:a0)(n,r,e))}function f0(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function d0(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function p0(t,e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&d0(t,o)),n}return s._value=e,s}function g0(t,e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&f0(t,o)),n}return s._value=e,s}function m0(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Rs(t);return this.tween(n,(r.local?p0:g0)(r,e))}function y0(t,e){return function(){pi(this,t).delay=+e.apply(this,arguments)}}function w0(t,e){return e=+e,function(){pi(this,t).delay=e}}function x0(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?y0:w0)(e,t)):Nt(this.node(),e).delay}function v0(t,e){return function(){Yt(this,t).duration=+e.apply(this,arguments)}}function S0(t,e){return e=+e,function(){Yt(this,t).duration=e}}function E0(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?v0:S0)(e,t)):Nt(this.node(),e).duration}function b0(t,e){if(typeof e!="function")throw new Error;return function(){Yt(this,t).ease=e}}function T0(t){var e=this._id;return arguments.length?this.each(b0(e,t)):Nt(this.node(),e).ease}function _0(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Yt(this,t).ease=n}}function C0(t){if(typeof t!="function")throw new Error;return this.each(_0(this._id,t))}function P0(t){typeof t!="function"&&(t=Ul(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new Wt(r,this._parents,this._name,this._id)}function k0(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,s=n.length,o=Math.min(r,s),i=new Array(r),a=0;a<o;++a)for(var c=e[a],l=n[a],u=c.length,h=i[a]=new Array(u),d,p=0;p<u;++p)(d=c[p]||l[p])&&(h[p]=d);for(;a<r;++a)i[a]=e[a];return new Wt(i,this._parents,this._name,this._id)}function R0(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function M0(t,e,n){var r,s,o=R0(e)?pi:Yt;return function(){var i=o(this,t),a=i.on;a!==r&&(s=(r=a).copy()).on(e,n),i.on=s}}function A0(t,e){var n=this._id;return arguments.length<2?Nt(this.node(),n).on.on(t):this.each(M0(n,t,e))}function N0(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function O0(){return this.on("end.remove",N0(this._id))}function D0(t){var e=this._name,n=this._id;typeof t!="function"&&(t=hi(t));for(var r=this._groups,s=r.length,o=new Array(s),i=0;i<s;++i)for(var a=r[i],c=a.length,l=o[i]=new Array(c),u,h,d=0;d<c;++d)(u=a[d])&&(h=t.call(u,u.__data__,d,a))&&("__data__"in u&&(h.__data__=u.__data__),l[d]=h,As(l[d],e,n,d,l,Nt(u,n)));return new Wt(o,this._parents,e,n)}function z0(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Zl(t));for(var r=this._groups,s=r.length,o=[],i=[],a=0;a<s;++a)for(var c=r[a],l=c.length,u,h=0;h<l;++h)if(u=c[h]){for(var d=t.call(u,u.__data__,h,c),p,w=Nt(u,n),y=0,E=d.length;y<E;++y)(p=d[y])&&As(p,e,n,y,d,w);o.push(d),i.push(u)}return new Wt(o,i,e,n)}var L0=fr.prototype.constructor;function I0(){return new L0(this._groups,this._parents)}function $0(t,e){var n,r,s;return function(){var o=nn(this,t),i=(this.style.removeProperty(t),nn(this,t));return o===i?null:o===n&&i===r?s:s=e(n=o,r=i)}}function au(t){return function(){this.style.removeProperty(t)}}function Y0(t,e,n){var r,s=n+"",o;return function(){var i=nn(this,t);return i===s?null:i===r?o:o=e(r=i,n)}}function B0(t,e,n){var r,s,o;return function(){var i=nn(this,t),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(t),nn(this,t))),i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a))}}function q0(t,e){var n,r,s,o="style."+e,i="end."+o,a;return function(){var c=Yt(this,t),l=c.on,u=c.value[o]==null?a||(a=au(e)):void 0;(l!==n||s!==u)&&(r=(n=l).copy()).on(i,s=u),c.on=r}}function F0(t,e,n){var r=(t+="")=="transform"?vd:iu;return e==null?this.styleTween(t,$0(t,r)).on("end.style."+t,au(t)):typeof e=="function"?this.styleTween(t,B0(t,r,gi(this,"style."+t,e))).each(q0(this._id,t)):this.styleTween(t,Y0(t,r,e),n).on("end.style."+t,null)}function Z0(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function U0(t,e,n){var r,s;function o(){var i=e.apply(this,arguments);return i!==s&&(r=(s=i)&&Z0(t,i,n)),r}return o._value=e,o}function H0(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,U0(t,e,n??""))}function V0(t){return function(){this.textContent=t}}function G0(t){return function(){var e=t(this);this.textContent=e??""}}function X0(t){return this.tween("text",typeof t=="function"?G0(gi(this,"text",t)):V0(t==null?"":t+""))}function W0(t){return function(e){this.textContent=t.call(this,e)}}function K0(t){var e,n;function r(){var s=t.apply(this,arguments);return s!==n&&(e=(n=s)&&W0(s)),e}return r._value=t,r}function j0(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,K0(t))}function J0(){for(var t=this._name,e=this._id,n=cu(),r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)if(c=i[l]){var u=Nt(c,e);As(c,t,n,l,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Wt(r,this._parents,t,n)}function Q0(){var t,e,n=this,r=n._id,s=n.size();return new Promise(function(o,i){var a={value:i},c={value:function(){--s===0&&o()}};n.each(function(){var l=Yt(this,r),u=l.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(c)),l.on=e}),s===0&&o()})}var tw=0;function Wt(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function cu(){return++tw}var Ft=fr.prototype;Wt.prototype={constructor:Wt,select:D0,selectAll:z0,selectChild:Ft.selectChild,selectChildren:Ft.selectChildren,filter:P0,merge:k0,selection:I0,transition:J0,call:Ft.call,nodes:Ft.nodes,node:Ft.node,size:Ft.size,empty:Ft.empty,each:Ft.each,on:A0,attr:h0,attrTween:m0,style:F0,styleTween:H0,text:X0,textTween:j0,remove:O0,tween:s0,delay:x0,duration:E0,ease:T0,easeVarying:C0,end:Q0,[Symbol.iterator]:Ft[Symbol.iterator]};function ew(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var nw={time:null,delay:0,duration:250,ease:ew};function rw(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function sw(t){var e,n;t instanceof Wt?(e=t._id,t=t._name):(e=cu(),(n=nw).time=di(),t=t==null?null:t+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&As(c,t,e,l,i,n||rw(c,e));return new Wt(r,this._parents,t,e)}fr.prototype.interrupt=e0;fr.prototype.transition=sw;const xr=t=>()=>t;function ow(t,{sourceEvent:e,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Ht(t,e,n){this.k=t,this.x=e,this.y=n}Ht.prototype={constructor:Ht,scale:function(t){return t===1?this:new Ht(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Ht(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ee=new Ht(1,0,0);Ht.prototype;function to(t){t.stopImmediatePropagation()}function vn(t){t.preventDefault(),t.stopImmediatePropagation()}function iw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function aw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Ra(){return this.__zoom||ee}function cw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function lw(){return navigator.maxTouchPoints||"ontouchstart"in this}function uw(t,e,n){var r=t.invertX(e[0][0])-n[0][0],s=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],i=t.invertY(e[1][1])-n[1][1];return t.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function hw(){var t=iw,e=aw,n=uw,r=cw,s=lw,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=_d,l=ks("start","zoom","end"),u,h,d,p=500,w=150,y=0,E=10;function v(g){g.property("__zoom",Ra).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",Z).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",Y).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(g,A,k,z){var B=g.selection?g.selection():g;B.property("__zoom",Ra),g!==B?M(g,A,k,z):B.interrupt().each(function(){C(this,arguments).event(z).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},v.scaleBy=function(g,A,k,z){v.scaleTo(g,function(){var B=this.__zoom.k,P=typeof A=="function"?A.apply(this,arguments):A;return B*P},k,z)},v.scaleTo=function(g,A,k,z){v.transform(g,function(){var B=e.apply(this,arguments),P=this.__zoom,L=k==null?S(B):typeof k=="function"?k.apply(this,arguments):k,q=P.invert(L),F=typeof A=="function"?A.apply(this,arguments):A;return n(_(R(P,F),L,q),B,i)},k,z)},v.translateBy=function(g,A,k,z){v.transform(g,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof k=="function"?k.apply(this,arguments):k),e.apply(this,arguments),i)},null,z)},v.translateTo=function(g,A,k,z,B){v.transform(g,function(){var P=e.apply(this,arguments),L=this.__zoom,q=z==null?S(P):typeof z=="function"?z.apply(this,arguments):z;return n(ee.translate(q[0],q[1]).scale(L.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof k=="function"?-k.apply(this,arguments):-k),P,i)},z,B)};function R(g,A){return A=Math.max(o[0],Math.min(o[1],A)),A===g.k?g:new Ht(A,g.x,g.y)}function _(g,A,k){var z=A[0]-k[0]*g.k,B=A[1]-k[1]*g.k;return z===g.x&&B===g.y?g:new Ht(g.k,z,B)}function S(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function M(g,A,k,z){g.on("start.zoom",function(){C(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(z).end()}).tween("zoom",function(){var B=this,P=arguments,L=C(B,P).event(z),q=e.apply(B,P),F=k==null?S(q):typeof k=="function"?k.apply(B,P):k,G=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),V=B.__zoom,K=typeof A=="function"?A.apply(B,P):A,tt=c(V.invert(F).concat(G/V.k),K.invert(F).concat(G/K.k));return function(et){if(et===1)et=K;else{var ot=tt(et),H=G/ot[2];et=new Ht(H,F[0]-ot[0]*H,F[1]-ot[1]*H)}L.zoom(null,et)}})}function C(g,A,k){return!k&&g.__zooming||new O(g,A)}function O(g,A){this.that=g,this.args=A,this.active=0,this.sourceEvent=null,this.extent=e.apply(g,A),this.taps=0}O.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,A){return this.mouse&&g!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var A=Rt(this.that).datum();l.call(g,this.that,new ow(g,{sourceEvent:this.sourceEvent,target:v,type:g,transform:this.that.__zoom,dispatch:l}),A)}};function $(g,...A){if(!t.apply(this,arguments))return;var k=C(this,A).event(g),z=this.__zoom,B=Math.max(o[0],Math.min(o[1],z.k*Math.pow(2,r.apply(this,arguments)))),P=zt(g);if(k.wheel)(k.mouse[0][0]!==P[0]||k.mouse[0][1]!==P[1])&&(k.mouse[1]=z.invert(k.mouse[0]=P)),clearTimeout(k.wheel);else{if(z.k===B)return;k.mouse=[P,z.invert(P)],Nr(this),k.start()}vn(g),k.wheel=setTimeout(L,w),k.zoom("mouse",n(_(R(z,B),k.mouse[0],k.mouse[1]),k.extent,i));function L(){k.wheel=null,k.end()}}function D(g,...A){if(d||!t.apply(this,arguments))return;var k=g.currentTarget,z=C(this,A,!0).event(g),B=Rt(g.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",G,!0),P=zt(g,k),L=g.clientX,q=g.clientY;tu(g.view),to(g),z.mouse=[P,this.__zoom.invert(P)],Nr(this),z.start();function F(V){if(vn(V),!z.moved){var K=V.clientX-L,tt=V.clientY-q;z.moved=K*K+tt*tt>y}z.event(V).zoom("mouse",n(_(z.that.__zoom,z.mouse[0]=zt(V,k),z.mouse[1]),z.extent,i))}function G(V){B.on("mousemove.zoom mouseup.zoom",null),eu(V.view,z.moved),vn(V),z.event(V).end()}}function Z(g,...A){if(t.apply(this,arguments)){var k=this.__zoom,z=zt(g.changedTouches?g.changedTouches[0]:g,this),B=k.invert(z),P=k.k*(g.shiftKey?.5:2),L=n(_(R(k,P),z,B),e.apply(this,A),i);vn(g),a>0?Rt(this).transition().duration(a).call(M,L,z,g):Rt(this).call(v.transform,L,z,g)}}function N(g,...A){if(t.apply(this,arguments)){var k=g.touches,z=k.length,B=C(this,A,g.changedTouches.length===z).event(g),P,L,q,F;for(to(g),L=0;L<z;++L)q=k[L],F=zt(q,this),F=[F,this.__zoom.invert(F),q.identifier],B.touch0?!B.touch1&&B.touch0[2]!==F[2]&&(B.touch1=F,B.taps=0):(B.touch0=F,P=!0,B.taps=1+!!u);u&&(u=clearTimeout(u)),P&&(B.taps<2&&(h=F[0],u=setTimeout(function(){u=null},p)),Nr(this),B.start())}}function U(g,...A){if(this.__zooming){var k=C(this,A).event(g),z=g.changedTouches,B=z.length,P,L,q,F;for(vn(g),P=0;P<B;++P)L=z[P],q=zt(L,this),k.touch0&&k.touch0[2]===L.identifier?k.touch0[0]=q:k.touch1&&k.touch1[2]===L.identifier&&(k.touch1[0]=q);if(L=k.that.__zoom,k.touch1){var G=k.touch0[0],V=k.touch0[1],K=k.touch1[0],tt=k.touch1[1],et=(et=K[0]-G[0])*et+(et=K[1]-G[1])*et,ot=(ot=tt[0]-V[0])*ot+(ot=tt[1]-V[1])*ot;L=R(L,Math.sqrt(et/ot)),q=[(G[0]+K[0])/2,(G[1]+K[1])/2],F=[(V[0]+tt[0])/2,(V[1]+tt[1])/2]}else if(k.touch0)q=k.touch0[0],F=k.touch0[1];else return;k.zoom("touch",n(_(L,q,F),k.extent,i))}}function Y(g,...A){if(this.__zooming){var k=C(this,A).event(g),z=g.changedTouches,B=z.length,P,L;for(to(g),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),P=0;P<B;++P)L=z[P],k.touch0&&k.touch0[2]===L.identifier?delete k.touch0:k.touch1&&k.touch1[2]===L.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(L=zt(L,this),Math.hypot(h[0]-L[0],h[1]-L[1])<E)){var q=Rt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return v.wheelDelta=function(g){return arguments.length?(r=typeof g=="function"?g:xr(+g),v):r},v.filter=function(g){return arguments.length?(t=typeof g=="function"?g:xr(!!g),v):t},v.touchable=function(g){return arguments.length?(s=typeof g=="function"?g:xr(!!g),v):s},v.extent=function(g){return arguments.length?(e=typeof g=="function"?g:xr([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),v):e},v.scaleExtent=function(g){return arguments.length?(o[0]=+g[0],o[1]=+g[1],v):[o[0],o[1]]},v.translateExtent=function(g){return arguments.length?(i[0][0]=+g[0][0],i[1][0]=+g[1][0],i[0][1]=+g[0][1],i[1][1]=+g[1][1],v):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},v.constrain=function(g){return arguments.length?(n=g,v):n},v.duration=function(g){return arguments.length?(a=+g,v):a},v.interpolate=function(g){return arguments.length?(c=g,v):c},v.on=function(){var g=l.on.apply(l,arguments);return g===l?v:g},v.clickDistance=function(g){return arguments.length?(y=(g=+g)*g,v):Math.sqrt(y)},v.tapDistance=function(g){return arguments.length?(E=+g,v):E},v}const Ns=x.createContext(null),fw=Ns.Provider,vt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},lu=vt.error001();function lt(t,e){const n=x.useContext(Ns);if(n===null)throw new Error(lu);return ql(n,t,e)}const ht=()=>{const t=x.useContext(Ns);if(t===null)throw new Error(lu);return x.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},dw=t=>t.userSelectionActive?"none":"all";function pw({position:t,children:e,className:n,style:r,...s}){const o=lt(dw),i=`${t}`.split("-");return x.createElement("div",{className:St(["react-flow__panel",n,...i]),style:{...r,pointerEvents:o},...s},e)}function gw({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:x.createElement(pw,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},x.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const mw=({x:t,y:e,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u})=>{const h=x.useRef(null),[d,p]=x.useState({x:0,y:0,width:0,height:0}),w=St(["react-flow__edge-textwrapper",l]);return x.useEffect(()=>{if(h.current){const y=h.current.getBBox();p({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),typeof n>"u"||!n?null:x.createElement("g",{transform:`translate(${t-d.width/2} ${e-d.height/2})`,className:w,visibility:d.width?"visible":"hidden",...u},s&&x.createElement("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),x.createElement("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:h,style:r},n),c)};var yw=x.memo(mw);const mi=t=>({width:t.offsetWidth,height:t.offsetHeight}),sn=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),yi=(t={x:0,y:0},e)=>({x:sn(t.x,e[0][0],e[1][0]),y:sn(t.y,e[0][1],e[1][1])}),Ma=(t,e,n)=>t<e?sn(Math.abs(t-e),1,50)/50:t>n?-sn(Math.abs(t-n),1,50)/50:0,uu=(t,e)=>{const n=Ma(t.x,35,e.width-35)*20,r=Ma(t.y,35,e.height-35)*20;return[n,r]},hu=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},ww=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),wi=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),xw=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),Aa=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),To=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},vw=t=>Tt(t.width)&&Tt(t.height)&&Tt(t.x)&&Tt(t.y),Tt=t=>!isNaN(t)&&isFinite(t),ct=Symbol.for("internals"),fu=["Enter"," ","Escape"],fs=(t,e)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${e} Help: https://reactflow.dev/error#${t}`)},Sw=t=>"nativeEvent"in t;function _o(t){var s,o;const e=Sw(t)?t.nativeEvent:t,n=((o=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:o[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const du=t=>"clientX"in t,ne=(t,e)=>{var o,i;const n=du(t),r=n?t.clientX:(o=t.touches)==null?void 0:o[0].clientX,s=n?t.clientY:(i=t.touches)==null?void 0:i[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:s-((e==null?void 0:e.top)??0)}},ds=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},hn=({id:t,path:e,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p=20})=>x.createElement(x.Fragment,null,x.createElement("path",{id:t,style:u,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:d}),p&&x.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}),s&&Tt(n)&&Tt(r)?x.createElement(yw,{x:n,y:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null);hn.displayName="BaseEdge";function Sn(t,e,n){return n===void 0?n:r=>{const s=e().edges.find(o=>o.id===t);s&&n(r,{...s})}}function pu({sourceX:t,sourceY:e,targetX:n,targetY:r}){const s=Math.abs(n-t)/2,o=n<t?n+s:n-s,i=Math.abs(r-e)/2,a=r<e?r+i:r-i;return[o,a,s,i]}function gu({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:i,targetControlY:a}){const c=t*.125+s*.375+i*.375+n*.125,l=e*.125+o*.375+a*.375+r*.125,u=Math.abs(c-t),h=Math.abs(l-e);return[c,l,u,h]}exports.ConnectionMode=void 0;(function(t){t.Strict="strict",t.Loose="loose"})(exports.ConnectionMode||(exports.ConnectionMode={}));var ge;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ge||(ge={}));exports.SelectionMode=void 0;(function(t){t.Partial="partial",t.Full="full"})(exports.SelectionMode||(exports.SelectionMode={}));var Jt;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Jt||(Jt={}));var ps;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(ps||(ps={}));exports.Position=void 0;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(exports.Position||(exports.Position={}));function Na({pos:t,x1:e,y1:n,x2:r,y2:s}){return t===exports.Position.Left||t===exports.Position.Right?[.5*(e+r),n]:[e,.5*(n+s)]}function mu({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top}){const[i,a]=Na({pos:n,x1:t,y1:e,x2:r,y2:s}),[c,l]=Na({pos:o,x1:r,y1:s,x2:t,y2:e}),[u,h,d,p]=gu({sourceX:t,sourceY:e,targetX:r,targetY:s,sourceControlX:i,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${t},${e} C${i},${a} ${c},${l} ${r},${s}`,u,h,d,p]}const xi=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:s=exports.Position.Bottom,targetPosition:o=exports.Position.Top,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,interactionWidth:y})=>{const[E,v,R]=mu({sourceX:t,sourceY:e,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return x.createElement(hn,{path:E,labelX:v,labelY:R,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,interactionWidth:y})});xi.displayName="SimpleBezierEdge";const Oa={[exports.Position.Left]:{x:-1,y:0},[exports.Position.Right]:{x:1,y:0},[exports.Position.Top]:{x:0,y:-1},[exports.Position.Bottom]:{x:0,y:1}},Ew=({source:t,sourcePosition:e=exports.Position.Bottom,target:n})=>e===exports.Position.Left||e===exports.Position.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},Da=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function bw({source:t,sourcePosition:e=exports.Position.Bottom,target:n,targetPosition:r=exports.Position.Top,center:s,offset:o}){const i=Oa[e],a=Oa[r],c={x:t.x+i.x*o,y:t.y+i.y*o},l={x:n.x+a.x*o,y:n.y+a.y*o},u=Ew({source:c,sourcePosition:e,target:l}),h=u.x!==0?"x":"y",d=u[h];let p=[],w,y;const E={x:0,y:0},v={x:0,y:0},[R,_,S,M]=pu({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(i[h]*a[h]===-1){w=s.x??R,y=s.y??_;const O=[{x:w,y:c.y},{x:w,y:l.y}],$=[{x:c.x,y},{x:l.x,y}];i[h]===d?p=h==="x"?O:$:p=h==="x"?$:O}else{const O=[{x:c.x,y:l.y}],$=[{x:l.x,y:c.y}];if(h==="x"?p=i.x===d?$:O:p=i.y===d?O:$,e===r){const Y=Math.abs(t[h]-n[h]);if(Y<=o){const g=Math.min(o-1,o-Y);i[h]===d?E[h]=(c[h]>t[h]?-1:1)*g:v[h]=(l[h]>n[h]?-1:1)*g}}if(e!==r){const Y=h==="x"?"y":"x",g=i[h]===a[Y],A=c[Y]>l[Y],k=c[Y]<l[Y];(i[h]===1&&(!g&&A||g&&k)||i[h]!==1&&(!g&&k||g&&A))&&(p=h==="x"?O:$)}const D={x:c.x+E.x,y:c.y+E.y},Z={x:l.x+v.x,y:l.y+v.y},N=Math.max(Math.abs(D.x-p[0].x),Math.abs(Z.x-p[0].x)),U=Math.max(Math.abs(D.y-p[0].y),Math.abs(Z.y-p[0].y));N>=U?(w=(D.x+Z.x)/2,y=p[0].y):(w=p[0].x,y=(D.y+Z.y)/2)}return[[t,{x:c.x+E.x,y:c.y+E.y},...p,{x:l.x+v.x,y:l.y+v.y},n],w,y,S,M]}function Tw(t,e,n,r){const s=Math.min(Da(t,e)/2,Da(e,n)/2,r),{x:o,y:i}=e;if(t.x===o&&o===n.x||t.y===i&&i===n.y)return`L${o} ${i}`;if(t.y===i){const l=t.x<n.x?-1:1,u=t.y<n.y?1:-1;return`L ${o+s*l},${i}Q ${o},${i} ${o},${i+s*u}`}const a=t.x<n.x?1:-1,c=t.y<n.y?-1:1;return`L ${o},${i+s*c}Q ${o},${i} ${o+s*a},${i}`}function Co({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top,borderRadius:i=5,centerX:a,centerY:c,offset:l=20}){const[u,h,d,p,w]=bw({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:a,y:c},offset:l});return[u.reduce((E,v,R)=>{let _="";return R>0&&R<u.length-1?_=Tw(u[R-1],v,u[R+1],i):_=`${R===0?"M":"L"}${v.x} ${v.y}`,E+=_,E},""),h,d,p,w]}const Os=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:h=exports.Position.Bottom,targetPosition:d=exports.Position.Top,markerEnd:p,markerStart:w,pathOptions:y,interactionWidth:E})=>{const[v,R,_]=Co({sourceX:t,sourceY:e,sourcePosition:h,targetX:n,targetY:r,targetPosition:d,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset});return x.createElement(hn,{path:v,labelX:R,labelY:_,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:p,markerStart:w,interactionWidth:E})});Os.displayName="SmoothStepEdge";const vi=x.memo(t=>{var e;return x.createElement(Os,{...t,pathOptions:x.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});vi.displayName="StepEdge";function _w({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[s,o,i,a]=pu({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,s,o,i,a]}const Si=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p})=>{const[w,y,E]=_w({sourceX:t,sourceY:e,targetX:n,targetY:r});return x.createElement(hn,{path:w,labelX:y,labelY:E,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p})});Si.displayName="StraightEdge";function vr(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function za({pos:t,x1:e,y1:n,x2:r,y2:s,c:o}){switch(t){case exports.Position.Left:return[e-vr(e-r,o),n];case exports.Position.Right:return[e+vr(r-e,o),n];case exports.Position.Top:return[e,n-vr(n-s,o)];case exports.Position.Bottom:return[e,n+vr(s-n,o)]}}function yu({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top,curvature:i=.25}){const[a,c]=za({pos:n,x1:t,y1:e,x2:r,y2:s,c:i}),[l,u]=za({pos:o,x1:r,y1:s,x2:t,y2:e,c:i}),[h,d,p,w]=gu({sourceX:t,sourceY:e,targetX:r,targetY:s,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${t},${e} C${a},${c} ${l},${u} ${r},${s}`,h,d,p,w]}const gs=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:s=exports.Position.Bottom,targetPosition:o=exports.Position.Top,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,pathOptions:y,interactionWidth:E})=>{const[v,R,_]=yu({sourceX:t,sourceY:e,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:y==null?void 0:y.curvature});return x.createElement(hn,{path:v,labelX:R,labelY:_,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,interactionWidth:E})});gs.displayName="BezierEdge";const Ei=x.createContext(null),Cw=Ei.Provider;Ei.Consumer;const Pw=()=>x.useContext(Ei),kw=t=>"id"in t&&"source"in t&&"target"in t,wu=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`reactflow__edge-${t}${e||""}-${n}${r||""}`,Po=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`,Rw=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),xu=(t,e)=>{if(!t.source||!t.target)return fs("006",vt.error006()),e;let n;return kw(t)?n={...t}:n={...t,id:wu(t)},Rw(n,e)?e:e.concat(n)},Mw=(t,e,n,r={shouldReplaceId:!0})=>{const{id:s,...o}=t;if(!e.source||!e.target)return fs("006",vt.error006()),n;if(!n.find(c=>c.id===s))return fs("007",vt.error007(s)),n;const a={...o,id:r.shouldReplaceId?wu(e):s,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle};return n.filter(c=>c.id!==s).concat(a)},Aw=(t,e,n,r={shouldReplaceId:!0})=>(console.warn("[DEPRECATED] `updateEdge` is deprecated. Instead use `reconnectEdge` https://reactflow.dev/api-reference/utils/reconnect-edge"),Mw(t,e,n,r)),ko=({x:t,y:e},[n,r,s],o,[i,a])=>{const c={x:(t-n)/s,y:(e-r)/s};return o?{x:i*Math.round(c.x/i),y:a*Math.round(c.y/a)}:c},vu=({x:t,y:e},[n,r,s])=>({x:t*s+n,y:e*s+r}),Fe=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],r=(t.height??0)*e[1],s={x:t.position.x-n,y:t.position.y-r};return{...s,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-r}:s}},bi=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,s)=>{const{x:o,y:i}=Fe(s,e).positionAbsolute;return ww(r,wi({x:o,y:i,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return xw(n)},Su=(t,e,[n,r,s]=[0,0,1],o=!1,i=!1,a=[0,0])=>{const c={x:(e.x-n)/s,y:(e.y-r)/s,width:e.width/s,height:e.height/s},l=[];return t.forEach(u=>{const{width:h,height:d,selectable:p=!0,hidden:w=!1}=u;if(i&&!p||w)return!1;const{positionAbsolute:y}=Fe(u,a),E={x:y.x,y:y.y,width:h||0,height:d||0},v=To(c,E),R=typeof h>"u"||typeof d>"u"||h===null||d===null,_=o&&v>0,S=(h||0)*(d||0);(R||_||v>=S||u.dragging)&&l.push(u)}),l},Eu=(t,e)=>{const n=t.map(r=>r.id);return e.filter(r=>n.includes(r.source)||n.includes(r.target))},bu=(t,e,n,r,s,o=.1)=>{const i=e/(t.width*(1+o)),a=n/(t.height*(1+o)),c=Math.min(i,a),l=sn(c,r,s),u=t.x+t.width/2,h=t.y+t.height/2,d=e/2-u*l,p=n/2-h*l;return{x:d,y:p,zoom:l}},fe=(t,e=0)=>t.transition().duration(e);function La(t,e,n,r){return(e[n]||[]).reduce((s,o)=>{var i,a;return`${t.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:t.id,x:(((i=t.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((a=t.positionAbsolute)==null?void 0:a.y)??0)+o.y+o.height/2}),s},[])}function Nw(t,e,n,r,s,o){const{x:i,y:a}=ne(t),l=e.elementsFromPoint(i,a).find(w=>w.classList.contains("react-flow__handle"));if(l){const w=l.getAttribute("data-nodeid");if(w){const y=Ti(void 0,l),E=l.getAttribute("data-handleid"),v=o({nodeId:w,id:E,type:y});if(v){const R=s.find(_=>_.nodeId===w&&_.type===y&&_.id===E);return{handle:{id:E,type:y,nodeId:w,x:(R==null?void 0:R.x)||n.x,y:(R==null?void 0:R.y)||n.y},validHandleResult:v}}}}let u=[],h=1/0;if(s.forEach(w=>{const y=Math.sqrt((w.x-n.x)**2+(w.y-n.y)**2);if(y<=r){const E=o(w);y<=h&&(y<h?u=[{handle:w,validHandleResult:E}]:y===h&&u.push({handle:w,validHandleResult:E}),h=y)}}),!u.length)return{handle:null,validHandleResult:Tu()};if(u.length===1)return u[0];const d=u.some(({validHandleResult:w})=>w.isValid),p=u.some(({handle:w})=>w.type==="target");return u.find(({handle:w,validHandleResult:y})=>p?w.type==="target":d?y.isValid:!0)||u[0]}const Ow={source:null,target:null,sourceHandle:null,targetHandle:null},Tu=()=>({handleDomNode:null,isValid:!1,connection:Ow,endHandle:null});function _u(t,e,n,r,s,o,i){const a=s==="target",c=i.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),l={...Tu(),handleDomNode:c};if(c){const u=Ti(void 0,c),h=c.getAttribute("data-nodeid"),d=c.getAttribute("data-handleid"),p=c.classList.contains("connectable"),w=c.classList.contains("connectableend"),y={source:a?h:n,sourceHandle:a?d:r,target:a?n:h,targetHandle:a?r:d};l.connection=y,p&&w&&(e===exports.ConnectionMode.Strict?a&&u==="source"||!a&&u==="target":h!==n||d!==r)&&(l.endHandle={nodeId:h,handleId:d,type:u},l.isValid=o(y))}return l}function Dw({nodes:t,nodeId:e,handleId:n,handleType:r}){return t.reduce((s,o)=>{if(o[ct]){const{handleBounds:i}=o[ct];let a=[],c=[];i&&(a=La(o,i,"source",`${e}-${n}-${r}`),c=La(o,i,"target",`${e}-${n}-${r}`)),s.push(...a,...c)}return s},[])}function Ti(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function eo(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function zw(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function Cu({event:t,handleId:e,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:i,isValidConnection:a,edgeUpdaterType:c,onReconnectEnd:l}){const u=hu(t.target),{connectionMode:h,domNode:d,autoPanOnConnect:p,connectionRadius:w,onConnectStart:y,panBy:E,getNodes:v,cancelConnection:R}=o();let _=0,S;const{x:M,y:C}=ne(t),O=u==null?void 0:u.elementFromPoint(M,C),$=Ti(c,O),D=d==null?void 0:d.getBoundingClientRect();if(!D||!$)return;let Z,N=ne(t,D),U=!1,Y=null,g=!1,A=null;const k=Dw({nodes:v(),nodeId:n,handleId:e,handleType:$}),z=()=>{if(!p)return;const[L,q]=uu(N,D);E({x:L,y:q}),_=requestAnimationFrame(z)};i({connectionPosition:N,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:$,connectionStartHandle:{nodeId:n,handleId:e,type:$},connectionEndHandle:null}),y==null||y(t,{nodeId:n,handleId:e,handleType:$});function B(L){const{transform:q}=o();N=ne(L,D);const{handle:F,validHandleResult:G}=Nw(L,u,ko(N,q,!1,[1,1]),w,k,V=>_u(V,h,n,e,s?"target":"source",a,u));if(S=F,U||(z(),U=!0),A=G.handleDomNode,Y=G.connection,g=G.isValid,i({connectionPosition:S&&g?vu({x:S.x,y:S.y},q):N,connectionStatus:zw(!!S,g),connectionEndHandle:G.endHandle}),!S&&!g&&!A)return eo(Z);Y.source!==Y.target&&A&&(eo(Z),Z=A,A.classList.add("connecting","react-flow__handle-connecting"),A.classList.toggle("valid",g),A.classList.toggle("react-flow__handle-valid",g))}function P(L){var q,F;(S||A)&&Y&&g&&(r==null||r(Y)),(F=(q=o()).onConnectEnd)==null||F.call(q,L),c&&(l==null||l(L)),eo(Z),R(),cancelAnimationFrame(_),U=!1,g=!1,Y=null,A=null,u.removeEventListener("mousemove",B),u.removeEventListener("mouseup",P),u.removeEventListener("touchmove",B),u.removeEventListener("touchend",P)}u.addEventListener("mousemove",B),u.addEventListener("mouseup",P),u.addEventListener("touchmove",B),u.addEventListener("touchend",P)}const Ia=()=>!0,Lw=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),Iw=(t,e,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:i}=r;return{connecting:(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.handleId)===e&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.handleId)===e&&(i==null?void 0:i.type)===n}},Pu=x.forwardRef(({type:t="source",position:e=exports.Position.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:i,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:h,...d},p)=>{var D,Z;const w=i||null,y=t==="target",E=ht(),v=Pw(),{connectOnClick:R,noPanClassName:_}=lt(Lw,gt),{connecting:S,clickConnecting:M}=lt(Iw(v,w,t),gt);v||(Z=(D=E.getState()).onError)==null||Z.call(D,"010",vt.error010());const C=N=>{const{defaultEdgeOptions:U,onConnect:Y,hasDefaultEdges:g}=E.getState(),A={...U,...N};if(g){const{edges:k,setEdges:z}=E.getState();z(xu(A,k))}Y==null||Y(A),a==null||a(A)},O=N=>{if(!v)return;const U=du(N);s&&(U&&N.button===0||!U)&&Cu({event:N,handleId:w,nodeId:v,onConnect:C,isTarget:y,getState:E.getState,setState:E.setState,isValidConnection:n||E.getState().isValidConnection||Ia}),U?u==null||u(N):h==null||h(N)},$=N=>{const{onClickConnectStart:U,onClickConnectEnd:Y,connectionClickStartHandle:g,connectionMode:A,isValidConnection:k}=E.getState();if(!v||!g&&!s)return;if(!g){U==null||U(N,{nodeId:v,handleId:w,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:v,type:t,handleId:w}});return}const z=hu(N.target),B=n||k||Ia,{connection:P,isValid:L}=_u({nodeId:v,id:w,type:t},A,g.nodeId,g.handleId||null,g.type,B,z);L&&C(P),Y==null||Y(N),E.setState({connectionClickStartHandle:null})};return x.createElement("div",{"data-handleid":w,"data-nodeid":v,"data-handlepos":e,"data-id":`${v}-${w}-${t}`,className:St(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",_,l,{source:!y,target:y,connectable:r,connectablestart:s,connectableend:o,connecting:M,connectionindicator:r&&(s&&!S||o&&S)}]),onMouseDown:O,onTouchStart:O,onClick:R?$:void 0,ref:p,...d},c)});Pu.displayName="Handle";var Qn=x.memo(Pu);const ku=({data:t,isConnectable:e,targetPosition:n=exports.Position.Top,sourcePosition:r=exports.Position.Bottom})=>x.createElement(x.Fragment,null,x.createElement(Qn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,x.createElement(Qn,{type:"source",position:r,isConnectable:e}));ku.displayName="DefaultNode";var Ro=x.memo(ku);const Ru=({data:t,isConnectable:e,sourcePosition:n=exports.Position.Bottom})=>x.createElement(x.Fragment,null,t==null?void 0:t.label,x.createElement(Qn,{type:"source",position:n,isConnectable:e}));Ru.displayName="InputNode";var Mu=x.memo(Ru);const Au=({data:t,isConnectable:e,targetPosition:n=exports.Position.Top})=>x.createElement(x.Fragment,null,x.createElement(Qn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);Au.displayName="OutputNode";var Nu=x.memo(Au);const _i=()=>null;_i.displayName="GroupNode";const $w=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),Sr=t=>t.id;function Yw(t,e){return gt(t.selectedNodes.map(Sr),e.selectedNodes.map(Sr))&>(t.selectedEdges.map(Sr),e.selectedEdges.map(Sr))}const Ou=x.memo(({onSelectionChange:t})=>{const e=ht(),{selectedNodes:n,selectedEdges:r}=lt($w,Yw);return x.useEffect(()=>{const s={nodes:n,edges:r};t==null||t(s),e.getState().onSelectionChange.forEach(o=>o(s))},[n,r,t]),null});Ou.displayName="SelectionListener";const Bw=t=>!!t.onSelectionChange;function qw({onSelectionChange:t}){const e=lt(Bw);return t||e?x.createElement(Ou,{onSelectionChange:t}):null}const Fw=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function Me(t,e){x.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function Q(t,e,n){x.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const Zw=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:i,onClickConnectStart:a,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:h,edgesFocusable:d,edgesUpdatable:p,elevateNodesOnSelect:w,minZoom:y,maxZoom:E,nodeExtent:v,onNodesChange:R,onEdgesChange:_,elementsSelectable:S,connectionMode:M,snapGrid:C,snapToGrid:O,translateExtent:$,connectOnClick:D,defaultEdgeOptions:Z,fitView:N,fitViewOptions:U,onNodesDelete:Y,onEdgesDelete:g,onNodeDrag:A,onNodeDragStart:k,onNodeDragStop:z,onSelectionDrag:B,onSelectionDragStart:P,onSelectionDragStop:L,noPanClassName:q,nodeOrigin:F,rfId:G,autoPanOnConnect:V,autoPanOnNodeDrag:K,onError:tt,connectionRadius:et,isValidConnection:ot,nodeDragThreshold:H})=>{const{setNodes:X,setEdges:j,setDefaultNodesAndEdges:I,setMinZoom:it,setMaxZoom:J,setTranslateExtent:nt,setNodeExtent:at,reset:rt}=lt(Fw,gt),W=ht();return x.useEffect(()=>{const wt=r==null?void 0:r.map(oe=>({...oe,...Z}));return I(n,wt),()=>{rt()}},[]),Q("defaultEdgeOptions",Z,W.setState),Q("connectionMode",M,W.setState),Q("onConnect",s,W.setState),Q("onConnectStart",o,W.setState),Q("onConnectEnd",i,W.setState),Q("onClickConnectStart",a,W.setState),Q("onClickConnectEnd",c,W.setState),Q("nodesDraggable",l,W.setState),Q("nodesConnectable",u,W.setState),Q("nodesFocusable",h,W.setState),Q("edgesFocusable",d,W.setState),Q("edgesUpdatable",p,W.setState),Q("elementsSelectable",S,W.setState),Q("elevateNodesOnSelect",w,W.setState),Q("snapToGrid",O,W.setState),Q("snapGrid",C,W.setState),Q("onNodesChange",R,W.setState),Q("onEdgesChange",_,W.setState),Q("connectOnClick",D,W.setState),Q("fitViewOnInit",N,W.setState),Q("fitViewOnInitOptions",U,W.setState),Q("onNodesDelete",Y,W.setState),Q("onEdgesDelete",g,W.setState),Q("onNodeDrag",A,W.setState),Q("onNodeDragStart",k,W.setState),Q("onNodeDragStop",z,W.setState),Q("onSelectionDrag",B,W.setState),Q("onSelectionDragStart",P,W.setState),Q("onSelectionDragStop",L,W.setState),Q("noPanClassName",q,W.setState),Q("nodeOrigin",F,W.setState),Q("rfId",G,W.setState),Q("autoPanOnConnect",V,W.setState),Q("autoPanOnNodeDrag",K,W.setState),Q("onError",tt,W.setState),Q("connectionRadius",et,W.setState),Q("isValidConnection",ot,W.setState),Q("nodeDragThreshold",H,W.setState),Me(t,X),Me(e,j),Me(y,it),Me(E,J),Me($,nt),Me(v,at),null},$a={display:"none"},Uw={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Du="react-flow__node-desc",zu="react-flow__edge-desc",Hw="react-flow__aria-live",Vw=t=>t.ariaLiveMessage;function Gw({rfId:t}){const e=lt(Vw);return x.createElement("div",{id:`${Hw}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Uw},e)}function Xw({rfId:t,disableKeyboardA11y:e}){return x.createElement(x.Fragment,null,x.createElement("div",{id:`${Du}-${t}`,style:$a},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),x.createElement("div",{id:`${zu}-${t}`,style:$a},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&x.createElement(Gw,{rfId:t}))}var tr=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,r]=x.useState(!1),s=x.useRef(!1),o=x.useRef(new Set([])),[i,a]=x.useMemo(()=>{if(t!==null){const l=(Array.isArray(t)?t:[t]).filter(h=>typeof h=="string").map(h=>h.split("+")),u=l.reduce((h,d)=>h.concat(...d),[]);return[l,u]}return[[],[]]},[t]);return x.useEffect(()=>{const c=typeof document<"u"?document:null,l=(e==null?void 0:e.target)||c;if(t!==null){const u=p=>{if(s.current=p.ctrlKey||p.metaKey||p.shiftKey,(!s.current||s.current&&!e.actInsideInputWithModifier)&&_o(p))return!1;const y=Ba(p.code,a);o.current.add(p[y]),Ya(i,o.current,!1)&&(p.preventDefault(),r(!0))},h=p=>{if((!s.current||s.current&&!e.actInsideInputWithModifier)&&_o(p))return!1;const y=Ba(p.code,a);Ya(i,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(p[y]),p.key==="Meta"&&o.current.clear(),s.current=!1},d=()=>{o.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",u),l==null||l.addEventListener("keyup",h),window.addEventListener("blur",d),()=>{l==null||l.removeEventListener("keydown",u),l==null||l.removeEventListener("keyup",h),window.removeEventListener("blur",d)}}},[t,r]),n};function Ya(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(s=>e.has(s)))}function Ba(t,e){return e.includes(t)?"code":"key"}function Lu(t,e,n,r){var a,c;const s=t.parentNode||t.parentId;if(!s)return n;const o=e.get(s),i=Fe(o,r);return Lu(o,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((a=o[ct])==null?void 0:a.z)??0)>(n.z??0)?((c=o[ct])==null?void 0:c.z)??0:n.z??0},r)}function Iu(t,e,n){t.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!t.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:i,y:a,z:c}=Lu(r,t,{...r.position,z:((o=r[ct])==null?void 0:o.z)??0},e);r.positionAbsolute={x:i,y:a},r[ct].z=c,n!=null&&n[r.id]&&(r[ct].isParent=!0)}})}function no(t,e,n,r){const s=new Map,o={},i=r?1e3:0;return t.forEach(a=>{var p;const c=(Tt(a.zIndex)?a.zIndex:0)+(a.selected?i:0),l=e.get(a.id),u={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},h=a.parentNode||a.parentId;h&&(o[h]=!0);const d=(l==null?void 0:l.type)&&(l==null?void 0:l.type)!==a.type;Object.defineProperty(u,ct,{enumerable:!1,value:{handleBounds:d||(p=l==null?void 0:l[ct])==null?void 0:p.handleBounds,z:c}}),s.set(a.id,u)}),Iu(s,n,o),s}function $u(t,e={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:i,d3Zoom:a,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:h}=t(),d=e.initial&&!l&&u;if(a&&c&&(d||!e.initial)){const w=n().filter(E=>{var R;const v=e.includeHiddenNodes?E.width&&E.height:!E.hidden;return(R=e.nodes)!=null&&R.length?v&&e.nodes.some(_=>_.id===E.id):v}),y=w.every(E=>E.width&&E.height);if(w.length>0&&y){const E=bi(w,h),{x:v,y:R,zoom:_}=bu(E,r,s,e.minZoom??o,e.maxZoom??i,e.padding??.1),S=ee.translate(v,R).scale(_);return typeof e.duration=="number"&&e.duration>0?a.transform(fe(c,e.duration),S):a.transform(c,S),!0}}return!1}function Ww(t,e){return t.forEach(n=>{const r=e.get(n.id);r&&e.set(r.id,{...r,[ct]:r[ct],selected:n.selected})}),new Map(e)}function Kw(t,e){return e.map(n=>{const r=t.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function Er({changedNodes:t,changedEdges:e,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:i,onEdgesChange:a,hasDefaultNodes:c,hasDefaultEdges:l}=n();t!=null&&t.length&&(c&&r({nodeInternals:Ww(t,s)}),i==null||i(t)),e!=null&&e.length&&(l&&r({edges:Kw(e,o)}),a==null||a(e))}const Ae=()=>{},jw={zoomIn:Ae,zoomOut:Ae,zoomTo:Ae,getZoom:()=>1,setViewport:Ae,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ae,fitBounds:Ae,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},Jw=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),Qw=()=>{const t=ht(),{d3Zoom:e,d3Selection:n}=lt(Jw,gt);return x.useMemo(()=>n&&e?{zoomIn:s=>e.scaleBy(fe(n,s==null?void 0:s.duration),1.2),zoomOut:s=>e.scaleBy(fe(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>e.scaleTo(fe(n,o==null?void 0:o.duration),s),getZoom:()=>t.getState().transform[2],setViewport:(s,o)=>{const[i,a,c]=t.getState().transform,l=ee.translate(s.x??i,s.y??a).scale(s.zoom??c);e.transform(fe(n,o==null?void 0:o.duration),l)},getViewport:()=>{const[s,o,i]=t.getState().transform;return{x:s,y:o,zoom:i}},fitView:s=>$u(t.getState,s),setCenter:(s,o,i)=>{const{width:a,height:c,maxZoom:l}=t.getState(),u=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:l,h=a/2-s*u,d=c/2-o*u,p=ee.translate(h,d).scale(u);e.transform(fe(n,i==null?void 0:i.duration),p)},fitBounds:(s,o)=>{const{width:i,height:a,minZoom:c,maxZoom:l}=t.getState(),{x:u,y:h,zoom:d}=bu(s,i,a,c,l,(o==null?void 0:o.padding)??.1),p=ee.translate(u,h).scale(d);e.transform(fe(n,o==null?void 0:o.duration),p)},project:s=>{const{transform:o,snapToGrid:i,snapGrid:a}=t.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),ko(s,o,i,a)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:i,snapGrid:a,domNode:c}=t.getState();if(!c)return s;const{x:l,y:u}=c.getBoundingClientRect(),h={x:s.x-l,y:s.y-u};return ko(h,o,i,a)},flowToScreenPosition:s=>{const{transform:o,domNode:i}=t.getState();if(!i)return s;const{x:a,y:c}=i.getBoundingClientRect(),l=vu(s,o);return{x:l.x+a,y:l.y+c}},viewportInitialized:!0}:jw,[e,n])};function Ds(){const t=Qw(),e=ht(),n=x.useCallback(()=>e.getState().getNodes().map(y=>({...y})),[]),r=x.useCallback(y=>e.getState().nodeInternals.get(y),[]),s=x.useCallback(()=>{const{edges:y=[]}=e.getState();return y.map(E=>({...E}))},[]),o=x.useCallback(y=>{const{edges:E=[]}=e.getState();return E.find(v=>v.id===y)},[]),i=x.useCallback(y=>{const{getNodes:E,setNodes:v,hasDefaultNodes:R,onNodesChange:_}=e.getState(),S=E(),M=typeof y=="function"?y(S):y;if(R)v(M);else if(_){const C=M.length===0?S.map(O=>({type:"remove",id:O.id})):M.map(O=>({item:O,type:"reset"}));_(C)}},[]),a=x.useCallback(y=>{const{edges:E=[],setEdges:v,hasDefaultEdges:R,onEdgesChange:_}=e.getState(),S=typeof y=="function"?y(E):y;if(R)v(S);else if(_){const M=S.length===0?E.map(C=>({type:"remove",id:C.id})):S.map(C=>({item:C,type:"reset"}));_(M)}},[]),c=x.useCallback(y=>{const E=Array.isArray(y)?y:[y],{getNodes:v,setNodes:R,hasDefaultNodes:_,onNodesChange:S}=e.getState();if(_){const C=[...v(),...E];R(C)}else if(S){const M=E.map(C=>({item:C,type:"add"}));S(M)}},[]),l=x.useCallback(y=>{const E=Array.isArray(y)?y:[y],{edges:v=[],setEdges:R,hasDefaultEdges:_,onEdgesChange:S}=e.getState();if(_)R([...v,...E]);else if(S){const M=E.map(C=>({item:C,type:"add"}));S(M)}},[]),u=x.useCallback(()=>{const{getNodes:y,edges:E=[],transform:v}=e.getState(),[R,_,S]=v;return{nodes:y().map(M=>({...M})),edges:E.map(M=>({...M})),viewport:{x:R,y:_,zoom:S}}},[]),h=x.useCallback(({nodes:y,edges:E})=>{const{nodeInternals:v,getNodes:R,edges:_,hasDefaultNodes:S,hasDefaultEdges:M,onNodesDelete:C,onEdgesDelete:O,onNodesChange:$,onEdgesChange:D}=e.getState(),Z=(y||[]).map(A=>A.id),N=(E||[]).map(A=>A.id),U=R().reduce((A,k)=>{const z=k.parentNode||k.parentId,B=!Z.includes(k.id)&&z&&A.find(L=>L.id===z);return(typeof k.deletable=="boolean"?k.deletable:!0)&&(Z.includes(k.id)||B)&&A.push(k),A},[]),Y=_.filter(A=>typeof A.deletable=="boolean"?A.deletable:!0),g=Y.filter(A=>N.includes(A.id));if(U||g){const A=Eu(U,Y),k=[...g,...A],z=k.reduce((B,P)=>(B.includes(P.id)||B.push(P.id),B),[]);if((M||S)&&(M&&e.setState({edges:_.filter(B=>!z.includes(B.id))}),S&&(U.forEach(B=>{v.delete(B.id)}),e.setState({nodeInternals:new Map(v)}))),z.length>0&&(O==null||O(k),D&&D(z.map(B=>({id:B,type:"remove"})))),U.length>0&&(C==null||C(U),$)){const B=U.map(P=>({id:P.id,type:"remove"}));$(B)}}},[]),d=x.useCallback(y=>{const E=vw(y),v=E?null:e.getState().nodeInternals.get(y.id);return!E&&!v?[null,null,E]:[E?y:Aa(v),v,E]},[]),p=x.useCallback((y,E=!0,v)=>{const[R,_,S]=d(y);return R?(v||e.getState().getNodes()).filter(M=>{if(!S&&(M.id===_.id||!M.positionAbsolute))return!1;const C=Aa(M),O=To(C,R);return E&&O>0||O>=R.width*R.height}):[]},[]),w=x.useCallback((y,E,v=!0)=>{const[R]=d(y);if(!R)return!1;const _=To(R,E);return v&&_>0||_>=R.width*R.height},[]);return x.useMemo(()=>({...t,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:i,setEdges:a,addNodes:c,addEdges:l,toObject:u,deleteElements:h,getIntersectingNodes:p,isNodeIntersecting:w}),[t,n,r,s,o,i,a,c,l,u,h,p,w])}const tx={actInsideInputWithModifier:!1};var ex=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=ht(),{deleteElements:r}=Ds(),s=tr(t,tx),o=tr(e);x.useEffect(()=>{if(s){const{edges:i,getNodes:a}=n.getState(),c=a().filter(u=>u.selected),l=i.filter(u=>u.selected);r({nodes:c,edges:l}),n.setState({nodesSelectionActive:!1})}},[s]),x.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function nx(t){const e=ht();x.useEffect(()=>{let n;const r=()=>{var o,i;if(!t.current)return;const s=mi(t.current);(s.height===0||s.width===0)&&((i=(o=e.getState()).onError)==null||i.call(o,"004",vt.error004())),e.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),t.current&&(n=new ResizeObserver(()=>r()),n.observe(t.current)),()=>{window.removeEventListener("resize",r),n&&t.current&&n.unobserve(t.current)}},[])}const Ci={position:"absolute",width:"100%",height:"100%",top:0,left:0},rx=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,br=t=>({x:t.x,y:t.y,zoom:t.k}),Ne=(t,e)=>t.target.closest(`.${e}`),qa=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),Fa=t=>{const e=t.ctrlKey&&ds()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},sx=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),ox=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:a=.5,panOnScrollMode:c=ge.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:h=!0,defaultViewport:d,translateExtent:p,minZoom:w,maxZoom:y,zoomActivationKeyCode:E,preventScrolling:v=!0,children:R,noWheelClassName:_,noPanClassName:S})=>{const M=x.useRef(),C=ht(),O=x.useRef(!1),$=x.useRef(!1),D=x.useRef(null),Z=x.useRef({x:0,y:0,zoom:0}),{d3Zoom:N,d3Selection:U,d3ZoomHandler:Y,userSelectionActive:g}=lt(sx,gt),A=tr(E),k=x.useRef(0),z=x.useRef(!1),B=x.useRef();return nx(D),x.useEffect(()=>{if(D.current){const P=D.current.getBoundingClientRect(),L=hw().scaleExtent([w,y]).translateExtent(p),q=Rt(D.current).call(L),F=ee.translate(d.x,d.y).scale(sn(d.zoom,w,y)),G=[[0,0],[P.width,P.height]],V=L.constrain()(F,G,p);L.transform(q,V),L.wheelDelta(Fa),C.setState({d3Zoom:L,d3Selection:q,d3ZoomHandler:q.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:D.current.closest(".react-flow")})}},[]),x.useEffect(()=>{U&&N&&(i&&!A&&!g?U.on("wheel.zoom",P=>{if(Ne(P,_))return!1;P.preventDefault(),P.stopImmediatePropagation();const L=U.property("__zoom").k||1;if(P.ctrlKey&&o){const ot=zt(P),H=Fa(P),X=L*Math.pow(2,H);N.scaleTo(U,X,ot,P);return}const q=P.deltaMode===1?20:1;let F=c===ge.Vertical?0:P.deltaX*q,G=c===ge.Horizontal?0:P.deltaY*q;!ds()&&P.shiftKey&&c!==ge.Vertical&&(F=P.deltaY*q,G=0),N.translateBy(U,-(F/L)*a,-(G/L)*a,{internal:!0});const V=br(U.property("__zoom")),{onViewportChangeStart:K,onViewportChange:tt,onViewportChangeEnd:et}=C.getState();clearTimeout(B.current),z.current||(z.current=!0,e==null||e(P,V),K==null||K(V)),z.current&&(t==null||t(P,V),tt==null||tt(V),B.current=setTimeout(()=>{n==null||n(P,V),et==null||et(V),z.current=!1},150))},{passive:!1}):typeof Y<"u"&&U.on("wheel.zoom",function(P,L){if(!v&&P.type==="wheel"&&!P.ctrlKey||Ne(P,_))return null;P.preventDefault(),Y.call(this,P,L)},{passive:!1}))},[g,i,c,U,N,Y,A,o,v,_,e,t,n]),x.useEffect(()=>{N&&N.on("start",P=>{var F,G;if(!P.sourceEvent||P.sourceEvent.internal)return null;k.current=(F=P.sourceEvent)==null?void 0:F.button;const{onViewportChangeStart:L}=C.getState(),q=br(P.transform);O.current=!0,Z.current=q,((G=P.sourceEvent)==null?void 0:G.type)==="mousedown"&&C.setState({paneDragging:!0}),L==null||L(q),e==null||e(P.sourceEvent,q)})},[N,e]),x.useEffect(()=>{N&&(g&&!O.current?N.on("zoom",null):g||N.on("zoom",P=>{var q;const{onViewportChange:L}=C.getState();if(C.setState({transform:[P.transform.x,P.transform.y,P.transform.k]}),$.current=!!(r&&qa(h,k.current??0)),(t||L)&&!((q=P.sourceEvent)!=null&&q.internal)){const F=br(P.transform);L==null||L(F),t==null||t(P.sourceEvent,F)}}))},[g,N,t,h,r]),x.useEffect(()=>{N&&N.on("end",P=>{if(!P.sourceEvent||P.sourceEvent.internal)return null;const{onViewportChangeEnd:L}=C.getState();if(O.current=!1,C.setState({paneDragging:!1}),r&&qa(h,k.current??0)&&!$.current&&r(P.sourceEvent),$.current=!1,(n||L)&&rx(Z.current,P.transform)){const q=br(P.transform);Z.current=q,clearTimeout(M.current),M.current=setTimeout(()=>{L==null||L(q),n==null||n(P.sourceEvent,q)},i?150:0)}})},[N,i,h,n,r]),x.useEffect(()=>{N&&N.filter(P=>{const L=A||s,q=o&&P.ctrlKey;if((h===!0||Array.isArray(h)&&h.includes(1))&&P.button===1&&P.type==="mousedown"&&(Ne(P,"react-flow__node")||Ne(P,"react-flow__edge")))return!0;if(!h&&!L&&!i&&!l&&!o||g||!l&&P.type==="dblclick"||Ne(P,_)&&P.type==="wheel"||Ne(P,S)&&(P.type!=="wheel"||i&&P.type==="wheel"&&!A)||!o&&P.ctrlKey&&P.type==="wheel"||!L&&!i&&!q&&P.type==="wheel"||!h&&(P.type==="mousedown"||P.type==="touchstart")||Array.isArray(h)&&!h.includes(P.button)&&P.type==="mousedown")return!1;const F=Array.isArray(h)&&h.includes(P.button)||!P.button||P.button<=1;return(!P.ctrlKey||P.type==="wheel")&&F})},[g,N,s,o,i,l,h,u,A]),x.createElement("div",{className:"react-flow__renderer",ref:D,style:Ci},R)},ix=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function ax(){const{userSelectionActive:t,userSelectionRect:e}=lt(ix,gt);return t&&e?x.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function Za(t,e){const n=e.parentNode||e.parentId,r=t.find(s=>s.id===n);if(r){const s=e.position.x+e.width-r.width,o=e.position.y+e.height-r.height;if(s>0||o>0||e.position.x<0||e.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),e.position.x<0){const i=Math.abs(e.position.x);r.position.x=r.position.x-i,r.style.width+=i,e.position.x=0}if(e.position.y<0){const i=Math.abs(e.position.y);r.position.y=r.position.y-i,r.style.height+=i,e.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Yu(t,e){if(t.some(r=>r.type==="reset"))return t.filter(r=>r.type==="reset").map(r=>r.item);const n=t.filter(r=>r.type==="add").map(r=>r.item);return e.reduce((r,s)=>{const o=t.filter(a=>a.id===s.id);if(o.length===0)return r.push(s),r;const i={...s};for(const a of o)if(a)switch(a.type){case"select":{i.selected=a.selected;break}case"position":{typeof a.position<"u"&&(i.position=a.position),typeof a.positionAbsolute<"u"&&(i.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(i.dragging=a.dragging),i.expandParent&&Za(r,i);break}case"dimensions":{typeof a.dimensions<"u"&&(i.width=a.dimensions.width,i.height=a.dimensions.height),typeof a.updateStyle<"u"&&(i.style={...i.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(i.resizing=a.resizing),i.expandParent&&Za(r,i);break}case"remove":return r}return r.push(i),r},n)}function Bu(t,e){return Yu(t,e)}function cx(t,e){return Yu(t,e)}const jt=(t,e)=>({id:t,type:"select",selected:e});function Le(t,e){return t.reduce((n,r)=>{const s=e.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(jt(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(jt(r.id,!1))),n},[])}const ro=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},lx=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),qu=x.memo(({isSelecting:t,selectionMode:e=exports.SelectionMode.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:a,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:h})=>{const d=x.useRef(null),p=ht(),w=x.useRef(0),y=x.useRef(0),E=x.useRef(),{userSelectionActive:v,elementsSelectable:R,dragging:_}=lt(lx,gt),S=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),w.current=0,y.current=0},M=Y=>{o==null||o(Y),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},C=Y=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){Y.preventDefault();return}i==null||i(Y)},O=a?Y=>a(Y):void 0,$=Y=>{const{resetSelectedElements:g,domNode:A}=p.getState();if(E.current=A==null?void 0:A.getBoundingClientRect(),!R||!t||Y.button!==0||Y.target!==d.current||!E.current)return;const{x:k,y:z}=ne(Y,E.current);g(),p.setState({userSelectionRect:{width:0,height:0,startX:k,startY:z,x:k,y:z}}),r==null||r(Y)},D=Y=>{const{userSelectionRect:g,nodeInternals:A,edges:k,transform:z,onNodesChange:B,onEdgesChange:P,nodeOrigin:L,getNodes:q}=p.getState();if(!t||!E.current||!g)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const F=ne(Y,E.current),G=g.startX??0,V=g.startY??0,K={...g,x:F.x<G?F.x:G,y:F.y<V?F.y:V,width:Math.abs(F.x-G),height:Math.abs(F.y-V)},tt=q(),et=Su(A,K,z,e===exports.SelectionMode.Partial,!0,L),ot=Eu(et,k).map(X=>X.id),H=et.map(X=>X.id);if(w.current!==H.length){w.current=H.length;const X=Le(tt,H);X.length&&(B==null||B(X))}if(y.current!==ot.length){y.current=ot.length;const X=Le(k,ot);X.length&&(P==null||P(X))}p.setState({userSelectionRect:K})},Z=Y=>{if(Y.button!==0)return;const{userSelectionRect:g}=p.getState();!v&&g&&Y.target===d.current&&(M==null||M(Y)),p.setState({nodesSelectionActive:w.current>0}),S(),s==null||s(Y)},N=Y=>{v&&(p.setState({nodesSelectionActive:w.current>0}),s==null||s(Y)),S()},U=R&&(t||v);return x.createElement("div",{className:St(["react-flow__pane",{dragging:_,selection:t}]),onClick:U?void 0:ro(M,d),onContextMenu:ro(C,d),onWheel:ro(O,d),onMouseEnter:U?void 0:c,onMouseDown:U?$:void 0,onMouseMove:U?D:l,onMouseUp:U?Z:void 0,onMouseLeave:U?N:u,ref:d,style:Ci},h,x.createElement(ax,null))});qu.displayName="Pane";function Fu(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const r=e.get(n);return r?r.selected?!0:Fu(r,e):!1}function Ua(t,e,n){let r=t;do{if(r!=null&&r.matches(e))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function ux(t,e,n,r){return Array.from(t.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!Fu(s,t))&&(s.draggable||e&&typeof s.draggable>"u")).map(s=>{var o,i;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=s.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function hx(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function Zu(t,e,n,r,s=[0,0],o){const i=hx(t,t.extent||r);let a=i;const c=t.parentNode||t.parentId;if(t.extent==="parent"&&!t.expandParent)if(c&&t.width&&t.height){const h=n.get(c),{x:d,y:p}=Fe(h,s).positionAbsolute;a=h&&Tt(d)&&Tt(p)&&Tt(h.width)&&Tt(h.height)?[[d+t.width*s[0],p+t.height*s[1]],[d+h.width-t.width+t.width*s[0],p+h.height-t.height+t.height*s[1]]]:a}else o==null||o("005",vt.error005()),a=i;else if(t.extent&&c&&t.extent!=="parent"){const h=n.get(c),{x:d,y:p}=Fe(h,s).positionAbsolute;a=[[t.extent[0][0]+d,t.extent[0][1]+p],[t.extent[1][0]+d,t.extent[1][1]+p]]}let l={x:0,y:0};if(c){const h=n.get(c);l=Fe(h,s).positionAbsolute}const u=a&&a!=="parent"?yi(e,a):e;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function so({nodeId:t,dragItems:e,nodeInternals:n}){const r=e.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[t?r.find(s=>s.id===t):r[0],r]}const Ha=(t,e,n,r)=>{const s=e.querySelectorAll(t);if(!s||!s.length)return null;const o=Array.from(s),i=e.getBoundingClientRect(),a={x:i.width*r[0],y:i.height*r[1]};return o.map(c=>{const l=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(l.left-i.left-a.x)/n,y:(l.top-i.top-a.y)/n,...mi(c)}})};function En(t,e,n){return n===void 0?n:r=>{const s=e().nodeInternals.get(t);s&&n(r,{...s})}}function Mo({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:a,onError:c}=e.getState(),l=a.get(t);if(!l){c==null||c("012",vt.error012(t));return}e.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(o({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([t])}function fx(){const t=ht();return x.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=t.getState(),i=n.touches?n.touches[0].clientX:n.clientX,a=n.touches?n.touches[0].clientY:n.clientY,c={x:(i-r[0])/r[2],y:(a-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(c.x/s[0]):c.x,ySnapped:o?s[1]*Math.round(c.y/s[1]):c.y,...c}},[])}function oo(t){return(e,n,r)=>t==null?void 0:t(e,r)}function Uu({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:i}){const a=ht(),[c,l]=x.useState(!1),u=x.useRef([]),h=x.useRef({x:null,y:null}),d=x.useRef(0),p=x.useRef(null),w=x.useRef({x:0,y:0}),y=x.useRef(null),E=x.useRef(!1),v=x.useRef(!1),R=x.useRef(!1),_=fx();return x.useEffect(()=>{if(t!=null&&t.current){const S=Rt(t.current),M=({x:$,y:D})=>{const{nodeInternals:Z,onNodeDrag:N,onSelectionDrag:U,updateNodePositions:Y,nodeExtent:g,snapGrid:A,snapToGrid:k,nodeOrigin:z,onError:B}=a.getState();h.current={x:$,y:D};let P=!1,L={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&g){const F=bi(u.current,z);L=wi(F)}if(u.current=u.current.map(F=>{const G={x:$-F.distance.x,y:D-F.distance.y};k&&(G.x=A[0]*Math.round(G.x/A[0]),G.y=A[1]*Math.round(G.y/A[1]));const V=[[g[0][0],g[0][1]],[g[1][0],g[1][1]]];u.current.length>1&&g&&!F.extent&&(V[0][0]=F.positionAbsolute.x-L.x+g[0][0],V[1][0]=F.positionAbsolute.x+(F.width??0)-L.x2+g[1][0],V[0][1]=F.positionAbsolute.y-L.y+g[0][1],V[1][1]=F.positionAbsolute.y+(F.height??0)-L.y2+g[1][1]);const K=Zu(F,G,Z,V,z,B);return P=P||F.position.x!==K.position.x||F.position.y!==K.position.y,F.position=K.position,F.positionAbsolute=K.positionAbsolute,F}),!P)return;Y(u.current,!0,!0),l(!0);const q=s?N:oo(U);if(q&&y.current){const[F,G]=so({nodeId:s,dragItems:u.current,nodeInternals:Z});q(y.current,F,G)}},C=()=>{if(!p.current)return;const[$,D]=uu(w.current,p.current);if($!==0||D!==0){const{transform:Z,panBy:N}=a.getState();h.current.x=(h.current.x??0)-$/Z[2],h.current.y=(h.current.y??0)-D/Z[2],N({x:$,y:D})&&M(h.current)}d.current=requestAnimationFrame(C)},O=$=>{var z;const{nodeInternals:D,multiSelectionActive:Z,nodesDraggable:N,unselectNodesAndEdges:U,onNodeDragStart:Y,onSelectionDragStart:g}=a.getState();v.current=!0;const A=s?Y:oo(g);(!i||!o)&&!Z&&s&&((z=D.get(s))!=null&&z.selected||U()),s&&o&&i&&Mo({id:s,store:a,nodeRef:t});const k=_($);if(h.current=k,u.current=ux(D,N,k,s),A&&u.current){const[B,P]=so({nodeId:s,dragItems:u.current,nodeInternals:D});A($.sourceEvent,B,P)}};if(e)S.on(".drag",null);else{const $=Gy().on("start",D=>{const{domNode:Z,nodeDragThreshold:N}=a.getState();N===0&&O(D),R.current=!1;const U=_(D);h.current=U,p.current=(Z==null?void 0:Z.getBoundingClientRect())||null,w.current=ne(D.sourceEvent,p.current)}).on("drag",D=>{var Y,g;const Z=_(D),{autoPanOnNodeDrag:N,nodeDragThreshold:U}=a.getState();if(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1&&(R.current=!0),!R.current){if(!E.current&&v.current&&N&&(E.current=!0,C()),!v.current){const A=Z.xSnapped-(((Y=h==null?void 0:h.current)==null?void 0:Y.x)??0),k=Z.ySnapped-(((g=h==null?void 0:h.current)==null?void 0:g.y)??0);Math.sqrt(A*A+k*k)>U&&O(D)}(h.current.x!==Z.xSnapped||h.current.y!==Z.ySnapped)&&u.current&&v.current&&(y.current=D.sourceEvent,w.current=ne(D.sourceEvent,p.current),M(Z))}}).on("end",D=>{if(!(!v.current||R.current)&&(l(!1),E.current=!1,v.current=!1,cancelAnimationFrame(d.current),u.current)){const{updateNodePositions:Z,nodeInternals:N,onNodeDragStop:U,onSelectionDragStop:Y}=a.getState(),g=s?U:oo(Y);if(Z(u.current,!1,!1),g){const[A,k]=so({nodeId:s,dragItems:u.current,nodeInternals:N});g(D.sourceEvent,A,k)}}}).filter(D=>{const Z=D.target;return!D.button&&(!n||!Ua(Z,`.${n}`,t))&&(!r||Ua(Z,r,t))});return S.call($),()=>{S.on(".drag",null)}}}},[t,e,n,r,o,a,s,i,_]),c}function Hu(){const t=ht();return x.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:i,snapToGrid:a,snapGrid:c,onError:l,nodesDraggable:u}=t.getState(),h=i().filter(R=>R.selected&&(R.draggable||u&&typeof R.draggable>"u")),d=a?c[0]:5,p=a?c[1]:5,w=n.isShiftPressed?4:1,y=n.x*d*w,E=n.y*p*w,v=h.map(R=>{if(R.positionAbsolute){const _={x:R.positionAbsolute.x+y,y:R.positionAbsolute.y+E};a&&(_.x=c[0]*Math.round(_.x/c[0]),_.y=c[1]*Math.round(_.y/c[1]));const{positionAbsolute:S,position:M}=Zu(R,_,r,s,void 0,l);R.position=M,R.positionAbsolute=S}return R});o(v,!0,!1)},[])}const Ze={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var bn=t=>{const e=({id:n,type:r,data:s,xPos:o,yPos:i,xPosOrigin:a,yPosOrigin:c,selected:l,onClick:u,onMouseEnter:h,onMouseMove:d,onMouseLeave:p,onContextMenu:w,onDoubleClick:y,style:E,className:v,isDraggable:R,isSelectable:_,isConnectable:S,isFocusable:M,selectNodesOnDrag:C,sourcePosition:O,targetPosition:$,hidden:D,resizeObserver:Z,dragHandle:N,zIndex:U,isParent:Y,noDragClassName:g,noPanClassName:A,initialized:k,disableKeyboardA11y:z,ariaLabel:B,rfId:P,hasHandleBounds:L})=>{const q=ht(),F=x.useRef(null),G=x.useRef(null),V=x.useRef(O),K=x.useRef($),tt=x.useRef(r),et=_||R||u||h||d||p,ot=Hu(),H=En(n,q.getState,h),X=En(n,q.getState,d),j=En(n,q.getState,p),I=En(n,q.getState,w),it=En(n,q.getState,y),J=rt=>{const{nodeDragThreshold:W}=q.getState();if(_&&(!C||!R||W>0)&&Mo({id:n,store:q,nodeRef:F}),u){const wt=q.getState().nodeInternals.get(n);wt&&u(rt,{...wt})}},nt=rt=>{if(!_o(rt)&&!z)if(fu.includes(rt.key)&&_){const W=rt.key==="Escape";Mo({id:n,store:q,unselect:W,nodeRef:F})}else R&&l&&Object.prototype.hasOwnProperty.call(Ze,rt.key)&&(q.setState({ariaLiveMessage:`Moved selected node ${rt.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),ot({x:Ze[rt.key].x,y:Ze[rt.key].y,isShiftPressed:rt.shiftKey}))};x.useEffect(()=>()=>{G.current&&(Z==null||Z.unobserve(G.current),G.current=null)},[]),x.useEffect(()=>{if(F.current&&!D){const rt=F.current;(!k||!L||G.current!==rt)&&(G.current&&(Z==null||Z.unobserve(G.current)),Z==null||Z.observe(rt),G.current=rt)}},[D,k,L]),x.useEffect(()=>{const rt=tt.current!==r,W=V.current!==O,wt=K.current!==$;F.current&&(rt||W||wt)&&(rt&&(tt.current=r),W&&(V.current=O),wt&&(K.current=$),q.getState().updateNodeDimensions([{id:n,nodeElement:F.current,forceUpdate:!0}]))},[n,r,O,$]);const at=Uu({nodeRef:F,disabled:D||!R,noDragClassName:g,handleSelector:N,nodeId:n,isSelectable:_,selectNodesOnDrag:C});return D?null:x.createElement("div",{className:St(["react-flow__node",`react-flow__node-${r}`,{[A]:R},v,{selected:l,selectable:_,parent:Y,dragging:at}]),ref:F,style:{zIndex:U,transform:`translate(${a}px,${c}px)`,pointerEvents:et?"all":"none",visibility:k?"visible":"hidden",...E},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:H,onMouseMove:X,onMouseLeave:j,onContextMenu:I,onClick:J,onDoubleClick:it,onKeyDown:M?nt:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":z?void 0:`${Du}-${P}`,"aria-label":B},x.createElement(Cw,{value:n},x.createElement(t,{id:n,data:s,type:r,xPos:o,yPos:i,selected:l,isConnectable:S,sourcePosition:O,targetPosition:$,dragging:at,dragHandle:N,zIndex:U})))};return e.displayName="NodeWrapper",x.memo(e)};const dx=t=>{const e=t.getNodes().filter(n=>n.selected);return{...bi(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function px({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=ht(),{width:s,height:o,x:i,y:a,transformString:c,userSelectionActive:l}=lt(dx,gt),u=Hu(),h=x.useRef(null);if(x.useEffect(()=>{var w;n||(w=h.current)==null||w.focus({preventScroll:!0})},[n]),Uu({nodeRef:h}),l||!s||!o)return null;const d=t?w=>{const y=r.getState().getNodes().filter(E=>E.selected);t(w,y)}:void 0,p=w=>{Object.prototype.hasOwnProperty.call(Ze,w.key)&&u({x:Ze[w.key].x,y:Ze[w.key].y,isShiftPressed:w.shiftKey})};return x.createElement("div",{className:St(["react-flow__nodesselection","react-flow__container",e]),style:{transform:c}},x.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:o,top:a,left:i}}))}var gx=x.memo(px);const mx=t=>t.nodesSelectionActive,Vu=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:a,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:h,selectionOnDrag:d,selectionMode:p,onSelectionStart:w,onSelectionEnd:y,multiSelectionKeyCode:E,panActivationKeyCode:v,zoomActivationKeyCode:R,elementsSelectable:_,zoomOnScroll:S,zoomOnPinch:M,panOnScroll:C,panOnScrollSpeed:O,panOnScrollMode:$,zoomOnDoubleClick:D,panOnDrag:Z,defaultViewport:N,translateExtent:U,minZoom:Y,maxZoom:g,preventScrolling:A,onSelectionContextMenu:k,noWheelClassName:z,noPanClassName:B,disableKeyboardA11y:P})=>{const L=lt(mx),q=tr(h),F=tr(v),G=F||Z,V=F||C,K=q||d&&G!==!0;return ex({deleteKeyCode:a,multiSelectionKeyCode:E}),x.createElement(ox,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:S,zoomOnPinch:M,panOnScroll:V,panOnScrollSpeed:O,panOnScrollMode:$,zoomOnDoubleClick:D,panOnDrag:!q&&G,defaultViewport:N,translateExtent:U,minZoom:Y,maxZoom:g,zoomActivationKeyCode:R,preventScrolling:A,noWheelClassName:z,noPanClassName:B},x.createElement(qu,{onSelectionStart:w,onSelectionEnd:y,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:G,isSelecting:!!K,selectionMode:p},t,L&&x.createElement(gx,{onSelectionContextMenu:k,noPanClassName:B,disableKeyboardA11y:P})))};Vu.displayName="FlowRenderer";var yx=x.memo(Vu);function wx(t){return lt(x.useCallback(n=>t?Su(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function xx(t){const e={input:bn(t.input||Mu),default:bn(t.default||Ro),output:bn(t.output||Nu),group:bn(t.group||_i)},n={},r=Object.keys(t).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=bn(t[o]||Ro),s),n);return{...e,...r}}const vx=({x:t,y:e,width:n,height:r,origin:s})=>!n||!r?{x:t,y:e}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:t,y:e}:{x:t-n*s[0],y:e-r*s[1]},Sx=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),Gu=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:i}=lt(Sx,gt),a=wx(t.onlyRenderVisibleElements),c=x.useRef(),l=x.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(h=>{const d=h.map(p=>({id:p.target.getAttribute("data-id"),nodeElement:p.target,forceUpdate:!0}));o(d)});return c.current=u,u},[]);return x.useEffect(()=>()=>{var u;(u=c==null?void 0:c.current)==null||u.disconnect()},[]),x.createElement("div",{className:"react-flow__nodes",style:Ci},a.map(u=>{var M,C,O;let h=u.type||"default";t.nodeTypes[h]||(i==null||i("003",vt.error003(h)),h="default");const d=t.nodeTypes[h]||t.nodeTypes.default,p=!!(u.draggable||e&&typeof u.draggable>"u"),w=!!(u.selectable||s&&typeof u.selectable>"u"),y=!!(u.connectable||n&&typeof u.connectable>"u"),E=!!(u.focusable||r&&typeof u.focusable>"u"),v=t.nodeExtent?yi(u.positionAbsolute,t.nodeExtent):u.positionAbsolute,R=(v==null?void 0:v.x)??0,_=(v==null?void 0:v.y)??0,S=vx({x:R,y:_,width:u.width??0,height:u.height??0,origin:t.nodeOrigin});return x.createElement(d,{key:u.id,id:u.id,className:u.className,style:u.style,type:h,data:u.data,sourcePosition:u.sourcePosition||exports.Position.Bottom,targetPosition:u.targetPosition||exports.Position.Top,hidden:u.hidden,xPos:R,yPos:_,xPosOrigin:S.x,yPosOrigin:S.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!u.selected,isDraggable:p,isSelectable:w,isConnectable:y,isFocusable:E,resizeObserver:l,dragHandle:u.dragHandle,zIndex:((M=u[ct])==null?void 0:M.z)??0,isParent:!!((C=u[ct])!=null&&C.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!u.width&&!!u.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((O=u[ct])!=null&&O.handleBounds)})}))};Gu.displayName="NodeRenderer";var Ex=x.memo(Gu);const bx=(t,e,n)=>n===exports.Position.Left?t-e:n===exports.Position.Right?t+e:t,Tx=(t,e,n)=>n===exports.Position.Top?t-e:n===exports.Position.Bottom?t+e:t,Va="react-flow__edgeupdater",Ga=({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:i,type:a})=>x.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:i,className:St([Va,`${Va}-${a}`]),cx:bx(e,r,t),cy:Tx(n,r,t),r,stroke:"transparent",fill:"transparent"}),_x=()=>!0;var Oe=t=>{const e=({id:n,className:r,type:s,data:o,onClick:i,onEdgeDoubleClick:a,selected:c,animated:l,label:u,labelStyle:h,labelShowBg:d,labelBgStyle:p,labelBgPadding:w,labelBgBorderRadius:y,style:E,source:v,target:R,sourceX:_,sourceY:S,targetX:M,targetY:C,sourcePosition:O,targetPosition:$,elementsSelectable:D,hidden:Z,sourceHandleId:N,targetHandleId:U,onContextMenu:Y,onMouseEnter:g,onMouseMove:A,onMouseLeave:k,reconnectRadius:z,onReconnect:B,onReconnectStart:P,onReconnectEnd:L,markerEnd:q,markerStart:F,rfId:G,ariaLabel:V,isFocusable:K,isReconnectable:tt,pathOptions:et,interactionWidth:ot,disableKeyboardA11y:H})=>{const X=x.useRef(null),[j,I]=x.useState(!1),[it,J]=x.useState(!1),nt=ht(),at=x.useMemo(()=>`url('#${Po(F,G)}')`,[F,G]),rt=x.useMemo(()=>`url('#${Po(q,G)}')`,[q,G]);if(Z)return null;const W=dt=>{var Ot;const{edges:Ct,addSelectedEdges:ce,unselectNodesAndEdges:le,multiSelectionActive:ue}=nt.getState(),qt=Ct.find(pn=>pn.id===n);qt&&(D&&(nt.setState({nodesSelectionActive:!1}),qt.selected&&ue?(le({nodes:[],edges:[qt]}),(Ot=X.current)==null||Ot.blur()):ce([n])),i&&i(dt,qt))},wt=Sn(n,nt.getState,a),oe=Sn(n,nt.getState,Y),fn=Sn(n,nt.getState,g),Te=Sn(n,nt.getState,A),_e=Sn(n,nt.getState,k),Bt=(dt,Ct)=>{if(dt.button!==0)return;const{edges:ce,isValidConnection:le}=nt.getState(),ue=Ct?R:v,qt=(Ct?U:N)||null,Ot=Ct?"target":"source",pn=le||_x,Ls=Ct,gn=ce.find(he=>he.id===n);J(!0),P==null||P(dt,gn,Ot);const Is=he=>{J(!1),L==null||L(he,gn,Ot)};Cu({event:dt,handleId:qt,nodeId:ue,onConnect:he=>B==null?void 0:B(gn,he),isTarget:Ls,getState:nt.getState,setState:nt.setState,isValidConnection:pn,edgeUpdaterType:Ot,onReconnectEnd:Is})},Ce=dt=>Bt(dt,!0),ie=dt=>Bt(dt,!1),ae=()=>I(!0),Pe=()=>I(!1),ke=!D&&!i,dn=dt=>{var Ct;if(!H&&fu.includes(dt.key)&&D){const{unselectNodesAndEdges:ce,addSelectedEdges:le,edges:ue}=nt.getState();dt.key==="Escape"?((Ct=X.current)==null||Ct.blur(),ce({edges:[ue.find(Ot=>Ot.id===n)]})):le([n])}};return x.createElement("g",{className:St(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:c,animated:l,inactive:ke,updating:j}]),onClick:W,onDoubleClick:wt,onContextMenu:oe,onMouseEnter:fn,onMouseMove:Te,onMouseLeave:_e,onKeyDown:K?dn:void 0,tabIndex:K?0:void 0,role:K?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${v} to ${R}`,"aria-describedby":K?`${zu}-${G}`:void 0,ref:X},!it&&x.createElement(t,{id:n,source:v,target:R,selected:c,animated:l,label:u,labelStyle:h,labelShowBg:d,labelBgStyle:p,labelBgPadding:w,labelBgBorderRadius:y,data:o,style:E,sourceX:_,sourceY:S,targetX:M,targetY:C,sourcePosition:O,targetPosition:$,sourceHandleId:N,targetHandleId:U,markerStart:at,markerEnd:rt,pathOptions:et,interactionWidth:ot}),tt&&x.createElement(x.Fragment,null,(tt==="source"||tt===!0)&&x.createElement(Ga,{position:O,centerX:_,centerY:S,radius:z,onMouseDown:Ce,onMouseEnter:ae,onMouseOut:Pe,type:"source"}),(tt==="target"||tt===!0)&&x.createElement(Ga,{position:$,centerX:M,centerY:C,radius:z,onMouseDown:ie,onMouseEnter:ae,onMouseOut:Pe,type:"target"})))};return e.displayName="EdgeWrapper",x.memo(e)};function Cx(t){const e={default:Oe(t.default||gs),straight:Oe(t.bezier||Si),step:Oe(t.step||vi),smoothstep:Oe(t.step||Os),simplebezier:Oe(t.simplebezier||xi)},n={},r=Object.keys(t).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Oe(t[o]||gs),s),n);return{...e,...r}}function Xa(t,e,n=null){const r=((n==null?void 0:n.x)||0)+e.x,s=((n==null?void 0:n.y)||0)+e.y,o=(n==null?void 0:n.width)||e.width,i=(n==null?void 0:n.height)||e.height;switch(t){case exports.Position.Top:return{x:r+o/2,y:s};case exports.Position.Right:return{x:r+o,y:s+i/2};case exports.Position.Bottom:return{x:r+o/2,y:s+i};case exports.Position.Left:return{x:r,y:s+i/2}}}function Wa(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const Px=(t,e,n,r,s,o)=>{const i=Xa(n,t,e),a=Xa(o,r,s);return{sourceX:i.x,sourceY:i.y,targetX:a.x,targetY:a.y}};function kx({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:i,height:a,transform:c}){const l={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x+n,e.x+s),y2:Math.max(t.y+r,e.y+o)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=wi({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:i/c[2],height:a/c[2]}),h=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),d=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(h*d)>0}function Ka(t){var r,s,o,i,a;const e=((r=t==null?void 0:t[ct])==null?void 0:r.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&typeof((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=t==null?void 0:t.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=t==null?void 0:t.positionAbsolute)==null?void 0:i.x)||0,y:((a=t==null?void 0:t.positionAbsolute)==null?void 0:a.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const Rx=[{level:0,isMaxLevel:!0,edges:[]}];function Mx(t,e,n=!1){let r=-1;const s=t.reduce((i,a)=>{var u,h;const c=Tt(a.zIndex);let l=c?a.zIndex:0;if(n){const d=e.get(a.target),p=e.get(a.source),w=a.selected||(d==null?void 0:d.selected)||(p==null?void 0:p.selected),y=Math.max(((u=p==null?void 0:p[ct])==null?void 0:u.z)||0,((h=d==null?void 0:d[ct])==null?void 0:h.z)||0,1e3);l=(c?a.zIndex:0)+(w?y:0)}return i[l]?i[l].push(a):i[l]=[a],r=l>r?l:r,i},{}),o=Object.entries(s).map(([i,a])=>{const c=+i;return{edges:a,level:c,isMaxLevel:c===r}});return o.length===0?Rx:o}function Ax(t,e,n){const r=lt(x.useCallback(s=>t?s.edges.filter(o=>{const i=e.get(o.source),a=e.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&kx({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:a.width,targetHeight:a.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[t,e]));return Mx(r,e,n)}const Nx=({color:t="none",strokeWidth:e=1})=>x.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Ox=({color:t="none",strokeWidth:e=1})=>x.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),ja={[ps.Arrow]:Nx,[ps.ArrowClosed]:Ox};function Dx(t){const e=ht();return x.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(ja,t)?ja[t]:((o=(s=e.getState()).onError)==null||o.call(s,"009",vt.error009(t)),null)},[t])}const zx=({id:t,type:e,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const c=Dx(e);return c?x.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0"},x.createElement(c,{color:n,strokeWidth:i})):null},Lx=({defaultColor:t,rfId:e})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const a=Po(i,e);r.includes(a)||(s.push({id:a,color:i.color||t,...i}),r.push(a))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},Xu=({defaultColor:t,rfId:e})=>{const n=lt(x.useCallback(Lx({defaultColor:t,rfId:e}),[t,e]),(r,s)=>!(r.length!==s.length||r.some((o,i)=>o.id!==s[i].id)));return x.createElement("defs",null,n.map(r=>x.createElement(zx,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};Xu.displayName="MarkerDefinitions";var Ix=x.memo(Xu);const $x=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),Wu=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:h,onReconnect:d,onReconnectStart:p,onReconnectEnd:w,reconnectRadius:y,children:E,disableKeyboardA11y:v})=>{const{edgesFocusable:R,edgesUpdatable:_,elementsSelectable:S,width:M,height:C,connectionMode:O,nodeInternals:$,onError:D}=lt($x,gt),Z=Ax(e,$,n);return M?x.createElement(x.Fragment,null,Z.map(({level:N,edges:U,isMaxLevel:Y})=>x.createElement("svg",{key:N,style:{zIndex:N},width:M,height:C,className:"react-flow__edges react-flow__container"},Y&&x.createElement(Ix,{defaultColor:t,rfId:r}),x.createElement("g",null,U.map(g=>{const[A,k,z]=Ka($.get(g.source)),[B,P,L]=Ka($.get(g.target));if(!z||!L)return null;let q=g.type||"default";s[q]||(D==null||D("011",vt.error011(q)),q="default");const F=s[q]||s.default,G=O===exports.ConnectionMode.Strict?P.target:(P.target??[]).concat(P.source??[]),V=Wa(k.source,g.sourceHandle),K=Wa(G,g.targetHandle),tt=(V==null?void 0:V.position)||exports.Position.Bottom,et=(K==null?void 0:K.position)||exports.Position.Top,ot=!!(g.focusable||R&&typeof g.focusable>"u"),H=g.reconnectable||g.updatable,X=typeof d<"u"&&(H||_&&typeof H>"u");if(!V||!K)return D==null||D("008",vt.error008(V,g)),null;const{sourceX:j,sourceY:I,targetX:it,targetY:J}=Px(A,V,tt,B,K,et);return x.createElement(F,{key:g.id,id:g.id,className:St([g.className,o]),type:q,data:g.data,selected:!!g.selected,animated:!!g.animated,hidden:!!g.hidden,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,style:g.style,source:g.source,target:g.target,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerEnd:g.markerEnd,markerStart:g.markerStart,sourceX:j,sourceY:I,targetX:it,targetY:J,sourcePosition:tt,targetPosition:et,elementsSelectable:S,onContextMenu:i,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,onEdgeDoubleClick:h,onReconnect:d,onReconnectStart:p,onReconnectEnd:w,reconnectRadius:y,rfId:r,ariaLabel:g.ariaLabel,isFocusable:ot,isReconnectable:X,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth,disableKeyboardA11y:v})})))),E):null};Wu.displayName="EdgeRenderer";var Yx=x.memo(Wu);const Bx=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function qx({children:t}){const e=lt(Bx);return x.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function Fx(t){const e=Ds(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const Zx={[exports.Position.Left]:exports.Position.Right,[exports.Position.Right]:exports.Position.Left,[exports.Position.Top]:exports.Position.Bottom,[exports.Position.Bottom]:exports.Position.Top},Ku=({nodeId:t,handleType:e,style:n,type:r=Jt.Bezier,CustomComponent:s,connectionStatus:o})=>{var C,O,$;const{fromNode:i,handleId:a,toX:c,toY:l,connectionMode:u}=lt(x.useCallback(D=>({fromNode:D.nodeInternals.get(t),handleId:D.connectionHandleId,toX:(D.connectionPosition.x-D.transform[0])/D.transform[2],toY:(D.connectionPosition.y-D.transform[1])/D.transform[2],connectionMode:D.connectionMode}),[t]),gt),h=(C=i==null?void 0:i[ct])==null?void 0:C.handleBounds;let d=h==null?void 0:h[e];if(u===exports.ConnectionMode.Loose&&(d=d||(h==null?void 0:h[e==="source"?"target":"source"])),!i||!d)return null;const p=a?d.find(D=>D.id===a):d[0],w=p?p.x+p.width/2:(i.width??0)/2,y=p?p.y+p.height/2:i.height??0,E=(((O=i.positionAbsolute)==null?void 0:O.x)??0)+w,v=((($=i.positionAbsolute)==null?void 0:$.y)??0)+y,R=p==null?void 0:p.position,_=R?Zx[R]:null;if(!R||!_)return null;if(s)return x.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:p,fromX:E,fromY:v,toX:c,toY:l,fromPosition:R,toPosition:_,connectionStatus:o});let S="";const M={sourceX:E,sourceY:v,sourcePosition:R,targetX:c,targetY:l,targetPosition:_};return r===Jt.Bezier?[S]=yu(M):r===Jt.Step?[S]=Co({...M,borderRadius:0}):r===Jt.SmoothStep?[S]=Co(M):r===Jt.SimpleBezier?[S]=mu(M):S=`M${E},${v} ${c},${l}`,x.createElement("path",{d:S,fill:"none",className:"react-flow__connection-path",style:n})};Ku.displayName="ConnectionLine";const Ux=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function Hx({containerStyle:t,style:e,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:i,width:a,height:c,connectionStatus:l}=lt(Ux,gt);return!(s&&o&&a&&i)?null:x.createElement("svg",{style:t,width:a,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},x.createElement("g",{className:St(["react-flow__connection",l])},x.createElement(Ku,{nodeId:s,handleType:o,style:e,type:n,CustomComponent:r,connectionStatus:l})))}function Ja(t,e){const n=x.useRef(null),r=ht();return x.useMemo(()=>{var o,i;if(process.env.NODE_ENV==="development"){const a=Object.keys(t);gt(n.current,a)&&((i=(o=r.getState()).onError)==null||i.call(o,"002",vt.error002())),n.current=a}return e(t)},[t])}const ju=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:w,onSelectionStart:y,onSelectionEnd:E,connectionLineType:v,connectionLineStyle:R,connectionLineComponent:_,connectionLineContainerStyle:S,selectionKeyCode:M,selectionOnDrag:C,selectionMode:O,multiSelectionKeyCode:$,panActivationKeyCode:D,zoomActivationKeyCode:Z,deleteKeyCode:N,onlyRenderVisibleElements:U,elementsSelectable:Y,selectNodesOnDrag:g,defaultViewport:A,translateExtent:k,minZoom:z,maxZoom:B,preventScrolling:P,defaultMarkerColor:L,zoomOnScroll:q,zoomOnPinch:F,panOnScroll:G,panOnScrollSpeed:V,panOnScrollMode:K,zoomOnDoubleClick:tt,panOnDrag:et,onPaneClick:ot,onPaneMouseEnter:H,onPaneMouseMove:X,onPaneMouseLeave:j,onPaneScroll:I,onPaneContextMenu:it,onEdgeContextMenu:J,onEdgeMouseEnter:nt,onEdgeMouseMove:at,onEdgeMouseLeave:rt,onReconnect:W,onReconnectStart:wt,onReconnectEnd:oe,reconnectRadius:fn,noDragClassName:Te,noWheelClassName:_e,noPanClassName:Bt,elevateEdgesOnSelect:Ce,disableKeyboardA11y:ie,nodeOrigin:ae,nodeExtent:Pe,rfId:ke})=>{const dn=Ja(t,xx),dt=Ja(e,Cx);return Fx(o),x.createElement(yx,{onPaneClick:ot,onPaneMouseEnter:H,onPaneMouseMove:X,onPaneMouseLeave:j,onPaneContextMenu:it,onPaneScroll:I,deleteKeyCode:N,selectionKeyCode:M,selectionOnDrag:C,selectionMode:O,onSelectionStart:y,onSelectionEnd:E,multiSelectionKeyCode:$,panActivationKeyCode:D,zoomActivationKeyCode:Z,elementsSelectable:Y,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:q,zoomOnPinch:F,zoomOnDoubleClick:tt,panOnScroll:G,panOnScrollSpeed:V,panOnScrollMode:K,panOnDrag:et,defaultViewport:A,translateExtent:k,minZoom:z,maxZoom:B,onSelectionContextMenu:w,preventScrolling:P,noDragClassName:Te,noWheelClassName:_e,noPanClassName:Bt,disableKeyboardA11y:ie},x.createElement(qx,null,x.createElement(Yx,{edgeTypes:dt,onEdgeClick:a,onEdgeDoubleClick:l,onlyRenderVisibleElements:U,onEdgeContextMenu:J,onEdgeMouseEnter:nt,onEdgeMouseMove:at,onEdgeMouseLeave:rt,onReconnect:W,onReconnectStart:wt,onReconnectEnd:oe,reconnectRadius:fn,defaultMarkerColor:L,noPanClassName:Bt,elevateEdgesOnSelect:!!Ce,disableKeyboardA11y:ie,rfId:ke},x.createElement(Hx,{style:R,type:v,component:_,containerStyle:S})),x.createElement("div",{className:"react-flow__edgelabel-renderer"}),x.createElement(Ex,{nodeTypes:dn,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,selectNodesOnDrag:g,onlyRenderVisibleElements:U,noPanClassName:Bt,noDragClassName:Te,disableKeyboardA11y:ie,nodeOrigin:ae,nodeExtent:Pe,rfId:ke})))};ju.displayName="GraphView";var Vx=x.memo(ju);const Ao=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Kt={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Ao,nodeExtent:Ao,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:exports.ConnectionMode.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:fs,isValidConnection:void 0},Gx=()=>om((t,e)=>({...Kt,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=e();t({nodeInternals:no(n,r,s,o)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=e();t({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",i=s?no(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:i,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:a,domNode:c,nodeOrigin:l}=e(),u=c==null?void 0:c.querySelector(".react-flow__viewport");if(!u)return;const h=window.getComputedStyle(u),{m22:d}=new window.DOMMatrixReadOnly(h.transform),p=n.reduce((y,E)=>{const v=s.get(E.id);if(v!=null&&v.hidden)s.set(v.id,{...v,[ct]:{...v[ct],handleBounds:void 0}});else if(v){const R=mi(E.nodeElement);!!(R.width&&R.height&&(v.width!==R.width||v.height!==R.height||E.forceUpdate))&&(s.set(v.id,{...v,[ct]:{...v[ct],handleBounds:{source:Ha(".source",E.nodeElement,d,l),target:Ha(".target",E.nodeElement,d,l)}},...R}),y.push({id:v.id,type:"dimensions",dimensions:R}))}return y},[]);Iu(s,l);const w=i||o&&!i&&$u(e,{initial:!0,...a});t({nodeInternals:new Map(s),fitViewOnInitDone:w}),(p==null?void 0:p.length)>0&&(r==null||r(p))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=e(),i=n.map(a=>{const c={id:a.id,type:"position",dragging:s};return r&&(c.positionAbsolute=a.positionAbsolute,c.position=a.position),c});o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:i,getNodes:a,elevateNodesOnSelect:c}=e();if(n!=null&&n.length){if(o){const l=Bu(n,a()),u=no(l,s,i,c);t({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=e();let i,a=null;r?i=n.map(c=>jt(c,!0)):(i=Le(o(),n),a=Le(s,[])),Er({changedNodes:i,changedEdges:a,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=e();let i,a=null;r?i=n.map(c=>jt(c,!0)):(i=Le(s,n),a=Le(o(),[])),Er({changedNodes:a,changedEdges:i,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=e(),i=n||o(),a=r||s,c=i.map(u=>(u.selected=!1,jt(u.id,!1))),l=a.map(u=>jt(u.id,!1));Er({changedNodes:c,changedEdges:l,get:e,set:t})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=e();r==null||r.scaleExtent([n,s]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=e();r==null||r.scaleExtent([s,n]),t({maxZoom:n})},setTranslateExtent:n=>{var r;(r=e().d3Zoom)==null||r.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=e(),o=r().filter(a=>a.selected).map(a=>jt(a.id,!1)),i=n.filter(a=>a.selected).map(a=>jt(a.id,!1));Er({changedNodes:o,changedEdges:i,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:r}=e();r.forEach(s=>{s.positionAbsolute=yi(s.position,n)}),t({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:i,d3Selection:a,translateExtent:c}=e();if(!i||!a||!n.x&&!n.y)return!1;const l=ee.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[s,o]],h=i==null?void 0:i.constrain()(l,u,c);return i.transform(a,h),r[0]!==h.x||r[1]!==h.y||r[2]!==h.k},cancelConnection:()=>t({connectionNodeId:Kt.connectionNodeId,connectionHandleId:Kt.connectionHandleId,connectionHandleType:Kt.connectionHandleType,connectionStatus:Kt.connectionStatus,connectionStartHandle:Kt.connectionStartHandle,connectionEndHandle:Kt.connectionEndHandle}),reset:()=>t({...Kt})}),Object.is),Pi=({children:t})=>{const e=x.useRef(null);return e.current||(e.current=Gx()),x.createElement(fw,{value:e.current},t)};Pi.displayName="ReactFlowProvider";const Ju=({children:t})=>x.useContext(Ns)?x.createElement(x.Fragment,null,t):x.createElement(Pi,null,t);Ju.displayName="ReactFlowWrapper";const Xx={input:Mu,default:Ro,output:Nu,group:_i},Wx={default:gs,straight:Si,step:vi,smoothstep:Os,simplebezier:xi},Kx=[0,0],jx=[15,15],Jx={x:0,y:0,zoom:1},Qx={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Qu=x.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=Xx,edgeTypes:i=Wx,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:h,onMoveEnd:d,onConnect:p,onConnectStart:w,onConnectEnd:y,onClickConnectStart:E,onClickConnectEnd:v,onNodeMouseEnter:R,onNodeMouseMove:_,onNodeMouseLeave:S,onNodeContextMenu:M,onNodeDoubleClick:C,onNodeDragStart:O,onNodeDrag:$,onNodeDragStop:D,onNodesDelete:Z,onEdgesDelete:N,onSelectionChange:U,onSelectionDragStart:Y,onSelectionDrag:g,onSelectionDragStop:A,onSelectionContextMenu:k,onSelectionStart:z,onSelectionEnd:B,connectionMode:P=exports.ConnectionMode.Strict,connectionLineType:L=Jt.Bezier,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:G,deleteKeyCode:V="Backspace",selectionKeyCode:K="Shift",selectionOnDrag:tt=!1,selectionMode:et=exports.SelectionMode.Full,panActivationKeyCode:ot="Space",multiSelectionKeyCode:H=ds()?"Meta":"Control",zoomActivationKeyCode:X=ds()?"Meta":"Control",snapToGrid:j=!1,snapGrid:I=jx,onlyRenderVisibleElements:it=!1,selectNodesOnDrag:J=!0,nodesDraggable:nt,nodesConnectable:at,nodesFocusable:rt,nodeOrigin:W=Kx,edgesFocusable:wt,edgesUpdatable:oe,elementsSelectable:fn,defaultViewport:Te=Jx,minZoom:_e=.5,maxZoom:Bt=2,translateExtent:Ce=Ao,preventScrolling:ie=!0,nodeExtent:ae,defaultMarkerColor:Pe="#b1b1b7",zoomOnScroll:ke=!0,zoomOnPinch:dn=!0,panOnScroll:dt=!1,panOnScrollSpeed:Ct=.5,panOnScrollMode:ce=ge.Free,zoomOnDoubleClick:le=!0,panOnDrag:ue=!0,onPaneClick:qt,onPaneMouseEnter:Ot,onPaneMouseMove:pn,onPaneMouseLeave:Ls,onPaneScroll:gn,onPaneContextMenu:Is,children:Ai,onEdgeContextMenu:he,onEdgeDoubleClick:xh,onEdgeMouseEnter:vh,onEdgeMouseMove:Sh,onEdgeMouseLeave:Eh,onEdgeUpdate:bh,onEdgeUpdateStart:Th,onEdgeUpdateEnd:_h,onReconnect:Ch,onReconnectStart:Ph,onReconnectEnd:kh,reconnectRadius:Rh=10,edgeUpdaterRadius:Mh=10,onNodesChange:Ah,onEdgesChange:Nh,noDragClassName:Oh="nodrag",noWheelClassName:Dh="nowheel",noPanClassName:Ni="nopan",fitView:zh=!1,fitViewOptions:Lh,connectOnClick:Ih=!0,attributionPosition:$h,proOptions:Yh,defaultEdgeOptions:Bh,elevateNodesOnSelect:qh=!0,elevateEdgesOnSelect:Fh=!1,disableKeyboardA11y:Oi=!1,autoPanOnConnect:Zh=!0,autoPanOnNodeDrag:Uh=!0,connectionRadius:Hh=20,isValidConnection:Vh,onError:Gh,style:Xh,id:Di,nodeDragThreshold:Wh,...Kh},jh)=>{const $s=Di||"1";return x.createElement("div",{...Kh,style:{...Xh,...Qx},ref:jh,className:St(["react-flow",s]),"data-testid":"rf__wrapper",id:Di},x.createElement(Ju,null,x.createElement(Vx,{onInit:l,onMove:u,onMoveStart:h,onMoveEnd:d,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:R,onNodeMouseMove:_,onNodeMouseLeave:S,onNodeContextMenu:M,onNodeDoubleClick:C,nodeTypes:o,edgeTypes:i,connectionLineType:L,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:G,selectionKeyCode:K,selectionOnDrag:tt,selectionMode:et,deleteKeyCode:V,multiSelectionKeyCode:H,panActivationKeyCode:ot,zoomActivationKeyCode:X,onlyRenderVisibleElements:it,selectNodesOnDrag:J,defaultViewport:Te,translateExtent:Ce,minZoom:_e,maxZoom:Bt,preventScrolling:ie,zoomOnScroll:ke,zoomOnPinch:dn,zoomOnDoubleClick:le,panOnScroll:dt,panOnScrollSpeed:Ct,panOnScrollMode:ce,panOnDrag:ue,onPaneClick:qt,onPaneMouseEnter:Ot,onPaneMouseMove:pn,onPaneMouseLeave:Ls,onPaneScroll:gn,onPaneContextMenu:Is,onSelectionContextMenu:k,onSelectionStart:z,onSelectionEnd:B,onEdgeContextMenu:he,onEdgeDoubleClick:xh,onEdgeMouseEnter:vh,onEdgeMouseMove:Sh,onEdgeMouseLeave:Eh,onReconnect:Ch??bh,onReconnectStart:Ph??Th,onReconnectEnd:kh??_h,reconnectRadius:Rh??Mh,defaultMarkerColor:Pe,noDragClassName:Oh,noWheelClassName:Dh,noPanClassName:Ni,elevateEdgesOnSelect:Fh,rfId:$s,disableKeyboardA11y:Oi,nodeOrigin:W,nodeExtent:ae}),x.createElement(Zw,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:w,onConnectEnd:y,onClickConnectStart:E,onClickConnectEnd:v,nodesDraggable:nt,nodesConnectable:at,nodesFocusable:rt,edgesFocusable:wt,edgesUpdatable:oe,elementsSelectable:fn,elevateNodesOnSelect:qh,minZoom:_e,maxZoom:Bt,nodeExtent:ae,onNodesChange:Ah,onEdgesChange:Nh,snapToGrid:j,snapGrid:I,connectionMode:P,translateExtent:Ce,connectOnClick:Ih,defaultEdgeOptions:Bh,fitView:zh,fitViewOptions:Lh,onNodesDelete:Z,onEdgesDelete:N,onNodeDragStart:O,onNodeDrag:$,onNodeDragStop:D,onSelectionDrag:g,onSelectionDragStart:Y,onSelectionDragStop:A,noPanClassName:Ni,nodeOrigin:W,rfId:$s,autoPanOnConnect:Zh,autoPanOnNodeDrag:Uh,onError:Gh,connectionRadius:Hh,isValidConnection:Vh,nodeDragThreshold:Wh}),x.createElement(qw,{onSelectionChange:U}),Ai,x.createElement(gw,{proOptions:Yh,position:$h}),x.createElement(Xw,{rfId:$s,disableKeyboardA11y:Oi})))});Qu.displayName="ReactFlow";function tv(){const t=ht();return x.useCallback(e=>{const{domNode:n,updateNodeDimensions:r}=t.getState(),o=(Array.isArray(e)?e:[e]).reduce((i,a)=>{const c=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);return c&&i.push({id:a,nodeElement:c,forceUpdate:!0}),i},[]);requestAnimationFrame(()=>r(o))},[])}function ev({onStart:t,onChange:e,onEnd:n}){const r=ht();x.useEffect(()=>{r.setState({onViewportChangeStart:t})},[t]),x.useEffect(()=>{r.setState({onViewportChange:e})},[e]),x.useEffect(()=>{r.setState({onViewportChangeEnd:n})},[n])}const nv=({sourcePos:t,targetPos:e,next:n,prev:r})=>{const s=Pn(t,...n);return f.q.distance(s,e)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",s),console.log("Actual target",e),console.log("Segments",n),console.log("Prev segments",r),!1)},Qa=({sourceStumpTip:t,sourceOrientation:e,sourceBox:n,targetStumpTip:r,targetOrientation:s,targetBox:o})=>{if(!sv({sourcePos:t,sourceOrientation:e,targetPos:r}))return;const i=f.g.construct(e),a=f.g.swap(i);let c=ye(a,r[a]-t[a]);const l=f.Eo.loc(n,c);if(f.J.swap(e)===s){const u=f.Eo.loc(o,f.J.swap(c));Math.abs(l-u)<Et&&(c=f.J.swap(c))}return{direction:a,length:l-t[a]+Se(c,Et)}},No=b.z.object({direction:f.g.direction,length:b.z.number()}),Pn=(t,...e)=>{let n=t;for(const r of e)n=f.q.translate(n,r.direction,r.length);return n},rv=(t,e,n,r)=>{try{let s=t;const o=[t,...e.map(p=>(s=f.q.translate(s,p.direction,p.length),s))];if(!r)return o;const i=e[0],a=ye(i.direction,i.length),c=tc(a),l=4*(2-n**.5);o[0]=f.q.translate(o[0],{[i.direction]:-1*c*l,[f.g.swap(i.direction)]:0});const u=e[e.length-1],h=ye(u.direction,u.length),d=tc(h);return o[o.length-1]=f.q.translate(o[o.length-1],{[u.direction]:d*l,[f.g.swap(u.direction)]:0}),o}catch{return[]}},Et=10,tc=t=>t==="top"||t==="left"?-1:1,Se=(t,e)=>t==="top"||t==="left"?-e:e,ye=(t,e)=>t==="x"?e>0?"right":"left":e>0?"bottom":"top",te=t=>ye(t.direction,t.length),sv=({sourcePos:t,targetPos:e,sourceOrientation:n})=>{const r=f.g.construct(n),s=e[r]-t[r];return Se(n,s)<0},Tr=t=>({direction:f.g.construct(t),length:Se(t,Et)}),ec={top:Tr("top"),bottom:Tr("bottom"),left:Tr("left"),right:Tr("right")},ov=4,iv=.25,zs=t=>Oo(av(Oo(t))),av=t=>{const e=[...t],n=t.findIndex((r,s)=>{const o=Math.abs(r.length);if(o<ov){if(o<iv)return!0;if(s===0||s===t.length-1||t.length<=3)return!1;if(s+2<t.length){const i=e[s+2];if(i.direction!==r.direction)return!1;e[s+2]={...i,length:i.length+r.length}}else{const i=e[s-2];if(i.direction!==r.direction)return!1;e[s-2]={...i,length:i.length+r.length}}return!0}return!1});return n!==-1&&e.splice(n,1),e},Oo=t=>{const e=[...t];return t.findIndex((r,s)=>{const o=e[s-1];if(s===0||r.direction!==o.direction)return!1;if(s===1){const i=s-1,a=s,c=te(o),l=te(r);if(c===l)return e[s-1]={direction:e[s-1].direction,length:e[s-1].length+e[s].length},e.splice(s,1),!0;if(Math.abs(o.length)===Et)return!1;const u=Se(c,Et),h=e[i].length-u,d=e[a].length+h;return Math.abs(d)<Et?!1:(e[i]={...e[i],length:u},e[a]={...e[a],length:d},!0)}if(s===t.length-1){const i=s,a=s-1,c=te(r),l=te(o);if(c===l)return e[s-1]={direction:e[s-1].direction,length:e[s-1].length+e[s].length},e.splice(s,1),!0;if(Math.abs(r.length)===Et)return!1;const u=Se(c,Et),h=e[i].length-u,d=e[a].length+h;return Math.abs(d)<Et?!1:(e[i]={...e[i],length:u},e[a]={...e[a],length:d},!0)}return e[s-1]={direction:e[s-1].direction,length:e[s-1].length+e[s].length},e.splice(s,1),!0})!==-1?Oo(e):e},cv=t=>zs(lv(t)),lv=({sourceBox:t,targetBox:e,sourcePos:n,targetPos:r,targetOrientation:s,sourceOrientation:o})=>{let i=o,a=s,c={...ec[o]},l=Pn(n,c);const u={...ec[s]};let h=Pn(r,u);const d=[c],p=Qa({sourceStumpTip:l,sourceOrientation:o,sourceBox:t,targetStumpTip:h,targetOrientation:s,targetBox:e});p!=null&&(d.push(p),l=Pn(l,p),i=te(p),c=p);const w=Qa({sourceStumpTip:h,sourceOrientation:a,sourceBox:e,targetStumpTip:l,targetOrientation:i,targetBox:t});w!=null&&(h=Pn(h,w),a=ye(w.direction,w.length));const y=()=>{w!=null&&(w.length*=-1,d.push(w)),u.length*=-1,d.push(u)};if(f.J.swap(i)===s){const M=f.g.construct(i),C=(h[M]-l[M])/2;d.push({direction:M,length:C});const O=f.g.swap(M);return d.push({direction:O,length:h[O]-l[O]}),d.push({direction:M,length:C}),y(),d}const E=h[c.direction]-l[c.direction];let v=f.g.swap(c.direction);const R=l[v]-h[v];let _;ye(c.direction,E)===i&&ye(v,R)===a?_={direction:c.direction,length:E}:(_={direction:v,length:h[v]-l[v]},v=f.g.swap(v)),d.push(_);const S={direction:v,length:h[v]-l[v]};return d.push(S),y(),d},uv=t=>zs(hv(t)),hv=({segments:t,index:e,magnitude:n})=>{const r=[...t],s=r[e],o=f.g.swap(s.direction),i=te(s);if(e===0){r.unshift({direction:o,length:n});const a=Se(i,Et);r.unshift({direction:s.direction,length:a}),e+=2,r[e]={...r[e],length:r[e].length-a}}else r[e-1]={direction:r[e-1].direction,length:r[e-1].length+n};if(e===r.length-1){r.push({direction:o,length:-n});const a=Se(i,Et);r.push({direction:s.direction,length:a}),r[e]={...r[e],length:r[e].length-a}}else r[e+1]={direction:r[e+1].direction,length:r[e+1].length-n};return r},fv=(t,e)=>{for(let n=t.length-1;n>=0;n--)if(e(t[n],n))return n;return-1},dv=(t,e,n=!1,...r)=>{const s=(o,i)=>!r.includes(i)&&e(o,i);return n?fv(t,s):t.findIndex(s)},pv=({delta:t,segments:e})=>zs(th(t,e,!1)),gv=({delta:t,segments:e})=>zs(th(t,e,!0)),th=(t,e,n)=>{let r=[...e];return t.x!==0&&(r=rc("x",t,r,n)),t.y!==0&&(r=rc("y",t,r,n)),r},nc=(t,e,n)=>{if(e.direction!==t)return!1;const r={...e,length:e.length-n[t]},s=te(e),o=te(r);return Math.abs(r.length)>Et&&s===o},rc=(t,e,n,r)=>{const s=f.g.swap(t),o=r?n.length-1:0,i=n[o];if(nc(t,i,e))return n[o]={...i,length:i.length-e[t]},n;const a=r?0:n.length-1,l=dv(n,h=>h.direction===t,r,o);if(l===a){const h=n[a];return nc(t,h,e)?(n[a]={...h,length:h.length-e[t]},n):(i.direction===t?n[o]={...i,length:i.length-e[t]}:n[a]={...h,length:h.length-e[t]},n)}if(l===-1)return n.length===1?n[0].direction===t?[{direction:t,length:n[0].length-e[t]}]:[{direction:s,length:n[0].length/2},{direction:t,length:-e[t]},{direction:s,length:n[0].length/2}]:i.direction===t?(n[o]={...i,length:i.length-e[t]},n):[{direction:s,length:n[0].length},{direction:t,length:-e[t]},...n.slice(1)];const u=n[l];return n[l]={...u,length:u.length-e[t]},n},mv=b.z.object({position:f.q.xy,zoom:b.z.number()}),eh=b.z.object({color:f.crudeZ,segments:b.z.array(No)}),yv=eh.extend({key:b.z.string(),source:b.z.string(),target:b.z.string(),segments:b.z.array(No),color:f.crudeZ,id:b.z.string(),data:b.z.object({segments:b.z.array(No),color:f.crudeZ}).optional(),selected:b.z.boolean(),sourceHandle:b.z.string().nullable().optional(),targetHandle:b.z.string().nullable().optional()}),wv=b.z.object({key:b.z.string(),position:f.q.xy,selected:b.z.boolean().optional(),zIndex:b.z.number().optional(),id:b.z.string().optional(),type:b.z.string().optional(),data:b.z.unknown().optional(),width:b.z.number().optional().nullable(),height:b.z.number().optional().nullable()}),nh=t=>t.map(e=>({...e,id:e.key,type:"custom",zIndex:e.zIndex,data:{}})),rh=t=>t.map(({segments:e,color:n,...r})=>({...r,id:r.key,data:{segments:e,color:n}})),sh=t=>t.map(e=>({key:e.id,selected:e.selected,...e})),oh=(t,e)=>t.map(n=>{var r,s;return n.data==null&&(n.data={segments:[],color:e}),{key:n.id,segments:((r=n.data)==null?void 0:r.segments)??[],selected:n.selected??!1,color:((s=n.data)==null?void 0:s.color)??e,...n}}),xv=t=>({...t.position,zoom:t.zoom}),ih=t=>({position:f.q.construct(t),zoom:t.zoom}),vv=(t,e)=>sh(e(nh(t))),Sv=(t,e,n)=>oh(e(rh(t)),n),ki=b.z.object({position:f.q.xy,zoom:b.z.number(),region:f.Eo.box,clearOverScan:f.q.crudeZ.optional().default(10),visible:b.z.boolean().optional().default(!0)}),_r=["upper2d","lower2d"],ah=()=>{const t=Ds();return x.useRef(ih(t.getViewport())).current},Ye=class Ye extends T.Composite{constructor(){super(...arguments);m(this,"schema",Ye.stateZ)}async afterUpdate(){this.internal.renderCtx=pt.use(this.ctx),this.internal.addStatus=T.useAggregate(this.ctx),mt.control(this.ctx,()=>this.requestRender("low")),this.requestRender("high")}async afterDelete(){this.requestRender("high")}async render(){if(this.deleted)return;const{renderCtx:n,addStatus:r}=this.internal,{zoom:s,position:o}=this.state,i=f.Eo.construct(this.state.region);if(!this.state.visible)return async()=>n.erase(i,this.state.clearOverScan,..._r);const a=n.scissor(i,f.q.ZERO,_r),c=f.k$2.XY.magnify(f.q.construct(s)).translate(f.Eo.topLeft(i)).translate(o);try{await Promise.all(this.children.map(async u=>await u.render({viewportScale:c})))}catch(u){r({variant:"error",message:u.message})}finally{a()}const l=f.Eo.copy(this.state.region);return async()=>{this.internal.renderCtx.erase(l,this.state.clearOverScan,..._r)}}requestRender(n){const{renderCtx:r}=this.internal;r.loop.set({key:`${Ye.TYPE}-${this.key}`,render:async()=>await this.render(),priority:n,canvases:_r})}};m(Ye,"TYPE","Diagram"),m(Ye,"stateZ",ki);let on=Ye;const ch={[on.TYPE]:on},Ev=Object.freeze(Object.defineProperty({__proto__:null,Diagram:on,REGISTRY:ch,diagramStateZ:ki,useInitialViewport:ah},Symbol.toStringTag,{value:"Module"})),lh=b.z.object({region:f.Eo.box,enabled:b.z.boolean().optional().default(!1)});class ms extends T.Leaf{constructor(){super(...arguments);m(this,"schema",lh);m(this,"eraser",new xl)}async afterUpdate(){this.deleted||(this.internal.render=pt.use(this.ctx),await this.internal.render.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:["gl","lower2d","upper2d"]}))}async afterDelete(){await this.internal.render.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:["gl","lower2d","upper2d"]})}async render(){this.deleted||!this.state.enabled||this.internal.render.erase(this.state.region,f.q.construct(0),"gl","lower2d","upper2d")}}m(ms,"TYPE","eraser");const bv={[ms.TYPE]:ms},uh=b.z.object({enabled:b.z.boolean(),source:Yo.optional().default(Io)});class ys extends T.Leaf{constructor(){super(...arguments);m(this,"schema",uh)}async afterUpdate(){var s;this.internal.addStatus=T.useOptionalAggregate(this.ctx);const{source:n}=this.state,{internal:r}=this;this.internal.source=await At(this.ctx,n,this.internal.source),await this.updateEnabledState(),(s=r.stopListening)==null||s.call(r),r.stopListening=r.source.onChange(()=>this.updateEnabledState().catch(this.reportError.bind(this)))}reportError(n){this.internal.addStatus({key:this.key,variant:"error",message:`Failed to update Light: ${n.message}`})}async updateEnabledState(){const n=await this.internal.source.value();n!==this.state.enabled&&this.setState(r=>({...r,enabled:n}))}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var n,r;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n))}async render(){}}m(ys,"TYPE","Light");const Tv={[ys.TYPE]:ys},Ri=b.z.object({position:f.q.xy.or(b.z.null()),textColor:f.Color.z.optional().default(f.ZERO),backgroundColor:f.Color.z.optional().default(f.ZERO),borderColor:f.Color.z.optional().default(f.ZERO),ruleColor:f.Color.z.optional().default(f.ZERO),ruleStrokeWidth:b.z.number().optional().default(1),ruleStrokeDash:b.z.number().default(0)});class an extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Ri)}async afterUpdate(){const n=T.use(this.ctx);this.state.textColor.isZero&&(this.state.textColor=n.colors.text),this.state.backgroundColor.isZero&&(this.state.backgroundColor=n.colors.gray.l1),this.state.borderColor.isZero&&(this.state.borderColor=n.colors.border),this.state.ruleColor.isZero&&(this.state.ruleColor=n.colors.gray.l5),this.internal.dotColor=n.colors.text,this.internal.dotColorContrast=n.colors.textInverted,this.internal.render=pt.use(this.ctx),this.internal.draw=new un(this.internal.render.upper2d,n),mt.requestRender(this.ctx,Xt)}async afterDelete(){mt.requestRender(this.ctx,Xt)}async render(n){if(this.deleted||this.state.position==null)return;const{region:r}=n,s=f.k$2.XY.scale(f.Eo.DECIMAL).scale(r),o=f.k$2.XY.scale(r).scale(f.Eo.DECIMAL),i=await n.findByXDecimal(o.x.pos(this.state.position.x)),a=i.filter(w=>f.q.isFinite(w.value)),{draw:c}=this.internal,l=a.reduce((w,y)=>w+y.position.x,0)/a.length,u=new T.m(a.reduce((w,y)=>w+y.value.x,0)/a.length),h=s.x.pos(l);if(!f.G.contains(f.Eo.xBounds(r),h))return;c.rule({stroke:this.state.ruleColor,lineWidth:this.state.ruleStrokeWidth,lineDash:this.state.ruleStrokeDash,direction:"y",region:r,position:h}),a.forEach(w=>{const y=s.pos(w.position);c.circle({fill:w.color.setAlpha(.5),radius:8,position:y}),c.circle({fill:w.color.setAlpha(.8),radius:5,position:y}),c.circle({fill:w.color.pickByContrast(this.internal.dotColor,this.internal.dotColorContrast),radius:2,position:y})});const d=i.map(w=>`${w.label??""}: ${w.value.y.toFixed(2)}`);d.unshift(`Time: ${u.fString("preciseDate","local")}`);const p=o.pos(this.state.position);c.textContainer({text:d,backgroundColor:this.state.backgroundColor,borderColor:this.state.borderColor,position:this.state.position,direction:"y",level:"small",spacing:.5,offset:{x:12,y:12},root:{x:p.x>.8?"right":"left",y:p.y>.8?"top":"bottom"}})}}m(an,"TYPE","tooltip");const hh={[an.TYPE]:an},_v=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:hh,Tooltip:an,tooltipStateZ:Ri},Symbol.toStringTag,{value:"Module"})),fh=b.z.object({region:f.Eo.box,wheelPos:b.z.number(),scrolling:b.z.boolean(),empty:b.z.boolean(),visible:b.z.boolean(),telem:Fr.optional().default(dc),font:T.levelZ.optional().default("p"),color:f.Color.z.optional().default(f.ZERO),overshoot:f.q.xy.optional().default({x:0,y:0})}),Cv=.98,Tn="lower2d",Pv={offset:0n,offsetRef:0n,scrollRef:0},On=class On extends T.Leaf{constructor(){super(...arguments);m(this,"schema",On.z);m(this,"values",new T.Ct([]));m(this,"scrollState",Pv)}async afterUpdate(){var c;const{internal:n}=this;n.render=pt.use(this.ctx),n.theme=T.use(this.ctx),this.state.color.isZero?this.internal.textColor=n.theme.colors.gray.l8:n.textColor=this.state.color,n.telem=await At(this.ctx,this.state.telem,n.telem);const{scrolling:r,wheelPos:s}=this.state;if(this.state.scrolling&&!this.prevState.scrolling){const l=this.values.alignmentBounds.upper-1n;this.scrollState={offset:l,offsetRef:l,scrollRef:this.state.wheelPos}}else if(r){const{scrollState:l,values:u}=this,h=Math.ceil((s-this.scrollState.scrollRef)/this.lineHeight);l.offset=this.values.traverseAlignment(l.offsetRef,-BigInt(h)),l.offset<u.alignmentBounds.lower+BigInt(this.visibleLineCount)&&(l.offset=u.alignmentBounds.lower,this.setState(d=>({...d,wheelPos:this.prevState.wheelPos}))),l.offset>=u.alignmentBounds.upper&&this.setState(d=>({...d,scrolling:!1}))}const[i,a]=await this.internal.telem.value();this.values=new T.Ct(a),this.checkEmpty(),(c=n.stopListeningTelem)==null||c.call(n),n.stopListeningTelem=n.telem.onChange(()=>this.internal.telem.value().then(([l,u])=>{this.checkEmpty(),this.values=new T.Ct(u),this.requestRender()})),this.requestRender()}checkEmpty(){const n=this.values.length===0;n!==this.state.empty&&this.setState(r=>({...r,empty:n}))}async afterDelete(){var s;const{telem:n,render:r}=this.internal;await((s=n.cleanup)==null?void 0:s.call(n)),r.erase(f.Eo.construct(this.state.region),f.q.ZERO,Tn)}requestRender(){const{render:n}=this.internal;n.loop.set({key:`${this.type}-${this.key}`,render:async()=>await this.render(),priority:"high",canvases:[Tn]})}get lineHeight(){return this.internal.theme.typography[this.state.font].size*this.internal.theme.sizes.base}get totalHeight(){return Math.ceil(this.values.length*this.lineHeight)}get visibleLineCount(){return Math.min(Math.floor((f.Eo.height(this.state.region)-12)/this.lineHeight),this.values.length)}async render(){const{render:n}=this.internal,r=this.state.region;if(f.Eo.areaIsZero(r))return;if(!this.state.visible)return async()=>n.erase(r,f.q.ZERO,Tn);let s;if(!this.state.scrolling)s=this.values.subIterator(this.values.length-this.visibleLineCount,this.values.length);else{const u=this.values.traverseAlignment(this.scrollState.offset,-BigInt(this.visibleLineCount));s=this.values.subAlignmentSpanIterator(u,this.visibleLineCount)}const o=this.state.region,i=n[Tn],a=new un(i,this.internal.theme),c=n.scissor(o,f.q.ZERO,[Tn]);this.renderElements(a,s),this.renderScrollbar(a),c();const l=f.Eo.copy(this.state.region);return async({canvases:u})=>n.erase(l,this.state.overshoot,...u)}renderScrollbar(n){const r=this.state.region,s=f.Eo.height(r)/this.totalHeight*f.Eo.height(r);if(s>=f.Eo.height(r)*Cv)return;let o=f.Eo.bottom(r)-s;this.state.scrolling&&(o-=Number(this.values.distance(this.values.alignmentBounds.upper,this.scrollState.offset))/this.values.length*f.Eo.height(r)),o<0&&(o=f.Eo.top(r)),n.container({region:f.Eo.construct({x:f.Eo.right(r)-6,y:o},{width:6,height:s}),bordered:!1,backgroundColor:i=>i.colors.gray.l4})}renderElements(n,r){const s=this.state.region;let o=0;for(const i of r){const a=this.values.dataType.equals(T.g.JSON)?JSON.stringify(i):i.toString();n.text({text:a,level:this.state.font,shade:9,position:f.q.translate(f.Eo.topLeft(s),{x:6,y:o*this.lineHeight+6}),code:!0}),o++}}};m(On,"TYPE","log"),m(On,"z",fh);let er=On;const kv={[er.TYPE]:er},Mi=b.z.object({one:f.q.xy.nullable(),two:f.q.xy.nullable(),hover:f.q.xy.nullable(),color:b.z.union([f.Color.z,b.z.object({verticalLine:f.Color.z.optional().default(f.ZERO),horizontalLine:f.Color.z.optional().default(f.ZERO),obliqueLine:f.Color.z.optional().default(f.ZERO)})]).optional().default(f.ZERO),strokeWidth:b.z.number().optional().default(1),strokeDash:b.z.number().optional().default(2)});class cn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Mi)}async afterUpdate(){const n=pt.use(this.ctx);this.internal.theme=T.use(this.ctx),this.internal.render=n,this.internal.draw=new un(n.upper2d,this.internal.theme),mt.requestRender(this.ctx,Xt)}async afterDelete(){mt.requestRender(this.ctx,$t)}get verticalLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.verticalLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.verticalLine}get horizontalLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.horizontalLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.horizontalLine}get obliqueLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.obliqueLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.obliqueLine}async find(n){const{one:r,two:s}=this.state;if(r==null||s==null)return null;const{one:o,two:i}=this.prevState,{dataOne:a,dataTwo:c}=this.internal;if(o!=null&&f.q.equals(r,o)&&i!=null&&f.q.equals(s,i)&&a!=null&&c!=null){const[E,v]=[await n.findByXValue(a.x),await n.findByXValue(c.x)];return E.length===0||v.length===0?null:[E.sort((R,_)=>f.q.distance(a,R.value)-f.q.distance(a,_.value))[0],v.sort((R,_)=>f.q.distance(c,R.value)-f.q.distance(c,_.value))[0]]}const l=f.k$2.XY.scale(n.region).scale(f.Eo.DECIMAL),[u,h]=[l.pos(r),l.pos(s)],[d,p]=[await n.findByXDecimal(u.x),await n.findByXDecimal(h.x)];if(d.length===0||p.length===0)return null;const[w,y]=[d.sort((E,v)=>f.q.distance(u,E.position)-f.q.distance(u,v.position))[0],p.sort((E,v)=>f.q.distance(h,E.position)-f.q.distance(h,v.position))[0]];return this.internal.dataOne=w.value,this.internal.dataTwo=y.value,[w,y]}async renderHover(n){if(this.state.hover==null)return;const r=this.state.hover,s=f.k$2.XY.scale(n.region).scale(f.Eo.DECIMAL),o=s.pos(r),i=await n.findByXDecimal(s.pos(r).x);if(i.length===0)return;const a=i.sort((l,u)=>f.q.distance(o,l.position)-f.q.distance(o,u.position))[0],{draw:c}=this.internal;c.circle({fill:a.color.setAlpha(.5),radius:9,position:s.reverse().pos(a.position)})}async render(n){if(this.deleted)return;await this.renderHover(n);const r=await this.find(n);if(r==null)return;const[s,o]=r,{draw:i}=this.internal,{strokeDash:a,strokeWidth:c}=this.state,l=f.k$2.XY.scale(f.Eo.DECIMAL).scale(n.region),u=l.pos(s.position),h=l.pos(o.position),d=new T.y(Math.abs(s.value.x-o.value.x)),p=Math.abs(s.value.y-o.value.y),w=p/d.seconds;i.line({start:f.q.construct(u.x,u.y),end:f.q.construct(u.x,h.y),stroke:this.verticalLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[`${p.toFixed(2)} ${s.units??""}`],direction:"x",position:f.q.construct(u.x,(u.y+h.y)/2),level:"small"}),i.line({start:f.q.construct(u.x,h.y),end:f.q.construct(h.x,h.y),stroke:this.horizontalLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[d.truncate(T.y.MILLISECOND).toString()],direction:"x",position:f.q.construct((u.x+h.x)/2,h.y),level:"small"}),i.line({start:f.q.construct(u.x,u.y),end:f.q.construct(h.x,h.y),stroke:this.obliqueLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[`${w.toFixed(2)} ${s.units??""} / S`],direction:"x",position:f.q.construct((u.x+h.x)/2,(u.y+h.y)/2),level:"small"}),i.circle({fill:s.color.setAlpha(.5),radius:8,position:u}),i.circle({fill:s.color.setAlpha(.8),radius:5,position:u}),i.circle({fill:new f.Color("#ffffff"),radius:2,position:u}),i.circle({fill:o.color.setAlpha(.5),radius:8,position:h}),i.circle({fill:o.color.setAlpha(.8),radius:5,position:h}),i.circle({fill:new f.Color("#ffffff"),radius:2,position:h})}}m(cn,"TYPE","measure");const dh={[cn.TYPE]:cn},Rv=Object.freeze(Object.defineProperty({__proto__:null,Measure:cn,REGISTRY:dh,measureStateZ:Mi},Symbol.toStringTag,{value:"Module"})),ph=b.z.object({trigger:b.z.number(),command:b.z.number().optional(),value:b.z.number(),sink:wc.optional().default(lc),source:yc.optional().default(uc)});class ws extends T.Leaf{constructor(){super(...arguments);m(this,"schema",ph)}async afterUpdate(){var c;this.internal.addStatus=T.useOptionalAggregate(this.ctx);const{sink:n,source:r,trigger:s,command:o}=this.state,{trigger:i}=this.prevState,{internal:a}=this;this.internal.source=await At(this.ctx,r,this.internal.source),a.sink=await or(this.ctx,n,a.sink),s!==i&&o!=null&&this.internal.sink.set(o),await this.updateValue(),(c=a.stopListening)==null||c.call(a),a.stopListening=a.source.onChange(()=>{this.updateValue().catch(this.reportError.bind(this))})}reportError(n){this.internal.addStatus({key:this.key,variant:"error",message:`Failed to update Setpoint: ${n.message}`})}async updateValue(){const n=await this.internal.source.value();n!==this.state.value&&this.setState(r=>({...r,value:n,triggered:!1}))}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}async render(){}}m(ws,"TYPE","Setpoint");const Mv={[ws.TYPE]:ws},gh=b.z.object({triggered:b.z.boolean(),enabled:b.z.boolean(),sink:Ts.optional().default(Es),source:Yo.optional().default(Io)});class xs extends T.Leaf{constructor(){super(...arguments);m(this,"schema",gh)}async afterUpdate(){var c;this.internal.addStatus=T.useOptionalAggregate(this.ctx);const{sink:n,source:r,triggered:s,enabled:o}=this.state,{triggered:i}=this.prevState,{internal:a}=this;this.internal.source=await At(this.ctx,r,this.internal.source),a.sink=await or(this.ctx,n,a.sink),s&&!i&&await a.sink.set(!o),await this.updateEnabledState(),(c=a.stopListening)==null||c.call(a),a.stopListening=a.source.onChange(()=>{this.updateEnabledState().catch(this.reportError.bind(this))})}reportError(n){this.internal.addStatus({key:this.key,variant:"error",message:`Failed to update Toggle: ${n.message}`})}async updateEnabledState(){const n=await this.internal.source.value();n!==this.state.enabled&&this.setState(r=>({...r,enabled:n,triggered:!1}))}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}async render(){}}m(xs,"TYPE","Toggle");const Av={[xs.TYPE]:xs},Nv=b.z.object({box:f.Eo.box,telem:vc.optional().default(hc),font:T.levelZ.optional().default("p"),color:f.Color.z.optional().default(f.ZERO),precision:b.z.number().optional().default(2),minWidth:b.z.number().optional().default(60),width:b.z.number().optional()}),Dn=class Dn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Dn.z)}async afterUpdate(){var r;const{internal:n}=this;n.render=pt.use(this.ctx),n.theme=T.use(this.ctx),this.state.color.isZero?this.internal.textColor=n.theme.colors.gray.l8:n.textColor=this.state.color,n.telem=await At(this.ctx,this.state.telem,n.telem),(r=n.stopListening)==null||r.call(n),n.stopListening=this.internal.telem.onChange(()=>this.requestRender()),this.internal.requestRender=mt.useOptionalRequest(this.ctx),this.requestRender()}async afterDelete(){var o;const{requestRender:n,telem:r,render:s}=this.internal;await((o=r.cleanup)==null?void 0:o.call(r)),n==null?s.erase(f.Eo.construct(this.state.box),f.q.ZERO,"upper2d"):n($t)}requestRender(){const{requestRender:n}=this.internal;n!=null?n($t):this.render({})}async render({viewportScale:n=f.k$2.XY.IDENTITY}){const{render:r,telem:s,theme:o}=this.internal,i=f.Eo.construct(this.state.box);if(f.Eo.areaIsZero(i))return;const a=r.upper2d.applyScale(n),c=await s.value();a.font=this.state.font;const l=o.typography[this.state.font].size*o.sizes.base,u=T.dimensions(c,T.fontString(this.internal.theme,this.state.font),a).width;this.internal.requestRender==null&&r.erase(f.Eo.construct(this.prevState.box));const h=u+o.sizes.base*1;(this.state.width==null||this.state.width<h||this.state.minWidth>h&&this.state.width!==this.state.minWidth)&&this.setState(p=>({...p,width:Math.max(h,p.minWidth)}));const d=f.q.couple(f.q.translate(f.Eo.topLeft(i),{x:0,y:f.Eo.height(i)/2},{y:l/2,x:12}));a.fillStyle=this.internal.textColor.hex,a.fillText(c,...d)}};m(Dn,"TYPE","value"),m(Dn,"z",Nv);let ln=Dn;const mh={[ln.TYPE]:ln},Ov=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:mh,Value:ln},Symbol.toStringTag,{value:"Module"})),Dv=T.Bg.payloadZ.extend({viewport:f.G.bounds}),sc=t=>f.Color.z.safeParse(t).success,yh=b.z.object({cursor:f.q.xy.or(b.z.null()),hovered:Dv.or(b.z.null()),count:b.z.number()});class nr extends T.Leaf{constructor(){super(...arguments);m(this,"schema",yh);m(this,"fetchedInitial",T.E.ZERO)}async afterUpdate(){const{internal:n}=this;n.render=pt.use(this.ctx),n.draw=new un(n.render.upper2d,T.use(this.ctx)),n.ranges==null&&(n.ranges=new Map);const r=sr(this.ctx);r!=null&&(n.client=r,n.tracker==null&&(n.tracker=await n.client.ranges.openTracker(),n.tracker.onChange(async s=>{s.forEach(async o=>{o.variant==="delete"?n.ranges.delete(o.key):sc(o.value.color)&&n.ranges.set(o.key,o.value)}),mt.requestRender(this.ctx,Xt),this.setState(o=>({...o,count:n.ranges.size}))}),mt.requestRender(this.ctx,Xt)))}async fetchInitial(n){const{internal:r}=this;if(r.client==null||this.fetchedInitial.roughlyEquals(n,T.y.minutes(1)))return;this.fetchedInitial=n,(await r.client.ranges.retrieve(n)).forEach(o=>{sc(o.color)&&r.ranges.set(o.key,o)}),this.setState(o=>({...o,count:r.ranges.size}))}async render(n){const{dataToDecimalScale:r,region:s,viewport:o,timeRange:i}=n;await this.fetchInitial(i);const{draw:a,ranges:c}=this.internal,l=r.scale(f.Eo.xBounds(s)),u=this.state.cursor==null?null:this.state.cursor.x;let h=null;const d=a.canvas.scissor(f.Eo.construct({x:f.Eo.left(s),y:f.Eo.top(s)-35},{x:f.Eo.right(s),y:f.Eo.bottom(s)}));c.forEach(p=>{const w=f.Color.z.safeParse(p.color);if(!w.success)return;const y=w.data;let E=l.pos(Number(p.timeRange.start.valueOf()));const v=l.pos(Number(p.timeRange.end.valueOf()));if(v<f.Eo.left(s)||E>f.Eo.right(s))return;E=f.j(E,f.Eo.left(s)-2,f.Eo.right(s)-1);let R=!1;u!=null&&(R=f.G.contains({lower:E,upper:v},u)),R&&(h={key:p.key,name:p.name,color:p.color,timeRange:p.timeRange,viewport:{lower:r.scale(f.Eo.xBounds(o)).pos(Number(p.timeRange.start.valueOf())),upper:r.scale(f.Eo.xBounds(o)).pos(Number(p.timeRange.end.valueOf()))}}),a.container({region:f.Eo.construct({x:E,y:f.Eo.top(s)-1},{x:v,y:f.Eo.bottom(s)-1}),backgroundColor:y.setAlpha(.2),bordered:!1});const _=f.Eo.construct({x:E+1,y:f.Eo.top(s)-34},{x:v-1,y:f.Eo.top(s)-12});a.container({region:_,backgroundColor:f.Eo.width(_)<20?y.setAlpha(.4):S=>R?S.colors.gray.l2:S.colors.gray.l0,bordered:!0,borderWidth:1,borderRadius:2,borderColor:y.setAlpha(.8)}),a.text({text:p.name,position:{x:E+8,y:f.Eo.top(s)-30},level:"small",shade:8,weight:500,maxWidth:v-E-16})}),d(),h!=null?this.setState(p=>({...p,hovered:h})):this.state.hovered&&this.setState(p=>({...p,hovered:null}))}}m(nr,"TYPE","range-provider");const zv={[ns.TYPE]:ns,[nr.TYPE]:nr},Lv=hr;class rr extends El{constructor(){super(...arguments);m(this,"schema",hr)}async render(n){if(this.deleted)return;const[r,s]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(this.renderAxis(n,r.reverse()),await this.renderYAxes(n,r),await this.renderRangeAnnotations(n,r),s!=null)throw s}async findByXDecimal(n,r){const[s,o]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(o!=null)throw o;return await this.findByXValue(n,s.reverse().pos(r))}async findByXValue(n,r){const[s,o]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(o!=null)throw o;const i={...n,xDataToDecimalScale:s},a=this.yAxes.map(async c=>await c.findByXValue(i,r));return(await Promise.all(a)).flat()}async renderYAxes(n,r){const s={...n,xDataToDecimalScale:r};await Promise.all(this.yAxes.map(async o=>await o.render(s)))}get yAxes(){return this.childrenOfType(Vn.TYPE)}get rangeAnnotations(){return this.childrenOfType(nr.TYPE)}async renderRangeAnnotations(n,r){const[s,o]=await this.bounds(n.hold,this.dataBounds.bind(this));if(o!=null)throw o;await Promise.all(this.rangeAnnotations.map(async i=>await i.render({dataToDecimalScale:r,region:n.plot,viewport:n.viewport,timeRange:new T.E(s.lower,s.upper)})))}async dataBounds(){return await Promise.all(this.yAxes.map(async n=>await n.xBounds()))}}m(rr,"TYPE","XAxis");const wh=b.z.object({container:f.Eo.box,viewport:f.Eo.box,hold:b.z.boolean().optional().default(!1),grid:b.z.record(Wc),visible:b.z.boolean().optional().default(!0),clearOverScan:f.q.crudeZ.optional().default(f.q.ZERO)}),Iv=(t,e)=>{const n=f.Eo.width(t)*Math.sqrt(f.Eo.height(t)),r=f.Eo.width(e)*Math.sqrt(f.Eo.height(e));return n/r};class vs extends T.Composite{constructor(){super(...arguments);m(this,"schema",wh)}async afterUpdate(){this.internal.instrumentation=cr(this.ctx,"lineplot"),this.internal.aggregate=T.useAggregate(this.ctx),this.internal.renderCtx=pt.use(this.ctx),mt.control(this.ctx,n=>this.requestRender("low",n)),this.requestRender("high",$t)}async afterDelete(){this.internal.renderCtx=pt.use(this.ctx),this.requestRender("high",$t)}async findByXDecimal(n){const r={...this.state,plot:this.calculatePlot(),exposure:this.exposure},s=this.axes.flatMap(async o=>await o.findByXDecimal(r,n));return(await Promise.all(s)).flat()}async findByXValue(n){const r={...this.state,plot:this.calculatePlot(),exposure:this.exposure},s=this.axes.flatMap(async o=>await o.findByXValue(r,n));return(await Promise.all(s)).flat()}get axes(){return this.childrenOfType(rr.TYPE)}get tooltips(){return this.childrenOfType(an.TYPE)}get measures(){return this.childrenOfType(cn.TYPE)}get exposure(){return Iv(this.state.viewport,this.state.container)}async renderAxes(n,r){const s={...this.state,plot:n,canvases:r,exposure:this.exposure};await Promise.all(this.axes.map(async o=>await o.render(s)))}async renderTooltips(n,r){const s={findByXDecimal:this.findByXDecimal.bind(this),region:n,canvases:r};await Promise.all(this.tooltips.map(async o=>await o.render(s)))}async renderMeasures(n,r){const s={findByXDecimal:this.findByXDecimal.bind(this),findByXValue:this.findByXValue.bind(this),region:n,canvases:r};await Promise.all(this.measures.map(async o=>await o.render(s)))}calculatePlot(){return Yf(this.state.grid,this.state.container)}async render(n){const{renderCtx:r}=this.internal,{instrumentation:s}=this.internal;if(this.deleted){s.L.debug("deleted, skipping render",{key:this.key});return}if(!this.state.visible)return s.L.debug("not visible, skipping render",{key:this.key}),async({canvases:u})=>r.erase(this.state.container,this.state.clearOverScan,...u);const o=this.calculatePlot();s.L.debug("rendering",{key:this.key,viewport:this.state.viewport,container:this.state.container,grid:this.state.grid,plot:o,canvases:n});const i=f.q.construct(this.state.clearOverScan),a=r.scissor(this.state.container,i,n.filter(u=>u!=="gl")),c=r.scissor(o,f.q.ZERO,n.filter(u=>u==="gl"));try{await this.renderAxes(o,n),await this.renderTooltips(o,n),await this.renderMeasures(o,n),r.gl.finish(),r.gl.flush(),r.gl.finish()}catch(u){if(u.message.toLowerCase().includes("bigint"))return;this.internal.aggregate({key:`${this.type}-${this.key}`,variant:"error",message:u.message})}finally{a(),c()}s.L.debug("rendered",{key:this.key});const l=f.Eo.copy(this.state.container);return async({canvases:u})=>r.erase(l,this.state.clearOverScan,...u)}requestRender(n,r){const{renderCtx:s}=this.internal;let o=["upper2d","lower2d","gl"];r===Xt&&(o=["upper2d"]),s.loop.set({key:`${this.type}-${this.key}`,render:async()=>await this.render(o),priority:n,canvases:o})}}m(vs,"TYPE","LinePlot");const $v={[vs.TYPE]:vs,[rr.TYPE]:rr,[Vn.TYPE]:Vn};exports.AcquireChannelControl=Xn;exports.Annotation=ns;exports.AuthoritySource=Wn;exports.BaseEdge=hn;exports.BaseProvider=Ke;exports.Button=as;exports.Canvas=yl;exports.Canvas$1=Kn;exports.Chip=rs;exports.Context=pt;exports.Controller=mt;exports.Controller$1=ss;exports.Diagram=Ev;exports.Diagram$1=on;exports.Eraser=xl;exports.Eraser$1=ms;exports.GLProgram=ci;exports.Handle$1=Qn;exports.Indicator=os;exports.Legend=is;exports.Light=ys;exports.Line=Hn;exports.LinePlot=vs;exports.Log=er;exports.Loop=wl;exports.Measure=cn;exports.Provider=Or;exports.Provider$1=nr;exports.Provider$2=co;exports.REASON_DATA=yo;exports.REASON_LAYOUT=$t;exports.REASON_TOOL=Xt;exports.REGISTRY=Ef;exports.REGISTRY$1=Vg;exports.REGISTRY$10=zv;exports.REGISTRY$11=_l;exports.REGISTRY$12=Mv;exports.REGISTRY$13=oc;exports.REGISTRY$14=Xc;exports.REGISTRY$15=Av;exports.REGISTRY$16=hh;exports.REGISTRY$17=mh;exports.REGISTRY$18=kv;exports.REGISTRY$2=Yl;exports.REGISTRY$3=Hg;exports.REGISTRY$4=ch;exports.REGISTRY$5=bv;exports.REGISTRY$6=Tv;exports.REGISTRY$7=Lg;exports.REGISTRY$8=$v;exports.REGISTRY$9=dh;exports.ReactFlow=Qu;exports.ReactFlowProvider=Pi;exports.Rule=tn;exports.STATUSES=Ml;exports.SetChannelValue=Gn;exports.Setpoint=ws;exports.StateProvider=en;exports.Toggle=xs;exports.Tooltip=an;exports.Value=ln;exports.XAxis=rr;exports.YAxis=Vn;exports.ZERO_CONTEXT_VALUE=zo;exports.acquireChannelControl=Zg;exports.acquireChannelControlPropsZ=Dl;exports.addEdge=xu;exports.aether=Bg;exports.annotationStateZ=Cl;exports.applyEdgeChanges=cx;exports.applyNodeChanges=Bu;exports.authoritySource=Ug;exports.authoritySourceProps=zl;exports.axisStateZ=ai;exports.buildNew=cv;exports.buttonStateZ=$l;exports.canvas=Gg;exports.canvasStateZ=ui;exports.cc=St;exports.channelData=kc;exports.checkIntegrity=nv;exports.chipStateZ=Pl;exports.controllerStateZ=Nl;exports.coreAxisStateZ=hr;exports.diagramStateZ=ki;exports.dragSegment=uv;exports.edgeConverter=Sv;exports.edgeZ=yv;exports.eraserStateZ=lh;exports.external=If;exports.indicatorStateZ=Ll;exports.legendStateZ=Il;exports.lightStateZ=uh;exports.linePlotStateZ=wh;exports.logState=fh;exports.measure=Rv;exports.measureStateZ=Mi;exports.moveSourceNode=pv;exports.moveTargetNode=gv;exports.newTickFactory=mo;exports.nodeConverter=vv;exports.nodeZ=wv;exports.parseAutoBounds=bl;exports.provider=of;exports.providerStateZ=yh;exports.providerStateZ$1=Uc;exports.providerStateZ$2=Xo;exports.regions=de;exports.rfEdgeDataZ=eh;exports.rollingAverage=qc;exports.rollingAverageProps=Go;exports.ruleStateZ=li;exports.segmentsToPoints=rv;exports.setChannelValue=Fg;exports.setChannelValuePropsZ=Ol;exports.setpoint=Lc;exports.setpointStateZ=ph;exports.shallow$1=gt;exports.sinkPipeline=Cc;exports.sinkPipelinePropsZ=Fo;exports.sourcePipeline=_c;exports.sourcePipelinePropsZ=qo;exports.stateProviderStateZ=kl;exports.stateZ=Tl;exports.statusZ=Al;exports.streamChannelData=Rc;exports.streamChannelValue=Mc;exports.streamChannelValuePropsZ=Zo;exports.stringifyNumber=Bc;exports.stringifyNumberProps=Vo;exports.sugaredStateZ=Rl;exports.tickFactoryProps=ii;exports.tickType=oi;exports.toggleStateZ=gh;exports.tooltip=_v;exports.tooltipStateZ=Ri;exports.translateEdgesBackward=oh;exports.translateEdgesForward=rh;exports.translateNodesBackward=sh;exports.translateNodesForward=nh;exports.translateViewportBackward=ih;exports.translateViewportForward=xv;exports.updateEdge=Aw;exports.useInitialViewport=ah;exports.useOnViewportChange=ev;exports.useReactFlow=Ds;exports.useStore=lt;exports.useUpdateNodeInternals=tv;exports.value=Ov;exports.viewportZ=mv;exports.withinBounds=Ic;exports.withinSizeThreshold=vl;exports.xAxisStateZ=Lv;exports.yAxisStateZ=qg;
|