@synnaxlabs/pluto 0.41.0 → 0.42.3

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 (444) hide show
  1. package/dist/{Center-Dr9Np3yZ.js → Center-D0JeI7Ta.js} +2 -2
  2. package/dist/{Center-sJghNsrv.cjs → Center-DuI3XH-Q.cjs} +1 -1
  3. package/dist/{ContextMenu-GUed89mt.js → ContextMenu-BiNr7Gxv.js} +19 -20
  4. package/dist/ContextMenu-HpMLd1Ht.cjs +1 -0
  5. package/dist/DateTime-BsjSfOY-.cjs +1 -0
  6. package/dist/{DateTime-DEbT6v4l.js → DateTime-r6hocEmI.js} +2 -2
  7. package/dist/{Divider-Bpe7zJig.js → Divider-DqEkzRIY.js} +103 -97
  8. package/dist/{Divider-CloQr3vQ.cjs → Divider-Dut8qPee.cjs} +4 -4
  9. package/dist/Dropdown-BSSe1E1e.cjs +1 -0
  10. package/dist/{Dropdown-4Cti-bbQ.js → Dropdown-BrFL1eSc.js} +111 -112
  11. package/dist/Haul-C6i2oI7z.cjs +1 -0
  12. package/dist/{Haul-Bw54Yj6J.js → Haul-CEFSvdy9.js} +37 -38
  13. package/dist/{Item-9WCCzBv2.js → Item-C5SQraZM.js} +10 -11
  14. package/dist/Item-DSBs9VLu.cjs +1 -0
  15. package/dist/{Keyboard-CZFi6COK.cjs → Keyboard-Ca7TAAHK.cjs} +1 -1
  16. package/dist/{Keyboard-634856lT.js → Keyboard-Duo41pJL.js} +2 -2
  17. package/dist/{Link-fkoogssj.cjs → Link-B9ZGvoBU.cjs} +1 -1
  18. package/dist/{Link-BEheZd26.js → Link-C9GeoB0w.js} +1 -1
  19. package/dist/{Pack-DhZO_rza.js → Pack-BozAEHBp.js} +2 -2
  20. package/dist/{Pack-D6Z6WuZl.cjs → Pack-DeZUUdJM.cjs} +1 -1
  21. package/dist/{Provider-UAXPVomG.js → Provider-B86QO9NT.js} +301 -292
  22. package/dist/Provider-Cw0mSr2D.cjs +1 -0
  23. package/dist/{Space-DunsWl06.js → Space-CyTH97CN.js} +1 -1
  24. package/dist/{Space-BtaH1buB.cjs → Space-DvalhzRj.cjs} +1 -1
  25. package/dist/Text-8ps3Uw4T.js +35 -0
  26. package/dist/{Text-3PiRcn8q.js → Text-BR4FW9Hy.js} +75 -77
  27. package/dist/Text-C8GBHl-F.cjs +1 -0
  28. package/dist/Text-CMTkSEWx.cjs +4 -0
  29. package/dist/Text-DkA06TeT.cjs +1 -0
  30. package/dist/Text-sH_NOelc.js +137 -0
  31. package/dist/{Toggle-CZd8L4GI.js → Toggle-BRuUrO2N.js} +99 -101
  32. package/dist/Toggle-C0lZDyeo.cjs +1 -0
  33. package/dist/{Video-4XQ1qozd.js → Video-DWStbcmD.js} +1 -1
  34. package/dist/{Video-BM9uJLaQ.cjs → Video-DgjuFLiE.cjs} +1 -1
  35. package/dist/WithIcon-BgS5shNZ.cjs +1 -0
  36. package/dist/WithIcon-BhR6nwRh.js +98 -0
  37. package/dist/align.cjs +1 -1
  38. package/dist/align.js +1 -1
  39. package/dist/button.cjs +1 -1
  40. package/dist/button.js +1 -1
  41. package/dist/color.cjs +1 -1
  42. package/dist/color.js +1 -1
  43. package/dist/css-9iEiTRNL.cjs +15 -0
  44. package/dist/css-Cnb9DQMD.js +4747 -0
  45. package/dist/css.cjs +1 -1
  46. package/dist/css.js +2 -2
  47. package/dist/deep-BNa3STCp.cjs +1 -0
  48. package/dist/deep-P35D0Sz7.js +112 -0
  49. package/dist/dimensions-B6qmnzv3.js +19 -0
  50. package/dist/dimensions-By-vgVks.cjs +1 -0
  51. package/dist/dropdown.cjs +1 -1
  52. package/dist/dropdown.js +1 -1
  53. package/dist/eraser-BkqFgBRY.cjs +11 -0
  54. package/dist/eraser-CK8SwEJa.js +1148 -0
  55. package/dist/ether.cjs +1 -1
  56. package/dist/ether.js +67 -75
  57. package/dist/external-B1YsdhS4.js +432 -0
  58. package/dist/{external-BY2AjzRx.js → external-B7NxSklQ.js} +20 -19
  59. package/dist/external-B8uaUKhb.cjs +1 -0
  60. package/dist/external-BA_VOnV-.js +400 -0
  61. package/dist/{external-DNF8yEwq.js → external-BDkqwq72.js} +27 -28
  62. package/dist/external-BGBgNbe2.cjs +1 -0
  63. package/dist/{external-CVGidiDt.js → external-BOMdfX8_.js} +2 -2
  64. package/dist/{external-BIwhkj24.js → external-Bl8q9UBF.js} +1996 -2011
  65. package/dist/{external-BFOrrNde.js → external-BnK4UIFe.js} +3 -3
  66. package/dist/{external-CnxSp7fm.cjs → external-BwUa_5Vs.cjs} +1 -1
  67. package/dist/{external-BlUic3Vz.js → external-C0X4mXVG.js} +7 -8
  68. package/dist/{external-CH66YjTZ.js → external-C7yPkamb.js} +12 -13
  69. package/dist/external-CTc1n-JC.cjs +1 -0
  70. package/dist/{external-B-Cao-ae.cjs → external-CUgPP-JD.cjs} +1 -1
  71. package/dist/external-CzTBFiv_.cjs +1 -0
  72. package/dist/external-DGJ8YAe-.cjs +1 -0
  73. package/dist/{external-kZf9CjYn.cjs → external-DQwznOyH.cjs} +37 -37
  74. package/dist/external-DiLZ1dEk.cjs +1 -0
  75. package/dist/{external-BCUxzSzk.js → external-DissGp_3.js} +9 -10
  76. package/dist/{external-DVajt6X6.cjs → external-DmryCcwg.cjs} +1 -1
  77. package/dist/external-Dq8-cbf3.cjs +1 -0
  78. package/dist/{external-BbrPEGJw.js → external-_8qdWaAg.js} +2 -2
  79. package/dist/{external-C0ZRdtdj.js → external-bSUra-q7.js} +28 -28
  80. package/dist/external-zbKPQ9ls.cjs +46 -0
  81. package/dist/{font-BXKdXsr5.js → font-CjYcjBiv.js} +2 -2
  82. package/dist/{font-DCE90lco.cjs → font-XlUAG1-r.cjs} +1 -1
  83. package/dist/{fontString-C7Q9Laqk.js → fontString-BN1kd1AP.js} +1 -1
  84. package/dist/{fontString-BBvH9Ypy.cjs → fontString-Ddza50DF.cjs} +1 -1
  85. package/dist/header.cjs +1 -1
  86. package/dist/header.js +1 -1
  87. package/dist/hooks-B5aLaWzS.cjs +1 -0
  88. package/dist/hooks-DjznxGgm.js +296 -0
  89. package/dist/index.cjs +7 -7
  90. package/dist/index.js +8669 -8584
  91. package/dist/input.cjs +1 -1
  92. package/dist/input.js +1 -1
  93. package/dist/list.cjs +1 -1
  94. package/dist/list.js +1 -1
  95. package/dist/menu.cjs +1 -1
  96. package/dist/menu.js +1 -1
  97. package/dist/pluto.css +1 -1
  98. package/dist/provider-aWtsGnV8.cjs +58 -0
  99. package/dist/provider-r5Ly36FI.js +12854 -0
  100. package/dist/src/aether/aether/aether.d.ts +17 -18
  101. package/dist/src/aether/aether/aether.d.ts.map +1 -1
  102. package/dist/src/aether/aether/aether.spec.spec.d.ts +1 -5
  103. package/dist/src/aether/aether/aether.spec.spec.d.ts.map +1 -1
  104. package/dist/src/aether/main.d.ts.map +1 -1
  105. package/dist/src/aether/main.spec.d.ts +1 -5
  106. package/dist/src/aether/main.spec.d.ts.map +1 -1
  107. package/dist/src/aether/message.d.ts +11 -1
  108. package/dist/src/aether/message.d.ts.map +1 -1
  109. package/dist/src/alamos/aether/alamos.d.ts +19 -25
  110. package/dist/src/alamos/aether/alamos.d.ts.map +1 -1
  111. package/dist/src/button/Button.d.ts +2 -2
  112. package/dist/src/button/Button.d.ts.map +1 -1
  113. package/dist/src/button/color.d.ts +2 -2
  114. package/dist/src/button/color.d.ts.map +1 -1
  115. package/dist/src/channel/LinePlot.d.ts +4 -4
  116. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  117. package/dist/src/color/BaseSwatch.d.ts +3 -3
  118. package/dist/src/color/BaseSwatch.d.ts.map +1 -1
  119. package/dist/src/color/GradientPicker.d.ts +1 -2
  120. package/dist/src/color/GradientPicker.d.ts.map +1 -1
  121. package/dist/src/color/Picker.d.ts +1 -1
  122. package/dist/src/color/Picker.d.ts.map +1 -1
  123. package/dist/src/color/Provider.d.ts +10 -98
  124. package/dist/src/color/Provider.d.ts.map +1 -1
  125. package/dist/src/color/external.d.ts +0 -4
  126. package/dist/src/color/external.d.ts.map +1 -1
  127. package/dist/src/css/color.d.ts +2 -2
  128. package/dist/src/css/color.d.ts.map +1 -1
  129. package/dist/src/divider/Divider.d.ts +2 -1
  130. package/dist/src/divider/Divider.d.ts.map +1 -1
  131. package/dist/src/ether.d.ts +0 -1
  132. package/dist/src/ether.d.ts.map +1 -1
  133. package/dist/src/form/Form.d.ts +1 -1
  134. package/dist/src/form/Form.d.ts.map +1 -1
  135. package/dist/src/haul/Haul.d.ts +7 -63
  136. package/dist/src/haul/Haul.d.ts.map +1 -1
  137. package/dist/src/hooks/useResize.d.ts.map +1 -1
  138. package/dist/src/index.d.ts +1 -0
  139. package/dist/src/index.d.ts.map +1 -1
  140. package/dist/src/input/Text.d.ts +4 -4
  141. package/dist/src/input/Text.d.ts.map +1 -1
  142. package/dist/src/mosaic/types.d.ts +6 -66
  143. package/dist/src/mosaic/types.d.ts.map +1 -1
  144. package/dist/src/pluto/Pluto.d.ts.map +1 -1
  145. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  146. package/dist/src/select/Multiple.d.ts +2 -3
  147. package/dist/src/select/Multiple.d.ts.map +1 -1
  148. package/dist/src/state/state.d.ts +1 -2
  149. package/dist/src/state/state.d.ts.map +1 -1
  150. package/dist/src/status/Circle.d.ts.map +1 -1
  151. package/dist/src/status/aether/aggregator.d.ts +34 -96
  152. package/dist/src/status/aether/aggregator.d.ts.map +1 -1
  153. package/dist/src/status/aether/types.d.ts +23 -27
  154. package/dist/src/status/aether/types.d.ts.map +1 -1
  155. package/dist/src/synnax/Provider.d.ts +4 -0
  156. package/dist/src/synnax/Provider.d.ts.map +1 -1
  157. package/dist/src/synnax/aether/provider.d.ts +54 -388
  158. package/dist/src/synnax/aether/provider.d.ts.map +1 -1
  159. package/dist/src/table/aether/Table.d.ts +58 -418
  160. package/dist/src/table/aether/Table.d.ts.map +1 -1
  161. package/dist/src/table/cells/Cells.d.ts +41 -152
  162. package/dist/src/table/cells/Cells.d.ts.map +1 -1
  163. package/dist/src/table/cells/Forms.d.ts.map +1 -1
  164. package/dist/src/table/cells/registry.d.ts +6 -3
  165. package/dist/src/table/cells/registry.d.ts.map +1 -1
  166. package/dist/src/tabs/Selector.d.ts.map +1 -1
  167. package/dist/src/tabs/types.d.ts +5 -38
  168. package/dist/src/tabs/types.d.ts.map +1 -1
  169. package/dist/src/tag/Tag.d.ts +3 -4
  170. package/dist/src/tag/Tag.d.ts.map +1 -1
  171. package/dist/src/telem/aether/context.d.ts +8 -8
  172. package/dist/src/telem/aether/context.d.ts.map +1 -1
  173. package/dist/src/telem/aether/factory.d.ts +6 -2
  174. package/dist/src/telem/aether/factory.d.ts.map +1 -1
  175. package/dist/src/telem/aether/noop.d.ts.map +1 -1
  176. package/dist/src/telem/aether/pipeline.d.ts +25 -215
  177. package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
  178. package/dist/src/telem/aether/provider.d.ts +7 -5
  179. package/dist/src/telem/aether/provider.d.ts.map +1 -1
  180. package/dist/src/telem/aether/remote.d.ts +62 -183
  181. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  182. package/dist/src/telem/aether/static.d.ts +23 -72
  183. package/dist/src/telem/aether/static.d.ts.map +1 -1
  184. package/dist/src/telem/aether/telem.d.ts +60 -284
  185. package/dist/src/telem/aether/telem.d.ts.map +1 -1
  186. package/dist/src/telem/aether/transformers.d.ts +82 -318
  187. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  188. package/dist/src/telem/client/cache/cache.d.ts +1 -1
  189. package/dist/src/telem/client/cache/cache.d.ts.map +1 -1
  190. package/dist/src/telem/client/cache/dynamic.d.ts +5 -5
  191. package/dist/src/telem/client/cache/dynamic.d.ts.map +1 -1
  192. package/dist/src/telem/client/cache/static.d.ts +3 -3
  193. package/dist/src/telem/client/cache/static.d.ts.map +1 -1
  194. package/dist/src/telem/client/cache/unary.d.ts +3 -3
  195. package/dist/src/telem/client/cache/unary.d.ts.map +1 -1
  196. package/dist/src/telem/client/client.d.ts +8 -12
  197. package/dist/src/telem/client/client.d.ts.map +1 -1
  198. package/dist/src/telem/client/external.d.ts +0 -1
  199. package/dist/src/telem/client/external.d.ts.map +1 -1
  200. package/dist/src/telem/client/reader.d.ts +28 -10
  201. package/dist/src/telem/client/reader.d.ts.map +1 -1
  202. package/dist/src/telem/client/reader.spec.d.ts +6 -1
  203. package/dist/src/telem/client/reader.spec.d.ts.map +1 -1
  204. package/dist/src/telem/client/streamer.d.ts +6 -6
  205. package/dist/src/telem/client/streamer.d.ts.map +1 -1
  206. package/dist/src/telem/client/streamer.spec.d.ts +2 -0
  207. package/dist/src/telem/client/streamer.spec.d.ts.map +1 -0
  208. package/dist/src/telem/control/Indicator.d.ts.map +1 -1
  209. package/dist/src/telem/control/aether/chip.d.ts +44 -232
  210. package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
  211. package/dist/src/telem/control/aether/controller.d.ts +36 -73
  212. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  213. package/dist/src/telem/control/aether/indicator.d.ts +53 -253
  214. package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
  215. package/dist/src/telem/control/aether/legend.d.ts +22 -128
  216. package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
  217. package/dist/src/telem/control/aether/state.d.ts +12 -42
  218. package/dist/src/telem/control/aether/state.d.ts.map +1 -1
  219. package/dist/src/text/Text.d.ts +5 -4
  220. package/dist/src/text/Text.d.ts.map +1 -1
  221. package/dist/src/text/core/types.d.ts +17 -14
  222. package/dist/src/text/core/types.d.ts.map +1 -1
  223. package/dist/src/text/dimensions.d.ts +1 -0
  224. package/dist/src/text/dimensions.d.ts.map +1 -1
  225. package/dist/src/theming/aether/provider.d.ts +1156 -5764
  226. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  227. package/dist/src/theming/core/theme.d.ts +558 -1740
  228. package/dist/src/theming/core/theme.d.ts.map +1 -1
  229. package/dist/src/theming/css.d.ts.map +1 -1
  230. package/dist/src/tree/Tree.d.ts +1 -1
  231. package/dist/src/tree/Tree.d.ts.map +1 -1
  232. package/dist/src/tree/core.d.ts.map +1 -1
  233. package/dist/src/triggers/Provider.d.ts.map +1 -1
  234. package/dist/src/triggers/triggers.d.ts +248 -9
  235. package/dist/src/triggers/triggers.d.ts.map +1 -1
  236. package/dist/src/util/component.d.ts +7 -1
  237. package/dist/src/util/component.d.ts.map +1 -1
  238. package/dist/src/viewport/use.d.ts +8 -1
  239. package/dist/src/viewport/use.d.ts.map +1 -1
  240. package/dist/src/vis/axis/axis.d.ts +21 -44
  241. package/dist/src/vis/axis/axis.d.ts.map +1 -1
  242. package/dist/src/vis/axis/canvas.d.ts +17 -20
  243. package/dist/src/vis/axis/canvas.d.ts.map +1 -1
  244. package/dist/src/vis/axis/preciseTimeScale.d.ts +1 -2
  245. package/dist/src/vis/axis/preciseTimeScale.d.ts.map +1 -1
  246. package/dist/src/vis/axis/ticks.d.ts +11 -11
  247. package/dist/src/vis/axis/ticks.d.ts.map +1 -1
  248. package/dist/src/vis/button/aether/button.d.ts +10 -80
  249. package/dist/src/vis/button/aether/button.d.ts.map +1 -1
  250. package/dist/src/vis/canvas/Canvas.d.ts +2 -2
  251. package/dist/src/vis/canvas/Canvas.d.ts.map +1 -1
  252. package/dist/src/vis/canvas/aether/canvas.d.ts +45 -193
  253. package/dist/src/vis/canvas/aether/canvas.d.ts.map +1 -1
  254. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  255. package/dist/src/vis/diagram/aether/Diagram.d.ts +62 -469
  256. package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
  257. package/dist/src/vis/diagram/aether/types.d.ts +32 -246
  258. package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
  259. package/dist/src/vis/diagram/edge/Edge.d.ts +2 -3
  260. package/dist/src/vis/diagram/edge/Edge.d.ts.map +1 -1
  261. package/dist/src/vis/diagram/edge/connector/connector.d.ts +5 -8
  262. package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
  263. package/dist/src/vis/diagram/edge/paths.d.ts +3 -4
  264. package/dist/src/vis/diagram/edge/paths.d.ts.map +1 -1
  265. package/dist/src/vis/draw2d/canvas.d.ts +21 -3
  266. package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
  267. package/dist/src/vis/draw2d/index.d.ts +3 -4
  268. package/dist/src/vis/draw2d/index.d.ts.map +1 -1
  269. package/dist/src/vis/eraser/aether/eraser.d.ts +30 -170
  270. package/dist/src/vis/eraser/aether/eraser.d.ts.map +1 -1
  271. package/dist/src/vis/grid/grid.d.ts +14 -24
  272. package/dist/src/vis/grid/grid.d.ts.map +1 -1
  273. package/dist/src/vis/legend/Container.d.ts +42 -86
  274. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  275. package/dist/src/vis/legend/Simple.d.ts +3 -4
  276. package/dist/src/vis/legend/Simple.d.ts.map +1 -1
  277. package/dist/src/vis/light/aether/light.d.ts +10 -80
  278. package/dist/src/vis/light/aether/light.d.ts.map +1 -1
  279. package/dist/src/vis/line/aether/line.d.ts +20 -99
  280. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  281. package/dist/src/vis/lineplot/Axis.d.ts.map +1 -1
  282. package/dist/src/vis/lineplot/LinePlot.d.ts +2 -3
  283. package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
  284. package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts +35 -0
  285. package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts.map +1 -0
  286. package/dist/src/vis/lineplot/aether/LinePlot.d.ts +82 -489
  287. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
  288. package/dist/src/vis/lineplot/aether/XAxis.d.ts +63 -187
  289. package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +1 -1
  290. package/dist/src/vis/lineplot/aether/YAxis.d.ts +61 -190
  291. package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +1 -1
  292. package/dist/src/vis/lineplot/aether/axis.d.ts +33 -96
  293. package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
  294. package/dist/src/vis/lineplot/aether/external.d.ts +1 -0
  295. package/dist/src/vis/lineplot/aether/external.d.ts.map +1 -1
  296. package/dist/src/vis/lineplot/external.d.ts +1 -0
  297. package/dist/src/vis/lineplot/external.d.ts.map +1 -1
  298. package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
  299. package/dist/src/vis/lineplot/range/aether/annotation.d.ts +15 -52
  300. package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +1 -1
  301. package/dist/src/vis/lineplot/range/aether/provider.d.ts +43 -294
  302. package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
  303. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts +33 -138
  304. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
  305. package/dist/src/vis/lineplot/useBoundQuerier.d.ts +11 -0
  306. package/dist/src/vis/lineplot/useBoundQuerier.d.ts.map +1 -0
  307. package/dist/src/vis/log/aether/Log.d.ts +88 -455
  308. package/dist/src/vis/log/aether/Log.d.ts.map +1 -1
  309. package/dist/src/vis/measure/aether/measure.d.ts +40 -233
  310. package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
  311. package/dist/src/vis/performance/Performance.d.ts +2 -0
  312. package/dist/src/vis/performance/Performance.d.ts.map +1 -0
  313. package/dist/src/vis/performance/aether/index.d.ts +2 -0
  314. package/dist/src/vis/performance/aether/index.d.ts.map +1 -0
  315. package/dist/src/vis/performance/aether/performance.d.ts +15 -0
  316. package/dist/src/vis/performance/aether/performance.d.ts.map +1 -0
  317. package/dist/src/vis/performance/index.d.ts +2 -0
  318. package/dist/src/vis/performance/index.d.ts.map +1 -0
  319. package/dist/src/vis/render/GLProgram.d.ts +1 -2
  320. package/dist/src/vis/render/GLProgram.d.ts.map +1 -1
  321. package/dist/src/vis/render/context.d.ts +1 -0
  322. package/dist/src/vis/render/context.d.ts.map +1 -1
  323. package/dist/src/vis/render/controller.d.ts +7 -12
  324. package/dist/src/vis/render/controller.d.ts.map +1 -1
  325. package/dist/src/vis/render/loop.d.ts +15 -5
  326. package/dist/src/vis/render/loop.d.ts.map +1 -1
  327. package/dist/src/vis/rule/Rule.d.ts +1 -1
  328. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  329. package/dist/src/vis/rule/aether/aether.d.ts +12 -53
  330. package/dist/src/vis/rule/aether/aether.d.ts.map +1 -1
  331. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  332. package/dist/src/vis/schematic/Symbols.d.ts +3 -4
  333. package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
  334. package/dist/src/vis/schematic/primitives/Primitives.d.ts +34 -35
  335. package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
  336. package/dist/src/vis/schematic/registry.d.ts +96 -1
  337. package/dist/src/vis/schematic/registry.d.ts.map +1 -1
  338. package/dist/src/vis/setpoint/aether/setpoint.d.ts +16 -155
  339. package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
  340. package/dist/src/vis/text/atlas.d.ts +32 -0
  341. package/dist/src/vis/text/atlas.d.ts.map +1 -0
  342. package/dist/src/vis/text/index.d.ts +2 -0
  343. package/dist/src/vis/text/index.d.ts.map +1 -0
  344. package/dist/src/vis/toggle/aether/toggle.d.ts +16 -150
  345. package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
  346. package/dist/src/vis/value/aether/value.d.ts +150 -563
  347. package/dist/src/vis/value/aether/value.d.ts.map +1 -1
  348. package/dist/src/vis/value/use.d.ts +59 -199
  349. package/dist/src/vis/value/use.d.ts.map +1 -1
  350. package/dist/{state-Bd_8X2jl.cjs → state-_FFrG5nH.cjs} +1 -1
  351. package/dist/tabs.cjs +1 -1
  352. package/dist/tabs.js +1 -1
  353. package/dist/text.cjs +1 -1
  354. package/dist/text.js +2 -2
  355. package/dist/theming.cjs +1 -1
  356. package/dist/theming.js +2 -2
  357. package/dist/{toArray-Dvn9FA_3.js → toArray-B7nD2CTw.js} +1 -1
  358. package/dist/{toArray-DRKOku1s.cjs → toArray-BvVYuN_b.cjs} +1 -1
  359. package/dist/tree.cjs +1 -1
  360. package/dist/tree.js +1 -1
  361. package/dist/triggers.cjs +1 -1
  362. package/dist/triggers.js +1 -1
  363. package/dist/units-CX_coN92.cjs +1 -0
  364. package/dist/units-Ct3Xl5nK.js +11 -0
  365. package/dist/useClickOutside-CSff8yb-.cjs +1 -0
  366. package/dist/useClickOutside-DDCP7Fh-.js +106 -0
  367. package/dist/{useDebouncedCallback-Dg4BDGP-.js → useDebouncedCallback-BG4I7mbT.js} +1 -1
  368. package/dist/useDebouncedCallback-DnwYZzjR.cjs +1 -0
  369. package/dist/{useMemoCompare-BEDaTIXL.js → useMemoCompare-BViQehyd.js} +2 -2
  370. package/dist/useMemoCompare-C2X7Mzx8.cjs +1 -0
  371. package/dist/useVirtualCursorDragWebKit-DDmXE4RW.cjs +1 -0
  372. package/dist/{useVirtualCursorDragWebKit-BixysrXI.js → useVirtualCursorDragWebKit-DTU2tUmp.js} +22 -23
  373. package/dist/value-B6OlPXe1.js +5974 -0
  374. package/dist/value-Bq1w9UY8.cjs +57 -0
  375. package/dist/video.cjs +1 -1
  376. package/dist/video.js +1 -1
  377. package/package.json +9 -8
  378. package/dist/ContextMenu-DCxj35_j.cjs +0 -1
  379. package/dist/DateTime-D6J8sRSH.cjs +0 -1
  380. package/dist/Dropdown-C7Im-qW-.cjs +0 -1
  381. package/dist/Haul-hv7TLQ7N.cjs +0 -1
  382. package/dist/Item-piF6rFAm.cjs +0 -1
  383. package/dist/Provider-DNTq46b0.cjs +0 -1
  384. package/dist/Text-BTEov6di.cjs +0 -1
  385. package/dist/Text-CaRMYy3U.js +0 -135
  386. package/dist/Text-DNspRcte.js +0 -36
  387. package/dist/Text-DylGoRKw.cjs +0 -4
  388. package/dist/Text-X_BHez8W.cjs +0 -1
  389. package/dist/Toggle-BKKBcuTj.cjs +0 -1
  390. package/dist/WithIcon-CC-RSx6r.js +0 -93
  391. package/dist/WithIcon-Dn8eAoMj.cjs +0 -1
  392. package/dist/aggregator-74jWxDne.cjs +0 -1
  393. package/dist/aggregator-DMvP8cai.js +0 -83
  394. package/dist/css-Cj2UCGXB.cjs +0 -1
  395. package/dist/css-Dyt-QnKy.js +0 -1199
  396. package/dist/deep-Cvb4bVYY.js +0 -105
  397. package/dist/deep-ICSlPm58.cjs +0 -1
  398. package/dist/dimensions-Cc0z-IDd.js +0 -18
  399. package/dist/dimensions-Djqdrqi0.cjs +0 -1
  400. package/dist/eraser-9-LOWZvk.cjs +0 -11
  401. package/dist/eraser-BjtEI-1I.js +0 -823
  402. package/dist/external-B-UNCzPY.cjs +0 -1
  403. package/dist/external-B18FBGpk.cjs +0 -1
  404. package/dist/external-BG1mV1W8.cjs +0 -1
  405. package/dist/external-BWeX0nyq.js +0 -399
  406. package/dist/external-BbmpRAH3.cjs +0 -1
  407. package/dist/external-D2vS6j9c.cjs +0 -46
  408. package/dist/external-DHmQqAfL.js +0 -435
  409. package/dist/external-DRGfSFQT.cjs +0 -1
  410. package/dist/external-DX4m-5qT.cjs +0 -1
  411. package/dist/external-DlywBW-S.cjs +0 -1
  412. package/dist/hooks-BQJQyGWV.js +0 -293
  413. package/dist/hooks-ClXSlga9.cjs +0 -1
  414. package/dist/index-CSKP1UPN.js +0 -2343
  415. package/dist/index-Ch3utIMa.cjs +0 -15
  416. package/dist/provider-CH0eoGfz.js +0 -10358
  417. package/dist/provider-D054LCpB.cjs +0 -53
  418. package/dist/src/color/core/color.d.ts +0 -143
  419. package/dist/src/color/core/color.d.ts.map +0 -1
  420. package/dist/src/color/core/color.spec.d.ts +0 -2
  421. package/dist/src/color/core/color.spec.d.ts.map +0 -1
  422. package/dist/src/color/core/external.d.ts +0 -5
  423. package/dist/src/color/core/external.d.ts.map +0 -1
  424. package/dist/src/color/core/gradient.d.ts +0 -58
  425. package/dist/src/color/core/gradient.d.ts.map +0 -1
  426. package/dist/src/color/core/index.d.ts +0 -2
  427. package/dist/src/color/core/index.d.ts.map +0 -1
  428. package/dist/src/color/core/palette.d.ts +0 -74
  429. package/dist/src/color/core/palette.d.ts.map +0 -1
  430. package/dist/src/color/core/transformColorsToHex.d.ts +0 -6
  431. package/dist/src/color/core/transformColorsToHex.d.ts.map +0 -1
  432. package/dist/src/telem/client/types.d.ts +0 -20
  433. package/dist/src/telem/client/types.d.ts.map +0 -1
  434. package/dist/transformColorsToHex-DE7uEs1w.cjs +0 -1
  435. package/dist/transformColorsToHex-UBrryWh5.js +0 -14
  436. package/dist/units-DjoHPrqM.cjs +0 -1
  437. package/dist/units-MBd0L3ff.js +0 -8
  438. package/dist/useClickOutside-4k9PAT_i.cjs +0 -1
  439. package/dist/useClickOutside-BYjsXGgb.js +0 -107
  440. package/dist/useDebouncedCallback-BBsAgC9k.cjs +0 -1
  441. package/dist/useMemoCompare-DORTZbzY.cjs +0 -1
  442. package/dist/useVirtualCursorDragWebKit-BSafZVD_.cjs +0 -1
  443. package/dist/value-CudL8z5e.js +0 -5957
  444. package/dist/value-DT0qJqgQ.cjs +0 -57
@@ -1,53 +0,0 @@
1
- "use strict";var il=Object.defineProperty;var al=(t,e,n)=>e in t?il(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var D=(t,e,n)=>al(t,typeof e!="symbol"?e+"":e,n);const s=require("zod"),ol=require("./deep-ICSlPm58.cjs"),xe=require("./state-Bd_8X2jl.cjs"),z=require("./css-Cj2UCGXB.cjs");var ll=Object.defineProperty,cl=(t,e,n)=>e in t?ll(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,An=(t,e,n)=>cl(t,typeof e!="symbol"?e+"":e,n);let ul=class{constructor(e){An(this,"sender"),An(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var n;const r=(n=this.handlers.get(e.type))==null?void 0:n.handler;r==null?console.warn(`No handler for ${e.type}`):r(e.payload)}route(e){const n=hl(e,this.sender),r=new dl(n);return this.handlers.set(e,r),r}};const hl=(t,e)=>(n,r)=>e({type:t,payload:n},r);let dl=class{constructor(e){An(this,"_send"),An(this,"handler"),this._send=e,this.handler=null}send(e,n=[]){this._send(e,n)}handle(e){this.handler=e}};const fl=s.z.object({l0:z.Color.z,l1:z.Color.z,l2:z.Color.z,l3:z.Color.z,l4:z.Color.z,l5:z.Color.z,l6:z.Color.z,l7:z.Color.z,l8:z.Color.z,l9:z.Color.z,l10:z.Color.z,l11:z.Color.z}),ce=(t,e)=>[t[0],t[1],e,t[3]],yl=s.z.object({m2:z.Color.z,m1:z.Color.z,z:z.Color.z,p1:z.Color.z,p2:z.Color.z}),Jt=yl.or(z.Color.z.transform(t=>{const e=t.hsla;return{m2:new z.Color(z.fromHSLA(ce(e,40))),m1:new z.Color(z.fromHSLA(ce(e,45))),z:t,p1:new z.Color(z.fromHSLA(ce(e,55))),p2:new z.Color(z.fromHSLA(ce(e,65)))}})),_i=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:z.Color.z,primary:Jt,gray:fl,error:Jt,secondary:Jt,warning:Jt,palettes:s.z.record(z.paletteZ),visualization:s.z.object({palettes:s.z.record(s.z.array(z.Color.z))}).optional().default({palettes:{}}),white:z.Color.z,black:z.Color.z,text:z.Color.z,textInverted:z.Color.z,textOnPrimary:z.Color.z.optional().default(z.ZERO),logo:s.z.string()}),sizes:s.z.object({base:s.z.number(),border:s.z.object({radius:s.z.number(),width:s.z.number(),thickWidth:s.z.number()}),schematic:s.z.object({elementStrokeWidth:s.z.number()})}),typography:s.z.object({family:s.z.string(),codeFamily:s.z.string(),h1:xe.specZ,h2:xe.specZ,h3:xe.specZ,h4:xe.specZ,h5:xe.specZ,p:xe.specZ,small:xe.specZ})}).transform(t=>((t.colors.textOnPrimary==null||t.colors.textOnPrimary.isZero)&&(t.colors.textOnPrimary=t.colors.primary.z.pickByContrast(t.colors.text,t.colors.textInverted)),t)),pl="'Inter Variable', sans-serif",gl="'Geist Mono', monospace",ml=6,it=[357,91,55,1],at=[58,100,50,1],wl=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],ot=Object.fromEntries(wl.map((t,e)=>[`l${e}`,t])),bl=()=>typeof window>"u"?!1:window.devicePixelRatio>1,vl=bl(),xr={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#356fc5",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:ot,border:ot.l4,error:{m2:z.fromHSLA(ce(it,30)),m1:z.fromHSLA(ce(it,40)),z:z.fromHSLA(it),p1:z.fromHSLA(ce(it,65)),p2:z.fromHSLA(ce(it,77))},warning:{m2:z.fromHSLA(ce(at,30)),m1:z.fromHSLA(ce(at,40)),z:z.fromHSLA(at),p1:z.fromHSLA(ce(at,65)),p2:z.fromHSLA(ce(at,75))},palettes:{recent:{key:"recent",name:"Recent",swatches:[]}},visualization:{palettes:{default:["#DC136C","#20A4F3","#7AC74F","#FFC43D","#FE5F55","#8075FF","#D90429","#f7aef8","#f18f01","#791e94","#279af1","#d9fff5","#ff6b6b","#52ffb8"]}},logo:"url(#synnax-linear-gradient)",white:"#FFFFFF",black:"#000000",text:ot.l11,textInverted:ot.l0,textOnPrimary:ot.l0},sizes:{base:ml,border:{radius:3,width:vl?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:pl,codeFamily:gl,h1:{size:6,weight:"500",lineHeight:6*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.6666,weight:"medium",lineHeight:2.6666*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:2.3333333}}},qi=Object.freeze({...xr,key:"synnaxLight",name:"Synnax Light"}),Ol=["#020202","#080808","#151515","#242424","#2F2F2F","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],lt=Object.fromEntries(Ol.map((t,e)=>[`l${e}`,t])),Yi=Object.freeze({...xr,key:"synnaxDark",name:"Synnax Dark",colors:{...xr.colors,gray:lt,logo:"var(--pluto-text-color)",border:lt.l3,text:lt.l11,textInverted:lt.l0,textOnPrimary:lt.l11}}),zl={synnaxDark:Yi,synnaxLight:qi},Tl=["tiny","small","medium","large","huge"],Sl=s.z.enum(Tl),kl=t=>Sl.safeParse(t).success;var Nl=Object.defineProperty,El=(t,e,n)=>e in t?Nl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e,n)=>El(t,typeof e!="symbol"?e+"":e,n);const b=t=>Array.isArray(t)?t:[t],Il="policy",Fi="allow_all";var xl=Object.defineProperty,Al=(t,e,n)=>e in t?xl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e,n)=>Al(t,typeof e!="symbol"?e+"":e,n);const Cl=t=>{const e=t.replace(/_[a-z]/g,n=>n[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Wi=t=>{const e=(n,r=Ar)=>{if(typeof n=="string")return t(n);if(Array.isArray(n))return n.map(o=>e(o,r));if(!tr(n))return n;r=Pl(r);const i={},a=n;return Object.keys(a).forEach(o=>{let c=a[o];const u=t(o);r.recursive&&(tr(c)?Bs(c,r.keepTypesOnRecursion)||(c=e(c,r)):r.recursiveInArray&&Ms(c)&&(c=[...c].map(h=>{let f=h;return tr(h)?Bs(f,r.keepTypesOnRecursion)||(f=e(h,r)):Ms(h)&&(f=e({key:h},r).key),f}))),i[u]=c}),i};return e},Vi=Wi(Cl),jl=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,n,r)=>`${n}_${r.toLowerCase()}`),Rl=Wi(jl),Ar={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Pl=(t=Ar)=>(t.recursive==null?t=Ar:t.recursiveInArray??(t.recursiveInArray=!1),t),Ms=t=>t!=null&&Array.isArray(t),tr=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Bs=(t,e)=>(e||[]).some(n=>t instanceof n),Gi=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var Ml=Object.defineProperty,Bl=(t,e,n)=>e in t?Ml(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,It=(t,e,n)=>Bl(t,typeof e!="symbol"?e+"":e,n);let Ul=class{constructor(){It(this,"contentType","application/json"),It(this,"decoder"),It(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const n=JSON.parse(t),r=Vi(n);return e!=null?e.parse(r):r}encodeString(t){const e=Rl(t);return JSON.stringify(e,(n,r)=>ArrayBuffer.isView(r)?Array.from(r):Gi(r)&&"encode_value"in r?typeof r.value=="bigint"?r.value.toString():r.value:typeof r=="bigint"?r.toString():r)}static registerCustomType(){}},$l=class{constructor(){It(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const n=new TextDecoder().decode(t);return this.decodeString(n,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!Gi(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),n=[e.join(",")];return t.forEach(r=>{const i=e.map(a=>JSON.stringify(r[a]??""));n.push(i.join(","))}),n.join(`
2
- `)}decodeString(t,e){const[n,...r]=t.trim().split(`
3
- `).map(o=>o.trim());if(n.length===0)return e!=null?e.parse({}):{};const i=n.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),r.forEach(o=>{const c=o.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(c[h]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},Dl=class{constructor(){It(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const n=new TextDecoder().decode(t);return e!=null?e.parse(n):n}};const sn=new Ul;new $l;new Dl;const Ll=t=>t!=null&&typeof t=="object"&&"toString"in t,_l=(t,e=!1)=>{const n=Ll(t)?"stringer":typeof t;let r;switch(n){case"string":r=(i,a)=>i.localeCompare(a);break;case"stringer":r=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":r=(i,a)=>Number(i)-Number(a);break;case"bigint":r=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":r=(i,a)=>Number(i)-Number(a);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return e?ql(r):r},ql=t=>(e,n)=>t(n,e),Un=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const Zi=s.z.object({width:s.z.number(),height:s.z.number()}),Yl=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Fl=["width","height"];s.z.enum(Fl);const Wl=["start","center","end"],Vl=["signedWidth","signedHeight"];s.z.enum(Vl);const Cn=s.z.object({x:s.z.number(),y:s.z.number()}),Gl=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Zl=["x","y"],Ki=s.z.enum(Zl),Ji=["top","right","bottom","left"];s.z.enum(Ji);const Kl=["left","right"],Hi=s.z.enum(Kl),Jl=["top","bottom"],Xi=s.z.enum(Jl),Qi=["center"],Us=s.z.enum(Qi),Hl=[...Ji,...Qi],ea=s.z.enum(Hl);s.z.enum(Wl);const Xl=["first","last"];s.z.enum(Xl);const Ql=s.z.object({lower:s.z.number(),upper:s.z.number()}),ec=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Ql,Un]);s.z.union([ec,Un]);s.z.enum([...Ki.options,...ea.options]);s.z.union([Ki,ea,s.z.instanceof(String)]);const tc=t=>typeof t=="bigint"||t instanceof BigInt,qe=(t,e)=>tc(t)?t.valueOf()*BigInt(e.valueOf()):t.valueOf()*Number(e.valueOf()),$e=(t,e)=>{const n={};if(typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else return $s(t);return $s(n)},$s=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,Ds=(t,e)=>{const n=$e(t);return e<n.lower?n.lower:e>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):e};s.z.object({x:Hi.or(Us),y:Xi.or(Us)});const nc=s.z.object({x:Hi,y:Xi}),rc=Object.freeze({x:"left",y:"top"}),sc=(t,e)=>t.x===e.x&&t.y===e.y,Ls=s.z.union([s.z.number(),Cn,Un,Zi,Yl,Gl]),ic=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},_s=Object.freeze({x:0,y:0}),Ht=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Ht,left:Ht,width:Ht,height:Ht});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Cn,two:Cn,root:nc});const ns=(t,e,n=0,r=0,i)=>{const a={one:{..._s},two:{..._s},root:i??rc};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+n,y:a.one.y+r},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+n}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},nr=t=>{const e=ns(t);return{lower:e.one.x,upper:e.two.x}},rr=t=>{const e=ns(t);return{lower:e.one.y,upper:e.two.y}},ac=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,oc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([Zi,oc,Cn,Un]);var lc=Object.defineProperty,cc=(t,e,n)=>e in t?lc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ze=(t,e,n)=>cc(t,typeof e!="symbol"?e+"":e,n);const uc=(t,e,n)=>e!==void 0&&t<e?e:n!==void 0&&t>n?n:t;s.z.object({offset:Ls,scale:Ls});s.z.object({offset:s.z.number(),scale:s.z.number()});const hc=t=>(e,n,r,i)=>n==="dimension"?[e,r]:[e,i?r-t:r+t],dc=t=>(e,n,r,i)=>[e,i?r/t:r*t],fc=t=>(e,n,r)=>{if(e===null)return[t,r];const{lower:i,upper:a}=e,{lower:o,upper:c}=t,u=a-i,h=c-o;if(n==="dimension")return[t,r*(h/u)];const f=(r-i)*(h/u)+o;return[t,f]},yc=t=>(e,n,r)=>[t,r],pc=()=>(t,e,n)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,n];const{lower:r,upper:i}=t;return[t,i-(n-r)]},gc=t=>(e,n,r)=>{const{lower:i,upper:a}=t;return r=uc(r,i,a),[e,r]},Cr=class ht{constructor(){ze(this,"ops",[]),ze(this,"currBounds",null),ze(this,"currType",null),ze(this,"reversed",!1),this.ops=[]}static translate(e){return new ht().translate(e)}static magnify(e){return new ht().magnify(e)}static scale(e,n){return new ht().scale(e,n)}translate(e){const n=this.new(),r=hc(e);return r.type="translate",n.ops.push(r),n}magnify(e){const n=this.new(),r=dc(e);return r.type="magnify",n.ops.push(r),n}scale(e,n){const r=$e(e,n),i=this.new(),a=fc(r);return a.type="scale",i.ops.push(a),i}clamp(e,n){const r=$e(e,n),i=this.new(),a=gc(r);return a.type="clamp",i.ops.push(a),i}reBound(e,n){const r=$e(e,n),i=this.new(),a=yc(r);return a.type="re-bound",i.ops.push(a),i}invert(){const e=pc();e.type="invert";const n=this.new();return n.ops.push(e),n}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new ht;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,n){return this.currBounds=null,this.ops.reduce(([r,i],a)=>a(r,e,i,this.reversed),[null,n])[1]}reverse(){const e=this.new();e.ops.reverse();const n=[];return e.ops.forEach((r,i)=>{if(r.type==="scale"||n.some(([o,c])=>i>=o&&i<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>i);a!==-1&&n.push([i,a])}),n.forEach(([r,i])=>{const a=e.ops.slice(r,i);a.unshift(e.ops[i]),e.ops.splice(r,i-r+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};ze(Cr,"IDENTITY",new Cr);let qs=Cr;const Ys=class ve{constructor(e=new qs,n=new qs,r=null){ze(this,"x"),ze(this,"y"),ze(this,"currRoot"),this.x=e,this.y=n,this.currRoot=r}static translate(e,n){return new ve().translate(e,n)}static translateX(e){return new ve().translateX(e)}static translateY(e){return new ve().translateY(e)}static clamp(e){return new ve().clamp(e)}static magnify(e){return new ve().magnify(e)}static scale(e){return new ve().scale(e)}static reBound(e){return new ve().reBound(e)}translate(e,n){const r=ic(e,n),i=this.copy();return i.x=this.x.translate(r.x),i.y=this.y.translate(r.y),i}translateX(e){const n=this.copy();return n.x=this.x.translate(e),n}translateY(e){const n=this.copy();return n.y=this.y.translate(e),n}magnify(e){const n=this.copy();return n.x=this.x.magnify(e.x),n.y=this.y.magnify(e.y),n}scale(e){const n=this.copy();if(ac(e)){const r=this.currRoot;return n.currRoot=e.root,r!=null&&!sc(r,e.root)&&(r.x!==e.root.x&&(n.x=n.x.invert()),r.y!==e.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(nr(e)),n.y=n.y.scale(rr(e)),n}return n.x=n.x.scale(e.width),n.y=n.y.scale(e.height),n}reBound(e){const n=this.copy();return n.x=this.x.reBound(nr(e)),n.y=this.y.reBound(rr(e)),n}clamp(e){const n=this.copy();return n.x=this.x.clamp(nr(e)),n.y=this.y.clamp(rr(e)),n}copy(){const e=new ve;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ns(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};ze(Ys,"IDENTITY",new Ys);var mc=Object.defineProperty,wc=(t,e,n)=>e in t?mc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e,n)=>wc(t,typeof e!="symbol"?e+"":e,n);let bc=(t,e=21)=>(n=e)=>{let r="",i=n|0;for(;i--;)r+=t[Math.random()*t.length|0];return r};const vc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Oc=bc(vc,11),zc=()=>Oc(),Tc=s.z.enum(["static","dynamic"]),ta=(t,e)=>{const n=new $(e);if(![B.DAY,B.HOUR,B.MINUTE,B.SECOND,B.MILLISECOND,B.MICROSECOND,B.NANOSECOND].some(i=>i.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=t.valueOf()%n.valueOf();return t instanceof $?new $(r):new B(r)},j=class v{constructor(e,n="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=v.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*v.MILLISECOND.valueOf();else if(typeof e=="string")this.value=v.parseDateTimeString(e,n).valueOf();else if(Array.isArray(e))this.value=v.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),n==="local"&&(r=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,n=1,r=1]){const i=new Date(e,n-1,r,0,0,0,0);return new v(BigInt(i.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,n="UTC"){const[r,i,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let u=v.hours(parseInt(r??"00")).add(v.minutes(parseInt(i??"00"))).add(v.seconds(parseInt(o??"00"))).add(v.milliseconds(parseInt(c??"00")));return n==="local"&&(u=u.add(v.utcOffset)),u.valueOf()}static parseDateTimeString(e,n="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,n);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new v(BigInt(r.getTime())*v.MILLISECOND.valueOf(),n).valueOf()}fString(e="ISO",n="UTC"){switch(e){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(v.utcOffset).date().toISOString()}timeString(e=!1,n="UTC"){const r=this.toISOString(n);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),n=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new B(BigInt(new Date().getTimezoneOffset())*v.MINUTE.valueOf())}static since(e){return new v().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new v(e).valueOf()}span(e){return this.range(e).span}range(e){return new rs(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new v(e).valueOf()}afterEq(e){return this.valueOf()>=new v(e).valueOf()}before(e){return this.valueOf()<new v(e).valueOf()}beforeEq(e){return this.valueOf()<=new v(e).valueOf()}add(e){return new v(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new v(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(B.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(B.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(B.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(B.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(v.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const n=this.date();return n.setFullYear(e),new v(n)}get month(){return this.date().getMonth()}setMonth(e){const n=this.date();return n.setMonth(e),new v(n)}get day(){return this.date().getDate()}setDay(e){const n=this.date();return n.setDate(e),new v(n)}get hour(){return this.date().getHours()}setHour(e){const n=this.date();return n.setHours(e),new v(n)}get minute(){return this.date().getMinutes()}setMinute(e){const n=this.date();return n.setMinutes(e),new v(n)}get second(){return this.date().getSeconds()}setSecond(e){const n=this.date();return n.setSeconds(e),new v(n)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const n=this.date();return n.setMilliseconds(e),new v(n)}toString(){return this.date().toISOString()}remainder(e){return ta(this,e)}get isToday(){return this.truncate(B.DAY).equals(v.now().truncate(B.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new v(new Date)}static max(...e){let n=v.MIN;for(const r of e){const i=new v(r);i.after(n)&&(n=i)}return n}static min(...e){let n=v.MAX;for(const r of e){const i=new v(r);i.before(n)&&(n=i)}return n}static nanoseconds(e){return new v(e)}static microseconds(e){return v.nanoseconds(e*1e3)}static milliseconds(e){return v.microseconds(e*1e3)}static seconds(e){return v.milliseconds(e*1e3)}static minutes(e){return v.seconds(e*60)}static hours(e){return v.minutes(e*60)}static days(e){return v.hours(e*24)}};m(j,"NANOSECOND",j.nanoseconds(1)),m(j,"MICROSECOND",j.microseconds(1)),m(j,"MILLISECOND",j.milliseconds(1)),m(j,"SECOND",j.seconds(1)),m(j,"MINUTE",j.minutes(1)),m(j,"HOUR",j.hours(1)),m(j,"DAY",j.days(1)),m(j,"MAX",new j((1n<<63n)-1n)),m(j,"MIN",new j(0)),m(j,"ZERO",new j(0)),m(j,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new j(t.value)),s.z.string().transform(t=>new j(BigInt(t))),s.z.instanceof(Number).transform(t=>new j(t)),s.z.number().transform(t=>new j(t)),s.z.instanceof(j)]));let $=j;const R=class S{constructor(e){m(this,"value"),m(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof S?e:e instanceof Fs?e.period:e instanceof $?new S(e):["number","bigint"].includes(typeof e)?S.seconds(e):new S(e)}static fromMilliseconds(e){return e instanceof S?e:e instanceof Fs?e.period:e instanceof $?new S(e):["number","bigint"].includes(typeof e)?S.milliseconds(e):new S(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new S(e).valueOf()}greaterThan(e){return this.valueOf()>new S(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new S(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new S(e).valueOf()}remainder(e){return ta(this,e)}truncate(e){return new S(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(S.DAY),n=this.truncate(S.HOUR),r=this.truncate(S.MINUTE),i=this.truncate(S.SECOND),a=this.truncate(S.MILLISECOND),o=this.truncate(S.MICROSECOND),c=this.truncate(S.NANOSECOND),u=e,h=n.sub(e),f=r.sub(n),d=i.sub(r),N=a.sub(i),x=o.sub(a),ae=c.sub(o);let Y="";return u.isZero||(Y+=`${u.days}d `),h.isZero||(Y+=`${h.hours}h `),f.isZero||(Y+=`${f.minutes}m `),d.isZero||(Y+=`${d.seconds}s `),N.isZero||(Y+=`${N.milliseconds}ms `),x.isZero||(Y+=`${x.microseconds}µs `),ae.isZero||(Y+=`${ae.nanoseconds}ns`),Y.trim()}mult(e){return new S(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(S.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(S.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(S.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(S.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(S.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(S.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new S(e).valueOf()}add(e){return new S(this.valueOf()+new S(e).valueOf())}sub(e){return new S(this.valueOf()-new S(e).valueOf())}static nanoseconds(e=1){return new S(e)}static microseconds(e=1){return S.nanoseconds(qe(e,1e3))}static milliseconds(e=1){return S.microseconds(qe(e,1e3))}static seconds(e=1){return S.milliseconds(qe(e,1e3))}static minutes(e=1){return S.seconds(qe(e,60))}static hours(e){return S.minutes(qe(e,60))}static days(e){return S.hours(qe(e,24))}};m(R,"NANOSECOND",R.nanoseconds(1)),m(R,"MICROSECOND",R.microseconds(1)),m(R,"MILLISECOND",R.milliseconds(1)),m(R,"SECOND",R.seconds(1)),m(R,"MINUTE",R.minutes(1)),m(R,"HOUR",R.hours(1)),m(R,"DAY",R.days(1)),m(R,"MAX",new R((1n<<63n)-1n)),m(R,"MIN",new R(0)),m(R,"ZERO",new R(0)),m(R,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new R(t.value)),s.z.string().transform(t=>new R(BigInt(t))),s.z.instanceof(Number).transform(t=>new R(t)),s.z.number().transform(t=>new R(t)),s.z.instanceof(R)]));let B=R;const dt=class an extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new an(e).valueOf()}get period(){return B.seconds(1/this.valueOf())}sampleCount(e){return new B(e).seconds*this.valueOf()}byteCount(e,n){return this.sampleCount(e)*new te(n).valueOf()}span(e){return B.seconds(e/this.valueOf())}byteSpan(e,n){return this.span(e.valueOf()/n.valueOf())}static hz(e){return new an(e)}static khz(e){return an.hz(e*1e3)}};m(dt,"z",s.z.union([s.z.number().transform(t=>new dt(t)),s.z.instanceof(Number).transform(t=>new dt(t)),s.z.instanceof(dt)]));let Fs=dt;const G=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new jr(e*this.valueOf())}};m(G,"UNKNOWN",new G(0)),m(G,"BIT128",new G(16)),m(G,"BIT64",new G(8)),m(G,"BIT32",new G(4)),m(G,"BIT16",new G(2)),m(G,"BIT8",new G(1)),m(G,"z",s.z.union([s.z.number().transform(t=>new G(t)),s.z.instanceof(Number).transform(t=>new G(t)),s.z.instanceof(G)]));let te=G;const fe=class on{constructor(e,n){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new $(e.start),this.end=new $(e.end)):(this.start=new $(e),this.end=new $(n))}get span(){return new B(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new on(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,n=B.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const i=$.max(r.start,e.start),a=$.min(r.end,e.end);return a.before(i)?!1:new B(a.sub(i)).greaterThanOrEqual(n)}roughlyEquals(e,n){let r=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=n.valueOf()&&i<=n.valueOf()}contains(e){return e instanceof on?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const n=new on(this.start,this.end);return e.start.after(this.start)&&(n.start=e.start),e.start.after(this.end)&&(n.end=e.start),e.end.before(this.end)&&(n.end=e.end),e.end.before(this.start)&&(n.start=e.end),n}};m(fe,"MAX",new fe($.MIN,$.MAX)),m(fe,"MIN",new fe($.MAX,$.MIN)),m(fe,"ZERO",new fe($.ZERO,$.ZERO)),m(fe,"z",s.z.union([s.z.object({start:$.z,end:$.z}).transform(t=>new fe(t.start,t.end)),s.z.instanceof(fe)]));let rs=fe;const p=class L extends String{constructor(e){if(e instanceof L||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const n=L.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(n!=null){super(n.valueOf());return}throw super(L.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=L.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(n=>this.equals(n))}toString(){return this.valueOf()}get isVariable(){return this.equals(L.JSON)||this.equals(L.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(L.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=L.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(L.UINT8)||this.equals(L.UINT16)||this.equals(L.UINT32)||this.equals(L.UINT64)}get isSigned(){return this.equals(L.INT8)||this.equals(L.INT16)||this.equals(L.INT32)||this.equals(L.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(L.INT32)&&e.equals(L.FLOAT64)||this.equals(L.INT8)&&e.equals(L.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return L.BIG_INT_TYPES.some(e=>e.equals(this))}};m(p,"UNKNOWN",new p("unknown")),m(p,"FLOAT64",new p("float64")),m(p,"FLOAT32",new p("float32")),m(p,"INT64",new p("int64")),m(p,"INT32",new p("int32")),m(p,"INT16",new p("int16")),m(p,"INT8",new p("int8")),m(p,"UINT64",new p("uint64")),m(p,"UINT32",new p("uint32")),m(p,"UINT16",new p("uint16")),m(p,"UINT8",new p("uint8")),m(p,"BOOLEAN",p.UINT8),m(p,"TIMESTAMP",new p("timestamp")),m(p,"UUID",new p("uuid")),m(p,"STRING",new p("string")),m(p,"JSON",new p("json")),m(p,"ARRAY_CONSTRUCTORS",new Map([[p.UINT8.toString(),Uint8Array],[p.UINT16.toString(),Uint16Array],[p.UINT32.toString(),Uint32Array],[p.UINT64.toString(),BigUint64Array],[p.FLOAT32.toString(),Float32Array],[p.FLOAT64.toString(),Float64Array],[p.INT8.toString(),Int8Array],[p.INT16.toString(),Int16Array],[p.INT32.toString(),Int32Array],[p.INT64.toString(),BigInt64Array],[p.TIMESTAMP.toString(),BigInt64Array],[p.STRING.toString(),Uint8Array],[p.JSON.toString(),Uint8Array],[p.UUID.toString(),Uint8Array]])),m(p,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,p.UINT8],[Uint16Array.name,p.UINT16],[Uint32Array.name,p.UINT32],[BigUint64Array.name,p.UINT64],[Float32Array.name,p.FLOAT32],[Float64Array.name,p.FLOAT64],[Int8Array.name,p.INT8],[Int16Array.name,p.INT16],[Int32Array.name,p.INT32],[BigInt64Array.name,p.INT64]])),m(p,"DENSITIES",new Map([[p.UINT8.toString(),te.BIT8],[p.UINT16.toString(),te.BIT16],[p.UINT32.toString(),te.BIT32],[p.UINT64.toString(),te.BIT64],[p.FLOAT32.toString(),te.BIT32],[p.FLOAT64.toString(),te.BIT64],[p.INT8.toString(),te.BIT8],[p.INT16.toString(),te.BIT16],[p.INT32.toString(),te.BIT32],[p.INT64.toString(),te.BIT64],[p.TIMESTAMP.toString(),te.BIT64],[p.STRING.toString(),te.UNKNOWN],[p.JSON.toString(),te.UNKNOWN],[p.UUID.toString(),te.BIT128]])),m(p,"ALL",[p.UNKNOWN,p.FLOAT64,p.FLOAT32,p.INT64,p.INT32,p.INT16,p.INT8,p.UINT64,p.UINT32,p.UINT16,p.UINT8,p.TIMESTAMP,p.UUID,p.STRING,p.JSON]),m(p,"BIG_INT_TYPES",[p.INT64,p.UINT64,p.TIMESTAMP]),m(p,"z",s.z.union([s.z.string().transform(t=>new p(t)),s.z.instanceof(p)]));let U=p;const X=class F extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return F.bytes(this.valueOf()+e.valueOf())}sub(e){return F.bytes(this.valueOf()-e.valueOf())}truncate(e){return new F(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return F.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/F.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/F.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/F.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/F.TERABYTE.valueOf()}toString(){const e=this.truncate(F.TERABYTE),n=this.truncate(F.GIGABYTE),r=this.truncate(F.MEGABYTE),i=this.truncate(F.KILOBYTE),a=this.truncate(F.BYTE),o=e,c=n.sub(e),u=r.sub(n),h=i.sub(r),f=a.sub(i);let d="";return o.isZero||(d+=`${o.terabytes}TB `),c.isZero||(d+=`${c.gigabytes}GB `),u.isZero||(d+=`${u.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new F(e)}static kilobytes(e=1){return F.bytes(e.valueOf()*1e3)}static megabytes(e=1){return F.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return F.megabytes(e.valueOf()*1e3)}static terabytes(e){return F.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(X,"BYTE",new X(1)),m(X,"KILOBYTE",X.kilobytes(1)),m(X,"MEGABYTE",X.megabytes(1)),m(X,"GIGABYTE",X.gigabytes(1)),m(X,"TERABYTE",X.terabytes(1)),m(X,"ZERO",new X(0)),m(X,"z",s.z.union([s.z.number().transform(t=>new X(t)),s.z.instanceof(X)]));let jr=X;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const na=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof $||t instanceof B||t instanceof Date},Sc=(t,e,n,r=0)=>t.usesBigInt&&!e.usesBigInt?Number(n)-Number(r):!t.usesBigInt&&e.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):ft(n,-r).valueOf(),ft=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e),kc=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof xc?!0:na(t),Ne=-1,Nc=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Ec=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),Rr=10,Ic=(t,e)=>{if(t==="string"&&!e.isVariable)throw new Error(`cannot convert series of type ${e.toString()} to string`);if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},yt=class ye{constructor(e){m(this,"key",""),m(this,"isSynnaxSeries",!0),m(this,"dataType"),m(this,"sampleOffset"),m(this,"gl"),m(this,"_data"),m(this,"_timeRange"),m(this,"alignment",0n),m(this,"_cachedMin"),m(this,"_cachedMax"),m(this,"writePos",Ne),m(this,"_refCount",0),m(this,"_cachedLength"),m(this,"_cachedIndexes"),kc(e)&&(e={data:e});const{dataType:n,timeRange:r,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:c=zc()}=e,u=e.data??[];if(u instanceof ye||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this._timeRange=d._timeRange,this.alignment=d.alignment,this._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=na(u),f=Array.isArray(u);if(n!=null)this.dataType=new U(n);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=U.STRING;else if(typeof d=="number")this.dataType=U.FLOAT64;else if(typeof d=="bigint")this.dataType=U.INT64;else if(typeof d=="boolean")this.dataType=U.BOOLEAN;else if(d instanceof $||d instanceof Date||d instanceof $)this.dataType=U.TIMESTAMP;else if(typeof d=="object")this.dataType=U.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new U(u)}if(!f&&!h)this._data=u;else{let d=h?[u]:u;const N=d[0];(N instanceof $||N instanceof Date||N instanceof B)&&(d=d.map(x=>new $(x).valueOf())),this.dataType.equals(U.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
4
- `)}
5
- `).buffer):this.dataType.equals(U.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(x=>sn.encodeString(x)).join(`
6
- `)}
7
- `).buffer):this.dataType.usesBigInt&&typeof N=="number"?this._data=new this.dataType.Array(d.map(x=>BigInt(Math.round(x)))).buffer:!this.dataType.usesBigInt&&typeof N=="bigint"?this._data=new this.dataType.Array(d.map(x=>Number(x))).buffer:this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:n,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new U(n).Array(e),a=new ye({data:i.buffer,dataType:n,...r});return a.writePos=0,a}static createTimestamps(e,n,r){const i=r.spanRange(n.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(r.add(n.span(o)).valueOf());return new ye({data:a,dataType:U.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,n){const r=new TextEncoder().encode(`${e.join(`
8
- `)}
9
- `);return new ye({data:r,dataType:U.STRING,timeRange:n})}static fromJSON(e,n){const r=new TextEncoder().encode(`${e.map(i=>sn.encodeString(i)).join(`
10
- `)}
11
- `);return new ye({data:r,dataType:U.JSON,timeRange:n})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ne)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===Ne)return 0;const n=this.capacity-this.writePos,r=e.sub(0,n);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ne?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(U.STRING,U.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
12
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(U.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=U.UUID.density.valueOf(),n=Array(this.length);for(let r=0;r<this.length;r++){const i=this.underlyingData.slice(r*e,(r+1)*e),a=Array.from(new Uint8Array(i.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");n[r]=a}return n}parseJSON(e){if(!this.dataType.equals(U.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
13
- `).slice(0,-1).map(n=>e.parse(sn.decodeString(n)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new jr(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ne?this.byteCapacity:this.dataType.isVariable?new jr(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ne?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const n=[0];return this.data.forEach((r,i)=>{r===Rr&&(e++,n.push(i+1))}),this._cachedIndexes=n,this._cachedLength=e,e}convert(e,n=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let i=0;i<this.length;i++)r[i]=Sc(this.dataType,e,this.data[i],n);return new ye({data:r.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(U.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}else{const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),ft(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(U.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}else{const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),ft(this._cachedMin,this.sampleOffset))}get bounds(){return $e(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const n=e._cachedMin??e.calcRawMin();n<this._cachedMin&&(this._cachedMin=n)}if(this._cachedMax!=null){const n=e._cachedMax??e.calcRawMax();n>this._cachedMax&&(this._cachedMax=n)}}enrich(){this.max,this.min}get range(){return ft(this.max,-this.min)}atAlignment(e,n){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(e,n){if(this.dataType.isVariable)return this.atVariable(e,n??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${e}`);return}return ft(r,this.sampleOffset)}atVariable(e,n){let r=0,i=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],i=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===Rr){if(e===0){i=o;break}r=o+1,e--}if(i===0&&(i=this.data.length),r>=i||e>0){if(n)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(r,i);return this.dataType.equals(U.STRING)?new TextDecoder().decode(a):Vi(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let n=0,r=this.length-1;const i=_l(e);for(;n<=r;){const a=Math.floor((n+r)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?n=a+1:r=a-1}return n}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(U.FLOAT32)&&!this.dataType.equals(U.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:i}=this.gl;if(n==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ne){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ne}as(e){return Ic(e,this.dataType),this}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Js(this.alignmentBounds.lower),upper:Js(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return $e(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Ac(this);return this.dataType.equals(U.JSON)?new Cc(e):e}return new jc(this)}slice(e,n){return this.sliceSub(!1,e,n)}sub(e,n){return this.sliceSub(!0,e,n)}subIterator(e,n){return new Ws(this,e,n??this.length)}subAlignmentIterator(e,n){return new Ws(this,Number(e-this.alignment),Number(n-this.alignment))}subBytes(e,n){if(e>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,n);return new ye({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return e?i=this.data.subarray(n,r):i=this.data.slice(n,r),new ye({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(e){return new ye({data:this.buffer,dataType:this.dataType,timeRange:rs.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};m(yt,"crudeZ",s.z.object({timeRange:rs.z.optional(),dataType:U.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([Nc,Ec,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:Tc.optional().default("static").optional()})),m(yt,"z",yt.crudeZ.transform(t=>new yt(t)));let xc=yt;class Ws{constructor(e,n,r){m(this,"series"),m(this,"end"),m(this,"index"),this.series=e;const i=$e(0,e.length);this.end=Ds(i,r),this.index=Ds(i,n)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class Ac{constructor(e){if(m(this,"series"),m(this,"index"),m(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==Rr;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var Vs,Gs;class Cc{constructor(e){m(this,"wrapped"),m(this,Vs,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:sn.decodeString(e.value)}}[(Gs=Symbol.iterator,Vs=Symbol.toStringTag,Gs)](){return this}}var Zs,Ks;class jc{constructor(e){m(this,"series"),m(this,"index"),m(this,Zs,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(Ks=Symbol.iterator,Zs=Symbol.toStringTag,Ks)](){return this}}const Js=t=>{const e=t>>32n,n=t&0xffffffffn;return{domain:e,sample:n}};s.z.object({key:s.z.string(),value:s.z.string()});s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const ra=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Rc=ra(),sa=["macOS","Windows","Linux"],Pc=["macos","windows","linux"],Mc={macos:"macOS",windows:"Windows",linux:"Linux"},Bc=s.z.enum(sa).or(s.z.enum(Pc).transform(t=>Mc[t])),Uc=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"macOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"};let sr;const $c=(t={})=>{const{force:e,default:n}=t;return e??sr??(sr=Uc(),sr??n)},ia=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:sa,RUNTIME:Rc,detect:ra,getOS:$c,osZ:Bc},Symbol.toStringTag,{value:"Module"}));var Dc=Object.defineProperty,Lc=(t,e,n)=>e in t?Dc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,pt=(t,e,n)=>Lc(t,typeof e!="symbol"?e+"":e,n);const _c=(...t)=>t.map(aa).join(""),aa=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),qc=t=>t.endsWith("/")?t.slice(0,-1):t,Yc=(t,e="")=>t===null?"":`?${Object.entries(t).filter(([,n])=>n==null?!1:Array.isArray(n)?n.length>0:!0).map(([n,r])=>`${e}${n}=${r}`).join("&")}`,Pr=class Mr{constructor({host:e,port:n,protocol:r="",pathPrefix:i=""}){pt(this,"protocol"),pt(this,"host"),pt(this,"port"),pt(this,"path"),this.protocol=r,this.host=e,this.port=n,this.path=aa(i)}replace(e){return new Mr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Mr({...this,pathPrefix:_c(this.path,e)})}toString(){return qc(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};pt(Pr,"UNKNOWN",new Pr({host:"unknown",port:0}));let Fc=Pr;const Wc=-128,Vc=127;s.z.number().int().min(Wc).max(Vc);const Gc=-32768,Zc=32767;s.z.number().int().min(Gc).max(Zc);const Kc=-2147483648,Jc=2147483647;s.z.number().int().min(Kc).max(Jc);const Hc=-9223372036854775808n,Xc=9223372036854775807n;s.z.bigint().min(Hc).max(Xc);const Qc=255;s.z.number().int().min(0).max(Qc);const eu=65535;s.z.number().int().min(0).max(eu);const tu=4294967295;s.z.number().int().min(0).max(tu);const nu=18446744073709551615n;s.z.bigint().min(0n).max(nu);var ru=Object.defineProperty,su=(t,e,n)=>e in t?ru(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,gt=(t,e,n)=>su(t,typeof e!="symbol"?e+"":e,n);const iu=async t=>await new Promise(e=>setTimeout(e,B.fromMilliseconds(t).milliseconds)),au=s.z.object({interval:B.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),ou=(t={})=>{const e=t.sleepFn||iu,n=t.maxRetries??5,r=t.scale??1;let i=0,a=new B(t.interval??B.milliseconds(1));return async()=>i>=n?!1:(await e(a),a=a.mult(r),i++,!0)},lu=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:au,create:ou},Symbol.toStringTag,{value:"Module"})),be=class extends Number{};gt(be,"ABSOLUTE",255),gt(be,"MINIMUM",0),gt(be,"BOUNDS",{lower:be.MINIMUM,upper:be.ABSOLUTE+1}),gt(be,"z",s.z.union([s.z.instanceof(be),s.z.number().int().min(0).max(255).transform(t=>new be(t)),s.z.instanceof(Number).transform(t=>new be(t))]));s.z.object({name:s.z.string(),key:s.z.string()});const oa=class mt extends Error{constructor(){super(mt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(mt.MESSAGE):e instanceof mt||e.message.includes(mt.MESSAGE)}};gt(oa,"MESSAGE","canceled");let cu=oa;new cu;s.z.string().regex(/^\d+\.\d+\.\d+$/);const uu=["standard","scientific","engineering"];s.z.enum(uu);const ee=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(t):e instanceof Error?e.message.includes(t):typeof e!="string"?!1:e.includes(t);let de=class extends Error{constructor(){super(...arguments),A(this,"discriminator","FreighterError"),A(this,"type","")}};const hu=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Hs="unknown",Xs="nil",du="freighter",Lt=s.z.object({type:s.z.string(),data:s.z.string()});class fu{constructor(){A(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Xs,data:""};if(hu(e))for(const n of this.providers){const r=n.encode(e);if(r!=null)return r}return{type:Hs,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Xs)return null;if(e.type===Hs)return new Qs(e.data);for(const n of this.providers){const r=n.decode(e);if(r!=null)return r}return new Qs(e.data)}}const la=new fu,ca=({encode:t,decode:e})=>la.register({encode:t,decode:e}),jn=t=>la.decode(t);class Qs extends de{constructor(){super(...arguments),A(this,"type","unknown")}}const $n="freighter.",ln=class ua extends de{constructor(){super("EOF"),A(this,"type",ua.TYPE)}};A(ln,"TYPE",`${$n}eof`),A(ln,"matches",ee(ln.TYPE));let je=ln;const cn=class ha extends de{constructor(){super("StreamClosed"),A(this,"type",ha.TYPE)}};A(cn,"TYPE",`${$n}stream_closed`),A(cn,"matches",ee(cn.TYPE));let Ze=cn;const un=class da extends de{constructor(e={}){const{message:n="Unreachable",url:r=Fc.UNKNOWN}=e;super(n),A(this,"type",da.TYPE),A(this,"url"),this.url=r}};A(un,"TYPE",`${$n}unreachable`),A(un,"matches",ee(un.TYPE));let Re=un;const yu=t=>{if(!t.type.startsWith(du))return null;if(je.matches(t))return{type:je.TYPE,data:"EOF"};if(Ze.matches(t))return{type:Ze.TYPE,data:"StreamClosed"};if(Re.matches(t))return{type:Re.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},pu=t=>{if(!t.type.startsWith($n))return null;switch(t.type){case je.TYPE:return new je;case Ze.TYPE:return new Ze;case Re.TYPE:return new Re;default:throw new Error(`Unknown error type: ${t.data}`)}};ca({encode:yu,decode:pu});let fa=class{constructor(){A(this,"middleware",[])}use(...t){this.middleware.push(...t)}async executeMiddleware(t,e){let n=0;const r=async i=>{if(n===this.middleware.length)return await e(i);const a=this.middleware[n];return n++,await a(i,r)};return await r(t)}};const ya="Content-Type",ei=t=>{if(ia.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(t==="http")return e;const n=require("https"),r=new n.Agent({rejectUnauthorized:!1});return async(i,a)=>await e(i,{...a,agent:r})};class gu extends fa{constructor(e,n,r=!1){return super(),A(this,"endpoint"),A(this,"encoder"),A(this,"fetch"),this.endpoint=e.replace({protocol:r?"https":"http"}),this.encoder=n,this.fetch=ei(this.endpoint.protocol),new Proxy(this,{get:(i,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(i,a,o)})}get headers(){return{[ya]:this.encoder.contentType}}async send(e,n,r,i){n=r==null?void 0:r.parse(n);let a=null;const o=this.endpoint.child(e),c={};c.method="POST",c.body=this.encoder.encode(n??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async h=>{const f={...h,params:{}};c.headers={...this.headers,...h.params};let d;try{d=await ei(h.protocol)(h.target,c)}catch(x){let ae=x;return ae.message==="Load failed"&&(ae=new Re({url:o})),[f,ae]}const N=await d.arrayBuffer();if(d!=null&&d.ok)return i!=null&&(a=this.encoder.decode(N,i)),[f,null];try{if(d.status!==400)return[f,new Error(d.statusText)];const x=this.encoder.decode(N,Lt),ae=jn(x);return[f,ae]}catch(x){return[f,new Error(`[freighter] - failed to decode error: ${d.statusText}: ${x.message}`)]}});return[a,u]}}const mu=(t,e)=>{class n{constructor(i){A(this,"wrapped"),this.wrapped=i}use(...i){this.wrapped.use(...i)}async send(i,a,o,c){const u=lu.create(e);do{const[h,f]=await this.wrapped.send(i,a,o,c);if(f==null||!Re.matches(f))return[h,f];if(!await u())return[h,f]}while(!0)}}return new n(t)},w=async(t,e,n,r,i)=>{const[a,o]=await t.send(e,n,r,i);if(o!=null)throw o;return a},wu=()=>ia.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),bu=s.z.object({type:s.z.enum(["data","close","open"]),payload:s.z.unknown().optional(),error:s.z.optional(Lt)});class vu{constructor(e,n,r,i){A(this,"encoder"),A(this,"reqSchema"),A(this,"resSchema"),A(this,"ws"),A(this,"serverClosed"),A(this,"sendClosed"),A(this,"receiveDataQueue",[]),A(this,"receiveCallbacksQueue",[]),this.encoder=n,this.reqSchema=r,this.resSchema=i,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const e=await this.receiveMsg();if(e.type!=="open"){if(e.error==null)throw new Error("Message error must be defined");return jn(e.error)}return null}send(e){if(this.serverClosed!=null)return new je;if(this.sendClosed)throw new Ze;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=jn(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,n)=>this.receiveCallbacksQueue.push({resolve:e,reject:n}))}addMessage(e){const n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,bu)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:ku(e)?je.TYPE:Ze.TYPE,data:""}})}}const Ou="freighterctx",zu=1e3,Tu=1001,Su=[zu,Tu],ku=t=>Su.includes(t.code),pa=class ga extends fa{constructor(e,n,r=!1){super(),A(this,"baseUrl"),A(this,"encoder"),this.baseUrl=e.replace({protocol:r?"wss":"ws"}),this.encoder=n}async stream(e,n,r){const i=wu();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async c=>{const u=i(this.buildURL(e,c)),h={...c,params:{}};u.binaryType=ga.MESSAGE_TYPE;const f=await this.wrapSocket(u,n,r);return f instanceof Error?[h,f]:(a=f,[h,null])});if(o!=null)throw o;return a}buildURL(e,n){const r=Yc({[ya]:this.encoder.contentType,...n.params},Ou);return this.baseUrl.child(e).toString()+r}async wrapSocket(e,n,r){return await new Promise(i=>{e.onopen=()=>{const a=new vu(e,this.encoder,n,r);a.receiveOpenAck().then(o=>{o!=null?i(o):i(a)}).catch(o=>i(o))},e.onerror=a=>{const o=a;i(new Error(o.message))}})}};A(pa,"MESSAGE_TYPE","arraybuffer");let Nu=pa;const Eu="all",Iu="create",xu="delete",Au="retrieve",Cu="update",Br=s.z.enum([Eu,Iu,xu,Au,Cu]),ju=t=>{const e=t.replace(/_[a-z]/g,n=>n[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},ma=t=>{const e=(n,r=Ur)=>{if(typeof n=="string")return t(n);if(Array.isArray(n))return n.map(o=>e(o,r));if(!ir(n))return n;r=Mu(r);const i={},a=n;return Object.keys(a).forEach(o=>{let c=a[o];const u=t(o);r.recursive&&(ir(c)?ni(c,r.keepTypesOnRecursion)||(c=e(c,r)):r.recursiveInArray&&ti(c)&&(c=[...c].map(h=>{let f=h;return ir(h)?ni(f,r.keepTypesOnRecursion)||(f=e(h,r)):ti(h)&&(f=e({key:h},r).key),f}))),i[u]=c}),i};return e},wa=ma(ju),Ru=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,n,r)=>`${n}_${r.toLowerCase()}`),Pu=ma(Ru),Ur={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Mu=(t=Ur)=>(t.recursive==null?t=Ur:t.recursiveInArray??(t.recursiveInArray=!1),t),ti=t=>t!=null&&Array.isArray(t),ir=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ni=(t,e)=>(e||[]).some(n=>t instanceof n),ss=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var Bu=Object.defineProperty,Uu=(t,e,n)=>e in t?Bu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xt=(t,e,n)=>Uu(t,typeof e!="symbol"?e+"":e,n);let ba=class{constructor(){xt(this,"contentType","application/json"),xt(this,"decoder"),xt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const n=JSON.parse(t),r=wa(n);return e!=null?e.parse(r):r}encodeString(t){const e=Pu(t);return JSON.stringify(e,(n,r)=>ArrayBuffer.isView(r)?Array.from(r):ss(r)&&"encode_value"in r?typeof r.value=="bigint"?r.value.toString():r.value:typeof r=="bigint"?r.toString():r)}static registerCustomType(){}},va=class{constructor(){xt(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const n=new TextDecoder().decode(t);return this.decodeString(n,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!ss(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),n=[e.join(",")];return t.forEach(r=>{const i=e.map(a=>JSON.stringify(r[a]??""));n.push(i.join(","))}),n.join(`
14
- `)}decodeString(t,e){const[n,...r]=t.trim().split(`
15
- `).map(o=>o.trim());if(n.length===0)return e!=null?e.parse({}):{};const i=n.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),r.forEach(o=>{const c=o.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(c[h]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},Oa=class{constructor(){xt(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const n=new TextDecoder().decode(t);return e!=null?e.parse(n):n}};const Ge=new ba,$u=new va,Du=new Oa,Lu=[Ge],_t=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:va,CSV_CODEC:$u,ENCODERS:Lu,JSONCodec:ba,JSON_CODEC:Ge,TEXT_CODEC:Du,TextCodec:Oa},Symbol.toStringTag,{value:"Module"})),_u=t=>[...new Set(t)],qu=(t,e,n=!0)=>{const r=new Map;return t.forEach(i=>{const a=e(i);if(r.has(a)){if(n)return;r.delete(a)}r.set(a,i)}),Array.from(r.values())},ri=Object.freeze(Object.defineProperty({__proto__:null,by:qu,unique:_u},Symbol.toStringTag,{value:"Module"})),Yu=t=>t!=null&&typeof t=="object"&&"toString"in t,Fu=(t,e=!1)=>{const n=Yu(t)?"stringer":typeof t;let r;switch(n){case"string":r=(i,a)=>i.localeCompare(a);break;case"stringer":r=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":r=(i,a)=>Number(i)-Number(a);break;case"bigint":r=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":r=(i,a)=>Number(i)-Number(a);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return e?Wu(r):r},Wu=t=>(e,n)=>t(n,e),Dn=0,ar=-1,or=1,Vu=t=>t<Dn,Gu=t=>t>Dn,Zu=t=>t===Dn,Ln=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const za=s.z.object({width:s.z.number(),height:s.z.number()}),Ku=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Ju=["width","height"];s.z.enum(Ju);const Hu=["start","center","end"],Xu=["signedWidth","signedHeight"];s.z.enum(Xu);const Rn=s.z.object({x:s.z.number(),y:s.z.number()}),Qu=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),eh=["x","y"],Ta=s.z.enum(eh),Sa=["top","right","bottom","left"];s.z.enum(Sa);const th=["left","right"],ka=s.z.enum(th),nh=["top","bottom"],Na=s.z.enum(nh),Ea=["center"],si=s.z.enum(Ea),rh=[...Sa,...Ea],Ia=s.z.enum(rh);s.z.enum(Hu);const sh=["first","last"];s.z.enum(sh);const ih=s.z.object({lower:s.z.number(),upper:s.z.number()}),ah=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([ih,Ln]);s.z.union([ah,Ln]);s.z.enum([...Ta.options,...Ia.options]);s.z.union([Ta,Ia,s.z.instanceof(String)]);const et=t=>typeof t=="bigint"||t instanceof BigInt,lr=(t,e)=>et(t)?t.valueOf()-BigInt(e.valueOf().valueOf()):t.valueOf()-Number(e.valueOf()),oh=(t,e)=>et(t)?t.valueOf()+BigInt(e.valueOf().valueOf()):t+Number(e.valueOf()),ii=(t,e)=>et(t)?t===BigInt(e.valueOf().valueOf()):t===Number(e.valueOf()),lh=(t,e)=>et(t)?t.valueOf()<BigInt(e.valueOf())?t:BigInt(e.valueOf()):t.valueOf()<Number(e.valueOf())?t:Number(e.valueOf()),ch=t=>et(t)||t instanceof BigInt?t.valueOf()<0n?-t:t:t.valueOf()<0?-t:t,Ye=(t,e)=>et(t)?t.valueOf()*BigInt(e.valueOf()):t.valueOf()*Number(e.valueOf()),re=(t,e)=>{const n={};if(typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else return ai(t);return ai(n)},ai=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,oi=(t,e)=>{const n=re(t);return e<n.lower?n.lower:e>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):e},Xt=(t,e)=>{const n=re(t);if(typeof e=="number"||typeof e=="bigint")return e>=n.lower&&e<n.upper;const r=re(e);return r.lower>=n.lower&&r.upper<=n.upper},uh=(t,e,n)=>{const r=t.map(c=>re(c)),i=n>0?1:n<0?-1:0;if(i===0)return e;let a=n,o=e;for(;ii(a,0)===!1;){const c=r.findIndex(u=>i>0?o>=u.lower&&o<u.upper:o>u.lower&&o<=u.upper);if(c!==-1){const u=r[c];let h;if(i>0?h=lr(u.upper,o):h=lr(o,u.lower),h>0){const f=lh(ch(a),h);if(o=oh(o,i>0?f:-f),a=lr(a,i>0?f:-f),ii(a,0))return o;continue}}if(i>0){const u=r.filter(h=>h.lower>o);if(u.length>0)o=u[0].lower;else return o}else{const u=r.filter(h=>h.upper<o);if(u.length>0)o=u[u.length-1].upper;else return o}}return o},hh=(t,e,n)=>{const r=t.map(o=>re(o));if(e===n)return typeof e=="bigint"?0n:0;const i=e<n?re([e,n]):re([n,e]);let a=typeof e=="bigint"?0n:0;for(const o of r){const c=o.lower>i.lower?o.lower:i.lower,u=o.upper<i.upper?o.upper:i.upper;if(c<u){const h=u-c;a=a+h}}return a};s.z.object({x:ka.or(si),y:Na.or(si)});const dh=s.z.object({x:ka,y:Na}),fh=Object.freeze({x:"left",y:"top"}),yh=(t,e)=>t.x===e.x&&t.y===e.y,li=s.z.union([s.z.number(),Rn,Ln,za,Ku,Qu]),ph=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},ci=Object.freeze({x:0,y:0}),Qt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Qt,left:Qt,width:Qt,height:Qt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Rn,two:Rn,root:dh});const is=(t,e,n=0,r=0,i)=>{const a={one:{...ci},two:{...ci},root:i??fh};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+n,y:a.one.y+r},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+n}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},cr=t=>{const e=is(t);return{lower:e.one.x,upper:e.two.x}},ur=t=>{const e=is(t);return{lower:e.one.y,upper:e.two.y}},gh=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,mh=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([za,mh,Rn,Ln]);var wh=Object.defineProperty,bh=(t,e,n)=>e in t?wh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Te=(t,e,n)=>bh(t,typeof e!="symbol"?e+"":e,n);const vh=(t,e,n)=>e!==void 0&&t<e?e:n!==void 0&&t>n?n:t;s.z.object({offset:li,scale:li});s.z.object({offset:s.z.number(),scale:s.z.number()});const Oh=t=>(e,n,r,i)=>n==="dimension"?[e,r]:[e,i?r-t:r+t],zh=t=>(e,n,r,i)=>[e,i?r/t:r*t],Th=t=>(e,n,r)=>{if(e===null)return[t,r];const{lower:i,upper:a}=e,{lower:o,upper:c}=t,u=a-i,h=c-o;if(n==="dimension")return[t,r*(h/u)];const f=(r-i)*(h/u)+o;return[t,f]},Sh=t=>(e,n,r)=>[t,r],kh=()=>(t,e,n)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,n];const{lower:r,upper:i}=t;return[t,i-(n-r)]},Nh=t=>(e,n,r)=>{const{lower:i,upper:a}=t;return r=vh(r,i,a),[e,r]},$r=class wt{constructor(){Te(this,"ops",[]),Te(this,"currBounds",null),Te(this,"currType",null),Te(this,"reversed",!1),this.ops=[]}static translate(e){return new wt().translate(e)}static magnify(e){return new wt().magnify(e)}static scale(e,n){return new wt().scale(e,n)}translate(e){const n=this.new(),r=Oh(e);return r.type="translate",n.ops.push(r),n}magnify(e){const n=this.new(),r=zh(e);return r.type="magnify",n.ops.push(r),n}scale(e,n){const r=re(e,n),i=this.new(),a=Th(r);return a.type="scale",i.ops.push(a),i}clamp(e,n){const r=re(e,n),i=this.new(),a=Nh(r);return a.type="clamp",i.ops.push(a),i}reBound(e,n){const r=re(e,n),i=this.new(),a=Sh(r);return a.type="re-bound",i.ops.push(a),i}invert(){const e=kh();e.type="invert";const n=this.new();return n.ops.push(e),n}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new wt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,n){return this.currBounds=null,this.ops.reduce(([r,i],a)=>a(r,e,i,this.reversed),[null,n])[1]}reverse(){const e=this.new();e.ops.reverse();const n=[];return e.ops.forEach((r,i)=>{if(r.type==="scale"||n.some(([o,c])=>i>=o&&i<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>i);a!==-1&&n.push([i,a])}),n.forEach(([r,i])=>{const a=e.ops.slice(r,i);a.unshift(e.ops[i]),e.ops.splice(r,i-r+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};Te($r,"IDENTITY",new $r);let ui=$r;const hi=class Oe{constructor(e=new ui,n=new ui,r=null){Te(this,"x"),Te(this,"y"),Te(this,"currRoot"),this.x=e,this.y=n,this.currRoot=r}static translate(e,n){return new Oe().translate(e,n)}static translateX(e){return new Oe().translateX(e)}static translateY(e){return new Oe().translateY(e)}static clamp(e){return new Oe().clamp(e)}static magnify(e){return new Oe().magnify(e)}static scale(e){return new Oe().scale(e)}static reBound(e){return new Oe().reBound(e)}translate(e,n){const r=ph(e,n),i=this.copy();return i.x=this.x.translate(r.x),i.y=this.y.translate(r.y),i}translateX(e){const n=this.copy();return n.x=this.x.translate(e),n}translateY(e){const n=this.copy();return n.y=this.y.translate(e),n}magnify(e){const n=this.copy();return n.x=this.x.magnify(e.x),n.y=this.y.magnify(e.y),n}scale(e){const n=this.copy();if(gh(e)){const r=this.currRoot;return n.currRoot=e.root,r!=null&&!yh(r,e.root)&&(r.x!==e.root.x&&(n.x=n.x.invert()),r.y!==e.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(cr(e)),n.y=n.y.scale(ur(e)),n}return n.x=n.x.scale(e.width),n.y=n.y.scale(e.height),n}reBound(e){const n=this.copy();return n.x=this.x.reBound(cr(e)),n.y=this.y.reBound(ur(e)),n}clamp(e){const n=this.copy();return n.x=this.x.clamp(cr(e)),n.y=this.y.clamp(ur(e)),n}copy(){const e=new Oe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return is(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};Te(hi,"IDENTITY",new hi);var Eh=Object.defineProperty,Ih=(t,e,n)=>e in t?Eh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e,n)=>Ih(t,typeof e!="symbol"?e+"":e,n);let xh=(t,e=21)=>(n=e)=>{let r="",i=n|0;for(;i--;)r+=t[Math.random()*t.length|0];return r};const Ah="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ch=xh(Ah,11),xa=()=>Ch(),jh=Object.freeze(Object.defineProperty({__proto__:null,create:xa},Symbol.toStringTag,{value:"Module"})),Rh=s.z.enum(["static","dynamic"]),Aa=(t,e)=>{const n=new E(e);if(![T.DAY,T.HOUR,T.MINUTE,T.SECOND,T.MILLISECOND,T.MICROSECOND,T.NANOSECOND].some(i=>i.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=t.valueOf()%n.valueOf();return t instanceof E?new E(r):new T(r)},P=class O{constructor(e,n="UTC"){if(y(this,"value"),y(this,"encodeValue",!0),e==null)this.value=O.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*O.MILLISECOND.valueOf();else if(typeof e=="string")this.value=O.parseDateTimeString(e,n).valueOf();else if(Array.isArray(e))this.value=O.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),n==="local"&&(r=O.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=O.MAX:e=O.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,n=1,r=1]){const i=new Date(e,n-1,r,0,0,0,0);return new O(BigInt(i.getTime())*O.MILLISECOND.valueOf()).truncate(O.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,n="UTC"){const[r,i,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let u=O.hours(parseInt(r??"00")).add(O.minutes(parseInt(i??"00"))).add(O.seconds(parseInt(o??"00"))).add(O.milliseconds(parseInt(c??"00")));return n==="local"&&(u=u.add(O.utcOffset)),u.valueOf()}static parseDateTimeString(e,n="UTC"){if(!e.includes("/")&&!e.includes("-"))return O.parseTimeString(e,n);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new O(BigInt(r.getTime())*O.MILLISECOND.valueOf(),n).valueOf()}fString(e="ISO",n="UTC"){switch(e){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(O.utcOffset).date().toISOString()}timeString(e=!1,n="UTC"){const r=this.toISOString(n);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),n=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new T(BigInt(new Date().getTimezoneOffset())*O.MINUTE.valueOf())}static since(e){return new O().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new O(e).valueOf()}span(e){return this.range(e).span}range(e){return new K(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new O(e).valueOf()}afterEq(e){return this.valueOf()>=new O(e).valueOf()}before(e){return this.valueOf()<new O(e).valueOf()}beforeEq(e){return this.valueOf()<=new O(e).valueOf()}add(e){return new O(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new O(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(T.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(T.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(T.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(T.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(O.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(O.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const n=this.date();return n.setFullYear(e),new O(n)}get month(){return this.date().getMonth()}setMonth(e){const n=this.date();return n.setMonth(e),new O(n)}get day(){return this.date().getDate()}setDay(e){const n=this.date();return n.setDate(e),new O(n)}get hour(){return this.date().getHours()}setHour(e){const n=this.date();return n.setHours(e),new O(n)}get minute(){return this.date().getMinutes()}setMinute(e){const n=this.date();return n.setMinutes(e),new O(n)}get second(){return this.date().getSeconds()}setSecond(e){const n=this.date();return n.setSeconds(e),new O(n)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const n=this.date();return n.setMilliseconds(e),new O(n)}toString(){return this.date().toISOString()}remainder(e){return Aa(this,e)}get isToday(){return this.truncate(T.DAY).equals(O.now().truncate(T.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new O(new Date)}static max(...e){let n=O.MIN;for(const r of e){const i=new O(r);i.after(n)&&(n=i)}return n}static min(...e){let n=O.MAX;for(const r of e){const i=new O(r);i.before(n)&&(n=i)}return n}static nanoseconds(e){return new O(e)}static microseconds(e){return O.nanoseconds(e*1e3)}static milliseconds(e){return O.microseconds(e*1e3)}static seconds(e){return O.milliseconds(e*1e3)}static minutes(e){return O.seconds(e*60)}static hours(e){return O.minutes(e*60)}static days(e){return O.hours(e*24)}};y(P,"NANOSECOND",P.nanoseconds(1)),y(P,"MICROSECOND",P.microseconds(1)),y(P,"MILLISECOND",P.milliseconds(1)),y(P,"SECOND",P.seconds(1)),y(P,"MINUTE",P.minutes(1)),y(P,"HOUR",P.hours(1)),y(P,"DAY",P.days(1)),y(P,"MAX",new P((1n<<63n)-1n)),y(P,"MIN",new P(0)),y(P,"ZERO",new P(0)),y(P,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new P(t.value)),s.z.string().transform(t=>new P(BigInt(t))),s.z.instanceof(Number).transform(t=>new P(t)),s.z.number().transform(t=>new P(t)),s.z.instanceof(P)]));let E=P;const M=class k{constructor(e){y(this,"value"),y(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof k?e:e instanceof jt?e.period:e instanceof E?new k(e):["number","bigint"].includes(typeof e)?k.seconds(e):new k(e)}static fromMilliseconds(e){return e instanceof k?e:e instanceof jt?e.period:e instanceof E?new k(e):["number","bigint"].includes(typeof e)?k.milliseconds(e):new k(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new k(e).valueOf()}greaterThan(e){return this.valueOf()>new k(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new k(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new k(e).valueOf()}remainder(e){return Aa(this,e)}truncate(e){return new k(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(k.DAY),n=this.truncate(k.HOUR),r=this.truncate(k.MINUTE),i=this.truncate(k.SECOND),a=this.truncate(k.MILLISECOND),o=this.truncate(k.MICROSECOND),c=this.truncate(k.NANOSECOND),u=e,h=n.sub(e),f=r.sub(n),d=i.sub(r),N=a.sub(i),x=o.sub(a),ae=c.sub(o);let Y="";return u.isZero||(Y+=`${u.days}d `),h.isZero||(Y+=`${h.hours}h `),f.isZero||(Y+=`${f.minutes}m `),d.isZero||(Y+=`${d.seconds}s `),N.isZero||(Y+=`${N.milliseconds}ms `),x.isZero||(Y+=`${x.microseconds}µs `),ae.isZero||(Y+=`${ae.nanoseconds}ns`),Y.trim()}mult(e){return new k(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(k.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(k.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(k.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(k.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(k.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(k.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new k(e).valueOf()}add(e){return new k(this.valueOf()+new k(e).valueOf())}sub(e){return new k(this.valueOf()-new k(e).valueOf())}static nanoseconds(e=1){return new k(e)}static microseconds(e=1){return k.nanoseconds(Ye(e,1e3))}static milliseconds(e=1){return k.microseconds(Ye(e,1e3))}static seconds(e=1){return k.milliseconds(Ye(e,1e3))}static minutes(e=1){return k.seconds(Ye(e,60))}static hours(e){return k.minutes(Ye(e,60))}static days(e){return k.hours(Ye(e,24))}};y(M,"NANOSECOND",M.nanoseconds(1)),y(M,"MICROSECOND",M.microseconds(1)),y(M,"MILLISECOND",M.milliseconds(1)),y(M,"SECOND",M.seconds(1)),y(M,"MINUTE",M.minutes(1)),y(M,"HOUR",M.hours(1)),y(M,"DAY",M.days(1)),y(M,"MAX",new M((1n<<63n)-1n)),y(M,"MIN",new M(0)),y(M,"ZERO",new M(0)),y(M,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new M(t.value)),s.z.string().transform(t=>new M(BigInt(t))),s.z.instanceof(Number).transform(t=>new M(t)),s.z.number().transform(t=>new M(t)),s.z.instanceof(M)]));let T=M;const bt=class hn extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new hn(e).valueOf()}get period(){return T.seconds(1/this.valueOf())}sampleCount(e){return new T(e).seconds*this.valueOf()}byteCount(e,n){return this.sampleCount(e)*new ne(n).valueOf()}span(e){return T.seconds(e/this.valueOf())}byteSpan(e,n){return this.span(e.valueOf()/n.valueOf())}static hz(e){return new hn(e)}static khz(e){return hn.hz(e*1e3)}};y(bt,"z",s.z.union([s.z.number().transform(t=>new bt(t)),s.z.instanceof(Number).transform(t=>new bt(t)),s.z.instanceof(bt)]));let jt=bt;const Z=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ke(e*this.valueOf())}};y(Z,"UNKNOWN",new Z(0)),y(Z,"BIT128",new Z(16)),y(Z,"BIT64",new Z(8)),y(Z,"BIT32",new Z(4)),y(Z,"BIT16",new Z(2)),y(Z,"BIT8",new Z(1)),y(Z,"z",s.z.union([s.z.number().transform(t=>new Z(t)),s.z.instanceof(Number).transform(t=>new Z(t)),s.z.instanceof(Z)]));let ne=Z;const pe=class dn{constructor(e,n){y(this,"start"),y(this,"end"),typeof e=="object"&&"start"in e?(this.start=new E(e.start),this.end=new E(e.end)):(this.start=new E(e),this.end=new E(n))}get span(){return new T(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new dn(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,n=T.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const i=E.max(r.start,e.start),a=E.min(r.end,e.end);return a.before(i)?!1:new T(a.sub(i)).greaterThanOrEqual(n)}roughlyEquals(e,n){let r=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=n.valueOf()&&i<=n.valueOf()}contains(e){return e instanceof dn?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const n=new dn(this.start,this.end);return e.start.after(this.start)&&(n.start=e.start),e.start.after(this.end)&&(n.end=e.start),e.end.before(this.end)&&(n.end=e.end),e.end.before(this.start)&&(n.start=e.end),n}};y(pe,"MAX",new pe(E.MIN,E.MAX)),y(pe,"MIN",new pe(E.MAX,E.MIN)),y(pe,"ZERO",new pe(E.ZERO,E.ZERO)),y(pe,"z",s.z.union([s.z.object({start:E.z,end:E.z}).transform(t=>new pe(t.start,t.end)),s.z.instanceof(pe)]));let K=pe;const Ph=(t,e)=>t.start.before(e.start)?-1:t.start.after(e.start)?1:t.end.before(e.end)?-1:t.end.after(e.end)?1:0,g=class _ extends String{constructor(e){if(e instanceof _||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const n=_.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(n!=null){super(n.valueOf());return}throw super(_.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=_.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(n=>this.equals(n))}toString(){return this.valueOf()}get isVariable(){return this.equals(_.JSON)||this.equals(_.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(_.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=_.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(_.UINT8)||this.equals(_.UINT16)||this.equals(_.UINT32)||this.equals(_.UINT64)}get isSigned(){return this.equals(_.INT8)||this.equals(_.INT16)||this.equals(_.INT32)||this.equals(_.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(_.INT32)&&e.equals(_.FLOAT64)||this.equals(_.INT8)&&e.equals(_.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return _.BIG_INT_TYPES.some(e=>e.equals(this))}};y(g,"UNKNOWN",new g("unknown")),y(g,"FLOAT64",new g("float64")),y(g,"FLOAT32",new g("float32")),y(g,"INT64",new g("int64")),y(g,"INT32",new g("int32")),y(g,"INT16",new g("int16")),y(g,"INT8",new g("int8")),y(g,"UINT64",new g("uint64")),y(g,"UINT32",new g("uint32")),y(g,"UINT16",new g("uint16")),y(g,"UINT8",new g("uint8")),y(g,"BOOLEAN",g.UINT8),y(g,"TIMESTAMP",new g("timestamp")),y(g,"UUID",new g("uuid")),y(g,"STRING",new g("string")),y(g,"JSON",new g("json")),y(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),y(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),y(g,"DENSITIES",new Map([[g.UINT8.toString(),ne.BIT8],[g.UINT16.toString(),ne.BIT16],[g.UINT32.toString(),ne.BIT32],[g.UINT64.toString(),ne.BIT64],[g.FLOAT32.toString(),ne.BIT32],[g.FLOAT64.toString(),ne.BIT64],[g.INT8.toString(),ne.BIT8],[g.INT16.toString(),ne.BIT16],[g.INT32.toString(),ne.BIT32],[g.INT64.toString(),ne.BIT64],[g.TIMESTAMP.toString(),ne.BIT64],[g.STRING.toString(),ne.UNKNOWN],[g.JSON.toString(),ne.UNKNOWN],[g.UUID.toString(),ne.BIT128]])),y(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),y(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),y(g,"z",s.z.union([s.z.string().transform(t=>new g(t)),s.z.instanceof(g)]));let I=g;const Q=class W extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return W.bytes(this.valueOf()+e.valueOf())}sub(e){return W.bytes(this.valueOf()-e.valueOf())}truncate(e){return new W(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return W.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/W.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/W.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/W.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/W.TERABYTE.valueOf()}toString(){const e=this.truncate(W.TERABYTE),n=this.truncate(W.GIGABYTE),r=this.truncate(W.MEGABYTE),i=this.truncate(W.KILOBYTE),a=this.truncate(W.BYTE),o=e,c=n.sub(e),u=r.sub(n),h=i.sub(r),f=a.sub(i);let d="";return o.isZero||(d+=`${o.terabytes}TB `),c.isZero||(d+=`${c.gigabytes}GB `),u.isZero||(d+=`${u.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new W(e)}static kilobytes(e=1){return W.bytes(e.valueOf()*1e3)}static megabytes(e=1){return W.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return W.megabytes(e.valueOf()*1e3)}static terabytes(e){return W.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};y(Q,"BYTE",new Q(1)),y(Q,"KILOBYTE",Q.kilobytes(1)),y(Q,"MEGABYTE",Q.megabytes(1)),y(Q,"GIGABYTE",Q.gigabytes(1)),y(Q,"TERABYTE",Q.terabytes(1)),y(Q,"ZERO",new Q(0)),y(Q,"z",s.z.union([s.z.number().transform(t=>new Q(t)),s.z.instanceof(Q)]));let Ke=Q;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const Ca=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof E||t instanceof T||t instanceof Date},Mh=(t,e,n,r=0)=>t.usesBigInt&&!e.usesBigInt?Number(n)-Number(r):!t.usesBigInt&&e.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):vt(n,-r).valueOf(),vt=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e),Bh=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Be?!0:Ca(t),Ee=-1,Dr={[Symbol.iterator]:()=>Dr,next:()=>({done:!0,value:void 0})},Uh=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),$h=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),Lr=10,ja=(t,e)=>{if(t==="string"&&!e.isVariable)throw new Error(`cannot convert series of type ${e.toString()} to string`);if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Ot=class ge{constructor(e){y(this,"key",""),y(this,"isSynnaxSeries",!0),y(this,"dataType"),y(this,"sampleOffset"),y(this,"gl"),y(this,"_data"),y(this,"_timeRange"),y(this,"alignment",0n),y(this,"_cachedMin"),y(this,"_cachedMax"),y(this,"writePos",Ee),y(this,"_refCount",0),y(this,"_cachedLength"),y(this,"_cachedIndexes"),Bh(e)&&(e={data:e});const{dataType:n,timeRange:r,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:c=xa()}=e,u=e.data??[];if(u instanceof ge||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this._timeRange=d._timeRange,this.alignment=d.alignment,this._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=Ca(u),f=Array.isArray(u);if(n!=null)this.dataType=new I(n);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=I.STRING;else if(typeof d=="number")this.dataType=I.FLOAT64;else if(typeof d=="bigint")this.dataType=I.INT64;else if(typeof d=="boolean")this.dataType=I.BOOLEAN;else if(d instanceof E||d instanceof Date||d instanceof E)this.dataType=I.TIMESTAMP;else if(typeof d=="object")this.dataType=I.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new I(u)}if(!f&&!h)this._data=u;else{let d=h?[u]:u;const N=d[0];(N instanceof E||N instanceof Date||N instanceof T)&&(d=d.map(x=>new E(x).valueOf())),this.dataType.equals(I.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
16
- `)}
17
- `).buffer):this.dataType.equals(I.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(x=>Ge.encodeString(x)).join(`
18
- `)}
19
- `).buffer):this.dataType.usesBigInt&&typeof N=="number"?this._data=new this.dataType.Array(d.map(x=>BigInt(Math.round(x)))).buffer:!this.dataType.usesBigInt&&typeof N=="bigint"?this._data=new this.dataType.Array(d.map(x=>Number(x))).buffer:this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:n,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new I(n).Array(e),a=new ge({data:i.buffer,dataType:n,...r});return a.writePos=0,a}static createTimestamps(e,n,r){const i=r.spanRange(n.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(r.add(n.span(o)).valueOf());return new ge({data:a,dataType:I.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,n){const r=new TextEncoder().encode(`${e.join(`
20
- `)}
21
- `);return new ge({data:r,dataType:I.STRING,timeRange:n})}static fromJSON(e,n){const r=new TextEncoder().encode(`${e.map(i=>Ge.encodeString(i)).join(`
22
- `)}
23
- `);return new ge({data:r,dataType:I.JSON,timeRange:n})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ee)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===Ee)return 0;const n=this.capacity-this.writePos,r=e.sub(0,n);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ee?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(I.STRING,I.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
24
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(I.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=I.UUID.density.valueOf(),n=Array(this.length);for(let r=0;r<this.length;r++){const i=this.underlyingData.slice(r*e,(r+1)*e),a=Array.from(new Uint8Array(i.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");n[r]=a}return n}parseJSON(e){if(!this.dataType.equals(I.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
25
- `).slice(0,-1).map(n=>e.parse(Ge.decodeString(n)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Ke(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ee?this.byteCapacity:this.dataType.isVariable?new Ke(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ee?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const n=[0];return this.data.forEach((r,i)=>{r===Lr&&(e++,n.push(i+1))}),this._cachedIndexes=n,this._cachedLength=e,e}convert(e,n=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let i=0;i<this.length;i++)r[i]=Mh(this.dataType,e,this.data[i],n);return new ge({data:r.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(I.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}else{const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),vt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(I.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}else{const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),vt(this._cachedMin,this.sampleOffset))}get bounds(){return re(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const n=e._cachedMin??e.calcRawMin();n<this._cachedMin&&(this._cachedMin=n)}if(this._cachedMax!=null){const n=e._cachedMax??e.calcRawMax();n>this._cachedMax&&(this._cachedMax=n)}}enrich(){this.max,this.min}get range(){return vt(this.max,-this.min)}atAlignment(e,n){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(e,n){if(this.dataType.isVariable)return this.atVariable(e,n??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${e}`);return}return vt(r,this.sampleOffset)}atVariable(e,n){let r=0,i=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],i=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===Lr){if(e===0){i=o;break}r=o+1,e--}if(i===0&&(i=this.data.length),r>=i||e>0){if(n)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(r,i);return this.dataType.equals(I.STRING)?new TextDecoder().decode(a):wa(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let n=0,r=this.length-1;const i=Fu(e);for(;n<=r;){const a=Math.floor((n+r)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?n=a+1:r=a-1}return n}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(I.FLOAT32)&&!this.dataType.equals(I.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:i}=this.gl;if(n==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ee){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ee}as(e){return ja(e,this.dataType),this}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:bi(this.alignmentBounds.lower),upper:bi(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return re(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Dh(this);return this.dataType.equals(I.JSON)?new Lh(e):e}return new _h(this)}slice(e,n){return this.sliceSub(!1,e,n)}sub(e,n){return this.sliceSub(!0,e,n)}subIterator(e,n){return new di(this,e,n??this.length)}subAlignmentIterator(e,n){return new di(this,Number(e-this.alignment),Number(n-this.alignment))}subBytes(e,n){if(e>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,n);return new ge({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return e?i=this.data.subarray(n,r):i=this.data.slice(n,r),new ge({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(e){return new ge({data:this.buffer,dataType:this.dataType,timeRange:K.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};y(Ot,"crudeZ",s.z.object({timeRange:K.z.optional(),dataType:I.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([Uh,$h,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:Rh.optional().default("static").optional()})),y(Ot,"z",Ot.crudeZ.transform(t=>new Ot(t)));let Be=Ot;class di{constructor(e,n,r){y(this,"series"),y(this,"end"),y(this,"index"),this.series=e;const i=re(0,e.length);this.end=oi(i,r),this.index=oi(i,n)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class Dh{constructor(e){if(y(this,"series"),y(this,"index"),y(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==Lr;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var fi,yi;class Lh{constructor(e){y(this,"wrapped"),y(this,fi,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Ge.decodeString(e.value)}}[(yi=Symbol.iterator,fi=Symbol.toStringTag,yi)](){return this}}var pi,gi;class _h{constructor(e){y(this,"series"),y(this,"index"),y(this,pi,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(gi=Symbol.iterator,pi=Symbol.toStringTag,gi)](){return this}}class qh{constructor(e){if(y(this,"series"),e.length!==0){const n=e[0].dataType;for(let r=1;r<e.length;r++)if(!e[r].dataType.equals(n))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){return ja(e,this.dataType),this}get dataType(){return this.series.length===0?I.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?K.ZERO:new K(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?re(0n,0n):re(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,n)=>e+n.length,0)}atAlignment(e,n){if(this.series.length===0){if(n)throw new Error(`[series] - no value at alignment ${e}`);return}for(const r of this.series)if(Xt(r.alignmentBounds,e))return r.atAlignment(e,n);if(n)throw new Error(`[series] - no value at alignment ${e}`)}at(e,n=!1){e<0&&(e=this.length+e);for(const r of this.series){if(e<r.length)return r.at(e,n);e-=r.length}if(n)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,n){return new hr(this,e,n??this.length)}subAlignmentIterator(e,n){if(e>=this.alignmentBounds.upper||n<=this.alignmentBounds.lower)return Dr;let r=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)r+=o.length;else if(Xt(o.alignmentBounds,e)){r+=Number(e-o.alignment);break}}let i=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(n<o.alignment)break;if(n>=o.alignmentBounds.upper)i+=o.length;else if(Xt(o.alignmentBounds,n)){i+=Number(n-o.alignment);break}}return new hr(this,r,i)}subAlignmentSpanIterator(e,n){if(e>=this.alignmentBounds.upper)return Dr;let r=0;for(let i=0;i<this.series.length;i++){const a=this.series[i];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)r+=a.length;else if(Xt(a.alignmentBounds,e)){r+=Number(e-a.alignment);break}}return new hr(this,r,r+n)}get byteLength(){return new Ke(this.series.reduce((e,n)=>e+n.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let n=0;for(const r of this.series)e.set(r.data,n),n+=r.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,n){const r=this.series.map(i=>i.alignmentBounds);return uh(r,e,n)}distance(e,n){const r=this.series.map(i=>i.alignmentBounds);return hh(r,e,n)}parseJSON(e){if(!this.dataType.equals(I.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(n=>n.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Yh(this.series)}}var mi,wi;class Yh{constructor(e){y(this,"series"),y(this,"seriesIndex"),y(this,"internal"),y(this,mi,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(wi=Symbol.iterator,mi=Symbol.toStringTag,wi)](){return this}}let hr=class{constructor(t,e,n){y(this,"series"),y(this,"index"),y(this,"end"),this.series=t,this.end=n,this.index=e}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};const bi=t=>{const e=t>>32n,n=t&0xffffffffn;return{domain:e,sample:n}},Fh=(t,e)=>{let n=null;return e===0?t:(...r)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...r),e)}},Wh=(t,e,n=".")=>{const r=t.split(n);return r.map((i,a)=>{const o=e(i,a,r);return o==null?null:typeof o=="string"?o:o.join(n)}).filter(i=>i!=null).join(n)},Vh=(t,e,n={optional:!1,separator:"."})=>{n.separator??(n.separator=".");const{optional:r,getter:i=(c,u)=>c[u]}=n,a=e.split(n.separator);if(a.length===1&&a[0]==="")return t;let o=t;for(const c of a){const u=i(o,c);if(u==null){if(r)return null;throw new Error(`Path ${e} does not exist. ${c} is null`)}o=u}return o};s.z.object({key:s.z.string(),value:s.z.string()});var Gh=Object.defineProperty,Zh=(t,e,n)=>e in t?Gh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fn=(t,e,n)=>Zh(t,typeof e!="symbol"?e+"":e,n);let Kh=class{constructor(t,e){fn(this,"handlers"),fn(this,"transform"),fn(this,"closer"),this.transform=t,this.handlers=e??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){let e=t;if(this.transform!=null){const[n,r]=this.transform(t);if(!r)return;e=n}this.handlers.forEach((n,r)=>r(e))}setCloser(t){this.closer=t}async close(){var t;return await((t=this.closer)==null?void 0:t.call(this))}},Jh=class{constructor(t){fn(this,"handlers"),this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((e,n)=>n(t))}};const De=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Jh,Observer:Kh},Symbol.toStringTag,{value:"Module"})),qt=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),Hh=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Hh();const Xh=["macOS","Windows","Linux"],Qh=["macos","windows","linux"],ed={macos:"macOS",windows:"Windows",linux:"Linux"};s.z.enum(Xh).or(s.z.enum(Qh).transform(t=>ed[t]));var td=Object.defineProperty,nd=(t,e,n)=>e in t?td(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,zt=(t,e,n)=>nd(t,typeof e!="symbol"?e+"":e,n);const rd=(...t)=>t.map(Ra).join(""),Ra=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),sd=t=>t.endsWith("/")?t.slice(0,-1):t,_r=class qr{constructor({host:e,port:n,protocol:r="",pathPrefix:i=""}){zt(this,"protocol"),zt(this,"host"),zt(this,"port"),zt(this,"path"),this.protocol=r,this.host=e,this.port=n,this.path=Ra(i)}replace(e){return new qr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new qr({...this,pathPrefix:rd(this.path,e)})}toString(){return sd(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};zt(_r,"UNKNOWN",new _r({host:"unknown",port:0}));let id=_r;const ad=-128,od=127,ld=s.z.number().int().min(ad).max(od),cd=-32768,ud=32767,hd=s.z.number().int().min(cd).max(ud),dd=-2147483648,fd=2147483647,yd=s.z.number().int().min(dd).max(fd),pd=-9223372036854775808n,gd=9223372036854775807n,md=s.z.bigint().min(pd).max(gd),wd=255,bd=s.z.number().int().min(0).max(wd),vd=65535,Od=s.z.number().int().min(0).max(vd),zd=4294967295,Td=s.z.number().int().min(0).max(zd),Sd=18446744073709551615n,kd=s.z.bigint().min(0n).max(Sd),Pa=t=>Wh(t,(e,n,r)=>{const i=n===r.length-1,a=!isNaN(parseInt(e)),o=!isNaN(parseInt(r[n+1]));return a&&(e="element"),i||o?e:[e,"shape"]}),vi=(t,e)=>{if(t==null)return null;const n=t[e];return n==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:n},Nd=(t,e,n)=>Vh(vi(t,"shape"),Pa(e),{...n,getter:vi}),Ed=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:Nd,getFieldSchemaPath:Pa,int16:hd,int32:yd,int64:md,int8:ld,uint16:Od,uint32:Td,uint64:kd,uint8:bd},Symbol.toStringTag,{value:"Module"}));var Id=Object.defineProperty,xd=(t,e,n)=>e in t?Id(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Tt=(t,e,n)=>xd(t,typeof e!="symbol"?e+"":e,n);const Ad=async t=>await new Promise(e=>setTimeout(e,T.fromMilliseconds(t).milliseconds)),Cd=s.z.object({interval:T.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),jd=(t={})=>{const e=t.sleepFn||Ad,n=t.maxRetries??5,r=t.scale??1;let i=0,a=new T(t.interval??T.milliseconds(1));return async()=>i>=n?!1:(await e(a),a=a.mult(r),i++,!0)},Rd=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:Cd,create:jd},Symbol.toStringTag,{value:"Module"})),me=class extends Number{};Tt(me,"ABSOLUTE",255),Tt(me,"MINIMUM",0),Tt(me,"BOUNDS",{lower:me.MINIMUM,upper:me.ABSOLUTE+1}),Tt(me,"z",s.z.union([s.z.instanceof(me),s.z.number().int().min(0).max(255).transform(t=>new me(t)),s.z.instanceof(Number).transform(t=>new me(t))]));let Ma=me;const Ba=s.z.object({name:s.z.string(),key:s.z.string()}),Pd=t=>s.z.object({subject:Ba,resource:t,authority:Ma.z}),Md=(...t)=>e=>e.filter(n=>{let r=!1;return n.to!=null&&(r=t.includes(n.to.resource)),n.from!=null&&!r&&(r=t.includes(n.from.resource)),r}),Je=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ma,filterTransfersByChannelKey:Md,stateZ:Pd,subjectZ:Ba},Symbol.toStringTag,{value:"Module"})),Ua=class St extends Error{constructor(){super(St.MESSAGE)}matches(e){return typeof e=="string"?e.includes(St.MESSAGE):e instanceof St||e.message.includes(St.MESSAGE)}};Tt(Ua,"MESSAGE","canceled");let Bd=Ua;new Bd;const Yr=s.z.string().regex(/^\d+\.\d+\.\d+$/),Yt=(t,e,n={})=>{n.checkMajor??(n.checkMajor=!0),n.checkMinor??(n.checkMinor=!0),n.checkPatch??(n.checkPatch=!0);const r=Yr.parse(t),i=Yr.parse(e),[a,o,c]=r.split(".").map(Number),[u,h,f]=i.split(".").map(Number);if(n.checkMajor){if(a<u)return ar;if(a>u)return or}if(n.checkMinor){if(o<h)return ar;if(o>h)return or}if(n.checkPatch){if(c<f)return ar;if(c>f)return or}return Dn},Ud=(t,e,n={})=>Zu(Yt(t,e,n)),$a=(t,e,n={})=>Gu(Yt(t,e,n)),$d=(t,e,n={})=>Vu(Yt(t,e,n)),Dd=({name:t,migrate:e})=>n=>{try{const r=e(n);return console.log(`${t} migrated: ${n.version} -> ${r.version}`),r}catch(r){throw console.log(`${t} failed to migrate from ${n.version}`),console.error(r),r}},Ld=({name:t,migrations:e,targetSchema:n,defaultVersion:r,def:i})=>{const a=Object.keys(e).sort(Yt).pop();if(a==null)return h=>{if(h.version??(h.version=r),h.version!==i.version)return console.log(`${t} version ${h.version} is newer than latest version of ${i.version}.
26
- Returning default instead.
27
- `),i;try{return n!=null?n.parse(h):h}catch(f){return console.log(`${t} failed to parse default. Exiting with default`),console.error(f),i}};const o=Object.keys(e).length;let c=!1;const u=h=>{try{if(o===0||$a(h.version,a))return console.log(c?`${t} ${h.version} now up to date`:`${t} version ${h.version} is up to date with target version ${i.version}`),h;const f=h.version,d=e[f],N=d(h);return c=!0,u(N)}catch(f){return console.log(`${t} failed to migrate from ${h.version} to ${a}`),console.error(f),i}};return h=>{try{if(h.version==null)if(r!=null)console.log(`${t} version is null. Setting version to default of ${r}`),h.version=r;else return console.log(`${t} version is null and no default version set. Exiting with default`),i;return u(h)}catch(f){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(f),i}}},Oi=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:Yt,createMigration:Dd,migrator:Ld,semVerNewer:$a,semVerOlder:$d,semVerZ:Yr,versionsEqual:Ud},Symbol.toStringTag,{value:"Module"})),_d=["standard","scientific","engineering"];s.z.enum(_d);const qd=(t,e="")=>{const n=t.length;return n===0?e:n===1?t[0]:n===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[n-1]}`},Yd=t=>{const e=t.split(" "),n=new Set,r=e.map(o=>o.charAt(0).toLowerCase()).join("");n.add(r.replace(/-/g,"_")),n.add(r.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const i=/\d+/g;t.match(i)&&e.forEach((o,c)=>{if(i.test(o)){const u=e.map((h,f)=>f!==c?h.charAt(0).toLowerCase():h).join("");n.add(u.replace(/-/g,"_")),n.add(u.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const a=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return n.add(a.join("").replace(/-/g,"_")),n.add(a.join("_").replace(/-/g,"_")),Array.from(n).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},Fd=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Yd,naturalLanguageJoin:qd},Symbol.toStringTag,{value:"Module"})),Me="sy.",yn=class Da extends de{constructor(){super(...arguments),l(this,"type",Da.TYPE)}};l(yn,"TYPE",`${Me}validation`),l(yn,"matches",ee(yn.TYPE));let q=yn;const pn=class La extends q{constructor(e,n){super(`${e}: ${n}`),l(this,"type",La.TYPE),l(this,"field"),l(this,"message"),this.field=e,this.message=n}};l(pn,"TYPE",`${q.TYPE}.field`),l(pn,"matches",ee(pn.TYPE));let zi=pn;const gn=class _a extends de{constructor(){super(...arguments),l(this,"type",_a.TYPE)}};l(gn,"TYPE",`${Me}auth`),l(gn,"matches",ee(gn.TYPE));let He=gn;const mn=class qa extends He{constructor(){super(...arguments),l(this,"type",qa.TYPE)}};l(mn,"TYPE",`${He.TYPE}.invalid-token`),l(mn,"matches",ee(mn.TYPE));let Fr=mn;const wn=class Ya extends He{constructor(){super(...arguments),l(this,"type",Ya.TYPE)}};l(wn,"TYPE",`${He.TYPE}.expired-token`),l(wn,"matches",ee(wn.TYPE));let Wr=wn;const bn=class Fa extends de{constructor(e){super(`
28
- Unexpected error encountered:
29
-
30
- ${e}
31
-
32
- Please report this to the Synnax team.
33
- `),l(this,"type",Fa.TYPE)}};l(bn,"TYPE",`${Me}unexpected`),l(bn,"matches",ee(bn.TYPE));let le=bn;const vn=class Wa extends de{constructor(){super(...arguments),l(this,"type",Wa.TYPE)}};l(vn,"TYPE",`${Me}query`),l(vn,"matches",ee(vn.TYPE));let he=vn;const On=class Va extends he{constructor(){super(...arguments),l(this,"type",Va.TYPE)}};l(On,"TYPE",`${he.TYPE}.not_found`),l(On,"matches",ee(On.TYPE));let Xe=On;const zn=class Ga extends he{constructor(){super(...arguments),l(this,"type",Ga.TYPE)}};l(zn,"TYPE",`${he.TYPE}.multiple_results`),l(zn,"matches",ee(zn.TYPE));let Qe=zn;const Tn=class Za extends de{constructor(e,n){super(e),l(this,"type",Za.TYPE),l(this,"path"),this.path=n}};l(Tn,"TYPE",`${Me}route`),l(Tn,"matches",ee(Tn.TYPE));let Ti=Tn;const Sn=class Ka extends de{constructor(){super(...arguments),l(this,"type",Ka.TYPE)}};l(Sn,"TYPE",`${Me}control`),l(Sn,"matches",ee(Sn.TYPE));let Pn=Sn;const kn=class Ja extends Pn{constructor(){super(...arguments),l(this,"type",Ja.TYPE)}};l(kn,"TYPE",`${Pn.TYPE}.unauthorized`),l(kn,"matches",ee(kn.TYPE));let Si=kn;const dr=class Ha extends de{constructor(){super(...arguments),l(this,"type",Ha.TYPE)}};l(dr,"TYPE",`${Me}contiguity`),l(dr,"matches",ee(dr.TYPE));const Wd=t=>{if(!t.type.startsWith(Me))return null;if(t.type.startsWith(q.TYPE)){if(t.type===zi.TYPE){const e=t.data.split(": ");return e.length<2?new q(t.data):new zi(e[0],e[1])}return new q(t.data)}return t.type.startsWith(He.TYPE)?t.type.startsWith(Fr.TYPE)?new Fr(t.data):t.type.startsWith(Wr.TYPE)?new Wr(t.data):new He(t.data):t.type.startsWith(le.TYPE)?new le(t.data):t.type.startsWith(he.TYPE)?t.type.startsWith(Xe.TYPE)?new Xe(t.data):t.type.startsWith(Qe.TYPE)?new Qe(t.data):new he(t.data):t.type.startsWith(Pn.TYPE)?t.type.startsWith(Si.TYPE)?new Si(t.data):new Pn(t.data):t.type.startsWith(Ti.TYPE)?new Ti(t.data,t.data):new le(t.data)},Vd=()=>{throw new Error("Not implemented")};ca({encode:Vd,decode:Wd});const Gd=async(t,e)=>{const[n,r]=await e(t);return r==null?[n,r]:r instanceof Re?[n,new Re({message:`Cannot reach cluster at ${r.url.host}:${r.url.port}`,url:r.url})]:[n,r]},_n=s.z.string().uuid(),as=s.z.string(),Xa=s.z.object({key:_n,name:as}),Qa="group",J=t=>s.z.union([s.z.union([s.z.null(),s.z.undefined()]).transform(()=>[]),t.array()]),H=s.z.number(),Ft=s.z.string(),Wt=s.z.object({name:Ft,key:H,rate:jt.z,dataType:I.z,leaseholder:s.z.number(),index:H,isIndex:s.z.boolean(),internal:s.z.boolean(),virtual:s.z.boolean(),alias:s.z.string().optional(),expression:s.z.string().default(""),requires:J(H)}),eo=Wt.extend({key:H.optional(),leaseholder:s.z.number().optional(),index:H.optional(),rate:jt.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1),expression:s.z.string().optional().default(""),requires:J(H).optional().default([])}),qn="channel",Zd="framer",ki=t=>{const e=b(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Ni=(t,e)=>{const n=b(t);if(n.length===e.length)return;const r=ki(t);throw ki===null?new q("[Frame] - channel keys or names must be provided when constructing a frame."):new q(`[Frame] - ${r}s and series must be the same length.
34
- Got ${n.length} ${r}s and ${e.length} series.`)};let ue=class Fe{constructor(e=[],n=[]){if(l(this,"columns",[]),l(this,"series",[]),e instanceof Fe){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((r,i)=>this.push(i,...b(r)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const r=e;r.series??(r.series=[]),r.keys??(r.keys=[]);const i=r.series.map(a=>Kd(a));Ni(r.keys,i),r.keys.forEach((a,o)=>this.push(a,i[o]))}else Object.entries(e).forEach(([r,i])=>{const a=parseInt(r);if(!isNaN(a))return this.push(a,...b(i));this.push(r,...b(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const r=b(n),i=b(e);Ni(i,r),r.forEach((a,o)=>this.push(i[o],a));return}throw new q(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
35
- payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
36
- name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new le("colType is not key");return this.columns??[]}get uniqueKeys(){return ri.unique(this.keys)}get names(){if(this.colType==="key")throw new le("colType is not name");return this.columns??[]}get uniqueNames(){return ri.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Jd(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(n=>n.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return K.ZERO;const r=E.min(...this.series.map(a=>a.timeRange.start)),i=E.max(...this.series.map(a=>a.timeRange.end));return new K(r,i)}const n=this.get(e);return n==null?K.ZERO:n.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(n=>e.includes(n)):new qh(this.series.filter((n,r)=>this.columns[r]===e))}push(e,...n){if(e instanceof Fe){if(this.colType!==null&&e.colType!==this.colType)throw new q("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...n),typeof e=="string"&&this.colType==="key")throw new q("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new q("keyVariant must match");this.columns.push(...Array.from({length:n.length},()=>e))}}concat(e){return new Fe([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const n=new Fe;return this.forEach((r,i,a)=>n.push(...e(r,i,a))),n}forEach(e){this.columns.forEach((n,r)=>{const i=this.series[r];e(n,i,r)})}at(e,n=!1){const r={};return this.uniqueColumns.forEach(i=>{r[i]=this.get(i).at(e,n)}),r}filter(e){const n=new Fe;return this.columns.forEach((r,i)=>{const a=this.series[i];e(r,a,i)&&n.push(r,a)}),n}get byteLength(){return new Ke(this.series.reduce((e,n)=>e.add(n.byteLength),Ke.ZERO))}get digest(){const e={};return this.keys.forEach((n,r)=>{const i=this.series[r].digest;n in e?e[n].push(i):e[n]=[i]}),e}get length(){return this.series.reduce((e,n)=>e+n.length,0)}};const os=s.z.object({keys:s.z.union([s.z.null().transform(()=>[]),s.z.number().array().optional().default([])]),series:s.z.union([s.z.null().transform(()=>[]),Be.crudeZ.array().optional().default([])])}),Kd=t=>{const{dataType:e,data:n,timeRange:r,alignment:i}=t;return new Be({data:n,dataType:e,timeRange:r,glBufferUsage:"static",alignment:i})},Jd=t=>({timeRange:t._timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment}),Le=Ed.uint32,to=s.z.object({key:Le,variant:s.z.string(),message:s.z.string(),lastReceived:E.z.optional()}),ls=s.z.object({key:Le,name:s.z.string(),state:to.optional()}),Hd=ls.partial({key:!0}),no="rack",cs=t=>t?_t.JSON_CODEC.decodeString(t):{},Yn=s.z.string(),ro=s.z.object({key:Yn,variant:s.z.string(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(cs))}),Fn=s.z.object({key:Yn,rack:Le,name:s.z.string(),make:s.z.string(),model:s.z.string(),location:s.z.string(),configured:s.z.boolean().optional(),properties:s.z.record(s.z.unknown()).or(s.z.string().transform(cs)),state:ro.optional()}),Xd=Fn.extend({properties:s.z.unknown().transform(t=>_t.JSON_CODEC.encodeString(t))}),so="device",we=t=>t?JSON.parse(t):{},_e=s.z.union([s.z.string(),s.z.bigint().transform(t=>t.toString()),s.z.number().transform(t=>t.toString())]),Qd=s.z.enum(["info","success","error","warning"]),Mn=s.z.object({task:_e,variant:Qd,key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(we)).or(s.z.array(s.z.unknown())).or(s.z.null())}),Wn=s.z.object({key:_e,name:s.z.string(),type:s.z.string(),internal:s.z.boolean().optional(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(cs)),state:Mn.optional().nullable(),snapshot:s.z.boolean().optional()}),ef=Wn.omit({key:!0}).extend({key:_e.transform(t=>t.toString()).optional(),config:s.z.unknown().transform(t=>_t.JSON_CODEC.encodeString(t))}),io=s.z.object({task:_e,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(we)).or(s.z.array(s.z.unknown())).or(s.z.null()).optional()}),us="task",tt=s.z.string().uuid(),Vn=s.z.object({key:tt,name:s.z.string().min(1),color:s.z.string()}),ao="label",se=s.z.string().uuid(),hs=s.z.string().min(1),Vt=s.z.object({key:se,name:hs,timeRange:K.z,color:s.z.string().optional()}),oo=Vt.partial({key:!0}),lo=t=>{const e=b(t),n=e.length===0;let r=!1;return n||(r=se.safeParse(e[0]).success),{single:!Array.isArray(t),variant:r?"keys":"names",normalized:e,actual:t,empty:n}},ds="range",fs="range-alias",nt=s.z.string().uuid(),Gn=s.z.object({key:nt,username:s.z.string().min(1),firstName:s.z.string().default(""),lastName:s.z.string().default(""),rootUser:s.z.boolean().default(!0)}),tf=Gn.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:s.z.string().min(1)}),nf="user",Gt=s.z.string().uuid(),ys=s.z.object({key:Gt,name:s.z.string(),data:qt.or(s.z.string().transform(we))}),rf=ys.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),sf="lineplot",Zt=s.z.string().uuid(),ps=s.z.object({key:Zt,name:s.z.string(),data:qt.or(s.z.string().transform(we))}),af=ps.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),of="log",ke=s.z.string().uuid(),gs=s.z.object({key:ke,name:s.z.string(),layout:qt.or(s.z.string().transform(we))}),co="workspace",lf=gs.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),cf=gs.omit({layout:!0}).extend({layout:s.z.string().transform(we)}),rt=s.z.string().uuid(),ms=s.z.object({key:rt,name:s.z.string(),data:qt.or(s.z.string().transform(we)),snapshot:s.z.boolean()}),uf=ms.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),uo=ms.extend({data:s.z.string().transform(we)}),hf="schematic",Kt=s.z.string().uuid(),ho=s.z.object({key:Kt,name:s.z.string(),data:qt.or(s.z.string().transform(we))}),df=ho.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),fo=ho.extend({data:s.z.string().transform(we)}),ff="table",yo="builtin",yf="cluster",pf="node",Zn=s.z.enum([ao,of,Fi,yo,yf,qn,pf,Qa,ds,Zd,fs,nf,co,hf,sf,no,so,us,Il,ff]),ie=s.z.object({type:Zn,key:s.z.string()}),gf=s.z.string().transform(t=>{const[e,n]=t.split(":");return{type:Zn.parse(e),key:n??""}}),kt=s.z.union([gf,ie]),Nn=class po{constructor(e){if(l(this,"type"),l(this,"key"),e instanceof po){this.type=e.type,this.key=e.key;return}if(typeof e=="string"){const[n,r]=e.split(":");this.type=n,this.key=r??"";return}this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}isType(){return this.key===""}matchesType(e){return this.type===e&&this.isType()}get payload(){return{type:this.type,key:this.key}}};l(Nn,"z",s.z.union([s.z.instanceof(Nn),kt.transform(t=>new Nn(t))]));let C=Nn;new C({type:yo,key:"root"});const mf=s.z.object({type:s.z.number()}),wf=s.z.object({type:Zn,fields:s.z.record(mf)}),bf=s.z.object({id:C.z,name:s.z.string(),schema:wf.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(t=>({key:t.id.toString(),...t}));s.z.object({from:C.z,type:s.z.string(),to:C.z});const Ei=t=>{const[e,n,r]=t.split("->");return{from:new C(e),type:n,to:new C(r)}};class go{constructor(e,n){l(this,"key"),l(this,"name"),this.key=n,this.name=e}get ontologyID(){return vf(this.key)}}const vf=t=>new C({type:Qa,key:t}),Of=s.z.object({group:Xa}),zf=s.z.object({parent:ie,key:_n.optional(),name:as}),Tf=s.z.object({key:_n,name:as}),Sf=s.z.object({keys:s.z.array(_n)});var Ie;let kf=(Ie=class{constructor(t){l(this,"client"),this.client=t}async create(t,e,n){return(await w(this.client,Ie.CREATE_ENDPOINT,{parent:t,name:e,key:n},zf,Of)).group}async rename(t,e){await w(this.client,Ie.RENAME_ENDPOINT,{key:t,name:e},Tf,s.z.object({}))}async delete(t){await w(this.client,Ie.DELETE_ENDPOINT,{keys:t},Sf,s.z.object({}))}},l(Ie,"CREATE_ENDPOINT","/ontology/create-group"),l(Ie,"RENAME_ENDPOINT","/ontology/rename-group"),l(Ie,"DELETE_ENDPOINT","/ontology/delete-group"),Ie),Nf=class{constructor(t){l(this,"creator"),this.creator=new kf(t)}async create(t,e,n){return this.sugar(await this.creator.create(t,e,n))}async rename(t,e){return await this.creator.rename(t,e)}async delete(...t){return await this.creator.delete(t)}sugar(t){return new go(t.name,t.key)}};const Ef="/ontology/add-children",If="/ontology/remove-children",xf="/ontology/move-children",Ii=s.z.object({id:ie,children:ie.array()}),Af=s.z.object({from:ie,to:ie,children:ie.array()}),fr=s.z.object({});let Cf=class{constructor(t){l(this,"client"),this.client=t}async addChildren(t,...e){await w(this.client,Ef,{id:new C(t).payload,children:e.map(n=>new C(n).payload)},Ii,fr)}async removeChildren(t,...e){await w(this.client,If,{id:new C(t).payload,children:e.map(n=>new C(n).payload)},Ii,fr)}async moveChildren(t,e,...n){const r={from:new C(t).payload,to:new C(e).payload,children:n.map(i=>new C(i).payload)};await w(this.client,xf,r,Af,fr)}};const jf="/ontology/retrieve",Rf=s.z.object({ids:ie.array().optional(),children:s.z.boolean().optional(),parents:s.z.boolean().optional(),includeSchema:s.z.boolean().optional(),excludeFieldData:s.z.boolean().optional(),term:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),types:Zn.array().optional()}),Pf=s.z.object({resources:bf.array()}),yr=t=>b(t).map(e=>new C(e).payload);let Mf=class{constructor(t,e){l(this,"type","ontology"),l(this,"groups"),l(this,"client"),l(this,"writer"),l(this,"framer"),this.client=t,this.writer=new Cf(t),this.groups=new Nf(t),this.framer=e}async search(t,e){return await this.execRetrieve({term:t,...e})}async retrieve(t,e){const n=await this.execRetrieve({ids:yr(t),...e});if(Array.isArray(t))return n;if(n.length===0)throw new he(`No resource found with ID ${Fd.naturalLanguageJoin(b(t).map(r=>new C(r).toString()))}`);return n[0]}async page(t,e,n){return await this.execRetrieve({offset:t,limit:e,...n})}async retrieveChildren(t,e){return await this.execRetrieve({ids:yr(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:yr(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...n){return await this.writer.moveChildren(t,e,...n)}async openChangeTracker(){return await Kn.open(this.framer,this)}async openDependentTracker(t){return await ws.open(t,this.framer,this)}newSearcherWithOptions(t){return{type:this.type,search:e=>this.search(e,t),retrieve:e=>this.retrieve(e,t),page:(e,n)=>this.page(e,n,t)}}async execRetrieve(t){const{resources:e}=await w(this.client,jf,t,Rf,Pf);return e}};const xi="sy_ontology_resource_set",Ai="sy_ontology_resource_delete",Ci="sy_ontology_relationship_set",ji="sy_ontology_relationship_delete";class Kn{constructor(e,n){l(this,"relationships"),l(this,"resources"),l(this,"resourceObs"),l(this,"relationshipObs"),l(this,"streamer"),l(this,"client"),l(this,"closePromise"),this.relationshipObs=new De.Observer,this.relationships=this.relationshipObs,this.resourceObs=new De.Observer,this.resources=this.resourceObs,this.client=n,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const n=await this.parseResourceSets(e),r=this.parseResourceDeletes(e);n.concat(r).length>0&&this.resourceObs.notify(n.concat(r));const i=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);i.concat(a).length>0&&this.relationshipObs.notify(i.concat(a))}parseRelationshipSets(e){const n=e.get(Ci);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"set",key:Ei(r),value:void 0}))}parseRelationshipDeletes(e){const n=e.get(ji);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"delete",key:Ei(r)}))}async parseResourceSets(e){const n=e.get(xi);if(n.length===0)return[];const r=Array.from(n.as("string")).map(i=>new C(i));try{return(await this.client.retrieve(r)).map(i=>({variant:"set",key:i.id,value:i}))}catch(i){if(i instanceof he)return[];throw i}}parseResourceDeletes(e){const n=e.get(Ai);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"delete",key:new C(r)}))}static async open(e,n){const r=await e.openStreamer([xi,Ai,Ci,ji]);return new Kn(r,n)}}const Ri=t=>t==="from"?"to":"from";class ws extends De.Observer{constructor({target:e,dependents:n,relationshipType:r="parent",relationshipDirection:i="from",resourceType:a},o,c){super(),l(this,"internal"),l(this,"target"),l(this,"relDir"),l(this,"resourceType"),l(this,"dependents"),l(this,"client"),l(this,"relType"),l(this,"handleResourceChange",u=>{this.dependents=this.dependents.map(h=>{const f=u.find(d=>d.key.toString()==h.id.toString());return f==null||f.variant==="delete"?h:f.value}),this.notify(this.dependents)}),l(this,"handleRelationshipChange",u=>{const h=u.filter(d=>d.variant==="delete"&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[Ri(this.relDir)].type===this.resourceType));this.dependents=this.dependents.filter(d=>!h.some(N=>N.key.to.toString()===d.id.toString()&&N.key.type===this.relType));const f=u.filter(d=>d.variant==="set"&&d.key.type===this.relType&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[Ri(this.relDir)].type===this.resourceType));if(f.length===0)return this.notify(this.dependents);this.client.retrieve(f.map(d=>d.key.to)).then(d=>{this.dependents=this.dependents.concat(d),this.notify(this.dependents)}).catch(console.error)}),this.resourceType=a,this.internal=o,this.target=e,this.dependents=n,this.resourceType!=null&&(this.dependents=this.dependents.filter(u=>u.id.type===this.resourceType)),this.client=c,this.relType=r,this.relDir=i,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,n,r){const i=await Kn.open(n,r);return new ws(e,i,r)}async close(){await this.internal.close()}}const Jn=s.z.string().uuid(),bs=s.z.object({key:Jn,subjects:J(ie),objects:J(ie),actions:J(Br)}),Bf=s.z.object({key:Jn.optional(),subjects:kt.array().or(kt),objects:kt.array().or(kt),actions:Br.array().or(Br)}),Uf=s.z.object({keys:Jn.array().optional(),subjects:ie.array().optional()}),$f=s.z.object({policies:J(bs)}),Df="/access/policy/retrieve";let Lf=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){return(await w(this.client,Df,t,Uf,$f)).policies}};const _f=s.z.object({policies:bs.partial({key:!0}).array()}),qf=s.z.object({policies:bs.array()}),Yf=s.z.object({keys:Jn.array()}),Ff=s.z.object({}),Wf="/access/policy/create",Vf="/access/policy/delete";let Gf=class{constructor(t){l(this,"client"),this.client=t}async create(t){const e=Bf.array().parse(b(t)).map(n=>({objects:b(n.objects),actions:b(n.actions),subjects:b(n.subjects)}));return(await w(this.client,Wf,{policies:e},_f,qf)).policies}async delete(t){await w(this.client,Vf,{keys:b(t)},Yf,Ff)}},Zf=class{constructor(t){l(this,"retriever"),l(this,"writer"),this.retriever=new Lf(t),this.writer=new Gf(t)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve({keys:b(t)});return e?n:n[0]}async retrieveFor(t){const e=b(t).map(n=>new C(n).payload);return await this.retriever.retrieve({subjects:e})}async delete(t){await this.writer.delete(t)}};new C({type:Fi,key:""});let Kf=class{constructor(t){l(this,"policy"),this.policy=new Zf(t)}};const Jf=new Error("request for lock canceled");var Hf=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Xf{constructor(e,n=Jf){this._value=e,this._cancelError=n,this._queue=[],this._weightedWaiters=[]}acquire(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,i)=>{const a={resolve:r,reject:i,weight:e,priority:n},o=mo(this._queue,c=>n<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Hf(this,arguments,void 0,function*(n,r=1,i=0){const[a,o]=yield this.acquire(r,i);try{return yield n(a)}finally{o()}})}waitForUnlock(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,n)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Qf(this._weightedWaiters[e-1],{resolve:r,priority:n})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const n=this._value;this._value-=e.weight,e.resolve([n,this._newReleaser(e.weight)])}_newReleaser(e){let n=!1;return()=>{n||(n=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const n=this._weightedWaiters[e-1];n&&(n.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let n=this._value;n>0;n--){const r=this._weightedWaiters[n-1];if(!r)continue;const i=r.findIndex(a=>a.priority<=e);(i===-1?r:r.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,n){return(this._queue.length===0||this._queue[0].priority<n)&&e<=this._value}}function Qf(t,e){const n=mo(t,r=>e.priority<=r.priority);t.splice(n+1,0,e)}function mo(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}var ey=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class ty{constructor(e){this._semaphore=new Xf(1,e)}acquire(){return ey(this,arguments,void 0,function*(e=0){const[,n]=yield this._semaphore.acquire(1,e);return n})}runExclusive(e,n=0){return this._semaphore.runExclusive(()=>e(),1,n)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Hn=(t,e,{convertNumericStrings:n=!0}={})=>{const r=!Array.isArray(t);let i=b(t);const a=i[0],o=typeof a;let c;return o==="string"&&n&&!isNaN(parseInt(a))&&"number"in e?(c=e.number,i=i.map(u=>parseInt(u))):c=e[o],{single:r,variant:c,normalized:i,actual:t}},Xn=(t,e,n,r)=>{if(r){if(n.length===0)throw new Xe(`${t} not found matching ${JSON.stringify(e)}`);if(n.length>1)throw new Qe(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${n.length}`)}},ny=s.z.object({leaseholder:s.z.number().optional(),keys:H.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),rangeKey:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),dataTypes:I.z.array().optional(),notDataTypes:I.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),ry=s.z.object({channels:J(Wt)}),Se=t=>Hn(t,{number:"keys",string:"names"}),wo=class bo{constructor(e){l(this,"client"),this.client=e}async search(e,n){return await this.execute({search:e,...n})}async retrieve(e,n){const r=Se(e),{variant:i}=r;let{normalized:a}=r;return i==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[i]:a,...n})}async page(e,n,r){return await this.execute({offset:e,limit:n,...r})}async execute(e){const[n,r]=await this.client.send(bo.ENDPOINT,e,ny,ry);if(r!=null)throw r;return n.channels}};l(wo,"ENDPOINT","/channel/retrieve");let vs=wo;class Os{constructor(e){l(this,"cache"),l(this,"namesToKeys"),l(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,n){return await this.wrapped.search(e,n)}async page(e,n,r){return await this.wrapped.page(e,n,r)}async retrieve(e,n){const{normalized:r}=Hn(e,{string:"names",number:"keys"}),i=[],a=[];if(r.forEach(c=>{const u=this.get(c);u!=null?i.push(...u):a.push(c)}),a.length===0)return i;const o=await this.wrapped.retrieve(a,n);return this.set(o),i.concat(o)}delete(e){const{variant:n,normalized:r}=Se(e);n==="names"?r.forEach(i=>{const a=this.namesToKeys.get(i);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(i))}):r.forEach(i=>{const a=this.cache.get(i);a!=null&&(this.cache.delete(i),this.namesToKeys.delete(a.name))})}rename(e,n){e.forEach((r,i)=>{const a=n[i],o=this.cache.get(r);if(o==null)return;this.cache.delete(r);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(r),c.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(r,o);const u=this.namesToKeys.get(a);u==null?this.namesToKeys.set(a,new Set([r])):u.add(r)})}set(e){e.forEach(n=>{this.cache.set(n.key,n);const r=this.namesToKeys.get(n.name);r==null?this.namesToKeys.set(n.name,new Set([n.key])):r.add(n.key)})}get(e){if(typeof e=="number"){const i=this.cache.get(e);return i==null?void 0:[i]}const n=this.namesToKeys.get(e);if(n==null)return;const r=[];if(n.forEach(i=>{const a=this.cache.get(i);a!=null&&r.push(a)}),r.length!==0)return r}}class vo{constructor(e,n){l(this,"mu",new ty),l(this,"requests",new Map),l(this,"wrapped"),l(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Fh(()=>{this.run()},n)}async search(e,n){return await this.wrapped.search(e,n)}async page(e,n,r){return await this.wrapped.page(e,n,r)}async retrieve(e){const{normalized:n,variant:r}=Se(e);return r==="names"?await this.wrapped.retrieve(n):await new Promise((i,a)=>{this.mu.runExclusive(()=>{this.requests.set(n,{resolve:i,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((n,r)=>r.forEach(i=>e.add(i)));try{const n=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((r,i)=>r.resolve(n.filter(a=>i.includes(a.key))))}catch(n){this.requests.forEach(r=>r.reject(n))}finally{this.requests.clear()}})}}const Oo=async(t,e)=>{const{normalized:n}=Se(e),r=await t.retrieve(n),i=[];if(n.forEach(a=>{r.find(o=>o.name===a||o.key===a)==null&&i.push(a)}),i.length>0)throw new he(`Could not find channels: ${JSON.stringify(i)}`);return r};class zo{constructor({dataType:e,rate:n,name:r,leaseholder:i=0,key:a=0,isIndex:o=!1,index:c=0,internal:u=!1,virtual:h=!1,frameClient:f,alias:d,expression:N="",requires:x=[]}){l(this,"_frameClient"),l(this,"key"),l(this,"name"),l(this,"rate"),l(this,"dataType"),l(this,"leaseholder"),l(this,"index"),l(this,"isIndex"),l(this,"internal"),l(this,"alias"),l(this,"virtual"),l(this,"expression"),l(this,"requires"),this.key=a,this.name=r,this.rate=new jt(n??0),this.dataType=new I(e),this.leaseholder=i,this.index=c,this.isIndex=o,this.internal=u,this.alias=d,this.virtual=h,this.expression=N,this.requires=x??[],this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new q("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Wt.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,requires:this.requires})}get isCalculated(){return Bn(this.payload)}get ontologyID(){return ko(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,n){return await this.framer.write(e,this.key,n)}}const sy="/channel/retrieve-group",iy=s.z.object({}),ay=s.z.object({group:Xa});let To=class{constructor(t,e,n,r){l(this,"type",qn),l(this,"frameClient"),l(this,"client"),l(this,"retriever"),l(this,"writer"),this.frameClient=t,this.retriever=e,this.client=n,this.writer=r}async create(t,e={}){const{retrieveIfNameExists:n=!1}=e,r=!Array.isArray(t);let i=b(t),a=[];if(n){const o=await this.retriever.retrieve(i.map(u=>u.name)),c=new Set(o.map(u=>u.name));i=i.filter(u=>!c.has(u.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(i))),r?a[0]:a}async retrieve(t,e){const n=!Array.isArray(t),r=this.sugar(await this.retriever.retrieve(t,e));return Xn("channel",t,r,n),n?r[0]:r}async search(t,e){return this.sugar(await this.retriever.search(t,e))}async delete(t){const{normalized:e,variant:n}=Se(t);return n==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(b(t),b(e))}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,n)=>await this.page(e,n,t)}}async page(t,e,n){return this.sugar(await this.retriever.page(t,e,n))}createDebouncedBatchRetriever(t=10){return new Os(new vo(new vs(this.client),t))}sugar(t){const{frameClient:e}=this;return t.map(n=>new zo({...n,frameClient:e}))}async retrieveGroup(){const t=await w(this.client,sy,{},iy,ay);return new go(t.group.name,t.group.key)}};const Bn=({virtual:t,expression:e})=>t&&e!=="",So=async(t,e)=>{if(!Bn(e))return e.index;for(const n of e.requires){const r=await t(n);if(r==null)return null;if(!r.virtual)return r.index}for(const n of e.requires){const r=await t(n);if(r==null)return null;if(Bn(r)){const i=await So(t,r);if(i!=null)return i}}return null},ko=t=>new C({type:qn,key:t.toString()}),oy=s.z.object({channels:eo.array()}),ly=s.z.object({channels:Wt.array()}),cy=s.z.object({keys:H.array().optional(),names:Ft.array().optional()}),uy=s.z.object({}),hy=s.z.object({keys:H.array(),names:Ft.array()}),dy=s.z.object({}),fy="/channel/create",yy="/channel/delete",py="/channel/rename";let No=class{constructor(t,e){l(this,"client"),l(this,"cache"),this.client=t,this.cache=e}async create(t){const{channels:e}=await w(this.client,fy,{channels:t},oy,ly);return this.cache.set(e),e}async delete(t){await w(this.client,yy,t,cy,uy),t.keys!=null&&this.cache.delete(t.keys),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await w(this.client,py,{keys:t,names:e},hy,dy),this.cache.rename(t,e)}};const gy=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Os,Channel:zo,Client:To,ClusterRetriever:vs,DebouncedBatchRetriever:vo,ONTOLOGY_TYPE:qn,Writer:No,analyzeParams:Se,channelZ:Wt,isCalculated:Bn,keyZ:H,nameZ:Ft,newZ:eo,ontologyID:ko,resolveCalculatedIndex:So,retrieveRequired:Oo},Symbol.toStringTag,{value:"Module"})),my=s.z.object({keys:nt.array().optional(),usernames:s.z.string().array().optional()}),wy=s.z.object({users:J(Gn)}),by="/user/retrieve";let vy=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){return(await w(this.client,by,t,my,wy)).users}};const Oy=s.z.object({users:tf.array()}),zy=s.z.object({users:Gn.array()}),Ty=s.z.object({key:nt,username:s.z.string().min(1)}),Sy=s.z.object({}),ky=s.z.object({key:nt,firstName:s.z.string().optional(),lastName:s.z.string().optional()}),Ny=s.z.object({}),Ey=s.z.object({keys:nt.array()}),Iy=s.z.object({}),xy="/user/create",Ay="/user/change-username",Cy="/user/rename",jy="/user/delete";let Ry=class{constructor(t){l(this,"client"),this.client=t}async create(t){return(await w(this.client,xy,{users:b(t)},Oy,zy)).users}async changeUsername(t,e){await w(this.client,Ay,{key:t,username:e},Ty,Sy)}async rename(t,e,n){await w(this.client,Cy,{key:t,firstName:e,lastName:n},ky,Ny)}async delete(t){await w(this.client,jy,{keys:b(t)},Ey,Iy)}},Py=class{constructor(t){l(this,"reader"),l(this,"writer"),this.writer=new Ry(t),this.reader=new vy(t)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async changeUsername(t,e){await this.writer.changeUsername(t,e)}async retrieve(t){const e=Array.isArray(t),n=await this.reader.retrieve({keys:b(t)});if(e)return n;if(n.length===0)throw new Xe(`No user with key ${t} found`);if(n.length>1)throw new Qe(`Multiple users found with key ${t}`);return n[0]}async retrieveByName(t){const e=Array.isArray(t),n=await this.reader.retrieve({usernames:b(t)});if(e)return n;if(n.length===0)throw new Xe(`No user with username ${t} found`);if(n.length>1)throw new Qe(`Multiple users found with username ${t}`);return n[0]}async rename(t,e,n){await this.writer.rename(t,e,n)}async delete(t){await this.writer.delete(t)}};const My=s.z.object({username:s.z.string(),password:s.z.string()}),By=s.z.object({token:s.z.string(),user:Gn}),Pi="/auth/login",Uy=3,$y="/auth/change-password",Dy=s.z.object({username:s.z.string(),password:s.z.string(),newPassword:s.z.string().min(1)}),Ly=s.z.object({}),_y=[Fr,Wr];let qy=class{constructor(t,e){l(this,"token"),l(this,"client"),l(this,"credentials"),l(this,"authenticating"),l(this,"authenticated"),l(this,"user"),l(this,"retryCount"),this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,$y,{username:this.credentials.username,password:this.credentials.password,newPassword:t},Dy,Ly),this.credentials.password=t}middleware(){const t=async(e,n)=>{if(!this.authenticated&&!e.target.endsWith(Pi)){this.authenticating??(this.authenticating=new Promise((o,c)=>{this.client.send(Pi,this.credentials,My,By).then(([u,h])=>{if(h!=null)return o(h);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}).catch(c)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[r,i]=await n(e);return _y.some(a=>a.matches(i))&&this.retryCount<Uy?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,n)):(this.retryCount=0,[r,i])};return t}};const Yy=s.z.enum(["disconnected","connecting","connected","failed"]),Fy=s.z.object({status:Yy,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string(),clientVersion:s.z.string(),clientServerCompatible:s.z.boolean(),nodeVersion:s.z.string().optional()}),Wy=s.z.object({clusterKey:s.z.string(),nodeVersion:s.z.string().optional()}),Eo={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.41.0"},Mi=(t,e,n)=>{const r=n?"cluster":"client";return`Synnax cluster node version ${t!=null?`${t} `:""}is too ${n?"old":"new"} for client version ${e}.
37
- This may cause compatibility issues. We recommend updating the ${r}. For more information, see
38
- https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${r}-version`},En=class Io{constructor(e,n=T.seconds(30),r,i){l(this,"_state"),l(this,"pollFrequency",T.seconds(30)),l(this,"client"),l(this,"name"),l(this,"interval"),l(this,"clientVersion"),l(this,"onChangeHandlers",[]),l(this,"versionWarned",!1),this._state={...Eo},this.client=e,this.pollFrequency=n,this.clientVersion=r,this.name=i,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const n=this._state.status;try{const[r,i]=await this.client.send(Io.ENDPOINT,{},s.z.object({}),Wy);if(i!=null)throw i;const a=r.nodeVersion,o=this.clientVersion,c=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,c||(console.warn(Mi(null,o,!0)),this.versionWarned=!0)):Oi.versionsEqual(o,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,c||(console.warn(Mi(a,o,Oi.semVerNewer(o,a))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=r.clusterKey,this._state.nodeVersion=r.nodeVersion,this._state.clientVersion=this.clientVersion}catch(r){this._state.status="failed",this._state.error=r,this._state.message=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&n!==this._state.status&&this.onChangeHandlers.forEach(r=>r(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};l(En,"ENDPOINT","/connectivity/check"),l(En,"DEFAULT",Eo),l(En,"connectionStateZ",Fy);let xo=En;const Vy=s.z.object({keys:H.array().optional(),bounds:K.z,names:Ft.array().optional()}),Gy=s.z.object({}),Zy="/frame/delete";class Ky{constructor(e){l(this,"client"),this.client=e}async delete(e){await w(this.client,Zy,e,Vy,Gy)}}class Qn{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,n){const r=new Qn(e);return await r.update(n),r}async update(e){const{variant:n,normalized:r}=Se(e);if(n==="keys"){this.adapter=null,this.keys=r;return}const i=await this.retriever.retrieve(r),a=new Map;this.adapter=a,r.forEach(o=>{const c=i.find(u=>u.name===o);if(c==null)throw new Error(`Channel ${o} not found`);a.set(c.key,c.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const n=this.adapter;return e.map((r,i)=>{if(typeof r=="number"){const a=n.get(r);if(a==null)throw new Error(`Channel ${r} not found`);return[a,i]}return[r,i]})}}class zs{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,n){const r=new zs(e);return await r.update(n),r}async adaptObjectKeys(e){const n={};for(const[r,i]of Object.entries(e))n[await this.adaptToKey(r)]=i;return n}async update(e){const n=await Oo(this.retriever,e);this.adapter=new Map(n.map(r=>[r.name,r.key])),this.keys=n.map(r=>r.key)}async fetchChannel(e){const n=await this.retriever.retrieve(e);if(n.length===0)throw new Error(`Channel ${e} not found`);return n[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}async adapt(e,n){if(typeof e=="string"||typeof e=="number"){if(n==null)throw new q(`
39
- Received a single channel name or key but no series.
40
- `);if(Array.isArray(n)){if(n.some(u=>u instanceof Be||Array.isArray(u)))throw new q(`
41
- Received a single channel name or key but multiple series.
42
- `);n=n}const o=await this.fetchChannel(e),c=new Be({data:n,dataType:o.dataType});return new ue(o.key,c)}if(Array.isArray(e)){if(n==null)throw new q(`
43
- Received an array of channel names or keys but no series.
44
- `);if(!Array.isArray(n))throw new q(`
45
- Received an array of channel names or keys but no array of series.
46
- `);const o=[],c=[];for(let u=0;u<e.length;u++){const h=await this.fetchChannel(e[u]);if(u>=n.length)throw new q(`
47
- Received an array of channel names or keys but not enough series.
48
- `);const f=new Be({data:n[u],dataType:h.dataType});o.push(h.key),c.push(f)}return new ue(o,c)}if(e instanceof ue||e instanceof Map){const o=new ue(e);if(this.adapter==null)return o;const c=o.columns.map(u=>{var h;const f=typeof u=="string"?(h=this.adapter)==null?void 0:h.get(u):u;if(f==null)throw new q(`
49
- Channel ${u} was not provided in the list of channels when opening the writer
50
- `);return f});return new ue(c,o.series)}const r=[],i=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[c,u]=a[o],h=await this.fetchChannel(c),f=new Be({data:u,dataType:h.dataType});r.push(h.key),i.push(f)}return new ue(r,i)}}class Ts{constructor(e,n){l(this,"name"),l(this,"stream"),this.stream=n,this.name=e}async receive(){const[e,n]=await this.stream.receive();if(n!=null)throw n;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,n]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
51
- Please report this error to the Synnax team. ${JSON.stringify(e)}`),n!=null){if(je.matches(n))return;throw n}}}closeSend(){this.stream.closeSend()}send(e){const n=this.stream.send(e);if(n!=null)throw n}}const Bi=new T(-1);var Ss=(t=>(t[t.Open=0]="Open",t[t.Next=1]="Next",t[t.Prev=2]="Prev",t[t.SeekFirst=3]="SeekFirst",t[t.SeekLast=4]="SeekLast",t[t.SeekLE=5]="SeekLE",t[t.SeekGE=6]="SeekGE",t[t.Valid=7]="Valid",t[t.Error=8]="Error",t))(Ss||{}),Ao=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(Ao||{});const Jy=s.z.object({command:s.z.nativeEnum(Ss),span:T.z.optional(),bounds:K.z.optional(),stamp:E.z.optional(),keys:H.array().optional(),chunkSize:s.z.number().optional()}),Hy=s.z.object({variant:s.z.nativeEnum(Ao),ack:s.z.boolean(),command:s.z.nativeEnum(Ss),error:Lt.optional().nullable(),frame:os.optional()}),Co=class Vr{constructor(e,n){l(this,"stream"),l(this,"adapter"),l(this,"value"),this.stream=new Ts("Iterator",e),this.value=new ue,this.adapter=n}static async _open(e,n,r,i,a={}){const o=await Qn.open(r,n),c=await i.stream(Vr.ENDPOINT,Jy,Hy),u=new Vr(c,o);return await u.execute({command:0,keys:o.keys,bounds:new K(e),chunkSize:a.chunkSize??1e5}),u}async next(e=Bi){return await this.execute({command:1,span:new T(e)})}async prev(e=Bi){return await this.execute({command:2,span:new T(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new E(e)})}async seekGE(e){return await this.execute({command:6,stamp:new E(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Qy(this)}async execute(e){for(this.stream.send(e),this.value=new ue;;){const n=await this.stream.receive();if(n.variant===1)return n.ack;this.value.push(this.adapter.adapt(new ue(n.frame)))}}};l(Co,"ENDPOINT","/frame/iterate");let Xy=Co;class Qy{constructor(e){l(this,"iter"),l(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const ep=s.z.object({keys:s.z.number().array(),downsampleFactor:s.z.number()}),tp=s.z.object({frame:os,error:Lt.optional().nullable()}),np="/frame/stream";class ks{constructor(e,n){l(this,"stream"),l(this,"adapter"),l(this,"downsampleFactor"),this.stream=new Ts("Streamer",e),this.adapter=n,this.downsampleFactor=1}get keys(){return this.adapter.keys}static async _open(e,n,{channels:r,downsampleFactor:i}){const a=await Qn.open(e,r),o=await n.stream(np,ep,tp),c=new ks(o,a);o.send({keys:a.keys,downsampleFactor:i??1});const[,u]=await o.receive();if(u!=null)throw u;return c}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(je.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ue((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys,downsampleFactor:this.downsampleFactor})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}let Pe=class extends De.Observer{constructor(e,n){super(n),l(this,"streamer"),l(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}};var Ns=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.Error=3]="Error",t[t.SetAuthority=4]="SetAuthority",t))(Ns||{}),Rt=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(Rt||{});const rp=t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof t=="number"&&t in Rt)return t;throw new Error(`invalid writer mode: ${t}`)}};new T(-1);const sp=s.z.object({start:E.z.optional(),controlSubject:Je.subjectZ.optional(),keys:H.array().optional(),authorities:Je.Authority.z.array().optional(),mode:s.z.nativeEnum(Rt).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:T.z.optional()}),ip=s.z.object({command:s.z.nativeEnum(Ns),config:sp.optional(),frame:os.optional()}),ap=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(Ns),error:Lt.optional().nullable()});var ct;let op=(ct=class{constructor(t,e){l(this,"stream"),l(this,"adapter"),l(this,"errAccumulated",!1),this.stream=new Ts("Writer",t),this.adapter=e}static async _open(t,e,{channels:n,start:r=E.now(),authorities:i=Je.Authority.ABSOLUTE,controlSubject:a,mode:o=1,errOnUnauthorized:c=!1,enableAutoCommit:u=!1,autoIndexPersistInterval:h=T.SECOND}){const f=await zs.open(t,n),d=await e.stream(ct.ENDPOINT,ip,ap),N=new ct(d,f);return await N.execute({command:0,config:{start:new E(r),keys:f.keys,controlSubject:a,authorities:b(i),mode:rp(o),errOnUnauthorized:c,enableAutoCommit:u,autoIndexPersistInterval:h}}),N}async checkForAccumulatedError(){if(!this.errAccumulated&&this.stream.received())for(this.errAccumulated=!0;this.stream.received();)await this.stream.receive();return this.errAccumulated}async write(t,e){if(await this.checkForAccumulatedError())return!1;const n=await this.adapter.adapt(t,e);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(t,e){if(await this.checkForAccumulatedError())return!1;let n;if(typeof t=="number"&&e==null)n={keys:[],authorities:[t]};else{let r;typeof t=="string"||typeof t=="number"?r={[t]:e}:r=t,r=await this.adapter.adaptObjectKeys(r),n={keys:Object.keys(r).map(i=>Number(i)),authorities:Object.values(r)}}return(await this.execute({command:4,config:n})).ack}async commit(){return await this.checkForAccumulatedError()?!1:(await this.execute({command:2})).ack}async error(){const t=await this.execute({command:3});return t.error!=null?jn(t.error):null}async close(){await this.stream.closeAndAck()}async execute(t){for(this.stream.send(t);;){const e=await this.stream.receive();if(e.command===t.command)return e;console.warn("writer received unexpected response",e)}}get errorAccumulated(){return this.stream.received()}},l(ct,"ENDPOINT","/frame/write"),ct),lp=class{constructor(t,e,n){l(this,"streamClient"),l(this,"retriever"),l(this,"deleter"),this.streamClient=t,this.retriever=n,this.deleter=new Ky(e)}async openIterator(t,e,n){return await Xy._open(t,e,this.retriever,this.streamClient,n)}async openWriter(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await op._open(this.retriever,this.streamClient,t)}async openStreamer(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t,downsampleFactor:1}),await ks._open(this.retriever,this.streamClient,t)}async write(t,e,n){if(n==null){const i=e,a=await this.openWriter({start:t,channels:Object.keys(i),mode:Rt.Persist});try{await a.write(i),await a.commit()}finally{await a.close()}return}const r=await this.openWriter({start:t,channels:e,mode:Rt.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:T.MAX});try{await r.write(e,n)}finally{await r.close()}}async read(t,e){const{single:n}=Se(e),r=await this.readFrame(t,e);return n?r.get(e):r}async readFrame(t,e){const n=await this.openIterator(t,e),r=new ue;try{for await(const i of n)r.push(i)}finally{await n.close()}return r}async delete(t,e){const{normalized:n,variant:r}=Se(t);return r==="keys"?await this.deleter.delete({keys:n,bounds:e}):await this.deleter.delete({names:n,bounds:e})}};const cp=Je.Authority,up=Je.stateZ(s.z.number()),hp=t=>{var e,n;return t.to==null?`${(e=t.from)==null?void 0:e.resource} - ${(n=t.from)==null?void 0:n.subject.name} -> released`:t.from==null?`${t.to.resource} - released -> ${t.to.subject.name} (${t.to.authority.toString()})`:`${t.to.resource} - ${t.from.subject.name} -> ${t.to.subject.name} (${t.to.authority.toString()})`};class jo extends Pe{constructor(e){super(e,n=>{const r=this.codec.decode(n.series[0].buffer);return this.merge(r),[r.transfers,!0]}),l(this,"states"),l(this,"codec"),this.states=new Map,this.codec=new _t.JSONCodec}subjects(){const e=new Map;return this.states.forEach(n=>e.set(n.subject.key,n.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(n=>{n.from==null&&n.to==null&&console.warn("Invalid transfer: ",n),n.to==null?this.states.delete(n.from.resource):this.states.set(n.to.resource,n.to)})}}const dp="sy_node_1_control";let Ro=class{constructor(t){l(this,"framer"),this.framer=t}async openStateTracker(){const t=await this.framer.openStreamer(dp);return new jo(t)}};const fp=Object.freeze(Object.defineProperty({__proto__:null,Authority:cp,Client:Ro,StateTracker:jo,stateZ:up,transferString:hp},Symbol.toStringTag,{value:"Module"}));let yp=class{constructor(t,e,n){l(this,"tasks"),l(this,"racks"),l(this,"devices"),this.tasks=t,this.racks=e,this.devices=n}};const st=async(t,e,n,r)=>{const i=await t.openStreamer([e,n]),a=o=>{const c=[];return n!=null&&c.push(...o.get(n).series.flatMap(u=>r("delete",u))),e!=null&&c.push(...o.get(e).series.flatMap(u=>r("set",u))),[c,c.length>0]};return new Pe(i,a)},pp="sy_device_set",gp="sy_device_delete",Ui="sy_device_state",pr="/hardware/device/retrieve",mp="/hardware/device/create",wp="/hardware/device/delete",bp=s.z.object({devices:Xd.array()}),vp=s.z.object({devices:Fn.array()}),Op=s.z.object({keys:Yn.array()}),zp=s.z.object({}),gr=s.z.object({keys:Yn.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional(),models:s.z.string().array().optional(),locations:s.z.string().array().optional(),racks:Le.array().optional(),search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),ignoreNotFound:s.z.boolean().optional(),includeState:s.z.boolean().optional()}),mr=s.z.object({devices:J(Fn)});let Tp=class{constructor(t,e){l(this,"type",so),l(this,"client"),l(this,"frameClient"),this.client=t,this.frameClient=e}async retrieve(t,e){const n=!Array.isArray(t),r=await w(this.client,pr,{keys:b(t),...e},gr,mr);return Xn("Device",t,r.devices,n),n?r.devices[0]:r.devices}async search(t,e){return(await w(this.client,pr,{search:t,...e},gr,mr)).devices}async page(t,e,n){return(await w(this.client,pr,{offset:t,limit:e,...n},gr,mr)).devices}async create(t){const e=!Array.isArray(t),n=await w(this.client,mp,{devices:b(t)},bp,vp);return e?n.devices[0]:n.devices}async delete(t){await w(this.client,wp,{keys:b(t)},Op,zp)}async openDeviceTracker(){return await st(this.frameClient,pp,gp,Sp)}async openStateObserver(){return new Pe(await this.frameClient.openStreamer(Ui),t=>{const e=t.get(Ui);return e.length===0?[null,!1]:[e.parseJSON(ro),!0]})}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,n)=>await this.page(e,n,t)}}};const Sp=(t,e)=>t==="delete"?e.toStrings().map(n=>({variant:t,key:n,value:void 0})):e.parseJSON(Fn).map(n=>({variant:t,key:n.key,value:n})),wr="/hardware/rack/retrieve",kp="/hardware/rack/create",Np="/hardware/rack/delete",$i="sy_rack_state",br=s.z.object({keys:Le.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),embedded:s.z.boolean().optional(),hostIsNode:s.z.boolean().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),includeState:s.z.boolean().optional()}),vr=s.z.object({racks:J(ls)}),Ep=s.z.object({racks:Hd.array()}),Ip=s.z.object({racks:ls.array()}),xp=s.z.object({keys:Le.array()}),Ap=s.z.object({});let Cp=class{constructor(t,e,n){l(this,"type",no),l(this,"client"),l(this,"tasks"),l(this,"frameClient"),this.client=t,this.tasks=e,this.frameClient=n}async delete(t){await w(this.client,Np,{keys:b(t)},xp,Ap)}async create(t){const e=!Array.isArray(t),n=await w(this.client,kp,{racks:b(t)},Ep,Ip),r=this.sugar(n.racks);return e?r[0]:r}async search(t){const e=await w(this.client,wr,{search:t},br,vr);return this.sugar(e.racks)}async page(t,e){const n=await w(this.client,wr,{offset:t,limit:e},br,vr);return this.sugar(n.racks)}async retrieve(t,e){const{variant:n,normalized:r,single:i}=Hn(t,{string:"names",number:"keys"}),a=await w(this.client,wr,{[n]:r,includeState:e==null?void 0:e.includeState},br,vr),o=this.sugar(a.racks);return Xn("Rack",t,o,i),i?o[0]:o}async openStateObserver(){return new Pe(await this.frameClient.openStreamer($i),t=>{const e=t.get($i);return e.length===0?[[],!1]:[e.parseJSON(to),!0]})}sugar(t){return t.map(({key:e,name:n,state:r})=>new jp(e,n,this.tasks,r))}};class jp{constructor(e,n,r,i){l(this,"key"),l(this,"name"),l(this,"state"),l(this,"tasks"),this.key=e,this.name=n,this.tasks=r,this.state=i}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async retrieveTaskByType(e){return await this.tasks.retrieveByType(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const At="sy_task_state",Ve="sy_task_cmd",Rp="sy_task_set",Pp="sy_task_delete",We=new Error("Task not created"),Po=async(t,e)=>{const n=await e.retrieveParents(t);return n.length===0?null:n[0]};class Mp{constructor(e,n,r,i,a=!1,o=!1,c,u=null,h=null,f=null){l(this,"key"),l(this,"name"),l(this,"internal"),l(this,"type"),l(this,"config"),l(this,"snapshot"),l(this,"state"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=e,this.name=n,this.type=r,this.config=i,this.internal=a,this.snapshot=o,c!==null&&(this.state=c),this.frameClient=u,this.ontologyClient=h,this.rangeClient=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}get ontologyID(){return Kp(this.key)}async executeCommand(e,n){if(this.frameClient==null)throw We;const r=await this.frameClient.openWriter(Ve),i=jh.create();return await r.write(Ve,[{task:this.key,type:e,key:i,args:n}]),await r.close(),i}async executeCommandSync(e,n,r){if(this.frameClient==null)throw We;const i=await this.frameClient.openStreamer(At),a=await this.executeCommand(e,n);let o;const c=new Promise(u=>setTimeout(()=>u(!1),new T(r).milliseconds));for(;;){const u=await Promise.any([i.read(),c]);if(u===!1)throw new Error("Command timed out");const h=Mn.safeParse(u.at(-1).sy_task_state);if(h.success){if(o=h.data,o.key===a)break}else throw h.error}return i.close(),o}async openStateObserver(){if(this.frameClient==null)throw We;return new Pe(await this.frameClient.openStreamer(At),e=>{const n=e.get(At);if(n.length===0)return[null,!1];const r=Mn.safeParse(n.at(-1));if(!r.success)return console.error(r.error),[null,!1];const i=r.data;return i.task!==this.key?[null,!1]:[i,!0]})}async openCommandObserver(){if(this.frameClient==null)throw We;return new Pe(await this.frameClient.openStreamer(Ve),e=>{const n=e.get(Ve);if(n.length===0)return[null,!1];const r=io.safeParse(n.at(-1));if(!r.success)return console.error(r.error),[null,!1];const i=r.data;return i.task!==this.key?[null,!1]:[i,!0]})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw We;return this.snapshot?await Po(this.key,this.ontologyClient):null}}const Bp=s.z.object({rack:Le.optional(),keys:_e.array().optional(),names:s.z.string().array().optional(),types:s.z.string().array().optional(),includeState:s.z.boolean().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Up=s.z.object({tasks:J(Wn)}),$p="/hardware/task/retrieve",Dp="/hardware/task/create",Lp="/hardware/task/delete",_p="/hardware/task/copy",qp=s.z.object({tasks:ef.array()}),Yp=s.z.object({tasks:Wn.array()}),Fp=s.z.object({keys:_e.array()}),Wp=s.z.object({}),Vp=s.z.object({key:_e,name:s.z.string(),snapshot:s.z.boolean()}),Gp=s.z.object({task:Wn});let Zp=class{constructor(t,e,n,r){l(this,"type",us),l(this,"client"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.client=t,this.frameClient=e,this.ontologyClient=n,this.rangeClient=r}async create(t){const e=!Array.isArray(t),n=await w(this.client,Dp,{tasks:b(t)},qp,Yp),r=this.sugar(n.tasks);return e?r[0]:r}async delete(t){await w(this.client,Lp,{keys:b(t)},Fp,Wp)}async search(t){return await this.execRetrieve({keys:[t]})}async page(t,e){return await this.execRetrieve({offset:t,limit:e})}async list(t={}){return this.sugar(await this.execRetrieve(t))}async retrieve(t,e){const{single:n,normalized:r,variant:i}=Hn(t,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};i==="rack"?a.rack=t:a.keys=r;const o=await this.execRetrieve(a),c=this.sugar(o);return n&&i!=="rack"?c[0]:c}async copy(t,e,n){const r=await w(this.client,_p,{key:t,name:e,snapshot:n},Vp,Gp);return this.sugar([r.task])[0]}async retrieveByName(t,e){const n=await this.execRetrieve({names:[t],rack:e});return Xn("Task",t,n,!0),this.sugar(n)[0]}async retrieveByType(t,e){const n=await this.execRetrieve({types:[t],rack:e});return this.sugar(n)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw We;return await Po(t,this.ontologyClient)}async execRetrieve(t){return(await w(this.client,$p,t,Bp,Up)).tasks}sugar(t){const e=!Array.isArray(t),n=b(t).map(({key:r,name:i,type:a,config:o,state:c,internal:u,snapshot:h})=>new Mp(r,i,a,o,u,h,c,this.frameClient,this.ontologyClient,this.rangeClient));return e?n[0]:n}async openTracker(){return await st(this.frameClient,Rp,Pp,(t,e)=>Array.from(e).map(n=>({variant:t,key:n.toString(),value:n.toString()})))}async openStateObserver(){return new Pe(await this.frameClient.openStreamer(At),t=>{const e=t.get(At);if(e.length===0)return[null,!1];const n=Mn.safeParse(e.at(-1));return n.success?[n.data,!0]:(console.error(n.error),[null,!1])})}async openCommandObserver(){return new Pe(await this.frameClient.openStreamer(Ve),t=>{const e=t.get(Ve);if(e.length===0)return[null,!1];const n=io.safeParse(e.at(-1));return n.success?[n.data,!0]:(console.error(n.error),[null,!1])})}};const Kp=t=>new C({type:us,key:t}),Jp=s.z.object({keys:tt.array().optional(),for:ie.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Hp=s.z.object({labels:J(Vn)}),Mo=class Bo{constructor(e){l(this,"client"),this.client=e}async retrieve(e){return await this.execute({keys:b(e)})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,n){return await this.execute({offset:e,limit:n})}async execute(e){const[n,r]=await this.client.send(Bo.ENDPOINT,e,Jp,Hp);if(r!=null)throw r;return n.labels}};l(Mo,"ENDPOINT","/label/retrieve");let Xp=Mo;const Qp=Vn.extend({key:tt.optional()}),eg=s.z.object({labels:Qp.array()}),tg=s.z.object({labels:Vn.array()}),ng=s.z.object({keys:tt.array()}),Uo=s.z.object({id:ie,labels:tt.array(),replace:s.z.boolean().optional()}),rg=Uo.omit({replace:!0}),Or=s.z.object({}),sg="/label/create",ig="/label/delete",ag="/label/set",og="/label/remove";let lg=class{constructor(t){l(this,"client"),this.client=t}async create(t){return(await w(this.client,sg,{labels:b(t)},eg,tg)).labels}async delete(t){await w(this.client,ig,{keys:b(t)},ng,Or)}async set(t,e,{replace:n}={}){await w(this.client,ag,{id:t,labels:e,replace:n},Uo,Or)}async remove(t,e){await w(this.client,og,{id:t,labels:e},rg,Or)}};const cg="sy_label_set",ug="sy_label_delete";let hg=class{constructor(t,e,n){l(this,"type","label"),l(this,"retriever"),l(this,"writer"),l(this,"frameClient"),l(this,"ontology"),this.writer=new lg(t),this.retriever=new Xp(t),this.frameClient=e,this.ontology=n}async search(t){return await this.retriever.search(t)}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve(t);return e?n:n[0]}async retrieveFor(t){return await this.retriever.retrieveFor(new C(t))}async label(t,e,n={}){await this.writer.set(new C(t),e,n)}async removeLabels(t,e){await this.writer.remove(new C(t),e)}async page(t,e){return await this.retriever.page(t,e)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async delete(t){await this.writer.delete(t)}async openChangeTracker(){return await st(this.frameClient,cg,ug,dg)}async trackLabelsOf(t){const e=new De.Observer,n=(await this.retrieveFor(t)).map(r=>({id:fg(r.key),key:r.key,name:r.name,data:r}));return(await this.ontology.openDependentTracker({target:new C(t),dependents:n,relationshipType:"labeled_by"})).onChange(r=>e.notify(r.map(i=>{var a,o;return{key:i.id.key,color:(a=i.data)==null?void 0:a.color,name:(o=i.data)==null?void 0:o.name}}))),e}};const dg=(t,e)=>t==="delete"?e.toUUIDs().map(n=>({variant:t,key:n})):e.parseJSON(Vn).map(n=>({variant:t,key:n.key,value:n})),fg=t=>new C({type:ao,key:t}),yg="sy_range_alias_set",pg="sy_range_alias_delete",gg=s.z.object({range:se,aliases:s.z.string().array()}),mg=s.z.object({aliases:s.z.record(s.z.string(),H)}),wg=s.z.object({range:se,aliases:s.z.record(H.or(s.z.string()),s.z.string())}),bg=s.z.unknown(),vg=s.z.object({range:se,channels:H.array()}),Og=s.z.unknown(),zg=s.z.object({range:se}),Tg=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),Nt=class Et{constructor(e,n,r){l(this,"frameClient"),l(this,"cache",new Map),l(this,"client"),l(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=r,this.frameClient=n}async resolve(e){const n=[],r=typeof e=="string",i={};if(r){const o=this.cache.get(e);if(o!=null)return o;n.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?i[o]=c:n.push(o)});if(n.length===0)return i;const a=await w(this.client,Et.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:n},gg,mg);return Object.entries(a.aliases).forEach(([o,c])=>this.cache.set(o,c)),r?a.aliases[n[0]]:{...i,...a.aliases}}async set(e){await w(this.client,Et.SET_ENDPOINT,{range:this.rangeKey,aliases:e},wg,bg)}async list(){return(await w(this.client,Et.LIST_ENDPOINT,{range:this.rangeKey},zg,Tg)).aliases}async delete(e){await w(this.client,Et.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},vg,Og)}async openChangeTracker(){return await st(this.frameClient,yg,pg,Eg(this.rangeKey))}};l(Nt,"SET_ENDPOINT","/range/alias/set"),l(Nt,"RESOLVE_ENDPOINT","/range/alias/resolve"),l(Nt,"LIST_ENDPOINT","/range/alias/list"),l(Nt,"DELETE_ENDPOINT","/range/alias/delete");let Sg=Nt;const kg=s.z.object({range:se,channel:H,alias:s.z.string()}),Ng="---",Eg=t=>(e,n)=>e==="delete"?n.toStrings().filter(r=>r.split(Ng)[0]===t).map(r=>({variant:e,key:r,value:void 0})):n.parseJSON(kg).map(r=>({variant:e,key:r.alias,value:r})),Es=s.z.object({range:se,key:s.z.string(),value:s.z.string()}),Ig=s.z.object({range:se,keys:s.z.string().array()}),xg=s.z.object({pairs:J(Es)}),Ag=s.z.object({range:se,pairs:Es.array()}),Cg=s.z.object({range:se,keys:s.z.string().array()}),In=class xn{constructor(e,n,r){l(this,"rangeKey"),l(this,"client"),l(this,"frameClient"),this.rangeKey=e,this.client=n,this.frameClient=r}async get(e){const n=await w(this.client,xn.GET_ENDPOINT,{range:this.rangeKey,keys:b(e)},Ig,xg);return typeof e=="string"?n.pairs[0].value:Object.fromEntries(n.pairs.map(r=>[r.key,r.value]))}async list(){return this.get([])}async set(e,n=""){let r;ss(e)?r=Object.entries(e).map(([i,a])=>({range:this.rangeKey,key:i,value:a})):r=[{range:this.rangeKey,key:e,value:n}],await w(this.client,xn.SET_ENDPOINT,{range:this.rangeKey,pairs:r},Ag,s.z.unknown())}async delete(e){await w(this.client,xn.DELETE_ENDPOINT,{range:this.rangeKey,keys:b(e)},Cg,s.z.unknown())}async openTracker(){return await st(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,n)=>e==="delete"?n.toStrings().map(r=>{const[i,a]=r.split("<--->",2);return{variant:e,key:r,value:{range:i,key:a,value:""}}}):n.parseJSON(Es).map(r=>({variant:e,key:`${r.range}${r.key}`,value:r})))}};l(In,"GET_ENDPOINT","/range/kv/get"),l(In,"SET_ENDPOINT","/range/kv/set"),l(In,"DELETE_ENDPOINT","/range/kv/delete");let Gr=In;class $o{constructor(e,n=K.ZERO,r,i,a,o,c,u,h,f,d){l(this,"key"),l(this,"name"),l(this,"kv"),l(this,"timeRange"),l(this,"color"),l(this,"channels"),l(this,"aliaser"),l(this,"frameClient"),l(this,"labelClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=r,this.name=e,this.timeRange=n,this.frameClient=a,this.color=i,this.kv=o,this.aliaser=c,this.channels=u,this.labelClient=h,this.ontologyClient=f,this.rangeClient=d}get ontologyID(){return Ae(this.key)}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,n){const r=await this.channels.retrieve(e);if(r.length===0)throw new he(`Channel ${e} does not exist`);await this.aliaser.set({[r[0].key]:n})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(n=>n.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ae(this.key))}async addLabel(...e){await this.labelClient.label(Ae(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ae(this.key),e)}async openChildRangeTracker(){const e=new De.Observer,n=(await this.retrieveChildren()).map(i=>{const a=Ae(i.key);return{id:a,key:a.toString(),name:i.name,data:i.payload}}),r=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:n,resourceType:"range"});return r.onChange(i=>e.notify(this.rangeClient.resourcesToRanges(i))),e.setCloser(async()=>await r.close()),e}async openParentRangeTracker(){const e=new De.Observer,n=await this.retrieveParent();if(n==null)return null;const r=Ae(n.key),i={id:r,key:r.toString(),name:n.name,data:n.payload},a=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:[i],relationshipDirection:"to"});return a.onChange(o=>{const c=this.rangeClient.resourcesToRanges(o);if(c.length===0)return;const u=c[0];e.notify(u)}),e.setCloser(async()=>await a.close()),e}}const jg=(t,e)=>Ph(t.timeRange,e.timeRange),Rg=s.z.object({keys:se.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:K.z.optional(),limit:s.z.number().int().optional(),offset:s.z.number().int().optional(),hasLabels:tt.array().optional()}),Pg="/range/retrieve",Mg=s.z.object({ranges:J(Vt)});let Do=class{constructor(t,e,n,r,i,a){l(this,"type","range"),l(this,"frameClient"),l(this,"writer"),l(this,"unaryClient"),l(this,"channels"),l(this,"labelClient"),l(this,"ontologyClient"),this.frameClient=t,this.writer=e,this.unaryClient=n,this.channels=r,this.labelClient=i,this.ontologyClient=a}async create(t,e){const n=!Array.isArray(t),r=this.sugarMany(await this.writer.create(b(t),e));return n?r[0]:r}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(b(t))}async search(t){return this.sugarMany(await this.execRetrieve({term:t}))}async page(t,e){return this.sugarMany(await this.execRetrieve({offset:t,limit:e}))}async retrieve(t){if(typeof t=="object"&&"start"in t)return await this.execRetrieve({overlapsWith:new K(t)});const{single:e,actual:n,variant:r,normalized:i,empty:a}=lo(t);if(a)return[];const o=await this.execRetrieve({[r]:i});if(!e)return o;if(o.length===0)throw new Xe(`range matching ${n} not found`);if(o.length>1)throw new Qe(`multiple ranges matching ${n} found`);return o[0]}getKV(t){return new Gr(t,this.unaryClient,this.frameClient)}async execRetrieve(t){const{ranges:e}=await w(this.unaryClient,Pg,t,Rg,Mg);return this.sugarMany(e)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents(Ae(t));if(e.length===0)return null;const n=e[0];return n.id.type!=="range"?null:await this.retrieve(n.id.key)}sugarOne(t){return new $o(t.name,t.timeRange,t.key,t.color,this.frameClient,new Gr(t.key,this.unaryClient,this.frameClient),new Sg(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this)}sugarMany(t){return t.map(e=>this.sugarOne(e))}async openTracker(){return await st(this.frameClient,"sy_range_set","sy_range_delete",(t,e)=>t==="delete"?e.toUUIDs().map(n=>({variant:t,key:n,value:void 0})):this.sugarMany(e.parseJSON(Vt)).map(n=>({variant:t,key:n.key,value:n})))}resourcesToRanges(t){return t.map(e=>this.resourceToRange(e))}resourceToRange(t){var e,n,r;return this.sugarOne({key:t.id.key,name:(e=t.data)==null?void 0:e.name,timeRange:new K((n=t.data)==null?void 0:n.timeRange),color:(r=t.data)==null?void 0:r.color})}};const Ae=t=>new C({type:ds,key:t}),Bg=t=>new C({type:fs,key:t}),Ug=s.z.object({ranges:Vt.array()}),$g=s.z.object({parent:ie.optional(),ranges:oo.array()}),Dg=s.z.object({keys:se.array()}),Lg=s.z.object({}),_g=s.z.object({key:se,name:hs}),qg=s.z.object({}),Yg="/range/create",Fg="/range/delete",Wg="/range/rename";class Lo{constructor(e){l(this,"client"),this.client=e}async rename(e,n){await w(this.client,Wg,{key:e,name:n},_g,qg)}async create(e,n){return(await w(this.client,Yg,{ranges:e,...n},$g,Ug)).ranges}async delete(e){await w(this.client,Fg,{keys:e},Dg,Lg)}}const Vg=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_ONTOLOGY_TYPE:fs,Client:Do,KV:Gr,ONTOLOGY_TYPE:ds,Range:$o,Writer:Lo,aliasOntologyID:Bg,analyzeParams:lo,keyZ:se,nameZ:hs,newZ:oo,ontologyID:Ae,payloadZ:Vt,sort:jg},Symbol.toStringTag,{value:"Module"})),Gg="/api/v1/";class Zg{constructor(e,n={},r=!1){l(this,"url"),l(this,"unary"),l(this,"stream"),l(this,"secure"),this.secure=r,this.url=e.child(Gg);const i=new _t.JSONCodec;this.unary=mu(new gu(this.url,i,this.secure),n),this.stream=new Nu(this.url,i,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Kg="/workspace/lineplot/retrieve",Jg="/workspace/lineplot/create",Hg="/workspace/lineplot/rename",Xg="/workspace/lineplot/set-data",Qg="/workspace/lineplot/delete",em=s.z.object({keys:Gt.array()}),tm=s.z.object({workspace:ke,linePlots:rf.array()}),nm=s.z.object({key:Gt,name:s.z.string()}),rm=s.z.object({key:Gt,data:s.z.string()}),sm=s.z.object({keys:Gt.array()}),im=s.z.object({linePlots:J(ys)}),am=s.z.object({linePlots:ys.array()}),zr=s.z.object({});let om=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,Jg,{workspace:t,linePlots:b(e)},tm,am);return n?r.linePlots:r.linePlots[0]}async rename(t,e){await w(this.client,Hg,{key:t,name:e},nm,zr)}async setData(t,e){await w(this.client,Xg,{key:t,data:JSON.stringify(e)},rm,zr)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,Kg,{keys:b(t)},em,im);return e?n.linePlots:n.linePlots[0]}async delete(t){await w(this.client,Qg,{keys:b(t)},sm,zr)}};const lm="/workspace/log/retrieve",cm="/workspace/log/create",um="/workspace/log/rename",hm="/workspace/log/set-data",dm="/workspace/log/delete",fm=s.z.object({keys:Zt.array()}),ym=s.z.object({workspace:ke,logs:af.array()}),pm=s.z.object({key:Zt,name:s.z.string()}),gm=s.z.object({key:Zt,data:s.z.string()}),mm=s.z.object({keys:Zt.array()}),wm=s.z.object({logs:ps.array()}),bm=s.z.object({logs:ps.array()}),Tr=s.z.object({});let vm=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,cm,{workspace:t,logs:b(e)},ym,bm);return n?r.logs:r.logs[0]}async rename(t,e){await w(this.client,um,{key:t,name:e},pm,Tr)}async setData(t,e){await w(this.client,hm,{key:t,data:JSON.stringify(e)},gm,Tr)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,lm,{keys:b(t)},fm,wm);return e?n.logs:n.logs[0]}async delete(t){await w(this.client,dm,{keys:b(t)},mm,Tr)}};const Om="/workspace/schematic/retrieve",zm="/workspace/schematic/create",Tm="/workspace/schematic/rename",Sm="/workspace/schematic/set-data",km="/workspace/schematic/delete",Nm="/workspace/schematic/copy",Em=s.z.object({keys:rt.array()}),Im=s.z.object({workspace:ke,schematics:uf.array()}),xm=s.z.object({key:rt,name:s.z.string()}),Am=s.z.object({key:rt,data:s.z.string()}),Cm=s.z.object({keys:rt.array()}),jm=s.z.object({key:rt,name:s.z.string(),snapshot:s.z.boolean()}),Rm=s.z.object({schematics:J(uo)}),Pm=s.z.object({schematics:uo.array()}),Mm=s.z.object({schematic:ms}),Sr=s.z.object({});let Bm=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,zm,{workspace:t,schematics:b(e)},Im,Pm);return n?r.schematics:r.schematics[0]}async rename(t,e){await w(this.client,Tm,{key:t,name:e},xm,Sr)}async setData(t,e){await w(this.client,Sm,{key:t,data:JSON.stringify(e)},Am,Sr)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,Om,{keys:b(t)},Em,Rm);return e?n.schematics:n.schematics[0]}async delete(t){await w(this.client,km,{keys:b(t)},Cm,Sr)}async copy(t,e,n){return(await w(this.client,Nm,{key:t,name:e,snapshot:n},jm,Mm)).schematic}};const Um="/workspace/table/retrieve",$m="/workspace/table/create",Dm="/workspace/table/rename",Lm="/workspace/table/set-data",_m="/workspace/table/delete",qm=s.z.object({keys:Kt.array()}),Ym=s.z.object({workspace:ke,tables:df.array()}),Fm=s.z.object({key:Kt,name:s.z.string()}),Wm=s.z.object({key:Kt,data:s.z.string()}),Vm=s.z.object({keys:Kt.array()}),Gm=s.z.object({tables:fo.array()}),Zm=s.z.object({tables:fo.array()}),kr=s.z.object({});let Km=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,$m,{workspace:t,tables:b(e)},Ym,Zm);return n?r.tables:r.tables[0]}async rename(t,e){await w(this.client,Dm,{key:t,name:e},Fm,kr)}async setData(t,e){await w(this.client,Lm,{key:t,data:JSON.stringify(e)},Wm,kr)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,Um,{keys:b(t)},qm,Gm);return e?n.tables:n.tables[0]}async delete(t){await w(this.client,_m,{keys:b(t)},Vm,kr)}};const en="/workspace/retrieve",Jm="/workspace/create",Hm="/workspace/rename",Xm="/workspace/set-layout",Qm="/workspace/delete",tn=s.z.object({keys:ke.array().optional(),search:s.z.string().optional(),author:nt.optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),ew=s.z.object({workspaces:lf.array()}),tw=s.z.object({key:ke,name:s.z.string()}),nw=s.z.object({key:ke,layout:s.z.string()}),rw=s.z.object({keys:ke.array()}),nn=s.z.object({workspaces:J(gs)}),sw=s.z.object({workspaces:cf.array()}),Nr=s.z.object({});class iw{constructor(e){l(this,"type",co),l(this,"schematic"),l(this,"linePlot"),l(this,"log"),l(this,"table"),l(this,"client"),this.client=e,this.schematic=new Bm(e),this.linePlot=new om(e),this.log=new vm(e),this.table=new Km(e)}async create(e){const n=Array.isArray(e),r=await w(this.client,Jm,{workspaces:b(e)},ew,sw);return n?r.workspaces:r.workspaces[0]}async rename(e,n){await w(this.client,Hm,{key:e,name:n},tw,Nr)}async setLayout(e,n){await w(this.client,Xm,{key:e,layout:JSON.stringify(n)},nw,Nr)}async retrieve(e){const n=Array.isArray(e),r=await w(this.client,en,{keys:b(e)},tn,nn);return n?r.workspaces:r.workspaces[0]}async retrieveByAuthor(e){return(await w(this.client,en,{author:e},tn,nn)).workspaces}async search(e){return(await w(this.client,en,{search:e},tn,nn)).workspaces}async page(e,n){return(await w(this.client,en,{offset:e,limit:n},tn,nn)).workspaces}async delete(e){await w(this.client,Qm,{keys:b(e)},rw,Nr)}}const _o=s.z.object({host:s.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:s.z.number({required_error:"Port is required"}).or(s.z.string({required_error:"Port is required"})),username:s.z.string().min(1,"Username is required"),password:s.z.string().min(1,"Password is required"),connectivityPollFrequency:T.z.default(T.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional(),retry:Rd.breakerConfig.optional()});class qo extends lp{constructor(e){const n=_o.parse(e),{host:r,port:i,username:a,password:o,connectivityPollFrequency:c,secure:u,retry:h}=n,f=new Zg(new id({host:r,port:Number(i)}),h,u);f.use(Gd);let d;a!=null&&o!=null&&(d=new qy(f.unary,{username:a,password:o}),f.use(d.middleware()));const N=new Os(new vs(f.unary)),x=new No(f.unary,N);super(f.stream,f.unary,N),l(this,"createdAt"),l(this,"props"),l(this,"ranges"),l(this,"channels"),l(this,"auth"),l(this,"user"),l(this,"access"),l(this,"connectivity"),l(this,"ontology"),l(this,"workspaces"),l(this,"labels"),l(this,"hardware"),l(this,"control"),l(this,"transport"),l(this,"clientVersion","0.41.0"),this.createdAt=E.now(),this.props=n,this.auth=d,this.transport=f,this.channels=new To(this,N,f.unary,x),this.connectivity=new xo(f.unary,c,this.clientVersion,n.name),this.control=new Ro(this),this.ontology=new Mf(f.unary,this);const ae=new Lo(this.transport.unary);this.labels=new hg(this.transport.unary,this,this.ontology),this.ranges=new Do(this,ae,this.transport.unary,N,this.labels,this.ontology),this.access=new Kf(this.transport.unary),this.user=new Py(this.transport.unary),this.workspaces=new iw(this.transport.unary);const Y=new Tp(this.transport.unary,this),Ps=new Zp(this.transport.unary,this,this.ontology,this.ranges),sl=new Cp(this.transport.unary,Ps,this);this.hardware=new yp(Ps,sl,Y)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}l(qo,"connectivity",xo);const aw=Je.Authority,Zr=(t,e,n="")=>{try{return t.parse(e)}catch(r){if(r instanceof s.z.ZodError){const i=r.errors.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${n} - ${i.join(`
52
- `)}`)}else throw r}};var ow=Object.defineProperty,lw=(t,e,n)=>e in t?ow(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,V=(t,e,n)=>lw(t,typeof e!="symbol"?e+"":e,n);const Kr=class Yo{constructor(e,n,r="",i=!1){V(this,"_noop",!1),V(this,"key"),V(this,"path"),V(this,"serviceName"),this.key=e,this.path=n,this.serviceName=r,this._noop=i}child(e){return new Yo(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};V(Kr,"NOOP",new Kr("","",""));let Is=Kr;const Jr=["debug","info","warn","error"],cw=t=>{const e=Jr.indexOf(t);return({level:n})=>Jr.indexOf(n)>=e},uw=t=>{const{include:e,exclude:n}=t;return({path:r})=>!(e!=null&&!e.some(i=>r.startsWith(i))||n!=null&&n.some(i=>r.startsWith(i)))},Hr=class Fo{constructor(e={}){V(this,"meta",Is.NOOP),V(this,"filters");const{filters:n=[]}=e;this.filters=n}filter(e){return!this.meta.noop&&this.filters.every(n=>n({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const n=new Fo({filters:this.filters});return n.meta=e,n}debug(e,n,r=!1){!this.filter("debug")&&!r||(n==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,rn(n)))}info(e,n,r=!1){!this.filter("info")&&!r||(n==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,rn(n)))}warn(e,n,r=!1){!this.filter("warn")&&!r||(n==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,rn(n)))}error(e,n,r=!1){!this.filter("error")&&!r||(n==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,rn(n)))}};V(Hr,"NOOP",new Hr);let Wo=Hr;const rn=t=>typeof t=="function"?t():t;var hw=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Ue="1.9.0",Di=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function dw(t){var e=new Set([t]),n=new Set,r=t.match(Di);if(!r)return function(){return!1};var i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(c){return c===t};function a(c){return n.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(n.has(c))return!1;var u=c.match(Di);if(!u)return a(c);var h={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return h.prerelease!=null||i.major!==h.major?a(c):i.major===0?i.minor===h.minor&&i.patch<=h.patch?o(c):a(c):i.minor<=h.minor?o(c):a(c)}}var fw=dw(Ue),yw=Ue.split(".")[0],Pt=Symbol.for("opentelemetry.js.api."+yw),Mt=hw;function xs(t,e,n,r){var i;r===void 0&&(r=!1);var a=Mt[Pt]=(i=Mt[Pt])!==null&&i!==void 0?i:{version:Ue};if(!r&&a[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return n.error(o.stack||o.message),!1}if(a.version!==Ue){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+t+" does not match previously registered API v"+Ue);return n.error(o.stack||o.message),!1}return a[t]=e,n.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ue+"."),!0}function Bt(t){var e,n,r=(e=Mt[Pt])===null||e===void 0?void 0:e.version;if(!(!r||!fw(r)))return(n=Mt[Pt])===null||n===void 0?void 0:n[t]}function As(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ue+".");var n=Mt[Pt];n&&delete n[t]}var pw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},gw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},mw=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return ut("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return ut("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return ut("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return ut("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return ut("verbose",this._namespace,e)},t}();function ut(t,e,n){var r=Bt("diag");if(r)return n.unshift(e),r[t].apply(r,gw([],pw(n),!1))}var oe;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(oe||(oe={}));function ww(t,e){t<oe.NONE?t=oe.NONE:t>oe.ALL&&(t=oe.ALL),e=e||{};function n(r,i){var a=e[r];return typeof a=="function"&&t>=i?a.bind(e):function(){}}return{error:n("error",oe.ERROR),warn:n("warn",oe.WARN),info:n("info",oe.INFO),debug:n("debug",oe.DEBUG),verbose:n("verbose",oe.VERBOSE)}}var bw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},vw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},Ow="diag",Ut=function(){function t(){function e(i){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var c=Bt("diag");if(c)return c[i].apply(c,vw([],bw(a),!1))}}var n=this,r=function(i,a){var o,c,u;if(a===void 0&&(a={logLevel:oe.INFO}),i===n){var h=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((o=h.stack)!==null&&o!==void 0?o:h.message),!1}typeof a=="number"&&(a={logLevel:a});var f=Bt("diag"),d=ww((c=a.logLevel)!==null&&c!==void 0?c:oe.INFO,i);if(f&&!a.suppressOverrideMessage){var N=(u=new Error().stack)!==null&&u!==void 0?u:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+N),d.warn("Current logger will overwrite one already registered from "+N)}return xs("diag",d,n,!0)};n.setLogger=r,n.disable=function(){As(Ow,n)},n.createComponentLogger=function(i){return new mw(i)},n.verbose=e("verbose"),n.debug=e("debug"),n.info=e("info"),n.warn=e("warn"),n.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),zw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Tw=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Sw=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var n=this._entries.get(e);if(n)return Object.assign({},n)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var n=zw(e,2),r=n[0],i=n[1];return[r,i]})},t.prototype.setEntry=function(e,n){var r=new t(this._entries);return r._entries.set(e,n),r},t.prototype.removeEntry=function(e){var n=new t(this._entries);return n._entries.delete(e),n},t.prototype.removeEntries=function(){for(var e,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=new t(this._entries);try{for(var o=Tw(r),c=o.next();!c.done;c=o.next()){var u=c.value;a._entries.delete(u)}}catch(h){e={error:h}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return a},t.prototype.clear=function(){return new t},t}();Ut.instance();function kw(t){return t===void 0&&(t={}),new Sw(new Map(Object.entries(t)))}function Nw(t){return Symbol.for(t)}var Ew=function(){function t(e){var n=this;n._currentContext=e?new Map(e):new Map,n.getValue=function(r){return n._currentContext.get(r)},n.setValue=function(r,i){var a=new t(n._currentContext);return a._currentContext.set(r,i),a},n.deleteValue=function(r){var i=new t(n._currentContext);return i._currentContext.delete(r),i}}return t}(),Iw=new Ew,xw={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Aw={set:function(t,e,n){t!=null&&(t[e]=n)}},Cw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},jw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},Rw=function(){function t(){}return t.prototype.active=function(){return Iw},t.prototype.with=function(e,n,r){for(var i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return n.call.apply(n,jw([r],Cw(i),!1))},t.prototype.bind=function(e,n){return n},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),Pw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Mw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},Er="context",Bw=new Rw,Vo=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return xs(Er,e,Ut.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,n,r){for(var i,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Mw([e,n,r],Pw(a),!1))},t.prototype.bind=function(e,n){return this._getContextManager().bind(e,n)},t.prototype._getContextManager=function(){return Bt(Er)||Bw},t.prototype.disable=function(){this._getContextManager().disable(),As(Er,Ut.instance())},t}(),Xr;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Xr||(Xr={}));var Uw=Vo.getInstance(),$w=function(){function t(){}return t.prototype.inject=function(e,n){},t.prototype.extract=function(e,n){return e},t.prototype.fields=function(){return[]},t}(),Cs=Nw("OpenTelemetry Baggage Key");function Go(t){return t.getValue(Cs)||void 0}function Dw(){return Go(Vo.getInstance().active())}function Lw(t,e){return t.setValue(Cs,e)}function _w(t){return t.deleteValue(Cs)}var Ir="propagation",qw=new $w,Yw=function(){function t(){this.createBaggage=kw,this.getBaggage=Go,this.getActiveBaggage=Dw,this.setBaggage=Lw,this.deleteBaggage=_w}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return xs(Ir,e,Ut.instance())},t.prototype.inject=function(e,n,r){return r===void 0&&(r=Aw),this._getGlobalPropagator().inject(e,n,r)},t.prototype.extract=function(e,n,r){return r===void 0&&(r=xw),this._getGlobalPropagator().extract(e,n,r)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){As(Ir,Ut.instance())},t.prototype._getGlobalPropagator=function(){return Bt(Ir)||qw},t}(),Fw=Yw.getInstance();const Li=["bench","debug","prod"],Ww=t=>e=>Li.indexOf(e)>=Li.indexOf(t),Qr=class Zo{constructor(e,n=Ww("debug")){V(this,"meta",Is.NOOP),V(this,"tracer"),V(this,"filter"),this.tracer=e,this.filter=n}child(e){const n=new Zo(this.tracer,this.filter);return n.meta=e,n}debug(e,n){return this.trace(e,"debug",n)}bench(e,n){return this.trace(e,"bench",n)}prod(e,n){return this.trace(e,"prod",n)}trace(e,n,r){return this.meta.noop||!this.filter(n)?r(new Ho(e)):this.tracer.startActiveSpan(e,i=>{const a=new Jo(e,i),o=r(a);return i.end(),o})}propagate(e){if(this.meta.noop)return;const n=Uw.active();Fw.inject(n,e,{set:(r,i,a)=>{r[i]=a}})}};V(Qr,"NOOP",new Qr);let Ko=Qr;class Jo{constructor(e,n){V(this,"key"),V(this,"otel"),this.key=e,this.otel=n}set(e,n){this.otel.setAttribute(e,n)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Xr.ERROR}))}}class Ho{constructor(e){V(this,"key"),this.key=e}set(){}recordError(e){}}const es=class Xo{constructor({key:e="",serviceName:n="",logger:r=Wo.NOOP,tracer:i=Ko.NOOP,noop:a=!1,__meta:o}){V(this,"meta"),V(this,"T"),V(this,"L"),this.meta=o??new Is(e,e,n,a),this.T=i.child(this.meta),this.L=r.child(this.meta)}child(e){const n=this.meta.child(e);return new Xo({__meta:n,tracer:this.T,logger:this.L})}};V(es,"NOOP",new es({noop:!0}));let js=es;const Vw=js.NOOP,Qo=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:js,LOG_LEVELS:Jr,Logger:Wo,NOOP:Vw,NoopSpan:Ho,Tracer:Ko,_Span:Jo,logLevelKeyFiler:uw,logThresholdFilter:cw},Symbol.toStringTag,{value:"Module"})),Gw=new Error("request for lock canceled");var Zw=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Kw{constructor(e,n=Gw){this._value=e,this._cancelError=n,this._queue=[],this._weightedWaiters=[]}acquire(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,i)=>{const a={resolve:r,reject:i,weight:e,priority:n},o=el(this._queue,c=>n<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Zw(this,arguments,void 0,function*(n,r=1,i=0){const[a,o]=yield this.acquire(r,i);try{return yield n(a)}finally{o()}})}waitForUnlock(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,n)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Jw(this._weightedWaiters[e-1],{resolve:r,priority:n})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const n=this._value;this._value-=e.weight,e.resolve([n,this._newReleaser(e.weight)])}_newReleaser(e){let n=!1;return()=>{n||(n=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const n=this._weightedWaiters[e-1];n&&(n.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let n=this._value;n>0;n--){const r=this._weightedWaiters[n-1];if(!r)continue;const i=r.findIndex(a=>a.priority<=e);(i===-1?r:r.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,n){return(this._queue.length===0||this._queue[0].priority<n)&&e<=this._value}}function Jw(t,e){const n=el(t,r=>e.priority<=r.priority);t.splice(n+1,0,e)}function el(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}var Hw=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class tl{constructor(e){this._semaphore=new Kw(1,e)}acquire(){return Hw(this,arguments,void 0,function*(e=0){const[,n]=yield this._semaphore.acquire(1,e);return n})}runExclusive(e,n=0){return this._semaphore.runExclusive(()=>e(),1,n)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class Rs{constructor({key:e,type:n,sender:r,instrumentation:i,parentCtxValues:a}){D(this,"type");D(this,"key");D(this,"sender");D(this,"_internalState");D(this,"_state");D(this,"_prevState");D(this,"_deleted",!1);D(this,"parentCtxValues");D(this,"childCtxValues");D(this,"childCtxChangedKeys");D(this,"instrumentation");D(this,"schema");this.type=n,this.key=e,this.sender=r,this._internalState={},this.instrumentation=i.child(`${this.type}(${this.key})`),this.parentCtxValues=new Map,a==null||a.forEach((o,c)=>this.parentCtxValues.set(c,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}get _schema(){if(this.schema==null)throw new q(`[AetherLeaf] - expected subclass to define component schema, but none was found.
53
- Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const n=xe.executeSetter(e,this._state);this._prevState={...this._state},this._state=Zr(this._schema,n,`${this.type}:${this.key}`),this.sender.send({key:this.key,state:n})}get state(){if(this._state==null)throw new le(`[AetherLeaf] - state not defined in ${this.type}:${this.key}`);return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>this.parentCtxValues.get(e),getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),setPreviously:e=>this.childCtxValues.has(e),set:(e,n,r=!0)=>{this.childCtxValues.set(e,n),r&&this.childCtxChangedKeys.add(e)}}}async _updateState(e,n,r){if(this.deleted)return;this.validatePath(e);const i=Zr(this._schema,n,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:ol.I.difference(this.state,i)})):this.instrumentation.L.debug("setting initial state",{state:n}),this._prevState=this._state??i,this._state=i,await this.afterUpdate(this.ctx)}async _updateContext(e){e.forEach((n,r)=>this.parentCtxValues.set(r,n)),await this.afterUpdate(this.ctx)}async _delete(e){this.validatePath(e),this._deleted=!0,await this.afterDelete(this.ctx)}async afterUpdate(e){}async afterDelete(e){}validatePath(e){if(e.length===0)throw new le(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const n=e[e.length-1];if(e.length>1)throw new le(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(n!==this.key)throw new le(`[Leaf.setState] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`)}}class er extends Rs{constructor(){super(...arguments);D(this,"_children",new Map)}get children(){return Array.from(this._children.values())}getChild(n){return this._children.get(n)??null}childrenOfType(...n){return this.children.filter(r=>n.includes(r.type))}async _updateState(n,r,i){if(this.deleted)return;const a=this.parsePath(n);if(a.length===0){if(this.childCtxChangedKeys.clear(),await super._updateState(n,r,i),this.childCtxChangedKeys.size==0)return;await this.updateChildContexts();return}const c=a[0],u=this.getChild(c);if(u!=null)return u._updateState(a,r,i);if(a.length>1)throw new le(`[Composite.update] - ${this.type}:${this.key} received a subPath ${a.join(".")} but found now child with key ${c}`);const h=i(this.childCtx());await h._updateState(a,r,i),this._children.set(c,h)}async _updateContext(n){await super._updateContext(n),await this.updateChildContexts()}childCtx(){return{get:n=>this.childCtxValues.get(n)??this.parentCtxValues.get(n),forEach:n=>{this.childCtxValues.forEach((r,i)=>n(r,i,this.childCtxValues)),this.parentCtxValues.forEach((r,i)=>{this.childCtxValues.has(i)||n(r,i,this.parentCtxValues)})}}}async updateChildContexts(){for(const n of this.children)await n._updateContext(this.childCtx())}async _delete(n){const r=this.parsePath(n);if(r.length===0){for(const a of this.children)await a._delete([a.key]);this._children.clear(),await super._delete([this.key])}const i=this.getChild(r[0]);if(i!=null){if(r.length>1)return await i._delete(r);this._children.delete(i.key),await i._delete(r)}}parsePath(n,r){const[i,...a]=n;if(i==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path${r!=null?` for ${r}`:""}`);if(i!==this.key)throw new le(`[Composite.getRequiredKey] - ${this.type}:${this.key} received a key ${i} but expected ${this.key}`);return a}}const Xw=s.z.object({}),Qw=()=>{throw new Error("should not call create")},Ce=class Ce extends er{constructor({comms:n,instrumentation:r=Qo.Instrumentation.NOOP,registry:i}){super({key:Ce.KEY,type:Ce.TYPE,sender:n,instrumentation:r,parentCtxValues:null});D(this,"comms");D(this,"registry");D(this,"mu",new tl);D(this,"schema",Xw);this.comms=n,this.registry=i}static async render(n){const r=new Ce(n);return await r._updateState([Ce.KEY],{},Qw),r.comms.handle(i=>{r.mu.runExclusive(async()=>{await r.handle(i)})}),r}async handle(n){const{path:r,variant:i,type:a}=n;i==="delete"?await this._delete(r):await this._updateState(r,n.state,o=>{const c=r[r.length-1];return this.create({key:c,type:a,parentCtxValues:o})})}create({key:n,type:r,parentCtxValues:i}){const a=this.registry[r];if(a==null)throw new le(`[Root.create] - ${r} not found in registry`);return new a({key:n,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:i})}};D(Ce,"TYPE","root"),D(Ce,"KEY","root");let $t=Ce;const nl=$t.render.bind($t),eb=Object.freeze(Object.defineProperty({__proto__:null,Composite:er,Leaf:Rs,Root:$t,render:nl},Symbol.toStringTag,{value:"Module"})),ts="pluto-theming-context",rl=s.z.object({name:s.z.string(),url:s.z.string()}),tb=s.z.object({theme:_i,fontURLs:s.z.array(rl)}),Ct=class Ct extends er{constructor(){super(...arguments);D(this,"schema",Ct.z)}async afterUpdate(n){n.getOptional(ts)!=null&&this.state.theme.key===this.prevState.theme.key||(n.set(ts,this.state.theme),await this.loadFonts())}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:n,url:r})=>{const i=new FontFace(n,`url(${r})`);try{await i.load(),self.fonts.add(i)}catch(a){console.error(a)}}))}};D(Ct,"TYPE","theming.Provider"),D(Ct,"z",tb);let Dt=Ct;const nb=t=>t.get(ts),rb={[Dt.TYPE]:Dt};exports.$=E;exports.$m=Vg;exports.$p=qo;exports.B=js;exports.Bm=aw;exports.Composite=er;exports.H=K;exports.Ip=_o;exports.L=q;exports.Leaf=Rs;exports.Mutex=tl;exports.Provider=Dt;exports.REGISTRY=rb;exports.S=T;exports.SYNNAX_DARK=Yi;exports.SYNNAX_LIGHT=qi;exports.SYNNAX_THEMES=zl;exports.Ze=le;exports.ae=he;exports.aether=eb;exports.fm=fp;exports.fontSpecZ=rl;exports.g=Qo;exports.isComponentSize=kl;exports.l=ul;exports.nm=gy;exports.prettyParse=Zr;exports.render=nl;exports.themeZ=_i;exports.use=nb;