@synnaxlabs/pluto 0.46.7 → 0.47.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 (399) hide show
  1. package/dist/Animated-BewuBtBY.cjs +1 -0
  2. package/dist/Animated-Ck-9v2gm.cjs +1 -0
  3. package/dist/Animated-M9ynNzcI.js +356 -0
  4. package/dist/Animated-otpyxn5i.js +28 -0
  5. package/dist/Box-BvqALodh.cjs +1 -0
  6. package/dist/Box-D5Qv__kr.js +95 -0
  7. package/dist/Button-BFoGC4WW.js +305 -0
  8. package/dist/Button-C3dvpk52.cjs +1 -0
  9. package/dist/Dialog-CO4iLhHf.js +58 -0
  10. package/dist/Dialog-DwhFD4z2.cjs +1 -0
  11. package/dist/Editable-BXFY3-UW.cjs +1 -0
  12. package/dist/Editable-CxgdRDPb.js +193 -0
  13. package/dist/Haul-2Xa_nMgc.cjs +1 -0
  14. package/dist/Haul-BuI0PZpo.js +128 -0
  15. package/dist/Items-DNcTFEUJ.cjs +4 -0
  16. package/dist/Items-G25zb57I.js +777 -0
  17. package/dist/Menu-D-uhqnfk.cjs +1 -0
  18. package/dist/Menu-DqkB9vpH.js +156 -0
  19. package/dist/Provider--RxgAoVG.js +434 -0
  20. package/dist/Provider-575hnWmi.cjs +5 -0
  21. package/dist/Tags-Dekr_hwk.cjs +1 -0
  22. package/dist/Tags-Dpu9kD_T.js +604 -0
  23. package/dist/Text-BzTkWLeU.js +1580 -0
  24. package/dist/Text-DECnk5vG.cjs +1 -0
  25. package/dist/{Video-CBAgqKPg.js → Video-CITi2j07.js} +1 -1
  26. package/dist/{Video-DqumxMbz.cjs → Video-VlT7jSYk.cjs} +1 -1
  27. package/dist/_commonjsHelpers-BH3jXuIh.cjs +1 -0
  28. package/dist/_commonjsHelpers-ByX85dGu.js +33 -0
  29. package/dist/button.cjs +1 -1
  30. package/dist/button.js +1 -1
  31. package/dist/color.cjs +1 -1
  32. package/dist/color.js +1 -1
  33. package/dist/{css-BYwooBtA.js → css-D6ZBcSwh.js} +800 -799
  34. package/dist/css-HnNQMUzV.cjs +8 -0
  35. package/dist/css.cjs +1 -1
  36. package/dist/css.js +2 -2
  37. package/dist/debounce-CW9Q-DsR.js +17 -0
  38. package/dist/debounce-heEWeOqL.cjs +1 -0
  39. package/dist/deep-DRVLw7iw.js +349 -0
  40. package/dist/deep-DtdcJG4q.cjs +1 -0
  41. package/dist/dialog.cjs +1 -1
  42. package/dist/dialog.js +1 -1
  43. package/dist/dimensions-BFCMI7yN.js +19 -0
  44. package/dist/dimensions-CGLhBwVq.cjs +1 -0
  45. package/dist/eraser-Dm5Du4PL.cjs +11 -0
  46. package/dist/eraser-DvzR9kLf.js +955 -0
  47. package/dist/eslint.config.d.ts +3 -0
  48. package/dist/eslint.config.d.ts.map +1 -0
  49. package/dist/ether.cjs +1 -1
  50. package/dist/ether.js +70 -67
  51. package/dist/external-B2Q-Yx8D.cjs +1 -0
  52. package/dist/external-B7hb5HYU.js +88 -0
  53. package/dist/external-B9a_p-VK.cjs +1 -0
  54. package/dist/external-BA6DRS2n.cjs +1 -0
  55. package/dist/external-BVcgi9yX.cjs +1 -0
  56. package/dist/external-BZwFEYop.js +44 -0
  57. package/dist/external-BhOvtmPt.js +24 -0
  58. package/dist/external-C5W7VXIW.cjs +1 -0
  59. package/dist/external-C5ssXUvL.cjs +46 -0
  60. package/dist/external-CGRGVYRj.js +31 -0
  61. package/dist/{external-CnSq_bSU.js → external-CMiEiLpE.js} +29 -19
  62. package/dist/external-C_dsD7px.cjs +1 -0
  63. package/dist/external-CeNR2kU9.js +46 -0
  64. package/dist/{main-CEC8k4uE.js → external-CraRr06G.js} +16962 -22990
  65. package/dist/external-D9LndfvY.js +29 -0
  66. package/dist/external-DEWhnbVF.cjs +1 -0
  67. package/dist/external-DUoHSX0Q.js +80 -0
  68. package/dist/external-DZSXelLG.js +130 -0
  69. package/dist/external-DrUtWpiV.js +388 -0
  70. package/dist/external-FIE7PzLB.cjs +1 -0
  71. package/dist/external-OLyg-4Ab.cjs +1 -0
  72. package/dist/external-_LWHQroW.cjs +1 -0
  73. package/dist/external-g62tixOz.cjs +85 -0
  74. package/dist/{external-CafWN471.js → external-x9Ylk2op.js} +108 -97
  75. package/dist/flex.cjs +1 -1
  76. package/dist/flex.js +1 -1
  77. package/dist/{fontString-CVUEOEMw.js → fontString-CGd4NYXa.js} +11 -10
  78. package/dist/fontString-yPlq8smc.cjs +1 -0
  79. package/dist/header.cjs +1 -1
  80. package/dist/header.js +1 -1
  81. package/dist/hooks-15yB7IKE.js +74 -0
  82. package/dist/hooks-D_-XdOAe.cjs +1 -0
  83. package/dist/index.cjs +16 -16
  84. package/dist/index.js +10251 -9623
  85. package/dist/input.cjs +1 -1
  86. package/dist/input.js +1 -1
  87. package/dist/list.cjs +1 -1
  88. package/dist/list.js +1 -1
  89. package/dist/menu.cjs +1 -1
  90. package/dist/menu.js +1 -1
  91. package/dist/pluto.css +1 -1
  92. package/dist/{provider-CKYgKu3z.js → provider-C8In649C.js} +4955 -8152
  93. package/dist/provider-lNhTlIWj.cjs +72 -0
  94. package/dist/src/aether/aether/aether.d.ts.map +1 -1
  95. package/dist/src/aether/main.d.ts.map +1 -1
  96. package/dist/src/arc/external.d.ts +1 -1
  97. package/dist/src/arc/external.d.ts.map +1 -1
  98. package/dist/src/arc/functions/Base.d.ts.map +1 -0
  99. package/dist/src/arc/functions/constant/Constant.d.ts.map +1 -0
  100. package/dist/src/arc/functions/constant/Form.d.ts.map +1 -0
  101. package/dist/src/arc/functions/constant/external.d.ts.map +1 -0
  102. package/dist/src/arc/functions/constant/index.d.ts.map +1 -0
  103. package/dist/src/arc/functions/external.d.ts.map +1 -0
  104. package/dist/src/arc/functions/index.d.ts.map +1 -0
  105. package/dist/src/arc/functions/operator/Operator.d.ts.map +1 -0
  106. package/dist/src/arc/functions/operator/external.d.ts.map +1 -0
  107. package/dist/src/arc/functions/operator/index.d.ts.map +1 -0
  108. package/dist/src/arc/functions/read/Form.d.ts.map +1 -0
  109. package/dist/src/arc/functions/read/Read.d.ts.map +1 -0
  110. package/dist/src/arc/functions/read/external.d.ts.map +1 -0
  111. package/dist/src/arc/functions/read/index.d.ts.map +1 -0
  112. package/dist/src/arc/functions/registry.d.ts.map +1 -0
  113. package/dist/src/arc/functions/select/Select.d.ts.map +1 -0
  114. package/dist/src/arc/functions/select/external.d.ts.map +1 -0
  115. package/dist/src/arc/functions/select/index.d.ts.map +1 -0
  116. package/dist/src/arc/functions/sink/Form.d.ts.map +1 -0
  117. package/dist/src/arc/functions/sink/Sink.d.ts.map +1 -0
  118. package/dist/src/arc/functions/sink/external.d.ts.map +1 -0
  119. package/dist/src/arc/functions/sink/index.d.ts.map +1 -0
  120. package/dist/src/arc/functions/source/Form.d.ts.map +1 -0
  121. package/dist/src/arc/functions/source/Source.d.ts.map +1 -0
  122. package/dist/src/arc/functions/source/external.d.ts.map +1 -0
  123. package/dist/src/arc/functions/source/index.d.ts.map +1 -0
  124. package/dist/src/arc/functions/stable/Form.d.ts.map +1 -0
  125. package/dist/src/arc/functions/stable/StableFor.d.ts.map +1 -0
  126. package/dist/src/arc/functions/stable/external.d.ts.map +1 -0
  127. package/dist/src/arc/functions/stable/index.d.ts.map +1 -0
  128. package/dist/src/arc/functions/status/Change.d.ts.map +1 -0
  129. package/dist/src/arc/functions/status/Form.d.ts.map +1 -0
  130. package/dist/src/arc/functions/status/external.d.ts.map +1 -0
  131. package/dist/src/arc/functions/status/index.d.ts.map +1 -0
  132. package/dist/src/arc/functions/types/index.d.ts.map +1 -0
  133. package/dist/src/arc/functions/types/spec.d.ts.map +1 -0
  134. package/dist/src/arc/handle/Core.d.ts.map +1 -1
  135. package/dist/src/arc/handle/Sink.d.ts.map +1 -1
  136. package/dist/src/arc/handle/Source.d.ts.map +1 -1
  137. package/dist/src/arc/handle/external.d.ts.map +1 -1
  138. package/dist/src/arc/handle/index.d.ts.map +1 -1
  139. package/dist/src/arc/queries.d.ts +6 -3
  140. package/dist/src/arc/queries.d.ts.map +1 -1
  141. package/dist/src/arc/queries.spec.d.ts +2 -0
  142. package/dist/src/arc/queries.spec.d.ts.map +1 -0
  143. package/dist/src/button/Button.d.ts +1 -1
  144. package/dist/src/button/Button.d.ts.map +1 -1
  145. package/dist/src/channel/AliasInput.d.ts +0 -1
  146. package/dist/src/channel/AliasInput.d.ts.map +1 -1
  147. package/dist/src/channel/CreateCalculatedIcon.d.ts +3 -0
  148. package/dist/src/channel/CreateCalculatedIcon.d.ts.map +1 -0
  149. package/dist/src/channel/LinePlot.d.ts +1 -3
  150. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  151. package/dist/src/channel/external.d.ts +1 -0
  152. package/dist/src/channel/external.d.ts.map +1 -1
  153. package/dist/src/channel/queries.d.ts +77 -5
  154. package/dist/src/channel/queries.d.ts.map +1 -1
  155. package/dist/src/component/SelectSize.d.ts.map +1 -1
  156. package/dist/src/css/css.d.ts +1 -2
  157. package/dist/src/css/css.d.ts.map +1 -1
  158. package/dist/src/flex/Box.d.ts +1 -2
  159. package/dist/src/flex/Box.d.ts.map +1 -1
  160. package/dist/src/flex/index.d.ts +1 -1
  161. package/dist/src/flex/index.d.ts.map +1 -1
  162. package/dist/src/flux/Provider.d.ts.map +1 -1
  163. package/dist/src/flux/aether/provider.d.ts +1 -1
  164. package/dist/src/flux/aether/provider.d.ts.map +1 -1
  165. package/dist/src/flux/core/client.d.ts.map +1 -1
  166. package/dist/src/flux/core/external.d.ts.map +1 -1
  167. package/dist/src/flux/core/index.d.ts.map +1 -1
  168. package/dist/src/flux/list.d.ts +5 -1
  169. package/dist/src/flux/list.d.ts.map +1 -1
  170. package/dist/src/group/index.d.ts.map +1 -1
  171. package/dist/src/hardware/device/Select.d.ts +0 -1
  172. package/dist/src/hardware/device/Select.d.ts.map +1 -1
  173. package/dist/src/hardware/device/queries.d.ts +6 -6
  174. package/dist/src/hardware/rack/Select.d.ts +0 -1
  175. package/dist/src/hardware/rack/Select.d.ts.map +1 -1
  176. package/dist/src/header/Header.d.ts.map +1 -1
  177. package/dist/src/icon/registry.d.ts.map +1 -1
  178. package/dist/src/index.d.ts +0 -1
  179. package/dist/src/index.d.ts.map +1 -1
  180. package/dist/src/input/Item.d.ts +2 -2
  181. package/dist/src/input/Item.d.ts.map +1 -1
  182. package/dist/src/log/aether/Log.d.ts.map +1 -1
  183. package/dist/src/menu/ContextMenu.d.ts +0 -3
  184. package/dist/src/menu/ContextMenu.d.ts.map +1 -1
  185. package/dist/src/menu/external.d.ts +1 -0
  186. package/dist/src/menu/external.d.ts.map +1 -1
  187. package/dist/src/menu/types.d.ts +4 -0
  188. package/dist/src/menu/types.d.ts.map +1 -0
  189. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  190. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  191. package/dist/src/schematic/symbol/Forms.d.ts +1 -0
  192. package/dist/src/schematic/symbol/Forms.d.ts.map +1 -1
  193. package/dist/src/schematic/symbol/Primitives.d.ts +11 -2
  194. package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
  195. package/dist/src/schematic/symbol/Symbols.d.ts +7 -0
  196. package/dist/src/schematic/symbol/Symbols.d.ts.map +1 -1
  197. package/dist/src/schematic/symbol/registry.d.ts +2 -1
  198. package/dist/src/schematic/symbol/registry.d.ts.map +1 -1
  199. package/dist/src/select/Button.d.ts +0 -1
  200. package/dist/src/select/Button.d.ts.map +1 -1
  201. package/dist/src/select/Multiple.d.ts +5 -6
  202. package/dist/src/select/Multiple.d.ts.map +1 -1
  203. package/dist/src/select/MultipleTrigger.d.ts +0 -1
  204. package/dist/src/select/MultipleTrigger.d.ts.map +1 -1
  205. package/dist/src/select/SearchInput.d.ts.map +1 -1
  206. package/dist/src/select/Single.d.ts +1 -2
  207. package/dist/src/select/Single.d.ts.map +1 -1
  208. package/dist/src/select/Static.d.ts +0 -1
  209. package/dist/src/select/Static.d.ts.map +1 -1
  210. package/dist/src/select/external.d.ts +1 -0
  211. package/dist/src/select/external.d.ts.map +1 -1
  212. package/dist/src/select/flex/Alignment.d.ts +7 -0
  213. package/dist/src/select/flex/Alignment.d.ts.map +1 -0
  214. package/dist/src/select/flex/index.d.ts +2 -0
  215. package/dist/src/select/flex/index.d.ts.map +1 -0
  216. package/dist/src/select/text/Level.d.ts.map +1 -1
  217. package/dist/src/select/text/Weight.d.ts.map +1 -1
  218. package/dist/src/status/aether/errorHandler.d.ts.map +1 -1
  219. package/dist/src/status/aether/external.d.ts.map +1 -1
  220. package/dist/src/status/core/external.d.ts +0 -1
  221. package/dist/src/status/core/external.d.ts.map +1 -1
  222. package/dist/src/status/core/index.d.ts.map +1 -1
  223. package/dist/src/status/external.d.ts +1 -0
  224. package/dist/src/status/external.d.ts.map +1 -1
  225. package/dist/src/status/index.d.ts.map +1 -1
  226. package/dist/src/status/queries.d.ts +5 -1
  227. package/dist/src/status/queries.d.ts.map +1 -1
  228. package/dist/src/synnax/Provider.d.ts.map +1 -1
  229. package/dist/src/tabs/Selector.d.ts.map +1 -1
  230. package/dist/src/telem/SelectDataType.d.ts.map +1 -1
  231. package/dist/src/telem/aether/context.d.ts +1 -2
  232. package/dist/src/telem/aether/context.d.ts.map +1 -1
  233. package/dist/src/telem/aether/noop.d.ts +2 -1
  234. package/dist/src/telem/aether/noop.d.ts.map +1 -1
  235. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  236. package/dist/src/telem/aether/telem.d.ts +9 -0
  237. package/dist/src/telem/aether/telem.d.ts.map +1 -1
  238. package/dist/src/telem/client/reader.d.ts +1 -1
  239. package/dist/src/telem/client/reader.d.ts.map +1 -1
  240. package/dist/src/telem/control/Controller.d.ts.map +1 -1
  241. package/dist/src/telem/control/aether/controller.d.ts +0 -1
  242. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  243. package/dist/src/telem/control/aether/state.d.ts.map +1 -1
  244. package/dist/src/theming/Provider.d.ts +0 -2
  245. package/dist/src/theming/Provider.d.ts.map +1 -1
  246. package/dist/src/tooltip/Config.d.ts.map +1 -1
  247. package/dist/src/tree/Context.d.ts.map +1 -1
  248. package/dist/src/vis/input/aether/index.d.ts +2 -0
  249. package/dist/src/vis/input/aether/index.d.ts.map +1 -0
  250. package/dist/src/vis/input/aether/input.d.ts +40 -0
  251. package/dist/src/vis/input/aether/input.d.ts.map +1 -0
  252. package/dist/src/vis/input/index.d.ts +2 -0
  253. package/dist/src/vis/input/index.d.ts.map +1 -0
  254. package/dist/src/vis/input/use.d.ts +9 -0
  255. package/dist/src/vis/input/use.d.ts.map +1 -0
  256. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  257. package/dist/src/vis/value/aether/value.d.ts +1 -2
  258. package/dist/src/vis/value/aether/value.d.ts.map +1 -1
  259. package/dist/tabs.cjs +1 -1
  260. package/dist/tabs.js +1 -1
  261. package/dist/text.cjs +1 -1
  262. package/dist/text.js +2 -2
  263. package/dist/theme.css +11 -0
  264. package/dist/theming.cjs +1 -1
  265. package/dist/theming.js +2 -2
  266. package/dist/tree.cjs +1 -1
  267. package/dist/tree.js +1 -1
  268. package/dist/triggers.cjs +1 -1
  269. package/dist/triggers.js +1 -1
  270. package/dist/types-BNX_Jj6k.js +80 -0
  271. package/dist/types-D-yz1qsT.cjs +1 -0
  272. package/dist/{units-CeCcz4O4.js → units-BqIfn6VX.js} +1 -1
  273. package/dist/units-DCifOxd9.cjs +1 -0
  274. package/dist/useStaticData-BTwIe0Il.cjs +1 -0
  275. package/dist/useStaticData-p8sk2VCJ.js +1051 -0
  276. package/dist/value-B3LTg1lE.cjs +53 -0
  277. package/dist/value-ChGMEPP3.js +6508 -0
  278. package/dist/video.cjs +1 -1
  279. package/dist/video.js +1 -1
  280. package/package.json +8 -8
  281. package/dist/Toggle-BSJnQkJM.js +0 -26
  282. package/dist/Toggle-C0DIo816.cjs +0 -1
  283. package/dist/css-B0VZnJIa.cjs +0 -8
  284. package/dist/external-B0_MIms2.js +0 -78
  285. package/dist/external-B1ETpyFM.js +0 -89
  286. package/dist/external-B3WxrVX0.js +0 -30
  287. package/dist/external-BP7GC2X2.cjs +0 -1
  288. package/dist/external-Bf8170BC.js +0 -380
  289. package/dist/external-BgNRw5Al.js +0 -23
  290. package/dist/external-BgSmm_d3.js +0 -84
  291. package/dist/external-BmxkwvZQ.cjs +0 -1
  292. package/dist/external-BoVr9B-m.cjs +0 -1
  293. package/dist/external-BrDpLk_U.js +0 -42
  294. package/dist/external-CAiETio2.js +0 -10
  295. package/dist/external-CQpqJGka.cjs +0 -1
  296. package/dist/external-CmmZWsrB.cjs +0 -1
  297. package/dist/external-Cutp76YR.cjs +0 -1
  298. package/dist/external-Cux9mC64.js +0 -69
  299. package/dist/external-D8EUzT1C.cjs +0 -1
  300. package/dist/external-DEYDSJ_G.cjs +0 -1
  301. package/dist/external-DElBi-Q-.js +0 -87
  302. package/dist/external-DP8Ao5TN.cjs +0 -1
  303. package/dist/external-DS6CmLLZ.cjs +0 -46
  304. package/dist/external-DoerTjzk.js +0 -14
  305. package/dist/external-FJ3vTUtb.cjs +0 -1
  306. package/dist/external-V3s19XkB.cjs +0 -1
  307. package/dist/external-Zuxgy86I.cjs +0 -1
  308. package/dist/fontString-DBgTdlAe.cjs +0 -1
  309. package/dist/main-Bg0vBNCG.cjs +0 -92
  310. package/dist/provider-CSa0L57i.js +0 -4673
  311. package/dist/provider-CWezGpoq.cjs +0 -52
  312. package/dist/provider-Fw6FIHoE.cjs +0 -83
  313. package/dist/src/arc/stage/Base.d.ts.map +0 -1
  314. package/dist/src/arc/stage/constant/Constant.d.ts.map +0 -1
  315. package/dist/src/arc/stage/constant/Form.d.ts.map +0 -1
  316. package/dist/src/arc/stage/constant/external.d.ts.map +0 -1
  317. package/dist/src/arc/stage/constant/index.d.ts.map +0 -1
  318. package/dist/src/arc/stage/external.d.ts.map +0 -1
  319. package/dist/src/arc/stage/index.d.ts.map +0 -1
  320. package/dist/src/arc/stage/operator/Operator.d.ts.map +0 -1
  321. package/dist/src/arc/stage/operator/external.d.ts.map +0 -1
  322. package/dist/src/arc/stage/operator/index.d.ts.map +0 -1
  323. package/dist/src/arc/stage/read/Form.d.ts.map +0 -1
  324. package/dist/src/arc/stage/read/Read.d.ts.map +0 -1
  325. package/dist/src/arc/stage/read/external.d.ts.map +0 -1
  326. package/dist/src/arc/stage/read/index.d.ts.map +0 -1
  327. package/dist/src/arc/stage/registry.d.ts.map +0 -1
  328. package/dist/src/arc/stage/select/Select.d.ts.map +0 -1
  329. package/dist/src/arc/stage/select/external.d.ts.map +0 -1
  330. package/dist/src/arc/stage/select/index.d.ts.map +0 -1
  331. package/dist/src/arc/stage/sink/Form.d.ts.map +0 -1
  332. package/dist/src/arc/stage/sink/Sink.d.ts.map +0 -1
  333. package/dist/src/arc/stage/sink/external.d.ts.map +0 -1
  334. package/dist/src/arc/stage/sink/index.d.ts.map +0 -1
  335. package/dist/src/arc/stage/source/Form.d.ts.map +0 -1
  336. package/dist/src/arc/stage/source/Source.d.ts.map +0 -1
  337. package/dist/src/arc/stage/source/external.d.ts.map +0 -1
  338. package/dist/src/arc/stage/source/index.d.ts.map +0 -1
  339. package/dist/src/arc/stage/stable/Form.d.ts.map +0 -1
  340. package/dist/src/arc/stage/stable/StableFor.d.ts.map +0 -1
  341. package/dist/src/arc/stage/stable/external.d.ts.map +0 -1
  342. package/dist/src/arc/stage/stable/index.d.ts.map +0 -1
  343. package/dist/src/arc/stage/status/Change.d.ts.map +0 -1
  344. package/dist/src/arc/stage/status/Form.d.ts.map +0 -1
  345. package/dist/src/arc/stage/status/external.d.ts.map +0 -1
  346. package/dist/src/arc/stage/status/index.d.ts.map +0 -1
  347. package/dist/src/arc/stage/types/index.d.ts.map +0 -1
  348. package/dist/src/arc/stage/types/spec.d.ts.map +0 -1
  349. package/dist/src/flex/Select.d.ts +0 -7
  350. package/dist/src/flex/Select.d.ts.map +0 -1
  351. package/dist/src/flex/external.d.ts +0 -3
  352. package/dist/src/flex/external.d.ts.map +0 -1
  353. package/dist/src/override/factory.d.ts +0 -3
  354. package/dist/src/override/factory.d.ts.map +0 -1
  355. package/dist/src/override/index.d.ts +0 -2
  356. package/dist/src/override/index.d.ts.map +0 -1
  357. package/dist/src/status/CreateIcon.d.ts +0 -1
  358. package/dist/src/status/CreateIcon.d.ts.map +0 -1
  359. package/dist/src/status/core/SelectVariant.d.ts +0 -7
  360. package/dist/src/status/core/SelectVariant.d.ts.map +0 -1
  361. package/dist/units-gFJ6UvpU.cjs +0 -1
  362. package/dist/useKeysData-DXXVQfXZ.js +0 -18
  363. package/dist/useKeysData-Do63LaI0.cjs +0 -1
  364. /package/dist/src/arc/{stage → functions}/Base.d.ts +0 -0
  365. /package/dist/src/arc/{stage → functions}/constant/Constant.d.ts +0 -0
  366. /package/dist/src/arc/{stage → functions}/constant/Form.d.ts +0 -0
  367. /package/dist/src/arc/{stage → functions}/constant/external.d.ts +0 -0
  368. /package/dist/src/arc/{stage → functions}/constant/index.d.ts +0 -0
  369. /package/dist/src/arc/{stage → functions}/external.d.ts +0 -0
  370. /package/dist/src/arc/{stage → functions}/index.d.ts +0 -0
  371. /package/dist/src/arc/{stage → functions}/operator/Operator.d.ts +0 -0
  372. /package/dist/src/arc/{stage → functions}/operator/external.d.ts +0 -0
  373. /package/dist/src/arc/{stage → functions}/operator/index.d.ts +0 -0
  374. /package/dist/src/arc/{stage → functions}/read/Form.d.ts +0 -0
  375. /package/dist/src/arc/{stage → functions}/read/Read.d.ts +0 -0
  376. /package/dist/src/arc/{stage → functions}/read/external.d.ts +0 -0
  377. /package/dist/src/arc/{stage → functions}/read/index.d.ts +0 -0
  378. /package/dist/src/arc/{stage → functions}/registry.d.ts +0 -0
  379. /package/dist/src/arc/{stage → functions}/select/Select.d.ts +0 -0
  380. /package/dist/src/arc/{stage → functions}/select/external.d.ts +0 -0
  381. /package/dist/src/arc/{stage → functions}/select/index.d.ts +0 -0
  382. /package/dist/src/arc/{stage → functions}/sink/Form.d.ts +0 -0
  383. /package/dist/src/arc/{stage → functions}/sink/Sink.d.ts +0 -0
  384. /package/dist/src/arc/{stage → functions}/sink/external.d.ts +0 -0
  385. /package/dist/src/arc/{stage → functions}/sink/index.d.ts +0 -0
  386. /package/dist/src/arc/{stage → functions}/source/Form.d.ts +0 -0
  387. /package/dist/src/arc/{stage → functions}/source/Source.d.ts +0 -0
  388. /package/dist/src/arc/{stage → functions}/source/external.d.ts +0 -0
  389. /package/dist/src/arc/{stage → functions}/source/index.d.ts +0 -0
  390. /package/dist/src/arc/{stage → functions}/stable/Form.d.ts +0 -0
  391. /package/dist/src/arc/{stage → functions}/stable/StableFor.d.ts +0 -0
  392. /package/dist/src/arc/{stage → functions}/stable/external.d.ts +0 -0
  393. /package/dist/src/arc/{stage → functions}/stable/index.d.ts +0 -0
  394. /package/dist/src/arc/{stage → functions}/status/Change.d.ts +0 -0
  395. /package/dist/src/arc/{stage → functions}/status/Form.d.ts +0 -0
  396. /package/dist/src/arc/{stage → functions}/status/external.d.ts +0 -0
  397. /package/dist/src/arc/{stage → functions}/status/index.d.ts +0 -0
  398. /package/dist/src/arc/{stage → functions}/types/index.d.ts +0 -0
  399. /package/dist/src/arc/{stage → functions}/types/spec.d.ts +0 -0
@@ -1,4673 +0,0 @@
1
- import { B as on, D as kr, E as Ms, F as Ps, H as Ls, I as As, J as Os, K as Ns, M as _s, N as Is, Q as Ys, T as Us, U as Zs, V as Bs, W as Fs, X as $s, Y as qs, Z as Hs, m as js, $ as zs, a0 as Ws, a1 as Xs, a2 as qt, a3 as Vs, a4 as Gs, a5 as Ks, a6 as Qs, a7 as Js, a8 as ei, a9 as ti, aa as ni, ab as ri, ac as si, ad as ii, ae as Et, af as ai, ag as ln, ah as oi, ai as li, aj as ci, ak as ui, al as hi, am as di, an as Rt, ao as fi, ap as gi, aq as pi, ar as mi, as as Dr, at as yi, au as bi, av as xi, aw as Si, ax as vi, ay as Ti, az as wi, aA as Ci, aB as Ei, aC as Ri, aD as ki, aE as kt, aF as cn, aG as Ge, aH as Mr, aI as Pr, aJ as Lr, aK as un, aL as hn, aM as Ar, aN as Or, aO as Di, aP as Mi, aQ as Pi, aR as Li, aS as Ai, aT as Oi, aU as ct, aV as Ni, aW as _i, aX as Ii, aY as Yi, aZ as Ui, a_ as Zi, a$ as Bi, b0 as Fi, b1 as $i, b2 as qi, b3 as Hi, b4 as dn, b5 as ji, b6 as zi, b7 as Wi, b8 as fn, b9 as Xi, ba as Vi, bb as Nr, bc as Gi, bd as Ke, be as H, bf as Ki, bg as Qi, bh as Z, bi as _r, bj as Dt, bk as Mt, G as Ji, bl as fe, h as j, bm as he, bn as ea, bo as An, bp as ta, bq as na, u as re, br as ra, d as On, bs as $e, bt as Pt, l as gn, bu as V, bv as pn, bw as mn, bx as sa, by as Ir, bz as yn, bA as ia, bB as aa, c as Nt, bC as oa, bD as la } from "./provider-CKYgKu3z.js";
2
- import pe, { z as p } from "zod";
3
- import { R as y, e as C, d as A, Q as d, g as Qe, A as Yr, l as Ur, S as ca, j as g, f as ua, b as G, a as Zr, c as Br, G as ha, r as $, m as qe, K, _ as Nn, p as te, O as da, Z as Lt, X as Fr, k as _n, F as $r } from "./css-BYwooBtA.js";
4
- import { f as Fe } from "./fontString-CVUEOEMw.js";
5
- import "react";
6
- const bn = "pluto-vis-renderer", xn = (t, e) => {
7
- t.set(bn, e, !1);
8
- }, Sn = (t) => t.get(bn), qr = (t) => t.getOptional(bn), de = (t, e) => Sn(t)(e), Pu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9
- __proto__: null,
10
- AbstractSink: on,
11
- AbstractSource: kr,
12
- Base: Ms,
13
- BaseProvider: Ps,
14
- BooleanStatus: Ls,
15
- CONTEXT_KEY: As,
16
- ChannelData: Os,
17
- ColorGradient: Ns,
18
- CompoundTelemFactory: _s,
19
- Context: Is,
20
- FixedColorSource: Ys,
21
- FixedNumber: Us,
22
- FixedString: Zs,
23
- IterativeSeries: Bs,
24
- Mean: Fs,
25
- MultiSourceTransformer: $s,
26
- NoopFactory: qs,
27
- PipelineFactory: Hs,
28
- REGISTRY: js,
29
- RemoteFactory: zs,
30
- RollingAverage: Ws,
31
- ScaleNumber: Xs,
32
- SeriesDownsampler: qt,
33
- SetPoint: Vs,
34
- SinkPipeline: Gs,
35
- SourcePipeline: Ks,
36
- StaticFactory: Qs,
37
- StreamChannelData: Js,
38
- StreamChannelValue: ei,
39
- StringifyNumber: ti,
40
- TransformerFactory: ni,
41
- UnarySinkTransformer: ri,
42
- UnarySourceTransformer: si,
43
- WithinBounds: ii,
44
- booleanSinkSpecZ: Et,
45
- booleanSinkTransformerSpecZ: ai,
46
- booleanSourceSpecZ: ln,
47
- booleanSourceTransformerSpecZ: oi,
48
- booleanStatus: li,
49
- booleanStatusProps: ci,
50
- channelData: ui,
51
- colorGradient: hi,
52
- colorGradientProps: di,
53
- colorSourceSpecZ: Rt,
54
- connectionZ: fi,
55
- createFactory: gi,
56
- downsampleMode: pi,
57
- downsampleModeProps: mi,
58
- downsampleModeZ: Dr,
59
- fixedArray: yi,
60
- fixedColor: bi,
61
- fixedColorSourcePropsZ: xi,
62
- fixedNumber: Si,
63
- fixedNumberPropsZ: vi,
64
- fixedSeriesPropsZ: Ti,
65
- fixedString: wi,
66
- fixedStringPropsZ: Ci,
67
- iterativeArray: Ei,
68
- iterativeSeriesPropsZ: Ri,
69
- mean: ki,
70
- noopBooleanSinkSpec: kt,
71
- noopBooleanSourceSpec: cn,
72
- noopColorSourceSpec: Ge,
73
- noopNumericSinkSpec: Mr,
74
- noopNumericSourceSpec: Pr,
75
- noopSeriesSourceSpec: Lr,
76
- noopStatusSourceSpec: un,
77
- noopStringSourceSpec: hn,
78
- numberSinkSpecZ: Ar,
79
- numberSourceSpecZ: Or,
80
- providerStateZ: Di,
81
- rollingAverage: Mi,
82
- rollingAverageProps: Pi,
83
- scaleNumber: Li,
84
- scaleNumberProps: Ai,
85
- seriesDownsampler: Oi,
86
- seriesSourceSpecZ: ct,
87
- setContext: Ni,
88
- setpoint: _i,
89
- sinkPipeline: Ii,
90
- sinkPipelinePropsZ: Yi,
91
- sinkSpecZ: Ui,
92
- sinkTransformerSpecZ: Zi,
93
- sourcePipeline: Bi,
94
- sourcePipelinePropsZ: Fi,
95
- sourceSpecZ: $i,
96
- sourceTransformerSpecZ: qi,
97
- specZ: Hi,
98
- statusSourceSpecZ: dn,
99
- streamChannelData: ji,
100
- streamChannelValue: zi,
101
- streamChannelValuePropsZ: Wi,
102
- stringSourceSpecZ: fn,
103
- stringifyNumber: Xi,
104
- stringifyNumberProps: Vi,
105
- useChildContext: Nr,
106
- useContext: Gi,
107
- useSink: Ke,
108
- useSource: H,
109
- withinBounds: Ki,
110
- withinBoundsProps: Qi
111
- }, Symbol.toStringTag, { value: "Module" }));
112
- function vn(t, e, n) {
113
- t.prototype = e.prototype = n, n.constructor = t;
114
- }
115
- function Hr(t, e) {
116
- var n = Object.create(t.prototype);
117
- for (var r in e) n[r] = e[r];
118
- return n;
119
- }
120
- function Je() {
121
- }
122
- var He = 0.7, ut = 1 / He, Me = "\\s*([+-]?\\d+)\\s*", je = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", ne = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", fa = /^#([0-9a-f]{3,8})$/, ga = new RegExp(`^rgb\\(${Me},${Me},${Me}\\)$`), pa = new RegExp(`^rgb\\(${ne},${ne},${ne}\\)$`), ma = new RegExp(`^rgba\\(${Me},${Me},${Me},${je}\\)$`), ya = new RegExp(`^rgba\\(${ne},${ne},${ne},${je}\\)$`), ba = new RegExp(`^hsl\\(${je},${ne},${ne}\\)$`), xa = new RegExp(`^hsla\\(${je},${ne},${ne},${je}\\)$`), In = {
123
- aliceblue: 15792383,
124
- antiquewhite: 16444375,
125
- aqua: 65535,
126
- aquamarine: 8388564,
127
- azure: 15794175,
128
- beige: 16119260,
129
- bisque: 16770244,
130
- black: 0,
131
- blanchedalmond: 16772045,
132
- blue: 255,
133
- blueviolet: 9055202,
134
- brown: 10824234,
135
- burlywood: 14596231,
136
- cadetblue: 6266528,
137
- chartreuse: 8388352,
138
- chocolate: 13789470,
139
- coral: 16744272,
140
- cornflowerblue: 6591981,
141
- cornsilk: 16775388,
142
- crimson: 14423100,
143
- cyan: 65535,
144
- darkblue: 139,
145
- darkcyan: 35723,
146
- darkgoldenrod: 12092939,
147
- darkgray: 11119017,
148
- darkgreen: 25600,
149
- darkgrey: 11119017,
150
- darkkhaki: 12433259,
151
- darkmagenta: 9109643,
152
- darkolivegreen: 5597999,
153
- darkorange: 16747520,
154
- darkorchid: 10040012,
155
- darkred: 9109504,
156
- darksalmon: 15308410,
157
- darkseagreen: 9419919,
158
- darkslateblue: 4734347,
159
- darkslategray: 3100495,
160
- darkslategrey: 3100495,
161
- darkturquoise: 52945,
162
- darkviolet: 9699539,
163
- deeppink: 16716947,
164
- deepskyblue: 49151,
165
- dimgray: 6908265,
166
- dimgrey: 6908265,
167
- dodgerblue: 2003199,
168
- firebrick: 11674146,
169
- floralwhite: 16775920,
170
- forestgreen: 2263842,
171
- fuchsia: 16711935,
172
- gainsboro: 14474460,
173
- ghostwhite: 16316671,
174
- gold: 16766720,
175
- goldenrod: 14329120,
176
- gray: 8421504,
177
- green: 32768,
178
- greenyellow: 11403055,
179
- grey: 8421504,
180
- honeydew: 15794160,
181
- hotpink: 16738740,
182
- indianred: 13458524,
183
- indigo: 4915330,
184
- ivory: 16777200,
185
- khaki: 15787660,
186
- lavender: 15132410,
187
- lavenderblush: 16773365,
188
- lawngreen: 8190976,
189
- lemonchiffon: 16775885,
190
- lightblue: 11393254,
191
- lightcoral: 15761536,
192
- lightcyan: 14745599,
193
- lightgoldenrodyellow: 16448210,
194
- lightgray: 13882323,
195
- lightgreen: 9498256,
196
- lightgrey: 13882323,
197
- lightpink: 16758465,
198
- lightsalmon: 16752762,
199
- lightseagreen: 2142890,
200
- lightskyblue: 8900346,
201
- lightslategray: 7833753,
202
- lightslategrey: 7833753,
203
- lightsteelblue: 11584734,
204
- lightyellow: 16777184,
205
- lime: 65280,
206
- limegreen: 3329330,
207
- linen: 16445670,
208
- magenta: 16711935,
209
- maroon: 8388608,
210
- mediumaquamarine: 6737322,
211
- mediumblue: 205,
212
- mediumorchid: 12211667,
213
- mediumpurple: 9662683,
214
- mediumseagreen: 3978097,
215
- mediumslateblue: 8087790,
216
- mediumspringgreen: 64154,
217
- mediumturquoise: 4772300,
218
- mediumvioletred: 13047173,
219
- midnightblue: 1644912,
220
- mintcream: 16121850,
221
- mistyrose: 16770273,
222
- moccasin: 16770229,
223
- navajowhite: 16768685,
224
- navy: 128,
225
- oldlace: 16643558,
226
- olive: 8421376,
227
- olivedrab: 7048739,
228
- orange: 16753920,
229
- orangered: 16729344,
230
- orchid: 14315734,
231
- palegoldenrod: 15657130,
232
- palegreen: 10025880,
233
- paleturquoise: 11529966,
234
- palevioletred: 14381203,
235
- papayawhip: 16773077,
236
- peachpuff: 16767673,
237
- peru: 13468991,
238
- pink: 16761035,
239
- plum: 14524637,
240
- powderblue: 11591910,
241
- purple: 8388736,
242
- rebeccapurple: 6697881,
243
- red: 16711680,
244
- rosybrown: 12357519,
245
- royalblue: 4286945,
246
- saddlebrown: 9127187,
247
- salmon: 16416882,
248
- sandybrown: 16032864,
249
- seagreen: 3050327,
250
- seashell: 16774638,
251
- sienna: 10506797,
252
- silver: 12632256,
253
- skyblue: 8900331,
254
- slateblue: 6970061,
255
- slategray: 7372944,
256
- slategrey: 7372944,
257
- snow: 16775930,
258
- springgreen: 65407,
259
- steelblue: 4620980,
260
- tan: 13808780,
261
- teal: 32896,
262
- thistle: 14204888,
263
- tomato: 16737095,
264
- turquoise: 4251856,
265
- violet: 15631086,
266
- wheat: 16113331,
267
- white: 16777215,
268
- whitesmoke: 16119285,
269
- yellow: 16776960,
270
- yellowgreen: 10145074
271
- };
272
- vn(Je, ze, {
273
- copy(t) {
274
- return Object.assign(new this.constructor(), this, t);
275
- },
276
- displayable() {
277
- return this.rgb().displayable();
278
- },
279
- hex: Yn,
280
- // Deprecated! Use color.formatHex.
281
- formatHex: Yn,
282
- formatHex8: Sa,
283
- formatHsl: va,
284
- formatRgb: Un,
285
- toString: Un
286
- });
287
- function Yn() {
288
- return this.rgb().formatHex();
289
- }
290
- function Sa() {
291
- return this.rgb().formatHex8();
292
- }
293
- function va() {
294
- return jr(this).formatHsl();
295
- }
296
- function Un() {
297
- return this.rgb().formatRgb();
298
- }
299
- function ze(t) {
300
- var e, n;
301
- return t = (t + "").trim().toLowerCase(), (e = fa.exec(t)) ? (n = e[1].length, e = parseInt(e[1], 16), n === 6 ? Zn(e) : n === 3 ? new q(e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, (e & 15) << 4 | e & 15, 1) : n === 8 ? st(e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, (e & 255) / 255) : n === 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 = ga.exec(t)) ? new q(e[1], e[2], e[3], 1) : (e = pa.exec(t)) ? new q(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, 1) : (e = ma.exec(t)) ? st(e[1], e[2], e[3], e[4]) : (e = ya.exec(t)) ? st(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, e[4]) : (e = ba.exec(t)) ? $n(e[1], e[2] / 100, e[3] / 100, 1) : (e = xa.exec(t)) ? $n(e[1], e[2] / 100, e[3] / 100, e[4]) : In.hasOwnProperty(t) ? Zn(In[t]) : t === "transparent" ? new q(NaN, NaN, NaN, 0) : null;
302
- }
303
- function Zn(t) {
304
- return new q(t >> 16 & 255, t >> 8 & 255, t & 255, 1);
305
- }
306
- function st(t, e, n, r) {
307
- return r <= 0 && (t = e = n = NaN), new q(t, e, n, r);
308
- }
309
- function Ta(t) {
310
- return t instanceof Je || (t = ze(t)), t ? (t = t.rgb(), new q(t.r, t.g, t.b, t.opacity)) : new q();
311
- }
312
- function Ht(t, e, n, r) {
313
- return arguments.length === 1 ? Ta(t) : new q(t, e, n, r ?? 1);
314
- }
315
- function q(t, e, n, r) {
316
- this.r = +t, this.g = +e, this.b = +n, this.opacity = +r;
317
- }
318
- vn(q, Ht, Hr(Je, {
319
- brighter(t) {
320
- return t = t == null ? ut : Math.pow(ut, t), new q(this.r * t, this.g * t, this.b * t, this.opacity);
321
- },
322
- darker(t) {
323
- return t = t == null ? He : Math.pow(He, t), new q(this.r * t, this.g * t, this.b * t, this.opacity);
324
- },
325
- rgb() {
326
- return this;
327
- },
328
- clamp() {
329
- return new q(ye(this.r), ye(this.g), ye(this.b), ht(this.opacity));
330
- },
331
- displayable() {
332
- return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
333
- },
334
- hex: Bn,
335
- // Deprecated! Use color.formatHex.
336
- formatHex: Bn,
337
- formatHex8: wa,
338
- formatRgb: Fn,
339
- toString: Fn
340
- }));
341
- function Bn() {
342
- return `#${me(this.r)}${me(this.g)}${me(this.b)}`;
343
- }
344
- function wa() {
345
- return `#${me(this.r)}${me(this.g)}${me(this.b)}${me((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
346
- }
347
- function Fn() {
348
- const t = ht(this.opacity);
349
- return `${t === 1 ? "rgb(" : "rgba("}${ye(this.r)}, ${ye(this.g)}, ${ye(this.b)}${t === 1 ? ")" : `, ${t})`}`;
350
- }
351
- function ht(t) {
352
- return isNaN(t) ? 1 : Math.max(0, Math.min(1, t));
353
- }
354
- function ye(t) {
355
- return Math.max(0, Math.min(255, Math.round(t) || 0));
356
- }
357
- function me(t) {
358
- return t = ye(t), (t < 16 ? "0" : "") + t.toString(16);
359
- }
360
- function $n(t, e, n, r) {
361
- return r <= 0 ? t = e = n = NaN : n <= 0 || n >= 1 ? t = e = NaN : e <= 0 && (t = NaN), new ee(t, e, n, r);
362
- }
363
- function jr(t) {
364
- if (t instanceof ee) return new ee(t.h, t.s, t.l, t.opacity);
365
- if (t instanceof Je || (t = ze(t)), !t) return new ee();
366
- if (t instanceof ee) return t;
367
- t = t.rgb();
368
- var e = t.r / 255, n = t.g / 255, r = t.b / 255, s = Math.min(e, n, r), a = Math.max(e, n, r), i = NaN, o = a - s, c = (a + s) / 2;
369
- return o ? (e === a ? i = (n - r) / o + (n < r) * 6 : n === a ? i = (r - e) / o + 2 : i = (e - n) / o + 4, o /= c < 0.5 ? a + s : 2 - a - s, i *= 60) : o = c > 0 && c < 1 ? 0 : i, new ee(i, o, c, t.opacity);
370
- }
371
- function Ca(t, e, n, r) {
372
- return arguments.length === 1 ? jr(t) : new ee(t, e, n, r ?? 1);
373
- }
374
- function ee(t, e, n, r) {
375
- this.h = +t, this.s = +e, this.l = +n, this.opacity = +r;
376
- }
377
- vn(ee, Ca, Hr(Je, {
378
- brighter(t) {
379
- return t = t == null ? ut : Math.pow(ut, t), new ee(this.h, this.s, this.l * t, this.opacity);
380
- },
381
- darker(t) {
382
- return t = t == null ? He : Math.pow(He, t), new ee(this.h, this.s, this.l * t, this.opacity);
383
- },
384
- rgb() {
385
- var t = this.h % 360 + (this.h < 0) * 360, e = isNaN(t) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < 0.5 ? n : 1 - n) * e, s = 2 * n - r;
386
- return new q(
387
- _t(t >= 240 ? t - 240 : t + 120, s, r),
388
- _t(t, s, r),
389
- _t(t < 120 ? t + 240 : t - 120, s, r),
390
- this.opacity
391
- );
392
- },
393
- clamp() {
394
- return new ee(qn(this.h), it(this.s), it(this.l), ht(this.opacity));
395
- },
396
- displayable() {
397
- return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
398
- },
399
- formatHsl() {
400
- const t = ht(this.opacity);
401
- return `${t === 1 ? "hsl(" : "hsla("}${qn(this.h)}, ${it(this.s) * 100}%, ${it(this.l) * 100}%${t === 1 ? ")" : `, ${t})`}`;
402
- }
403
- }));
404
- function qn(t) {
405
- return t = (t || 0) % 360, t < 0 ? t + 360 : t;
406
- }
407
- function it(t) {
408
- return Math.max(0, Math.min(1, t || 0));
409
- }
410
- function _t(t, e, n) {
411
- return (t < 60 ? e + (n - e) * t / 60 : t < 180 ? n : t < 240 ? e + (n - e) * (240 - t) / 60 : e) * 255;
412
- }
413
- const Tn = (t) => () => t;
414
- function Ea(t, e) {
415
- return function(n) {
416
- return t + n * e;
417
- };
418
- }
419
- function Ra(t, e, n) {
420
- return t = Math.pow(t, n), e = Math.pow(e, n) - t, n = 1 / n, function(r) {
421
- return Math.pow(t + r * e, n);
422
- };
423
- }
424
- function ka(t) {
425
- return (t = +t) == 1 ? zr : function(e, n) {
426
- return n - e ? Ra(e, n, t) : Tn(isNaN(e) ? n : e);
427
- };
428
- }
429
- function zr(t, e) {
430
- var n = e - t;
431
- return n ? Ea(t, n) : Tn(isNaN(t) ? e : t);
432
- }
433
- const Hn = (function t(e) {
434
- var n = ka(e);
435
- function r(s, a) {
436
- var i = n((s = Ht(s)).r, (a = Ht(a)).r), o = n(s.g, a.g), c = n(s.b, a.b), l = zr(s.opacity, a.opacity);
437
- return function(u) {
438
- return s.r = i(u), s.g = o(u), s.b = c(u), s.opacity = l(u), s + "";
439
- };
440
- }
441
- return r.gamma = t, r;
442
- })(1);
443
- function Da(t, e) {
444
- e || (e = []);
445
- var n = t ? Math.min(e.length, t.length) : 0, r = e.slice(), s;
446
- return function(a) {
447
- for (s = 0; s < n; ++s) r[s] = t[s] * (1 - a) + e[s] * a;
448
- return r;
449
- };
450
- }
451
- function Ma(t) {
452
- return ArrayBuffer.isView(t) && !(t instanceof DataView);
453
- }
454
- function Pa(t, e) {
455
- var n = e ? e.length : 0, r = t ? Math.min(n, t.length) : 0, s = new Array(r), a = new Array(n), i;
456
- for (i = 0; i < r; ++i) s[i] = wn(t[i], e[i]);
457
- for (; i < n; ++i) a[i] = e[i];
458
- return function(o) {
459
- for (i = 0; i < r; ++i) a[i] = s[i](o);
460
- return a;
461
- };
462
- }
463
- function La(t, e) {
464
- var n = /* @__PURE__ */ new Date();
465
- return t = +t, e = +e, function(r) {
466
- return n.setTime(t * (1 - r) + e * r), n;
467
- };
468
- }
469
- function dt(t, e) {
470
- return t = +t, e = +e, function(n) {
471
- return t * (1 - n) + e * n;
472
- };
473
- }
474
- function Aa(t, e) {
475
- var n = {}, r = {}, s;
476
- (t === null || typeof t != "object") && (t = {}), (e === null || typeof e != "object") && (e = {});
477
- for (s in e)
478
- s in t ? n[s] = wn(t[s], e[s]) : r[s] = e[s];
479
- return function(a) {
480
- for (s in n) r[s] = n[s](a);
481
- return r;
482
- };
483
- }
484
- var jt = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, It = new RegExp(jt.source, "g");
485
- function Oa(t) {
486
- return function() {
487
- return t;
488
- };
489
- }
490
- function Na(t) {
491
- return function(e) {
492
- return t(e) + "";
493
- };
494
- }
495
- function _a(t, e) {
496
- var n = jt.lastIndex = It.lastIndex = 0, r, s, a, i = -1, o = [], c = [];
497
- for (t = t + "", e = e + ""; (r = jt.exec(t)) && (s = It.exec(e)); )
498
- (a = s.index) > n && (a = e.slice(n, a), o[i] ? o[i] += a : o[++i] = a), (r = r[0]) === (s = s[0]) ? o[i] ? o[i] += s : o[++i] = s : (o[++i] = null, c.push({ i, x: dt(r, s) })), n = It.lastIndex;
499
- return n < e.length && (a = e.slice(n), o[i] ? o[i] += a : o[++i] = a), o.length < 2 ? c[0] ? Na(c[0].x) : Oa(e) : (e = c.length, function(l) {
500
- for (var u = 0, h; u < e; ++u) o[(h = c[u]).i] = h.x(l);
501
- return o.join("");
502
- });
503
- }
504
- function wn(t, e) {
505
- var n = typeof e, r;
506
- return e == null || n === "boolean" ? Tn(e) : (n === "number" ? dt : n === "string" ? (r = ze(e)) ? (e = r, Hn) : _a : e instanceof ze ? Hn : e instanceof Date ? La : Ma(e) ? Da : Array.isArray(e) ? Pa : typeof e.valueOf != "function" && typeof e.toString != "function" || isNaN(e) ? Aa : dt)(t, e);
507
- }
508
- function Ia(t, e) {
509
- return t = +t, e = +e, function(n) {
510
- return Math.round(t * (1 - n) + e * n);
511
- };
512
- }
513
- const jn = `#version 300 es
514
- precision lowp float;
515
-
516
- uniform lowp vec4 u_color;
517
- out vec4 fragColor;
518
-
519
- void main(void) {
520
- fragColor = u_color;
521
- }
522
- `, Ya = `#version 300 es
523
-
524
- // Copyright 2025 Synnax Labs, Inc.
525
- //
526
- // Use of this software is governed by the Business Source License included in the file
527
- // licenses/BSL.txt.
528
- //
529
- // As of the Change Date specified in that file, in accordance with the Business Source
530
- // License, use of this software will be governed by the Apache License, Version 2.0,
531
- // included in the file licenses/APL.txt.
532
-
533
- in mediump float a_x;
534
- in mediump float a_y;
535
- in mediump vec2 a_translate;
536
-
537
- uniform mediump vec2 u_scale_aggregate;
538
- uniform mediump vec2 u_offset_aggregate;
539
-
540
- void main(void) {
541
- gl_Position = vec4((u_scale_aggregate * vec2(a_x, a_y) + u_offset_aggregate) + a_translate, 0.0, 1.0);
542
- }
543
- `, Ua = `#version 300 es
544
-
545
- // Copyright 2025 Synnax Labs, Inc.
546
- //
547
- // Use of this software is governed by the Business Source License included in the file
548
- // licenses/BSL.txt.
549
- //
550
- // As of the Change Date specified in that file, in accordance with the Business Source
551
- // License, use of this software will be governed by the Apache License, Version 2.0,
552
- // included in the file licenses/APL.txt.
553
-
554
- in mediump float a_x;
555
- in mediump uint a_y;
556
- in mediump vec2 a_translate;
557
-
558
- uniform mediump vec2 u_scale_aggregate;
559
- uniform mediump vec2 u_offset_aggregate;
560
-
561
- void main(void) {
562
- gl_Position = vec4((u_scale_aggregate * vec2(a_x, float(a_y)) + u_offset_aggregate) + a_translate, 0.0, 1.0);
563
- }
564
- `, Za = p.object({
565
- x: ct,
566
- y: ct,
567
- label: p.string().optional(),
568
- color: y.colorZ,
569
- strokeWidth: p.number().default(1),
570
- downsample: p.number().min(1).max(50).default(1),
571
- downsampleMode: Dr.default("decimate"),
572
- visible: p.boolean().optional().default(!0)
573
- }), Ba = (t, e, n) => t === -1 || e === -1 || t >= n.series.length ? NaN : Number(n.series[t].at(e)), Fa = C.milliseconds(2);
574
- d.NAN, d.NAN, y.ZERO, A.ZERO;
575
- const $a = (t, e) => e.equals(Qe.UINT8) ? t.UNSIGNED_BYTE : t.FLOAT;
576
- class zn extends Ji {
577
- translationBufferCache = /* @__PURE__ */ new Map();
578
- constructor(e, n, r) {
579
- super(e, n, r), this.translationBufferCache = /* @__PURE__ */ new Map();
580
- }
581
- bindState({ strokeWidth: e, color: n }) {
582
- return this.uniformColor("u_color", n), this.attrStrokeWidth(e);
583
- }
584
- bindScale(e, n) {
585
- const r = d.scale(e.scale, n.scale), s = d.translate(
586
- d.scale(n.scale, e.offset),
587
- n.offset
588
- );
589
- this.uniformXY("u_scale_aggregate", r), this.uniformXY("u_offset_aggregate", s);
590
- }
591
- draw({ x: e, y: n, count: r, downsample: s, xOffset: a, yOffset: i }, o, c, l) {
592
- const { gl: u } = this.renderCtx;
593
- this.bindAttrBuffer("x", e.glBuffer, s, a, c), this.bindAttrBuffer("y", n.glBuffer, s, i, l), u.drawArraysInstanced(u.LINE_STRIP, 0, r / s, o);
594
- }
595
- bindAttrBuffer(e, n, r, s = 0, a) {
596
- const { gl: i } = this.renderCtx;
597
- i.bindBuffer(i.ARRAY_BUFFER, n);
598
- const o = i.getAttribLocation(this.prog, `a_${e}`), c = $a(i, a), l = a.density.valueOf();
599
- a.equals(Qe.UINT8) ? i.vertexAttribIPointer(
600
- o,
601
- 1,
602
- c,
603
- // e.g., gl.UNSIGNED_BYTE
604
- l * r,
605
- l * s
606
- ) : i.vertexAttribPointer(
607
- o,
608
- 1,
609
- c,
610
- !1,
611
- l * r,
612
- l * s
613
- ), i.enableVertexAttribArray(o);
614
- }
615
- getAndBindTranslationBuffer(e) {
616
- const { gl: n } = this.renderCtx, r = `${this.renderCtx.aspect}:${e}`, s = this.translationBufferCache.get(r);
617
- if (s != null)
618
- return n.bindBuffer(n.ARRAY_BUFFER, s.glBuffer), s;
619
- const a = n.createBuffer();
620
- if (a == null)
621
- throw new Mt("Failed to create buffer from WebGL context");
622
- const i = Ha(this.renderCtx.aspect, e);
623
- n.bindBuffer(n.ARRAY_BUFFER, a), n.bufferData(n.ARRAY_BUFFER, i, n.DYNAMIC_DRAW);
624
- const o = { glBuffer: a, jsBuffer: i };
625
- return this.translationBufferCache.set(r, o), o;
626
- }
627
- /**
628
- * We apply stroke width by drawing the line multiple times, each time with a slight
629
- * transformation. This is done as simply as possible. We draw the "centered" line
630
- * and then four more lines: one to the left, one to the right, one above, and one
631
- * below. We can repeat this process an arbitrary number of times to make the line
632
- * thicker. As we increase the stroke width, we also increase the cost of drawing the
633
- * line.
634
- */
635
- attrStrokeWidth(e) {
636
- const { gl: n } = this.renderCtx, { jsBuffer: r } = this.getAndBindTranslationBuffer(e), s = n.getAttribLocation(this.prog, "a_translate");
637
- return n.vertexAttribPointer(s, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(s), n.vertexAttribDivisor(s, 1), r.length / 2;
638
- }
639
- }
640
- class Pe {
641
- static CONTEXT_KEY = "pluto-line-gl-program";
642
- // Uint8 hybrid program is used for high performance rendering of uint8 data along
643
- // with float32 timestamp data. It's used as a hot path optimization for common
644
- // channel such as actuator states.
645
- uint8HybridProgram;
646
- // Float32 program is used for rendering float32 data. It's used for all other
647
- // channel types.
648
- float32Program;
649
- constructor(e) {
650
- this.uint8HybridProgram = new zn(e, Ua, jn), this.float32Program = new zn(e, Ya, jn);
651
- }
652
- get gl() {
653
- return this.uint8HybridProgram.renderCtx.gl;
654
- }
655
- getProgram(e) {
656
- return e.equals(Qe.UINT8) ? this.uint8HybridProgram : this.float32Program;
657
- }
658
- static create(e, n) {
659
- const r = new Pe(n);
660
- return e.set(Pe.CONTEXT_KEY, r), r;
661
- }
662
- static use(e) {
663
- const n = e.get(Pe.CONTEXT_KEY);
664
- if (n == null) throw new Mt("GLProgram not found");
665
- return n;
666
- }
667
- }
668
- class zt extends Z {
669
- static TYPE = "line";
670
- schema = Za;
671
- afterUpdate(e) {
672
- const { internal: n } = this, r = {
673
- onStatusChange: _r(e)
674
- };
675
- n.xTelem = H(e, this.state.x, n.xTelem, r), n.yTelem = H(e, this.state.y, n.yTelem, r), n.instrumentation = Dt(e, "line"), n.lineCtx = Pe.use(e), n.requestRender = Sn(e), n.stopListeningXTelem?.(), n.stopListeningYTelem?.(), n.stopListeningXTelem = n.xTelem.onChange(() => n.requestRender("data")), n.stopListeningYTelem = n.yTelem.onChange(() => n.requestRender("data")), n.requestRender("layout"), (n.xDownsampler?.props.mode !== this.state.downsampleMode || n.xDownsampler?.props.windowSize !== this.state.downsample) && (n.xDownsampler = new qt({
676
- mode: this.state.downsampleMode,
677
- windowSize: this.state.downsample
678
- }), n.yDownsampler = new qt({
679
- mode: this.state.downsampleMode,
680
- windowSize: this.state.downsample
681
- }));
682
- }
683
- afterDelete() {
684
- const { internal: e } = this;
685
- e.xTelem.cleanup?.(), e.yTelem.cleanup?.(), e.requestRender("layout");
686
- }
687
- xBounds() {
688
- return this.internal.xTelem.value()[0];
689
- }
690
- yBounds() {
691
- return this.internal.yTelem.value()[0];
692
- }
693
- findByXValue(e, n) {
694
- const { xTelem: r, yTelem: s } = this.internal;
695
- let [, a] = r.value();
696
- a = this.internal.xDownsampler.transform(a);
697
- let [i, o] = [-1, -1];
698
- a.series.find((T, k) => {
699
- const L = T.binarySearch(n), D = L >= 0 && L < T.length;
700
- return D && ([i, o] = [L, k]), D;
701
- });
702
- const { key: c } = this, { color: l, label: u } = this.state, h = {
703
- key: c,
704
- color: l,
705
- label: u,
706
- position: { x: 0, y: 0 },
707
- value: { x: NaN, y: NaN },
708
- bounds: { lower: 0, upper: 0 }
709
- };
710
- if (i === -1 || o === -1 || !this.state.visible) return h;
711
- const f = a.series[o];
712
- h.value.x = Ba(o, i, a);
713
- let [, b] = s.value();
714
- b = this.internal.yDownsampler.transform(b);
715
- const v = b.series.find(
716
- (T) => A.contains(T.alignmentBounds, f.alignment + BigInt(i))
717
- );
718
- if (v == null) return h;
719
- const S = Number(v.alignment - f.alignment);
720
- return h.value.y = Number(v.at(i - S)), h.bounds = { ...v.bounds }, h.position = {
721
- x: e.dataToDecimalScale.x.pos(h.value.x),
722
- y: e.dataToDecimalScale.y.pos(h.value.y)
723
- }, h;
724
- }
725
- render(e) {
726
- if (this.deleted || !this.state.visible) return;
727
- const { downsample: n } = this.state, { xTelem: r, yTelem: s, lineCtx: a, xDownsampler: i, yDownsampler: o } = this.internal, { dataToDecimalScale: c, exposure: l } = e;
728
- let [[, u], [, h]] = [r.value(), s.value()];
729
- if (u = i.transform(u), h = o.transform(h), u.updateGLBuffer(a.gl), h.updateGLBuffer(a.gl), u.length === 0 || h.length === 0) return;
730
- const f = a.getProgram(h.dataType), b = Va(
731
- u,
732
- h,
733
- l,
734
- n,
735
- this.state.downsampleMode,
736
- Fa
737
- );
738
- this.internal.instrumentation.L.debug("render", () => ({
739
- key: this.key,
740
- downsample: n,
741
- scale: c.transform,
742
- props: e.region,
743
- ops: Ga(b)
744
- }));
745
- const v = f.setAsActive(), S = f.bindState(this.state), T = f.renderCtx.scaleRegion(e.region).transform;
746
- b.forEach((k) => {
747
- const L = Xa(c, k).transform;
748
- f.bindScale(L, T), f.draw(k, S, u.dataType, h.dataType);
749
- }), v();
750
- }
751
- }
752
- const qa = 5e3, Ha = (t, e) => Wa(za(t), e).map(
753
- (n, r) => Math.floor(r / ja) * (1 / (qa * t)) * n
754
- ), ja = 5, za = (t) => (
755
- // prettier-ignore
756
- new Float32Array([
757
- 0,
758
- 0,
759
- // center
760
- 0,
761
- t,
762
- // top
763
- 0,
764
- -t,
765
- // bottom
766
- 1,
767
- 0,
768
- // right
769
- -1,
770
- 0
771
- // left
772
- ])
773
- ), Wa = (t, e) => {
774
- const n = new Float32Array(t.length * e);
775
- for (let r = 0; r < e; r++) n.set(t, r * t.length);
776
- return n;
777
- }, Xa = (t, e) => t.translate(
778
- t.x.dim(Number(e.x.sampleOffset)),
779
- t.y.dim(Number(e.y.sampleOffset))
780
- ), Lu = { [zt.TYPE]: zt }, Va = (t, e, n, r, s, a) => {
781
- if (t.series.length === 0 || e.series.length === 0) return [];
782
- const i = [];
783
- return t.series.forEach(
784
- (o) => e.series.forEach((c) => {
785
- if (!Ka(o, c, a)) return;
786
- let l = 0n, u = 0n;
787
- o.alignment < c.alignment ? l = c.alignment - o.alignment : c.alignment < o.alignment && (u = o.alignment - c.alignment);
788
- const h = Yr.min(
789
- A.span(o.alignmentBounds) - l,
790
- A.span(c.alignmentBounds) - u
791
- );
792
- if (h === 0n) return;
793
- let f = Ur(
794
- Math.round(n * 4 * Number(h)),
795
- r,
796
- 51
797
- );
798
- s !== "decimate" && (f = 1);
799
- const b = Number(h / o.alignmentMultiple), v = Number(l / o.alignmentMultiple), S = Number(u / c.alignmentMultiple);
800
- i.push({ x: o, y: c, xOffset: v, yOffset: S, count: b, downsample: f });
801
- })
802
- ), i;
803
- }, Ga = (t) => t.map((e) => ({ ...e, x: e.x.digest, y: e.y.digest })), Ka = (t, e, n) => {
804
- if (t.alignmentMultiple !== e.alignmentMultiple)
805
- return console.warn(
806
- "encountered two series with different alignment multiples in draw operations",
807
- { x: t.digest, y: e.digest }
808
- ), !1;
809
- const r = t.timeRange.overlapsWith(e.timeRange, n), s = A.overlapsWith(t.alignmentBounds, e.alignmentBounds);
810
- return r && s;
811
- }, Wr = p.object({
812
- dpr: p.number(),
813
- region: g.box,
814
- bootstrap: p.boolean().optional().default(!1),
815
- bootstrapped: p.boolean().optional().default(!1),
816
- // We set all of these to ay because nodejs can't identify OffscreenCanvas
817
- // and polyfilling causes more problems than it solves
818
- glCanvas: p.any().optional(),
819
- upper2dCanvas: p.any().optional(),
820
- lower2dCanvas: p.any().optional(),
821
- os: ca.osZ
822
- });
823
- class Wt extends fe {
824
- static TYPE = "Canvas";
825
- schema = Wr;
826
- renderCtx = null;
827
- afterUpdate(e) {
828
- if (this.renderCtx == null) {
829
- if (!this.state.bootstrap) return;
830
- const { glCanvas: n, lower2dCanvas: r, upper2dCanvas: s, os: a } = this.state;
831
- if (n == null || r == null || s == null)
832
- throw new Mt(
833
- "[vis.worker.Canvas] - expected render context bootstrap to include all canvases"
834
- );
835
- this.renderCtx = j.create(
836
- e,
837
- n,
838
- r,
839
- s,
840
- a
841
- ), Pe.create(e, this.renderCtx), this.setState((i) => ({
842
- ...i,
843
- bootstrap: !1,
844
- bootstrapped: !0,
845
- glCanvas: void 0,
846
- lower2dCanvas: void 0,
847
- upper2dCanvas: void 0
848
- }));
849
- } else this.renderCtx.update(e);
850
- this.renderCtx.resize(this.state.region, this.state.dpr);
851
- }
852
- }
853
- const Qa = {
854
- [Wt.TYPE]: Wt
855
- }, Au = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
856
- __proto__: null,
857
- Canvas: Wt,
858
- REGISTRY: Qa,
859
- canvasStateZ: Wr
860
- }, Symbol.toStringTag, { value: "Module" })), Xr = p.object({
861
- position: d.xy,
862
- zoom: p.number(),
863
- region: g.box,
864
- clearOverScan: d.crudeZ.optional().default(10),
865
- visible: p.boolean().optional().default(!0),
866
- autoRenderInterval: p.number().optional()
867
- }), at = ["upper2d", "lower2d"];
868
- class Le extends fe {
869
- static TYPE = "Diagram";
870
- static stateZ = Xr;
871
- schema = Le.stateZ;
872
- afterUpdate(e) {
873
- this.internal.renderCtx = j.use(e), this.internal.handleError = he(e), ua.isNonZero(this.state.autoRenderInterval) && (this.internal.autoRenderInterval ??= setInterval(() => {
874
- this.state.visible && this.requestRender("low");
875
- }, this.state.autoRenderInterval)), xn(e, () => {
876
- this.state.visible && this.requestRender("low");
877
- }), !(!this.state.visible && !this.prevState.visible) && (this.internal.viewportScale = G.XY.magnify(d.construct(this.state.zoom)).translate(g.topLeft(this.state.region)).translate(this.state.position), this.requestRender("high"));
878
- }
879
- afterDelete() {
880
- this.internal.autoRenderInterval != null && clearInterval(this.internal.autoRenderInterval), this.requestRender("high");
881
- }
882
- render() {
883
- if (this.deleted) return;
884
- const { renderCtx: e, handleError: n, viewportScale: r } = this.internal, s = g.construct(this.state.region);
885
- if (!this.state.visible)
886
- return () => e.erase(s, this.state.clearOverScan, ...at);
887
- const a = e.scissor(s, d.ZERO, at);
888
- try {
889
- this.children.forEach((o) => o.render?.({ viewportScale: r }));
890
- } catch (o) {
891
- n(o, "failed to render diagram");
892
- } finally {
893
- a();
894
- }
895
- const i = g.copy(this.state.region);
896
- return () => {
897
- e.lower2d.fillStyle = y.hex(y.BLACK), e.lower2d.fillRect(
898
- ...d.couple(g.topLeft(i)),
899
- g.width(i),
900
- g.height(i)
901
- ), e.erase(i, this.state.clearOverScan, ...at);
902
- };
903
- }
904
- requestRender(e) {
905
- const { renderCtx: n } = this.internal;
906
- n.loop.set({
907
- key: `${Le.TYPE}-${this.key}`,
908
- render: this.render.bind(this),
909
- priority: e,
910
- canvases: at
911
- });
912
- }
913
- }
914
- const Ja = {
915
- [Le.TYPE]: Le
916
- }, Ou = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
917
- __proto__: null,
918
- Diagram: Le,
919
- REGISTRY: Ja,
920
- diagramStateZ: Xr
921
- }, Symbol.toStringTag, { value: "Module" }));
922
- class eo {
923
- entries = /* @__PURE__ */ new Map();
924
- setListeners = /* @__PURE__ */ new Map();
925
- deleteListeners = /* @__PURE__ */ new Map();
926
- handleError;
927
- equal;
928
- constructor(e, n = () => !1) {
929
- this.handleError = e, this.equal = n;
930
- }
931
- setOne(e, n, r, s) {
932
- const a = this.entries.get(n), i = ea(r, a);
933
- if (!(i == null || a != null && this.equal(i, a, n)))
934
- return this.entries.set(n, i), this.notifySet(e, n, i, s), () => {
935
- a === void 0 ? (this.entries.delete(n), this.notifyDelete(e, n)) : (this.entries.set(n, a), this.notifySet(e, n, a, s));
936
- };
937
- }
938
- /**
939
- * Sets a value for the given key in the store.
940
- *
941
- * @param key - The key to set
942
- * @param value - The value to set, or a function to compute the value from the previous state
943
- * @param opts - Options for the set operation
944
- * @returns A rollback function that undoes the set operation
945
- */
946
- set(e, n, r, s) {
947
- const a = [];
948
- if (Array.isArray(n))
949
- n.forEach((i) => {
950
- const o = this.setOne(e, i.key, i, r);
951
- o != null && a.push(o);
952
- });
953
- else if (typeof n == "object" && "key" in n) {
954
- const i = n, o = this.setOne(e, i.key, i, r);
955
- o != null && a.push(o);
956
- } else {
957
- const i = this.setOne(
958
- e,
959
- n,
960
- r,
961
- s
962
- );
963
- i != null && a.push(i);
964
- }
965
- return () => a.reverse().forEach((i) => i());
966
- }
967
- get(e) {
968
- return typeof e == "function" ? Array.from(this.entries.values()).filter(e) : Array.isArray(e) ? e.map((n) => this.entries.get(n)).filter((n) => n != null) : this.entries.get(e);
969
- }
970
- list() {
971
- return Array.from(this.entries.values());
972
- }
973
- has(e) {
974
- return Array.isArray(e) ? e.every((n) => this.entries.has(n)) : this.entries.has(e);
975
- }
976
- /**
977
- * Deletes entries from the store and notifies delete listeners.
978
- * @param key - The key(s) to delete or a filter function
979
- * @param variant - Optional variant data for set operations during rollback
980
- * @returns A rollback function that restores the deleted entries
981
- */
982
- delete(e, n, r) {
983
- const s = [];
984
- return typeof n == "function" ? this.entries.forEach((a, i) => {
985
- n(a, i) && s.push({ key: i, value: a });
986
- }) : Zr.toArray(n).forEach((a) => {
987
- const i = this.entries.get(a);
988
- s.push({ key: a, value: i });
989
- }), s.forEach(({ key: a }) => {
990
- this.entries.delete(a), this.notifyDelete(e, a);
991
- }), () => s.forEach(({ key: a, value: i }) => {
992
- i != null && (this.entries.set(a, i), this.notifySet(e, a, i, r));
993
- });
994
- }
995
- clear() {
996
- this.entries.clear();
997
- }
998
- /**
999
- * Registers a listener for set operations.
1000
- *
1001
- * @param callback - Function to call when a value is set
1002
- * @param key - Optional key to filter notifications (if provided, only changes to this
1003
- * key trigger the callback)
1004
- * @returns A destructor function to remove the listener
1005
- */
1006
- onSet(e, n, r) {
1007
- return this.setListeners.set(n, { scope: e, key: r }), () => this.setListeners.delete(n);
1008
- }
1009
- /**
1010
- * Registers a listener for delete operations.
1011
- *
1012
- * @param callback - Function to call when a value is deleted
1013
- * @param key - Optional key to filter notifications (if provided, only deletion
1014
- * of this key triggers the callback)
1015
- * @returns A destructor function to remove the listener
1016
- */
1017
- onDelete(e, n, r) {
1018
- return this.deleteListeners.set(n, { scope: e, key: r }), () => this.deleteListeners.delete(n);
1019
- }
1020
- notifySet(e, n, r, s) {
1021
- this.setListeners.forEach((a, i) => {
1022
- const o = a.key == null || a.key === n, c = a.scope !== e;
1023
- o && c && this.handleError(
1024
- async () => await i(r, s),
1025
- "Failed to notify set listener"
1026
- );
1027
- });
1028
- }
1029
- notifyDelete(e, n) {
1030
- this.deleteListeners.forEach((r, s) => {
1031
- const a = r.key == null || r.key === n, i = r.scope !== e;
1032
- a && i && this.handleError(
1033
- async () => await s(n),
1034
- "Failed to notify delete listener"
1035
- );
1036
- });
1037
- }
1038
- scope(e) {
1039
- return {
1040
- set: (n, r, s) => this.set(e, n, r, s),
1041
- get: ((n) => this.get(n)),
1042
- list: () => this.list(),
1043
- has: (n) => this.has(n),
1044
- delete: (n, r) => this.delete(e, n, r),
1045
- onSet: (n, r) => this.onSet(e, n, r),
1046
- onDelete: (n, r) => this.onDelete(e, n, r)
1047
- };
1048
- }
1049
- }
1050
- const to = (t, e) => Object.fromEntries(
1051
- Object.entries(t).map(([n, { equal: r }]) => [
1052
- n,
1053
- new eo(e, r)
1054
- ])
1055
- ), Wn = (t, e) => Object.fromEntries(
1056
- Object.entries(t).map(([n]) => [
1057
- n,
1058
- t[n].scope(e)
1059
- ])
1060
- ), Nu = (t, e, n) => t.set(e, (r) => r == null ? void 0 : { ...r, ...n }), no = (t, e) => {
1061
- const n = t.includes("delete"), r = e.includes("delete");
1062
- return n && !r ? -1 : !n && r ? 1 : 0;
1063
- }, ro = async ({
1064
- openStreamer: t,
1065
- storeConfig: e,
1066
- handleError: n,
1067
- client: r,
1068
- store: s
1069
- }) => {
1070
- const a = Object.values(e), i = Br.unique(
1071
- a.flatMap(({ listeners: h }) => h.map(({ channel: f }) => f))
1072
- ), o = {};
1073
- a.forEach(
1074
- ({ listeners: h }) => h.forEach((f) => {
1075
- const { channel: b } = f;
1076
- o[b] = [...o[b] || [], f];
1077
- })
1078
- );
1079
- const c = await An.HardenedStreamer.open(t, i), l = new An.ObservableStreamer(c), u = (h) => {
1080
- const f = [...h.uniqueNames];
1081
- f.sort(no), n(
1082
- async () => {
1083
- for (const b of f) {
1084
- const v = h.get(b), S = o[b];
1085
- if (S != null)
1086
- for (const { onChange: T, schema: k } of S)
1087
- await n(async () => {
1088
- let L;
1089
- v.dataType.equals(Qe.JSON) ? L = v.parseJSON(k) : L = Array.from(v).map((D) => k.parse(D));
1090
- for (const D of L)
1091
- await n(
1092
- () => T({ changed: D, client: r, store: s }),
1093
- `Failed to handle streamer change for ${b}`,
1094
- ta
1095
- );
1096
- }, `Failed to parse streamer change for ${b}`);
1097
- }
1098
- },
1099
- `Failed to handle streamer change for ${ha.naturalLanguageJoin(f)}`
1100
- );
1101
- };
1102
- return l.onChange(u), l.close.bind(l);
1103
- };
1104
- class so {
1105
- store;
1106
- streamCloser = null;
1107
- client;
1108
- constructor({
1109
- client: e,
1110
- openStreamer: n,
1111
- storeConfig: r,
1112
- handleError: s,
1113
- handleAsyncError: a
1114
- }) {
1115
- this.store = to(r, s), this.client = e, e != null && (n ??= e?.openStreamer.bind(e), this.streamCloser = ro({
1116
- client: e,
1117
- storeConfig: r,
1118
- handleError: a,
1119
- store: Wn(this.store, ""),
1120
- openStreamer: n
1121
- }));
1122
- }
1123
- async awaitInitialized() {
1124
- this.streamCloser != null && await this.streamCloser;
1125
- }
1126
- scopedStore(e) {
1127
- return Wn(this.store, e);
1128
- }
1129
- async close() {
1130
- if (this.streamCloser == null) return;
1131
- await (await this.streamCloser)();
1132
- }
1133
- }
1134
- const io = pe.object({
1135
- request: pe.string(),
1136
- bounds: pe.record(pe.string(), A.bounds)
1137
- }), ao = pe.object({
1138
- request: pe.string(),
1139
- response: io
1140
- });
1141
- class Xt extends Z {
1142
- static TYPE = "Bounds";
1143
- schema = ao;
1144
- afterUpdate(e) {
1145
- this.state.request !== this.prevState.request && this.setState((n) => ({
1146
- ...n,
1147
- response: {
1148
- request: n.request,
1149
- bounds: this.internal.getBounds()
1150
- }
1151
- }));
1152
- }
1153
- render(e) {
1154
- this.internal.getBounds = e.getBounds;
1155
- }
1156
- }
1157
- function lt(t, e) {
1158
- return t == null || e == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
1159
- }
1160
- function oo(t, e) {
1161
- return t == null || e == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
1162
- }
1163
- function Cn(t) {
1164
- let e, n, r;
1165
- t.length !== 2 ? (e = lt, n = (o, c) => lt(t(o), c), r = (o, c) => t(o) - c) : (e = t === lt || t === oo ? t : lo, n = t, r = t);
1166
- function s(o, c, l = 0, u = o.length) {
1167
- if (l < u) {
1168
- if (e(c, c) !== 0) return u;
1169
- do {
1170
- const h = l + u >>> 1;
1171
- n(o[h], c) < 0 ? l = h + 1 : u = h;
1172
- } while (l < u);
1173
- }
1174
- return l;
1175
- }
1176
- function a(o, c, l = 0, u = o.length) {
1177
- if (l < u) {
1178
- if (e(c, c) !== 0) return u;
1179
- do {
1180
- const h = l + u >>> 1;
1181
- n(o[h], c) <= 0 ? l = h + 1 : u = h;
1182
- } while (l < u);
1183
- }
1184
- return l;
1185
- }
1186
- function i(o, c, l = 0, u = o.length) {
1187
- const h = s(o, c, l, u - 1);
1188
- return h > l && r(o[h - 1], c) > -r(o[h], c) ? h - 1 : h;
1189
- }
1190
- return { left: s, center: i, right: a };
1191
- }
1192
- function lo() {
1193
- return 0;
1194
- }
1195
- function co(t) {
1196
- return t === null ? NaN : +t;
1197
- }
1198
- const uo = Cn(lt), ho = uo.right;
1199
- Cn(co).center;
1200
- const fo = Math.sqrt(50), go = Math.sqrt(10), po = Math.sqrt(2);
1201
- function ft(t, e, n) {
1202
- const r = (e - t) / Math.max(0, n), s = Math.floor(Math.log10(r)), a = r / Math.pow(10, s), i = a >= fo ? 10 : a >= go ? 5 : a >= po ? 2 : 1;
1203
- let o, c, l;
1204
- return s < 0 ? (l = Math.pow(10, -s) / i, o = Math.round(t * l), c = Math.round(e * l), o / l < t && ++o, c / l > e && --c, l = -l) : (l = Math.pow(10, s) * i, o = Math.round(t / l), c = Math.round(e / l), o * l < t && ++o, c * l > e && --c), c < o && 0.5 <= n && n < 2 ? ft(t, e, n * 2) : [o, c, l];
1205
- }
1206
- function mo(t, e, n) {
1207
- if (e = +e, t = +t, n = +n, !(n > 0)) return [];
1208
- if (t === e) return [t];
1209
- const r = e < t, [s, a, i] = r ? ft(e, t, n) : ft(t, e, n);
1210
- if (!(a >= s)) return [];
1211
- const o = a - s + 1, c = new Array(o);
1212
- if (r)
1213
- if (i < 0) for (let l = 0; l < o; ++l) c[l] = (a - l) / -i;
1214
- else for (let l = 0; l < o; ++l) c[l] = (a - l) * i;
1215
- else if (i < 0) for (let l = 0; l < o; ++l) c[l] = (s + l) / -i;
1216
- else for (let l = 0; l < o; ++l) c[l] = (s + l) * i;
1217
- return c;
1218
- }
1219
- function Vt(t, e, n) {
1220
- return e = +e, t = +t, n = +n, ft(t, e, n)[2];
1221
- }
1222
- function Gt(t, e, n) {
1223
- e = +e, t = +t, n = +n;
1224
- const r = e < t, s = r ? Vt(e, t, n) : Vt(t, e, n);
1225
- return (r ? -1 : 1) * (s < 0 ? 1 / -s : s);
1226
- }
1227
- function Vr(t, e) {
1228
- switch (arguments.length) {
1229
- case 0:
1230
- break;
1231
- case 1:
1232
- this.range(t);
1233
- break;
1234
- default:
1235
- this.range(e).domain(t);
1236
- break;
1237
- }
1238
- return this;
1239
- }
1240
- function yo(t) {
1241
- return function() {
1242
- return t;
1243
- };
1244
- }
1245
- function bo(t) {
1246
- return +t;
1247
- }
1248
- var Xn = [0, 1];
1249
- function Re(t) {
1250
- return t;
1251
- }
1252
- function Kt(t, e) {
1253
- return (e -= t = +t) ? function(n) {
1254
- return (n - t) / e;
1255
- } : yo(isNaN(e) ? NaN : 0.5);
1256
- }
1257
- function xo(t, e) {
1258
- var n;
1259
- return t > e && (n = t, t = e, e = n), function(r) {
1260
- return Math.max(t, Math.min(e, r));
1261
- };
1262
- }
1263
- function So(t, e, n) {
1264
- var r = t[0], s = t[1], a = e[0], i = e[1];
1265
- return s < r ? (r = Kt(s, r), a = n(i, a)) : (r = Kt(r, s), a = n(a, i)), function(o) {
1266
- return a(r(o));
1267
- };
1268
- }
1269
- function vo(t, e, n) {
1270
- var r = Math.min(t.length, e.length) - 1, s = new Array(r), a = new Array(r), i = -1;
1271
- for (t[r] < t[0] && (t = t.slice().reverse(), e = e.slice().reverse()); ++i < r; )
1272
- s[i] = Kt(t[i], t[i + 1]), a[i] = n(e[i], e[i + 1]);
1273
- return function(o) {
1274
- var c = ho(t, o, 1, r) - 1;
1275
- return a[c](s[c](o));
1276
- };
1277
- }
1278
- function Gr(t, e) {
1279
- return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());
1280
- }
1281
- function To() {
1282
- var t = Xn, e = Xn, n = wn, r, s, a, i = Re, o, c, l;
1283
- function u() {
1284
- var f = Math.min(t.length, e.length);
1285
- return i !== Re && (i = xo(t[0], t[f - 1])), o = f > 2 ? vo : So, c = l = null, h;
1286
- }
1287
- function h(f) {
1288
- return f == null || isNaN(f = +f) ? a : (c || (c = o(t.map(r), e, n)))(r(i(f)));
1289
- }
1290
- return h.invert = function(f) {
1291
- return i(s((l || (l = o(e, t.map(r), dt)))(f)));
1292
- }, h.domain = function(f) {
1293
- return arguments.length ? (t = Array.from(f, bo), u()) : t.slice();
1294
- }, h.range = function(f) {
1295
- return arguments.length ? (e = Array.from(f), u()) : e.slice();
1296
- }, h.rangeRound = function(f) {
1297
- return e = Array.from(f), n = Ia, u();
1298
- }, h.clamp = function(f) {
1299
- return arguments.length ? (i = f ? !0 : Re, u()) : i !== Re;
1300
- }, h.interpolate = function(f) {
1301
- return arguments.length ? (n = f, u()) : n;
1302
- }, h.unknown = function(f) {
1303
- return arguments.length ? (a = f, h) : a;
1304
- }, function(f, b) {
1305
- return r = f, s = b, u();
1306
- };
1307
- }
1308
- function Kr() {
1309
- return To()(Re, Re);
1310
- }
1311
- function wo(t) {
1312
- return Math.abs(t = Math.round(t)) >= 1e21 ? t.toLocaleString("en").replace(/,/g, "") : t.toString(10);
1313
- }
1314
- function gt(t, e) {
1315
- if ((n = (t = e ? t.toExponential(e - 1) : t.toExponential()).indexOf("e")) < 0) return null;
1316
- var n, r = t.slice(0, n);
1317
- return [
1318
- r.length > 1 ? r[0] + r.slice(2) : r,
1319
- +t.slice(n + 1)
1320
- ];
1321
- }
1322
- function Ae(t) {
1323
- return t = gt(Math.abs(t)), t ? t[1] : NaN;
1324
- }
1325
- function Co(t, e) {
1326
- return function(n, r) {
1327
- for (var s = n.length, a = [], i = 0, o = t[0], c = 0; s > 0 && o > 0 && (c + o + 1 > r && (o = Math.max(1, r - c)), a.push(n.substring(s -= o, s + o)), !((c += o + 1) > r)); )
1328
- o = t[i = (i + 1) % t.length];
1329
- return a.reverse().join(e);
1330
- };
1331
- }
1332
- function Eo(t) {
1333
- return function(e) {
1334
- return e.replace(/[0-9]/g, function(n) {
1335
- return t[+n];
1336
- });
1337
- };
1338
- }
1339
- var Ro = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
1340
- function pt(t) {
1341
- if (!(e = Ro.exec(t))) throw new Error("invalid format: " + t);
1342
- var e;
1343
- return new En({
1344
- fill: e[1],
1345
- align: e[2],
1346
- sign: e[3],
1347
- symbol: e[4],
1348
- zero: e[5],
1349
- width: e[6],
1350
- comma: e[7],
1351
- precision: e[8] && e[8].slice(1),
1352
- trim: e[9],
1353
- type: e[10]
1354
- });
1355
- }
1356
- pt.prototype = En.prototype;
1357
- function En(t) {
1358
- this.fill = t.fill === void 0 ? " " : t.fill + "", this.align = t.align === void 0 ? ">" : t.align + "", this.sign = t.sign === void 0 ? "-" : t.sign + "", this.symbol = t.symbol === void 0 ? "" : t.symbol + "", this.zero = !!t.zero, this.width = t.width === void 0 ? void 0 : +t.width, this.comma = !!t.comma, this.precision = t.precision === void 0 ? void 0 : +t.precision, this.trim = !!t.trim, this.type = t.type === void 0 ? "" : t.type + "";
1359
- }
1360
- En.prototype.toString = function() {
1361
- 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;
1362
- };
1363
- function ko(t) {
1364
- e: for (var e = t.length, n = 1, r = -1, s; n < e; ++n)
1365
- switch (t[n]) {
1366
- case ".":
1367
- r = s = n;
1368
- break;
1369
- case "0":
1370
- r === 0 && (r = n), s = n;
1371
- break;
1372
- default:
1373
- if (!+t[n]) break e;
1374
- r > 0 && (r = 0);
1375
- break;
1376
- }
1377
- return r > 0 ? t.slice(0, r) + t.slice(s + 1) : t;
1378
- }
1379
- var Qr;
1380
- function Do(t, e) {
1381
- var n = gt(t, e);
1382
- if (!n) return t + "";
1383
- var r = n[0], s = n[1], a = s - (Qr = Math.max(-8, Math.min(8, Math.floor(s / 3))) * 3) + 1, i = r.length;
1384
- return a === i ? r : a > i ? r + new Array(a - i + 1).join("0") : a > 0 ? r.slice(0, a) + "." + r.slice(a) : "0." + new Array(1 - a).join("0") + gt(t, Math.max(0, e + a - 1))[0];
1385
- }
1386
- function Vn(t, e) {
1387
- var n = gt(t, e);
1388
- if (!n) return t + "";
1389
- var r = n[0], s = n[1];
1390
- return s < 0 ? "0." + new Array(-s).join("0") + r : r.length > s + 1 ? r.slice(0, s + 1) + "." + r.slice(s + 1) : r + new Array(s - r.length + 2).join("0");
1391
- }
1392
- const Gn = {
1393
- "%": (t, e) => (t * 100).toFixed(e),
1394
- b: (t) => Math.round(t).toString(2),
1395
- c: (t) => t + "",
1396
- d: wo,
1397
- e: (t, e) => t.toExponential(e),
1398
- f: (t, e) => t.toFixed(e),
1399
- g: (t, e) => t.toPrecision(e),
1400
- o: (t) => Math.round(t).toString(8),
1401
- p: (t, e) => Vn(t * 100, e),
1402
- r: Vn,
1403
- s: Do,
1404
- X: (t) => Math.round(t).toString(16).toUpperCase(),
1405
- x: (t) => Math.round(t).toString(16)
1406
- };
1407
- function Kn(t) {
1408
- return t;
1409
- }
1410
- var Qn = Array.prototype.map, Jn = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
1411
- function Mo(t) {
1412
- var e = t.grouping === void 0 || t.thousands === void 0 ? Kn : Co(Qn.call(t.grouping, Number), t.thousands + ""), n = t.currency === void 0 ? "" : t.currency[0] + "", r = t.currency === void 0 ? "" : t.currency[1] + "", s = t.decimal === void 0 ? "." : t.decimal + "", a = t.numerals === void 0 ? Kn : Eo(Qn.call(t.numerals, String)), i = t.percent === void 0 ? "%" : t.percent + "", o = t.minus === void 0 ? "−" : t.minus + "", c = t.nan === void 0 ? "NaN" : t.nan + "";
1413
- function l(h) {
1414
- h = pt(h);
1415
- var f = h.fill, b = h.align, v = h.sign, S = h.symbol, T = h.zero, k = h.width, L = h.comma, D = h.precision, N = h.trim, _ = h.type;
1416
- _ === "n" ? (L = !0, _ = "g") : Gn[_] || (D === void 0 && (D = 12), N = !0, _ = "g"), (T || f === "0" && b === "=") && (T = !0, f = "0", b = "=");
1417
- var w = S === "$" ? n : S === "#" && /[boxX]/.test(_) ? "0" + _.toLowerCase() : "", I = S === "$" ? r : /[%p]/.test(_) ? i : "", ce = Gn[_], Ie = /[defgprs%]/.test(_);
1418
- D = D === void 0 ? 6 : /[gprs]/.test(_) ? Math.max(1, Math.min(21, D)) : Math.max(0, Math.min(20, D));
1419
- function nt(R) {
1420
- var se = w, B = I, ue, rt, Te;
1421
- if (_ === "c")
1422
- B = ce(R) + B, R = "";
1423
- else {
1424
- R = +R;
1425
- var we = R < 0 || 1 / R < 0;
1426
- if (R = isNaN(R) ? c : ce(Math.abs(R), D), N && (R = ko(R)), we && +R == 0 && v !== "+" && (we = !1), se = (we ? v === "(" ? v : o : v === "-" || v === "(" ? "" : v) + se, B = (_ === "s" ? Jn[8 + Qr / 3] : "") + B + (we && v === "(" ? ")" : ""), Ie) {
1427
- for (ue = -1, rt = R.length; ++ue < rt; )
1428
- if (Te = R.charCodeAt(ue), 48 > Te || Te > 57) {
1429
- B = (Te === 46 ? s + R.slice(ue + 1) : R.slice(ue)) + B, R = R.slice(0, ue);
1430
- break;
1431
- }
1432
- }
1433
- }
1434
- L && !T && (R = e(R, 1 / 0));
1435
- var Ce = se.length + R.length + B.length, J = Ce < k ? new Array(k - Ce + 1).join(f) : "";
1436
- switch (L && T && (R = e(J + R, J.length ? k - B.length : 1 / 0), J = ""), b) {
1437
- case "<":
1438
- R = se + R + B + J;
1439
- break;
1440
- case "=":
1441
- R = se + J + R + B;
1442
- break;
1443
- case "^":
1444
- R = J.slice(0, Ce = J.length >> 1) + se + R + B + J.slice(Ce);
1445
- break;
1446
- default:
1447
- R = J + se + R + B;
1448
- break;
1449
- }
1450
- return a(R);
1451
- }
1452
- return nt.toString = function() {
1453
- return h + "";
1454
- }, nt;
1455
- }
1456
- function u(h, f) {
1457
- var b = l((h = pt(h), h.type = "f", h)), v = Math.max(-8, Math.min(8, Math.floor(Ae(f) / 3))) * 3, S = Math.pow(10, -v), T = Jn[8 + v / 3];
1458
- return function(k) {
1459
- return b(S * k) + T;
1460
- };
1461
- }
1462
- return {
1463
- format: l,
1464
- formatPrefix: u
1465
- };
1466
- }
1467
- var ot, Jr, es;
1468
- Po({
1469
- thousands: ",",
1470
- grouping: [3],
1471
- currency: ["$", ""]
1472
- });
1473
- function Po(t) {
1474
- return ot = Mo(t), Jr = ot.format, es = ot.formatPrefix, ot;
1475
- }
1476
- function Lo(t) {
1477
- return Math.max(0, -Ae(Math.abs(t)));
1478
- }
1479
- function Ao(t, e) {
1480
- return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Ae(e) / 3))) * 3 - Ae(Math.abs(t)));
1481
- }
1482
- function Oo(t, e) {
1483
- return t = Math.abs(t), e = Math.abs(e) - t, Math.max(0, Ae(e) - Ae(t)) + 1;
1484
- }
1485
- function No(t, e, n, r) {
1486
- var s = Gt(t, e, n), a;
1487
- switch (r = pt(r ?? ",f"), r.type) {
1488
- case "s": {
1489
- var i = Math.max(Math.abs(t), Math.abs(e));
1490
- return r.precision == null && !isNaN(a = Ao(s, i)) && (r.precision = a), es(r, i);
1491
- }
1492
- case "":
1493
- case "e":
1494
- case "g":
1495
- case "p":
1496
- case "r": {
1497
- r.precision == null && !isNaN(a = Oo(s, Math.max(Math.abs(t), Math.abs(e)))) && (r.precision = a - (r.type === "e"));
1498
- break;
1499
- }
1500
- case "f":
1501
- case "%": {
1502
- r.precision == null && !isNaN(a = Lo(s)) && (r.precision = a - (r.type === "%") * 2);
1503
- break;
1504
- }
1505
- }
1506
- return Jr(r);
1507
- }
1508
- function _o(t) {
1509
- var e = t.domain;
1510
- return t.ticks = function(n) {
1511
- var r = e();
1512
- return mo(r[0], r[r.length - 1], n ?? 10);
1513
- }, t.tickFormat = function(n, r) {
1514
- var s = e();
1515
- return No(s[0], s[s.length - 1], n ?? 10, r);
1516
- }, t.nice = function(n) {
1517
- n == null && (n = 10);
1518
- var r = e(), s = 0, a = r.length - 1, i = r[s], o = r[a], c, l, u = 10;
1519
- for (o < i && (l = i, i = o, o = l, l = s, s = a, a = l); u-- > 0; ) {
1520
- if (l = Vt(i, o, n), l === c)
1521
- return r[s] = i, r[a] = o, e(r);
1522
- if (l > 0)
1523
- i = Math.floor(i / l) * l, o = Math.ceil(o / l) * l;
1524
- else if (l < 0)
1525
- i = Math.ceil(i * l) / l, o = Math.floor(o * l) / l;
1526
- else
1527
- break;
1528
- c = l;
1529
- }
1530
- return t;
1531
- }, t;
1532
- }
1533
- function ts() {
1534
- var t = Kr();
1535
- return t.copy = function() {
1536
- return Gr(t, ts());
1537
- }, Vr.apply(t, arguments), _o(t);
1538
- }
1539
- function Io(t, e) {
1540
- t = t.slice();
1541
- var n = 0, r = t.length - 1, s = t[n], a = t[r], i;
1542
- return a < s && (i = n, n = r, r = i, i = s, s = a, a = i), t[n] = e.floor(s), t[r] = e.ceil(a), t;
1543
- }
1544
- const Yt = /* @__PURE__ */ new Date(), Ut = /* @__PURE__ */ new Date();
1545
- function Y(t, e, n, r) {
1546
- function s(a) {
1547
- return t(a = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+a)), a;
1548
- }
1549
- return s.floor = (a) => (t(a = /* @__PURE__ */ new Date(+a)), a), s.ceil = (a) => (t(a = new Date(a - 1)), e(a, 1), t(a), a), s.round = (a) => {
1550
- const i = s(a), o = s.ceil(a);
1551
- return a - i < o - a ? i : o;
1552
- }, s.offset = (a, i) => (e(a = /* @__PURE__ */ new Date(+a), i == null ? 1 : Math.floor(i)), a), s.range = (a, i, o) => {
1553
- const c = [];
1554
- if (a = s.ceil(a), o = o == null ? 1 : Math.floor(o), !(a < i) || !(o > 0)) return c;
1555
- let l;
1556
- do
1557
- c.push(l = /* @__PURE__ */ new Date(+a)), e(a, o), t(a);
1558
- while (l < a && a < i);
1559
- return c;
1560
- }, s.filter = (a) => Y((i) => {
1561
- if (i >= i) for (; t(i), !a(i); ) i.setTime(i - 1);
1562
- }, (i, o) => {
1563
- if (i >= i)
1564
- if (o < 0) for (; ++o <= 0; )
1565
- for (; e(i, -1), !a(i); )
1566
- ;
1567
- else for (; --o >= 0; )
1568
- for (; e(i, 1), !a(i); )
1569
- ;
1570
- }), n && (s.count = (a, i) => (Yt.setTime(+a), Ut.setTime(+i), t(Yt), t(Ut), Math.floor(n(Yt, Ut))), s.every = (a) => (a = Math.floor(a), !isFinite(a) || !(a > 0) ? null : a > 1 ? s.filter(r ? (i) => r(i) % a === 0 : (i) => s.count(0, i) % a === 0) : s)), s;
1571
- }
1572
- const mt = Y(() => {
1573
- }, (t, e) => {
1574
- t.setTime(+t + e);
1575
- }, (t, e) => e - t);
1576
- mt.every = (t) => (t = Math.floor(t), !isFinite(t) || !(t > 0) ? null : t > 1 ? Y((e) => {
1577
- e.setTime(Math.floor(e / t) * t);
1578
- }, (e, n) => {
1579
- e.setTime(+e + n * t);
1580
- }, (e, n) => (n - e) / t) : mt);
1581
- mt.range;
1582
- const ie = 1e3, X = ie * 60, ae = X * 60, oe = ae * 24, Rn = oe * 7, er = oe * 30, Zt = oe * 365, ke = Y((t) => {
1583
- t.setTime(t - t.getMilliseconds());
1584
- }, (t, e) => {
1585
- t.setTime(+t + e * ie);
1586
- }, (t, e) => (e - t) / ie, (t) => t.getUTCSeconds());
1587
- ke.range;
1588
- const kn = Y((t) => {
1589
- t.setTime(t - t.getMilliseconds() - t.getSeconds() * ie);
1590
- }, (t, e) => {
1591
- t.setTime(+t + e * X);
1592
- }, (t, e) => (e - t) / X, (t) => t.getMinutes());
1593
- kn.range;
1594
- const Yo = Y((t) => {
1595
- t.setUTCSeconds(0, 0);
1596
- }, (t, e) => {
1597
- t.setTime(+t + e * X);
1598
- }, (t, e) => (e - t) / X, (t) => t.getUTCMinutes());
1599
- Yo.range;
1600
- const Dn = Y((t) => {
1601
- t.setTime(t - t.getMilliseconds() - t.getSeconds() * ie - t.getMinutes() * X);
1602
- }, (t, e) => {
1603
- t.setTime(+t + e * ae);
1604
- }, (t, e) => (e - t) / ae, (t) => t.getHours());
1605
- Dn.range;
1606
- const Uo = Y((t) => {
1607
- t.setUTCMinutes(0, 0, 0);
1608
- }, (t, e) => {
1609
- t.setTime(+t + e * ae);
1610
- }, (t, e) => (e - t) / ae, (t) => t.getUTCHours());
1611
- Uo.range;
1612
- const et = Y(
1613
- (t) => t.setHours(0, 0, 0, 0),
1614
- (t, e) => t.setDate(t.getDate() + e),
1615
- (t, e) => (e - t - (e.getTimezoneOffset() - t.getTimezoneOffset()) * X) / oe,
1616
- (t) => t.getDate() - 1
1617
- );
1618
- et.range;
1619
- const Mn = Y((t) => {
1620
- t.setUTCHours(0, 0, 0, 0);
1621
- }, (t, e) => {
1622
- t.setUTCDate(t.getUTCDate() + e);
1623
- }, (t, e) => (e - t) / oe, (t) => t.getUTCDate() - 1);
1624
- Mn.range;
1625
- const Zo = Y((t) => {
1626
- t.setUTCHours(0, 0, 0, 0);
1627
- }, (t, e) => {
1628
- t.setUTCDate(t.getUTCDate() + e);
1629
- }, (t, e) => (e - t) / oe, (t) => Math.floor(t / oe));
1630
- Zo.range;
1631
- function xe(t) {
1632
- return Y((e) => {
1633
- e.setDate(e.getDate() - (e.getDay() + 7 - t) % 7), e.setHours(0, 0, 0, 0);
1634
- }, (e, n) => {
1635
- e.setDate(e.getDate() + n * 7);
1636
- }, (e, n) => (n - e - (n.getTimezoneOffset() - e.getTimezoneOffset()) * X) / Rn);
1637
- }
1638
- const At = xe(0), yt = xe(1), Bo = xe(2), Fo = xe(3), Oe = xe(4), $o = xe(5), qo = xe(6);
1639
- At.range;
1640
- yt.range;
1641
- Bo.range;
1642
- Fo.range;
1643
- Oe.range;
1644
- $o.range;
1645
- qo.range;
1646
- function Se(t) {
1647
- return Y((e) => {
1648
- e.setUTCDate(e.getUTCDate() - (e.getUTCDay() + 7 - t) % 7), e.setUTCHours(0, 0, 0, 0);
1649
- }, (e, n) => {
1650
- e.setUTCDate(e.getUTCDate() + n * 7);
1651
- }, (e, n) => (n - e) / Rn);
1652
- }
1653
- const ns = Se(0), bt = Se(1), Ho = Se(2), jo = Se(3), Ne = Se(4), zo = Se(5), Wo = Se(6);
1654
- ns.range;
1655
- bt.range;
1656
- Ho.range;
1657
- jo.range;
1658
- Ne.range;
1659
- zo.range;
1660
- Wo.range;
1661
- const Pn = Y((t) => {
1662
- t.setDate(1), t.setHours(0, 0, 0, 0);
1663
- }, (t, e) => {
1664
- t.setMonth(t.getMonth() + e);
1665
- }, (t, e) => e.getMonth() - t.getMonth() + (e.getFullYear() - t.getFullYear()) * 12, (t) => t.getMonth());
1666
- Pn.range;
1667
- const Xo = Y((t) => {
1668
- t.setUTCDate(1), t.setUTCHours(0, 0, 0, 0);
1669
- }, (t, e) => {
1670
- t.setUTCMonth(t.getUTCMonth() + e);
1671
- }, (t, e) => e.getUTCMonth() - t.getUTCMonth() + (e.getUTCFullYear() - t.getUTCFullYear()) * 12, (t) => t.getUTCMonth());
1672
- Xo.range;
1673
- const le = Y((t) => {
1674
- t.setMonth(0, 1), t.setHours(0, 0, 0, 0);
1675
- }, (t, e) => {
1676
- t.setFullYear(t.getFullYear() + e);
1677
- }, (t, e) => e.getFullYear() - t.getFullYear(), (t) => t.getFullYear());
1678
- le.every = (t) => !isFinite(t = Math.floor(t)) || !(t > 0) ? null : Y((e) => {
1679
- e.setFullYear(Math.floor(e.getFullYear() / t) * t), e.setMonth(0, 1), e.setHours(0, 0, 0, 0);
1680
- }, (e, n) => {
1681
- e.setFullYear(e.getFullYear() + n * t);
1682
- });
1683
- le.range;
1684
- const be = Y((t) => {
1685
- t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0);
1686
- }, (t, e) => {
1687
- t.setUTCFullYear(t.getUTCFullYear() + e);
1688
- }, (t, e) => e.getUTCFullYear() - t.getUTCFullYear(), (t) => t.getUTCFullYear());
1689
- be.every = (t) => !isFinite(t = Math.floor(t)) || !(t > 0) ? null : Y((e) => {
1690
- e.setUTCFullYear(Math.floor(e.getUTCFullYear() / t) * t), e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0);
1691
- }, (e, n) => {
1692
- e.setUTCFullYear(e.getUTCFullYear() + n * t);
1693
- });
1694
- be.range;
1695
- function Vo(t, e, n, r, s, a) {
1696
- const i = [
1697
- [ke, 1, ie],
1698
- [ke, 5, 5 * ie],
1699
- [ke, 15, 15 * ie],
1700
- [ke, 30, 30 * ie],
1701
- [a, 1, X],
1702
- [a, 5, 5 * X],
1703
- [a, 15, 15 * X],
1704
- [a, 30, 30 * X],
1705
- [s, 1, ae],
1706
- [s, 3, 3 * ae],
1707
- [s, 6, 6 * ae],
1708
- [s, 12, 12 * ae],
1709
- [r, 1, oe],
1710
- [r, 2, 2 * oe],
1711
- [n, 1, Rn],
1712
- [e, 1, er],
1713
- [e, 3, 3 * er],
1714
- [t, 1, Zt]
1715
- ];
1716
- function o(l, u, h) {
1717
- const f = u < l;
1718
- f && ([l, u] = [u, l]);
1719
- const b = h && typeof h.range == "function" ? h : c(l, u, h), v = b ? b.range(l, +u + 1) : [];
1720
- return f ? v.reverse() : v;
1721
- }
1722
- function c(l, u, h) {
1723
- const f = Math.abs(u - l) / h, b = Cn(([, , T]) => T).right(i, f);
1724
- if (b === i.length) return t.every(Gt(l / Zt, u / Zt, h));
1725
- if (b === 0) return mt.every(Math.max(Gt(l, u, h), 1));
1726
- const [v, S] = i[f / i[b - 1][2] < i[b][2] / f ? b - 1 : b];
1727
- return v.every(S);
1728
- }
1729
- return [o, c];
1730
- }
1731
- const [Go, Ko] = Vo(le, Pn, At, et, Dn, kn);
1732
- function Bt(t) {
1733
- if (0 <= t.y && t.y < 100) {
1734
- var e = new Date(-1, t.m, t.d, t.H, t.M, t.S, t.L);
1735
- return e.setFullYear(t.y), e;
1736
- }
1737
- return new Date(t.y, t.m, t.d, t.H, t.M, t.S, t.L);
1738
- }
1739
- function Ft(t) {
1740
- if (0 <= t.y && t.y < 100) {
1741
- var e = new Date(Date.UTC(-1, t.m, t.d, t.H, t.M, t.S, t.L));
1742
- return e.setUTCFullYear(t.y), e;
1743
- }
1744
- return new Date(Date.UTC(t.y, t.m, t.d, t.H, t.M, t.S, t.L));
1745
- }
1746
- function Ye(t, e, n) {
1747
- return { y: t, m: e, d: n, H: 0, M: 0, S: 0, L: 0 };
1748
- }
1749
- function Qo(t) {
1750
- var e = t.dateTime, n = t.date, r = t.time, s = t.periods, a = t.days, i = t.shortDays, o = t.months, c = t.shortMonths, l = Ue(s), u = Ze(s), h = Ue(a), f = Ze(a), b = Ue(i), v = Ze(i), S = Ue(o), T = Ze(o), k = Ue(c), L = Ze(c), D = {
1751
- a: we,
1752
- A: Ce,
1753
- b: J,
1754
- B: Ss,
1755
- c: null,
1756
- d: ar,
1757
- e: ar,
1758
- f: vl,
1759
- g: Ll,
1760
- G: Ol,
1761
- H: bl,
1762
- I: xl,
1763
- j: Sl,
1764
- L: rs,
1765
- m: Tl,
1766
- M: wl,
1767
- p: vs,
1768
- q: Ts,
1769
- Q: cr,
1770
- s: ur,
1771
- S: Cl,
1772
- u: El,
1773
- U: Rl,
1774
- V: kl,
1775
- w: Dl,
1776
- W: Ml,
1777
- x: null,
1778
- X: null,
1779
- y: Pl,
1780
- Y: Al,
1781
- Z: Nl,
1782
- "%": lr
1783
- }, N = {
1784
- a: ws,
1785
- A: Cs,
1786
- b: Es,
1787
- B: Rs,
1788
- c: null,
1789
- d: or,
1790
- e: or,
1791
- f: Ul,
1792
- g: Xl,
1793
- G: Gl,
1794
- H: _l,
1795
- I: Il,
1796
- j: Yl,
1797
- L: is,
1798
- m: Zl,
1799
- M: Bl,
1800
- p: ks,
1801
- q: Ds,
1802
- Q: cr,
1803
- s: ur,
1804
- S: Fl,
1805
- u: $l,
1806
- U: ql,
1807
- V: Hl,
1808
- w: jl,
1809
- W: zl,
1810
- x: null,
1811
- X: null,
1812
- y: Wl,
1813
- Y: Vl,
1814
- Z: Kl,
1815
- "%": lr
1816
- }, _ = {
1817
- a: nt,
1818
- A: R,
1819
- b: se,
1820
- B,
1821
- c: ue,
1822
- d: sr,
1823
- e: sr,
1824
- f: gl,
1825
- g: rr,
1826
- G: nr,
1827
- H: ir,
1828
- I: ir,
1829
- j: ul,
1830
- L: fl,
1831
- m: cl,
1832
- M: hl,
1833
- p: Ie,
1834
- q: ll,
1835
- Q: ml,
1836
- s: yl,
1837
- S: dl,
1838
- u: rl,
1839
- U: sl,
1840
- V: il,
1841
- w: nl,
1842
- W: al,
1843
- x: rt,
1844
- X: Te,
1845
- y: rr,
1846
- Y: nr,
1847
- Z: ol,
1848
- "%": pl
1849
- };
1850
- D.x = w(n, D), D.X = w(r, D), D.c = w(e, D), N.x = w(n, N), N.X = w(r, N), N.c = w(e, N);
1851
- function w(x, E) {
1852
- return function(M) {
1853
- var m = [], F = -1, O = 0, z = x.length, W, ge, Ln;
1854
- for (M instanceof Date || (M = /* @__PURE__ */ new Date(+M)); ++F < z; )
1855
- x.charCodeAt(F) === 37 && (m.push(x.slice(O, F)), (ge = tr[W = x.charAt(++F)]) != null ? W = x.charAt(++F) : ge = W === "e" ? " " : "0", (Ln = E[W]) && (W = Ln(M, ge)), m.push(W), O = F + 1);
1856
- return m.push(x.slice(O, F)), m.join("");
1857
- };
1858
- }
1859
- function I(x, E) {
1860
- return function(M) {
1861
- var m = Ye(1900, void 0, 1), F = ce(m, x, M += "", 0), O, z;
1862
- if (F != M.length) return null;
1863
- if ("Q" in m) return new Date(m.Q);
1864
- if ("s" in m) return new Date(m.s * 1e3 + ("L" in m ? m.L : 0));
1865
- if (E && !("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) {
1866
- if (m.V < 1 || m.V > 53) return null;
1867
- "w" in m || (m.w = 1), "Z" in m ? (O = Ft(Ye(m.y, 0, 1)), z = O.getUTCDay(), O = z > 4 || z === 0 ? bt.ceil(O) : bt(O), O = Mn.offset(O, (m.V - 1) * 7), m.y = O.getUTCFullYear(), m.m = O.getUTCMonth(), m.d = O.getUTCDate() + (m.w + 6) % 7) : (O = Bt(Ye(m.y, 0, 1)), z = O.getDay(), O = z > 4 || z === 0 ? yt.ceil(O) : yt(O), O = et.offset(O, (m.V - 1) * 7), m.y = O.getFullYear(), m.m = O.getMonth(), m.d = O.getDate() + (m.w + 6) % 7);
1868
- } else ("W" in m || "U" in m) && ("w" in m || (m.w = "u" in m ? m.u % 7 : "W" in m ? 1 : 0), z = "Z" in m ? Ft(Ye(m.y, 0, 1)).getUTCDay() : Bt(Ye(m.y, 0, 1)).getDay(), m.m = 0, m.d = "W" in m ? (m.w + 6) % 7 + m.W * 7 - (z + 5) % 7 : m.w + m.U * 7 - (z + 6) % 7);
1869
- return "Z" in m ? (m.H += m.Z / 100 | 0, m.M += m.Z % 100, Ft(m)) : Bt(m);
1870
- };
1871
- }
1872
- function ce(x, E, M, m) {
1873
- for (var F = 0, O = E.length, z = M.length, W, ge; F < O; ) {
1874
- if (m >= z) return -1;
1875
- if (W = E.charCodeAt(F++), W === 37) {
1876
- if (W = E.charAt(F++), ge = _[W in tr ? E.charAt(F++) : W], !ge || (m = ge(x, M, m)) < 0) return -1;
1877
- } else if (W != M.charCodeAt(m++))
1878
- return -1;
1879
- }
1880
- return m;
1881
- }
1882
- function Ie(x, E, M) {
1883
- var m = l.exec(E.slice(M));
1884
- return m ? (x.p = u.get(m[0].toLowerCase()), M + m[0].length) : -1;
1885
- }
1886
- function nt(x, E, M) {
1887
- var m = b.exec(E.slice(M));
1888
- return m ? (x.w = v.get(m[0].toLowerCase()), M + m[0].length) : -1;
1889
- }
1890
- function R(x, E, M) {
1891
- var m = h.exec(E.slice(M));
1892
- return m ? (x.w = f.get(m[0].toLowerCase()), M + m[0].length) : -1;
1893
- }
1894
- function se(x, E, M) {
1895
- var m = k.exec(E.slice(M));
1896
- return m ? (x.m = L.get(m[0].toLowerCase()), M + m[0].length) : -1;
1897
- }
1898
- function B(x, E, M) {
1899
- var m = S.exec(E.slice(M));
1900
- return m ? (x.m = T.get(m[0].toLowerCase()), M + m[0].length) : -1;
1901
- }
1902
- function ue(x, E, M) {
1903
- return ce(x, e, E, M);
1904
- }
1905
- function rt(x, E, M) {
1906
- return ce(x, n, E, M);
1907
- }
1908
- function Te(x, E, M) {
1909
- return ce(x, r, E, M);
1910
- }
1911
- function we(x) {
1912
- return i[x.getDay()];
1913
- }
1914
- function Ce(x) {
1915
- return a[x.getDay()];
1916
- }
1917
- function J(x) {
1918
- return c[x.getMonth()];
1919
- }
1920
- function Ss(x) {
1921
- return o[x.getMonth()];
1922
- }
1923
- function vs(x) {
1924
- return s[+(x.getHours() >= 12)];
1925
- }
1926
- function Ts(x) {
1927
- return 1 + ~~(x.getMonth() / 3);
1928
- }
1929
- function ws(x) {
1930
- return i[x.getUTCDay()];
1931
- }
1932
- function Cs(x) {
1933
- return a[x.getUTCDay()];
1934
- }
1935
- function Es(x) {
1936
- return c[x.getUTCMonth()];
1937
- }
1938
- function Rs(x) {
1939
- return o[x.getUTCMonth()];
1940
- }
1941
- function ks(x) {
1942
- return s[+(x.getUTCHours() >= 12)];
1943
- }
1944
- function Ds(x) {
1945
- return 1 + ~~(x.getUTCMonth() / 3);
1946
- }
1947
- return {
1948
- format: function(x) {
1949
- var E = w(x += "", D);
1950
- return E.toString = function() {
1951
- return x;
1952
- }, E;
1953
- },
1954
- parse: function(x) {
1955
- var E = I(x += "", !1);
1956
- return E.toString = function() {
1957
- return x;
1958
- }, E;
1959
- },
1960
- utcFormat: function(x) {
1961
- var E = w(x += "", N);
1962
- return E.toString = function() {
1963
- return x;
1964
- }, E;
1965
- },
1966
- utcParse: function(x) {
1967
- var E = I(x += "", !0);
1968
- return E.toString = function() {
1969
- return x;
1970
- }, E;
1971
- }
1972
- };
1973
- }
1974
- var tr = { "-": "", _: " ", 0: "0" }, U = /^\s*\d+/, Jo = /^%/, el = /[\\^$*+?|[\]().{}]/g;
1975
- function P(t, e, n) {
1976
- var r = t < 0 ? "-" : "", s = (r ? -t : t) + "", a = s.length;
1977
- return r + (a < n ? new Array(n - a + 1).join(e) + s : s);
1978
- }
1979
- function tl(t) {
1980
- return t.replace(el, "\\$&");
1981
- }
1982
- function Ue(t) {
1983
- return new RegExp("^(?:" + t.map(tl).join("|") + ")", "i");
1984
- }
1985
- function Ze(t) {
1986
- return new Map(t.map((e, n) => [e.toLowerCase(), n]));
1987
- }
1988
- function nl(t, e, n) {
1989
- var r = U.exec(e.slice(n, n + 1));
1990
- return r ? (t.w = +r[0], n + r[0].length) : -1;
1991
- }
1992
- function rl(t, e, n) {
1993
- var r = U.exec(e.slice(n, n + 1));
1994
- return r ? (t.u = +r[0], n + r[0].length) : -1;
1995
- }
1996
- function sl(t, e, n) {
1997
- var r = U.exec(e.slice(n, n + 2));
1998
- return r ? (t.U = +r[0], n + r[0].length) : -1;
1999
- }
2000
- function il(t, e, n) {
2001
- var r = U.exec(e.slice(n, n + 2));
2002
- return r ? (t.V = +r[0], n + r[0].length) : -1;
2003
- }
2004
- function al(t, e, n) {
2005
- var r = U.exec(e.slice(n, n + 2));
2006
- return r ? (t.W = +r[0], n + r[0].length) : -1;
2007
- }
2008
- function nr(t, e, n) {
2009
- var r = U.exec(e.slice(n, n + 4));
2010
- return r ? (t.y = +r[0], n + r[0].length) : -1;
2011
- }
2012
- function rr(t, e, n) {
2013
- var r = U.exec(e.slice(n, n + 2));
2014
- return r ? (t.y = +r[0] + (+r[0] > 68 ? 1900 : 2e3), n + r[0].length) : -1;
2015
- }
2016
- function ol(t, e, n) {
2017
- var r = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n, n + 6));
2018
- return r ? (t.Z = r[1] ? 0 : -(r[2] + (r[3] || "00")), n + r[0].length) : -1;
2019
- }
2020
- function ll(t, e, n) {
2021
- var r = U.exec(e.slice(n, n + 1));
2022
- return r ? (t.q = r[0] * 3 - 3, n + r[0].length) : -1;
2023
- }
2024
- function cl(t, e, n) {
2025
- var r = U.exec(e.slice(n, n + 2));
2026
- return r ? (t.m = r[0] - 1, n + r[0].length) : -1;
2027
- }
2028
- function sr(t, e, n) {
2029
- var r = U.exec(e.slice(n, n + 2));
2030
- return r ? (t.d = +r[0], n + r[0].length) : -1;
2031
- }
2032
- function ul(t, e, n) {
2033
- var r = U.exec(e.slice(n, n + 3));
2034
- return r ? (t.m = 0, t.d = +r[0], n + r[0].length) : -1;
2035
- }
2036
- function ir(t, e, n) {
2037
- var r = U.exec(e.slice(n, n + 2));
2038
- return r ? (t.H = +r[0], n + r[0].length) : -1;
2039
- }
2040
- function hl(t, e, n) {
2041
- var r = U.exec(e.slice(n, n + 2));
2042
- return r ? (t.M = +r[0], n + r[0].length) : -1;
2043
- }
2044
- function dl(t, e, n) {
2045
- var r = U.exec(e.slice(n, n + 2));
2046
- return r ? (t.S = +r[0], n + r[0].length) : -1;
2047
- }
2048
- function fl(t, e, n) {
2049
- var r = U.exec(e.slice(n, n + 3));
2050
- return r ? (t.L = +r[0], n + r[0].length) : -1;
2051
- }
2052
- function gl(t, e, n) {
2053
- var r = U.exec(e.slice(n, n + 6));
2054
- return r ? (t.L = Math.floor(r[0] / 1e3), n + r[0].length) : -1;
2055
- }
2056
- function pl(t, e, n) {
2057
- var r = Jo.exec(e.slice(n, n + 1));
2058
- return r ? n + r[0].length : -1;
2059
- }
2060
- function ml(t, e, n) {
2061
- var r = U.exec(e.slice(n));
2062
- return r ? (t.Q = +r[0], n + r[0].length) : -1;
2063
- }
2064
- function yl(t, e, n) {
2065
- var r = U.exec(e.slice(n));
2066
- return r ? (t.s = +r[0], n + r[0].length) : -1;
2067
- }
2068
- function ar(t, e) {
2069
- return P(t.getDate(), e, 2);
2070
- }
2071
- function bl(t, e) {
2072
- return P(t.getHours(), e, 2);
2073
- }
2074
- function xl(t, e) {
2075
- return P(t.getHours() % 12 || 12, e, 2);
2076
- }
2077
- function Sl(t, e) {
2078
- return P(1 + et.count(le(t), t), e, 3);
2079
- }
2080
- function rs(t, e) {
2081
- return P(t.getMilliseconds(), e, 3);
2082
- }
2083
- function vl(t, e) {
2084
- return rs(t, e) + "000";
2085
- }
2086
- function Tl(t, e) {
2087
- return P(t.getMonth() + 1, e, 2);
2088
- }
2089
- function wl(t, e) {
2090
- return P(t.getMinutes(), e, 2);
2091
- }
2092
- function Cl(t, e) {
2093
- return P(t.getSeconds(), e, 2);
2094
- }
2095
- function El(t) {
2096
- var e = t.getDay();
2097
- return e === 0 ? 7 : e;
2098
- }
2099
- function Rl(t, e) {
2100
- return P(At.count(le(t) - 1, t), e, 2);
2101
- }
2102
- function ss(t) {
2103
- var e = t.getDay();
2104
- return e >= 4 || e === 0 ? Oe(t) : Oe.ceil(t);
2105
- }
2106
- function kl(t, e) {
2107
- return t = ss(t), P(Oe.count(le(t), t) + (le(t).getDay() === 4), e, 2);
2108
- }
2109
- function Dl(t) {
2110
- return t.getDay();
2111
- }
2112
- function Ml(t, e) {
2113
- return P(yt.count(le(t) - 1, t), e, 2);
2114
- }
2115
- function Pl(t, e) {
2116
- return P(t.getFullYear() % 100, e, 2);
2117
- }
2118
- function Ll(t, e) {
2119
- return t = ss(t), P(t.getFullYear() % 100, e, 2);
2120
- }
2121
- function Al(t, e) {
2122
- return P(t.getFullYear() % 1e4, e, 4);
2123
- }
2124
- function Ol(t, e) {
2125
- var n = t.getDay();
2126
- return t = n >= 4 || n === 0 ? Oe(t) : Oe.ceil(t), P(t.getFullYear() % 1e4, e, 4);
2127
- }
2128
- function Nl(t) {
2129
- var e = t.getTimezoneOffset();
2130
- return (e > 0 ? "-" : (e *= -1, "+")) + P(e / 60 | 0, "0", 2) + P(e % 60, "0", 2);
2131
- }
2132
- function or(t, e) {
2133
- return P(t.getUTCDate(), e, 2);
2134
- }
2135
- function _l(t, e) {
2136
- return P(t.getUTCHours(), e, 2);
2137
- }
2138
- function Il(t, e) {
2139
- return P(t.getUTCHours() % 12 || 12, e, 2);
2140
- }
2141
- function Yl(t, e) {
2142
- return P(1 + Mn.count(be(t), t), e, 3);
2143
- }
2144
- function is(t, e) {
2145
- return P(t.getUTCMilliseconds(), e, 3);
2146
- }
2147
- function Ul(t, e) {
2148
- return is(t, e) + "000";
2149
- }
2150
- function Zl(t, e) {
2151
- return P(t.getUTCMonth() + 1, e, 2);
2152
- }
2153
- function Bl(t, e) {
2154
- return P(t.getUTCMinutes(), e, 2);
2155
- }
2156
- function Fl(t, e) {
2157
- return P(t.getUTCSeconds(), e, 2);
2158
- }
2159
- function $l(t) {
2160
- var e = t.getUTCDay();
2161
- return e === 0 ? 7 : e;
2162
- }
2163
- function ql(t, e) {
2164
- return P(ns.count(be(t) - 1, t), e, 2);
2165
- }
2166
- function as(t) {
2167
- var e = t.getUTCDay();
2168
- return e >= 4 || e === 0 ? Ne(t) : Ne.ceil(t);
2169
- }
2170
- function Hl(t, e) {
2171
- return t = as(t), P(Ne.count(be(t), t) + (be(t).getUTCDay() === 4), e, 2);
2172
- }
2173
- function jl(t) {
2174
- return t.getUTCDay();
2175
- }
2176
- function zl(t, e) {
2177
- return P(bt.count(be(t) - 1, t), e, 2);
2178
- }
2179
- function Wl(t, e) {
2180
- return P(t.getUTCFullYear() % 100, e, 2);
2181
- }
2182
- function Xl(t, e) {
2183
- return t = as(t), P(t.getUTCFullYear() % 100, e, 2);
2184
- }
2185
- function Vl(t, e) {
2186
- return P(t.getUTCFullYear() % 1e4, e, 4);
2187
- }
2188
- function Gl(t, e) {
2189
- var n = t.getUTCDay();
2190
- return t = n >= 4 || n === 0 ? Ne(t) : Ne.ceil(t), P(t.getUTCFullYear() % 1e4, e, 4);
2191
- }
2192
- function Kl() {
2193
- return "+0000";
2194
- }
2195
- function lr() {
2196
- return "%";
2197
- }
2198
- function cr(t) {
2199
- return +t;
2200
- }
2201
- function ur(t) {
2202
- return Math.floor(+t / 1e3);
2203
- }
2204
- var Ee, os;
2205
- Ql({
2206
- dateTime: "%x, %X",
2207
- date: "%-m/%-d/%Y",
2208
- time: "%-I:%M:%S %p",
2209
- periods: ["AM", "PM"],
2210
- days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
2211
- shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
2212
- months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
2213
- shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
2214
- });
2215
- function Ql(t) {
2216
- return Ee = Qo(t), os = Ee.format, Ee.parse, Ee.utcFormat, Ee.utcParse, Ee;
2217
- }
2218
- function Jl(t) {
2219
- return new Date(t);
2220
- }
2221
- function ec(t) {
2222
- return t instanceof Date ? +t : +/* @__PURE__ */ new Date(+t);
2223
- }
2224
- function ls(t, e, n, r, s, a, i, o, c, l) {
2225
- var u = Kr(), h = u.invert, f = u.domain, b = l(".%L"), v = l(":%S"), S = l("%I:%M"), T = l("%I %p"), k = l("%a %d"), L = l("%b %d"), D = l("%B"), N = l("%Y");
2226
- function _(w) {
2227
- return (c(w) < w ? b : o(w) < w ? v : i(w) < w ? S : a(w) < w ? T : r(w) < w ? s(w) < w ? k : L : n(w) < w ? D : N)(w);
2228
- }
2229
- return u.invert = function(w) {
2230
- return new Date(h(w));
2231
- }, u.domain = function(w) {
2232
- return arguments.length ? f(Array.from(w, ec)) : f().map(Jl);
2233
- }, u.ticks = function(w) {
2234
- var I = f();
2235
- return t(I[0], I[I.length - 1], w ?? 10);
2236
- }, u.tickFormat = function(w, I) {
2237
- return I == null ? _ : l(I);
2238
- }, u.nice = function(w) {
2239
- var I = f();
2240
- return (!w || typeof w.range != "function") && (w = e(I[0], I[I.length - 1], w ?? 10)), w ? f(Io(I, w)) : u;
2241
- }, u.copy = function() {
2242
- return Gr(u, ls(t, e, n, r, s, a, i, o, c, l));
2243
- }, u;
2244
- }
2245
- function tc() {
2246
- return Vr.apply(ls(Go, Ko, le, Pn, At, et, Dn, kn, ke, os).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
2247
- }
2248
- const hr = [
2249
- C.NANOSECOND,
2250
- // 1ns
2251
- C.nanoseconds(2),
2252
- // 2ns
2253
- C.nanoseconds(5),
2254
- // 5ns
2255
- C.nanoseconds(10),
2256
- // 10ns
2257
- C.nanoseconds(20),
2258
- // 20ns
2259
- C.nanoseconds(50),
2260
- // 50ns
2261
- C.nanoseconds(100),
2262
- // 100ns
2263
- C.nanoseconds(200),
2264
- // 200ns
2265
- C.nanoseconds(500),
2266
- // 500ns
2267
- C.MICROSECOND,
2268
- // 1µs
2269
- C.microseconds(2),
2270
- // 2µs
2271
- C.microseconds(5),
2272
- // 5µs
2273
- C.microseconds(10),
2274
- // 10µs
2275
- C.microseconds(20),
2276
- // 20µs
2277
- C.microseconds(50),
2278
- // 50µs
2279
- C.microseconds(100),
2280
- // 100µs
2281
- C.microseconds(200),
2282
- // 200µs
2283
- C.microseconds(500),
2284
- // 500µs
2285
- C.MILLISECOND,
2286
- // 1ms
2287
- C.milliseconds(2),
2288
- // 2ms
2289
- C.milliseconds(5),
2290
- // 5ms
2291
- C.milliseconds(10),
2292
- // 10ms
2293
- C.milliseconds(20),
2294
- // 20ms
2295
- C.milliseconds(50),
2296
- // 50ms
2297
- C.milliseconds(100),
2298
- // 100ms
2299
- C.milliseconds(200),
2300
- // 200ms
2301
- C.milliseconds(500),
2302
- // 500ms
2303
- C.SECOND
2304
- // 1s
2305
- ];
2306
- class nc {
2307
- _domain;
2308
- _range;
2309
- _span;
2310
- /**
2311
- * Creates a new PreciseTimeScale instance with default domain [0, 1] and range [0, 1].
2312
- */
2313
- constructor() {
2314
- this._domain = [new $(0n), new $(1n)], this._range = [0, 1], this._span = this._domain[1].span(this._domain[0]);
2315
- }
2316
- domain(e) {
2317
- return e === void 0 ? this._domain : (this._domain = [new $(e[0]), new $(e[1])], this._span = this._domain[1].span(this._domain[0]), this);
2318
- }
2319
- range(e) {
2320
- return e === void 0 ? this._range : (this._range = e, this);
2321
- }
2322
- /**
2323
- * Scales a timestamp to its corresponding position in the range.
2324
- *
2325
- * @param value - The timestamp to scale
2326
- * @returns The scaled numeric value within the range
2327
- */
2328
- scale(e) {
2329
- const r = new $(e).valueOf(), s = this._domain[0].valueOf(), a = this._domain[1].valueOf() - s, i = this._range[1] - this._range[0];
2330
- return Number(r - s) / Number(a) * i + this._range[0];
2331
- }
2332
- /**
2333
- * Generates an array of evenly spaced tick marks within the domain.
2334
- * The ticks are automatically adjusted to use human-friendly time intervals.
2335
- *
2336
- * @param count - Desired number of ticks (actual count may differ to maintain nice intervals)
2337
- * @returns Array of timestamps representing tick positions
2338
- */
2339
- ticks(e) {
2340
- const n = this.calculateOptimalStep(e).valueOf(), r = this._domain[0].valueOf(), s = this._domain[1].valueOf(), a = (r + n - 1n) / n * n, i = Number((s - a) / n);
2341
- return Array.from({ length: i + 1 }, (o, c) => {
2342
- const l = a + BigInt(c) * n;
2343
- return new $(l);
2344
- }).filter((o) => o.afterEq(this._domain[0]) && o.beforeEq(this._domain[1]));
2345
- }
2346
- /**
2347
- * Calculates the optimal step size for tick generation based on the desired tick count.
2348
- * Uses predefined steps from TIME_SCALE_STEPS to ensure human-readable intervals.
2349
- *
2350
- * @param targetCount - Desired number of ticks
2351
- * @returns The optimal TimeSpan step size
2352
- */
2353
- calculateOptimalStep(e) {
2354
- const n = this._span.valueOf() / BigInt(Math.ceil(e));
2355
- let r = hr[0];
2356
- for (const s of hr) {
2357
- if (s.valueOf() > n) break;
2358
- r = s;
2359
- }
2360
- return r;
2361
- }
2362
- /**
2363
- * Formats a timestamp for display on tick marks.
2364
- * Automatically adjusts the format based on the current time scale:
2365
- * - For spans < 50µs: displays microseconds
2366
- * - For spans >= 50µs: displays milliseconds
2367
- *
2368
- * @param value - The timestamp to format
2369
- * @returns Formatted string representation of the timestamp
2370
- */
2371
- formatTick(e) {
2372
- return this._span.lessThan(C.microseconds(50)) ? `${e.remainder(C.MILLISECOND).microseconds.toString()}µs` : `${e.remainder(C.SECOND).milliseconds.toString()}ms`;
2373
- }
2374
- }
2375
- const rc = () => new nc(), cs = p.enum(["linear", "time"]), us = p.object({
2376
- tickSpacing: p.number().default(75),
2377
- type: cs.optional().default("linear")
2378
- }), dr = (t) => {
2379
- const e = us.parse(t);
2380
- return ac[e.type](e);
2381
- };
2382
- class sc {
2383
- props;
2384
- prevScaleSize;
2385
- prevDomain;
2386
- currTicks;
2387
- normalScale;
2388
- preciseScale;
2389
- constructor(e) {
2390
- this.props = e, this.normalScale = tc(), this.preciseScale = rc(), this.prevScaleSize = 0, this.prevDomain = new qe(new $(0), new $(0)), this.currTicks = [];
2391
- }
2392
- create({ decimalToDataScale: e, size: n }) {
2393
- const r = new qe(
2394
- new $(e.pos(0)),
2395
- new $(e.pos(1))
2396
- );
2397
- if (this.prevDomain.equals(r) && this.prevScaleSize === n)
2398
- return this.currTicks;
2399
- if (this.prevDomain = r, this.prevScaleSize !== n) {
2400
- const s = [0, n];
2401
- this.preciseScale.range(s), this.normalScale.range(s), this.prevScaleSize = n;
2402
- }
2403
- if (r.span.milliseconds < 5) {
2404
- this.preciseScale.domain([r.start, r.end]);
2405
- const s = Qt(n, this.props.tickSpacing) / 2, a = this.preciseScale.ticks(s);
2406
- this.currTicks = a.map((i) => ({
2407
- label: this.preciseScale.formatTick(i),
2408
- position: this.preciseScale.scale(i)
2409
- }));
2410
- } else {
2411
- this.normalScale.domain([r.start.date(), r.end.date()]);
2412
- const s = this.normalScale.ticks(Qt(n, this.props.tickSpacing));
2413
- this.currTicks = s.map((a) => ({
2414
- label: this.normalTickLabel(a),
2415
- position: this.normalScale(a)
2416
- }));
2417
- }
2418
- return this.currTicks;
2419
- }
2420
- normalTickLabel(e) {
2421
- let n = `:${e.getSeconds()}`;
2422
- const r = e.getMilliseconds();
2423
- if (r !== 0) {
2424
- const s = Math.round(e.getMilliseconds()).toString().padStart(3, "0").replace(/0+$/, "");
2425
- n += `.${s}`;
2426
- }
2427
- return e.getSeconds() === 0 && r === 0 && (n = `${e.getHours()}:${e.getMinutes().toString().padStart(2, "0")}`), n;
2428
- }
2429
- }
2430
- class ic {
2431
- props;
2432
- prevDomain;
2433
- prevScaleSize;
2434
- currTicks;
2435
- d3Scale;
2436
- constructor(e) {
2437
- this.props = e, this.prevDomain = A.construct(0, 0), this.prevScaleSize = 0, this.currTicks = [], this.d3Scale = ts();
2438
- }
2439
- create({ decimalToDataScale: e, size: n }) {
2440
- const r = { lower: e.pos(0), upper: e.pos(1) };
2441
- if (A.equals(this.prevDomain, r) && this.prevScaleSize === n)
2442
- return this.currTicks;
2443
- A.equals(this.prevDomain, r) || (this.d3Scale = this.d3Scale.domain([r.lower, r.upper])), this.prevScaleSize !== n && (this.d3Scale = this.d3Scale.range([0, n])), this.prevDomain = r, this.prevScaleSize = n;
2444
- const s = Qt(n, this.props.tickSpacing), a = this.d3Scale.ticks(s);
2445
- return this.currTicks = a.map((i) => ({
2446
- label: this.tickLabel(i),
2447
- position: this.d3Scale(i)
2448
- })), this.currTicks;
2449
- }
2450
- tickLabel(e) {
2451
- return e.toString();
2452
- }
2453
- }
2454
- const Qt = (t, e) => {
2455
- const n = Math.floor(t / e);
2456
- return n > 0 ? n : 1;
2457
- }, ac = {
2458
- linear: (t) => new ic(t),
2459
- time: (t) => new sc(t)
2460
- }, hs = us.extend({
2461
- color: y.colorZ,
2462
- type: cs.optional().default("linear"),
2463
- font: p.string(),
2464
- showGrid: p.boolean().optional().default(!0),
2465
- location: K.outer,
2466
- gridColor: y.colorZ
2467
- }), Q = 5, We = 6, tt = { useAtlas: !0 }, oc = {
2468
- bottom: (t, e) => new cc(t, e),
2469
- top: (t, e) => new uc(t, e),
2470
- left: (t, e) => new hc(t, e),
2471
- right: (t, e) => new dc(t, e)
2472
- }, lc = (t, e, n) => oc[t](e, n);
2473
- class _e {
2474
- renderCtx;
2475
- state;
2476
- tickFactory;
2477
- constructor(e, n) {
2478
- this.renderCtx = e, this.state = n, this.tickFactory = dr(this.state);
2479
- }
2480
- setState(e) {
2481
- this.state = na(hs, e), this.tickFactory = dr(e);
2482
- }
2483
- drawLine(e, n) {
2484
- const { lower2d: r } = this.renderCtx;
2485
- r.moveTo(...d.couple(e)), r.lineTo(...d.couple(n));
2486
- }
2487
- drawTicks(e, n) {
2488
- let r = Nn.ZERO;
2489
- return e.forEach((s) => {
2490
- const a = this.renderCtx.lower2d.textDimensions(s.label, tt);
2491
- r = Nn.max([r, a]), n(a, s);
2492
- }), r;
2493
- }
2494
- static START_BOUND = A.construct(-1, 1);
2495
- maybeDrawGrid(e, n, r) {
2496
- const { showGrid: s, gridColor: a } = this.state;
2497
- if (s) {
2498
- const i = _e.START_BOUND, o = A.construct(e - 1, e + 1), { lower2d: c } = this.renderCtx;
2499
- c.beginPath(), c.strokeStyle = y.hex(a), n.forEach((l) => {
2500
- A.contains(i, l.position) || A.contains(o, l.position) || this.drawLine(...r(l));
2501
- }), c.stroke();
2502
- }
2503
- }
2504
- setColor(e) {
2505
- const n = y.hex(e);
2506
- this.renderCtx.lower2d.strokeStyle = n, this.renderCtx.lower2d.fillStyle = n, this.renderCtx.lower2d.font = this.state.font;
2507
- }
2508
- }
2509
- class cc extends _e {
2510
- render(e) {
2511
- const { lower2d: n } = this.renderCtx, { plot: r, position: s } = e, { width: a, height: i } = g.dims(r), o = this.tickFactory.create({ ...e, size: a });
2512
- n.beginPath(), this.setColor(this.state.color), this.drawLine(s, d.translate(s, "x", a));
2513
- const c = this.drawTicks(o, (l, u) => {
2514
- this.drawLine(
2515
- d.translateX(s, u.position),
2516
- d.translate(s, { x: u.position, y: Q })
2517
- ), n.fillText(
2518
- u.label,
2519
- s.x + u.position - l.width / 2,
2520
- s.y + Q + l.height + We,
2521
- void 0,
2522
- tt
2523
- );
2524
- });
2525
- return n.stroke(), this.maybeDrawGrid(a, o, (l) => [
2526
- d.translate(s, "x", l.position),
2527
- d.translate(s, { x: l.position, y: -i })
2528
- ]), { size: c.height + Q + We };
2529
- }
2530
- }
2531
- class uc extends _e {
2532
- render(e) {
2533
- const { lower2d: n } = this.renderCtx, { plot: r } = e, { width: s, height: a } = g.dims(r), i = d.translate(e.position, "y", e.size), o = this.tickFactory.create({ ...e, size: s });
2534
- n.beginPath(), this.setColor(this.state.color), this.drawLine(i, d.translate(i, "x", s));
2535
- const c = this.drawTicks(o, (l, u) => {
2536
- this.drawLine(
2537
- d.translateX(i, u.position),
2538
- d.translate(i, { x: u.position, y: -Q })
2539
- ), n.fillText(
2540
- u.label,
2541
- i.x + u.position - l.width / 2,
2542
- i.y - Q - l.height - We,
2543
- void 0,
2544
- tt
2545
- );
2546
- });
2547
- return n.stroke(), this.maybeDrawGrid(s, o, (l) => [
2548
- d.translate(i, "x", l.position),
2549
- d.translate(i, { x: l.position, y: a })
2550
- ]), { size: c.height + Q };
2551
- }
2552
- }
2553
- class hc extends _e {
2554
- render(e) {
2555
- const { lower2d: n } = this.renderCtx, { plot: r, position: s } = e, { height: a, width: i } = g.dims(r), o = d.translate(s, "x", e.size), c = this.tickFactory.create({ ...e, size: a });
2556
- n.beginPath(), this.setColor(this.state.color), this.drawLine(o, d.translate(o, "y", a));
2557
- const l = this.drawTicks(c, (u, h) => {
2558
- this.drawLine(
2559
- d.translateY(o, h.position),
2560
- d.translate(o, { x: -Q, y: h.position })
2561
- ), n.fillText(
2562
- h.label,
2563
- o.x - u.width - Q * 2,
2564
- o.y + h.position + u.height / 2,
2565
- void 0,
2566
- tt
2567
- );
2568
- });
2569
- return n.stroke(), this.maybeDrawGrid(a, c, (u) => [
2570
- d.translate(o, "y", u.position),
2571
- d.translate(o, { x: i, y: u.position })
2572
- ]), { size: l.width + Q * 2 };
2573
- }
2574
- }
2575
- class dc extends _e {
2576
- render(e) {
2577
- const { lower2d: n } = this.renderCtx, { plot: r, position: s } = e, { height: a, width: i } = g.dims(r), o = this.tickFactory.create({ ...e, size: a });
2578
- n.beginPath(), this.setColor(this.state.color), this.drawLine(s, d.translateY(s, a));
2579
- const c = this.drawTicks(o, (l, u) => {
2580
- this.drawLine(
2581
- d.translateY(s, u.position),
2582
- d.translate(s, { x: Q, y: u.position })
2583
- ), n.fillText(
2584
- u.label,
2585
- s.x + Q + We,
2586
- s.y + u.position + l.height / 2,
2587
- void 0,
2588
- tt
2589
- );
2590
- });
2591
- return n.stroke(), this.maybeDrawGrid(a, o, (l) => [
2592
- d.translateY(s, l.position),
2593
- d.translate(s, { x: -i, y: l.position })
2594
- ]), { size: c.width + Q + We };
2595
- }
2596
- }
2597
- const ds = p.object({
2598
- key: p.string(),
2599
- size: p.number(),
2600
- order: p.number(),
2601
- loc: K.outer
2602
- });
2603
- p.record(p.string(), ds);
2604
- const De = (t, e) => Object.values(e).filter(({ loc: n }) => n === t).sort((n, r) => r.order - n.order), fc = (t, e, n) => {
2605
- const r = e[t];
2606
- if (r == null) return d.ZERO;
2607
- const s = K.construct(r.loc), a = De(s, e), i = K.construct(te.swap(K.direction(s))), o = De(i, e), c = a.findIndex(({ key: h }) => h === t), l = a.slice(0, c).reduce((h, { size: f }) => h + f, 0), u = o.reduce((h, { size: f }) => h + f, 0);
2608
- switch (s) {
2609
- case "left":
2610
- return d.translate(g.topLeft(n), [l, u]);
2611
- case "right":
2612
- return d.translate(g.topRight(n), [l - r.size, u]);
2613
- case "top":
2614
- return d.translate(g.topLeft(n), [u, l]);
2615
- default:
2616
- return d.translate(g.bottomLeft(n), [
2617
- u,
2618
- -l - r.size
2619
- ]);
2620
- }
2621
- }, gc = (t, e) => {
2622
- const n = De("left", t), r = De("right", t), s = De("top", t), a = De("bottom", t), i = n.reduce((u, { size: h }) => u + h, 0), o = r.reduce((u, { size: h }) => u + h, 0), c = s.reduce((u, { size: h }) => u + h, 0), l = a.reduce((u, { size: h }) => u + h, 0);
2623
- return g.construct(
2624
- d.translate(g.topLeft(e), { x: i, y: c }),
2625
- g.width(e) - i - o,
2626
- g.height(e) - c - l
2627
- );
2628
- }, Ot = hs.extend({
2629
- axisKey: p.string().optional(),
2630
- bounds: A.bounds.optional(),
2631
- autoBounds: p.object({
2632
- lower: p.boolean().optional().default(!0),
2633
- upper: p.boolean().optional().default(!0)
2634
- }).or(p.boolean().optional().default(!0)),
2635
- autoBoundPadding: p.number().optional(),
2636
- autoBoundUpdateInterval: C.z.optional().default(C.seconds(10)),
2637
- size: p.number().optional().default(0),
2638
- label: p.string().optional().default(""),
2639
- labelSize: p.number().optional().default(0)
2640
- }).partial({ color: !0, font: !0, gridColor: !0 }), pc = 2, mc = 7, yc = (t, e) => A.contains(
2641
- {
2642
- lower: t - mc,
2643
- upper: t + pc
2644
- },
2645
- e
2646
- ), bc = A.DECIMAL, fr = $.now(), xc = {
2647
- lower: Number(fr.valueOf()),
2648
- upper: Number(fr.add(C.HOUR).valueOf())
2649
- }, fs = (t) => t === "linear" ? bc : xc, Sc = (t, e = 0.1, n) => {
2650
- const r = A.max(t.filter(A.isFinite));
2651
- if (!A.isFinite(r)) return fs(n);
2652
- const { lower: s, upper: a } = r;
2653
- if (a === s) return { lower: s - 1, upper: a + 1 };
2654
- const i = (a - s) * e;
2655
- return { lower: s - i, upper: a + i };
2656
- }, vc = 0.01, Tc = 0.1;
2657
- class gs extends fe {
2658
- afterUpdate(e) {
2659
- const { internal: n } = this, { location: r, autoBoundUpdateInterval: s } = this.state;
2660
- n.render = j.use(e);
2661
- const a = re(e), i = te.construct(r);
2662
- this.state.autoBoundPadding ??= i === "x" ? Tc : vc, n.core = lc(r, n.render, {
2663
- color: a.colors.gray.l10,
2664
- font: Fe(a, { level: "small", code: !0 }),
2665
- gridColor: a.colors.gray.l1,
2666
- ...this.state
2667
- }), de(e, "layout"), n.updateBounds ??= ra(
2668
- (o) => this.setState((c) => ({ ...c, bounds: o })),
2669
- s.milliseconds
2670
- );
2671
- }
2672
- afterDelete(e) {
2673
- de(e, "layout");
2674
- }
2675
- renderAxis(e, n) {
2676
- if (!e.canvases.includes("lower2d")) return;
2677
- const { core: r } = this.internal, { grid: s, container: a } = e, i = fc(`${this.type}-${this.key}`, s, a), o = {
2678
- ...e,
2679
- position: i,
2680
- decimalToDataScale: n,
2681
- size: this.state.size + this.state.labelSize
2682
- }, { size: c } = r.render(o);
2683
- yc(this.state.size, c) || this.setState((l) => ({ ...l, size: c }));
2684
- }
2685
- iBounds(e, n) {
2686
- if (e && this.internal.boundSnapshot != null)
2687
- return [this.internal.boundSnapshot, null];
2688
- const { lower: r, upper: s } = wc(this.state.autoBounds);
2689
- if (!r && !s && this.state.bounds != null)
2690
- return this.internal.boundSnapshot = this.state.bounds, [this.state.bounds, null];
2691
- const a = (l) => ({
2692
- upper: s || this.state.bounds == null ? l.upper : this.state.bounds.upper,
2693
- lower: r || this.state.bounds == null ? l.lower : this.state.bounds.lower
2694
- });
2695
- let i, o = null;
2696
- try {
2697
- const l = n();
2698
- i = Sc(l, this.state.autoBoundPadding, this.state.type);
2699
- } catch (l) {
2700
- i = fs(this.state.type), o = l;
2701
- }
2702
- const c = a(i);
2703
- return this.internal.boundSnapshot = c, (this.state.bounds == null || r && this.state.bounds.lower !== c.lower || s && this.state.bounds.upper !== c.upper) && this.internal.updateBounds?.(c), [c, o];
2704
- }
2705
- dataToDecimalScale(e, n, r) {
2706
- const [s, a] = this.iBounds(e, n), i = te.swap(te.construct(this.state.location));
2707
- return [
2708
- G.Scale.scale(s).scale(1).translate(-g.root(r)[i]).magnify(1 / g.dim(r, i)),
2709
- a
2710
- ];
2711
- }
2712
- }
2713
- const wc = (t) => typeof t == "boolean" ? { lower: t, upper: t } : { lower: t?.lower ?? !0, upper: t?.upper ?? !0 };
2714
- class ve {
2715
- canvas;
2716
- theme;
2717
- constructor(e, n) {
2718
- this.canvas = e, this.theme = n;
2719
- }
2720
- rule({ direction: e, region: n, position: r, ...s }) {
2721
- return e === "x" ? this.line({
2722
- start: d.construct(g.left(n), r),
2723
- end: d.construct(g.right(n), r),
2724
- ...s
2725
- }) : this.line({
2726
- start: d.construct(r, g.top(n)),
2727
- end: d.construct(r, g.bottom(n)),
2728
- ...s
2729
- });
2730
- }
2731
- line({ stroke: e, lineWidth: n, lineDash: r, start: s, end: a }) {
2732
- const i = this.canvas;
2733
- i.strokeStyle = y.hex(e), i.lineWidth = n, i.setLineDash([r]), i.beginPath(), i.moveTo(...d.couple(s)), i.lineTo(...d.couple(a)), i.stroke();
2734
- }
2735
- circle({
2736
- fill: e,
2737
- stroke: n,
2738
- strokeWidth: r,
2739
- radius: s,
2740
- position: a,
2741
- angle: i,
2742
- lineCap: o
2743
- }) {
2744
- const c = this.canvas;
2745
- c.beginPath();
2746
- const l = i?.lower ?? 0, u = i?.upper ?? 2 * Math.PI;
2747
- if (n != null && typeof s == "object") {
2748
- const { inner: h, outer: f } = s, b = (h + f) / 2, v = f - h;
2749
- c.arc(...d.couple(a), b, l, u, !1), c.strokeStyle = y.hex(n), c.lineWidth = r ?? v, o && (c.lineCap = o), c.stroke();
2750
- } else if (e != null)
2751
- if (c.fillStyle = y.hex(e), typeof s == "number")
2752
- c.arc(...d.couple(a), s, l, u), c.fill();
2753
- else {
2754
- const { inner: h, outer: f } = s;
2755
- c.arc(...d.couple(a), f, l, u, !1);
2756
- const b = a.x + h * Math.cos(u), v = a.y + h * Math.sin(u);
2757
- c.lineTo(b, v), c.arc(...d.couple(a), h, u, l, !0), c.closePath(), c.fill();
2758
- }
2759
- }
2760
- resolveColor(e, n) {
2761
- return e == null ? n == null ? this.theme.colors.text : this.resolveColor(n) : typeof e == "function" ? e(this.theme) : y.construct(e);
2762
- }
2763
- border({
2764
- region: e,
2765
- color: n,
2766
- width: r,
2767
- radius: s,
2768
- location: a
2769
- }) {
2770
- const i = this.canvas;
2771
- i.strokeStyle = y.hex(this.resolveColor(n, this.theme.colors.border)), i.lineWidth = r ?? this.theme.sizes.border.width, s ??= this.theme.sizes.border.radius, a == null || a === !0 ? s > 0 ? (i.roundRect(
2772
- ...d.couple(g.topLeft(e)),
2773
- ...d.couple(g.dims(e)),
2774
- s
2775
- ), i.stroke()) : (i.rect(...d.couple(g.topLeft(e)), ...d.couple(g.dims(e))), i.stroke()) : Zr.toArray(a).forEach((o) => {
2776
- const [c, l] = g.edgePoints(e, o);
2777
- i.beginPath(), i.moveTo(...d.couple(c)), i.lineTo(...d.couple(l)), i.stroke();
2778
- });
2779
- }
2780
- container({
2781
- region: e,
2782
- bordered: n = !0,
2783
- rounded: r = !0,
2784
- borderColor: s,
2785
- borderRadius: a,
2786
- borderWidth: i,
2787
- backgroundColor: o
2788
- }) {
2789
- a ??= this.theme.sizes.border.radius, i ??= 1;
2790
- const c = this.canvas;
2791
- c.fillStyle = y.hex(
2792
- this.resolveColor(o, this.theme.colors.gray.l1)
2793
- ), c.strokeStyle = y.hex(
2794
- this.resolveColor(s, this.theme.colors.border)
2795
- ), c.setLineDash([]), c.lineWidth = 1, c.beginPath(), r ? c.roundRect(
2796
- ...d.couple(g.topLeft(e)),
2797
- ...d.couple(g.dims(e)),
2798
- a
2799
- ) : c.rect(...d.couple(g.topLeft(e)), ...d.couple(g.dims(e))), c.fill(), n && this.border({
2800
- region: e,
2801
- color: s,
2802
- radius: a,
2803
- width: i,
2804
- location: n
2805
- });
2806
- }
2807
- textContainer(e) {
2808
- const [n, r] = this.spacedTextDrawF(e);
2809
- n.width += 12, n.height += 12;
2810
- const { root: s = K.TOP_LEFT, offset: a = d.ZERO } = e, i = { ...e.position };
2811
- s.x === "right" ? i.x -= n.width + a.x : i.x += a.x, s.y === "bottom" ? i.y -= n.height + a.y : i.y += a.y, this.container({
2812
- region: g.construct(i, n.width, n.height),
2813
- ...e
2814
- }), this.canvas.filter = "none", r(d.translate(i, [6, 6]));
2815
- }
2816
- spacedTextDrawF({
2817
- text: e,
2818
- direction: n,
2819
- spacing: r = 1,
2820
- level: s = "p"
2821
- }) {
2822
- const a = Fe(this.theme, { level: s }), i = e.map((l) => On(l, a, this.canvas)), o = this.theme.sizes.base * r, c = Math.max(...i.map((l) => l[te.dimension(n)])) + o;
2823
- return [
2824
- {
2825
- [te.dimension(te.swap(n))]: Math.max(
2826
- ...i.map((l) => l[te.dimension(te.swap(n))])
2827
- ),
2828
- [te.dimension(n)]: c * e.length - o
2829
- },
2830
- (l) => {
2831
- const u = Fe(this.theme, { level: s });
2832
- this.canvas.font = u, this.canvas.fillStyle = y.hex(this.theme.colors.text), this.canvas.textBaseline = "top", e.forEach((h, f) => {
2833
- this.canvas.fillText(h, l.x, l.y + c * f);
2834
- });
2835
- }
2836
- ];
2837
- }
2838
- list({
2839
- length: e,
2840
- itemHeight: n,
2841
- width: r,
2842
- spacing: s = 0,
2843
- position: a,
2844
- draw: i,
2845
- root: o = K.TOP_LEFT,
2846
- offset: c = d.ZERO,
2847
- padding: l = d.ZERO
2848
- }) {
2849
- const u = e * n + l.y * 2 + s * (e - 1), h = r + l.x * 2, f = { ...a };
2850
- o.x === "right" ? f.x -= r + c.x * 2 : f.x += c.x, o.y === "top" ? f.y -= u + c.y * 2 : f.y += c.y, this.container({
2851
- region: g.construct(f, { width: h, height: u }),
2852
- backgroundColor: (b) => b.colors.gray.l1
2853
- });
2854
- for (let b = 0; b < e; b++) {
2855
- const v = g.construct(
2856
- d.construct(
2857
- f.x + l.x,
2858
- f.y + b * n + l.y + s * b
2859
- ),
2860
- r,
2861
- n
2862
- );
2863
- i(b, v);
2864
- }
2865
- }
2866
- drawTextInCenter({ box: e, text: n, level: r }) {
2867
- const s = On(n, this.canvas.font, this.canvas), a = g.positionInCenter(g.construct(d.ZERO, s), e);
2868
- return this.text({ text: n, position: g.topLeft(a), level: r });
2869
- }
2870
- text({
2871
- text: e,
2872
- position: n,
2873
- level: r = "p",
2874
- weight: s,
2875
- shade: a,
2876
- maxWidth: i,
2877
- code: o,
2878
- justify: c = "left",
2879
- align: l = "top",
2880
- useAtlas: u,
2881
- color: h
2882
- }) {
2883
- this.canvas.font = Fe(this.theme, { level: r, weight: s, code: o }), h != null ? this.canvas.fillStyle = y.hex(this.resolveColor(h)) : a == null ? this.canvas.fillStyle = y.hex(this.theme.colors.text) : this.canvas.fillStyle = y.hex(this.theme.colors.gray[`l${a}`]), this.canvas.textAlign = c, this.canvas.textBaseline = l;
2884
- let f;
2885
- i != null && (f = this.canvas.scissor(g.construct(n, i, 1e3))), this.canvas.fillText(e, n.x, n.y, void 0, { useAtlas: u }), f?.();
2886
- }
2887
- }
2888
- const ps = p.object({
2889
- position: p.number().optional(),
2890
- pixelPosition: p.number().optional(),
2891
- dragging: p.boolean(),
2892
- lineWidth: p.number().optional().default(1),
2893
- lineDash: p.number().optional().default(20),
2894
- color: y.colorZ
2895
- }), Cc = 3;
2896
- class xt extends Z {
2897
- static TYPE = "Rule";
2898
- schema = ps;
2899
- lastUpdateRef = null;
2900
- afterUpdate(e) {
2901
- this.internal.renderCtx = j.use(e);
2902
- const n = re(e);
2903
- this.internal.draw = new ve(this.internal.renderCtx.upper2d, n), de(e, "tool");
2904
- }
2905
- afterDelete(e) {
2906
- de(e, "tool");
2907
- }
2908
- updatePositions({ decimalToDataScale: e, plot: n }) {
2909
- const r = this.state.dragging, s = this.prevState.dragging && !r;
2910
- if ((r || s) && this.state.pixelPosition != null) {
2911
- if (this.lastUpdateRef ??= this.state.pixelPosition, Math.abs(this.state.pixelPosition - this.lastUpdateRef) < Cc && !s)
2912
- return this.state.pixelPosition;
2913
- this.lastUpdateRef = this.state.pixelPosition;
2914
- const o = e.pos(this.state.pixelPosition / g.height(n));
2915
- return this.setState((c) => ({ ...c, position: o })), this.state.pixelPosition;
2916
- }
2917
- if (this.state.position == null) {
2918
- const i = e.pos(0.5);
2919
- this.setState((o) => ({ ...o, position: i }));
2920
- }
2921
- const a = e.reverse().pos(this.state.position) * g.height(n);
2922
- if (!isNaN(a)) {
2923
- if (this.state.pixelPosition != null && Math.abs(a - this.state.pixelPosition) < 1)
2924
- return this.state.pixelPosition;
2925
- this.setState((i) => ({ ...i, pixelPosition: a }));
2926
- }
2927
- return a;
2928
- }
2929
- render(e) {
2930
- if (this.deleted) return;
2931
- const { renderCtx: n } = this.internal, { location: r, plot: s } = e, a = K.direction(r), { upper2d: i } = n, o = this.internal.draw, c = this.updatePositions(e) + g.top(e.plot);
2932
- o.rule({
2933
- stroke: this.state.color,
2934
- lineWidth: this.state.lineWidth,
2935
- lineDash: this.state.lineDash,
2936
- direction: a,
2937
- region: s,
2938
- position: c
2939
- }), i.fillStyle = y.hex(this.state.color), i.lineJoin = "round", i.lineWidth = 3.5, i.lineCap = "round", i.beginPath();
2940
- const l = 4;
2941
- if (r === "left") {
2942
- const u = g.left(s) - 1;
2943
- i.moveTo(u, c), i.lineTo(u - l, c - l), i.lineTo(u - l, c + l);
2944
- } else r === "right" && (i.moveTo(g.right(s), c), i.lineTo(g.right(s) + l, c - l), i.lineTo(g.right(s) + l, c + l));
2945
- i.closePath(), i.stroke();
2946
- }
2947
- }
2948
- const Ec = {
2949
- [xt.TYPE]: xt
2950
- }, _u = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2951
- __proto__: null,
2952
- REGISTRY: Ec,
2953
- Rule: xt,
2954
- ruleStateZ: ps
2955
- }, Symbol.toStringTag, { value: "Module" })), Iu = Ot.extend({
2956
- location: K.x.optional().default("left")
2957
- }), gr = 2, Rc = (t) => g.signedWidth(t) < gr || g.signedHeight(t) < gr;
2958
- class Jt extends gs {
2959
- static TYPE = "YAxis";
2960
- schema = Ot;
2961
- xBounds() {
2962
- return A.max(
2963
- this.lines.map((e) => e.xBounds()).filter((e) => A.isFinite(e))
2964
- );
2965
- }
2966
- bounds(e) {
2967
- const [n, r] = this.iBounds(e, this.dataBounds.bind(this));
2968
- if (r != null) throw r;
2969
- return n;
2970
- }
2971
- render(e) {
2972
- if (this.deleted) return;
2973
- const [n, r] = this.dataToDecimalScale(
2974
- e.hold,
2975
- this.dataBounds.bind(this),
2976
- e.viewport
2977
- ), s = n.invert().reverse();
2978
- if (this.renderAxis(e, s), this.renderLines(e, n), this.renderRules(e, s), r != null) throw r;
2979
- }
2980
- renderLines({ xDataToDecimalScale: e, plot: n, canvases: r, exposure: s }, a) {
2981
- if (!r.includes("gl") || Rc(n)) return;
2982
- const i = {
2983
- region: n,
2984
- dataToDecimalScale: new G.XY(e, a),
2985
- exposure: s
2986
- };
2987
- this.lines.forEach((o) => o.render(i));
2988
- }
2989
- renderRules({ container: e, plot: n, canvases: r }, s) {
2990
- if (!r.includes("upper2d")) return;
2991
- const { location: a } = this.state, { render: i } = this.internal, o = g.construct(
2992
- g.left(e),
2993
- g.top(n),
2994
- g.width(e),
2995
- g.height(n)
2996
- ), c = i.scissor(o, d.ZERO, ["upper2d"]), l = { container: e, plot: n, decimalToDataScale: s, location: a };
2997
- this.rules.map((u) => u.render(l)), c();
2998
- }
2999
- findByXValue({
3000
- xDataToDecimalScale: e,
3001
- plot: n,
3002
- viewport: r,
3003
- hold: s,
3004
- exposure: a
3005
- }, i) {
3006
- const [o, c] = this.dataToDecimalScale(
3007
- s,
3008
- this.dataBounds.bind(this),
3009
- r
3010
- );
3011
- if (c != null) throw c;
3012
- const l = new G.XY(e, o), u = { region: n, dataToDecimalScale: l, exposure: a };
3013
- return this.lines.map((h) => ({
3014
- ...h.findByXValue(u, i),
3015
- units: this.state.label
3016
- }));
3017
- }
3018
- dataBounds() {
3019
- return this.lines.map((e) => e.yBounds());
3020
- }
3021
- get lines() {
3022
- return this.childrenOfType(zt.TYPE);
3023
- }
3024
- get rules() {
3025
- return this.childrenOfType(xt.TYPE);
3026
- }
3027
- }
3028
- const kc = p.object({ start: $.z, end: $.z });
3029
- class pr extends Z {
3030
- static TYPE = "range-annotation";
3031
- schema = kc;
3032
- afterUpdate(e) {
3033
- this.internal.render = j.use(e), this.internal.draw = new ve(this.internal.render.upper2d, re(e));
3034
- }
3035
- }
3036
- const Dc = $e.payloadZ.extend({
3037
- viewport: A.bounds
3038
- }), Mc = p.object({
3039
- cursor: d.xy.or(p.null()),
3040
- hovered: Dc.or(p.null()),
3041
- count: p.number()
3042
- });
3043
- class en extends Z {
3044
- static TYPE = "range-provider";
3045
- schema = Mc;
3046
- fetchedInitial = qe.ZERO;
3047
- afterUpdate(e) {
3048
- const { internal: n } = this;
3049
- n.render = j.use(e), n.draw = new ve(n.render.upper2d, re(e)), n.requestRender = Sn(e), n.runAsync = he(e), n.ranges ??= /* @__PURE__ */ new Map();
3050
- const r = Pt(e);
3051
- if (n.requestRender("tool"), r == null) return;
3052
- n.client = r;
3053
- const s = wu(e, this.key);
3054
- n.removeListener?.();
3055
- const a = s.ranges.onSet((o) => {
3056
- n.client != null && (y.isCrude(o.color) && n.ranges.set(o.key, n.client.ranges.sugarOne(o)), this.setState((c) => ({ ...c, count: n.ranges.size })), n.requestRender("tool"));
3057
- }), i = s.ranges.onDelete(async (o) => {
3058
- n.ranges.delete(o), this.setState((c) => ({ ...c, count: n.ranges.size })), n.requestRender("tool");
3059
- });
3060
- n.removeListener = () => {
3061
- a(), i();
3062
- };
3063
- }
3064
- fetchInitial(e) {
3065
- const { internal: n } = this, { client: r, runAsync: s } = n;
3066
- r == null || this.fetchedInitial.equals(e, C.minutes(1)) || (this.fetchedInitial = e, s(async () => {
3067
- (await r.ranges.retrieve(e)).forEach((i) => {
3068
- y.isCrude(i.color) && n.ranges.set(i.key, i);
3069
- }), this.setState((i) => ({ ...i, count: n.ranges.size }));
3070
- }, "failed to fetch initial ranges"));
3071
- }
3072
- render(e) {
3073
- const { dataToDecimalScale: n, region: r, viewport: s, timeRange: a } = e;
3074
- this.fetchInitial(a);
3075
- const { draw: i, ranges: o } = this.internal, c = n.scale(g.xBounds(r)), l = this.state.cursor == null ? null : this.state.cursor.x;
3076
- let u = null;
3077
- const h = i.canvas.scissor(
3078
- g.construct(
3079
- { x: g.left(r), y: g.top(r) - 35 },
3080
- { x: g.right(r), y: g.bottom(r) }
3081
- )
3082
- );
3083
- o.forEach((f) => {
3084
- const b = y.colorZ.safeParse(f.color);
3085
- if (!b.success) return;
3086
- const v = b.data;
3087
- let S = c.pos(Number(f.timeRange.start.valueOf()));
3088
- const T = c.pos(Number(f.timeRange.end.valueOf()));
3089
- if (T < g.left(r) || S > g.right(r)) return;
3090
- S = Ur(S, g.left(r) - 2, g.right(r) - 1);
3091
- let k = !1;
3092
- l != null && (k = A.contains({ lower: S, upper: T }, l)), k && (u = {
3093
- key: f.key,
3094
- parent: f.parent,
3095
- name: f.name,
3096
- color: f.color,
3097
- labels: f.labels,
3098
- timeRange: f.timeRange,
3099
- viewport: {
3100
- lower: n.scale(g.xBounds(s)).pos(Number(f.timeRange.start.valueOf())),
3101
- upper: n.scale(g.xBounds(s)).pos(Number(f.timeRange.end.valueOf()))
3102
- }
3103
- }), i.container({
3104
- region: g.construct(
3105
- { x: S, y: g.top(r) - 1 },
3106
- { x: T, y: g.bottom(r) - 1 }
3107
- ),
3108
- backgroundColor: y.setAlpha(v, 0.2),
3109
- bordered: !1
3110
- });
3111
- const L = g.construct(
3112
- { x: S + 1, y: g.top(r) - 34 },
3113
- { x: T - 1, y: g.top(r) - 12 }
3114
- );
3115
- i.container({
3116
- region: L,
3117
- backgroundColor: g.width(L) < 20 ? y.setAlpha(v, 0.4) : (D) => k ? D.colors.gray.l2 : D.colors.gray.l0,
3118
- bordered: !0,
3119
- borderWidth: 1,
3120
- borderRadius: 2,
3121
- borderColor: y.setAlpha(v, 0.8)
3122
- }), i.text({
3123
- text: f.name,
3124
- position: { x: S + 8, y: g.top(r) - 30 },
3125
- level: "small",
3126
- shade: 10,
3127
- weight: 500,
3128
- maxWidth: T - S - 16
3129
- });
3130
- }), h(), u != null ? this.setState((f) => ({ ...f, hovered: u })) : this.state.hovered && this.setState((f) => ({ ...f, hovered: null }));
3131
- }
3132
- }
3133
- const Yu = {
3134
- [pr.TYPE]: pr,
3135
- [en.TYPE]: en
3136
- }, Uu = Ot;
3137
- class tn extends gs {
3138
- static TYPE = "XAxis";
3139
- schema = Ot;
3140
- render(e) {
3141
- if (this.deleted) return;
3142
- const [n, r] = this.dataToDecimalScale(
3143
- e.hold,
3144
- this.dataBounds.bind(this),
3145
- e.viewport
3146
- );
3147
- if (this.renderAxis(e, n.reverse()), this.renderYAxes(e, n), this.renderRanges(e, n), r != null) throw r;
3148
- }
3149
- findByXDecimal(e, n) {
3150
- const [r, s] = this.dataToDecimalScale(
3151
- e.hold,
3152
- this.dataBounds.bind(this),
3153
- e.viewport
3154
- );
3155
- if (s != null) throw s;
3156
- return this.findByXValue(e, r.reverse().pos(n));
3157
- }
3158
- findByXValue(e, n) {
3159
- const [r, s] = this.dataToDecimalScale(
3160
- e.hold,
3161
- this.dataBounds.bind(this),
3162
- e.viewport
3163
- );
3164
- if (s != null) throw s;
3165
- const a = { ...e, xDataToDecimalScale: r };
3166
- return this.yAxes.map((i) => i.findByXValue(a, n)).flat();
3167
- }
3168
- renderYAxes(e, n) {
3169
- const r = { ...e, xDataToDecimalScale: n };
3170
- this.yAxes.forEach((s) => s.render(r));
3171
- }
3172
- get yAxes() {
3173
- return this.childrenOfType(Jt.TYPE);
3174
- }
3175
- get ranges() {
3176
- return this.childrenOfType(en.TYPE);
3177
- }
3178
- bounds(e) {
3179
- const [n, r] = this.iBounds(e, this.dataBounds.bind(this));
3180
- if (r != null) throw r;
3181
- return n;
3182
- }
3183
- renderRanges(e, n) {
3184
- const r = this.bounds(e.hold), s = A.min([r, qe.MAX.numericBounds]), a = new qe(s.lower, s.upper);
3185
- this.ranges.forEach(
3186
- (i) => i.render({
3187
- dataToDecimalScale: n,
3188
- region: e.plot,
3189
- viewport: e.viewport,
3190
- timeRange: a
3191
- })
3192
- );
3193
- }
3194
- dataBounds() {
3195
- return this.yAxes.map((e) => e.xBounds());
3196
- }
3197
- }
3198
- const Pc = d.construct(12), Lc = 3, Ac = 14, Oc = d.construct(6), ms = p.object({
3199
- position: d.xy.or(p.null()),
3200
- textColor: y.colorZ.optional().default(y.ZERO),
3201
- backgroundColor: y.colorZ.optional().default(y.ZERO),
3202
- borderColor: y.colorZ.optional().default(y.ZERO),
3203
- ruleColor: y.colorZ.optional().default(y.ZERO),
3204
- ruleStrokeWidth: p.number().optional().default(1),
3205
- ruleStrokeDash: p.number().default(0)
3206
- });
3207
- class St extends Z {
3208
- static TYPE = "tooltip";
3209
- schema = ms;
3210
- afterUpdate(e) {
3211
- const n = re(e);
3212
- y.isZero(this.state.textColor) && (this.state.textColor = n.colors.text), y.isZero(this.state.backgroundColor) && (this.state.backgroundColor = n.colors.gray.l1), y.isZero(this.state.borderColor) && (this.state.borderColor = n.colors.border), y.isZero(this.state.ruleColor) && (this.state.ruleColor = n.colors.gray.l7), this.internal.dotColor = n.colors.text, this.internal.dotColorContrast = n.colors.textInverted, this.internal.render = j.use(e), this.internal.draw = new ve(this.internal.render.upper2d, n), de(e, "tool");
3213
- }
3214
- afterDelete(e) {
3215
- de(e, "tool");
3216
- }
3217
- render(e) {
3218
- if (this.deleted || this.state.position == null) return;
3219
- const { region: n } = e, r = G.XY.scale(g.DECIMAL).scale(n), s = G.XY.scale(n).scale(g.DECIMAL), a = e.findByXDecimal(s.x.pos(this.state.position.x)), i = a.filter((S) => d.isFinite(S.value)), { draw: o } = this.internal, c = i.reduce((S, T) => S + T.position.x, 0) / i.length, l = new $(
3220
- i.reduce((S, T) => S + T.value.x, 0) / i.length
3221
- ), u = r.x.pos(c);
3222
- if (!A.contains(g.xBounds(n), u)) return;
3223
- o.rule({
3224
- stroke: this.state.ruleColor,
3225
- lineWidth: this.state.ruleStrokeWidth,
3226
- lineDash: this.state.ruleStrokeDash,
3227
- direction: "y",
3228
- region: n,
3229
- position: u
3230
- }), i.forEach((S) => {
3231
- const T = r.pos(S.position);
3232
- o.circle({ fill: y.setAlpha(S.color, 0.5), radius: 8, position: T }), o.circle({ fill: y.setAlpha(S.color, 0.8), radius: 5, position: T }), o.circle({
3233
- fill: y.pickByContrast(
3234
- S.color,
3235
- this.internal.dotColor,
3236
- this.internal.dotColorContrast
3237
- ),
3238
- radius: 2,
3239
- position: T
3240
- });
3241
- });
3242
- const h = s.pos(this.state.position), f = { ...K.TOP_LEFT };
3243
- h.x > 0.6 && (f.x = "right"), h.y > 0.6 && (f.y = "bottom");
3244
- let b = a.reduce((S, T) => Math.max(S, T.label?.length ?? 0), 0);
3245
- const v = l.toString("preciseDate", "local").length;
3246
- v > b && (b = v), o.list({
3247
- root: f,
3248
- offset: Pc,
3249
- length: i.length + 1,
3250
- padding: Oc,
3251
- itemHeight: Ac,
3252
- spacing: Lc,
3253
- width: b * 7 + 48,
3254
- position: this.state.position,
3255
- draw: (S, T) => {
3256
- let k = "", L = "", D = this.state.textColor;
3257
- if (S === 0)
3258
- k = "Time", L = l.toString("preciseDate", "local");
3259
- else {
3260
- const N = i[S - 1];
3261
- k = N.label ?? "", L = Yr.roundBySpan(N.value.y, N.bounds).toString(), D = N.color;
3262
- }
3263
- o.text({
3264
- position: g.topLeft(T),
3265
- text: k,
3266
- level: "small",
3267
- weight: 500,
3268
- color: D
3269
- }), o.text({
3270
- position: d.translateY(g.topRight(T), -1),
3271
- text: L,
3272
- level: "small",
3273
- justify: "right",
3274
- code: !0,
3275
- shade: 10
3276
- });
3277
- }
3278
- });
3279
- }
3280
- }
3281
- const Nc = {
3282
- [St.TYPE]: St
3283
- }, Zu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3284
- __proto__: null,
3285
- REGISTRY: Nc,
3286
- Tooltip: St,
3287
- tooltipStateZ: ms
3288
- }, Symbol.toStringTag, { value: "Module" })), ys = p.object({
3289
- one: d.xy.nullable(),
3290
- two: d.xy.nullable(),
3291
- hover: d.xy.nullable(),
3292
- color: p.union([
3293
- y.colorZ,
3294
- p.object({
3295
- verticalLine: y.colorZ.optional().default(y.ZERO),
3296
- horizontalLine: y.colorZ.optional().default(y.ZERO),
3297
- obliqueLine: y.colorZ.optional().default(y.ZERO)
3298
- })
3299
- ]).optional().default(y.ZERO),
3300
- strokeWidth: p.number().optional().default(1),
3301
- strokeDash: p.number().optional().default(2)
3302
- });
3303
- class vt extends Z {
3304
- static TYPE = "measure";
3305
- schema = ys;
3306
- afterUpdate(e) {
3307
- const n = j.use(e);
3308
- this.internal.theme = re(e), this.internal.renderCtx = n, this.internal.draw = new ve(n.upper2d, this.internal.theme), de(e, "tool");
3309
- }
3310
- afterDelete(e) {
3311
- de(e, "layout");
3312
- }
3313
- get verticalLineColor() {
3314
- return y.isColor(this.state.color) ? y.isZero(this.state.color) ? this.internal.theme.colors.gray.l8 : this.state.color : y.isZero(this.state.color.verticalLine) ? this.internal.theme.colors.gray.l8 : this.state.color.verticalLine;
3315
- }
3316
- get horizontalLineColor() {
3317
- return y.isColor(this.state.color) ? y.isZero(this.state.color) ? this.internal.theme.colors.gray.l8 : this.state.color : y.isZero(this.state.color.horizontalLine) ? this.internal.theme.colors.gray.l8 : this.state.color.horizontalLine;
3318
- }
3319
- get obliqueLineColor() {
3320
- return y.isColor(this.state.color) ? y.isZero(this.state.color) ? this.internal.theme.colors.gray.l8 : this.state.color : y.isZero(this.state.color.obliqueLine) ? this.internal.theme.colors.gray.l8 : this.state.color.obliqueLine;
3321
- }
3322
- find(e) {
3323
- const { one: n, two: r } = this.state;
3324
- if (n == null || r == null) return null;
3325
- const { one: s, two: a } = this.prevState, { dataOne: i, dataTwo: o } = this.internal;
3326
- if (s != null && d.equals(n, s) && a != null && d.equals(r, a) && i != null && o != null) {
3327
- const [S, T] = [e.findByXValue(i.x), e.findByXValue(o.x)];
3328
- return S.length === 0 || T.length === 0 ? null : [
3329
- S.sort(
3330
- (k, L) => d.distance(i, k.value) - d.distance(i, L.value)
3331
- )[0],
3332
- T.sort(
3333
- (k, L) => d.distance(o, k.value) - d.distance(o, L.value)
3334
- )[0]
3335
- ];
3336
- }
3337
- const c = G.XY.scale(e.region).scale(g.DECIMAL), [l, u] = [c.pos(n), c.pos(r)], [h, f] = [
3338
- e.findByXDecimal(l.x),
3339
- e.findByXDecimal(u.x)
3340
- ];
3341
- if (h.length === 0 || f.length === 0) return null;
3342
- const [b, v] = [
3343
- h.sort(
3344
- (S, T) => d.distance(l, S.position) - d.distance(l, T.position)
3345
- )[0],
3346
- f.sort(
3347
- (S, T) => d.distance(u, S.position) - d.distance(u, T.position)
3348
- )[0]
3349
- ];
3350
- return this.internal.dataOne = b.value, this.internal.dataTwo = v.value, [b, v];
3351
- }
3352
- renderHover(e) {
3353
- if (this.state.hover == null) return;
3354
- const n = this.state.hover, r = G.XY.scale(e.region).scale(g.DECIMAL), s = r.pos(n), a = e.findByXDecimal(r.pos(n).x);
3355
- if (a.length === 0) return;
3356
- const i = a.sort(
3357
- (c, l) => d.distance(s, c.position) - d.distance(s, l.position)
3358
- )[0], { draw: o } = this.internal;
3359
- o.circle({
3360
- fill: y.setAlpha(i.color, 0.5),
3361
- radius: 9,
3362
- position: r.reverse().pos(i.position)
3363
- });
3364
- }
3365
- render(e) {
3366
- if (this.deleted) return;
3367
- this.renderHover(e);
3368
- const n = this.find(e);
3369
- if (n == null) return;
3370
- const [r, s] = n, { draw: a } = this.internal, { strokeDash: i, strokeWidth: o } = this.state, c = G.XY.scale(g.DECIMAL).scale(e.region), l = c.pos(r.position), u = c.pos(s.position), h = new C(Math.abs(r.value.x - s.value.x)), f = Math.abs(r.value.y - s.value.y), b = f / h.seconds;
3371
- a.line({
3372
- start: d.construct(l.x, l.y),
3373
- end: d.construct(l.x, u.y),
3374
- stroke: this.verticalLineColor,
3375
- lineDash: i,
3376
- lineWidth: o
3377
- }), a.textContainer({
3378
- text: [`${f.toFixed(2)} ${r.units ?? ""}`],
3379
- direction: "x",
3380
- position: d.construct(l.x, (l.y + u.y) / 2),
3381
- level: "small"
3382
- }), a.line({
3383
- start: d.construct(l.x, u.y),
3384
- end: d.construct(u.x, u.y),
3385
- stroke: this.horizontalLineColor,
3386
- lineDash: i,
3387
- lineWidth: o
3388
- }), a.textContainer({
3389
- text: [h.truncate(C.MILLISECOND).toString()],
3390
- direction: "x",
3391
- position: d.construct((l.x + u.x) / 2, u.y),
3392
- level: "small"
3393
- }), a.line({
3394
- start: d.construct(l.x, l.y),
3395
- end: d.construct(u.x, u.y),
3396
- stroke: this.obliqueLineColor,
3397
- lineDash: i,
3398
- lineWidth: o
3399
- }), a.textContainer({
3400
- text: [`${b.toFixed(2)} ${r.units ?? ""} / S`],
3401
- direction: "x",
3402
- position: d.construct((l.x + u.x) / 2, (l.y + u.y) / 2),
3403
- level: "small"
3404
- }), a.circle({
3405
- fill: y.setAlpha(r.color, 0.5),
3406
- radius: 8,
3407
- position: l
3408
- }), a.circle({
3409
- fill: y.setAlpha(r.color, 0.8),
3410
- radius: 5,
3411
- position: l
3412
- }), a.circle({ fill: y.WHITE, radius: 2, position: l }), a.circle({
3413
- fill: y.setAlpha(s.color, 0.5),
3414
- radius: 8,
3415
- position: u
3416
- }), a.circle({
3417
- fill: y.setAlpha(s.color, 0.8),
3418
- radius: 5,
3419
- position: u
3420
- }), a.circle({ fill: y.WHITE, radius: 2, position: u });
3421
- }
3422
- }
3423
- const _c = {
3424
- [vt.TYPE]: vt
3425
- }, Bu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3426
- __proto__: null,
3427
- Measure: vt,
3428
- REGISTRY: _c,
3429
- measureStateZ: ys
3430
- }, Symbol.toStringTag, { value: "Module" })), Ic = p.object({
3431
- container: g.box,
3432
- viewport: g.box,
3433
- hold: p.boolean().optional().default(!1),
3434
- grid: p.record(p.string(), ds),
3435
- visible: p.boolean().optional().default(!0),
3436
- clearOverScan: d.crudeZ.optional().default(d.ZERO)
3437
- }), Yc = (t, e) => {
3438
- const n = g.width(t) * Math.sqrt(g.height(t)), r = g.width(e) * Math.sqrt(g.height(e));
3439
- return n / r;
3440
- }, Uc = ["upper2d", "lower2d", "gl"], Zc = ["upper2d"];
3441
- class mr extends fe {
3442
- static TYPE = "LinePlot";
3443
- schema = Ic;
3444
- afterUpdate(e) {
3445
- this.internal.instrumentation = Dt(e, "lineplot"), this.internal.handleError = he(e), this.internal.renderCtx = j.use(e), xn(e, (n) => {
3446
- this.state.visible && this.requestRender("low", n);
3447
- }), !(!this.state.visible && !this.prevState.visible) && this.requestRender("high", "layout");
3448
- }
3449
- afterDelete(e) {
3450
- this.internal.renderCtx = j.use(e), this.requestRender("high", "layout");
3451
- }
3452
- findByXDecimal(e) {
3453
- const n = {
3454
- ...this.state,
3455
- plot: this.calculatePlot(),
3456
- exposure: this.exposure
3457
- };
3458
- return this.axes.flatMap((r) => r.findByXDecimal(n, e)).flat();
3459
- }
3460
- findByXValue(e) {
3461
- const n = {
3462
- ...this.state,
3463
- plot: this.calculatePlot(),
3464
- exposure: this.exposure
3465
- };
3466
- return this.axes.flatMap((r) => r.findByXValue(n, e)).flat();
3467
- }
3468
- get axes() {
3469
- return this.childrenOfType(tn.TYPE);
3470
- }
3471
- get tooltips() {
3472
- return this.childrenOfType(St.TYPE);
3473
- }
3474
- get measures() {
3475
- return this.childrenOfType(vt.TYPE);
3476
- }
3477
- get bounds() {
3478
- return this.childrenOfType(Xt.TYPE);
3479
- }
3480
- get exposure() {
3481
- return Yc(this.state.viewport, this.state.container);
3482
- }
3483
- renderAxes(e, n) {
3484
- const r = { ...this.state, plot: e, canvases: n, exposure: this.exposure };
3485
- this.axes.forEach((s) => s.render(r));
3486
- }
3487
- renderTooltips(e, n) {
3488
- const r = { findByXDecimal: this.findByXDecimal.bind(this), region: e, canvases: n };
3489
- this.tooltips.forEach((s) => s.render(r));
3490
- }
3491
- renderBounds() {
3492
- this.bounds.forEach(
3493
- (e) => e.render({
3494
- getBounds: () => {
3495
- const n = {};
3496
- return this.axes.forEach((r) => {
3497
- const s = r.state.axisKey ?? r.key;
3498
- n[s] = r.bounds(this.state.hold), r.yAxes.forEach((a) => {
3499
- const i = a.state.axisKey ?? a.key;
3500
- n[i] = a.bounds(this.state.hold);
3501
- });
3502
- }), n;
3503
- }
3504
- })
3505
- );
3506
- }
3507
- renderMeasures(e) {
3508
- const n = {
3509
- findByXDecimal: this.findByXDecimal.bind(this),
3510
- findByXValue: this.findByXValue.bind(this),
3511
- region: e
3512
- };
3513
- this.measures.forEach((r) => r.render(n));
3514
- }
3515
- calculatePlot() {
3516
- return gc(this.state.grid, this.state.container);
3517
- }
3518
- render(e) {
3519
- const { instrumentation: n, renderCtx: r, handleError: s } = this.internal;
3520
- if (this.deleted) {
3521
- n.L.debug("deleted, skipping render", { key: this.key });
3522
- return;
3523
- }
3524
- if (!this.state.visible)
3525
- return n.L.debug("not visible, skipping render", { key: this.key }), ({ canvases: u }) => r.erase(this.state.container, this.state.clearOverScan, ...u);
3526
- const a = this.calculatePlot();
3527
- n.L.debug("rendering", {
3528
- key: this.key,
3529
- viewport: this.state.viewport,
3530
- container: this.state.container,
3531
- grid: this.state.grid,
3532
- plot: a,
3533
- canvases: e
3534
- });
3535
- const i = d.construct(this.state.clearOverScan), o = r.scissor(
3536
- this.state.container,
3537
- i,
3538
- e.filter((u) => u !== "gl")
3539
- ), c = r.scissor(
3540
- a,
3541
- d.ZERO,
3542
- e.filter((u) => u === "gl")
3543
- );
3544
- try {
3545
- this.renderAxes(a, e), this.renderTooltips(a, e), this.renderMeasures(a), this.renderBounds();
3546
- } catch (u) {
3547
- s(u, "failed to render line plot");
3548
- } finally {
3549
- o(), c();
3550
- }
3551
- n.L.debug("rendered", { key: this.key });
3552
- const l = g.copy(this.state.container);
3553
- return ({ canvases: u }) => r.erase(l, this.state.clearOverScan, ...u);
3554
- }
3555
- requestRender(e, n) {
3556
- const { renderCtx: r } = this.internal;
3557
- let s = Uc;
3558
- n === "tool" && (s = Zc), r.loop.set({
3559
- key: `${this.type}-${this.key}`,
3560
- render: () => this.render(s),
3561
- priority: e,
3562
- canvases: s
3563
- });
3564
- }
3565
- }
3566
- const Fu = {
3567
- [mr.TYPE]: mr,
3568
- [tn.TYPE]: tn,
3569
- [Jt.TYPE]: Jt,
3570
- [Xt.TYPE]: Xt
3571
- }, Bc = p.object({
3572
- region: g.box,
3573
- wheelPos: p.number(),
3574
- scrolling: p.boolean(),
3575
- empty: p.boolean(),
3576
- visible: p.boolean(),
3577
- telem: ct.optional().default(Lr),
3578
- font: gn.optional().default("p"),
3579
- color: y.colorZ.optional().default(y.ZERO),
3580
- overshoot: d.xy.optional().default({ x: 0, y: 0 })
3581
- }), Fc = 0.98, Be = "lower2d", $c = {
3582
- offset: 0n,
3583
- offsetRef: 0n,
3584
- scrollRef: 0
3585
- };
3586
- class Tt extends Z {
3587
- static TYPE = "log";
3588
- static z = Bc;
3589
- schema = Tt.z;
3590
- values = new da([]);
3591
- scrollState = $c;
3592
- afterUpdate(e) {
3593
- const { internal: n } = this;
3594
- n.render = j.use(e), n.theme = re(e), y.isZero(this.state.color) ? this.internal.textColor = n.theme.colors.gray.l11 : n.textColor = this.state.color, n.telem = H(e, this.state.telem, n.telem);
3595
- const { scrolling: r, wheelPos: s } = this.state;
3596
- if (this.state.scrolling && !this.prevState.scrolling) {
3597
- const c = this.values.alignmentBounds.upper - 1n;
3598
- this.scrollState = {
3599
- offset: c,
3600
- offsetRef: c,
3601
- scrollRef: this.state.wheelPos
3602
- };
3603
- } else if (r) {
3604
- const { scrollState: c, values: l } = this, u = Math.ceil((s - this.scrollState.scrollRef) / this.lineHeight);
3605
- c.offset = this.values.traverseAlignment(
3606
- c.offsetRef,
3607
- -BigInt(u)
3608
- ), c.offset < l.alignmentBounds.lower + BigInt(this.visibleLineCount) && (c.offset = l.alignmentBounds.lower, this.setState((h) => ({ ...h, wheelPos: this.prevState.wheelPos }))), c.offset >= l.alignmentBounds.upper && this.setState((h) => ({ ...h, scrolling: !1 }));
3609
- }
3610
- const [i, o] = this.internal.telem.value();
3611
- this.values = o, this.checkEmpty(), n.stopListeningTelem?.(), n.stopListeningTelem = n.telem.onChange(() => {
3612
- const [c, l] = this.internal.telem.value();
3613
- this.checkEmpty(), this.values = l, this.requestRender();
3614
- }), !(!this.state.visible && !this.prevState.visible) && this.requestRender();
3615
- }
3616
- checkEmpty() {
3617
- const e = this.values.length === 0;
3618
- e !== this.state.empty && this.setState((n) => ({ ...n, empty: e }));
3619
- }
3620
- afterDelete() {
3621
- const { telem: e, render: n } = this.internal;
3622
- e.cleanup?.(), n.erase(g.construct(this.state.region), d.ZERO, Be);
3623
- }
3624
- requestRender() {
3625
- const { render: e } = this.internal;
3626
- e.loop.set({
3627
- key: `${this.type}-${this.key}`,
3628
- render: () => this.render(),
3629
- priority: "high",
3630
- canvases: [Be]
3631
- });
3632
- }
3633
- get lineHeight() {
3634
- return this.internal.theme.typography[this.state.font].size * this.internal.theme.sizes.base;
3635
- }
3636
- get totalHeight() {
3637
- return Math.ceil(this.values.length * this.lineHeight);
3638
- }
3639
- get visibleLineCount() {
3640
- return Math.min(
3641
- Math.floor((g.height(this.state.region) - 12) / this.lineHeight),
3642
- this.values.length
3643
- );
3644
- }
3645
- render() {
3646
- const { render: e } = this.internal, n = this.state.region;
3647
- if (g.areaIsZero(n)) return;
3648
- if (!this.state.visible) return () => e.erase(n, d.ZERO, Be);
3649
- let r;
3650
- if (!this.state.scrolling)
3651
- r = this.values.subIterator(
3652
- this.values.length - this.visibleLineCount,
3653
- this.values.length
3654
- );
3655
- else {
3656
- const l = this.values.traverseAlignment(
3657
- this.scrollState.offset,
3658
- -BigInt(this.visibleLineCount)
3659
- );
3660
- r = this.values.subAlignmentSpanIterator(l, this.visibleLineCount);
3661
- }
3662
- const s = this.state.region, a = e[Be], i = new ve(a, this.internal.theme), o = e.scissor(s, d.ZERO, [Be]);
3663
- this.renderElements(i, r), this.renderScrollbar(i), o();
3664
- const c = g.copy(this.state.region);
3665
- return ({ canvases: l }) => e.erase(c, this.state.overshoot, ...l);
3666
- }
3667
- renderScrollbar(e) {
3668
- const n = this.state.region, r = g.height(n) / this.totalHeight * g.height(n);
3669
- if (r >= g.height(n) * Fc) return;
3670
- let s = g.bottom(n) - r;
3671
- this.state.scrolling && (s -= Number(
3672
- this.values.distance(
3673
- this.values.alignmentBounds.upper,
3674
- this.scrollState.offset
3675
- )
3676
- ) / this.values.length * g.height(n)), s < 0 && (s = g.top(n)), e.container({
3677
- region: g.construct(
3678
- { x: g.right(n) - 6, y: s },
3679
- { width: 6, height: r }
3680
- ),
3681
- bordered: !1,
3682
- backgroundColor: (a) => a.colors.gray.l6
3683
- });
3684
- }
3685
- renderElements(e, n) {
3686
- const r = this.state.region;
3687
- let s = 0;
3688
- for (const a of n) {
3689
- const i = this.values.dataType.equals(Qe.JSON) ? JSON.stringify(a) : a.toString();
3690
- e.text({
3691
- text: i,
3692
- level: this.state.font,
3693
- shade: 11,
3694
- position: d.translate(g.topLeft(r), { x: 6, y: s * this.lineHeight + 6 }),
3695
- code: !0
3696
- }), s++;
3697
- }
3698
- }
3699
- }
3700
- const $u = { [Tt.TYPE]: Tt }, qu = "relationships", Hu = "resources", qc = {
3701
- channel: V.RELATIONSHIP_SET_CHANNEL_NAME,
3702
- schema: V.relationshipZ,
3703
- onChange: ({ store: t, changed: e }) => t.relationships.set(V.relationshipToString(e), e)
3704
- }, Hc = {
3705
- channel: V.RELATIONSHIP_DELETE_CHANNEL_NAME,
3706
- schema: V.relationshipZ,
3707
- onChange: ({ store: t, changed: e }) => {
3708
- t.relationships.delete(V.relationshipToString(e));
3709
- }
3710
- }, ju = {
3711
- equal: (t, e) => V.idsEqual(t.from, e.from) && V.idsEqual(t.to, e.to) && t.type === e.type,
3712
- listeners: [qc, Hc]
3713
- }, jc = {
3714
- channel: V.RESOURCE_SET_CHANNEL_NAME,
3715
- schema: V.resourceZ,
3716
- onChange: async ({ store: t, changed: e }) => {
3717
- t.resources.set(
3718
- e.key,
3719
- (n) => n == null ? e : { ...n, ...e }
3720
- );
3721
- }
3722
- }, zc = {
3723
- channel: V.RESOURCE_DELETE_CHANNEL_NAME,
3724
- schema: V.idZ,
3725
- onChange: ({ store: t, changed: e }) => t.resources.delete(e.key)
3726
- }, zu = {
3727
- equal: (t, e) => pn.equal(t, e),
3728
- listeners: [jc, zc]
3729
- }, Wu = "ranges", Wc = {
3730
- channel: $e.SET_CHANNEL_NAME,
3731
- schema: $e.payloadZ,
3732
- onChange: async ({ store: t, changed: e, client: n }) => {
3733
- const r = n.ranges.sugarOne(e), s = t.ranges.get(e.key);
3734
- let a;
3735
- s?.labels == null && (a = await r.retrieveLabels());
3736
- let i = null;
3737
- s?.parent == null && (i = await r.retrieveParent()), t.ranges.set(
3738
- e.key,
3739
- (o) => n.ranges.sugarOne({
3740
- ...r.payload,
3741
- labels: o?.labels ?? a,
3742
- parent: o?.parent ?? i
3743
- })
3744
- );
3745
- }
3746
- }, Xc = {
3747
- channel: $e.DELETE_CHANNEL_NAME,
3748
- schema: $e.keyZ,
3749
- onChange: ({ store: t, changed: e }) => t.ranges.delete(e)
3750
- }, Xu = {
3751
- equal: (t, e) => pn.equal(t.payload, e.payload),
3752
- listeners: [Wc, Xc]
3753
- }, Vc = p.object({
3754
- region: g.box,
3755
- clearOverScan: d.crudeZ.optional().default(0),
3756
- visible: p.boolean().optional().default(!0),
3757
- autoRenderInterval: p.number().optional().default(1e3)
3758
- }), yr = ["upper2d", "lower2d"];
3759
- class Xe extends fe {
3760
- static TYPE = "Table";
3761
- static stateZ = Vc;
3762
- schema = Xe.stateZ;
3763
- afterUpdate(e) {
3764
- const { internal: n } = this;
3765
- n.renderCtx = j.use(e), n.handleError = he(e), n.autoRenderInterval ??= setInterval(
3766
- () => this.state.visible && this.requestRender("low"),
3767
- this.state.autoRenderInterval
3768
- ), xn(e, () => {
3769
- this.state.visible && this.requestRender("low");
3770
- }), !(!this.state.visible && !this.prevState.visible) && this.requestRender("high");
3771
- }
3772
- afterDelete() {
3773
- this.internal.autoRenderInterval != null && clearInterval(this.internal.autoRenderInterval), this.requestRender("high");
3774
- }
3775
- render() {
3776
- if (this.deleted) return;
3777
- const e = g.copy(this.state.region);
3778
- if (!this.state.visible)
3779
- return () => this.internal.renderCtx.erase(e, this.state.clearOverScan);
3780
- const { renderCtx: n, handleError: r } = this.internal, s = G.XY.translate(g.topLeft(this.state.region)), a = n.scissor(
3781
- this.state.region,
3782
- d.construct(this.state.clearOverScan),
3783
- yr
3784
- );
3785
- try {
3786
- for (const i of this.children) i.render({ viewportScale: s });
3787
- } catch (i) {
3788
- r(i, "Failed to render table");
3789
- } finally {
3790
- a();
3791
- }
3792
- return () => this.internal.renderCtx.erase(e, this.state.clearOverScan);
3793
- }
3794
- requestRender(e) {
3795
- const { renderCtx: n } = this.internal;
3796
- n.loop.set({
3797
- key: `${Xe.TYPE}-${this.key}`,
3798
- render: this.render.bind(this),
3799
- priority: e,
3800
- canvases: yr
3801
- });
3802
- }
3803
- }
3804
- const Vu = {
3805
- [Xe.TYPE]: Xe
3806
- }, Gc = p.object({
3807
- authority: Lt.authorityZ.optional(),
3808
- valid: p.boolean().optional()
3809
- }).default({ authority: void 0, valid: !1 }), Kc = p.object({
3810
- triggered: p.boolean(),
3811
- status: Fr.statusZ(Gc),
3812
- sink: Et.optional().default(kt),
3813
- source: dn.optional().default(un)
3814
- });
3815
- class br extends Z {
3816
- static TYPE = "Chip";
3817
- schema = Kc;
3818
- afterUpdate(e) {
3819
- const { internal: n } = this, { sink: r, source: s } = this.state;
3820
- n.source = H(
3821
- e,
3822
- s,
3823
- n.source
3824
- ), n.sink = Ke(e, r, n.sink), this.state.triggered && !this.prevState.triggered && n.sink.set(this.state.status.details?.authority !== Lt.ABSOLUTE_AUTHORITY), this.updateEnabledState(), n.stopListening?.(), n.stopListening = n.source.onChange(() => this.updateEnabledState());
3825
- }
3826
- updateEnabledState() {
3827
- const e = this.internal.source.value();
3828
- pn.equal(e, this.state.status) || this.setState((n) => ({ ...n, status: e, triggered: !1 }));
3829
- }
3830
- afterDelete() {
3831
- this.internal.stopListening(), this.internal.source.cleanup?.(), this.internal.sink.cleanup?.();
3832
- }
3833
- render() {
3834
- }
3835
- }
3836
- const Qc = p.object({}), xr = "control-state-provider", Jc = mn.stateZ.extend({
3837
- subjectColor: y.colorZ
3838
- });
3839
- class wt extends fe {
3840
- static TYPE = "StateProvider";
3841
- schema = Qc;
3842
- /** Tracks the colors we assign to a particular control subject. */
3843
- colors = /* @__PURE__ */ new Map();
3844
- /** Tracks the current control state for each channel and allows us to access it */
3845
- tracker;
3846
- /** Stop listening for changes to the tracker */
3847
- disconnectTrackerChange;
3848
- /** An observer that lets external subscribers know when the control state changes */
3849
- obs = new sa.Observer();
3850
- /**
3851
- * Grabs the state provider from the current aether context.
3852
- *
3853
- * @param ctx - The component's current aether context.
3854
- * @throws {Error} if the state provider is not in the context.
3855
- */
3856
- static use(e) {
3857
- return e.get(xr);
3858
- }
3859
- afterUpdate(e) {
3860
- const { internal: n } = this;
3861
- n.instrumentation = Dt(e, "control-state");
3862
- const r = re(e);
3863
- n.palette = r.colors.visualization.palettes.default, n.defaultColor = r.colors.gray.l8;
3864
- const s = Pt(e);
3865
- if (n.client != null && s === n.client) return;
3866
- n.client = s, e.set(xr, this), he(e)(async () => {
3867
- await this.maybeCloseTracker(), n.client != null && (this.internal.instrumentation.L.debug("starting state tracker"), await this.openTracker(n.client));
3868
- }, "failed to open control state tracker");
3869
- }
3870
- async maybeCloseTracker() {
3871
- this.tracker != null && (this.internal.instrumentation.L.debug("stopping state tracker"), this.disconnectTrackerChange?.(), await this.tracker.close(), this.tracker = void 0);
3872
- }
3873
- afterDelete(e) {
3874
- he(e)(async () => {
3875
- await this.maybeCloseTracker();
3876
- }, "failed to close control state tracker");
3877
- }
3878
- onChange(e) {
3879
- return this.obs.onChange(e);
3880
- }
3881
- get(e) {
3882
- return Array.isArray(e) ? Br.unique(e).map((n) => this.getOne(n)).filter((n) => n != null) : this.getOne(e);
3883
- }
3884
- getOne(e) {
3885
- if (this.tracker == null) return;
3886
- const n = this.tracker.states.get(e);
3887
- if (n != null)
3888
- return {
3889
- ...n,
3890
- subjectColor: this.colors.get(n.subject.key) ?? this.internal.defaultColor
3891
- };
3892
- }
3893
- async openTracker(e) {
3894
- const { internal: n } = this, { instrumentation: r } = n;
3895
- try {
3896
- this.tracker = await e.control.openStateTracker();
3897
- } catch {
3898
- r.L.error("failed to open state tracker");
3899
- return;
3900
- }
3901
- this.disconnectTrackerChange?.(), this.disconnectTrackerChange = this.tracker.onChange((s) => {
3902
- if (r.L.debug("transfer", { transfers: s.map((a) => mn.transferString(a)) }), this.tracker == null)
3903
- throw new Mt("tracker is null inside it's own onChange callback!");
3904
- this.updateColors(this.tracker), this.obs.notify(s);
3905
- });
3906
- }
3907
- updateColors(e) {
3908
- const n = e.subjects(), r = n.map((i) => i.key), s = Array.from(this.colors.values());
3909
- this.colors.forEach((i, o) => !r.includes(o) && this.colors.delete(o));
3910
- const { palette: a } = this.internal;
3911
- n.forEach((i) => {
3912
- if (this.colors.has(i.key)) return;
3913
- const o = a.find((c) => !s.includes(c)) ?? a[0];
3914
- this.colors.set(i.key, o), s.push(o);
3915
- });
3916
- }
3917
- }
3918
- const eu = ["acquired", "released", "overridden", "failed"], tu = p.enum(eu), nu = p.object({
3919
- name: p.string(),
3920
- authority: p.number().default(0),
3921
- acquireTrigger: p.number(),
3922
- status: tu.optional(),
3923
- needsControlOf: Ir.keyZ.array().optional().default([])
3924
- });
3925
- class Sr extends fe {
3926
- static TYPE = "Controller";
3927
- schema = nu;
3928
- registry = /* @__PURE__ */ new Map();
3929
- writer;
3930
- afterUpdate(e) {
3931
- const { internal: n } = this;
3932
- n.instrumentation = Dt(e), n.addStatus = _r(e), n.runAsync = he(e), (n.prevTrigger == null || Math.abs(this.state.acquireTrigger - n.prevTrigger) > 1) && (n.prevTrigger = this.state.acquireTrigger);
3933
- const r = Pt(e), s = wt.use(e);
3934
- n.stateProv = s, n.telemCtx = Nr(e, this, n.telemCtx), n.client = r, n.runAsync(async () => {
3935
- n.client == null && await this.release(), this.state.acquireTrigger > n.prevTrigger ? await this.acquire() : this.state.acquireTrigger < n.prevTrigger && await this.release();
3936
- }, "failed to acquire control");
3937
- }
3938
- afterDelete() {
3939
- const { internal: e } = this;
3940
- e.runAsync(async () => await this.release(), "failed to release control");
3941
- }
3942
- async updateNeedsControlOf() {
3943
- const { client: e } = this.internal;
3944
- if (e == null) return;
3945
- const n = /* @__PURE__ */ new Set([]);
3946
- for (const s of this.registry.keys())
3947
- (await s.needsControlOf(e)).forEach((i) => i !== 0 && n.add(i));
3948
- const r = Array.from(n);
3949
- _n.unorderedPrimitiveArrays(this.state.needsControlOf, r) !== _n.EQUAL && this.setState((s) => ({ ...s, needsControlOf: r }));
3950
- }
3951
- async acquire() {
3952
- this.internal.prevTrigger = this.state.acquireTrigger;
3953
- const { client: e, addStatus: n } = this.internal;
3954
- if (e == null)
3955
- return n({
3956
- message: `Cannot acquire control on ${this.state.name} because no cluster has been connected.`,
3957
- variant: "warning"
3958
- });
3959
- try {
3960
- await this.updateNeedsControlOf();
3961
- const r = this.state.needsControlOf;
3962
- if (r.length === 0)
3963
- return n({
3964
- message: `Cannot acquire control on ${this.state.name} because there are no channels to control.`,
3965
- variant: "warning"
3966
- });
3967
- const s = yn.now().sub(C.milliseconds(1));
3968
- this.writer = await e.openWriter({
3969
- start: s,
3970
- channels: r,
3971
- controlSubject: { key: this.key, name: this.state.name },
3972
- authorities: this.state.authority,
3973
- enableAutoCommit: !0
3974
- }), this.setState((a) => ({ ...a, status: "acquired" }));
3975
- } catch (r) {
3976
- if (this.setState((s) => ({ ...s, status: "failed" })), !(r instanceof Error)) throw r;
3977
- n({
3978
- variant: "error",
3979
- message: `${this.state.name} failed to acquire control`,
3980
- description: r.message
3981
- });
3982
- }
3983
- }
3984
- async release() {
3985
- this.internal.prevTrigger = this.state.acquireTrigger;
3986
- try {
3987
- await this.writer?.close();
3988
- } catch (e) {
3989
- this.internal.addStatus({
3990
- message: `${this.state.name} failed to release control: ${e.message}`,
3991
- variant: "error"
3992
- });
3993
- } finally {
3994
- this.setState((e) => ({ ...e, status: "released" })), this.writer = void 0;
3995
- }
3996
- }
3997
- async set(e) {
3998
- this.writer == null && await this.acquire(), await this.writer?.write(e);
3999
- }
4000
- async setAuthority(e, n) {
4001
- this.writer == null && await this.acquire(), await this.writer?.setAuthority(
4002
- Object.fromEntries(e.map((r) => [r, n]))
4003
- );
4004
- }
4005
- async releaseAuthority(e) {
4006
- this.writer == null && await this.acquire(), await this.writer?.setAuthority(
4007
- Object.fromEntries(e.map((n) => [n, this.state.authority]))
4008
- );
4009
- }
4010
- deleteTelem(e) {
4011
- this.registry.delete(e), this.updateNeedsControlOf();
4012
- }
4013
- /** @implements telem.Factory to create telemetry that is bound to this controller. */
4014
- create(e) {
4015
- const { internal: n } = this, s = (() => {
4016
- switch (e.type) {
4017
- case nn.TYPE: {
4018
- const a = new nn(this, n.runAsync, e.props);
4019
- return this.registry.set(a, null), a;
4020
- }
4021
- case sn.TYPE: {
4022
- const a = new sn(this, this.internal.stateProv, e.props);
4023
- return this.registry.set(a, null), a;
4024
- }
4025
- case rn.TYPE:
4026
- return new rn(this, n.runAsync, e.props);
4027
- default:
4028
- return null;
4029
- }
4030
- })();
4031
- return s != null && this.updateNeedsControlOf(), s;
4032
- }
4033
- }
4034
- const ru = p.object({
4035
- channel: p.number()
4036
- });
4037
- class nn extends on {
4038
- static TYPE = "controlled-numeric-telem-sink";
4039
- controller;
4040
- runAsync;
4041
- schema = ru;
4042
- constructor(e, n, r) {
4043
- super(r), this.controller = e, this.runAsync = n;
4044
- }
4045
- invalidate() {
4046
- }
4047
- cleanup() {
4048
- this.controller.deleteTelem(this);
4049
- }
4050
- async needsControlOf(e) {
4051
- if (this.props.channel === 0) return [];
4052
- const n = await e.channels.retrieve(this.props.channel), r = [n.key];
4053
- return n.index !== 0 && r.push(n.index), r;
4054
- }
4055
- set(...e) {
4056
- this.runAsync(async () => {
4057
- const { client: n } = this.controller.internal;
4058
- if (n == null) throw new ia("No cluster connected");
4059
- if (this.props.channel === 0)
4060
- throw new aa("No command channel specified for actuator");
4061
- const r = await n.channels.retrieve(this.props.channel), s = { [r.key]: e };
4062
- if (r.index !== 0) {
4063
- const a = await n.channels.retrieve(r.index), i = yn.now();
4064
- s[a.key] = Array.from(
4065
- { length: e.length },
4066
- (o, c) => i.add(C.nanoseconds(c))
4067
- );
4068
- }
4069
- await this.controller.set(s);
4070
- }, "Failed to command channel");
4071
- }
4072
- }
4073
- const Gu = (t) => ({
4074
- type: nn.TYPE,
4075
- props: t,
4076
- variant: "sink",
4077
- valueType: "number"
4078
- }), su = p.object({
4079
- authority: p.number().default(mn.ABSOLUTE_AUTHORITY),
4080
- channel: p.number()
4081
- });
4082
- class rn extends on {
4083
- static TYPE = "acquire-channel-control";
4084
- controller;
4085
- runAsync;
4086
- schema = su;
4087
- constructor(e, n, r) {
4088
- super(r), this.controller = e, this.runAsync = n;
4089
- }
4090
- cleanup() {
4091
- this.controller.deleteTelem(this);
4092
- }
4093
- async needsControlOf(e) {
4094
- const n = await e.channels.retrieve(this.props.channel), r = [n.key];
4095
- return n.index !== 0 && r.push(n.index), r;
4096
- }
4097
- set(e) {
4098
- this.runAsync(async () => {
4099
- const { controller: n } = this, { client: r } = n.internal;
4100
- if (r == null) return;
4101
- const s = await r.channels.retrieve(this.props.channel), a = [s.key];
4102
- s.index !== 0 && a.push(s.index), e ? await this.controller.setAuthority(a, this.props.authority) : await this.controller.releaseAuthority(a);
4103
- }, "failed to set channel authority");
4104
- }
4105
- }
4106
- const Ku = (t) => ({
4107
- type: rn.TYPE,
4108
- props: t,
4109
- variant: "sink",
4110
- valueType: "boolean"
4111
- }), iu = p.object({
4112
- channel: p.number()
4113
- }), Qu = p.object({
4114
- valid: p.boolean(),
4115
- color: y.colorZ.optional(),
4116
- authority: p.number()
4117
- });
4118
- class sn extends kr {
4119
- static TYPE = "controlled-status-source";
4120
- prov;
4121
- valid = !1;
4122
- stopListening;
4123
- controller;
4124
- schema = iu;
4125
- constructor(e, n, r) {
4126
- super(r), this.prov = n, this.controller = e;
4127
- }
4128
- async needsControlOf() {
4129
- return [];
4130
- }
4131
- maybeRevalidate() {
4132
- if (this.valid) return;
4133
- const { channel: e } = this.props;
4134
- this.stopListening?.();
4135
- const n = Lt.filterTransfersByChannelKey(e);
4136
- this.stopListening = this.prov.onChange((r) => {
4137
- n(r).length !== 0 && this.notify?.();
4138
- }), this.valid = !0;
4139
- }
4140
- value() {
4141
- this.maybeRevalidate();
4142
- const e = yn.now();
4143
- if (this.props.channel === 0)
4144
- return {
4145
- name: this.controller.key,
4146
- key: this.controller.key,
4147
- variant: "disabled",
4148
- message: "No Channel",
4149
- time: e,
4150
- details: { valid: !1, authority: 0 }
4151
- };
4152
- const n = this.prov.get(this.props.channel);
4153
- return n == null ? {
4154
- name: this.controller.key,
4155
- key: this.controller.key,
4156
- variant: "disabled",
4157
- message: "Uncontrolled",
4158
- time: e,
4159
- details: { valid: !0, color: void 0, authority: 0 }
4160
- } : {
4161
- name: this.controller.key,
4162
- key: n.subject.key,
4163
- variant: n.subject.key === this.controller.key ? "success" : "error",
4164
- message: `Controlled by ${n.subject.name}`,
4165
- time: e,
4166
- details: { valid: !0, color: n.subjectColor, authority: n.authority }
4167
- };
4168
- }
4169
- cleanup() {
4170
- this.controller.deleteTelem(this), this.stopListening?.();
4171
- }
4172
- }
4173
- const Ju = (t) => ({
4174
- type: sn.TYPE,
4175
- props: t,
4176
- variant: "source",
4177
- valueType: "status"
4178
- }), au = p.object({ color: y.colorZ.optional() }).default({ color: void 0 }), ou = p.object({
4179
- statusSource: dn.optional().default(un),
4180
- colorSource: Rt.optional().default(Ge),
4181
- status: Fr.statusZ(au),
4182
- color: y.colorZ.optional()
4183
- });
4184
- class vr extends Z {
4185
- static TYPE = "Indicator";
4186
- schema = ou;
4187
- stopListeningStatus;
4188
- stopListeningColor;
4189
- afterUpdate(e) {
4190
- const { internal: n } = this, { statusSource: r, colorSource: s } = this.state;
4191
- n.statusSource = H(e, r, n.statusSource), n.colorSource = H(e, s, n.colorSource), this.updateState(), this.stopListeningStatus?.(), this.stopListeningColor?.(), this.stopListeningStatus = n.statusSource.onChange(this.updateState.bind(this)), this.stopListeningColor = n.colorSource.onChange(this.updateState.bind(this));
4192
- }
4193
- afterDelete() {
4194
- this.internal.statusSource.cleanup?.(), this.internal.colorSource.cleanup?.();
4195
- }
4196
- render() {
4197
- }
4198
- updateState() {
4199
- const e = this.internal.colorSource.value(), n = this.internal.statusSource.value();
4200
- y.equals(e, this.state.color) && n.message === this.state.status.message || this.setState((r) => ({ ...r, color: e, status: n }));
4201
- }
4202
- }
4203
- const lu = p.object({
4204
- needsControlOf: Ir.keyZ.array(),
4205
- states: Jc.array()
4206
- });
4207
- class Tr extends Z {
4208
- static TYPE = "Legend";
4209
- schema = lu;
4210
- afterUpdate(e) {
4211
- const { internal: n } = this;
4212
- n.stateProv = wt.use(e);
4213
- const r = this.state.needsControlOf;
4214
- n.disconnectStateProv?.();
4215
- const s = Lt.filterTransfersByChannelKey(...r), a = n.stateProv.get(r);
4216
- this.setState((i) => ({ ...i, states: a })), n.disconnectStateProv = n.stateProv.onChange((i) => {
4217
- if (s(i).length === 0) return;
4218
- const o = n.stateProv.get(r);
4219
- this.setState((c) => ({ ...c, states: o }));
4220
- });
4221
- }
4222
- afterDelete() {
4223
- const { internal: e } = this;
4224
- e.disconnectStateProv?.();
4225
- }
4226
- render() {
4227
- }
4228
- }
4229
- const eh = {
4230
- [Sr.TYPE]: Sr,
4231
- [wt.TYPE]: wt,
4232
- [vr.TYPE]: vr,
4233
- [br.TYPE]: br,
4234
- [Tr.TYPE]: Tr
4235
- }, cu = ["fire", "momentary", "pulse"], uu = p.enum(cu), hu = p.object({
4236
- trigger: p.number(),
4237
- sink: Et.optional().default(kt),
4238
- mode: uu.optional().default("fire")
4239
- }), du = 2, fu = 1;
4240
- class wr extends Z {
4241
- static TYPE = "Button";
4242
- schema = hu;
4243
- afterUpdate(e) {
4244
- const { sink: n, mode: r, trigger: s } = this.state, { internal: a } = this;
4245
- a.prevTrigger ??= s, a.sink = Ke(e, n, a.sink);
4246
- const i = a.prevTrigger;
4247
- a.prevTrigger = s;
4248
- const o = s === i + du;
4249
- s === i + fu ? r == "fire" ? this.internal.sink.set(!0) : r == "momentary" && this.internal.sink.set(!1) : o && (r == "momentary" ? this.internal.sink.set(!0) : r == "pulse" && this.internal.sink.set(!0, !1));
4250
- }
4251
- afterDelete() {
4252
- this.internal.sink.cleanup?.();
4253
- }
4254
- }
4255
- const th = { [wr.TYPE]: wr };
4256
- p.enum(["small", "medium", "large", "huge"]);
4257
- const gu = p.object({
4258
- box: g.box,
4259
- telem: fn.optional().default(hn),
4260
- backgroundTelem: Rt.optional().default(Ge),
4261
- level: gn.optional().default("p"),
4262
- color: y.colorZ.optional().default(y.ZERO),
4263
- precision: p.number().optional().default(2),
4264
- minWidth: p.number().optional().default(60),
4265
- width: p.number().optional(),
4266
- notation: $r.notationZ.optional().default("standard"),
4267
- location: K.xy.optional().default({ x: "left", y: "center" }),
4268
- units: p.string().optional().default("RPM"),
4269
- bounds: A.bounds.optional().default(A.construct(0, 100)),
4270
- // New gauge configuration properties
4271
- barWidth: p.number().optional().default(12)
4272
- // Width of the gauge bar in pixels
4273
- }), pu = ["upper2d", "lower2d"];
4274
- class Ct extends Z {
4275
- static TYPE = "gauge";
4276
- static z = gu;
4277
- schema = Ct.z;
4278
- afterUpdate(e) {
4279
- const { internal: n } = this;
4280
- n.render = j.use(e), n.theme = re(e), y.isZero(this.state.color) ? n.textColor = n.theme.colors.gray.l8 : n.textColor = this.state.color, n.telem = H(e, this.state.telem, n.telem), n.stopListening?.(), n.stopListening = n.telem.onChange(() => this.requestRender()), n.backgroundTelem = H(
4281
- e,
4282
- this.state.backgroundTelem,
4283
- n.backgroundTelem
4284
- ), n.stopListeningBackground?.(), n.stopListeningBackground = n.backgroundTelem.onChange(() => this.requestRender()), n.requestRender = qr(e), n.strokeColor = y.isZero(this.state.color) ? n.theme.colors.visualization.palettes.default[0] : this.state.color;
4285
- const r = this.state.box, s = g.width(r) / 2, { barWidth: a } = this.state;
4286
- n.outerRadius = s - 8, n.innerRadius = n.outerRadius - a;
4287
- const i = Math.PI / 2;
4288
- n.gaugeStartAngle = 3 * Math.PI / 4, n.gaugeAngleRange = 2 * Math.PI - i, n.gaugeEndAngle = n.gaugeStartAngle + n.gaugeAngleRange, n.labelRadius = n.outerRadius + 12, n.labelInwardShift = 12, n.centerPos = g.center(r);
4289
- const o = n.centerPos.y + n.labelRadius * Math.sin(n.gaugeStartAngle) + 6;
4290
- n.minLabelPos = d.construct(
4291
- n.centerPos.x + n.labelRadius * Math.cos(n.gaugeStartAngle) + n.labelInwardShift,
4292
- o
4293
- ), n.maxLabelPos = d.construct(
4294
- n.centerPos.x + n.labelRadius * Math.cos(n.gaugeEndAngle) - n.labelInwardShift,
4295
- o
4296
- ), n.valueTextPos = d.translateY(n.centerPos, -6), n.unitsTextPos = d.translateY(n.centerPos, g.height(r) / 9), n.textLevel = this.state.level, n.labelLevel = Nt(Nt(n.textLevel)), this.requestRender();
4297
- }
4298
- afterDelete() {
4299
- const { internal: e } = this;
4300
- e.stopListening?.(), e.stopListeningBackground?.(), e.telem.cleanup?.(), e.backgroundTelem.cleanup?.(), e.requestRender == null ? e.render.erase(g.construct(this.state.box), d.ZERO, ...pu) : e.requestRender("layout");
4301
- }
4302
- requestRender() {
4303
- const { requestRender: e } = this.internal;
4304
- e != null ? e("layout") : this.render({});
4305
- }
4306
- render({ viewportScale: e = G.XY.IDENTITY }) {
4307
- const { internal: n } = this, r = n.render.upper2d.applyScale(e), s = new ve(r, n.theme), a = n.telem.value(), { lower: i, upper: o } = this.state.bounds, c = Number(a), l = A.clamp(this.state.bounds, c), u = o - i, h = u === 0 ? 0 : (l - i) / u, f = n.gaugeStartAngle + h * n.gaugeAngleRange;
4308
- s.text({
4309
- text: a,
4310
- position: n.valueTextPos,
4311
- shade: 10,
4312
- level: n.textLevel,
4313
- align: "middle",
4314
- justify: "center",
4315
- weight: 450,
4316
- code: !0,
4317
- useAtlas: !0
4318
- }), s.text({
4319
- text: this.state.units,
4320
- position: n.unitsTextPos,
4321
- shade: 8,
4322
- level: Nt(n.textLevel),
4323
- align: "middle",
4324
- justify: "center",
4325
- code: !0,
4326
- useAtlas: !0
4327
- }), s.text({
4328
- text: i.toString(),
4329
- position: n.minLabelPos,
4330
- shade: 7,
4331
- level: n.labelLevel,
4332
- align: "middle",
4333
- justify: "center",
4334
- code: !0,
4335
- useAtlas: !0
4336
- }), s.text({
4337
- text: o.toString(),
4338
- position: n.maxLabelPos,
4339
- shade: 7,
4340
- level: n.labelLevel,
4341
- align: "middle",
4342
- justify: "center",
4343
- code: !0,
4344
- useAtlas: !0
4345
- }), s.circle({
4346
- stroke: n.theme.colors.gray.l5,
4347
- radius: { inner: n.innerRadius, outer: n.outerRadius },
4348
- position: n.centerPos,
4349
- angle: { lower: n.gaugeStartAngle, upper: n.gaugeEndAngle },
4350
- lineCap: "round"
4351
- }), s.circle({
4352
- stroke: n.strokeColor,
4353
- radius: { inner: n.innerRadius, outer: n.outerRadius },
4354
- position: n.centerPos,
4355
- angle: {
4356
- lower: n.gaugeStartAngle,
4357
- upper: f
4358
- },
4359
- lineCap: "round"
4360
- });
4361
- }
4362
- }
4363
- const nh = { [Ct.TYPE]: Ct }, mu = p.object({
4364
- enabled: p.boolean(),
4365
- source: ln.optional().default(cn)
4366
- });
4367
- class Cr extends Z {
4368
- static TYPE = "Light";
4369
- schema = mu;
4370
- afterUpdate(e) {
4371
- const { internal: n } = this;
4372
- this.internal.source = H(e, this.state.source, n.source), this.updateEnabledState(), n.stopListening?.(), n.stopListening = n.source.onChange(() => this.updateEnabledState());
4373
- }
4374
- updateEnabledState() {
4375
- const e = this.internal.source.value();
4376
- e !== this.state.enabled && this.setState((n) => ({ ...n, enabled: e }));
4377
- }
4378
- afterDelete() {
4379
- this.internal.stopListening?.(), this.internal.source.cleanup?.();
4380
- }
4381
- }
4382
- const rh = { [Cr.TYPE]: Cr }, yu = p.object({
4383
- trigger: p.number(),
4384
- command: p.number().optional(),
4385
- value: p.number(),
4386
- sink: Ar.optional().default(Mr),
4387
- source: Or.optional().default(Pr)
4388
- });
4389
- class Er extends Z {
4390
- static TYPE = "Setpoint";
4391
- schema = yu;
4392
- afterUpdate(e) {
4393
- const { sink: n, source: r, trigger: s, command: a } = this.state, { internal: i } = this;
4394
- i.prevTrigger ??= s, this.internal.source = H(e, r, this.internal.source), i.sink = Ke(e, n, i.sink);
4395
- const o = i.prevTrigger;
4396
- i.prevTrigger = s, s > o && a != null && this.internal.sink.set(a), this.updateValue(), i.stopListening?.(), i.stopListening = i.source.onChange(() => this.updateValue());
4397
- }
4398
- updateValue() {
4399
- const e = this.internal.source.value();
4400
- e === this.state.value || isNaN(e) || this.setState((n) => ({ ...n, value: e, triggered: !1 }));
4401
- }
4402
- afterDelete() {
4403
- const { internal: e } = this;
4404
- e.stopListening?.(), e.source.cleanup?.(), e.sink.cleanup?.();
4405
- }
4406
- }
4407
- const sh = { [Er.TYPE]: Er }, bu = p.object({
4408
- triggered: p.boolean(),
4409
- enabled: p.boolean(),
4410
- sink: Et.optional().default(kt),
4411
- source: ln.optional().default(cn)
4412
- });
4413
- class Rr extends Z {
4414
- static TYPE = "Toggle";
4415
- schema = bu;
4416
- afterUpdate(e) {
4417
- this.internal.addStatus = oa(e);
4418
- const { sink: n, source: r, triggered: s, enabled: a } = this.state, { triggered: i } = this.prevState, { internal: o } = this;
4419
- o.source = H(e, r, o.source), o.sink = Ke(e, n, o.sink), s && !i && o.sink.set(!a), this.updateEnabledState(), o.stopListening?.(), o.stopListening = o.source.onChange(() => this.updateEnabledState());
4420
- }
4421
- updateEnabledState() {
4422
- const e = this.internal.source.value();
4423
- e !== this.state.enabled && this.setState((n) => ({ ...n, enabled: e, triggered: !1 }));
4424
- }
4425
- afterDelete() {
4426
- this.internal.stopListening?.(), this.internal.source.cleanup?.(), this.internal.sink.cleanup?.();
4427
- }
4428
- }
4429
- const ih = { [Rr.TYPE]: Rr }, $t = { useAtlas: !0 }, xu = p.object({
4430
- box: g.box,
4431
- telem: fn.optional().default(hn),
4432
- backgroundTelem: Rt.optional().default(Ge),
4433
- level: gn.optional().default("p"),
4434
- color: y.colorZ.optional().default(y.ZERO),
4435
- precision: p.number().optional().default(2),
4436
- stalenessTimeout: p.number().optional().default(5),
4437
- stalenessColor: y.colorZ.optional().default(y.ZERO),
4438
- minWidth: p.number().optional().default(60),
4439
- width: p.number().optional(),
4440
- notation: $r.notationZ.optional().default("standard"),
4441
- location: K.xy.optional().default({ x: "left", y: "center" }),
4442
- useWidthForBackground: p.boolean().optional().default(!1),
4443
- valueBackgroundShift: d.xy.optional().default(d.ZERO),
4444
- valueBackgroundOverScan: d.xy.optional().default(d.ZERO)
4445
- }), Su = ["upper2d", "lower2d"];
4446
- class Ve extends Z {
4447
- static TYPE = "value";
4448
- static z = xu;
4449
- schema = Ve.z;
4450
- afterUpdate(e) {
4451
- const { internal: n } = this;
4452
- n.renderCtx = j.use(e), n.theme = re(e), n.telem = H(e, this.state.telem, n.telem), n.stopListening?.(), n.stopListening = n.telem.onChange(() => {
4453
- n.lastReceived = performance.now(), this.requestRender();
4454
- }), n.fontString = Fe(n.theme, { level: this.state.level, code: !0 }), n.backgroundTelem = H(
4455
- e,
4456
- this.state.backgroundTelem,
4457
- n.backgroundTelem
4458
- ), n.stopListeningBackground?.(), n.stopListeningBackground = n.backgroundTelem.onChange(() => this.requestRender()), n.requestRender = qr(e), this.requestRender();
4459
- }
4460
- afterDelete() {
4461
- const { internal: e } = this;
4462
- e.stopListening?.(), e.stopListeningBackground?.(), e.telem.cleanup?.(), e.backgroundTelem.cleanup?.(), e.requestRender == null ? e.renderCtx.erase(g.construct(this.state.box), d.ZERO, ...Su) : e.requestRender("layout");
4463
- }
4464
- requestRender() {
4465
- const { requestRender: e } = this.internal;
4466
- e != null ? e("layout") : this.render({});
4467
- }
4468
- get fontHeight() {
4469
- const { theme: e } = this.internal;
4470
- return e.typography[this.state.level].size * e.sizes.base;
4471
- }
4472
- maybeUpdateWidth(e) {
4473
- const { theme: n } = this.internal, r = e + n.sizes.base + this.fontHeight;
4474
- this.state.width == null || this.state.width + this.fontHeight * 0.5 < r || this.state.minWidth > r && this.state.width !== this.state.minWidth ? this.setState((s) => ({ ...s, width: Math.max(r, s.minWidth) })) : this.state.width - this.fontHeight > r && this.setState((s) => ({ ...s, width: Math.max(r, s.minWidth) }));
4475
- }
4476
- getTextColor() {
4477
- const { theme: e } = this.internal;
4478
- return performance.now() - this.internal.lastReceived > this.state.stalenessTimeout * 1e3 ? y.isZero(this.state.stalenessColor) ? e.colors.warning.m1 : this.state.stalenessColor : y.isZero(this.state.color) ? y.pickByContrast(
4479
- e.colors.border,
4480
- e.colors.gray.l11,
4481
- e.colors.gray.l0
4482
- ) : y.pickByContrast(
4483
- e.colors.border,
4484
- e.colors.gray.l11,
4485
- this.state.color
4486
- );
4487
- }
4488
- render({ viewportScale: e = G.XY.IDENTITY }) {
4489
- const { renderCtx: n, telem: r, backgroundTelem: s, fontString: a, requestRender: i } = this.internal, { location: o, box: c } = this.state;
4490
- if (g.areaIsZero(c)) return;
4491
- const l = g.topLeft(c), u = g.width(c), h = g.height(c), f = n.lower2d.applyScale(e);
4492
- let b = r.value();
4493
- f.font = a;
4494
- const v = this.fontHeight, S = b[0] == "-";
4495
- S && (b = b.slice(1));
4496
- const { theme: T } = this.internal, k = f.textDimensions(b, $t), L = k.width + T.sizes.base, D = k.height;
4497
- i == null && n.erase(g.construct(this.prevState.box)), this.maybeUpdateWidth(L);
4498
- const N = { ...d.ZERO };
4499
- o.x === "left" ? N.x = 6 + v * 0.75 : o.x === "center" && (N.x = u / 2 - L / 2), o.y === "center" && (N.y = h / 2 + D / 2);
4500
- const _ = d.translate(l, N);
4501
- if (this.state.backgroundTelem.type != Ge.type) {
4502
- const I = s.value();
4503
- if (!y.isZero(I)) {
4504
- f.fillStyle = y.hex(I);
4505
- const Ie = this.state.useWidthForBackground ? this.state.width ?? this.state.minWidth : g.width(c);
4506
- f.fillRect(
4507
- ...d.couple(d.translate(l, this.state.valueBackgroundShift)),
4508
- Ie + this.state.valueBackgroundOverScan.x,
4509
- h + this.state.valueBackgroundOverScan.y
4510
- );
4511
- }
4512
- }
4513
- const w = this.getTextColor();
4514
- f.fillStyle = y.hex(w), S && f.fillText(
4515
- "-",
4516
- ...d.couple(d.translateX(_, -v * 0.6)),
4517
- void 0,
4518
- $t
4519
- ), f.fillText(b, ...d.couple(_), void 0, $t);
4520
- }
4521
- }
4522
- const vu = {
4523
- [Ve.TYPE]: Ve
4524
- }, ah = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4525
- __proto__: null,
4526
- REGISTRY: vu,
4527
- Value: Ve
4528
- }, Symbol.toStringTag, { value: "Module" })), Tu = pe.object({}), an = "flux-context", bs = "flux.Provider", wu = (t, e) => t.get(an).scopedStore(e), Cu = (t) => {
4529
- const e = (n, r) => {
4530
- if ("client" in t) return t.client;
4531
- const s = Pt(n);
4532
- return r != null && r?.client?.key === s?.key ? r : new so({
4533
- client: s,
4534
- storeConfig: t.storeConfig,
4535
- handleError: he(n),
4536
- handleAsyncError: la(n)
4537
- });
4538
- };
4539
- return class xs extends fe {
4540
- static TYPE = bs;
4541
- static stateZ = Tu;
4542
- schema = xs.stateZ;
4543
- afterUpdate(r) {
4544
- const { internal: s } = this;
4545
- s.store = e(r, s.store), r.wasSetPreviously(an) || r.set(an, s.store);
4546
- }
4547
- };
4548
- }, oh = (t) => ({ [bs]: Cu(t) });
4549
- export {
4550
- cc as $,
4551
- ju as A,
4552
- Xt as B,
4553
- Hu as C,
4554
- qu as D,
4555
- Wu as E,
4556
- Xu as F,
4557
- Zu as G,
4558
- Pu as H,
4559
- Au as I,
4560
- Ou as J,
4561
- Bu as K,
4562
- mr as L,
4563
- _u as M,
4564
- ah as N,
4565
- dt as O,
4566
- Hn as P,
4567
- _a as Q,
4568
- Fu as R,
4569
- ze as S,
4570
- wn as T,
4571
- Wr as U,
4572
- Wt as V,
4573
- Xr as W,
4574
- tn as X,
4575
- Jt as Y,
4576
- Le as Z,
4577
- _e as _,
4578
- Sn as a,
4579
- Cr as a$,
4580
- dc as a0,
4581
- uc as a1,
4582
- hs as a2,
4583
- lc as a3,
4584
- dr as a4,
4585
- us as a5,
4586
- cs as a6,
4587
- rn as a7,
4588
- sn as a8,
4589
- br as a9,
4590
- to as aA,
4591
- Nu as aB,
4592
- Wn as aC,
4593
- De as aD,
4594
- wc as aE,
4595
- yc as aF,
4596
- Ot as aG,
4597
- Za as aH,
4598
- zt as aI,
4599
- ms as aJ,
4600
- St as aK,
4601
- Mc as aL,
4602
- en as aM,
4603
- ys as aN,
4604
- vt as aO,
4605
- ps as aP,
4606
- xt as aQ,
4607
- Bc as aR,
4608
- Tt as aS,
4609
- wr as aT,
4610
- hu as aU,
4611
- fu as aV,
4612
- du as aW,
4613
- cu as aX,
4614
- Ve as aY,
4615
- Ct as aZ,
4616
- mu as a_,
4617
- Sr as aa,
4618
- vr as ab,
4619
- Tr as ac,
4620
- eu as ad,
4621
- nn as ae,
4622
- wt as af,
4623
- Ku as ag,
4624
- su as ah,
4625
- Ju as ai,
4626
- Qu as aj,
4627
- iu as ak,
4628
- Kc as al,
4629
- Gc as am,
4630
- nu as an,
4631
- ou as ao,
4632
- au as ap,
4633
- lu as aq,
4634
- Gu as ar,
4635
- ru as as,
4636
- Qc as at,
4637
- tu as au,
4638
- Jc as av,
4639
- bs as aw,
4640
- Tu as ax,
4641
- so as ay,
4642
- eo as az,
4643
- ao as b,
4644
- yu as b0,
4645
- Er as b1,
4646
- bu as b2,
4647
- Rr as b3,
4648
- Xe as b4,
4649
- xn as c,
4650
- nh as d,
4651
- Vu as e,
4652
- $u as f,
4653
- vu as g,
4654
- Nc as h,
4655
- ih as i,
4656
- sh as j,
4657
- Ec as k,
4658
- Ic as l,
4659
- Yu as m,
4660
- _c as n,
4661
- Lu as o,
4662
- rh as p,
4663
- Ja as q,
4664
- de as r,
4665
- eh as s,
4666
- Qa as t,
4667
- qr as u,
4668
- th as v,
4669
- oh as w,
4670
- Uu as x,
4671
- Iu as y,
4672
- zu as z
4673
- };