@synnaxlabs/pluto 0.44.6 → 0.44.7
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-BDoJWl9g.cjs → Animated-D5LYKEkW.cjs} +1 -1
- package/dist/{Animated-fI-NFaha.js → Animated-DdcRuSba.js} +2 -2
- package/dist/Editable-7Abx7gK5.cjs +92 -0
- package/dist/{Editable-C1g_CFYk.js → Editable-BrtvNf66.js} +11315 -11270
- package/dist/{LinePlot-YMJgGruk.js → LinePlot-BIZ1E3Rb.js} +208 -204
- package/dist/LinePlot-DslwDvAo.cjs +53 -0
- package/dist/{Toggle-DUKDeqpe.cjs → Toggle-BVFmU1mL.cjs} +1 -1
- package/dist/{Toggle-DEJ8Uvun.js → Toggle-DfINNQZ3.js} +1 -1
- package/dist/{Video-B6tujjr8.js → Video-CMuBiBcp.js} +1 -1
- package/dist/{Video-BjRd9sFv.cjs → Video-CbaEeyGH.cjs} +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-DvIPI3Qm.js → css-BlHGoCgb.js} +578 -559
- package/dist/css-CZ_XGkIB.cjs +8 -0
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/{eraser-CnRJY__h.js → eraser-BstNvEkO.js} +1940 -1889
- package/dist/eraser-DiJNbabo.cjs +63 -0
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +13 -13
- package/dist/{external-DKh0JhWO.cjs → external-B33LW5pz.cjs} +1 -1
- package/dist/{external-Dfr7xymv.js → external-BNwo0Mju.js} +3 -3
- package/dist/{external-CAAPXpVr.cjs → external-C3hm9xgd.cjs} +1 -1
- package/dist/external-CE5Gf1U4.cjs +1 -0
- package/dist/{external-D6hAP7eJ.js → external-CSkXMvdW.js} +7 -7
- package/dist/{external-R9a28aP6.js → external-C_25EtbW.js} +31 -31
- package/dist/{external-dew29Q0v.js → external-ClD0dLdB.js} +2 -2
- package/dist/{external-CKhbbig_.js → external-CoEPLcYb.js} +12 -12
- package/dist/{external-DwRvB5ZT.cjs → external-CoVeaXHg.cjs} +1 -1
- package/dist/{external-CNF5TNBY.cjs → external-Cs-XdMNw.cjs} +1 -1
- package/dist/{external-BzV_PGNe.js → external-CsZA1s33.js} +2 -2
- package/dist/{external-Db9iKa8k.js → external-CtRU4mkG.js} +3 -3
- package/dist/{external-D98a3YQJ.cjs → external-D-FHwqls.cjs} +1 -1
- package/dist/{external-BS9S-b49.cjs → external-D91gCQ3U.cjs} +1 -1
- package/dist/external-DE-uFhwW.cjs +1 -0
- package/dist/{external-DOEaBrpz.cjs → external-DSkHe-2Y.cjs} +1 -1
- package/dist/{external-DNO3FJLl.cjs → external-DXm6LsSg.cjs} +1 -1
- package/dist/{external-C2iqWGd2.js → external-DkZwoQZk.js} +29 -29
- package/dist/external-Ds3Wz9sk.js +44 -0
- package/dist/{external-B3dPSZUg.js → external-FrSPoRvt.js} +2 -2
- package/dist/{external-DRuZ24L7.js → external-GS2AbOOd.js} +6 -6
- package/dist/{external-Blrrgnzw.cjs → external-IBErJ3kF.cjs} +1 -1
- package/dist/{external-GR-20z_c.js → external-J5kFGShS.js} +20 -20
- package/dist/{external-Daage1AI.js → external-V3Tbt95R.js} +10 -10
- package/dist/{external-BenP6Hcm.cjs → external-mX8u0eSb.cjs} +1 -1
- package/dist/{external-BVDQNHbo.cjs → external-vdf1a_j1.cjs} +1 -1
- package/dist/flex.cjs +1 -1
- package/dist/flex.js +1 -1
- package/dist/{fontString-CW0wLG5g.js → fontString-Ca1-oixk.js} +2 -2
- package/dist/{fontString-aK--tYMM.cjs → fontString-Cp4X6CqQ.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.js +6511 -6409
- 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/pluto.css +1 -1
- package/dist/src/channel/LinePlot.d.ts +0 -4
- package/dist/src/channel/LinePlot.d.ts.map +1 -1
- package/dist/src/channel/queries.d.ts +13 -13
- package/dist/src/channel/queries.d.ts.map +1 -1
- package/dist/src/dialog/Dialog.d.ts.map +1 -1
- package/dist/src/dialog/Frame.d.ts +13 -7
- package/dist/src/dialog/Frame.d.ts.map +1 -1
- package/dist/src/dialog/position.d.ts +22 -8
- package/dist/src/dialog/position.d.ts.map +1 -1
- package/dist/src/dialog/position.spec.d.ts +2 -0
- package/dist/src/dialog/position.spec.d.ts.map +1 -0
- package/dist/src/flux/core/store.d.ts +2 -0
- package/dist/src/flux/core/store.d.ts.map +1 -1
- package/dist/src/flux/list.d.ts +9 -2
- package/dist/src/flux/list.d.ts.map +1 -1
- package/dist/src/group/index.d.ts +2 -0
- package/dist/src/group/index.d.ts.map +1 -0
- package/dist/src/group/queries.d.ts +35 -0
- package/dist/src/group/queries.d.ts.map +1 -0
- package/dist/src/group/queries.spec.d.ts +2 -0
- package/dist/src/group/queries.spec.d.ts.map +1 -0
- package/dist/src/hardware/device/queries.d.ts +1 -1
- package/dist/src/hardware/device/queries.d.ts.map +1 -1
- package/dist/src/hardware/rack/queries.d.ts +1 -1
- package/dist/src/hardware/rack/queries.d.ts.map +1 -1
- package/dist/src/hardware/task/queries.d.ts +1 -1
- package/dist/src/hardware/task/queries.d.ts.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -2
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/useDestructors.d.ts.map +1 -1
- package/dist/src/hooks/useDestructors.spec.d.ts +2 -0
- package/dist/src/hooks/useDestructors.spec.d.ts.map +1 -0
- package/dist/src/hooks/useResize.d.ts +1 -0
- package/dist/src/hooks/useResize.d.ts.map +1 -1
- package/dist/src/icon/registry.d.ts +1 -0
- package/dist/src/icon/registry.d.ts.map +1 -1
- package/dist/src/label/queries.d.ts +1 -1
- package/dist/src/label/queries.d.ts.map +1 -1
- package/dist/src/menu/ContextMenu.d.ts +1 -1
- package/dist/src/menu/ContextMenu.d.ts.map +1 -1
- package/dist/src/ontology/queries.d.ts +2 -2
- package/dist/src/ontology/queries.d.ts.map +1 -1
- package/dist/src/pluto/Pluto.d.ts +2 -0
- package/dist/src/pluto/Pluto.d.ts.map +1 -1
- package/dist/src/ranger/aether/queries.d.ts +1 -1
- package/dist/src/ranger/aether/queries.d.ts.map +1 -1
- package/dist/src/ranger/queries.d.ts +2 -2
- package/dist/src/ranger/queries.d.ts.map +1 -1
- package/dist/src/state/state.d.ts.map +1 -1
- package/dist/src/telem/control/aether/controller.d.ts +2 -2
- package/dist/src/telem/control/aether/legend.d.ts +2 -2
- package/dist/src/testutil/Synnax.d.ts +1 -1
- package/dist/src/testutil/Synnax.d.ts.map +1 -1
- package/dist/src/vis/legend/Container.d.ts +3 -29
- package/dist/src/vis/legend/Container.d.ts.map +1 -1
- package/dist/src/vis/legend/Entries.d.ts +22 -0
- package/dist/src/vis/legend/Entries.d.ts.map +1 -0
- package/dist/src/vis/legend/Grouped.d.ts +15 -0
- package/dist/src/vis/legend/Grouped.d.ts.map +1 -0
- package/dist/src/vis/legend/Simple.d.ts +5 -19
- package/dist/src/vis/legend/Simple.d.ts.map +1 -1
- package/dist/src/vis/legend/external.d.ts +1 -0
- package/dist/src/vis/legend/external.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Legend.d.ts +3 -3
- package/dist/src/vis/lineplot/Legend.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Line.d.ts +2 -1
- package/dist/src/vis/lineplot/Line.d.ts.map +1 -1
- package/dist/src/vis/lineplot/LinePlot.d.ts +1 -0
- package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
- package/dist/src/workspace/queries.d.ts +1 -1
- package/dist/src/workspace/queries.d.ts.map +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-WWUmv-rf.cjs → units-Cqxg-SBx.cjs} +1 -1
- package/dist/{units-Dh7MflIZ.js → units-D8blpqyN.js} +1 -1
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +6 -6
- package/dist/Editable-DUtJOqJ5.cjs +0 -92
- package/dist/LinePlot-DRbAPdEU.cjs +0 -53
- package/dist/css-DI0uCCGq.cjs +0 -8
- package/dist/eraser-B03ej59l.cjs +0 -63
- package/dist/external-BEd3F7zY.cjs +0 -1
- package/dist/external-D16M7vHB.js +0 -43
- package/dist/external-I_-aclFy.cjs +0 -1
- package/dist/src/hooks/useDelayedState.d.ts +0 -11
- package/dist/src/hooks/useDelayedState.d.ts.map +0 -1
- package/dist/src/hooks/useTransforms.d.ts +0 -16
- package/dist/src/hooks/useTransforms.d.ts.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";const i=require("./css-CZ_XGkIB.cjs"),d=require("zod"),p=require("./eraser-DiJNbabo.cjs"),qe=require("./fontString-Cp4X6CqQ.cjs");require("react");class wo{handlers;transform;closer;constructor(e,t){this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){const[r,s]=this.transform(e);if(!s)return;t=r}this.handlers.forEach((r,s)=>s(t))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}}class xo{handlers;constructor(e){this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,r)=>r(e))}}const $t=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:xo,Observer:wo},Symbol.toStringTag,{value:"Module"})),Nn="pluto-vis-renderer",qt=(n,e)=>{n.set(Nn,e,!1)},Ft=n=>n.get(Nn),os=n=>n.getOptional(Nn),X=(n,e)=>Ft(n)(e);class ne extends $t.Observer{cleanup(){}}class hn extends ne{static TYPE="noop-boolean-sink";set(){}}const Kt={type:hn.TYPE,props:{},variant:"sink",valueType:"boolean"};class dn extends ne{static TYPE="noop-numeric-sink";set(){}}const as={type:dn.TYPE,props:{},variant:"sink",valueType:"number"};class fn extends ne{static TYPE="noop-boolean-source";value(){return!1}}const Bn={type:fn.TYPE,props:{},variant:"source",valueType:"boolean"};class pn extends ne{static TYPE="noop-numeric-source";value(){return 0}}const ls={type:pn.TYPE,props:{},variant:"source",valueType:"number"};class gn extends ne{static TYPE="noop-string-source";value(){return""}}const cs={type:gn.TYPE,props:{},variant:"source",valueType:"string"};class mn extends ne{static TYPE="noop-status-source";value(){return{key:"noop",variant:"disabled",message:"unknown",time:i.r.now()}}}const Un={type:mn.TYPE,props:{},variant:"source",valueType:"status"};class yn extends ne{static TYPE="noop-color-source";value(){return i.cr.ZERO}}const Wt={type:yn.TYPE,props:{},variant:"source",valueType:"color"};class vn extends ne{static TYPE="noop-series";value(){return[i.H.ZERO,new i.Wt([])]}}const us={type:vn.TYPE,props:{},variant:"source",valueType:"series"},To={[hn.TYPE]:hn,[dn.TYPE]:dn,[fn.TYPE]:fn,[pn.TYPE]:pn,[mn.TYPE]:mn,[yn.TYPE]:yn,[gn.TYPE]:gn,[vn.TYPE]:vn};class hs{type="noop";create(e){const t=To[e.type];return t==null?null:new t}}const Eo=d.z.instanceof(ArrayBuffer),tt=d.z.object({type:d.z.string(),variant:d.z.enum(["source","sink","source-transformer","sink-transformer"]),valueType:d.z.string(),props:d.z.any(),transfer:d.z.array(Eo).optional()}),re=tt.extend({variant:d.z.literal("source")}),jt=tt.extend({variant:d.z.literal("sink")}),ds=tt.extend({variant:d.z.literal("source-transformer")}),fs=tt.extend({variant:d.z.literal("sink-transformer")}),pt=re.extend({valueType:d.z.literal("series")}),$n=re.extend({valueType:d.z.literal("boolean")}),Gt=jt.extend({valueType:d.z.literal("boolean")}),Co=fs.extend({valueType:d.z.literal("boolean")}),Po=ds.extend({valueType:d.z.literal("boolean")}),ps=re.extend({valueType:d.z.literal("number")}),gs=jt.extend({valueType:d.z.literal("number")}),qn=re.extend({valueType:d.z.literal("color")}),Fn=re.extend({valueType:d.z.literal("status")}),Kn=re.extend({valueType:d.z.literal("string")});let Vt=class extends $t.BaseObserver{props_=void 0;uProps_=void 0;constructor(e){super(),this.uProps_=e}get props(){if(this.props_==null){const e=this.schema.safeParse(this.uProps_);if(e.success)this.props_=e.data;else throw new p.P(`[BaseTelem] - expected props to be valid, but found the following errors:
|
|
2
|
+
${e.error.message}`)}return this.props_}cleanup(){}};class B extends Vt{}class Xt extends Vt{}class ue extends B{source_=void 0;get source(){if(this.source_==null)throw new p.P("[UnarySourceTransformer] - expected source to exist, but none was found.");return this.source_}value(){return this.transform(this.source.value())}onChange(e){return this.source.onChange(()=>{this.shouldNotify(this.source.value())&&e()})}setSources(e){this.source_=Object.values(e)[0]}shouldNotify(e){return!0}}class ms extends B{sources={};value(){const e=Object.fromEntries(Object.entries(this.sources).map(([t,r])=>[t,r.value()]));return this.transform(e)}setSources(e){this.sources={...this.sources,...e}}}class ys extends Vt{sinks={};get sink(){const[e]=Object.values(this.sinks);if(e==null)throw new p.P("[UnarySinkTransformer] - expected sink to exist, but none was found.");return e}set(...e){return this.sink.set(...this.transform(...e))}setSinks(e){this.sinks={...this.sinks,...e}}}const Wn=d.z.object({from:d.z.string(),to:d.z.string()}),jn=d.z.object({connections:d.z.array(Wn),outlet:d.z.string(),segments:d.z.record(d.z.string(),re)});class Gn{type="pipeline";factory;constructor(e){this.factory=e}create(e){switch(e.type){case gt.TYPE:return new gt(e.props,this.factory);case mt.TYPE:return new mt(e.props,this.factory);default:return null}}}class gt extends B{static TYPE="source-pipeline";schema=jn;sources={};get outlet(){const{outlet:e}=this.props,t=this.sources[e];if(t==null)throw new p.P(`[SourcePipeline] - expected source to exist at outlet '${e}', but none was found.`);return t}constructor(e,t){super(e);const{connections:r,segments:s}=this.props;Object.entries(s).forEach(([o,a])=>{const l=t.create(a);l!=null&&(this.sources[o]=l)}),r.forEach(({from:o,to:a})=>{const l=this.sources[o],u=this.sources[a];l==null||u==null||"setSources"in u&&u.setSources({[o]:l})})}value(){return this.outlet.value()}onChange(e){return this.outlet.onChange(e)}cleanup(){Object.values(this.sources).forEach(e=>e.cleanup?.())}}const vs=(n,e)=>({variant:"source",props:e,type:gt.TYPE,valueType:n}),Vn=d.z.object({connections:d.z.array(Wn),inlet:d.z.string(),segments:d.z.record(d.z.string(),jt)});class mt extends Xt{static TYPE="sink-pipeline";schema=Vn;sinks={};get inlet(){const{inlet:e}=this.props,t=this.sinks[e];if(t==null)throw new p.P(`[SinkPipeline] - expected source to exist at inlet '${e}', but none was found.`);return t}constructor(e,t){super(e);const{connections:r,segments:s}=this.props;Object.entries(s).forEach(([o,a])=>{const l=t.create(a);l!=null&&(this.sinks[o]=l)}),r.forEach(({from:o,to:a})=>{const l=this.sinks[o],u=this.sinks[a];l==null||u==null||"setSinks"in l&&l.setSinks({[a]:u})})}set(...e){return this.inlet.set(...e)}cleanup(){Object.values(this.sinks).forEach(e=>e.cleanup?.())}}const bs=(n,e)=>({variant:"sink",props:e,type:mt.TYPE,valueType:n}),Xn=d.z.object({channel:d.z.number().or(d.z.string())});class yt extends B{static TYPE="stream-channel-value";schema=Xn;client;removeStreamHandler=null;leadingBuffer=null;valid=!1;onStatusChange;constructor(e,t,r){super(t),this.client=e,this.onStatusChange=r?.onStatusChange}get testingOnlyLeadingBuffer(){return this.leadingBuffer}get testingOnlyValid(){return this.valid}cleanup(){this.removeStreamHandler?.(),this.valid=!1,this.leadingBuffer?.release(),this.leadingBuffer=null,this.removeStreamHandler=null}value(){return i.O$1.isZero(this.props.channel)||(this.valid||this.read(),this.leadingBuffer==null||this.leadingBuffer.length===0)?0:this.leadingBuffer.at(-1,!0)}async read(){try{this.valid=!0,this.removeStreamHandler?.();const e=await this.client.retrieveChannel(this.props.channel),t=r=>{const s=r.get(e.key);if(s==null)return;const o=s.series.at(-1);o!=null&&(o.acquire(),this.leadingBuffer?.release(),this.leadingBuffer=o),this.notify()};this.removeStreamHandler=await this.client.stream(t,[e.key]),this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(i.wr.fromException(e,"failed to stream channel value"))}}}const Ss=async(n,e,t)=>{const r=await n.retrieveChannel(e),s=p.ow.isCalculated(r);if(!t||r.isIndex)return{key:r.key,dataType:r.dataType,virtual:r.virtual,isCalculated:s};if(s){const o=await p.ow.resolveCalculatedIndex(n.retrieveChannel.bind(n),r);if(o==null)throw new p._t("Failed to resolve calculated index");return{key:(await n.retrieveChannel(o)).key,dataType:i.n.TIMESTAMP,virtual:!1,isCalculated:s}}if(r.virtual)throw new p._t("cannot use virtual channels as a data source");return{key:r.index,dataType:i.n.TIMESTAMP,virtual:!1,isCalculated:s}},ko=d.z.object({timeRange:i.O.z,channel:d.z.number().or(d.z.string()),useIndexOfChannel:d.z.boolean().optional().default(!1)});class vt extends B{static TYPE="series-source";client;schema=ko;data=new i.Wt;valid=!1;channel=null;onStatusChange;constructor(e,t,r){super(t),this.client=e,this.onStatusChange=r?.onStatusChange}cleanup(){this.data.release(),this.valid=!1,this.channel=null}value(){const{channel:e,timeRange:t}=this.props;if(t.isZero||e===0)return[i.H.ZERO,this.data];this.valid||this.read();const{channel:r,data:s}=this;if(r==null)return[i.H.ZERO,this.data];let o=s.bounds;return r.dataType.equals(i.n.TIMESTAMP)&&(o=i.H.min([o,t.numericBounds])),[o,s]}async read(){try{this.valid=!0;const{timeRange:e,channel:t,useIndexOfChannel:r}=this.props;this.channel=await Ss(this.client,t,r);const s=await this.client.read(e,this.channel.key);s.acquire(),this.data=s,this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(i.wr.fromException(e,"failed to read channel data"))}}}const Ro=d.z.object({channel:d.z.number().or(d.z.string()),useIndexOfChannel:d.z.boolean().optional().default(!1),timeSpan:i.i.z,keepFor:i.i.z.optional()});class bt extends B{static TYPE="dynamic-series-source";client;data=new i.Wt([]);now;onStatusChange;channel=null;stopStreaming;valid=!1;schema=Ro;constructor(e,t,r,s=()=>i.r.now()){super(t),this.client=e,this.now=s,this.onStatusChange=r?.onStatusChange}value(){const{channel:e,timeSpan:t}=this.props;if(e===0)return[i.H.ZERO,this.data];this.valid||this.read();const{data:r,channel:s}=this,o=this.now();if(s!=null&&s.dataType.isVariable)return[i.H.ZERO,this.data];const a=r.series.filter(u=>u.timeRange.end.after(o.sub(t))).map(u=>u.bounds),l=i.H.max(a);return s!=null&&s.dataType.equals(i.n.TIMESTAMP)&&(l.lower=Math.max(l.lower,l.upper-Number(t.valueOf()))),[l,this.data]}async read(){try{this.valid=!0;const{channel:e,useIndexOfChannel:t,timeSpan:r}=this.props;this.channel=await Ss(this.client,e,t);const s=this.now().spanRange(-r);if(!this.channel.virtual||this.channel.isCalculated){const a=await this.client.read(s,this.channel.key);a.acquire(),this.data.push(a)}this.stopStreaming?.();const o=a=>{if(this.channel==null)return;const l=a.get(this.channel.key);l!=null&&(l.acquire(),this.data.push(l),this.notify(),this.gcOutOfRangeData())};this.stopStreaming=await this.client.stream(o,[this.channel.key]),this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(i.wr.fromException(e,"failed to stream channel data"))}}gcOutOfRangeData(){const e=this.now().sub(this.props.keepFor??this.props.timeSpan),t=this.data.series.findIndex(r=>r.timeRange.end.before(e));t!==-1&&(this.data.series.splice(t,1).forEach(r=>r.release()),this.gcOutOfRangeData())}cleanup(){this.stopStreaming?.(),this.stopStreaming=void 0,this.data.release(),this.valid=!1}}const Oo={[vt.TYPE]:vt,[bt.TYPE]:bt,[yt.TYPE]:yt};class ws{type="remote";client;constructor(e){this.client=e}create(e,t){const r=Oo[e.type];return r==null?null:new r(this.client,e.props,t)}}const xs=n=>({type:vt.TYPE,props:n,variant:"source",valueType:"series"}),Ts=n=>({type:bt.TYPE,props:n,variant:"source",valueType:"series"}),Es=n=>({type:yt.TYPE,props:n,variant:"source",valueType:"number"});class Cs{type="static";create(e){switch(e.type){case bn.TYPE:return new bn(e.props);case St.TYPE:return new St(e.props);case wt.TYPE:return new wt(e.props);case xt.TYPE:return new xt(e.props);case Tt.TYPE:return new Tt(e.props);default:return null}}}const Qn=d.z.object({data:d.z.array(i.Jt),offsets:d.z.array(d.z.number()).optional().default([])});class bn extends B{data;schema=Qn;static TYPE="static-series";constructor(e){super(e),this.data=this.props.data.map((t,r)=>new i.v({data:t,dataType:i.n.FLOAT32,timeRange:i.O.ZERO,sampleOffset:this.props.offsets[r]??0}))}value(){return[i.H.max(this.data.map(t=>t.bounds)),this.data]}}const Ps=Qn.extend({rate:i.I.z,yOffset:d.z.number().optional().default(0),scroll:d.z.number().optional().default(0),startPosition:d.z.number().optional().default(0),scrollBounds:d.z.boolean().optional().default(!1)});class St extends B{static TYPE="iterative-series";schema=Ps;position;interval;data;constructor(e){super(e),this.position=this.props.startPosition,this.start(this.props.rate),this.data=this.props.data.map((t,r)=>new i.v({data:t,dataType:i.n.FLOAT32,timeRange:i.O.ZERO,sampleOffset:this.props.offsets[r]??0}))}value(){const e=this.data.map(r=>r.slice(0,this.position));if(this.props.scrollBounds){const r=e[0].data[this.position-this.props.scroll<0?0:this.position-this.props.scroll],s=e[0].data[this.position-1];return[{lower:Number(r),upper:Number(s)},new i.Wt(e)]}return[i.H.max(e.map(r=>r.bounds)),new i.Wt(e)]}start(e){this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{this.notify?.(),this.position++},e.period.milliseconds)}cleanup(){clearInterval(this.interval),this.interval=void 0}}const ks=d.z.number();class wt extends B{static TYPE="static-numeric";schema=ks;value(){return this.props}}const Rs=d.z.string();class xt extends B{static TYPE="static-string";schema=Rs;value(){return this.props}}const Os=i.cr.crudeZ;class Tt extends B{static TYPE="static-color";schema=Os;value(){return i.cr.construct(this.props)}}const Mo=n=>({type:bn.TYPE,props:n,variant:"source",valueType:"series"}),Do=n=>({type:St.TYPE,props:n,variant:"source",valueType:"series"}),Lo=n=>({type:wt.TYPE,props:n,variant:"source",valueType:"number"}),_o=n=>({type:xt.TYPE,props:n,variant:"source",valueType:"string"}),Yo=n=>({type:Tt.TYPE,props:n,variant:"source",valueType:"color"});class Ms{type="transformer";create(e){switch(e.type){case Te.TYPE:return new Te(e.props);case Ee.TYPE:return new Ee(e.props);case Ce.TYPE:return new Ce(e.props);case Pe.TYPE:return new Pe(e.props);case ke.TYPE:return new ke(e.props);case Et.TYPE:return new Et(e.props);case Re.TYPE:return new Re(e.props);case Oe.TYPE:return new Oe(e.props)}return null}}const zo=d.z.object({truthy:d.z.number().optional().default(1),falsy:d.z.number().optional().default(0)}),Ds=n=>({props:n,type:Te.TYPE,variant:"sink",valueType:"boolean"});class Te extends ys{static TYPE="boolean-numeric-converter-sink";static propsZ=zo;schema=Te.propsZ;transform(...e){return e.map(t=>t?this.props.truthy:this.props.falsy)}}const Jn=d.z.object({trueBound:i.H.bounds}),Ls=n=>({props:n,type:Ee.TYPE,variant:"source",valueType:"boolean"});class Ee extends ue{static TYPE="boolean-source";static propsZ=Jn;schema=Ee.propsZ;curr=null;shouldNotify(e){const t=i.H.contains(this.props.trueBound,e)!==this.curr;return this.curr=i.H.contains(this.props.trueBound,e),t}transform(e){return this.curr=i.H.contains(this.props.trueBound,e),this.curr}}const _s=d.z.object({});class Ce extends ms{static TYPE="mean";static propsZ=_s;schema=Ce.propsZ;transform(e){return Object.values(e).reduce((t,r)=>t+r,0)/Object.keys(e).length}}const Ao=n=>({props:n,type:Ce.TYPE,variant:"source",valueType:"boolean"}),Ys=d.z.object({trueVariant:i.wr.variantZ.optional().default("success")});class Pe extends ue{static TYPE="boolean-status";static propsZ=Ys;schema=Pe.propsZ;transform(e){return e.variant===this.props.trueVariant}}const Ho=n=>({props:n,type:Pe.TYPE,variant:"source",valueType:"boolean"}),er=d.z.object({precision:d.z.number().optional().default(2),prefix:d.z.string().optional().default(""),suffix:d.z.string().optional().default(""),notation:i.br.notationZ.optional().default("standard")});class ke extends ue{static TYPE="stringify-number";static propsZ=er;schema=ke.propsZ;transform(e){const{precision:t,prefix:r,suffix:s,notation:o}=this.props;return`${r}${i.br.stringifyNumber(e,t,o)}${s}`}}const zs=n=>({props:n,type:ke.TYPE,variant:"source",valueType:"string"}),tr=d.z.object({windowSize:d.z.number().optional().default(5)});class Et extends ue{static TYPE="rolling-average";static propsZ=_s;schema=tr;values=[];transform(e){return this.props.windowSize<2?e:this.values.reduce((t,r)=>t+r,0)/this.values.length}shouldNotify(e){return this.props.windowSize<2?!0:(this.values.length>this.props.windowSize&&(this.values=[]),this.values.push(e),this.values.length===this.props.windowSize)}}const As=n=>({props:n,type:Et.TYPE,variant:"source",valueType:"number"}),Hs=d.z.object({gradient:i.cr.gradientZ});class Re extends ue{static TYPE="color-gradient";static propsZ=Hs;schema=Re.propsZ;transform(e){return i.cr.fromGradient(this.props.gradient,e)}}const Is=n=>({props:n,type:Re.TYPE,variant:"source",valueType:"color"}),Zs=d.z.object({scale:i.C.transform});class Oe extends ue{static TYPE="scale-number";static propsZ=Zs;schema=Oe.propsZ;transform(e){const{offset:t,scale:r}=this.props.scale;return e*r+t}}const Ns=n=>({props:n,type:Oe.TYPE,variant:"source",valueType:"number"}),nr=d.z.enum(["average","decimate"]),Io=d.z.object({mode:nr,windowSize:d.z.number().optional().default(5)}),Zo=n=>({props:n,type:Fe.TYPE,variant:"source",valueType:"number"}),Bs=(n,e,t)=>{const r=e.length*t;for(let s=r;s<n.length;s+=t){const o=n.sub(s,s+1);o!==void 0&&e.write(o)}},No=(n,e,t)=>{const r=e.length*t;for(let s=r;s<n.length&&!(s+t>n.length);s+=t){const o=Math.min(s+t,n.length);let a=0,l=0;for(let u=s;u<o;u++){const c=n.at(u);c!==void 0&&typeof c=="number"&&(a+=c,l++)}l>0&&e.write(new i.v({data:[a/l],dataType:n.dataType}))}},Bo={decimate:Bs,average:No};class Fe{static TYPE="series-downsampler";_downsample=null;cache=new i.Wt;props;constructor(e){this.props=e}downsample(e){return this._downsample==null&&(e.series[0].sampleOffset!==0?this._downsample=Bs:this._downsample=Bo[this.props.mode]),this._downsample}transform(e){if(this.props.mode==="decimate"||this.props.windowSize<=1)return e;if(e.series.length===0)return this.cache;for(;this.cache.series.length>0&&!this.cache.series[0].key.startsWith(e.series[0].key);)this.cache.series.shift();return e.series.forEach((t,r)=>{let s=this.cache.series.at(r);if(s==null){const o=Math.ceil(t.capacity/this.props.windowSize);s=i.v.alloc({key:t.key+i.kt.create(),dataType:t.dataType,capacity:o,alignment:t.alignment,alignmentMultiple:BigInt(this.props.windowSize),sampleOffset:t.sampleOffset,timeRange:t.timeRange}),this.cache.push(s)}else if(!s.key.startsWith(t.key))throw new p.ht(`[SeriesDownsampler] - expected series with key ${t.key} to be in cache, but found ${s.key}`);this.downsample(e)(t,s,this.props.windowSize)}),this.cache}}const Uo=n=>({props:n,type:Fe.TYPE,variant:"source",valueType:"series"});class rr{factories;type="compound";constructor(e){this.factories=e}add(e){this.factories=[...this.factories.filter(t=>t.type!==e.type),e]}create(e,t){for(const r of this.factories){const s=r.create(e,t);if(s!=null)return s}return null}}const Us=n=>{const e=[new Ms,new Cs,new hs],t=new rr(e);return n!=null&&t.add(new ws(n)),t.add(new Gn(t)),t};let $s=class qs{factory;key;parent;constructor(e,t){this.factory=e,this.key=i.kt.create(),this.parent=t}child(e,t){const r=new rr([...this.factory.factories,...p.t.toArray(e)]);return r.add(new Gn(r)),new qs(r,t)}create(e,t){const r=this.factory.create(e,t);if(r==null)throw new p.ht(`Telemetry service could not find a source for type ${e.type}`);return r}};const nt="pluto-telem-context",Qt=n=>n.get(nt),Fs=(n,e)=>n.set(nt,e),Ks=(n,e,t)=>{const r=Qt(n);if(r!=null&&t!=null&&r.key===t?.parent?.key)return t;const s=r.child(e,r);return n.set(nt,s),s};class Ws{spec;wrapped;prevProv;constructor(e,t,r){this.wrapped=e,this.spec=r,this.prevProv=t}shouldUpdate(e,t){return this.prevProv.key!==e.key||!p.N.equal(this.spec,t)}}class Pr extends Ws{value(){return this.wrapped.value()}cleanup(){this.wrapped.cleanup?.()}onChange(e){return this.wrapped.onChange(e)}}class kr extends Ws{set(...e){this.wrapped.set(...e)}cleanup(){this.wrapped.cleanup?.()}}const q=(n,e,t,r)=>{const s=Qt(n);if(t instanceof Pr){if(!t.shouldUpdate(s,e))return t;t.cleanup?.()}return new Pr(s.create(e,r),s,e)},rt=(n,e,t,r)=>{const s=Qt(n);if(t instanceof kr){if(!t.shouldUpdate(s,e))return t;t.cleanup?.()}return new kr(s.create(e,r),s,e)},$o=d.z.object({props:p.Nm.nullable(),state:p.Sm.connectivity.connectionStateZ.nullable()}),sr={client:null};let Ct=class js extends p.Composite{static TYPE="synnax.Provider";static stateZ=$o;schema=js.stateZ;afterUpdate(e){if(e.wasSetPreviously(ir)||tn(e,sr),this.state.props==null){this.internal.client!=null&&(this.internal.client?.close(),this.internal.client=null),tn(e,this.internal);return}this.prevState.props!=null&&p.N.equal(this.state.props,this.prevState.props)&&this.internal.client!=null||(this.internal.client=new p.Sm(this.state.props),tn(e,this.internal))}};const ir="pluto-client-context",tn=(n,e)=>n.set(ir,e),He=n=>n.get(ir)?.client??null,Gs={[Ct.TYPE]:Ct},qo=Object.freeze(Object.defineProperty({__proto__:null,Provider:Ct,REGISTRY:Gs,ZERO_CONTEXT_VALUE:sr,use:He},Symbol.toStringTag,{value:"Module"})),Vs=(n,e)=>n.dataType.isVariable||n.dataType.equals(i.n.UINT8)?n:(e==null&&n.dataType.equals(i.n.TIMESTAMP)&&(e=BigInt(n.data[0])),n.convert(i.n.FLOAT32,e)),Fo=n=>n.isVariable||n.equals(i.n.UINT8)?n:i.n.FLOAT32,Xs=()=>({purgedSeries:0,purgedBytes:i.c$1.bytes(0)}),Qs={instrumentation:p.g.NOOP,staleEntryThreshold:i.i.seconds(20)};class Ko{data=[];props;constructor(e){this.props={...Qs,...e}}write(e){e.length!==0&&(e.series.forEach(t=>this.writeOne(Vs(t))),this.checkIntegrity(e))}dirtyRead(e){const t=this.data.filter(({data:a})=>a.timeRange.overlapsWith(e)).map(({data:a})=>a);if(t.length===0)return{series:new i.Wt([]),gaps:[e]};const r=t.map((a,l)=>l===0?i.O.ZERO:new i.O(t[l-1].timeRange.end,a.timeRange.start)).filter(a=>!a.isZero&&a.isValid),s=new i.O(e.start,t[0].timeRange.start),o=new i.O(t[t.length-1].timeRange.end,e.end);return s.isValid&&!s.isZero&&r.unshift(s),o.isValid&&!o.isZero&&r.push(o),{series:new i.Wt(t),gaps:r}}gc(){const{staleEntryThreshold:e}=this.props,t=Xs(),r=this.data.filter(s=>{const o=s.data.refCount>0||i.r.since(s.addedAt).lessThan(e);return o||(t.purgedBytes=t.purgedBytes.add(s.data.byteCapacity)),o});return t.purgedSeries=this.data.length-r.length,this.data=r,t}close(){this.data=[]}writeOne(e){const{instrumentation:{L:t}}=this.props;if(e.length===0)return;const r=i.H.buildInsertionPlan(this.data.map(u=>u.data.alignmentBounds),e.alignmentBounds);if(r===null)return t.debug("Found no viable insertion plan",{inserting:e.digest,cacheContents:this.data.map(u=>u.data.digest)});const{removeBefore:s,removeAfter:o,insertInto:a,deleteInBetween:l}=r;e=e.slice(s,e.data.length-o),e.length!==0&&this.data.splice(a,l,{data:e,addedAt:i.r.now()})}checkIntegrity(e){const{instrumentation:{L:t}}=this.props,r=this.data.map(o=>o.data.alignmentBounds);if(r.some((o,a)=>r.some((l,u)=>a===u?!1:i.H.overlapsWith(o,l))))throw t.debug("Cache is in an invalid state - bounds overlap!",()=>({write:e.series.map(o=>o.digest),cacheContents:this.data.map(o=>o.data.digest)})),new Error("Invalid state")}}const Wo=100,jo=1e6,Go=1e4,Vo=100,Xo=40;class Qo{props;counter=0;curr;avgRate=0;timeOfLastWrite;totalWrites=0;now=()=>i.r.now();constructor(e){this.props=e,this.curr=null,e.now!=null&&(this.now=e.now),this.timeOfLastWrite=this.now()}get length(){return this.curr?.length??0}get leadingBuffer(){return this.curr}write(e){const t=e.series.flatMap(r=>this._write(r));return{flushed:new i.Wt(t.flatMap(r=>r.flushed.series)),allocated:new i.Wt(t.flatMap(r=>r.allocated.series))}}allocate(e,t,r){this.counter++;const s=this.props.dataType.isVariable,o=this.props.dataType.equals(i.n.TIMESTAMP);return i.v.alloc({capacity:s?e*Xo:e,dataType:Fo(this.props.dataType),timeRange:r.range(i.r.MAX),sampleOffset:o?r.valueOf():0,glBufferUsage:"dynamic",alignment:t,key:`dynamic-${this.counter}`})}_write(e){const t=this.nextBufferSize(),r={flushed:new i.Wt([]),allocated:new i.Wt([])};if(this.curr==null)this.curr=this.allocate(t,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 u=this.now();this.curr.timeRange.end=u,r.flushed.push(this.curr),this.curr=this.allocate(t,e.alignment,u),r.allocated.push(this.curr)}const s=Vs(e,this.curr.sampleOffset),o=this.curr.write(s);if(o===e.length)return this.updateAvgRate(e),r;const a=this.now();this.curr.timeRange.end=a,r.flushed.push(this.curr),this.curr=this.allocate(t,e.alignment+BigInt(o),a),r.allocated.push(this.curr);const l=this._write(e.slice(o));return r.flushed.push(l.flushed),r.allocated.push(l.allocated),r}updateAvgRate(e){if(typeof this.props.dynamicBufferSize=="number")return;const t=e.length/this.now().span(this.timeOfLastWrite).seconds;this.totalWrites>0&&isFinite(t)&&t>0&&(this.avgRate=(this.avgRate*(this.totalWrites-1)+t)/this.totalWrites),this.totalWrites++,this.timeOfLastWrite=this.now()}nextBufferSize(){const{dynamicBufferSize:e}=this.props;if(typeof e=="number")return e;if(this.totalWrites<Vo)return Go;const t=i.or.roundToNearestMagnitude(this.avgRate*e.seconds);return Math.round(Math.max(Math.min(t,jo),Wo))}close(){this.curr=null}}class Jo{channel;closed=!1;ins;static;dynamic;constructor(e){this.channel=e.channel,this.ins=e.instrumentation??p.g.NOOP,this.static=new Ko(e),this.dynamic=new Qo({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}`),new i.Wt([]);const{flushed:t,allocated:r}=this.dynamic.write(e);return t.length>0&&this.static.write(t),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:new i.Wt([]),gaps:[e]}):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:i.c$1.bytes(0)}):this.static.gc()}close(){this.closed=!0,this.dynamic.close(),this.static.close()}}const ea=p.O$1.seconds(60);class ta{props;cache=new Map;gcInterval;constructor(e){this.props={dynamicBufferSize:ea,gcInterval:p.O$1.seconds(30),...Qs,...e},this.gcInterval=setInterval(()=>this.gc(),this.props.gcInterval.milliseconds)}async populateMissing(e){const{instrumentation:t,channelRetriever:r,dynamicBufferSize:s}=this.props,o=[];for(const l of e)this.cache.has(l)||o.push(l);if(o.length===0)return;(await r.retrieve(o)).forEach(l=>{if(this.cache.has(l.key))return;const u=new Jo({channel:l,dynamicBufferSize:s,instrumentation:t.child(`cache-${l.name}-${l.key}`)});this.cache.set(l.key,u)})}get(e){const t=this.cache.get(e);if(t!=null)return t;throw new p.ht(`cache entry for ${e} not found`)}gc(){const{instrumentation:{L:e}}=this.props;e.info("starting garbage collection");const t=Xs();this.cache.forEach(r=>{const s=r.gc();t.purgedSeries+=s.purgedSeries,t.purgedBytes=t.purgedBytes.add(s.purgedBytes)}),e.info("garbage collection complete",{purgedSeries:t.purgedSeries,purgedBytes:t.purgedBytes.toString()},!0)}close(){clearInterval(this.gcInterval),this.cache.forEach(e=>e.close()),this.cache.clear()}}class na{args;debouncedRead;mu=i.Sr.newMutex({requests:new Set,closed:!1});constructor(e){this.args={...e,instrumentation:e.instrumentation??p.g.NOOP,batchDebounce:e.batchDebounce??i.i.milliseconds(50),overlapThreshold:e.overlapThreshold??i.i.milliseconds(5)};const t=this.args.batchDebounce.milliseconds;this.debouncedRead=p.o(()=>void this.batchRead(),t)}async read(e,t){const{cache:r}=this.args;await r.populateMissing([t]);const s=r.get(t),{series:o,gaps:a}=s.read(e);if(a.length===0)return o;const{mu:l}=this;return await new Promise((u,c)=>{l.runExclusive(async()=>{l.closed||l.requests.add({channel:t,gaps:a,resolve:u,reject:c})}),this.debouncedRead()}),s.read(e).series}async batchRead(){const{readRemote:e,cache:t,overlapThreshold:r}=this.args,{mu:s}=this;await s.runExclusive(async()=>{const o=a=>s.requests.forEach(({resolve:l,reject:u})=>a==null?l():u(a));try{if(s.closed)return o();const a=[];s.requests.forEach(({channel:l,gaps:u})=>u.forEach(c=>{const h=a.find(f=>f.gap.equals(c,r));h==null?a.push({gap:c,channels:new Set([l])}):(h.channels.add(l),h.gap=i.O.max(h.gap,c))})),await Promise.all(a.map(async({gap:l,channels:u})=>{const c=await e(l,Array.from(u));u.forEach(h=>t.get(h).writeStatic(c.get(h)))})),o()}catch(a){o(a)}finally{s.requests.clear()}})}async close(){await this.mu.runExclusive(async()=>{this.mu.closed=!0})}}const ra=new Error("request for lock canceled");var sa=function(n,e,t,r){function s(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function l(h){try{c(r.next(h))}catch(f){a(f)}}function u(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?o(h.value):s(h.value).then(l,u)}c((r=r.apply(n,e||[])).next())})};class ia{constructor(e,t=ra){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,s)=>{const o={resolve:r,reject:s,weight:e,priority:t},a=Js(this._queue,l=>t<=l.priority);a===-1&&e<=this._value?this._dispatchItem(o):this._queue.splice(a+1,0,o)})}runExclusive(e){return sa(this,arguments,void 0,function*(t,r=1,s=0){const[o,a]=yield this.acquire(r,s);try{return yield t(o)}finally{a()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),oa(this._weightedWaiters[e-1],{resolve:r,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const r=this._weightedWaiters[t-1];if(!r)continue;const s=r.findIndex(o=>o.priority<=e);(s===-1?r:r.splice(0,s)).forEach(o=>o.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function oa(n,e){const t=Js(n,r=>e.priority<=r.priority);n.splice(t+1,0,e)}function Js(n,e){for(let t=n.length-1;t>=0;t--)if(e(n[t]))return t;return-1}var aa=function(n,e,t,r){function s(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function l(h){try{c(r.next(h))}catch(f){a(f)}}function u(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?o(h.value):s(h.value).then(l,u)}c((r=r.apply(n,e||[])).next())})};class la{constructor(e){this._semaphore=new ia(1,e)}acquire(){return aa(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class ca{props;mu=new la;listeners=new Map;streamerRunLoop=null;streamer=null;closed=!1;constructor(e){this.props={instrumentation:p.g.NOOP,...e,streamUpdateDelay:new i.i(e.streamUpdateDelay??i.i.seconds(5))}}async stream(e,t){const{cache:r,instrumentation:s}=this.props;return this.closed?()=>{}:(await r.populateMissing(t),await this.mu.runExclusive(async()=>{s.L.debug("adding stream handler",{keys:t}),this.listeners.set(e,{valid:!0,keys:new Set(t)});const o=new Map(t.map(a=>{const l=r.get(a);return[a,new i.Wt(p.t.toArray(l.leadingBuffer))]}));return e(o),await this.updateStreamer(),()=>this.removeStreamHandler(e)}))}removeStreamHandler(e){const{instrumentation:t}=this.props;this.mu.runExclusive(()=>{const r=this.listeners.get(e);r!=null&&(r.valid=!1)}),setTimeout(()=>{this.mu.runExclusive(async()=>{if(t.L.debug("removing stream handler"),this.listeners.delete(e))return await this.updateStreamer();t.L.warn("attempted to remove non-existent stream handler")})},this.props.streamUpdateDelay.milliseconds)}async updateStreamer(){if(this.closed)return;const{instrumentation:e}=this.props;try{const t=new Set;if(this.listeners.forEach(o=>o.keys.forEach(a=>t.add(a))),t.size===0){e.L.info("no keys to stream, closing streamer"),this.streamer?.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.streamer=null,e.L.info("streamer closed successfully");return}const r=Array.from(t);if(i.k.primitiveArrays(r,this.streamer?.keys??[])===i.k.EQUAL){e.L.debug("streamer keys unchanged",{keys:r});return}this.streamer==null&&(e.L.info("creating new streamer",{keys:r}),this.streamer=await this.props.openStreamer(r),this.streamerRunLoop=this.runStreamer(this.streamer)),e.L.debug("updating streamer",{prev:this.streamer.keys,next:r}),await this.streamer.update(r)}catch(t){throw e.L.error("failed to update streamer",{error:t}),t}}async runStreamer(e){const{cache:t,instrumentation:r}=this.props;try{for await(const s of e){const o=new Map;for(const a of s.keys){const l=s.get(a),c=t.get(a).writeDynamic(l);o.set(a,c)}o.size!==0&&this.listeners.forEach(({valid:a},l)=>a&&l(o))}}catch(s){throw r.L.error("streamer run loop failed",{error:s},!0),s}}async close(){const{instrumentation:e}=this.props;try{this.streamer?.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop}catch(t){e.L.error("failed to close streamer",{error:t})}this.closed=!0}}class ua{async retrieveChannel(){throw new p._t("NoopClient does not support retrieving channels")}async read(){return new i.Wt([])}async stream(){return async()=>{}}async close(){}}class ha{ins;cache;reader;streamer;channelRetriever;constructor({instrumentation:e,core:t}){this.ins=e,this.channelRetriever=t.channels.createDebouncedBatchRetriever(10),this.cache=new ta({channelRetriever:this.channelRetriever,instrumentation:this.ins.child("cache")}),this.reader=new na({cache:this.cache,readRemote:t.read.bind(t),instrumentation:this.ins.child("reader")}),this.streamer=new ca({cache:this.cache,openStreamer:async r=>p.fw.HardenedStreamer.open(t.openStreamer.bind(t),r),instrumentation:this.ins.child("streamer")})}async retrieveChannel(e){const t=await this.channelRetriever.retrieve([e]);if(t.length===0)throw new p.Ue(`channel ${e} not found`);return t[0]}async read(e,t){return await this.reader.read(e,t)}async stream(e,t){return await this.streamer.stream(e,t)}async close(){this.ins.L.info("closing client"),await this.streamer.close(),await this.reader.close(),this.cache.close()}}const or=d.z.object({});class Me extends p.Composite{static TYPE="telem.Provider";static stateZ=or;schema=Me.stateZ;prevCore=null;client=null;afterUpdate(e){const{internal:t}=this,r=He(e),s=p.useErrorHandler(e);if(t.instrumentation=p.useInstrumentation(e,"telem").child("provider"),!(r!==this.prevCore||!e.wasSetPreviously(nt)))return;this.prevCore=r,this.client!=null&&s(async()=>{if(this.client==null)throw new Error("no client to close");await this.client.close()},"failed to close client"),this.client=r==null?new ua:new ha({core:r,instrumentation:t.instrumentation});const a=Us(this.client),l=new $s(a);Fs(e,l)}}const ei={[Me.TYPE]:Me},da=Object.freeze(Object.defineProperty({__proto__:null,AbstractSink:Xt,AbstractSource:B,Base:Vt,BaseProvider:Me,BooleanStatus:Pe,CONTEXT_KEY:nt,ChannelData:vt,ColorGradient:Re,CompoundTelemFactory:rr,Context:$s,FixedColorSource:Tt,FixedNumber:wt,FixedString:xt,IterativeSeries:St,Mean:Ce,MultiSourceTransformer:ms,NoopFactory:hs,PipelineFactory:Gn,REGISTRY:ei,RemoteFactory:ws,RollingAverage:Et,ScaleNumber:Oe,SeriesDownsampler:Fe,SetPoint:Te,SinkPipeline:mt,SourcePipeline:gt,StaticFactory:Cs,StreamChannelData:bt,StreamChannelValue:yt,StringifyNumber:ke,TransformerFactory:Ms,UnarySinkTransformer:ys,UnarySourceTransformer:ue,WithinBounds:Ee,booleanSinkSpecZ:Gt,booleanSinkTransformerSpecZ:Co,booleanSourceSpecZ:$n,booleanSourceTransformerSpecZ:Po,booleanStatus:Ho,booleanStatusProps:Ys,channelData:xs,colorGradient:Is,colorGradientProps:Hs,colorSourceSpecZ:qn,connectionZ:Wn,createFactory:Us,downsampleMode:Zo,downsampleModeProps:Io,downsampleModeZ:nr,fixedArray:Mo,fixedColor:Yo,fixedColorSourcePropsZ:Os,fixedNumber:Lo,fixedNumberPropsZ:ks,fixedSeriesPropsZ:Qn,fixedString:_o,fixedStringPropsZ:Rs,iterativeArray:Do,iterativeSeriesPropsZ:Ps,mean:Ao,noopBooleanSinkSpec:Kt,noopBooleanSourceSpec:Bn,noopColorSourceSpec:Wt,noopNumericSinkSpec:as,noopNumericSourceSpec:ls,noopSeriesSourceSpec:us,noopStatusSourceSpec:Un,noopStringSourceSpec:cs,numberSinkSpecZ:gs,numberSourceSpecZ:ps,providerStateZ:or,rollingAverage:As,rollingAverageProps:tr,scaleNumber:Ns,scaleNumberProps:Zs,seriesDownsampler:Uo,seriesSourceSpecZ:pt,setContext:Fs,setpoint:Ds,sinkPipeline:bs,sinkPipelinePropsZ:Vn,sinkSpecZ:jt,sinkTransformerSpecZ:fs,sourcePipeline:vs,sourcePipelinePropsZ:jn,sourceSpecZ:re,sourceTransformerSpecZ:ds,specZ:tt,statusSourceSpecZ:Fn,streamChannelData:Ts,streamChannelValue:Es,streamChannelValuePropsZ:Xn,stringSourceSpecZ:Kn,stringifyNumber:zs,stringifyNumberProps:er,useChildContext:Ks,useContext:Qt,useSink:rt,useSource:q,withinBounds:Ls,withinBoundsProps:Jn},Symbol.toStringTag,{value:"Module"})),fa=d.object({request:d.string(),bounds:d.record(d.string(),i.H.bounds)}),ti=d.object({request:d.string(),response:fa});class Pt extends p.Leaf{static TYPE="Bounds";schema=ti;afterUpdate(e){this.state.request!==this.prevState.request&&this.setState(t=>({...t,response:{request:t.request,bounds:this.internal.getBounds()}}))}render(e){this.internal.getBounds=e.getBounds}}const ni=d.z.object({key:d.z.string(),size:d.z.number(),order:d.z.number(),loc:i.K$1.outer});d.z.record(d.z.string(),ni);const ie=(n,e)=>Object.values(e).filter(({loc:t})=>t===n).sort((t,r)=>r.order-t.order),pa=(n,e,t)=>{const r=e[n];if(r==null)return i.K.ZERO;const s=i.K$1.construct(r.loc),o=ie(s,e),a=i.K$1.construct(i.p.swap(i.K$1.direction(s))),l=ie(a,e),u=o.findIndex(({key:f})=>f===n),c=o.slice(0,u).reduce((f,{size:g})=>f+g,0),h=l.reduce((f,{size:g})=>f+g,0);switch(s){case"left":return i.K.translate(i.Ho.topLeft(t),[c,h]);case"right":return i.K.translate(i.Ho.topRight(t),[c-r.size,h]);case"top":return i.K.translate(i.Ho.topLeft(t),[h,c]);default:return i.K.translate(i.Ho.bottomLeft(t),[h,-c-r.size])}},ga=(n,e)=>{const t=ie("left",n),r=ie("right",n),s=ie("top",n),o=ie("bottom",n),a=t.reduce((h,{size:f})=>h+f,0),l=r.reduce((h,{size:f})=>h+f,0),u=s.reduce((h,{size:f})=>h+f,0),c=o.reduce((h,{size:f})=>h+f,0);return i.Ho.construct(i.K.translate(i.Ho.topLeft(e),{x:a,y:u}),i.Ho.width(e)-a-l,i.Ho.height(e)-u-c)};function ft(n,e){return n==null||e==null?NaN:n<e?-1:n>e?1:n>=e?0:NaN}function ma(n,e){return n==null||e==null?NaN:e<n?-1:e>n?1:e>=n?0:NaN}function ar(n){let e,t,r;n.length!==2?(e=ft,t=(l,u)=>ft(n(l),u),r=(l,u)=>n(l)-u):(e=n===ft||n===ma?n:ya,t=n,r=n);function s(l,u,c=0,h=l.length){if(c<h){if(e(u,u)!==0)return h;do{const f=c+h>>>1;t(l[f],u)<0?c=f+1:h=f}while(c<h)}return c}function o(l,u,c=0,h=l.length){if(c<h){if(e(u,u)!==0)return h;do{const f=c+h>>>1;t(l[f],u)<=0?c=f+1:h=f}while(c<h)}return c}function a(l,u,c=0,h=l.length){const f=s(l,u,c,h-1);return f>c&&r(l[f-1],u)>-r(l[f],u)?f-1:f}return{left:s,center:a,right:o}}function ya(){return 0}function va(n){return n===null?NaN:+n}const ba=ar(ft),Sa=ba.right;ar(va).center;const wa=Math.sqrt(50),xa=Math.sqrt(10),Ta=Math.sqrt(2);function kt(n,e,t){const r=(e-n)/Math.max(0,t),s=Math.floor(Math.log10(r)),o=r/Math.pow(10,s),a=o>=wa?10:o>=xa?5:o>=Ta?2:1;let l,u,c;return s<0?(c=Math.pow(10,-s)/a,l=Math.round(n*c),u=Math.round(e*c),l/c<n&&++l,u/c>e&&--u,c=-c):(c=Math.pow(10,s)*a,l=Math.round(n/c),u=Math.round(e/c),l*c<n&&++l,u*c>e&&--u),u<l&&.5<=t&&t<2?kt(n,e,t*2):[l,u,c]}function Ea(n,e,t){if(e=+e,n=+n,t=+t,!(t>0))return[];if(n===e)return[n];const r=e<n,[s,o,a]=r?kt(e,n,t):kt(n,e,t);if(!(o>=s))return[];const l=o-s+1,u=new Array(l);if(r)if(a<0)for(let c=0;c<l;++c)u[c]=(o-c)/-a;else for(let c=0;c<l;++c)u[c]=(o-c)*a;else if(a<0)for(let c=0;c<l;++c)u[c]=(s+c)/-a;else for(let c=0;c<l;++c)u[c]=(s+c)*a;return u}function Sn(n,e,t){return e=+e,n=+n,t=+t,kt(n,e,t)[2]}function wn(n,e,t){e=+e,n=+n,t=+t;const r=e<n,s=r?Sn(e,n,t):Sn(n,e,t);return(r?-1:1)*(s<0?1/-s:s)}function ri(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function lr(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function si(n,e){var t=Object.create(n.prototype);for(var r in e)t[r]=e[r];return t}function st(){}var Ke=.7,Rt=1/Ke,we="\\s*([+-]?\\d+)\\s*",We="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",W="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ca=/^#([0-9a-f]{3,8})$/,Pa=new RegExp(`^rgb\\(${we},${we},${we}\\)$`),ka=new RegExp(`^rgb\\(${W},${W},${W}\\)$`),Ra=new RegExp(`^rgba\\(${we},${we},${we},${We}\\)$`),Oa=new RegExp(`^rgba\\(${W},${W},${W},${We}\\)$`),Ma=new RegExp(`^hsl\\(${We},${W},${W}\\)$`),Da=new RegExp(`^hsla\\(${We},${W},${W},${We}\\)$`),Rr={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};lr(st,De,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:Or,formatHex:Or,formatHex8:La,formatHsl:_a,formatRgb:Mr,toString:Mr});function Or(){return this.rgb().formatHex()}function La(){return this.rgb().formatHex8()}function _a(){return ii(this).formatHsl()}function Mr(){return this.rgb().formatRgb()}function De(n){var e,t;return n=(n+"").trim().toLowerCase(),(e=Ca.exec(n))?(t=e[1].length,e=parseInt(e[1],16),t===6?Dr(e):t===3?new I(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ct(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ct(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=Pa.exec(n))?new I(e[1],e[2],e[3],1):(e=ka.exec(n))?new I(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Ra.exec(n))?ct(e[1],e[2],e[3],e[4]):(e=Oa.exec(n))?ct(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Ma.exec(n))?Yr(e[1],e[2]/100,e[3]/100,1):(e=Da.exec(n))?Yr(e[1],e[2]/100,e[3]/100,e[4]):Rr.hasOwnProperty(n)?Dr(Rr[n]):n==="transparent"?new I(NaN,NaN,NaN,0):null}function Dr(n){return new I(n>>16&255,n>>8&255,n&255,1)}function ct(n,e,t,r){return r<=0&&(n=e=t=NaN),new I(n,e,t,r)}function Ya(n){return n instanceof st||(n=De(n)),n?(n=n.rgb(),new I(n.r,n.g,n.b,n.opacity)):new I}function xn(n,e,t,r){return arguments.length===1?Ya(n):new I(n,e,t,r??1)}function I(n,e,t,r){this.r=+n,this.g=+e,this.b=+t,this.opacity=+r}lr(I,xn,si(st,{brighter(n){return n=n==null?Rt:Math.pow(Rt,n),new I(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Ke:Math.pow(Ke,n),new I(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new I(ae(this.r),ae(this.g),ae(this.b),Ot(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:Lr,formatHex:Lr,formatHex8:za,formatRgb:_r,toString:_r}));function Lr(){return`#${oe(this.r)}${oe(this.g)}${oe(this.b)}`}function za(){return`#${oe(this.r)}${oe(this.g)}${oe(this.b)}${oe((isNaN(this.opacity)?1:this.opacity)*255)}`}function _r(){const n=Ot(this.opacity);return`${n===1?"rgb(":"rgba("}${ae(this.r)}, ${ae(this.g)}, ${ae(this.b)}${n===1?")":`, ${n})`}`}function Ot(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function ae(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function oe(n){return n=ae(n),(n<16?"0":"")+n.toString(16)}function Yr(n,e,t,r){return r<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new K(n,e,t,r)}function ii(n){if(n instanceof K)return new K(n.h,n.s,n.l,n.opacity);if(n instanceof st||(n=De(n)),!n)return new K;if(n instanceof K)return n;n=n.rgb();var e=n.r/255,t=n.g/255,r=n.b/255,s=Math.min(e,t,r),o=Math.max(e,t,r),a=NaN,l=o-s,u=(o+s)/2;return l?(e===o?a=(t-r)/l+(t<r)*6:t===o?a=(r-e)/l+2:a=(e-t)/l+4,l/=u<.5?o+s:2-o-s,a*=60):l=u>0&&u<1?0:a,new K(a,l,u,n.opacity)}function Aa(n,e,t,r){return arguments.length===1?ii(n):new K(n,e,t,r??1)}function K(n,e,t,r){this.h=+n,this.s=+e,this.l=+t,this.opacity=+r}lr(K,Aa,si(st,{brighter(n){return n=n==null?Rt:Math.pow(Rt,n),new K(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Ke:Math.pow(Ke,n),new K(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,r=t+(t<.5?t:1-t)*e,s=2*t-r;return new I(nn(n>=240?n-240:n+120,s,r),nn(n,s,r),nn(n<120?n+240:n-120,s,r),this.opacity)},clamp(){return new K(zr(this.h),ut(this.s),ut(this.l),Ot(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 n=Ot(this.opacity);return`${n===1?"hsl(":"hsla("}${zr(this.h)}, ${ut(this.s)*100}%, ${ut(this.l)*100}%${n===1?")":`, ${n})`}`}}));function zr(n){return n=(n||0)%360,n<0?n+360:n}function ut(n){return Math.max(0,Math.min(1,n||0))}function nn(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const cr=n=>()=>n;function Ha(n,e){return function(t){return n+t*e}}function Ia(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(r){return Math.pow(n+r*e,t)}}function Za(n){return(n=+n)==1?oi:function(e,t){return t-e?Ia(e,t,n):cr(isNaN(e)?t:e)}}function oi(n,e){var t=e-n;return t?Ha(n,t):cr(isNaN(n)?e:n)}const Tn=function n(e){var t=Za(e);function r(s,o){var a=t((s=xn(s)).r,(o=xn(o)).r),l=t(s.g,o.g),u=t(s.b,o.b),c=oi(s.opacity,o.opacity);return function(h){return s.r=a(h),s.g=l(h),s.b=u(h),s.opacity=c(h),s+""}}return r.gamma=n,r}(1);function Na(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,r=e.slice(),s;return function(o){for(s=0;s<t;++s)r[s]=n[s]*(1-o)+e[s]*o;return r}}function Ba(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ua(n,e){var t=e?e.length:0,r=n?Math.min(t,n.length):0,s=new Array(r),o=new Array(t),a;for(a=0;a<r;++a)s[a]=Jt(n[a],e[a]);for(;a<t;++a)o[a]=e[a];return function(l){for(a=0;a<r;++a)o[a]=s[a](l);return o}}function $a(n,e){var t=new Date;return n=+n,e=+e,function(r){return t.setTime(n*(1-r)+e*r),t}}function je(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}function qa(n,e){var t={},r={},s;(n===null||typeof n!="object")&&(n={}),(e===null||typeof e!="object")&&(e={});for(s in e)s in n?t[s]=Jt(n[s],e[s]):r[s]=e[s];return function(o){for(s in t)r[s]=t[s](o);return r}}var En=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,rn=new RegExp(En.source,"g");function Fa(n){return function(){return n}}function Ka(n){return function(e){return n(e)+""}}function ai(n,e){var t=En.lastIndex=rn.lastIndex=0,r,s,o,a=-1,l=[],u=[];for(n=n+"",e=e+"";(r=En.exec(n))&&(s=rn.exec(e));)(o=s.index)>t&&(o=e.slice(t,o),l[a]?l[a]+=o:l[++a]=o),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,u.push({i:a,x:je(r,s)})),t=rn.lastIndex;return t<e.length&&(o=e.slice(t),l[a]?l[a]+=o:l[++a]=o),l.length<2?u[0]?Ka(u[0].x):Fa(e):(e=u.length,function(c){for(var h=0,f;h<e;++h)l[(f=u[h]).i]=f.x(c);return l.join("")})}function Jt(n,e){var t=typeof e,r;return e==null||t==="boolean"?cr(e):(t==="number"?je:t==="string"?(r=De(e))?(e=r,Tn):ai:e instanceof De?Tn:e instanceof Date?$a:Ba(e)?Na:Array.isArray(e)?Ua:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?qa:je)(n,e)}function Wa(n,e){return n=+n,e=+e,function(t){return Math.round(n*(1-t)+e*t)}}function ja(n){return function(){return n}}function Ga(n){return+n}var Ar=[0,1];function be(n){return n}function Cn(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:ja(isNaN(e)?NaN:.5)}function Va(n,e){var t;return n>e&&(t=n,n=e,e=t),function(r){return Math.max(n,Math.min(e,r))}}function Xa(n,e,t){var r=n[0],s=n[1],o=e[0],a=e[1];return s<r?(r=Cn(s,r),o=t(a,o)):(r=Cn(r,s),o=t(o,a)),function(l){return o(r(l))}}function Qa(n,e,t){var r=Math.min(n.length,e.length)-1,s=new Array(r),o=new Array(r),a=-1;for(n[r]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++a<r;)s[a]=Cn(n[a],n[a+1]),o[a]=t(e[a],e[a+1]);return function(l){var u=Sa(n,l,1,r)-1;return o[u](s[u](l))}}function li(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Ja(){var n=Ar,e=Ar,t=Jt,r,s,o,a=be,l,u,c;function h(){var g=Math.min(n.length,e.length);return a!==be&&(a=Va(n[0],n[g-1])),l=g>2?Qa:Xa,u=c=null,f}function f(g){return g==null||isNaN(g=+g)?o:(u||(u=l(n.map(r),e,t)))(r(a(g)))}return f.invert=function(g){return a(s((c||(c=l(e,n.map(r),je)))(g)))},f.domain=function(g){return arguments.length?(n=Array.from(g,Ga),h()):n.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),h()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),t=Wa,h()},f.clamp=function(g){return arguments.length?(a=g?!0:be,h()):a!==be},f.interpolate=function(g){return arguments.length?(t=g,h()):t},f.unknown=function(g){return arguments.length?(o=g,f):o},function(g,y){return r=g,s=y,h()}}function ci(){return Ja()(be,be)}function el(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function Mt(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,r=n.slice(0,t);return[r.length>1?r[0]+r.slice(2):r,+n.slice(t+1)]}function Le(n){return n=Mt(Math.abs(n)),n?n[1]:NaN}function tl(n,e){return function(t,r){for(var s=t.length,o=[],a=0,l=n[0],u=0;s>0&&l>0&&(u+l+1>r&&(l=Math.max(1,r-u)),o.push(t.substring(s-=l,s+l)),!((u+=l+1)>r));)l=n[a=(a+1)%n.length];return o.reverse().join(e)}}function nl(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var rl=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Dt(n){if(!(e=rl.exec(n)))throw new Error("invalid format: "+n);var e;return new ur({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]})}Dt.prototype=ur.prototype;function ur(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}ur.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 sl(n){e:for(var e=n.length,t=1,r=-1,s;t<e;++t)switch(n[t]){case".":r=s=t;break;case"0":r===0&&(r=t),s=t;break;default:if(!+n[t])break e;r>0&&(r=0);break}return r>0?n.slice(0,r)+n.slice(s+1):n}var ui;function il(n,e){var t=Mt(n,e);if(!t)return n+"";var r=t[0],s=t[1],o=s-(ui=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Mt(n,Math.max(0,e+o-1))[0]}function Hr(n,e){var t=Mt(n,e);if(!t)return n+"";var r=t[0],s=t[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 Ir={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:el,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>Hr(n*100,e),r:Hr,s:il,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function Zr(n){return n}var Nr=Array.prototype.map,Br=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ol(n){var e=n.grouping===void 0||n.thousands===void 0?Zr:tl(Nr.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",r=n.currency===void 0?"":n.currency[1]+"",s=n.decimal===void 0?".":n.decimal+"",o=n.numerals===void 0?Zr:nl(Nr.call(n.numerals,String)),a=n.percent===void 0?"%":n.percent+"",l=n.minus===void 0?"−":n.minus+"",u=n.nan===void 0?"NaN":n.nan+"";function c(f){f=Dt(f);var g=f.fill,y=f.align,w=f.sign,b=f.symbol,S=f.zero,C=f.width,O=f.comma,P=f.precision,D=f.trim,_=f.type;_==="n"?(O=!0,_="g"):Ir[_]||(P===void 0&&(P=12),D=!0,_="g"),(S||g==="0"&&y==="=")&&(S=!0,g="0",y="=");var x=b==="$"?t:b==="#"&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",L=b==="$"?r:/[%p]/.test(_)?a:"",ee=Ir[_],Ze=/[defgprs%]/.test(_);P=P===void 0?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,P)):Math.max(0,Math.min(20,P));function pe(E){var j=x,A=L,te,lt,ge;if(_==="c")A=ee(E)+A,E="";else{E=+E;var me=E<0||1/E<0;if(E=isNaN(E)?u:ee(Math.abs(E),P),D&&(E=sl(E)),me&&+E==0&&w!=="+"&&(me=!1),j=(me?w==="("?w:l:w==="-"||w==="("?"":w)+j,A=(_==="s"?Br[8+ui/3]:"")+A+(me&&w==="("?")":""),Ze){for(te=-1,lt=E.length;++te<lt;)if(ge=E.charCodeAt(te),48>ge||ge>57){A=(ge===46?s+E.slice(te+1):E.slice(te))+A,E=E.slice(0,te);break}}}O&&!S&&(E=e(E,1/0));var ye=j.length+E.length+A.length,F=ye<C?new Array(C-ye+1).join(g):"";switch(O&&S&&(E=e(F+E,F.length?C-A.length:1/0),F=""),y){case"<":E=j+E+A+F;break;case"=":E=j+F+E+A;break;case"^":E=F.slice(0,ye=F.length>>1)+j+E+A+F.slice(ye);break;default:E=F+j+E+A;break}return o(E)}return pe.toString=function(){return f+""},pe}function h(f,g){var y=c((f=Dt(f),f.type="f",f)),w=Math.max(-8,Math.min(8,Math.floor(Le(g)/3)))*3,b=Math.pow(10,-w),S=Br[8+w/3];return function(C){return y(b*C)+S}}return{format:c,formatPrefix:h}}var ht,hi,di;al({thousands:",",grouping:[3],currency:["$",""]});function al(n){return ht=ol(n),hi=ht.format,di=ht.formatPrefix,ht}function ll(n){return Math.max(0,-Le(Math.abs(n)))}function cl(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Le(e)/3)))*3-Le(Math.abs(n)))}function ul(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,Le(e)-Le(n))+1}function hl(n,e,t,r){var s=wn(n,e,t),o;switch(r=Dt(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(n),Math.abs(e));return r.precision==null&&!isNaN(o=cl(s,a))&&(r.precision=o),di(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=ul(s,Math.max(Math.abs(n),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=ll(s))&&(r.precision=o-(r.type==="%")*2);break}}return hi(r)}function dl(n){var e=n.domain;return n.ticks=function(t){var r=e();return Ea(r[0],r[r.length-1],t??10)},n.tickFormat=function(t,r){var s=e();return hl(s[0],s[s.length-1],t??10,r)},n.nice=function(t){t==null&&(t=10);var r=e(),s=0,o=r.length-1,a=r[s],l=r[o],u,c,h=10;for(l<a&&(c=a,a=l,l=c,c=s,s=o,o=c);h-- >0;){if(c=Sn(a,l,t),c===u)return r[s]=a,r[o]=l,e(r);if(c>0)a=Math.floor(a/c)*c,l=Math.ceil(l/c)*c;else if(c<0)a=Math.ceil(a*c)/c,l=Math.floor(l*c)/c;else break;u=c}return n},n}function fi(){var n=ci();return n.copy=function(){return li(n,fi())},ri.apply(n,arguments),dl(n)}function fl(n,e){n=n.slice();var t=0,r=n.length-1,s=n[t],o=n[r],a;return o<s&&(a=t,t=r,r=a,a=s,s=o,o=a),n[t]=e.floor(s),n[r]=e.ceil(o),n}const sn=new Date,on=new Date;function Y(n,e,t,r){function s(o){return n(o=arguments.length===0?new Date:new Date(+o)),o}return s.floor=o=>(n(o=new Date(+o)),o),s.ceil=o=>(n(o=new Date(o-1)),e(o,1),n(o),o),s.round=o=>{const a=s(o),l=s.ceil(o);return o-a<l-o?a:l},s.offset=(o,a)=>(e(o=new Date(+o),a==null?1:Math.floor(a)),o),s.range=(o,a,l)=>{const u=[];if(o=s.ceil(o),l=l==null?1:Math.floor(l),!(o<a)||!(l>0))return u;let c;do u.push(c=new Date(+o)),e(o,l),n(o);while(c<o&&o<a);return u},s.filter=o=>Y(a=>{if(a>=a)for(;n(a),!o(a);)a.setTime(a-1)},(a,l)=>{if(a>=a)if(l<0)for(;++l<=0;)for(;e(a,-1),!o(a););else for(;--l>=0;)for(;e(a,1),!o(a););}),t&&(s.count=(o,a)=>(sn.setTime(+o),on.setTime(+a),n(sn),n(on),Math.floor(t(sn,on))),s.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?s.filter(r?a=>r(a)%o===0:a=>s.count(0,a)%o===0):s)),s}const Lt=Y(()=>{},(n,e)=>{n.setTime(+n+e)},(n,e)=>e-n);Lt.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?Y(e=>{e.setTime(Math.floor(e/n)*n)},(e,t)=>{e.setTime(+e+t*n)},(e,t)=>(t-e)/n):Lt);Lt.range;const G=1e3,U=G*60,V=U*60,Q=V*24,hr=Q*7,Ur=Q*30,an=Q*365,Se=Y(n=>{n.setTime(n-n.getMilliseconds())},(n,e)=>{n.setTime(+n+e*G)},(n,e)=>(e-n)/G,n=>n.getUTCSeconds());Se.range;const dr=Y(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*G)},(n,e)=>{n.setTime(+n+e*U)},(n,e)=>(e-n)/U,n=>n.getMinutes());dr.range;const pl=Y(n=>{n.setUTCSeconds(0,0)},(n,e)=>{n.setTime(+n+e*U)},(n,e)=>(e-n)/U,n=>n.getUTCMinutes());pl.range;const fr=Y(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*G-n.getMinutes()*U)},(n,e)=>{n.setTime(+n+e*V)},(n,e)=>(e-n)/V,n=>n.getHours());fr.range;const gl=Y(n=>{n.setUTCMinutes(0,0,0)},(n,e)=>{n.setTime(+n+e*V)},(n,e)=>(e-n)/V,n=>n.getUTCHours());gl.range;const it=Y(n=>n.setHours(0,0,0,0),(n,e)=>n.setDate(n.getDate()+e),(n,e)=>(e-n-(e.getTimezoneOffset()-n.getTimezoneOffset())*U)/Q,n=>n.getDate()-1);it.range;const pr=Y(n=>{n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCDate(n.getUTCDate()+e)},(n,e)=>(e-n)/Q,n=>n.getUTCDate()-1);pr.range;const ml=Y(n=>{n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCDate(n.getUTCDate()+e)},(n,e)=>(e-n)/Q,n=>Math.floor(n/Q));ml.range;function he(n){return Y(e=>{e.setDate(e.getDate()-(e.getDay()+7-n)%7),e.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*U)/hr)}const en=he(0),_t=he(1),yl=he(2),vl=he(3),_e=he(4),bl=he(5),Sl=he(6);en.range;_t.range;yl.range;vl.range;_e.range;bl.range;Sl.range;function de(n){return Y(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-n)%7),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/hr)}const pi=de(0),Yt=de(1),wl=de(2),xl=de(3),Ye=de(4),Tl=de(5),El=de(6);pi.range;Yt.range;wl.range;xl.range;Ye.range;Tl.range;El.range;const gr=Y(n=>{n.setDate(1),n.setHours(0,0,0,0)},(n,e)=>{n.setMonth(n.getMonth()+e)},(n,e)=>e.getMonth()-n.getMonth()+(e.getFullYear()-n.getFullYear())*12,n=>n.getMonth());gr.range;const Cl=Y(n=>{n.setUTCDate(1),n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCMonth(n.getUTCMonth()+e)},(n,e)=>e.getUTCMonth()-n.getUTCMonth()+(e.getUTCFullYear()-n.getUTCFullYear())*12,n=>n.getUTCMonth());Cl.range;const J=Y(n=>{n.setMonth(0,1),n.setHours(0,0,0,0)},(n,e)=>{n.setFullYear(n.getFullYear()+e)},(n,e)=>e.getFullYear()-n.getFullYear(),n=>n.getFullYear());J.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:Y(e=>{e.setFullYear(Math.floor(e.getFullYear()/n)*n),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t*n)});J.range;const le=Y(n=>{n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCFullYear(n.getUTCFullYear()+e)},(n,e)=>e.getUTCFullYear()-n.getUTCFullYear(),n=>n.getUTCFullYear());le.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:Y(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/n)*n),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t*n)});le.range;function Pl(n,e,t,r,s,o){const a=[[Se,1,G],[Se,5,5*G],[Se,15,15*G],[Se,30,30*G],[o,1,U],[o,5,5*U],[o,15,15*U],[o,30,30*U],[s,1,V],[s,3,3*V],[s,6,6*V],[s,12,12*V],[r,1,Q],[r,2,2*Q],[t,1,hr],[e,1,Ur],[e,3,3*Ur],[n,1,an]];function l(c,h,f){const g=h<c;g&&([c,h]=[h,c]);const y=f&&typeof f.range=="function"?f:u(c,h,f),w=y?y.range(c,+h+1):[];return g?w.reverse():w}function u(c,h,f){const g=Math.abs(h-c)/f,y=ar(([,,S])=>S).right(a,g);if(y===a.length)return n.every(wn(c/an,h/an,f));if(y===0)return Lt.every(Math.max(wn(c,h,f),1));const[w,b]=a[g/a[y-1][2]<a[y][2]/g?y-1:y];return w.every(b)}return[l,u]}const[kl,Rl]=Pl(J,gr,en,it,fr,dr);function ln(n){if(0<=n.y&&n.y<100){var e=new Date(-1,n.m,n.d,n.H,n.M,n.S,n.L);return e.setFullYear(n.y),e}return new Date(n.y,n.m,n.d,n.H,n.M,n.S,n.L)}function cn(n){if(0<=n.y&&n.y<100){var e=new Date(Date.UTC(-1,n.m,n.d,n.H,n.M,n.S,n.L));return e.setUTCFullYear(n.y),e}return new Date(Date.UTC(n.y,n.m,n.d,n.H,n.M,n.S,n.L))}function Ne(n,e,t){return{y:n,m:e,d:t,H:0,M:0,S:0,L:0}}function Ol(n){var e=n.dateTime,t=n.date,r=n.time,s=n.periods,o=n.days,a=n.shortDays,l=n.months,u=n.shortMonths,c=Be(s),h=Ue(s),f=Be(o),g=Ue(o),y=Be(a),w=Ue(a),b=Be(l),S=Ue(l),C=Be(u),O=Ue(u),P={a:me,A:ye,b:F,B:ho,c:null,d:jr,e:jr,f:Ql,g:lc,G:uc,H:Gl,I:Vl,j:Xl,L:gi,m:Jl,M:ec,p:fo,q:po,Q:Xr,s:Qr,S:tc,u:nc,U:rc,V:sc,w:ic,W:oc,x:null,X:null,y:ac,Y:cc,Z:hc,"%":Vr},D={a:go,A:mo,b:yo,B:vo,c:null,d:Gr,e:Gr,f:gc,g:Cc,G:kc,H:dc,I:fc,j:pc,L:yi,m:mc,M:yc,p:bo,q:So,Q:Xr,s:Qr,S:vc,u:bc,U:Sc,V:wc,w:xc,W:Tc,x:null,X:null,y:Ec,Y:Pc,Z:Rc,"%":Vr},_={a:pe,A:E,b:j,B:A,c:te,d:Kr,e:Kr,f:Fl,g:Fr,G:qr,H:Wr,I:Wr,j:Bl,L:ql,m:Nl,M:Ul,p:Ze,q:Zl,Q:Wl,s:jl,S:$l,u:Yl,U:zl,V:Al,w:_l,W:Hl,x:lt,X:ge,y:Fr,Y:qr,Z:Il,"%":Kl};P.x=x(t,P),P.X=x(r,P),P.c=x(e,P),D.x=x(t,D),D.X=x(r,D),D.c=x(e,D);function x(v,T){return function(k){var m=[],H=-1,M=0,Z=v.length,N,se,Cr;for(k instanceof Date||(k=new Date(+k));++H<Z;)v.charCodeAt(H)===37&&(m.push(v.slice(M,H)),(se=$r[N=v.charAt(++H)])!=null?N=v.charAt(++H):se=N==="e"?" ":"0",(Cr=T[N])&&(N=Cr(k,se)),m.push(N),M=H+1);return m.push(v.slice(M,H)),m.join("")}}function L(v,T){return function(k){var m=Ne(1900,void 0,1),H=ee(m,v,k+="",0),M,Z;if(H!=k.length)return null;if("Q"in m)return new Date(m.Q);if("s"in m)return new Date(m.s*1e3+("L"in m?m.L:0));if(T&&!("Z"in m)&&(m.Z=0),"p"in m&&(m.H=m.H%12+m.p*12),m.m===void 0&&(m.m="q"in m?m.q:0),"V"in m){if(m.V<1||m.V>53)return null;"w"in m||(m.w=1),"Z"in m?(M=cn(Ne(m.y,0,1)),Z=M.getUTCDay(),M=Z>4||Z===0?Yt.ceil(M):Yt(M),M=pr.offset(M,(m.V-1)*7),m.y=M.getUTCFullYear(),m.m=M.getUTCMonth(),m.d=M.getUTCDate()+(m.w+6)%7):(M=ln(Ne(m.y,0,1)),Z=M.getDay(),M=Z>4||Z===0?_t.ceil(M):_t(M),M=it.offset(M,(m.V-1)*7),m.y=M.getFullYear(),m.m=M.getMonth(),m.d=M.getDate()+(m.w+6)%7)}else("W"in m||"U"in m)&&("w"in m||(m.w="u"in m?m.u%7:"W"in m?1:0),Z="Z"in m?cn(Ne(m.y,0,1)).getUTCDay():ln(Ne(m.y,0,1)).getDay(),m.m=0,m.d="W"in m?(m.w+6)%7+m.W*7-(Z+5)%7:m.w+m.U*7-(Z+6)%7);return"Z"in m?(m.H+=m.Z/100|0,m.M+=m.Z%100,cn(m)):ln(m)}}function ee(v,T,k,m){for(var H=0,M=T.length,Z=k.length,N,se;H<M;){if(m>=Z)return-1;if(N=T.charCodeAt(H++),N===37){if(N=T.charAt(H++),se=_[N in $r?T.charAt(H++):N],!se||(m=se(v,k,m))<0)return-1}else if(N!=k.charCodeAt(m++))return-1}return m}function Ze(v,T,k){var m=c.exec(T.slice(k));return m?(v.p=h.get(m[0].toLowerCase()),k+m[0].length):-1}function pe(v,T,k){var m=y.exec(T.slice(k));return m?(v.w=w.get(m[0].toLowerCase()),k+m[0].length):-1}function E(v,T,k){var m=f.exec(T.slice(k));return m?(v.w=g.get(m[0].toLowerCase()),k+m[0].length):-1}function j(v,T,k){var m=C.exec(T.slice(k));return m?(v.m=O.get(m[0].toLowerCase()),k+m[0].length):-1}function A(v,T,k){var m=b.exec(T.slice(k));return m?(v.m=S.get(m[0].toLowerCase()),k+m[0].length):-1}function te(v,T,k){return ee(v,e,T,k)}function lt(v,T,k){return ee(v,t,T,k)}function ge(v,T,k){return ee(v,r,T,k)}function me(v){return a[v.getDay()]}function ye(v){return o[v.getDay()]}function F(v){return u[v.getMonth()]}function ho(v){return l[v.getMonth()]}function fo(v){return s[+(v.getHours()>=12)]}function po(v){return 1+~~(v.getMonth()/3)}function go(v){return a[v.getUTCDay()]}function mo(v){return o[v.getUTCDay()]}function yo(v){return u[v.getUTCMonth()]}function vo(v){return l[v.getUTCMonth()]}function bo(v){return s[+(v.getUTCHours()>=12)]}function So(v){return 1+~~(v.getUTCMonth()/3)}return{format:function(v){var T=x(v+="",P);return T.toString=function(){return v},T},parse:function(v){var T=L(v+="",!1);return T.toString=function(){return v},T},utcFormat:function(v){var T=x(v+="",D);return T.toString=function(){return v},T},utcParse:function(v){var T=L(v+="",!0);return T.toString=function(){return v},T}}}var $r={"-":"",_:" ",0:"0"},z=/^\s*\d+/,Ml=/^%/,Dl=/[\\^$*+?|[\]().{}]/g;function R(n,e,t){var r=n<0?"-":"",s=(r?-n:n)+"",o=s.length;return r+(o<t?new Array(t-o+1).join(e)+s:s)}function Ll(n){return n.replace(Dl,"\\$&")}function Be(n){return new RegExp("^(?:"+n.map(Ll).join("|")+")","i")}function Ue(n){return new Map(n.map((e,t)=>[e.toLowerCase(),t]))}function _l(n,e,t){var r=z.exec(e.slice(t,t+1));return r?(n.w=+r[0],t+r[0].length):-1}function Yl(n,e,t){var r=z.exec(e.slice(t,t+1));return r?(n.u=+r[0],t+r[0].length):-1}function zl(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.U=+r[0],t+r[0].length):-1}function Al(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.V=+r[0],t+r[0].length):-1}function Hl(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.W=+r[0],t+r[0].length):-1}function qr(n,e,t){var r=z.exec(e.slice(t,t+4));return r?(n.y=+r[0],t+r[0].length):-1}function Fr(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.y=+r[0]+(+r[0]>68?1900:2e3),t+r[0].length):-1}function Il(n,e,t){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(t,t+6));return r?(n.Z=r[1]?0:-(r[2]+(r[3]||"00")),t+r[0].length):-1}function Zl(n,e,t){var r=z.exec(e.slice(t,t+1));return r?(n.q=r[0]*3-3,t+r[0].length):-1}function Nl(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.m=r[0]-1,t+r[0].length):-1}function Kr(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.d=+r[0],t+r[0].length):-1}function Bl(n,e,t){var r=z.exec(e.slice(t,t+3));return r?(n.m=0,n.d=+r[0],t+r[0].length):-1}function Wr(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.H=+r[0],t+r[0].length):-1}function Ul(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.M=+r[0],t+r[0].length):-1}function $l(n,e,t){var r=z.exec(e.slice(t,t+2));return r?(n.S=+r[0],t+r[0].length):-1}function ql(n,e,t){var r=z.exec(e.slice(t,t+3));return r?(n.L=+r[0],t+r[0].length):-1}function Fl(n,e,t){var r=z.exec(e.slice(t,t+6));return r?(n.L=Math.floor(r[0]/1e3),t+r[0].length):-1}function Kl(n,e,t){var r=Ml.exec(e.slice(t,t+1));return r?t+r[0].length:-1}function Wl(n,e,t){var r=z.exec(e.slice(t));return r?(n.Q=+r[0],t+r[0].length):-1}function jl(n,e,t){var r=z.exec(e.slice(t));return r?(n.s=+r[0],t+r[0].length):-1}function jr(n,e){return R(n.getDate(),e,2)}function Gl(n,e){return R(n.getHours(),e,2)}function Vl(n,e){return R(n.getHours()%12||12,e,2)}function Xl(n,e){return R(1+it.count(J(n),n),e,3)}function gi(n,e){return R(n.getMilliseconds(),e,3)}function Ql(n,e){return gi(n,e)+"000"}function Jl(n,e){return R(n.getMonth()+1,e,2)}function ec(n,e){return R(n.getMinutes(),e,2)}function tc(n,e){return R(n.getSeconds(),e,2)}function nc(n){var e=n.getDay();return e===0?7:e}function rc(n,e){return R(en.count(J(n)-1,n),e,2)}function mi(n){var e=n.getDay();return e>=4||e===0?_e(n):_e.ceil(n)}function sc(n,e){return n=mi(n),R(_e.count(J(n),n)+(J(n).getDay()===4),e,2)}function ic(n){return n.getDay()}function oc(n,e){return R(_t.count(J(n)-1,n),e,2)}function ac(n,e){return R(n.getFullYear()%100,e,2)}function lc(n,e){return n=mi(n),R(n.getFullYear()%100,e,2)}function cc(n,e){return R(n.getFullYear()%1e4,e,4)}function uc(n,e){var t=n.getDay();return n=t>=4||t===0?_e(n):_e.ceil(n),R(n.getFullYear()%1e4,e,4)}function hc(n){var e=n.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+R(e/60|0,"0",2)+R(e%60,"0",2)}function Gr(n,e){return R(n.getUTCDate(),e,2)}function dc(n,e){return R(n.getUTCHours(),e,2)}function fc(n,e){return R(n.getUTCHours()%12||12,e,2)}function pc(n,e){return R(1+pr.count(le(n),n),e,3)}function yi(n,e){return R(n.getUTCMilliseconds(),e,3)}function gc(n,e){return yi(n,e)+"000"}function mc(n,e){return R(n.getUTCMonth()+1,e,2)}function yc(n,e){return R(n.getUTCMinutes(),e,2)}function vc(n,e){return R(n.getUTCSeconds(),e,2)}function bc(n){var e=n.getUTCDay();return e===0?7:e}function Sc(n,e){return R(pi.count(le(n)-1,n),e,2)}function vi(n){var e=n.getUTCDay();return e>=4||e===0?Ye(n):Ye.ceil(n)}function wc(n,e){return n=vi(n),R(Ye.count(le(n),n)+(le(n).getUTCDay()===4),e,2)}function xc(n){return n.getUTCDay()}function Tc(n,e){return R(Yt.count(le(n)-1,n),e,2)}function Ec(n,e){return R(n.getUTCFullYear()%100,e,2)}function Cc(n,e){return n=vi(n),R(n.getUTCFullYear()%100,e,2)}function Pc(n,e){return R(n.getUTCFullYear()%1e4,e,4)}function kc(n,e){var t=n.getUTCDay();return n=t>=4||t===0?Ye(n):Ye.ceil(n),R(n.getUTCFullYear()%1e4,e,4)}function Rc(){return"+0000"}function Vr(){return"%"}function Xr(n){return+n}function Qr(n){return Math.floor(+n/1e3)}var ve,bi;Oc({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 Oc(n){return ve=Ol(n),bi=ve.format,ve.parse,ve.utcFormat,ve.utcParse,ve}function Mc(n){return new Date(n)}function Dc(n){return n instanceof Date?+n:+new Date(+n)}function Si(n,e,t,r,s,o,a,l,u,c){var h=ci(),f=h.invert,g=h.domain,y=c(".%L"),w=c(":%S"),b=c("%I:%M"),S=c("%I %p"),C=c("%a %d"),O=c("%b %d"),P=c("%B"),D=c("%Y");function _(x){return(u(x)<x?y:l(x)<x?w:a(x)<x?b:o(x)<x?S:r(x)<x?s(x)<x?C:O:t(x)<x?P:D)(x)}return h.invert=function(x){return new Date(f(x))},h.domain=function(x){return arguments.length?g(Array.from(x,Dc)):g().map(Mc)},h.ticks=function(x){var L=g();return n(L[0],L[L.length-1],x??10)},h.tickFormat=function(x,L){return L==null?_:c(L)},h.nice=function(x){var L=g();return(!x||typeof x.range!="function")&&(x=e(L[0],L[L.length-1],x??10)),x?g(fl(L,x)):h},h.copy=function(){return li(h,Si(n,e,t,r,s,o,a,l,u,c))},h}function Lc(){return ri.apply(Si(kl,Rl,J,gr,en,it,fr,dr,Se,bi).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}const Jr=[i.i.NANOSECOND,i.i.nanoseconds(2),i.i.nanoseconds(5),i.i.nanoseconds(10),i.i.nanoseconds(20),i.i.nanoseconds(50),i.i.nanoseconds(100),i.i.nanoseconds(200),i.i.nanoseconds(500),i.i.MICROSECOND,i.i.microseconds(2),i.i.microseconds(5),i.i.microseconds(10),i.i.microseconds(20),i.i.microseconds(50),i.i.microseconds(100),i.i.microseconds(200),i.i.microseconds(500),i.i.MILLISECOND,i.i.milliseconds(2),i.i.milliseconds(5),i.i.milliseconds(10),i.i.milliseconds(20),i.i.milliseconds(50),i.i.milliseconds(100),i.i.milliseconds(200),i.i.milliseconds(500),i.i.SECOND];class _c{_domain;_range;_span;constructor(){this._domain=[new i.r(0n),new i.r(1n)],this._range=[0,1],this._span=this._domain[1].span(this._domain[0])}domain(e){return e===void 0?this._domain:(this._domain=[new i.r(e[0]),new i.r(e[1])],this._span=this._domain[1].span(this._domain[0]),this)}range(e){return e===void 0?this._range:(this._range=e,this)}scale(e){const r=new i.r(e).valueOf(),s=this._domain[0].valueOf(),o=this._domain[1].valueOf()-s,a=this._range[1]-this._range[0];return Number(r-s)/Number(o)*a+this._range[0]}ticks(e){const t=this.calculateOptimalStep(e).valueOf(),r=this._domain[0].valueOf(),s=this._domain[1].valueOf(),o=(r+t-1n)/t*t,a=Number((s-o)/t);return Array.from({length:a+1},(l,u)=>{const c=o+BigInt(u)*t;return new i.r(c)}).filter(l=>l.afterEq(this._domain[0])&&l.beforeEq(this._domain[1]))}calculateOptimalStep(e){const t=this._span.valueOf()/BigInt(Math.ceil(e));let r=Jr[0];for(const s of Jr){if(s.valueOf()>t)break;r=s}return r}formatTick(e){return this._span.lessThan(i.i.microseconds(50))?`${e.remainder(i.i.MILLISECOND).microseconds.toString()}µs`:`${e.remainder(i.i.SECOND).milliseconds.toString()}ms`}}const Yc=()=>new _c,mr=d.z.enum(["linear","time"]),yr=d.z.object({tickSpacing:d.z.number().default(75),type:mr.optional().default("linear")}),Pn=n=>{const e=yr.parse(n);return Hc[e.type](e)};class zc{props;prevScaleSize;prevDomain;currTicks;normalScale;preciseScale;constructor(e){this.props=e,this.normalScale=Lc(),this.preciseScale=Yc(),this.prevScaleSize=0,this.prevDomain=new i.O(new i.r(0),new i.r(0)),this.currTicks=[]}create({decimalToDataScale:e,size:t}){const r=new i.O(new i.r(e.pos(0)),new i.r(e.pos(1)));if(this.prevDomain.equals(r)&&this.prevScaleSize===t)return this.currTicks;if(this.prevDomain=r,this.prevScaleSize!==t){const s=[0,t];this.preciseScale.range(s),this.normalScale.range(s),this.prevScaleSize=t}if(r.span.milliseconds<5){this.preciseScale.domain([r.start,r.end]);const s=kn(t,this.props.tickSpacing)/2,o=this.preciseScale.ticks(s);this.currTicks=o.map(a=>({label:this.preciseScale.formatTick(a),position:this.preciseScale.scale(a)}))}else{this.normalScale.domain([r.start.date(),r.end.date()]);const s=this.normalScale.ticks(kn(t,this.props.tickSpacing));this.currTicks=s.map(o=>({label:this.normalTickLabel(o),position:this.normalScale(o)}))}return this.currTicks}normalTickLabel(e){let t=`:${e.getSeconds()}`;const r=e.getMilliseconds();if(r!==0){const s=Math.round(e.getMilliseconds()).toString().padStart(3,"0").replace(/0+$/,"");t+=`.${s}`}return e.getSeconds()===0&&r===0&&(t=`${e.getHours()}:${e.getMinutes().toString().padStart(2,"0")}`),t}}class Ac{props;prevDomain;prevScaleSize;currTicks;d3Scale;constructor(e){this.props=e,this.prevDomain=i.H.construct(0,0),this.prevScaleSize=0,this.currTicks=[],this.d3Scale=fi()}create({decimalToDataScale:e,size:t}){const r={lower:e.pos(0),upper:e.pos(1)};if(i.H.equals(this.prevDomain,r)&&this.prevScaleSize===t)return this.currTicks;i.H.equals(this.prevDomain,r)||(this.d3Scale=this.d3Scale.domain([r.lower,r.upper])),this.prevScaleSize!==t&&(this.d3Scale=this.d3Scale.range([0,t])),this.prevDomain=r,this.prevScaleSize=t;const s=kn(t,this.props.tickSpacing),o=this.d3Scale.ticks(s);return this.currTicks=o.map(a=>({label:this.tickLabel(a),position:this.d3Scale(a)})),this.currTicks}tickLabel(e){return e.toString()}}const kn=(n,e)=>{const t=Math.floor(n/e);return t>0?t:1},Hc={linear:n=>new Ac(n),time:n=>new zc(n)},vr=yr.extend({color:i.cr.colorZ,type:mr.optional().default("linear"),font:d.z.string(),showGrid:d.z.boolean().optional().default(!0),location:i.K$1.outer,gridColor:i.cr.colorZ}),$=5,Ge=6,ot={useAtlas:!0},Ic={bottom:(n,e)=>new xi(n,e),top:(n,e)=>new Ti(n,e),left:(n,e)=>new Zc(n,e),right:(n,e)=>new Ei(n,e)},wi=(n,e,t)=>Ic[n](e,t);class fe{renderCtx;state;tickFactory;constructor(e,t){this.renderCtx=e,this.state=t,this.tickFactory=Pn(this.state)}setState(e){this.state=p.prettyParse(vr,e),this.tickFactory=Pn(e)}drawLine(e,t){const{lower2d:r}=this.renderCtx;r.moveTo(...i.K.couple(e)),r.lineTo(...i.K.couple(t))}drawTicks(e,t){let r=i._.ZERO;return e.forEach(s=>{const o=this.renderCtx.lower2d.textDimensions(s.label,ot);r=i._.max([r,o]),t(o,s)}),r}static START_BOUND=i.H.construct(-1,1);maybeDrawGrid(e,t,r){const{showGrid:s,gridColor:o}=this.state;if(s){const a=fe.START_BOUND,l=i.H.construct(e-1,e+1),{lower2d:u}=this.renderCtx;u.beginPath(),u.strokeStyle=i.cr.hex(o),t.forEach(c=>{i.H.contains(a,c.position)||i.H.contains(l,c.position)||this.drawLine(...r(c))}),u.stroke()}}setColor(e){const t=i.cr.hex(e);this.renderCtx.lower2d.strokeStyle=t,this.renderCtx.lower2d.fillStyle=t,this.renderCtx.lower2d.font=this.state.font}}class xi extends fe{render(e){const{lower2d:t}=this.renderCtx,{plot:r,position:s}=e,{width:o,height:a}=i.Ho.dims(r),l=this.tickFactory.create({...e,size:o});t.beginPath(),this.setColor(this.state.color),this.drawLine(s,i.K.translate(s,"x",o));const u=this.drawTicks(l,(c,h)=>{this.drawLine(i.K.translateX(s,h.position),i.K.translate(s,{x:h.position,y:$})),t.fillText(h.label,s.x+h.position-c.width/2,s.y+$+c.height+Ge,void 0,ot)});return t.stroke(),this.maybeDrawGrid(o,l,c=>[i.K.translate(s,"x",c.position),i.K.translate(s,{x:c.position,y:-a})]),{size:u.height+$+Ge}}}class Ti extends fe{render(e){const{lower2d:t}=this.renderCtx,{plot:r}=e,{width:s,height:o}=i.Ho.dims(r),a=i.K.translate(e.position,"y",e.size),l=this.tickFactory.create({...e,size:s});t.beginPath(),this.setColor(this.state.color),this.drawLine(a,i.K.translate(a,"x",s));const u=this.drawTicks(l,(c,h)=>{this.drawLine(i.K.translateX(a,h.position),i.K.translate(a,{x:h.position,y:-$})),t.fillText(h.label,a.x+h.position-c.width/2,a.y-$-c.height-Ge,void 0,ot)});return t.stroke(),this.maybeDrawGrid(s,l,c=>[i.K.translate(a,"x",c.position),i.K.translate(a,{x:c.position,y:o})]),{size:u.height+$}}}class Zc extends fe{render(e){const{lower2d:t}=this.renderCtx,{plot:r,position:s}=e,{height:o,width:a}=i.Ho.dims(r),l=i.K.translate(s,"x",e.size),u=this.tickFactory.create({...e,size:o});t.beginPath(),this.setColor(this.state.color),this.drawLine(l,i.K.translate(l,"y",o));const c=this.drawTicks(u,(h,f)=>{this.drawLine(i.K.translateY(l,f.position),i.K.translate(l,{x:-$,y:f.position})),t.fillText(f.label,l.x-h.width-$*2,l.y+f.position+h.height/2,void 0,ot)});return t.stroke(),this.maybeDrawGrid(o,u,h=>[i.K.translate(l,"y",h.position),i.K.translate(l,{x:a,y:h.position})]),{size:c.width+$*2}}}class Ei extends fe{render(e){const{lower2d:t}=this.renderCtx,{plot:r,position:s}=e,{height:o,width:a}=i.Ho.dims(r),l=this.tickFactory.create({...e,size:o});t.beginPath(),this.setColor(this.state.color),this.drawLine(s,i.K.translateY(s,o));const u=this.drawTicks(l,(c,h)=>{this.drawLine(i.K.translateY(s,h.position),i.K.translate(s,{x:$,y:h.position})),t.fillText(h.label,s.x+$+Ge,s.y+h.position+c.height/2,void 0,ot)});return t.stroke(),this.maybeDrawGrid(o,l,c=>[i.K.translateY(s,c.position),i.K.translate(s,{x:-a,y:c.position})]),{size:u.width+$+Ge}}}const at=vr.extend({axisKey:d.z.string().optional(),bounds:i.H.bounds.optional(),autoBounds:d.z.object({lower:d.z.boolean().optional().default(!0),upper:d.z.boolean().optional().default(!0)}).or(d.z.boolean().optional().default(!0)),autoBoundPadding:d.z.number().optional(),autoBoundUpdateInterval:i.i.z.optional().default(i.i.seconds(10)),size:d.z.number().optional().default(0),label:d.z.string().optional().default(""),labelSize:d.z.number().optional().default(0)}).partial({color:!0,font:!0,gridColor:!0}),Nc=2,Bc=7,Ci=(n,e)=>i.H.contains({lower:n-Bc,upper:n+Nc},e),Uc=i.H.DECIMAL,es=i.r.now(),$c={lower:Number(es.valueOf()),upper:Number(es.add(i.i.HOUR).valueOf())},Pi=n=>n==="linear"?Uc:$c,qc=(n,e=.1,t)=>{const r=i.H.max(n.filter(i.H.isFinite));if(!i.H.isFinite(r))return Pi(t);const{lower:s,upper:o}=r;if(o===s)return{lower:s-1,upper:o+1};const a=(o-s)*e;return{lower:s-a,upper:o+a}},Fc=.01,Kc=.1;class ki extends p.Composite{afterUpdate(e){const{internal:t}=this,{location:r,autoBoundUpdateInterval:s}=this.state;t.render=p.Context.use(e);const o=p.use(e),a=i.p.construct(r);this.state.autoBoundPadding??=a==="x"?Kc:Fc,t.core=wi(r,t.render,{color:o.colors.gray.l10,font:qe.fontString(o,{level:"small",code:!0}),gridColor:o.colors.gray.l1,...this.state}),X(e,"layout"),t.updateBounds??=p.r(l=>this.setState(u=>({...u,bounds:l})),s.milliseconds)}afterDelete(e){X(e,"layout")}renderAxis(e,t){if(!e.canvases.includes("lower2d"))return;const{core:r}=this.internal,{grid:s,container:o}=e,a=pa(`${this.type}-${this.key}`,s,o),l={...e,position:a,decimalToDataScale:t,size:this.state.size+this.state.labelSize},{size:u}=r.render(l);Ci(this.state.size,u)||this.setState(c=>({...c,size:u}))}iBounds(e,t){if(e&&this.internal.boundSnapshot!=null)return[this.internal.boundSnapshot,null];const{lower:r,upper:s}=Ri(this.state.autoBounds);if(!r&&!s&&this.state.bounds!=null)return this.internal.boundSnapshot=this.state.bounds,[this.state.bounds,null];const o=c=>({upper:s||this.state.bounds==null?c.upper:this.state.bounds.upper,lower:r||this.state.bounds==null?c.lower:this.state.bounds.lower});let a,l=null;try{const c=t();a=qc(c,this.state.autoBoundPadding,this.state.type)}catch(c){a=Pi(this.state.type),l=c}const u=o(a);return this.internal.boundSnapshot=u,(this.state.bounds==null||r&&this.state.bounds.lower!==u.lower||s&&this.state.bounds.upper!==u.upper)&&this.internal.updateBounds?.(u),[u,l]}dataToDecimalScale(e,t,r){const[s,o]=this.iBounds(e,t),a=i.p.swap(i.p.construct(this.state.location));return[i.C.Scale.scale(s).scale(1).translate(-i.Ho.root(r)[a]).magnify(1/i.Ho.dim(r,a)),o]}}const Ri=n=>typeof n=="boolean"?{lower:n,upper:n}:{lower:n?.lower??!0,upper:n?.upper??!0},ts=`#version 300 es
|
|
3
|
+
precision lowp float;
|
|
4
|
+
|
|
5
|
+
uniform lowp vec4 u_color;
|
|
6
|
+
out vec4 fragColor;
|
|
7
|
+
|
|
8
|
+
void main(void) {
|
|
9
|
+
fragColor = u_color;
|
|
10
|
+
}
|
|
11
|
+
`,Wc=`#version 300 es
|
|
12
|
+
|
|
13
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
14
|
+
//
|
|
15
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
16
|
+
// licenses/BSL.txt.
|
|
17
|
+
//
|
|
18
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
19
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
20
|
+
// included in the file licenses/APL.txt.
|
|
21
|
+
|
|
22
|
+
in mediump float a_x;
|
|
23
|
+
in mediump float a_y;
|
|
24
|
+
in mediump vec2 a_translate;
|
|
25
|
+
|
|
26
|
+
uniform mediump vec2 u_scale_aggregate;
|
|
27
|
+
uniform mediump vec2 u_offset_aggregate;
|
|
28
|
+
|
|
29
|
+
void main(void) {
|
|
30
|
+
gl_Position = vec4((u_scale_aggregate * vec2(a_x, a_y) + u_offset_aggregate) + a_translate, 0.0, 1.0);
|
|
31
|
+
}
|
|
32
|
+
`,jc=`#version 300 es
|
|
33
|
+
|
|
34
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
35
|
+
//
|
|
36
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
37
|
+
// licenses/BSL.txt.
|
|
38
|
+
//
|
|
39
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
40
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
41
|
+
// included in the file licenses/APL.txt.
|
|
42
|
+
|
|
43
|
+
in mediump float a_x;
|
|
44
|
+
in mediump uint a_y;
|
|
45
|
+
in mediump vec2 a_translate;
|
|
46
|
+
|
|
47
|
+
uniform mediump vec2 u_scale_aggregate;
|
|
48
|
+
uniform mediump vec2 u_offset_aggregate;
|
|
49
|
+
|
|
50
|
+
void main(void) {
|
|
51
|
+
gl_Position = vec4((u_scale_aggregate * vec2(a_x, float(a_y)) + u_offset_aggregate) + a_translate, 0.0, 1.0);
|
|
52
|
+
}
|
|
53
|
+
`,Oi=d.z.object({x:pt,y:pt,label:d.z.string().optional(),color:i.cr.colorZ,strokeWidth:d.z.number().default(1),downsample:d.z.number().min(1).max(50).default(1),downsampleMode:nr.default("decimate"),visible:d.z.boolean().optional().default(!0)}),Gc=(n,e,t)=>n===-1||e===-1||n>=t.series.length?NaN:Number(t.series[n].at(e)),Vc=i.i.milliseconds(2);i.K.NAN,i.K.NAN,i.cr.ZERO,i.H.ZERO;const Xc=(n,e)=>e.equals(i.n.UINT8)?n.UNSIGNED_BYTE:n.FLOAT;class ns extends p.GLProgram{translationBufferCache=new Map;constructor(e,t,r){super(e,t,r),this.translationBufferCache=new Map}bindState({strokeWidth:e,color:t}){return this.uniformColor("u_color",t),this.attrStrokeWidth(e)}bindScale(e,t){const r=i.K.scale(e.scale,t.scale),s=i.K.translate(i.K.scale(t.scale,e.offset),t.offset);this.uniformXY("u_scale_aggregate",r),this.uniformXY("u_offset_aggregate",s)}draw({x:e,y:t,count:r,downsample:s,xOffset:o,yOffset:a},l,u,c){const{gl:h}=this.renderCtx;this.bindAttrBuffer("x",e.glBuffer,s,o,u),this.bindAttrBuffer("y",t.glBuffer,s,a,c),h.drawArraysInstanced(h.LINE_STRIP,0,r/s,l)}bindAttrBuffer(e,t,r,s=0,o){const{gl:a}=this.renderCtx;a.bindBuffer(a.ARRAY_BUFFER,t);const l=a.getAttribLocation(this.prog,`a_${e}`),u=Xc(a,o),c=o.density.valueOf();o.equals(i.n.UINT8)?a.vertexAttribIPointer(l,1,u,c*r,c*s):a.vertexAttribPointer(l,1,u,!1,c*r,c*s),a.enableVertexAttribArray(l)}getAndBindTranslationBuffer(e){const{gl:t}=this.renderCtx,r=`${this.renderCtx.aspect}:${e}`,s=this.translationBufferCache.get(r);if(s!=null)return t.bindBuffer(t.ARRAY_BUFFER,s.glBuffer),s;const o=t.createBuffer();if(o==null)throw new p.ht("Failed to create buffer from WebGL context");const a=Jc(this.renderCtx.aspect,e);t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,a,t.DYNAMIC_DRAW);const l={glBuffer:o,jsBuffer:a};return this.translationBufferCache.set(r,l),l}attrStrokeWidth(e){const{gl:t}=this.renderCtx,{jsBuffer:r}=this.getAndBindTranslationBuffer(e),s=t.getAttribLocation(this.prog,"a_translate");return t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(s),t.vertexAttribDivisor(s,1),r.length/2}}class xe{static CONTEXT_KEY="pluto-line-gl-program";uint8HybridProgram;float32Program;constructor(e){this.uint8HybridProgram=new ns(e,jc,ts),this.float32Program=new ns(e,Wc,ts)}get gl(){return this.uint8HybridProgram.renderCtx.gl}getProgram(e){return e.equals(i.n.UINT8)?this.uint8HybridProgram:this.float32Program}static create(e,t){const r=new xe(t);return e.set(xe.CONTEXT_KEY,r),r}static use(e){const t=e.get(xe.CONTEXT_KEY);if(t==null)throw new p.ht("GLProgram not found");return t}}class zt extends p.Leaf{static TYPE="line";schema=Oi;afterUpdate(e){const{internal:t}=this,r={onStatusChange:p.useAdder(e)};t.xTelem=q(e,this.state.x,t.xTelem,r),t.yTelem=q(e,this.state.y,t.yTelem,r),t.instrumentation=p.useInstrumentation(e,"line"),t.lineCtx=xe.use(e),t.requestRender=Ft(e),t.stopListeningXTelem?.(),t.stopListeningYTelem?.(),t.stopListeningXTelem=t.xTelem.onChange(()=>t.requestRender("data")),t.stopListeningYTelem=t.yTelem.onChange(()=>t.requestRender("data")),t.requestRender("layout"),(t.xDownsampler?.props.mode!==this.state.downsampleMode||t.xDownsampler?.props.windowSize!==this.state.downsample)&&(t.xDownsampler=new Fe({mode:this.state.downsampleMode,windowSize:this.state.downsample}),t.yDownsampler=new Fe({mode:this.state.downsampleMode,windowSize:this.state.downsample}))}afterDelete(){const{internal:e}=this;e.xTelem.cleanup?.(),e.yTelem.cleanup?.(),e.requestRender("layout")}xBounds(){return this.internal.xTelem.value()[0]}yBounds(){return this.internal.yTelem.value()[0]}findByXValue(e,t){const{xTelem:r,yTelem:s}=this.internal;let[,o]=r.value();o=this.internal.xDownsampler.transform(o);let[a,l]=[-1,-1];o.series.find((S,C)=>{const O=S.binarySearch(t),P=O>=0&&O<S.length;return P&&([a,l]=[O,C]),P});const{key:u}=this,{color:c,label:h}=this.state,f={key:u,color:c,label:h,position:{x:0,y:0},value:{x:NaN,y:NaN},bounds:{lower:0,upper:0}};if(a===-1||l===-1||!this.state.visible)return f;const g=o.series[l];f.value.x=Gc(l,a,o);let[,y]=s.value();y=this.internal.yDownsampler.transform(y);const w=y.series.find(S=>i.H.contains(S.alignmentBounds,g.alignment+BigInt(a)));if(w==null)return f;const b=Number(w.alignment-g.alignment);return f.value.y=Number(w.at(a-b)),f.bounds={...w.bounds},f.position={x:e.dataToDecimalScale.x.pos(f.value.x),y:e.dataToDecimalScale.y.pos(f.value.y)},f}render(e){if(this.deleted||!this.state.visible)return;const{downsample:t}=this.state,{xTelem:r,yTelem:s,lineCtx:o,xDownsampler:a,yDownsampler:l}=this.internal,{dataToDecimalScale:u,exposure:c}=e;let[[,h],[,f]]=[r.value(),s.value()];if(h=a.transform(h),f=l.transform(f),h.updateGLBuffer(o.gl),f.updateGLBuffer(o.gl),h.length===0||f.length===0)return;const g=o.getProgram(f.dataType),y=iu(h,f,c,t,this.state.downsampleMode,Vc);this.internal.instrumentation.L.debug("render",()=>({key:this.key,downsample:t,scale:u.transform,props:e.region,ops:ou(y)}));const w=g.setAsActive(),b=g.bindState(this.state),S=g.renderCtx.scaleRegion(e.region).transform;y.forEach(C=>{const O=ru(u,C).transform;g.bindScale(O,S),g.draw(C,b,h.dataType,f.dataType)}),w()}}const Qc=5e3,Jc=(n,e)=>nu(tu(n),e).map((t,r)=>Math.floor(r/eu)*(1/(Qc*n))*t),eu=5,tu=n=>new Float32Array([0,0,0,n,0,-n,1,0,-1,0]),nu=(n,e)=>{const t=new Float32Array(n.length*e);for(let r=0;r<e;r++)t.set(n,r*n.length);return t},ru=(n,e)=>n.translate(n.x.dim(Number(e.x.sampleOffset)),n.y.dim(Number(e.y.sampleOffset))),su={[zt.TYPE]:zt},iu=(n,e,t,r,s,o)=>{if(n.series.length===0||e.series.length===0)return[];const a=[];return n.series.forEach(l=>e.series.forEach(u=>{if(!au(l,u,o))return;let c=0,h=0;l.alignment<u.alignment?c=Number(u.alignment-l.alignment):u.alignment<l.alignment&&(h=Number(l.alignment-u.alignment));const f=Math.min(l.length-c,u.length-h);if(f===0)return;let g=i.R(Math.round(t*4*f),r,51);s!=="decimate"&&(g=1),a.push({x:l,y:u,xOffset:c,yOffset:h,count:f,downsample:g})})),a},ou=n=>n.map(e=>({...e,x:e.x.digest,y:e.y.digest})),au=(n,e,t)=>{const r=n.timeRange.overlapsWith(e.timeRange,t),s=i.H.overlapsWith(n.alignmentBounds,e.alignmentBounds);return r&&s};class Ie{canvas;theme;constructor(e,t){this.canvas=e,this.theme=t}rule({direction:e,region:t,position:r,...s}){return e==="x"?this.line({start:i.K.construct(i.Ho.left(t),r),end:i.K.construct(i.Ho.right(t),r),...s}):this.line({start:i.K.construct(r,i.Ho.top(t)),end:i.K.construct(r,i.Ho.bottom(t)),...s})}line({stroke:e,lineWidth:t,lineDash:r,start:s,end:o}){const a=this.canvas;a.strokeStyle=i.cr.hex(e),a.lineWidth=t,a.setLineDash([r]),a.beginPath(),a.moveTo(...i.K.couple(s)),a.lineTo(...i.K.couple(o)),a.stroke()}circle({fill:e,radius:t,position:r}){const s=this.canvas;s.fillStyle=i.cr.hex(e),s.beginPath(),s.arc(...i.K.couple(r),t,0,2*Math.PI),s.fill()}resolveColor(e,t){return e==null?t==null?this.theme.colors.text:this.resolveColor(t):typeof e=="function"?e(this.theme):i.cr.construct(e)}border({region:e,color:t,width:r,radius:s,location:o}){const a=this.canvas;a.strokeStyle=i.cr.hex(this.resolveColor(t,this.theme.colors.border)),a.lineWidth=r??this.theme.sizes.border.width,s??=this.theme.sizes.border.radius,o==null||o===!0?s>0?(a.roundRect(...i.K.couple(i.Ho.topLeft(e)),...i.K.couple(i.Ho.dims(e)),s),a.stroke()):(a.rect(...i.K.couple(i.Ho.topLeft(e)),...i.K.couple(i.Ho.dims(e))),a.stroke()):p.t.toArray(o).forEach(l=>{const[u,c]=i.Ho.edgePoints(e,l);a.beginPath(),a.moveTo(...i.K.couple(u)),a.lineTo(...i.K.couple(c)),a.stroke()})}container({region:e,bordered:t=!0,rounded:r=!0,borderColor:s,borderRadius:o,borderWidth:a,backgroundColor:l}){o??=this.theme.sizes.border.radius,a??=1;const u=this.canvas;u.fillStyle=i.cr.hex(this.resolveColor(l,this.theme.colors.gray.l1)),u.strokeStyle=i.cr.hex(this.resolveColor(s,this.theme.colors.border)),u.setLineDash([]),u.lineWidth=1,u.beginPath(),r?u.roundRect(...i.K.couple(i.Ho.topLeft(e)),...i.K.couple(i.Ho.dims(e)),o):u.rect(...i.K.couple(i.Ho.topLeft(e)),...i.K.couple(i.Ho.dims(e))),u.fill(),t&&this.border({region:e,color:s,radius:o,width:a,location:t})}textContainer(e){const[t,r]=this.spacedTextDrawF(e);t.width+=12,t.height+=12;const{root:s=i.K$1.TOP_LEFT,offset:o=i.K.ZERO}=e,a={...e.position};s.x==="right"?a.x-=t.width+o.x:a.x+=o.x,s.y==="bottom"?a.y-=t.height+o.y:a.y+=o.y,this.container({region:i.Ho.construct(a,t.width,t.height),...e}),this.canvas.filter="none",r(i.K.translate(a,[6,6]))}spacedTextDrawF({text:e,direction:t,spacing:r=1,level:s="p"}){const o=qe.fontString(this.theme,{level:s}),a=e.map(c=>p.dimensions(c,o,this.canvas)),l=this.theme.sizes.base*r,u=Math.max(...a.map(c=>c[i.p.dimension(t)]))+l;return[{[i.p.dimension(i.p.swap(t))]:Math.max(...a.map(c=>c[i.p.dimension(i.p.swap(t))])),[i.p.dimension(t)]:u*e.length-l},c=>{const h=qe.fontString(this.theme,{level:s});this.canvas.font=h,this.canvas.fillStyle=i.cr.hex(this.theme.colors.text),this.canvas.textBaseline="top",e.forEach((f,g)=>{this.canvas.fillText(f,c.x,c.y+u*g)})}]}list({length:e,itemHeight:t,width:r,spacing:s=0,position:o,draw:a,root:l=i.K$1.TOP_LEFT,offset:u=i.K.ZERO,padding:c=i.K.ZERO}){const h=e*t+c.y*2+s*(e-1),f=r+c.x*2,g={...o};l.x==="right"?g.x-=r+u.x*2:g.x+=u.x,l.y==="top"?g.y-=h+u.y*2:g.y+=u.y,this.container({region:i.Ho.construct(g,{width:f,height:h}),backgroundColor:y=>y.colors.gray.l1});for(let y=0;y<e;y++){const w=i.Ho.construct(i.K.construct(g.x+c.x,g.y+y*t+c.y+s*y),r,t);a(y,w)}}drawTextInCenter({box:e,text:t,level:r}){const s=p.dimensions(t,this.canvas.font,this.canvas),o=i.Ho.positionInCenter(i.Ho.construct(i.K.ZERO,s),e);return this.text({text:t,position:i.Ho.topLeft(o),level:r})}text({text:e,position:t,level:r="p",weight:s,shade:o,maxWidth:a,code:l,justify:u="left",align:c="top",color:h}){this.canvas.font=qe.fontString(this.theme,{level:r,weight:s,code:l}),h!=null?this.canvas.fillStyle=i.cr.hex(this.resolveColor(h)):o==null?this.canvas.fillStyle=i.cr.hex(this.theme.colors.text):this.canvas.fillStyle=i.cr.hex(this.theme.colors.gray[`l${o}`]),this.canvas.textAlign=u,this.canvas.textBaseline=c;let f;a!=null&&(f=this.canvas.scissor(i.Ho.construct(t,a,1e3))),this.canvas.fillText(e,t.x,t.y),f?.()}}const br=d.z.object({position:d.z.number().optional(),pixelPosition:d.z.number().optional(),dragging:d.z.boolean(),lineWidth:d.z.number().optional().default(1),lineDash:d.z.number().optional().default(20),color:i.cr.colorZ}),lu=3;class Ve extends p.Leaf{static TYPE="Rule";schema=br;lastUpdateRef=null;afterUpdate(e){this.internal.renderCtx=p.Context.use(e);const t=p.use(e);this.internal.draw=new Ie(this.internal.renderCtx.upper2d,t),X(e,"tool")}afterDelete(e){X(e,"tool")}updatePositions({decimalToDataScale:e,plot:t}){const r=this.state.dragging,s=this.prevState.dragging&&!r;if((r||s)&&this.state.pixelPosition!=null){if(this.lastUpdateRef??=this.state.pixelPosition,Math.abs(this.state.pixelPosition-this.lastUpdateRef)<lu&&!s)return this.state.pixelPosition;this.lastUpdateRef=this.state.pixelPosition;const l=e.pos(this.state.pixelPosition/i.Ho.height(t));return this.setState(u=>({...u,position:l})),this.state.pixelPosition}if(this.state.position==null){const a=e.pos(.5);this.setState(l=>({...l,position:a}))}const o=e.reverse().pos(this.state.position)*i.Ho.height(t);if(!isNaN(o)){if(this.state.pixelPosition!=null&&Math.abs(o-this.state.pixelPosition)<1)return this.state.pixelPosition;this.setState(a=>({...a,pixelPosition:o}))}return o}render(e){if(this.deleted)return;const{renderCtx:t}=this.internal,{location:r,plot:s}=e,o=i.K$1.direction(r),{upper2d:a}=t,l=this.internal.draw,u=this.updatePositions(e)+i.Ho.top(e.plot);l.rule({stroke:this.state.color,lineWidth:this.state.lineWidth,lineDash:this.state.lineDash,direction:o,region:s,position:u}),a.fillStyle=i.cr.hex(this.state.color),a.lineJoin="round",a.lineWidth=3.5,a.lineCap="round",a.beginPath();const c=4;if(r==="left"){const h=i.Ho.left(s)-1;a.moveTo(h,u),a.lineTo(h-c,u-c),a.lineTo(h-c,u+c)}else r==="right"&&(a.moveTo(i.Ho.right(s),u),a.lineTo(i.Ho.right(s)+c,u-c),a.lineTo(i.Ho.right(s)+c,u+c));a.closePath(),a.stroke()}}const Mi={[Ve.TYPE]:Ve},cu=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:Mi,Rule:Ve,ruleStateZ:br},Symbol.toStringTag,{value:"Module"})),uu=at.extend({location:i.K$1.x.optional().default("left")}),rs=2,hu=n=>i.Ho.signedWidth(n)<rs||i.Ho.signedHeight(n)<rs;class At extends ki{static TYPE="YAxis";schema=at;xBounds(){return i.H.max(this.lines.map(e=>e.xBounds()).filter(e=>i.H.isFinite(e)))}bounds(e){const[t,r]=this.iBounds(e,this.dataBounds.bind(this));if(r!=null)throw r;return t}render(e){if(this.deleted)return;const[t,r]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport),s=t.invert().reverse();if(this.renderAxis(e,s),this.renderLines(e,t),this.renderRules(e,s),r!=null)throw r}renderLines({xDataToDecimalScale:e,plot:t,canvases:r,exposure:s},o){if(!r.includes("gl")||hu(t))return;const a={region:t,dataToDecimalScale:new i.C.XY(e,o),exposure:s};this.lines.forEach(l=>l.render(a))}renderRules({container:e,plot:t,canvases:r},s){if(!r.includes("upper2d"))return;const{location:o}=this.state,{render:a}=this.internal,l=i.Ho.construct(i.Ho.left(e),i.Ho.top(t),i.Ho.width(e),i.Ho.height(t)),u=a.scissor(l,i.K.ZERO,["upper2d"]),c={container:e,plot:t,decimalToDataScale:s,location:o};this.rules.map(h=>h.render(c)),u()}findByXValue({xDataToDecimalScale:e,plot:t,viewport:r,hold:s,exposure:o},a){const[l,u]=this.dataToDecimalScale(s,this.dataBounds.bind(this),r);if(u!=null)throw u;const c=new i.C.XY(e,l),h={region:t,dataToDecimalScale:c,exposure:o};return this.lines.map(f=>({...f.findByXValue(h,a),units:this.state.label}))}dataBounds(){return this.lines.map(e=>e.yBounds())}get lines(){return this.childrenOfType(zt.TYPE)}get rules(){return this.childrenOfType(Ve.TYPE)}}const Di=d.z.object({start:i.r.z,end:i.r.z});class Rn extends p.Leaf{static TYPE="range-annotation";schema=Di;afterUpdate(e){this.internal.render=p.Context.use(e),this.internal.draw=new Ie(this.internal.render.upper2d,p.use(e))}}const du="ranges",fu={channel:p.Iw.SET_CHANNEL_NAME,schema:p.Iw.payloadZ,onChange:async({store:n,changed:e,client:t})=>{const r=t.ranges.sugarOne(e),s=n.ranges.get(e.key);let o;s?.labels==null&&(o=await r.retrieveLabels());let a=null;s?.parent==null&&(a=await r.retrieveParent()),n.ranges.set(e.key,l=>t.ranges.sugarOne({...r.payload,labels:l?.labels??o,parent:l?.parent??a}))}},pu={channel:p.Iw.DELETE_CHANNEL_NAME,schema:p.Iw.keyZ,onChange:({store:n,changed:e})=>n.ranges.delete(e)},gu={equal:(n,e)=>p.N.equal(n.payload,e.payload),listeners:[fu,pu]},mu=d.z.object({region:i.Ho.box,clearOverScan:i.K.crudeZ.optional().default(0),visible:d.z.boolean().optional().default(!0)}),ss=["upper2d","lower2d"];class ze extends p.Composite{static TYPE="Table";static stateZ=mu;schema=ze.stateZ;afterUpdate(e){const{internal:t}=this;t.renderCtx=p.Context.use(e),t.handleError=p.useErrorHandler(e),qt(e,()=>{this.state.visible&&this.requestRender("low")}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender("high")}afterDelete(){this.requestRender("high")}render(){if(this.deleted)return;const e=i.Ho.copy(this.state.region);if(!this.state.visible)return()=>this.internal.renderCtx.erase(e,this.state.clearOverScan);const{renderCtx:t,handleError:r}=this.internal,s=i.C.XY.translate(i.Ho.topLeft(this.state.region)),o=t.scissor(this.state.region,i.K.construct(this.state.clearOverScan),ss);try{for(const a of this.children)a.render({viewportScale:s})}catch(a){r(a,"Failed to render table")}finally{o()}return()=>this.internal.renderCtx.erase(e,this.state.clearOverScan)}requestRender(e){const{renderCtx:t}=this.internal;t.loop.set({key:`${ze.TYPE}-${this.key}`,render:this.render.bind(this),priority:e,canvases:ss})}}const yu={[ze.TYPE]:ze},Li=d.z.object({authority:i.lr.authorityZ.optional(),valid:d.z.boolean().optional()}).default({authority:void 0,valid:!1}),_i=d.z.object({triggered:d.z.boolean(),status:i.wr.statusZ(Li),sink:Gt.optional().default(Kt),source:Fn.optional().default(Un)});class On extends p.Leaf{static TYPE="Chip";schema=_i;afterUpdate(e){const{internal:t}=this,{sink:r,source:s}=this.state;t.source=q(e,s,t.source),t.sink=rt(e,r,t.sink),this.state.triggered&&!this.prevState.triggered&&t.sink.set(this.state.status.details?.authority!==i.lr.ABSOLUTE_AUTHORITY),this.updateEnabledState(),t.stopListening?.(),t.stopListening=t.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();p.N.equal(e,this.state.status)||this.setState(t=>({...t,status:e,triggered:!1}))}afterDelete(){this.internal.stopListening(),this.internal.source.cleanup?.(),this.internal.sink.cleanup?.()}render(){}}const Yi=d.z.object({}),is="control-state-provider",zi=p.gw.stateZ.extend({subjectColor:i.cr.colorZ});class Xe extends p.Composite{static TYPE="StateProvider";schema=Yi;colors=new Map;tracker;disconnectTrackerChange;obs=new $t.Observer;static use(e){return e.get(is)}afterUpdate(e){const{internal:t}=this;t.instrumentation=p.useInstrumentation(e,"control-state");const r=p.use(e);t.palette=r.colors.visualization.palettes.default,t.defaultColor=r.colors.gray.l8;const s=He(e);if(t.client!=null&&s===t.client)return;t.client=s,e.set(is,this),p.useErrorHandler(e)(async()=>{await this.maybeCloseTracker(),t.client!=null&&(this.internal.instrumentation.L.debug("starting state tracker"),await this.openTracker(t.client))},"failed to open control state tracker")}async maybeCloseTracker(){this.tracker!=null&&(this.internal.instrumentation.L.debug("stopping state tracker"),this.disconnectTrackerChange?.(),await this.tracker.close(),this.tracker=void 0)}afterDelete(e){p.useErrorHandler(e)(async()=>{await this.maybeCloseTracker()},"failed to close control state tracker")}onChange(e){return this.obs.onChange(e)}get(e){return Array.isArray(e)?i.c.unique(e).map(t=>this.getOne(t)).filter(t=>t!=null):this.getOne(e)}getOne(e){if(this.tracker==null)return;const t=this.tracker.states.get(e);if(t!=null)return{...t,subjectColor:this.colors.get(t.subject.key)??this.internal.defaultColor}}async openTracker(e){const{internal:t}=this,{instrumentation:r}=t;try{this.tracker=await e.control.openStateTracker()}catch{r.L.error("failed to open state tracker");return}this.disconnectTrackerChange?.(),this.disconnectTrackerChange=this.tracker.onChange(s=>{if(r.L.debug("transfer",{transfers:s.map(o=>p.gw.transferString(o))}),this.tracker==null)throw new p.ht("tracker is null inside it's own onChange callback!");this.updateColors(this.tracker),this.obs.notify(s)})}updateColors(e){const t=e.subjects(),r=t.map(a=>a.key),s=Array.from(this.colors.values());this.colors.forEach((a,l)=>!r.includes(l)&&this.colors.delete(l));const{palette:o}=this.internal;t.forEach(a=>{if(this.colors.has(a.key))return;const l=o.find(u=>!s.includes(u))??o[0];this.colors.set(a.key,l),s.push(l)})}}const Ai=["acquired","released","overridden","failed"],Hi=d.z.enum(Ai),Ii=d.z.object({name:d.z.string(),authority:d.z.number().default(0),acquireTrigger:d.z.number(),status:Hi.optional(),needsControlOf:p.ow.keyZ.array().optional().default([])});class Mn extends p.Composite{static TYPE="Controller";schema=Ii;registry=new Map;writer;afterUpdate(e){const{internal:t}=this;t.instrumentation=p.useInstrumentation(e),t.addStatus=p.useAdder(e),t.runAsync=p.useErrorHandler(e),(t.prevTrigger==null||Math.abs(this.state.acquireTrigger-t.prevTrigger)>1)&&(t.prevTrigger=this.state.acquireTrigger);const r=He(e),s=Xe.use(e);t.stateProv=s,t.telemCtx=Ks(e,this,t.telemCtx),t.client=r,t.runAsync(async()=>{t.client==null&&await this.release(),this.state.acquireTrigger>t.prevTrigger?await this.acquire():this.state.acquireTrigger<t.prevTrigger&&await this.release()},"failed to acquire control")}afterDelete(){const{internal:e}=this;e.runAsync(async()=>await this.release(),"failed to release control")}async updateNeedsControlOf(){const{client:e}=this.internal;if(e==null)return;const t=new Set([]);for(const s of this.registry.keys())(await s.needsControlOf(e)).forEach(a=>a!==0&&t.add(a));const r=Array.from(t);i.k.unorderedPrimitiveArrays(this.state.needsControlOf,r)!==i.k.EQUAL&&this.setState(s=>({...s,needsControlOf:r}))}async acquire(){this.internal.prevTrigger=this.state.acquireTrigger;const{client:e,addStatus:t}=this.internal;if(e==null)return t({message:`Cannot acquire control on ${this.state.name} because no cluster has been connected.`,variant:"warning"});try{await this.updateNeedsControlOf();const r=this.state.needsControlOf;if(r.length===0)return t({message:`Cannot acquire control on ${this.state.name} because there are no channels to control.`,variant:"warning"});const s=p.d$1.now().sub(i.i.milliseconds(1));this.writer=await e.openWriter({start:s,channels:r,controlSubject:{key:this.key,name:this.state.name},authorities:this.state.authority,enableAutoCommit:!0}),this.setState(o=>({...o,status:"acquired"}))}catch(r){if(this.setState(s=>({...s,status:"failed"})),!(r instanceof Error))throw r;t({variant:"error",message:`${this.state.name} failed to acquire control`,description:r.message})}}async release(){this.internal.prevTrigger=this.state.acquireTrigger;try{await this.writer?.close()}catch(e){this.internal.addStatus({message:`${this.state.name} failed to release control: ${e.message}`,variant:"error"})}finally{this.setState(e=>({...e,status:"released"})),this.writer=void 0}}async set(e){this.writer==null&&await this.acquire(),await this.writer?.write(e)}async setAuthority(e,t){this.writer==null&&await this.acquire(),await this.writer?.setAuthority(Object.fromEntries(e.map(r=>[r,t])))}async releaseAuthority(e){this.writer==null&&await this.acquire(),await this.writer?.setAuthority(Object.fromEntries(e.map(t=>[t,this.state.authority])))}deleteTelem(e){this.registry.delete(e),this.updateNeedsControlOf()}create(e){const{internal:t}=this,s=(()=>{switch(e.type){case Ht.TYPE:{const o=new Ht(this,t.runAsync,e.props);return this.registry.set(o,null),o}case Zt.TYPE:{const o=new Zt(this,this.internal.stateProv,e.props);return this.registry.set(o,null),o}case It.TYPE:return new It(this,t.runAsync,e.props);default:return null}})();return s!=null&&this.updateNeedsControlOf(),s}}const Zi=d.z.object({channel:d.z.number()});class Ht extends Xt{static TYPE="controlled-numeric-telem-sink";controller;runAsync;schema=Zi;constructor(e,t,r){super(r),this.controller=e,this.runAsync=t}invalidate(){}cleanup(){this.controller.deleteTelem(this)}async needsControlOf(e){if(this.props.channel===0)return[];const t=await e.channels.retrieve(this.props.channel),r=[t.key];return t.index!==0&&r.push(t.index),r}set(...e){this.runAsync(async()=>{const{client:t}=this.controller.internal;if(t==null)throw new p._m("No cluster connected");if(this.props.channel===0)throw new p.P("No command channel specified for actuator");const r=await t.channels.retrieve(this.props.channel),s={[r.key]:e};if(r.index!==0){const o=await t.channels.retrieve(r.index),a=p.d$1.now();s[o.key]=Array.from({length:e.length},(l,u)=>a.add(i.i.nanoseconds(u)))}await this.controller.set(s)},"Failed to command channel")}}const vu=n=>({type:Ht.TYPE,props:n,variant:"sink",valueType:"number"}),Ni=d.z.object({authority:d.z.number().default(p.gw.ABSOLUTE_AUTHORITY),channel:d.z.number()});class It extends Xt{static TYPE="acquire-channel-control";controller;runAsync;schema=Ni;constructor(e,t,r){super(r),this.controller=e,this.runAsync=t}cleanup(){this.controller.deleteTelem(this)}async needsControlOf(e){const t=await e.channels.retrieve(this.props.channel),r=[t.key];return t.index!==0&&r.push(t.index),r}set(e){this.runAsync(async()=>{const{controller:t}=this,{client:r}=t.internal;if(r==null)return;const s=await r.channels.retrieve(this.props.channel),o=[s.key];s.index!==0&&o.push(s.index),e?await this.controller.setAuthority(o,this.props.authority):await this.controller.releaseAuthority(o)},"failed to set channel authority")}}const bu=n=>({type:It.TYPE,props:n,variant:"sink",valueType:"boolean"}),Bi=d.z.object({channel:d.z.number()}),Su=d.z.object({valid:d.z.boolean(),color:i.cr.colorZ.optional(),authority:d.z.number()});class Zt extends B{static TYPE="controlled-status-source";prov;valid=!1;stopListening;controller;schema=Bi;constructor(e,t,r){super(r),this.prov=t,this.controller=e}async needsControlOf(){return[]}maybeRevalidate(){if(this.valid)return;const{channel:e}=this.props;this.stopListening?.();const t=i.lr.filterTransfersByChannelKey(e);this.stopListening=this.prov.onChange(r=>{t(r).length!==0&&this.notify?.()}),this.valid=!0}value(){this.maybeRevalidate();const e=p.d$1.now();if(this.props.channel===0)return{key:this.controller.key,variant:"disabled",message:"No Channel",time:e,details:{valid:!1,authority:0}};const t=this.prov.get(this.props.channel);return t==null?{key:this.controller.key,variant:"disabled",message:"Uncontrolled",time:e,details:{valid:!0,color:void 0,authority:0}}:{key:t.subject.key,variant:t.subject.key===this.controller.key?"success":"error",message:`Controlled by ${t.subject.name}`,time:e,details:{valid:!0,color:t.subjectColor,authority:t.authority}}}cleanup(){this.controller.deleteTelem(this),this.stopListening?.()}}const wu=n=>({type:Zt.TYPE,props:n,variant:"source",valueType:"status"}),Ui=d.z.object({color:i.cr.colorZ.optional()}).default({color:void 0}),$i=d.z.object({statusSource:Fn.optional().default(Un),colorSource:qn.optional().default(Wt),status:i.wr.statusZ(Ui),color:i.cr.colorZ.optional()});class Dn extends p.Leaf{static TYPE="Indicator";schema=$i;stopListeningStatus;stopListeningColor;afterUpdate(e){const{internal:t}=this,{statusSource:r,colorSource:s}=this.state;t.statusSource=q(e,r,t.statusSource),t.colorSource=q(e,s,t.colorSource),this.updateState(),this.stopListeningStatus?.(),this.stopListeningColor?.(),this.stopListeningStatus=t.statusSource.onChange(this.updateState.bind(this)),this.stopListeningColor=t.colorSource.onChange(this.updateState.bind(this))}afterDelete(){this.internal.statusSource.cleanup?.(),this.internal.colorSource.cleanup?.()}render(){}updateState(){const e=this.internal.colorSource.value(),t=this.internal.statusSource.value();i.cr.equals(e,this.state.color)&&t.message===this.state.status.message||this.setState(r=>({...r,color:e,status:t}))}}const qi=d.z.object({needsControlOf:p.ow.keyZ.array(),states:zi.array()});class Ln extends p.Leaf{static TYPE="Legend";schema=qi;afterUpdate(e){const{internal:t}=this;t.stateProv=Xe.use(e);const r=this.state.needsControlOf;t.disconnectStateProv?.();const s=i.lr.filterTransfersByChannelKey(...r),o=t.stateProv.get(r);this.setState(a=>({...a,states:o})),t.disconnectStateProv=t.stateProv.onChange(a=>{if(s(a).length===0)return;const l=t.stateProv.get(r);this.setState(u=>({...u,states:l}))})}afterDelete(){const{internal:e}=this;e.disconnectStateProv?.()}render(){}}const xu={[Mn.TYPE]:Mn,[Xe.TYPE]:Xe,[Dn.TYPE]:Dn,[On.TYPE]:On,[Ln.TYPE]:Ln},Fi=["fire","momentary","pulse"],Tu=d.z.enum(Fi),Ki=d.z.object({trigger:d.z.number(),sink:Gt.optional().default(Kt),mode:Tu.optional().default("fire")}),Wi=2,ji=1;class _n extends p.Leaf{static TYPE="Button";schema=Ki;afterUpdate(e){const{sink:t,mode:r,trigger:s}=this.state,{internal:o}=this;o.prevTrigger??=s,o.sink=rt(e,t,o.sink);const a=o.prevTrigger;o.prevTrigger=s;const l=s===a+Wi;s===a+ji?r=="fire"?this.internal.sink.set(!0):r=="momentary"&&this.internal.sink.set(!1):l&&(r=="momentary"?this.internal.sink.set(!0):r=="pulse"&&this.internal.sink.set(!0,!1))}afterDelete(){this.internal.sink.cleanup?.()}}const Eu={[_n.TYPE]:_n},Sr=d.z.object({dpr:d.z.number(),region:i.Ho.box,bootstrap:d.z.boolean().optional().default(!1),bootstrapped:d.z.boolean().optional().default(!1),glCanvas:d.z.any().optional(),upper2dCanvas:d.z.any().optional(),lower2dCanvas:d.z.any().optional(),os:i.S.osZ});class Nt extends p.Composite{static TYPE="Canvas";schema=Sr;renderCtx=null;afterUpdate(e){if(this.renderCtx==null){if(!this.state.bootstrap)return;const{glCanvas:t,lower2dCanvas:r,upper2dCanvas:s,os:o}=this.state;if(t==null||r==null||s==null)throw new p.ht("[vis.worker.Canvas] - expected render context bootstrap to include all canvases");this.renderCtx=p.Context.create(e,t,r,s,o),xe.create(e,this.renderCtx),this.setState(a=>({...a,bootstrap:!1,bootstrapped:!0,glCanvas:void 0,lower2dCanvas:void 0,upper2dCanvas:void 0}))}else this.renderCtx.update(e);this.renderCtx.resize(this.state.region,this.state.dpr)}}const Gi={[Nt.TYPE]:Nt},Cu=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Nt,REGISTRY:Gi,canvasStateZ:Sr},Symbol.toStringTag,{value:"Module"})),wr=d.z.object({position:i.K.xy,zoom:d.z.number(),region:i.Ho.box,clearOverScan:i.K.crudeZ.optional().default(10),visible:d.z.boolean().optional().default(!0)}),dt=["upper2d","lower2d"];class ce extends p.Composite{static TYPE="Diagram";static stateZ=wr;schema=ce.stateZ;afterUpdate(e){this.internal.renderCtx=p.Context.use(e),this.internal.handleError=p.useErrorHandler(e),qt(e,()=>{this.state.visible&&this.requestRender("low")}),!(!this.state.visible&&!this.prevState.visible)&&(this.internal.viewportScale=i.C.XY.magnify(i.K.construct(this.state.zoom)).translate(i.Ho.topLeft(this.state.region)).translate(this.state.position),this.requestRender("high"))}afterDelete(){this.requestRender("high")}render(){if(this.deleted)return;const{renderCtx:e,handleError:t,viewportScale:r}=this.internal,s=i.Ho.construct(this.state.region);if(!this.state.visible)return()=>e.erase(s,this.state.clearOverScan,...dt);const o=e.scissor(s,i.K.ZERO,dt);try{this.children.forEach(l=>l.render?.({viewportScale:r}))}catch(l){t(l,"failed to render diagram")}finally{o()}const a=i.Ho.copy(this.state.region);return()=>{e.lower2d.fillStyle=i.cr.hex(i.cr.BLACK),e.lower2d.fillRect(...i.K.couple(i.Ho.topLeft(a)),i.Ho.width(a),i.Ho.height(a)),e.erase(a,this.state.clearOverScan,...dt)}}requestRender(e){const{renderCtx:t}=this.internal;t.loop.set({key:`${ce.TYPE}-${this.key}`,render:this.render.bind(this),priority:e,canvases:dt})}}const Vi={[ce.TYPE]:ce},Pu=Object.freeze(Object.defineProperty({__proto__:null,Diagram:ce,REGISTRY:Vi,diagramStateZ:wr},Symbol.toStringTag,{value:"Module"})),Xi=d.z.object({enabled:d.z.boolean(),source:$n.optional().default(Bn)});class Yn extends p.Leaf{static TYPE="Light";schema=Xi;afterUpdate(e){const{internal:t}=this;this.internal.source=q(e,this.state.source,t.source),this.updateEnabledState(),t.stopListening?.(),t.stopListening=t.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();e!==this.state.enabled&&this.setState(t=>({...t,enabled:e}))}afterDelete(){this.internal.stopListening(),this.internal.source.cleanup?.()}}const ku={[Yn.TYPE]:Yn},Ru=i.K.construct(12),Ou=3,Mu=14,Du=i.K.construct(6),xr=d.z.object({position:i.K.xy.or(d.z.null()),textColor:i.cr.colorZ.optional().default(i.cr.ZERO),backgroundColor:i.cr.colorZ.optional().default(i.cr.ZERO),borderColor:i.cr.colorZ.optional().default(i.cr.ZERO),ruleColor:i.cr.colorZ.optional().default(i.cr.ZERO),ruleStrokeWidth:d.z.number().optional().default(1),ruleStrokeDash:d.z.number().default(0)});class Qe extends p.Leaf{static TYPE="tooltip";schema=xr;afterUpdate(e){const t=p.use(e);i.cr.isZero(this.state.textColor)&&(this.state.textColor=t.colors.text),i.cr.isZero(this.state.backgroundColor)&&(this.state.backgroundColor=t.colors.gray.l1),i.cr.isZero(this.state.borderColor)&&(this.state.borderColor=t.colors.border),i.cr.isZero(this.state.ruleColor)&&(this.state.ruleColor=t.colors.gray.l7),this.internal.dotColor=t.colors.text,this.internal.dotColorContrast=t.colors.textInverted,this.internal.render=p.Context.use(e),this.internal.draw=new Ie(this.internal.render.upper2d,t),X(e,"tool")}afterDelete(e){X(e,"tool")}render(e){if(this.deleted||this.state.position==null)return;const{region:t}=e,r=i.C.XY.scale(i.Ho.DECIMAL).scale(t),s=i.C.XY.scale(t).scale(i.Ho.DECIMAL),o=e.findByXDecimal(s.x.pos(this.state.position.x)),a=o.filter(b=>i.K.isFinite(b.value)),{draw:l}=this.internal,u=a.reduce((b,S)=>b+S.position.x,0)/a.length,c=new i.r(a.reduce((b,S)=>b+S.value.x,0)/a.length),h=r.x.pos(u);if(!i.H.contains(i.Ho.xBounds(t),h))return;l.rule({stroke:this.state.ruleColor,lineWidth:this.state.ruleStrokeWidth,lineDash:this.state.ruleStrokeDash,direction:"y",region:t,position:h}),a.forEach(b=>{const S=r.pos(b.position);l.circle({fill:i.cr.setAlpha(b.color,.5),radius:8,position:S}),l.circle({fill:i.cr.setAlpha(b.color,.8),radius:5,position:S}),l.circle({fill:i.cr.pickByContrast(b.color,this.internal.dotColor,this.internal.dotColorContrast),radius:2,position:S})});const f=s.pos(this.state.position),g={...i.K$1.TOP_LEFT};f.x>.6&&(g.x="right"),f.y>.6&&(g.y="bottom");let y=o.reduce((b,S)=>Math.max(b,S.label?.length??0),0);const w=c.fString("preciseDate","local").length;w>y&&(y=w),l.list({root:g,offset:Ru,length:a.length+1,padding:Du,itemHeight:Mu,spacing:Ou,width:y*7+48,position:this.state.position,draw:(b,S)=>{let C="",O="",P=this.state.textColor;if(b===0)C="Time",O=c.fString("preciseDate","local");else{const D=a[b-1];C=D.label??"",O=i.or.roundBySpan(D.value.y,D.bounds).toString(),P=D.color}l.text({position:i.Ho.topLeft(S),text:C,level:"small",weight:500,color:P}),l.text({position:i.K.translateY(i.Ho.topRight(S),-1),text:O,level:"small",justify:"right",code:!0,shade:10})}})}}const Qi={[Qe.TYPE]:Qe},Lu=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:Qi,Tooltip:Qe,tooltipStateZ:xr},Symbol.toStringTag,{value:"Module"})),Ji=d.z.object({region:i.Ho.box,wheelPos:d.z.number(),scrolling:d.z.boolean(),empty:d.z.boolean(),visible:d.z.boolean(),telem:pt.optional().default(us),font:p.levelZ.optional().default("p"),color:i.cr.colorZ.optional().default(i.cr.ZERO),overshoot:i.K.xy.optional().default({x:0,y:0})}),_u=.98,$e="lower2d",Yu={offset:0n,offsetRef:0n,scrollRef:0};class Je extends p.Leaf{static TYPE="log";static z=Ji;schema=Je.z;values=new i.Wt([]);scrollState=Yu;afterUpdate(e){const{internal:t}=this;t.render=p.Context.use(e),t.theme=p.use(e),i.cr.isZero(this.state.color)?this.internal.textColor=t.theme.colors.gray.l11:t.textColor=this.state.color,t.telem=q(e,this.state.telem,t.telem);const{scrolling:r,wheelPos:s}=this.state;if(this.state.scrolling&&!this.prevState.scrolling){const u=this.values.alignmentBounds.upper-1n;this.scrollState={offset:u,offsetRef:u,scrollRef:this.state.wheelPos}}else if(r){const{scrollState:u,values:c}=this,h=Math.ceil((s-this.scrollState.scrollRef)/this.lineHeight);u.offset=this.values.traverseAlignment(u.offsetRef,-BigInt(h)),u.offset<c.alignmentBounds.lower+BigInt(this.visibleLineCount)&&(u.offset=c.alignmentBounds.lower,this.setState(f=>({...f,wheelPos:this.prevState.wheelPos}))),u.offset>=c.alignmentBounds.upper&&this.setState(f=>({...f,scrolling:!1}))}const[a,l]=this.internal.telem.value();this.values=l,this.checkEmpty(),t.stopListeningTelem?.(),t.stopListeningTelem=t.telem.onChange(()=>{const[u,c]=this.internal.telem.value();this.checkEmpty(),this.values=c,this.requestRender()}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender()}checkEmpty(){const e=this.values.length===0;e!==this.state.empty&&this.setState(t=>({...t,empty:e}))}afterDelete(){const{telem:e,render:t}=this.internal;e.cleanup?.(),t.erase(i.Ho.construct(this.state.region),i.K.ZERO,$e)}requestRender(){const{render:e}=this.internal;e.loop.set({key:`${this.type}-${this.key}`,render:()=>this.render(),priority:"high",canvases:[$e]})}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((i.Ho.height(this.state.region)-12)/this.lineHeight),this.values.length)}render(){const{render:e}=this.internal,t=this.state.region;if(i.Ho.areaIsZero(t))return;if(!this.state.visible)return()=>e.erase(t,i.K.ZERO,$e);let r;if(!this.state.scrolling)r=this.values.subIterator(this.values.length-this.visibleLineCount,this.values.length);else{const c=this.values.traverseAlignment(this.scrollState.offset,-BigInt(this.visibleLineCount));r=this.values.subAlignmentSpanIterator(c,this.visibleLineCount)}const s=this.state.region,o=e[$e],a=new Ie(o,this.internal.theme),l=e.scissor(s,i.K.ZERO,[$e]);this.renderElements(a,r),this.renderScrollbar(a),l();const u=i.Ho.copy(this.state.region);return({canvases:c})=>e.erase(u,this.state.overshoot,...c)}renderScrollbar(e){const t=this.state.region,r=i.Ho.height(t)/this.totalHeight*i.Ho.height(t);if(r>=i.Ho.height(t)*_u)return;let s=i.Ho.bottom(t)-r;this.state.scrolling&&(s-=Number(this.values.distance(this.values.alignmentBounds.upper,this.scrollState.offset))/this.values.length*i.Ho.height(t)),s<0&&(s=i.Ho.top(t)),e.container({region:i.Ho.construct({x:i.Ho.right(t)-6,y:s},{width:6,height:r}),bordered:!1,backgroundColor:o=>o.colors.gray.l6})}renderElements(e,t){const r=this.state.region;let s=0;for(const o of t){const a=this.values.dataType.equals(i.n.JSON)?JSON.stringify(o):o.toString();e.text({text:a,level:this.state.font,shade:11,position:i.K.translate(i.Ho.topLeft(r),{x:6,y:s*this.lineHeight+6}),code:!0}),s++}}}const zu={[Je.TYPE]:Je},Tr=d.z.object({one:i.K.xy.nullable(),two:i.K.xy.nullable(),hover:i.K.xy.nullable(),color:d.z.union([i.cr.colorZ,d.z.object({verticalLine:i.cr.colorZ.optional().default(i.cr.ZERO),horizontalLine:i.cr.colorZ.optional().default(i.cr.ZERO),obliqueLine:i.cr.colorZ.optional().default(i.cr.ZERO)})]).optional().default(i.cr.ZERO),strokeWidth:d.z.number().optional().default(1),strokeDash:d.z.number().optional().default(2)});class et extends p.Leaf{static TYPE="measure";schema=Tr;afterUpdate(e){const t=p.Context.use(e);this.internal.theme=p.use(e),this.internal.renderCtx=t,this.internal.draw=new Ie(t.upper2d,this.internal.theme),X(e,"tool")}afterDelete(e){X(e,"layout")}get verticalLineColor(){return i.cr.isColor(this.state.color)?i.cr.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:i.cr.isZero(this.state.color.verticalLine)?this.internal.theme.colors.gray.l8:this.state.color.verticalLine}get horizontalLineColor(){return i.cr.isColor(this.state.color)?i.cr.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:i.cr.isZero(this.state.color.horizontalLine)?this.internal.theme.colors.gray.l8:this.state.color.horizontalLine}get obliqueLineColor(){return i.cr.isColor(this.state.color)?i.cr.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:i.cr.isZero(this.state.color.obliqueLine)?this.internal.theme.colors.gray.l8:this.state.color.obliqueLine}find(e){const{one:t,two:r}=this.state;if(t==null||r==null)return null;const{one:s,two:o}=this.prevState,{dataOne:a,dataTwo:l}=this.internal;if(s!=null&&i.K.equals(t,s)&&o!=null&&i.K.equals(r,o)&&a!=null&&l!=null){const[b,S]=[e.findByXValue(a.x),e.findByXValue(l.x)];return b.length===0||S.length===0?null:[b.sort((C,O)=>i.K.distance(a,C.value)-i.K.distance(a,O.value))[0],S.sort((C,O)=>i.K.distance(l,C.value)-i.K.distance(l,O.value))[0]]}const u=i.C.XY.scale(e.region).scale(i.Ho.DECIMAL),[c,h]=[u.pos(t),u.pos(r)],[f,g]=[e.findByXDecimal(c.x),e.findByXDecimal(h.x)];if(f.length===0||g.length===0)return null;const[y,w]=[f.sort((b,S)=>i.K.distance(c,b.position)-i.K.distance(c,S.position))[0],g.sort((b,S)=>i.K.distance(h,b.position)-i.K.distance(h,S.position))[0]];return this.internal.dataOne=y.value,this.internal.dataTwo=w.value,[y,w]}renderHover(e){if(this.state.hover==null)return;const t=this.state.hover,r=i.C.XY.scale(e.region).scale(i.Ho.DECIMAL),s=r.pos(t),o=e.findByXDecimal(r.pos(t).x);if(o.length===0)return;const a=o.sort((u,c)=>i.K.distance(s,u.position)-i.K.distance(s,c.position))[0],{draw:l}=this.internal;l.circle({fill:i.cr.setAlpha(a.color,.5),radius:9,position:r.reverse().pos(a.position)})}render(e){if(this.deleted)return;this.renderHover(e);const t=this.find(e);if(t==null)return;const[r,s]=t,{draw:o}=this.internal,{strokeDash:a,strokeWidth:l}=this.state,u=i.C.XY.scale(i.Ho.DECIMAL).scale(e.region),c=u.pos(r.position),h=u.pos(s.position),f=new i.i(Math.abs(r.value.x-s.value.x)),g=Math.abs(r.value.y-s.value.y),y=g/f.seconds;o.line({start:i.K.construct(c.x,c.y),end:i.K.construct(c.x,h.y),stroke:this.verticalLineColor,lineDash:a,lineWidth:l}),o.textContainer({text:[`${g.toFixed(2)} ${r.units??""}`],direction:"x",position:i.K.construct(c.x,(c.y+h.y)/2),level:"small"}),o.line({start:i.K.construct(c.x,h.y),end:i.K.construct(h.x,h.y),stroke:this.horizontalLineColor,lineDash:a,lineWidth:l}),o.textContainer({text:[f.truncate(i.i.MILLISECOND).toString()],direction:"x",position:i.K.construct((c.x+h.x)/2,h.y),level:"small"}),o.line({start:i.K.construct(c.x,c.y),end:i.K.construct(h.x,h.y),stroke:this.obliqueLineColor,lineDash:a,lineWidth:l}),o.textContainer({text:[`${y.toFixed(2)} ${r.units??""} / S`],direction:"x",position:i.K.construct((c.x+h.x)/2,(c.y+h.y)/2),level:"small"}),o.circle({fill:i.cr.setAlpha(r.color,.5),radius:8,position:c}),o.circle({fill:i.cr.setAlpha(r.color,.8),radius:5,position:c}),o.circle({fill:i.cr.WHITE,radius:2,position:c}),o.circle({fill:i.cr.setAlpha(s.color,.5),radius:8,position:h}),o.circle({fill:i.cr.setAlpha(s.color,.8),radius:5,position:h}),o.circle({fill:i.cr.WHITE,radius:2,position:h})}}const eo={[et.TYPE]:et},Au=Object.freeze(Object.defineProperty({__proto__:null,Measure:et,REGISTRY:eo,measureStateZ:Tr},Symbol.toStringTag,{value:"Module"})),to=d.z.object({trigger:d.z.number(),command:d.z.number().optional(),value:d.z.number(),sink:gs.optional().default(as),source:ps.optional().default(ls)});class zn extends p.Leaf{static TYPE="Setpoint";schema=to;afterUpdate(e){const{sink:t,source:r,trigger:s,command:o}=this.state,{internal:a}=this;a.prevTrigger??=s,(async()=>{this.internal.source=q(e,r,this.internal.source),a.sink=rt(e,t,a.sink);const l=a.prevTrigger;a.prevTrigger=s,s>l&&o!=null&&this.internal.sink.set(o),this.updateValue(),a.stopListening?.(),a.stopListening=a.source.onChange(()=>this.updateValue())})()}updateValue(){const e=this.internal.source.value();e!==this.state.value&&this.setState(t=>({...t,value:e,triggered:!1}))}afterDelete(){const{internal:e}=this;e.stopListening(),e.source.cleanup?.(),e.sink.cleanup?.()}}const Hu={[zn.TYPE]:zn},no=d.z.object({triggered:d.z.boolean(),enabled:d.z.boolean(),sink:Gt.optional().default(Kt),source:$n.optional().default(Bn)});class An extends p.Leaf{static TYPE="Toggle";schema=no;afterUpdate(e){this.internal.addStatus=p.useOptionalAdder(e);const{sink:t,source:r,triggered:s,enabled:o}=this.state,{triggered:a}=this.prevState,{internal:l}=this;l.source=q(e,r,l.source),l.sink=rt(e,t,l.sink),s&&!a&&l.sink.set(!o),this.updateEnabledState(),l.stopListening?.(),l.stopListening=l.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();e!==this.state.enabled&&this.setState(t=>({...t,enabled:e,triggered:!1}))}afterDelete(){this.internal.stopListening(),this.internal.source.cleanup?.(),this.internal.sink.cleanup?.()}}const Iu={[An.TYPE]:An},un={useAtlas:!0},Zu=d.z.object({box:i.Ho.box,telem:Kn.optional().default(cs),backgroundTelem:qn.optional().default(Wt),level:p.levelZ.optional().default("p"),color:i.cr.colorZ.optional().default(i.cr.ZERO),precision:d.z.number().optional().default(2),minWidth:d.z.number().optional().default(60),width:d.z.number().optional(),notation:i.br.notationZ.optional().default("standard"),location:i.K$1.xy.optional().default({x:"left",y:"center"}),useWidthForBackground:d.z.boolean().optional().default(!1),valueBackgroundShift:i.K.xy.optional().default(i.K.ZERO),valueBackgroundOverScan:i.K.xy.optional().default(i.K.ZERO)}),Nu=["upper2d","lower2d"];class Ae extends p.Leaf{static TYPE="value";static z=Zu;schema=Ae.z;afterUpdate(e){const{internal:t}=this;t.renderCtx=p.Context.use(e),t.theme=p.use(e),i.cr.isZero(this.state.color)?t.textColor=t.theme.colors.gray.l10:t.textColor=this.state.color,t.telem=q(e,this.state.telem,t.telem),t.stopListening?.(),t.stopListening=t.telem.onChange(()=>this.requestRender()),t.fontString=qe.fontString(t.theme,{level:this.state.level,code:!0}),t.backgroundTelem=q(e,this.state.backgroundTelem,t.backgroundTelem),t.stopListeningBackground?.(),t.stopListeningBackground=t.backgroundTelem.onChange(()=>this.requestRender()),t.requestRender=os(e),this.requestRender()}afterDelete(){const{internal:e}=this;e.stopListening?.(),e.stopListeningBackground?.(),e.telem.cleanup?.(),e.backgroundTelem.cleanup?.(),e.requestRender==null?e.renderCtx.erase(i.Ho.construct(this.state.box),i.K.ZERO,...Nu):e.requestRender("layout")}requestRender(){const{requestRender:e}=this.internal;e!=null?e("layout"):this.render({})}get fontHeight(){const{theme:e}=this.internal;return e.typography[this.state.level].size*e.sizes.base}maybeUpdateWidth(e){const{theme:t}=this.internal,r=e+t.sizes.base+this.fontHeight;this.state.width==null||this.state.width+this.fontHeight*.5<r||this.state.minWidth>r&&this.state.width!==this.state.minWidth?this.setState(s=>({...s,width:Math.max(r,s.minWidth)})):this.state.width-this.fontHeight>r&&this.setState(s=>({...s,width:Math.max(r,s.minWidth)}))}render({viewportScale:e=i.C.XY.IDENTITY}){const{renderCtx:t,telem:r,backgroundTelem:s,fontString:o,requestRender:a}=this.internal,{location:l,box:u}=this.state;if(i.Ho.areaIsZero(u))return;const c=i.Ho.topLeft(u),h=i.Ho.width(u),f=i.Ho.height(u),g=t.lower2d.applyScale(e);let y=r.value();g.font=o;const w=this.fontHeight,b=y[0]=="-";b&&(y=y.slice(1));const{theme:S}=this.internal,C=g.textDimensions(y,un),O=C.width+S.sizes.base,P=C.height;a==null&&t.erase(i.Ho.construct(this.prevState.box)),this.maybeUpdateWidth(O);const D={...i.K.ZERO};l.x==="left"?D.x=6+w*.75:l.x==="center"&&(D.x=h/2-O/2),l.y==="center"&&(D.y=f/2+P/2);const _=i.K.translate(c,D);let x=!0;if(this.state.backgroundTelem.type!=Wt.type){const L=s.value();if(!i.cr.isZero(L)){x=!1,g.fillStyle=i.cr.hex(L);const Ze=this.state.useWidthForBackground?this.state.width??this.state.minWidth:i.Ho.width(u);g.fillRect(...i.K.couple(i.K.translate(c,this.state.valueBackgroundShift)),Ze+this.state.valueBackgroundOverScan.x,f+this.state.valueBackgroundOverScan.y);const pe=i.cr.pickByContrast(L,S.colors.gray.l0,S.colors.gray.l11);g.fillStyle=i.cr.hex(pe)}}x&&(g.fillStyle=i.cr.hex(this.internal.textColor)),b&&g.fillText("-",...i.K.couple(i.K.translateX(_,-w*.6)),void 0,un),g.fillText(y,...i.K.couple(_),void 0,un)}}const ro={[Ae.TYPE]:Ae},Bu=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:ro,Value:Ae},Symbol.toStringTag,{value:"Module"}));class so{entries=new Map;setListeners=new Map;deleteListeners=new Map;handleError;equal;constructor(e,t=()=>!1){this.handleError=e,this.equal=t}set(e,t,r){if(Array.isArray(t))return t.forEach(a=>this.set(e,a.key,a));const s=this.entries.get(t),o=p.executeSetter(r,s);o==null||s!=null&&this.equal(o,s,t)||(this.entries.set(t,o),this.notifySet(e,t,o))}get(e){return typeof e=="function"?Array.from(this.entries.values()).filter(e):Array.isArray(e)?e.map(t=>this.entries.get(t)).filter(t=>t!=null):this.entries.get(e)}list(){return Array.from(this.entries.values())}has(e){return this.entries.has(e)}delete(e,t){p.t.toArray(t).forEach(r=>{this.entries.delete(r),this.notifyDelete(e,r)})}clear(){this.entries.clear()}onSet(e,t,r){return this.setListeners.set(t,{scope:e,key:r}),()=>{this.setListeners.delete(t)}}onDelete(e,t,r){return this.deleteListeners.set(t,{scope:e,key:r}),()=>this.deleteListeners.delete(t)}notifySet(e,t,r){this.setListeners.forEach((s,o)=>{const a=s.key==null||s.key===t,l=s.scope!==e;a&&l&&this.handleError(async()=>o(r),"Failed to notify set listener")})}notifyDelete(e,t){this.deleteListeners.forEach((r,s)=>{const o=r.key==null||r.key===t,a=r.scope!==e;o&&a&&this.handleError(async()=>s(t),"Failed to notify delete listener")})}scope(e){return{set:(t,r)=>this.set(e,t,r),get:t=>this.get(t),list:()=>this.list(),has:t=>this.has(t),delete:t=>this.delete(e,t),onSet:(t,r)=>this.onSet(e,t,r),onDelete:(t,r)=>this.onDelete(e,t,r)}}}const io=(n,e)=>Object.fromEntries(Object.entries(n).map(([t,{equal:r}])=>[t,new so(e,r)])),Hn=(n,e)=>Object.fromEntries(Object.entries(n).map(([t])=>[t,n[t].scope(e)])),Uu=(n,e)=>{const t=n.includes("delete"),r=e.includes("delete");return t&&!r?-1:!t&&r?1:0},$u=async({openStreamer:n,storeConfig:e,handleError:t,client:r,store:s})=>{const o=Object.values(e),a=i.c.unique(o.flatMap(({listeners:f})=>f.map(({channel:g})=>g))),l={};o.forEach(({listeners:f})=>f.forEach(g=>{const{channel:y}=g;l[y]=[...l[y]||[],g]}));const u=await p.fw.HardenedStreamer.open(n,a),c=new p.fw.ObservableStreamer(u),h=f=>{const g=[...f.uniqueNames];g.sort(Uu),t(async()=>{for(const y of g){const w=f.get(y),b=l[y];if(b!=null)for(const{onChange:S,schema:C}of b)await t(async()=>{let O;w.dataType.equals(i.n.JSON)?O=w.parseJSON(C):O=Array.from(w).map(P=>C.parse(P));for(const P of O)await t(()=>S({changed:P,client:r,store:s}),`Failed to handle streamer change for ${y}`,p._t)},`Failed to parse streamer change for ${y}`)}},`Failed to handle streamer change for ${i.vr.naturalLanguageJoin(g)}`)};return c.onChange(h),c.close.bind(c)};class oo{store;streamCloser=null;client;constructor({client:e,openStreamer:t,storeConfig:r,handleError:s,handleAsyncError:o}){this.store=io(r,s),this.client=e,e!=null&&(t??=e?.openStreamer.bind(e),this.streamCloser=$u({client:e,storeConfig:r,handleError:o,store:Hn(this.store,""),openStreamer:t}))}async awaitInitialized(){this.streamCloser!=null&&await this.streamCloser}scopedStore(e){return Hn(this.store,e)}async close(){if(this.streamCloser==null)return;await(await this.streamCloser)()}}const ao=d.object({}),In="flux-context",Er="flux.Provider",qu=(n,e)=>n.get(In).scopedStore(e),Fu=n=>{const e=(t,r)=>{if("client"in n)return n.client;const s=He(t);return r!=null&&r?.client?.key===s?.key?r:new oo({client:s,storeConfig:n.storeConfig,handleError:p.useErrorHandler(t),handleAsyncError:p.useAsyncErrorHandler(t)})};return class lo extends p.Composite{static TYPE=Er;static stateZ=ao;schema=lo.stateZ;afterUpdate(r){const{internal:s}=this;s.store=e(r,s.store),r.wasSetPreviously(In)||r.set(In,s.store)}}},Ku=n=>({[Er]:Fu(n)}),Wu=p.Iw.payloadZ.extend({viewport:i.H.bounds}),co=d.z.object({cursor:i.K.xy.or(d.z.null()),hovered:Wu.or(d.z.null()),count:d.z.number()});class Bt extends p.Leaf{static TYPE="range-provider";schema=co;fetchedInitial=i.O.ZERO;afterUpdate(e){const{internal:t}=this;t.render=p.Context.use(e),t.draw=new Ie(t.render.upper2d,p.use(e)),t.requestRender=Ft(e),t.runAsync=p.useErrorHandler(e),t.ranges??=new Map;const r=He(e);if(t.requestRender("tool"),r==null)return;t.client=r;const s=qu(e,this.key);t.removeListener?.();const o=s.ranges.onSet(l=>{t.client!=null&&(i.cr.isCrude(l.color)&&t.ranges.set(l.key,t.client.ranges.sugarOne(l)),this.setState(u=>({...u,count:t.ranges.size})),t.requestRender("tool"))}),a=s.ranges.onDelete(async l=>{t.ranges.delete(l),this.setState(u=>({...u,count:t.ranges.size})),t.requestRender("tool")});t.removeListener=()=>{o(),a()}}fetchInitial(e){const{internal:t}=this,{client:r,runAsync:s}=t;r==null||this.fetchedInitial.equals(e,i.i.minutes(1))||(this.fetchedInitial=e,s(async()=>{(await r.ranges.retrieve(e)).forEach(a=>{i.cr.isCrude(a.color)&&t.ranges.set(a.key,a)}),this.setState(a=>({...a,count:t.ranges.size}))},"failed to fetch initial ranges"))}render(e){const{dataToDecimalScale:t,region:r,viewport:s,timeRange:o}=e;this.fetchInitial(o);const{draw:a,ranges:l}=this.internal,u=t.scale(i.Ho.xBounds(r)),c=this.state.cursor==null?null:this.state.cursor.x;let h=null;const f=a.canvas.scissor(i.Ho.construct({x:i.Ho.left(r),y:i.Ho.top(r)-35},{x:i.Ho.right(r),y:i.Ho.bottom(r)}));l.forEach(g=>{const y=i.cr.colorZ.safeParse(g.color);if(!y.success)return;const w=y.data;let b=u.pos(Number(g.timeRange.start.valueOf()));const S=u.pos(Number(g.timeRange.end.valueOf()));if(S<i.Ho.left(r)||b>i.Ho.right(r))return;b=i.R(b,i.Ho.left(r)-2,i.Ho.right(r)-1);let C=!1;c!=null&&(C=i.H.contains({lower:b,upper:S},c)),C&&(h={key:g.key,parent:g.parent,name:g.name,color:g.color,labels:g.labels,timeRange:g.timeRange,viewport:{lower:t.scale(i.Ho.xBounds(s)).pos(Number(g.timeRange.start.valueOf())),upper:t.scale(i.Ho.xBounds(s)).pos(Number(g.timeRange.end.valueOf()))}}),a.container({region:i.Ho.construct({x:b,y:i.Ho.top(r)-1},{x:S,y:i.Ho.bottom(r)-1}),backgroundColor:i.cr.setAlpha(w,.2),bordered:!1});const O=i.Ho.construct({x:b+1,y:i.Ho.top(r)-34},{x:S-1,y:i.Ho.top(r)-12});a.container({region:O,backgroundColor:i.Ho.width(O)<20?i.cr.setAlpha(w,.4):P=>C?P.colors.gray.l2:P.colors.gray.l0,bordered:!0,borderWidth:1,borderRadius:2,borderColor:i.cr.setAlpha(w,.8)}),a.text({text:g.name,position:{x:b+8,y:i.Ho.top(r)-30},level:"small",shade:10,weight:500,maxWidth:S-b-16})}),f(),h!=null?this.setState(g=>({...g,hovered:h})):this.state.hovered&&this.setState(g=>({...g,hovered:null}))}}const ju={[Rn.TYPE]:Rn,[Bt.TYPE]:Bt},Gu=at;class Ut extends ki{static TYPE="XAxis";schema=at;render(e){if(this.deleted)return;const[t,r]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(this.renderAxis(e,t.reverse()),this.renderYAxes(e,t),this.renderRangeAnnotations(e,t),r!=null)throw r}findByXDecimal(e,t){const[r,s]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(s!=null)throw s;return this.findByXValue(e,r.reverse().pos(t))}findByXValue(e,t){const[r,s]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(s!=null)throw s;const o={...e,xDataToDecimalScale:r};return this.yAxes.map(a=>a.findByXValue(o,t)).flat()}renderYAxes(e,t){const r={...e,xDataToDecimalScale:t};this.yAxes.forEach(s=>s.render(r))}get yAxes(){return this.childrenOfType(At.TYPE)}get rangeAnnotations(){return this.childrenOfType(Bt.TYPE)}bounds(e){const[t,r]=this.iBounds(e,this.dataBounds.bind(this));if(r!=null)throw r;return t}renderRangeAnnotations(e,t){const r=this.bounds(e.hold);this.rangeAnnotations.forEach(s=>s.render({dataToDecimalScale:t,region:e.plot,viewport:e.viewport,timeRange:new i.O(r.lower,r.upper)}))}dataBounds(){return this.yAxes.map(e=>e.xBounds())}}const uo=d.z.object({container:i.Ho.box,viewport:i.Ho.box,hold:d.z.boolean().optional().default(!1),grid:d.z.record(d.z.string(),ni),visible:d.z.boolean().optional().default(!0),clearOverScan:i.K.crudeZ.optional().default(i.K.ZERO)}),Vu=(n,e)=>{const t=i.Ho.width(n)*Math.sqrt(i.Ho.height(n)),r=i.Ho.width(e)*Math.sqrt(i.Ho.height(e));return t/r},Xu=["upper2d","lower2d","gl"],Qu=["upper2d"];class Zn extends p.Composite{static TYPE="LinePlot";schema=uo;afterUpdate(e){this.internal.instrumentation=p.useInstrumentation(e,"lineplot"),this.internal.handleError=p.useErrorHandler(e),this.internal.renderCtx=p.Context.use(e),qt(e,t=>{this.state.visible&&this.requestRender("low",t)}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender("high","layout")}afterDelete(e){this.internal.renderCtx=p.Context.use(e),this.requestRender("high","layout")}findByXDecimal(e){const t={...this.state,plot:this.calculatePlot(),exposure:this.exposure};return this.axes.flatMap(r=>r.findByXDecimal(t,e)).flat()}findByXValue(e){const t={...this.state,plot:this.calculatePlot(),exposure:this.exposure};return this.axes.flatMap(r=>r.findByXValue(t,e)).flat()}get axes(){return this.childrenOfType(Ut.TYPE)}get tooltips(){return this.childrenOfType(Qe.TYPE)}get measures(){return this.childrenOfType(et.TYPE)}get bounds(){return this.childrenOfType(Pt.TYPE)}get exposure(){return Vu(this.state.viewport,this.state.container)}renderAxes(e,t){const r={...this.state,plot:e,canvases:t,exposure:this.exposure};this.axes.forEach(s=>s.render(r))}renderTooltips(e,t){const r={findByXDecimal:this.findByXDecimal.bind(this),region:e,canvases:t};this.tooltips.forEach(s=>s.render(r))}renderBounds(){this.bounds.forEach(e=>e.render({getBounds:()=>{const t={};return this.axes.forEach(r=>{const s=r.state.axisKey??r.key;t[s]=r.bounds(this.state.hold),r.yAxes.forEach(o=>{const a=o.state.axisKey??o.key;t[a]=o.bounds(this.state.hold)})}),t}}))}renderMeasures(e){const t={findByXDecimal:this.findByXDecimal.bind(this),findByXValue:this.findByXValue.bind(this),region:e};this.measures.forEach(r=>r.render(t))}calculatePlot(){return ga(this.state.grid,this.state.container)}render(e){const{instrumentation:t,renderCtx:r,handleError:s}=this.internal;if(this.deleted){t.L.debug("deleted, skipping render",{key:this.key});return}if(!this.state.visible)return t.L.debug("not visible, skipping render",{key:this.key}),({canvases:h})=>r.erase(this.state.container,this.state.clearOverScan,...h);const o=this.calculatePlot();t.L.debug("rendering",{key:this.key,viewport:this.state.viewport,container:this.state.container,grid:this.state.grid,plot:o,canvases:e});const a=i.K.construct(this.state.clearOverScan),l=r.scissor(this.state.container,a,e.filter(h=>h!=="gl")),u=r.scissor(o,i.K.ZERO,e.filter(h=>h==="gl"));try{this.renderAxes(o,e),this.renderTooltips(o,e),this.renderMeasures(o),this.renderBounds()}catch(h){s(h,"failed to render line plot")}finally{l(),u()}t.L.debug("rendered",{key:this.key});const c=i.Ho.copy(this.state.container);return({canvases:h})=>r.erase(c,this.state.clearOverScan,...h)}requestRender(e,t){const{renderCtx:r}=this.internal;let s=Xu;t==="tool"&&(s=Qu),r.loop.set({key:`${this.type}-${this.key}`,render:()=>this.render(s),priority:e,canvases:s})}}const Ju={[Zn.TYPE]:Zn,[Ut.TYPE]:Ut,[At.TYPE]:At,[Pt.TYPE]:Pt};exports.AcquireChannelControl=It;exports.Annotation=Rn;exports.AuthoritySource=Zt;exports.Base=fe;exports.BaseProvider=Me;exports.Bottom=xi;exports.BoundQuerier=Pt;exports.Button=_n;exports.Canvas=Nt;exports.Chip=On;exports.Client=oo;exports.Controller=Mn;exports.Diagram=Pu;exports.Diagram$1=ce;exports.FLUX_STORE_CONFIG=gu;exports.FLUX_STORE_KEY=du;exports.Indicator=Dn;exports.Legend=Ln;exports.Light=Yn;exports.Line=zt;exports.LinePlot=Zn;exports.Log=Je;exports.MODES=Fi;exports.MOUSE_DOWN_INCREMENT=Wi;exports.MOUSE_UP_INCREMENT=ji;exports.Measure=et;exports.PROVIDER_TYPE=Er;exports.Provider=Bt;exports.Provider$1=Ct;exports.REGISTRY=yu;exports.REGISTRY$1=zu;exports.REGISTRY$10=eo;exports.REGISTRY$11=Ju;exports.REGISTRY$12=su;exports.REGISTRY$13=ku;exports.REGISTRY$14=Vi;exports.REGISTRY$15=xu;exports.REGISTRY$16=Gi;exports.REGISTRY$17=Eu;exports.REGISTRY$2=ro;exports.REGISTRY$3=Qi;exports.REGISTRY$4=Iu;exports.REGISTRY$5=ei;exports.REGISTRY$6=Gs;exports.REGISTRY$7=Hu;exports.REGISTRY$8=Mi;exports.REGISTRY$9=ju;exports.Right=Ei;exports.Rule=Ve;exports.STATUSES=Ai;exports.ScopedUnaryStore=so;exports.SetChannelValue=Ht;exports.Setpoint=zn;exports.StateProvider=Xe;exports.Table=ze;exports.Toggle=An;exports.Tooltip=Qe;exports.Top=Ti;exports.Value=Ae;exports.XAxis=Ut;exports.YAxis=At;exports.ZERO_CONTEXT_VALUE=sr;exports.a=$t;exports.acquireChannelControl=bu;exports.acquireChannelControlPropsZ=Ni;exports.aether=cu;exports.annotationStateZ=Di;exports.authoritySource=wu;exports.authoritySourceDetailsZ=Su;exports.authoritySourceProps=Bi;exports.axisStateZ=vr;exports.boundQuerierStateZ=ti;exports.buttonStateZ=Ki;exports.canvas=Cu;exports.canvasStateZ=Sr;exports.channelData=xs;exports.chipStateZ=_i;exports.chipStatusDetailsZ=Li;exports.color=De;exports.colorGradient=Is;exports.control=qt;exports.controllerStateZ=Ii;exports.coreAxisStateZ=at;exports.createRegistry=Ku;exports.createStore=io;exports.diagramStateZ=wr;exports.external=da;exports.indicatorStateZ=$i;exports.indicatorStatusDetailsZ=Ui;exports.interpolate=Jt;exports.interpolateNumber=je;exports.interpolateRgb=Tn;exports.interpolateString=ai;exports.legendStateZ=qi;exports.linePlotStateZ=uo;exports.logState=Ji;exports.measure=Au;exports.measureStateZ=Tr;exports.newCanvas=wi;exports.newTickFactory=Pn;exports.parseAutoBounds=Ri;exports.provider=qo;exports.providerStateZ=co;exports.providerStateZ$1=ao;exports.providerStateZ$2=or;exports.regions=ie;exports.request=X;exports.rollingAverage=As;exports.rollingAverageProps=tr;exports.ruleStateZ=br;exports.scaleNumber=Ns;exports.scopeStore=Hn;exports.setChannelValue=vu;exports.setChannelValuePropsZ=Zi;exports.setpoint=Ds;exports.setpointStateZ=to;exports.sinkPipeline=bs;exports.sinkPipelinePropsZ=Vn;exports.sourcePipeline=vs;exports.sourcePipelinePropsZ=jn;exports.stateProviderStateZ=Yi;exports.stateZ=Oi;exports.stateZ$1=Xi;exports.statusZ=Hi;exports.streamChannelData=Ts;exports.streamChannelValue=Es;exports.streamChannelValuePropsZ=Xn;exports.stringSourceSpecZ=Kn;exports.stringifyNumber=zs;exports.stringifyNumberProps=er;exports.sugaredStateZ=zi;exports.tickFactoryProps=yr;exports.tickType=mr;exports.toggleStateZ=no;exports.tooltip=Lu;exports.tooltipStateZ=xr;exports.useOptionalRequestor=os;exports.useRequestor=Ft;exports.value=Bu;exports.withinBounds=Ls;exports.withinBoundsProps=Jn;exports.withinSizeThreshold=Ci;exports.xAxisStateZ=Gu;exports.yAxisStateZ=uu;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const f=require("./jsx-runtime-CITbqOLs.cjs"),x=require("./Editable-
|
|
1
|
+
"use strict";const f=require("./jsx-runtime-CITbqOLs.cjs"),x=require("./Editable-7Abx7gK5.cjs"),a=({value:e,onClick:o,onChange:n,checkedVariant:s="filled",uncheckedVariant:i,rightClickToggle:r=!1,...u})=>f.jsxRuntimeExports.jsx(x.Button,{onClick:t=>{o?.(t),!r&&n(!e)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),r&&n(!e)},variant:e?s:i,...u});exports.Toggle=a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { j as o } from "./jsx-runtime-C5mzlN2N.js";
|
|
2
|
-
import { C as t } from "./css-
|
|
2
|
+
import { C as t } from "./css-BlHGoCgb.js";
|
|
3
3
|
const i = ({ href: e, className: r, ...s }) => /* @__PURE__ */ o.jsx("video", { className: t(t.B("video"), r), ...s, children: /* @__PURE__ */ o.jsx("source", { id: e, src: e, type: "video/mp4" }) }), m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
4
|
__proto__: null,
|
|
5
5
|
Video: i
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./jsx-runtime-CITbqOLs.cjs"),s=require("./css-
|
|
1
|
+
"use strict";const o=require("./jsx-runtime-CITbqOLs.cjs"),s=require("./css-CZ_XGkIB.cjs"),r=({href:e,className:t,...i})=>o.jsxRuntimeExports.jsx("video",{className:s.CSS(s.CSS.B("video"),t),...i,children:o.jsxRuntimeExports.jsx("source",{id:e,src:e,type:"video/mp4"})}),c=Object.freeze(Object.defineProperty({__proto__:null,Video:r},Symbol.toStringTag,{value:"Module"}));exports.Video=c;
|
package/dist/button.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-DE-uFhwW.cjs");exports.Button=e.external;
|
package/dist/button.js
CHANGED
package/dist/color.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-DSkHe-2Y.cjs");exports.Color=e.external;
|
package/dist/color.js
CHANGED