@synnaxlabs/pluto 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/{Animated-DjcnDVGC.cjs → Animated-Cbt7tqBk.cjs} +1 -1
  2. package/dist/{Animated-DPIV1IH6.js → Animated-DGp8qHGT.js} +2 -2
  3. package/dist/{Keyboard-CJLEUbYu.cjs → Keyboard-BjnOIJ5V.cjs} +1 -1
  4. package/dist/{Keyboard-BLHHROrq.js → Keyboard-HZ6Llqo5.js} +2 -2
  5. package/dist/{LinePlot-C9MVJErC.js → LinePlot-Dw8vQLJw.js} +154 -148
  6. package/dist/LinePlot-tnVASicV.cjs +66 -0
  7. package/dist/{Link-C3NUk5cp.cjs → Link-CmzvCQDi.cjs} +1 -1
  8. package/dist/{Link-BsqVxj6V.js → Link-j-xpQ9HD.js} +1 -1
  9. package/dist/List-BX3MLMNz.cjs +1 -0
  10. package/dist/List-BlgM15Pf.js +22 -0
  11. package/dist/{Pack-mkZBsSIU.js → Pack-B5JX1aqf.js} +5 -5
  12. package/dist/{Pack-CBNcamuh.cjs → Pack-D93gFUU9.cjs} +1 -1
  13. package/dist/Toggle-BvWOTk9-.cjs +188 -0
  14. package/dist/{Toggle-W4K3cLf7.js → Toggle-Cq3FTFfq.js} +8169 -8032
  15. package/dist/{Video-Kb-c-N69.cjs → Video-D382cbrn.cjs} +1 -1
  16. package/dist/{Video-C2EYBKLN.js → Video-DIIo17du.js} +1 -1
  17. package/dist/{aggregator-BZJAV5yZ.js → aggregator-BIhLPgXc.js} +4811 -4482
  18. package/dist/aggregator-CaPKb9Zv.cjs +51 -0
  19. package/dist/align.cjs +1 -1
  20. package/dist/align.js +1 -1
  21. package/dist/button.cjs +1 -1
  22. package/dist/button.js +1 -1
  23. package/dist/color.cjs +1 -1
  24. package/dist/color.js +1 -1
  25. package/dist/css-BNL3vU5o.cjs +1 -0
  26. package/dist/{css-TXuXKs3A.js → css-CDB-JY4S.js} +358 -352
  27. package/dist/css.cjs +1 -1
  28. package/dist/css.js +2 -2
  29. package/dist/dropdown.cjs +1 -1
  30. package/dist/dropdown.js +1 -1
  31. package/dist/ether.cjs +1 -1
  32. package/dist/ether.js +5 -5
  33. package/dist/{external-BB2SaR1o.js → external-B4-opRnY.js} +1 -1
  34. package/dist/{external-BKWizK6o.cjs → external-B5j7Ee09.cjs} +1 -1
  35. package/dist/{external-DsNtnR-y.cjs → external-BCyTR9bj.cjs} +1 -1
  36. package/dist/{external-TNsi3_BK.js → external-BJI4w1QU.js} +26 -26
  37. package/dist/external-BK0QWtit.cjs +1 -0
  38. package/dist/{external-WGyRiKbb.js → external-C3TJ5wKl.js} +24 -24
  39. package/dist/{external-DlCoToEB.cjs → external-CD2dFTTj.cjs} +1 -1
  40. package/dist/{external-XoJlPNFB.js → external-CDZA7f7F.js} +2 -2
  41. package/dist/{external-mlV4Onnq.cjs → external-CFqe6ymi.cjs} +1 -1
  42. package/dist/{external-BphNoXuB.js → external-CRbJq-i4.js} +8 -8
  43. package/dist/{external-CduvGaPN.js → external-CZiW7AR4.js} +18 -18
  44. package/dist/{external-D1NnASGa.cjs → external-CjjdhnS5.cjs} +1 -1
  45. package/dist/external-D6mqXF0b.js +272 -0
  46. package/dist/external-D9eq1UnF.cjs +1 -0
  47. package/dist/external-DKxxR-uc.cjs +1 -0
  48. package/dist/{external-DjjMU4Z6.cjs → external-DUeGQ4si.cjs} +1 -1
  49. package/dist/external-DVg6hQ24.js +98 -0
  50. package/dist/external-DvFgLm4v.js +222 -0
  51. package/dist/external-IpylADnr.cjs +1 -0
  52. package/dist/external-RIKGjo5R.js +74 -0
  53. package/dist/external-jSb_axxw.js +346 -0
  54. package/dist/{external-0w2SHXg_.js → external-lDVnD7Yi.js} +2 -2
  55. package/dist/{external-CztU6wom.cjs → external-v3jmKHoB.cjs} +1 -1
  56. package/dist/external-zDAAJJHM.cjs +1 -0
  57. package/dist/header.cjs +1 -1
  58. package/dist/header.js +1 -1
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.js +3311 -3123
  61. package/dist/input.cjs +1 -1
  62. package/dist/input.js +1 -1
  63. package/dist/list.cjs +1 -1
  64. package/dist/list.js +1 -1
  65. package/dist/menu.cjs +1 -1
  66. package/dist/menu.js +1 -1
  67. package/dist/src/button/Button.d.ts +3 -1
  68. package/dist/src/button/Button.d.ts.map +1 -1
  69. package/dist/src/channel/LinePlot.d.ts +4 -1
  70. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  71. package/dist/src/dialog/index.d.ts +2 -0
  72. package/dist/src/dialog/index.d.ts.map +1 -0
  73. package/dist/src/dialog/use.d.ts +28 -0
  74. package/dist/src/dialog/use.d.ts.map +1 -0
  75. package/dist/src/divider/Divider.d.ts +2 -2
  76. package/dist/src/divider/Divider.d.ts.map +1 -1
  77. package/dist/src/dropdown/Dropdown.d.ts +5 -27
  78. package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
  79. package/dist/src/form/Field.d.ts +35 -0
  80. package/dist/src/form/Field.d.ts.map +1 -0
  81. package/dist/src/form/Form.d.ts +15 -45
  82. package/dist/src/form/Form.d.ts.map +1 -1
  83. package/dist/src/form/external.d.ts +1 -0
  84. package/dist/src/form/external.d.ts.map +1 -1
  85. package/dist/src/haul/Haul.d.ts +79 -2
  86. package/dist/src/haul/Haul.d.ts.map +1 -1
  87. package/dist/src/index.d.ts +4 -0
  88. package/dist/src/index.d.ts.map +1 -1
  89. package/dist/src/input/Text.d.ts +2 -0
  90. package/dist/src/input/Text.d.ts.map +1 -1
  91. package/dist/src/list/Column.d.ts +1 -0
  92. package/dist/src/list/Column.d.ts.map +1 -1
  93. package/dist/src/list/Core.d.ts.map +1 -1
  94. package/dist/src/list/Hover.d.ts.map +1 -1
  95. package/dist/src/list/Selector.d.ts +1 -7
  96. package/dist/src/list/Selector.d.ts.map +1 -1
  97. package/dist/src/list/useSelect.d.ts +5 -1
  98. package/dist/src/list/useSelect.d.ts.map +1 -1
  99. package/dist/src/menu/Menu.d.ts +5 -3
  100. package/dist/src/menu/Menu.d.ts.map +1 -1
  101. package/dist/src/modal/Modal.d.ts +8 -0
  102. package/dist/src/modal/Modal.d.ts.map +1 -0
  103. package/dist/src/modal/index.d.ts +2 -0
  104. package/dist/src/modal/index.d.ts.map +1 -0
  105. package/dist/src/mosaic/Mosaic.d.ts +1 -1
  106. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  107. package/dist/src/mosaic/tree.d.ts +1 -0
  108. package/dist/src/mosaic/tree.d.ts.map +1 -1
  109. package/dist/src/mosaic/types.d.ts +62 -0
  110. package/dist/src/mosaic/types.d.ts.map +1 -1
  111. package/dist/src/note/Note.d.ts.map +1 -1
  112. package/dist/src/observe/index.d.ts +2 -0
  113. package/dist/src/observe/index.d.ts.map +1 -0
  114. package/dist/src/observe/use.d.ts +19 -0
  115. package/dist/src/observe/use.d.ts.map +1 -0
  116. package/dist/src/os/Controls/Windows.d.ts +1 -1
  117. package/dist/src/os/Controls/Windows.d.ts.map +1 -1
  118. package/dist/src/ranger/TimeRangeChip.d.ts +3 -2
  119. package/dist/src/ranger/TimeRangeChip.d.ts.map +1 -1
  120. package/dist/src/select/List.d.ts +3 -2
  121. package/dist/src/select/List.d.ts.map +1 -1
  122. package/dist/src/select/Multiple.d.ts +3 -2
  123. package/dist/src/select/Multiple.d.ts.map +1 -1
  124. package/dist/src/select/Select.spec.d.ts.map +1 -1
  125. package/dist/src/select/Single.d.ts +5 -3
  126. package/dist/src/select/Single.d.ts.map +1 -1
  127. package/dist/src/state/state.d.ts +1 -0
  128. package/dist/src/state/state.d.ts.map +1 -1
  129. package/dist/src/status/Notification.d.ts +1 -1
  130. package/dist/src/status/Notification.d.ts.map +1 -1
  131. package/dist/src/tabs/Selector.d.ts +4 -10
  132. package/dist/src/tabs/Selector.d.ts.map +1 -1
  133. package/dist/src/tabs/Tabs.d.ts +6 -11
  134. package/dist/src/tabs/Tabs.d.ts.map +1 -1
  135. package/dist/src/tabs/external.d.ts +1 -0
  136. package/dist/src/tabs/external.d.ts.map +1 -1
  137. package/dist/src/tabs/types.d.ts +54 -0
  138. package/dist/src/tabs/types.d.ts.map +1 -0
  139. package/dist/src/text/Editable.d.ts +5 -1
  140. package/dist/src/text/Editable.d.ts.map +1 -1
  141. package/dist/src/text/WithIcon.d.ts.map +1 -1
  142. package/dist/src/tree/Tree.d.ts +7 -2
  143. package/dist/src/tree/Tree.d.ts.map +1 -1
  144. package/dist/src/tree/core.d.ts +1 -0
  145. package/dist/src/tree/core.d.ts.map +1 -1
  146. package/dist/src/triggers/Text.d.ts +1 -1
  147. package/dist/src/triggers/Text.d.ts.map +1 -1
  148. package/dist/src/triggers/hooks.d.ts +1 -1
  149. package/dist/src/triggers/hooks.d.ts.map +1 -1
  150. package/dist/src/triggers/triggers.d.ts +2 -1
  151. package/dist/src/triggers/triggers.d.ts.map +1 -1
  152. package/dist/src/util/rootElement.d.ts +2 -0
  153. package/dist/src/util/rootElement.d.ts.map +1 -0
  154. package/dist/src/viewport/use.d.ts +2 -0
  155. package/dist/src/viewport/use.d.ts.map +1 -1
  156. package/dist/src/vis/legend/Container.d.ts +99 -5
  157. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  158. package/dist/src/vis/line/aether/line.d.ts +2 -2
  159. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  160. package/dist/src/vis/render/context.d.ts.map +1 -1
  161. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  162. package/dist/style.css +1 -1
  163. package/dist/tabs.cjs +1 -1
  164. package/dist/tabs.js +1 -1
  165. package/dist/text.cjs +1 -1
  166. package/dist/text.js +2 -2
  167. package/dist/theming.cjs +1 -1
  168. package/dist/theming.js +2 -2
  169. package/dist/tree.cjs +1 -1
  170. package/dist/tree.js +1 -1
  171. package/dist/triggers.cjs +1 -1
  172. package/dist/triggers.js +1 -1
  173. package/dist/{units-DechjShe.js → units-DeLVJ01P.js} +1 -1
  174. package/dist/{units-BsHX82D_.cjs → units-MTRY0KtD.cjs} +1 -1
  175. package/dist/video.cjs +1 -1
  176. package/dist/video.js +1 -1
  177. package/package.json +4 -4
  178. package/dist/LinePlot-DkAUE5Nq.cjs +0 -68
  179. package/dist/List-BbB1S5Vo.cjs +0 -1
  180. package/dist/List-DPugi06W.js +0 -22
  181. package/dist/Toggle-BBGPiXIA.cjs +0 -188
  182. package/dist/aggregator-DueF6Q-Z.cjs +0 -45
  183. package/dist/css-DZx3bWkH.cjs +0 -1
  184. package/dist/external-B-CtJFCn.js +0 -96
  185. package/dist/external-B39SmpRo.js +0 -201
  186. package/dist/external-BbnWD0Pc.js +0 -66
  187. package/dist/external-CsPOXIEm.cjs +0 -1
  188. package/dist/external-CyiLaYmg.js +0 -322
  189. package/dist/external-DrS33VU5.cjs +0 -1
  190. package/dist/external-WzX6JA2j.cjs +0 -1
  191. package/dist/external-fg-pJfZR.js +0 -260
  192. package/dist/external-vZfda3xX.cjs +0 -1
  193. package/dist/external-vgqH7hLg.cjs +0 -1
@@ -1,68 +0,0 @@
1
- "use strict";var lh=Object.defineProperty;var uh=(t,e,n)=>e in t?lh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var m=(t,e,n)=>(uh(t,typeof e!="symbol"?e+"":e,n),n);const T=require("./aggregator-DueF6Q-Z.cjs"),M=require("zod"),f=require("./css-DZx3bWkH.cjs"),y=require("react");require("react-dom");const hh=Object.freeze(Object.defineProperty({__proto__:null,ALIGNMENTS:f.u,ORDERS:f.d,alignment:f.D,order:f.A},Symbol.toStringTag,{value:"Module"}));var fh=Object.defineProperty,dh=(t,e,n)=>e in t?fh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Xs=(t,e,n)=>(dh(t,typeof e!="symbol"?e+"":e,n),n);class ph{constructor(e,n){Xs(this,"handlers"),Xs(this,"transform"),this.transform=e,this.handlers=n??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let n=e;if(this.transform!=null){const[r,s]=this.transform(e);if(!s)return;n=r}this.handlers.forEach((r,s)=>s(n))}}class gh{constructor(e){Xs(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((n,r)=>r(e))}}const xo=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:gh,Observer:ph},Symbol.toStringTag,{value:"Module"})),mh=M.z.object({props:T.dd.nullable(),state:T.yd.connectivity.connectionStateZ.nullable()}),vo={synnax:null,state:T.yd.connectivity.DEFAULT};var fe;let wr=(fe=class extends T.Composite{constructor(){super(...arguments);m(this,"schema",fe.stateZ)}async afterUpdate(){var n;if(this.ctx.has(So)||Es(this.ctx,vo),this.state.props==null){this.internal.synnax!=null&&(this.setState(r=>({...r,state:T.yd.connectivity.DEFAULT})),(n=this.internal.synnax)==null||n.close(),this.internal.synnax=null),Es(this.ctx,this.internal);return}this.prevState.props!=null&&T._.equal(this.state.props,this.prevState.props)&&this.internal.synnax!=null||(this.internal.synnax=new T.yd(this.state.props),this.internal.synnax.connectivity.onChange(r=>this.setState(s=>({...s,state:r}))),Es(this.ctx,this.internal))}},m(fe,"TYPE","SynnaxProvider"),m(fe,"stateZ",mh),fe);const So="pluto-client-context",Es=(t,e)=>t.set(So,e),Vn=t=>t.get(So).synnax,Oa={[wr.TYPE]:wr},yh=Object.freeze(Object.defineProperty({__proto__:null,Provider:wr,REGISTRY:Oa,ZERO_CONTEXT_VALUE:vo,use:Vn},Symbol.toStringTag,{value:"Module"})),za="pluto-telem-context",os=t=>t.get(za),Ia=(t,e)=>t.set(za,e),$a=(t,e)=>os(t).registerFactory(e);class gi{constructor(e,n,r){m(this,"spec");m(this,"wrapped");m(this,"prevKey");this.wrapped=e,this.spec=r,this.prevKey=n.clusterKey}async value(){return await this.wrapped.value()}async cleanup(){var e,n;await((n=(e=this.wrapped).cleanup)==null?void 0:n.call(e))}onChange(e){return this.wrapped.onChange(e)}shouldUpdate(e,n){return this.prevKey!==e.clusterKey||!T._.equal(this.spec,n)}}class mi{constructor(e,n,r){m(this,"spec");m(this,"prov");m(this,"prevKey");m(this,"wrapped");this.wrapped=e,this.spec=r,this.prov=n,this.prevKey=n.clusterKey}async set(e){return await this.wrapped.set(e)}async cleanup(){var e,n;await((n=(e=this.wrapped).cleanup)==null?void 0:n.call(e))}shouldUpdate(e,n){return this.prevKey!==e.clusterKey||!T._.equal(this.spec,n)}}const Qt=async(t,e,n)=>{var s;const r=os(t);if(n instanceof gi){if(!n.shouldUpdate(r,e))return n;await((s=n.cleanup)==null?void 0:s.call(n))}return new gi(r.create(e),r,e)},is=async(t,e,n)=>{var s;const r=os(t);if(n instanceof mi){if(!n.shouldUpdate(r,e))return n;await((s=n.cleanup)==null?void 0:s.call(n))}return new mi(r.create(e),r,e)};class ye extends xo.Observer{async cleanup(){}}class xr extends ye{async set(){return await Promise.resolve()}}m(xr,"TYPE","noop-boolean-sink");const as={type:xr.TYPE,props:{},variant:"sink",valueType:"boolean"};class vr extends ye{async set(){return await Promise.resolve()}}m(vr,"TYPE","noop-numeric-sink");const wh={type:vr.TYPE,props:{},variant:"sink",valueType:"number"};class Sr extends ye{async value(){return await Promise.resolve(!1)}}m(Sr,"TYPE","noop-boolean-source");const La={type:Sr.TYPE,props:{},variant:"source",valueType:"boolean"};class br extends ye{async value(){return 0}}m(br,"TYPE","noop-numeric-source");const xh={type:br.TYPE,props:{},variant:"source",valueType:"number"};class Tr extends ye{async value(){return""}}m(Tr,"TYPE","noop-string-source");const Ya={type:Tr.TYPE,props:{},variant:"source",valueType:"string"};class Er extends ye{async value(){return{key:"noop",variant:"disabled",message:"unknown",time:T.m.now()}}}m(Er,"TYPE","noop-status-source");const bo={type:Er.TYPE,props:{},variant:"source",valueType:"status"};class _r extends ye{async value(){return f.ZERO}}m(_r,"TYPE","noop-color-source");const Ba={type:_r.TYPE,props:{},variant:"source",valueType:"color"},vh={[xr.TYPE]:xr,[vr.TYPE]:vr,[Sr.TYPE]:Sr,[br.TYPE]:br,[Er.TYPE]:Er,[_r.TYPE]:_r,[Tr.TYPE]:Tr};class Fa{constructor(){m(this,"type","noop")}create(e){const n=vh[e.type];return n==null?null:new n}}const Sh=M.z.instanceof(ArrayBuffer),Xn=M.z.object({type:M.z.string(),variant:M.z.enum(["source","sink","source-transformer","sink-transformer"]),valueType:M.z.string(),props:M.z.any(),transfer:M.z.array(Sh).optional()}),te=Xn.extend({variant:M.z.literal("source")}),cs=Xn.extend({variant:M.z.literal("sink")}),qa=Xn.extend({variant:M.z.literal("source-transformer")}),Ua=Xn.extend({variant:M.z.literal("sink-transformer")}),Ws=te.extend({valueType:M.z.literal("series")}),Za=te.extend({valueType:M.z.literal("boolean")}),ls=cs.extend({valueType:M.z.literal("boolean")}),bh=Ua.extend({valueType:M.z.literal("boolean")}),Th=qa.extend({valueType:M.z.literal("boolean")}),Eh=te.extend({valueType:M.z.literal("number")}),_h=cs.extend({valueType:M.z.literal("number")}),Ha=te.extend({valueType:M.z.literal("color")}),To=te.extend({valueType:M.z.literal("status")}),Va=te.extend({valueType:M.z.literal("string")});class us extends xo.BaseObserver{constructor(n){super();m(this,"props_");m(this,"uProps_");m(this,"schema");this.uProps_=n}get props(){if(this.props_==null){const n=this._schema.safeParse(this.uProps_);if(n.success)this.props_=n.data;else throw new T._$1(`[BaseTelem] - expected props to be valid, but found the following errors:
2
- ${n.error.message}`)}return this.props_}get _schema(){if(this.schema==null)throw new T._$1(`[BaseTelem] - expected subclass to define props schema, but none was found.
3
- Make sure to define a property 'schema' on the class.`);return this.schema}async cleanup(){}}class Et extends us{}class hs extends us{}class Wn extends Et{constructor(){super(...arguments);m(this,"sources",{})}get source(){const[n]=Object.values(this.sources);if(n==null)throw new T._$1("[UnarySourceTransformer] - expected source to exist, but none was found.");return n}async value(){return this.transform(await this.source.value())}onChange(n){return this.source.onChange(()=>{this.source.value().then(r=>{this.shouldNotify(r)&&n()}).catch(console.error)})}setSources(n){this.sources=n}shouldNotify(n){return!0}transform(n){throw new T._$1(`[UnarySourceTransformer] - expected subclass to define transform method, but none was found.
4
- Make sure to define a method 'transform' on the class.`)}}class Xa extends Et{constructor(){super(...arguments);m(this,"sources",{})}async value(){const n=Object.fromEntries(await Promise.all(Object.entries(this.sources).map(async([r,s])=>[r,await s.value()])));return this.transform(n)}setSources(n){this.sources={...this.sources,...n}}transform(n){throw new T._$1(`[MultiSourceTransformer] - expected subclass to define transform method, but none was found.
5
- Make sure to define a method 'transform' on the class.`)}}class Wa extends us{constructor(){super(...arguments);m(this,"sinks",{})}get sink(){const[n]=Object.values(this.sinks);if(n==null)throw new T._$1("[UnarySinkTransformer] - expected sink to exist, but none was found.");return n}async set(n){return await this.sink.set(this.transform(n))}setSinks(n){this.sinks={...this.sinks,...n}}transform(n){throw new T._$1(`[UnarySinkTransformer] - expected subclass to define transform method, but none was found.
6
- Make sure to define a method 'transform' on the class.`)}}const Ga=M.z.object({from:M.z.string(),to:M.z.string()}),Eo=M.z.object({connections:M.z.array(Ga),outlet:M.z.string(),segments:M.z.record(te)});class Ka{constructor(e){m(this,"type","pipeline");m(this,"factory");this.factory=e}create(e){switch(e.type){case Pn.TYPE:return new Pn(e.props,this.factory);case kn.TYPE:return new kn(e.props,this.factory);default:return null}}}class Pn extends Et{constructor(n,r){super(n);m(this,"schema",Eo);m(this,"sources",{});const{connections:s,segments:o}=this.props;Object.entries(o).forEach(([i,a])=>{const c=r.create(a);c!=null&&(this.sources[i]=c)}),s.forEach(({from:i,to:a})=>{const c=this.sources[i],l=this.sources[a];c==null||l==null||"setSources"in l&&l.setSources({[i]:c})})}get outlet(){const{outlet:n}=this.props,r=this.sources[n];if(r==null)throw new T._$1(`[SourcePipeline] - expected source to exist at outlet '${n}', but none was found.`);return r}async value(){return await this.outlet.value()}onChange(n){return this.outlet.onChange(n)}async cleanup(){await Promise.all(Object.values(this.sources).map(async n=>{var r;return await((r=n.cleanup)==null?void 0:r.call(n))}))}}m(Pn,"TYPE","source-pipeline");const ja=(t,e)=>({variant:"source",props:e,type:Pn.TYPE,valueType:t}),_o=M.z.object({connections:M.z.array(Ga),inlet:M.z.string(),segments:M.z.record(cs)});class kn extends hs{constructor(n,r){super(n);m(this,"schema",_o);m(this,"sinks",{});const{connections:s,segments:o}=this.props;Object.entries(o).forEach(([i,a])=>{const c=r.create(a);c!=null&&(this.sinks[i]=c)}),s.forEach(({from:i,to:a})=>{const c=this.sinks[i],l=this.sinks[a];c==null||l==null||"setSinks"in c&&c.setSinks({[a]:l})})}get inlet(){const{inlet:n}=this.props,r=this.sinks[n];if(r==null)throw new T._$1(`[SinkPipeline] - expected source to exist at inlet '${n}', but none was found.`);return r}async set(n){return await this.inlet.set(n)}async cleanup(){await Promise.all(Object.values(this.sinks).map(async n=>{var r;return await((r=n.cleanup)==null?void 0:r.call(n))}))}}m(kn,"TYPE","sink-pipeline");const Qa=(t,e)=>({variant:"sink",props:e,type:kn.TYPE,valueType:t}),Co=M.z.object({channel:M.z.number().or(M.z.string())});class Mn extends Et{constructor(n,r){super(r);m(this,"client");m(this,"removeStreamHandler",null);m(this,"channelKey",0);m(this,"schema",Co);m(this,"leadingBuffer",null);m(this,"valid",!1);this.client=n}get testingOnlyLeadingBuffer(){return this.leadingBuffer}get testingOnlyValid(){return this.valid}async cleanup(){var n,r;await((n=this.removeStreamHandler)==null?void 0:n.call(this)),this.valid=!1,(r=this.leadingBuffer)==null||r.release(),this.leadingBuffer=null,this.removeStreamHandler=null}async value(){return T.A$2(this.props.channel)||(this.channelKey===0&&(this.channelKey=(await Po(this.client,this.props.channel,!1)).key),this.valid||await this.read(),this.leadingBuffer==null||this.leadingBuffer.length===0)?0:this.leadingBuffer.at(-1,!0)}async read(){this.valid=!0,await this.updateStreamHandler()}async updateStreamHandler(){var r;await((r=this.removeStreamHandler)==null?void 0:r.call(this));const n=s=>{var a;const i=s[this.channelKey].data;if(i.length!==0){const c=i[i.length-1];c.acquire(),(a=this.leadingBuffer)==null||a.release(),this.leadingBuffer=c}this.notify()};this.removeStreamHandler=await this.client.stream(n,[this.channelKey])}}m(Mn,"TYPE","stream-channel-value");const Po=async(t,e,n)=>{const r=await t.retrieveChannel(e);return!n||r.isIndex?{key:r.key,dataType:r.dataType}:{key:r.index,dataType:T.g.TIMESTAMP}},Ch=M.z.object({timeRange:T.U.z,channel:M.z.number().or(M.z.string()),useIndexOfChannel:M.z.boolean().optional().default(!1)});class Rn extends Et{constructor(n,r){super(r);m(this,"client");m(this,"data",[]);m(this,"valid",!1);m(this,"schema",Ch);this.client=n}async cleanup(){this.data.forEach(n=>n.release()),this.valid=!1}async value(){const{timeRange:n,channel:r,useIndexOfChannel:s}=this.props;if(n.isZero||r===0)return[f.C.ZERO,[]];const o=await Po(this.client,r,s);this.valid||await this.readFixed(o.key);let i=f.C.max(this.data.map(a=>a.bounds));return o.dataType.equals(T.g.TIMESTAMP)&&(i={upper:Math.min(i.upper,Number(this.props.timeRange.end.valueOf())),lower:Math.max(i.lower,Number(this.props.timeRange.start.valueOf()))}),[i,this.data]}async readFixed(n){const s=(await this.client.read(this.props.timeRange,[n]))[n].data;s.forEach(o=>o.acquire()),this.data=s,this.valid=!0}}m(Rn,"TYPE","series-source");const Ph=M.z.object({channel:M.z.number().or(M.z.string()),useIndexOfChannel:M.z.boolean().optional().default(!1),timeSpan:T.w.z,keepFor:T.w.z.optional()});class An extends Et{constructor(n,r){super(r);m(this,"client");m(this,"data",[]);m(this,"stopStreaming");m(this,"valid",!1);m(this,"schema",Ph);this.client=n}async value(){const{channel:n,useIndexOfChannel:r,timeSpan:s}=this.props;if(n===0)return[f.C.ZERO,[]];const o=T.m.now(),i=await Po(this.client,n,r);this.valid||await this.read(i.key);let a=f.C.max(this.data.filter(c=>c.timeRange.end.after(o.sub(s))).map(c=>c.bounds));return i.dataType.equals(T.g.TIMESTAMP)&&(a={upper:a.upper,lower:Math.max(a.lower,a.upper-Number(s.valueOf()))}),[a,this.data]}async read(n){const r=T.m.now().spanRange(-this.props.timeSpan),o=(await this.client.read(r,[n]))[n].data;o.forEach(i=>i.acquire()),this.data.push(...o),await this.updateStreamHandler(n),this.valid=!0}async updateStreamHandler(n){this.stopStreaming!=null&&await this.stopStreaming();const r=s=>{const o=s[n].data;o.forEach(i=>i.acquire()),this.data.push(...o),this.gcOutOfRangeData(),this.notify()};this.stopStreaming=await this.client.stream(r,[n])}gcOutOfRangeData(){const n=T.m.now().sub(this.props.keepFor??this.props.timeSpan),r=this.data.findIndex(s=>s.timeRange.end.before(n));r!==-1&&(this.data.splice(r,1).forEach(s=>s.release()),this.gcOutOfRangeData())}async cleanup(){var n;await((n=this.stopStreaming)==null?void 0:n.call(this)),this.stopStreaming=void 0,this.data.forEach(r=>r.release())}}m(An,"TYPE","dynamic-series-source");const kh={[Rn.TYPE]:Rn,[An.TYPE]:An,[Mn.TYPE]:Mn};class Ja{constructor(e){m(this,"type","remote");m(this,"client");this.client=e}create(e){const n=kh[e.type];return n==null?null:new n(this.client,e.props)}}const tc=t=>({type:Rn.TYPE,props:t,variant:"source",valueType:"series"}),ec=t=>({type:An.TYPE,props:t,variant:"source",valueType:"series"}),nc=t=>({type:Mn.TYPE,props:t,variant:"source",valueType:"number"});class rc{constructor(){m(this,"type","static")}create(e){switch(e.type){case Cr.TYPE:return new Cr(e.props);case Nn.TYPE:return new Nn(e.props);case Dn.TYPE:return new Dn(e.props);case On.TYPE:return new On(e.props);default:return null}}}const ko=M.z.object({data:M.z.array(T.ft),offsets:M.z.array(M.z.number()).optional().default([])});class Cr extends Et{constructor(n){super(n);m(this,"data");m(this,"schema",ko);this.data=this.props.data.map((r,s)=>new T.N({data:r,dataType:T.g.FLOAT32,timeRange:T.U.ZERO,sampleOffset:this.props.offsets[s]??0}))}async value(){return[f.C.max(this.data.map(r=>r.bounds)),this.data]}}m(Cr,"TYPE","static-series");const sc=ko.extend({rate:T.q.z,yOffset:M.z.number().optional().default(0),scroll:M.z.number().optional().default(0),startPosition:M.z.number().optional().default(0),scrollBounds:M.z.boolean().optional().default(!1)});class Nn extends Et{constructor(n){super(n);m(this,"schema",sc);m(this,"position");m(this,"interval");m(this,"data");this.position=this.props.startPosition,this.start(this.props.rate),this.data=this.props.data.map((r,s)=>new T.N({data:r,dataType:T.g.FLOAT32,timeRange:T.U.ZERO,sampleOffset:this.props.offsets[s]??0}))}async value(){const n=this.data.map(s=>s.slice(0,this.position));if(this.props.scrollBounds){const s=n[0].data[this.position-this.props.scroll<0?0:this.position-this.props.scroll],o=n[0].data[this.position-1];return[{lower:Number(s),upper:Number(o)},n]}return[f.C.max(n.map(s=>s.bounds)),n]}start(n){this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{var r;(r=this.notify)==null||r.call(this),this.position++},n.period.milliseconds)}async cleanup(){clearInterval(this.interval),this.interval=void 0}}m(Nn,"TYPE","iterative-series");const oc=M.z.number();class Dn extends Et{constructor(){super(...arguments);m(this,"schema",oc)}async value(){return this.props}}m(Dn,"TYPE","static-numeric");const ic=M.z.string();class On extends Et{constructor(){super(...arguments);m(this,"schema",ic)}async value(){return this.props}}m(On,"TYPE","static-string");const Mh=t=>({type:Cr.TYPE,props:t,variant:"source",valueType:"series"}),Rh=t=>({type:Nn.TYPE,props:t,variant:"source",valueType:"series"}),Ah=t=>({type:Dn.TYPE,props:t,variant:"source",valueType:"number"}),Nh=t=>({type:On.TYPE,props:t,variant:"source",valueType:"string"});class ac{constructor(){m(this,"type","transformer")}create(e){switch(e.type){case Be.TYPE:return new Be(e.props);case Fe.TYPE:return new Fe(e.props);case qe.TYPE:return new qe(e.props);case Ue.TYPE:return new Ue(e.props);case Ze.TYPE:return new Ze(e.props);case He.TYPE:return new He(e.props)}return null}}const Dh=M.z.object({truthy:M.z.number().optional().default(1),falsy:M.z.number().optional().default(0)}),cc=t=>({props:t,type:Be.TYPE,variant:"sink",valueType:"boolean"}),Sn=class Sn extends Wa{constructor(){super(...arguments);m(this,"schema",Sn.propsZ)}transform(n){return n?this.props.truthy:this.props.falsy}};m(Sn,"TYPE","boolean-numeric-converter-sink"),m(Sn,"propsZ",Dh);let Be=Sn;const Oh=M.z.object({trueBound:f.C.bounds}),lc=t=>({props:t,type:Fe.TYPE,variant:"source",valueType:"boolean"}),bn=class bn extends Wn{constructor(){super(...arguments);m(this,"schema",bn.propsZ);m(this,"curr",null)}shouldNotify(n){const r=f.C.contains(this.props.trueBound,n)!==this.curr;return this.curr=f.C.contains(this.props.trueBound,n),r}transform(n){return this.curr=f.C.contains(this.props.trueBound,n),this.curr}};m(bn,"TYPE","boolean-source"),m(bn,"propsZ",Oh);let Fe=bn;const uc=M.z.object({}),Tn=class Tn extends Xa{constructor(){super(...arguments);m(this,"schema",Tn.propsZ)}transform(n){return Object.values(n).reduce((r,s)=>r+s,0)/Object.keys(n).length}};m(Tn,"TYPE","mean"),m(Tn,"propsZ",uc);let qe=Tn;const zh=t=>({props:t,type:qe.TYPE,variant:"source",valueType:"boolean"}),hc=M.z.object({trueVariant:T.variantZ.optional().default("success")}),En=class En extends Wn{constructor(){super(...arguments);m(this,"schema",En.propsZ)}transform(n){return n.variant===this.props.trueVariant}};m(En,"TYPE","boolean-status"),m(En,"propsZ",hc);let Ue=En;const Ih=t=>({props:t,type:Ue.TYPE,variant:"source",valueType:"boolean"}),Mo=M.z.object({precision:M.z.number().optional().default(2),prefix:M.z.string().optional().default(""),suffix:M.z.string().optional().default("")}),_n=class _n extends Wn{constructor(){super(...arguments);m(this,"schema",_n.propsZ)}transform(n){return`${this.props.prefix}${n.toFixed(this.props.precision)}${this.props.suffix}`}};m(_n,"TYPE","stringify-number"),m(_n,"propsZ",Mo);let Ze=_n;const fc=t=>({props:t,type:Ze.TYPE,variant:"source",valueType:"string"}),Ro=M.z.object({windowSize:M.z.number().optional().default(5)});class He extends Wn{constructor(){super(...arguments);m(this,"schema",Ro);m(this,"values",[])}transform(n){return this.props.windowSize<2?n:this.values.reduce((r,s)=>r+s,0)/this.values.length}shouldNotify(n){return this.props.windowSize<2?!0:(this.values.length>this.props.windowSize&&(this.values=[]),this.values.push(n),this.values.length===this.props.windowSize)}}m(He,"TYPE","rolling-average"),m(He,"propsZ",uc);const dc=t=>({props:t,type:He.TYPE,variant:"source",valueType:"number"});class pc{constructor(e){m(this,"factories");m(this,"type","compound");this.factories=e}add(e){this.factories=[...this.factories.filter(n=>n.type!==e.type),e]}create(e){for(const n of this.factories){const r=n.create(e);if(r!=null)return r}return null}}const gc=t=>{const e=[new ac,new rc,new Fa],n=new pc(e);return t!=null&&n.add(new Ja(t)),n.add(new Ka(n)),n},mc=M.z.object({include:M.z.string().array().optional(),exclude:M.z.string().array().optional(),level:M.z.enum(T.g$1.LOG_LEVELS).optional().default("info")}),Gs="alamos-provider";var Vs;let Ks=(Vs=class extends T.Composite{constructor(){super(...arguments);m(this,"schema",mc)}async afterUpdate(){if(this.ctx.getOptional(Gs)!=null)return;const r=[],{include:s,exclude:o,level:i}=this.state;(s!=null||o!=null)&&r.push(T.g$1.logLevelKeyFiler({include:s,exclude:o})),i!=null&&r.push(T.g$1.logThresholdFilter(i)),r.length===0&&r.push(()=>!1),this.internal.ins=new T.g$1.Instrumentation({key:"aether",logger:new T.g$1.Logger({filters:r})}),this.ctx.set(Gs,this.internal.ins)}},m(Vs,"TYPE","AlamosProvider"),Vs);const Gn=(t,e)=>{const n=t.get(Gs);if(n==null)throw new Error("No instrumentation provider");return e==null?n:n.child(e)},$h={[Ks.TYPE]:Ks},yc=(t,e)=>(e==null&&t.dataType.equals(T.g.TIMESTAMP)&&(e=BigInt(t.data[0])),t.convert(T.g.FLOAT32,e)),wc=()=>({purgedSeries:0,purgedBytes:T.C.bytes(0)}),xc={instrumentation:T.g$1.NOOP,staleEntryThreshold:T.w.seconds(20)};class Lh{constructor(e){m(this,"data",[]);m(this,"props");this.props={...xc,...e}}write(e){e.length!==0&&(e.forEach(n=>this.writeOne(yc(n))),this.checkIntegrity(e))}dirtyRead(e){const n=this.data.filter(({data:i})=>i.timeRange.overlapsWith(e)).map(({data:i})=>i);if(n.length===0)return{series:[],gaps:[e]};const r=n.map((i,a)=>a===0?T.U.ZERO:new T.U(n[a-1].timeRange.end,i.timeRange.start)).filter(i=>!i.isZero&&i.isValid),s=new T.U(e.start,n[0].timeRange.start),o=new T.U(n[n.length-1].timeRange.end,e.end);return s.isValid&&!s.isZero&&r.unshift(s),o.isValid&&!o.isZero&&r.push(o),{series:n,gaps:r}}gc(){const{staleEntryThreshold:e}=this.props,n=wc(),r=this.data.filter(s=>{const o=s.data.refCount>0||T.m.since(s.addedAt).lessThan(e);return o||(n.purgedBytes=n.purgedBytes.add(s.data.byteCapacity)),o});return n.purgedSeries=this.data.length-r.length,this.data=r,n}close(){this.data=[]}writeOne(e){const{instrumentation:{L:n}}=this.props;if(e.length===0)return;const r=f.C.buildInsertionPlan(this.data.map(c=>c.data.alignmentBounds),e.alignmentBounds);if(r===null)return n.debug("Found no viable insertion plan",{inserting:e.digest,cacheContents:this.data.map(c=>c.data.digest)});const{removeBefore:s,removeAfter:o,insertInto:i,deleteInBetween:a}=r;e=e.slice(s,e.data.length-Number(o)),e.length!==0&&this.data.splice(i,a,{data:e,addedAt:T.m.now()})}checkIntegrity(e){const{instrumentation:{L:n}}=this.props,r=this.data.map(o=>o.data.alignmentBounds);if(r.some((o,i)=>r.some((a,c)=>i===c?!1:f.C.overlapsWith(o,a))))throw n.debug("Cache is in an invalid state - bounds overlap!",()=>({write:e.map(o=>o.digest),cacheContents:this.data.map(o=>o.data.digest)})),new Error("Invalid state")}}const Yh=100,Bh=1e6,Fh=1e4,qh=100;class Uh{constructor(e){m(this,"props");m(this,"counter",0);m(this,"buffer");m(this,"avgRate",0);m(this,"timeOfLastWrite");m(this,"totalWrites",0);m(this,"now",()=>T.m.now());this.props=e,this.buffer=null,e.testingNow!=null&&(this.now=e.testingNow),this.timeOfLastWrite=this.now()}get length(){var e;return((e=this.buffer)==null?void 0:e.length)??0}get leadingBuffer(){return this.buffer}write(e){const n=e.flatMap(r=>this._write(r));return{flushed:n.flatMap(r=>r.flushed),allocated:n.flatMap(r=>r.allocated)}}allocate(e,n,r){return this.counter++,T.N.alloc({capacity:e,dataType:T.g.FLOAT32,timeRange:r.range(T.m.MAX),sampleOffset:this.props.dataType.equals(T.g.TIMESTAMP)?BigInt(r.valueOf()):0,glBufferUsage:"dynamic",alignment:n,key:`dynamic-${this.counter}`})}_write(e){const n=this.nextBufferSize(),r={flushed:[],allocated:[]};if(this.buffer==null)this.buffer=this.allocate(n,e.alignment,this.now()),r.allocated.push(this.buffer);else if(Math.abs(Number(this.buffer.alignment+BigInt(this.buffer.length)-e.alignment))>1){const c=this.now();this.buffer.timeRange.end=c,r.flushed.push(this.buffer),this.buffer=this.allocate(n,e.alignment,c),r.allocated.push(this.buffer)}const s=yc(e,this.buffer.sampleOffset),o=this.buffer.write(s);if(o===e.length)return this.updateAvgRate(e),r;const i=this.now();this.buffer.timeRange.end=i,r.flushed.push(this.buffer),this.buffer=this.allocate(n,e.alignment+BigInt(o),i),r.allocated.push(this.buffer);const a=this._write(e.slice(o));return r.flushed.push(...a.flushed),r.allocated.push(...a.allocated),r}updateAvgRate(e){if(typeof this.props.dynamicBufferSize=="number")return;const n=e.length/this.now().span(this.timeOfLastWrite).seconds;this.totalWrites>0&&isFinite(n)&&n>0&&(this.avgRate=(this.avgRate*(this.totalWrites-1)+n)/this.totalWrites),this.totalWrites++,this.timeOfLastWrite=this.now()}nextBufferSize(){const{dynamicBufferSize:e}=this.props;if(typeof e=="number")return e;if(this.totalWrites<qh)return Fh;const n=f.L.roundToNearestMagnitude(this.avgRate*e.seconds);return Math.round(Math.max(Math.min(n,Bh),Yh))}close(){this.buffer=null}}class Zh{constructor(e){m(this,"channel");m(this,"closed",!1);m(this,"ins");m(this,"static");m(this,"dynamic");this.channel=e.channel,this.ins=e.instrumentation??T.g$1.NOOP,this.static=new Lh(e),this.dynamic=new Uh({dynamicBufferSize:e.dynamicBufferSize,dataType:this.channel.dataType})}writeDynamic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted dynamic write to a closed cache for channel ${this.channel.name}`),[];const{flushed:n,allocated:r}=this.dynamic.write(e);return n.length>0&&this.static.write(n),r}get leadingBuffer(){return this.dynamic.leadingBuffer}writeStatic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted static write to a closed cache for channel ${this.channel.name}`);this.static.write(e)}read(e){return this.closed?(this.ins.L.warn(`Ignoring attempted dirty read from a closed cache for channel ${this.channel.name}`),{series:[],gaps:[]}):this.static.dirtyRead(e)}gc(){return this.closed?(this.ins.L.warn(`Ignoring attempted garbage collection on a closed cache for channel ${this.channel.name}`),{purgedSeries:0,purgedBytes:T.C.bytes(0)}):this.static.gc()}close(){this.closed=!0,this.dynamic.close(),this.static.close()}}const Hh=T.A$1.seconds(60);class Vh{constructor(e){m(this,"props");m(this,"cache",new Map);m(this,"gcInterval");this.props={dynamicBufferSize:Hh,gcInterval:T.A$1.seconds(30),...xc,...e},this.gcInterval=setInterval(()=>this.gc(),this.props.gcInterval.milliseconds)}async populateMissing(e){const{instrumentation:n,channelRetriever:r,dynamicBufferSize:s}=this.props,o=[];for(const a of e)this.cache.has(a)||o.push(a);if(o.length===0)return;const i=await r.retrieve(o);for(const a of i){const c=new Zh({channel:a,dynamicBufferSize:s,instrumentation:n.child(`cache-${a.name}-${a.key}`)});this.cache.has(a.key)||this.cache.set(a.key,c)}}get(e){const n=this.cache.get(e);if(n!=null)return n;throw new T.ze(`cache entry for ${e} not found`)}gc(){const{instrumentation:{L:e}}=this.props;e.info("starting garbage collection");const n=wc();this.cache.forEach(r=>{const s=r.gc();n.purgedSeries+=s.purgedSeries,n.purgedBytes=n.purgedBytes.add(s.purgedBytes)}),e.info("garbage collection complete",{purgedSeries:n.purgedSeries,purgedBytes:n.purgedBytes.toString()},!0)}close(){clearInterval(this.gcInterval),this.cache.forEach(e=>e.close()),this.cache.clear()}}class Pr{constructor(e,n){m(this,"channel");m(this,"data");this.channel=e,this.data=n}get timeRange(){if(this.data.length===0)return T.H.ZERO;const e=this.data[0].timeRange,n=this.data[this.data.length-1].timeRange;return new T.H(e.start,n.end)}get digest(){return{channel:this.channel.key,timeRange:this.timeRange.toPrettyString(),series:this.data.map(e=>e.digest)}}}const _s=t=>t.map(e=>e.digest);class Xh{constructor(e){m(this,"props");m(this,"debouncedRead");m(this,"guarded",{mu:new T.Mutex,requests:new Map});this.props={instrumentation:T.g$1.NOOP,batchDebounce:T.w.milliseconds(50),...e},this.debouncedRead=T.o$1(()=>{this.batchRead()},this.props.batchDebounce.milliseconds)}async read(e,n){const{instrumentation:{L:r},cache:s}=this.props;r.debug("starting read",{tr:e.toPrettyString(),channels:n});const o=performance.now(),i=new Map,a={};await s.populateMissing(n);try{for(const u of n){const h=s.get(u),{series:d,gaps:p}=h.read(e);p.length===0&&(a[u]=new Pr(h.channel,d)),p.forEach(x=>{const w=i.get(x.toString());w==null?i.set(x.toString(),[x,new Set([u])]):i.set(x.toString(),[x,new Set([...w[1],u])])})}if(i.size===0)return r.debug("read satisfied by cache",()=>({tr:e.toPrettyString(),channels:n,responses:_s(Object.values(a)),time:T.w.milliseconds(performance.now()-o).toString()})),a;r.debug("read cache miss",()=>({tr:e.toPrettyString(),channels:n,toFetch:Array.from(i.values()).map(([u,h])=>({timeRange:u.toPrettyString(),channels:h})),responses:_s(Object.values(a))}));const{mu:c,requests:l}=this.guarded;for(const[,[u,h]]of i)await new Promise((d,p)=>{c.runExclusive(async()=>{l.set([u,h],{resolve:d,reject:p}),this.debouncedRead()})})}catch(c){throw r.error("read failed",{tr:e.toPrettyString(),channels:n,error:c}),c}for(const c of n){const l=s.get(c),{series:u}=l.read(e);a[c]=new Pr(l.channel,u)}return r.debug("read satisfied by fetch",()=>({tr:e.toPrettyString(),channels:n,responses:_s(Object.values(a)),time:T.w.milliseconds(performance.now()-o).toString()})),a}async batchRead(){const{instrumentation:{L:e},readRemote:n,cache:r}=this.props,{mu:s,requests:o}=this.guarded;await s.runExclusive(async()=>{const i=[];try{o.forEach((a,c)=>{const[l,u]=c,h=i.find(([d])=>d.start.span(l.start).lessThan(T.w.milliseconds(5))&&d.end.span(l.end).lessThan(T.w.milliseconds(5)));h==null?i.push([l,u]):h[1]=new Set([...h[1],...u])}),e.debug("batch read",{toFetch:i.map(([a,c])=>({timeRange:a.toPrettyString(),channels:c}))});for(const[a,c]of i){const l=Array.from(c),u=await n(a,l);l.forEach(h=>{const d=r.get(h),p=u.get(h);d.writeStatic(p.series)})}o.forEach(a=>a.resolve())}catch(a){e.error("batch read failed",{error:a},!0),o.forEach(c=>c.reject(a))}finally{o.clear()}})}}class Wh{constructor(e){m(this,"props");m(this,"mu",new T.Mutex);m(this,"listeners",new Map);m(this,"streamerRunLoop",null);m(this,"streamer",null);m(this,"closed",!1);this.props={instrumentation:T.g$1.NOOP,...e}}async stream(e,n){const{cache:r,instrumentation:{L:s}}=this.props;return await r.populateMissing(n),await this.mu.runExclusive(async()=>{s.debug("adding stream handler",{keys:n}),this.listeners.set(e,{valid:!0,keys:n});const o={};for(const i of n){const a=r.get(i),c=a.leadingBuffer!=null?[a.leadingBuffer]:[];o[i]=new Pr(a.channel,c)}return e(o),await this.updateStreamer(),async()=>await this.removeStreamHandler(e)})}async removeStreamHandler(e){const{instrumentation:{L:n}}=this.props;await this.mu.runExclusive(()=>{const r=this.listeners.get(e);r!=null&&(r.valid=!1)}),setTimeout(()=>{this.mu.runExclusive(async()=>{if(n.debug("removing stream handler"),this.listeners.delete(e))return await this.updateStreamer();n.warn("attempted to remove non-existent stream handler")})},5e3)}async updateStreamer(){var o,i;if(this.closed)return;const{instrumentation:{L:e},core:n}=this.props,r=new Set;if(this.listeners.forEach(a=>a.keys.forEach(c=>r.add(c))),r.size===0){e.info("no keys to stream, closing streamer"),(o=this.streamer)==null||o.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.streamer=null,e.info("streamer closed successfully");return}const s=Array.from(r);if(T.S.primitiveArrays(s,((i=this.streamer)==null?void 0:i.keys)??[])===T.S.EQUAL){e.debug("streamer keys unchanged",{keys:s});return}this.streamer==null&&(e.info("creating new streamer",{keys:s}),this.streamer=await n.openStreamer(s),this.streamerRunLoop=this.runStreamer(this.streamer)),e.debug("updating streamer",{prev:this.streamer.keys,next:s});try{await this.streamer.update(s)}catch(a){throw e.error("failed to update streamer",{error:a}),a}}async runStreamer(e){const{cache:n,instrumentation:{L:r}}=this.props;try{for await(const s of e){const o=[];for(const i of s.keys){const a=s.get(i),c=n.get(i),l=c.writeDynamic(a.series);o.push(new Pr(c.channel,l))}this.listeners.forEach((i,a)=>{if(!i.valid)return;const c=o.filter(u=>i.keys.includes(u.channel.key));if(c.length===0)return;const l=Object.fromEntries(c.map(u=>[u.channel.key,u]));a(l)})}}catch(s){throw r.error("streamer run loop failed",{error:s},!0),s}}async close(){var e;(e=this.streamer)==null||e.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.closed=!0}}class Gh{constructor(){m(this,"key",T.nanoid());m(this,"_client",null)}async swap(e){var n;this.key=T.nanoid(),await((n=this._client)==null?void 0:n.close()),this._client=e}async retrieveChannel(e){return await this.client.retrieveChannel(e)}async read(e,n){return await this.client.read(e,n)}async stream(e,n){return await this.client.stream(e,n)}async close(){await this.client.close()}get client(){if(this._client==null)throw new T.re("No cluster has been connected");return this._client}}class Kh{constructor({instrumentation:e,core:n}){m(this,"key",T.nanoid());m(this,"ins");m(this,"cache");m(this,"reader");m(this,"streamer");m(this,"channelRetriever");this.ins=e??T.g$1.NOOP,this.channelRetriever=n.channels.createDebouncedBatchRetriever(10),this.cache=new Vh({channelRetriever:this.channelRetriever,instrumentation:this.ins.child("cache")}),this.reader=new Xh({cache:this.cache,readRemote:async(r,s)=>await n.read(r,s),instrumentation:this.ins.child("reader")}),this.streamer=new Wh({cache:this.cache,core:n,instrumentation:this.ins.child("streamer")})}async retrieveChannel(e){const n=await this.channelRetriever.retrieve([e]);if(n.length===0)throw new T.re(`channel ${e} not found`);return n[0]}async read(e,n){return await this.reader.read(e,n)}async stream(e,n){return await this.streamer.stream(e,n)}async close(){this.ins.L.info("closing client",{key:this.key}),await this.streamer.close(),this.cache.close()}}const Ao=M.z.object({}),De=class De extends T.Composite{constructor(){super(...arguments);m(this,"client",new Gh);m(this,"factory",gc(this.client));m(this,"schema",De.stateZ);m(this,"prevClient",null)}create(n){const{instrumentation:r}=this.internal;r.L.debug("creating telem",{spec:n});const s=this.factory.create(n);if(s==null)throw new T.ze(`Telemetry service could not find a source for type ${n.type}`);return s}get clusterKey(){return this.client.key}registerFactory(n){this.factory.add(n)}equals(n){return n instanceof De?this.client._client===n.client._client:!1}async afterUpdate(){const n=Vn(this.ctx),r=Gn(this.ctx,"telem");this.internal.instrumentation=r.child("provider"),n!==this.prevClient&&(r.L.info("swapping client",{client:n}),n==null?await this.client.swap(null):await this.client.swap(new Kh({core:n,instrumentation:r})),this.prevClient=n,Ia(this.ctx,this))}};m(De,"TYPE","TelemProvider"),m(De,"stateZ",Ao);let Ve=De;const vc={[Ve.TYPE]:Ve},jh=Object.freeze(Object.defineProperty({__proto__:null,AbstractSink:hs,AbstractSource:Et,Base:us,BaseProvider:Ve,BooleanStatus:Ue,ChannelData:Rn,CompoundTelemFactory:pc,FixedNumber:Dn,FixedString:On,IterativeSeries:Nn,Mean:qe,MultiSourceTransformer:Xa,NoopFactory:Fa,PipelineFactory:Ka,REGISTRY:vc,RemoteFactory:Ja,RollingAverage:He,SetPoint:Be,SinkPipeline:kn,SourcePipeline:Pn,StaticFactory:rc,StreamChannelData:An,StreamChannelValue:Mn,StringifyNumber:Ze,TransformerFactory:ac,UnarySinkTransformer:Wa,UnarySourceTransformer:Wn,WithinBounds:Fe,booleanSinkSpecZ:ls,booleanSinkTransformerSpecZ:bh,booleanSourceSpecZ:Za,booleanSourceTransformerSpecZ:Th,booleanStatus:Ih,booleanStatusProps:hc,channelData:tc,colorSourceSpecZ:Ha,factory:gc,fixedArray:Mh,fixedNumber:Ah,fixedNumberPropsZ:oc,fixedSeriesPropsZ:ko,fixedString:Nh,fixedStringPropsZ:ic,iterativeArray:Rh,iterativeSeriesPropsZ:sc,mean:zh,noopBooleanSinkSpec:as,noopBooleanSourceSpec:La,noopColorSourceSpec:Ba,noopNumericSinkSpec:wh,noopNumericSourceSpec:xh,noopStatusSourceSpec:bo,noopStringSourceSpec:Ya,numberSinkSpecZ:_h,numberSourceSpecZ:Eh,providerStateZ:Ao,registerFactory:$a,rollingAverage:dc,rollingAverageProps:Ro,seriesSourceSpecZ:Ws,setProvider:Ia,setpoint:cc,sinkPipeline:Qa,sinkPipelinePropsZ:_o,sinkSpecZ:cs,sinkTransformerSpecZ:Ua,sourcePipeline:ja,sourcePipelinePropsZ:Eo,sourceSpecZ:te,sourceTransformerSpecZ:qa,specZ:Xn,statusSourceSpecZ:To,streamChannelData:ec,streamChannelValue:nc,streamChannelValuePropsZ:Co,stringSourceSpecZ:Va,stringifyNumber:fc,stringifyNumberProps:Mo,useProvider:os,useSink:is,useSource:Qt,withinBounds:lc},Symbol.toStringTag,{value:"Module"})),Sc=M.z.object({key:M.z.string(),size:M.z.number(),order:hh.order,loc:f.J.outer});M.z.record(Sc);const le=(t,e)=>Object.values(e).filter(({loc:n})=>n===t).sort((n,r)=>T.S.order(n.order,r.order)),Qh=(t,e,n)=>{const r=e[t];if(r==null)return f.q.ZERO;const s=f.J.construct(r.loc),o=le(s,e),i=f.J.construct(f.f.swap(f.J.direction(s))),a=le(i,e),c=o.findIndex(({key:h})=>h===t),l=o.slice(0,c).reduce((h,{size:d})=>h+d,0),u=a.reduce((h,{size:d})=>h+d,0);switch(s){case"left":return f.q.translate(f.To.topLeft(n),[l,u]);case"right":return f.q.translate(f.To.topRight(n),[l-r.size,u]);case"top":return f.q.translate(f.To.topLeft(n),[l,u]);default:return f.q.translate(f.To.bottomLeft(n),[u,l-r.size])}},Jh=(t,e)=>{const n=le("left",t),r=le("right",t),s=le("top",t),o=le("bottom",t),i=n.reduce((u,{size:h})=>u+h,0),a=r.reduce((u,{size:h})=>u+h,0),c=s.reduce((u,{size:h})=>u+h,0),l=o.reduce((u,{size:h})=>u+h,0);return f.To.construct(f.q.translate(f.To.topLeft(e),{x:i,y:c}),f.To.width(e)-i-a,f.To.height(e)-c-l)};function fr(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function tf(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function No(t){let e,n,r;t.length!==2?(e=fr,n=(a,c)=>fr(t(a),c),r=(a,c)=>t(a)-c):(e=t===fr||t===tf?t:ef,n=t,r=t);function s(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const h=l+u>>>1;n(a[h],c)<0?l=h+1:u=h}while(l<u)}return l}function o(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const h=l+u>>>1;n(a[h],c)<=0?l=h+1:u=h}while(l<u)}return l}function i(a,c,l=0,u=a.length){const h=s(a,c,l,u-1);return h>l&&r(a[h-1],c)>-r(a[h],c)?h-1:h}return{left:s,center:i,right:o}}function ef(){return 0}function nf(t){return t===null?NaN:+t}const rf=No(fr),sf=rf.right;No(nf).center;const of=Math.sqrt(50),af=Math.sqrt(10),cf=Math.sqrt(2);function kr(t,e,n){const r=(e-t)/Math.max(0,n),s=Math.floor(Math.log10(r)),o=r/Math.pow(10,s),i=o>=of?10:o>=af?5:o>=cf?2:1;let a,c,l;return s<0?(l=Math.pow(10,-s)/i,a=Math.round(t*l),c=Math.round(e*l),a/l<t&&++a,c/l>e&&--c,l=-l):(l=Math.pow(10,s)*i,a=Math.round(t/l),c=Math.round(e/l),a*l<t&&++a,c*l>e&&--c),c<a&&.5<=n&&n<2?kr(t,e,n*2):[a,c,l]}function lf(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[s,o,i]=r?kr(e,t,n):kr(t,e,n);if(!(o>=s))return[];const a=o-s+1,c=new Array(a);if(r)if(i<0)for(let l=0;l<a;++l)c[l]=(o-l)/-i;else for(let l=0;l<a;++l)c[l]=(o-l)*i;else if(i<0)for(let l=0;l<a;++l)c[l]=(s+l)/-i;else for(let l=0;l<a;++l)c[l]=(s+l)*i;return c}function js(t,e,n){return e=+e,t=+t,n=+n,kr(t,e,n)[2]}function Qs(t,e,n){e=+e,t=+t,n=+n;const r=e<t,s=r?js(e,t,n):js(t,e,n);return(r?-1:1)*(s<0?1/-s:s)}function bc(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Do(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Tc(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Kn(){}var zn=.7,Mr=1/zn,Ie="\\s*([+-]?\\d+)\\s*",In="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ot="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",uf=/^#([0-9a-f]{3,8})$/,hf=new RegExp(`^rgb\\(${Ie},${Ie},${Ie}\\)$`),ff=new RegExp(`^rgb\\(${Ot},${Ot},${Ot}\\)$`),df=new RegExp(`^rgba\\(${Ie},${Ie},${Ie},${In}\\)$`),pf=new RegExp(`^rgba\\(${Ot},${Ot},${Ot},${In}\\)$`),gf=new RegExp(`^hsl\\(${In},${Ot},${Ot}\\)$`),mf=new RegExp(`^hsla\\(${In},${Ot},${Ot},${In}\\)$`),yi={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};Do(Kn,pe,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:wi,formatHex:wi,formatHex8:yf,formatHsl:wf,formatRgb:xi,toString:xi});function wi(){return this.rgb().formatHex()}function yf(){return this.rgb().formatHex8()}function wf(){return Ec(this).formatHsl()}function xi(){return this.rgb().formatRgb()}function pe(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=uf.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?vi(e):n===3?new mt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?er(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?er(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=hf.exec(t))?new mt(e[1],e[2],e[3],1):(e=ff.exec(t))?new mt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=df.exec(t))?er(e[1],e[2],e[3],e[4]):(e=pf.exec(t))?er(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=gf.exec(t))?Ti(e[1],e[2]/100,e[3]/100,1):(e=mf.exec(t))?Ti(e[1],e[2]/100,e[3]/100,e[4]):yi.hasOwnProperty(t)?vi(yi[t]):t==="transparent"?new mt(NaN,NaN,NaN,0):null}function vi(t){return new mt(t>>16&255,t>>8&255,t&255,1)}function er(t,e,n,r){return r<=0&&(t=e=n=NaN),new mt(t,e,n,r)}function xf(t){return t instanceof Kn||(t=pe(t)),t?(t=t.rgb(),new mt(t.r,t.g,t.b,t.opacity)):new mt}function Js(t,e,n,r){return arguments.length===1?xf(t):new mt(t,e,n,r??1)}function mt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Do(mt,Js,Tc(Kn,{brighter(t){return t=t==null?Mr:Math.pow(Mr,t),new mt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?zn:Math.pow(zn,t),new mt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new mt(de(this.r),de(this.g),de(this.b),Rr(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:Si,formatHex:Si,formatHex8:vf,formatRgb:bi,toString:bi}));function Si(){return`#${ue(this.r)}${ue(this.g)}${ue(this.b)}`}function vf(){return`#${ue(this.r)}${ue(this.g)}${ue(this.b)}${ue((isNaN(this.opacity)?1:this.opacity)*255)}`}function bi(){const t=Rr(this.opacity);return`${t===1?"rgb(":"rgba("}${de(this.r)}, ${de(this.g)}, ${de(this.b)}${t===1?")":`, ${t})`}`}function Rr(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function de(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ue(t){return t=de(t),(t<16?"0":"")+t.toString(16)}function Ti(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Pt(t,e,n,r)}function Ec(t){if(t instanceof Pt)return new Pt(t.h,t.s,t.l,t.opacity);if(t instanceof Kn||(t=pe(t)),!t)return new Pt;if(t instanceof Pt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,s=Math.min(e,n,r),o=Math.max(e,n,r),i=NaN,a=o-s,c=(o+s)/2;return a?(e===o?i=(n-r)/a+(n<r)*6:n===o?i=(r-e)/a+2:i=(e-n)/a+4,a/=c<.5?o+s:2-o-s,i*=60):a=c>0&&c<1?0:i,new Pt(i,a,c,t.opacity)}function Sf(t,e,n,r){return arguments.length===1?Ec(t):new Pt(t,e,n,r??1)}function Pt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Do(Pt,Sf,Tc(Kn,{brighter(t){return t=t==null?Mr:Math.pow(Mr,t),new Pt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?zn:Math.pow(zn,t),new Pt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,s=2*n-r;return new mt(Cs(t>=240?t-240:t+120,s,r),Cs(t,s,r),Cs(t<120?t+240:t-120,s,r),this.opacity)},clamp(){return new Pt(Ei(this.h),nr(this.s),nr(this.l),Rr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Rr(this.opacity);return`${t===1?"hsl(":"hsla("}${Ei(this.h)}, ${nr(this.s)*100}%, ${nr(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Ei(t){return t=(t||0)%360,t<0?t+360:t}function nr(t){return Math.max(0,Math.min(1,t||0))}function Cs(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Oo=t=>()=>t;function bf(t,e){return function(n){return t+n*e}}function Tf(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function Ef(t){return(t=+t)==1?_c:function(e,n){return n-e?Tf(e,n,t):Oo(isNaN(e)?n:e)}}function _c(t,e){var n=e-t;return n?bf(t,n):Oo(isNaN(t)?e:t)}const Ar=function t(e){var n=Ef(e);function r(s,o){var i=n((s=Js(s)).r,(o=Js(o)).r),a=n(s.g,o.g),c=n(s.b,o.b),l=_c(s.opacity,o.opacity);return function(u){return s.r=i(u),s.g=a(u),s.b=c(u),s.opacity=l(u),s+""}}return r.gamma=t,r}(1);function _f(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),s;return function(o){for(s=0;s<n;++s)r[s]=t[s]*(1-o)+e[s]*o;return r}}function Cf(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Pf(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,s=new Array(r),o=new Array(n),i;for(i=0;i<r;++i)s[i]=zo(t[i],e[i]);for(;i<n;++i)o[i]=e[i];return function(a){for(i=0;i<r;++i)o[i]=s[i](a);return o}}function kf(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Ct(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Mf(t,e){var n={},r={},s;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(s in e)s in t?n[s]=zo(t[s],e[s]):r[s]=e[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var to=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ps=new RegExp(to.source,"g");function Rf(t){return function(){return t}}function Af(t){return function(e){return t(e)+""}}function Cc(t,e){var n=to.lastIndex=Ps.lastIndex=0,r,s,o,i=-1,a=[],c=[];for(t=t+"",e=e+"";(r=to.exec(t))&&(s=Ps.exec(e));)(o=s.index)>n&&(o=e.slice(n,o),a[i]?a[i]+=o:a[++i]=o),(r=r[0])===(s=s[0])?a[i]?a[i]+=s:a[++i]=s:(a[++i]=null,c.push({i,x:Ct(r,s)})),n=Ps.lastIndex;return n<e.length&&(o=e.slice(n),a[i]?a[i]+=o:a[++i]=o),a.length<2?c[0]?Af(c[0].x):Rf(e):(e=c.length,function(l){for(var u=0,h;u<e;++u)a[(h=c[u]).i]=h.x(l);return a.join("")})}function zo(t,e){var n=typeof e,r;return e==null||n==="boolean"?Oo(e):(n==="number"?Ct:n==="string"?(r=pe(e))?(e=r,Ar):Cc:e instanceof pe?Ar:e instanceof Date?kf:Cf(e)?_f:Array.isArray(e)?Pf:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Mf:Ct)(t,e)}function Nf(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var _i=180/Math.PI,eo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pc(t,e,n,r,s,o){var i,a,c;return(i=Math.sqrt(t*t+e*e))&&(t/=i,e/=i),(c=t*n+e*r)&&(n-=t*c,r-=e*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),t*r<e*n&&(t=-t,e=-e,c=-c,i=-i),{translateX:s,translateY:o,rotate:Math.atan2(e,t)*_i,skewX:Math.atan(c)*_i,scaleX:i,scaleY:a}}var rr;function Df(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?eo:Pc(e.a,e.b,e.c,e.d,e.e,e.f)}function Of(t){return t==null||(rr||(rr=document.createElementNS("http://www.w3.org/2000/svg","g")),rr.setAttribute("transform",t),!(t=rr.transform.baseVal.consolidate()))?eo:(t=t.matrix,Pc(t.a,t.b,t.c,t.d,t.e,t.f))}function kc(t,e,n,r){function s(l){return l.length?l.pop()+" ":""}function o(l,u,h,d,p,x){if(l!==h||u!==d){var w=p.push("translate(",null,e,null,n);x.push({i:w-4,x:Ct(l,h)},{i:w-2,x:Ct(u,d)})}else(h||d)&&p.push("translate("+h+e+d+n)}function i(l,u,h,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:h.push(s(h)+"rotate(",null,r)-2,x:Ct(l,u)})):u&&h.push(s(h)+"rotate("+u+r)}function a(l,u,h,d){l!==u?d.push({i:h.push(s(h)+"skewX(",null,r)-2,x:Ct(l,u)}):u&&h.push(s(h)+"skewX("+u+r)}function c(l,u,h,d,p,x){if(l!==h||u!==d){var w=p.push(s(p)+"scale(",null,",",null,")");x.push({i:w-4,x:Ct(l,h)},{i:w-2,x:Ct(u,d)})}else(h!==1||d!==1)&&p.push(s(p)+"scale("+h+","+d+")")}return function(l,u){var h=[],d=[];return l=t(l),u=t(u),o(l.translateX,l.translateY,u.translateX,u.translateY,h,d),i(l.rotate,u.rotate,h,d),a(l.skewX,u.skewX,h,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,h,d),l=u=null,function(p){for(var x=-1,w=d.length,b;++x<w;)h[(b=d[x]).i]=b.x(p);return h.join("")}}}var zf=kc(Df,"px, ","px)","deg)"),If=kc(Of,", ",")",")"),$f=1e-12;function Ci(t){return((t=Math.exp(t))+1/t)/2}function Lf(t){return((t=Math.exp(t))-1/t)/2}function Yf(t){return((t=Math.exp(2*t))-1)/(t+1)}const Bf=function t(e,n,r){function s(o,i){var a=o[0],c=o[1],l=o[2],u=i[0],h=i[1],d=i[2],p=u-a,x=h-c,w=p*p+x*x,b,v;if(w<$f)v=Math.log(d/l)/e,b=function(N){return[a+N*p,c+N*x,l*Math.exp(e*N*v)]};else{var k=Math.sqrt(w),C=(d*d-l*l+r*w)/(2*l*n*k),S=(d*d-l*l-r*w)/(2*d*n*k),R=Math.log(Math.sqrt(C*C+1)-C),_=Math.log(Math.sqrt(S*S+1)-S);v=(_-R)/e,b=function(N){var I=N*v,O=Ci(R),Z=l/(n*k)*(O*Yf(e*I+R)-Lf(R));return[a+Z*p,c+Z*x,l*O/Ci(e*I+R)]}}return b.duration=v*1e3*e/Math.SQRT2,b}return s.rho=function(o){var i=Math.max(.001,+o),a=i*i,c=a*a;return t(i,a,c)},s}(Math.SQRT2,2,4);function Ff(t){return function(){return t}}function qf(t){return+t}var Pi=[0,1];function Re(t){return t}function no(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Ff(isNaN(e)?NaN:.5)}function Uf(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Zf(t,e,n){var r=t[0],s=t[1],o=e[0],i=e[1];return s<r?(r=no(s,r),o=n(i,o)):(r=no(r,s),o=n(o,i)),function(a){return o(r(a))}}function Hf(t,e,n){var r=Math.min(t.length,e.length)-1,s=new Array(r),o=new Array(r),i=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++i<r;)s[i]=no(t[i],t[i+1]),o[i]=n(e[i],e[i+1]);return function(a){var c=sf(t,a,1,r)-1;return o[c](s[c](a))}}function Mc(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Vf(){var t=Pi,e=Pi,n=zo,r,s,o,i=Re,a,c,l;function u(){var d=Math.min(t.length,e.length);return i!==Re&&(i=Uf(t[0],t[d-1])),a=d>2?Hf:Zf,c=l=null,h}function h(d){return d==null||isNaN(d=+d)?o:(c||(c=a(t.map(r),e,n)))(r(i(d)))}return h.invert=function(d){return i(s((l||(l=a(e,t.map(r),Ct)))(d)))},h.domain=function(d){return arguments.length?(t=Array.from(d,qf),u()):t.slice()},h.range=function(d){return arguments.length?(e=Array.from(d),u()):e.slice()},h.rangeRound=function(d){return e=Array.from(d),n=Nf,u()},h.clamp=function(d){return arguments.length?(i=d?!0:Re,u()):i!==Re},h.interpolate=function(d){return arguments.length?(n=d,u()):n},h.unknown=function(d){return arguments.length?(o=d,h):o},function(d,p){return r=d,s=p,u()}}function Rc(){return Vf()(Re,Re)}function Xf(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Nr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Xe(t){return t=Nr(Math.abs(t)),t?t[1]:NaN}function Wf(t,e){return function(n,r){for(var s=n.length,o=[],i=0,a=t[0],c=0;s>0&&a>0&&(c+a+1>r&&(a=Math.max(1,r-c)),o.push(n.substring(s-=a,s+a)),!((c+=a+1)>r));)a=t[i=(i+1)%t.length];return o.reverse().join(e)}}function Gf(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Kf=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Dr(t){if(!(e=Kf.exec(t)))throw new Error("invalid format: "+t);var e;return new Io({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]})}Dr.prototype=Io.prototype;function Io(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Io.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 jf(t){t:for(var e=t.length,n=1,r=-1,s;n<e;++n)switch(t[n]){case".":r=s=n;break;case"0":r===0&&(r=n),s=n;break;default:if(!+t[n])break t;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(s+1):t}var Ac;function Qf(t,e){var n=Nr(t,e);if(!n)return t+"";var r=n[0],s=n[1],o=s-(Ac=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,i=r.length;return o===i?r:o>i?r+new Array(o-i+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Nr(t,Math.max(0,e+o-1))[0]}function ki(t,e){var n=Nr(t,e);if(!n)return t+"";var r=n[0],s=n[1];return s<0?"0."+new Array(-s).join("0")+r:r.length>s+1?r.slice(0,s+1)+"."+r.slice(s+1):r+new Array(s-r.length+2).join("0")}const Mi={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Xf,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>ki(t*100,e),r:ki,s:Qf,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Ri(t){return t}var Ai=Array.prototype.map,Ni=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Jf(t){var e=t.grouping===void 0||t.thousands===void 0?Ri:Wf(Ai.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",s=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Ri:Gf(Ai.call(t.numerals,String)),i=t.percent===void 0?"%":t.percent+"",a=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function l(h){h=Dr(h);var d=h.fill,p=h.align,x=h.sign,w=h.symbol,b=h.zero,v=h.width,k=h.comma,C=h.precision,S=h.trim,R=h.type;R==="n"?(k=!0,R="g"):Mi[R]||(C===void 0&&(C=12),S=!0,R="g"),(b||d==="0"&&p==="=")&&(b=!0,d="0",p="=");var _=w==="$"?n:w==="#"&&/[boxX]/.test(R)?"0"+R.toLowerCase():"",N=w==="$"?r:/[%p]/.test(R)?i:"",I=Mi[R],O=/[defgprs%]/.test(R);C=C===void 0?6:/[gprs]/.test(R)?Math.max(1,Math.min(21,C)):Math.max(0,Math.min(20,C));function Z(D){var q=_,L=N,g,A,P;if(R==="c")L=I(D)+L,D="";else{D=+D;var z=D<0||1/D<0;if(D=isNaN(D)?c:I(Math.abs(D),C),S&&(D=jf(D)),z&&+D==0&&x!=="+"&&(z=!1),q=(z?x==="("?x:a:x==="-"||x==="("?"":x)+q,L=(R==="s"?Ni[8+Ac/3]:"")+L+(z&&x==="("?")":""),O){for(g=-1,A=D.length;++g<A;)if(P=D.charCodeAt(g),48>P||P>57){L=(P===46?s+D.slice(g+1):D.slice(g))+L,D=D.slice(0,g);break}}}k&&!b&&(D=e(D,1/0));var F=q.length+D.length+L.length,E=F<v?new Array(v-F+1).join(d):"";switch(k&&b&&(D=e(E+D,E.length?v-L.length:1/0),E=""),p){case"<":D=q+D+L+E;break;case"=":D=q+E+D+L;break;case"^":D=E.slice(0,F=E.length>>1)+q+D+L+E.slice(F);break;default:D=E+q+D+L;break}return o(D)}return Z.toString=function(){return h+""},Z}function u(h,d){var p=l((h=Dr(h),h.type="f",h)),x=Math.max(-8,Math.min(8,Math.floor(Xe(d)/3)))*3,w=Math.pow(10,-x),b=Ni[8+x/3];return function(v){return p(w*v)+b}}return{format:l,formatPrefix:u}}var sr,Nc,Dc;td({thousands:",",grouping:[3],currency:["$",""]});function td(t){return sr=Jf(t),Nc=sr.format,Dc=sr.formatPrefix,sr}function ed(t){return Math.max(0,-Xe(Math.abs(t)))}function nd(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Xe(e)/3)))*3-Xe(Math.abs(t)))}function rd(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Xe(e)-Xe(t))+1}function sd(t,e,n,r){var s=Qs(t,e,n),o;switch(r=Dr(r??",f"),r.type){case"s":{var i=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(o=nd(s,i))&&(r.precision=o),Dc(r,i)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=rd(s,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=ed(s))&&(r.precision=o-(r.type==="%")*2);break}}return Nc(r)}function od(t){var e=t.domain;return t.ticks=function(n){var r=e();return lf(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var s=e();return sd(s[0],s[s.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),s=0,o=r.length-1,i=r[s],a=r[o],c,l,u=10;for(a<i&&(l=i,i=a,a=l,l=s,s=o,o=l);u-- >0;){if(l=js(i,a,n),l===c)return r[s]=i,r[o]=a,e(r);if(l>0)i=Math.floor(i/l)*l,a=Math.ceil(a/l)*l;else if(l<0)i=Math.ceil(i*l)/l,a=Math.floor(a*l)/l;else break;c=l}return t},t}function Oc(){var t=Rc();return t.copy=function(){return Mc(t,Oc())},bc.apply(t,arguments),od(t)}function id(t,e){t=t.slice();var n=0,r=t.length-1,s=t[n],o=t[r],i;return o<s&&(i=n,n=r,r=i,i=s,s=o,o=i),t[n]=e.floor(s),t[r]=e.ceil(o),t}const ks=new Date,Ms=new Date;function ut(t,e,n,r){function s(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return s.floor=o=>(t(o=new Date(+o)),o),s.ceil=o=>(t(o=new Date(o-1)),e(o,1),t(o),o),s.round=o=>{const i=s(o),a=s.ceil(o);return o-i<a-o?i:a},s.offset=(o,i)=>(e(o=new Date(+o),i==null?1:Math.floor(i)),o),s.range=(o,i,a)=>{const c=[];if(o=s.ceil(o),a=a==null?1:Math.floor(a),!(o<i)||!(a>0))return c;let l;do c.push(l=new Date(+o)),e(o,a),t(o);while(l<o&&o<i);return c},s.filter=o=>ut(i=>{if(i>=i)for(;t(i),!o(i);)i.setTime(i-1)},(i,a)=>{if(i>=i)if(a<0)for(;++a<=0;)for(;e(i,-1),!o(i););else for(;--a>=0;)for(;e(i,1),!o(i););}),n&&(s.count=(o,i)=>(ks.setTime(+o),Ms.setTime(+i),t(ks),t(Ms),Math.floor(n(ks,Ms))),s.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?s.filter(r?i=>r(i)%o===0:i=>s.count(0,i)%o===0):s)),s}const Or=ut(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Or.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ut(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Or);Or.range;const Bt=1e3,bt=Bt*60,Ft=bt*60,Zt=Ft*24,$o=Zt*7,Di=Zt*30,Rs=Zt*365,Ae=ut(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Bt)},(t,e)=>(e-t)/Bt,t=>t.getUTCSeconds());Ae.range;const Lo=ut(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Bt)},(t,e)=>{t.setTime(+t+e*bt)},(t,e)=>(e-t)/bt,t=>t.getMinutes());Lo.range;const ad=ut(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*bt)},(t,e)=>(e-t)/bt,t=>t.getUTCMinutes());ad.range;const Yo=ut(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Bt-t.getMinutes()*bt)},(t,e)=>{t.setTime(+t+e*Ft)},(t,e)=>(e-t)/Ft,t=>t.getHours());Yo.range;const cd=ut(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Ft)},(t,e)=>(e-t)/Ft,t=>t.getUTCHours());cd.range;const jn=ut(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*bt)/Zt,t=>t.getDate()-1);jn.range;const Bo=ut(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Zt,t=>t.getUTCDate()-1);Bo.range;const ld=ut(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Zt,t=>Math.floor(t/Zt));ld.range;function we(t){return ut(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*bt)/$o)}const fs=we(0),zr=we(1),ud=we(2),hd=we(3),We=we(4),fd=we(5),dd=we(6);fs.range;zr.range;ud.range;hd.range;We.range;fd.range;dd.range;function xe(t){return ut(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/$o)}const zc=xe(0),Ir=xe(1),pd=xe(2),gd=xe(3),Ge=xe(4),md=xe(5),yd=xe(6);zc.range;Ir.range;pd.range;gd.range;Ge.range;md.range;yd.range;const Fo=ut(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());Fo.range;const wd=ut(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());wd.range;const Ht=ut(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Ht.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ut(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Ht.range;const ge=ut(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());ge.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ut(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});ge.range;function xd(t,e,n,r,s,o){const i=[[Ae,1,Bt],[Ae,5,5*Bt],[Ae,15,15*Bt],[Ae,30,30*Bt],[o,1,bt],[o,5,5*bt],[o,15,15*bt],[o,30,30*bt],[s,1,Ft],[s,3,3*Ft],[s,6,6*Ft],[s,12,12*Ft],[r,1,Zt],[r,2,2*Zt],[n,1,$o],[e,1,Di],[e,3,3*Di],[t,1,Rs]];function a(l,u,h){const d=u<l;d&&([l,u]=[u,l]);const p=h&&typeof h.range=="function"?h:c(l,u,h),x=p?p.range(l,+u+1):[];return d?x.reverse():x}function c(l,u,h){const d=Math.abs(u-l)/h,p=No(([,,b])=>b).right(i,d);if(p===i.length)return t.every(Qs(l/Rs,u/Rs,h));if(p===0)return Or.every(Math.max(Qs(l,u,h),1));const[x,w]=i[d/i[p-1][2]<i[p][2]/d?p-1:p];return x.every(w)}return[a,c]}const[vd,Sd]=xd(Ht,Fo,fs,jn,Yo,Lo);function As(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Ns(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function hn(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function bd(t){var e=t.dateTime,n=t.date,r=t.time,s=t.periods,o=t.days,i=t.shortDays,a=t.months,c=t.shortMonths,l=fn(s),u=dn(s),h=fn(o),d=dn(o),p=fn(i),x=dn(i),w=fn(a),b=dn(a),v=fn(c),k=dn(c),C={a:z,A:F,b:E,B:Y,c:null,d:Yi,e:Yi,f:Hd,g:ep,G:rp,H:qd,I:Ud,j:Zd,L:Ic,m:Vd,M:Xd,p:$,q:H,Q:qi,s:Ui,S:Wd,u:Gd,U:Kd,V:jd,w:Qd,W:Jd,x:null,X:null,y:tp,Y:np,Z:sp,"%":Fi},S={a:X,A:W,b:j,B:tt,c:null,d:Bi,e:Bi,f:cp,g:wp,G:vp,H:op,I:ip,j:ap,L:Lc,m:lp,M:up,p:et,q:ot,Q:qi,s:Ui,S:hp,u:fp,U:dp,V:pp,w:gp,W:mp,x:null,X:null,y:yp,Y:xp,Z:Sp,"%":Fi},R={a:Z,A:D,b:q,B:L,c:g,d:$i,e:$i,f:Ld,g:Ii,G:zi,H:Li,I:Li,j:Od,L:$d,m:Dd,M:zd,p:O,q:Nd,Q:Bd,s:Fd,S:Id,u:Pd,U:kd,V:Md,w:Cd,W:Rd,x:A,X:P,y:Ii,Y:zi,Z:Ad,"%":Yd};C.x=_(n,C),C.X=_(r,C),C.c=_(e,C),S.x=_(n,S),S.X=_(r,S),S.c=_(e,S);function _(U,V){return function(K){var B=[],it=-1,J=0,nt=U.length,at,rt,G;for(K instanceof Date||(K=new Date(+K));++it<nt;)U.charCodeAt(it)===37&&(B.push(U.slice(J,it)),(rt=Oi[at=U.charAt(++it)])!=null?at=U.charAt(++it):rt=at==="e"?" ":"0",(G=V[at])&&(at=G(K,rt)),B.push(at),J=it+1);return B.push(U.slice(J,it)),B.join("")}}function N(U,V){return function(K){var B=hn(1900,void 0,1),it=I(B,U,K+="",0),J,nt;if(it!=K.length)return null;if("Q"in B)return new Date(B.Q);if("s"in B)return new Date(B.s*1e3+("L"in B?B.L:0));if(V&&!("Z"in B)&&(B.Z=0),"p"in B&&(B.H=B.H%12+B.p*12),B.m===void 0&&(B.m="q"in B?B.q:0),"V"in B){if(B.V<1||B.V>53)return null;"w"in B||(B.w=1),"Z"in B?(J=Ns(hn(B.y,0,1)),nt=J.getUTCDay(),J=nt>4||nt===0?Ir.ceil(J):Ir(J),J=Bo.offset(J,(B.V-1)*7),B.y=J.getUTCFullYear(),B.m=J.getUTCMonth(),B.d=J.getUTCDate()+(B.w+6)%7):(J=As(hn(B.y,0,1)),nt=J.getDay(),J=nt>4||nt===0?zr.ceil(J):zr(J),J=jn.offset(J,(B.V-1)*7),B.y=J.getFullYear(),B.m=J.getMonth(),B.d=J.getDate()+(B.w+6)%7)}else("W"in B||"U"in B)&&("w"in B||(B.w="u"in B?B.u%7:"W"in B?1:0),nt="Z"in B?Ns(hn(B.y,0,1)).getUTCDay():As(hn(B.y,0,1)).getDay(),B.m=0,B.d="W"in B?(B.w+6)%7+B.W*7-(nt+5)%7:B.w+B.U*7-(nt+6)%7);return"Z"in B?(B.H+=B.Z/100|0,B.M+=B.Z%100,Ns(B)):As(B)}}function I(U,V,K,B){for(var it=0,J=V.length,nt=K.length,at,rt;it<J;){if(B>=nt)return-1;if(at=V.charCodeAt(it++),at===37){if(at=V.charAt(it++),rt=R[at in Oi?V.charAt(it++):at],!rt||(B=rt(U,K,B))<0)return-1}else if(at!=K.charCodeAt(B++))return-1}return B}function O(U,V,K){var B=l.exec(V.slice(K));return B?(U.p=u.get(B[0].toLowerCase()),K+B[0].length):-1}function Z(U,V,K){var B=p.exec(V.slice(K));return B?(U.w=x.get(B[0].toLowerCase()),K+B[0].length):-1}function D(U,V,K){var B=h.exec(V.slice(K));return B?(U.w=d.get(B[0].toLowerCase()),K+B[0].length):-1}function q(U,V,K){var B=v.exec(V.slice(K));return B?(U.m=k.get(B[0].toLowerCase()),K+B[0].length):-1}function L(U,V,K){var B=w.exec(V.slice(K));return B?(U.m=b.get(B[0].toLowerCase()),K+B[0].length):-1}function g(U,V,K){return I(U,e,V,K)}function A(U,V,K){return I(U,n,V,K)}function P(U,V,K){return I(U,r,V,K)}function z(U){return i[U.getDay()]}function F(U){return o[U.getDay()]}function E(U){return c[U.getMonth()]}function Y(U){return a[U.getMonth()]}function $(U){return s[+(U.getHours()>=12)]}function H(U){return 1+~~(U.getMonth()/3)}function X(U){return i[U.getUTCDay()]}function W(U){return o[U.getUTCDay()]}function j(U){return c[U.getUTCMonth()]}function tt(U){return a[U.getUTCMonth()]}function et(U){return s[+(U.getUTCHours()>=12)]}function ot(U){return 1+~~(U.getUTCMonth()/3)}return{format:function(U){var V=_(U+="",C);return V.toString=function(){return U},V},parse:function(U){var V=N(U+="",!1);return V.toString=function(){return U},V},utcFormat:function(U){var V=_(U+="",S);return V.toString=function(){return U},V},utcParse:function(U){var V=N(U+="",!0);return V.toString=function(){return U},V}}}var Oi={"-":"",_:" ",0:"0"},ft=/^\s*\d+/,Td=/^%/,Ed=/[\\^$*+?|[\]().{}]/g;function st(t,e,n){var r=t<0?"-":"",s=(r?-t:t)+"",o=s.length;return r+(o<n?new Array(n-o+1).join(e)+s:s)}function _d(t){return t.replace(Ed,"\\$&")}function fn(t){return new RegExp("^(?:"+t.map(_d).join("|")+")","i")}function dn(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Cd(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Pd(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function kd(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Md(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Rd(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function zi(t,e,n){var r=ft.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Ii(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Ad(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Nd(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Dd(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function $i(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Od(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Li(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function zd(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Id(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function $d(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ld(t,e,n){var r=ft.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Yd(t,e,n){var r=Td.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Bd(t,e,n){var r=ft.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Fd(t,e,n){var r=ft.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Yi(t,e){return st(t.getDate(),e,2)}function qd(t,e){return st(t.getHours(),e,2)}function Ud(t,e){return st(t.getHours()%12||12,e,2)}function Zd(t,e){return st(1+jn.count(Ht(t),t),e,3)}function Ic(t,e){return st(t.getMilliseconds(),e,3)}function Hd(t,e){return Ic(t,e)+"000"}function Vd(t,e){return st(t.getMonth()+1,e,2)}function Xd(t,e){return st(t.getMinutes(),e,2)}function Wd(t,e){return st(t.getSeconds(),e,2)}function Gd(t){var e=t.getDay();return e===0?7:e}function Kd(t,e){return st(fs.count(Ht(t)-1,t),e,2)}function $c(t){var e=t.getDay();return e>=4||e===0?We(t):We.ceil(t)}function jd(t,e){return t=$c(t),st(We.count(Ht(t),t)+(Ht(t).getDay()===4),e,2)}function Qd(t){return t.getDay()}function Jd(t,e){return st(zr.count(Ht(t)-1,t),e,2)}function tp(t,e){return st(t.getFullYear()%100,e,2)}function ep(t,e){return t=$c(t),st(t.getFullYear()%100,e,2)}function np(t,e){return st(t.getFullYear()%1e4,e,4)}function rp(t,e){var n=t.getDay();return t=n>=4||n===0?We(t):We.ceil(t),st(t.getFullYear()%1e4,e,4)}function sp(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+st(e/60|0,"0",2)+st(e%60,"0",2)}function Bi(t,e){return st(t.getUTCDate(),e,2)}function op(t,e){return st(t.getUTCHours(),e,2)}function ip(t,e){return st(t.getUTCHours()%12||12,e,2)}function ap(t,e){return st(1+Bo.count(ge(t),t),e,3)}function Lc(t,e){return st(t.getUTCMilliseconds(),e,3)}function cp(t,e){return Lc(t,e)+"000"}function lp(t,e){return st(t.getUTCMonth()+1,e,2)}function up(t,e){return st(t.getUTCMinutes(),e,2)}function hp(t,e){return st(t.getUTCSeconds(),e,2)}function fp(t){var e=t.getUTCDay();return e===0?7:e}function dp(t,e){return st(zc.count(ge(t)-1,t),e,2)}function Yc(t){var e=t.getUTCDay();return e>=4||e===0?Ge(t):Ge.ceil(t)}function pp(t,e){return t=Yc(t),st(Ge.count(ge(t),t)+(ge(t).getUTCDay()===4),e,2)}function gp(t){return t.getUTCDay()}function mp(t,e){return st(Ir.count(ge(t)-1,t),e,2)}function yp(t,e){return st(t.getUTCFullYear()%100,e,2)}function wp(t,e){return t=Yc(t),st(t.getUTCFullYear()%100,e,2)}function xp(t,e){return st(t.getUTCFullYear()%1e4,e,4)}function vp(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Ge(t):Ge.ceil(t),st(t.getUTCFullYear()%1e4,e,4)}function Sp(){return"+0000"}function Fi(){return"%"}function qi(t){return+t}function Ui(t){return Math.floor(+t/1e3)}var _e,Bc;bp({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 bp(t){return _e=bd(t),Bc=_e.format,_e.parse,_e.utcFormat,_e.utcParse,_e}function Tp(t){return new Date(t)}function Ep(t){return t instanceof Date?+t:+new Date(+t)}function Fc(t,e,n,r,s,o,i,a,c,l){var u=Rc(),h=u.invert,d=u.domain,p=l(".%L"),x=l(":%S"),w=l("%I:%M"),b=l("%I %p"),v=l("%a %d"),k=l("%b %d"),C=l("%B"),S=l("%Y");function R(_){return(c(_)<_?p:a(_)<_?x:i(_)<_?w:o(_)<_?b:r(_)<_?s(_)<_?v:k:n(_)<_?C:S)(_)}return u.invert=function(_){return new Date(h(_))},u.domain=function(_){return arguments.length?d(Array.from(_,Ep)):d().map(Tp)},u.ticks=function(_){var N=d();return t(N[0],N[N.length-1],_??10)},u.tickFormat=function(_,N){return N==null?R:l(N)},u.nice=function(_){var N=d();return(!_||typeof _.range!="function")&&(_=e(N[0],N[N.length-1],_??10)),_?d(id(N,_)):u},u.copy=function(){return Mc(u,Fc(t,e,n,r,s,o,i,a,c,l))},u}function _p(){return bc.apply(Fc(vd,Sd,Ht,Fo,fs,jn,Yo,Lo,Ae,Bc).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}const qc=M.z.enum(["linear","time"]),Uc=M.z.object({tickSpacing:M.z.number().default(75),type:qc.optional().default("linear")}),Zi=t=>{const e=Uc.parse(t);return kp[e.type](e)};class Cp{constructor(e){m(this,"props");this.props=e}generate({decimalToDataScale:e,size:n}){const r=[0,n],s=[new T.m(e.pos(0)).date(),new T.m(e.pos(1)).date()],o=_p().domain(s).range(r);return o.ticks(Zc(n,this.props.tickSpacing)).map(a=>({label:this.tickLabel(a),position:o(a)}))}tickLabel(e){const n=new T.m(e).date();let r=`:${n.getSeconds()}`;if(n.getMilliseconds()!==0){const o=Math.round(n.getMilliseconds()).toString().padStart(3,"0").replace(/0+$/,"");r+=`.${o}`}return n.getSeconds()===0&&n.getMilliseconds()===0&&(r=`${n.getHours()}:${n.getMinutes().toString().padStart(2,"0")}`),r}}class Pp{constructor(e){m(this,"props");this.props=e}generate({decimalToDataScale:e,size:n}){const r=[0,n],s=[e.pos(0),e.pos(1)],o=Oc().domain(s).range(r),i=Zc(n,this.props.tickSpacing);return o.ticks(i).map(c=>({label:this.tickLabel(c),position:o(c)}))}tickLabel(e){return e.toString()}}const Zc=(t,e)=>{const n=Math.floor(t/e);return n>0?n:1},kp={linear:t=>new Pp(t),time:t=>new Cp(t)},Hc=Uc.extend({color:f.Color.z,type:qc.optional().default("linear"),font:M.z.string(),showGrid:M.z.boolean().optional().default(!0),location:f.J.outer,gridColor:f.Color.z}),At=4;let Mp=class{constructor(e,n){m(this,"ctx");m(this,"state");m(this,"tickFactory");this.ctx=e,this.state=n,this.tickFactory=Zi(this.state)}setState(e){this.state=T.prettyParse(Hc,e),this.tickFactory=Zi(e)}render(e){const{lower2d:n}=this.ctx;switch(n.font=this.state.font,n.fillStyle=this.state.color.hex,n.lineWidth=1,this.state.location){case"left":return this.drawLeft(e);case"right":return this.drawRight(e);case"top":return this.drawTop(e);default:return this.drawBottom(e)}}drawBottom(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.width(r),o=f.To.height(r),i=e.position,a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"x",l.position),f.q.translate(i,{x:l.position,y:-o})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"x",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x+u.position,i.y),n.lineTo(i.x+u.position,i.y+At),n.stroke(),n.fillText(u.label,i.x+u.position-l.width/2,i.y+5+l.height)}).height+At}}drawTop(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.width(r),o=f.To.height(r),i=f.q.translate(e.position,"y",e.size),a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"x",l.position),f.q.translate(i,{x:l.position,y:o})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"x",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x+u.position,i.y),n.lineTo(i.x+u.position,i.y-At),n.stroke(),n.fillText(u.label,i.x+u.position-l.width/2,i.y-5-l.height)}).height+At}}drawLeft(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.height(r),o=f.To.width(r),i=f.q.translate(e.position,"x",e.size),a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"y",l.position),f.q.translate(i,{x:o,y:l.position})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"y",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x,i.y+u.position),n.lineTo(i.x-At,i.y+u.position),n.stroke(),n.fillText(u.label,i.x-l.width-At*2,i.y+u.position+l.height/3)}).width+At*2}}drawRight(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.height(r),o=f.To.width(r),i=e.position,a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"y",l.position),f.q.translate(i,{x:-o,y:l.position})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"y",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x,i.y+u.position),n.lineTo(i.x+At,i.y+u.position),n.stroke(),n.fillText(u.label,i.x+At+2,i.y+u.position+l.height/3)}).width+At*2}}drawLine(e,n){const{lower2d:r}=this.ctx;r.beginPath(),r.moveTo(...f.q.couple(e)),r.lineTo(...f.q.couple(n)),r.stroke()}drawTicks(e,n){let r=f._.ZERO;return e.forEach(s=>{const o=T.dimensions(s.label,this.state.font,this.ctx.lower2d);r=f._.max([r,o]),n(o,s)}),r}maybeDrawGrid(e,n,r){const{showGrid:s,gridColor:o}=this.state;if(s){const i=f.C.construct(-1,1),a=f.C.construct(e-1,e+1);this.ctx.lower2d.strokeStyle=o.hex,n.filter(({position:c})=>!f.C.contains(i,c)&&!f.C.contains(a,c)).forEach(c=>this.drawLine(...r(c)))}}};const dr=(t,e)=>f.To.construct(f.To.left(t)-e.x,f.To.top(t)-e.y,f.To.width(t)+e.x*2,f.To.height(t)+e.y*2);class $r{constructor(e,n=f.k.XY.IDENTITY){m(this,"scale_");m(this,"wrapped");this.wrapped=e,this.scale_=n}get fontStretch(){return this.wrapped.fontStretch}set fontStretch(e){this.wrapped.fontStretch=e}get fontVariantCaps(){return this.wrapped.fontVariantCaps}set fontVariantCaps(e){this.wrapped.fontVariantCaps=e}get wordSpacing(){return this.wrapped.wordSpacing}set wordSpacing(e){this.wrapped.wordSpacing=e}get letterSpacing(){return this.wrapped.letterSpacing}set letterSpacing(e){this.wrapped.letterSpacing=e}get textRendering(){return this.wrapped.textRendering}set textRendering(e){this.wrapped.textRendering=e}reset(){this.wrapped.reset()}applyScale(e){return new $r(this,e)}get canvas(){return this.wrapped.canvas}get miterLimit(){return this.wrapped.miterLimit}set miterLimit(e){this.wrapped.miterLimit=this.scale_.x.dim(e)}get globalAlpha(){return this.wrapped.globalAlpha}set globalAlpha(e){this.wrapped.globalAlpha=e}get globalCompositeOperation(){return this.wrapped.globalCompositeOperation}set globalCompositeOperation(e){this.wrapped.globalCompositeOperation=e}get fillStyle(){return this.wrapped.fillStyle}set fillStyle(e){this.wrapped.fillStyle=e}get strokeStyle(){return this.wrapped.strokeStyle}set strokeStyle(e){this.wrapped.strokeStyle=e}commit(){this.wrapped.commit()}drawImage(e,n,r,s,o,i,a,c,l){this.wrapped.drawImage(e,n,r,s,o,i,a,c,l)}beginPath(){this.wrapped.beginPath()}clip(e,n){this.wrapped.clip(e,n)}fill(e,n){if(e==null)return this.wrapped.fill();this.wrapped.fill(e,n)}isPointInPath(e,n,r,s){return this.wrapped.isPointInPath(e,n,r,s)}isPointInStroke(e,n,r){return this.wrapped.isPointInStroke(e,n,r)}stroke(e){if(e==null)return this.wrapped.stroke();this.wrapped.stroke(e)}createConicGradient(e,n,r){return this.wrapped.createConicGradient(e,n,r)}createLinearGradient(e,n,r,s){return this.wrapped.createLinearGradient(e,n,r,s)}createPattern(e,n){return this.wrapped.createPattern(e,n)}createRadialGradient(e,n,r,s,o,i){return this.wrapped.createRadialGradient(e,n,r,s,o,i)}get filter(){return this.wrapped.filter}set filter(e){this.wrapped.filter=e}createImageData(e,n,r){return this.wrapped.createImageData(e,n,r)}getImageData(e,n,r,s,o){return this.wrapped.getImageData(e,n,r,s,o)}putImageData(e,n,r,s,o,i,a){this.wrapped.putImageData(e,n,r,s,o,i,a)}get imageSmoothingEnabled(){return this.wrapped.imageSmoothingEnabled}set imageSmoothingEnabled(e){this.wrapped.imageSmoothingEnabled=e}get imageSmoothingQuality(){return this.wrapped.imageSmoothingQuality}set imageSmoothingQuality(e){this.wrapped.imageSmoothingQuality=e}arc(e,n,r,s,o,i){this.wrapped.arc(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),s,o,i)}arcTo(e,n,r,s,o){this.wrapped.arcTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s),this.scale_.x.dim(o))}bezierCurveTo(e,n,r,s,o,i){this.wrapped.bezierCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s),this.scale_.x.pos(o),this.scale_.y.pos(i))}closePath(){this.wrapped.closePath()}ellipse(e,n,r,s,o,i,a,c){this.wrapped.ellipse(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s),o,i,a,c)}lineTo(e,n){this.wrapped.lineTo(this.scale_.x.pos(e),this.scale_.y.pos(n))}moveTo(e,n){this.wrapped.moveTo(this.scale_.x.pos(e),this.scale_.y.pos(n))}quadraticCurveTo(e,n,r,s){this.wrapped.quadraticCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s))}rect(e,n,r,s){this.wrapped.rect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}roundRect(e,n,r,s,o){this.wrapped.roundRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s),typeof o=="number"?this.scale_.x.dim(o):o)}get lineCap(){return this.wrapped.lineCap}set lineCap(e){this.wrapped.lineCap=e}get lineDashOffset(){return this.wrapped.lineDashOffset}set lineDashOffset(e){this.wrapped.lineDashOffset=this.scale_.x.dim(e)}get lineJoin(){return this.wrapped.lineJoin}set lineJoin(e){this.wrapped.lineJoin=e}get lineWidth(){return this.wrapped.lineWidth}set lineWidth(e){this.wrapped.lineWidth=this.scale_.x.dim(e)}getLineDash(){return this.wrapped.getLineDash()}setLineDash(e){const n=Array.from(e).map(r=>this.scale_.x.dim(r));this.wrapped.setLineDash(n)}clearRect(e,n,r,s){this.wrapped.clearRect(e,n,r,s)}fillRect(e,n,r,s){this.wrapped.fillRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}strokeRect(e,n,r,s){this.wrapped.strokeRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}get shadowBlur(){return this.wrapped.shadowBlur}set shadowBlur(e){this.wrapped.shadowBlur=e}get shadowColor(){return this.wrapped.shadowColor}set shadowColor(e){this.wrapped.shadowColor=e}get shadowOffsetX(){return this.wrapped.shadowOffsetX}set shadowOffsetX(e){this.wrapped.shadowOffsetX=e}get shadowOffsetY(){return this.wrapped.shadowOffsetY}restore(){this.wrapped.restore()}save(){this.wrapped.save()}fillText(e,n,r,s){this.wrapped.fillText(e,this.scale_.x.pos(n),this.scale_.y.pos(r),s!=null?this.scale_.x.dim(s):void 0)}measureText(e){this.wrapped.font=Ds(this.wrapped.font,this.scale_.x.reverse());const n=this.wrapped.measureText(e);return this.wrapped.font=Ds(this.wrapped.font,this.scale_.x),n}strokeText(e,n,r,s){this.wrapped.strokeText(e,this.scale_.x.pos(n),this.scale_.y.pos(r),s!=null?this.scale_.x.dim(s):void 0)}get direction(){return this.wrapped.direction}set direction(e){this.wrapped.direction=e}get font(){return this.wrapped.font}set font(e){this.wrapped.font=Ds(e,this.scale_.x)}get fontKerning(){return this.wrapped.fontKerning}set fontKerning(e){this.wrapped.fontKerning=e}get textAlign(){return this.wrapped.textAlign}set textAlign(e){this.wrapped.textAlign=e}get textBaseline(){return this.wrapped.textBaseline}set textBaseline(e){this.wrapped.textBaseline=e}getTransform(){return this.wrapped.getTransform()}resetTransform(){this.wrapped.resetTransform()}rotate(e){this.wrapped.rotate(e)}scale(e,n){this.wrapped.scale(e,n)}scissor(e,n=f.q.ZERO){const r=new Path2D;return e=dr(e,n),r.rect(...f.q.couple(f.To.topLeft(e)),...f._.couple(f.To.dims(e))),this.save(),this.clip(r),()=>this.restore()}setTransform(e,n,r,s,o,i){this.wrapped.setTransform(e,n,r,s,o,i)}transform(e,n,r,s,o,i){this.wrapped.transform(e,n,r,s,o,i)}translate(e,n){this.wrapped.translate(e,n)}}const Hi=/(\d+(\.\d+)?)px/,Ds=(t,e)=>{var s;const n=Number((s=t.match(Hi))==null?void 0:s[1]);if(n==null)return t;const r=e.dim(n);return t.replace(Hi,`${r}px`)},Rp=`precision mediump float;
7
-
8
- void main(void) {
9
- gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
10
- }
11
- `,Ap=`attribute vec4 a_position;
12
-
13
- void main(void) {
14
- gl_Position = a_position;
15
- }
16
- `,Vi=t=>new Error(`failed to compile webgl program: ${t}`),Np=new Error("null shader encountered");class qo{constructor(e,n,r){m(this,"ctx");m(this,"prog");m(this,"vertShader");m(this,"fragShader");m(this,"uniformLocCache",new Map);this.ctx=e;const s=e.gl.createProgram();if(s==null)throw Vi("failed to create program");this.prog=s,this.vertShader=n,this.fragShader=r,this.compile()}setAsActive(){return this.ctx.gl.useProgram(this.prog),()=>this.ctx.gl.useProgram(null)}uniformXY(e,n){this.ctx.gl.uniform2fv(this.getUniformLoc(e),f.q.couple(f.q.construct(n)))}uniformColor(e,n){this.ctx.gl.uniform4fv(this.getUniformLoc(e),n.rgba1)}getUniformLoc(e){const n=this.uniformLocCache.get(e);if(n!=null)return n;const r=this.ctx.gl.getUniformLocation(this.prog,e);if(r==null)throw new Error(`unexpected missing uniform ${e}`);return this.uniformLocCache.set(e,r),r}compile(){const e=this.ctx.gl;this.compileShader(this.vertShader,e.VERTEX_SHADER),this.compileShader(this.fragShader,e.FRAGMENT_SHADER),e.linkProgram(this.prog)}compileShader(e,n){const r=this.ctx.gl,s=r.createShader(n);if(s==null)throw Np;if(r.shaderSource(s,e),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS)){const i=r.getShaderInfoLog(s);throw r.deleteShader(s),Vi(i??"unknown")}r.attachShader(this.prog,s)}}const Dp=new Float32Array([0,0,0,0,0,0]);class Op extends qo{constructor(n){super(n,Ap,Rp);m(this,"positionBuffer");const r=n.gl.createBuffer();if(r==null)throw new T.ze("webgl: failed to create buffer");this.positionBuffer=r,n.gl.bindBuffer(n.gl.ARRAY_BUFFER,this.positionBuffer),n.gl.bufferData(n.gl.ARRAY_BUFFER,Dp,n.gl.STATIC_DRAW)}exec(){const{gl:n}=this.ctx,r=n.getAttribLocation(this.prog,"a_position");n.bindBuffer(n.ARRAY_BUFFER,this.positionBuffer);const s=n.createVertexArray();n.bindVertexArray(s),n.enableVertexAttribArray(r),n.vertexAttribPointer(r,2,n.FLOAT,!1,0,0),this.setAsActive(),n.drawArrays(n.TRIANGLES,0,3)}}const Xi={high:1,low:0};class Vc{constructor(e){m(this,"mutex",new T.Mutex);m(this,"requests",new Map);m(this,"cleanup",new Map);m(this,"afterRender");this.start(),this.afterRender=e}async set(e){let n;e.priority==="high"&&(n=await this.mutex.acquire());const r=this.requests.get(e.key);if(r==null)this.requests.set(e.key,e);else{const s=Xi[e.priority]>=Xi[r.priority],o=e.canvases.length>=r.canvases.length;s&&o&&this.requests.set(e.key,e)}n==null||n()}async render(){await this.mutex.runExclusive(async()=>{var i;const e=performance.now();if(this.requests.size===0)return;const{requests:n,cleanup:r}=this;for(const[a,c]of r.entries()){const l=n.get(a);l!=null&&(await c(l),r.delete(a))}for(const a of n.values())try{const c=await a.render();c!=null&&this.cleanup.set(a.key,c)}catch(c){console.error(c)}const s=performance.now(),o=T.w.milliseconds(s-e);o.greaterThan(T.w.milliseconds(25))&&console.warn(`Render loop for ${this.requests.size} took longer than 16ms to execute: ${o.milliseconds}`),this.requests.clear(),(i=this.afterRender)==null||i.call(this)})}async start(){do{try{await this.render()}catch(e){console.error(e)}await this.sleep()}while(!0)}async sleep(){return await new Promise(requestAnimationFrame)}}var Dt;let gt=(Dt=class{constructor(e,n,r,s){m(this,"glCanvas");m(this,"upper2dCanvas");m(this,"lower2dCanvas");m(this,"gl");m(this,"lower2d");m(this,"upper2d");m(this,"region");m(this,"dpr");m(this,"loop");m(this,"clearProgram");m(this,"os");this.upper2dCanvas=r,this.lower2dCanvas=n,this.glCanvas=e,this.os=s;const o=this.lower2dCanvas.getContext("2d");if(o==null)throw new Error("Could not get 2D context");this.lower2d=new $r(o);const i=this.upper2dCanvas.getContext("2d");if(i==null)throw new Error("Could not get 2D context");this.upper2d=new $r(i);const a={preserveDrawingBuffer:!0,powerPreference:"high-performance",stencil:!1,depth:!1},c=this.glCanvas.getContext("webgl2",a);if(c==null)throw new Error("Could not get WebGL context");c.disable(c.DEPTH_TEST),c.disable(c.STENCIL_TEST),c.disable(c.CULL_FACE),c.disable(c.DITHER),this.gl=c;const l=()=>{this.gl.flush(),this.gl.finish()};this.loop=new Vc(l),this.region=f.To.ZERO,this.dpr=1,this.os==="Windows"&&(this.clearProgram=new Op(this))}static create(e,n,r,s,o){const i=new Dt(n,r,s,o);return e.set(Dt.CONTEXT_KEY,i),i}static useOptional(e){return e.getOptional(Dt.CONTEXT_KEY)}static use(e){return e.get(Dt.CONTEXT_KEY)}update(e){e.set(Dt.CONTEXT_KEY,this)}resize(e,n){f.To.equals(this.region,e)&&this.dpr===n||(this.region=e,this.dpr=n,this.resizeCanvas(this.glCanvas),this.resizeCanvas(this.upper2dCanvas),this.resizeCanvas(this.lower2dCanvas),this.lower2d.scale(this.dpr,this.dpr),this.upper2d.scale(this.dpr,this.dpr),this.gl.viewport(0,0,f.To.width(e)*n,f.To.height(e)*n))}resizeCanvas(e){e.width=f.To.width(this.region)*this.dpr,e.height=f.To.height(this.region)*this.dpr}get aspect(){return f.To.aspect(this.region)}scaleRegion(e){return new f.k.XY(f.k.Scale.scale(0,1).scale(f.To.width(e)).translate(f.To.left(e)).reBound(f.To.width(this.region)).scale(-1,1),f.k.Scale.scale(0,1).scale(f.To.height(e)).invert().translate(f.To.top(e)).reBound(f.To.height(this.region)).scale(-1,1).invert())}scissor(e,n=f.q.ZERO,r){const s=[];return r.includes("upper2d")&&s.push(this.upper2d.scissor(e,n)),r.includes("lower2d")&&s.push(this.lower2d.scissor(e,n)),r.includes("gl")&&s.push(this.scissorGL(e,n)),()=>s.forEach(o=>o())}scissorGL(e,n=f.q.ZERO){return this.gl.enable(this.gl.SCISSOR_TEST),e=dr(e,n),this.gl.scissor(f.To.left(e)*this.dpr,(f.To.height(this.region)-f.To.bottom(e))*this.dpr,f.To.width(e)*this.dpr,f.To.height(e)*this.dpr),()=>this.gl.disable(this.gl.SCISSOR_TEST)}erase(e,n=f.q.ZERO,...r){n=f.q.construct(n),r.length===0&&(r=["upper2d","lower2d","gl"]),r.includes("upper2d")&&this.eraseCanvas(this.upper2d,e,n),r.includes("lower2d")&&this.eraseCanvas(this.lower2d,e,n),r.includes("gl")&&this.eraseGL(e,n)}eraseGL(e,n=f.q.ZERO){var o;const{gl:r}=this,s=this.scissorGL(dr(e,n));r.clearColor(...f.ZERO.rgba1),r.clear(r.COLOR_BUFFER_BIT),this.os==="Windows"&&((o=this.clearProgram)==null||o.exec()),s()}eraseCanvas(e,n,r=f.q.ZERO){const s=dr(n,r);e.clearRect(...f.q.couple(f.To.topLeft(s)),...f._.couple(f.To.dims(s)))}},m(Dt,"CONTEXT_KEY",f.CSS.B("render-context")),Dt);const zt="layout",ro="data",Jt="tool";var Ut;let yt=(Ut=class{constructor(e){m(this,"f");this.f=e}static control(e,n){e.set(Ut.CONTEXT_KEY,new Ut(n),!1)}static useRequest(e){return e.get(Ut.CONTEXT_KEY).f}static useOptionalRequest(e){var n;return((n=e.getOptional(Ut.CONTEXT_KEY))==null?void 0:n.f)??null}static requestRender(e,n){this.useRequest(e)(n)}},m(Ut,"CONTEXT_KEY","pluto-vis-renderer"),Ut),ds=class{constructor(){m(this,"prevErase",f.To.ZERO)}erase(e,n,r,s,o){!f.To.equals(r,n)&&!f.To.equals(this.prevErase,r)?(e.erase(r,s,...o),this.prevErase=r):e.erase(n,s,...o)}};const Qn=Hc.extend({bounds:f.C.bounds.optional(),autoBounds:M.z.object({lower:M.z.boolean().optional().default(!0),upper:M.z.boolean().optional().default(!0)}).or(M.z.boolean().optional().default(!0)),autoBoundPadding:M.z.number().optional(),autoBoundUpdateInterval:T.w.z.optional().default(T.w.seconds(2)),size:M.z.number().optional().default(0),label:M.z.string().optional().default(""),labelSize:M.z.number().optional().default(0)}).partial({color:!0,font:!0,gridColor:!0}),zp=2,Ip=7,Xc=(t,e)=>f.C.contains({lower:t-Ip,upper:t+zp},e),$p=f.C.DECIMAL,Wi=T.m.now(),Lp={lower:Number(Wi.valueOf()),upper:Number(Wi.add(T.w.HOUR).valueOf())},Wc=t=>t==="linear"?$p:Lp,Yp=(t,e=.1,n)=>{const r=f.C.max(t.filter(f.C.isFinite));if(!f.C.isFinite(r))return Wc(n);const{lower:s,upper:o}=r;if(o===s)return{lower:s-1,upper:o+1};const i=(o-s)*e;return{lower:s-i,upper:o+i}},Bp=.01,Fp=.1;class Gc extends T.Composite{async afterUpdate(){var n;this.internal.render=gt.use(this.ctx);const e=T.use(this.ctx);(n=this.state).autoBoundPadding??(n.autoBoundPadding=f.f.construct(this.state.location)==="x"?Fp:Bp),this.internal.core=new Mp(this.internal.render,{color:e.colors.gray.l8,font:T.fontString(e,"small"),gridColor:e.colors.gray.l2,...this.state}),yt.requestRender(this.ctx,zt),this.internal.updateBounds==null&&(this.internal.updateBounds=T.r(r=>{this.setState(s=>({...s,bounds:r}))},this.state.autoBoundUpdateInterval.milliseconds))}async afterDelete(){yt.requestRender(this.ctx,zt)}renderAxis(e,n){if(!e.canvases.includes("lower2d"))return;const{core:r}=this.internal,{grid:s,container:o}=e,i=Qh(`${this.type}-${this.key}`,s,o),a={...e,position:i,decimalToDataScale:n,size:this.state.size+this.state.labelSize},{size:c}=r.render(a);Xc(this.state.size,c)||this.setState(l=>({...l,size:c}))}async bounds(e,n){var l,u;if(e&&this.internal.boundSnapshot!=null)return[this.internal.boundSnapshot,null];const{lower:r,upper:s}=Kc(this.state.autoBounds);if(!r&&!s&&this.state.bounds!=null)return this.internal.boundSnapshot=this.state.bounds,[this.state.bounds,null];const o=h=>({upper:s||this.state.bounds==null?h.upper:this.state.bounds.upper,lower:r||this.state.bounds==null?h.lower:this.state.bounds.lower});let i,a=null;try{const h=await n();i=Yp(h,this.state.autoBoundPadding,this.state.type)}catch(h){i=Wc(this.state.type),a=h}const c=o(i);return this.internal.boundSnapshot=c,(this.state.bounds==null||r&&this.state.bounds.lower!==c.lower||s&&this.state.bounds.upper!==c.upper)&&((u=(l=this.internal).updateBounds)==null||u.call(l,c)),[c,a]}async dataToDecimalScale(e,n,r){const[s,o]=await this.bounds(e,n),i=f.f.swap(f.f.construct(this.state.location));return[f.k.Scale.scale(s).scale(1).translate(-f.To.root(r)[i]).magnify(1/f.To.dim(r,i)),o]}}const Kc=t=>typeof t=="boolean"?{lower:t,upper:t}:{lower:(t==null?void 0:t.lower)??!0,upper:(t==null?void 0:t.upper)??!0},qp=`precision lowp float;
17
- uniform lowp vec4 u_color;
18
-
19
- void main(void) {
20
- gl_FragColor = u_color;
21
- }
22
- `,Up=`attribute float a_x;
23
- attribute float a_y;
24
- attribute vec2 a_translate;
25
-
26
- uniform lowp vec2 u_region_scale;
27
- uniform lowp vec2 u_region_offset;
28
- uniform lowp vec2 u_scale;
29
- uniform lowp vec2 u_offset;
30
-
31
- void main(void) {
32
- vec2 transformed = u_region_scale * (u_scale * vec2(a_x,a_y) + u_offset) + u_region_offset;
33
- transformed = transformed + a_translate;
34
- gl_Position = vec4(transformed, 0.0, 1.0);
35
- }
36
- `,Gi=T.g.FLOAT32.density.valueOf(),jc=M.z.object({x:Ws,y:Ws,label:M.z.string().optional(),color:f.Color.z,strokeWidth:M.z.number().default(1),downsample:M.z.number().min(1).max(50).optional().default(1)}),Zp=(t,e,n)=>t===-1||e===-1||t>=n.length?NaN:Number(n[t].at(e)),Hp=T.w.milliseconds(2);f.q.NAN,f.q.NAN,f.ZERO;const Oe=class Oe extends qo{constructor(n){super(n,Up,qp);m(this,"translationBufferCache",new Map);this.translationBufferCache=new Map}bindCommonPropsAndState({dataToDecimalScale:n,region:r},{strokeWidth:s,color:o}){const i=f.k.xyScaleToTransform(n),a=f.k.xyScaleToTransform(this.ctx.scaleRegion(r));return this.uniformXY("u_region_scale",a.scale),this.uniformXY("u_region_offset",a.offset),this.uniformColor("u_color",o),this.uniformXY("u_scale",i.scale),this.uniformXY("u_offset",i.offset),this.attrStrokeWidth(s)}bindScale(n){const r=f.k.xyScaleToTransform(n);this.uniformXY("u_scale",r.scale),this.uniformXY("u_offset",r.offset)}draw({x:n,y:r,count:s,downsample:o,xOffset:i,yOffset:a},c){const{gl:l}=this.ctx;this.bindAttrBuffer("x",n.glBuffer,o,i),this.bindAttrBuffer("y",r.glBuffer,o,a),l.drawArraysInstanced(l.LINE_STRIP,0,s/o,c)}static create(n){const r=gt.use(n),s=new Oe(r);return n.set(Oe.CONTEXT_KEY,s),s}static use(n){return n.get(Oe.CONTEXT_KEY)}bindAttrBuffer(n,r,s,o=0){const{gl:i}=this.ctx;i.bindBuffer(i.ARRAY_BUFFER,r);const a=i.getAttribLocation(this.prog,`a_${n}`);i.vertexAttribPointer(a,1,i.FLOAT,!1,Gi*s,Gi*o),i.enableVertexAttribArray(a)}getAndBindTranslationBuffer(n){const{gl:r}=this.ctx,s=`${this.ctx.aspect}:${n}`,o=this.translationBufferCache.get(s);if(o!=null)return r.bindBuffer(r.ARRAY_BUFFER,o.glBuffer),o;const i=r.createBuffer();if(i==null)throw new T.ze("Failed to create buffer from WebGL context");const a=Xp(this.ctx.aspect,n);r.bindBuffer(r.ARRAY_BUFFER,i),r.bufferData(r.ARRAY_BUFFER,a,r.DYNAMIC_DRAW);const c={glBuffer:i,jsBuffer:a};return this.translationBufferCache.set(s,c),c}attrStrokeWidth(n){const{gl:r}=this.ctx,{jsBuffer:s}=this.getAndBindTranslationBuffer(n),o=r.getAttribLocation(this.prog,"a_translate");return r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(o),r.vertexAttribDivisor(o,1),s.length/2}};m(Oe,"CONTEXT_KEY","pluto-line-gl-program");let Lr=Oe;class $n extends T.Leaf{constructor(){super(...arguments);m(this,"schema",jc)}async afterUpdate(){if(this.deleted)return;const{internal:n}=this;n.xTelem=await Qt(this.ctx,this.state.x,n.xTelem),n.yTelem=await Qt(this.ctx,this.state.y,n.yTelem),n.instrumentation=Gn(this.ctx,"line"),n.prog=Lr.use(this.ctx),n.requestRender=yt.useRequest(this.ctx),n.xTelem.onChange(()=>n.requestRender(ro)),n.yTelem.onChange(()=>n.requestRender(ro)),n.requestRender(zt)}async afterDelete(){var r,s,o,i;const{internal:n}=this;await((s=(r=n.xTelem).cleanup)==null?void 0:s.call(r)),await((i=(o=n.yTelem).cleanup)==null?void 0:i.call(o)),n.requestRender(zt)}async xBounds(){return(await this.internal.xTelem.value())[0]}async yBounds(){return(await this.internal.yTelem.value())[0]}async findByXValue(n,r){const{xTelem:s,yTelem:o}=this.internal,[,i]=await s.value();let[a,c]=[-1,-1];i.find((v,k)=>{const C=v.binarySearch(r),S=C>=0&&C<v.length;return S&&([a,c]=[C,k]),S});const{key:l}=this,{color:u,label:h}=this.state,d={key:l,color:u,label:h,position:{x:0,y:0},value:{x:NaN,y:NaN}};if(a===-1||c===-1)return d;const p=i[c];d.value.x=Zp(c,a,i);const[,x]=await o.value(),w=x.find(v=>f.C.contains(v.alignmentBounds,p.alignment+BigInt(a)));if(w==null)return d;const b=Number(w.alignment-p.alignment);return d.value.y=Number(w.at(a-b)),d.position={x:n.dataToDecimalScale.x.pos(d.value.x),y:n.dataToDecimalScale.y.pos(d.value.y)},d}async render(n){if(this.deleted)return;const{downsample:r}=this.state,{xTelem:s,yTelem:o,prog:i}=this.internal,{dataToDecimalScale:a}=n,[[,c],[,l]]=await Promise.all([s.value(),o.value()]);c.forEach(p=>p.updateGLBuffer(i.ctx.gl)),l.forEach(p=>p.updateGLBuffer(i.ctx.gl));const u=Jp(c,l,r,Hp);this.internal.instrumentation.L.debug("render",()=>({key:this.key,downsample:r,scale:f.k.xyScaleToTransform(a),props:n.region,ops:eg(u)}));const h=i.setAsActive(),d=i.bindCommonPropsAndState(n,this.state);u.forEach(p=>{i.bindScale(jp(a,p)),i.draw(p,d)}),h()}}m($n,"TYPE","line");const Vp=5e3,Xp=(t,e)=>Kp(Gp(t),e).map((n,r)=>Math.floor(r/Wp)*(1/(Vp*t))*n),Wp=5,Gp=t=>new Float32Array([0,0,0,t,0,-t,1,0,-1,0]),Kp=(t,e)=>{const n=new Float32Array(t.length*e);for(let r=0;r<e;r++)n.set(t,r*t.length);return n},jp=(t,e)=>t.translate(t.x.dim(Number(e.x.sampleOffset)),t.y.dim(Number(e.y.sampleOffset))),Qp={[$n.TYPE]:$n},Jp=(t,e,n,r)=>{if(t.length===0||e.length===0)return[];const s=[];return t.forEach(o=>{tg(o,e,r).forEach(a=>{let c=0,l=0;o.alignment<a.alignment?c=Number(a.alignment-o.alignment):a.alignment<o.alignment&&(l=Number(o.alignment-a.alignment));const u=Math.min(o.length-c,a.length-l);u!==0&&s.push({x:o,y:a,xOffset:c,yOffset:l,count:u,downsample:n})})}),s},tg=(t,e,n)=>e.filter(r=>{if(!(t._timeRange!=null&&r._timeRange!=null))throw new T.ze(`Encountered series without time range in buildDrawOperations. X series present: ${t._timeRange!=null}, Y series present: ${r._timeRange!=null}`);const o=t.timeRange.overlapsWith(r.timeRange,n),i=f.C.overlapsWith(t.alignmentBounds,r.alignmentBounds);return o&&i}),eg=t=>t.map(e=>({...e,x:e.x.digest,y:e.y.digest}));class Jn{constructor(e,n){m(this,"canvas");m(this,"theme");this.canvas=e,this.theme=n}rule({direction:e,region:n,position:r,...s}){return e==="x"?this.line({start:f.q.construct(f.To.left(n),r),end:f.q.construct(f.To.right(n),r),...s}):this.line({start:f.q.construct(r,f.To.top(n)),end:f.q.construct(r,f.To.bottom(n)),...s})}line({stroke:e,lineWidth:n,lineDash:r,start:s,end:o}){const i=this.canvas;i.strokeStyle=e.hex,i.lineWidth=n,i.setLineDash([r]),i.beginPath(),i.moveTo(...f.q.couple(s)),i.lineTo(...f.q.couple(o)),i.stroke()}circle({fill:e,radius:n,position:r}){const s=this.canvas;s.fillStyle=e.hex,s.beginPath(),s.arc(...f.q.couple(r),n,0,2*Math.PI),s.fill()}resolveColor(e,n){return e==null?this.resolveColor(n):typeof e=="function"?e(this.theme):new f.Color(e)}border({region:e,color:n,width:r,radius:s,location:o}){const i=this.canvas;i.strokeStyle=this.resolveColor(n,this.theme.colors.border).hex,i.lineWidth=r??this.theme.sizes.border.width,s??(s=this.theme.sizes.border.radius),o==null||o===!0?s>0?(i.roundRect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e)),s),i.stroke()):(i.rect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e))),i.stroke()):T.A(o).forEach(a=>{const[c,l]=f.To.edgePoints(e,a);i.beginPath(),i.moveTo(...f.q.couple(c)),i.lineTo(...f.q.couple(l)),i.stroke()})}container({region:e,bordered:n=!0,rounded:r=!0,borderColor:s,borderRadius:o,borderWidth:i,backgroundColor:a}){o==null&&(o=this.theme.sizes.border.radius),i==null&&(i=1);const c=this.canvas;c.fillStyle=this.resolveColor(a,this.theme.colors.gray.l1).hex,c.strokeStyle=this.resolveColor(s,this.theme.colors.border).hex,c.setLineDash([]),c.lineWidth=1,c.beginPath(),r?c.roundRect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e)),o):c.rect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e))),c.fill(),n&&this.border({region:e,color:s,radius:o,width:i,location:n})}textContainer(e){const[n,r]=this.spacedTextDrawF(e);n.width+=12,n.height+=12;const{root:s=f.J.TOP_LEFT,offset:o=f.q.ZERO}=e,i={...e.position};s.x==="right"?i.x-=n.width+o.x:i.x+=o.x,s.y==="bottom"?i.y-=n.height+o.y:i.y+=o.y,this.container({region:f.To.construct(i,n.width,n.height),...e}),this.canvas.filter="none",r(f.q.translate(i,[6,6]))}spacedTextDrawF({text:e,direction:n,spacing:r=1,level:s="p"}){const o=T.fontString(this.theme,s),i=e.map(l=>T.dimensions(l,o,this.canvas)),a=this.theme.sizes.base*r,c=Math.max(...i.map(l=>l[f.f.dimension(n)]))+a;return[{[f.f.dimension(f.f.swap(n))]:Math.max(...i.map(l=>l[f.f.dimension(f.f.swap(n))])),[f.f.dimension(n)]:c*e.length-a},l=>{const u=T.fontString(this.theme,s);this.canvas.font=u,this.canvas.fillStyle=this.theme.colors.text.hex,this.canvas.textBaseline="top",e.forEach((h,d)=>{this.canvas.fillText(h,l.x,l.y+c*d)})}]}drawTextInCenter({box:e,text:n,level:r}){const s=T.dimensions(n,this.canvas.font,this.canvas),o=f.To.positionInCenter(f.To.construct(f.q.ZERO,s),e);return this.text({text:n,position:f.To.topLeft(o),level:r})}text({text:e,position:n,level:r="p",weight:s,shade:o,maxWidth:i}){this.canvas.font=T.fontString(this.theme,r,s),o==null?this.canvas.fillStyle=this.theme.colors.text.hex:this.canvas.fillStyle=this.theme.colors.gray[`l${o}`].hex,this.canvas.textBaseline="top";let a;i!=null&&(a=this.canvas.scissor(f.To.construct(n,i,1e3))),this.canvas.fillText(e,n.x,n.y),a==null||a()}}const Uo=M.z.object({position:M.z.number().optional(),pixelPosition:M.z.number().optional(),dragging:M.z.boolean(),lineWidth:M.z.number().optional().default(1),lineDash:M.z.number().optional().default(20),color:f.Color.z});class Ke extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Uo)}async afterUpdate(){this.internal.renderCtx=gt.use(this.ctx);const n=T.use(this.ctx);this.internal.draw=new Jn(this.internal.renderCtx.upper2d,n),yt.requestRender(this.ctx,Jt)}async afterDelete(){yt.requestRender(this.ctx,Jt)}updatePositions({decimalToDataScale:n,plot:r,container:s}){if(this.state.dragging&&this.state.pixelPosition!=null){const i=n.pos((this.state.pixelPosition-f.To.top(r)+f.To.top(s))/f.To.height(r));return this.setState(a=>({...a,position:i})),this.state.pixelPosition}if(this.state.position==null){const i=n.pos(.5);this.setState(a=>({...a,position:i}))}const o=n.reverse().pos(this.state.position)*f.To.height(r)+f.To.top(r)-f.To.top(s);return isNaN(o)||this.setState(i=>({...i,pixelPosition:o})),o}async render(n){if(this.deleted)return;const{renderCtx:r}=this.internal,{location:s,plot:o}=n,i=f.J.direction(s),{upper2d:a}=r,c=this.internal.draw;let l=this.updatePositions(n);l+=f.To.top(n.container),c.rule({stroke:this.state.color,lineWidth:this.state.lineWidth,lineDash:this.state.lineDash,direction:i,region:o,position:l}),a.fillStyle=this.state.color.hex,a.beginPath(),s==="left"?(a.moveTo(f.To.left(o),l),a.lineTo(f.To.left(o)-5,l-5),a.lineTo(f.To.left(o)-5,l+5)):s==="right"&&(a.moveTo(f.To.right(o),l),a.lineTo(f.To.right(o)+5,l-5),a.lineTo(f.To.right(o)+5,l+5)),a.closePath(),a.fill()}}m(Ke,"TYPE","Rule");const Qc={[Ke.TYPE]:Ke},ng=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:Qc,Rule:Ke,ruleStateZ:Uo},Symbol.toStringTag,{value:"Module"})),rg=Qn.extend({location:f.J.x.optional().default("left")});class Ln extends Gc{constructor(){super(...arguments);m(this,"schema",Qn)}async xBounds(){return f.C.max(await Promise.all(this.lines.map(async n=>await n.xBounds())))}async render(n){if(this.deleted)return;const[r,s]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport),o=r.invert().reverse();if(this.renderAxis(n,o),await this.renderLines(n,r),await this.renderRules(n,o),s!=null)throw s}async renderLines({xDataToDecimalScale:n,plot:r,canvases:s},o){if(!s.includes("gl"))return;const i={region:r,dataToDecimalScale:new f.k.XY(n,o)};await Promise.all(this.lines.map(async a=>await a.render(i)))}async renderRules({container:n,plot:r,canvases:s},o){if(!s.includes("upper2d"))return;const{location:i}=this.state,{render:a}=this.internal,c=f.To.construct(f.To.left(n),f.To.top(r),f.To.width(n),f.To.height(r)),l=a.scissor(c,f.q.ZERO,["upper2d"]),u={container:n,plot:r,decimalToDataScale:o,location:i};await Promise.all(this.rules.map(async h=>await h.render(u))),l()}async findByXValue({xDataToDecimalScale:n,plot:r,viewport:s,hold:o},i){const[a,c]=await this.dataToDecimalScale(o,this.dataBounds.bind(this),s);if(c!=null)throw c;const l=new f.k.XY(n,a),u={region:r,dataToDecimalScale:l};return(await Promise.all(this.lines.map(async h=>await h.findByXValue(u,i)))).map(h=>({...h,units:this.state.label}))}async dataBounds(){return await Promise.all(this.lines.map(async n=>await n.yBounds()))}get lines(){return this.childrenOfType($n.TYPE)}get rules(){return this.childrenOfType(Ke.TYPE)}}m(Ln,"TYPE","YAxis");const Jc=M.z.object({start:T.m.z,end:T.m.z});class Yr extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Jc)}async afterUpdate(){this.internal.render=gt.use(this.ctx),this.internal.draw=new Jn(this.internal.render.upper2d,T.use(this.ctx))}async render(){}}m(Yr,"TYPE","range-annotation");const tl=M.z.object({triggered:M.z.boolean(),status:T.specZ$1,sink:ls.optional().default(as),source:To.optional().default(bo)});class Br extends T.Leaf{constructor(){super(...arguments);m(this,"schema",tl)}async afterUpdate(){var s,o,i;const{sink:n,source:r}=this.state;this.internal.source=await Qt(this.ctx,r,this.internal.source),this.internal.sink=await is(this.ctx,n,this.internal.sink),this.state.triggered&&!this.prevState.triggered&&this.internal.sink.set(((s=this.state.status.data)==null?void 0:s.authority)!==T.iy.Absolute.valueOf()).catch(console.error),await this.updateEnabledState(),(i=(o=this.internal).stopListening)==null||i.call(o),this.internal.stopListening=this.internal.source.onChange(()=>{this.updateEnabledState()})}async updateEnabledState(){const n=await this.internal.source.value();n.time.equals(this.state.status.time)||this.setState(r=>({...r,status:n,triggered:!1}))}async afterDelete(){this.asyncAfterDelete().catch(console.error)}async asyncAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}render(){}}m(Br,"TYPE","Chip");const el=M.z.object({}),Ki="control-state-provider",sg=T.Dd.stateZ.extend({subjectColor:f.Color.z});class je extends T.Composite{constructor(){super(...arguments);m(this,"schema",el);m(this,"colors",new Map);m(this,"tracker");m(this,"disconnectTrackerChange");m(this,"obs",new xo.Observer)}static use(n){return n.get(Ki)}async afterUpdate(){const{internal:n}=this;n.instrumentation=Gn(this.ctx,"control-state");const r=T.use(this.ctx);n.palette=r.colors.visualization.palettes.default,n.defaultColor=r.colors.gray.l6;const s=Vn(this.ctx);n.client!=null&&s===n.client||(n.client=s,this.ctx.set(Ki,this),await this.maybeCloseTracker(),n.client!=null&&(this.internal.instrumentation.L.debug("starting state tracker"),await this.openTracker(n.client)))}async maybeCloseTracker(){var n;this.tracker!=null&&(this.internal.instrumentation.L.debug("stopping state tracker"),(n=this.disconnectTrackerChange)==null||n.call(this),await this.tracker.close(),this.tracker=void 0)}async afterDelete(){await this.maybeCloseTracker()}onChange(n){return this.obs.onChange(n)}get(n){return Array.isArray(n)?T.n(n).map(r=>this.getOne(r)).filter(r=>r!=null):this.getOne(n)}getOne(n){if(this.tracker==null)return;const r=this.tracker.states.get(n);if(r!=null)return{...r,subjectColor:this.colors.get(r.subject.key)??this.internal.defaultColor}}async openTracker(n){var o;const{internal:r}=this,{instrumentation:s}=r;try{this.tracker=await n.control.openStateTracker()}catch{s.L.error("failed to open state tracker");return}(o=this.disconnectTrackerChange)==null||o.call(this),this.disconnectTrackerChange=this.tracker.onChange(i=>{if(s.L.debug("transfer",{transfers:i.map(a=>T.Dd.transferString(a))}),this.tracker==null)throw new T.ze("tracker is null inside it's own onChange callback!");this.updateColors(this.tracker),this.obs.notify(i)})}updateColors(n){const r=n.subjects(),s=r.map(a=>a.key),o=Array.from(this.colors.values());this.colors.forEach((a,c)=>!s.includes(c)&&this.colors.delete(c));const{palette:i}=this.internal;r.forEach(a=>{if(this.colors.has(a.key))return;const c=i.find(l=>!o.includes(l))??i[0];this.colors.set(a.key,c),o.push(c)})}}m(je,"TYPE","StateProvider");const og=["acquired","released","overridden","failed"],ig=M.z.enum(og),nl=M.z.object({name:M.z.string(),authority:M.z.number().default(0),acquireTrigger:M.z.number(),status:ig.optional(),needsControlOf:T.kd.keyZ.array().optional().default([])});class Fr extends T.Composite{constructor(){super(...arguments);m(this,"schema",nl);m(this,"registry",new Map);m(this,"writer")}async afterUpdate(){this.internal.instrumentation=Gn(this.ctx),(this.internal.prevTrigger==null||Math.abs(this.state.acquireTrigger-this.internal.prevTrigger)>1)&&(this.internal.prevTrigger=this.state.acquireTrigger);const n=Vn(this.ctx),r=je.use(this.ctx);this.internal.client=n,this.internal.client==null&&await this.release(),this.internal.stateProv=r,$a(this.ctx,this),this.internal.addStatus=T.useAggregate(this.ctx),this.state.acquireTrigger>this.internal.prevTrigger?(this.acquire(),this.internal.prevTrigger=this.state.acquireTrigger):this.state.acquireTrigger<this.internal.prevTrigger&&(this.release(),this.internal.prevTrigger=this.state.acquireTrigger)}async afterDelete(){await this.release()}async updateNeedsControlOf(){if(this.internal.client==null)throw new T.ze("No cluster connected but channelKeys were requested");const n=new Set([]);for(const s of this.registry.keys())(await s.needsControlOf(this.internal.client)).forEach(i=>i!==0&&n.add(i));const r=Array.from(n);T.S.unorderedPrimitiveArrays(this.state.needsControlOf,r)!==T.S.EQUAL&&this.setState(s=>({...s,needsControlOf:r}))}async acquire(){const{client:n,addStatus:r}=this.internal;if(n==null)return r({message:`Cannot acquire control on ${this.state.name} because no cluster has been connected.`,variant:"warning"});try{await this.updateNeedsControlOf();const s=this.state.needsControlOf;if(s.length===0)return r({message:`Cannot acquire control on ${this.state.name} because there are no channels to control.`,variant:"warning"});this.writer=await n.openWriter({start:T.S$1.now(),channels:s,controlSubject:{key:this.key,name:this.state.name},authorities:this.state.authority}),this.setState(o=>({...o,status:"acquired"})),r({message:`Acquired control on ${this.state.name}`,variant:"success"})}catch(s){this.setState(o=>({...o,status:"failed"})),r({message:`${this.state.name} failed to acquire control: ${s.message}`,variant:"error"})}}async release(){var n;await((n=this.writer)==null?void 0:n.close()),this.setState(r=>({...r,status:"released"})),this.writer!=null&&this.internal.addStatus({message:`Released control on ${this.state.name}.`,variant:"success"}),this.writer=void 0}async set(n){var r;this.writer==null&&await this.acquire(),await((r=this.writer)==null?void 0:r.write(n))}async setAuthority(n,r){var s;this.writer==null&&await this.acquire(),await((s=this.writer)==null?void 0:s.setAuthority(Object.fromEntries(n.map(o=>[o,r]))))}async releaseAuthority(n){var r;this.writer==null&&await this.acquire(),await((r=this.writer)==null?void 0:r.setAuthority(Object.fromEntries(n.map(s=>[s,this.state.authority]))))}deleteTelem(n){this.registry.delete(n),this.updateNeedsControlOf()}create(n){const s=(()=>{switch(n.type){case qr.TYPE:{const o=new qr(this,n.props);return this.registry.set(o,null),o}case Zr.TYPE:{const o=new Zr(this,this.internal.stateProv,n.props);return this.registry.set(o,null),o}case Ur.TYPE:return new Ur(this,n.props);default:return null}})();return s!=null&&this.updateNeedsControlOf(),s}}m(Fr,"TYPE","Controller");const rl=M.z.object({channel:M.z.number()});class qr extends hs{constructor(n,r){super(r);m(this,"controller");m(this,"schema",rl);this.controller=n}invalidate(){}async cleanup(){this.controller.deleteTelem(this)}async needsControlOf(n){if(this.props.channel===0)return[];const r=await n.channels.retrieve(this.props.channel),s=[r.key];return r.index!==0&&s.push(r.index),s}async set(n){const{client:r}=this.controller.internal;if(r==null)return;const s=await r.channels.retrieve(this.props.channel),o=await r.channels.retrieve(s.index),i=new T.jd.Frame([s.key,o.key],[new T.G({data:new s.dataType.Array([n])}),new T.G({data:new o.dataType.Array([BigInt(T.S$1.now())])})]);await this.controller.set(i)}}m(qr,"TYPE","controlled-numeric-telem-sink");const ag=t=>({type:qr.TYPE,props:t,variant:"sink",valueType:"number"}),cg=M.z.object({authority:M.z.number().default(T.Dd.Authority.Absolute.valueOf()),channel:M.z.number()});class Ur extends hs{constructor(n,r){super(r);m(this,"controller");m(this,"schema",cg);this.controller=n}async cleanup(){this.controller.deleteTelem(this)}async needsControlOf(n){const r=await n.channels.retrieve(this.props.channel),s=[r.key];return r.index!==0&&s.push(r.index),s}async set(n){const{controller:r}=this,{client:s}=r.internal;if(s==null)return;const o=await s.channels.retrieve(this.props.channel),i=[o.key];o.index!==0&&i.push(o.index),n?await this.controller.setAuthority(i,this.props.authority):await this.controller.releaseAuthority(i)}}m(Ur,"TYPE","acquire-channel-control");const lg=t=>({type:Ur.TYPE,props:t,variant:"sink",valueType:"boolean"}),ug=M.z.object({channel:M.z.number()});class Zr extends Et{constructor(n,r,s){super(s);m(this,"prov");m(this,"valid",!1);m(this,"stopListening");m(this,"controller");m(this,"schema",ug);this.prov=r,this.controller=n}async needsControlOf(){return[]}maybeRevalidate(){var s;if(this.valid)return;const{channel:n}=this.props;(s=this.stopListening)==null||s.call(this);const r=T.R.filterTransfersByChannelKey(n);this.stopListening=this.prov.onChange(o=>{var i;r(o).length!==0&&((i=this.notify)==null||i.call(this))}),this.valid=!0}async value(){this.maybeRevalidate();const n=T.S$1.now();if(this.props.channel===0)return{key:this.controller.key,variant:"disabled",message:"No Channel",time:n,data:{valid:!1,authority:0}};const r=this.prov.get(this.props.channel);return r==null?{key:this.controller.key,variant:"disabled",message:"Uncontrolled",time:n,data:{valid:!0,color:void 0,authority:0}}:{key:r.subject.key,variant:r.subject.key===this.controller.key?"success":"error",message:`Controlled by ${r.subject.name}`,time:n,data:{valid:!0,color:r.subjectColor,authority:r.authority}}}async cleanup(){var n;this.controller.deleteTelem(this),(n=this.stopListening)==null||n.call(this)}}m(Zr,"TYPE","controlled-status-source");const hg=t=>({type:Zr.TYPE,props:t,variant:"source",valueType:"status"}),sl=M.z.object({statusSource:To.optional().default(bo),colorSource:Ha.optional().default(Ba),status:T.specZ$1,color:f.Color.z.optional()});class Hr extends T.Leaf{constructor(){super(...arguments);m(this,"schema",sl);m(this,"stopListeningStatus");m(this,"stopListeningColor")}async afterUpdate(){var r,s;const{internal:n}=this;n.statusSource=await Qt(this.ctx,this.state.statusSource,n.statusSource),n.colorSource=await Qt(this.ctx,this.state.colorSource,n.colorSource),await this.updateState(),(r=this.stopListeningStatus)==null||r.call(this),this.stopListeningStatus=n.statusSource.onChange(()=>{this.updateState()}),(s=this.stopListeningColor)==null||s.call(this),this.stopListeningColor=n.colorSource.onChange(()=>{this.updateState()})}async afterDelete(){this.internalAfterDelete().catch(console.error)}async internalAfterDelete(){var n,r,s,o;await((r=(n=this.internal.statusSource).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.colorSource).cleanup)==null?void 0:o.call(s))}async render(){}async updateState(){const n=await this.internal.colorSource.value(),r=await this.internal.statusSource.value();n.equals(this.state.color)&&r.message===this.state.status.message||this.setState(s=>({...s,color:n,status:r}))}}m(Hr,"TYPE","Indicator");const ol=M.z.object({needsControlOf:T.kd.keyZ.array(),states:sg.array()});class Vr extends T.Leaf{constructor(){super(...arguments);m(this,"schema",ol)}async afterUpdate(){var i;const{internal:n}=this;n.stateProv=je.use(this.ctx);const r=this.state.needsControlOf;(i=n.disconnectStateProv)==null||i.call(n);const s=T.R.filterTransfersByChannelKey(...r),o=n.stateProv.get(r);this.setState(a=>({...a,states:o})),n.disconnectStateProv=n.stateProv.onChange(a=>{if(s(a).length===0)return;const c=n.stateProv.get(r);this.setState(l=>({...l,states:c}))})}async afterDelete(){var r;const{internal:n}=this;(r=n.disconnectStateProv)==null||r.call(n)}async render(){}}m(Vr,"TYPE","Legend");const fg={[Fr.TYPE]:Fr,[je.TYPE]:je,[Hr.TYPE]:Hr,[Br.TYPE]:Br,[Vr.TYPE]:Vr},il=M.z.object({trigger:M.z.number(),sink:ls.optional().default(as)});class Xr extends T.Leaf{constructor(){super(...arguments);m(this,"schema",il)}async afterUpdate(){const{sink:n}=this.state;this.internal.sink=await is(this.ctx,n,this.internal.sink),this.state.trigger>this.prevState.trigger&&this.internal.sink.set(!0).catch(console.error)}render(){}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var r,s;const{internal:n}=this;await((s=(r=n.sink).cleanup)==null?void 0:s.call(r))}}m(Xr,"TYPE","Button");const dg={[Xr.TYPE]:Xr},Zo=M.z.object({dpr:M.z.number(),region:f.To.box,bootstrap:M.z.boolean().optional().default(!1),bootstrapped:M.z.boolean().optional().default(!1),glCanvas:M.z.any().optional(),upper2dCanvas:M.z.any().optional(),lower2dCanvas:M.z.any().optional(),os:T.w$1.osZ});class Yn extends T.Composite{constructor(){super(...arguments);m(this,"schema",Zo);m(this,"renderContextSet",!1)}async afterUpdate(){let n=gt.useOptional(this.ctx);if(n==null){if(this.renderContextSet)throw new T.ze("[vis.worker.Canvas] - expected render context to be set");if(!this.state.bootstrap)return;const{glCanvas:r,lower2dCanvas:s,upper2dCanvas:o,os:i}=this.state;if(r==null||s==null||o==null)throw new T.ze("[vis.worker.Canvas] - expected render context bootstrap to include all canvases");n=gt.create(this.ctx,r,s,o,i),Lr.create(this.ctx),this.setState(a=>({...a,bootstrap:!1,bootstrapped:!0,glCanvas:void 0,lower2dCanvas:void 0,upper2dCanvas:void 0}))}else n.update(this.ctx);n.resize(this.state.region,this.state.dpr)}}m(Yn,"TYPE","Canvas");const al={[Yn.TYPE]:Yn},pg=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Yn,REGISTRY:al,canvasStateZ:Zo},Symbol.toStringTag,{value:"Module"}));function St(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=St(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var so={exports:{}},Os={},or={exports:{}},zs={};/**
37
- * @license React
38
- * use-sync-external-store-shim.production.min.js
39
- *
40
- * Copyright (c) Facebook, Inc. and its affiliates.
41
- *
42
- * This source code is licensed under the MIT license found in the
43
- * LICENSE file in the root directory of this source tree.
44
- */var ji;function gg(){if(ji)return zs;ji=1;var t=y;function e(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,o=t.useLayoutEffect,i=t.useDebugValue;function a(h,d){var p=d(),x=r({inst:{value:p,getSnapshot:d}}),w=x[0].inst,b=x[1];return o(function(){w.value=p,w.getSnapshot=d,c(w)&&b({inst:w})},[h,p,d]),s(function(){return c(w)&&b({inst:w}),h(function(){c(w)&&b({inst:w})})},[h]),i(p),p}function c(h){var d=h.getSnapshot;h=h.value;try{var p=d();return!n(h,p)}catch{return!0}}function l(h,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return zs.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,zs}var Is={};/**
45
- * @license React
46
- * use-sync-external-store-shim.development.js
47
- *
48
- * Copyright (c) Facebook, Inc. and its affiliates.
49
- *
50
- * This source code is licensed under the MIT license found in the
51
- * LICENSE file in the root directory of this source tree.
52
- */var Qi;function mg(){return Qi||(Qi=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=y,e=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(C){{for(var S=arguments.length,R=new Array(S>1?S-1:0),_=1;_<S;_++)R[_-1]=arguments[_];r("error",C,R)}}function r(C,S,R){{var _=e.ReactDebugCurrentFrame,N=_.getStackAddendum();N!==""&&(S+="%s",R=R.concat([N]));var I=R.map(function(O){return String(O)});I.unshift("Warning: "+S),Function.prototype.apply.call(console[C],console,I)}}function s(C,S){return C===S&&(C!==0||1/C===1/S)||C!==C&&S!==S}var o=typeof Object.is=="function"?Object.is:s,i=t.useState,a=t.useEffect,c=t.useLayoutEffect,l=t.useDebugValue,u=!1,h=!1;function d(C,S,R){u||t.startTransition!==void 0&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var _=S();if(!h){var N=S();o(_,N)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),h=!0)}var I=i({inst:{value:_,getSnapshot:S}}),O=I[0].inst,Z=I[1];return c(function(){O.value=_,O.getSnapshot=S,p(O)&&Z({inst:O})},[C,_,S]),a(function(){p(O)&&Z({inst:O});var D=function(){p(O)&&Z({inst:O})};return C(D)},[C]),l(_),_}function p(C){var S=C.getSnapshot,R=C.value;try{var _=S();return!o(R,_)}catch{return!0}}function x(C,S,R){return S()}var w=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",b=!w,v=b?x:d,k=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:v;Is.useSyncExternalStore=k,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Is}var Ji;function cl(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?or.exports=gg():or.exports=mg()),or.exports}/**
53
- * @license React
54
- * use-sync-external-store-shim/with-selector.production.min.js
55
- *
56
- * Copyright (c) Facebook, Inc. and its affiliates.
57
- *
58
- * This source code is licensed under the MIT license found in the
59
- * LICENSE file in the root directory of this source tree.
60
- */var ta;function yg(){if(ta)return Os;ta=1;var t=y,e=cl();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,a=t.useMemo,c=t.useDebugValue;return Os.useSyncExternalStoreWithSelector=function(l,u,h,d,p){var x=o(null);if(x.current===null){var w={hasValue:!1,value:null};x.current=w}else w=x.current;x=a(function(){function v(_){if(!k){if(k=!0,C=_,_=d(_),p!==void 0&&w.hasValue){var N=w.value;if(p(N,_))return S=N}return S=_}if(N=S,r(C,_))return N;var I=d(_);return p!==void 0&&p(N,I)?N:(C=_,S=I)}var k=!1,C,S,R=h===void 0?null:h;return[function(){return v(u())},R===null?void 0:function(){return v(R())}]},[u,h,d,p]);var b=s(l,x[0],x[1]);return i(function(){w.hasValue=!0,w.value=b},[b]),c(b),b},Os}var $s={};/**
61
- * @license React
62
- * use-sync-external-store-shim/with-selector.development.js
63
- *
64
- * Copyright (c) Facebook, Inc. and its affiliates.
65
- *
66
- * This source code is licensed under the MIT license found in the
67
- * LICENSE file in the root directory of this source tree.
68
- */var ea;function wg(){return ea||(ea=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=y,e=cl();function n(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,a=t.useMemo,c=t.useDebugValue;function l(u,h,d,p,x){var w=o(null),b;w.current===null?(b={hasValue:!1,value:null},w.current=b):b=w.current;var v=a(function(){var R=!1,_,N,I=function(q){if(!R){R=!0,_=q;var L=p(q);if(x!==void 0&&b.hasValue){var g=b.value;if(x(g,L))return N=g,g}return N=L,L}var A=_,P=N;if(r(A,q))return P;var z=p(q);return x!==void 0&&x(P,z)?P:(_=q,N=z,z)},O=d===void 0?null:d,Z=function(){return I(h())},D=O===null?void 0:function(){return I(O())};return[Z,D]},[h,d,p,x]),k=v[0],C=v[1],S=s(u,k,C);return i(function(){b.hasValue=!0,b.value=S},[S]),c(S),S}$s.useSyncExternalStoreWithSelector=l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),$s}process.env.NODE_ENV==="production"?so.exports=yg():so.exports=wg();var xg=so.exports;const vg=T.getDefaultExportFromCjs(xg);var Sg={BASE_URL:"/pluto/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const na=t=>{let e;const n=new Set,r=(u,h)=>{const d=typeof u=="function"?u(e):u;if(!Object.is(d,e)){const p=e;e=h??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(x=>x(e,p))}},s=()=>e,c={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Sg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=e=t(r,s,c);return c},bg=t=>t?na(t):na,{useDebugValue:Tg}=y,{useSyncExternalStoreWithSelector:Eg}=vg,_g=t=>t;function ll(t,e=_g,n){const r=Eg(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return Tg(r),r}const ra=(t,e)=>{const n=bg(t),r=(s,o=e)=>ll(n,s,o);return Object.assign(r,n),r},Cg=(t,e)=>t?ra(t,e):ra;function pt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,s]of t)if(!Object.is(s,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}var Pg={value:()=>{}};function ps(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new pr(n)}function pr(t){this._=t}function kg(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}pr.prototype=ps.prototype={constructor:pr,on:function(t,e){var n=this._,r=kg(t+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o<i;)if((s=(t=r[o]).type)&&(s=Mg(n[s],t.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<i;)if(s=(t=r[o]).type)n[s]=sa(n[s],t.name,e);else if(e==null)for(s in n)n[s]=sa(n[s],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new pr(t)},call:function(t,e){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,s=o.length;r<s;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],s=0,o=r.length;s<o;++s)r[s].value.apply(e,n)}};function Mg(t,e){for(var n=0,r=t.length,s;n<r;++n)if((s=t[n]).name===e)return s.value}function sa(t,e,n){for(var r=0,s=t.length;r<s;++r)if(t[r].name===e){t[r]=Pg,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var oo="http://www.w3.org/1999/xhtml";const oa={svg:"http://www.w3.org/2000/svg",xhtml:oo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gs(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),oa.hasOwnProperty(e)?{space:oa[e],local:t}:t}function Rg(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===oo&&e.documentElement.namespaceURI===oo?e.createElement(t):e.createElementNS(n,t)}}function Ag(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function ul(t){var e=gs(t);return(e.local?Ag:Rg)(e)}function Ng(){}function Ho(t){return t==null?Ng:function(){return this.querySelector(t)}}function Dg(t){typeof t!="function"&&(t=Ho(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=new Array(i),c,l,u=0;u<i;++u)(c=o[u])&&(l=t.call(c,c.__data__,u,o))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new xt(r,this._parents)}function Og(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function zg(){return[]}function hl(t){return t==null?zg:function(){return this.querySelectorAll(t)}}function Ig(t){return function(){return Og(t.apply(this,arguments))}}function $g(t){typeof t=="function"?t=Ig(t):t=hl(t);for(var e=this._groups,n=e.length,r=[],s=[],o=0;o<n;++o)for(var i=e[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&(r.push(t.call(c,c.__data__,l,i)),s.push(c));return new xt(r,s)}function fl(t){return function(){return this.matches(t)}}function dl(t){return function(e){return e.matches(t)}}var Lg=Array.prototype.find;function Yg(t){return function(){return Lg.call(this.children,t)}}function Bg(){return this.firstElementChild}function Fg(t){return this.select(t==null?Bg:Yg(typeof t=="function"?t:dl(t)))}var qg=Array.prototype.filter;function Ug(){return Array.from(this.children)}function Zg(t){return function(){return qg.call(this.children,t)}}function Hg(t){return this.selectAll(t==null?Ug:Zg(typeof t=="function"?t:dl(t)))}function Vg(t){typeof t!="function"&&(t=fl(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new xt(r,this._parents)}function pl(t){return new Array(t.length)}function Xg(){return new xt(this._enter||this._groups.map(pl),this._parents)}function Wr(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Wr.prototype={constructor:Wr,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Wg(t){return function(){return t}}function Gg(t,e,n,r,s,o){for(var i=0,a,c=e.length,l=o.length;i<l;++i)(a=e[i])?(a.__data__=o[i],r[i]=a):n[i]=new Wr(t,o[i]);for(;i<c;++i)(a=e[i])&&(s[i]=a)}function Kg(t,e,n,r,s,o,i){var a,c,l=new Map,u=e.length,h=o.length,d=new Array(u),p;for(a=0;a<u;++a)(c=e[a])&&(d[a]=p=i.call(c,c.__data__,a,e)+"",l.has(p)?s[a]=c:l.set(p,c));for(a=0;a<h;++a)p=i.call(t,o[a],a,o)+"",(c=l.get(p))?(r[a]=c,c.__data__=o[a],l.delete(p)):n[a]=new Wr(t,o[a]);for(a=0;a<u;++a)(c=e[a])&&l.get(d[a])===c&&(s[a]=c)}function jg(t){return t.__data__}function Qg(t,e){if(!arguments.length)return Array.from(this,jg);var n=e?Kg:Gg,r=this._parents,s=this._groups;typeof t!="function"&&(t=Wg(t));for(var o=s.length,i=new Array(o),a=new Array(o),c=new Array(o),l=0;l<o;++l){var u=r[l],h=s[l],d=h.length,p=Jg(t.call(u,u&&u.__data__,l,r)),x=p.length,w=a[l]=new Array(x),b=i[l]=new Array(x),v=c[l]=new Array(d);n(u,h,w,b,v,p,e);for(var k=0,C=0,S,R;k<x;++k)if(S=w[k]){for(k>=C&&(C=k+1);!(R=b[C])&&++C<x;);S._next=R||null}}return i=new xt(i,r),i._enter=a,i._exit=c,i}function Jg(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function tm(){return new xt(this._exit||this._groups.map(pl),this._parents)}function em(t,e,n){var r=this.enter(),s=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(s=e(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function nm(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,s=n.length,o=r.length,i=Math.min(s,o),a=new Array(s),c=0;c<i;++c)for(var l=n[c],u=r[c],h=l.length,d=a[c]=new Array(h),p,x=0;x<h;++x)(p=l[x]||u[x])&&(d[x]=p);for(;c<s;++c)a[c]=n[c];return new xt(a,this._parents)}function rm(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],s=r.length-1,o=r[s],i;--s>=0;)(i=r[s])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function sm(t){t||(t=om);function e(h,d){return h&&d?t(h.__data__,d.__data__):!h-!d}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var i=n[o],a=i.length,c=s[o]=new Array(a),l,u=0;u<a;++u)(l=i[u])&&(c[u]=l);c.sort(e)}return new xt(s,this._parents).order()}function om(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function im(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function am(){return Array.from(this)}function cm(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],s=0,o=r.length;s<o;++s){var i=r[s];if(i)return i}return null}function lm(){let t=0;for(const e of this)++t;return t}function um(){return!this.node()}function hm(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var s=e[n],o=0,i=s.length,a;o<i;++o)(a=s[o])&&t.call(a,a.__data__,o,s);return this}function fm(t){return function(){this.removeAttribute(t)}}function dm(t){return function(){this.removeAttributeNS(t.space,t.local)}}function pm(t,e){return function(){this.setAttribute(t,e)}}function gm(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function mm(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function ym(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function wm(t,e){var n=gs(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?dm:fm:typeof e=="function"?n.local?ym:mm:n.local?gm:pm)(n,e))}function gl(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function xm(t){return function(){this.style.removeProperty(t)}}function vm(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Sm(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function bm(t,e,n){return arguments.length>1?this.each((e==null?xm:typeof e=="function"?Sm:vm)(t,e,n??"")):Qe(this.node(),t)}function Qe(t,e){return t.style.getPropertyValue(e)||gl(t).getComputedStyle(t,null).getPropertyValue(e)}function Tm(t){return function(){delete this[t]}}function Em(t,e){return function(){this[t]=e}}function _m(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Cm(t,e){return arguments.length>1?this.each((e==null?Tm:typeof e=="function"?_m:Em)(t,e)):this.node()[t]}function ml(t){return t.trim().split(/^|\s+/)}function Vo(t){return t.classList||new yl(t)}function yl(t){this._node=t,this._names=ml(t.getAttribute("class")||"")}yl.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function wl(t,e){for(var n=Vo(t),r=-1,s=e.length;++r<s;)n.add(e[r])}function xl(t,e){for(var n=Vo(t),r=-1,s=e.length;++r<s;)n.remove(e[r])}function Pm(t){return function(){wl(this,t)}}function km(t){return function(){xl(this,t)}}function Mm(t,e){return function(){(e.apply(this,arguments)?wl:xl)(this,t)}}function Rm(t,e){var n=ml(t+"");if(arguments.length<2){for(var r=Vo(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof e=="function"?Mm:e?Pm:km)(n,e))}function Am(){this.textContent=""}function Nm(t){return function(){this.textContent=t}}function Dm(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Om(t){return arguments.length?this.each(t==null?Am:(typeof t=="function"?Dm:Nm)(t)):this.node().textContent}function zm(){this.innerHTML=""}function Im(t){return function(){this.innerHTML=t}}function $m(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Lm(t){return arguments.length?this.each(t==null?zm:(typeof t=="function"?$m:Im)(t)):this.node().innerHTML}function Ym(){this.nextSibling&&this.parentNode.appendChild(this)}function Bm(){return this.each(Ym)}function Fm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qm(){return this.each(Fm)}function Um(t){var e=typeof t=="function"?t:ul(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Zm(){return null}function Hm(t,e){var n=typeof t=="function"?t:ul(t),r=e==null?Zm:typeof e=="function"?e:Ho(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Vm(){var t=this.parentNode;t&&t.removeChild(this)}function Xm(){return this.each(Vm)}function Wm(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Gm(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Km(t){return this.select(t?Gm:Wm)}function jm(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Qm(t){return function(e){t.call(this,e,this.__data__)}}function Jm(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function ty(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,s=e.length,o;n<s;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++r]=o;++r?e.length=r:delete this.__on}}}function ey(t,e,n){return function(){var r=this.__on,s,o=Qm(e);if(r){for(var i=0,a=r.length;i<a;++i)if((s=r[i]).type===t.type&&s.name===t.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=e;return}}this.addEventListener(t.type,o,n),s={type:t.type,name:t.name,value:e,listener:o,options:n},r?r.push(s):this.__on=[s]}}function ny(t,e,n){var r=Jm(t+""),s,o=r.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(s=0,u=a[c];s<o;++s)if((i=r[s]).type===u.type&&i.name===u.name)return u.value}return}for(a=e?ey:ty,s=0;s<o;++s)this.each(a(r[s],e,n));return this}function vl(t,e,n){var r=gl(t),s=r.CustomEvent;typeof s=="function"?s=new s(e,n):(s=r.document.createEvent("Event"),n?(s.initEvent(e,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(e,!1,!1)),t.dispatchEvent(s)}function ry(t,e){return function(){return vl(this,t,e)}}function sy(t,e){return function(){return vl(this,t,e.apply(this,arguments))}}function oy(t,e){return this.each((typeof e=="function"?sy:ry)(t,e))}function*iy(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],s=0,o=r.length,i;s<o;++s)(i=r[s])&&(yield i)}var Sl=[null];function xt(t,e){this._groups=t,this._parents=e}function tr(){return new xt([[document.documentElement]],Sl)}function ay(){return this}xt.prototype=tr.prototype={constructor:xt,select:Dg,selectAll:$g,selectChild:Fg,selectChildren:Hg,filter:Vg,data:Qg,enter:Xg,exit:tm,join:em,merge:nm,selection:ay,order:rm,sort:sm,call:im,nodes:am,node:cm,size:lm,empty:um,each:hm,attr:wm,style:bm,property:Cm,classed:Rm,text:Om,html:Lm,raise:Bm,lower:qm,append:Um,insert:Hm,remove:Xm,clone:Km,datum:jm,on:ny,dispatch:oy,[Symbol.iterator]:iy};function kt(t){return typeof t=="string"?new xt([[document.querySelector(t)]],[document.documentElement]):new xt([[t]],Sl)}function cy(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Nt(t,e){if(t=cy(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}}return[t.pageX,t.pageY]}const ly={passive:!1},Bn={capture:!0,passive:!1};function Ls(t){t.stopImmediatePropagation()}function $e(t){t.preventDefault(),t.stopImmediatePropagation()}function bl(t){var e=t.document.documentElement,n=kt(t).on("dragstart.drag",$e,Bn);"onselectstart"in e?n.on("selectstart.drag",$e,Bn):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Tl(t,e){var n=t.document.documentElement,r=kt(t).on("dragstart.drag",null);e&&(r.on("click.drag",$e,Bn),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const ir=t=>()=>t;function io(t,{sourceEvent:e,subject:n,target:r,identifier:s,active:o,x:i,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}io.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function uy(t){return!t.ctrlKey&&!t.button}function hy(){return this.parentNode}function fy(t,e){return e??{x:t.x,y:t.y}}function dy(){return navigator.maxTouchPoints||"ontouchstart"in this}function py(){var t=uy,e=hy,n=fy,r=dy,s={},o=ps("start","drag","end"),i=0,a,c,l,u,h=0;function d(S){S.on("mousedown.drag",p).filter(r).on("touchstart.drag",b).on("touchmove.drag",v,ly).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(S,R){if(!(u||!t.call(this,S,R))){var _=C(this,e.call(this,S,R),S,R,"mouse");_&&(kt(S.view).on("mousemove.drag",x,Bn).on("mouseup.drag",w,Bn),bl(S.view),Ls(S),l=!1,a=S.clientX,c=S.clientY,_("start",S))}}function x(S){if($e(S),!l){var R=S.clientX-a,_=S.clientY-c;l=R*R+_*_>h}s.mouse("drag",S)}function w(S){kt(S.view).on("mousemove.drag mouseup.drag",null),Tl(S.view,l),$e(S),s.mouse("end",S)}function b(S,R){if(t.call(this,S,R)){var _=S.changedTouches,N=e.call(this,S,R),I=_.length,O,Z;for(O=0;O<I;++O)(Z=C(this,N,S,R,_[O].identifier,_[O]))&&(Ls(S),Z("start",S,_[O]))}}function v(S){var R=S.changedTouches,_=R.length,N,I;for(N=0;N<_;++N)(I=s[R[N].identifier])&&($e(S),I("drag",S,R[N]))}function k(S){var R=S.changedTouches,_=R.length,N,I;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),N=0;N<_;++N)(I=s[R[N].identifier])&&(Ls(S),I("end",S,R[N]))}function C(S,R,_,N,I,O){var Z=o.copy(),D=Nt(O||_,R),q,L,g;if((g=n.call(S,new io("beforestart",{sourceEvent:_,target:d,identifier:I,active:i,x:D[0],y:D[1],dx:0,dy:0,dispatch:Z}),N))!=null)return q=g.x-D[0]||0,L=g.y-D[1]||0,function A(P,z,F){var E=D,Y;switch(P){case"start":s[I]=A,Y=i++;break;case"end":delete s[I],--i;case"drag":D=Nt(F||z,R),Y=i;break}Z.call(P,S,new io(P,{sourceEvent:z,subject:g,target:d,identifier:I,active:Y,x:D[0]+q,y:D[1]+L,dx:D[0]-E[0],dy:D[1]-E[1],dispatch:Z}),N)}}return d.filter=function(S){return arguments.length?(t=typeof S=="function"?S:ir(!!S),d):t},d.container=function(S){return arguments.length?(e=typeof S=="function"?S:ir(S),d):e},d.subject=function(S){return arguments.length?(n=typeof S=="function"?S:ir(S),d):n},d.touchable=function(S){return arguments.length?(r=typeof S=="function"?S:ir(!!S),d):r},d.on=function(){var S=o.on.apply(o,arguments);return S===o?d:S},d.clickDistance=function(S){return arguments.length?(h=(S=+S)*S,d):Math.sqrt(h)},d}var Je=0,xn=0,pn=0,El=1e3,Gr,vn,Kr=0,me=0,ms=0,Fn=typeof performance=="object"&&performance.now?performance:Date,_l=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Xo(){return me||(_l(gy),me=Fn.now()+ms)}function gy(){me=0}function jr(){this._call=this._time=this._next=null}jr.prototype=Cl.prototype={constructor:jr,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Xo():+n)+(e==null?0:+e),!this._next&&vn!==this&&(vn?vn._next=this:Gr=this,vn=this),this._call=t,this._time=n,ao()},stop:function(){this._call&&(this._call=null,this._time=1/0,ao())}};function Cl(t,e,n){var r=new jr;return r.restart(t,e,n),r}function my(){Xo(),++Je;for(var t=Gr,e;t;)(e=me-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Je}function ia(){me=(Kr=Fn.now())+ms,Je=xn=0;try{my()}finally{Je=0,wy(),me=0}}function yy(){var t=Fn.now(),e=t-Kr;e>El&&(ms-=e,Kr=t)}function wy(){for(var t,e=Gr,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Gr=n);vn=t,ao(r)}function ao(t){if(!Je){xn&&(xn=clearTimeout(xn));var e=t-me;e>24?(t<1/0&&(xn=setTimeout(ia,t-Fn.now()-ms)),pn&&(pn=clearInterval(pn))):(pn||(Kr=Fn.now(),pn=setInterval(yy,El)),Je=1,_l(ia))}}function aa(t,e,n){var r=new jr;return e=e==null?0:+e,r.restart(s=>{r.stop(),t(s+e)},e,n),r}var xy=ps("start","end","cancel","interrupt"),vy=[],Pl=0,ca=1,co=2,gr=3,la=4,lo=5,mr=6;function ys(t,e,n,r,s,o){var i=t.__transition;if(!i)t.__transition={};else if(n in i)return;Sy(t,n,{name:e,index:r,group:s,on:xy,tween:vy,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Pl})}function Wo(t,e){var n=Mt(t,e);if(n.state>Pl)throw new Error("too late; already scheduled");return n}function It(t,e){var n=Mt(t,e);if(n.state>gr)throw new Error("too late; already running");return n}function Mt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Sy(t,e,n){var r=t.__transition,s;r[e]=n,n.timer=Cl(o,0,n.time);function o(l){n.state=ca,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var u,h,d,p;if(n.state!==ca)return c();for(u in r)if(p=r[u],p.name===n.name){if(p.state===gr)return aa(i);p.state===la?(p.state=mr,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=mr,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(aa(function(){n.state===gr&&(n.state=la,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=co,n.on.call("start",t,t.__data__,n.index,n.group),n.state===co){for(n.state=gr,s=new Array(d=n.tween.length),u=0,h=-1;u<d;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(s[++h]=p);s.length=h+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=lo,1),h=-1,d=s.length;++h<d;)s[h].call(t,u);n.state===lo&&(n.on.call("end",t,t.__data__,n.index,n.group),c())}function c(){n.state=mr,n.timer.stop(),delete r[e];for(var l in r)return;delete t.__transition}}function yr(t,e){var n=t.__transition,r,s,o=!0,i;if(n){e=e==null?null:e+"";for(i in n){if((r=n[i]).name!==e){o=!1;continue}s=r.state>co&&r.state<lo,r.state=mr,r.timer.stop(),r.on.call(s?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[i]}o&&delete t.__transition}}function by(t){return this.each(function(){yr(this,t)})}function Ty(t,e){var n,r;return function(){var s=It(this,t),o=s.tween;if(o!==n){r=n=o;for(var i=0,a=r.length;i<a;++i)if(r[i].name===e){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function Ey(t,e,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=It(this,t),i=o.tween;if(i!==r){s=(r=i).slice();for(var a={name:e,value:n},c=0,l=s.length;c<l;++c)if(s[c].name===e){s[c]=a;break}c===l&&s.push(a)}o.tween=s}}function _y(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=Mt(this.node(),n).tween,s=0,o=r.length,i;s<o;++s)if((i=r[s]).name===t)return i.value;return null}return this.each((e==null?Ty:Ey)(n,t,e))}function Go(t,e,n){var r=t._id;return t.each(function(){var s=It(this,r);(s.value||(s.value={}))[e]=n.apply(this,arguments)}),function(s){return Mt(s,r).value[e]}}function kl(t,e){var n;return(typeof e=="number"?Ct:e instanceof pe?Ar:(n=pe(e))?(e=n,Ar):Cc)(t,e)}function Cy(t){return function(){this.removeAttribute(t)}}function Py(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ky(t,e,n){var r,s=n+"",o;return function(){var i=this.getAttribute(t);return i===s?null:i===r?o:o=e(r=i,n)}}function My(t,e,n){var r,s=n+"",o;return function(){var i=this.getAttributeNS(t.space,t.local);return i===s?null:i===r?o:o=e(r=i,n)}}function Ry(t,e,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttribute(t):(i=this.getAttribute(t),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a)))}}function Ay(t,e,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttributeNS(t.space,t.local):(i=this.getAttributeNS(t.space,t.local),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a)))}}function Ny(t,e){var n=gs(t),r=n==="transform"?If:kl;return this.attrTween(t,typeof e=="function"?(n.local?Ay:Ry)(n,r,Go(this,"attr."+t,e)):e==null?(n.local?Py:Cy)(n):(n.local?My:ky)(n,r,e))}function Dy(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Oy(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function zy(t,e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&Oy(t,o)),n}return s._value=e,s}function Iy(t,e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&Dy(t,o)),n}return s._value=e,s}function $y(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=gs(t);return this.tween(n,(r.local?zy:Iy)(r,e))}function Ly(t,e){return function(){Wo(this,t).delay=+e.apply(this,arguments)}}function Yy(t,e){return e=+e,function(){Wo(this,t).delay=e}}function By(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Ly:Yy)(e,t)):Mt(this.node(),e).delay}function Fy(t,e){return function(){It(this,t).duration=+e.apply(this,arguments)}}function qy(t,e){return e=+e,function(){It(this,t).duration=e}}function Uy(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Fy:qy)(e,t)):Mt(this.node(),e).duration}function Zy(t,e){if(typeof e!="function")throw new Error;return function(){It(this,t).ease=e}}function Hy(t){var e=this._id;return arguments.length?this.each(Zy(e,t)):Mt(this.node(),e).ease}function Vy(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;It(this,t).ease=n}}function Xy(t){if(typeof t!="function")throw new Error;return this.each(Vy(this._id,t))}function Wy(t){typeof t!="function"&&(t=fl(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new Vt(r,this._parents,this._name,this._id)}function Gy(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,s=n.length,o=Math.min(r,s),i=new Array(r),a=0;a<o;++a)for(var c=e[a],l=n[a],u=c.length,h=i[a]=new Array(u),d,p=0;p<u;++p)(d=c[p]||l[p])&&(h[p]=d);for(;a<r;++a)i[a]=e[a];return new Vt(i,this._parents,this._name,this._id)}function Ky(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function jy(t,e,n){var r,s,o=Ky(e)?Wo:It;return function(){var i=o(this,t),a=i.on;a!==r&&(s=(r=a).copy()).on(e,n),i.on=s}}function Qy(t,e){var n=this._id;return arguments.length<2?Mt(this.node(),n).on.on(t):this.each(jy(n,t,e))}function Jy(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function t0(){return this.on("end.remove",Jy(this._id))}function e0(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Ho(t));for(var r=this._groups,s=r.length,o=new Array(s),i=0;i<s;++i)for(var a=r[i],c=a.length,l=o[i]=new Array(c),u,h,d=0;d<c;++d)(u=a[d])&&(h=t.call(u,u.__data__,d,a))&&("__data__"in u&&(h.__data__=u.__data__),l[d]=h,ys(l[d],e,n,d,l,Mt(u,n)));return new Vt(o,this._parents,e,n)}function n0(t){var e=this._name,n=this._id;typeof t!="function"&&(t=hl(t));for(var r=this._groups,s=r.length,o=[],i=[],a=0;a<s;++a)for(var c=r[a],l=c.length,u,h=0;h<l;++h)if(u=c[h]){for(var d=t.call(u,u.__data__,h,c),p,x=Mt(u,n),w=0,b=d.length;w<b;++w)(p=d[w])&&ys(p,e,n,w,d,x);o.push(d),i.push(u)}return new Vt(o,i,e,n)}var r0=tr.prototype.constructor;function s0(){return new r0(this._groups,this._parents)}function o0(t,e){var n,r,s;return function(){var o=Qe(this,t),i=(this.style.removeProperty(t),Qe(this,t));return o===i?null:o===n&&i===r?s:s=e(n=o,r=i)}}function Ml(t){return function(){this.style.removeProperty(t)}}function i0(t,e,n){var r,s=n+"",o;return function(){var i=Qe(this,t);return i===s?null:i===r?o:o=e(r=i,n)}}function a0(t,e,n){var r,s,o;return function(){var i=Qe(this,t),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(t),Qe(this,t))),i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a))}}function c0(t,e){var n,r,s,o="style."+e,i="end."+o,a;return function(){var c=It(this,t),l=c.on,u=c.value[o]==null?a||(a=Ml(e)):void 0;(l!==n||s!==u)&&(r=(n=l).copy()).on(i,s=u),c.on=r}}function l0(t,e,n){var r=(t+="")=="transform"?zf:kl;return e==null?this.styleTween(t,o0(t,r)).on("end.style."+t,Ml(t)):typeof e=="function"?this.styleTween(t,a0(t,r,Go(this,"style."+t,e))).each(c0(this._id,t)):this.styleTween(t,i0(t,r,e),n).on("end.style."+t,null)}function u0(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function h0(t,e,n){var r,s;function o(){var i=e.apply(this,arguments);return i!==s&&(r=(s=i)&&u0(t,i,n)),r}return o._value=e,o}function f0(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,h0(t,e,n??""))}function d0(t){return function(){this.textContent=t}}function p0(t){return function(){var e=t(this);this.textContent=e??""}}function g0(t){return this.tween("text",typeof t=="function"?p0(Go(this,"text",t)):d0(t==null?"":t+""))}function m0(t){return function(e){this.textContent=t.call(this,e)}}function y0(t){var e,n;function r(){var s=t.apply(this,arguments);return s!==n&&(e=(n=s)&&m0(s)),e}return r._value=t,r}function w0(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,y0(t))}function x0(){for(var t=this._name,e=this._id,n=Rl(),r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)if(c=i[l]){var u=Mt(c,e);ys(c,t,n,l,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Vt(r,this._parents,t,n)}function v0(){var t,e,n=this,r=n._id,s=n.size();return new Promise(function(o,i){var a={value:i},c={value:function(){--s===0&&o()}};n.each(function(){var l=It(this,r),u=l.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(c)),l.on=e}),s===0&&o()})}var S0=0;function Vt(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Rl(){return++S0}var Yt=tr.prototype;Vt.prototype={constructor:Vt,select:e0,selectAll:n0,selectChild:Yt.selectChild,selectChildren:Yt.selectChildren,filter:Wy,merge:Gy,selection:s0,transition:x0,call:Yt.call,nodes:Yt.nodes,node:Yt.node,size:Yt.size,empty:Yt.empty,each:Yt.each,on:Qy,attr:Ny,attrTween:$y,style:l0,styleTween:f0,text:g0,textTween:w0,remove:t0,tween:_y,delay:By,duration:Uy,ease:Hy,easeVarying:Xy,end:v0,[Symbol.iterator]:Yt[Symbol.iterator]};function b0(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var T0={time:null,delay:0,duration:250,ease:b0};function E0(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function _0(t){var e,n;t instanceof Vt?(e=t._id,t=t._name):(e=Rl(),(n=T0).time=Xo(),t=t==null?null:t+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&ys(c,t,e,l,i,n||E0(c,e));return new Vt(r,this._parents,t,e)}tr.prototype.interrupt=by;tr.prototype.transition=_0;const ar=t=>()=>t;function C0(t,{sourceEvent:e,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function qt(t,e,n){this.k=t,this.x=e,this.y=n}qt.prototype={constructor:qt,scale:function(t){return t===1?this:new qt(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new qt(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kt=new qt(1,0,0);qt.prototype;function Ys(t){t.stopImmediatePropagation()}function gn(t){t.preventDefault(),t.stopImmediatePropagation()}function P0(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function k0(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function ua(){return this.__zoom||Kt}function M0(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function R0(){return navigator.maxTouchPoints||"ontouchstart"in this}function A0(t,e,n){var r=t.invertX(e[0][0])-n[0][0],s=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],i=t.invertY(e[1][1])-n[1][1];return t.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function N0(){var t=P0,e=k0,n=A0,r=M0,s=R0,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Bf,l=ps("start","zoom","end"),u,h,d,p=500,x=150,w=0,b=10;function v(g){g.property("__zoom",ua).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",Z).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(g,A,P,z){var F=g.selection?g.selection():g;F.property("__zoom",ua),g!==F?R(g,A,P,z):F.interrupt().each(function(){_(this,arguments).event(z).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},v.scaleBy=function(g,A,P,z){v.scaleTo(g,function(){var F=this.__zoom.k,E=typeof A=="function"?A.apply(this,arguments):A;return F*E},P,z)},v.scaleTo=function(g,A,P,z){v.transform(g,function(){var F=e.apply(this,arguments),E=this.__zoom,Y=P==null?S(F):typeof P=="function"?P.apply(this,arguments):P,$=E.invert(Y),H=typeof A=="function"?A.apply(this,arguments):A;return n(C(k(E,H),Y,$),F,i)},P,z)},v.translateBy=function(g,A,P,z){v.transform(g,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof P=="function"?P.apply(this,arguments):P),e.apply(this,arguments),i)},null,z)},v.translateTo=function(g,A,P,z,F){v.transform(g,function(){var E=e.apply(this,arguments),Y=this.__zoom,$=z==null?S(E):typeof z=="function"?z.apply(this,arguments):z;return n(Kt.translate($[0],$[1]).scale(Y.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof P=="function"?-P.apply(this,arguments):-P),E,i)},z,F)};function k(g,A){return A=Math.max(o[0],Math.min(o[1],A)),A===g.k?g:new qt(A,g.x,g.y)}function C(g,A,P){var z=A[0]-P[0]*g.k,F=A[1]-P[1]*g.k;return z===g.x&&F===g.y?g:new qt(g.k,z,F)}function S(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function R(g,A,P,z){g.on("start.zoom",function(){_(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(z).end()}).tween("zoom",function(){var F=this,E=arguments,Y=_(F,E).event(z),$=e.apply(F,E),H=P==null?S($):typeof P=="function"?P.apply(F,E):P,X=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),W=F.__zoom,j=typeof A=="function"?A.apply(F,E):A,tt=c(W.invert(H).concat(X/W.k),j.invert(H).concat(X/j.k));return function(et){if(et===1)et=j;else{var ot=tt(et),U=X/ot[2];et=new qt(U,H[0]-ot[0]*U,H[1]-ot[1]*U)}Y.zoom(null,et)}})}function _(g,A,P){return!P&&g.__zooming||new N(g,A)}function N(g,A){this.that=g,this.args=A,this.active=0,this.sourceEvent=null,this.extent=e.apply(g,A),this.taps=0}N.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,A){return this.mouse&&g!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var A=kt(this.that).datum();l.call(g,this.that,new C0(g,{sourceEvent:this.sourceEvent,target:v,type:g,transform:this.that.__zoom,dispatch:l}),A)}};function I(g,...A){if(!t.apply(this,arguments))return;var P=_(this,A).event(g),z=this.__zoom,F=Math.max(o[0],Math.min(o[1],z.k*Math.pow(2,r.apply(this,arguments)))),E=Nt(g);if(P.wheel)(P.mouse[0][0]!==E[0]||P.mouse[0][1]!==E[1])&&(P.mouse[1]=z.invert(P.mouse[0]=E)),clearTimeout(P.wheel);else{if(z.k===F)return;P.mouse=[E,z.invert(E)],yr(this),P.start()}gn(g),P.wheel=setTimeout(Y,x),P.zoom("mouse",n(C(k(z,F),P.mouse[0],P.mouse[1]),P.extent,i));function Y(){P.wheel=null,P.end()}}function O(g,...A){if(d||!t.apply(this,arguments))return;var P=g.currentTarget,z=_(this,A,!0).event(g),F=kt(g.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",X,!0),E=Nt(g,P),Y=g.clientX,$=g.clientY;bl(g.view),Ys(g),z.mouse=[E,this.__zoom.invert(E)],yr(this),z.start();function H(W){if(gn(W),!z.moved){var j=W.clientX-Y,tt=W.clientY-$;z.moved=j*j+tt*tt>w}z.event(W).zoom("mouse",n(C(z.that.__zoom,z.mouse[0]=Nt(W,P),z.mouse[1]),z.extent,i))}function X(W){F.on("mousemove.zoom mouseup.zoom",null),Tl(W.view,z.moved),gn(W),z.event(W).end()}}function Z(g,...A){if(t.apply(this,arguments)){var P=this.__zoom,z=Nt(g.changedTouches?g.changedTouches[0]:g,this),F=P.invert(z),E=P.k*(g.shiftKey?.5:2),Y=n(C(k(P,E),z,F),e.apply(this,A),i);gn(g),a>0?kt(this).transition().duration(a).call(R,Y,z,g):kt(this).call(v.transform,Y,z,g)}}function D(g,...A){if(t.apply(this,arguments)){var P=g.touches,z=P.length,F=_(this,A,g.changedTouches.length===z).event(g),E,Y,$,H;for(Ys(g),Y=0;Y<z;++Y)$=P[Y],H=Nt($,this),H=[H,this.__zoom.invert(H),$.identifier],F.touch0?!F.touch1&&F.touch0[2]!==H[2]&&(F.touch1=H,F.taps=0):(F.touch0=H,E=!0,F.taps=1+!!u);u&&(u=clearTimeout(u)),E&&(F.taps<2&&(h=H[0],u=setTimeout(function(){u=null},p)),yr(this),F.start())}}function q(g,...A){if(this.__zooming){var P=_(this,A).event(g),z=g.changedTouches,F=z.length,E,Y,$,H;for(gn(g),E=0;E<F;++E)Y=z[E],$=Nt(Y,this),P.touch0&&P.touch0[2]===Y.identifier?P.touch0[0]=$:P.touch1&&P.touch1[2]===Y.identifier&&(P.touch1[0]=$);if(Y=P.that.__zoom,P.touch1){var X=P.touch0[0],W=P.touch0[1],j=P.touch1[0],tt=P.touch1[1],et=(et=j[0]-X[0])*et+(et=j[1]-X[1])*et,ot=(ot=tt[0]-W[0])*ot+(ot=tt[1]-W[1])*ot;Y=k(Y,Math.sqrt(et/ot)),$=[(X[0]+j[0])/2,(X[1]+j[1])/2],H=[(W[0]+tt[0])/2,(W[1]+tt[1])/2]}else if(P.touch0)$=P.touch0[0],H=P.touch0[1];else return;P.zoom("touch",n(C(Y,$,H),P.extent,i))}}function L(g,...A){if(this.__zooming){var P=_(this,A).event(g),z=g.changedTouches,F=z.length,E,Y;for(Ys(g),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),E=0;E<F;++E)Y=z[E],P.touch0&&P.touch0[2]===Y.identifier?delete P.touch0:P.touch1&&P.touch1[2]===Y.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(Y=Nt(Y,this),Math.hypot(h[0]-Y[0],h[1]-Y[1])<b)){var $=kt(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return v.wheelDelta=function(g){return arguments.length?(r=typeof g=="function"?g:ar(+g),v):r},v.filter=function(g){return arguments.length?(t=typeof g=="function"?g:ar(!!g),v):t},v.touchable=function(g){return arguments.length?(s=typeof g=="function"?g:ar(!!g),v):s},v.extent=function(g){return arguments.length?(e=typeof g=="function"?g:ar([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),v):e},v.scaleExtent=function(g){return arguments.length?(o[0]=+g[0],o[1]=+g[1],v):[o[0],o[1]]},v.translateExtent=function(g){return arguments.length?(i[0][0]=+g[0][0],i[1][0]=+g[1][0],i[0][1]=+g[0][1],i[1][1]=+g[1][1],v):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},v.constrain=function(g){return arguments.length?(n=g,v):n},v.duration=function(g){return arguments.length?(a=+g,v):a},v.interpolate=function(g){return arguments.length?(c=g,v):c},v.on=function(){var g=l.on.apply(l,arguments);return g===l?v:g},v.clickDistance=function(g){return arguments.length?(w=(g=+g)*g,v):Math.sqrt(w)},v.tapDistance=function(g){return arguments.length?(b=+g,v):b},v}const ws=y.createContext(null),D0=ws.Provider,vt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Al=vt.error001();function lt(t,e){const n=y.useContext(ws);if(n===null)throw new Error(Al);return ll(n,t,e)}const ht=()=>{const t=y.useContext(ws);if(t===null)throw new Error(Al);return y.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},O0=t=>t.userSelectionActive?"none":"all";function z0({position:t,children:e,className:n,style:r,...s}){const o=lt(O0),i=`${t}`.split("-");return y.createElement("div",{className:St(["react-flow__panel",n,...i]),style:{...r,pointerEvents:o},...s},e)}function I0({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:y.createElement(z0,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},y.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const $0=({x:t,y:e,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u})=>{const h=y.useRef(null),[d,p]=y.useState({x:0,y:0,width:0,height:0}),x=St(["react-flow__edge-textwrapper",l]);return y.useEffect(()=>{if(h.current){const w=h.current.getBBox();p({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),typeof n>"u"||!n?null:y.createElement("g",{transform:`translate(${t-d.width/2} ${e-d.height/2})`,className:x,visibility:d.width?"visible":"hidden",...u},s&&y.createElement("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),y.createElement("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:h,style:r},n),c)};var L0=y.memo($0);const Ko=t=>({width:t.offsetWidth,height:t.offsetHeight}),tn=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),jo=(t={x:0,y:0},e)=>({x:tn(t.x,e[0][0],e[1][0]),y:tn(t.y,e[0][1],e[1][1])}),ha=(t,e,n)=>t<e?tn(Math.abs(t-e),1,50)/50:t>n?-tn(Math.abs(t-n),1,50)/50:0,Nl=(t,e)=>{const n=ha(t.x,35,e.width-35)*20,r=ha(t.y,35,e.height-35)*20;return[n,r]},Dl=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},Y0=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),Qo=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),B0=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),fa=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),uo=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},F0=t=>Tt(t.width)&&Tt(t.height)&&Tt(t.x)&&Tt(t.y),Tt=t=>!isNaN(t)&&isFinite(t),ct=Symbol.for("internals"),Ol=["Enter"," ","Escape"],Qr=(t,e)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${e} Help: https://reactflow.dev/error#${t}`)},q0=t=>"nativeEvent"in t;function ho(t){var s,o;const e=q0(t)?t.nativeEvent:t,n=((o=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:o[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const zl=t=>"clientX"in t,jt=(t,e)=>{var o,i;const n=zl(t),r=n?t.clientX:(o=t.touches)==null?void 0:o[0].clientX,s=n?t.clientY:(i=t.touches)==null?void 0:i[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:s-((e==null?void 0:e.top)??0)}},Jr=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},on=({id:t,path:e,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p=20})=>y.createElement(y.Fragment,null,y.createElement("path",{id:t,style:u,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:d}),p&&y.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}),s&&Tt(n)&&Tt(r)?y.createElement(L0,{x:n,y:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null);on.displayName="BaseEdge";function mn(t,e,n){return n===void 0?n:r=>{const s=e().edges.find(o=>o.id===t);s&&n(r,{...s})}}function Il({sourceX:t,sourceY:e,targetX:n,targetY:r}){const s=Math.abs(n-t)/2,o=n<t?n+s:n-s,i=Math.abs(r-e)/2,a=r<e?r+i:r-i;return[o,a,s,i]}function $l({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:i,targetControlY:a}){const c=t*.125+s*.375+i*.375+n*.125,l=e*.125+o*.375+a*.375+r*.125,u=Math.abs(c-t),h=Math.abs(l-e);return[c,l,u,h]}exports.ConnectionMode=void 0;(function(t){t.Strict="strict",t.Loose="loose"})(exports.ConnectionMode||(exports.ConnectionMode={}));var he;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(he||(he={}));exports.SelectionMode=void 0;(function(t){t.Partial="partial",t.Full="full"})(exports.SelectionMode||(exports.SelectionMode={}));var Gt;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Gt||(Gt={}));var ts;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(ts||(ts={}));exports.Position=void 0;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(exports.Position||(exports.Position={}));function da({pos:t,x1:e,y1:n,x2:r,y2:s}){return t===exports.Position.Left||t===exports.Position.Right?[.5*(e+r),n]:[e,.5*(n+s)]}function Ll({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top}){const[i,a]=da({pos:n,x1:t,y1:e,x2:r,y2:s}),[c,l]=da({pos:o,x1:r,y1:s,x2:t,y2:e}),[u,h,d,p]=$l({sourceX:t,sourceY:e,targetX:r,targetY:s,sourceControlX:i,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${t},${e} C${i},${a} ${c},${l} ${r},${s}`,u,h,d,p]}const Jo=y.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:s=exports.Position.Bottom,targetPosition:o=exports.Position.Top,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:x,interactionWidth:w})=>{const[b,v,k]=Ll({sourceX:t,sourceY:e,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return y.createElement(on,{path:b,labelX:v,labelY:k,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:x,interactionWidth:w})});Jo.displayName="SimpleBezierEdge";const pa={[exports.Position.Left]:{x:-1,y:0},[exports.Position.Right]:{x:1,y:0},[exports.Position.Top]:{x:0,y:-1},[exports.Position.Bottom]:{x:0,y:1}},U0=({source:t,sourcePosition:e=exports.Position.Bottom,target:n})=>e===exports.Position.Left||e===exports.Position.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},ga=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function Z0({source:t,sourcePosition:e=exports.Position.Bottom,target:n,targetPosition:r=exports.Position.Top,center:s,offset:o}){const i=pa[e],a=pa[r],c={x:t.x+i.x*o,y:t.y+i.y*o},l={x:n.x+a.x*o,y:n.y+a.y*o},u=U0({source:c,sourcePosition:e,target:l}),h=u.x!==0?"x":"y",d=u[h];let p=[],x,w;const b={x:0,y:0},v={x:0,y:0},[k,C,S,R]=Il({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(i[h]*a[h]===-1){x=s.x??k,w=s.y??C;const N=[{x,y:c.y},{x,y:l.y}],I=[{x:c.x,y:w},{x:l.x,y:w}];i[h]===d?p=h==="x"?N:I:p=h==="x"?I:N}else{const N=[{x:c.x,y:l.y}],I=[{x:l.x,y:c.y}];if(h==="x"?p=i.x===d?I:N:p=i.y===d?N:I,e===r){const L=Math.abs(t[h]-n[h]);if(L<=o){const g=Math.min(o-1,o-L);i[h]===d?b[h]=(c[h]>t[h]?-1:1)*g:v[h]=(l[h]>n[h]?-1:1)*g}}if(e!==r){const L=h==="x"?"y":"x",g=i[h]===a[L],A=c[L]>l[L],P=c[L]<l[L];(i[h]===1&&(!g&&A||g&&P)||i[h]!==1&&(!g&&P||g&&A))&&(p=h==="x"?N:I)}const O={x:c.x+b.x,y:c.y+b.y},Z={x:l.x+v.x,y:l.y+v.y},D=Math.max(Math.abs(O.x-p[0].x),Math.abs(Z.x-p[0].x)),q=Math.max(Math.abs(O.y-p[0].y),Math.abs(Z.y-p[0].y));D>=q?(x=(O.x+Z.x)/2,w=p[0].y):(x=p[0].x,w=(O.y+Z.y)/2)}return[[t,{x:c.x+b.x,y:c.y+b.y},...p,{x:l.x+v.x,y:l.y+v.y},n],x,w,S,R]}function H0(t,e,n,r){const s=Math.min(ga(t,e)/2,ga(e,n)/2,r),{x:o,y:i}=e;if(t.x===o&&o===n.x||t.y===i&&i===n.y)return`L${o} ${i}`;if(t.y===i){const l=t.x<n.x?-1:1,u=t.y<n.y?1:-1;return`L ${o+s*l},${i}Q ${o},${i} ${o},${i+s*u}`}const a=t.x<n.x?1:-1,c=t.y<n.y?-1:1;return`L ${o},${i+s*c}Q ${o},${i} ${o+s*a},${i}`}function fo({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top,borderRadius:i=5,centerX:a,centerY:c,offset:l=20}){const[u,h,d,p,x]=Z0({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:a,y:c},offset:l});return[u.reduce((b,v,k)=>{let C="";return k>0&&k<u.length-1?C=H0(u[k-1],v,u[k+1],i):C=`${k===0?"M":"L"}${v.x} ${v.y}`,b+=C,b},""),h,d,p,x]}const xs=y.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:h=exports.Position.Bottom,targetPosition:d=exports.Position.Top,markerEnd:p,markerStart:x,pathOptions:w,interactionWidth:b})=>{const[v,k,C]=fo({sourceX:t,sourceY:e,sourcePosition:h,targetX:n,targetY:r,targetPosition:d,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset});return y.createElement(on,{path:v,labelX:k,labelY:C,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:p,markerStart:x,interactionWidth:b})});xs.displayName="SmoothStepEdge";const ti=y.memo(t=>{var e;return y.createElement(xs,{...t,pathOptions:y.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});ti.displayName="StepEdge";function V0({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[s,o,i,a]=Il({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,s,o,i,a]}const ei=y.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p})=>{const[x,w,b]=V0({sourceX:t,sourceY:e,targetX:n,targetY:r});return y.createElement(on,{path:x,labelX:w,labelY:b,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p})});ei.displayName="StraightEdge";function cr(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function ma({pos:t,x1:e,y1:n,x2:r,y2:s,c:o}){switch(t){case exports.Position.Left:return[e-cr(e-r,o),n];case exports.Position.Right:return[e+cr(r-e,o),n];case exports.Position.Top:return[e,n-cr(n-s,o)];case exports.Position.Bottom:return[e,n+cr(s-n,o)]}}function Yl({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top,curvature:i=.25}){const[a,c]=ma({pos:n,x1:t,y1:e,x2:r,y2:s,c:i}),[l,u]=ma({pos:o,x1:r,y1:s,x2:t,y2:e,c:i}),[h,d,p,x]=$l({sourceX:t,sourceY:e,targetX:r,targetY:s,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${t},${e} C${a},${c} ${l},${u} ${r},${s}`,h,d,p,x]}const es=y.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:s=exports.Position.Bottom,targetPosition:o=exports.Position.Top,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:x,pathOptions:w,interactionWidth:b})=>{const[v,k,C]=Yl({sourceX:t,sourceY:e,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:w==null?void 0:w.curvature});return y.createElement(on,{path:v,labelX:k,labelY:C,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:x,interactionWidth:b})});es.displayName="BezierEdge";const ni=y.createContext(null),X0=ni.Provider;ni.Consumer;const W0=()=>y.useContext(ni),G0=t=>"id"in t&&"source"in t&&"target"in t,Bl=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`reactflow__edge-${t}${e||""}-${n}${r||""}`,po=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`,K0=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),Fl=(t,e)=>{if(!t.source||!t.target)return Qr("006",vt.error006()),e;let n;return G0(t)?n={...t}:n={...t,id:Bl(t)},K0(n,e)?e:e.concat(n)},j0=(t,e,n,r={shouldReplaceId:!0})=>{const{id:s,...o}=t;if(!e.source||!e.target)return Qr("006",vt.error006()),n;if(!n.find(c=>c.id===s))return Qr("007",vt.error007(s)),n;const a={...o,id:r.shouldReplaceId?Bl(e):s,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle};return n.filter(c=>c.id!==s).concat(a)},go=({x:t,y:e},[n,r,s],o,[i,a])=>{const c={x:(t-n)/s,y:(e-r)/s};return o?{x:i*Math.round(c.x/i),y:a*Math.round(c.y/a)}:c},ql=({x:t,y:e},[n,r,s])=>({x:t*s+n,y:e*s+r}),Le=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],r=(t.height??0)*e[1],s={x:t.position.x-n,y:t.position.y-r};return{...s,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-r}:s}},ri=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,s)=>{const{x:o,y:i}=Le(s,e).positionAbsolute;return Y0(r,Qo({x:o,y:i,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return B0(n)},Ul=(t,e,[n,r,s]=[0,0,1],o=!1,i=!1,a=[0,0])=>{const c={x:(e.x-n)/s,y:(e.y-r)/s,width:e.width/s,height:e.height/s},l=[];return t.forEach(u=>{const{width:h,height:d,selectable:p=!0,hidden:x=!1}=u;if(i&&!p||x)return!1;const{positionAbsolute:w}=Le(u,a),b={x:w.x,y:w.y,width:h||0,height:d||0},v=uo(c,b),k=typeof h>"u"||typeof d>"u"||h===null||d===null,C=o&&v>0,S=(h||0)*(d||0);(k||C||v>=S||u.dragging)&&l.push(u)}),l},Zl=(t,e)=>{const n=t.map(r=>r.id);return e.filter(r=>n.includes(r.source)||n.includes(r.target))},Hl=(t,e,n,r,s,o=.1)=>{const i=e/(t.width*(1+o)),a=n/(t.height*(1+o)),c=Math.min(i,a),l=tn(c,r,s),u=t.x+t.width/2,h=t.y+t.height/2,d=e/2-u*l,p=n/2-h*l;return{x:d,y:p,zoom:l}},ce=(t,e=0)=>t.transition().duration(e);function ya(t,e,n,r){return(e[n]||[]).reduce((s,o)=>{var i,a;return`${t.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:t.id,x:(((i=t.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((a=t.positionAbsolute)==null?void 0:a.y)??0)+o.y+o.height/2}),s},[])}function Q0(t,e,n,r,s,o){const{x:i,y:a}=jt(t),l=e.elementsFromPoint(i,a).find(x=>x.classList.contains("react-flow__handle"));if(l){const x=l.getAttribute("data-nodeid");if(x){const w=si(void 0,l),b=l.getAttribute("data-handleid"),v=o({nodeId:x,id:b,type:w});if(v){const k=s.find(C=>C.nodeId===x&&C.type===w&&C.id===b);return{handle:{id:b,type:w,nodeId:x,x:(k==null?void 0:k.x)||n.x,y:(k==null?void 0:k.y)||n.y},validHandleResult:v}}}}let u=[],h=1/0;if(s.forEach(x=>{const w=Math.sqrt((x.x-n.x)**2+(x.y-n.y)**2);if(w<=r){const b=o(x);w<=h&&(w<h?u=[{handle:x,validHandleResult:b}]:w===h&&u.push({handle:x,validHandleResult:b}),h=w)}}),!u.length)return{handle:null,validHandleResult:Vl()};if(u.length===1)return u[0];const d=u.some(({validHandleResult:x})=>x.isValid),p=u.some(({handle:x})=>x.type==="target");return u.find(({handle:x,validHandleResult:w})=>p?x.type==="target":d?w.isValid:!0)||u[0]}const J0={source:null,target:null,sourceHandle:null,targetHandle:null},Vl=()=>({handleDomNode:null,isValid:!1,connection:J0,endHandle:null});function Xl(t,e,n,r,s,o,i){const a=s==="target",c=i.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),l={...Vl(),handleDomNode:c};if(c){const u=si(void 0,c),h=c.getAttribute("data-nodeid"),d=c.getAttribute("data-handleid"),p=c.classList.contains("connectable"),x=c.classList.contains("connectableend"),w={source:a?h:n,sourceHandle:a?d:r,target:a?n:h,targetHandle:a?r:d};l.connection=w,p&&x&&(e===exports.ConnectionMode.Strict?a&&u==="source"||!a&&u==="target":h!==n||d!==r)&&(l.endHandle={nodeId:h,handleId:d,type:u},l.isValid=o(w))}return l}function tw({nodes:t,nodeId:e,handleId:n,handleType:r}){return t.reduce((s,o)=>{if(o[ct]){const{handleBounds:i}=o[ct];let a=[],c=[];i&&(a=ya(o,i,"source",`${e}-${n}-${r}`),c=ya(o,i,"target",`${e}-${n}-${r}`)),s.push(...a,...c)}return s},[])}function si(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Bs(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function ew(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function Wl({event:t,handleId:e,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:i,isValidConnection:a,edgeUpdaterType:c,onEdgeUpdateEnd:l}){const u=Dl(t.target),{connectionMode:h,domNode:d,autoPanOnConnect:p,connectionRadius:x,onConnectStart:w,panBy:b,getNodes:v,cancelConnection:k}=o();let C=0,S;const{x:R,y:_}=jt(t),N=u==null?void 0:u.elementFromPoint(R,_),I=si(c,N),O=d==null?void 0:d.getBoundingClientRect();if(!O||!I)return;let Z,D=jt(t,O),q=!1,L=null,g=!1,A=null;const P=tw({nodes:v(),nodeId:n,handleId:e,handleType:I}),z=()=>{if(!p)return;const[Y,$]=Nl(D,O);b({x:Y,y:$}),C=requestAnimationFrame(z)};i({connectionPosition:D,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:I,connectionStartHandle:{nodeId:n,handleId:e,type:I},connectionEndHandle:null}),w==null||w(t,{nodeId:n,handleId:e,handleType:I});function F(Y){const{transform:$}=o();D=jt(Y,O);const{handle:H,validHandleResult:X}=Q0(Y,u,go(D,$,!1,[1,1]),x,P,W=>Xl(W,h,n,e,s?"target":"source",a,u));if(S=H,q||(z(),q=!0),A=X.handleDomNode,L=X.connection,g=X.isValid,i({connectionPosition:S&&g?ql({x:S.x,y:S.y},$):D,connectionStatus:ew(!!S,g),connectionEndHandle:X.endHandle}),!S&&!g&&!A)return Bs(Z);L.source!==L.target&&A&&(Bs(Z),Z=A,A.classList.add("connecting","react-flow__handle-connecting"),A.classList.toggle("valid",g),A.classList.toggle("react-flow__handle-valid",g))}function E(Y){var $,H;(S||A)&&L&&g&&(r==null||r(L)),(H=($=o()).onConnectEnd)==null||H.call($,Y),c&&(l==null||l(Y)),Bs(Z),k(),cancelAnimationFrame(C),q=!1,g=!1,L=null,A=null,u.removeEventListener("mousemove",F),u.removeEventListener("mouseup",E),u.removeEventListener("touchmove",F),u.removeEventListener("touchend",E)}u.addEventListener("mousemove",F),u.addEventListener("mouseup",E),u.addEventListener("touchmove",F),u.addEventListener("touchend",E)}const wa=()=>!0,nw=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),rw=(t,e,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:i}=r;return{connecting:(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.handleId)===e&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.handleId)===e&&(i==null?void 0:i.type)===n}},Gl=y.forwardRef(({type:t="source",position:e=exports.Position.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:i,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:h,...d},p)=>{var O,Z;const x=i||null,w=t==="target",b=ht(),v=W0(),{connectOnClick:k,noPanClassName:C}=lt(nw,pt),{connecting:S,clickConnecting:R}=lt(rw(v,x,t),pt);v||(Z=(O=b.getState()).onError)==null||Z.call(O,"010",vt.error010());const _=D=>{const{defaultEdgeOptions:q,onConnect:L,hasDefaultEdges:g}=b.getState(),A={...q,...D};if(g){const{edges:P,setEdges:z}=b.getState();z(Fl(A,P))}L==null||L(A),a==null||a(A)},N=D=>{if(!v)return;const q=zl(D);s&&(q&&D.button===0||!q)&&Wl({event:D,handleId:x,nodeId:v,onConnect:_,isTarget:w,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||wa}),q?u==null||u(D):h==null||h(D)},I=D=>{const{onClickConnectStart:q,onClickConnectEnd:L,connectionClickStartHandle:g,connectionMode:A,isValidConnection:P}=b.getState();if(!v||!g&&!s)return;if(!g){q==null||q(D,{nodeId:v,handleId:x,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:v,type:t,handleId:x}});return}const z=Dl(D.target),F=n||P||wa,{connection:E,isValid:Y}=Xl({nodeId:v,id:x,type:t},A,g.nodeId,g.handleId||null,g.type,F,z);Y&&_(E),L==null||L(D),b.setState({connectionClickStartHandle:null})};return y.createElement("div",{"data-handleid":x,"data-nodeid":v,"data-handlepos":e,"data-id":`${v}-${x}-${t}`,className:St(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",C,l,{source:!w,target:w,connectable:r,connectablestart:s,connectableend:o,connecting:R,connectionindicator:r&&(s&&!S||o&&S)}]),onMouseDown:N,onTouchStart:N,onClick:k?I:void 0,ref:p,...d},c)});Gl.displayName="Handle";var qn=y.memo(Gl);const Kl=({data:t,isConnectable:e,targetPosition:n=exports.Position.Top,sourcePosition:r=exports.Position.Bottom})=>y.createElement(y.Fragment,null,y.createElement(qn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,y.createElement(qn,{type:"source",position:r,isConnectable:e}));Kl.displayName="DefaultNode";var mo=y.memo(Kl);const jl=({data:t,isConnectable:e,sourcePosition:n=exports.Position.Bottom})=>y.createElement(y.Fragment,null,t==null?void 0:t.label,y.createElement(qn,{type:"source",position:n,isConnectable:e}));jl.displayName="InputNode";var Ql=y.memo(jl);const Jl=({data:t,isConnectable:e,targetPosition:n=exports.Position.Top})=>y.createElement(y.Fragment,null,y.createElement(qn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);Jl.displayName="OutputNode";var tu=y.memo(Jl);const oi=()=>null;oi.displayName="GroupNode";const sw=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),lr=t=>t.id;function ow(t,e){return pt(t.selectedNodes.map(lr),e.selectedNodes.map(lr))&&pt(t.selectedEdges.map(lr),e.selectedEdges.map(lr))}const eu=y.memo(({onSelectionChange:t})=>{const e=ht(),{selectedNodes:n,selectedEdges:r}=lt(sw,ow);return y.useEffect(()=>{const s={nodes:n,edges:r};t==null||t(s),e.getState().onSelectionChange.forEach(o=>o(s))},[n,r,t]),null});eu.displayName="SelectionListener";const iw=t=>!!t.onSelectionChange;function aw({onSelectionChange:t}){const e=lt(iw);return t||e?y.createElement(eu,{onSelectionChange:t}):null}const cw=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function Ce(t,e){y.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function Q(t,e,n){y.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const lw=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:i,onClickConnectStart:a,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:h,edgesFocusable:d,edgesUpdatable:p,elevateNodesOnSelect:x,minZoom:w,maxZoom:b,nodeExtent:v,onNodesChange:k,onEdgesChange:C,elementsSelectable:S,connectionMode:R,snapGrid:_,snapToGrid:N,translateExtent:I,connectOnClick:O,defaultEdgeOptions:Z,fitView:D,fitViewOptions:q,onNodesDelete:L,onEdgesDelete:g,onNodeDrag:A,onNodeDragStart:P,onNodeDragStop:z,onSelectionDrag:F,onSelectionDragStart:E,onSelectionDragStop:Y,noPanClassName:$,nodeOrigin:H,rfId:X,autoPanOnConnect:W,autoPanOnNodeDrag:j,onError:tt,connectionRadius:et,isValidConnection:ot,nodeDragThreshold:U})=>{const{setNodes:V,setEdges:K,setDefaultNodesAndEdges:B,setMinZoom:it,setMaxZoom:J,setTranslateExtent:nt,setNodeExtent:at,reset:rt}=lt(cw,pt),G=ht();return y.useEffect(()=>{const wt=r==null?void 0:r.map(ee=>({...ee,...Z}));return B(n,wt),()=>{rt()}},[]),Q("defaultEdgeOptions",Z,G.setState),Q("connectionMode",R,G.setState),Q("onConnect",s,G.setState),Q("onConnectStart",o,G.setState),Q("onConnectEnd",i,G.setState),Q("onClickConnectStart",a,G.setState),Q("onClickConnectEnd",c,G.setState),Q("nodesDraggable",l,G.setState),Q("nodesConnectable",u,G.setState),Q("nodesFocusable",h,G.setState),Q("edgesFocusable",d,G.setState),Q("edgesUpdatable",p,G.setState),Q("elementsSelectable",S,G.setState),Q("elevateNodesOnSelect",x,G.setState),Q("snapToGrid",N,G.setState),Q("snapGrid",_,G.setState),Q("onNodesChange",k,G.setState),Q("onEdgesChange",C,G.setState),Q("connectOnClick",O,G.setState),Q("fitViewOnInit",D,G.setState),Q("fitViewOnInitOptions",q,G.setState),Q("onNodesDelete",L,G.setState),Q("onEdgesDelete",g,G.setState),Q("onNodeDrag",A,G.setState),Q("onNodeDragStart",P,G.setState),Q("onNodeDragStop",z,G.setState),Q("onSelectionDrag",F,G.setState),Q("onSelectionDragStart",E,G.setState),Q("onSelectionDragStop",Y,G.setState),Q("noPanClassName",$,G.setState),Q("nodeOrigin",H,G.setState),Q("rfId",X,G.setState),Q("autoPanOnConnect",W,G.setState),Q("autoPanOnNodeDrag",j,G.setState),Q("onError",tt,G.setState),Q("connectionRadius",et,G.setState),Q("isValidConnection",ot,G.setState),Q("nodeDragThreshold",U,G.setState),Ce(t,V),Ce(e,K),Ce(w,it),Ce(b,J),Ce(I,nt),Ce(v,at),null},xa={display:"none"},uw={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},nu="react-flow__node-desc",ru="react-flow__edge-desc",hw="react-flow__aria-live",fw=t=>t.ariaLiveMessage;function dw({rfId:t}){const e=lt(fw);return y.createElement("div",{id:`${hw}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:uw},e)}function pw({rfId:t,disableKeyboardA11y:e}){return y.createElement(y.Fragment,null,y.createElement("div",{id:`${nu}-${t}`,style:xa},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),y.createElement("div",{id:`${ru}-${t}`,style:xa},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&y.createElement(dw,{rfId:t}))}var Un=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,r]=y.useState(!1),s=y.useRef(!1),o=y.useRef(new Set([])),[i,a]=y.useMemo(()=>{if(t!==null){const l=(Array.isArray(t)?t:[t]).filter(h=>typeof h=="string").map(h=>h.split("+")),u=l.reduce((h,d)=>h.concat(...d),[]);return[l,u]}return[[],[]]},[t]);return y.useEffect(()=>{const c=typeof document<"u"?document:null,l=(e==null?void 0:e.target)||c;if(t!==null){const u=p=>{if(s.current=p.ctrlKey||p.metaKey||p.shiftKey,(!s.current||s.current&&!e.actInsideInputWithModifier)&&ho(p))return!1;const w=Sa(p.code,a);o.current.add(p[w]),va(i,o.current,!1)&&(p.preventDefault(),r(!0))},h=p=>{if((!s.current||s.current&&!e.actInsideInputWithModifier)&&ho(p))return!1;const w=Sa(p.code,a);va(i,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(p[w]),p.key==="Meta"&&o.current.clear(),s.current=!1},d=()=>{o.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",u),l==null||l.addEventListener("keyup",h),window.addEventListener("blur",d),()=>{l==null||l.removeEventListener("keydown",u),l==null||l.removeEventListener("keyup",h),window.removeEventListener("blur",d)}}},[t,r]),n};function va(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(s=>e.has(s)))}function Sa(t,e){return e.includes(t)?"code":"key"}function su(t,e,n,r){var a,c;const s=t.parentNode||t.parentId;if(!s)return n;const o=e.get(s),i=Le(o,r);return su(o,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((a=o[ct])==null?void 0:a.z)??0)>(n.z??0)?((c=o[ct])==null?void 0:c.z)??0:n.z??0},r)}function ou(t,e,n){t.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!t.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:i,y:a,z:c}=su(r,t,{...r.position,z:((o=r[ct])==null?void 0:o.z)??0},e);r.positionAbsolute={x:i,y:a},r[ct].z=c,n!=null&&n[r.id]&&(r[ct].isParent=!0)}})}function Fs(t,e,n,r){const s=new Map,o={},i=r?1e3:0;return t.forEach(a=>{var p;const c=(Tt(a.zIndex)?a.zIndex:0)+(a.selected?i:0),l=e.get(a.id),u={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},h=a.parentNode||a.parentId;h&&(o[h]=!0);const d=(l==null?void 0:l.type)&&(l==null?void 0:l.type)!==a.type;Object.defineProperty(u,ct,{enumerable:!1,value:{handleBounds:d||(p=l==null?void 0:l[ct])==null?void 0:p.handleBounds,z:c}}),s.set(a.id,u)}),ou(s,n,o),s}function iu(t,e={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:i,d3Zoom:a,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:h}=t(),d=e.initial&&!l&&u;if(a&&c&&(d||!e.initial)){const x=n().filter(b=>{var k;const v=e.includeHiddenNodes?b.width&&b.height:!b.hidden;return(k=e.nodes)!=null&&k.length?v&&e.nodes.some(C=>C.id===b.id):v}),w=x.every(b=>b.width&&b.height);if(x.length>0&&w){const b=ri(x,h),{x:v,y:k,zoom:C}=Hl(b,r,s,e.minZoom??o,e.maxZoom??i,e.padding??.1),S=Kt.translate(v,k).scale(C);return typeof e.duration=="number"&&e.duration>0?a.transform(ce(c,e.duration),S):a.transform(c,S),!0}}return!1}function gw(t,e){return t.forEach(n=>{const r=e.get(n.id);r&&e.set(r.id,{...r,[ct]:r[ct],selected:n.selected})}),new Map(e)}function mw(t,e){return e.map(n=>{const r=t.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function ur({changedNodes:t,changedEdges:e,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:i,onEdgesChange:a,hasDefaultNodes:c,hasDefaultEdges:l}=n();t!=null&&t.length&&(c&&r({nodeInternals:gw(t,s)}),i==null||i(t)),e!=null&&e.length&&(l&&r({edges:mw(e,o)}),a==null||a(e))}const Pe=()=>{},yw={zoomIn:Pe,zoomOut:Pe,zoomTo:Pe,getZoom:()=>1,setViewport:Pe,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Pe,fitBounds:Pe,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},ww=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),xw=()=>{const t=ht(),{d3Zoom:e,d3Selection:n}=lt(ww,pt);return y.useMemo(()=>n&&e?{zoomIn:s=>e.scaleBy(ce(n,s==null?void 0:s.duration),1.2),zoomOut:s=>e.scaleBy(ce(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>e.scaleTo(ce(n,o==null?void 0:o.duration),s),getZoom:()=>t.getState().transform[2],setViewport:(s,o)=>{const[i,a,c]=t.getState().transform,l=Kt.translate(s.x??i,s.y??a).scale(s.zoom??c);e.transform(ce(n,o==null?void 0:o.duration),l)},getViewport:()=>{const[s,o,i]=t.getState().transform;return{x:s,y:o,zoom:i}},fitView:s=>iu(t.getState,s),setCenter:(s,o,i)=>{const{width:a,height:c,maxZoom:l}=t.getState(),u=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:l,h=a/2-s*u,d=c/2-o*u,p=Kt.translate(h,d).scale(u);e.transform(ce(n,i==null?void 0:i.duration),p)},fitBounds:(s,o)=>{const{width:i,height:a,minZoom:c,maxZoom:l}=t.getState(),{x:u,y:h,zoom:d}=Hl(s,i,a,c,l,(o==null?void 0:o.padding)??.1),p=Kt.translate(u,h).scale(d);e.transform(ce(n,o==null?void 0:o.duration),p)},project:s=>{const{transform:o,snapToGrid:i,snapGrid:a}=t.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),go(s,o,i,a)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:i,snapGrid:a,domNode:c}=t.getState();if(!c)return s;const{x:l,y:u}=c.getBoundingClientRect(),h={x:s.x-l,y:s.y-u};return go(h,o,i,a)},flowToScreenPosition:s=>{const{transform:o,domNode:i}=t.getState();if(!i)return s;const{x:a,y:c}=i.getBoundingClientRect(),l=ql(s,o);return{x:l.x+a,y:l.y+c}},viewportInitialized:!0}:yw,[e,n])};function vs(){const t=xw(),e=ht(),n=y.useCallback(()=>e.getState().getNodes().map(w=>({...w})),[]),r=y.useCallback(w=>e.getState().nodeInternals.get(w),[]),s=y.useCallback(()=>{const{edges:w=[]}=e.getState();return w.map(b=>({...b}))},[]),o=y.useCallback(w=>{const{edges:b=[]}=e.getState();return b.find(v=>v.id===w)},[]),i=y.useCallback(w=>{const{getNodes:b,setNodes:v,hasDefaultNodes:k,onNodesChange:C}=e.getState(),S=b(),R=typeof w=="function"?w(S):w;if(k)v(R);else if(C){const _=R.length===0?S.map(N=>({type:"remove",id:N.id})):R.map(N=>({item:N,type:"reset"}));C(_)}},[]),a=y.useCallback(w=>{const{edges:b=[],setEdges:v,hasDefaultEdges:k,onEdgesChange:C}=e.getState(),S=typeof w=="function"?w(b):w;if(k)v(S);else if(C){const R=S.length===0?b.map(_=>({type:"remove",id:_.id})):S.map(_=>({item:_,type:"reset"}));C(R)}},[]),c=y.useCallback(w=>{const b=Array.isArray(w)?w:[w],{getNodes:v,setNodes:k,hasDefaultNodes:C,onNodesChange:S}=e.getState();if(C){const _=[...v(),...b];k(_)}else if(S){const R=b.map(_=>({item:_,type:"add"}));S(R)}},[]),l=y.useCallback(w=>{const b=Array.isArray(w)?w:[w],{edges:v=[],setEdges:k,hasDefaultEdges:C,onEdgesChange:S}=e.getState();if(C)k([...v,...b]);else if(S){const R=b.map(_=>({item:_,type:"add"}));S(R)}},[]),u=y.useCallback(()=>{const{getNodes:w,edges:b=[],transform:v}=e.getState(),[k,C,S]=v;return{nodes:w().map(R=>({...R})),edges:b.map(R=>({...R})),viewport:{x:k,y:C,zoom:S}}},[]),h=y.useCallback(({nodes:w,edges:b})=>{const{nodeInternals:v,getNodes:k,edges:C,hasDefaultNodes:S,hasDefaultEdges:R,onNodesDelete:_,onEdgesDelete:N,onNodesChange:I,onEdgesChange:O}=e.getState(),Z=(w||[]).map(A=>A.id),D=(b||[]).map(A=>A.id),q=k().reduce((A,P)=>{const z=P.parentNode||P.parentId,F=!Z.includes(P.id)&&z&&A.find(Y=>Y.id===z);return(typeof P.deletable=="boolean"?P.deletable:!0)&&(Z.includes(P.id)||F)&&A.push(P),A},[]),L=C.filter(A=>typeof A.deletable=="boolean"?A.deletable:!0),g=L.filter(A=>D.includes(A.id));if(q||g){const A=Zl(q,L),P=[...g,...A],z=P.reduce((F,E)=>(F.includes(E.id)||F.push(E.id),F),[]);if((R||S)&&(R&&e.setState({edges:C.filter(F=>!z.includes(F.id))}),S&&(q.forEach(F=>{v.delete(F.id)}),e.setState({nodeInternals:new Map(v)}))),z.length>0&&(N==null||N(P),O&&O(z.map(F=>({id:F,type:"remove"})))),q.length>0&&(_==null||_(q),I)){const F=q.map(E=>({id:E.id,type:"remove"}));I(F)}}},[]),d=y.useCallback(w=>{const b=F0(w),v=b?null:e.getState().nodeInternals.get(w.id);return!b&&!v?[null,null,b]:[b?w:fa(v),v,b]},[]),p=y.useCallback((w,b=!0,v)=>{const[k,C,S]=d(w);return k?(v||e.getState().getNodes()).filter(R=>{if(!S&&(R.id===C.id||!R.positionAbsolute))return!1;const _=fa(R),N=uo(_,k);return b&&N>0||N>=k.width*k.height}):[]},[]),x=y.useCallback((w,b,v=!0)=>{const[k]=d(w);if(!k)return!1;const C=uo(k,b);return v&&C>0||C>=k.width*k.height},[]);return y.useMemo(()=>({...t,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:i,setEdges:a,addNodes:c,addEdges:l,toObject:u,deleteElements:h,getIntersectingNodes:p,isNodeIntersecting:x}),[t,n,r,s,o,i,a,c,l,u,h,p,x])}const vw={actInsideInputWithModifier:!1};var Sw=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=ht(),{deleteElements:r}=vs(),s=Un(t,vw),o=Un(e);y.useEffect(()=>{if(s){const{edges:i,getNodes:a}=n.getState(),c=a().filter(u=>u.selected),l=i.filter(u=>u.selected);r({nodes:c,edges:l}),n.setState({nodesSelectionActive:!1})}},[s]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function bw(t){const e=ht();y.useEffect(()=>{let n;const r=()=>{var o,i;if(!t.current)return;const s=Ko(t.current);(s.height===0||s.width===0)&&((i=(o=e.getState()).onError)==null||i.call(o,"004",vt.error004())),e.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),t.current&&(n=new ResizeObserver(()=>r()),n.observe(t.current)),()=>{window.removeEventListener("resize",r),n&&t.current&&n.unobserve(t.current)}},[])}const ii={position:"absolute",width:"100%",height:"100%",top:0,left:0},Tw=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,hr=t=>({x:t.x,y:t.y,zoom:t.k}),ke=(t,e)=>t.target.closest(`.${e}`),ba=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),Ta=t=>{const e=t.ctrlKey&&Jr()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},Ew=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),_w=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:a=.5,panOnScrollMode:c=he.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:h=!0,defaultViewport:d,translateExtent:p,minZoom:x,maxZoom:w,zoomActivationKeyCode:b,preventScrolling:v=!0,children:k,noWheelClassName:C,noPanClassName:S})=>{const R=y.useRef(),_=ht(),N=y.useRef(!1),I=y.useRef(!1),O=y.useRef(null),Z=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:D,d3Selection:q,d3ZoomHandler:L,userSelectionActive:g}=lt(Ew,pt),A=Un(b),P=y.useRef(0),z=y.useRef(!1),F=y.useRef();return bw(O),y.useEffect(()=>{if(O.current){const E=O.current.getBoundingClientRect(),Y=N0().scaleExtent([x,w]).translateExtent(p),$=kt(O.current).call(Y),H=Kt.translate(d.x,d.y).scale(tn(d.zoom,x,w)),X=[[0,0],[E.width,E.height]],W=Y.constrain()(H,X,p);Y.transform($,W),Y.wheelDelta(Ta),_.setState({d3Zoom:Y,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:O.current.closest(".react-flow")})}},[]),y.useEffect(()=>{q&&D&&(i&&!A&&!g?q.on("wheel.zoom",E=>{if(ke(E,C))return!1;E.preventDefault(),E.stopImmediatePropagation();const Y=q.property("__zoom").k||1,$=Jr();if(E.ctrlKey&&o&&$){const U=Nt(E),V=Ta(E),K=Y*Math.pow(2,V);D.scaleTo(q,K,U,E);return}const H=E.deltaMode===1?20:1;let X=c===he.Vertical?0:E.deltaX*H,W=c===he.Horizontal?0:E.deltaY*H;!$&&E.shiftKey&&c!==he.Vertical&&(X=E.deltaY*H,W=0),D.translateBy(q,-(X/Y)*a,-(W/Y)*a,{internal:!0});const j=hr(q.property("__zoom")),{onViewportChangeStart:tt,onViewportChange:et,onViewportChangeEnd:ot}=_.getState();clearTimeout(F.current),z.current||(z.current=!0,e==null||e(E,j),tt==null||tt(j)),z.current&&(t==null||t(E,j),et==null||et(j),F.current=setTimeout(()=>{n==null||n(E,j),ot==null||ot(j),z.current=!1},150))},{passive:!1}):typeof L<"u"&&q.on("wheel.zoom",function(E,Y){if(!v&&E.type==="wheel"&&!E.ctrlKey||ke(E,C))return null;E.preventDefault(),L.call(this,E,Y)},{passive:!1}))},[g,i,c,q,D,L,A,o,v,C,e,t,n]),y.useEffect(()=>{D&&D.on("start",E=>{var H,X;if(!E.sourceEvent||E.sourceEvent.internal)return null;P.current=(H=E.sourceEvent)==null?void 0:H.button;const{onViewportChangeStart:Y}=_.getState(),$=hr(E.transform);N.current=!0,Z.current=$,((X=E.sourceEvent)==null?void 0:X.type)==="mousedown"&&_.setState({paneDragging:!0}),Y==null||Y($),e==null||e(E.sourceEvent,$)})},[D,e]),y.useEffect(()=>{D&&(g&&!N.current?D.on("zoom",null):g||D.on("zoom",E=>{var $;const{onViewportChange:Y}=_.getState();if(_.setState({transform:[E.transform.x,E.transform.y,E.transform.k]}),I.current=!!(r&&ba(h,P.current??0)),(t||Y)&&!(($=E.sourceEvent)!=null&&$.internal)){const H=hr(E.transform);Y==null||Y(H),t==null||t(E.sourceEvent,H)}}))},[g,D,t,h,r]),y.useEffect(()=>{D&&D.on("end",E=>{if(!E.sourceEvent||E.sourceEvent.internal)return null;const{onViewportChangeEnd:Y}=_.getState();if(N.current=!1,_.setState({paneDragging:!1}),r&&ba(h,P.current??0)&&!I.current&&r(E.sourceEvent),I.current=!1,(n||Y)&&Tw(Z.current,E.transform)){const $=hr(E.transform);Z.current=$,clearTimeout(R.current),R.current=setTimeout(()=>{Y==null||Y($),n==null||n(E.sourceEvent,$)},i?150:0)}})},[D,i,h,n,r]),y.useEffect(()=>{D&&D.filter(E=>{const Y=A||s,$=o&&E.ctrlKey;if((h===!0||Array.isArray(h)&&h.includes(1))&&E.button===1&&E.type==="mousedown"&&(ke(E,"react-flow__node")||ke(E,"react-flow__edge")))return!0;if(!h&&!Y&&!i&&!l&&!o||g||!l&&E.type==="dblclick"||ke(E,C)&&E.type==="wheel"||ke(E,S)&&(E.type!=="wheel"||i&&E.type==="wheel"&&!A)||!o&&E.ctrlKey&&E.type==="wheel"||!Y&&!i&&!$&&E.type==="wheel"||!h&&(E.type==="mousedown"||E.type==="touchstart")||Array.isArray(h)&&!h.includes(E.button)&&(E.type==="mousedown"||E.type==="touchstart"))return!1;const H=Array.isArray(h)&&h.includes(E.button)||!E.button||E.button<=1;return(!E.ctrlKey||E.type==="wheel")&&H})},[g,D,s,o,i,l,h,u,A]),y.createElement("div",{className:"react-flow__renderer",ref:O,style:ii},k)},Cw=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function Pw(){const{userSelectionActive:t,userSelectionRect:e}=lt(Cw,pt);return t&&e?y.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function Ea(t,e){const n=e.parentNode||e.parentId,r=t.find(s=>s.id===n);if(r){const s=e.position.x+e.width-r.width,o=e.position.y+e.height-r.height;if(s>0||o>0||e.position.x<0||e.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),e.position.x<0){const i=Math.abs(e.position.x);r.position.x=r.position.x-i,r.style.width+=i,e.position.x=0}if(e.position.y<0){const i=Math.abs(e.position.y);r.position.y=r.position.y-i,r.style.height+=i,e.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function au(t,e){if(t.some(r=>r.type==="reset"))return t.filter(r=>r.type==="reset").map(r=>r.item);const n=t.filter(r=>r.type==="add").map(r=>r.item);return e.reduce((r,s)=>{const o=t.filter(a=>a.id===s.id);if(o.length===0)return r.push(s),r;const i={...s};for(const a of o)if(a)switch(a.type){case"select":{i.selected=a.selected;break}case"position":{typeof a.position<"u"&&(i.position=a.position),typeof a.positionAbsolute<"u"&&(i.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(i.dragging=a.dragging),i.expandParent&&Ea(r,i);break}case"dimensions":{typeof a.dimensions<"u"&&(i.width=a.dimensions.width,i.height=a.dimensions.height),typeof a.updateStyle<"u"&&(i.style={...i.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(i.resizing=a.resizing),i.expandParent&&Ea(r,i);break}case"remove":return r}return r.push(i),r},n)}function cu(t,e){return au(t,e)}function kw(t,e){return au(t,e)}const Wt=(t,e)=>({id:t,type:"select",selected:e});function Ne(t,e){return t.reduce((n,r)=>{const s=e.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Wt(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Wt(r.id,!1))),n},[])}const qs=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},Mw=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),lu=y.memo(({isSelecting:t,selectionMode:e=exports.SelectionMode.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:a,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:h})=>{const d=y.useRef(null),p=ht(),x=y.useRef(0),w=y.useRef(0),b=y.useRef(),{userSelectionActive:v,elementsSelectable:k,dragging:C}=lt(Mw,pt),S=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),x.current=0,w.current=0},R=L=>{o==null||o(L),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},_=L=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){L.preventDefault();return}i==null||i(L)},N=a?L=>a(L):void 0,I=L=>{const{resetSelectedElements:g,domNode:A}=p.getState();if(b.current=A==null?void 0:A.getBoundingClientRect(),!k||!t||L.button!==0||L.target!==d.current||!b.current)return;const{x:P,y:z}=jt(L,b.current);g(),p.setState({userSelectionRect:{width:0,height:0,startX:P,startY:z,x:P,y:z}}),r==null||r(L)},O=L=>{const{userSelectionRect:g,nodeInternals:A,edges:P,transform:z,onNodesChange:F,onEdgesChange:E,nodeOrigin:Y,getNodes:$}=p.getState();if(!t||!b.current||!g)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const H=jt(L,b.current),X=g.startX??0,W=g.startY??0,j={...g,x:H.x<X?H.x:X,y:H.y<W?H.y:W,width:Math.abs(H.x-X),height:Math.abs(H.y-W)},tt=$(),et=Ul(A,j,z,e===exports.SelectionMode.Partial,!0,Y),ot=Zl(et,P).map(V=>V.id),U=et.map(V=>V.id);if(x.current!==U.length){x.current=U.length;const V=Ne(tt,U);V.length&&(F==null||F(V))}if(w.current!==ot.length){w.current=ot.length;const V=Ne(P,ot);V.length&&(E==null||E(V))}p.setState({userSelectionRect:j})},Z=L=>{if(L.button!==0)return;const{userSelectionRect:g}=p.getState();!v&&g&&L.target===d.current&&(R==null||R(L)),p.setState({nodesSelectionActive:x.current>0}),S(),s==null||s(L)},D=L=>{v&&(p.setState({nodesSelectionActive:x.current>0}),s==null||s(L)),S()},q=k&&(t||v);return y.createElement("div",{className:St(["react-flow__pane",{dragging:C,selection:t}]),onClick:q?void 0:qs(R,d),onContextMenu:qs(_,d),onWheel:qs(N,d),onMouseEnter:q?void 0:c,onMouseDown:q?I:void 0,onMouseMove:q?O:l,onMouseUp:q?Z:void 0,onMouseLeave:q?D:u,ref:d,style:ii},h,y.createElement(Pw,null))});lu.displayName="Pane";function uu(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const r=e.get(n);return r?r.selected?!0:uu(r,e):!1}function _a(t,e,n){let r=t;do{if(r!=null&&r.matches(e))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function Rw(t,e,n,r){return Array.from(t.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!uu(s,t))&&(s.draggable||e&&typeof s.draggable>"u")).map(s=>{var o,i;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=s.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function Aw(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function hu(t,e,n,r,s=[0,0],o){const i=Aw(t,t.extent||r);let a=i;const c=t.parentNode||t.parentId;if(t.extent==="parent"&&!t.expandParent)if(c&&t.width&&t.height){const h=n.get(c),{x:d,y:p}=Le(h,s).positionAbsolute;a=h&&Tt(d)&&Tt(p)&&Tt(h.width)&&Tt(h.height)?[[d+t.width*s[0],p+t.height*s[1]],[d+h.width-t.width+t.width*s[0],p+h.height-t.height+t.height*s[1]]]:a}else o==null||o("005",vt.error005()),a=i;else if(t.extent&&c&&t.extent!=="parent"){const h=n.get(c),{x:d,y:p}=Le(h,s).positionAbsolute;a=[[t.extent[0][0]+d,t.extent[0][1]+p],[t.extent[1][0]+d,t.extent[1][1]+p]]}let l={x:0,y:0};if(c){const h=n.get(c);l=Le(h,s).positionAbsolute}const u=a&&a!=="parent"?jo(e,a):e;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function Us({nodeId:t,dragItems:e,nodeInternals:n}){const r=e.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[t?r.find(s=>s.id===t):r[0],r]}const Ca=(t,e,n,r)=>{const s=e.querySelectorAll(t);if(!s||!s.length)return null;const o=Array.from(s),i=e.getBoundingClientRect(),a={x:i.width*r[0],y:i.height*r[1]};return o.map(c=>{const l=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(l.left-i.left-a.x)/n,y:(l.top-i.top-a.y)/n,...Ko(c)}})};function yn(t,e,n){return n===void 0?n:r=>{const s=e().nodeInternals.get(t);s&&n(r,{...s})}}function yo({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:a,onError:c}=e.getState(),l=a.get(t);if(!l){c==null||c("012",vt.error012(t));return}e.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(o({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([t])}function Nw(){const t=ht();return y.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=t.getState(),i=n.touches?n.touches[0].clientX:n.clientX,a=n.touches?n.touches[0].clientY:n.clientY,c={x:(i-r[0])/r[2],y:(a-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(c.x/s[0]):c.x,ySnapped:o?s[1]*Math.round(c.y/s[1]):c.y,...c}},[])}function Zs(t){return(e,n,r)=>t==null?void 0:t(e,r)}function fu({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:i}){const a=ht(),[c,l]=y.useState(!1),u=y.useRef([]),h=y.useRef({x:null,y:null}),d=y.useRef(0),p=y.useRef(null),x=y.useRef({x:0,y:0}),w=y.useRef(null),b=y.useRef(!1),v=y.useRef(!1),k=Nw();return y.useEffect(()=>{if(t!=null&&t.current){const C=kt(t.current),S=({x:N,y:I})=>{const{nodeInternals:O,onNodeDrag:Z,onSelectionDrag:D,updateNodePositions:q,nodeExtent:L,snapGrid:g,snapToGrid:A,nodeOrigin:P,onError:z}=a.getState();h.current={x:N,y:I};let F=!1,E={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&L){const $=ri(u.current,P);E=Qo($)}if(u.current=u.current.map($=>{const H={x:N-$.distance.x,y:I-$.distance.y};A&&(H.x=g[0]*Math.round(H.x/g[0]),H.y=g[1]*Math.round(H.y/g[1]));const X=[[L[0][0],L[0][1]],[L[1][0],L[1][1]]];u.current.length>1&&L&&!$.extent&&(X[0][0]=$.positionAbsolute.x-E.x+L[0][0],X[1][0]=$.positionAbsolute.x+($.width??0)-E.x2+L[1][0],X[0][1]=$.positionAbsolute.y-E.y+L[0][1],X[1][1]=$.positionAbsolute.y+($.height??0)-E.y2+L[1][1]);const W=hu($,H,O,X,P,z);return F=F||$.position.x!==W.position.x||$.position.y!==W.position.y,$.position=W.position,$.positionAbsolute=W.positionAbsolute,$}),!F)return;q(u.current,!0,!0),l(!0);const Y=s?Z:Zs(D);if(Y&&w.current){const[$,H]=Us({nodeId:s,dragItems:u.current,nodeInternals:O});Y(w.current,$,H)}},R=()=>{if(!p.current)return;const[N,I]=Nl(x.current,p.current);if(N!==0||I!==0){const{transform:O,panBy:Z}=a.getState();h.current.x=(h.current.x??0)-N/O[2],h.current.y=(h.current.y??0)-I/O[2],Z({x:N,y:I})&&S(h.current)}d.current=requestAnimationFrame(R)},_=N=>{var P;const{nodeInternals:I,multiSelectionActive:O,nodesDraggable:Z,unselectNodesAndEdges:D,onNodeDragStart:q,onSelectionDragStart:L}=a.getState();v.current=!0;const g=s?q:Zs(L);(!i||!o)&&!O&&s&&((P=I.get(s))!=null&&P.selected||D()),s&&o&&i&&yo({id:s,store:a,nodeRef:t});const A=k(N);if(h.current=A,u.current=Rw(I,Z,A,s),g&&u.current){const[z,F]=Us({nodeId:s,dragItems:u.current,nodeInternals:I});g(N.sourceEvent,z,F)}};if(e)C.on(".drag",null);else{const N=py().on("start",I=>{const{domNode:O,nodeDragThreshold:Z}=a.getState();Z===0&&_(I);const D=k(I);h.current=D,p.current=(O==null?void 0:O.getBoundingClientRect())||null,x.current=jt(I.sourceEvent,p.current)}).on("drag",I=>{var q,L;const O=k(I),{autoPanOnNodeDrag:Z,nodeDragThreshold:D}=a.getState();if(!b.current&&v.current&&Z&&(b.current=!0,R()),!v.current){const g=O.xSnapped-(((q=h==null?void 0:h.current)==null?void 0:q.x)??0),A=O.ySnapped-(((L=h==null?void 0:h.current)==null?void 0:L.y)??0);Math.sqrt(g*g+A*A)>D&&_(I)}(h.current.x!==O.xSnapped||h.current.y!==O.ySnapped)&&u.current&&v.current&&(w.current=I.sourceEvent,x.current=jt(I.sourceEvent,p.current),S(O))}).on("end",I=>{if(v.current&&(l(!1),b.current=!1,v.current=!1,cancelAnimationFrame(d.current),u.current)){const{updateNodePositions:O,nodeInternals:Z,onNodeDragStop:D,onSelectionDragStop:q}=a.getState(),L=s?D:Zs(q);if(O(u.current,!1,!1),L){const[g,A]=Us({nodeId:s,dragItems:u.current,nodeInternals:Z});L(I.sourceEvent,g,A)}}}).filter(I=>{const O=I.target;return!I.button&&(!n||!_a(O,`.${n}`,t))&&(!r||_a(O,r,t))});return C.call(N),()=>{C.on(".drag",null)}}}},[t,e,n,r,o,a,s,i,k]),c}function du(){const t=ht();return y.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:i,snapToGrid:a,snapGrid:c,onError:l,nodesDraggable:u}=t.getState(),h=i().filter(k=>k.selected&&(k.draggable||u&&typeof k.draggable>"u")),d=a?c[0]:5,p=a?c[1]:5,x=n.isShiftPressed?4:1,w=n.x*d*x,b=n.y*p*x,v=h.map(k=>{if(k.positionAbsolute){const C={x:k.positionAbsolute.x+w,y:k.positionAbsolute.y+b};a&&(C.x=c[0]*Math.round(C.x/c[0]),C.y=c[1]*Math.round(C.y/c[1]));const{positionAbsolute:S,position:R}=hu(k,C,r,s,void 0,l);k.position=R,k.positionAbsolute=S}return k});o(v,!0,!1)},[])}const Ye={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var wn=t=>{const e=({id:n,type:r,data:s,xPos:o,yPos:i,xPosOrigin:a,yPosOrigin:c,selected:l,onClick:u,onMouseEnter:h,onMouseMove:d,onMouseLeave:p,onContextMenu:x,onDoubleClick:w,style:b,className:v,isDraggable:k,isSelectable:C,isConnectable:S,isFocusable:R,selectNodesOnDrag:_,sourcePosition:N,targetPosition:I,hidden:O,resizeObserver:Z,dragHandle:D,zIndex:q,isParent:L,noDragClassName:g,noPanClassName:A,initialized:P,disableKeyboardA11y:z,ariaLabel:F,rfId:E,hasHandleBounds:Y})=>{const $=ht(),H=y.useRef(null),X=y.useRef(null),W=y.useRef(N),j=y.useRef(I),tt=y.useRef(r),et=C||k||u||h||d||p,ot=du(),U=yn(n,$.getState,h),V=yn(n,$.getState,d),K=yn(n,$.getState,p),B=yn(n,$.getState,x),it=yn(n,$.getState,w),J=rt=>{const{nodeDragThreshold:G}=$.getState();if(C&&(!_||!k||G>0)&&yo({id:n,store:$,nodeRef:H}),u){const wt=$.getState().nodeInternals.get(n);wt&&u(rt,{...wt})}},nt=rt=>{if(!ho(rt)&&!z)if(Ol.includes(rt.key)&&C){const G=rt.key==="Escape";yo({id:n,store:$,unselect:G,nodeRef:H})}else k&&l&&Object.prototype.hasOwnProperty.call(Ye,rt.key)&&($.setState({ariaLiveMessage:`Moved selected node ${rt.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),ot({x:Ye[rt.key].x,y:Ye[rt.key].y,isShiftPressed:rt.shiftKey}))};y.useEffect(()=>()=>{X.current&&(Z==null||Z.unobserve(X.current),X.current=null)},[]),y.useEffect(()=>{if(H.current&&!O){const rt=H.current;(!P||!Y||X.current!==rt)&&(X.current&&(Z==null||Z.unobserve(X.current)),Z==null||Z.observe(rt),X.current=rt)}},[O,P,Y]),y.useEffect(()=>{const rt=tt.current!==r,G=W.current!==N,wt=j.current!==I;H.current&&(rt||G||wt)&&(rt&&(tt.current=r),G&&(W.current=N),wt&&(j.current=I),$.getState().updateNodeDimensions([{id:n,nodeElement:H.current,forceUpdate:!0}]))},[n,r,N,I]);const at=fu({nodeRef:H,disabled:O||!k,noDragClassName:g,handleSelector:D,nodeId:n,isSelectable:C,selectNodesOnDrag:_});return O?null:y.createElement("div",{className:St(["react-flow__node",`react-flow__node-${r}`,{[A]:k},v,{selected:l,selectable:C,parent:L,dragging:at}]),ref:H,style:{zIndex:q,transform:`translate(${a}px,${c}px)`,pointerEvents:et?"all":"none",visibility:P?"visible":"hidden",...b},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:U,onMouseMove:V,onMouseLeave:K,onContextMenu:B,onClick:J,onDoubleClick:it,onKeyDown:R?nt:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":z?void 0:`${nu}-${E}`,"aria-label":F},y.createElement(X0,{value:n},y.createElement(t,{id:n,data:s,type:r,xPos:o,yPos:i,selected:l,isConnectable:S,sourcePosition:N,targetPosition:I,dragging:at,dragHandle:D,zIndex:q})))};return e.displayName="NodeWrapper",y.memo(e)};const Dw=t=>{const e=t.getNodes().filter(n=>n.selected);return{...ri(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function Ow({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=ht(),{width:s,height:o,x:i,y:a,transformString:c,userSelectionActive:l}=lt(Dw,pt),u=du(),h=y.useRef(null);if(y.useEffect(()=>{var x;n||(x=h.current)==null||x.focus({preventScroll:!0})},[n]),fu({nodeRef:h}),l||!s||!o)return null;const d=t?x=>{const w=r.getState().getNodes().filter(b=>b.selected);t(x,w)}:void 0,p=x=>{Object.prototype.hasOwnProperty.call(Ye,x.key)&&u({x:Ye[x.key].x,y:Ye[x.key].y,isShiftPressed:x.shiftKey})};return y.createElement("div",{className:St(["react-flow__nodesselection","react-flow__container",e]),style:{transform:c}},y.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:o,top:a,left:i}}))}var zw=y.memo(Ow);const Iw=t=>t.nodesSelectionActive,pu=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:a,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:h,selectionOnDrag:d,selectionMode:p,onSelectionStart:x,onSelectionEnd:w,multiSelectionKeyCode:b,panActivationKeyCode:v,zoomActivationKeyCode:k,elementsSelectable:C,zoomOnScroll:S,zoomOnPinch:R,panOnScroll:_,panOnScrollSpeed:N,panOnScrollMode:I,zoomOnDoubleClick:O,panOnDrag:Z,defaultViewport:D,translateExtent:q,minZoom:L,maxZoom:g,preventScrolling:A,onSelectionContextMenu:P,noWheelClassName:z,noPanClassName:F,disableKeyboardA11y:E})=>{const Y=lt(Iw),$=Un(h),H=Un(v),X=H||Z,W=H||_,j=$||d&&X!==!0;return Sw({deleteKeyCode:a,multiSelectionKeyCode:b}),y.createElement(_w,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:o,elementsSelectable:C,zoomOnScroll:S,zoomOnPinch:R,panOnScroll:W,panOnScrollSpeed:N,panOnScrollMode:I,zoomOnDoubleClick:O,panOnDrag:!$&&X,defaultViewport:D,translateExtent:q,minZoom:L,maxZoom:g,zoomActivationKeyCode:k,preventScrolling:A,noWheelClassName:z,noPanClassName:F},y.createElement(lu,{onSelectionStart:x,onSelectionEnd:w,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:X,isSelecting:!!j,selectionMode:p},t,Y&&y.createElement(zw,{onSelectionContextMenu:P,noPanClassName:F,disableKeyboardA11y:E})))};pu.displayName="FlowRenderer";var $w=y.memo(pu);function Lw(t){return lt(y.useCallback(n=>t?Ul(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function Yw(t){const e={input:wn(t.input||Ql),default:wn(t.default||mo),output:wn(t.output||tu),group:wn(t.group||oi)},n={},r=Object.keys(t).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=wn(t[o]||mo),s),n);return{...e,...r}}const Bw=({x:t,y:e,width:n,height:r,origin:s})=>!n||!r?{x:t,y:e}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:t,y:e}:{x:t-n*s[0],y:e-r*s[1]},Fw=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),gu=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:i}=lt(Fw,pt),a=Lw(t.onlyRenderVisibleElements),c=y.useRef(),l=y.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(h=>{const d=h.map(p=>({id:p.target.getAttribute("data-id"),nodeElement:p.target,forceUpdate:!0}));o(d)});return c.current=u,u},[]);return y.useEffect(()=>()=>{var u;(u=c==null?void 0:c.current)==null||u.disconnect()},[]),y.createElement("div",{className:"react-flow__nodes",style:ii},a.map(u=>{var R,_,N;let h=u.type||"default";t.nodeTypes[h]||(i==null||i("003",vt.error003(h)),h="default");const d=t.nodeTypes[h]||t.nodeTypes.default,p=!!(u.draggable||e&&typeof u.draggable>"u"),x=!!(u.selectable||s&&typeof u.selectable>"u"),w=!!(u.connectable||n&&typeof u.connectable>"u"),b=!!(u.focusable||r&&typeof u.focusable>"u"),v=t.nodeExtent?jo(u.positionAbsolute,t.nodeExtent):u.positionAbsolute,k=(v==null?void 0:v.x)??0,C=(v==null?void 0:v.y)??0,S=Bw({x:k,y:C,width:u.width??0,height:u.height??0,origin:t.nodeOrigin});return y.createElement(d,{key:u.id,id:u.id,className:u.className,style:u.style,type:h,data:u.data,sourcePosition:u.sourcePosition||exports.Position.Bottom,targetPosition:u.targetPosition||exports.Position.Top,hidden:u.hidden,xPos:k,yPos:C,xPosOrigin:S.x,yPosOrigin:S.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!u.selected,isDraggable:p,isSelectable:x,isConnectable:w,isFocusable:b,resizeObserver:l,dragHandle:u.dragHandle,zIndex:((R=u[ct])==null?void 0:R.z)??0,isParent:!!((_=u[ct])!=null&&_.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!u.width&&!!u.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((N=u[ct])!=null&&N.handleBounds)})}))};gu.displayName="NodeRenderer";var qw=y.memo(gu);const Uw=(t,e,n)=>n===exports.Position.Left?t-e:n===exports.Position.Right?t+e:t,Zw=(t,e,n)=>n===exports.Position.Top?t-e:n===exports.Position.Bottom?t+e:t,Pa="react-flow__edgeupdater",ka=({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:i,type:a})=>y.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:i,className:St([Pa,`${Pa}-${a}`]),cx:Uw(e,r,t),cy:Zw(n,r,t),r,stroke:"transparent",fill:"transparent"}),Hw=()=>!0;var Me=t=>{const e=({id:n,className:r,type:s,data:o,onClick:i,onEdgeDoubleClick:a,selected:c,animated:l,label:u,labelStyle:h,labelShowBg:d,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:w,style:b,source:v,target:k,sourceX:C,sourceY:S,targetX:R,targetY:_,sourcePosition:N,targetPosition:I,elementsSelectable:O,hidden:Z,sourceHandleId:D,targetHandleId:q,onContextMenu:L,onMouseEnter:g,onMouseMove:A,onMouseLeave:P,edgeUpdaterRadius:z,onEdgeUpdate:F,onEdgeUpdateStart:E,onEdgeUpdateEnd:Y,markerEnd:$,markerStart:H,rfId:X,ariaLabel:W,isFocusable:j,isUpdatable:tt,pathOptions:et,interactionWidth:ot,disableKeyboardA11y:U})=>{const V=y.useRef(null),[K,B]=y.useState(!1),[it,J]=y.useState(!1),nt=ht(),at=y.useMemo(()=>`url('#${po(H,X)}')`,[H,X]),rt=y.useMemo(()=>`url('#${po($,X)}')`,[$,X]);if(Z)return null;const G=dt=>{var Rt;const{edges:_t,addSelectedEdges:se,unselectNodesAndEdges:oe,multiSelectionActive:ie}=nt.getState(),Lt=_t.find(ln=>ln.id===n);Lt&&(O&&(nt.setState({nodesSelectionActive:!1}),Lt.selected&&ie?(oe({nodes:[],edges:[Lt]}),(Rt=V.current)==null||Rt.blur()):se([n])),i&&i(dt,Lt))},wt=mn(n,nt.getState,a),ee=mn(n,nt.getState,L),an=mn(n,nt.getState,g),ve=mn(n,nt.getState,A),Se=mn(n,nt.getState,P),$t=(dt,_t)=>{if(dt.button!==0)return;const{edges:se,isValidConnection:oe}=nt.getState(),ie=_t?k:v,Lt=(_t?q:D)||null,Rt=_t?"target":"source",ln=oe||Hw,Ss=_t,un=se.find(ae=>ae.id===n);J(!0),E==null||E(dt,un,Rt);const bs=ae=>{J(!1),Y==null||Y(ae,un,Rt)};Wl({event:dt,handleId:Lt,nodeId:ie,onConnect:ae=>F==null?void 0:F(un,ae),isTarget:Ss,getState:nt.getState,setState:nt.setState,isValidConnection:ln,edgeUpdaterType:Rt,onEdgeUpdateEnd:bs})},be=dt=>$t(dt,!0),ne=dt=>$t(dt,!1),re=()=>B(!0),Te=()=>B(!1),Ee=!O&&!i,cn=dt=>{var _t;if(!U&&Ol.includes(dt.key)&&O){const{unselectNodesAndEdges:se,addSelectedEdges:oe,edges:ie}=nt.getState();dt.key==="Escape"?((_t=V.current)==null||_t.blur(),se({edges:[ie.find(Rt=>Rt.id===n)]})):oe([n])}};return y.createElement("g",{className:St(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:c,animated:l,inactive:Ee,updating:K}]),onClick:G,onDoubleClick:wt,onContextMenu:ee,onMouseEnter:an,onMouseMove:ve,onMouseLeave:Se,onKeyDown:j?cn:void 0,tabIndex:j?0:void 0,role:j?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":W===null?void 0:W||`Edge from ${v} to ${k}`,"aria-describedby":j?`${ru}-${X}`:void 0,ref:V},!it&&y.createElement(t,{id:n,source:v,target:k,selected:c,animated:l,label:u,labelStyle:h,labelShowBg:d,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:w,data:o,style:b,sourceX:C,sourceY:S,targetX:R,targetY:_,sourcePosition:N,targetPosition:I,sourceHandleId:D,targetHandleId:q,markerStart:at,markerEnd:rt,pathOptions:et,interactionWidth:ot}),tt&&y.createElement(y.Fragment,null,(tt==="source"||tt===!0)&&y.createElement(ka,{position:N,centerX:C,centerY:S,radius:z,onMouseDown:be,onMouseEnter:re,onMouseOut:Te,type:"source"}),(tt==="target"||tt===!0)&&y.createElement(ka,{position:I,centerX:R,centerY:_,radius:z,onMouseDown:ne,onMouseEnter:re,onMouseOut:Te,type:"target"})))};return e.displayName="EdgeWrapper",y.memo(e)};function Vw(t){const e={default:Me(t.default||es),straight:Me(t.bezier||ei),step:Me(t.step||ti),smoothstep:Me(t.step||xs),simplebezier:Me(t.simplebezier||Jo)},n={},r=Object.keys(t).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Me(t[o]||es),s),n);return{...e,...r}}function Ma(t,e,n=null){const r=((n==null?void 0:n.x)||0)+e.x,s=((n==null?void 0:n.y)||0)+e.y,o=(n==null?void 0:n.width)||e.width,i=(n==null?void 0:n.height)||e.height;switch(t){case exports.Position.Top:return{x:r+o/2,y:s};case exports.Position.Right:return{x:r+o,y:s+i/2};case exports.Position.Bottom:return{x:r+o/2,y:s+i};case exports.Position.Left:return{x:r,y:s+i/2}}}function Ra(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const Xw=(t,e,n,r,s,o)=>{const i=Ma(n,t,e),a=Ma(o,r,s);return{sourceX:i.x,sourceY:i.y,targetX:a.x,targetY:a.y}};function Ww({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:i,height:a,transform:c}){const l={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x+n,e.x+s),y2:Math.max(t.y+r,e.y+o)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=Qo({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:i/c[2],height:a/c[2]}),h=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),d=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(h*d)>0}function Aa(t){var r,s,o,i,a;const e=((r=t==null?void 0:t[ct])==null?void 0:r.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&typeof((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=t==null?void 0:t.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=t==null?void 0:t.positionAbsolute)==null?void 0:i.x)||0,y:((a=t==null?void 0:t.positionAbsolute)==null?void 0:a.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const Gw=[{level:0,isMaxLevel:!0,edges:[]}];function Kw(t,e,n=!1){let r=-1;const s=t.reduce((i,a)=>{var u,h;const c=Tt(a.zIndex);let l=c?a.zIndex:0;if(n){const d=e.get(a.target),p=e.get(a.source),x=a.selected||(d==null?void 0:d.selected)||(p==null?void 0:p.selected),w=Math.max(((u=p==null?void 0:p[ct])==null?void 0:u.z)||0,((h=d==null?void 0:d[ct])==null?void 0:h.z)||0,1e3);l=(c?a.zIndex:0)+(x?w:0)}return i[l]?i[l].push(a):i[l]=[a],r=l>r?l:r,i},{}),o=Object.entries(s).map(([i,a])=>{const c=+i;return{edges:a,level:c,isMaxLevel:c===r}});return o.length===0?Gw:o}function jw(t,e,n){const r=lt(y.useCallback(s=>t?s.edges.filter(o=>{const i=e.get(o.source),a=e.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&Ww({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:a.width,targetHeight:a.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[t,e]));return Kw(r,e,n)}const Qw=({color:t="none",strokeWidth:e=1})=>y.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Jw=({color:t="none",strokeWidth:e=1})=>y.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Na={[ts.Arrow]:Qw,[ts.ArrowClosed]:Jw};function tx(t){const e=ht();return y.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(Na,t)?Na[t]:((o=(s=e.getState()).onError)==null||o.call(s,"009",vt.error009(t)),null)},[t])}const ex=({id:t,type:e,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const c=tx(e);return c?y.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0"},y.createElement(c,{color:n,strokeWidth:i})):null},nx=({defaultColor:t,rfId:e})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const a=po(i,e);r.includes(a)||(s.push({id:a,color:i.color||t,...i}),r.push(a))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},mu=({defaultColor:t,rfId:e})=>{const n=lt(y.useCallback(nx({defaultColor:t,rfId:e}),[t,e]),(r,s)=>!(r.length!==s.length||r.some((o,i)=>o.id!==s[i].id)));return y.createElement("defs",null,n.map(r=>y.createElement(ex,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};mu.displayName="MarkerDefinitions";var rx=y.memo(mu);const sx=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),yu=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeUpdate:i,onEdgeContextMenu:a,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:h,edgeUpdaterRadius:d,onEdgeDoubleClick:p,onEdgeUpdateStart:x,onEdgeUpdateEnd:w,children:b,disableKeyboardA11y:v})=>{const{edgesFocusable:k,edgesUpdatable:C,elementsSelectable:S,width:R,height:_,connectionMode:N,nodeInternals:I,onError:O}=lt(sx,pt),Z=jw(e,I,n);return R?y.createElement(y.Fragment,null,Z.map(({level:D,edges:q,isMaxLevel:L})=>y.createElement("svg",{key:D,style:{zIndex:D},width:R,height:_,className:"react-flow__edges react-flow__container"},L&&y.createElement(rx,{defaultColor:t,rfId:r}),y.createElement("g",null,q.map(g=>{const[A,P,z]=Aa(I.get(g.source)),[F,E,Y]=Aa(I.get(g.target));if(!z||!Y)return null;let $=g.type||"default";s[$]||(O==null||O("011",vt.error011($)),$="default");const H=s[$]||s.default,X=N===exports.ConnectionMode.Strict?E.target:(E.target??[]).concat(E.source??[]),W=Ra(P.source,g.sourceHandle),j=Ra(X,g.targetHandle),tt=(W==null?void 0:W.position)||exports.Position.Bottom,et=(j==null?void 0:j.position)||exports.Position.Top,ot=!!(g.focusable||k&&typeof g.focusable>"u"),U=typeof i<"u"&&(g.updatable||C&&typeof g.updatable>"u");if(!W||!j)return O==null||O("008",vt.error008(W,g)),null;const{sourceX:V,sourceY:K,targetX:B,targetY:it}=Xw(A,W,tt,F,j,et);return y.createElement(H,{key:g.id,id:g.id,className:St([g.className,o]),type:$,data:g.data,selected:!!g.selected,animated:!!g.animated,hidden:!!g.hidden,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,style:g.style,source:g.source,target:g.target,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerEnd:g.markerEnd,markerStart:g.markerStart,sourceX:V,sourceY:K,targetX:B,targetY:it,sourcePosition:tt,targetPosition:et,elementsSelectable:S,onEdgeUpdate:i,onContextMenu:a,onMouseEnter:c,onMouseMove:l,onMouseLeave:u,onClick:h,edgeUpdaterRadius:d,onEdgeDoubleClick:p,onEdgeUpdateStart:x,onEdgeUpdateEnd:w,rfId:r,ariaLabel:g.ariaLabel,isFocusable:ot,isUpdatable:U,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth,disableKeyboardA11y:v})})))),b):null};yu.displayName="EdgeRenderer";var ox=y.memo(yu);const ix=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function ax({children:t}){const e=lt(ix);return y.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function cx(t){const e=vs(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const lx={[exports.Position.Left]:exports.Position.Right,[exports.Position.Right]:exports.Position.Left,[exports.Position.Top]:exports.Position.Bottom,[exports.Position.Bottom]:exports.Position.Top},wu=({nodeId:t,handleType:e,style:n,type:r=Gt.Bezier,CustomComponent:s,connectionStatus:o})=>{var _,N,I;const{fromNode:i,handleId:a,toX:c,toY:l,connectionMode:u}=lt(y.useCallback(O=>({fromNode:O.nodeInternals.get(t),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[t]),pt),h=(_=i==null?void 0:i[ct])==null?void 0:_.handleBounds;let d=h==null?void 0:h[e];if(u===exports.ConnectionMode.Loose&&(d=d||(h==null?void 0:h[e==="source"?"target":"source"])),!i||!d)return null;const p=a?d.find(O=>O.id===a):d[0],x=p?p.x+p.width/2:(i.width??0)/2,w=p?p.y+p.height/2:i.height??0,b=(((N=i.positionAbsolute)==null?void 0:N.x)??0)+x,v=(((I=i.positionAbsolute)==null?void 0:I.y)??0)+w,k=p==null?void 0:p.position,C=k?lx[k]:null;if(!k||!C)return null;if(s)return y.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:p,fromX:b,fromY:v,toX:c,toY:l,fromPosition:k,toPosition:C,connectionStatus:o});let S="";const R={sourceX:b,sourceY:v,sourcePosition:k,targetX:c,targetY:l,targetPosition:C};return r===Gt.Bezier?[S]=Yl(R):r===Gt.Step?[S]=fo({...R,borderRadius:0}):r===Gt.SmoothStep?[S]=fo(R):r===Gt.SimpleBezier?[S]=Ll(R):S=`M${b},${v} ${c},${l}`,y.createElement("path",{d:S,fill:"none",className:"react-flow__connection-path",style:n})};wu.displayName="ConnectionLine";const ux=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function hx({containerStyle:t,style:e,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:i,width:a,height:c,connectionStatus:l}=lt(ux,pt);return!(s&&o&&a&&i)?null:y.createElement("svg",{style:t,width:a,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},y.createElement("g",{className:St(["react-flow__connection",l])},y.createElement(wu,{nodeId:s,handleType:o,style:e,type:n,CustomComponent:r,connectionStatus:l})))}function Da(t,e){const n=y.useRef(null),r=ht();return y.useMemo(()=>{var o,i;if(process.env.NODE_ENV==="development"){const a=Object.keys(t);pt(n.current,a)&&((i=(o=r.getState()).onError)==null||i.call(o,"002",vt.error002())),n.current=a}return e(t)},[t])}const xu=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:x,onSelectionStart:w,onSelectionEnd:b,connectionLineType:v,connectionLineStyle:k,connectionLineComponent:C,connectionLineContainerStyle:S,selectionKeyCode:R,selectionOnDrag:_,selectionMode:N,multiSelectionKeyCode:I,panActivationKeyCode:O,zoomActivationKeyCode:Z,deleteKeyCode:D,onlyRenderVisibleElements:q,elementsSelectable:L,selectNodesOnDrag:g,defaultViewport:A,translateExtent:P,minZoom:z,maxZoom:F,preventScrolling:E,defaultMarkerColor:Y,zoomOnScroll:$,zoomOnPinch:H,panOnScroll:X,panOnScrollSpeed:W,panOnScrollMode:j,zoomOnDoubleClick:tt,panOnDrag:et,onPaneClick:ot,onPaneMouseEnter:U,onPaneMouseMove:V,onPaneMouseLeave:K,onPaneScroll:B,onPaneContextMenu:it,onEdgeUpdate:J,onEdgeContextMenu:nt,onEdgeMouseEnter:at,onEdgeMouseMove:rt,onEdgeMouseLeave:G,edgeUpdaterRadius:wt,onEdgeUpdateStart:ee,onEdgeUpdateEnd:an,noDragClassName:ve,noWheelClassName:Se,noPanClassName:$t,elevateEdgesOnSelect:be,disableKeyboardA11y:ne,nodeOrigin:re,nodeExtent:Te,rfId:Ee})=>{const cn=Da(t,Yw),dt=Da(e,Vw);return cx(o),y.createElement($w,{onPaneClick:ot,onPaneMouseEnter:U,onPaneMouseMove:V,onPaneMouseLeave:K,onPaneContextMenu:it,onPaneScroll:B,deleteKeyCode:D,selectionKeyCode:R,selectionOnDrag:_,selectionMode:N,onSelectionStart:w,onSelectionEnd:b,multiSelectionKeyCode:I,panActivationKeyCode:O,zoomActivationKeyCode:Z,elementsSelectable:L,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:$,zoomOnPinch:H,zoomOnDoubleClick:tt,panOnScroll:X,panOnScrollSpeed:W,panOnScrollMode:j,panOnDrag:et,defaultViewport:A,translateExtent:P,minZoom:z,maxZoom:F,onSelectionContextMenu:x,preventScrolling:E,noDragClassName:ve,noWheelClassName:Se,noPanClassName:$t,disableKeyboardA11y:ne},y.createElement(ax,null,y.createElement(ox,{edgeTypes:dt,onEdgeClick:a,onEdgeDoubleClick:l,onEdgeUpdate:J,onlyRenderVisibleElements:q,onEdgeContextMenu:nt,onEdgeMouseEnter:at,onEdgeMouseMove:rt,onEdgeMouseLeave:G,onEdgeUpdateStart:ee,onEdgeUpdateEnd:an,edgeUpdaterRadius:wt,defaultMarkerColor:Y,noPanClassName:$t,elevateEdgesOnSelect:!!be,disableKeyboardA11y:ne,rfId:Ee},y.createElement(hx,{style:k,type:v,component:C,containerStyle:S})),y.createElement("div",{className:"react-flow__edgelabel-renderer"}),y.createElement(qw,{nodeTypes:cn,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,selectNodesOnDrag:g,onlyRenderVisibleElements:q,noPanClassName:$t,noDragClassName:ve,disableKeyboardA11y:ne,nodeOrigin:re,nodeExtent:Te,rfId:Ee})))};xu.displayName="GraphView";var fx=y.memo(xu);const wo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Xt={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:wo,nodeExtent:wo,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:exports.ConnectionMode.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Qr,isValidConnection:void 0},dx=()=>Cg((t,e)=>({...Xt,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=e();t({nodeInternals:Fs(n,r,s,o)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=e();t({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",i=s?Fs(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:i,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:a,domNode:c,nodeOrigin:l}=e(),u=c==null?void 0:c.querySelector(".react-flow__viewport");if(!u)return;const h=window.getComputedStyle(u),{m22:d}=new window.DOMMatrixReadOnly(h.transform),p=n.reduce((w,b)=>{const v=s.get(b.id);if(v!=null&&v.hidden)s.set(v.id,{...v,[ct]:{...v[ct],handleBounds:void 0}});else if(v){const k=Ko(b.nodeElement);!!(k.width&&k.height&&(v.width!==k.width||v.height!==k.height||b.forceUpdate))&&(s.set(v.id,{...v,[ct]:{...v[ct],handleBounds:{source:Ca(".source",b.nodeElement,d,l),target:Ca(".target",b.nodeElement,d,l)}},...k}),w.push({id:v.id,type:"dimensions",dimensions:k}))}return w},[]);ou(s,l);const x=i||o&&!i&&iu(e,{initial:!0,...a});t({nodeInternals:new Map(s),fitViewOnInitDone:x}),(p==null?void 0:p.length)>0&&(r==null||r(p))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=e(),i=n.map(a=>{const c={id:a.id,type:"position",dragging:s};return r&&(c.positionAbsolute=a.positionAbsolute,c.position=a.position),c});o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:i,getNodes:a,elevateNodesOnSelect:c}=e();if(n!=null&&n.length){if(o){const l=cu(n,a()),u=Fs(l,s,i,c);t({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=e();let i,a=null;r?i=n.map(c=>Wt(c,!0)):(i=Ne(o(),n),a=Ne(s,[])),ur({changedNodes:i,changedEdges:a,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=e();let i,a=null;r?i=n.map(c=>Wt(c,!0)):(i=Ne(s,n),a=Ne(o(),[])),ur({changedNodes:a,changedEdges:i,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=e(),i=n||o(),a=r||s,c=i.map(u=>(u.selected=!1,Wt(u.id,!1))),l=a.map(u=>Wt(u.id,!1));ur({changedNodes:c,changedEdges:l,get:e,set:t})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=e();r==null||r.scaleExtent([n,s]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=e();r==null||r.scaleExtent([s,n]),t({maxZoom:n})},setTranslateExtent:n=>{var r;(r=e().d3Zoom)==null||r.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=e(),o=r().filter(a=>a.selected).map(a=>Wt(a.id,!1)),i=n.filter(a=>a.selected).map(a=>Wt(a.id,!1));ur({changedNodes:o,changedEdges:i,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:r}=e();r.forEach(s=>{s.positionAbsolute=jo(s.position,n)}),t({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:i,d3Selection:a,translateExtent:c}=e();if(!i||!a||!n.x&&!n.y)return!1;const l=Kt.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[s,o]],h=i==null?void 0:i.constrain()(l,u,c);return i.transform(a,h),r[0]!==h.x||r[1]!==h.y||r[2]!==h.k},cancelConnection:()=>t({connectionNodeId:Xt.connectionNodeId,connectionHandleId:Xt.connectionHandleId,connectionHandleType:Xt.connectionHandleType,connectionStatus:Xt.connectionStatus,connectionStartHandle:Xt.connectionStartHandle,connectionEndHandle:Xt.connectionEndHandle}),reset:()=>t({...Xt})}),Object.is),ai=({children:t})=>{const e=y.useRef(null);return e.current||(e.current=dx()),y.createElement(D0,{value:e.current},t)};ai.displayName="ReactFlowProvider";const vu=({children:t})=>y.useContext(ws)?y.createElement(y.Fragment,null,t):y.createElement(ai,null,t);vu.displayName="ReactFlowWrapper";const px={input:Ql,default:mo,output:tu,group:oi},gx={default:es,straight:ei,step:ti,smoothstep:xs,simplebezier:Jo},mx=[0,0],yx=[15,15],wx={x:0,y:0,zoom:1},xx={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Su=y.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=px,edgeTypes:i=gx,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:h,onMoveEnd:d,onConnect:p,onConnectStart:x,onConnectEnd:w,onClickConnectStart:b,onClickConnectEnd:v,onNodeMouseEnter:k,onNodeMouseMove:C,onNodeMouseLeave:S,onNodeContextMenu:R,onNodeDoubleClick:_,onNodeDragStart:N,onNodeDrag:I,onNodeDragStop:O,onNodesDelete:Z,onEdgesDelete:D,onSelectionChange:q,onSelectionDragStart:L,onSelectionDrag:g,onSelectionDragStop:A,onSelectionContextMenu:P,onSelectionStart:z,onSelectionEnd:F,connectionMode:E=exports.ConnectionMode.Strict,connectionLineType:Y=Gt.Bezier,connectionLineStyle:$,connectionLineComponent:H,connectionLineContainerStyle:X,deleteKeyCode:W="Backspace",selectionKeyCode:j="Shift",selectionOnDrag:tt=!1,selectionMode:et=exports.SelectionMode.Full,panActivationKeyCode:ot="Space",multiSelectionKeyCode:U=Jr()?"Meta":"Control",zoomActivationKeyCode:V=Jr()?"Meta":"Control",snapToGrid:K=!1,snapGrid:B=yx,onlyRenderVisibleElements:it=!1,selectNodesOnDrag:J=!0,nodesDraggable:nt,nodesConnectable:at,nodesFocusable:rt,nodeOrigin:G=mx,edgesFocusable:wt,edgesUpdatable:ee,elementsSelectable:an,defaultViewport:ve=wx,minZoom:Se=.5,maxZoom:$t=2,translateExtent:be=wo,preventScrolling:ne=!0,nodeExtent:re,defaultMarkerColor:Te="#b1b1b7",zoomOnScroll:Ee=!0,zoomOnPinch:cn=!0,panOnScroll:dt=!1,panOnScrollSpeed:_t=.5,panOnScrollMode:se=he.Free,zoomOnDoubleClick:oe=!0,panOnDrag:ie=!0,onPaneClick:Lt,onPaneMouseEnter:Rt,onPaneMouseMove:ln,onPaneMouseLeave:Ss,onPaneScroll:un,onPaneContextMenu:bs,children:hi,onEdgeUpdate:ae,onEdgeContextMenu:Ou,onEdgeDoubleClick:zu,onEdgeMouseEnter:Iu,onEdgeMouseMove:$u,onEdgeMouseLeave:Lu,onEdgeUpdateStart:Yu,onEdgeUpdateEnd:Bu,edgeUpdaterRadius:Fu=10,onNodesChange:qu,onEdgesChange:Uu,noDragClassName:Zu="nodrag",noWheelClassName:Hu="nowheel",noPanClassName:fi="nopan",fitView:Vu=!1,fitViewOptions:Xu,connectOnClick:Wu=!0,attributionPosition:Gu,proOptions:Ku,defaultEdgeOptions:ju,elevateNodesOnSelect:Qu=!0,elevateEdgesOnSelect:Ju=!1,disableKeyboardA11y:di=!1,autoPanOnConnect:th=!0,autoPanOnNodeDrag:eh=!0,connectionRadius:nh=20,isValidConnection:rh,onError:sh,style:oh,id:pi,nodeDragThreshold:ih,...ah},ch)=>{const Ts=pi||"1";return y.createElement("div",{...ah,style:{...oh,...xx},ref:ch,className:St(["react-flow",s]),"data-testid":"rf__wrapper",id:pi},y.createElement(vu,null,y.createElement(fx,{onInit:l,onMove:u,onMoveStart:h,onMoveEnd:d,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:C,onNodeMouseLeave:S,onNodeContextMenu:R,onNodeDoubleClick:_,nodeTypes:o,edgeTypes:i,connectionLineType:Y,connectionLineStyle:$,connectionLineComponent:H,connectionLineContainerStyle:X,selectionKeyCode:j,selectionOnDrag:tt,selectionMode:et,deleteKeyCode:W,multiSelectionKeyCode:U,panActivationKeyCode:ot,zoomActivationKeyCode:V,onlyRenderVisibleElements:it,selectNodesOnDrag:J,defaultViewport:ve,translateExtent:be,minZoom:Se,maxZoom:$t,preventScrolling:ne,zoomOnScroll:Ee,zoomOnPinch:cn,zoomOnDoubleClick:oe,panOnScroll:dt,panOnScrollSpeed:_t,panOnScrollMode:se,panOnDrag:ie,onPaneClick:Lt,onPaneMouseEnter:Rt,onPaneMouseMove:ln,onPaneMouseLeave:Ss,onPaneScroll:un,onPaneContextMenu:bs,onSelectionContextMenu:P,onSelectionStart:z,onSelectionEnd:F,onEdgeUpdate:ae,onEdgeContextMenu:Ou,onEdgeDoubleClick:zu,onEdgeMouseEnter:Iu,onEdgeMouseMove:$u,onEdgeMouseLeave:Lu,onEdgeUpdateStart:Yu,onEdgeUpdateEnd:Bu,edgeUpdaterRadius:Fu,defaultMarkerColor:Te,noDragClassName:Zu,noWheelClassName:Hu,noPanClassName:fi,elevateEdgesOnSelect:Ju,rfId:Ts,disableKeyboardA11y:di,nodeOrigin:G,nodeExtent:re}),y.createElement(lw,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:x,onConnectEnd:w,onClickConnectStart:b,onClickConnectEnd:v,nodesDraggable:nt,nodesConnectable:at,nodesFocusable:rt,edgesFocusable:wt,edgesUpdatable:ee,elementsSelectable:an,elevateNodesOnSelect:Qu,minZoom:Se,maxZoom:$t,nodeExtent:re,onNodesChange:qu,onEdgesChange:Uu,snapToGrid:K,snapGrid:B,connectionMode:E,translateExtent:be,connectOnClick:Wu,defaultEdgeOptions:ju,fitView:Vu,fitViewOptions:Xu,onNodesDelete:Z,onEdgesDelete:D,onNodeDragStart:N,onNodeDrag:I,onNodeDragStop:O,onSelectionDrag:g,onSelectionDragStart:L,onSelectionDragStop:A,noPanClassName:fi,nodeOrigin:G,rfId:Ts,autoPanOnConnect:th,autoPanOnNodeDrag:eh,onError:sh,connectionRadius:nh,isValidConnection:rh,nodeDragThreshold:ih}),y.createElement(aw,{onSelectionChange:q}),hi,y.createElement(I0,{proOptions:Ku,position:Gu}),y.createElement(pw,{rfId:Ts,disableKeyboardA11y:di})))});Su.displayName="ReactFlow";function vx(){const t=ht();return y.useCallback(e=>{const{domNode:n,updateNodeDimensions:r}=t.getState(),o=(Array.isArray(e)?e:[e]).reduce((i,a)=>{const c=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);return c&&i.push({id:a,nodeElement:c,forceUpdate:!0}),i},[]);requestAnimationFrame(()=>r(o))},[])}function Sx({onStart:t,onChange:e,onEnd:n}){const r=ht();y.useEffect(()=>{r.setState({onViewportChangeStart:t})},[t]),y.useEffect(()=>{r.setState({onViewportChange:e})},[e]),y.useEffect(()=>{r.setState({onViewportChangeEnd:n})},[n])}const bu=t=>t.map(e=>({...e,id:e.key,type:"custom",data:{}})),Tu=t=>t.map(({segments:e,color:n,...r})=>({...r,id:r.key,data:{segments:e,color:n}})),bx=t=>t.map(e=>({key:e.id,selected:e.selected,...e})),Tx=(t,e)=>t.map(n=>{var r,s;return n.data==null&&(n.data={segments:[],color:e}),{key:n.id,segments:((r=n.data)==null?void 0:r.segments)??[],selected:n.selected??!1,color:((s=n.data)==null?void 0:s.color)??e,...n}}),Ex=t=>({...t.position,zoom:t.zoom}),Eu=t=>({position:f.q.construct(t),zoom:t.zoom}),_x=(t,e)=>bx(e(bu(t))),Cx=(t,e,n)=>Tx(e(Tu(t)),n),ci=M.z.object({position:f.q.xy,zoom:M.z.number(),region:f.To.box,clearOverScan:f.q.crudeZ.optional().default(10)}),Hs=["upper2d","lower2d"],_u=()=>{const t=vs();return y.useRef(Eu(t.getViewport())).current},ze=class ze extends T.Composite{constructor(){super(...arguments);m(this,"eraser",new ds);m(this,"schema",ze.stateZ)}async afterUpdate(){this.internal.renderCtx=gt.use(this.ctx),this.internal.addStatus=T.useAggregate(this.ctx),yt.control(this.ctx,()=>this.requestRender("low")),this.requestRender("high")}async afterDelete(){this.requestRender("high")}async render(){if(this.deleted)return;const{renderCtx:n,addStatus:r}=this.internal,{zoom:s,position:o}=this.state,i=f.To.construct(this.state.region),a=n.scissor(i,f.q.ZERO,Hs),c=f.k.XY.magnify(f.q.construct(s)).translate(f.To.topLeft(i)).translate(o);try{await Promise.all(this.children.map(async u=>await u.render({viewportScale:c})))}catch(u){r({variant:"error",message:u.message})}finally{a()}const l=f.To.copy(this.state.region);return async()=>{this.internal.renderCtx.erase(l,this.state.clearOverScan,...Hs)}}requestRender(n){const{renderCtx:r}=this.internal;r.loop.set({key:`${ze.TYPE}-${this.key}`,render:async()=>await this.render(),priority:n,canvases:Hs})}};m(ze,"TYPE","Diagram"),m(ze,"stateZ",ci);let en=ze;const Cu={[en.TYPE]:en},Px=Object.freeze(Object.defineProperty({__proto__:null,Diagram:en,REGISTRY:Cu,diagramStateZ:ci,useInitialViewport:_u},Symbol.toStringTag,{value:"Module"})),Pu=M.z.object({region:f.To.box,enabled:M.z.boolean().optional().default(!1)});class ns extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Pu);m(this,"eraser",new ds)}async afterUpdate(){this.deleted||(this.internal.render=gt.use(this.ctx),await this.internal.render.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:["gl","lower2d","upper2d"]}))}async afterDelete(){await this.internal.render.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:["gl","lower2d","upper2d"]})}async render(){this.deleted||!this.state.enabled||this.internal.render.erase(this.state.region,f.q.construct(0),"gl","lower2d","upper2d")}}m(ns,"TYPE","eraser");const kx={[ns.TYPE]:ns},li=M.z.object({position:f.q.xy.or(M.z.null()),textColor:f.Color.z.optional().default(f.ZERO),backgroundColor:f.Color.z.optional().default(f.ZERO),borderColor:f.Color.z.optional().default(f.ZERO),ruleColor:f.Color.z.optional().default(f.ZERO),ruleStrokeWidth:M.z.number().optional().default(1),ruleStrokeDash:M.z.number().default(0)});class nn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",li)}async afterUpdate(){const n=T.use(this.ctx);this.state.textColor.isZero&&(this.state.textColor=n.colors.text),this.state.backgroundColor.isZero&&(this.state.backgroundColor=n.colors.gray.l1),this.state.borderColor.isZero&&(this.state.borderColor=n.colors.border),this.state.ruleColor.isZero&&(this.state.ruleColor=n.colors.gray.l5),this.internal.dotColor=n.colors.text,this.internal.dotColorContrast=n.colors.textInverted,this.internal.render=gt.use(this.ctx),this.internal.draw=new Jn(this.internal.render.upper2d,n),yt.requestRender(this.ctx,Jt)}async afterDelete(){yt.requestRender(this.ctx,Jt)}async render(n){if(this.deleted||this.state.position==null)return;const{region:r}=n,s=f.k.XY.scale(f.To.DECIMAL).scale(r),o=f.k.XY.scale(r).scale(f.To.DECIMAL),i=await n.findByXDecimal(o.x.pos(this.state.position.x)),a=i.filter(x=>f.q.isFinite(x.value)),{draw:c}=this.internal,l=a.reduce((x,w)=>x+w.position.x,0)/a.length,u=new T.m(a.reduce((x,w)=>x+w.value.x,0)/a.length),h=s.x.pos(l);if(!f.C.contains(f.To.xBounds(r),h))return;c.rule({stroke:this.state.ruleColor,lineWidth:this.state.ruleStrokeWidth,lineDash:this.state.ruleStrokeDash,direction:"y",region:r,position:h}),a.forEach(x=>{const w=s.pos(x.position);c.circle({fill:x.color.setAlpha(.5),radius:8,position:w}),c.circle({fill:x.color.setAlpha(.8),radius:5,position:w}),c.circle({fill:x.color.pickByContrast(this.internal.dotColor,this.internal.dotColorContrast),radius:2,position:w})});const d=i.map(x=>`${x.label??""}: ${x.value.y.toFixed(2)}`);d.unshift(`Time: ${u.fString("preciseDate","local")}`);const p=o.pos(this.state.position);c.textContainer({text:d,backgroundColor:this.state.backgroundColor,borderColor:this.state.borderColor,position:this.state.position,direction:"y",level:"small",spacing:.5,offset:{x:12,y:12},root:{x:p.x>.8?"right":"left",y:p.y>.8?"top":"bottom"}})}}m(nn,"TYPE","tooltip");const ku={[nn.TYPE]:nn},Mx=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:ku,Tooltip:nn,tooltipStateZ:li},Symbol.toStringTag,{value:"Module"})),ui=M.z.object({one:f.q.xy.nullable(),two:f.q.xy.nullable(),hover:f.q.xy.nullable(),color:M.z.union([f.Color.z,M.z.object({verticalLine:f.Color.z.optional().default(f.ZERO),horizontalLine:f.Color.z.optional().default(f.ZERO),obliqueLine:f.Color.z.optional().default(f.ZERO)})]).optional().default(f.ZERO),strokeWidth:M.z.number().optional().default(1),strokeDash:M.z.number().optional().default(2)});class rn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",ui)}async afterUpdate(){const n=gt.use(this.ctx);this.internal.theme=T.use(this.ctx),this.internal.render=n,this.internal.draw=new Jn(n.upper2d,this.internal.theme),yt.requestRender(this.ctx,Jt)}async afterDelete(){yt.requestRender(this.ctx,zt)}get verticalLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.verticalLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.verticalLine}get horizontalLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.horizontalLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.horizontalLine}get obliqueLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.obliqueLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.obliqueLine}async find(n){const{one:r,two:s}=this.state;if(r==null||s==null)return null;const{one:o,two:i}=this.prevState,{dataOne:a,dataTwo:c}=this.internal;if(o!=null&&f.q.equals(r,o)&&i!=null&&f.q.equals(s,i)&&a!=null&&c!=null){const[b,v]=[await n.findByXValue(a.x),await n.findByXValue(c.x)];return b.length===0||v.length===0?null:[b.sort((k,C)=>f.q.distance(a,k.value)-f.q.distance(a,C.value))[0],v.sort((k,C)=>f.q.distance(c,k.value)-f.q.distance(c,C.value))[0]]}const l=f.k.XY.scale(n.region).scale(f.To.DECIMAL),[u,h]=[l.pos(r),l.pos(s)],[d,p]=[await n.findByXDecimal(u.x),await n.findByXDecimal(h.x)];if(d.length===0||p.length===0)return null;const[x,w]=[d.sort((b,v)=>f.q.distance(u,b.position)-f.q.distance(u,v.position))[0],p.sort((b,v)=>f.q.distance(h,b.position)-f.q.distance(h,v.position))[0]];return this.internal.dataOne=x.value,this.internal.dataTwo=w.value,[x,w]}async renderHover(n){if(this.state.hover==null)return;const r=this.state.hover,s=f.k.XY.scale(n.region).scale(f.To.DECIMAL),o=s.pos(r),i=await n.findByXDecimal(s.pos(r).x);if(i.length===0)return;const a=i.sort((l,u)=>f.q.distance(o,l.position)-f.q.distance(o,u.position))[0],{draw:c}=this.internal;c.circle({fill:a.color.setAlpha(.5),radius:9,position:s.reverse().pos(a.position)})}async render(n){if(this.deleted)return;await this.renderHover(n);const r=await this.find(n);if(r==null)return;const[s,o]=r,{draw:i}=this.internal,{strokeDash:a,strokeWidth:c}=this.state,l=f.k.XY.scale(f.To.DECIMAL).scale(n.region),u=l.pos(s.position),h=l.pos(o.position),d=new T.w(Math.abs(s.value.x-o.value.x)),p=Math.abs(s.value.y-o.value.y),x=p/d.seconds;i.line({start:f.q.construct(u.x,u.y),end:f.q.construct(u.x,h.y),stroke:this.verticalLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[`${p.toFixed(2)} ${s.units??""}`],direction:"x",position:f.q.construct(u.x,(u.y+h.y)/2),level:"small"}),i.line({start:f.q.construct(u.x,h.y),end:f.q.construct(h.x,h.y),stroke:this.horizontalLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[d.truncate(T.w.MILLISECOND).toString()],direction:"x",position:f.q.construct((u.x+h.x)/2,h.y),level:"small"}),i.line({start:f.q.construct(u.x,u.y),end:f.q.construct(h.x,h.y),stroke:this.obliqueLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[`${x.toFixed(2)} ${s.units??""} / S`],direction:"x",position:f.q.construct((u.x+h.x)/2,(u.y+h.y)/2),level:"small"}),i.circle({fill:s.color.setAlpha(.5),radius:8,position:u}),i.circle({fill:s.color.setAlpha(.8),radius:5,position:u}),i.circle({fill:new f.Color("#ffffff"),radius:2,position:u}),i.circle({fill:o.color.setAlpha(.5),radius:8,position:h}),i.circle({fill:o.color.setAlpha(.8),radius:5,position:h}),i.circle({fill:new f.Color("#ffffff"),radius:2,position:h})}}m(rn,"TYPE","measure");const Mu={[rn.TYPE]:rn},Rx=Object.freeze(Object.defineProperty({__proto__:null,Measure:rn,REGISTRY:Mu,measureStateZ:ui},Symbol.toStringTag,{value:"Module"})),Ru=M.z.object({triggered:M.z.boolean(),enabled:M.z.boolean(),sink:ls.optional().default(as),source:Za.optional().default(La)});class rs extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Ru)}async afterUpdate(){var c;this.internal.addStatus=T.useOptionalAggregate(this.ctx);const{sink:n,source:r,triggered:s,enabled:o}=this.state,{triggered:i}=this.prevState,{internal:a}=this;this.internal.source=await Qt(this.ctx,r,this.internal.source),a.sink=await is(this.ctx,n,a.sink),s&&!i&&await a.sink.set(!o),await this.updateEnabledState(),(c=a.stopListening)==null||c.call(a),a.stopListening=a.source.onChange(()=>{this.updateEnabledState().catch(this.reportError.bind(this))})}reportError(n){this.internal.addStatus({key:this.key,variant:"error",message:`Failed to update Toggle: ${n.message}`})}async updateEnabledState(){const n=await this.internal.source.value();n!==this.state.enabled&&this.setState(r=>({...r,enabled:n,triggered:!1}))}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}async render(){}}m(rs,"TYPE","Toggle");const Ax={[rs.TYPE]:rs},Nx=M.z.object({box:f.To.box,telem:Va.optional().default(Ya),font:T.levelZ.optional().default("p"),color:f.Color.z.optional().default(f.ZERO),precision:M.z.number().optional().default(2),minWidth:M.z.number().optional().default(60),width:M.z.number().optional()}),Cn=class Cn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Cn.z)}async afterUpdate(){const{internal:n}=this;n.render=gt.use(this.ctx),n.theme=T.use(this.ctx),this.state.color.isZero?this.internal.textColor=n.theme.colors.gray.l8:n.textColor=this.state.color,n.telem=await Qt(this.ctx,this.state.telem,n.telem),this.internal.telem.onChange(()=>this.requestRender()),this.internal.requestRender=yt.useOptionalRequest(this.ctx),this.requestRender()}async afterDelete(){var o;const{requestRender:n,telem:r,render:s}=this.internal;await((o=r.cleanup)==null?void 0:o.call(r)),n==null?s.erase(f.To.construct(this.state.box),f.q.ZERO,"upper2d"):n(zt)}requestRender(){const{requestRender:n}=this.internal;n!=null?n(zt):this.render({})}async render({viewportScale:n=f.k.XY.IDENTITY}){const{render:r,telem:s,theme:o}=this.internal,i=f.To.construct(this.state.box);if(f.To.areaIsZero(i))return;const a=r.upper2d.applyScale(n),c=await s.value();a.font=this.state.font;const l=o.typography[this.state.font].size*o.sizes.base,u=T.dimensions(c,T.fontString(this.internal.theme,this.state.font),a).width;this.internal.requestRender==null&&r.erase(f.To.construct(this.prevState.box));const h=u+o.sizes.base*4;(this.state.width==null||this.state.width<h||this.state.minWidth>h&&this.state.width!==this.state.minWidth)&&this.setState(p=>({...p,width:Math.max(h,p.minWidth)}));const d=f.q.couple(f.q.translate(f.To.topLeft(i),{x:0,y:f.To.height(i)/2},{y:l/2,x:12}));a.fillStyle=this.internal.textColor.hex,a.fillText(c,...d)}};m(Cn,"TYPE","value"),m(Cn,"z",Nx);let sn=Cn;const Au={[sn.TYPE]:sn},Dx=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:Au,Value:sn},Symbol.toStringTag,{value:"Module"})),Ox=T.Qd.payloadZ.extend({viewport:f.C.bounds}),Nu=M.z.object({cursor:f.q.xy.or(M.z.null()),hovered:Ox.or(M.z.null()),count:M.z.number()});class Zn extends T.Leaf{constructor(){super(...arguments);m(this,"schema",Nu);m(this,"fetchedInitial",T.U.ZERO)}async afterUpdate(){const{internal:n}=this;n.render=gt.use(this.ctx),n.draw=new Jn(n.render.upper2d,T.use(this.ctx)),n.ranges==null&&(n.ranges=new Map);const r=Vn(this.ctx);r!=null&&(n.client=r,n.tracker==null&&(n.tracker=await n.client.ranges.openTracker(),n.tracker.onChange(async s=>{s.forEach(async o=>{o.variant==="delete"?n.ranges.delete(o.key):n.ranges.set(o.key,o.value)}),yt.requestRender(this.ctx,Jt),this.setState(o=>({...o,count:n.ranges.size}))})))}async fetchInitial(n){const{internal:r}=this;if(r.client==null||this.fetchedInitial.roughlyEquals(n,T.w.minutes(1)))return;this.fetchedInitial=n,(await r.client.ranges.retrieve(n)).forEach(o=>r.ranges.set(o.key,o)),this.setState(o=>({...o,count:r.ranges.size}))}async render(n){const{dataToDecimalScale:r,region:s,viewport:o,timeRange:i}=n;await this.fetchInitial(i);const{draw:a,ranges:c}=this.internal,l=r.scale(f.To.xBounds(s)),u=this.state.cursor==null?null:this.state.cursor.x;let h=null;const d=a.canvas.scissor(f.To.construct({x:f.To.left(s),y:f.To.top(s)-35},{x:f.To.right(s),y:f.To.bottom(s)}));c.forEach(p=>{const x=f.Color.z.safeParse(p.color);if(!x.success)return;const w=x.data;let b=l.pos(Number(p.timeRange.start.valueOf()));const v=l.pos(Number(p.timeRange.end.valueOf()));if(v<f.To.left(s)||b>f.To.right(s))return;b=f.Y(b,f.To.left(s)-2,f.To.right(s)-1);let k=!1;u!=null&&(k=f.C.contains({lower:b,upper:v},u)),k&&(h={key:p.key,name:p.name,color:p.color,timeRange:p.timeRange,viewport:{lower:r.scale(f.To.xBounds(o)).pos(Number(p.timeRange.start.valueOf())),upper:r.scale(f.To.xBounds(o)).pos(Number(p.timeRange.end.valueOf()))}}),a.container({region:f.To.construct({x:b,y:f.To.top(s)-1},{x:v,y:f.To.bottom(s)-1}),backgroundColor:w.setAlpha(.07),bordered:!1});const C=f.To.construct({x:b+1,y:f.To.top(s)-34},{x:v-1,y:f.To.top(s)-12});a.container({region:C,backgroundColor:f.To.width(C)<20?w.setAlpha(.4):S=>k?S.colors.gray.l2:S.colors.gray.l0,bordered:!0,borderWidth:1,borderRadius:2,borderColor:w.setAlpha(.8)}),a.text({text:p.name,position:{x:b+8,y:f.To.top(s)-30},level:"small",shade:8,weight:500,maxWidth:v-b-16})}),d(),h!=null?this.setState(p=>({...p,hovered:h})):this.state.hovered&&this.setState(p=>({...p,hovered:null}))}}m(Zn,"TYPE","range-provider");const zx={[Yr.TYPE]:Yr,[Zn.TYPE]:Zn},Ix=Qn;class Hn extends Gc{constructor(){super(...arguments);m(this,"schema",Qn)}async render(n){if(this.deleted)return;const[r,s]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(this.renderAxis(n,r.reverse()),await this.renderYAxes(n,r),await this.renderRangeAnnotations(n,r),s!=null)throw s}async findByXDecimal(n,r){const[s,o]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(o!=null)throw o;return await this.findByXValue(n,s.reverse().pos(r))}async findByXValue(n,r){const[s,o]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(o!=null)throw o;const i={...n,xDataToDecimalScale:s},a=this.yAxes.map(async c=>await c.findByXValue(i,r));return(await Promise.all(a)).flat()}async renderYAxes(n,r){const s={...n,xDataToDecimalScale:r};await Promise.all(this.yAxes.map(async o=>await o.render(s)))}get yAxes(){return this.childrenOfType(Ln.TYPE)}get rangeAnnotations(){return this.childrenOfType(Zn.TYPE)}async renderRangeAnnotations(n,r){const[s,o]=await this.bounds(n.hold,this.dataBounds.bind(this));if(o!=null)throw o;await Promise.all(this.rangeAnnotations.map(async i=>await i.render({dataToDecimalScale:r,region:n.plot,viewport:n.viewport,timeRange:new T.U(s.lower,s.upper)})))}async dataBounds(){return await Promise.all(this.yAxes.map(async n=>await n.xBounds()))}}m(Hn,"TYPE","XAxis");const Du=M.z.object({container:f.To.box,viewport:f.To.box,hold:M.z.boolean().optional().default(!1),grid:M.z.record(Sc),clearOverScan:f.q.crudeZ.optional().default(f.q.ZERO)});class ss extends T.Composite{constructor(){super(...arguments);m(this,"eraser",new ds);m(this,"schema",Du)}async afterUpdate(){this.internal.instrumentation=Gn(this.ctx,"lineplot"),this.internal.aggregate=T.useAggregate(this.ctx),this.internal.renderCtx=gt.use(this.ctx),yt.control(this.ctx,n=>this.requestRender("low",n)),this.requestRender("high",zt)}async afterDelete(){this.internal.renderCtx=gt.use(this.ctx),this.requestRender("high",zt)}async findByXDecimal(n){const r={...this.state,plot:this.calculatePlot()},s=this.axes.flatMap(async o=>await o.findByXDecimal(r,n));return(await Promise.all(s)).flat()}async findByXValue(n){const r={...this.state,plot:this.calculatePlot()},s=this.axes.flatMap(async o=>await o.findByXValue(r,n));return(await Promise.all(s)).flat()}get axes(){return this.childrenOfType(Hn.TYPE)}get tooltips(){return this.childrenOfType(nn.TYPE)}get measures(){return this.childrenOfType(rn.TYPE)}async renderAxes(n,r){const s={...this.state,plot:n,canvases:r};await Promise.all(this.axes.map(async o=>await o.render(s)))}async renderTooltips(n,r){const s={findByXDecimal:this.findByXDecimal.bind(this),region:n,canvases:r};await Promise.all(this.tooltips.map(async o=>await o.render(s)))}async renderMeasures(n,r){const s={findByXDecimal:this.findByXDecimal.bind(this),findByXValue:this.findByXValue.bind(this),region:n,canvases:r};await Promise.all(this.measures.map(async o=>await o.render(s)))}calculatePlot(){return Jh(this.state.grid,this.state.container)}async render(n){const{renderCtx:r}=this.internal,{instrumentation:s}=this.internal;if(this.deleted){s.L.debug("deleted, skipping render",{key:this.key});return}const o=this.calculatePlot();s.L.debug("rendering",{key:this.key,viewport:this.state.viewport,container:this.state.container,grid:this.state.grid,plot:o,canvases:n});const i=f.q.construct(this.state.clearOverScan),a=r.scissor(this.state.container,i,n.filter(u=>u!=="gl")),c=r.scissor(o,f.q.ZERO,n.filter(u=>u==="gl"));try{await this.renderAxes(o,n),await this.renderTooltips(o,n),await this.renderMeasures(o,n),r.gl.finish(),r.gl.flush(),r.gl.finish()}catch(u){if(u.message.toLowerCase().includes("bigint"))return;this.internal.aggregate({key:`${this.type}-${this.key}`,variant:"error",message:u.message})}finally{a(),c()}s.L.debug("rendered",{key:this.key});const l=f.To.copy(this.state.container);return async({canvases:u})=>{r.erase(l,this.state.clearOverScan,...u)}}requestRender(n,r){const{renderCtx:s}=this.internal;let o=["upper2d","lower2d","gl"];r===Jt&&(o=["upper2d"]),s.loop.set({key:`${this.type}-${this.key}`,render:async()=>await this.render(o),priority:n,canvases:o})}}m(ss,"TYPE","LinePlot");const $x={[ss.TYPE]:ss,[Hn.TYPE]:Hn,[Ln.TYPE]:Ln};exports.Annotation=Yr;exports.BaseEdge=on;exports.BaseProvider=Ve;exports.Button=Xr;exports.Canvas=Yn;exports.Chip=Br;exports.Context=gt;exports.Controller=yt;exports.Controller$1=Fr;exports.Diagram=Px;exports.Diagram$1=en;exports.Eraser=ds;exports.Eraser$1=ns;exports.GLProgram=qo;exports.Handle$1=qn;exports.Indicator=Hr;exports.Legend=Vr;exports.Line=$n;exports.LinePlot=ss;exports.Loop=Vc;exports.Measure=rn;exports.Provider=wr;exports.Provider$1=Zn;exports.Provider$2=Ks;exports.REASON_DATA=ro;exports.REASON_LAYOUT=zt;exports.REASON_TOOL=Jt;exports.REGISTRY=$x;exports.REGISTRY$1=al;exports.REGISTRY$10=Mu;exports.REGISTRY$11=fg;exports.REGISTRY$12=dg;exports.REGISTRY$13=$h;exports.REGISTRY$14=kx;exports.REGISTRY$15=zx;exports.REGISTRY$2=Oa;exports.REGISTRY$3=vc;exports.REGISTRY$4=Qp;exports.REGISTRY$5=Au;exports.REGISTRY$6=Ax;exports.REGISTRY$7=Cu;exports.REGISTRY$8=Qc;exports.REGISTRY$9=ku;exports.ReactFlow=Su;exports.ReactFlowProvider=ai;exports.Rule=Ke;exports.StateProvider=je;exports.Toggle=rs;exports.Tooltip=nn;exports.Value=sn;exports.XAxis=Hn;exports.YAxis=Ln;exports.ZERO_CONTEXT_VALUE=vo;exports.acquireChannelControl=lg;exports.addEdge=Fl;exports.aether=ng;exports.annotationStateZ=Jc;exports.applyEdgeChanges=kw;exports.applyNodeChanges=cu;exports.authoritySource=hg;exports.buttonStateZ=il;exports.canvas=pg;exports.canvasStateZ=Zo;exports.cc=St;exports.channelData=tc;exports.chipStateZ=tl;exports.controllerStateZ=nl;exports.coreAxisStateZ=Qn;exports.diagramStateZ=ci;exports.edgeConverter=Cx;exports.eraserStateZ=Pu;exports.external=jh;exports.filterGridEntries=le;exports.indicatorStateZ=sl;exports.legendStateZ=ol;exports.linePlotStateZ=Du;exports.measure=Rx;exports.measureStateZ=ui;exports.nodeConverter=_x;exports.parseAutoBounds=Kc;exports.provider=yh;exports.providerStateZ=Nu;exports.providerStateZ$1=mc;exports.providerStateZ$2=Ao;exports.rollingAverage=dc;exports.rollingAverageProps=Ro;exports.ruleStateZ=Uo;exports.setChannelValue=ag;exports.setChannelValuePropsZ=rl;exports.setpoint=cc;exports.shallow$1=pt;exports.sinkPipeline=Qa;exports.sinkPipelinePropsZ=_o;exports.sourcePipeline=ja;exports.sourcePipelinePropsZ=Eo;exports.stateProviderStateZ=el;exports.stateZ=jc;exports.streamChannelData=ec;exports.streamChannelValue=nc;exports.streamChannelValuePropsZ=Co;exports.stringifyNumber=fc;exports.stringifyNumberProps=Mo;exports.toggleStateZ=Ru;exports.tooltip=Mx;exports.tooltipStateZ=li;exports.translateEdgesForward=Tu;exports.translateNodesForward=bu;exports.translateViewportBackward=Eu;exports.translateViewportForward=Ex;exports.updateEdge=j0;exports.useInitialViewport=_u;exports.useOnViewportChange=Sx;exports.useReactFlow=vs;exports.useStore=lt;exports.useUpdateNodeInternals=vx;exports.value=Dx;exports.withinBounds=lc;exports.withinSizeThreshold=Xc;exports.xAxisStateZ=Ix;exports.yAxisStateZ=rg;