@synnaxlabs/pluto 0.47.0 → 0.48.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 (180) hide show
  1. package/dist/{Animated-BewuBtBY.cjs → Animated--SNIwznU.cjs} +1 -1
  2. package/dist/{Animated-M9ynNzcI.js → Animated-CC7iS0zH.js} +21 -21
  3. package/dist/{Animated-otpyxn5i.js → Animated-DfDp0-ep.js} +4 -4
  4. package/dist/{Animated-Ck-9v2gm.cjs → Animated-TMpTdCqK.cjs} +1 -1
  5. package/dist/{Box-D5Qv__kr.js → Box-CoQUaJk2.js} +2 -2
  6. package/dist/{Box-BvqALodh.cjs → Box-Ds_D3xR_.cjs} +1 -1
  7. package/dist/Button-BaMa3eGI.cjs +1 -0
  8. package/dist/Button-NgDHbsf8.js +306 -0
  9. package/dist/{Dialog-DwhFD4z2.cjs → Dialog-BL8T9CVw.cjs} +1 -1
  10. package/dist/{Dialog-CO4iLhHf.js → Dialog-CBDFqieV.js} +4 -4
  11. package/dist/{Editable-CxgdRDPb.js → Editable-C7KPD0hC.js} +3 -3
  12. package/dist/{Editable-BXFY3-UW.cjs → Editable-CWt3zqDm.cjs} +1 -1
  13. package/dist/{Haul-BuI0PZpo.js → Haul-Be1j5BU3.js} +2 -2
  14. package/dist/{Haul-2Xa_nMgc.cjs → Haul-D1WaI_xE.cjs} +1 -1
  15. package/dist/{Items-DNcTFEUJ.cjs → Items-BYlg9bb-.cjs} +1 -1
  16. package/dist/{Items-G25zb57I.js → Items-mikdEpyC.js} +8 -8
  17. package/dist/{Menu-DqkB9vpH.js → Menu-CcWs0t21.js} +9 -9
  18. package/dist/{Menu-D-uhqnfk.cjs → Menu-DJoh8bH7.cjs} +1 -1
  19. package/dist/{Provider--RxgAoVG.js → Provider-DScd3hYf.js} +26 -26
  20. package/dist/{Provider-575hnWmi.cjs → Provider-fx1wTnXk.cjs} +2 -2
  21. package/dist/Tags-DvPUmH2r.js +908 -0
  22. package/dist/Tags-KHafaGjR.cjs +1 -0
  23. package/dist/{Text-BzTkWLeU.js → Text-BbbqH88W.js} +492 -487
  24. package/dist/Text-CZrjPRjJ.cjs +1 -0
  25. package/dist/{Video-VlT7jSYk.cjs → Video-DRSEX8t7.cjs} +1 -1
  26. package/dist/{Video-CITi2j07.js → Video-_DrutSeT.js} +2 -2
  27. package/dist/button.cjs +1 -1
  28. package/dist/button.js +1 -1
  29. package/dist/color.cjs +1 -1
  30. package/dist/color.js +1 -1
  31. package/dist/css-C_YE-5Xa.cjs +8 -0
  32. package/dist/{css-D6ZBcSwh.js → css-Cn63X_Yv.js} +1161 -1111
  33. package/dist/css.cjs +1 -1
  34. package/dist/css.js +2 -2
  35. package/dist/{deep-DtdcJG4q.cjs → deep-7SxmCL0x.cjs} +1 -1
  36. package/dist/{deep-DRVLw7iw.js → deep-szN5DCOH.js} +1 -1
  37. package/dist/dialog.cjs +1 -1
  38. package/dist/dialog.js +1 -1
  39. package/dist/{dimensions-CGLhBwVq.cjs → dimensions-DFDTcQRG.cjs} +1 -1
  40. package/dist/{dimensions-BFCMI7yN.js → dimensions-Dclfavlh.js} +1 -1
  41. package/dist/{eraser-DvzR9kLf.js → eraser-Bpl4bpBx.js} +13 -13
  42. package/dist/{eraser-Dm5Du4PL.cjs → eraser-Bqibt23a.cjs} +2 -2
  43. package/dist/ether.cjs +1 -1
  44. package/dist/ether.js +7 -7
  45. package/dist/{_commonjsHelpers-BH3jXuIh.cjs → event-BxvV3arE.cjs} +1 -1
  46. package/dist/{_commonjsHelpers-ByX85dGu.js → event-nNH_pXSr.js} +17 -14
  47. package/dist/{external-B2Q-Yx8D.cjs → external-19BIaQc6.cjs} +1 -1
  48. package/dist/{external-CMiEiLpE.js → external-1uZLLxz-.js} +771 -792
  49. package/dist/{external-CraRr06G.js → external-6rS2YiWR.js} +16066 -15782
  50. package/dist/{external-DZSXelLG.js → external-8H4eB7TN.js} +8 -8
  51. package/dist/{external-C5W7VXIW.cjs → external-AInsIJp-.cjs} +1 -1
  52. package/dist/{external-C5ssXUvL.cjs → external-B3jTkhc4.cjs} +4 -22
  53. package/dist/external-B8hxM_jw.cjs +79 -0
  54. package/dist/{external-D9LndfvY.js → external-BOWnCKIe.js} +3 -3
  55. package/dist/external-Bi-OQCBH.js +45 -0
  56. package/dist/{external-CeNR2kU9.js → external-Bq4gfE5e.js} +6 -6
  57. package/dist/{external-CGRGVYRj.js → external-C0_sN1J0.js} +2 -2
  58. package/dist/{external-C_dsD7px.cjs → external-CFZ33YbY.cjs} +1 -1
  59. package/dist/{external-DEWhnbVF.cjs → external-CFdDgpzj.cjs} +1 -1
  60. package/dist/{external-BVcgi9yX.cjs → external-CJFfVl_u.cjs} +1 -1
  61. package/dist/{external-BA6DRS2n.cjs → external-CN15E8ls.cjs} +1 -1
  62. package/dist/{external-DUoHSX0Q.js → external-Caetm5fI.js} +5 -5
  63. package/dist/external-CfEVFfhL.cjs +1 -0
  64. package/dist/{external-DrUtWpiV.js → external-D6TsHpoG.js} +10 -10
  65. package/dist/{external-FIE7PzLB.cjs → external-D7WE6Leo.cjs} +1 -1
  66. package/dist/{external-OLyg-4Ab.cjs → external-DUGcSVbJ.cjs} +1 -1
  67. package/dist/{external-B7hb5HYU.js → external-DwhfVdFp.js} +5 -5
  68. package/dist/{external-BhOvtmPt.js → external-X_eFMRtE.js} +2 -2
  69. package/dist/{external-_LWHQroW.cjs → external-pRQzznIG.cjs} +1 -1
  70. package/dist/{external-x9Ylk2op.js → external-y1Apm7j1.js} +14 -14
  71. package/dist/flex.cjs +1 -1
  72. package/dist/flex.js +1 -1
  73. package/dist/{fontString-yPlq8smc.cjs → fontString-BcSXNOgW.cjs} +1 -1
  74. package/dist/{fontString-CGd4NYXa.js → fontString-D7EMGjIw.js} +2 -2
  75. package/dist/header.cjs +1 -1
  76. package/dist/header.js +1 -1
  77. package/dist/{hooks-15yB7IKE.js → hooks-BmUn8s1r.js} +4 -4
  78. package/dist/{hooks-D_-XdOAe.cjs → hooks-CutQY1o9.cjs} +1 -1
  79. package/dist/index.cjs +8 -40
  80. package/dist/index.js +10546 -10342
  81. package/dist/input.cjs +1 -1
  82. package/dist/input.js +1 -1
  83. package/dist/{jsx-runtime-OVHDjVDe.js → jsx-runtime-BbD0H88J.js} +108 -128
  84. package/dist/jsx-runtime-nZSsnGb7.cjs +6 -0
  85. package/dist/list.cjs +1 -1
  86. package/dist/list.js +1 -1
  87. package/dist/menu.cjs +1 -1
  88. package/dist/menu.js +1 -1
  89. package/dist/pluto.css +1 -1
  90. package/dist/{provider-C8In649C.js → provider-B6SgG_sT.js} +4910 -4821
  91. package/dist/provider-C9Beoajx.cjs +72 -0
  92. package/dist/src/button/Button.d.ts +2 -1
  93. package/dist/src/button/Button.d.ts.map +1 -1
  94. package/dist/src/channel/LinePlot.d.ts +4 -1
  95. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  96. package/dist/src/channel/Select.d.ts +2 -2
  97. package/dist/src/channel/Select.d.ts.map +1 -1
  98. package/dist/src/cluster/index.d.ts +2 -0
  99. package/dist/src/cluster/index.d.ts.map +1 -0
  100. package/dist/src/cluster/queries.d.ts +6 -0
  101. package/dist/src/cluster/queries.d.ts.map +1 -0
  102. package/dist/src/cluster/queries.spec.d.ts +2 -0
  103. package/dist/src/cluster/queries.spec.d.ts.map +1 -0
  104. package/dist/src/color/GradientPicker.d.ts.map +1 -1
  105. package/dist/src/flux/retrieve.d.ts +9 -8
  106. package/dist/src/flux/retrieve.d.ts.map +1 -1
  107. package/dist/src/hardware/device/Select.d.ts +1 -1
  108. package/dist/src/hardware/device/Select.d.ts.map +1 -1
  109. package/dist/src/hardware/rack/Select.d.ts +1 -1
  110. package/dist/src/hardware/rack/Select.d.ts.map +1 -1
  111. package/dist/src/icon/registry.d.ts +1 -0
  112. package/dist/src/icon/registry.d.ts.map +1 -1
  113. package/dist/src/index.d.ts +1 -0
  114. package/dist/src/index.d.ts.map +1 -1
  115. package/dist/src/input/DateTime.d.ts.map +1 -1
  116. package/dist/src/input/DateTime.spec.d.ts +2 -0
  117. package/dist/src/input/DateTime.spec.d.ts.map +1 -0
  118. package/dist/src/label/Select.d.ts +3 -3
  119. package/dist/src/label/Select.d.ts.map +1 -1
  120. package/dist/src/menu/Item.d.ts.map +1 -1
  121. package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
  122. package/dist/src/select/Dialog.d.ts +2 -3
  123. package/dist/src/select/Dialog.d.ts.map +1 -1
  124. package/dist/src/select/Multiple.d.ts.map +1 -1
  125. package/dist/src/select/MultipleTrigger.d.ts.map +1 -1
  126. package/dist/src/status/Select.d.ts +1 -1
  127. package/dist/src/status/Select.d.ts.map +1 -1
  128. package/dist/src/status/queries.d.ts +13 -0
  129. package/dist/src/status/queries.d.ts.map +1 -1
  130. package/dist/src/synnax/Provider.d.ts +2 -2
  131. package/dist/src/synnax/Provider.d.ts.map +1 -1
  132. package/dist/src/synnax/aether/provider.d.ts.map +1 -1
  133. package/dist/src/table/Table.d.ts.map +1 -1
  134. package/dist/src/tag/Tag.d.ts.map +1 -1
  135. package/dist/src/triggers/Provider.d.ts.map +1 -1
  136. package/dist/src/user/Avatar.d.ts +7 -0
  137. package/dist/src/user/Avatar.d.ts.map +1 -0
  138. package/dist/src/user/external.d.ts +3 -0
  139. package/dist/src/user/external.d.ts.map +1 -0
  140. package/dist/src/user/index.d.ts +1 -1
  141. package/dist/src/user/index.d.ts.map +1 -1
  142. package/dist/src/user/queries.d.ts +1 -0
  143. package/dist/src/user/queries.d.ts.map +1 -1
  144. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  145. package/dist/src/vis/draw2d/index.d.ts +2 -1
  146. package/dist/src/vis/draw2d/index.d.ts.map +1 -1
  147. package/dist/src/vis/measure/Measure.d.ts +4 -1
  148. package/dist/src/vis/measure/Measure.d.ts.map +1 -1
  149. package/dist/src/vis/measure/aether/measure.d.ts +27 -1
  150. package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
  151. package/dist/tabs.cjs +1 -1
  152. package/dist/tabs.js +1 -1
  153. package/dist/text.cjs +1 -1
  154. package/dist/text.js +2 -2
  155. package/dist/theming.cjs +1 -1
  156. package/dist/theming.js +2 -2
  157. package/dist/tree.cjs +1 -1
  158. package/dist/tree.js +1 -1
  159. package/dist/triggers.cjs +1 -1
  160. package/dist/triggers.js +1 -1
  161. package/dist/{units-BqIfn6VX.js → units-cBd5OJg4.js} +1 -1
  162. package/dist/units-zxke9Ng2.cjs +1 -0
  163. package/dist/value-Ce4T858D.cjs +53 -0
  164. package/dist/{value-ChGMEPP3.js → value-UJNdARAu.js} +2715 -2512
  165. package/dist/video.cjs +1 -1
  166. package/dist/video.js +1 -1
  167. package/package.json +24 -22
  168. package/dist/Button-BFoGC4WW.js +0 -305
  169. package/dist/Button-C3dvpk52.cjs +0 -1
  170. package/dist/Tags-Dekr_hwk.cjs +0 -1
  171. package/dist/Tags-Dpu9kD_T.js +0 -604
  172. package/dist/Text-DECnk5vG.cjs +0 -1
  173. package/dist/css-HnNQMUzV.cjs +0 -8
  174. package/dist/external-B9a_p-VK.cjs +0 -1
  175. package/dist/external-BZwFEYop.js +0 -44
  176. package/dist/external-g62tixOz.cjs +0 -85
  177. package/dist/jsx-runtime-Dszzpdy0.cjs +0 -22
  178. package/dist/provider-lNhTlIWj.cjs +0 -72
  179. package/dist/units-DCifOxd9.cjs +0 -1
  180. package/dist/value-B3LTg1lE.cjs +0 -53
@@ -0,0 +1,53 @@
1
+ "use strict";const g=require("./provider-C9Beoajx.cjs"),s=require("./css-C_YE-5Xa.cjs"),d=require("zod"),A=require("./eraser-Bqibt23a.cjs"),ie=require("./deep-7SxmCL0x.cjs"),Je=require("./fontString-BcSXNOgW.cjs"),cr=require("./debounce-heEWeOqL.cjs"),ge=require("./types-D-yz1qsT.cjs");require("react");const Gr=require("./dimensions-DFDTcQRG.cjs");class Za{handlers;transform;closer;constructor(e,t){this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){const[r,i]=this.transform(e);if(!i)return;t=r}this.handlers.forEach((r,i)=>i(t))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}}class ja{handlers;constructor(e){this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,r)=>r(e))}}const sn=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:ja,Observer:Za},Symbol.toStringTag,{value:"Module"}));function ur(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function Ms(n,e){var t=Object.create(n.prototype);for(var r in e)t[r]=e[r];return t}function ht(){}var et=.7,kt=1/et,Le="\\s*([+-]?\\d+)\\s*",tt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",$a=/^#([0-9a-f]{3,8})$/,Ba=new RegExp(`^rgb\\(${Le},${Le},${Le}\\)$`),Ua=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),Ha=new RegExp(`^rgba\\(${Le},${Le},${Le},${tt}\\)$`),qa=new RegExp(`^rgba\\(${ee},${ee},${ee},${tt}\\)$`),Fa=new RegExp(`^hsl\\(${tt},${ee},${ee}\\)$`),Qa=new RegExp(`^hsla\\(${tt},${ee},${ee},${tt}\\)$`),Xr={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};ur(ht,Oe,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:Kr,formatHex:Kr,formatHex8:Wa,formatHsl:Va,formatRgb:Jr,toString:Jr});function Kr(){return this.rgb().formatHex()}function Wa(){return this.rgb().formatHex8()}function Va(){return Is(this).formatHsl()}function Jr(){return this.rgb().formatRgb()}function Oe(n){var e,t;return n=(n+"").trim().toLowerCase(),(e=$a.exec(n))?(t=e[1].length,e=parseInt(e[1],16),t===6?es(e):t===3?new $(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?St(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?St(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=Ba.exec(n))?new $(e[1],e[2],e[3],1):(e=Ua.exec(n))?new $(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Ha.exec(n))?St(e[1],e[2],e[3],e[4]):(e=qa.exec(n))?St(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Fa.exec(n))?rs(e[1],e[2]/100,e[3]/100,1):(e=Qa.exec(n))?rs(e[1],e[2]/100,e[3]/100,e[4]):Xr.hasOwnProperty(n)?es(Xr[n]):n==="transparent"?new $(NaN,NaN,NaN,0):null}function es(n){return new $(n>>16&255,n>>8&255,n&255,1)}function St(n,e,t,r){return r<=0&&(n=e=t=NaN),new $(n,e,t,r)}function Ga(n){return n instanceof ht||(n=Oe(n)),n?(n=n.rgb(),new $(n.r,n.g,n.b,n.opacity)):new $}function Mn(n,e,t,r){return arguments.length===1?Ga(n):new $(n,e,t,r??1)}function $(n,e,t,r){this.r=+n,this.g=+e,this.b=+t,this.opacity=+r}ur($,Mn,Ms(ht,{brighter(n){return n=n==null?kt:Math.pow(kt,n),new $(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?et:Math.pow(et,n),new $(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new $(me(this.r),me(this.g),me(this.b),Ot(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ts,formatHex:ts,formatHex8:Xa,formatRgb:ns,toString:ns}));function ts(){return`#${fe(this.r)}${fe(this.g)}${fe(this.b)}`}function Xa(){return`#${fe(this.r)}${fe(this.g)}${fe(this.b)}${fe((isNaN(this.opacity)?1:this.opacity)*255)}`}function ns(){const n=Ot(this.opacity);return`${n===1?"rgb(":"rgba("}${me(this.r)}, ${me(this.g)}, ${me(this.b)}${n===1?")":`, ${n})`}`}function Ot(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function me(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function fe(n){return n=me(n),(n<16?"0":"")+n.toString(16)}function rs(n,e,t,r){return r<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new J(n,e,t,r)}function Is(n){if(n instanceof J)return new J(n.h,n.s,n.l,n.opacity);if(n instanceof ht||(n=Oe(n)),!n)return new J;if(n instanceof J)return n;n=n.rgb();var e=n.r/255,t=n.g/255,r=n.b/255,i=Math.min(e,t,r),o=Math.max(e,t,r),a=NaN,l=o-i,u=(o+i)/2;return l?(e===o?a=(t-r)/l+(t<r)*6:t===o?a=(r-e)/l+2:a=(e-t)/l+4,l/=u<.5?o+i:2-o-i,a*=60):l=u>0&&u<1?0:a,new J(a,l,u,n.opacity)}function Ka(n,e,t,r){return arguments.length===1?Is(n):new J(n,e,t,r??1)}function J(n,e,t,r){this.h=+n,this.s=+e,this.l=+t,this.opacity=+r}ur(J,Ka,Ms(ht,{brighter(n){return n=n==null?kt:Math.pow(kt,n),new J(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?et:Math.pow(et,n),new J(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,r=t+(t<.5?t:1-t)*e,i=2*t-r;return new $(En(n>=240?n-240:n+120,i,r),En(n,i,r),En(n<120?n+240:n-120,i,r),this.opacity)},clamp(){return new J(ss(this.h),Tt(this.s),Tt(this.l),Ot(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=Ot(this.opacity);return`${n===1?"hsl(":"hsla("}${ss(this.h)}, ${Tt(this.s)*100}%, ${Tt(this.l)*100}%${n===1?")":`, ${n})`}`}}));function ss(n){return n=(n||0)%360,n<0?n+360:n}function Tt(n){return Math.max(0,Math.min(1,n||0))}function En(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const hr=n=>()=>n;function Ja(n,e){return function(t){return n+t*e}}function eo(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(r){return Math.pow(n+r*e,t)}}function to(n){return(n=+n)==1?As:function(e,t){return t-e?eo(e,t,n):hr(isNaN(e)?t:e)}}function As(n,e){var t=e-n;return t?Ja(n,t):hr(isNaN(n)?e:n)}const In=(function n(e){var t=to(e);function r(i,o){var a=t((i=Mn(i)).r,(o=Mn(o)).r),l=t(i.g,o.g),u=t(i.b,o.b),c=As(i.opacity,o.opacity);return function(h){return i.r=a(h),i.g=l(h),i.b=u(h),i.opacity=c(h),i+""}}return r.gamma=n,r})(1);function no(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,r=e.slice(),i;return function(o){for(i=0;i<t;++i)r[i]=n[i]*(1-o)+e[i]*o;return r}}function ro(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function so(n,e){var t=e?e.length:0,r=n?Math.min(t,n.length):0,i=new Array(r),o=new Array(t),a;for(a=0;a<r;++a)i[a]=an(n[a],e[a]);for(;a<t;++a)o[a]=e[a];return function(l){for(a=0;a<r;++a)o[a]=i[a](l);return o}}function io(n,e){var t=new Date;return n=+n,e=+e,function(r){return t.setTime(n*(1-r)+e*r),t}}function nt(n,e){return n=+n,e=+e,function(t){return n*(1-t)+e*t}}function ao(n,e){var t={},r={},i;(n===null||typeof n!="object")&&(n={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in n?t[i]=an(n[i],e[i]):r[i]=e[i];return function(o){for(i in t)r[i]=t[i](o);return r}}var An=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Cn=new RegExp(An.source,"g");function oo(n){return function(){return n}}function lo(n){return function(e){return n(e)+""}}function Ds(n,e){var t=An.lastIndex=Cn.lastIndex=0,r,i,o,a=-1,l=[],u=[];for(n=n+"",e=e+"";(r=An.exec(n))&&(i=Cn.exec(e));)(o=i.index)>t&&(o=e.slice(t,o),l[a]?l[a]+=o:l[++a]=o),(r=r[0])===(i=i[0])?l[a]?l[a]+=i:l[++a]=i:(l[++a]=null,u.push({i:a,x:nt(r,i)})),t=Cn.lastIndex;return t<e.length&&(o=e.slice(t),l[a]?l[a]+=o:l[++a]=o),l.length<2?u[0]?lo(u[0].x):oo(e):(e=u.length,function(c){for(var h=0,f;h<e;++h)l[(f=u[h]).i]=f.x(c);return l.join("")})}function an(n,e){var t=typeof e,r;return e==null||t==="boolean"?hr(e):(t==="number"?nt:t==="string"?(r=Oe(e))?(e=r,In):Ds:e instanceof Oe?In:e instanceof Date?io:ro(e)?no:Array.isArray(e)?so:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?ao:nt)(n,e)}function co(n,e){return n=+n,e=+e,function(t){return Math.round(n*(1-t)+e*t)}}class ce extends sn.Observer{cleanup(){}}class Dn extends ce{static TYPE="noop-boolean-sink";set(){}}const on={type:Dn.TYPE,props:{},variant:"sink",valueType:"boolean"};class Yn extends ce{static TYPE="noop-numeric-sink";set(){}}const Ys={type:Yn.TYPE,props:{},variant:"sink",valueType:"number"};class Nn extends ce{static TYPE="noop-boolean-source";value(){return!1}}const dr={type:Nn.TYPE,props:{},variant:"source",valueType:"boolean"};class Zn extends ce{static TYPE="noop-numeric-source";value(){return 0}}const Ns={type:Zn.TYPE,props:{},variant:"source",valueType:"number"};class jn extends ce{static TYPE="noop-string-sink";set(){}}const Zs={type:jn.TYPE,props:{},variant:"sink",valueType:"string"};class $n extends ce{static TYPE="noop-string-source";value(){return""}}const fr={type:$n.TYPE,props:{},variant:"source",valueType:"string"};class Bn extends ce{static TYPE="noop-status-source";value(){return{key:"noop",name:"noop",variant:"disabled",message:"unknown",time:s.r.now()}}}const pr={type:Bn.TYPE,props:{},variant:"source",valueType:"status"};class Un extends ce{static TYPE="noop-color-source";value(){return s.zr.ZERO}}const dt={type:Un.TYPE,props:{},variant:"source",valueType:"color"};class Hn extends ce{static TYPE="noop-series";value(){return[s.H.ZERO,new s.Oe([])]}}const js={type:Hn.TYPE,props:{},variant:"source",valueType:"series"},uo={[Dn.TYPE]:Dn,[Yn.TYPE]:Yn,[jn.TYPE]:jn,[Nn.TYPE]:Nn,[Zn.TYPE]:Zn,[Bn.TYPE]:Bn,[Un.TYPE]:Un,[$n.TYPE]:$n,[Hn.TYPE]:Hn};class $s{type="noop";create(e){const t=uo[e.type];return t==null?null:new t}}const ho=d.z.instanceof(ArrayBuffer),ft=d.z.object({type:d.z.string(),variant:d.z.enum(["source","sink","source-transformer","sink-transformer"]),valueType:d.z.string(),props:d.z.any(),transfer:d.z.array(ho).optional()}),ue=ft.extend({variant:d.z.literal("source")}),pt=ft.extend({variant:d.z.literal("sink")}),Bs=ft.extend({variant:d.z.literal("source-transformer")}),Us=ft.extend({variant:d.z.literal("sink-transformer")}),_t=ue.extend({valueType:d.z.literal("series")}),gr=ue.extend({valueType:d.z.literal("boolean")}),ln=pt.extend({valueType:d.z.literal("boolean")}),fo=Us.extend({valueType:d.z.literal("boolean")}),po=Bs.extend({valueType:d.z.literal("boolean")}),Hs=ue.extend({valueType:d.z.literal("number")}),qs=pt.extend({valueType:d.z.literal("number")}),cn=ue.extend({valueType:d.z.literal("color")}),mr=ue.extend({valueType:d.z.literal("status")}),un=ue.extend({valueType:d.z.literal("string")}),Fs=pt.extend({valueType:d.z.literal("string")});let hn=class extends sn.BaseObserver{props_=void 0;uProps_=void 0;constructor(e){super(),this.uProps_=e}get props(){if(this.props_==null){const e=this.schema.safeParse(this.uProps_);if(e.success)this.props_=e.data;else throw new g.G(`[BaseTelem] - expected props to be valid, but found the following errors:
2
+ ${e.error.message}`)}return this.props_}cleanup(){}};class F extends hn{}class dn extends hn{}class ve extends F{source_=void 0;get source(){if(this.source_==null)throw new g.G("[UnarySourceTransformer] - expected source to exist, but none was found.");return this.source_}value(){return this.transform(this.source.value())}onChange(e){return this.source.onChange(()=>{this.shouldNotify(this.source.value())&&e()})}setSources(e){this.source_=Object.values(e)[0]}shouldNotify(e){return!0}}class Qs extends F{sources={};value(){const e=Object.fromEntries(Object.entries(this.sources).map(([t,r])=>[t,r.value()]));return this.transform(e)}setSources(e){this.sources={...this.sources,...e}}}class Ws extends hn{sinks={};get sink(){const[e]=Object.values(this.sinks);if(e==null)throw new g.G("[UnarySinkTransformer] - expected sink to exist, but none was found.");return e}set(...e){return this.sink.set(...this.transform(...e))}setSinks(e){this.sinks={...this.sinks,...e}}}const yr=d.z.object({from:d.z.string(),to:d.z.string()}),br=d.z.object({connections:d.z.array(yr),outlet:d.z.string(),segments:d.z.record(d.z.string(),ue)});class vr{type="pipeline";factory;constructor(e){this.factory=e}create(e){switch(e.type){case zt.TYPE:return new zt(e.props,this.factory);case Mt.TYPE:return new Mt(e.props,this.factory);default:return null}}}class zt extends F{static TYPE="source-pipeline";schema=br;sources={};get outlet(){const{outlet:e}=this.props,t=this.sources[e];if(t==null)throw new g.G(`[SourcePipeline] - expected source to exist at outlet '${e}', but none was found.`);return t}constructor(e,t){super(e);const{connections:r,segments:i}=this.props;Object.entries(i).forEach(([o,a])=>{const l=t.create(a);l!=null&&(this.sources[o]=l)}),r.forEach(({from:o,to:a})=>{const l=this.sources[o],u=this.sources[a];l==null||u==null||"setSources"in u&&u.setSources({[o]:l})})}value(){return this.outlet.value()}onChange(e){return this.outlet.onChange(e)}cleanup(){Object.values(this.sources).forEach(e=>e.cleanup?.())}}const Vs=(n,e)=>({variant:"source",props:e,type:zt.TYPE,valueType:n}),Sr=d.z.object({connections:d.z.array(yr),inlet:d.z.string(),segments:d.z.record(d.z.string(),pt)});class Mt extends dn{static TYPE="sink-pipeline";schema=Sr;sinks={};get inlet(){const{inlet:e}=this.props,t=this.sinks[e];if(t==null)throw new g.G(`[SinkPipeline] - expected source to exist at inlet '${e}', but none was found.`);return t}constructor(e,t){super(e);const{connections:r,segments:i}=this.props;Object.entries(i).forEach(([o,a])=>{const l=t.create(a);l!=null&&(this.sinks[o]=l)}),r.forEach(({from:o,to:a})=>{const l=this.sinks[o],u=this.sinks[a];l==null||u==null||"setSinks"in l&&l.setSinks({[a]:u})})}set(...e){return this.inlet.set(...e)}cleanup(){Object.values(this.sinks).forEach(e=>e.cleanup?.())}}const Gs=(n,e)=>({variant:"sink",props:e,type:Mt.TYPE,valueType:n}),Tr=d.z.object({channel:d.z.number().or(d.z.string())});class It extends F{static TYPE="stream-channel-value";schema=Tr;client;removeStreamHandler=null;leadingBuffer=null;valid=!1;onStatusChange;constructor(e,t,r){super(t),this.client=e,this.onStatusChange=r?.onStatusChange}get testingOnlyLeadingBuffer(){return this.leadingBuffer}get testingOnlyValid(){return this.valid}cleanup(){this.removeStreamHandler?.(),this.valid=!1,this.leadingBuffer?.release(),this.leadingBuffer=null,this.removeStreamHandler=null}value(){return s.y.isZero(this.props.channel)?NaN:(this.valid||this.read(),this.leadingBuffer==null||this.leadingBuffer.length===0?NaN:this.leadingBuffer.at(-1,!0))}async read(){try{this.valid=!0,this.removeStreamHandler?.();const e=await this.client.retrieveChannel(this.props.channel),t=r=>{const i=r.get(e.key);if(i==null)return;const o=i.series.at(-1);o!=null&&(o.acquire(),this.leadingBuffer?.release(),this.leadingBuffer=o),this.notify()};this.removeStreamHandler=await this.client.stream(t,[e.key]),this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(s.tn.fromException(e,"failed to stream channel value"))}}}const Xs=async(n,e,t)=>{const r=await n.retrieveChannel(e),i=g.zI.isCalculated(r),o=g.zI.isLegacyCalculated(r);if(!t||r.isIndex)return{key:r.key,dataType:r.dataType,virtual:r.virtual,isCalculated:i};if(o){const a=await g.zI.resolveLegacyCalculatedIndex(n.retrieveChannel.bind(n),r);if(a==null)throw new g.Mn("Failed to resolve calculated index");return{key:(await n.retrieveChannel(a)).key,dataType:s.n.TIMESTAMP,virtual:!1,isCalculated:i}}if(r.virtual&&!i)throw new g.Mn("cannot use virtual channels as a data source");return{key:r.index,dataType:s.n.TIMESTAMP,virtual:!1,isCalculated:i}},go=d.z.object({timeRange:s.m.z,channel:d.z.number().or(d.z.string()),useIndexOfChannel:d.z.boolean().optional().default(!1)});class At extends F{static TYPE="series-source";client;schema=go;data=new s.Oe;valid=!1;channel=null;onStatusChange;constructor(e,t,r){super(t),this.client=e,this.onStatusChange=r?.onStatusChange}cleanup(){this.data.release(),this.valid=!1,this.channel=null}value(){const{channel:e,timeRange:t}=this.props;if(t.span.isZero||e===0)return[s.H.ZERO,this.data];this.valid||this.read();const{channel:r,data:i}=this;if(r==null)return[s.H.ZERO,this.data];let o=i.bounds;return r.dataType.equals(s.n.TIMESTAMP)&&(o=s.H.min([o,t.numericBounds])),[o,i]}async read(){try{this.valid=!0;const{timeRange:e,channel:t,useIndexOfChannel:r}=this.props;this.channel=await Xs(this.client,t,r);const i=await this.client.read(e,this.channel.key);i.acquire(),this.data=i,this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(s.tn.fromException(e,"failed to read channel data"))}}}const mo=d.z.object({channel:d.z.number().or(d.z.string()),useIndexOfChannel:d.z.boolean().optional().default(!1),timeSpan:s.a$1.z,keepFor:s.a$1.z.optional()});class Dt extends F{static TYPE="dynamic-series-source";client;data=new s.Oe([]);now;onStatusChange;channel=null;stopStreaming;valid=!1;schema=mo;constructor(e,t,r,i=()=>s.r.now()){super(t),this.client=e,this.now=i,this.onStatusChange=r?.onStatusChange}value(){const{channel:e,timeSpan:t}=this.props;if(e===0)return[s.H.ZERO,this.data];this.valid||this.read();const{data:r,channel:i}=this,o=this.now();if(i!=null&&i.dataType.isVariable)return[s.H.ZERO,this.data];const a=r.series.filter(u=>u.timeRange.end.after(o.sub(t))).map(u=>u.bounds),l=s.H.max(a);return i!=null&&i.dataType.equals(s.n.TIMESTAMP)&&(l.lower=Math.max(l.lower,l.upper-Number(t.valueOf()))),[l,this.data]}async read(){try{this.valid=!0;const{channel:e,useIndexOfChannel:t,timeSpan:r}=this.props;this.channel=await Xs(this.client,e,t);const i=this.now().spanRange(-r);if(!this.channel.virtual||this.channel.isCalculated)try{const a=await this.client.read(i,this.channel.key);a.acquire(),this.data.push(a)}catch(a){if(a instanceof Error&&(a.message.includes("cannot open iterator on virtual channel")||a.message.includes("cannot read from free channel")))console.warn("failed to read calculated channel data",a);else throw a}this.stopStreaming?.();const o=a=>{if(this.channel==null)return;const l=a.get(this.channel.key);l!=null&&(l.acquire(),this.data.push(l),this.notify(),this.gcOutOfRangeData())};this.stopStreaming=await this.client.stream(o,[this.channel.key]),this.notify()}catch(e){this.valid=!1,this.onStatusChange?.(s.tn.fromException(e,"failed to stream channel data"))}}gcOutOfRangeData(){const e=this.now().sub(this.props.keepFor??this.props.timeSpan),t=this.data.series.findIndex(r=>r.timeRange.end.before(e));t!==-1&&(this.data.series.splice(t,1).forEach(r=>r.release()),this.gcOutOfRangeData())}cleanup(){this.stopStreaming?.(),this.stopStreaming=void 0,this.data.release(),this.valid=!1}}const yo={[At.TYPE]:At,[Dt.TYPE]:Dt,[It.TYPE]:It};class Ks{type="remote";client;constructor(e){this.client=e}create(e,t){const r=yo[e.type];return r==null?null:new r(this.client,e.props,t)}}const Js=n=>({type:At.TYPE,props:n,variant:"source",valueType:"series"}),ei=n=>({type:Dt.TYPE,props:n,variant:"source",valueType:"series"}),ti=n=>({type:It.TYPE,props:n,variant:"source",valueType:"number"});class ni{type="static";create(e){switch(e.type){case qn.TYPE:return new qn(e.props);case Yt.TYPE:return new Yt(e.props);case Nt.TYPE:return new Nt(e.props);case Zt.TYPE:return new Zt(e.props);case jt.TYPE:return new jt(e.props);default:return null}}}const xr=d.z.object({data:d.z.array(s.de),offsets:d.z.array(d.z.number()).optional().default([])});class qn extends F{data;schema=xr;static TYPE="static-series";constructor(e){super(e),this.data=this.props.data.map((t,r)=>new s.T$1({data:t,dataType:s.n.FLOAT32,timeRange:s.m.ZERO,sampleOffset:this.props.offsets[r]??0}))}value(){return[s.H.max(this.data.map(t=>t.bounds)),this.data]}}const ri=xr.extend({rate:s.M.z,yOffset:d.z.number().optional().default(0),scroll:d.z.number().optional().default(0),startPosition:d.z.number().optional().default(0),scrollBounds:d.z.boolean().optional().default(!1)});class Yt extends F{static TYPE="iterative-series";schema=ri;position;interval;data;constructor(e){super(e),this.position=this.props.startPosition,this.start(this.props.rate),this.data=this.props.data.map((t,r)=>new s.T$1({data:t,dataType:s.n.FLOAT32,timeRange:s.m.ZERO,sampleOffset:this.props.offsets[r]??0}))}value(){const e=this.data.map(r=>r.slice(0,this.position));if(this.props.scrollBounds){const r=e[0].data[this.position-this.props.scroll<0?0:this.position-this.props.scroll],i=e[0].data[this.position-1];return[{lower:Number(r),upper:Number(i)},new s.Oe(e)]}return[s.H.max(e.map(r=>r.bounds)),new s.Oe(e)]}start(e){this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{this.notify?.(),this.position++},e.period.milliseconds)}cleanup(){clearInterval(this.interval),this.interval=void 0}}const si=d.z.number();class Nt extends F{static TYPE="static-numeric";schema=si;value(){return this.props}}const ii=d.z.string();class Zt extends F{static TYPE="static-string";schema=ii;value(){return this.props}}const ai=s.zr.crudeZ;class jt extends F{static TYPE="static-color";schema=ai;value(){return s.zr.construct(this.props)}}const bo=n=>({type:qn.TYPE,props:n,variant:"source",valueType:"series"}),vo=n=>({type:Yt.TYPE,props:n,variant:"source",valueType:"series"}),So=n=>({type:Nt.TYPE,props:n,variant:"source",valueType:"number"}),To=n=>({type:Zt.TYPE,props:n,variant:"source",valueType:"string"}),xo=n=>({type:jt.TYPE,props:n,variant:"source",valueType:"color"});class oi{type="transformer";create(e){switch(e.type){case _e.TYPE:return new _e(e.props);case ze.TYPE:return new ze(e.props);case Me.TYPE:return new Me(e.props);case Ie.TYPE:return new Ie(e.props);case Ae.TYPE:return new Ae(e.props);case $t.TYPE:return new $t(e.props);case De.TYPE:return new De(e.props);case Ye.TYPE:return new Ye(e.props)}return null}}const wo=d.z.object({truthy:d.z.number().optional().default(1),falsy:d.z.number().optional().default(0)}),li=n=>({props:n,type:_e.TYPE,variant:"sink",valueType:"boolean"});class _e extends Ws{static TYPE="boolean-numeric-converter-sink";static propsZ=wo;schema=_e.propsZ;transform(...e){return e.map(t=>t?this.props.truthy:this.props.falsy)}}const wr=d.z.object({trueBound:s.H.bounds}),ci=n=>({props:n,type:ze.TYPE,variant:"source",valueType:"boolean"});class ze extends ve{static TYPE="boolean-source";static propsZ=wr;schema=ze.propsZ;curr=null;shouldNotify(e){const t=s.H.contains(this.props.trueBound,e)!==this.curr;return this.curr=s.H.contains(this.props.trueBound,e),t}transform(e){return this.curr=s.H.contains(this.props.trueBound,e),this.curr}}const ui=d.z.object({});class Me extends Qs{static TYPE="mean";static propsZ=ui;schema=Me.propsZ;transform(e){return Object.values(e).reduce((t,r)=>t+r,0)/Object.keys(e).length}}const Eo=n=>({props:n,type:Me.TYPE,variant:"source",valueType:"boolean"}),hi=d.z.object({trueVariant:s.tn.variantZ.optional().default("success")});class Ie extends ve{static TYPE="boolean-status";static propsZ=hi;schema=Ie.propsZ;transform(e){return e.variant===this.props.trueVariant}}const Co=n=>({props:n,type:Ie.TYPE,variant:"source",valueType:"boolean"}),Er=d.z.object({precision:d.z.number().optional().default(2),prefix:d.z.string().optional().default(""),suffix:d.z.string().optional().default(""),notation:s.Yr.notationZ.optional().default("standard")});class Ae extends ve{static TYPE="stringify-number";static propsZ=Er;schema=Ae.propsZ;transform(e){if(isNaN(e))return"";const{precision:t,prefix:r,suffix:i,notation:o}=this.props;return`${r}${s.Yr.stringifyNumber(e,t,o)}${i}`}}const di=n=>({props:n,type:Ae.TYPE,variant:"source",valueType:"string"}),Cr=d.z.object({windowSize:d.z.number().optional().default(5)});class $t extends ve{static TYPE="rolling-average";static propsZ=ui;schema=Cr;values=[];transform(e){return this.props.windowSize<2||isNaN(e)?e:this.values.reduce((t,r)=>t+r,0)/this.values.length}shouldNotify(e){return this.props.windowSize<2?!0:(this.values.length>this.props.windowSize&&(this.values=[]),this.values.push(e),this.values.length===this.props.windowSize)}}const fi=n=>({props:n,type:$t.TYPE,variant:"source",valueType:"number"}),pi=d.z.object({gradient:s.zr.gradientZ});class De extends ve{static TYPE="color-gradient";static propsZ=pi;schema=De.propsZ;transform(e){return s.zr.fromGradient(this.props.gradient,e)}}const gi=n=>({props:n,type:De.TYPE,variant:"source",valueType:"color"}),mi=d.z.object({scale:s.C$1.transform});class Ye extends ve{static TYPE="scale-number";static propsZ=mi;schema=Ye.propsZ;transform(e){if(isNaN(e))return e;const{offset:t,scale:r}=this.props.scale;return e*r+t}}const yi=n=>({props:n,type:Ye.TYPE,variant:"source",valueType:"number"}),Rr=d.z.enum(["average","decimate"]),Ro=d.z.object({mode:Rr,windowSize:d.z.number().optional().default(5)}),Po=n=>({props:n,type:rt.TYPE,variant:"source",valueType:"number"}),bi=(n,e,t)=>{const r=e.length*t;for(let i=r;i<n.length;i+=t){const o=n.sub(i,i+1);o!==void 0&&e.write(o)}},Lo=(n,e,t)=>{const r=e.length*t;for(let i=r;i<n.length&&!(i+t>n.length);i+=t){const o=Math.min(i+t,n.length);let a=0,l=0;for(let u=i;u<o;u++){const c=n.at(u);c!==void 0&&typeof c=="number"&&(a+=c,l++)}l>0&&e.write(new s.T$1({data:[a/l],dataType:n.dataType}))}},ko={decimate:bi,average:Lo};class rt{static TYPE="series-downsampler";_downsample=null;cache=new s.Oe;props;constructor(e){this.props=e}downsample(e){return this._downsample==null&&(e.series[0].sampleOffset!==0?this._downsample=bi:this._downsample=ko[this.props.mode]),this._downsample}transform(e){if(this.props.mode==="decimate"||this.props.windowSize<=1)return e;if(e.series.length===0)return this.cache;for(;this.cache.series.length>0&&!this.cache.series[0].key.startsWith(e.series[0].key);)this.cache.series.shift();return e.series.forEach((t,r)=>{let i=this.cache.series.at(r);if(i==null){const o=Math.ceil(t.capacity/this.props.windowSize);i=s.T$1.alloc({key:t.key+s.Qt.create(),dataType:t.dataType,capacity:o,alignment:t.alignment,alignmentMultiple:BigInt(this.props.windowSize),sampleOffset:t.sampleOffset,timeRange:t.timeRange}),this.cache.push(i)}else if(!i.key.startsWith(t.key))throw new g.qt(`[SeriesDownsampler] - expected series with key ${t.key} to be in cache, but found ${i.key}`);this.downsample(e)(t,i,this.props.windowSize)}),this.cache}}const Oo=n=>({props:n,type:rt.TYPE,variant:"source",valueType:"series"});class Pr{factories;type="compound";constructor(e){this.factories=e}add(e){this.factories=[...this.factories.filter(t=>t.type!==e.type),e]}create(e,t){for(const r of this.factories){const i=r.create(e,t);if(i!=null)return i}return null}}const vi=n=>{const e=[new oi,new ni,new $s],t=new Pr(e);return n!=null&&t.add(new Ks(n)),t.add(new vr(t)),t};let Si=class Ti{factory;key;parent;constructor(e,t){this.factory=e,this.key=s.Qt.create(),this.parent=t}child(e,t){const r=new Pr([...this.factory.factories,...s.a.toArray(e)]);return r.add(new vr(r)),new Ti(r,t)}create(e,t){const r=this.factory.create(e,t);if(r==null)throw new g.qt(`Telemetry service could not find a source for type ${e.type}`);return r}};const gt="pluto-telem-context",fn=n=>n.get(gt),xi=(n,e)=>n.set(gt,e),wi=(n,e,t)=>{const r=fn(n);if(r!=null&&t!=null&&r.key===t?.parent?.key)return t;const i=r.child(e,r);return n.set(gt,i),i};class Ei{spec;wrapped;prevProv;constructor(e,t,r){this.wrapped=e,this.spec=r,this.prevProv=t}shouldUpdate(e,t){return this.prevProv.key!==e.key||!ie.T.equal(this.spec,t)}}class is extends Ei{value(){return this.wrapped.value()}cleanup(){this.wrapped.cleanup?.()}onChange(e){return this.wrapped.onChange(e)}}class as extends Ei{set(...e){this.wrapped.set(...e)}cleanup(){this.wrapped.cleanup?.()}}const B=(n,e,t,r)=>{const i=fn(n);if(t instanceof is){if(!t.shouldUpdate(i,e))return t;t.cleanup?.()}return new is(i.create(e,r),i,e)},He=(n,e,t,r)=>{const i=fn(n);if(t instanceof as){if(!t.shouldUpdate(i,e))return t;t.cleanup?.()}return new as(i.create(e,r),i,e)},_o=d.z.object({props:g.XS.nullable(),state:g.QS.connectivity.connectionStateZ.nullable()}),Lr={client:null};let Bt=class Ci extends g.Composite{static TYPE="synnax.Provider";static stateZ=_o;schema=Ci.stateZ;afterUpdate(e){if(e.wasSetPreviously(kr)||Rn(e,Lr),this.state.props==null){this.internal.client!=null&&(this.internal.client?.close(),this.internal.client=null),Rn(e,this.internal);return}this.prevState.props!=null&&ie.T.equal(this.state.props,this.prevState.props)&&this.internal.client!=null||(this.internal.client=new g.QS(this.state.props),Rn(e,this.internal))}};const kr="pluto-client-context",Rn=(n,e)=>n.set(kr,e),qe=n=>n.get(kr)?.client??null,Ri={[Bt.TYPE]:Bt},zo=Object.freeze(Object.defineProperty({__proto__:null,Provider:Bt,REGISTRY:Ri,ZERO_CONTEXT_VALUE:Lr,use:qe},Symbol.toStringTag,{value:"Module"})),Pi=(n,e)=>n.dataType.isVariable||n.dataType.equals(s.n.UINT8)?n:(e==null&&n.dataType.equals(s.n.TIMESTAMP)&&(e=BigInt(n.data[0])),n.convert(s.n.FLOAT32,e)),Mo=n=>n.isVariable||n.equals(s.n.UINT8)?n:s.n.FLOAT32,Li=()=>({purgedSeries:0,purgedBytes:s.h.bytes(0)}),ki={instrumentation:g.g.NOOP,staleEntryThreshold:s.a$1.seconds(20)};class Io{data=[];props;constructor(e){this.props={...ki,...e}}write(e){e.length!==0&&(e.series.forEach(t=>this.writeOne(Pi(t))),this.checkIntegrity(e))}dirtyRead(e){const t=this.data.filter(({data:a})=>a.timeRange.overlapsWith(e)).map(({data:a})=>a);if(t.length===0)return{series:new s.Oe([]),gaps:[e]};const r=t.map((a,l)=>l===0?s.m.ZERO:new s.m(t[l-1].timeRange.end,a.timeRange.start)).filter(a=>!a.span.isZero&&a.isValid),i=new s.m(e.start,t[0].timeRange.start),o=new s.m(t[t.length-1].timeRange.end,e.end);return i.isValid&&!i.span.isZero&&r.unshift(i),o.isValid&&!o.span.isZero&&r.push(o),{series:new s.Oe(t),gaps:r}}gc(){const{staleEntryThreshold:e}=this.props,t=Li(),r=this.data.filter(i=>{const o=i.data.refCount>0||s.r.since(i.addedAt).lessThan(e);return o||(t.purgedBytes=t.purgedBytes.add(i.data.byteCapacity)),o});return t.purgedSeries=this.data.length-r.length,this.data=r,t}close(){this.data=[]}writeOne(e){const{instrumentation:{L:t}}=this.props;if(e.length===0)return;const r=s.H.buildInsertionPlan(this.data.map(u=>u.data.alignmentBounds),e.alignmentBounds);if(r===null)return t.debug("Found no viable insertion plan",{inserting:e.digest,cacheContents:this.data.map(u=>u.data.digest)});const{removeBefore:i,removeAfter:o,insertInto:a,deleteInBetween:l}=r;e=e.slice(i,e.data.length-o),e.length!==0&&this.data.splice(a,l,{data:e,addedAt:s.r.now()})}checkIntegrity(e){const{instrumentation:{L:t}}=this.props,r=this.data.map(o=>o.data.alignmentBounds);if(r.some((o,a)=>r.some((l,u)=>a===u?!1:s.H.overlapsWith(o,l))))throw t.debug("Cache is in an invalid state - bounds overlap!",()=>({write:e.series.map(o=>o.digest),cacheContents:this.data.map(o=>o.data.digest)})),new Error("Invalid state")}}const Ao=100,Do=1e6,Yo=1e4,No=100,Zo=40;class jo{props;counter=0;curr;avgRate=0;timeOfLastWrite;totalWrites=0;now=()=>s.r.now();constructor(e){this.props=e,this.curr=null,e.now!=null&&(this.now=e.now),this.timeOfLastWrite=this.now()}get length(){return this.curr?.length??0}get leadingBuffer(){return this.curr}write(e){const t=e.series.flatMap(r=>this._write(r));return{flushed:new s.Oe(t.flatMap(r=>r.flushed.series)),allocated:new s.Oe(t.flatMap(r=>r.allocated.series))}}allocate(e,t,r){this.counter++;const i=this.props.dataType.isVariable,o=this.props.dataType.equals(s.n.TIMESTAMP);return s.T$1.alloc({capacity:i?e*Zo:e,dataType:Mo(this.props.dataType),timeRange:r.range(s.r.MAX),sampleOffset:o?r.valueOf():0,glBufferUsage:"dynamic",alignment:t,key:`dynamic-${this.counter}`})}_write(e){const t=this.nextBufferSize(),r={flushed:new s.Oe([]),allocated:new s.Oe([])};if(this.curr==null)this.curr=this.allocate(t,e.alignment,this.now()),r.allocated.push(this.curr);else if(Math.abs(Number(this.curr.alignment+BigInt(this.curr.length)-e.alignment))>1){const u=this.now();this.curr.timeRange.end=u,r.flushed.push(this.curr),this.curr=this.allocate(t,e.alignment,u),r.allocated.push(this.curr)}const i=Pi(e,this.curr.sampleOffset),o=this.curr.write(i);if(o===e.length)return this.updateAvgRate(e),r;const a=this.now();this.curr.timeRange.end=a,r.flushed.push(this.curr),this.curr=this.allocate(t,e.alignment+BigInt(o),a),r.allocated.push(this.curr);const l=this._write(e.slice(o));return r.flushed.push(l.flushed),r.allocated.push(l.allocated),r}updateAvgRate(e){if(typeof this.props.dynamicBufferSize=="number")return;const t=e.length/this.now().span(this.timeOfLastWrite).seconds;this.totalWrites>0&&isFinite(t)&&t>0&&(this.avgRate=(this.avgRate*(this.totalWrites-1)+t)/this.totalWrites),this.totalWrites++,this.timeOfLastWrite=this.now()}nextBufferSize(){const{dynamicBufferSize:e}=this.props;if(typeof e=="number")return e;if(this.totalWrites<No)return Yo;const t=s.Lr.roundToNearestMagnitude(this.avgRate*e.seconds);return Math.round(Math.max(Math.min(t,Do),Ao))}close(){this.curr=null}}class $o{channel;closed=!1;ins;static;dynamic;constructor(e){this.channel=e.channel,this.ins=e.instrumentation??g.g.NOOP,this.static=new Io(e),this.dynamic=new jo({dynamicBufferSize:e.dynamicBufferSize,dataType:this.channel.dataType})}writeDynamic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted dynamic write to a closed cache for channel ${this.channel.name}`),new s.Oe([]);const{flushed:t,allocated:r}=this.dynamic.write(e);return t.length>0&&this.static.write(t),r}get leadingBuffer(){return this.dynamic.leadingBuffer}writeStatic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted static write to a closed cache for channel ${this.channel.name}`);this.static.write(e)}read(e){return this.closed?(this.ins.L.warn(`Ignoring attempted dirty read from a closed cache for channel ${this.channel.name}`),{series:new s.Oe([]),gaps:[e]}):this.static.dirtyRead(e)}gc(){return this.closed?(this.ins.L.warn(`Ignoring attempted garbage collection on a closed cache for channel ${this.channel.name}`),{purgedSeries:0,purgedBytes:s.h.bytes(0)}):this.static.gc()}close(){this.closed=!0,this.dynamic.close(),this.static.close()}}const Bo=g.A.seconds(60);class Uo{props;cache=new Map;gcInterval;constructor(e){this.props={dynamicBufferSize:Bo,gcInterval:g.A.seconds(30),...ki,...e},this.gcInterval=setInterval(()=>this.gc(),this.props.gcInterval.milliseconds)}async populateMissing(e){const{instrumentation:t,channelRetriever:r,dynamicBufferSize:i}=this.props,o=[];for(const l of e)this.cache.has(l)||o.push(l);if(o.length===0)return;(await r.retrieve(o)).forEach(l=>{if(this.cache.has(l.key))return;const u=new $o({channel:l,dynamicBufferSize:i,instrumentation:t.child(`cache-${l.name}-${l.key}`)});this.cache.set(l.key,u)})}get(e){const t=this.cache.get(e);if(t!=null)return t;throw new g.qt(`cache entry for ${e} not found`)}gc(){const{instrumentation:{L:e}}=this.props;e.info("starting garbage collection");const t=Li();this.cache.forEach(r=>{const i=r.gc();t.purgedSeries+=i.purgedSeries,t.purgedBytes=t.purgedBytes.add(i.purgedBytes)}),e.info("garbage collection complete",{purgedSeries:t.purgedSeries,purgedBytes:t.purgedBytes.toString()},!0)}close(){clearInterval(this.gcInterval),this.cache.forEach(e=>e.close()),this.cache.clear()}}class Ho{args;debouncedRead;mu=s.nn.newMutex({requests:new Set,closed:!1});constructor(e){this.args={...e,instrumentation:e.instrumentation??g.g.NOOP,batchDebounce:e.batchDebounce??s.a$1.milliseconds(50),overlapThreshold:e.overlapThreshold??s.a$1.milliseconds(5)};const t=this.args.batchDebounce.milliseconds;this.debouncedRead=cr.o(()=>void this.batchRead(),t)}async read(e,t){const{cache:r}=this.args;await r.populateMissing([t]);const i=r.get(t),{series:o,gaps:a}=i.read(e);if(a.length===0)return o;const{mu:l}=this;return await new Promise((u,c)=>{l.runExclusive(async()=>{l.closed||l.requests.add({channel:t,gaps:a,resolve:u,reject:c})}),this.debouncedRead()}),i.read(e).series}async batchRead(){const{readRemote:e,cache:t,overlapThreshold:r}=this.args,{mu:i}=this;await i.runExclusive(async()=>{const o=a=>i.requests.forEach(({resolve:l,reject:u})=>a==null?l():u(a));try{if(i.closed)return o();const a=[];i.requests.forEach(({channel:l,gaps:u})=>u.forEach(c=>{const h=a.find(f=>f.gap.equals(c,r));h==null?a.push({gap:c,channels:new Set([l])}):(h.channels.add(l),h.gap=s.m.max(h.gap,c))})),await Promise.all(a.map(async({gap:l,channels:u})=>{const c=await e(l,Array.from(u));u.forEach(h=>t.get(h).writeStatic(c.get(h)))})),o()}catch(a){o(a)}finally{i.requests.clear()}})}async close(){await this.mu.runExclusive(async()=>{this.mu.closed=!0})}}const qo=new Error("request for lock canceled");var Fo=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function l(h){try{c(r.next(h))}catch(f){a(f)}}function u(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?o(h.value):i(h.value).then(l,u)}c((r=r.apply(n,e||[])).next())})};class Qo{constructor(e,t=qo){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,i)=>{const o={resolve:r,reject:i,weight:e,priority:t},a=Oi(this._queue,l=>t<=l.priority);a===-1&&e<=this._value?this._dispatchItem(o):this._queue.splice(a+1,0,o)})}runExclusive(e){return Fo(this,arguments,void 0,function*(t,r=1,i=0){const[o,a]=yield this.acquire(r,i);try{return yield t(o)}finally{a()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Wo(this._weightedWaiters[e-1],{resolve:r,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const r=this._weightedWaiters[t-1];if(!r)continue;const i=r.findIndex(o=>o.priority<=e);(i===-1?r:r.splice(0,i)).forEach((o=>o.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Wo(n,e){const t=Oi(n,r=>e.priority<=r.priority);n.splice(t+1,0,e)}function Oi(n,e){for(let t=n.length-1;t>=0;t--)if(e(n[t]))return t;return-1}var Vo=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function l(h){try{c(r.next(h))}catch(f){a(f)}}function u(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?o(h.value):i(h.value).then(l,u)}c((r=r.apply(n,e||[])).next())})};class Go{constructor(e){this._semaphore=new Qo(1,e)}acquire(){return Vo(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Xo=s.a$1.milliseconds(100).milliseconds;class Ko{props;mu=new Go;listeners=new Map;debouncedUpdateStreamer;streamerRunLoop=null;streamer=null;closed=!1;constructor(e){this.props={instrumentation:g.g.NOOP,...e,streamUpdateDelay:new s.a$1(e.streamUpdateDelay??s.a$1.seconds(5))},this.debouncedUpdateStreamer=cr.o(()=>void this.updateStreamer(),Xo)}async stream(e,t){const{cache:r,instrumentation:i}=this.props;return this.closed?()=>{}:(await r.populateMissing(t),await this.mu.runExclusive(async()=>{i.L.debug("adding stream handler",{keys:t}),this.listeners.set(e,{valid:!0,keys:new Set(t)});const o=new Map(t.map(a=>{const l=r.get(a);return[a,new s.Oe(s.a.toArray(l.leadingBuffer))]}));return e(o),this.debouncedUpdateStreamer(),()=>this.removeStreamHandler(e)}))}removeStreamHandler(e){const{instrumentation:t}=this.props;this.mu.runExclusive(()=>{const r=this.listeners.get(e);r!=null&&(r.valid=!1)}),setTimeout(()=>{this.mu.runExclusive(async()=>{if(t.L.debug("removing stream handler"),this.listeners.delete(e))return this.debouncedUpdateStreamer();t.L.warn("attempted to remove non-existent stream handler")})},this.props.streamUpdateDelay.milliseconds)}async updateStreamer(){if(this.closed)return;const{instrumentation:e}=this.props;try{const t=new Set;if(this.listeners.forEach(o=>o.keys.forEach(a=>t.add(a))),t.size===0){e.L.info("no keys to stream, closing streamer"),this.streamer?.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.streamer=null,e.L.info("streamer closed successfully");return}const r=Array.from(t);if(ie.q.primitiveArrays(r,this.streamer?.keys??[])===ie.q.EQUAL){e.L.debug("streamer keys unchanged",{keys:r});return}this.streamer==null&&(e.L.info("creating new streamer",{keys:r}),this.streamer=await this.props.openStreamer({channels:r}),this.streamerRunLoop=this.runStreamer(this.streamer)),e.L.debug("updating streamer",{prev:this.streamer.keys,next:r}),await this.streamer.update(r)}catch(t){throw e.L.error("failed to update streamer",{error:t}),t}}async runStreamer(e){const{cache:t,instrumentation:r}=this.props;try{for await(const i of e){const o=new Map;for(const a of i.keys){const l=i.get(a),c=t.get(a).writeDynamic(l);o.set(a,c)}o.size!==0&&this.listeners.forEach(({valid:a},l)=>a&&l(o))}}catch(i){throw r.L.error("streamer run loop failed",{error:i},!0),i}}async close(){const{instrumentation:e}=this.props;try{this.streamer?.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop}catch(t){e.L.error("failed to close streamer",{error:t})}this.closed=!0}}class Jo{async retrieveChannel(){throw new g.Mn("NoopClient does not support retrieving channels")}async read(){return new s.Oe([])}async stream(){return async()=>{}}async close(){}}class el{ins;cache;reader;streamer;channelRetriever;constructor({instrumentation:e,core:t}){this.ins=e,this.channelRetriever=t.channels.createDebouncedBatchRetriever(10),this.cache=new Uo({channelRetriever:this.channelRetriever,instrumentation:this.ins.child("cache")}),this.reader=new Ho({cache:this.cache,readRemote:t.read.bind(t),instrumentation:this.ins.child("reader")}),this.streamer=new Ko({cache:this.cache,openStreamer:async r=>g.YI.HardenedStreamer.open(t.openStreamer.bind(t),r),instrumentation:this.ins.child("streamer")})}async retrieveChannel(e){const t=await this.channelRetriever.retrieve([e]);if(t.length===0)throw new g.rt(`channel ${e} not found`);return t[0]}async read(e,t){return await this.reader.read(e,t)}async stream(e,t){return await this.streamer.stream(e,t)}async close(){this.ins.L.info("closing client"),await this.streamer.close(),await this.reader.close(),this.cache.close()}}const Or=d.z.object({});class Ne extends g.Composite{static TYPE="telem.Provider";static stateZ=Or;schema=Ne.stateZ;prevCore=null;client=null;afterUpdate(e){const{internal:t}=this,r=qe(e),i=g.useErrorHandler(e);if(t.instrumentation=A.useInstrumentation(e,"telem").child("provider"),!(r!==this.prevCore||!e.wasSetPreviously(gt)))return;this.prevCore=r,this.client!=null&&i(async()=>{if(this.client==null)throw new Error("no client to close");await this.client.close()},"failed to close client"),this.client=r==null?new Jo:new el({core:r,instrumentation:t.instrumentation});const a=vi(this.client),l=new Si(a);xi(e,l)}}const _i={[Ne.TYPE]:Ne},tl=Object.freeze(Object.defineProperty({__proto__:null,AbstractSink:dn,AbstractSource:F,Base:hn,BaseProvider:Ne,BooleanStatus:Ie,CONTEXT_KEY:gt,ChannelData:At,ColorGradient:De,CompoundTelemFactory:Pr,Context:Si,FixedColorSource:jt,FixedNumber:Nt,FixedString:Zt,IterativeSeries:Yt,Mean:Me,MultiSourceTransformer:Qs,NoopFactory:$s,PipelineFactory:vr,REGISTRY:_i,RemoteFactory:Ks,RollingAverage:$t,ScaleNumber:Ye,SeriesDownsampler:rt,SetPoint:_e,SinkPipeline:Mt,SourcePipeline:zt,StaticFactory:ni,StreamChannelData:Dt,StreamChannelValue:It,StringifyNumber:Ae,TransformerFactory:oi,UnarySinkTransformer:Ws,UnarySourceTransformer:ve,WithinBounds:ze,booleanSinkSpecZ:ln,booleanSinkTransformerSpecZ:fo,booleanSourceSpecZ:gr,booleanSourceTransformerSpecZ:po,booleanStatus:Co,booleanStatusProps:hi,channelData:Js,colorGradient:gi,colorGradientProps:pi,colorSourceSpecZ:cn,connectionZ:yr,createFactory:vi,downsampleMode:Po,downsampleModeProps:Ro,downsampleModeZ:Rr,fixedArray:bo,fixedColor:xo,fixedColorSourcePropsZ:ai,fixedNumber:So,fixedNumberPropsZ:si,fixedSeriesPropsZ:xr,fixedString:To,fixedStringPropsZ:ii,iterativeArray:vo,iterativeSeriesPropsZ:ri,mean:Eo,noopBooleanSinkSpec:on,noopBooleanSourceSpec:dr,noopColorSourceSpec:dt,noopNumericSinkSpec:Ys,noopNumericSourceSpec:Ns,noopSeriesSourceSpec:js,noopStatusSourceSpec:pr,noopStringSinkSpec:Zs,noopStringSourceSpec:fr,numberSinkSpecZ:qs,numberSourceSpecZ:Hs,providerStateZ:Or,rollingAverage:fi,rollingAverageProps:Cr,scaleNumber:yi,scaleNumberProps:mi,seriesDownsampler:Oo,seriesSourceSpecZ:_t,setContext:xi,setpoint:li,sinkPipeline:Gs,sinkPipelinePropsZ:Sr,sinkSpecZ:pt,sinkTransformerSpecZ:Us,sourcePipeline:Vs,sourcePipelinePropsZ:br,sourceSpecZ:ue,sourceTransformerSpecZ:Bs,specZ:ft,statusSourceSpecZ:mr,streamChannelData:ei,streamChannelValue:ti,streamChannelValuePropsZ:Tr,stringSinkSpecZ:Fs,stringSourceSpecZ:un,stringifyNumber:di,stringifyNumberProps:Er,useChildContext:wi,useContext:fn,useSink:He,useSource:B,withinBounds:ci,withinBoundsProps:wr},Symbol.toStringTag,{value:"Module"})),os=`#version 300 es
3
+ precision lowp float;
4
+
5
+ uniform lowp vec4 u_color;
6
+ out vec4 fragColor;
7
+
8
+ void main(void) {
9
+ fragColor = u_color;
10
+ }
11
+ `,nl=`#version 300 es
12
+
13
+ // Copyright 2025 Synnax Labs, Inc.
14
+ //
15
+ // Use of this software is governed by the Business Source License included in the file
16
+ // licenses/BSL.txt.
17
+ //
18
+ // As of the Change Date specified in that file, in accordance with the Business Source
19
+ // License, use of this software will be governed by the Apache License, Version 2.0,
20
+ // included in the file licenses/APL.txt.
21
+
22
+ in mediump float a_x;
23
+ in mediump float a_y;
24
+ in mediump vec2 a_translate;
25
+
26
+ uniform mediump vec2 u_scale_aggregate;
27
+ uniform mediump vec2 u_offset_aggregate;
28
+
29
+ void main(void) {
30
+ gl_Position = vec4((u_scale_aggregate * vec2(a_x, a_y) + u_offset_aggregate) + a_translate, 0.0, 1.0);
31
+ }
32
+ `,rl=`#version 300 es
33
+
34
+ // Copyright 2025 Synnax Labs, Inc.
35
+ //
36
+ // Use of this software is governed by the Business Source License included in the file
37
+ // licenses/BSL.txt.
38
+ //
39
+ // As of the Change Date specified in that file, in accordance with the Business Source
40
+ // License, use of this software will be governed by the Apache License, Version 2.0,
41
+ // included in the file licenses/APL.txt.
42
+
43
+ in mediump float a_x;
44
+ in mediump uint a_y;
45
+ in mediump vec2 a_translate;
46
+
47
+ uniform mediump vec2 u_scale_aggregate;
48
+ uniform mediump vec2 u_offset_aggregate;
49
+
50
+ void main(void) {
51
+ gl_Position = vec4((u_scale_aggregate * vec2(a_x, float(a_y)) + u_offset_aggregate) + a_translate, 0.0, 1.0);
52
+ }
53
+ `,_r="pluto-vis-renderer",pn=(n,e)=>{n.set(_r,e,!1)},gn=n=>n.get(_r),zr=n=>n.getOptional(_r),ae=(n,e)=>gn(n)(e),zi=d.z.object({x:_t,y:_t,label:d.z.string().optional(),color:s.zr.colorZ,strokeWidth:d.z.number().default(1),downsample:d.z.number().min(1).max(50).default(1),downsampleMode:Rr.default("decimate"),visible:d.z.boolean().optional().default(!0)}),sl=(n,e,t)=>n===-1||e===-1||n>=t.series.length?NaN:Number(t.series[n].at(e)),il=s.a$1.milliseconds(2);s.Q.NAN,s.Q.NAN,s.zr.ZERO,s.H.ZERO;const al=(n,e)=>e.equals(s.n.UINT8)?n.UNSIGNED_BYTE:n.FLOAT;class ls extends A.GLProgram{translationBufferCache=new Map;constructor(e,t,r){super(e,t,r),this.translationBufferCache=new Map}bindState({strokeWidth:e,color:t}){return this.uniformColor("u_color",t),this.attrStrokeWidth(e)}bindScale(e,t){const r=s.Q.scale(e.scale,t.scale),i=s.Q.translate(s.Q.scale(t.scale,e.offset),t.offset);this.uniformXY("u_scale_aggregate",r),this.uniformXY("u_offset_aggregate",i)}draw({x:e,y:t,count:r,downsample:i,xOffset:o,yOffset:a},l,u,c){const{gl:h}=this.renderCtx;this.bindAttrBuffer("x",e.glBuffer,i,o,u),this.bindAttrBuffer("y",t.glBuffer,i,a,c),h.drawArraysInstanced(h.LINE_STRIP,0,r/i,l)}bindAttrBuffer(e,t,r,i=0,o){const{gl:a}=this.renderCtx;a.bindBuffer(a.ARRAY_BUFFER,t);const l=a.getAttribLocation(this.prog,`a_${e}`),u=al(a,o),c=o.density.valueOf();o.equals(s.n.UINT8)?a.vertexAttribIPointer(l,1,u,c*r,c*i):a.vertexAttribPointer(l,1,u,!1,c*r,c*i),a.enableVertexAttribArray(l)}getAndBindTranslationBuffer(e){const{gl:t}=this.renderCtx,r=`${this.renderCtx.aspect}:${e}`,i=this.translationBufferCache.get(r);if(i!=null)return t.bindBuffer(t.ARRAY_BUFFER,i.glBuffer),i;const o=t.createBuffer();if(o==null)throw new g.qt("Failed to create buffer from WebGL context");const a=ll(this.renderCtx.aspect,e);t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,a,t.DYNAMIC_DRAW);const l={glBuffer:o,jsBuffer:a};return this.translationBufferCache.set(r,l),l}attrStrokeWidth(e){const{gl:t}=this.renderCtx,{jsBuffer:r}=this.getAndBindTranslationBuffer(e),i=t.getAttribLocation(this.prog,"a_translate");return t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(i),t.vertexAttribDivisor(i,1),r.length/2}}class ke{static CONTEXT_KEY="pluto-line-gl-program";uint8HybridProgram;float32Program;constructor(e){this.uint8HybridProgram=new ls(e,rl,os),this.float32Program=new ls(e,nl,os)}get gl(){return this.uint8HybridProgram.renderCtx.gl}getProgram(e){return e.equals(s.n.UINT8)?this.uint8HybridProgram:this.float32Program}static create(e,t){const r=new ke(t);return e.set(ke.CONTEXT_KEY,r),r}static use(e){const t=e.get(ke.CONTEXT_KEY);if(t==null)throw new g.qt("GLProgram not found");return t}}class Ut extends g.Leaf{static TYPE="line";schema=zi;afterUpdate(e){const{internal:t}=this,r={onStatusChange:g.useAdder(e)};t.xTelem=B(e,this.state.x,t.xTelem,r),t.yTelem=B(e,this.state.y,t.yTelem,r),t.instrumentation=A.useInstrumentation(e,"line"),t.lineCtx=ke.use(e),t.requestRender=gn(e),t.stopListeningXTelem?.(),t.stopListeningYTelem?.(),t.stopListeningXTelem=t.xTelem.onChange(()=>t.requestRender("data")),t.stopListeningYTelem=t.yTelem.onChange(()=>t.requestRender("data")),t.requestRender("layout"),(t.xDownsampler?.props.mode!==this.state.downsampleMode||t.xDownsampler?.props.windowSize!==this.state.downsample)&&(t.xDownsampler=new rt({mode:this.state.downsampleMode,windowSize:this.state.downsample}),t.yDownsampler=new rt({mode:this.state.downsampleMode,windowSize:this.state.downsample}))}afterDelete(){const{internal:e}=this;e.xTelem.cleanup?.(),e.yTelem.cleanup?.(),e.requestRender("layout")}xBounds(){return this.internal.xTelem.value()[0]}yBounds(){return this.internal.yTelem.value()[0]}findByXValue(e,t){const{xTelem:r,yTelem:i}=this.internal;let[,o]=r.value();o=this.internal.xDownsampler.transform(o);let[a,l]=[-1,-1];o.series.find((T,E)=>{const P=T.binarySearch(t),C=P>=0&&P<T.length;return C&&([a,l]=[P,E]),C});const{key:u}=this,{color:c,label:h}=this.state,f={key:u,color:c,label:h,position:{x:0,y:0},value:{x:NaN,y:NaN},bounds:{lower:0,upper:0}};if(a===-1||l===-1||!this.state.visible)return f;const p=o.series[l];f.value.x=sl(l,a,o);let[,y]=i.value();y=this.internal.yDownsampler.transform(y);const v=y.series.find(T=>s.H.contains(T.alignmentBounds,p.alignment+BigInt(a)));if(v==null)return f;const b=Number(v.alignment-p.alignment);return f.value.y=Number(v.at(a-b)),f.bounds={...v.bounds},f.position={x:e.dataToDecimalScale.x.pos(f.value.x),y:e.dataToDecimalScale.y.pos(f.value.y)},f}render(e){if(this.deleted||!this.state.visible)return;const{downsample:t}=this.state,{xTelem:r,yTelem:i,lineCtx:o,xDownsampler:a,yDownsampler:l}=this.internal,{dataToDecimalScale:u,exposure:c}=e;let[[,h],[,f]]=[r.value(),i.value()];if(h=a.transform(h),f=l.transform(f),h.updateGLBuffer(o.gl),f.updateGLBuffer(o.gl),h.length===0||f.length===0)return;const p=o.getProgram(f.dataType),y=pl(h,f,c,t,this.state.downsampleMode,il);this.internal.instrumentation.L.debug("render",()=>({key:this.key,downsample:t,scale:u.transform,props:e.region,ops:gl(y)}));const v=p.setAsActive(),b=p.bindState(this.state),T=p.renderCtx.scaleRegion(e.region).transform;y.forEach(E=>{const P=dl(u,E).transform;p.bindScale(P,T),p.draw(E,b,h.dataType,f.dataType)}),v()}}const ol=5e3,ll=(n,e)=>hl(ul(n),e).map((t,r)=>Math.floor(r/cl)*(1/(ol*n))*t),cl=5,ul=n=>new Float32Array([0,0,0,n,0,-n,1,0,-1,0]),hl=(n,e)=>{const t=new Float32Array(n.length*e);for(let r=0;r<e;r++)t.set(n,r*n.length);return t},dl=(n,e)=>n.translate(n.x.dim(Number(e.x.sampleOffset)),n.y.dim(Number(e.y.sampleOffset))),fl={[Ut.TYPE]:Ut},pl=(n,e,t,r,i,o)=>{if(n.series.length===0||e.series.length===0)return[];const a=[];return n.series.forEach(l=>e.series.forEach(u=>{if(!ml(l,u,o))return;let c=0n,h=0n;l.alignment<u.alignment?c=u.alignment-l.alignment:u.alignment<l.alignment&&(h=l.alignment-u.alignment);const f=s.Lr.min(s.H.span(l.alignmentBounds)-c,s.H.span(u.alignmentBounds)-h);if(f===0n)return;let p=s.R(Math.round(t*4*Number(f)),r,51);i!=="decimate"&&(p=1);const y=Number(f/l.alignmentMultiple),v=Number(c/l.alignmentMultiple),b=Number(h/u.alignmentMultiple);a.push({x:l,y:u,xOffset:v,yOffset:b,count:y,downsample:p})})),a},gl=n=>n.map(e=>({...e,x:e.x.digest,y:e.y.digest})),ml=(n,e,t)=>{if(n.alignmentMultiple!==e.alignmentMultiple)return console.warn("encountered two series with different alignment multiples in draw operations",{x:n.digest,y:e.digest}),!1;const r=n.timeRange.overlapsWith(e.timeRange,t),i=s.H.overlapsWith(n.alignmentBounds,e.alignmentBounds);return r&&i},Mr=d.z.object({dpr:d.z.number(),region:s.jt.box,bootstrap:d.z.boolean().optional().default(!1),bootstrapped:d.z.boolean().optional().default(!1),glCanvas:d.z.any().optional(),upper2dCanvas:d.z.any().optional(),lower2dCanvas:d.z.any().optional(),os:s.S.osZ});class Ht extends g.Composite{static TYPE="Canvas";schema=Mr;renderCtx=null;afterUpdate(e){if(this.renderCtx==null){if(!this.state.bootstrap)return;const{glCanvas:t,lower2dCanvas:r,upper2dCanvas:i,os:o}=this.state;if(t==null||r==null||i==null)throw new g.qt("[vis.worker.Canvas] - expected render context bootstrap to include all canvases");this.renderCtx=A.Context.create(e,t,r,i,o),ke.create(e,this.renderCtx),this.setState(a=>({...a,bootstrap:!1,bootstrapped:!0,glCanvas:void 0,lower2dCanvas:void 0,upper2dCanvas:void 0}))}else this.renderCtx.update(e);this.renderCtx.resize(this.state.region,this.state.dpr)}}const Mi={[Ht.TYPE]:Ht},yl=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Ht,REGISTRY:Mi,canvasStateZ:Mr},Symbol.toStringTag,{value:"Module"})),Ir=d.z.object({position:s.Q.xy,zoom:d.z.number(),region:s.jt.box,clearOverScan:s.Q.crudeZ.optional().default(5),visible:d.z.boolean().optional().default(!0),autoRenderInterval:d.z.number().optional()}),xt=["upper2d","lower2d"];class ye extends g.Composite{static TYPE="Diagram";static stateZ=Ir;schema=ye.stateZ;afterUpdate(e){this.internal.renderCtx=A.Context.use(e),this.internal.handleError=g.useErrorHandler(e),s.y.isNonZero(this.state.autoRenderInterval)&&(this.internal.autoRenderInterval??=setInterval(()=>{this.state.visible&&this.requestRender("low")},this.state.autoRenderInterval)),pn(e,()=>{this.state.visible&&this.requestRender("low")}),!(!this.state.visible&&!this.prevState.visible)&&(this.internal.viewportScale=s.C$1.XY.magnify(s.Q.construct(this.state.zoom)).translate(s.jt.topLeft(this.state.region)).translate(this.state.position),this.requestRender("high"))}afterDelete(){this.internal.autoRenderInterval!=null&&clearInterval(this.internal.autoRenderInterval),this.requestRender("high")}render(){if(this.deleted)return;const{renderCtx:e,handleError:t,viewportScale:r}=this.internal,i=s.jt.construct(this.state.region);if(!this.state.visible)return()=>e.erase(i,this.state.clearOverScan,...xt);const o=e.scissor(i,s.Q.ZERO,xt);try{this.children.forEach(l=>l.render?.({viewportScale:r}))}catch(l){t(l,"failed to render diagram")}finally{o()}const a=s.jt.copy(this.state.region);return()=>{e.lower2d.fillStyle=s.zr.hex(s.zr.BLACK),e.lower2d.fillRect(...s.Q.couple(s.jt.topLeft(a)),s.jt.width(a),s.jt.height(a)),e.erase(a,this.state.clearOverScan,...xt)}}requestRender(e){const{renderCtx:t}=this.internal;t.loop.set({key:`${ye.TYPE}-${this.key}`,render:this.render.bind(this),priority:e,canvases:xt})}}const Ii={[ye.TYPE]:ye},bl=Object.freeze(Object.defineProperty({__proto__:null,Diagram:ye,REGISTRY:Ii,diagramStateZ:Ir},Symbol.toStringTag,{value:"Module"}));class Ai{entries=new Map;setListeners=new Map;deleteListeners=new Map;handleError;equal;constructor(e,t=()=>!1){this.handleError=e,this.equal=t}setOne(e,t,r,i){const o=this.entries.get(t),a=ge.executeSetter(r,o);if(!(a==null||o!=null&&this.equal(a,o,t)))return this.entries.set(t,a),this.notifySet(e,t,a,i),()=>{o===void 0?(this.entries.delete(t),this.notifyDelete(e,t)):(this.entries.set(t,o),this.notifySet(e,t,o,i))}}set(e,t,r,i){const o=[];if(Array.isArray(t))t.forEach(a=>{const l=this.setOne(e,a.key,a,r);l!=null&&o.push(l)});else if(typeof t=="object"&&"key"in t){const a=t,l=this.setOne(e,a.key,a,r);l!=null&&o.push(l)}else{const a=this.setOne(e,t,r,i);a!=null&&o.push(a)}return()=>o.reverse().forEach(a=>a())}get(e){return typeof e=="function"?Array.from(this.entries.values()).filter(e):Array.isArray(e)?e.map(t=>this.entries.get(t)).filter(t=>t!=null):this.entries.get(e)}list(){return Array.from(this.entries.values())}has(e){return Array.isArray(e)?e.every(t=>this.entries.has(t)):this.entries.has(e)}delete(e,t,r){const i=[];return typeof t=="function"?this.entries.forEach((o,a)=>{t(o,a)&&i.push({key:a,value:o})}):s.a.toArray(t).forEach(o=>{const a=this.entries.get(o);i.push({key:o,value:a})}),i.forEach(({key:o})=>{this.entries.delete(o),this.notifyDelete(e,o)}),()=>i.forEach(({key:o,value:a})=>{a!=null&&(this.entries.set(o,a),this.notifySet(e,o,a,r))})}clear(){this.entries.clear()}onSet(e,t,r){return this.setListeners.set(t,{scope:e,key:r}),()=>this.setListeners.delete(t)}onDelete(e,t,r){return this.deleteListeners.set(t,{scope:e,key:r}),()=>this.deleteListeners.delete(t)}notifySet(e,t,r,i){this.setListeners.forEach((o,a)=>{const l=o.key==null||o.key===t,u=o.scope!==e;l&&u&&this.handleError(async()=>await a(r,i),"Failed to notify set listener")})}notifyDelete(e,t){this.deleteListeners.forEach((r,i)=>{const o=r.key==null||r.key===t,a=r.scope!==e;o&&a&&this.handleError(async()=>await i(t),"Failed to notify delete listener")})}scope(e){return{set:(t,r,i)=>this.set(e,t,r,i),get:(t=>this.get(t)),list:()=>this.list(),has:t=>this.has(t),delete:(t,r)=>this.delete(e,t,r),onSet:(t,r)=>this.onSet(e,t,r),onDelete:(t,r)=>this.onDelete(e,t,r)}}}const Di=(n,e)=>Object.fromEntries(Object.entries(n).map(([t,{equal:r}])=>[t,new Ai(e,r)])),Fn=(n,e)=>Object.fromEntries(Object.entries(n).map(([t])=>[t,n[t].scope(e)])),vl=(n,e,t)=>n.set(e,r=>r==null?void 0:{...r,...t}),Sl=(n,e)=>{const t=n.includes("delete"),r=e.includes("delete");return t&&!r?-1:!t&&r?1:0},Tl=async({openStreamer:n,storeConfig:e,handleError:t,client:r,store:i})=>{const o=Object.values(e),a=s.c.unique(o.flatMap(({listeners:f})=>f.map(({channel:p})=>p))),l={};o.forEach(({listeners:f})=>f.forEach(p=>{const{channel:y}=p;l[y]=[...l[y]||[],p]}));const u=await g.YI.HardenedStreamer.open(n,a),c=new g.YI.ObservableStreamer(u),h=f=>{const p=[...f.uniqueNames];p.sort(Sl),t(async()=>{for(const y of p){const v=f.get(y),b=l[y];if(b!=null)for(const{onChange:T,schema:E}of b)await t(async()=>{let P;v.dataType.equals(s.n.JSON)?P=v.parseJSON(E):P=Array.from(v).map(C=>E.parse(C));for(const C of P)await t(()=>T({changed:C,client:r,store:i}),`Failed to handle streamer change for ${y}`,g.Mn)},`Failed to parse streamer change for ${y}`)}},`Failed to handle streamer change for ${s.rn.naturalLanguageJoin(p)}`)};return c.onChange(h),c.close.bind(c)};class Yi{store;streamCloser=null;client;constructor({client:e,openStreamer:t,storeConfig:r,handleError:i,handleAsyncError:o}){this.store=Di(r,i),this.client=e,e!=null&&(t??=e?.openStreamer.bind(e),this.streamCloser=Tl({client:e,storeConfig:r,handleError:o,store:Fn(this.store,""),openStreamer:t}))}async awaitInitialized(){this.streamCloser!=null&&await this.streamCloser}scopedStore(e){return Fn(this.store,e)}async close(){if(this.streamCloser==null)return;await(await this.streamCloser)()}}const Ni=d.object({}),Qn="flux-context",Ar="flux.Provider",xl=(n,e)=>n.get(Qn).scopedStore(e),wl=n=>{const e=(t,r)=>{if("client"in n)return n.client;const i=qe(t);return r!=null&&r?.client?.key===i?.key?r:new Yi({client:i,storeConfig:n.storeConfig,handleError:g.useErrorHandler(t),handleAsyncError:g.useAsyncErrorHandler(t)})};return class Zi extends g.Composite{static TYPE=Ar;static stateZ=Ni;schema=Zi.stateZ;afterUpdate(r){const{internal:i}=this;i.store=e(r,i.store),r.wasSetPreviously(Qn)||r.set(Qn,i.store)}}},El=n=>({[Ar]:wl(n)}),Cl="relationships",Rl="resources",Pl={channel:g.ZI.RELATIONSHIP_SET_CHANNEL_NAME,schema:g.ZI.relationshipZ,onChange:({store:n,changed:e})=>n.relationships.set(g.ZI.relationshipToString(e),e)},Ll={channel:g.ZI.RELATIONSHIP_DELETE_CHANNEL_NAME,schema:g.ZI.relationshipZ,onChange:({store:n,changed:e})=>{n.relationships.delete(g.ZI.relationshipToString(e))}},kl={equal:(n,e)=>g.ZI.idsEqual(n.from,e.from)&&g.ZI.idsEqual(n.to,e.to)&&n.type===e.type,listeners:[Pl,Ll]},Ol={channel:g.ZI.RESOURCE_SET_CHANNEL_NAME,schema:g.ZI.resourceZ,onChange:async({store:n,changed:e})=>{n.resources.set(e.key,t=>t==null?e:{...t,...e})}},_l={channel:g.ZI.RESOURCE_DELETE_CHANNEL_NAME,schema:g.ZI.idZ,onChange:({store:n,changed:e})=>n.resources.delete(e.key)},zl={equal:(n,e)=>ie.T.equal(n,e),listeners:[Ol,_l]},Ml=d.object({request:d.string(),bounds:d.record(d.string(),s.H.bounds)}),ji=d.object({request:d.string(),response:Ml});class qt extends g.Leaf{static TYPE="Bounds";schema=ji;afterUpdate(e){this.state.request!==this.prevState.request&&this.setState(t=>({...t,response:{request:t.request,bounds:this.internal.getBounds()}}))}render(e){this.internal.getBounds=e.getBounds}}function Lt(n,e){return n==null||e==null?NaN:n<e?-1:n>e?1:n>=e?0:NaN}function Il(n,e){return n==null||e==null?NaN:e<n?-1:e>n?1:e>=n?0:NaN}function Dr(n){let e,t,r;n.length!==2?(e=Lt,t=(l,u)=>Lt(n(l),u),r=(l,u)=>n(l)-u):(e=n===Lt||n===Il?n:Al,t=n,r=n);function i(l,u,c=0,h=l.length){if(c<h){if(e(u,u)!==0)return h;do{const f=c+h>>>1;t(l[f],u)<0?c=f+1:h=f}while(c<h)}return c}function o(l,u,c=0,h=l.length){if(c<h){if(e(u,u)!==0)return h;do{const f=c+h>>>1;t(l[f],u)<=0?c=f+1:h=f}while(c<h)}return c}function a(l,u,c=0,h=l.length){const f=i(l,u,c,h-1);return f>c&&r(l[f-1],u)>-r(l[f],u)?f-1:f}return{left:i,center:a,right:o}}function Al(){return 0}function Dl(n){return n===null?NaN:+n}const Yl=Dr(Lt),Nl=Yl.right;Dr(Dl).center;const Zl=Math.sqrt(50),jl=Math.sqrt(10),$l=Math.sqrt(2);function Ft(n,e,t){const r=(e-n)/Math.max(0,t),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),a=o>=Zl?10:o>=jl?5:o>=$l?2:1;let l,u,c;return i<0?(c=Math.pow(10,-i)/a,l=Math.round(n*c),u=Math.round(e*c),l/c<n&&++l,u/c>e&&--u,c=-c):(c=Math.pow(10,i)*a,l=Math.round(n/c),u=Math.round(e/c),l*c<n&&++l,u*c>e&&--u),u<l&&.5<=t&&t<2?Ft(n,e,t*2):[l,u,c]}function Bl(n,e,t){if(e=+e,n=+n,t=+t,!(t>0))return[];if(n===e)return[n];const r=e<n,[i,o,a]=r?Ft(e,n,t):Ft(n,e,t);if(!(o>=i))return[];const l=o-i+1,u=new Array(l);if(r)if(a<0)for(let c=0;c<l;++c)u[c]=(o-c)/-a;else for(let c=0;c<l;++c)u[c]=(o-c)*a;else if(a<0)for(let c=0;c<l;++c)u[c]=(i+c)/-a;else for(let c=0;c<l;++c)u[c]=(i+c)*a;return u}function Wn(n,e,t){return e=+e,n=+n,t=+t,Ft(n,e,t)[2]}function Vn(n,e,t){e=+e,n=+n,t=+t;const r=e<n,i=r?Wn(e,n,t):Wn(n,e,t);return(r?-1:1)*(i<0?1/-i:i)}function $i(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function Ul(n){return function(){return n}}function Hl(n){return+n}var cs=[0,1];function Re(n){return n}function Gn(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:Ul(isNaN(e)?NaN:.5)}function ql(n,e){var t;return n>e&&(t=n,n=e,e=t),function(r){return Math.max(n,Math.min(e,r))}}function Fl(n,e,t){var r=n[0],i=n[1],o=e[0],a=e[1];return i<r?(r=Gn(i,r),o=t(a,o)):(r=Gn(r,i),o=t(o,a)),function(l){return o(r(l))}}function Ql(n,e,t){var r=Math.min(n.length,e.length)-1,i=new Array(r),o=new Array(r),a=-1;for(n[r]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++a<r;)i[a]=Gn(n[a],n[a+1]),o[a]=t(e[a],e[a+1]);return function(l){var u=Nl(n,l,1,r)-1;return o[u](i[u](l))}}function Bi(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Wl(){var n=cs,e=cs,t=an,r,i,o,a=Re,l,u,c;function h(){var p=Math.min(n.length,e.length);return a!==Re&&(a=ql(n[0],n[p-1])),l=p>2?Ql:Fl,u=c=null,f}function f(p){return p==null||isNaN(p=+p)?o:(u||(u=l(n.map(r),e,t)))(r(a(p)))}return f.invert=function(p){return a(i((c||(c=l(e,n.map(r),nt)))(p)))},f.domain=function(p){return arguments.length?(n=Array.from(p,Hl),h()):n.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),h()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),t=co,h()},f.clamp=function(p){return arguments.length?(a=p?!0:Re,h()):a!==Re},f.interpolate=function(p){return arguments.length?(t=p,h()):t},f.unknown=function(p){return arguments.length?(o=p,f):o},function(p,y){return r=p,i=y,h()}}function Ui(){return Wl()(Re,Re)}function Vl(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function Qt(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,r=n.slice(0,t);return[r.length>1?r[0]+r.slice(2):r,+n.slice(t+1)]}function Ze(n){return n=Qt(Math.abs(n)),n?n[1]:NaN}function Gl(n,e){return function(t,r){for(var i=t.length,o=[],a=0,l=n[0],u=0;i>0&&l>0&&(u+l+1>r&&(l=Math.max(1,r-u)),o.push(t.substring(i-=l,i+l)),!((u+=l+1)>r));)l=n[a=(a+1)%n.length];return o.reverse().join(e)}}function Xl(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var Kl=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Wt(n){if(!(e=Kl.exec(n)))throw new Error("invalid format: "+n);var e;return new Yr({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]})}Wt.prototype=Yr.prototype;function Yr(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}Yr.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 Jl(n){e:for(var e=n.length,t=1,r=-1,i;t<e;++t)switch(n[t]){case".":r=i=t;break;case"0":r===0&&(r=t),i=t;break;default:if(!+n[t])break e;r>0&&(r=0);break}return r>0?n.slice(0,r)+n.slice(i+1):n}var Hi;function ec(n,e){var t=Qt(n,e);if(!t)return n+"";var r=t[0],i=t[1],o=i-(Hi=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Qt(n,Math.max(0,e+o-1))[0]}function us(n,e){var t=Qt(n,e);if(!t)return n+"";var r=t[0],i=t[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const hs={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:Vl,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>us(n*100,e),r:us,s:ec,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function ds(n){return n}var fs=Array.prototype.map,ps=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function tc(n){var e=n.grouping===void 0||n.thousands===void 0?ds:Gl(fs.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",r=n.currency===void 0?"":n.currency[1]+"",i=n.decimal===void 0?".":n.decimal+"",o=n.numerals===void 0?ds:Xl(fs.call(n.numerals,String)),a=n.percent===void 0?"%":n.percent+"",l=n.minus===void 0?"−":n.minus+"",u=n.nan===void 0?"NaN":n.nan+"";function c(f){f=Wt(f);var p=f.fill,y=f.align,v=f.sign,b=f.symbol,T=f.zero,E=f.width,P=f.comma,C=f.precision,L=f.trim,z=f.type;z==="n"?(P=!0,z="g"):hs[z]||(C===void 0&&(C=12),L=!0,z="g"),(T||p==="0"&&y==="=")&&(T=!0,p="0",y="=");var x=b==="$"?t:b==="#"&&/[boxX]/.test(z)?"0"+z.toLowerCase():"",_=b==="$"?r:/[%p]/.test(z)?a:"",I=hs[z],G=/[defgprs%]/.test(z);C=C===void 0?6:/[gprs]/.test(z)?Math.max(1,Math.min(21,C)):Math.max(0,Math.min(20,C));function Q(w){var U=x,Y=_,X,he,te;if(z==="c")Y=I(w)+Y,w="";else{w=+w;var ne=w<0||1/w<0;if(w=isNaN(w)?u:I(Math.abs(w),C),L&&(w=Jl(w)),ne&&+w==0&&v!=="+"&&(ne=!1),U=(ne?v==="("?v:l:v==="-"||v==="("?"":v)+U,Y=(z==="s"?ps[8+Hi/3]:"")+Y+(ne&&v==="("?")":""),G){for(X=-1,he=w.length;++X<he;)if(te=w.charCodeAt(X),48>te||te>57){Y=(te===46?i+w.slice(X+1):w.slice(X))+Y,w=w.slice(0,X);break}}}P&&!T&&(w=e(w,1/0));var K=U.length+w.length+Y.length,Z=K<E?new Array(E-K+1).join(p):"";switch(P&&T&&(w=e(Z+w,Z.length?E-Y.length:1/0),Z=""),y){case"<":w=U+w+Y+Z;break;case"=":w=U+Z+w+Y;break;case"^":w=Z.slice(0,K=Z.length>>1)+U+w+Y+Z.slice(K);break;default:w=Z+U+w+Y;break}return o(w)}return Q.toString=function(){return f+""},Q}function h(f,p){var y=c((f=Wt(f),f.type="f",f)),v=Math.max(-8,Math.min(8,Math.floor(Ze(p)/3)))*3,b=Math.pow(10,-v),T=ps[8+v/3];return function(E){return y(b*E)+T}}return{format:c,formatPrefix:h}}var wt,qi,Fi;nc({thousands:",",grouping:[3],currency:["$",""]});function nc(n){return wt=tc(n),qi=wt.format,Fi=wt.formatPrefix,wt}function rc(n){return Math.max(0,-Ze(Math.abs(n)))}function sc(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Ze(e)/3)))*3-Ze(Math.abs(n)))}function ic(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,Ze(e)-Ze(n))+1}function ac(n,e,t,r){var i=Vn(n,e,t),o;switch(r=Wt(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(n),Math.abs(e));return r.precision==null&&!isNaN(o=sc(i,a))&&(r.precision=o),Fi(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=ic(i,Math.max(Math.abs(n),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=rc(i))&&(r.precision=o-(r.type==="%")*2);break}}return qi(r)}function oc(n){var e=n.domain;return n.ticks=function(t){var r=e();return Bl(r[0],r[r.length-1],t??10)},n.tickFormat=function(t,r){var i=e();return ac(i[0],i[i.length-1],t??10,r)},n.nice=function(t){t==null&&(t=10);var r=e(),i=0,o=r.length-1,a=r[i],l=r[o],u,c,h=10;for(l<a&&(c=a,a=l,l=c,c=i,i=o,o=c);h-- >0;){if(c=Wn(a,l,t),c===u)return r[i]=a,r[o]=l,e(r);if(c>0)a=Math.floor(a/c)*c,l=Math.ceil(l/c)*c;else if(c<0)a=Math.ceil(a*c)/c,l=Math.floor(l*c)/c;else break;u=c}return n},n}function Qi(){var n=Ui();return n.copy=function(){return Bi(n,Qi())},$i.apply(n,arguments),oc(n)}function lc(n,e){n=n.slice();var t=0,r=n.length-1,i=n[t],o=n[r],a;return o<i&&(a=t,t=r,r=a,a=i,i=o,o=a),n[t]=e.floor(i),n[r]=e.ceil(o),n}const Pn=new Date,Ln=new Date;function D(n,e,t,r){function i(o){return n(o=arguments.length===0?new Date:new Date(+o)),o}return i.floor=o=>(n(o=new Date(+o)),o),i.ceil=o=>(n(o=new Date(o-1)),e(o,1),n(o),o),i.round=o=>{const a=i(o),l=i.ceil(o);return o-a<l-o?a:l},i.offset=(o,a)=>(e(o=new Date(+o),a==null?1:Math.floor(a)),o),i.range=(o,a,l)=>{const u=[];if(o=i.ceil(o),l=l==null?1:Math.floor(l),!(o<a)||!(l>0))return u;let c;do u.push(c=new Date(+o)),e(o,l),n(o);while(c<o&&o<a);return u},i.filter=o=>D(a=>{if(a>=a)for(;n(a),!o(a);)a.setTime(a-1)},(a,l)=>{if(a>=a)if(l<0)for(;++l<=0;)for(;e(a,-1),!o(a););else for(;--l>=0;)for(;e(a,1),!o(a););}),t&&(i.count=(o,a)=>(Pn.setTime(+o),Ln.setTime(+a),n(Pn),n(Ln),Math.floor(t(Pn,Ln))),i.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?i.filter(r?a=>r(a)%o===0:a=>i.count(0,a)%o===0):i)),i}const Vt=D(()=>{},(n,e)=>{n.setTime(+n+e)},(n,e)=>e-n);Vt.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?D(e=>{e.setTime(Math.floor(e/n)*n)},(e,t)=>{e.setTime(+e+t*n)},(e,t)=>(t-e)/n):Vt);Vt.range;const re=1e3,W=re*60,se=W*60,oe=se*24,Nr=oe*7,gs=oe*30,kn=oe*365,Pe=D(n=>{n.setTime(n-n.getMilliseconds())},(n,e)=>{n.setTime(+n+e*re)},(n,e)=>(e-n)/re,n=>n.getUTCSeconds());Pe.range;const Zr=D(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*re)},(n,e)=>{n.setTime(+n+e*W)},(n,e)=>(e-n)/W,n=>n.getMinutes());Zr.range;const cc=D(n=>{n.setUTCSeconds(0,0)},(n,e)=>{n.setTime(+n+e*W)},(n,e)=>(e-n)/W,n=>n.getUTCMinutes());cc.range;const jr=D(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*re-n.getMinutes()*W)},(n,e)=>{n.setTime(+n+e*se)},(n,e)=>(e-n)/se,n=>n.getHours());jr.range;const uc=D(n=>{n.setUTCMinutes(0,0,0)},(n,e)=>{n.setTime(+n+e*se)},(n,e)=>(e-n)/se,n=>n.getUTCHours());uc.range;const mt=D(n=>n.setHours(0,0,0,0),(n,e)=>n.setDate(n.getDate()+e),(n,e)=>(e-n-(e.getTimezoneOffset()-n.getTimezoneOffset())*W)/oe,n=>n.getDate()-1);mt.range;const $r=D(n=>{n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCDate(n.getUTCDate()+e)},(n,e)=>(e-n)/oe,n=>n.getUTCDate()-1);$r.range;const hc=D(n=>{n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCDate(n.getUTCDate()+e)},(n,e)=>(e-n)/oe,n=>Math.floor(n/oe));hc.range;function Se(n){return D(e=>{e.setDate(e.getDate()-(e.getDay()+7-n)%7),e.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*W)/Nr)}const mn=Se(0),Gt=Se(1),dc=Se(2),fc=Se(3),je=Se(4),pc=Se(5),gc=Se(6);mn.range;Gt.range;dc.range;fc.range;je.range;pc.range;gc.range;function Te(n){return D(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-n)%7),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/Nr)}const Wi=Te(0),Xt=Te(1),mc=Te(2),yc=Te(3),$e=Te(4),bc=Te(5),vc=Te(6);Wi.range;Xt.range;mc.range;yc.range;$e.range;bc.range;vc.range;const Br=D(n=>{n.setDate(1),n.setHours(0,0,0,0)},(n,e)=>{n.setMonth(n.getMonth()+e)},(n,e)=>e.getMonth()-n.getMonth()+(e.getFullYear()-n.getFullYear())*12,n=>n.getMonth());Br.range;const Sc=D(n=>{n.setUTCDate(1),n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCMonth(n.getUTCMonth()+e)},(n,e)=>e.getUTCMonth()-n.getUTCMonth()+(e.getUTCFullYear()-n.getUTCFullYear())*12,n=>n.getUTCMonth());Sc.range;const le=D(n=>{n.setMonth(0,1),n.setHours(0,0,0,0)},(n,e)=>{n.setFullYear(n.getFullYear()+e)},(n,e)=>e.getFullYear()-n.getFullYear(),n=>n.getFullYear());le.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:D(e=>{e.setFullYear(Math.floor(e.getFullYear()/n)*n),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t*n)});le.range;const be=D(n=>{n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},(n,e)=>{n.setUTCFullYear(n.getUTCFullYear()+e)},(n,e)=>e.getUTCFullYear()-n.getUTCFullYear(),n=>n.getUTCFullYear());be.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:D(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/n)*n),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t*n)});be.range;function Tc(n,e,t,r,i,o){const a=[[Pe,1,re],[Pe,5,5*re],[Pe,15,15*re],[Pe,30,30*re],[o,1,W],[o,5,5*W],[o,15,15*W],[o,30,30*W],[i,1,se],[i,3,3*se],[i,6,6*se],[i,12,12*se],[r,1,oe],[r,2,2*oe],[t,1,Nr],[e,1,gs],[e,3,3*gs],[n,1,kn]];function l(c,h,f){const p=h<c;p&&([c,h]=[h,c]);const y=f&&typeof f.range=="function"?f:u(c,h,f),v=y?y.range(c,+h+1):[];return p?v.reverse():v}function u(c,h,f){const p=Math.abs(h-c)/f,y=Dr(([,,T])=>T).right(a,p);if(y===a.length)return n.every(Vn(c/kn,h/kn,f));if(y===0)return Vt.every(Math.max(Vn(c,h,f),1));const[v,b]=a[p/a[y-1][2]<a[y][2]/p?y-1:y];return v.every(b)}return[l,u]}const[xc,wc]=Tc(le,Br,mn,mt,jr,Zr);function On(n){if(0<=n.y&&n.y<100){var e=new Date(-1,n.m,n.d,n.H,n.M,n.S,n.L);return e.setFullYear(n.y),e}return new Date(n.y,n.m,n.d,n.H,n.M,n.S,n.L)}function _n(n){if(0<=n.y&&n.y<100){var e=new Date(Date.UTC(-1,n.m,n.d,n.H,n.M,n.S,n.L));return e.setUTCFullYear(n.y),e}return new Date(Date.UTC(n.y,n.m,n.d,n.H,n.M,n.S,n.L))}function Fe(n,e,t){return{y:n,m:e,d:t,H:0,M:0,S:0,L:0}}function Ec(n){var e=n.dateTime,t=n.date,r=n.time,i=n.periods,o=n.days,a=n.shortDays,l=n.months,u=n.shortMonths,c=Qe(i),h=We(i),f=Qe(o),p=We(o),y=Qe(a),v=We(a),b=Qe(l),T=We(l),E=Qe(u),P=We(u),C={a:ne,A:K,b:Z,B:yn,c:null,d:Ts,e:Ts,f:Qc,g:ru,G:iu,H:Hc,I:qc,j:Fc,L:Vi,m:Wc,M:Vc,p:bn,q:vn,Q:Es,s:Cs,S:Gc,u:Xc,U:Kc,V:Jc,w:eu,W:tu,x:null,X:null,y:nu,Y:su,Z:au,"%":ws},L={a:Sn,A:Tn,b:xn,B:vt,c:null,d:xs,e:xs,f:uu,g:Su,G:xu,H:ou,I:lu,j:cu,L:Xi,m:hu,M:du,p:wn,q:Na,Q:Es,s:Cs,S:fu,u:pu,U:gu,V:mu,w:yu,W:bu,x:null,X:null,y:vu,Y:Tu,Z:wu,"%":ws},z={a:Q,A:w,b:U,B:Y,c:X,d:vs,e:vs,f:jc,g:bs,G:ys,H:Ss,I:Ss,j:Dc,L:Zc,m:Ac,M:Yc,p:G,q:Ic,Q:Bc,s:Uc,S:Nc,u:kc,U:Oc,V:_c,w:Lc,W:zc,x:he,X:te,y:bs,Y:ys,Z:Mc,"%":$c};C.x=x(t,C),C.X=x(r,C),C.c=x(e,C),L.x=x(t,L),L.X=x(r,L),L.c=x(e,L);function x(S,R){return function(k){var m=[],j=-1,M=0,H=S.length,q,de,Vr;for(k instanceof Date||(k=new Date(+k));++j<H;)S.charCodeAt(j)===37&&(m.push(S.slice(M,j)),(de=ms[q=S.charAt(++j)])!=null?q=S.charAt(++j):de=q==="e"?" ":"0",(Vr=R[q])&&(q=Vr(k,de)),m.push(q),M=j+1);return m.push(S.slice(M,j)),m.join("")}}function _(S,R){return function(k){var m=Fe(1900,void 0,1),j=I(m,S,k+="",0),M,H;if(j!=k.length)return null;if("Q"in m)return new Date(m.Q);if("s"in m)return new Date(m.s*1e3+("L"in m?m.L:0));if(R&&!("Z"in m)&&(m.Z=0),"p"in m&&(m.H=m.H%12+m.p*12),m.m===void 0&&(m.m="q"in m?m.q:0),"V"in m){if(m.V<1||m.V>53)return null;"w"in m||(m.w=1),"Z"in m?(M=_n(Fe(m.y,0,1)),H=M.getUTCDay(),M=H>4||H===0?Xt.ceil(M):Xt(M),M=$r.offset(M,(m.V-1)*7),m.y=M.getUTCFullYear(),m.m=M.getUTCMonth(),m.d=M.getUTCDate()+(m.w+6)%7):(M=On(Fe(m.y,0,1)),H=M.getDay(),M=H>4||H===0?Gt.ceil(M):Gt(M),M=mt.offset(M,(m.V-1)*7),m.y=M.getFullYear(),m.m=M.getMonth(),m.d=M.getDate()+(m.w+6)%7)}else("W"in m||"U"in m)&&("w"in m||(m.w="u"in m?m.u%7:"W"in m?1:0),H="Z"in m?_n(Fe(m.y,0,1)).getUTCDay():On(Fe(m.y,0,1)).getDay(),m.m=0,m.d="W"in m?(m.w+6)%7+m.W*7-(H+5)%7:m.w+m.U*7-(H+6)%7);return"Z"in m?(m.H+=m.Z/100|0,m.M+=m.Z%100,_n(m)):On(m)}}function I(S,R,k,m){for(var j=0,M=R.length,H=k.length,q,de;j<M;){if(m>=H)return-1;if(q=R.charCodeAt(j++),q===37){if(q=R.charAt(j++),de=z[q in ms?R.charAt(j++):q],!de||(m=de(S,k,m))<0)return-1}else if(q!=k.charCodeAt(m++))return-1}return m}function G(S,R,k){var m=c.exec(R.slice(k));return m?(S.p=h.get(m[0].toLowerCase()),k+m[0].length):-1}function Q(S,R,k){var m=y.exec(R.slice(k));return m?(S.w=v.get(m[0].toLowerCase()),k+m[0].length):-1}function w(S,R,k){var m=f.exec(R.slice(k));return m?(S.w=p.get(m[0].toLowerCase()),k+m[0].length):-1}function U(S,R,k){var m=E.exec(R.slice(k));return m?(S.m=P.get(m[0].toLowerCase()),k+m[0].length):-1}function Y(S,R,k){var m=b.exec(R.slice(k));return m?(S.m=T.get(m[0].toLowerCase()),k+m[0].length):-1}function X(S,R,k){return I(S,e,R,k)}function he(S,R,k){return I(S,t,R,k)}function te(S,R,k){return I(S,r,R,k)}function ne(S){return a[S.getDay()]}function K(S){return o[S.getDay()]}function Z(S){return u[S.getMonth()]}function yn(S){return l[S.getMonth()]}function bn(S){return i[+(S.getHours()>=12)]}function vn(S){return 1+~~(S.getMonth()/3)}function Sn(S){return a[S.getUTCDay()]}function Tn(S){return o[S.getUTCDay()]}function xn(S){return u[S.getUTCMonth()]}function vt(S){return l[S.getUTCMonth()]}function wn(S){return i[+(S.getUTCHours()>=12)]}function Na(S){return 1+~~(S.getUTCMonth()/3)}return{format:function(S){var R=x(S+="",C);return R.toString=function(){return S},R},parse:function(S){var R=_(S+="",!1);return R.toString=function(){return S},R},utcFormat:function(S){var R=x(S+="",L);return R.toString=function(){return S},R},utcParse:function(S){var R=_(S+="",!0);return R.toString=function(){return S},R}}}var ms={"-":"",_:" ",0:"0"},N=/^\s*\d+/,Cc=/^%/,Rc=/[\\^$*+?|[\]().{}]/g;function O(n,e,t){var r=n<0?"-":"",i=(r?-n:n)+"",o=i.length;return r+(o<t?new Array(t-o+1).join(e)+i:i)}function Pc(n){return n.replace(Rc,"\\$&")}function Qe(n){return new RegExp("^(?:"+n.map(Pc).join("|")+")","i")}function We(n){return new Map(n.map((e,t)=>[e.toLowerCase(),t]))}function Lc(n,e,t){var r=N.exec(e.slice(t,t+1));return r?(n.w=+r[0],t+r[0].length):-1}function kc(n,e,t){var r=N.exec(e.slice(t,t+1));return r?(n.u=+r[0],t+r[0].length):-1}function Oc(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.U=+r[0],t+r[0].length):-1}function _c(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.V=+r[0],t+r[0].length):-1}function zc(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.W=+r[0],t+r[0].length):-1}function ys(n,e,t){var r=N.exec(e.slice(t,t+4));return r?(n.y=+r[0],t+r[0].length):-1}function bs(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.y=+r[0]+(+r[0]>68?1900:2e3),t+r[0].length):-1}function Mc(n,e,t){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(t,t+6));return r?(n.Z=r[1]?0:-(r[2]+(r[3]||"00")),t+r[0].length):-1}function Ic(n,e,t){var r=N.exec(e.slice(t,t+1));return r?(n.q=r[0]*3-3,t+r[0].length):-1}function Ac(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.m=r[0]-1,t+r[0].length):-1}function vs(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.d=+r[0],t+r[0].length):-1}function Dc(n,e,t){var r=N.exec(e.slice(t,t+3));return r?(n.m=0,n.d=+r[0],t+r[0].length):-1}function Ss(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.H=+r[0],t+r[0].length):-1}function Yc(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.M=+r[0],t+r[0].length):-1}function Nc(n,e,t){var r=N.exec(e.slice(t,t+2));return r?(n.S=+r[0],t+r[0].length):-1}function Zc(n,e,t){var r=N.exec(e.slice(t,t+3));return r?(n.L=+r[0],t+r[0].length):-1}function jc(n,e,t){var r=N.exec(e.slice(t,t+6));return r?(n.L=Math.floor(r[0]/1e3),t+r[0].length):-1}function $c(n,e,t){var r=Cc.exec(e.slice(t,t+1));return r?t+r[0].length:-1}function Bc(n,e,t){var r=N.exec(e.slice(t));return r?(n.Q=+r[0],t+r[0].length):-1}function Uc(n,e,t){var r=N.exec(e.slice(t));return r?(n.s=+r[0],t+r[0].length):-1}function Ts(n,e){return O(n.getDate(),e,2)}function Hc(n,e){return O(n.getHours(),e,2)}function qc(n,e){return O(n.getHours()%12||12,e,2)}function Fc(n,e){return O(1+mt.count(le(n),n),e,3)}function Vi(n,e){return O(n.getMilliseconds(),e,3)}function Qc(n,e){return Vi(n,e)+"000"}function Wc(n,e){return O(n.getMonth()+1,e,2)}function Vc(n,e){return O(n.getMinutes(),e,2)}function Gc(n,e){return O(n.getSeconds(),e,2)}function Xc(n){var e=n.getDay();return e===0?7:e}function Kc(n,e){return O(mn.count(le(n)-1,n),e,2)}function Gi(n){var e=n.getDay();return e>=4||e===0?je(n):je.ceil(n)}function Jc(n,e){return n=Gi(n),O(je.count(le(n),n)+(le(n).getDay()===4),e,2)}function eu(n){return n.getDay()}function tu(n,e){return O(Gt.count(le(n)-1,n),e,2)}function nu(n,e){return O(n.getFullYear()%100,e,2)}function ru(n,e){return n=Gi(n),O(n.getFullYear()%100,e,2)}function su(n,e){return O(n.getFullYear()%1e4,e,4)}function iu(n,e){var t=n.getDay();return n=t>=4||t===0?je(n):je.ceil(n),O(n.getFullYear()%1e4,e,4)}function au(n){var e=n.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+O(e/60|0,"0",2)+O(e%60,"0",2)}function xs(n,e){return O(n.getUTCDate(),e,2)}function ou(n,e){return O(n.getUTCHours(),e,2)}function lu(n,e){return O(n.getUTCHours()%12||12,e,2)}function cu(n,e){return O(1+$r.count(be(n),n),e,3)}function Xi(n,e){return O(n.getUTCMilliseconds(),e,3)}function uu(n,e){return Xi(n,e)+"000"}function hu(n,e){return O(n.getUTCMonth()+1,e,2)}function du(n,e){return O(n.getUTCMinutes(),e,2)}function fu(n,e){return O(n.getUTCSeconds(),e,2)}function pu(n){var e=n.getUTCDay();return e===0?7:e}function gu(n,e){return O(Wi.count(be(n)-1,n),e,2)}function Ki(n){var e=n.getUTCDay();return e>=4||e===0?$e(n):$e.ceil(n)}function mu(n,e){return n=Ki(n),O($e.count(be(n),n)+(be(n).getUTCDay()===4),e,2)}function yu(n){return n.getUTCDay()}function bu(n,e){return O(Xt.count(be(n)-1,n),e,2)}function vu(n,e){return O(n.getUTCFullYear()%100,e,2)}function Su(n,e){return n=Ki(n),O(n.getUTCFullYear()%100,e,2)}function Tu(n,e){return O(n.getUTCFullYear()%1e4,e,4)}function xu(n,e){var t=n.getUTCDay();return n=t>=4||t===0?$e(n):$e.ceil(n),O(n.getUTCFullYear()%1e4,e,4)}function wu(){return"+0000"}function ws(){return"%"}function Es(n){return+n}function Cs(n){return Math.floor(+n/1e3)}var Ee,Ji;Eu({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 Eu(n){return Ee=Ec(n),Ji=Ee.format,Ee.parse,Ee.utcFormat,Ee.utcParse,Ee}function Cu(n){return new Date(n)}function Ru(n){return n instanceof Date?+n:+new Date(+n)}function ea(n,e,t,r,i,o,a,l,u,c){var h=Ui(),f=h.invert,p=h.domain,y=c(".%L"),v=c(":%S"),b=c("%I:%M"),T=c("%I %p"),E=c("%a %d"),P=c("%b %d"),C=c("%B"),L=c("%Y");function z(x){return(u(x)<x?y:l(x)<x?v:a(x)<x?b:o(x)<x?T:r(x)<x?i(x)<x?E:P:t(x)<x?C:L)(x)}return h.invert=function(x){return new Date(f(x))},h.domain=function(x){return arguments.length?p(Array.from(x,Ru)):p().map(Cu)},h.ticks=function(x){var _=p();return n(_[0],_[_.length-1],x??10)},h.tickFormat=function(x,_){return _==null?z:c(_)},h.nice=function(x){var _=p();return(!x||typeof x.range!="function")&&(x=e(_[0],_[_.length-1],x??10)),x?p(lc(_,x)):h},h.copy=function(){return Bi(h,ea(n,e,t,r,i,o,a,l,u,c))},h}function Pu(){return $i.apply(ea(xc,wc,le,Br,mn,mt,jr,Zr,Pe,Ji).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}const Rs=[s.a$1.NANOSECOND,s.a$1.nanoseconds(2),s.a$1.nanoseconds(5),s.a$1.nanoseconds(10),s.a$1.nanoseconds(20),s.a$1.nanoseconds(50),s.a$1.nanoseconds(100),s.a$1.nanoseconds(200),s.a$1.nanoseconds(500),s.a$1.MICROSECOND,s.a$1.microseconds(2),s.a$1.microseconds(5),s.a$1.microseconds(10),s.a$1.microseconds(20),s.a$1.microseconds(50),s.a$1.microseconds(100),s.a$1.microseconds(200),s.a$1.microseconds(500),s.a$1.MILLISECOND,s.a$1.milliseconds(2),s.a$1.milliseconds(5),s.a$1.milliseconds(10),s.a$1.milliseconds(20),s.a$1.milliseconds(50),s.a$1.milliseconds(100),s.a$1.milliseconds(200),s.a$1.milliseconds(500),s.a$1.SECOND];class Lu{_domain;_range;_span;constructor(){this._domain=[new s.r(0n),new s.r(1n)],this._range=[0,1],this._span=this._domain[1].span(this._domain[0])}domain(e){return e===void 0?this._domain:(this._domain=[new s.r(e[0]),new s.r(e[1])],this._span=this._domain[1].span(this._domain[0]),this)}range(e){return e===void 0?this._range:(this._range=e,this)}scale(e){const r=new s.r(e).valueOf(),i=this._domain[0].valueOf(),o=this._domain[1].valueOf()-i,a=this._range[1]-this._range[0];return Number(r-i)/Number(o)*a+this._range[0]}ticks(e){const t=this.calculateOptimalStep(e).valueOf(),r=this._domain[0].valueOf(),i=this._domain[1].valueOf(),o=(r+t-1n)/t*t,a=Number((i-o)/t);return Array.from({length:a+1},(l,u)=>{const c=o+BigInt(u)*t;return new s.r(c)}).filter(l=>l.afterEq(this._domain[0])&&l.beforeEq(this._domain[1]))}calculateOptimalStep(e){const t=this._span.valueOf()/BigInt(Math.ceil(e));let r=Rs[0];for(const i of Rs){if(i.valueOf()>t)break;r=i}return r}formatTick(e){return this._span.lessThan(s.a$1.microseconds(50))?`${e.remainder(s.a$1.MILLISECOND).microseconds.toString()}µs`:`${e.remainder(s.a$1.SECOND).milliseconds.toString()}ms`}}const ku=()=>new Lu,Ur=d.z.enum(["linear","time"]),Hr=d.z.object({tickSpacing:d.z.number().default(75),type:Ur.optional().default("linear")}),Xn=n=>{const e=Hr.parse(n);return zu[e.type](e)};class Ou{props;prevScaleSize;prevDomain;currTicks;normalScale;preciseScale;constructor(e){this.props=e,this.normalScale=Pu(),this.preciseScale=ku(),this.prevScaleSize=0,this.prevDomain=new s.m(new s.r(0),new s.r(0)),this.currTicks=[]}create({decimalToDataScale:e,size:t}){const r=new s.m(new s.r(e.pos(0)),new s.r(e.pos(1)));if(this.prevDomain.equals(r)&&this.prevScaleSize===t)return this.currTicks;if(this.prevDomain=r,this.prevScaleSize!==t){const i=[0,t];this.preciseScale.range(i),this.normalScale.range(i),this.prevScaleSize=t}if(r.span.milliseconds<5){this.preciseScale.domain([r.start,r.end]);const i=Kn(t,this.props.tickSpacing)/2,o=this.preciseScale.ticks(i);this.currTicks=o.map(a=>({label:this.preciseScale.formatTick(a),position:this.preciseScale.scale(a)}))}else{this.normalScale.domain([r.start.date(),r.end.date()]);const i=this.normalScale.ticks(Kn(t,this.props.tickSpacing));this.currTicks=i.map(o=>({label:this.normalTickLabel(o),position:this.normalScale(o)}))}return this.currTicks}normalTickLabel(e){let t=`:${e.getSeconds()}`;const r=e.getMilliseconds();if(r!==0){const i=Math.round(e.getMilliseconds()).toString().padStart(3,"0").replace(/0+$/,"");t+=`.${i}`}return e.getSeconds()===0&&r===0&&(t=`${e.getHours()}:${e.getMinutes().toString().padStart(2,"0")}`),t}}class _u{props;prevDomain;prevScaleSize;currTicks;d3Scale;constructor(e){this.props=e,this.prevDomain=s.H.construct(0,0),this.prevScaleSize=0,this.currTicks=[],this.d3Scale=Qi()}create({decimalToDataScale:e,size:t}){const r={lower:e.pos(0),upper:e.pos(1)};if(s.H.equals(this.prevDomain,r)&&this.prevScaleSize===t)return this.currTicks;s.H.equals(this.prevDomain,r)||(this.d3Scale=this.d3Scale.domain([r.lower,r.upper])),this.prevScaleSize!==t&&(this.d3Scale=this.d3Scale.range([0,t])),this.prevDomain=r,this.prevScaleSize=t;const i=Kn(t,this.props.tickSpacing),o=this.d3Scale.ticks(i);return this.currTicks=o.map(a=>({label:this.tickLabel(a),position:this.d3Scale(a)})),this.currTicks}tickLabel(e){return e.toString()}}const Kn=(n,e)=>{const t=Math.floor(n/e);return t>0?t:1},zu={linear:n=>new _u(n),time:n=>new Ou(n)},qr=Hr.extend({color:s.zr.colorZ,type:Ur.optional().default("linear"),font:d.z.string(),showGrid:d.z.boolean().optional().default(!0),location:s.K.outer,gridColor:s.zr.colorZ}),V=5,st=6,yt={useAtlas:!0},Mu={bottom:(n,e)=>new na(n,e),top:(n,e)=>new ra(n,e),left:(n,e)=>new Iu(n,e),right:(n,e)=>new sa(n,e)},ta=(n,e,t)=>Mu[n](e,t);class xe{renderCtx;state;tickFactory;constructor(e,t){this.renderCtx=e,this.state=t,this.tickFactory=Xn(this.state)}setState(e){this.state=g.prettyParse(qr,e),this.tickFactory=Xn(e)}drawLine(e,t){const{lower2d:r}=this.renderCtx;r.moveTo(...s.Q.couple(e)),r.lineTo(...s.Q.couple(t))}drawTicks(e,t){let r=s._$1.ZERO;return e.forEach(i=>{const o=this.renderCtx.lower2d.textDimensions(i.label,yt);r=s._$1.max([r,o]),t(o,i)}),r}static START_BOUND=s.H.construct(-1,1);maybeDrawGrid(e,t,r){const{showGrid:i,gridColor:o}=this.state;if(i){const a=xe.START_BOUND,l=s.H.construct(e-1,e+1),{lower2d:u}=this.renderCtx;u.beginPath(),u.strokeStyle=s.zr.hex(o),t.forEach(c=>{s.H.contains(a,c.position)||s.H.contains(l,c.position)||this.drawLine(...r(c))}),u.stroke()}}setColor(e){const t=s.zr.hex(e);this.renderCtx.lower2d.strokeStyle=t,this.renderCtx.lower2d.fillStyle=t,this.renderCtx.lower2d.font=this.state.font}}class na extends xe{render(e){const{lower2d:t}=this.renderCtx,{plot:r,position:i}=e,{width:o,height:a}=s.jt.dims(r),l=this.tickFactory.create({...e,size:o});t.beginPath(),this.setColor(this.state.color),this.drawLine(i,s.Q.translate(i,"x",o));const u=this.drawTicks(l,(c,h)=>{this.drawLine(s.Q.translateX(i,h.position),s.Q.translate(i,{x:h.position,y:V})),t.fillText(h.label,i.x+h.position-c.width/2,i.y+V+c.height+st,void 0,yt)});return t.stroke(),this.maybeDrawGrid(o,l,c=>[s.Q.translate(i,"x",c.position),s.Q.translate(i,{x:c.position,y:-a})]),{size:u.height+V+st}}}class ra extends xe{render(e){const{lower2d:t}=this.renderCtx,{plot:r}=e,{width:i,height:o}=s.jt.dims(r),a=s.Q.translate(e.position,"y",e.size),l=this.tickFactory.create({...e,size:i});t.beginPath(),this.setColor(this.state.color),this.drawLine(a,s.Q.translate(a,"x",i));const u=this.drawTicks(l,(c,h)=>{this.drawLine(s.Q.translateX(a,h.position),s.Q.translate(a,{x:h.position,y:-V})),t.fillText(h.label,a.x+h.position-c.width/2,a.y-V-c.height-st,void 0,yt)});return t.stroke(),this.maybeDrawGrid(i,l,c=>[s.Q.translate(a,"x",c.position),s.Q.translate(a,{x:c.position,y:o})]),{size:u.height+V}}}class Iu extends xe{render(e){const{lower2d:t}=this.renderCtx,{plot:r,position:i}=e,{height:o,width:a}=s.jt.dims(r),l=s.Q.translate(i,"x",e.size),u=this.tickFactory.create({...e,size:o});t.beginPath(),this.setColor(this.state.color),this.drawLine(l,s.Q.translate(l,"y",o));const c=this.drawTicks(u,(h,f)=>{this.drawLine(s.Q.translateY(l,f.position),s.Q.translate(l,{x:-V,y:f.position})),t.fillText(f.label,l.x-h.width-V*2,l.y+f.position+h.height/2,void 0,yt)});return t.stroke(),this.maybeDrawGrid(o,u,h=>[s.Q.translate(l,"y",h.position),s.Q.translate(l,{x:a,y:h.position})]),{size:c.width+V*2}}}class sa extends xe{render(e){const{lower2d:t}=this.renderCtx,{plot:r,position:i}=e,{height:o,width:a}=s.jt.dims(r),l=this.tickFactory.create({...e,size:o});t.beginPath(),this.setColor(this.state.color),this.drawLine(i,s.Q.translateY(i,o));const u=this.drawTicks(l,(c,h)=>{this.drawLine(s.Q.translateY(i,h.position),s.Q.translate(i,{x:V,y:h.position})),t.fillText(h.label,i.x+V+st,i.y+h.position+c.height/2,void 0,yt)});return t.stroke(),this.maybeDrawGrid(o,l,c=>[s.Q.translateY(i,c.position),s.Q.translate(i,{x:-a,y:c.position})]),{size:u.width+V+st}}}const ia=d.z.object({key:d.z.string(),size:d.z.number(),order:d.z.number(),loc:s.K.outer});d.z.record(d.z.string(),ia);const pe=(n,e)=>Object.values(e).filter(({loc:t})=>t===n).sort((t,r)=>r.order-t.order),Au=(n,e,t)=>{const r=e[n];if(r==null)return s.Q.ZERO;const i=s.K.construct(r.loc),o=pe(i,e),a=s.K.construct(s.p.swap(s.K.direction(i))),l=pe(a,e),u=o.findIndex(({key:f})=>f===n),c=o.slice(0,u).reduce((f,{size:p})=>f+p,0),h=l.reduce((f,{size:p})=>f+p,0);switch(i){case"left":return s.Q.translate(s.jt.topLeft(t),[c,h]);case"right":return s.Q.translate(s.jt.topRight(t),[c-r.size,h]);case"top":return s.Q.translate(s.jt.topLeft(t),[h,c]);default:return s.Q.translate(s.jt.bottomLeft(t),[h,-c-r.size])}},Du=(n,e)=>{const t=pe("left",n),r=pe("right",n),i=pe("top",n),o=pe("bottom",n),a=t.reduce((h,{size:f})=>h+f,0),l=r.reduce((h,{size:f})=>h+f,0),u=i.reduce((h,{size:f})=>h+f,0),c=o.reduce((h,{size:f})=>h+f,0);return s.jt.construct(s.Q.translate(s.jt.topLeft(e),{x:a,y:u}),s.jt.width(e)-a-l,s.jt.height(e)-u-c)},bt=qr.extend({axisKey:d.z.string().optional(),bounds:s.H.bounds.optional(),autoBounds:d.z.object({lower:d.z.boolean().optional().default(!0),upper:d.z.boolean().optional().default(!0)}).or(d.z.boolean().optional().default(!0)),autoBoundPadding:d.z.number().optional(),autoBoundUpdateInterval:s.a$1.z.optional().default(s.a$1.seconds(10)),size:d.z.number().optional().default(0),label:d.z.string().optional().default(""),labelSize:d.z.number().optional().default(0)}).partial({color:!0,font:!0,gridColor:!0}),Yu=2,Nu=7,aa=(n,e)=>s.H.contains({lower:n-Nu,upper:n+Yu},e),Zu=s.H.DECIMAL,Ps=s.r.now(),ju={lower:Number(Ps.valueOf()),upper:Number(Ps.add(s.a$1.HOUR).valueOf())},oa=n=>n==="linear"?Zu:ju,$u=(n,e=.1,t)=>{const r=s.H.max(n.filter(s.H.isFinite));if(!s.H.isFinite(r))return oa(t);const{lower:i,upper:o}=r;if(o===i)return{lower:i-1,upper:o+1};const a=(o-i)*e;return{lower:i-a,upper:o+a}},Bu=.01,Uu=.1;class la extends g.Composite{afterUpdate(e){const{internal:t}=this,{location:r,autoBoundUpdateInterval:i}=this.state;t.render=A.Context.use(e);const o=g.use(e),a=s.p.construct(r);this.state.autoBoundPadding??=a==="x"?Uu:Bu,t.core=ta(r,t.render,{color:o.colors.gray.l10,font:Je.fontString(o,{level:"small",code:!0}),gridColor:o.colors.gray.l1,...this.state}),ae(e,"layout"),t.updateBounds??=cr.r(l=>this.setState(u=>({...u,bounds:l})),i.milliseconds)}afterDelete(e){ae(e,"layout")}renderAxis(e,t){if(!e.canvases.includes("lower2d"))return;const{core:r}=this.internal,{grid:i,container:o}=e,a=Au(`${this.type}-${this.key}`,i,o),l={...e,position:a,decimalToDataScale:t,size:this.state.size+this.state.labelSize},{size:u}=r.render(l);aa(this.state.size,u)||this.setState(c=>({...c,size:u}))}iBounds(e,t){if(e&&this.internal.boundSnapshot!=null)return[this.internal.boundSnapshot,null];const{lower:r,upper:i}=ca(this.state.autoBounds);if(!r&&!i&&this.state.bounds!=null)return this.internal.boundSnapshot=this.state.bounds,[this.state.bounds,null];const o=c=>({upper:i||this.state.bounds==null?c.upper:this.state.bounds.upper,lower:r||this.state.bounds==null?c.lower:this.state.bounds.lower});let a,l=null;try{const c=t();a=$u(c,this.state.autoBoundPadding,this.state.type)}catch(c){a=oa(this.state.type),l=c}const u=o(a);return this.internal.boundSnapshot=u,(this.state.bounds==null||r&&this.state.bounds.lower!==u.lower||i&&this.state.bounds.upper!==u.upper)&&this.internal.updateBounds?.(u),[u,l]}dataToDecimalScale(e,t,r){const[i,o]=this.iBounds(e,t),a=s.p.swap(s.p.construct(this.state.location));return[s.C$1.Scale.scale(i).scale(1).translate(-s.jt.root(r)[a]).magnify(1/s.jt.dim(r,a)),o]}}const ca=n=>typeof n=="boolean"?{lower:n,upper:n}:{lower:n?.lower??!0,upper:n?.upper??!0};class we{canvas;theme;constructor(e,t){this.canvas=e,this.theme=t}rule({direction:e,region:t,position:r,...i}){return e==="x"?this.line({start:s.Q.construct(s.jt.left(t),r),end:s.Q.construct(s.jt.right(t),r),...i}):this.line({start:s.Q.construct(r,s.jt.top(t)),end:s.Q.construct(r,s.jt.bottom(t)),...i})}line({stroke:e,lineWidth:t,lineDash:r,start:i,end:o}){const a=this.canvas;a.strokeStyle=s.zr.hex(e),a.lineWidth=t,a.setLineDash([r]),a.beginPath(),a.moveTo(...s.Q.couple(i)),a.lineTo(...s.Q.couple(o)),a.stroke()}circle({fill:e,stroke:t,strokeWidth:r,lineDash:i,radius:o,position:a,angle:l,lineCap:u}){const c=this.canvas;c.beginPath();const h=l?.lower??0,f=l?.upper??2*Math.PI;if(t!=null&&typeof o=="object"){const{inner:p,outer:y}=o,v=(p+y)/2,b=y-p;c.arc(...s.Q.couple(a),v,h,f,!1),c.strokeStyle=s.zr.hex(t),c.lineWidth=r??b,u&&(c.lineCap=u),i!=null&&c.setLineDash([i]),c.stroke(),i!=null&&c.setLineDash([])}else if(t!=null&&typeof o=="number")c.arc(...s.Q.couple(a),o,h,f,!1),c.strokeStyle=s.zr.hex(t),c.lineWidth=r??1,u&&(c.lineCap=u),i!=null&&c.setLineDash([i]),c.stroke(),i!=null&&c.setLineDash([]);else if(e!=null)if(c.fillStyle=s.zr.hex(e),typeof o=="number")c.arc(...s.Q.couple(a),o,h,f),c.fill();else{const{inner:p,outer:y}=o;c.arc(...s.Q.couple(a),y,h,f,!1);const v=a.x+p*Math.cos(f),b=a.y+p*Math.sin(f);c.lineTo(v,b),c.arc(...s.Q.couple(a),p,f,h,!0),c.closePath(),c.fill()}}resolveColor(e,t){return e==null?t==null?this.theme.colors.text:this.resolveColor(t):typeof e=="function"?e(this.theme):s.zr.construct(e)}border({region:e,color:t,width:r,radius:i,location:o}){const a=this.canvas;a.strokeStyle=s.zr.hex(this.resolveColor(t,this.theme.colors.border)),a.lineWidth=r??this.theme.sizes.border.width,i??=this.theme.sizes.border.radius,o==null||o===!0?i>0?(a.roundRect(...s.Q.couple(s.jt.topLeft(e)),...s.Q.couple(s.jt.dims(e)),i),a.stroke()):(a.rect(...s.Q.couple(s.jt.topLeft(e)),...s.Q.couple(s.jt.dims(e))),a.stroke()):s.a.toArray(o).forEach(l=>{const[u,c]=s.jt.edgePoints(e,l);a.beginPath(),a.moveTo(...s.Q.couple(u)),a.lineTo(...s.Q.couple(c)),a.stroke()})}container({region:e,bordered:t=!0,rounded:r=!0,borderColor:i,borderRadius:o,borderWidth:a,backgroundColor:l}){o??=this.theme.sizes.border.radius,a??=1;const u=this.canvas;u.fillStyle=s.zr.hex(this.resolveColor(l,this.theme.colors.gray.l1)),u.strokeStyle=s.zr.hex(this.resolveColor(i,this.theme.colors.border)),u.setLineDash([]),u.lineWidth=1,u.beginPath(),r?u.roundRect(...s.Q.couple(s.jt.topLeft(e)),...s.Q.couple(s.jt.dims(e)),o):u.rect(...s.Q.couple(s.jt.topLeft(e)),...s.Q.couple(s.jt.dims(e))),u.fill(),t&&this.border({region:e,color:i,radius:o,width:a,location:t})}textContainer(e){const[t,r]=this.spacedTextDrawF(e);t.width+=12,t.height+=12;const{root:i=s.K.TOP_LEFT,offset:o=s.Q.ZERO}=e,a={...e.position};i.x==="right"?a.x-=t.width+o.x:a.x+=o.x,i.y==="bottom"?a.y-=t.height+o.y:a.y+=o.y,this.container({region:s.jt.construct(a,t.width,t.height),...e}),this.canvas.filter="none",r(s.Q.translate(a,[6,6]))}spacedTextDrawF({text:e,direction:t,spacing:r=1,level:i="p"}){const o=Je.fontString(this.theme,{level:i}),a=e.map(c=>Gr.dimensions(c,o,this.canvas)),l=this.theme.sizes.base*r,u=Math.max(...a.map(c=>c[s.p.dimension(t)]))+l;return[{[s.p.dimension(s.p.swap(t))]:Math.max(...a.map(c=>c[s.p.dimension(s.p.swap(t))])),[s.p.dimension(t)]:u*e.length-l},c=>{const h=Je.fontString(this.theme,{level:i});this.canvas.font=h,this.canvas.fillStyle=s.zr.hex(this.theme.colors.text),this.canvas.textBaseline="top",this.canvas.textAlign="start",e.forEach((f,p)=>{this.canvas.fillText(f,c.x,c.y+u*p)})}]}list({length:e,itemHeight:t,width:r,spacing:i=0,position:o,draw:a,root:l=s.K.TOP_LEFT,offset:u=s.Q.ZERO,padding:c=s.Q.ZERO}){const h=e*t+c.y*2+i*(e-1),f=r+c.x*2,p={...o};l.x==="right"?p.x-=r+u.x*2:p.x+=u.x,l.y==="top"?p.y-=h+u.y*2:p.y+=u.y,this.container({region:s.jt.construct(p,{width:f,height:h}),backgroundColor:y=>y.colors.gray.l1});for(let y=0;y<e;y++){const v=s.jt.construct(s.Q.construct(p.x+c.x,p.y+y*t+c.y+i*y),r,t);a(y,v)}}drawTextInCenter({box:e,text:t,level:r}){const i=Gr.dimensions(t,this.canvas.font,this.canvas),o=s.jt.positionInCenter(s.jt.construct(s.Q.ZERO,i),e);return this.text({text:t,position:s.jt.topLeft(o),level:r})}text({text:e,position:t,level:r="p",weight:i,shade:o,maxWidth:a,code:l,justify:u="left",align:c="top",useAtlas:h,color:f}){this.canvas.font=Je.fontString(this.theme,{level:r,weight:i,code:l}),f!=null?this.canvas.fillStyle=s.zr.hex(this.resolveColor(f)):o==null?this.canvas.fillStyle=s.zr.hex(this.theme.colors.text):this.canvas.fillStyle=s.zr.hex(this.theme.colors.gray[`l${o}`]),this.canvas.textAlign=u,this.canvas.textBaseline=c;let p;a!=null&&(p=this.canvas.scissor(s.jt.construct(t,a,1e3))),this.canvas.fillText(e,t.x,t.y,void 0,{useAtlas:h}),p?.()}}const Fr=d.z.object({position:d.z.number().optional(),pixelPosition:d.z.number().optional(),dragging:d.z.boolean(),lineWidth:d.z.number().optional().default(1),lineDash:d.z.number().optional().default(20),color:s.zr.colorZ}),Hu=3;class it extends g.Leaf{static TYPE="Rule";schema=Fr;lastUpdateRef=null;afterUpdate(e){this.internal.renderCtx=A.Context.use(e);const t=g.use(e);this.internal.draw=new we(this.internal.renderCtx.upper2d,t),ae(e,"tool")}afterDelete(e){ae(e,"tool")}updatePositions({decimalToDataScale:e,plot:t}){const r=this.state.dragging,i=this.prevState.dragging&&!r;if((r||i)&&this.state.pixelPosition!=null){if(this.lastUpdateRef??=this.state.pixelPosition,Math.abs(this.state.pixelPosition-this.lastUpdateRef)<Hu&&!i)return this.state.pixelPosition;this.lastUpdateRef=this.state.pixelPosition;const l=e.pos(this.state.pixelPosition/s.jt.height(t));return this.setState(u=>({...u,position:l})),this.state.pixelPosition}if(this.state.position==null){const a=e.pos(.5);this.setState(l=>({...l,position:a}))}const o=e.reverse().pos(this.state.position)*s.jt.height(t);if(!isNaN(o)){if(this.state.pixelPosition!=null&&Math.abs(o-this.state.pixelPosition)<1)return this.state.pixelPosition;this.setState(a=>({...a,pixelPosition:o}))}return o}render(e){if(this.deleted)return;const{renderCtx:t}=this.internal,{location:r,plot:i}=e,o=s.K.direction(r),{upper2d:a}=t,l=this.internal.draw,u=this.updatePositions(e)+s.jt.top(e.plot);l.rule({stroke:this.state.color,lineWidth:this.state.lineWidth,lineDash:this.state.lineDash,direction:o,region:i,position:u}),a.fillStyle=s.zr.hex(this.state.color),a.lineJoin="round",a.lineWidth=3.5,a.lineCap="round",a.beginPath();const c=4;if(r==="left"){const h=s.jt.left(i)-1;a.moveTo(h,u),a.lineTo(h-c,u-c),a.lineTo(h-c,u+c)}else r==="right"&&(a.moveTo(s.jt.right(i),u),a.lineTo(s.jt.right(i)+c,u-c),a.lineTo(s.jt.right(i)+c,u+c));a.closePath(),a.stroke()}}const ua={[it.TYPE]:it},qu=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:ua,Rule:it,ruleStateZ:Fr},Symbol.toStringTag,{value:"Module"})),Fu=bt.extend({location:s.K.x.optional().default("left")}),Ls=2,Qu=n=>s.jt.signedWidth(n)<Ls||s.jt.signedHeight(n)<Ls;class Kt extends la{static TYPE="YAxis";schema=bt;xBounds(){return s.H.max(this.lines.map(e=>e.xBounds()).filter(e=>s.H.isFinite(e)))}bounds(e){const[t,r]=this.iBounds(e,this.dataBounds.bind(this));if(r!=null)throw r;return t}render(e){if(this.deleted)return;const[t,r]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport),i=t.invert().reverse();if(this.renderAxis(e,i),this.renderLines(e,t),this.renderRules(e,i),r!=null)throw r}renderLines({xDataToDecimalScale:e,plot:t,canvases:r,exposure:i},o){if(!r.includes("gl")||Qu(t))return;const a={region:t,dataToDecimalScale:new s.C$1.XY(e,o),exposure:i};this.lines.forEach(l=>l.render(a))}renderRules({container:e,plot:t,canvases:r},i){if(!r.includes("upper2d"))return;const{location:o}=this.state,{render:a}=this.internal,l=s.jt.construct(s.jt.left(e),s.jt.top(t),s.jt.width(e),s.jt.height(t)),u=a.scissor(l,s.Q.ZERO,["upper2d"]),c={container:e,plot:t,decimalToDataScale:i,location:o};this.rules.map(h=>h.render(c)),u()}findByXValue({xDataToDecimalScale:e,plot:t,viewport:r,hold:i,exposure:o},a){const[l,u]=this.dataToDecimalScale(i,this.dataBounds.bind(this),r);if(u!=null)throw u;const c=new s.C$1.XY(e,l),h={region:t,dataToDecimalScale:c,exposure:o};return this.lines.map(f=>({...f.findByXValue(h,a),units:this.state.label}))}dataBounds(){return this.lines.map(e=>e.yBounds())}get lines(){return this.childrenOfType(Ut.TYPE)}get rules(){return this.childrenOfType(it.TYPE)}}const Wu=d.z.object({start:s.r.z,end:s.r.z});class ks extends g.Leaf{static TYPE="range-annotation";schema=Wu;afterUpdate(e){this.internal.render=A.Context.use(e),this.internal.draw=new we(this.internal.render.upper2d,g.use(e))}}const Vu=g.aA.payloadZ.extend({viewport:s.H.bounds}),ha=d.z.object({cursor:s.Q.xy.or(d.z.null()),hovered:Vu.or(d.z.null()),count:d.z.number()});class Jt extends g.Leaf{static TYPE="range-provider";schema=ha;fetchedInitial=s.m.ZERO;afterUpdate(e){const{internal:t}=this;t.render=A.Context.use(e),t.draw=new we(t.render.upper2d,g.use(e)),t.requestRender=gn(e),t.runAsync=g.useErrorHandler(e),t.ranges??=new Map;const r=qe(e);if(t.requestRender("tool"),r==null)return;t.client=r;const i=xl(e,this.key);t.removeListener?.();const o=i.ranges.onSet(l=>{t.client!=null&&(s.zr.isCrude(l.color)&&t.ranges.set(l.key,t.client.ranges.sugarOne(l)),this.setState(u=>({...u,count:t.ranges.size})),t.requestRender("tool"))}),a=i.ranges.onDelete(async l=>{t.ranges.delete(l),this.setState(u=>({...u,count:t.ranges.size})),t.requestRender("tool")});t.removeListener=()=>{o(),a()}}fetchInitial(e){const{internal:t}=this,{client:r,runAsync:i}=t;r==null||this.fetchedInitial.equals(e,s.a$1.minutes(1))||(this.fetchedInitial=e,i(async()=>{(await r.ranges.retrieve(e)).forEach(a=>{s.zr.isCrude(a.color)&&t.ranges.set(a.key,a)}),this.setState(a=>({...a,count:t.ranges.size}))},"failed to fetch initial ranges"))}render(e){const{dataToDecimalScale:t,region:r,viewport:i,timeRange:o}=e;this.fetchInitial(o);const{draw:a,ranges:l}=this.internal,u=t.scale(s.jt.xBounds(r)),c=this.state.cursor==null?null:this.state.cursor.x;let h=null;const f=a.canvas.scissor(s.jt.construct({x:s.jt.left(r),y:s.jt.top(r)-35},{x:s.jt.right(r),y:s.jt.bottom(r)}));l.forEach(p=>{const y=s.zr.colorZ.safeParse(p.color);if(!y.success)return;const v=y.data;let b=u.pos(Number(p.timeRange.start.valueOf()));const T=u.pos(Number(p.timeRange.end.valueOf()));if(T<s.jt.left(r)||b>s.jt.right(r))return;b=s.R(b,s.jt.left(r)-2,s.jt.right(r)-1);let E=!1;c!=null&&(E=s.H.contains({lower:b,upper:T},c)),E&&(h={key:p.key,parent:p.parent,name:p.name,color:p.color,labels:p.labels,timeRange:p.timeRange,viewport:{lower:t.scale(s.jt.xBounds(i)).pos(Number(p.timeRange.start.valueOf())),upper:t.scale(s.jt.xBounds(i)).pos(Number(p.timeRange.end.valueOf()))}}),a.container({region:s.jt.construct({x:b,y:s.jt.top(r)-1},{x:T,y:s.jt.bottom(r)-1}),backgroundColor:s.zr.setAlpha(v,.2),bordered:!1});const P=s.jt.construct({x:b+1,y:s.jt.top(r)-34},{x:T-1,y:s.jt.top(r)-12});a.container({region:P,backgroundColor:s.jt.width(P)<20?s.zr.setAlpha(v,.4):C=>E?C.colors.gray.l2:C.colors.gray.l0,bordered:!0,borderWidth:1,borderRadius:2,borderColor:s.zr.setAlpha(v,.8)}),a.text({text:p.name,position:{x:b+8,y:s.jt.top(r)-30},level:"small",shade:10,weight:500,maxWidth:T-b-16})}),f(),h!=null?this.setState(p=>({...p,hovered:h})):this.state.hovered&&this.setState(p=>({...p,hovered:null}))}}const Gu={[ks.TYPE]:ks,[Jt.TYPE]:Jt},Xu=bt;class en extends la{static TYPE="XAxis";schema=bt;render(e){if(this.deleted)return;const[t,r]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(this.renderAxis(e,t.reverse()),this.renderYAxes(e,t),this.renderRanges(e,t),r!=null)throw r}findByXDecimal(e,t){const[r,i]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(i!=null)throw i;return this.findByXValue(e,r.reverse().pos(t))}findByXValue(e,t){const[r,i]=this.dataToDecimalScale(e.hold,this.dataBounds.bind(this),e.viewport);if(i!=null)throw i;const o={...e,xDataToDecimalScale:r};return this.yAxes.map(a=>a.findByXValue(o,t)).flat()}renderYAxes(e,t){const r={...e,xDataToDecimalScale:t};this.yAxes.forEach(i=>i.render(r))}get yAxes(){return this.childrenOfType(Kt.TYPE)}get ranges(){return this.childrenOfType(Jt.TYPE)}bounds(e){const[t,r]=this.iBounds(e,this.dataBounds.bind(this));if(r!=null)throw r;return t}renderRanges(e,t){const r=this.bounds(e.hold),i=s.H.min([r,s.m.MAX.numericBounds]),o=new s.m(i.lower,i.upper);this.ranges.forEach(a=>a.render({dataToDecimalScale:t,region:e.plot,viewport:e.viewport,timeRange:o}))}dataBounds(){return this.yAxes.map(e=>e.xBounds())}}const Ku=s.Q.construct(12),Ju=3,eh=14,th=s.Q.construct(6),Qr=d.z.object({position:s.Q.xy.or(d.z.null()),textColor:s.zr.colorZ.optional().default(s.zr.ZERO),backgroundColor:s.zr.colorZ.optional().default(s.zr.ZERO),borderColor:s.zr.colorZ.optional().default(s.zr.ZERO),ruleColor:s.zr.colorZ.optional().default(s.zr.ZERO),ruleStrokeWidth:d.z.number().optional().default(1),ruleStrokeDash:d.z.number().default(0)});class at extends g.Leaf{static TYPE="tooltip";schema=Qr;afterUpdate(e){const t=g.use(e);s.zr.isZero(this.state.textColor)&&(this.state.textColor=t.colors.text),s.zr.isZero(this.state.backgroundColor)&&(this.state.backgroundColor=t.colors.gray.l1),s.zr.isZero(this.state.borderColor)&&(this.state.borderColor=t.colors.border),s.zr.isZero(this.state.ruleColor)&&(this.state.ruleColor=t.colors.gray.l7),this.internal.dotColor=t.colors.text,this.internal.dotColorContrast=t.colors.textInverted,this.internal.render=A.Context.use(e),this.internal.draw=new we(this.internal.render.upper2d,t),ae(e,"tool")}afterDelete(e){ae(e,"tool")}render(e){if(this.deleted||this.state.position==null)return;const{region:t}=e,r=s.C$1.XY.scale(s.jt.DECIMAL).scale(t),i=s.C$1.XY.scale(t).scale(s.jt.DECIMAL),o=e.findByXDecimal(i.x.pos(this.state.position.x)),a=o.filter(b=>s.Q.isFinite(b.value)),{draw:l}=this.internal,u=a.reduce((b,T)=>b+T.position.x,0)/a.length,c=new s.r(a.reduce((b,T)=>b+T.value.x,0)/a.length),h=r.x.pos(u);if(!s.H.contains(s.jt.xBounds(t),h))return;l.rule({stroke:this.state.ruleColor,lineWidth:this.state.ruleStrokeWidth,lineDash:this.state.ruleStrokeDash,direction:"y",region:t,position:h}),a.forEach(b=>{const T=r.pos(b.position);l.circle({fill:s.zr.setAlpha(b.color,.5),radius:8,position:T}),l.circle({fill:s.zr.setAlpha(b.color,.8),radius:5,position:T}),l.circle({fill:s.zr.pickByContrast(b.color,this.internal.dotColor,this.internal.dotColorContrast),radius:2,position:T})});const f=i.pos(this.state.position),p={...s.K.TOP_LEFT};f.x>.6&&(p.x="right"),f.y>.6&&(p.y="bottom");let y=o.reduce((b,T)=>Math.max(b,T.label?.length??0),0);const v=c.toString("preciseDate","local").length;v>y&&(y=v),l.list({root:p,offset:Ku,length:a.length+1,padding:th,itemHeight:eh,spacing:Ju,width:y*7+48,position:this.state.position,draw:(b,T)=>{let E="",P="",C=this.state.textColor;if(b===0)E="Time",P=c.toString("preciseDate","local");else{const L=a[b-1];E=L.label??"",P=s.Lr.roundBySpan(L.value.y,L.bounds).toString(),C=L.color}l.text({position:s.jt.topLeft(T),text:E,level:"small",weight:500,color:C}),l.text({position:s.Q.translateY(s.jt.topRight(T),-1),text:P,level:"small",justify:"right",code:!0,shade:10})}})}}const da={[at.TYPE]:at},nh=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:da,Tooltip:at,tooltipStateZ:Qr},Symbol.toStringTag,{value:"Module"})),fa=d.z.enum(["one","two"]),Wr=d.z.object({one:s.Q.xy.nullable(),two:s.Q.xy.nullable(),hover:s.Q.xy.nullable(),mode:fa.optional().default("one"),color:d.z.union([s.zr.colorZ,d.z.object({verticalLine:s.zr.colorZ.optional().default(s.zr.ZERO),horizontalLine:s.zr.colorZ.optional().default(s.zr.ZERO),obliqueLine:s.zr.colorZ.optional().default(s.zr.ZERO)})]).optional().default(s.zr.ZERO),strokeWidth:d.z.number().optional().default(1),strokeDash:d.z.number().optional().default(2)}),rh=n=>n==="one"?"1":"2",sh=n=>n.colors.error.z,ih=n=>n.colors.secondary.z,ah=n=>n.colors.gray.l9,Ve=6,Ge=14,Xe=8,Et=8,Ct=3,oh=9,lh=8,ch=2,uh=2,hh=8,dh=5,fh=2,ph=.5,gh=.8,Rt=50,Pt=80,mh=30,yh=30,bh=10,vh=40,Sh=100,Th=30,Ce=15,Os=8,xh=10;class ot extends g.Leaf{static TYPE="measure";schema=Wr;afterUpdate(e){const t=A.Context.use(e);this.internal.theme=g.use(e),this.internal.renderCtx=t,this.internal.draw=new we(t.upper2d,this.internal.theme),ae(e,"tool"),this.internal.dotColor=this.internal.theme.colors.text,this.internal.dotColorContrast=this.internal.theme.colors.textInverted}afterDelete(e){ae(e,"layout")}get verticalLineColor(){return s.zr.isColor(this.state.color)?s.zr.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:s.zr.isZero(this.state.color.verticalLine)?this.internal.theme.colors.gray.l8:this.state.color.verticalLine}get horizontalLineColor(){return s.zr.isColor(this.state.color)?s.zr.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:s.zr.isZero(this.state.color.horizontalLine)?this.internal.theme.colors.gray.l8:this.state.color.horizontalLine}get obliqueLineColor(){return s.zr.isColor(this.state.color)?s.zr.isZero(this.state.color)?this.internal.theme.colors.gray.l8:this.state.color:s.zr.isZero(this.state.color.obliqueLine)?this.internal.theme.colors.gray.l8:this.state.color.obliqueLine}findPoint(e,t,r,i,o){const a=i!=null&&!s.Q.equals(t,i);if(r!=null&&!a){const c=e.findByXValue(r.x).filter(h=>Number.isFinite(h.value.x)&&Number.isFinite(h.value.y));return c.length>0?c.sort((h,f)=>s.Q.distance(r,h.value)-s.Q.distance(r,f.value))[0]:null}const l=o.pos(t),u=e.findByXDecimal(l.x).filter(c=>Number.isFinite(c.value.x)&&Number.isFinite(c.value.y));return u.length===0?null:u.sort((c,h)=>s.Q.distance(l,c.position)-s.Q.distance(l,h.position))[0]}find(e){const{one:t,two:r}=this.state;if(t==null||r==null)return null;const{dataOne:i,dataTwo:o,clickOne:a,clickTwo:l}=this.internal,u=s.C$1.XY.scale(e.region).scale(s.jt.DECIMAL),c=this.findPoint(e,t,i,a,u);if(c==null)return null;(a==null||!s.Q.equals(t,a))&&(this.internal.dataOne={...c.value},this.internal.clickOne={...t});const h=this.findPoint(e,r,o,l,u);return h==null?null:((l==null||!s.Q.equals(r,l))&&(this.internal.dataTwo={...h.value},this.internal.clickTwo={...r}),[c,h])}drawLabelValue(e,t,r,i){const{draw:o}=this.internal,a=s.Q.construct(Ve),l=e.length*Xe,u=t.length*Et,c=l+u+a.x*Ct,h=Ge+a.y*2,f=s.jt.construct(r,c,h);o.container({region:f,backgroundColor:p=>p.colors.gray.l1}),o.text({text:e,position:s.Q.translate(s.jt.topLeft(f),a),level:"small",weight:500,color:i(this.internal.theme)}),o.text({text:t,position:s.Q.translate(s.jt.topRight(f),[-a.x-1,a.y-1]),level:"small",justify:"right",code:!0,shade:10})}drawCombinedDeltaLabel(e,t,r,i,o,a){const{draw:l,theme:u}=this.internal,c=s.Q.construct(Ve),h=Xe*5,f=Math.max(t.length,r.length,i.length),p=h+f*Et+c.x*Ct,y=Ge,v=y*3+c.y*2;let b;if(a){const T=s.Q.translate(e,[-p/2,-v/2]);b=s.jt.construct(T,p,v)}else if(b=s.jt.construct(e,p,v),s.jt.right(b)>s.jt.right(o)){const T=s.Q.translateX(e,-p-Pt*2);b=s.jt.construct(T,p,v)}l.container({region:b,backgroundColor:T=>T.colors.gray.l1}),this.drawPointLabelRow({region:b,label:"ΔX",value:t,labelColor:u.colors.error.z,yOffset:0,leftOffset:0}),this.drawPointLabelRow({region:b,label:"ΔY",value:r,labelColor:u.colors.secondary.z,yOffset:y,leftOffset:0}),this.drawPointLabelRow({region:b,label:"Slope",value:i,labelColor:u.colors.gray.l9,yOffset:y*2,leftOffset:0})}drawPointLabelRow(e){const{region:t,label:r,value:i,labelColor:o,yOffset:a,leftOffset:l}=e,{draw:u}=this.internal,c=s.Q.construct(Ve);u.text({text:r,position:s.Q.translate(s.jt.topLeft(t),[c.x+l,c.y+a]),level:"small",weight:500,color:o}),u.text({text:i,position:s.Q.translate(s.jt.topRight(t),[-c.x-1,c.y+a-1]),level:"small",justify:"right",code:!0,shade:10})}drawPointLabel(e){const{pointNumber:t,position:r,value:i,units:o,bounds:a,toTop:l,viewRegion:u,xDist:c}=e,{draw:h,theme:f}=this.internal,p=new s.r(i.x),y=p.toString(p.formatBySpan(c),"local"),v=`${s.Lr.roundBySpan(i.y,a)} ${o??""}`,b=`${t}`,T=b.length*Xe,E=s.Q.construct(Ve),P=Xe,C=Math.max(y.length,v.length),L=T+Os+P+C*Et+E.x*Ct,z=Ge,x=z*2+E.y*2;let _=l?-(x+Ce):Ce,I=s.jt.construct(s.Q.translate(r,[-L/2,_]),L,x);(l&&s.jt.top(I)<s.jt.top(u)||!l&&s.jt.bottom(I)>s.jt.bottom(u))&&(_=l?Ce:-(x+Ce),I=s.jt.construct(s.Q.translate(r,[-L/2,_]),L,x)),h.container({region:I,backgroundColor:Q=>Q.colors.gray.l1}),h.text({text:b,position:s.Q.translate(s.jt.topLeft(I),[E.x,E.y]),level:"small",weight:500,color:f.colors.gray.l9});const G=T+Os;this.drawPointLabelRow({region:I,label:"X",value:y,labelColor:f.colors.error.z,yOffset:0,leftOffset:G}),this.drawPointLabelRow({region:I,label:"Y",value:v,labelColor:f.colors.secondary.z,yOffset:z,leftOffset:G})}drawPointMarker(e,t){const{draw:r}=this.internal;r.circle({fill:s.zr.setAlpha(t,ph),radius:hh,position:e}),r.circle({fill:s.zr.setAlpha(t,gh),radius:dh,position:e}),r.circle({fill:s.zr.pickByContrast(t,this.internal.dotColor,this.internal.dotColorContrast),radius:fh,position:e})}calculateYLabelPosition(e,t,r){return t?s.Q.translateX(e,mh):r?s.Q.translateX(e,yh):e}calculateXLabelPosition(e,t,r){return t?s.Q.translateY(e,vh):r?s.Q.translateY(e,bh):e}calculateSlopeLabelPosition(e){const{basePos:t,yLabelPos:r,isVeryClose:i,isHorizontal:o,xPixelDist:a,yPixelDist:l}=e;return i?s.Q.translateX(t,Pt):o?s.Q.translateY(t,-35):Math.abs(t.x-r.x)<Sh&&Math.abs(t.y-r.y)<Th?a<l?s.Q.translateY(t,-35):s.Q.translateX(t,Pt):t}renderHover(e){if(this.state.hover==null)return;const t=this.state.hover,r=s.C$1.XY.scale(e.region).scale(s.jt.DECIMAL),i=r.pos(t),o=e.findByXDecimal(r.pos(t).x);if(o.length===0)return;const a=o.sort((c,h)=>s.Q.distance(i,c.position)-s.Q.distance(i,h.position))[0],{draw:l}=this.internal,u=r.reverse().pos(a.position);l.circle({stroke:s.zr.setAlpha(a.color,1),strokeWidth:ch,lineDash:uh,radius:oh,position:u}),l.circle({fill:this.internal.theme.colors.gray.l3,radius:lh,position:u}),l.text({text:rh(this.state.mode),position:u,level:"small",align:"middle",justify:"center"})}render(e){if(this.deleted)return;this.renderHover(e);const t=this.find(e);if(t==null)return;const[r,i]=t,{draw:o}=this.internal,{strokeDash:a,strokeWidth:l}=this.state,u=s.C$1.XY.scale(s.jt.DECIMAL).scale(e.region),c=u.pos(r.position),h=u.pos(i.position),f=Math.abs(r.value.x-i.value.x),p=i.value.y-r.value.y,y=Math.abs(p);if(!Number.isFinite(f)||!Number.isFinite(y))return;const v=new s.a$1(f),b=p/v.seconds,T=Math.abs(c.x-h.x),E=Math.abs(c.y-h.y),P=E<Rt,C=T<Rt,L=T<Rt||E<Rt;o.line({start:s.Q.construct(c.x,c.y),end:s.Q.construct(c.x,h.y),stroke:this.verticalLineColor,lineDash:a,lineWidth:l}),o.line({start:s.Q.construct(c.x,h.y),end:s.Q.construct(h.x,h.y),stroke:this.horizontalLineColor,lineDash:a,lineWidth:l}),o.line({start:s.Q.construct(c.x,c.y),end:s.Q.construct(h.x,h.y),stroke:this.obliqueLineColor,lineDash:a,lineWidth:l}),this.drawPointMarker(c,r.color),this.drawPointMarker(h,i.color);const z=`${s.Lr.roundBySpan(y,s.H.construct(y))} ${r.units??""}`,x=v.lessThan(s.a$1.milliseconds(xh))?s.a$1.MICROSECOND:s.a$1.MILLISECOND,_=v.truncate(x).toString();let I=s.Lr.roundBySpan(b,s.H.construct(Math.abs(b))).toString();if(r.units!=null&&r.units.length>0&&(I+=` ${r.units} / s`),L){const Q=s.Q.construct((c.x+h.x)/2,(c.y+h.y)/2),w=Xe*6,U=Math.max(_.length,z.length,I.length),Y=Ve,X=w+U*Et+Y*Ct,he=Ge*3+Y*2,te=s.jt.construct(s.Q.translate(Q,[-X/2,-he/2]),X,he),ne=c.y<h.y,K=150,Z=Ge*2+Y*2,yn=ne?-55:Ce,bn=s.jt.construct(s.Q.translate(c,[-K/2,yn]),K,Z),vn=ne?Ce:-55,Sn=s.jt.construct(s.Q.translate(h,[-K/2,vn]),K,Z),Tn=s.jt.area(s.jt.intersection(te,bn))>0,xn=s.jt.area(s.jt.intersection(te,Sn))>0,vt=!Tn&&!xn,wn=vt?Q:s.Q.construct(Math.max(c.x,h.x)+Pt,(c.y+h.y)/2);this.drawCombinedDeltaLabel(wn,_,z,I,e.region,vt)}else{const Q=this.calculateYLabelPosition(s.Q.construct(c.x,(c.y+h.y)/2),L,C);this.drawLabelValue("ΔY",z,Q,ih);const w=this.calculateXLabelPosition(s.Q.construct((c.x+h.x)/2,h.y),L,P);this.drawLabelValue("ΔX",_,s.Q.translateX(w,-15),sh);const U=this.calculateSlopeLabelPosition({basePos:s.Q.construct((c.x+h.x)/2,(c.y+h.y)/2),yLabelPos:Q,isVeryClose:L,isHorizontal:P,xPixelDist:T,yPixelDist:E});this.drawLabelValue("Slope",I,U,ah)}const G=c.y<h.y;this.drawPointLabel({pointNumber:1,position:c,value:r.value,units:r.units??null,bounds:r.bounds,toTop:G,viewRegion:e.region,xDist:v}),this.drawPointLabel({pointNumber:2,position:h,value:i.value,units:i.units??null,bounds:i.bounds,toTop:!G,viewRegion:e.region,xDist:v})}}const pa={[ot.TYPE]:ot},wh=Object.freeze(Object.defineProperty({__proto__:null,Measure:ot,REGISTRY:pa,measureStateZ:Wr,modeZ:fa},Symbol.toStringTag,{value:"Module"})),ga=d.z.object({container:s.jt.box,viewport:s.jt.box,hold:d.z.boolean().optional().default(!1),grid:d.z.record(d.z.string(),ia),visible:d.z.boolean().optional().default(!0),clearOverScan:s.Q.crudeZ.optional().default(s.Q.ZERO)}),Eh=(n,e)=>{const t=s.jt.width(n)*Math.sqrt(s.jt.height(n)),r=s.jt.width(e)*Math.sqrt(s.jt.height(e));return t/r},Ch=["upper2d","lower2d","gl"],Rh=["upper2d"];class Jn extends g.Composite{static TYPE="LinePlot";schema=ga;afterUpdate(e){this.internal.instrumentation=A.useInstrumentation(e,"lineplot"),this.internal.handleError=g.useErrorHandler(e),this.internal.renderCtx=A.Context.use(e),pn(e,t=>{this.state.visible&&this.requestRender("low",t)}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender("high","layout")}afterDelete(e){this.internal.renderCtx=A.Context.use(e),this.requestRender("high","layout")}findByXDecimal(e){const t={...this.state,plot:this.calculatePlot(),exposure:this.exposure};return this.axes.flatMap(r=>r.findByXDecimal(t,e)).flat()}findByXValue(e){const t={...this.state,plot:this.calculatePlot(),exposure:this.exposure};return this.axes.flatMap(r=>r.findByXValue(t,e)).flat()}get axes(){return this.childrenOfType(en.TYPE)}get tooltips(){return this.childrenOfType(at.TYPE)}get measures(){return this.childrenOfType(ot.TYPE)}get bounds(){return this.childrenOfType(qt.TYPE)}get exposure(){return Eh(this.state.viewport,this.state.container)}renderAxes(e,t){const r={...this.state,plot:e,canvases:t,exposure:this.exposure};this.axes.forEach(i=>i.render(r))}renderTooltips(e,t){const r={findByXDecimal:this.findByXDecimal.bind(this),region:e,canvases:t};this.tooltips.forEach(i=>i.render(r))}renderBounds(){this.bounds.forEach(e=>e.render({getBounds:()=>{const t={};return this.axes.forEach(r=>{const i=r.state.axisKey??r.key;t[i]=r.bounds(this.state.hold),r.yAxes.forEach(o=>{const a=o.state.axisKey??o.key;t[a]=o.bounds(this.state.hold)})}),t}}))}renderMeasures(e){const t={findByXDecimal:this.findByXDecimal.bind(this),findByXValue:this.findByXValue.bind(this),region:e};this.measures.forEach(r=>r.render(t))}calculatePlot(){return Du(this.state.grid,this.state.container)}render(e){const{instrumentation:t,renderCtx:r,handleError:i}=this.internal;if(this.deleted){t.L.debug("deleted, skipping render",{key:this.key});return}if(!this.state.visible)return t.L.debug("not visible, skipping render",{key:this.key}),({canvases:h})=>r.erase(this.state.container,this.state.clearOverScan,...h);const o=this.calculatePlot();t.L.debug("rendering",{key:this.key,viewport:this.state.viewport,container:this.state.container,grid:this.state.grid,plot:o,canvases:e});const a=s.Q.construct(this.state.clearOverScan),l=r.scissor(this.state.container,a,e.filter(h=>h!=="gl")),u=r.scissor(o,s.Q.ZERO,e.filter(h=>h==="gl"));try{this.renderAxes(o,e),this.renderTooltips(o,e),this.renderMeasures(o),this.renderBounds()}catch(h){i(h,"failed to render line plot")}finally{l(),u()}t.L.debug("rendered",{key:this.key});const c=s.jt.copy(this.state.container);return({canvases:h})=>r.erase(c,this.state.clearOverScan,...h)}requestRender(e,t){const{renderCtx:r}=this.internal;let i=Ch;t==="tool"&&(i=Rh),r.loop.set({key:`${this.type}-${this.key}`,render:()=>this.render(i),priority:e,canvases:i})}}const Ph={[Jn.TYPE]:Jn,[en.TYPE]:en,[Kt.TYPE]:Kt,[qt.TYPE]:qt},ma=d.z.object({region:s.jt.box,wheelPos:d.z.number(),scrolling:d.z.boolean(),empty:d.z.boolean(),visible:d.z.boolean(),telem:_t.optional().default(js),font:ge.levelZ.optional().default("p"),color:s.zr.colorZ.optional().default(s.zr.ZERO),overshoot:s.Q.xy.optional().default({x:0,y:0})}),Lh=.98,Ke="lower2d",kh={offset:0n,offsetRef:0n,scrollRef:0};class lt extends g.Leaf{static TYPE="log";static z=ma;schema=lt.z;values=new s.Oe([]);scrollState=kh;afterUpdate(e){const{internal:t}=this;t.render=A.Context.use(e),t.theme=g.use(e),s.zr.isZero(this.state.color)?this.internal.textColor=t.theme.colors.gray.l11:t.textColor=this.state.color,t.telem=B(e,this.state.telem,t.telem);const{scrolling:r,wheelPos:i}=this.state;if(this.state.scrolling&&!this.prevState.scrolling){const u=this.values.alignmentBounds.upper-1n;this.scrollState={offset:u,offsetRef:u,scrollRef:this.state.wheelPos}}else if(r){const{scrollState:u,values:c}=this,h=Math.ceil((i-this.scrollState.scrollRef)/this.lineHeight);u.offset=this.values.traverseAlignment(u.offsetRef,-BigInt(h)),u.offset<c.alignmentBounds.lower+BigInt(this.visibleLineCount)&&(u.offset=c.alignmentBounds.lower,this.setState(f=>({...f,wheelPos:this.prevState.wheelPos}))),u.offset>=c.alignmentBounds.upper&&this.setState(f=>({...f,scrolling:!1}))}const[a,l]=this.internal.telem.value();this.values=l,this.checkEmpty(),t.stopListeningTelem?.(),t.stopListeningTelem=t.telem.onChange(()=>{const[u,c]=this.internal.telem.value();this.checkEmpty(),this.values=c,this.requestRender()}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender()}checkEmpty(){const e=this.values.length===0;e!==this.state.empty&&this.setState(t=>({...t,empty:e}))}afterDelete(){const{telem:e,render:t}=this.internal;e.cleanup?.(),t.erase(s.jt.construct(this.state.region),s.Q.ZERO,Ke)}requestRender(){const{render:e}=this.internal;e.loop.set({key:`${this.type}-${this.key}`,render:()=>this.render(),priority:"high",canvases:[Ke]})}get lineHeight(){return this.internal.theme.typography[this.state.font].size*this.internal.theme.sizes.base}get totalHeight(){return Math.ceil(this.values.length*this.lineHeight)}get visibleLineCount(){return Math.min(Math.floor((s.jt.height(this.state.region)-12)/this.lineHeight),this.values.length)}render(){const{render:e}=this.internal,t=this.state.region;if(s.jt.areaIsZero(t))return;if(!this.state.visible)return()=>e.erase(t,s.Q.ZERO,Ke);let r;if(!this.state.scrolling)r=this.values.subIterator(this.values.length-this.visibleLineCount,this.values.length);else{const c=this.values.traverseAlignment(this.scrollState.offset,-BigInt(this.visibleLineCount));r=this.values.subAlignmentSpanIterator(c,this.visibleLineCount)}const i=this.state.region,o=e[Ke],a=new we(o,this.internal.theme),l=e.scissor(i,s.Q.ZERO,[Ke]);this.renderElements(a,r),this.renderScrollbar(a),l();const u=s.jt.copy(this.state.region);return({canvases:c})=>e.erase(u,this.state.overshoot,...c)}renderScrollbar(e){const t=this.state.region,r=s.jt.height(t)/this.totalHeight*s.jt.height(t);if(r>=s.jt.height(t)*Lh)return;let i=s.jt.bottom(t)-r;this.state.scrolling&&(i-=Number(this.values.distance(this.values.alignmentBounds.upper,this.scrollState.offset))/this.values.length*s.jt.height(t)),i<0&&(i=s.jt.top(t)),e.container({region:s.jt.construct({x:s.jt.right(t)-6,y:i},{width:6,height:r}),bordered:!1,backgroundColor:o=>o.colors.gray.l6})}renderElements(e,t){const r=this.state.region;let i=0;for(const o of t){const a=this.values.dataType.equals(s.n.JSON)?JSON.stringify(o):o.toString();e.text({text:a,level:this.state.font,shade:11,position:s.Q.translate(s.jt.topLeft(r),{x:6,y:i*this.lineHeight+6}),code:!0}),i++}}}const Oh={[lt.TYPE]:lt},_h="ranges",zh={channel:g.aA.SET_CHANNEL_NAME,schema:g.aA.payloadZ,onChange:async({store:n,changed:e,client:t})=>{const r=t.ranges.sugarOne(e),i=n.ranges.get(e.key);let o;i?.labels==null&&(o=await r.retrieveLabels());let a=null;i?.parent==null&&(a=await r.retrieveParent()),n.ranges.set(e.key,l=>t.ranges.sugarOne({...r.payload,labels:l?.labels??o,parent:l?.parent??a}))}},Mh={channel:g.aA.DELETE_CHANNEL_NAME,schema:g.aA.keyZ,onChange:({store:n,changed:e})=>n.ranges.delete(e)},Ih={equal:(n,e)=>ie.T.equal(n.payload,e.payload),listeners:[zh,Mh]},ya=d.z.object({authority:s.Wr.authorityZ.optional(),valid:d.z.boolean().optional()}).default({authority:void 0,valid:!1}),ba=d.z.object({triggered:d.z.boolean(),status:s.tn.statusZ(ya),sink:ln.optional().default(on),source:mr.optional().default(pr)});class er extends g.Leaf{static TYPE="Chip";schema=ba;afterUpdate(e){const{internal:t}=this,{sink:r,source:i}=this.state;t.source=B(e,i,t.source),t.sink=He(e,r,t.sink),this.state.triggered&&!this.prevState.triggered&&t.sink.set(this.state.status.details?.authority!==s.Wr.ABSOLUTE_AUTHORITY),this.updateEnabledState(),t.stopListening?.(),t.stopListening=t.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();ie.T.equal(e,this.state.status)||this.setState(t=>({...t,status:e,triggered:!1}))}afterDelete(){this.internal.stopListening(),this.internal.source.cleanup?.(),this.internal.sink.cleanup?.()}render(){}}const va=d.z.object({}),_s="control-state-provider",Sa=g.WI.stateZ.extend({subjectColor:s.zr.colorZ});class ct extends g.Composite{static TYPE="StateProvider";schema=va;colors=new Map;tracker;disconnectTrackerChange;obs=new sn.Observer;static use(e){return e.get(_s)}afterUpdate(e){const{internal:t}=this;t.instrumentation=A.useInstrumentation(e,"control-state");const r=g.use(e);t.palette=r.colors.visualization.palettes.default,t.defaultColor=r.colors.gray.l8;const i=qe(e);if(t.client!=null&&i===t.client)return;t.client=i,e.set(_s,this),g.useErrorHandler(e)(async()=>{await this.maybeCloseTracker(),t.client!=null&&(this.internal.instrumentation.L.debug("starting state tracker"),await this.openTracker(t.client))},"failed to open control state tracker")}async maybeCloseTracker(){this.tracker!=null&&(this.internal.instrumentation.L.debug("stopping state tracker"),this.disconnectTrackerChange?.(),await this.tracker.close(),this.tracker=void 0)}afterDelete(e){g.useErrorHandler(e)(async()=>{await this.maybeCloseTracker()},"failed to close control state tracker")}onChange(e){return this.obs.onChange(e)}get(e){return Array.isArray(e)?s.c.unique(e).map(t=>this.getOne(t)).filter(t=>t!=null):this.getOne(e)}getOne(e){if(this.tracker==null)return;const t=this.tracker.states.get(e);if(t!=null)return{...t,subjectColor:this.colors.get(t.subject.key)??this.internal.defaultColor}}async openTracker(e){const{internal:t}=this,{instrumentation:r}=t;try{this.tracker=await e.control.openStateTracker()}catch{r.L.error("failed to open state tracker");return}this.disconnectTrackerChange?.(),this.disconnectTrackerChange=this.tracker.onChange(i=>{if(r.L.debug("transfer",{transfers:i.map(o=>g.WI.transferString(o))}),this.tracker==null)throw new g.qt("tracker is null inside it's own onChange callback!");this.updateColors(this.tracker),this.obs.notify(i)})}updateColors(e){const t=e.subjects(),r=t.map(a=>a.key),i=Array.from(this.colors.values());this.colors.forEach((a,l)=>!r.includes(l)&&this.colors.delete(l));const{palette:o}=this.internal;t.forEach(a=>{if(this.colors.has(a.key))return;const l=o.find(u=>!i.includes(u))??o[0];this.colors.set(a.key,l),i.push(l)})}}const Ta=d.z.enum(["acquired","released","overridden","failed"]),xa=d.z.object({name:d.z.string(),authority:d.z.number().default(0),acquireTrigger:d.z.number(),status:Ta.optional(),needsControlOf:g.zI.keyZ.array().optional().default([])});class tr extends g.Composite{static TYPE="Controller";schema=xa;registry=new Map;writer;afterUpdate(e){const{internal:t}=this;t.instrumentation=A.useInstrumentation(e),t.addStatus=g.useAdder(e),t.runAsync=g.useErrorHandler(e),(t.prevTrigger==null||Math.abs(this.state.acquireTrigger-t.prevTrigger)>1)&&(t.prevTrigger=this.state.acquireTrigger);const r=qe(e),i=ct.use(e);t.stateProv=i,t.telemCtx=wi(e,this,t.telemCtx),t.client=r,t.runAsync(async()=>{t.client==null&&await this.release(),this.state.acquireTrigger>t.prevTrigger?await this.acquire():this.state.acquireTrigger<t.prevTrigger&&await this.release()},"failed to acquire control")}afterDelete(){const{internal:e}=this;e.runAsync(async()=>await this.release(),"failed to release control")}async updateNeedsControlOf(){const{client:e}=this.internal;if(e==null)return;const t=new Set([]);for(const i of this.registry.keys())(await i.needsControlOf(e)).forEach(a=>a!==0&&t.add(a));const r=Array.from(t);ie.q.unorderedPrimitiveArrays(this.state.needsControlOf,r)!==ie.q.EQUAL&&this.setState(i=>({...i,needsControlOf:r}))}async acquire(){this.internal.prevTrigger=this.state.acquireTrigger;const{client:e,addStatus:t}=this.internal;if(e==null)return t({message:`Cannot acquire control on ${this.state.name} because no Core has been connected.`,variant:"warning"});try{await this.updateNeedsControlOf();const r=this.state.needsControlOf;if(r.length===0)return t({message:`Cannot acquire control on ${this.state.name} because there are no channels to control.`,variant:"warning"});const i=g.p.now().sub(s.a$1.milliseconds(1));this.writer=await e.openWriter({start:i,channels:r,controlSubject:{key:this.key,name:this.state.name},authorities:this.state.authority}),this.setState(o=>({...o,status:"acquired"}))}catch(r){if(this.setState(i=>({...i,status:"failed"})),!(r instanceof Error))throw r;t({variant:"error",message:`${this.state.name} failed to acquire control`,description:r.message})}}async release(){this.internal.prevTrigger=this.state.acquireTrigger;try{await this.writer?.close()}catch(e){this.internal.addStatus({message:`${this.state.name} failed to release control: ${e.message}`,variant:"error"})}finally{this.setState(e=>({...e,status:"released"})),this.writer=void 0}}async set(e){this.writer==null&&await this.acquire(),await this.writer?.write(e)}async setAuthority(e,t){this.writer==null&&await this.acquire(),await this.writer?.setAuthority(Object.fromEntries(e.map(r=>[r,t])))}async releaseAuthority(e){this.writer==null&&await this.acquire(),await this.writer?.setAuthority(Object.fromEntries(e.map(t=>[t,this.state.authority])))}deleteTelem(e){this.registry.delete(e),this.updateNeedsControlOf()}create(e){const{internal:t}=this,i=(()=>{switch(e.type){case tn.TYPE:{const o=new tn(this,t.runAsync,e.props);return this.registry.set(o,null),o}case rn.TYPE:{const o=new rn(this,this.internal.stateProv,e.props);return this.registry.set(o,null),o}case nn.TYPE:return new nn(this,t.runAsync,e.props);default:return null}})();return i!=null&&this.updateNeedsControlOf(),i}}const wa=d.z.object({channel:d.z.number()});class tn extends dn{static TYPE="controlled-numeric-telem-sink";controller;runAsync;schema=wa;constructor(e,t,r){super(r),this.controller=e,this.runAsync=t}invalidate(){}cleanup(){this.controller.deleteTelem(this)}async needsControlOf(e){if(this.props.channel===0)return[];const t=await e.channels.retrieve(this.props.channel),r=[t.key];return t.index!==0&&r.push(t.index),r}set(...e){this.runAsync(async()=>{const{client:t}=this.controller.internal;if(t==null)throw new g.$I("No Core connected");if(this.props.channel===0)throw new g.G("No command channel specified for actuator");const r=await t.channels.retrieve(this.props.channel),i={[r.key]:e};if(r.index!==0){const o=await t.channels.retrieve(r.index),a=g.p.now();i[o.key]=Array.from({length:e.length},(l,u)=>a.add(s.a$1.nanoseconds(u)))}await this.controller.set(i)},"Failed to command channel")}}const Ah=n=>({type:tn.TYPE,props:n,variant:"sink",valueType:"number"}),Ea=d.z.object({authority:d.z.number().default(g.WI.ABSOLUTE_AUTHORITY),channel:d.z.number()});class nn extends dn{static TYPE="acquire-channel-control";controller;runAsync;schema=Ea;constructor(e,t,r){super(r),this.controller=e,this.runAsync=t}cleanup(){this.controller.deleteTelem(this)}async needsControlOf(e){const t=await e.channels.retrieve(this.props.channel),r=[t.key];return t.index!==0&&r.push(t.index),r}set(e){this.runAsync(async()=>{const{controller:t}=this,{client:r}=t.internal;if(r==null)return;const i=await r.channels.retrieve(this.props.channel),o=[i.key];i.index!==0&&o.push(i.index),e?await this.controller.setAuthority(o,this.props.authority):await this.controller.releaseAuthority(o)},"failed to set channel authority")}}const Dh=n=>({type:nn.TYPE,props:n,variant:"sink",valueType:"boolean"}),Ca=d.z.object({channel:d.z.number()}),Yh=d.z.object({valid:d.z.boolean(),color:s.zr.colorZ.optional(),authority:d.z.number()});class rn extends F{static TYPE="controlled-status-source";prov;valid=!1;stopListening;controller;schema=Ca;constructor(e,t,r){super(r),this.prov=t,this.controller=e}async needsControlOf(){return[]}maybeRevalidate(){if(this.valid)return;const{channel:e}=this.props;this.stopListening?.();const t=s.Wr.filterTransfersByChannelKey(e);this.stopListening=this.prov.onChange(r=>{t(r).length!==0&&this.notify?.()}),this.valid=!0}value(){this.maybeRevalidate();const e=g.p.now();if(this.props.channel===0)return{name:this.controller.key,key:this.controller.key,variant:"disabled",message:"No Channel",time:e,details:{valid:!1,authority:0}};const t=this.prov.get(this.props.channel);return t==null?{name:this.controller.key,key:this.controller.key,variant:"disabled",message:"Uncontrolled",time:e,details:{valid:!0,color:void 0,authority:0}}:{name:this.controller.key,key:t.subject.key,variant:t.subject.key===this.controller.key?"success":"error",message:`Controlled by ${t.subject.name}`,time:e,details:{valid:!0,color:t.subjectColor,authority:t.authority}}}cleanup(){this.controller.deleteTelem(this),this.stopListening?.()}}const Nh=n=>({type:rn.TYPE,props:n,variant:"source",valueType:"status"}),Ra=d.z.object({color:s.zr.colorZ.optional()}).default({color:void 0}),Pa=d.z.object({statusSource:mr.optional().default(pr),colorSource:cn.optional().default(dt),status:s.tn.statusZ(Ra),color:s.zr.colorZ.optional()});class nr extends g.Leaf{static TYPE="Indicator";schema=Pa;stopListeningStatus;stopListeningColor;afterUpdate(e){const{internal:t}=this,{statusSource:r,colorSource:i}=this.state;t.statusSource=B(e,r,t.statusSource),t.colorSource=B(e,i,t.colorSource),this.updateState(),this.stopListeningStatus?.(),this.stopListeningColor?.(),this.stopListeningStatus=t.statusSource.onChange(this.updateState.bind(this)),this.stopListeningColor=t.colorSource.onChange(this.updateState.bind(this))}afterDelete(){this.internal.statusSource.cleanup?.(),this.internal.colorSource.cleanup?.()}render(){}updateState(){const e=this.internal.colorSource.value(),t=this.internal.statusSource.value();s.zr.equals(e,this.state.color)&&t.message===this.state.status.message||this.setState(r=>({...r,color:e,status:t}))}}const La=d.z.object({needsControlOf:g.zI.keyZ.array(),states:Sa.array()});class rr extends g.Leaf{static TYPE="Legend";schema=La;afterUpdate(e){const{internal:t}=this;t.stateProv=ct.use(e);const r=this.state.needsControlOf;t.disconnectStateProv?.();const i=s.Wr.filterTransfersByChannelKey(...r),o=t.stateProv.get(r);this.setState(a=>({...a,states:o})),t.disconnectStateProv=t.stateProv.onChange(a=>{if(i(a).length===0)return;const l=t.stateProv.get(r);this.setState(u=>({...u,states:l}))})}afterDelete(){const{internal:e}=this;e.disconnectStateProv?.()}render(){}}const Zh={[tr.TYPE]:tr,[ct.TYPE]:ct,[nr.TYPE]:nr,[er.TYPE]:er,[rr.TYPE]:rr},ka=["fire","momentary","pulse"],jh=d.z.enum(ka),Oa=d.z.object({trigger:d.z.number(),sink:ln.optional().default(on),mode:jh.optional().default("fire")}),_a=2,za=1;class sr extends g.Leaf{static TYPE="Button";schema=Oa;afterUpdate(e){const{sink:t,mode:r,trigger:i}=this.state,{internal:o}=this;o.prevTrigger??=i,o.sink=He(e,t,o.sink);const a=o.prevTrigger;o.prevTrigger=i;const l=i===a+_a;i===a+za?r=="fire"?this.internal.sink.set(!0):r=="momentary"&&this.internal.sink.set(!1):l&&(r=="momentary"?this.internal.sink.set(!0):r=="pulse"&&this.internal.sink.set(!0,!1))}afterDelete(){this.internal.sink.cleanup?.()}}const $h={[sr.TYPE]:sr},Bh=d.z.object({region:s.jt.box,clearOverScan:s.Q.crudeZ.optional().default(0),visible:d.z.boolean().optional().default(!0),autoRenderInterval:d.z.number().optional().default(1e3)}),zs=["upper2d","lower2d"];class Be extends g.Composite{static TYPE="Table";static stateZ=Bh;schema=Be.stateZ;afterUpdate(e){const{internal:t}=this;t.renderCtx=A.Context.use(e),t.handleError=g.useErrorHandler(e),t.autoRenderInterval??=setInterval(()=>this.state.visible&&this.requestRender("low"),this.state.autoRenderInterval),pn(e,()=>{this.state.visible&&this.requestRender("low")}),!(!this.state.visible&&!this.prevState.visible)&&this.requestRender("high")}afterDelete(){this.internal.autoRenderInterval!=null&&clearInterval(this.internal.autoRenderInterval),this.requestRender("high")}render(){if(this.deleted)return;const e=s.jt.copy(this.state.region);if(!this.state.visible)return()=>this.internal.renderCtx.erase(e,this.state.clearOverScan);const{renderCtx:t,handleError:r}=this.internal,i=s.C$1.XY.translate(s.jt.topLeft(this.state.region)),o=t.scissor(this.state.region,s.Q.construct(this.state.clearOverScan),zs);try{for(const a of this.children)a.render({viewportScale:i})}catch(a){r(a,"Failed to render table")}finally{o()}return()=>this.internal.renderCtx.erase(e,this.state.clearOverScan)}requestRender(e){const{renderCtx:t}=this.internal;t.loop.set({key:`${Be.TYPE}-${this.key}`,render:this.render.bind(this),priority:e,canvases:zs})}}const Uh={[Be.TYPE]:Be};d.z.enum(["small","medium","large","huge"]);const Hh=d.z.object({box:s.jt.box,telem:un.optional().default(fr),backgroundTelem:cn.optional().default(dt),level:ge.levelZ.optional().default("p"),color:s.zr.colorZ.optional().default(s.zr.ZERO),precision:d.z.number().optional().default(2),minWidth:d.z.number().optional().default(60),width:d.z.number().optional(),notation:s.Yr.notationZ.optional().default("standard"),location:s.K.xy.optional().default({x:"left",y:"center"}),units:d.z.string().optional().default("RPM"),bounds:s.H.bounds.optional().default(s.H.construct(0,100)),barWidth:d.z.number().optional().default(12)}),qh=["upper2d","lower2d"];class ut extends g.Leaf{static TYPE="gauge";static z=Hh;schema=ut.z;afterUpdate(e){const{internal:t}=this;t.render=A.Context.use(e),t.theme=g.use(e),s.zr.isZero(this.state.color)?t.textColor=t.theme.colors.gray.l8:t.textColor=this.state.color,t.telem=B(e,this.state.telem,t.telem),t.stopListening?.(),t.stopListening=t.telem.onChange(()=>this.requestRender()),t.backgroundTelem=B(e,this.state.backgroundTelem,t.backgroundTelem),t.stopListeningBackground?.(),t.stopListeningBackground=t.backgroundTelem.onChange(()=>this.requestRender()),t.requestRender=zr(e),t.strokeColor=s.zr.isZero(this.state.color)?t.theme.colors.visualization.palettes.default[0]:this.state.color;const r=this.state.box,i=s.jt.width(r)/2,{barWidth:o}=this.state;t.outerRadius=i-8,t.innerRadius=t.outerRadius-o;const a=Math.PI/2;t.gaugeStartAngle=3*Math.PI/4,t.gaugeAngleRange=2*Math.PI-a,t.gaugeEndAngle=t.gaugeStartAngle+t.gaugeAngleRange,t.labelRadius=t.outerRadius+12,t.labelInwardShift=12,t.centerPos=s.jt.center(r);const l=t.centerPos.y+t.labelRadius*Math.sin(t.gaugeStartAngle)+6;t.minLabelPos=s.Q.construct(t.centerPos.x+t.labelRadius*Math.cos(t.gaugeStartAngle)+t.labelInwardShift,l),t.maxLabelPos=s.Q.construct(t.centerPos.x+t.labelRadius*Math.cos(t.gaugeEndAngle)-t.labelInwardShift,l),t.valueTextPos=s.Q.translateY(t.centerPos,-6),t.unitsTextPos=s.Q.translateY(t.centerPos,s.jt.height(r)/9),t.textLevel=this.state.level,t.labelLevel=ge.downLevel(ge.downLevel(t.textLevel)),this.requestRender()}afterDelete(){const{internal:e}=this;e.stopListening?.(),e.stopListeningBackground?.(),e.telem.cleanup?.(),e.backgroundTelem.cleanup?.(),e.requestRender==null?e.render.erase(s.jt.construct(this.state.box),s.Q.ZERO,...qh):e.requestRender("layout")}requestRender(){const{requestRender:e}=this.internal;e!=null?e("layout"):this.render({})}render({viewportScale:e=s.C$1.XY.IDENTITY}){const{internal:t}=this,r=t.render.upper2d.applyScale(e),i=new we(r,t.theme),o=t.telem.value(),{lower:a,upper:l}=this.state.bounds,u=Number(o),c=s.H.clamp(this.state.bounds,u),h=l-a,f=h===0?0:(c-a)/h,p=t.gaugeStartAngle+f*t.gaugeAngleRange;i.text({text:o,position:t.valueTextPos,shade:10,level:t.textLevel,align:"middle",justify:"center",weight:450,code:!0,useAtlas:!0}),i.text({text:this.state.units,position:t.unitsTextPos,shade:8,level:ge.downLevel(t.textLevel),align:"middle",justify:"center",code:!0,useAtlas:!0}),i.text({text:a.toString(),position:t.minLabelPos,shade:7,level:t.labelLevel,align:"middle",justify:"center",code:!0,useAtlas:!0}),i.text({text:l.toString(),position:t.maxLabelPos,shade:7,level:t.labelLevel,align:"middle",justify:"center",code:!0,useAtlas:!0}),i.circle({stroke:t.theme.colors.gray.l5,radius:{inner:t.innerRadius,outer:t.outerRadius},position:t.centerPos,angle:{lower:t.gaugeStartAngle,upper:t.gaugeEndAngle},lineCap:"round"}),i.circle({stroke:t.strokeColor,radius:{inner:t.innerRadius,outer:t.outerRadius},position:t.centerPos,angle:{lower:t.gaugeStartAngle,upper:p},lineCap:"round"})}}const Fh={[ut.TYPE]:ut},Ma=d.z.object({trigger:d.z.number(),command:d.z.string().optional(),sink:Fs.default(Zs)});class ir extends g.Leaf{static TYPE="Input";schema=Ma;afterUpdate(e){const{sink:t,trigger:r,command:i}=this.state,{internal:o}=this;o.sink=He(e,t,o.sink);const a=o.prevTrigger??r;r>a&&i!=null&&this.internal.sink.set(i),o.prevTrigger=r}afterDelete(){this.internal.sink.cleanup?.()}}const Qh={[ir.TYPE]:ir},Ia=d.z.object({enabled:d.z.boolean(),source:gr.optional().default(dr)});class ar extends g.Leaf{static TYPE="Light";schema=Ia;afterUpdate(e){const{internal:t}=this;this.internal.source=B(e,this.state.source,t.source),this.updateEnabledState(),t.stopListening?.(),t.stopListening=t.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();e!==this.state.enabled&&this.setState(t=>({...t,enabled:e}))}afterDelete(){this.internal.stopListening?.(),this.internal.source.cleanup?.()}}const Wh={[ar.TYPE]:ar},Aa=d.z.object({trigger:d.z.number(),command:d.z.number().optional(),value:d.z.number(),sink:qs.optional().default(Ys),source:Hs.optional().default(Ns)});class or extends g.Leaf{static TYPE="Setpoint";schema=Aa;afterUpdate(e){const{sink:t,source:r,trigger:i,command:o}=this.state,{internal:a}=this;a.prevTrigger??=i,this.internal.source=B(e,r,this.internal.source),a.sink=He(e,t,a.sink);const l=a.prevTrigger;a.prevTrigger=i,i>l&&o!=null&&this.internal.sink.set(o),this.updateValue(),a.stopListening?.(),a.stopListening=a.source.onChange(()=>this.updateValue())}updateValue(){const e=this.internal.source.value();e===this.state.value||isNaN(e)||this.setState(t=>({...t,value:e,triggered:!1}))}afterDelete(){const{internal:e}=this;e.stopListening?.(),e.source.cleanup?.(),e.sink.cleanup?.()}}const Vh={[or.TYPE]:or},Da=d.z.object({triggered:d.z.boolean(),enabled:d.z.boolean(),sink:ln.optional().default(on),source:gr.optional().default(dr)});class lr extends g.Leaf{static TYPE="Toggle";schema=Da;afterUpdate(e){this.internal.addStatus=g.useOptionalAdder(e);const{sink:t,source:r,triggered:i,enabled:o}=this.state,{triggered:a}=this.prevState,{internal:l}=this;l.source=B(e,r,l.source),l.sink=He(e,t,l.sink),i&&!a&&l.sink.set(!o),this.updateEnabledState(),l.stopListening?.(),l.stopListening=l.source.onChange(()=>this.updateEnabledState())}updateEnabledState(){const e=this.internal.source.value();e!==this.state.enabled&&this.setState(t=>({...t,enabled:e,triggered:!1}))}afterDelete(){this.internal.stopListening?.(),this.internal.source.cleanup?.(),this.internal.sink.cleanup?.()}}const Gh={[lr.TYPE]:lr},zn={useAtlas:!0},Xh=d.z.object({box:s.jt.box,telem:un.optional().default(fr),backgroundTelem:cn.optional().default(dt),level:ge.levelZ.optional().default("p"),color:s.zr.colorZ.optional().default(s.zr.ZERO),precision:d.z.number().optional().default(2),stalenessTimeout:d.z.number().optional().default(5),stalenessColor:s.zr.colorZ.optional().default(s.zr.ZERO),minWidth:d.z.number().optional().default(60),width:d.z.number().optional(),notation:s.Yr.notationZ.optional().default("standard"),location:s.K.xy.optional().default({x:"left",y:"center"}),useWidthForBackground:d.z.boolean().optional().default(!1),valueBackgroundShift:s.Q.xy.optional().default(s.Q.ZERO),valueBackgroundOverScan:s.Q.xy.optional().default(s.Q.ZERO)}),Kh=["upper2d","lower2d"];class Ue extends g.Leaf{static TYPE="value";static z=Xh;schema=Ue.z;afterUpdate(e){const{internal:t}=this;t.renderCtx=A.Context.use(e),t.theme=g.use(e),t.telem=B(e,this.state.telem,t.telem),t.stopListening?.(),t.stopListening=t.telem.onChange(()=>{t.lastReceived=performance.now(),this.requestRender()}),t.fontString=Je.fontString(t.theme,{level:this.state.level,code:!0}),t.backgroundTelem=B(e,this.state.backgroundTelem,t.backgroundTelem),t.stopListeningBackground?.(),t.stopListeningBackground=t.backgroundTelem.onChange(()=>this.requestRender()),t.requestRender=zr(e),this.requestRender()}afterDelete(){const{internal:e}=this;e.stopListening?.(),e.stopListeningBackground?.(),e.telem.cleanup?.(),e.backgroundTelem.cleanup?.(),e.requestRender==null?e.renderCtx.erase(s.jt.construct(this.state.box),s.Q.ZERO,...Kh):e.requestRender("layout")}requestRender(){const{requestRender:e}=this.internal;e!=null?e("layout"):this.render({})}get fontHeight(){const{theme:e}=this.internal;return e.typography[this.state.level].size*e.sizes.base}maybeUpdateWidth(e){const{theme:t}=this.internal,r=e+t.sizes.base+this.fontHeight;this.state.width==null||this.state.width+this.fontHeight*.5<r||this.state.minWidth>r&&this.state.width!==this.state.minWidth?this.setState(i=>({...i,width:Math.max(r,i.minWidth)})):this.state.width-this.fontHeight>r&&this.setState(i=>({...i,width:Math.max(r,i.minWidth)}))}getTextColor(){const{theme:e}=this.internal;return performance.now()-this.internal.lastReceived>this.state.stalenessTimeout*1e3?s.zr.isZero(this.state.stalenessColor)?e.colors.warning.m1:this.state.stalenessColor:s.zr.isZero(this.state.color)?s.zr.pickByContrast(e.colors.border,e.colors.gray.l11,e.colors.gray.l0):s.zr.pickByContrast(e.colors.border,e.colors.gray.l11,this.state.color)}render({viewportScale:e=s.C$1.XY.IDENTITY}){const{renderCtx:t,telem:r,backgroundTelem:i,fontString:o,requestRender:a}=this.internal,{location:l,box:u}=this.state;if(s.jt.areaIsZero(u))return;const c=s.jt.topLeft(u),h=s.jt.width(u),f=s.jt.height(u),p=t.lower2d.applyScale(e);let y=r.value();p.font=o;const v=this.fontHeight,b=y[0]=="-";b&&(y=y.slice(1));const{theme:T}=this.internal,E=p.textDimensions(y,zn),P=E.width+T.sizes.base,C=E.height;a==null&&t.erase(s.jt.construct(this.prevState.box)),this.maybeUpdateWidth(P);const L={...s.Q.ZERO};l.x==="left"?L.x=6+v*.75:l.x==="center"&&(L.x=h/2-P/2),l.y==="center"&&(L.y=f/2+C/2);const z=s.Q.translate(c,L);if(this.state.backgroundTelem.type!=dt.type){const _=i.value();if(!s.zr.isZero(_)){p.fillStyle=s.zr.hex(_);const G=this.state.useWidthForBackground?this.state.width??this.state.minWidth:s.jt.width(u);p.fillRect(...s.Q.couple(s.Q.translate(c,this.state.valueBackgroundShift)),G+this.state.valueBackgroundOverScan.x,f+this.state.valueBackgroundOverScan.y)}}const x=this.getTextColor();p.fillStyle=s.zr.hex(x),b&&p.fillText("-",...s.Q.couple(s.Q.translateX(z,-v*.6)),void 0,zn),p.fillText(y,...s.Q.couple(z),void 0,zn)}}const Ya={[Ue.TYPE]:Ue},Jh=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:Ya,Value:Ue},Symbol.toStringTag,{value:"Module"}));exports.AcquireChannelControl=nn;exports.AuthoritySource=rn;exports.Base=xe;exports.BaseProvider=Ne;exports.Bottom=na;exports.BoundQuerier=qt;exports.Button=sr;exports.Canvas=Ht;exports.Chip=er;exports.Client=Yi;exports.Controller=tr;exports.Diagram=bl;exports.Diagram$1=ye;exports.FLUX_STORE_CONFIG=Ih;exports.FLUX_STORE_KEY=_h;exports.Gauge=ut;exports.Indicator=nr;exports.Input=ir;exports.Legend=rr;exports.Light=ar;exports.Line=Ut;exports.LinePlot=Jn;exports.Log=lt;exports.MODES=ka;exports.MOUSE_DOWN_INCREMENT=_a;exports.MOUSE_UP_INCREMENT=za;exports.Measure=ot;exports.PROVIDER_TYPE=Ar;exports.Provider=Bt;exports.Provider$1=Jt;exports.REGISTRY=Ph;exports.REGISTRY$1=Fh;exports.REGISTRY$10=ua;exports.REGISTRY$11=Gu;exports.REGISTRY$12=pa;exports.REGISTRY$13=fl;exports.REGISTRY$14=Wh;exports.REGISTRY$15=Qh;exports.REGISTRY$16=Ii;exports.REGISTRY$17=Zh;exports.REGISTRY$18=Mi;exports.REGISTRY$19=$h;exports.REGISTRY$2=Uh;exports.REGISTRY$3=Oh;exports.REGISTRY$4=Ya;exports.REGISTRY$5=da;exports.REGISTRY$6=Gh;exports.REGISTRY$7=_i;exports.REGISTRY$8=Ri;exports.REGISTRY$9=Vh;exports.RELATIONSHIPS_FLUX_STORE_KEY=Cl;exports.RELATIONSHIP_FLUX_STORE_CONFIG=kl;exports.RESOURCES_FLUX_STORE_KEY=Rl;exports.RESOURCE_FLUX_STORE_CONFIG=zl;exports.Right=sa;exports.Rule=it;exports.ScopedUnaryStore=Ai;exports.SetChannelValue=tn;exports.Setpoint=or;exports.StateProvider=ct;exports.Table=Be;exports.Toggle=lr;exports.Tooltip=at;exports.Top=ra;exports.Value=Ue;exports.XAxis=en;exports.YAxis=Kt;exports.ZERO_CONTEXT_VALUE=Lr;exports.a=sn;exports.acquireChannelControl=Dh;exports.acquireChannelControlPropsZ=Ea;exports.aether=qu;exports.authoritySource=Nh;exports.authoritySourceDetailsZ=Yh;exports.authoritySourceProps=Ca;exports.axisStateZ=qr;exports.boundQuerierStateZ=ji;exports.buttonStateZ=Oa;exports.canvas=yl;exports.canvasStateZ=Mr;exports.channelData=Js;exports.chipStateZ=ba;exports.chipStatusDetailsZ=ya;exports.color=Oe;exports.colorGradient=gi;exports.control=pn;exports.controllerStateZ=xa;exports.coreAxisStateZ=bt;exports.createRegistry=El;exports.createStore=Di;exports.diagramStateZ=Ir;exports.external=tl;exports.indicatorStateZ=Pa;exports.indicatorStatusDetailsZ=Ra;exports.interpolate=an;exports.interpolateNumber=nt;exports.interpolateRgb=In;exports.interpolateString=Ds;exports.legendStateZ=La;exports.linePlotStateZ=ga;exports.logState=ma;exports.measure=wh;exports.measureStateZ=Wr;exports.newCanvas=ta;exports.newTickFactory=Xn;exports.parseAutoBounds=ca;exports.partialUpdate=vl;exports.provider=zo;exports.providerStateZ=Ni;exports.providerStateZ$1=ha;exports.providerStateZ$2=Or;exports.regions=pe;exports.request=ae;exports.rollingAverage=fi;exports.rollingAverageProps=Cr;exports.ruleStateZ=Fr;exports.scaleNumber=yi;exports.scopeStore=Fn;exports.setChannelValue=Ah;exports.setChannelValuePropsZ=wa;exports.setpoint=li;exports.sinkPipeline=Gs;exports.sinkPipelinePropsZ=Sr;exports.sourcePipeline=Vs;exports.sourcePipelinePropsZ=br;exports.stateProviderStateZ=va;exports.stateZ=zi;exports.stateZ$1=Ma;exports.stateZ$2=Ia;exports.stateZ$3=Aa;exports.statusZ=Ta;exports.streamChannelData=ei;exports.streamChannelValue=ti;exports.streamChannelValuePropsZ=Tr;exports.stringSourceSpecZ=un;exports.stringifyNumber=di;exports.stringifyNumberProps=Er;exports.sugaredStateZ=Sa;exports.tickFactoryProps=Hr;exports.tickType=Ur;exports.toggleStateZ=Da;exports.tooltip=nh;exports.tooltipStateZ=Qr;exports.useOptionalRequestor=zr;exports.useRequestor=gn;exports.value=Jh;exports.withinBounds=ci;exports.withinBoundsProps=wr;exports.withinSizeThreshold=aa;exports.xAxisStateZ=Xu;exports.yAxisStateZ=Fu;