@synnaxlabs/pluto 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) hide show
  1. package/dist/{Animated-zwHonFIj.cjs → Animated-CZ63NC05.cjs} +1 -1
  2. package/dist/{Animated-DNVDjbp5.js → Animated-CqT7-gZp.js} +2 -2
  3. package/dist/{Keyboard-CK96wQ5G.cjs → Keyboard-BIXxwSvF.cjs} +1 -1
  4. package/dist/{Keyboard-DIqjeZSO.js → Keyboard-fZbH7UAB.js} +2 -2
  5. package/dist/LinePlot-C6UR06-e.cjs +66 -0
  6. package/dist/{LinePlot-Cvi3y24D.js → LinePlot-Cc3CIgai.js} +1814 -1803
  7. package/dist/Link-BDA_zOS7.js +10 -0
  8. package/dist/Link-CYHWDE13.cjs +1 -0
  9. package/dist/{List-B6hlZNwe.js → List-DS2DLWjR.js} +2 -2
  10. package/dist/{List-CBMm9BLf.cjs → List-qhbpsD-f.cjs} +1 -1
  11. package/dist/{Pack-BM_LmeO7.cjs → Pack--3w90epp.cjs} +1 -1
  12. package/dist/{Pack-E_3LSkGG.js → Pack-B7_4Xpi5.js} +1 -1
  13. package/dist/{Toggle-_SGawcap.js → Toggle-0_fgC0fe.js} +8127 -8097
  14. package/dist/Toggle-DBbZoe_A.cjs +143 -0
  15. package/dist/{Video-Ct4BfJzt.js → Video-Breqk8IV.js} +1 -1
  16. package/dist/{Video-A2NddcPS.cjs → Video-yUL4iEVD.cjs} +1 -1
  17. package/dist/{aggregator-DaNTqAB0.js → aggregator-BQAqJzjZ.js} +4110 -3820
  18. package/dist/aggregator-Bs9fTewE.cjs +51 -0
  19. package/dist/align.cjs +1 -1
  20. package/dist/align.js +1 -1
  21. package/dist/button.cjs +1 -1
  22. package/dist/button.js +1 -1
  23. package/dist/color.cjs +1 -1
  24. package/dist/color.js +1 -1
  25. package/dist/{css-DY1Oedjj.cjs → css-B7TifAVb.cjs} +1 -1
  26. package/dist/{css-DEMSADUS.js → css-Dic6npsA.js} +1 -1
  27. package/dist/css.cjs +1 -1
  28. package/dist/css.js +2 -2
  29. package/dist/dropdown.cjs +1 -1
  30. package/dist/dropdown.js +1 -1
  31. package/dist/ether.cjs +1 -1
  32. package/dist/ether.js +5 -5
  33. package/dist/external-3Q2dzLIL.cjs +1 -0
  34. package/dist/{external-CS2UIUPR.js → external-69Ao7j7k.js} +13 -13
  35. package/dist/{external-Cja9j84T.cjs → external-B4OSNdH_.cjs} +1 -1
  36. package/dist/{external-C86d--c3.js → external-BUFyYRiR.js} +4 -4
  37. package/dist/{external-D23hMpey.js → external-BWE1zUh9.js} +14 -13
  38. package/dist/{external-CJOE_TDI.js → external-BjLjce7d.js} +2 -2
  39. package/dist/{external-9st6X3mL.cjs → external-BnJhvG1t.cjs} +1 -1
  40. package/dist/{external-DfwQACwH.js → external-By-puR46.js} +3 -3
  41. package/dist/{external-DOZ21f-5.cjs → external-C3c1BoRE.cjs} +1 -1
  42. package/dist/external-CAS1RuN6.cjs +1 -0
  43. package/dist/{external-DG3L9UDo.cjs → external-CHYxZzhb.cjs} +1 -1
  44. package/dist/{external-ChYLNmOM.js → external-CNTzwgmW.js} +16 -16
  45. package/dist/{external-D_dAdIZX.js → external-CPUf0VYV.js} +2 -2
  46. package/dist/{external-C4w_40JS.js → external-CVzm1emB.js} +4 -4
  47. package/dist/{external-ChI4-3Am.cjs → external-CpUUO6Ja.cjs} +1 -1
  48. package/dist/{external-CsAw5Bqm.js → external-DA_ZnqPs.js} +126 -120
  49. package/dist/{external-DlkO8mh4.js → external-DH3sAQ0c.js} +1 -1
  50. package/dist/{external-CE4wgFJ7.cjs → external-DR0u7Ium.cjs} +1 -1
  51. package/dist/{external-r0ozQhkY.cjs → external-DddErJ4X.cjs} +1 -1
  52. package/dist/{external-BxUqbUsk.js → external-DeMvP0U_.js} +6 -6
  53. package/dist/{external-BAw0sDOf.cjs → external-DrJrhKqG.cjs} +1 -1
  54. package/dist/{external-DZohHxSv.cjs → external-mBw4Opva.cjs} +1 -1
  55. package/dist/{external-rzy59VM1.cjs → external-o0TYQr9r.cjs} +1 -1
  56. package/dist/external-vJteyGA3.js +241 -0
  57. package/dist/header.cjs +1 -1
  58. package/dist/header.js +1 -1
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.js +5008 -4536
  61. package/dist/input.cjs +1 -1
  62. package/dist/input.js +1 -1
  63. package/dist/list.cjs +1 -1
  64. package/dist/list.js +1 -1
  65. package/dist/menu.cjs +1 -1
  66. package/dist/menu.js +1 -1
  67. package/dist/src/accordion/Accordion.d.ts +0 -1
  68. package/dist/src/aether/aether/aether.d.ts +0 -1
  69. package/dist/src/aether/aether/worker.spec.d.ts +0 -1
  70. package/dist/src/aether/main.d.ts +0 -1
  71. package/dist/src/aether/main.spec.d.ts +0 -1
  72. package/dist/src/aether/test/test.d.ts +0 -1
  73. package/dist/src/alamos/Provider.d.ts +0 -1
  74. package/dist/src/alamos/aether/alamos.d.ts +0 -1
  75. package/dist/src/align/Center.d.ts +0 -1
  76. package/dist/src/align/Pack.d.ts +0 -1
  77. package/dist/src/align/Space.d.ts +0 -1
  78. package/dist/src/button/Button.d.ts +0 -1
  79. package/dist/src/button/Icon.d.ts +0 -1
  80. package/dist/src/button/Link.d.ts +0 -1
  81. package/dist/src/button/Toggle.d.ts +0 -1
  82. package/dist/src/button/color.d.ts +0 -1
  83. package/dist/src/caret/Animated.d.ts +0 -1
  84. package/dist/src/caret/Animated.d.ts.map +1 -1
  85. package/dist/src/caret/index.d.ts.map +1 -1
  86. package/dist/src/channel/AliasProvider.d.ts +0 -1
  87. package/dist/src/channel/LinePlot.d.ts +0 -1
  88. package/dist/src/channel/Select.d.ts +0 -1
  89. package/dist/src/color/Picker/Picker.d.ts +0 -1
  90. package/dist/src/color/Swatch/Swatch.d.ts +0 -1
  91. package/dist/src/color/Swatch/Swatch.d.ts.map +1 -1
  92. package/dist/src/color/core/color.d.ts +0 -1
  93. package/dist/src/css/bem.d.ts +0 -1
  94. package/dist/src/css/color.d.ts +0 -1
  95. package/dist/src/css/css.d.ts +1 -1
  96. package/dist/src/css/css.d.ts.map +1 -1
  97. package/dist/src/css/grid.d.ts +0 -1
  98. package/dist/src/cursor/cursor.d.ts +0 -1
  99. package/dist/src/dialog/use.d.ts +5 -1
  100. package/dist/src/dialog/use.d.ts.map +1 -1
  101. package/dist/src/divider/Divider.d.ts +0 -1
  102. package/dist/src/dropdown/Dropdown.d.ts +4 -3
  103. package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
  104. package/dist/src/form/Field.d.ts +0 -1
  105. package/dist/src/form/Field.d.ts.map +1 -1
  106. package/dist/src/form/Form.d.ts +25 -4
  107. package/dist/src/form/Form.d.ts.map +1 -1
  108. package/dist/src/form/external.d.ts +1 -0
  109. package/dist/src/form/external.d.ts.map +1 -1
  110. package/dist/src/form/synced.d.ts +25 -0
  111. package/dist/src/form/synced.d.ts.map +1 -0
  112. package/dist/src/generic/Generic.d.ts +0 -1
  113. package/dist/src/hardware/device/Select.d.ts +0 -1
  114. package/dist/src/haul/Haul.d.ts +0 -1
  115. package/dist/src/header/Actions.d.ts +0 -1
  116. package/dist/src/header/ButtonTitle.d.ts +0 -1
  117. package/dist/src/header/Header.d.ts +0 -1
  118. package/dist/src/header/Title.d.ts +0 -1
  119. package/dist/src/hooks/effect.d.ts +0 -1
  120. package/dist/src/hooks/ref.d.ts +0 -1
  121. package/dist/src/hooks/useClickOutside.d.ts +1 -2
  122. package/dist/src/hooks/useClickOutside.d.ts.map +1 -1
  123. package/dist/src/hooks/useCursorDrag/types.d.ts +0 -1
  124. package/dist/src/hooks/useCursorDrag/useCursorDrag.d.ts +0 -1
  125. package/dist/src/hooks/useCursorDrag/useVirtualCursorDragWebKit.d.ts +0 -1
  126. package/dist/src/hooks/useCursorDrag/useVirtualCursorDragWebView.d.ts +0 -1
  127. package/dist/src/hooks/useDebouncedCallback.d.ts +0 -1
  128. package/dist/src/hooks/useFilter.d.ts +0 -1
  129. package/dist/src/hooks/useResize.d.ts +0 -1
  130. package/dist/src/hooks/useTransforms.d.ts +0 -1
  131. package/dist/src/icon/Icon.d.ts +0 -1
  132. package/dist/src/icon/Icon.d.ts.map +1 -1
  133. package/dist/src/icon/index.d.ts.map +1 -1
  134. package/dist/src/index.d.ts +2 -0
  135. package/dist/src/index.d.ts.map +1 -1
  136. package/dist/src/input/Date.d.ts +0 -1
  137. package/dist/src/input/DateTime.d.ts +0 -1
  138. package/dist/src/input/DragButton.d.ts +0 -1
  139. package/dist/src/input/HelpText.d.ts +0 -1
  140. package/dist/src/input/Item.d.ts +0 -1
  141. package/dist/src/input/Label.d.ts +0 -1
  142. package/dist/src/input/Numeric.d.ts +0 -1
  143. package/dist/src/input/Switch.d.ts +0 -1
  144. package/dist/src/input/Switch.d.ts.map +1 -1
  145. package/dist/src/input/Text.d.ts +4 -1
  146. package/dist/src/input/Text.d.ts.map +1 -1
  147. package/dist/src/input/TextArea.d.ts +0 -1
  148. package/dist/src/input/Time.d.ts +0 -1
  149. package/dist/src/input/types.d.ts +0 -1
  150. package/dist/src/label/Select.d.ts +11 -0
  151. package/dist/src/label/Select.d.ts.map +1 -0
  152. package/dist/src/label/external.d.ts +3 -0
  153. package/dist/src/label/external.d.ts.map +1 -0
  154. package/dist/src/label/index.d.ts +2 -0
  155. package/dist/src/label/index.d.ts.map +1 -0
  156. package/dist/src/label/types.d.ts +2 -0
  157. package/dist/src/label/types.d.ts.map +1 -0
  158. package/dist/src/list/Column.d.ts +1 -1
  159. package/dist/src/list/Column.d.ts.map +1 -1
  160. package/dist/src/list/Core.d.ts +0 -1
  161. package/dist/src/list/Data.d.ts +0 -1
  162. package/dist/src/list/Filter.d.ts +0 -1
  163. package/dist/src/list/Hover.d.ts +0 -1
  164. package/dist/src/list/Infinite.d.ts +0 -1
  165. package/dist/src/list/Item.d.ts +2 -2
  166. package/dist/src/list/Item.d.ts.map +1 -1
  167. package/dist/src/list/List.d.ts +0 -1
  168. package/dist/src/list/Search.d.ts +2 -2
  169. package/dist/src/list/Search.d.ts.map +1 -1
  170. package/dist/src/list/Selector.d.ts +0 -1
  171. package/dist/src/list/types.d.ts +0 -1
  172. package/dist/src/list/useSelect.d.ts +0 -1
  173. package/dist/src/memo/proxyMemo.d.ts +0 -1
  174. package/dist/src/memo/useMemoCompare.d.ts +2 -2
  175. package/dist/src/memo/useMemoCompare.d.ts.map +1 -1
  176. package/dist/src/menu/ContextMenu.d.ts +0 -1
  177. package/dist/src/menu/ContextMenu.d.ts.map +1 -1
  178. package/dist/src/menu/Item.d.ts +0 -1
  179. package/dist/src/menu/Menu.d.ts +0 -1
  180. package/dist/src/mock/MockGLBufferController.d.ts +5 -6
  181. package/dist/src/mock/MockGLBufferController.d.ts.map +1 -1
  182. package/dist/src/modal/Modal.d.ts +1 -2
  183. package/dist/src/modal/Modal.d.ts.map +1 -1
  184. package/dist/src/mosaic/Mosaic.d.ts +0 -1
  185. package/dist/src/mosaic/tree.d.ts +1 -1
  186. package/dist/src/mosaic/tree.d.ts.map +1 -1
  187. package/dist/src/mosaic/types.d.ts +0 -1
  188. package/dist/src/mosaic/use.d.ts +0 -1
  189. package/dist/src/nav/Bar.d.ts +0 -1
  190. package/dist/src/nav/Drawer.d.ts +0 -1
  191. package/dist/src/note/Note.d.ts +0 -1
  192. package/dist/src/observe/index.d.ts.map +1 -1
  193. package/dist/src/observe/use.d.ts +6 -10
  194. package/dist/src/observe/use.d.ts.map +1 -1
  195. package/dist/src/os/Controls/Controls.d.ts +0 -1
  196. package/dist/src/os/Controls/Mac.d.ts +0 -1
  197. package/dist/src/os/Controls/Windows.d.ts +0 -1
  198. package/dist/src/os/Controls/types.d.ts +0 -1
  199. package/dist/src/os/use.d.ts +0 -1
  200. package/dist/src/pluto/Pluto.d.ts +0 -1
  201. package/dist/src/progress/Progress.d.ts +0 -1
  202. package/dist/src/ranger/Select.d.ts +11 -0
  203. package/dist/src/ranger/Select.d.ts.map +1 -0
  204. package/dist/src/ranger/SelectLabel.d.ts +0 -1
  205. package/dist/src/ranger/TimeRangeChip.d.ts +3 -3
  206. package/dist/src/ranger/TimeRangeChip.d.ts.map +1 -1
  207. package/dist/src/ranger/external.d.ts +1 -0
  208. package/dist/src/ranger/external.d.ts.map +1 -1
  209. package/dist/src/ranger/types.d.ts +2 -0
  210. package/dist/src/ranger/types.d.ts.map +1 -0
  211. package/dist/src/resize/Core.d.ts +0 -1
  212. package/dist/src/resize/Multiple.d.ts +0 -1
  213. package/dist/src/resize/Single.d.ts +0 -1
  214. package/dist/src/select/Button.d.ts +1 -2
  215. package/dist/src/select/Button.d.ts.map +1 -1
  216. package/dist/src/select/ClearButton.d.ts +0 -1
  217. package/dist/src/select/DataType.d.ts +0 -1
  218. package/dist/src/select/Direction.d.ts +0 -1
  219. package/dist/src/select/List.d.ts +5 -4
  220. package/dist/src/select/List.d.ts.map +1 -1
  221. package/dist/src/select/Modal.d.ts +1 -0
  222. package/dist/src/select/Modal.d.ts.map +1 -0
  223. package/dist/src/select/Multiple.d.ts +5 -3
  224. package/dist/src/select/Multiple.d.ts.map +1 -1
  225. package/dist/src/select/Select.spec.d.ts +0 -1
  226. package/dist/src/select/Single.d.ts +10 -4
  227. package/dist/src/select/Single.d.ts.map +1 -1
  228. package/dist/src/state/state.d.ts +0 -1
  229. package/dist/src/status/Aggregator.d.ts +0 -1
  230. package/dist/src/status/Aggregator.d.ts.map +1 -1
  231. package/dist/src/status/Circle.d.ts +0 -1
  232. package/dist/src/status/Notification.d.ts +0 -1
  233. package/dist/src/status/Text.d.ts +0 -1
  234. package/dist/src/status/aether/aggregator.d.ts +0 -1
  235. package/dist/src/status/aether/types.d.ts +0 -1
  236. package/dist/src/status/colors.d.ts +0 -1
  237. package/dist/src/steps/Steps.d.ts +0 -1
  238. package/dist/src/synnax/Provider.d.ts +0 -1
  239. package/dist/src/synnax/aether/provider.d.ts +30 -31
  240. package/dist/src/tabs/Selector.d.ts +0 -1
  241. package/dist/src/tabs/Tabs.d.ts +0 -1
  242. package/dist/src/tabs/types.d.ts +0 -1
  243. package/dist/src/tag/Tag.d.ts +2 -2
  244. package/dist/src/tag/Tag.d.ts.map +1 -1
  245. package/dist/src/telem/Pipeline.d.ts +0 -1
  246. package/dist/src/telem/Provider.d.ts +0 -1
  247. package/dist/src/telem/aether/context.d.ts +0 -1
  248. package/dist/src/telem/aether/convertSeries.d.ts +0 -1
  249. package/dist/src/telem/aether/factory.d.ts +0 -1
  250. package/dist/src/telem/aether/noop.d.ts +0 -1
  251. package/dist/src/telem/aether/pipeline.d.ts +0 -1
  252. package/dist/src/telem/aether/provider.d.ts +0 -1
  253. package/dist/src/telem/aether/remote.d.ts +0 -1
  254. package/dist/src/telem/aether/static.d.ts +0 -1
  255. package/dist/src/telem/aether/telem.d.ts +0 -1
  256. package/dist/src/telem/aether/transformers.d.ts +0 -1
  257. package/dist/src/telem/client/cache/cache.d.ts +0 -1
  258. package/dist/src/telem/client/cache/dynamic.d.ts +0 -1
  259. package/dist/src/telem/client/cache/static.d.ts +0 -1
  260. package/dist/src/telem/client/cache/unary.d.ts +0 -1
  261. package/dist/src/telem/client/client.d.ts +0 -1
  262. package/dist/src/telem/client/reader.d.ts +0 -1
  263. package/dist/src/telem/client/streamer.d.ts +0 -1
  264. package/dist/src/telem/client/types.d.ts +0 -1
  265. package/dist/src/telem/control/Chip.d.ts +0 -1
  266. package/dist/src/telem/control/Controller.d.ts +0 -1
  267. package/dist/src/telem/control/Indicator.d.ts +0 -1
  268. package/dist/src/telem/control/Legend.d.ts +0 -1
  269. package/dist/src/telem/control/StateProvider.d.ts +0 -1
  270. package/dist/src/telem/control/aether/chip.d.ts +0 -1
  271. package/dist/src/telem/control/aether/controller.d.ts +0 -1
  272. package/dist/src/telem/control/aether/indicator.d.ts +0 -1
  273. package/dist/src/telem/control/aether/legend.d.ts +0 -1
  274. package/dist/src/telem/control/aether/registry.d.ts +0 -1
  275. package/dist/src/telem/control/aether/state.d.ts +0 -1
  276. package/dist/src/telem/test/mock.d.ts +0 -1
  277. package/dist/src/testutil/dom.d.ts +1 -2
  278. package/dist/src/testutil/dom.d.ts.map +1 -1
  279. package/dist/src/text/DateTime.d.ts +0 -1
  280. package/dist/src/text/Editable.d.ts +0 -1
  281. package/dist/src/text/Keyboard.d.ts +0 -1
  282. package/dist/src/text/Link.d.ts +0 -1
  283. package/dist/src/text/SelectLevel.d.ts +0 -1
  284. package/dist/src/text/Text.d.ts +0 -1
  285. package/dist/src/text/WithIcon.d.ts +0 -1
  286. package/dist/src/text/core/types.d.ts +0 -1
  287. package/dist/src/text/dimensions.d.ts +0 -1
  288. package/dist/src/text/index.d.ts +0 -1
  289. package/dist/src/text/symbols.d.ts +0 -1
  290. package/dist/src/theming/Provider.d.ts +0 -1
  291. package/dist/src/theming/aether/provider.d.ts +0 -1
  292. package/dist/src/theming/core/fontString.d.ts +0 -1
  293. package/dist/src/theming/core/theme.d.ts +0 -1
  294. package/dist/src/theming/css.d.ts +0 -1
  295. package/dist/src/theming/font.d.ts +0 -1
  296. package/dist/src/theming/index.d.ts +0 -1
  297. package/dist/src/tooltip/Config.d.ts +0 -1
  298. package/dist/src/tooltip/Dialog.d.ts +0 -1
  299. package/dist/src/tooltip/Dialog.d.ts.map +1 -1
  300. package/dist/src/tooltip/wrap.d.ts +0 -1
  301. package/dist/src/tree/Tree.d.ts +0 -1
  302. package/dist/src/tree/core.d.ts +1 -1
  303. package/dist/src/tree/core.d.ts.map +1 -1
  304. package/dist/src/triggers/Provider.d.ts +0 -1
  305. package/dist/src/triggers/Status.d.ts +0 -1
  306. package/dist/src/triggers/Text.d.ts +0 -1
  307. package/dist/src/triggers/hooks.d.ts +0 -1
  308. package/dist/src/triggers/triggers.d.ts +0 -1
  309. package/dist/src/triggers/useDrag.d.ts +0 -1
  310. package/dist/src/util/children.d.ts +0 -1
  311. package/dist/src/util/component.d.ts +0 -1
  312. package/dist/src/util/renderProp.d.ts +0 -1
  313. package/dist/src/util/zod.d.ts +0 -1
  314. package/dist/src/video/Video.d.ts +0 -1
  315. package/dist/src/viewport/Mask.d.ts +0 -1
  316. package/dist/src/viewport/SelectMode.d.ts +0 -1
  317. package/dist/src/viewport/use.d.ts +0 -1
  318. package/dist/src/vis/axis/axis.d.ts +0 -1
  319. package/dist/src/vis/axis/canvas.d.ts +0 -1
  320. package/dist/src/vis/axis/ticks.d.ts +0 -1
  321. package/dist/src/vis/button/aether/button.d.ts +0 -1
  322. package/dist/src/vis/button/use.d.ts +0 -1
  323. package/dist/src/vis/canvas/Canvas.d.ts +0 -1
  324. package/dist/src/vis/canvas/aether/canvas.d.ts +0 -1
  325. package/dist/src/vis/diagram/Diagram.d.ts +0 -1
  326. package/dist/src/vis/diagram/aether/Diagram.d.ts +0 -1
  327. package/dist/src/vis/diagram/align.d.ts +0 -1
  328. package/dist/src/vis/diagram/edge/Edge.d.ts +0 -1
  329. package/dist/src/vis/diagram/edge/connector/connector.d.ts +0 -1
  330. package/dist/src/vis/diagram/util.d.ts +0 -1
  331. package/dist/src/vis/draw2d/canvas.d.ts +0 -1
  332. package/dist/src/vis/draw2d/index.d.ts +0 -1
  333. package/dist/src/vis/eraser/aether/eraser.d.ts +0 -1
  334. package/dist/src/vis/eraser/use.d.ts +0 -1
  335. package/dist/src/vis/legend/Container.d.ts +0 -1
  336. package/dist/src/vis/legend/Simple.d.ts +0 -1
  337. package/dist/src/vis/legend/Simple.d.ts.map +1 -1
  338. package/dist/src/vis/line/Line.d.ts +0 -1
  339. package/dist/src/vis/line/aether/line.d.ts +0 -1
  340. package/dist/src/vis/lineplot/Axis.d.ts +0 -1
  341. package/dist/src/vis/lineplot/Legend.d.ts +0 -1
  342. package/dist/src/vis/lineplot/Line.d.ts +0 -1
  343. package/dist/src/vis/lineplot/LinePlot.d.ts +0 -1
  344. package/dist/src/vis/lineplot/Title.d.ts +0 -1
  345. package/dist/src/vis/lineplot/Viewport.d.ts +0 -1
  346. package/dist/src/vis/lineplot/aether/LinePlot.d.ts +0 -1
  347. package/dist/src/vis/lineplot/aether/XAxis.d.ts +0 -1
  348. package/dist/src/vis/lineplot/aether/YAxis.d.ts +0 -1
  349. package/dist/src/vis/lineplot/aether/axis.d.ts +0 -1
  350. package/dist/src/vis/lineplot/aether/grid.d.ts +0 -1
  351. package/dist/src/vis/lineplot/range/Annotation.d.ts +0 -1
  352. package/dist/src/vis/lineplot/range/Provider.d.ts +0 -1
  353. package/dist/src/vis/lineplot/range/aether/annotation.d.ts +0 -1
  354. package/dist/src/vis/lineplot/range/aether/external.d.ts +0 -1
  355. package/dist/src/vis/lineplot/range/aether/provider.d.ts +0 -1
  356. package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
  357. package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts +0 -1
  358. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts +0 -1
  359. package/dist/src/vis/measure/aether/measure.d.ts +0 -1
  360. package/dist/src/vis/render/GLProgram.d.ts +0 -1
  361. package/dist/src/vis/render/clear/program.d.ts +0 -1
  362. package/dist/src/vis/render/context.d.ts +0 -1
  363. package/dist/src/vis/render/controller.d.ts +0 -1
  364. package/dist/src/vis/render/eraser.d.ts +0 -1
  365. package/dist/src/vis/render/loop.d.ts +0 -1
  366. package/dist/src/vis/render/performance.d.ts +0 -1
  367. package/dist/src/vis/render/performance.d.ts.map +1 -1
  368. package/dist/src/vis/render/util.d.ts +0 -1
  369. package/dist/src/vis/rule/Rule.d.ts +0 -1
  370. package/dist/src/vis/rule/aether/aether.d.ts +0 -1
  371. package/dist/src/vis/schematic/Forms.d.ts +0 -1
  372. package/dist/src/vis/schematic/Labeled.d.ts +0 -1
  373. package/dist/src/vis/schematic/SelectOrientation.d.ts +0 -1
  374. package/dist/src/vis/schematic/Symbols.d.ts +0 -1
  375. package/dist/src/vis/schematic/primitives/Primitives.d.ts +0 -1
  376. package/dist/src/vis/schematic/registry.d.ts +0 -1
  377. package/dist/src/vis/setpoint/aether/setpoint.d.ts +0 -1
  378. package/dist/src/vis/setpoint/use.d.ts +0 -1
  379. package/dist/src/vis/toggle/aether/toggle.d.ts +0 -1
  380. package/dist/src/vis/toggle/use.d.ts +0 -1
  381. package/dist/src/vis/value/aether/value.d.ts +0 -1
  382. package/dist/src/vis/value/use.d.ts +0 -1
  383. package/dist/src/worker/Context.d.ts +0 -1
  384. package/dist/style.css +1 -1
  385. package/dist/tabs.cjs +1 -1
  386. package/dist/tabs.js +1 -1
  387. package/dist/text.cjs +1 -1
  388. package/dist/text.js +2 -2
  389. package/dist/theming.cjs +1 -1
  390. package/dist/theming.js +2 -2
  391. package/dist/tree.cjs +1 -1
  392. package/dist/tree.js +1 -1
  393. package/dist/triggers.cjs +1 -1
  394. package/dist/triggers.js +1 -1
  395. package/dist/{units-DNx3byGw.cjs → units-Bq69s424.cjs} +1 -1
  396. package/dist/{units-BREWRknL.js → units-BynnjwvA.js} +1 -1
  397. package/dist/video.cjs +1 -1
  398. package/dist/video.js +1 -1
  399. package/package.json +14 -14
  400. package/dist/LinePlot-Cm6T-Agy.cjs +0 -66
  401. package/dist/Link-CRvZcIvR.cjs +0 -1
  402. package/dist/Link-CfU1takx.js +0 -10
  403. package/dist/Toggle-YiHP9pVf.cjs +0 -143
  404. package/dist/aggregator-D9ExX_tt.cjs +0 -51
  405. package/dist/external-BgW4t-2y.cjs +0 -1
  406. package/dist/external-DSc2y4PB.cjs +0 -1
  407. package/dist/external-TgztmPvP.js +0 -231
@@ -0,0 +1,51 @@
1
+ "use strict";var tc=Object.defineProperty;var rc=(t,e,r)=>e in t?tc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var P=(t,e,r)=>rc(t,typeof e!="symbol"?e+"":e,r);const s=require("zod"),O=require("./css-B7TifAVb.cjs"),Gn=require("react");var nc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ic(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}const Ot=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var ac=Object.defineProperty,oc=(t,e,r)=>e in t?ac(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tt=(t,e,r)=>oc(t,typeof e!="symbol"?e+"":e,r);let cc=class{constructor(){Tt(this,"contentType","application/json"),Tt(this,"decoder"),Tt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=JSON.parse(e),i=O.T(n);return r!=null?r.parse(i):i}encodeString(e){const r=O.C(e);return JSON.stringify(r,(n,i)=>ArrayBuffer.isView(i)?Array.from(i):Ot(i)&&"encode_value"in i?typeof i.value=="bigint"?i.value.toString():i.value:typeof i=="bigint"?i.toString():i)}static registerCustomType(){}},lc=class{constructor(){Tt(this,"contentType","text/csv")}encode(e){const r=this.encodeString(e);return new TextEncoder().encode(r).buffer}decode(e,r){const n=new TextDecoder().decode(e);return this.decodeString(n,r)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Ot(e[0]))throw new Error("Payload must be an array of objects");const r=Object.keys(e[0]),n=[r.join(",")];return e.forEach(i=>{const a=r.map(o=>JSON.stringify(i[o]??""));n.push(a.join(","))}),n.join(`
2
+ `)}decodeString(e,r){const[n,...i]=e.trim().split(`
3
+ `).map(l=>l.trim());if(n.length===0)return r!=null?r.parse({}):{};const a=n.split(",").map(l=>l.trim()),o={};return a.forEach(l=>{o[l]=[]}),i.forEach(l=>{const u=l.split(",").map(d=>d.trim());a.forEach((d,f)=>{const h=this.parseValue(u[f]);h!=null&&o[d].push(h)})}),r!=null?r.parse(o):o}parseValue(e){if(e==null||e.length===0)return null;const r=Number(e);return isNaN(r)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:r}static registerCustomType(){}},uc=class{constructor(){Tt(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,r){const n=new TextDecoder().decode(e);return r!=null?r.parse(n):n}};const Qt=new cc;new lc;new uc;const Oi=t=>t!=null&&typeof t=="object"&&"toString"in t,hc=t=>{if(Oi(t))return(t==null?void 0:t.toString().length)===0;switch(typeof t){case"string":return t.length===0;case"number":return t===0;case"bigint":return t===0n;case"boolean":return!t;case"undefined":return!0;case"object":return t===null}},Br=(t,e=!1)=>{const r=Oi(t)?"stringer":typeof t;let n;switch(r){case"string":n=(i,a)=>i.localeCompare(a);break;case"stringer":n=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":n=(i,a)=>Number(i)-Number(a);break;case"bigint":n=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":n=(i,a)=>Number(i)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?Ti(n):n},dc=(t,e,r)=>{const n=Br(e[t],r);return(i,a)=>n(i[t],a[t])},fc=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,yc=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=Br(t[0]),n=[...t].sort(r),i=[...e].sort(r);return n.every((a,o)=>a===i[o])?0:-1},gc=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,Ti=t=>(e,r)=>t(r,e),pc=t=>t<0,mc=t=>t>0,wc=t=>t>=0,bc=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.-]+/g,"").match(r),i=e.replace(/[\s_.-]+/g,"").match(r);if(!n||!i)return 0;for(let a=0;a<Math.min(n.length,i.length);a++){const o=n[a],l=i[a];if(isNaN(Number(o))&&isNaN(Number(l))){const u=o.localeCompare(l);if(u!==0)return u}else if(!isNaN(Number(o))&&!isNaN(Number(l))){const u=Number(o)-Number(l);if(u!==0)return u}else return isNaN(Number(o))?-1:1}return n.length-i.length},vc=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:0,GREATER_THAN:1,LESS_THAN:-1,isGreaterThan:mc,isGreaterThanEqual:wc,isLessThan:pc,newF:Br,newFieldF:dc,order:gc,primitiveArrays:fc,reverseF:Ti,stringsWithNumbers:bc,unorderedPrimitiveArrays:yc},Symbol.toStringTag,{value:"Module"})),Oc=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Tc=(t,e)=>{let r=null;return e===0?t:(...n)=>{r===null&&(r=setTimeout(()=>{t(...n),r=null},e))}},Si=(t,e)=>{const r=t.split(".");return r.map((n,i)=>{const a=e(n,i,r);return a==null?null:typeof a=="string"?a:a.join(".")}).filter(n=>n!=null).join(".")},Zn=(t,e,r={optional:!1})=>{const{optional:n,getter:i=(l,u)=>l[u]}=r,a=e.split(".");if(a.length===1&&a[0]==="")return t;let o=t;for(const l of a){const u=i(o,l);if(u==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${l} is null`)}o=u}return o},Sc=(t,e,r)=>{const n=e.split(".");let i=t;for(let a=0;a<n.length-1;a++){const o=n[a];i[o]==null&&(i[o]={}),i=i[o]}i[n[n.length-1]]=r},zc=(t,e)=>{const r=e.split(".");let n=t;for(let i=0;i<r.length-1;i++){const a=r[i];if(n[a]==null)return;n=n[a]}if(Array.isArray(n)){const i=parseInt(r[r.length-1],10);if(isNaN(i))return;n.splice(i,1);return}delete n[r[r.length-1]]},Nc=(t,e)=>{const r=t.split(".");return e<0?r[r.length+e]:r[e]},Ec=(t,e)=>{try{return Zn(t,e),!0}catch{return!1}},Ic=(t,e)=>{if(e.length===0)return!0;const r=t.split("."),n=e.split(".");if(n.length>r.length)return!1;for(let i=0;i<n.length;i++){const a=r[i],o=n[i];if(o!=="*"&&a!==o)return!1}return!0},Ac=t=>JSON.parse(JSON.stringify(t)),kc=(t,...e)=>(e.forEach(r=>{let n=t;const i=r.split(".");i.forEach((a,o)=>{o===i.length-1?delete n[a]:a in n&&(n=n[a])})}),t),xc=(t,e,r="")=>{const n={},i=(a,o,l)=>{if(typeof a!=typeof o||a===null||o===null){n[l]=[a,o];return}if(typeof a=="object"&&typeof o=="object")if(Array.isArray(a)&&Array.isArray(o)){if(a.length!==o.length){n[l]=[a,o];return}for(let u=0;u<a.length;u++)i(a[u],o[u],`${l}[${u}]`)}else new Set([...Object.keys(a),...Object.keys(o)]).forEach(u=>{i(a[u],o[u],l!==""?`${l}.${u}`:u)});else a!==o&&(n[l]=[a,o])};return i(t,e,r),n},Sn=(t,e)=>{const r=Array.isArray(t),n=Array.isArray(e);if(r!==n)return!1;if(r&&n){const o=t,l=e;if(o.length!==l.length)return!1;for(let u=0;u<o.length;u++)if(!Sn(o[u],l[u]))return!1;return!0}if(t==null||e==null||typeof t!="object"||typeof e!="object")return t===e;if("equals"in t)return t.equals(e);const i=Object.keys(t),a=Object.keys(e);if(i.length!==a.length)return!1;for(const o of i){const l=t[o],u=e[o];if(typeof l=="object"&&typeof u=="object"){if(!Sn(l,u))return!1}else if(l!==u)return!1}return!0},zi=(t,e)=>{if(typeof t!="object"||t==null)return t===e;const r=Object.keys(t),n=Object.keys(e);if(n.length>r.length)return!1;for(const i of n){const a=t[i],o=e[i];if(typeof a=="object"&&typeof o=="object"){if(!zi(a,o))return!1}else if(a!==o)return!1}return!0},zn=(t,...e)=>{if(e.length===0)return t;const r=e.shift();if(Ot(t)&&Ot(r))for(const n in r)try{Ot(r[n])?(n in t||Object.assign(t,{[n]:{}}),zn(t[n],r[n])):Object.assign(t,{[n]:r[n]})}catch(i){throw i instanceof TypeError?new TypeError(`.${n}: ${i.message}`):i}return zn(t,...e)},Cc=(t,e,r)=>{const n=(i,a,o)=>{for(const l in a){const u=a[l];if(o!=null&&o.shape[l]){const d=o.shape[l].safeParse(u);d.success&&(i[l]=d.data)}else typeof u=="object"&&!Array.isArray(u)&&u!==null&&o&&o.shape&&o.shape[l]&&(i[l]||(i[l]={}),n(i[l],u,o.shape[l]))}return i};return n({...t},e,r)},Ni=Object.freeze(Object.defineProperty({__proto__:null,copy:Ac,deleteD:kc,difference:xc,element:Nc,equal:Sn,get:Zn,has:Ec,override:zn,overrideValidItems:Cc,partialEqual:zi,pathsMatch:Ic,remove:zc,set:Sc,transformPath:Si},Symbol.toStringTag,{value:"Module"}));var Rc=Object.defineProperty,jc=(t,e,r)=>e in t?Rc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,m=(t,e,r)=>jc(t,typeof e!="symbol"?e+"":e,r);let $c=(t,e=21)=>(r=e)=>{let n="",i=r;for(;i--;)n+=t[Math.random()*t.length|0];return n};const Mc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ei=$c(Mc,11),Dc=Object.freeze(Object.defineProperty({__proto__:null,id:Ei},Symbol.toStringTag,{value:"Module"})),Ii=(t,e)=>{const r=new _(e);if(![G.DAY,G.HOUR,G.MINUTE,G.SECOND,G.MILLISECOND,G.MICROSECOND,G.NANOSECOND].some(i=>i.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof _?new _(n):new G(n)},B=class T{constructor(e,r="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=T.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*T.MILLISECOND.valueOf();else if(typeof e=="string")this.value=T.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=T.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=T.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=T.MAX:e=T.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const i=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(i.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=T.hours(parseInt(n??"00",10)).add(T.minutes(parseInt(i??"00",10))).add(T.seconds(parseInt(o??"00",10))).add(T.milliseconds(parseInt(l??"00",10)));return r==="local"&&(u=u.add(T.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return T.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new T(BigInt(n.getTime())*T.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(T.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new G(BigInt(new Date().getTimezoneOffset())*T.MINUTE.valueOf())}static since(e){return new T().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new T(e).valueOf()}span(e){return this.range(e).span}range(e){return new At(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 T(e).valueOf()}afterEq(e){return this.valueOf()>=new T(e).valueOf()}before(e){return this.valueOf()<new T(e).valueOf()}beforeEq(e){return this.valueOf()<=new T(e).valueOf()}add(e){return new T(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new T(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Ii(this,e)}get isToday(){return this.truncate(G.DAY).equals(T.now().truncate(G.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new T(new Date)}static max(...e){let r=T.MIN;for(const n of e){const i=new T(n);i.after(r)&&(r=i)}return r}static min(...e){let r=T.MAX;for(const n of e){const i=new T(n);i.before(r)&&(r=i)}return r}static nanoseconds(e){return new T(e)}static microseconds(e){return T.nanoseconds(e*1e3)}static milliseconds(e){return T.microseconds(e*1e3)}static seconds(e){return T.milliseconds(e*1e3)}static minutes(e){return T.seconds(e*60)}static hours(e){return T.minutes(e*60)}static days(e){return T.hours(e*24)}};m(B,"NANOSECOND",B.nanoseconds(1)),m(B,"MICROSECOND",B.microseconds(1)),m(B,"MILLISECOND",B.milliseconds(1)),m(B,"SECOND",B.seconds(1)),m(B,"MINUTE",B.minutes(1)),m(B,"HOUR",B.hours(1)),m(B,"DAY",B.days(1)),m(B,"MAX",new B((1n<<63n)-1n)),m(B,"MIN",new B(0)),m(B,"ZERO",new B(0)),m(B,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new B(t.value)),s.z.string().transform(t=>new B(BigInt(t))),s.z.instanceof(Number).transform(t=>new B(t)),s.z.number().transform(t=>new B(t)),s.z.instanceof(B)]));let _=B;const U=class k{constructor(e){m(this,"value"),m(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}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 Ii(this,e)}truncate(e){return new k(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(k.DAY),r=this.truncate(k.HOUR),n=this.truncate(k.MINUTE),i=this.truncate(k.SECOND),a=this.truncate(k.MILLISECOND),o=this.truncate(k.MICROSECOND),l=this.truncate(k.NANOSECOND),u=e,d=r.sub(e),f=n.sub(r),h=i.sub(n),D=a.sub(i),W=o.sub(a),se=l.sub(o);let j="";return u.isZero||(j+=`${u.days}d `),d.isZero||(j+=`${d.hours}h `),f.isZero||(j+=`${f.minutes}m `),h.isZero||(j+=`${h.seconds}s `),D.isZero||(j+=`${D.milliseconds}ms `),W.isZero||(j+=`${W.microseconds}µs `),se.isZero||(j+=`${se.nanoseconds}ns`),j.trim()}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(e*1e3)}static milliseconds(e=1){return k.microseconds(e*1e3)}static seconds(e=1){return k.milliseconds(e*1e3)}static minutes(e){return k.seconds(e.valueOf()*60)}static hours(e){return k.minutes(e*60)}static days(e){return k.hours(e*24)}};m(U,"NANOSECOND",U.nanoseconds(1)),m(U,"MICROSECOND",U.microseconds(1)),m(U,"MILLISECOND",U.milliseconds(1)),m(U,"SECOND",U.seconds(1)),m(U,"MINUTE",U.minutes(1)),m(U,"HOUR",U.hours(1)),m(U,"DAY",U.days(1)),m(U,"MAX",new U((1n<<63n)-1n)),m(U,"MIN",new U(0)),m(U,"ZERO",new U(0)),m(U,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new U(t.value)),s.z.string().transform(t=>new U(BigInt(t))),s.z.instanceof(Number).transform(t=>new U(t)),s.z.number().transform(t=>new U(t)),s.z.instanceof(U)]));let G=U;const ot=class er extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new er(e).valueOf()}get period(){return G.seconds(1/this.valueOf())}sampleCount(e){return new G(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new ce(r).valueOf()}span(e){return G.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new er(e)}static khz(e){return er.hz(e*1e3)}};m(ot,"z",s.z.union([s.z.number().transform(t=>new ot(t)),s.z.instanceof(Number).transform(t=>new ot(t)),s.z.instanceof(ot)]));let Pc=ot;const X=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ur(e*this.valueOf())}};m(X,"UNKNOWN",new X(0)),m(X,"BIT128",new X(16)),m(X,"BIT64",new X(8)),m(X,"BIT32",new X(4)),m(X,"BIT16",new X(2)),m(X,"BIT8",new X(1)),m(X,"z",s.z.union([s.z.number().transform(t=>new X(t)),s.z.instanceof(Number).transform(t=>new X(t)),s.z.instanceof(X)]));let ce=X;const ve=class tr{constructor(e,r){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 _(r))}get span(){return new G(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 tr(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,r=G.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const i=_.max(n.start,e.start),a=_.min(n.end,e.end);return a.before(i)?!1:new G(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof tr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new tr(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};m(ve,"MAX",new ve(_.MIN,_.MAX)),m(ve,"MIN",new ve(_.MAX,_.MIN)),m(ve,"ZERO",new ve(_.ZERO,_.ZERO)),m(ve,"z",s.z.union([s.z.object({start:_.z,end:_.z}).transform(t=>new ve(t.start,t.end)),s.z.instanceof(ve)]));let At=ve;const y=class Oe extends String{constructor(e){if(e instanceof Oe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Oe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Oe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Oe.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(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(Oe.JSON)||this.equals(Oe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Oe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Oe.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!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 Oe.BIG_INT_TYPES.some(e=>e.equals(this))}};m(y,"UNKNOWN",new y("unknown")),m(y,"FLOAT64",new y("float64")),m(y,"FLOAT32",new y("float32")),m(y,"INT64",new y("int64")),m(y,"INT32",new y("int32")),m(y,"INT16",new y("int16")),m(y,"INT8",new y("int8")),m(y,"UINT64",new y("uint64")),m(y,"UINT32",new y("uint32")),m(y,"UINT16",new y("uint16")),m(y,"UINT8",new y("uint8")),m(y,"BOOLEAN",y.UINT8),m(y,"TIMESTAMP",new y("timestamp")),m(y,"UUID",new y("uuid")),m(y,"STRING",new y("string")),m(y,"JSON",new y("json")),m(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),m(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),m(y,"DENSITIES",new Map([[y.UINT8.toString(),ce.BIT8],[y.UINT16.toString(),ce.BIT16],[y.UINT32.toString(),ce.BIT32],[y.UINT64.toString(),ce.BIT64],[y.FLOAT32.toString(),ce.BIT32],[y.FLOAT64.toString(),ce.BIT64],[y.INT8.toString(),ce.BIT8],[y.INT16.toString(),ce.BIT16],[y.INT32.toString(),ce.BIT32],[y.INT64.toString(),ce.BIT64],[y.TIMESTAMP.toString(),ce.BIT64],[y.STRING.toString(),ce.UNKNOWN],[y.JSON.toString(),ce.UNKNOWN],[y.UUID.toString(),ce.BIT128]])),m(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),m(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),m(y,"z",s.z.union([s.z.string().transform(t=>new y(t)),s.z.instanceof(y)]));let $=y;const ie=class V extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return V.bytes(this.valueOf()+e.valueOf())}sub(e){return V.bytes(this.valueOf()-e.valueOf())}truncate(e){return new V(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return V.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/V.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/V.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/V.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/V.TERABYTE.valueOf()}toString(){const e=this.truncate(V.TERABYTE),r=this.truncate(V.GIGABYTE),n=this.truncate(V.MEGABYTE),i=this.truncate(V.KILOBYTE),a=this.truncate(V.BYTE),o=e,l=r.sub(e),u=n.sub(r),d=i.sub(n),f=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),d.isZero||(h+=`${d.kilobytes}KB `),(!f.isZero||h==="")&&(h+=`${f.valueOf()}B`),h.trim()}static bytes(e=1){return new V(e)}static kilobytes(e=1){return V.bytes(e.valueOf()*1e3)}static megabytes(e=1){return V.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return V.megabytes(e.valueOf()*1e3)}static terabytes(e){return V.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(ie,"BYTE",new ie(1)),m(ie,"KILOBYTE",ie.kilobytes(1)),m(ie,"MEGABYTE",ie.megabytes(1)),m(ie,"GIGABYTE",ie.gigabytes(1)),m(ie,"TERABYTE",ie.terabytes(1)),m(ie,"ZERO",new ie(0)),m(ie,"z",s.z.union([s.z.number().transform(t=>new ie(t)),s.z.instanceof(ie)]));let Ur=ie;const Bc=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)]),Ai=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof _||t instanceof G||t instanceof Date},Uc=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):ct(r,-n),Lc=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof ki?!0:Ai(t),Le=-1;let ki=class Ie{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",Le),m(this,"_refCount",0),m(this,"_cachedLength"),Lc(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:l=Ei()}=e,{data:u}=e;if(u instanceof Ie||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const h=u;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const d=Ai(u),f=Array.isArray(u);if(r!=null)this.dataType=new $(r);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||d){let h=u;if(!d){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.");h=u[0]}if(typeof h=="string")this.dataType=$.STRING;else if(typeof h=="number")this.dataType=$.FLOAT64;else if(typeof h=="bigint")this.dataType=$.INT64;else if(typeof h=="boolean")this.dataType=$.BOOLEAN;else if(h instanceof _||h instanceof Date||h instanceof _)this.dataType=$.TIMESTAMP;else if(typeof h=="object")this.dataType=$.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new $(u)}if(!f&&!d)this._data=u;else{let h=d?[u]:u;const D=h[0];(D instanceof _||D instanceof Date||D instanceof G)&&(h=h.map(W=>new _(W).valueOf())),this.dataType.equals($.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
4
+ `)+`
5
+ `)):this.dataType.equals($.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(W=>Qt.encodeString(W)).join(`
6
+ `)+`
7
+ `)):this._data=new this.dataType.Array(h).buffer}this.key=l,this.alignment=o,this.sampleOffset=i??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new $(r).Array(e),a=new Ie({data:i.buffer,dataType:r,...n});return a.writePos=0,a}static generateTimestamps(e,r,n){const i=n.spanRange(r.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(r.span(o)).valueOf());return new Ie({data:a,dataType:$.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
8
+ `)+`
9
+ `);return new Ie({data:n,dataType:$.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(i=>Qt.encodeString(i)).join(`
10
+ `)+`
11
+ `);return new Ie({data:n,dataType:$.JSON,timeRange:r})}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");if(this.writePos===Le)return 0;const r=this.capacity-this.writePos,n=r<e.length?e.slice(0,r):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Le?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches($.STRING,$.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
12
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals($.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=$.UUID.density.valueOf(),r=Array(this.length);for(let n=0;n<this.length;n++){const i=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=a}return r}parseJSON(e){if(!this.dataType.equals($.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
13
+ `).slice(0,-1).map(r=>e.parse(Qt.decodeString(r)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Ur(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Le?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Le?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;return this.data.forEach(r=>{r===10&&e++}),this._cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let i=0;i<this.length;i++)n[i]=Uc(this.dataType,e,this.data[i],r);return new Ie({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals($.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}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==null&&(this._cachedMax=this.calcRawMax()),ct(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals($.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}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==null&&(this._cachedMin=this.calcRawMin()),ct(this._cachedMin,this.sampleOffset))}get bounds(){return O.o(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const r=e._cachedMin??e.calcRawMin();r<this._cachedMin&&(this._cachedMin=r)}if(this._cachedMax!=null){const r=e._cachedMax??e.calcRawMax();r>this._cachedMax&&(this._cachedMax=r)}}enrich(){this.max,this.min}get range(){return ct(this.max,-this.min)}at(e,r){if(this.dataType.isVariable)return this.atVariable(e,r??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return ct(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,i=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){i=o;break}n=o+1,e--}if(i===0&&(i=this.data.length),n>=i||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,i);return this.dataType.equals($.STRING)?new TextDecoder().decode(a):O.T(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let r=0,n=this.length-1;const i=Br(e);for(;r<=n;){const a=Math.floor((r+n)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?r=a+1:n=a-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals($.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:i}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Le){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,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Le}as(e){if(e==="string"){if(!this.dataType.equals($.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals($.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,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 O.o(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 Yc(this);return this.dataType.equals($.JSON)?new qc(e):e}return new Fc(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new Ie({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new Ie({data:this.buffer,dataType:this.dataType,timeRange:At.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}},Yc=class{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,r=this.series.data;for(;this.index<r.length&&r[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}};var Ns,Es;let qc=class{constructor(e){m(this,"wrapped"),m(this,Ns,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Qt.decodeString(e.value)}}[(Es=Symbol.iterator,Ns=Symbol.toStringTag,Es)](){return this}};var Is,As;class Fc{constructor(e){m(this,"series"),m(this,"index"),m(this,Is,"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)}}[(As=Symbol.iterator,Is=Symbol.toStringTag,As)](){return this}}const ct=(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);let _c=class{constructor(e){if(m(this,"series"),e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new $(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?$.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?At.ZERO:new At(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,r)=>e+r.length,0)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new Ur(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Wc(this.series)}};var ks,xs;let Wc=class{constructor(e){m(this,"series"),m(this,"seriesIndex"),m(this,"internal"),m(this,ks,"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())}[(xs=Symbol.iterator,ks=Symbol.toStringTag,xs)](){return this}};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 xi=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Gc=xi(),Ci=["MacOS","Windows","Linux","Docker"],Zc=s.z.enum(Ci);let Qr;const Vc=()=>{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"},Kc=(t={})=>{const{force:e,default:r}=t;return e??Qr??(Qr=Vc(),Qr??r)},Ri=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Ci,RUNTIME:Gc,detect:xi,getOS:Kc,osZ:Zc},Symbol.toStringTag,{value:"Module"})),Jc=t=>Array.isArray(t)?t:[t],Hc=t=>Array.isArray(t)?t:t===null?[]:[t],Xc=t=>[...new Set(t)];var Qc=Object.defineProperty,el=(t,e,r)=>e in t?Qc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,lt=(t,e,r)=>el(t,typeof e!="symbol"?e+"":e,r);const tl=(...t)=>t.map(ji).join(""),ji=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),rl=t=>t.endsWith("/")?t.slice(0,-1):t,Cs=class Nn{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){lt(this,"protocol"),lt(this,"host"),lt(this,"port"),lt(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=ji(i)}replace(e){return new Nn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Nn({...this,pathPrefix:tl(this.path,e)})}toString(){return rl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};lt(Cs,"UNKNOWN",new Cs({host:"unknown",port:0}));var nl=Object.defineProperty,sl=(t,e,r)=>e in t?nl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ar=(t,e,r)=>sl(t,typeof e!="symbol"?e+"":e,r);let il=class{constructor(e){Ar(this,"sender"),Ar(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var r;const n=(r=this.handlers.get(e.type))==null?void 0:r.handler;n==null?console.warn(`No handler for ${e.type}`):n(e.payload)}route(e){const r=al(e,this.sender),n=new ol(r);return this.handlers.set(e,n),n}};const al=(t,e)=>(r,n)=>e({type:t,payload:r},n);let ol=class{constructor(e){Ar(this,"_send"),Ar(this,"handler"),this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}};var cl=Object.defineProperty,ll=(t,e,r)=>e in t?cl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rr=(t,e,r)=>ll(t,typeof e!="symbol"?e+"":e,r);const qe=class extends Number{};rr(qe,"Absolute",255),rr(qe,"Default",1),rr(qe,"z",s.z.union([s.z.instanceof(qe),s.z.number().int().min(0).max(255).transform(t=>new qe(t)),s.z.instanceof(Number).transform(t=>new qe(t))]));let $i=qe;const Mi=s.z.object({name:s.z.string(),key:s.z.string()}),ul=t=>s.z.object({subject:Mi,resource:t,authority:$i.z}),hl=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),dl=Object.freeze(Object.defineProperty({__proto__:null,Authority:$i,filterTransfersByChannelKey:hl,stateZ:ul,subjectZ:Mi},Symbol.toStringTag,{value:"Module"})),Di=class ut extends Error{constructor(){super(ut.MESSAGE)}matches(e){return typeof e=="string"?e.includes(ut.MESSAGE):e instanceof ut||e.message.includes(ut.MESSAGE)}};rr(Di,"MESSAGE","canceled");let fl=Di;new fl;const yl=t=>t?-1:1;s.z.string().regex(/^\d+\.\d+\.\d+$/);const gl=t=>{if(t===void 0||typeof t=="string"||typeof t=="number")return t;if(t.toString===void 0)throw new Error("invalid renderer");return t.toString()},pl=t=>Array.isArray(t)?[...t]:typeof t=="object"&&t!==null?{...t}:t,Vn=t=>typeof t=="function",Kn=(t,e)=>Vn(t)?t(e):t,Mt=t=>Pi(t)?t():t,Pi=t=>typeof t=="function",Bi=({initial:t,value:e,onChange:r})=>{const[n,i]=Gn.useState(Mt(e??t));return e!=null&&r!=null?[e,r]:[n,i]},Ui=({initial:t,value:e,onChange:r})=>{const[n,i]=Gn.useState(Mt(e??t));return e!=null&&r!=null?[e,r]:[n,i]},ml=(t,e)=>{const[r,n]=Gn.useState(()=>{const i=localStorage.getItem(e);return i==null?Mt(t):JSON.parse(i)});return[r,i=>{n(i),localStorage.setItem(e,JSON.stringify(i))}]},wl=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:Mt,executeSetter:Kn,isInitialSetter:Pi,isSetter:Vn,usePassthrough:Bi,usePersisted:ml,usePurePassthrough:Ui},Symbol.toStringTag,{value:"Module"})),Li=["h1","h2","h3","h4","h5","p","small"],bl=s.z.enum(Li),Me=s.z.object({size:s.z.number(),weight:s.z.union([s.z.number(),s.z.string()]),lineHeight:s.z.number(),textTransform:s.z.string().optional()}),Yi={small:"small",medium:"p",large:"h5",huge:"h2"},vl={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"};let en=null;const Ol=()=>(en==null&&(en=document.createElement("canvas")),en),Tl=(t,e,r)=>{if(Ri.RUNTIME==="node")return{width:0,height:0};r==null&&(r=Ol().getContext("2d")),r.font=e;const n=r.measureText(t);return{width:Math.trunc(Math.abs(n.actualBoundingBoxLeft)+Math.abs(n.actualBoundingBoxRight)),height:Math.trunc(Math.abs(n.actualBoundingBoxAscent)+Math.abs(n.actualBoundingBoxDescent))}},Sl=s.z.object({l0:O.Color.z,l1:O.Color.z,l2:O.Color.z,l3:O.Color.z,l4:O.Color.z,l5:O.Color.z,l6:O.Color.z,l7:O.Color.z,l8:O.Color.z,l9:O.Color.z,l10:O.Color.z}),ge=(t,e)=>[t[0],t[1],e,t[3]],zl=s.z.object({m2:O.Color.z,m1:O.Color.z,z:O.Color.z,p1:O.Color.z,p2:O.Color.z}),_t=zl.or(O.Color.z.transform(t=>{const e=t.hsla;return{m2:new O.Color(O.fromHSLA(ge(e,40))),m1:new O.Color(O.fromHSLA(ge(e,45))),z:t,p1:new O.Color(O.fromHSLA(ge(e,55))),p2:new O.Color(O.fromHSLA(ge(e,65)))}})),qi=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:O.Color.z,primary:_t,gray:Sl,error:_t,secondary:_t,warning:_t,visualization:s.z.object({palettes:s.z.record(s.z.array(O.Color.z))}).optional().default({palettes:{}}),white:O.Color.z,black:O.Color.z,text:O.Color.z,textInverted:O.Color.z,textOnPrimary:O.Color.z.optional().default(O.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()}),schematic:s.z.object({elementStrokeWidth:s.z.number()})}),typography:s.z.object({family:s.z.string(),h1:Me,h2:Me,h3:Me,h4:Me,h5:Me,p:Me,small:Me})}).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)),Nl="'Inter Variable', sans-serif",El=6,nt=[357,91,55,1],st=[42,100,50,1],Il=["#FCFCFC","#F9F9F9","#F4F4F4","#ededed","#d9d9d9","#ADADAD","#878787","#616161","#404040","#1C1C1C","#050505"],Wt=Object.fromEntries(Il.map((t,e)=>[`l${e}`,t])),En={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#164FA0",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:Wt,border:Wt.l3,error:{m2:O.fromHSLA(ge(nt,30)),m1:O.fromHSLA(ge(nt,40)),z:O.fromHSLA(nt),p1:O.fromHSLA(ge(nt,65)),p2:O.fromHSLA(ge(nt,77))},warning:{m2:O.fromHSLA(ge(st,30)),m1:O.fromHSLA(ge(st,40)),z:O.fromHSLA(st),p1:O.fromHSLA(ge(st,65)),p2:O.fromHSLA(ge(st,75))},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:Wt.l9,textInverted:Wt.l0},sizes:{base:El,border:{radius:3,width:1},schematic:{elementStrokeWidth:2}},typography:{family:Nl,h1:{size:7,weight:"500",lineHeight:7*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.5,weight:"medium",lineHeight:2.5*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:1.9166666*1.5}}},Fi=Object.freeze({...En,key:"synnaxLight",name:"Synnax Light"}),Al=["#020202","#080808","#141414","#1a1a1a","#242424","#515151","#7f7f7f","#9D9D9D","#BFBFBF","#EDEDED","#FDFDFD"],Gt=Object.fromEntries(Al.map((t,e)=>[`l${e}`,t])),_i=Object.freeze({...En,key:"synnaxDark",name:"Synnax Dark",colors:{...En.colors,gray:Gt,logo:"var(--pluto-text-color)",border:Gt.l3,text:Gt.l9,textInverted:Gt.l0}}),kl={synnaxDark:_i,synnaxLight:Fi},xl=["small","medium","large","huge"],Cl=s.z.enum(xl),Rl=t=>Cl.safeParse(t).success,jl=(t,e,r)=>{const{typography:n,sizes:{base:i}}=t,a=n[Rl(e)?Yi[e]:e].size,o=i*a,[l,u]=n.family.split(", ");return r!=null?` ${r} ${o}px ${l}, ${u}`:` ${o}px ${n.family}`};var $l=Object.defineProperty,Ml=(t,e,r)=>e in t?$l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e,r)=>Ml(t,typeof e!="symbol"?e+"":e,r),Dl=Object.defineProperty,Pl=(t,e,r)=>e in t?Dl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,M=(t,e,r)=>Pl(t,typeof e!="symbol"?e+"":e,r);const Bl=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()?e:e[0].toLowerCase()+e.slice(1)},Wi=t=>{const e=(r,n=In)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!tn(r))return r;n=ql(n);const i={},a=r;return Object.keys(a).forEach(o=>{let l=a[o];const u=t(o);n.recursive&&(tn(l)?js(l,n.keepTypesOnRecursion)||(l=e(l,n)):n.recursiveInArray&&Rs(l)&&(l=[...l].map(d=>{let f=d;return tn(d)?js(f,n.keepTypesOnRecursion)||(f=e(d,n)):Rs(d)&&(f=e({key:d},n).key),f}))),i[u]=l}),i};return e},Ul=Wi(Bl),Ll=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Yl=Wi(Ll),In={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},ql=(t=In)=>(t.recursive==null?t=In:t.recursiveInArray==null&&(t.recursiveInArray=!1),t),Rs=t=>t!=null&&Array.isArray(t),tn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),js=(t,e)=>(e||[]).some(r=>t instanceof r),Gi=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var Fl=Object.defineProperty,_l=(t,e,r)=>e in t?Fl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,St=(t,e,r)=>_l(t,typeof e!="symbol"?e+"":e,r);let Wl=class{constructor(){St(this,"contentType","application/json"),St(this,"decoder"),St(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 r=JSON.parse(t),n=Ul(r);return e!=null?e.parse(n):n}encodeString(t){const e=Yl(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):Gi(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},Gl=class{constructor(){St(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,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]),r=[e.join(",")];return t.forEach(n=>{const i=e.map(a=>JSON.stringify(n[a]??""));r.push(i.join(","))}),r.join(`
14
+ `)}decodeString(t,e){const[r,...n]=t.trim().split(`
15
+ `).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),n.forEach(o=>{const l=o.split(",").map(u=>u.trim());i.forEach((u,d)=>{const f=this.parseValue(l[d]);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(){}},Zl=class{constructor(){St(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const r=new TextDecoder().decode(t);return e!=null?e.parse(r):r}};new Wl;new Gl;new Zl;const Lr=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()}),Vl=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Kl=["width","height"];s.z.enum(Kl);const Jl=["start","center","end"],Hl=["signedWidth","signedHeight"];s.z.enum(Hl);const kr=s.z.object({x:s.z.number(),y:s.z.number()}),Xl=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Ql=["x","y"],Vi=s.z.enum(Ql),Ki=["top","right","bottom","left"];s.z.enum(Ki);const eu=["left","right"],Ji=s.z.enum(eu),tu=["top","bottom"],Hi=s.z.enum(tu),Xi=["center"],$s=s.z.enum(Xi),ru=[...Ki,...Xi],Qi=s.z.enum(ru);s.z.enum(Jl);const nu=["first","last"];s.z.enum(nu);const su=s.z.object({lower:s.z.number(),upper:s.z.number()}),iu=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([su,Lr]);s.z.union([iu,Lr]);s.z.union([Vi,Qi]);s.z.union([Vi,Qi,s.z.instanceof(String)]);const rn=(t,e)=>{const r={};if(typeof t=="number"||typeof t=="bigint")e!=null?(r.lower=t,r.upper=e):(r.lower=typeof t=="bigint"?0n:0,r.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=t}else return Ms(t);return Ms(r)},Ms=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;s.z.object({x:Ji.or($s),y:Hi.or($s)});const au=s.z.object({x:Ji,y:Hi}),ou=Object.freeze({x:"left",y:"top"}),cu=(t,e)=>t.x===e.x&&t.y===e.y,Ds=s.z.union([s.z.number(),kr,Lr,Zi,Vl,Xl]),lu=(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}},Ps=Object.freeze({x:0,y:0}),Zt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Zt,left:Zt,width:Zt,height:Zt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:kr,two:kr,root:au});const Jn=(t,e,r=0,n=0,i)=>{const a={one:{...Ps},two:{...Ps},root:i??ou};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+r,y:a.one.y+n},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+r,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+r}:"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))},nn=t=>{const e=Jn(t);return{lower:e.one.x,upper:e.two.x}},sn=t=>{const e=Jn(t);return{lower:e.one.y,upper:e.two.y}},uu=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t;var hu=Object.defineProperty,du=(t,e,r)=>e in t?hu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ce=(t,e,r)=>du(t,typeof e!="symbol"?e+"":e,r);const fu=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:Ds,scale:Ds});const yu=t=>(e,r,n,i)=>r==="dimension"?[e,n]:[e,i?n-t:n+t],gu=t=>(e,r,n,i)=>[e,i?n/t:n*t],pu=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:i,upper:a}=e,{lower:o,upper:l}=t,u=a-i,d=l-o;if(r==="dimension")return[t,n*(d/u)];const f=(n-i)*(d/u)+o;return[t,f]},mu=t=>(e,r,n)=>[t,n],wu=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:i}=t;return[t,i-(r-n)]},bu=t=>(e,r,n)=>{const{lower:i,upper:a}=t;return n=fu(n,i,a),[e,n]},An=class ht{constructor(){Ce(this,"ops",[]),Ce(this,"currBounds",null),Ce(this,"currType",null),Ce(this,"reversed",!1),this.ops=[]}static translate(e){return new ht().translate(e)}static magnify(e){return new ht().magnify(e)}static scale(e,r){return new ht().scale(e,r)}translate(e){const r=this.new(),n=yu(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=gu(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=rn(e,r),i=this.new(),a=pu(n);return a.type="scale",i.ops.push(a),i}clamp(e,r){const n=rn(e,r),i=this.new(),a=bu(n);return a.type="clamp",i.ops.push(a),i}reBound(e,r){const n=rn(e,r),i=this.new(),a=mu(n);return a.type="re-bound",i.ops.push(a),i}invert(){const e=wu();e.type="invert";const r=this.new();return r.ops.push(e),r}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,r){return this.currBounds=null,this.ops.reduce(([n,i],a)=>a(n,e,i,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,i)=>{if(n.type==="scale"||r.some(([o,l])=>i>=o&&i<=l))return;const a=e.ops.findIndex((o,l)=>o.type==="scale"&&l>i);a!==-1&&r.push([i,a])}),r.forEach(([n,i])=>{const a=e.ops.slice(n,i);a.unshift(e.ops[i]),e.ops.splice(n,i-n+1,...a)}),e.reversed=!e.reversed,e}};Ce(An,"IDENTITY",new An);let Bs=An;const Us=class Ae{constructor(e=new Bs,r=new Bs,n=null){Ce(this,"x"),Ce(this,"y"),Ce(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ae().translate(e,r)}static translateX(e){return new Ae().translateX(e)}static translateY(e){return new Ae().translateY(e)}static clamp(e){return new Ae().clamp(e)}static magnify(e){return new Ae().magnify(e)}static scale(e){return new Ae().scale(e)}static reBound(e){return new Ae().reBound(e)}translate(e,r){const n=lu(e,r),i=this.copy();return i.x=this.x.translate(n.x),i.y=this.y.translate(n.y),i}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(uu(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!cu(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(nn(e)),r.y=r.y.scale(sn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(nn(e)),r.y=this.y.reBound(sn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(nn(e)),r.y=this.y.clamp(sn(e)),r}copy(){const e=new Ae;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)}}box(e){return Jn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Ce(Us,"IDENTITY",new Us);const vu=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([Zi,vu,kr,Lr]);var Ou=Object.defineProperty,Tu=(t,e,r)=>e in t?Ou(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,b=(t,e,r)=>Tu(t,typeof e!="symbol"?e+"":e,r);const ea=(t,e)=>{const r=new te(e);if(![re.DAY,re.HOUR,re.MINUTE,re.SECOND,re.MILLISECOND,re.MICROSECOND,re.NANOSECOND].some(i=>i.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof te?new te(n):new re(n)},L=class S{constructor(e,r="UTC"){if(b(this,"value"),b(this,"encodeValue",!0),e==null)this.value=S.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*S.MILLISECOND.valueOf();else if(typeof e=="string")this.value=S.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=S.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=S.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=S.MAX:e=S.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const i=new Date(e,r-1,n,0,0,0,0);return new S(BigInt(i.getTime())*S.MILLISECOND.valueOf()).truncate(S.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=S.hours(parseInt(n??"00",10)).add(S.minutes(parseInt(i??"00",10))).add(S.seconds(parseInt(o??"00",10))).add(S.milliseconds(parseInt(l??"00",10)));return r==="local"&&(u=u.add(S.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return S.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new S(BigInt(n.getTime())*S.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(S.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new re(BigInt(new Date().getTimezoneOffset())*S.MINUTE.valueOf())}static since(e){return new S().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new S(e).valueOf()}span(e){return this.range(e).span}range(e){return new Su(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 S(e).valueOf()}afterEq(e){return this.valueOf()>=new S(e).valueOf()}before(e){return this.valueOf()<new S(e).valueOf()}beforeEq(e){return this.valueOf()<=new S(e).valueOf()}add(e){return new S(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new S(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(S.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ea(this,e)}get isToday(){return this.truncate(re.DAY).equals(S.now().truncate(re.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new S(new Date)}static max(...e){let r=S.MIN;for(const n of e){const i=new S(n);i.after(r)&&(r=i)}return r}static min(...e){let r=S.MAX;for(const n of e){const i=new S(n);i.before(r)&&(r=i)}return r}static nanoseconds(e){return new S(e)}static microseconds(e){return S.nanoseconds(e*1e3)}static milliseconds(e){return S.microseconds(e*1e3)}static seconds(e){return S.milliseconds(e*1e3)}static minutes(e){return S.seconds(e*60)}static hours(e){return S.minutes(e*60)}static days(e){return S.hours(e*24)}};b(L,"NANOSECOND",L.nanoseconds(1)),b(L,"MICROSECOND",L.microseconds(1)),b(L,"MILLISECOND",L.milliseconds(1)),b(L,"SECOND",L.seconds(1)),b(L,"MINUTE",L.minutes(1)),b(L,"HOUR",L.hours(1)),b(L,"DAY",L.days(1)),b(L,"MAX",new L((1n<<63n)-1n)),b(L,"MIN",new L(0)),b(L,"ZERO",new L(0)),b(L,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new L(t.value)),s.z.string().transform(t=>new L(BigInt(t))),s.z.instanceof(Number).transform(t=>new L(t)),s.z.number().transform(t=>new L(t)),s.z.instanceof(L)]));let te=L;const Y=class x{constructor(e){b(this,"value"),b(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new x(e).valueOf()}greaterThan(e){return this.valueOf()>new x(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new x(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new x(e).valueOf()}remainder(e){return ea(this,e)}truncate(e){return new x(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(x.DAY),r=this.truncate(x.HOUR),n=this.truncate(x.MINUTE),i=this.truncate(x.SECOND),a=this.truncate(x.MILLISECOND),o=this.truncate(x.MICROSECOND),l=this.truncate(x.NANOSECOND),u=e,d=r.sub(e),f=n.sub(r),h=i.sub(n),D=a.sub(i),W=o.sub(a),se=l.sub(o);let j="";return u.isZero||(j+=`${u.days}d `),d.isZero||(j+=`${d.hours}h `),f.isZero||(j+=`${f.minutes}m `),h.isZero||(j+=`${h.seconds}s `),D.isZero||(j+=`${D.milliseconds}ms `),W.isZero||(j+=`${W.microseconds}µs `),se.isZero||(j+=`${se.nanoseconds}ns`),j.trim()}get days(){return Number(this.valueOf())/Number(x.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(x.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(x.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(x.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(x.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(x.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new x(e).valueOf()}add(e){return new x(this.valueOf()+new x(e).valueOf())}sub(e){return new x(this.valueOf()-new x(e).valueOf())}static nanoseconds(e=1){return new x(e)}static microseconds(e=1){return x.nanoseconds(e*1e3)}static milliseconds(e=1){return x.microseconds(e*1e3)}static seconds(e=1){return x.milliseconds(e*1e3)}static minutes(e){return x.seconds(e.valueOf()*60)}static hours(e){return x.minutes(e*60)}static days(e){return x.hours(e*24)}};b(Y,"NANOSECOND",Y.nanoseconds(1)),b(Y,"MICROSECOND",Y.microseconds(1)),b(Y,"MILLISECOND",Y.milliseconds(1)),b(Y,"SECOND",Y.seconds(1)),b(Y,"MINUTE",Y.minutes(1)),b(Y,"HOUR",Y.hours(1)),b(Y,"DAY",Y.days(1)),b(Y,"MAX",new Y((1n<<63n)-1n)),b(Y,"MIN",new Y(0)),b(Y,"ZERO",new Y(0)),b(Y,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new Y(t.value)),s.z.string().transform(t=>new Y(BigInt(t))),s.z.instanceof(Number).transform(t=>new Y(t)),s.z.number().transform(t=>new Y(t)),s.z.instanceof(Y)]));let re=Y;const Vt=class nr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new nr(e).valueOf()}get period(){return re.seconds(1/this.valueOf())}sampleCount(e){return new re(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new le(r).valueOf()}span(e){return re.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new nr(e)}static khz(e){return nr.hz(e*1e3)}};b(Vt,"z",s.z.union([s.z.number().transform(t=>new Vt(t)),s.z.instanceof(Number).transform(t=>new Vt(t)),s.z.instanceof(Vt)]));const Q=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new zu(e*this.valueOf())}};b(Q,"UNKNOWN",new Q(0)),b(Q,"BIT128",new Q(16)),b(Q,"BIT64",new Q(8)),b(Q,"BIT32",new Q(4)),b(Q,"BIT16",new Q(2)),b(Q,"BIT8",new Q(1)),b(Q,"z",s.z.union([s.z.number().transform(t=>new Q(t)),s.z.instanceof(Number).transform(t=>new Q(t)),s.z.instanceof(Q)]));let le=Q;const Te=class sr{constructor(e,r){b(this,"start"),b(this,"end"),typeof e=="object"&&"start"in e?(this.start=new te(e.start),this.end=new te(e.end)):(this.start=new te(e),this.end=new te(r))}get span(){return new re(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 sr(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,r=re.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const i=te.max(n.start,e.start),a=te.min(n.end,e.end);return a.before(i)?!1:new re(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof sr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new sr(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};b(Te,"MAX",new Te(te.MIN,te.MAX)),b(Te,"MIN",new Te(te.MAX,te.MIN)),b(Te,"ZERO",new Te(te.ZERO,te.ZERO)),b(Te,"z",s.z.union([s.z.object({start:te.z,end:te.z}).transform(t=>new Te(t.start,t.end)),s.z.instanceof(Te)]));let Su=Te;const p=class Se extends String{constructor(e){if(e instanceof Se||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Se.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Se.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Se.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(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(Se.JSON)||this.equals(Se.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Se.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Se.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!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 Se.BIG_INT_TYPES.some(e=>e.equals(this))}};b(p,"UNKNOWN",new p("unknown")),b(p,"FLOAT64",new p("float64")),b(p,"FLOAT32",new p("float32")),b(p,"INT64",new p("int64")),b(p,"INT32",new p("int32")),b(p,"INT16",new p("int16")),b(p,"INT8",new p("int8")),b(p,"UINT64",new p("uint64")),b(p,"UINT32",new p("uint32")),b(p,"UINT16",new p("uint16")),b(p,"UINT8",new p("uint8")),b(p,"BOOLEAN",p.UINT8),b(p,"TIMESTAMP",new p("timestamp")),b(p,"UUID",new p("uuid")),b(p,"STRING",new p("string")),b(p,"JSON",new p("json")),b(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]])),b(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]])),b(p,"DENSITIES",new Map([[p.UINT8.toString(),le.BIT8],[p.UINT16.toString(),le.BIT16],[p.UINT32.toString(),le.BIT32],[p.UINT64.toString(),le.BIT64],[p.FLOAT32.toString(),le.BIT32],[p.FLOAT64.toString(),le.BIT64],[p.INT8.toString(),le.BIT8],[p.INT16.toString(),le.BIT16],[p.INT32.toString(),le.BIT32],[p.INT64.toString(),le.BIT64],[p.TIMESTAMP.toString(),le.BIT64],[p.STRING.toString(),le.UNKNOWN],[p.JSON.toString(),le.UNKNOWN],[p.UUID.toString(),le.BIT128]])),b(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]),b(p,"BIG_INT_TYPES",[p.INT64,p.UINT64,p.TIMESTAMP]),b(p,"z",s.z.union([s.z.string().transform(t=>new p(t)),s.z.instanceof(p)]));const ae=class K extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return K.bytes(this.valueOf()+e.valueOf())}sub(e){return K.bytes(this.valueOf()-e.valueOf())}truncate(e){return new K(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return K.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/K.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/K.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/K.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/K.TERABYTE.valueOf()}toString(){const e=this.truncate(K.TERABYTE),r=this.truncate(K.GIGABYTE),n=this.truncate(K.MEGABYTE),i=this.truncate(K.KILOBYTE),a=this.truncate(K.BYTE),o=e,l=r.sub(e),u=n.sub(r),d=i.sub(n),f=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),d.isZero||(h+=`${d.kilobytes}KB `),(!f.isZero||h==="")&&(h+=`${f.valueOf()}B`),h.trim()}static bytes(e=1){return new K(e)}static kilobytes(e=1){return K.bytes(e.valueOf()*1e3)}static megabytes(e=1){return K.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return K.megabytes(e.valueOf()*1e3)}static terabytes(e){return K.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};b(ae,"BYTE",new ae(1)),b(ae,"KILOBYTE",ae.kilobytes(1)),b(ae,"MEGABYTE",ae.megabytes(1)),b(ae,"GIGABYTE",ae.gigabytes(1)),b(ae,"TERABYTE",ae.terabytes(1)),b(ae,"ZERO",new ae(0)),b(ae,"z",s.z.union([s.z.number().transform(t=>new ae(t)),s.z.instanceof(ae)]));let zu=ae;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)]);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 ta=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Nu=ta(),ra=["MacOS","Windows","Linux","Docker"],Eu=s.z.enum(ra);let an;const Iu=()=>{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"},Au=(t={})=>{const{force:e,default:r}=t;return e??an??(an=Iu(),an??r)},na=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:ra,RUNTIME:Nu,detect:ta,getOS:Au,osZ:Eu},Symbol.toStringTag,{value:"Module"}));var ku=Object.defineProperty,xu=(t,e,r)=>e in t?ku(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dt=(t,e,r)=>xu(t,typeof e!="symbol"?e+"":e,r);const Cu=(...t)=>t.map(sa).join(""),sa=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Ru=t=>t.endsWith("/")?t.slice(0,-1):t,ju=(t,e="")=>t===null?"":"?"+Object.entries(t).filter(([,r])=>r==null?!1:Array.isArray(r)?r.length>0:!0).map(([r,n])=>`${e}${r}=${n}`).join("&"),kn=class xn{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){dt(this,"protocol"),dt(this,"host"),dt(this,"port"),dt(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=sa(i)}replace(e){return new xn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new xn({...this,pathPrefix:Cu(this.path,e)})}toString(){return Ru(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};dt(kn,"UNKNOWN",new kn({host:"unknown",port:0}));let $u=kn;var Mu=Object.defineProperty,Du=(t,e,r)=>e in t?Mu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ir=(t,e,r)=>Du(t,typeof e!="symbol"?e+"":e,r);const Ke=class extends Number{};ir(Ke,"Absolute",255),ir(Ke,"Default",1),ir(Ke,"z",s.z.union([s.z.instanceof(Ke),s.z.number().int().min(0).max(255).transform(t=>new Ke(t)),s.z.instanceof(Number).transform(t=>new Ke(t))]));s.z.object({name:s.z.string(),key:s.z.string()});const ia=class ft extends Error{constructor(){super(ft.MESSAGE)}matches(e){return typeof e=="string"?e.includes(ft.MESSAGE):e instanceof ft||e.message.includes(ft.MESSAGE)}};ir(ia,"MESSAGE","canceled");let Pu=ia;new Pu;s.z.string().regex(/^\d+\.\d+\.\d+$/);const he=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 be=class extends Error{constructor(e){super(e),M(this,"discriminator","FreighterError"),M(this,"type","")}};const Bu=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},Ls="unknown",Ys="nil",Uu="freighter",Dt=s.z.object({type:s.z.string(),data:s.z.string()});class Lu{constructor(){M(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Ys,data:""};if(Bu(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}return{type:Ls,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Ys)return null;if(e.type===Ls)return new qs(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new qs(e.data)}}const aa=new Lu,oa=({encode:t,decode:e})=>aa.register({encode:t,decode:e}),Hn=t=>aa.decode(t);class qs extends be{constructor(e){super(e),M(this,"type","unknown")}}const Yr="freighter.",ar=class ca extends be{constructor(){super("EOF"),M(this,"type",ca.TYPE)}};M(ar,"TYPE",Yr+"eof"),M(ar,"matches",he(ar.TYPE));let De=ar;const or=class la extends be{constructor(){super("StreamClosed"),M(this,"type",la.TYPE)}};M(or,"TYPE",Yr+"stream_closed"),M(or,"matches",he(or.TYPE));let Xe=or;const cr=class ua extends be{constructor(e={}){const{message:r="Unreachable",url:n=$u.UNKNOWN}=e;super(r),M(this,"type",ua.TYPE),M(this,"url"),this.url=n}};M(cr,"TYPE",Yr+"unreachable"),M(cr,"matches",he(cr.TYPE));let Ge=cr;const Yu=t=>{if(!t.type.startsWith(Uu))return null;if(De.matches(t))return{type:De.TYPE,data:"EOF"};if(Xe.matches(t))return{type:Xe.TYPE,data:"StreamClosed"};if(Ge.matches(t))return{type:Ge.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},qu=t=>{if(!t.type.startsWith(Yr))return null;switch(t.type){case De.TYPE:return new De;case Xe.TYPE:return new Xe;case Ge.TYPE:return new Ge;default:throw new Error(`Unknown error type: ${t.data}`)}};oa({encode:Yu,decode:qu});class ha{constructor(){M(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,r){let n=0;const i=async a=>{if(n===this.middleware.length)return await r(a);const o=this.middleware[n];return n++,await o(a,i)};return await i(e)}}const da="Content-Type",Fs=t=>{if(na.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(t==="http")return e;const r=require("https"),n=new r.Agent({rejectUnauthorized:!1});return async(i,a)=>await e(i,{...a,agent:n})};class Fu extends ha{constructor(e,r,n=!1){return super(),M(this,"endpoint"),M(this,"encoder"),M(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=r,this.fetch=Fs(this.endpoint.protocol),new Proxy(this,{get:(i,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(i,a,o)})}get headers(){return{[da]:this.encoder.contentType}}async send(e,r,n,i){r=n==null?void 0:n.parse(r);let a=null;const o=this.endpoint.child(e),l={};l.method="POST",l.body=this.encoder.encode(r??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async d=>{const f={...d,params:{}};l.headers={...this.headers,...d.params};let h;try{h=await Fs(d.protocol)(d.target,l)}catch(W){let se=W;return se.message==="Load failed"&&(se=new Ge({url:o})),[f,se]}const D=await h.arrayBuffer();if(h!=null&&h.ok)return i!=null&&(a=this.encoder.decode(D,i)),[f,null];try{if(h.status!==400)return[f,new Error(h.statusText)];const W=this.encoder.decode(D,Dt),se=Hn(W);return[f,se]}catch(W){return[f,new Error(`[freighter] - failed to decode error: ${h.statusText}: ${W.message}`)]}});return[a,u]}}const v=async(t,e,r,n,i)=>{const[a,o]=await t.send(e,r,n,i);if(o!=null)throw o;return a},_u=()=>na.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),Wu=s.z.object({type:s.z.union([s.z.literal("data"),s.z.literal("close")]),payload:s.z.unknown().optional(),error:s.z.optional(Dt)});class Gu{constructor(e,r,n,i){M(this,"encoder"),M(this,"reqSchema"),M(this,"resSchema"),M(this,"ws"),M(this,"serverClosed"),M(this,"sendClosed"),M(this,"receiveDataQueue",[]),M(this,"receiveCallbacksQueue",[]),this.encoder=r,this.reqSchema=n,this.resSchema=i,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new De;if(this.sendClosed)throw new Xe;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=Hn(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,r)=>this.receiveCallbacksQueue.push({resolve:e,reject:r}))}addMessage(e){const r=this.receiveCallbacksQueue.shift();r!=null?r.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,Wu)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:Hu(e)?De.TYPE:Xe.TYPE,data:""}})}}const Zu="freighterctx",Vu=1e3,Ku=1001,Ju=[Vu,Ku],Hu=t=>Ju.includes(t.code),fa=class ya extends ha{constructor(e,r,n=!1){super(),M(this,"baseUrl"),M(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=r}async stream(e,r,n){const i=_u();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async l=>{const u=i(this.buildURL(e,l)),d={...l,params:{}};u.binaryType=ya.MESSAGE_TYPE;const f=await this.wrapSocket(u,r,n);return f instanceof Error?[d,f]:(a=f,[d,null])});if(o!=null)throw o;return a}buildURL(e,r){const n=ju({[da]:this.encoder.contentType,...r.params},Zu);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(i=>{e.onopen=()=>{i(new Gu(e,this.encoder,r,n))},e.onerror=a=>{const o=a;i(new Error(o.message))}})}};M(fa,"MESSAGE_TYPE","arraybuffer");let Xu=fa;const Qu=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()?e:e[0].toLowerCase()+e.slice(1)},ga=t=>{const e=(r,n=Cn)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!on(r))return r;n=rh(n);const i={},a=r;return Object.keys(a).forEach(o=>{let l=a[o];const u=t(o);n.recursive&&(on(l)?Ws(l,n.keepTypesOnRecursion)||(l=e(l,n)):n.recursiveInArray&&_s(l)&&(l=[...l].map(d=>{let f=d;return on(d)?Ws(f,n.keepTypesOnRecursion)||(f=e(d,n)):_s(d)&&(f=e({key:d},n).key),f}))),i[u]=l}),i};return e},pa=ga(Qu),eh=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),th=ga(eh),Cn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},rh=(t=Cn)=>(t.recursive==null?t=Cn:t.recursiveInArray==null&&(t.recursiveInArray=!1),t),_s=t=>t!=null&&Array.isArray(t),on=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Ws=(t,e)=>(e||[]).some(r=>t instanceof r),Xn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var nh=Object.defineProperty,sh=(t,e,r)=>e in t?nh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zt=(t,e,r)=>sh(t,typeof e!="symbol"?e+"":e,r);let ma=class{constructor(){zt(this,"contentType","application/json"),zt(this,"decoder"),zt(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 r=JSON.parse(t),n=pa(r);return e!=null?e.parse(n):n}encodeString(t){const e=th(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):Xn(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},wa=class{constructor(){zt(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!Xn(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),r=[e.join(",")];return t.forEach(n=>{const i=e.map(a=>JSON.stringify(n[a]??""));r.push(i.join(","))}),r.join(`
16
+ `)}decodeString(t,e){const[r,...n]=t.trim().split(`
17
+ `).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),n.forEach(o=>{const l=o.split(",").map(u=>u.trim());i.forEach((u,d)=>{const f=this.parseValue(l[d]);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(){}},ba=class{constructor(){zt(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const r=new TextDecoder().decode(t);return e!=null?e.parse(r):r}};const He=new ma,ih=new wa,ah=new ba,oh=[He],tt=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:wa,CSV_CODEC:ih,ENCODERS:oh,JSONCodec:ma,JSON_CODEC:He,TEXT_CODEC:ah,TextCodec:ba},Symbol.toStringTag,{value:"Module"})),ch=t=>t!=null&&typeof t=="object"&&"toString"in t,lh=(t,e=!1)=>{const r=ch(t)?"stringer":typeof t;let n;switch(r){case"string":n=(i,a)=>i.localeCompare(a);break;case"stringer":n=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":n=(i,a)=>Number(i)-Number(a);break;case"bigint":n=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":n=(i,a)=>Number(i)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?uh(n):n},uh=t=>(e,r)=>t(r,e),qr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const va=s.z.object({width:s.z.number(),height:s.z.number()}),hh=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),dh=["width","height"];s.z.enum(dh);const fh=["start","center","end"],yh=["signedWidth","signedHeight"];s.z.enum(yh);const xr=s.z.object({x:s.z.number(),y:s.z.number()}),gh=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),ph=["x","y"],Oa=s.z.enum(ph),Ta=["top","right","bottom","left"];s.z.enum(Ta);const mh=["left","right"],Sa=s.z.enum(mh),wh=["top","bottom"],za=s.z.enum(wh),Na=["center"],Gs=s.z.enum(Na),bh=[...Ta,...Na],Ea=s.z.enum(bh);s.z.enum(fh);const vh=["first","last"];s.z.enum(vh);const Oh=s.z.object({lower:s.z.number(),upper:s.z.number()}),Th=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Oh,qr]);s.z.union([Th,qr]);s.z.union([Oa,Ea]);s.z.union([Oa,Ea,s.z.instanceof(String)]);const Nt=(t,e)=>{const r={};if(typeof t=="number"||typeof t=="bigint")e!=null?(r.lower=t,r.upper=e):(r.lower=typeof t=="bigint"?0n:0,r.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=t}else return Zs(t);return Zs(r)},Zs=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;s.z.object({x:Sa.or(Gs),y:za.or(Gs)});const Sh=s.z.object({x:Sa,y:za}),zh=Object.freeze({x:"left",y:"top"}),Nh=(t,e)=>t.x===e.x&&t.y===e.y,Vs=s.z.union([s.z.number(),xr,qr,va,hh,gh]),Eh=(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}},Ks=Object.freeze({x:0,y:0}),Kt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Kt,left:Kt,width:Kt,height:Kt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:xr,two:xr,root:Sh});const Qn=(t,e,r=0,n=0,i)=>{const a={one:{...Ks},two:{...Ks},root:i??zh};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+r,y:a.one.y+n},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+r,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+r}:"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))},cn=t=>{const e=Qn(t);return{lower:e.one.x,upper:e.two.x}},ln=t=>{const e=Qn(t);return{lower:e.one.y,upper:e.two.y}},Ih=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Ah=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([va,Ah,xr,qr]);var kh=Object.defineProperty,xh=(t,e,r)=>e in t?kh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Re=(t,e,r)=>xh(t,typeof e!="symbol"?e+"":e,r);const Ch=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:Vs,scale:Vs});const Rh=t=>(e,r,n,i)=>r==="dimension"?[e,n]:[e,i?n-t:n+t],jh=t=>(e,r,n,i)=>[e,i?n/t:n*t],$h=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:i,upper:a}=e,{lower:o,upper:l}=t,u=a-i,d=l-o;if(r==="dimension")return[t,n*(d/u)];const f=(n-i)*(d/u)+o;return[t,f]},Mh=t=>(e,r,n)=>[t,n],Dh=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:i}=t;return[t,i-(r-n)]},Ph=t=>(e,r,n)=>{const{lower:i,upper:a}=t;return n=Ch(n,i,a),[e,n]},Rn=class yt{constructor(){Re(this,"ops",[]),Re(this,"currBounds",null),Re(this,"currType",null),Re(this,"reversed",!1),this.ops=[]}static translate(e){return new yt().translate(e)}static magnify(e){return new yt().magnify(e)}static scale(e,r){return new yt().scale(e,r)}translate(e){const r=this.new(),n=Rh(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=jh(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=Nt(e,r),i=this.new(),a=$h(n);return a.type="scale",i.ops.push(a),i}clamp(e,r){const n=Nt(e,r),i=this.new(),a=Ph(n);return a.type="clamp",i.ops.push(a),i}reBound(e,r){const n=Nt(e,r),i=this.new(),a=Mh(n);return a.type="re-bound",i.ops.push(a),i}invert(){const e=Dh();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new yt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,i],a)=>a(n,e,i,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,i)=>{if(n.type==="scale"||r.some(([o,l])=>i>=o&&i<=l))return;const a=e.ops.findIndex((o,l)=>o.type==="scale"&&l>i);a!==-1&&r.push([i,a])}),r.forEach(([n,i])=>{const a=e.ops.slice(n,i);a.unshift(e.ops[i]),e.ops.splice(n,i-n+1,...a)}),e.reversed=!e.reversed,e}};Re(Rn,"IDENTITY",new Rn);let Js=Rn;const Hs=class ke{constructor(e=new Js,r=new Js,n=null){Re(this,"x"),Re(this,"y"),Re(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new ke().translate(e,r)}static translateX(e){return new ke().translateX(e)}static translateY(e){return new ke().translateY(e)}static clamp(e){return new ke().clamp(e)}static magnify(e){return new ke().magnify(e)}static scale(e){return new ke().scale(e)}static reBound(e){return new ke().reBound(e)}translate(e,r){const n=Eh(e,r),i=this.copy();return i.x=this.x.translate(n.x),i.y=this.y.translate(n.y),i}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Ih(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Nh(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(cn(e)),r.y=r.y.scale(ln(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(cn(e)),r.y=this.y.reBound(ln(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(cn(e)),r.y=this.y.clamp(ln(e)),r}copy(){const e=new ke;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)}}box(e){return Qn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Re(Hs,"IDENTITY",new Hs);var Bh=Object.defineProperty,Uh=(t,e,r)=>e in t?Bh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,w=(t,e,r)=>Uh(t,typeof e!="symbol"?e+"":e,r);let Lh=(t,e=21)=>(r=e)=>{let n="",i=r;for(;i--;)n+=t[Math.random()*t.length|0];return n};const Yh="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ia=Lh(Yh,11),qh=Object.freeze(Object.defineProperty({__proto__:null,id:Ia},Symbol.toStringTag,{value:"Module"})),Aa=(t,e)=>{const r=new E(e);if(![A.DAY,A.HOUR,A.MINUTE,A.SECOND,A.MILLISECOND,A.MICROSECOND,A.NANOSECOND].some(i=>i.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof E?new E(n):new A(n)},q=class z{constructor(e,r="UTC"){if(w(this,"value"),w(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const i=new Date(e,r-1,n,0,0,0,0);return new z(BigInt(i.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=z.hours(parseInt(n??"00",10)).add(z.minutes(parseInt(i??"00",10))).add(z.seconds(parseInt(o??"00",10))).add(z.milliseconds(parseInt(l??"00",10)));return r==="local"&&(u=u.add(z.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new z(BigInt(n.getTime())*z.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new A(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new ne(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 z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(z.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Aa(this,e)}get isToday(){return this.truncate(A.DAY).equals(z.now().truncate(A.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let r=z.MIN;for(const n of e){const i=new z(n);i.after(r)&&(r=i)}return r}static min(...e){let r=z.MAX;for(const n of e){const i=new z(n);i.before(r)&&(r=i)}return r}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};w(q,"NANOSECOND",q.nanoseconds(1)),w(q,"MICROSECOND",q.microseconds(1)),w(q,"MILLISECOND",q.milliseconds(1)),w(q,"SECOND",q.seconds(1)),w(q,"MINUTE",q.minutes(1)),w(q,"HOUR",q.hours(1)),w(q,"DAY",q.days(1)),w(q,"MAX",new q((1n<<63n)-1n)),w(q,"MIN",new q(0)),w(q,"ZERO",new q(0)),w(q,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new q(t.value)),s.z.string().transform(t=>new q(BigInt(t))),s.z.instanceof(Number).transform(t=>new q(t)),s.z.number().transform(t=>new q(t)),s.z.instanceof(q)]));let E=q;const F=class C{constructor(e){w(this,"value"),w(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new C(e).valueOf()}greaterThan(e){return this.valueOf()>new C(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new C(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new C(e).valueOf()}remainder(e){return Aa(this,e)}truncate(e){return new C(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(C.DAY),r=this.truncate(C.HOUR),n=this.truncate(C.MINUTE),i=this.truncate(C.SECOND),a=this.truncate(C.MILLISECOND),o=this.truncate(C.MICROSECOND),l=this.truncate(C.NANOSECOND),u=e,d=r.sub(e),f=n.sub(r),h=i.sub(n),D=a.sub(i),W=o.sub(a),se=l.sub(o);let j="";return u.isZero||(j+=`${u.days}d `),d.isZero||(j+=`${d.hours}h `),f.isZero||(j+=`${f.minutes}m `),h.isZero||(j+=`${h.seconds}s `),D.isZero||(j+=`${D.milliseconds}ms `),W.isZero||(j+=`${W.microseconds}µs `),se.isZero||(j+=`${se.nanoseconds}ns`),j.trim()}get days(){return Number(this.valueOf())/Number(C.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(C.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(C.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(C.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(C.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(C.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new C(e).valueOf()}add(e){return new C(this.valueOf()+new C(e).valueOf())}sub(e){return new C(this.valueOf()-new C(e).valueOf())}static nanoseconds(e=1){return new C(e)}static microseconds(e=1){return C.nanoseconds(e*1e3)}static milliseconds(e=1){return C.microseconds(e*1e3)}static seconds(e=1){return C.milliseconds(e*1e3)}static minutes(e){return C.seconds(e.valueOf()*60)}static hours(e){return C.minutes(e*60)}static days(e){return C.hours(e*24)}};w(F,"NANOSECOND",F.nanoseconds(1)),w(F,"MICROSECOND",F.microseconds(1)),w(F,"MILLISECOND",F.milliseconds(1)),w(F,"SECOND",F.seconds(1)),w(F,"MINUTE",F.minutes(1)),w(F,"HOUR",F.hours(1)),w(F,"DAY",F.days(1)),w(F,"MAX",new F((1n<<63n)-1n)),w(F,"MIN",new F(0)),w(F,"ZERO",new F(0)),w(F,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new F(t.value)),s.z.string().transform(t=>new F(BigInt(t))),s.z.instanceof(Number).transform(t=>new F(t)),s.z.number().transform(t=>new F(t)),s.z.instanceof(F)]));let A=F;const gt=class lr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new lr(e).valueOf()}get period(){return A.seconds(1/this.valueOf())}sampleCount(e){return new A(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new ue(r).valueOf()}span(e){return A.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new lr(e)}static khz(e){return lr.hz(e*1e3)}};w(gt,"z",s.z.union([s.z.number().transform(t=>new gt(t)),s.z.instanceof(Number).transform(t=>new gt(t)),s.z.instanceof(gt)]));let es=gt;const ee=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new kt(e*this.valueOf())}};w(ee,"UNKNOWN",new ee(0)),w(ee,"BIT128",new ee(16)),w(ee,"BIT64",new ee(8)),w(ee,"BIT32",new ee(4)),w(ee,"BIT16",new ee(2)),w(ee,"BIT8",new ee(1)),w(ee,"z",s.z.union([s.z.number().transform(t=>new ee(t)),s.z.instanceof(Number).transform(t=>new ee(t)),s.z.instanceof(ee)]));let ue=ee;const ze=class ur{constructor(e,r){w(this,"start"),w(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(r))}get span(){return new A(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 ur(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,r=A.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const i=E.max(n.start,e.start),a=E.min(n.end,e.end);return a.before(i)?!1:new A(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof ur?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new ur(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};w(ze,"MAX",new ze(E.MIN,E.MAX)),w(ze,"MIN",new ze(E.MAX,E.MIN)),w(ze,"ZERO",new ze(E.ZERO,E.ZERO)),w(ze,"z",s.z.union([s.z.object({start:E.z,end:E.z}).transform(t=>new ze(t.start,t.end)),s.z.instanceof(ze)]));let ne=ze;const g=class Ne extends String{constructor(e){if(e instanceof Ne||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Ne.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Ne.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Ne.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(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(Ne.JSON)||this.equals(Ne.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Ne.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Ne.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!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 Ne.BIG_INT_TYPES.some(e=>e.equals(this))}};w(g,"UNKNOWN",new g("unknown")),w(g,"FLOAT64",new g("float64")),w(g,"FLOAT32",new g("float32")),w(g,"INT64",new g("int64")),w(g,"INT32",new g("int32")),w(g,"INT16",new g("int16")),w(g,"INT8",new g("int8")),w(g,"UINT64",new g("uint64")),w(g,"UINT32",new g("uint32")),w(g,"UINT16",new g("uint16")),w(g,"UINT8",new g("uint8")),w(g,"BOOLEAN",g.UINT8),w(g,"TIMESTAMP",new g("timestamp")),w(g,"UUID",new g("uuid")),w(g,"STRING",new g("string")),w(g,"JSON",new g("json")),w(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]])),w(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]])),w(g,"DENSITIES",new Map([[g.UINT8.toString(),ue.BIT8],[g.UINT16.toString(),ue.BIT16],[g.UINT32.toString(),ue.BIT32],[g.UINT64.toString(),ue.BIT64],[g.FLOAT32.toString(),ue.BIT32],[g.FLOAT64.toString(),ue.BIT64],[g.INT8.toString(),ue.BIT8],[g.INT16.toString(),ue.BIT16],[g.INT32.toString(),ue.BIT32],[g.INT64.toString(),ue.BIT64],[g.TIMESTAMP.toString(),ue.BIT64],[g.STRING.toString(),ue.UNKNOWN],[g.JSON.toString(),ue.UNKNOWN],[g.UUID.toString(),ue.BIT128]])),w(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]),w(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),w(g,"z",s.z.union([s.z.string().transform(t=>new g(t)),s.z.instanceof(g)]));let I=g;const oe=class J extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return J.bytes(this.valueOf()+e.valueOf())}sub(e){return J.bytes(this.valueOf()-e.valueOf())}truncate(e){return new J(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return J.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/J.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/J.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/J.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/J.TERABYTE.valueOf()}toString(){const e=this.truncate(J.TERABYTE),r=this.truncate(J.GIGABYTE),n=this.truncate(J.MEGABYTE),i=this.truncate(J.KILOBYTE),a=this.truncate(J.BYTE),o=e,l=r.sub(e),u=n.sub(r),d=i.sub(n),f=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),d.isZero||(h+=`${d.kilobytes}KB `),(!f.isZero||h==="")&&(h+=`${f.valueOf()}B`),h.trim()}static bytes(e=1){return new J(e)}static kilobytes(e=1){return J.bytes(e.valueOf()*1e3)}static megabytes(e=1){return J.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return J.megabytes(e.valueOf()*1e3)}static terabytes(e){return J.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};w(oe,"BYTE",new oe(1)),w(oe,"KILOBYTE",oe.kilobytes(1)),w(oe,"MEGABYTE",oe.megabytes(1)),w(oe,"GIGABYTE",oe.gigabytes(1)),w(oe,"TERABYTE",oe.terabytes(1)),w(oe,"ZERO",new oe(0)),w(oe,"z",s.z.union([s.z.number().transform(t=>new oe(t)),s.z.instanceof(oe)]));let kt=oe;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 ka=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof E||t instanceof A||t instanceof Date},Fh=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):pt(r,-n),_h=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof _e?!0:ka(t),Ye=-1;let _e=class xe{constructor(e){w(this,"key",""),w(this,"isSynnaxSeries",!0),w(this,"dataType"),w(this,"sampleOffset"),w(this,"gl"),w(this,"_data"),w(this,"_timeRange"),w(this,"alignment",0n),w(this,"_cachedMin"),w(this,"_cachedMax"),w(this,"writePos",Ye),w(this,"_refCount",0),w(this,"_cachedLength"),_h(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:l=Ia()}=e,{data:u}=e;if(u instanceof xe||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const h=u;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const d=ka(u),f=Array.isArray(u);if(r!=null)this.dataType=new I(r);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||d){let h=u;if(!d){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.");h=u[0]}if(typeof h=="string")this.dataType=I.STRING;else if(typeof h=="number")this.dataType=I.FLOAT64;else if(typeof h=="bigint")this.dataType=I.INT64;else if(typeof h=="boolean")this.dataType=I.BOOLEAN;else if(h instanceof E||h instanceof Date||h instanceof E)this.dataType=I.TIMESTAMP;else if(typeof h=="object")this.dataType=I.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new I(u)}if(!f&&!d)this._data=u;else{let h=d?[u]:u;const D=h[0];(D instanceof E||D instanceof Date||D instanceof A)&&(h=h.map(W=>new E(W).valueOf())),this.dataType.equals(I.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
18
+ `)+`
19
+ `)):this.dataType.equals(I.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(W=>He.encodeString(W)).join(`
20
+ `)+`
21
+ `)):this._data=new this.dataType.Array(h).buffer}this.key=l,this.alignment=o,this.sampleOffset=i??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new I(r).Array(e),a=new xe({data:i.buffer,dataType:r,...n});return a.writePos=0,a}static generateTimestamps(e,r,n){const i=n.spanRange(r.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(r.span(o)).valueOf());return new xe({data:a,dataType:I.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
22
+ `)+`
23
+ `);return new xe({data:n,dataType:I.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(i=>He.encodeString(i)).join(`
24
+ `)+`
25
+ `);return new xe({data:n,dataType:I.JSON,timeRange:r})}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");if(this.writePos===Ye)return 0;const r=this.capacity-this.writePos,n=r<e.length?e.slice(0,r):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ye?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.buffer).split(`
26
+ `).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(),r=Array(this.length);for(let n=0;n<this.length;n++){const i=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=a}return r}parseJSON(e){if(!this.dataType.equals(I.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
27
+ `).slice(0,-1).map(r=>e.parse(He.decodeString(r)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new kt(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ye?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ye?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;return this.data.forEach(r=>{r===10&&e++}),this._cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let i=0;i<this.length;i++)n[i]=Fh(this.dataType,e,this.data[i],r);return new xe({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:r,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((r,n)=>r>n?r:n)}else{const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}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==null&&(this._cachedMax=this.calcRawMax()),pt(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((r,n)=>r<n?r:n)}else{const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}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==null&&(this._cachedMin=this.calcRawMin()),pt(this._cachedMin,this.sampleOffset))}get bounds(){return Nt(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const r=e._cachedMin??e.calcRawMin();r<this._cachedMin&&(this._cachedMin=r)}if(this._cachedMax!=null){const r=e._cachedMax??e.calcRawMax();r>this._cachedMax&&(this._cachedMax=r)}}enrich(){this.max,this.min}get range(){return pt(this.max,-this.min)}at(e,r){if(this.dataType.isVariable)return this.atVariable(e,r??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return pt(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,i=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){i=o;break}n=o+1,e--}if(i===0&&(i=this.data.length),n>=i||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,i);return this.dataType.equals(I.STRING)?new TextDecoder().decode(a):pa(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let r=0,n=this.length-1;const i=lh(e);for(;r<=n;){const a=Math.floor((r+n)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?r=a+1:n=a-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(I.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:i}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ye){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,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ye}as(e){if(e==="string"){if(!this.dataType.equals(I.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(I.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,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 Nt(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 Wh(this);return this.dataType.equals(I.JSON)?new Gh(e):e}return new Zh(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new xe({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new xe({data:this.buffer,dataType:this.dataType,timeRange:ne.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};class Wh{constructor(e){if(w(this,"series"),w(this,"index"),w(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,r=this.series.data;for(;this.index<r.length&&r[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var Xs,Qs;class Gh{constructor(e){w(this,"wrapped"),w(this,Xs,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:He.decodeString(e.value)}}[(Qs=Symbol.iterator,Xs=Symbol.toStringTag,Qs)](){return this}}var ei,ti;class Zh{constructor(e){w(this,"series"),w(this,"index"),w(this,ei,"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)}}[(ti=Symbol.iterator,ei=Symbol.toStringTag,ti)](){return this}}const pt=(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);class Vh{constructor(e){if(w(this,"series"),e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new I(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?I.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?ne.ZERO:new ne(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,r)=>e+r.length,0)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new kt(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Kh(this.series)}}var ri,ni;class Kh{constructor(e){w(this,"series"),w(this,"seriesIndex"),w(this,"internal"),w(this,ri,"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())}[(ni=Symbol.iterator,ri=Symbol.toStringTag,ni)](){return this}}const N=t=>Array.isArray(t)?t:[t],Jh=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}};s.z.object({key:s.z.string(),value:s.z.string()});var Hh=Object.defineProperty,Xh=(t,e,r)=>e in t?Hh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hr=(t,e,r)=>Xh(t,typeof e!="symbol"?e+"":e,r);let Qh=class{constructor(t,e){hr(this,"handlers"),hr(this,"transform"),hr(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[r,n]=this.transform(t);if(!n)return;e=r}this.handlers.forEach((r,n)=>n(e))}setCloser(t){this.closer=t}async close(){var t;return await((t=this.closer)==null?void 0:t.call(this))}},ed=class{constructor(t){hr(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,r)=>r(t))}};const Ze=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:ed,Observer:Qh},Symbol.toStringTag,{value:"Module"})),ts=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),td=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";td();const rd=["MacOS","Windows","Linux","Docker"];s.z.enum(rd);const si=t=>[...new Set(t)];var nd=Object.defineProperty,sd=(t,e,r)=>e in t?nd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mt=(t,e,r)=>sd(t,typeof e!="symbol"?e+"":e,r);const id=(...t)=>t.map(xa).join(""),xa=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),ad=t=>t.endsWith("/")?t.slice(0,-1):t,jn=class $n{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){mt(this,"protocol"),mt(this,"host"),mt(this,"port"),mt(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=xa(i)}replace(e){return new $n({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new $n({...this,pathPrefix:id(this.path,e)})}toString(){return ad(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};mt(jn,"UNKNOWN",new jn({host:"unknown",port:0}));let od=jn;var cd=Object.defineProperty,ld=(t,e,r)=>e in t?cd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dr=(t,e,r)=>ld(t,typeof e!="symbol"?e+"":e,r);const Fe=class extends Number{};dr(Fe,"Absolute",255),dr(Fe,"Default",1),dr(Fe,"z",s.z.union([s.z.instanceof(Fe),s.z.number().int().min(0).max(255).transform(t=>new Fe(t)),s.z.instanceof(Number).transform(t=>new Fe(t))]));let Ca=Fe;const Ra=s.z.object({name:s.z.string(),key:s.z.string()}),ud=t=>s.z.object({subject:Ra,resource:t,authority:Ca.z}),hd=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),Qe=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ca,filterTransfersByChannelKey:hd,stateZ:ud,subjectZ:Ra},Symbol.toStringTag,{value:"Module"})),ja=class wt extends Error{constructor(){super(wt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(wt.MESSAGE):e instanceof wt||e.message.includes(wt.MESSAGE)}};dr(ja,"MESSAGE","canceled");let dd=ja;new dd;s.z.string().regex(/^\d+\.\d+\.\d+$/);const Pe="sy.",fr=class $a extends be{constructor(){super(...arguments),c(this,"type",$a.TYPE)}};c(fr,"TYPE",Pe+"validation"),c(fr,"matches",he(fr.TYPE));let Z=fr;const yr=class Ma extends Z{constructor(e,r){super(e+": "+r),c(this,"type",Ma.TYPE),c(this,"field"),c(this,"message"),this.field=e,this.message=r}};c(yr,"TYPE",Z.TYPE+".field"),c(yr,"matches",he(yr.TYPE));let ii=yr;const gr=class Da extends be{constructor(){super(...arguments),c(this,"type",Da.TYPE)}};c(gr,"TYPE",Pe+"auth"),c(gr,"matches",he(gr.TYPE));let Cr=gr;const pr=class Pa extends Cr{constructor(){super(...arguments),c(this,"type",Pa.TYPE)}};c(pr,"TYPE",Cr.TYPE+".invalid-token"),c(pr,"matches",he(pr.TYPE));let Mn=pr;const mr=class Ba extends be{constructor(e){super(`
28
+ Unexpected error encountered:
29
+
30
+ ${e}
31
+
32
+ Please report this to the Synnax team.
33
+ `),c(this,"type",Ba.TYPE)}};c(mr,"TYPE",Pe+"unexpected"),c(mr,"matches",he(mr.TYPE));let me=mr;const wr=class Ua extends be{constructor(){super(...arguments),c(this,"type",Ua.TYPE)}};c(wr,"TYPE",Pe+"query"),c(wr,"matches",he(wr.TYPE));let we=wr;const br=class La extends we{constructor(){super(...arguments),c(this,"type",La.TYPE)}};c(br,"TYPE",we.TYPE+".not_found"),c(br,"matches",he(br.TYPE));let Rr=br;const vr=class Ya extends we{constructor(){super(...arguments),c(this,"type",Ya.TYPE)}};c(vr,"TYPE",we.TYPE+".multiple_results"),c(vr,"matches",he(vr.TYPE));let jr=vr;const Or=class qa extends be{constructor(e,r){super(e),c(this,"type",qa.TYPE),c(this,"path"),this.path=r}};c(Or,"TYPE",Pe+"route"),c(Or,"matches",he(Or.TYPE));let ai=Or;const Tr=class Fa extends be{constructor(){super(...arguments),c(this,"type",Fa.TYPE)}};c(Tr,"TYPE",Pe+"control"),c(Tr,"matches",he(Tr.TYPE));let $r=Tr;const Sr=class _a extends $r{constructor(){super(...arguments),c(this,"type",_a.TYPE)}};c(Sr,"TYPE",$r.TYPE+".unauthorized"),c(Sr,"matches",he(Sr.TYPE));let oi=Sr;const un=class Wa extends be{constructor(){super(...arguments),c(this,"type",Wa.TYPE)}};c(un,"TYPE",Pe+"contiguity"),c(un,"matches",he(un.TYPE));const fd=t=>{if(!t.type.startsWith(Pe))return null;if(t.type.startsWith(Z.TYPE)){if(t.type===ii.TYPE){const e=t.data.split(": ");return e.length<2?new Z(t.data):new ii(e[0],e[1])}return new Z(t.data)}return t.type.startsWith(Cr.TYPE)?t.type.startsWith(Mn.TYPE)?new Mn(t.data):new Cr(t.data):t.type.startsWith(me.TYPE)?new me(t.data):t.type.startsWith(we.TYPE)?t.type.startsWith(Rr.TYPE)?new Rr(t.data):t.type.startsWith(jr.TYPE)?new jr(t.data):new we(t.data):t.type.startsWith($r.TYPE)?t.type.startsWith(oi.TYPE)?new oi(t.data):new $r(t.data):t.type.startsWith(ai.TYPE)?new ai(t.data,t.data):new me(t.data)},yd=()=>{throw new Error("Not implemented")};oa({encode:yd,decode:fd});const gd=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof Ge?[r,new Ge({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]};class Ga{constructor(e,r){c(this,"key"),c(this,"name"),this.key=r,this.name=e}get ontologyID(){return new R({type:"group",key:this.key})}}const pd=s.z.string().uuid(),Za=s.z.object({key:pd,name:s.z.string()}),Va=s.z.union([s.z.literal("label"),s.z.literal("builtin"),s.z.literal("cluster"),s.z.literal("channel"),s.z.literal("node"),s.z.literal("group"),s.z.literal("range"),s.z.literal("range-alias"),s.z.literal("user"),s.z.literal("workspace"),s.z.literal("schematic"),s.z.literal("lineplot"),s.z.literal("rack"),s.z.literal("device"),s.z.literal("task"),s.z.literal("policy")]),fe=s.z.object({type:Va,key:s.z.string()}),md=s.z.string().transform(t=>{const[e,r]=t.split(":");return{type:e,key:r}}),wd=s.z.union([md,fe]),zr=class Ka{constructor(e){if(c(this,"type"),c(this,"key"),e instanceof Ka)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[r,n]=e.split(":");this.type=r,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};c(zr,"z",s.z.union([wd,s.z.instanceof(zr)]).transform(t=>new zr(t)));let R=zr;new R({type:"builtin",key:"root"});const bd=s.z.object({type:s.z.number()}),vd=s.z.object({type:Va,fields:s.z.record(bd)}),Od=s.z.object({id:R.z,name:s.z.string(),schema:vd.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(t=>({key:t.id.toString(),...t}));s.z.object({from:R.z,type:s.z.string(),to:R.z});const ci=t=>{const[e,r,n]=t.split("->");return{from:new R(e),type:r,to:new R(n)}},Td=s.z.object({group:Za}),Sd=s.z.object({parent:fe,key:s.z.string().uuid().optional(),name:s.z.string()}),zd=s.z.object({key:s.z.string(),name:s.z.string()}),Nd=s.z.object({keys:s.z.array(s.z.string())});var $e;let Ed=($e=class{constructor(t){c(this,"client"),this.client=t}async create(t,e,r){const[n,i]=await this.client.send($e.ENDPOINT,{parent:t,name:e,key:r},Sd,Td);if(i!=null)throw i;return n.group}async rename(t,e){const r={key:t,name:e},[,n]=await this.client.send($e.ENDPOINT_RENAME,r,zd,s.z.object({}));if(n!=null)throw n}async delete(t){const e={keys:t},[,r]=await this.client.send($e.ENDPOINT_DELETE,e,Nd,s.z.object({}));if(r!=null)throw r}},c($e,"ENDPOINT","/ontology/create-group"),c($e,"ENDPOINT_RENAME","/ontology/rename-group"),c($e,"ENDPOINT_DELETE","/ontology/delete-group"),$e),Id=class{constructor(t){c(this,"creator"),this.creator=new Ed(t)}async create(t,e,r){return this.sugar(await this.creator.create(t,e,r))}async rename(t,e){return await this.creator.rename(t,e)}async delete(...t){return await this.creator.delete(t)}sugar(t){return new Ga(t.name,t.key)}};const hn={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},li=s.z.object({id:fe,children:fe.array()}),Ad=s.z.object({from:fe,to:fe,children:fe.array()});let kd=class{constructor(t){c(this,"client"),this.client=t}async addChildren(t,...e){await v(this.client,hn.ADD_CHILDREN,{id:new R(t).payload,children:e.map(r=>new R(r).payload)},li,s.z.object({}))}async removeChildren(t,...e){await v(this.client,hn.REMOVE_CHILDREN,{id:new R(t).payload,children:e.map(r=>new R(r).payload)},li,s.z.object({}))}async moveChildren(t,e,...r){const n={from:new R(t).payload,to:new R(e).payload,children:r.map(i=>new R(i).payload)};await v(this.client,hn.MOVE_CHILDREN,n,Ad,s.z.object({}))}};const xd="/ontology/retrieve",Cd=s.z.object({ids:fe.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()}),Rd=s.z.object({resources:Od.array()}),dn=t=>N(t).map(e=>new R(e).payload);let jd=class{constructor(t,e){c(this,"type","ontology"),c(this,"groups"),c(this,"client"),c(this,"writer"),c(this,"framer"),this.client=t,this.writer=new kd(t),this.groups=new Id(t),this.framer=e}async search(t,e){return await this.execRetrieve({term:t,...e})}async retrieve(t,e){const r=await this.execRetrieve({ids:dn(t),...e});if(Array.isArray(t))return r;if(r.length===0)throw new we(`No resource found with ID ${t.toString()}`);return r[0]}async page(t,e,r){return await this.execRetrieve({offset:t,limit:e,...r})}async retrieveChildren(t,e){return await this.execRetrieve({ids:dn(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:dn(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,...r){return await this.writer.moveChildren(t,e,...r)}async openChangeTracker(){return await Fr.open(this.framer,this)}async openDependentTracker(t,e,r="parent",n="from"){return await rs.open(t,this,this.framer,e,r,n)}newSearcherWithOptions(t){return{type:this.type,search:e=>this.search(e,t),retrieve:e=>this.retrieve(e,t),page:(e,r)=>this.page(e,r,t)}}async execRetrieve(t){const{resources:e}=await v(this.client,xd,t,Cd,Rd);return e}};const ui="sy_ontology_resource_set",hi="sy_ontology_resource_delete",di="sy_ontology_relationship_set",fi="sy_ontology_relationship_delete";class Fr{constructor(e,r){c(this,"relationships"),c(this,"resources"),c(this,"resourceObs"),c(this,"relationshipObs"),c(this,"streamer"),c(this,"client"),c(this,"closePromise"),this.relationshipObs=new Ze.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Ze.Observer,this.resources=this.resourceObs,this.client=r,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 r=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);r.concat(n).length>0&&this.resourceObs.notify(r.concat(n));const i=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);i.concat(a).length>0&&this.relationshipObs.notify(i.concat(a))}parseRelationshipSets(e){const r=e.get(di);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"set",key:ci(n),value:void 0}))}parseRelationshipDeletes(e){const r=e.get(fi);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:ci(n)}))}async parseResourceSets(e){const r=e.get(ui);if(r.length===0)return[];const n=Array.from(r.as("string")).map(i=>new R(i));try{return(await this.client.retrieve(n)).map(i=>({variant:"set",key:i.id,value:i}))}catch(i){if(i instanceof we)return[];throw i}}parseResourceDeletes(e){const r=e.get(hi);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:new R(n)}))}static async open(e,r){const n=await e.openStreamer([ui,hi,di,fi]);return new Fr(n,r)}}class rs extends Ze.Observer{constructor(e,r,n,i,a="parent",o="from"){super(),c(this,"internal"),c(this,"target"),c(this,"direction"),c(this,"dependents"),c(this,"client"),c(this,"type"),c(this,"handleResourceChange",l=>{this.dependents=this.dependents.map(u=>{const d=l.find(f=>f.key.toString()==u.id.toString());return d==null||d.variant==="delete"?u:d.value}),this.notify(this.dependents)}),c(this,"handleRelationshipChange",l=>{const u=l.filter(f=>f.variant==="delete"&&f.key[this.direction].toString()===this.target.toString());this.dependents=this.dependents.filter(f=>!u.some(h=>h.key.to.toString()===f.id.toString()&&h.key.type===this.type));const d=l.filter(f=>f.variant==="set"&&f.key.type===this.type&&f.key[this.direction].toString()===this.target.toString());if(d.length===0)return this.notify(this.dependents);this.client.retrieve(d.map(f=>f.key.to)).then(f=>{this.dependents=this.dependents.concat(f),this.notify(this.dependents)})}),this.internal=r,this.target=e,this.dependents=n,this.client=i,this.type=a,this.direction=o,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,r,n,i,a="parent",o="from"){const l=await Fr.open(n,r);return new rs(e,l,i,r,a,o)}async close(){await this.internal.close()}}const Be=s.z.number(),Pt=s.z.object({name:s.z.string(),key:s.z.number(),rate:es.z,dataType:I.z,leaseholder:s.z.number(),index:s.z.number(),isIndex:s.z.boolean(),internal:s.z.boolean(),virtual:s.z.boolean(),alias:s.z.string().optional()}),Ja=Pt.extend({key:s.z.number().optional(),leaseholder:s.z.number().optional(),index:s.z.number().optional(),rate:es.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1)}),Ha="channel",$d=t=>new R({type:Ha,key:t.toString()}),Md=new Error("request for lock canceled");var Dd=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class Pd{constructor(e,r=Md){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,i)=>{const a={resolve:n,reject:i,weight:e,priority:r},o=Xa(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Dd(this,arguments,void 0,function*(r,n=1,i=0){const[a,o]=yield this.acquire(n,i);try{return yield r(a)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Bd(this._weightedWaiters[e-1],{resolve:n,priority:r})})}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 r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const i=n.findIndex(a=>a.priority<=e);(i===-1?n:n.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function Bd(t,e){const r=Xa(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Xa(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var Ud=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class Ld{constructor(e){this._semaphore=new Pd(1,e)}acquire(){return Ud(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}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 _r=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let i=N(t);const a=i[0],o=typeof a;let l;return o==="string"&&r&&!isNaN(parseInt(a))&&"number"in e?(l=e.number,i=i.map(u=>parseInt(u))):l=e[o],{single:n,variant:l,normalized:i,actual:t}},Wr=(t,e,r,n)=>{if(n){if(r.length===0)throw new Rr(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new jr(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},Ue=t=>s.z.union([s.z.null().transform(()=>[]),t.array()]),Yd=s.z.object({leaseholder:s.z.number().optional(),keys:s.z.number().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()}),qd=s.z.object({channels:Ue(Pt)}),je=t=>_r(t,{number:"keys",string:"names"}),Qa=class eo{constructor(e){c(this,"client"),this.client=e}async search(e,r){return await this.execute({search:e,...r})}async retrieve(e,r){const n=je(e),{variant:i}=n;let{normalized:a}=n;return i==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[i]:a,...r})}async page(e,r,n){return await this.execute({offset:e,limit:r,...n})}async execute(e){const[r,n]=await this.client.send(eo.ENDPOINT,e,Yd,qd);if(n!=null)throw n;return r.channels}};c(Qa,"ENDPOINT","/channel/retrieve");let ns=Qa;class ss{constructor(e){c(this,"cache"),c(this,"namesToKeys"),c(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,r){return await this.wrapped.search(e,r)}async page(e,r,n){return await this.wrapped.page(e,r,n)}async retrieve(e,r){const{normalized:n}=_r(e,{string:"names",number:"keys"}),i=[],a=[];if(n.forEach(l=>{const u=this.get(l);u!=null?i.push(...u):a.push(l)}),a.length===0)return i;const o=await this.wrapped.retrieve(a,r);return this.set(o),i.concat(o)}delete(e){const{variant:r,normalized:n}=je(e);r==="names"?n.forEach(i=>{const a=this.namesToKeys.get(i);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(i))}):n.forEach(i=>{const a=this.cache.get(i);a!=null&&(this.cache.delete(i),this.namesToKeys.delete(a.name))})}rename(e,r){e.forEach((n,i)=>{const a=r[i],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const l=this.namesToKeys.get(o.name);l!=null&&(l.delete(n),l.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(n,o);const u=this.namesToKeys.get(a);u==null?this.namesToKeys.set(a,new Set([n])):u.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const i=this.cache.get(e);return i==null?void 0:[i]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(i=>{const a=this.cache.get(i);a!=null&&n.push(a)}),n.length!==0)return n}}class to{constructor(e,r){c(this,"mu",new Ld),c(this,"requests",new Map),c(this,"wrapped"),c(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Jh(()=>{this.run()},r)}async search(e,r){return await this.wrapped.search(e,r)}async page(e,r,n){return await this.wrapped.page(e,r,n)}async retrieve(e){const{normalized:r,variant:n}=je(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((i,a)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:i,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(i=>e.add(i)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,i)=>n.resolve(r.filter(a=>i.includes(a.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const ro=async(t,e)=>{const{normalized:r}=je(e),n=await t.retrieve(r),i=[];if(r.forEach(a=>{n.find(o=>o.name===a||o.key===a)==null&&i.push(a)}),i.length>0)throw new we(`Could not find channels: ${JSON.stringify(i)}`);return n};class no{constructor({dataType:e,rate:r,name:n,leaseholder:i=0,key:a=0,isIndex:o=!1,index:l=0,internal:u=!1,virtual:d=!1,frameClient:f,alias:h}){c(this,"_frameClient"),c(this,"key"),c(this,"name"),c(this,"rate"),c(this,"dataType"),c(this,"leaseholder"),c(this,"index"),c(this,"isIndex"),c(this,"internal"),c(this,"alias"),c(this,"virtual"),this.key=a,this.name=n,this.rate=new es(r??0),this.dataType=new I(e),this.leaseholder=i,this.index=l,this.isIndex=o,this.internal=u,this.alias=h,this.virtual=d,this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new Z("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Pt.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})}get ontologyID(){return new R({type:"channel",key:this.key.toString()})}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const Fd="/channel/retrieve-group",_d=s.z.object({}),Wd=s.z.object({group:Za});let so=class{constructor(t,e,r,n){c(this,"type","channel"),c(this,"frameClient"),c(this,"client"),c(this,"retriever"),c(this,"writer"),this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let i=N(t),a=[];if(r){const o=await this.retriever.retrieve(i.map(u=>u.name)),l=new Set(o.map(u=>u.name));i=i.filter(u=>!l.has(u.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(i))),n?a[0]:a}async retrieve(t,e){const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return Wr("channel",t,n,r),r?n[0]:n}async search(t,e){return this.sugar(await this.retriever.search(t,e))}async delete(t){const{normalized:e,variant:r}=je(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(N(t),N(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,r)=>await this.page(e,r,t)}}async page(t,e,r){return this.sugar(await this.retriever.page(t,e,r))}createDebouncedBatchRetriever(t=10){return new ss(new to(new ns(this.client),t))}sugar(t){const{frameClient:e}=this;return t.map(r=>new no({...r,frameClient:e}))}async retrieveGroup(){const t=await v(this.client,Fd,{},_d,Wd);return new Ga(t.group.name,t.group.key)}};const Gd=s.z.object({channels:Ja.array()}),Zd=s.z.object({channels:Pt.array()}),Vd=s.z.object({keys:Be.array().optional(),names:s.z.string().array().optional()}),Kd=s.z.object({}),Jd=s.z.object({keys:Be.array(),names:s.z.string().array()}),Hd=s.z.object({}),Xd="/channel/create",Qd="/channel/delete",ef="/channel/rename";let io=class{constructor(t,e){c(this,"client"),c(this,"cache"),this.client=t,this.cache=e}async create(t){const{channels:e}=await v(this.client,Xd,{channels:t},Gd,Zd);return this.cache.set(e),e}async delete(t){await v(this.client,Qd,t,Vd,Kd),t.keys!=null&&this.cache.delete(t.keys),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await v(this.client,ef,{keys:t,names:e},Jd,Hd),this.cache.rename(t,e)}};const tf=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:ss,Channel:no,ChannelOntologyType:Ha,Client:so,ClusterRetriever:ns,DebouncedBatchRetriever:to,Writer:io,analyzeChannelParams:je,keyZ:Be,newPayload:Ja,ontologyID:$d,payload:Pt,retrieveRequired:ro},Symbol.toStringTag,{value:"Module"})),is=s.z.string().uuid(),as=s.z.object({key:is,subjects:fe.array(),objects:fe.array(),actions:s.z.string().array()}),rf=as.extend({key:is.optional()}),nf="/access/policy/create",sf="/access/policy/delete",af="/access/policy/retrieve",of=s.z.object({policies:rf.array()}),cf=s.z.object({policies:as.array()}),lf=s.z.object({keys:is.array()}),uf=s.z.object({}),hf=s.z.object({subject:fe}),df=s.z.object({policies:as.array().optional().default([])});let ff=class{constructor(t){c(this,"client"),this.client=t}async create(t){const e=!Array.isArray(t),{policies:r}=await v(this.client,nf,{policies:N(t)},of,cf);return e?r[0]:r}async retrieve(t){const{policies:e}=await v(this.client,af,{subject:t},hf,df);return e}async delete(t){await v(this.client,sf,{keys:N(t)},lf,uf)}};const yf="/user/register";let gf=class{constructor(t){c(this,"client"),this.client=t}async register(t,e){const{user:r}=await v(this.client,yf,{username:t,password:e},ao,oo);return r}};s.z.string().uuid();const pf=s.z.object({key:s.z.string(),username:s.z.string()}),ao=s.z.object({username:s.z.string(),password:s.z.string()}),oo=s.z.object({token:s.z.string(),user:pf}),yi="/auth/login",mf=3;let wf=class{constructor(t,e){c(this,"token"),c(this,"client"),c(this,"credentials"),c(this,"authenticating"),c(this,"authenticated"),c(this,"user"),c(this,"retryCount"),this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(yi)){this.authenticating==null&&(this.authenticating=new Promise((o,l)=>{this.client.send(yi,this.credentials,ao,oo).then(([u,d])=>{if(d!=null)return o(d);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}).catch(l)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[n,i]=await r(e);return Mn.matches(i)&&this.retryCount<mf?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,i])};return t}};const bf=["disconnected","connecting","connected","failed"],vf=s.z.enum(bf),Of=s.z.object({status:vf,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string()}),Tf=s.z.object({clusterKey:s.z.string()}),co={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},Nr=class lo{constructor(e,r=A.seconds(30),n){c(this,"_state"),c(this,"pollFrequency",A.seconds(30)),c(this,"client"),c(this,"name"),c(this,"interval"),c(this,"onChangeHandlers",[]),this._state={...co},this.client=e,this.pollFrequency=r,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const r=this._state.status;try{const[n,i]=await this.client.send(lo.ENDPOINT,{},s.z.object({}),Tf);if(i!=null)throw i;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&r!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};c(Nr,"ENDPOINT","/connectivity/check"),c(Nr,"DEFAULT",co),c(Nr,"connectionStateZ",Of);let uo=Nr;const Sf=s.z.object({keys:Be.array().optional(),bounds:ne.z,names:s.z.string().array().optional()}),zf=s.z.object({}),Nf="/frame/delete";class Ef{constructor(e){c(this,"client"),this.client=e}async delete(e){await v(this.client,Nf,e,Sf,zf)}}const gi=t=>{const e=N(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},pi=(t,e)=>{const r=N(t);if(r.length===e.length)return;const n=gi(t);throw gi===null?new Z("[Frame] - channel keys or names must be provided when constructing a frame."):new Z(`[Frame] - ${n}s and series must be the same length.
34
+ Got ${r.length} ${n}s and ${e.length} series.`)};let pe=class Je{constructor(e=[],r=[]){if(c(this,"columns",[]),c(this,"series",[]),e instanceof Je){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,i)=>this.push(i,...N(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e,i=n.series.map(a=>fo(a));pi(n.keys,i),n.keys.forEach((a,o)=>this.push(a,i[o]))}else Object.entries(e).forEach(([n,i])=>{const a=parseInt(n);if(isNaN(a))this.push(n,...N(i));else return this.push(a,...N(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=N(r),i=N(e);pi(i,n),n.forEach((a,o)=>this.push(i[o],a));return}throw new Z(`[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 me("colType is not key");return this.columns??[]}get uniqueKeys(){return si(this.keys)}get names(){if(this.colType==="key")throw new me("colType is not name");return this.columns??[]}get uniqueNames(){return si(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>yo(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(r=>r.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return ne.ZERO;const n=E.min(...this.series.map(a=>a.timeRange.start)),i=E.max(...this.series.map(a=>a.timeRange.end));return new ne(n,i)}const r=this.get(e);return r==null?ne.ZERO:r.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(r=>e.includes(r)):new Vh(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof Je){if(this.colType!==null&&e.colType!==this.colType)throw new Z("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...r),typeof e=="string"&&this.colType==="key")throw new Z("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new Z("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new Je([...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 r=new Je;return this.forEach((n,i,a)=>r.push(...e(n,i,a))),r}forEach(e){this.columns.forEach((r,n)=>{const i=this.series[n];e(r,i,n)})}at(e,r=!1){const n={};return this.uniqueColumns.forEach(i=>{n[i]=this.get(i).at(e,r)}),n}filter(e){const r=new Je;return this.columns.forEach((n,i)=>{const a=this.series[i];e(n,a,i)&&r.push(n,a)}),r}get byteLength(){return new kt(this.series.reduce((e,r)=>e.add(r.byteLength),kt.ZERO))}get length(){return this.series.reduce((e,r)=>e+r.length,0)}};const ho=s.z.object({timeRange:ne.z.optional(),alignment:s.z.bigint().or(s.z.string().transform(t=>BigInt(t))).optional(),dataType:I.z,data:s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer)}),Gr=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(()=>[]),ho.array().optional().default([])])}),fo=t=>{const{dataType:e,data:r,timeRange:n,alignment:i}=t;return new _e({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:i})},yo=t=>({timeRange:t._timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});class Zr{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new Zr(e);return await n.update(r),n}async update(e){const{variant:r,normalized:n}=je(e);if(r==="keys"){this.adapter=null,this.keys=n;return}const i=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(o=>{const l=i.find(u=>u.name===o);if(l==null)throw new Error(`Channel ${o} not found`);a.set(l.key,l.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const r=this.adapter;return e.map((n,i)=>{if(typeof n=="number"){const a=r.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,i]}return[n,i]})}}class os{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new os(e);return await n.update(r),n}async adaptObjectKeys(e){const r={};for(const[n,i]of Object.entries(e))r[await this.adaptToKey(n)]=i;return r}async update(e){const r=await ro(this.retriever,e);this.adapter=new Map(r.map(n=>[n.name,n.key])),this.keys=r.map(n=>n.key)}async fetchChannel(e){const r=await this.retriever.retrieve(e);if(r.length===0)throw new Error(`Channel ${e} not found`);return r[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}async adapt(e,r){if(typeof e=="string"||typeof e=="number"){if(r==null)throw new Z(`
37
+ Received a single channel name or key but no series.
38
+ `);if(Array.isArray(r)){if(r.some(u=>u instanceof _e||Array.isArray(u)))throw new Z(`
39
+ Received a single channel name or key but multiple series.
40
+ `);r=r}const o=await this.fetchChannel(e),l=new _e({data:r,dataType:o.dataType});return new pe(o.key,l)}if(Array.isArray(e)){if(r==null)throw new Z(`
41
+ Received an array of channel names or keys but no series.
42
+ `);if(!Array.isArray(r))throw new Z(`
43
+ Received an array of channel names or keys but no array of series.
44
+ `);const o=[],l=[];for(let u=0;u<e.length;u++){const d=await this.fetchChannel(e[u]);if(u>=r.length)throw new Z(`
45
+ Received an array of channel names or keys but not enough series.
46
+ `);const f=new _e({data:r[u],dataType:d.dataType});o.push(d.key),l.push(f)}return new pe(o,l)}if(e instanceof pe||e instanceof Map){const o=new pe(e);if(this.adapter==null)return o;let l=[];return l=o.columns.map(u=>{var d;const f=typeof u=="string"?(d=this.adapter)==null?void 0:d.get(u):u;if(f==null)throw new Z(`
47
+ Channel ${u} was not provided in the list of channels when opening the writer
48
+ `);return f}),new pe(l,o.series)}const n=[],i=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[l,u]=a[o],d=await this.fetchChannel(l),f=new _e({data:u,dataType:d.dataType});n.push(d.key),i.push(f)}return new pe(n,i)}}class cs{constructor(e,r){c(this,"name"),c(this,"stream"),this.stream=r,this.name=e}async receive(){const[e,r]=await this.stream.receive();if(r!=null)throw r;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,r]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
49
+ Please report this error to the Synnax team. ${JSON.stringify(e)}`),r!=null){if(De.matches(r))return;throw r}}}closeSend(){this.stream.closeSend()}send(e){const r=this.stream.send(e);if(r!=null)throw r}}const Dn=new A(-1);var ls=(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))(ls||{}),go=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(go||{});const If=s.z.object({command:s.z.nativeEnum(ls),span:A.z.optional(),bounds:ne.z.optional(),stamp:E.z.optional(),keys:s.z.number().array().optional(),chunkSize:s.z.number().optional()}),Af=s.z.object({variant:s.z.nativeEnum(go),ack:s.z.boolean(),command:s.z.nativeEnum(ls),error:Dt.optional().nullable(),frame:Gr.optional()}),po=class Pn{constructor(e,r){c(this,"stream"),c(this,"adapter"),c(this,"value"),this.stream=new cs("Iterator",e),this.value=new pe,this.adapter=r}static async _open(e,r,n,i,a={}){const o=await Zr.open(n,r),l=await i.stream(Pn.ENDPOINT,If,Af),u=new Pn(l,o);return await u.execute({command:0,keys:o.keys,bounds:new ne(e),chunkSize:a.chunkSize??1e5}),u}async next(e=Dn){return await this.execute({command:1,span:new A(e)})}async prev(e=Dn){return await this.execute({command:2,span:new A(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 kf(this)}async execute(e){for(this.stream.send(e),this.value=new pe;;){const r=await this.stream.receive();if(r.variant===1)return r.ack;this.value.push(this.adapter.adapt(new pe(r.frame)))}}};c(po,"ENDPOINT","/frame/iterate");let mo=po;class kf{constructor(e){c(this,"iter"),c(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 xf=s.z.object({start:E.z.optional(),keys:s.z.number().array()}),Cf=s.z.object({frame:Gr,error:Dt.optional().nullable()}),Rf="/frame/stream";class Vr{constructor(e,r){c(this,"stream"),c(this,"adapter"),this.stream=new cs("Streamer",e),this.adapter=r}get keys(){return this.adapter.keys}static async _open(e,r,{channels:n,from:i}){const a=await Zr.open(e,n),o=await r.stream(Rf,xf,Cf),l=new Vr(o,a);return o.send({start:new E(i),keys:a.keys}),l}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(De.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new pe((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class Bt extends Ze.Observer{constructor(e,r){super(r),c(this,"streamer"),c(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 us=(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))(us||{}),et=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(et||{});const jf=t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof t=="number"&&t in et)return t;throw new Error(`invalid writer mode: ${t}`)}},$f=new A(-1),Mf=s.z.object({start:E.z.optional(),controlSubject:Qe.subjectZ.optional(),keys:s.z.number().array().optional(),authorities:Qe.Authority.z.array().optional(),mode:s.z.nativeEnum(et).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:A.z.optional()}),Df=s.z.object({command:s.z.nativeEnum(us),config:Mf.optional(),frame:Gr.optional()}),Pf=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(us),error:Dt.optional().nullable()});var it;let wo=(it=class{constructor(t,e){c(this,"stream"),c(this,"adapter"),this.stream=new cs("Writer",t),this.adapter=e}static async _open(t,e,{channels:r,start:n=E.now(),authorities:i=Qe.Authority.Absolute,controlSubject:a,mode:o=1,errOnUnauthorized:l=!1,enableAutoCommit:u=!1,autoIndexPersistInterval:d=A.SECOND}){const f=await os.open(t,r),h=await e.stream(it.ENDPOINT,Df,Pf),D=new it(h,f);return await D.execute({command:0,config:{start:new E(n),keys:f.keys,controlSubject:a,authorities:N(i),mode:jf(o),errOnUnauthorized:l,enableAutoCommit:u,autoIndexPersistInterval:d}}),D}async write(t,e){const r=await this.adapter.adapt(t,e);return this.stream.send({command:1,frame:r.toPayload()}),!0}async setAuthority(t,e){let r={keys:[],authorities:[]};if(typeof t=="number"&&e==null)r={keys:[],authorities:[t]};else{let n;typeof t=="string"||typeof t=="number"?n={[t]:e}:n=t,n=await this.adapter.adaptObjectKeys(n),r={keys:Object.keys(n).map(i=>Number(i)),authorities:Object.values(n)}}return(await this.execute({command:4,config:r})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const t=await this.execute({command:3});return t.error!=null?Hn(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()}},c(it,"ENDPOINT","/frame/write"),it),bo=class{constructor(t,e,r){c(this,"streamClient"),c(this,"retriever"),c(this,"deleter"),this.streamClient=t,this.retriever=r,this.deleter=new Ef(e)}async openIterator(t,e,r){return await mo._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await wo._open(this.retriever,this.streamClient,t)}async openStreamer(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await Vr._open(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const i=e,a=await this.openWriter({start:t,channels:Object.keys(i),mode:et.Persist});try{await a.write(i),await a.commit()}finally{await a.close()}return}const n=await this.openWriter({start:t,channels:e,mode:et.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:A.MAX});try{await n.write(e,r)}finally{await n.close()}}async read(t,e){const{single:r}=je(e),n=await this.readFrame(t,e);return r?n.get(e):n}async readFrame(t,e){const r=await this.openIterator(t,e),n=new pe;try{for await(const i of r)n.push(i)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=je(t);return n==="keys"?await this.deleter.delete({keys:r,bounds:e}):await this.deleter.delete({names:r,bounds:e})}};const Bf=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:$f,AUTO_SPAN:Dn,Client:bo,Frame:pe,Iterator:mo,ObservableStreamer:Bt,Streamer:Vr,Writer:wo,WriterMode:et,frameZ:Gr,series:ho,seriesFromPayload:fo,seriesToPayload:yo},Symbol.toStringTag,{value:"Module"})),Uf=Qe.Authority,Lf=Qe.stateZ(s.z.number()),Yf=t=>{var e,r;return t.to==null?`${(e=t.from)==null?void 0:e.resource} - ${(r=t.from)==null?void 0:r.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 vo extends Bt{constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer);return this.merge(n),[n.transfers,!0]}),c(this,"states"),c(this,"codec"),this.states=new Map,this.codec=new tt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(r=>e.set(r.subject.key,r.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(r=>{r.from==null&&r.to==null&&console.warn("Invalid transfer: ",r),r.to==null?this.states.delete(r.from.resource):this.states.set(r.to.resource,r.to)})}}const qf="sy_node_1_control";let Oo=class{constructor(t){c(this,"framer"),this.framer=t}async openStateTracker(){const t=await this.framer.openStreamer(qf);return new vo(t)}};const Ff=Object.freeze(Object.defineProperty({__proto__:null,Authority:Uf,Client:Oo,StateTracker:vo,stateZ:Lf,transferString:Yf},Symbol.toStringTag,{value:"Module"}));let _f=class{constructor(t,e,r){c(this,"tasks"),c(this,"racks"),c(this,"devices"),this.tasks=t,this.racks=e,this.devices=r}};const Ut=s.z.number(),hs=s.z.object({key:Ut,name:s.z.string()}),Wf=hs.partial({key:!0}),ds=s.z.string(),Kr=s.z.object({key:ds,rack:Ut,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(t=>t===""?{}:tt.JSON_CODEC.decodeString(t)))}),Gf=Kr.extend({properties:s.z.unknown().transform(t=>tt.JSON_CODEC.encodeString(t))}),rt=async(t,e,r,n)=>{const i=await t.openStreamer([e,r]),a=o=>{const l=[];return r!=null&&l.push(...o.get(r).series.flatMap(u=>n("delete",u))),e!=null&&l.push(...o.get(e).series.flatMap(u=>n("set",u))),[l,l.length>0]};return new Bt(i,a)},Zf="sy_device_set",Vf="sy_device_delete",fn="/hardware/device/retrieve",Kf="/hardware/device/create",Jf="/hardware/device/delete",Hf=s.z.object({devices:Gf.array()}),Xf=s.z.object({devices:Kr.array()}),Qf=s.z.object({keys:ds.array()}),ey=s.z.object({}),yn=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:ds.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional()}),gn=s.z.object({devices:Ue(Kr)});let ty=class{constructor(t,e){c(this,"type","device"),c(this,"client"),c(this,"frameClient"),this.client=t,this.frameClient=e}async retrieve(t,e){const r=!Array.isArray(t),n=await v(this.client,fn,{keys:N(t),...e},yn,gn);return Wr("Device",t,n.devices,r),r?n.devices[0]:n.devices}async search(t,e){return(await v(this.client,fn,{search:t,...e},yn,gn)).devices}async page(t,e,r){return(await v(this.client,fn,{offset:t,limit:e,...r},yn,gn)).devices}async create(t){const e=!Array.isArray(t),r=await v(this.client,Kf,{devices:N(t)},Hf,Xf);return e?r.devices[0]:r.devices}async delete(t){await v(this.client,Jf,{keys:N(t)},Qf,ey)}async openDeviceTracker(){return await rt(this.frameClient,Zf,Vf,ry)}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,r)=>await this.page(e,r,t)}}};const ry=(t,e)=>t==="delete"?e.toStrings().map(r=>({variant:t,key:r,value:void 0})):e.parseJSON(Kr).map(r=>({variant:t,key:r.key,value:r})),pn="/hardware/rack/retrieve",ny="/hardware/rack/create",sy="/hardware/rack/delete",mn=s.z.object({keys:Ut.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),wn=s.z.object({racks:Ue(hs)}),iy=s.z.object({racks:Wf.array()}),ay=s.z.object({racks:hs.array()}),oy=s.z.object({keys:Ut.array()}),cy=s.z.object({});let ly=class{constructor(t,e,r){c(this,"type","rack"),c(this,"client"),c(this,"frameClient"),c(this,"tasks"),this.client=t,this.frameClient=e,this.tasks=r}async delete(t){await v(this.client,sy,{keys:N(t)},oy,cy)}async create(t){const e=!Array.isArray(t),r=await v(this.client,ny,{racks:N(t)},iy,ay),n=this.sugar(r.racks);return e?n[0]:n}async search(t){const e=await v(this.client,pn,{search:t},mn,wn);return this.sugar(e.racks)}async page(t,e){const r=await v(this.client,pn,{offset:t,limit:e},mn,wn);return this.sugar(r.racks)}async retrieve(t){const{variant:e,normalized:r,single:n}=_r(t,{string:"names",number:"keys"}),i=await v(this.client,pn,{[e]:r},mn,wn),a=this.sugar(i.racks);return Wr("Rack",t,a,n),n?a[0]:a}sugar(t){return t.map(({key:e,name:r})=>new uy(e,r,this.tasks))}};class uy{constructor(e,r,n){c(this,"key"),c(this,"name"),c(this,"tasks"),this.key=e,this.name=r,this.tasks=n}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(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 Lt=s.z.union([s.z.string(),s.z.bigint().transform(t=>t.toString()),s.z.number().transform(t=>t.toString())]),Mr=s.z.object({task:Lt,variant:s.z.string(),key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t))).or(s.z.array(s.z.unknown())).or(s.z.null())}),fs=s.z.object({key:Lt,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(t=>t===""?{}:tt.JSON_CODEC.decodeString(t))),state:Mr.optional().nullable()}),hy=fs.omit({key:!0}).extend({key:Lt.transform(t=>t.toString()).optional(),config:s.z.unknown().transform(t=>tt.JSON_CODEC.encodeString(t))});s.z.object({task:Lt,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t)))});const Et="sy_task_state",mi="sy_task_cmd";class dy{constructor(e,r,n,i,a,o=!1,l){c(this,"key"),c(this,"name"),c(this,"internal"),c(this,"type"),c(this,"config"),c(this,"state"),c(this,"frameClient"),this.key=e,this.name=r,this.type=n,this.config=i,this.internal=o,l!==null&&(this.state=l),this.frameClient=a}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}async executeCommand(e,r){const n=await this.frameClient.openWriter(mi),i=qh.id();return await n.write(mi,[{task:this.key,type:e,key:i,args:r}]),await n.close(),i}async executeCommandSync(e,r,n){const i=await this.frameClient.openStreamer(Et),a=await this.executeCommand(e,r);let o;const l=new Promise(u=>setTimeout(()=>u(!1),new A(n).milliseconds));for(;;){const u=await Promise.any([i.read(),l]);if(u===!1)throw new Error("Command timed out");const d=Mr.safeParse(u.at(-1).sy_task_state);if(d.success){if(o=d.data,o.key===a)break}else console.error(d.error)}return i.close(),o}async openStateObserver(){return new Bt(await this.frameClient.openStreamer(Et),e=>{const r=e.get(Et);if(r.length===0)return[null,!1];const n=Mr.safeParse(r.at(-1));if(!n.success)return[null,!1];const i=n.data;return i.task!==this.key?[null,!1]:[i,!0]})}}const fy=s.z.object({rack:Ut.optional(),keys:s.z.string().array().optional(),names:s.z.string().array().optional(),offset:s.z.number().optional(),limit:s.z.number().optional(),includeState:s.z.boolean().optional()}),yy=s.z.object({tasks:Ue(fs)}),gy="/hardware/task/retrieve",py="/hardware/task/create",my="/hardware/task/delete",wy=s.z.object({tasks:hy.array()}),by=s.z.object({tasks:fs.array()}),vy=s.z.object({keys:Lt.array()}),Oy=s.z.object({});let Ty=class{constructor(t,e){c(this,"type","task"),c(this,"client"),c(this,"frameClient"),this.client=t,this.frameClient=e}async create(t){const e=!Array.isArray(t),r=await v(this.client,py,{tasks:N(t)},wy,by),n=this.sugar(r.tasks);return e?n[0]:n}async delete(t){await v(this.client,my,{keys:N(t)},vy,Oy)}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:r,normalized:n,variant:i}=_r(t,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};i==="rack"?a.rack=t:a.keys=n;const o=await this.execRetrieve(a),l=this.sugar(o);return r&&i!=="rack"?l[0]:l}async retrieveByName(t,e){const r=await this.execRetrieve({names:[t],rack:e});return Wr("Task",t,r,!0),this.sugar(r)[0]}async execRetrieve(t){return(await v(this.client,gy,t,fy,yy)).tasks}sugar(t){return t.map(({key:e,name:r,type:n,config:i,state:a,internal:o})=>new dy(e,r,n,i,this.frameClient,o,a))}async openTracker(){return await rt(this.frameClient,"sy_task_set","sy_task_delete",(t,e)=>Array.from(e).map(r=>({variant:t,key:r.toString(),value:r.toString()})))}async openStateObserver(){return new Bt(await this.frameClient.openStreamer(Et),t=>{const e=t.get(Et);if(e.length===0)return[null,!1];const r=Mr.safeParse(e.at(-1));return r.success?[r.data,!0]:[null,!1]})}};const Yt=s.z.string().uuid(),Jr=s.z.object({key:Yt,name:s.z.string().min(1),color:s.z.string()}),Sy=s.z.object({keys:Yt.array().optional(),for:fe.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),zy=s.z.object({labels:Ue(Jr)});var Jt;let Ny=(Jt=class{constructor(t){c(this,"client"),this.client=t}async retrieve(t){const e=N(t);return await this.execute({keys:e})}async retrieveFor(t){return await this.execute({for:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){const[e,r]=await this.client.send(Jt.ENDPOINT,t,Sy,zy);if(r!=null)throw r;return e.labels}},c(Jt,"ENDPOINT","/label/retrieve"),Jt);const Ey=Jr.extend({key:Yt.optional()}),Iy=s.z.object({labels:Ey.array()}),Ay=s.z.object({labels:Jr.array()}),ky=s.z.object({keys:Yt.array()}),To=s.z.object({id:fe,labels:Yt.array(),replace:s.z.boolean().optional()}),xy=To.omit({replace:!0}),bn=s.z.object({}),Cy="/label/create",Ry="/label/delete",jy="/label/set",$y="/label/remove";let My=class{constructor(t){c(this,"client"),this.client=t}async create(t){return(await v(this.client,Cy,{labels:N(t)},Iy,Ay)).labels}async delete(t){await v(this.client,Ry,{keys:N(t)},ky,bn)}async set(t,e,{replace:r}={}){await v(this.client,jy,{id:t,labels:e,replace:r},To,bn)}async remove(t,e){await v(this.client,$y,{id:t,labels:e},xy,bn)}};const Dy="sy_label_set",Py="sy_label_delete";let By=class{constructor(t,e,r){c(this,"type","label"),c(this,"retriever"),c(this,"writer"),c(this,"frameClient"),c(this,"ontology"),this.writer=new My(t),this.retriever=new Ny(t),this.frameClient=e,this.ontology=r}async search(t){return await this.retriever.search(t)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async retrieveFor(t){return await this.retriever.retrieveFor(new R(t))}async label(t,e,r={}){await this.writer.set(new R(t),e,r)}async removeLabels(t,e){await this.writer.remove(new R(t),e)}async page(t,e){return await this.retriever.page(t,e)}async create(t){const e=Array.isArray(t),r=await this.writer.create(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}async openChangeTracker(){return await rt(this.frameClient,Dy,Py,Uy)}async trackLabelsOf(t){const e=new Ze.Observer,r=(await this.retrieveFor(t)).map(n=>({id:new R({key:n.key,type:"label"}),key:n.key,name:n.name,data:n}));return(await this.ontology.openDependentTracker(new R(t),r,"labeled_by")).onChange(n=>e.notify(n.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 Uy=(t,e)=>t==="delete"?e.toUUIDs().map(r=>({variant:t,key:r})):e.parseJSON(Jr).map(r=>({variant:t,key:r.key,value:r})),de=s.z.string().uuid(),qt=s.z.object({key:de,name:s.z.string().min(1),timeRange:ne.z,color:s.z.string().optional()}),So=qt.extend({key:s.z.string().uuid().optional()}),zo=t=>{const e=N(t),r=e.length===0;let n=!1;return r||(n=de.safeParse(e[0]).success),{single:!Array.isArray(t),variant:n?"keys":"names",normalized:e,actual:t,empty:r}},No="range",Eo="range-alias",Ly=t=>new R({type:No,key:t}),Yy=t=>new R({type:Eo,key:t}),qy="sy_range_alias_set",Fy="sy_range_alias_delete",_y=s.z.object({range:de,aliases:s.z.string().array()}),Wy=s.z.object({aliases:s.z.record(s.z.string(),Be)}),Gy=s.z.object({range:de,aliases:s.z.record(Be.or(s.z.string()),s.z.string())}),Zy=s.z.unknown(),Vy=s.z.object({range:de,channels:Be.array()}),Ky=s.z.unknown(),Jy=s.z.object({range:de}),Hy=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),bt=class vt{constructor(e,r,n){c(this,"frameClient"),c(this,"cache",new Map),c(this,"client"),c(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=r}async resolve(e){const r=[],n=typeof e=="string",i={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const l=this.cache.get(o);l!=null?i[o]=l:r.push(o)});if(r.length===0)return i;const a=await v(this.client,vt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:r},_y,Wy);return Object.entries(a.aliases).forEach(([o,l])=>this.cache.set(o,l)),n?a.aliases[r[0]]:{...i,...a.aliases}}async set(e){await v(this.client,vt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Gy,Zy)}async list(){return(await v(this.client,vt.LIST_ENDPOINT,{range:this.rangeKey},Jy,Hy)).aliases}async delete(e){await v(this.client,vt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Vy,Ky)}async openChangeTracker(){return await rt(this.frameClient,qy,Fy,tg(this.rangeKey))}};c(bt,"SET_ENDPOINT","/range/alias/set"),c(bt,"RESOLVE_ENDPOINT","/range/alias/resolve"),c(bt,"LIST_ENDPOINT","/range/alias/list"),c(bt,"DELETE_ENDPOINT","/range/alias/delete");let Xy=bt;const Qy=s.z.object({range:de,channel:Be,alias:s.z.string()}),eg="---",tg=t=>(e,r)=>e==="delete"?r.toStrings().filter(n=>n.split(eg)[0]===t).map(n=>({variant:e,key:n,value:void 0})):r.parseJSON(Qy).map(n=>({variant:e,key:n.alias,value:n})),rg=s.z.object({range:de,keys:s.z.string().array()}),ys=s.z.object({range:de,key:s.z.string(),value:s.z.string()}),ng=s.z.object({pairs:Ue(ys)}),sg=s.z.object({range:de,pairs:ys.array()}),ig=s.z.object({range:de,keys:s.z.string().array()}),Er=class Ir{constructor(e,r,n){c(this,"rangeKey"),c(this,"client"),c(this,"frameClient"),this.rangeKey=e,this.client=r,this.frameClient=n}async get(e){const r=await v(this.client,Ir.GET_ENDPOINT,{range:this.rangeKey,keys:N(e)},rg,ng);return typeof e=="string"?r.pairs[0].value:Object.fromEntries(r.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,r=""){let n;Xn(e)?n=Object.entries(e).map(([i,a])=>({range:this.rangeKey,key:i,value:a})):n=[{range:this.rangeKey,key:e,value:r}],await v(this.client,Ir.SET_ENDPOINT,{range:this.rangeKey,pairs:n},sg,s.z.unknown())}async delete(e){await v(this.client,Ir.DELETE_ENDPOINT,{range:this.rangeKey,keys:N(e)},ig,s.z.unknown())}async openTracker(){return await rt(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,r)=>e==="delete"?r.toStrings().map(n=>{const[i,a]=n.split("<--->",2);return{variant:e,key:n,value:{range:i,key:a,value:""}}}):r.parseJSON(ys).map(n=>({variant:e,key:`${n.range}${n.key}`,value:n})))}};c(Er,"GET_ENDPOINT","/range/kv/get"),c(Er,"SET_ENDPOINT","/range/kv/set"),c(Er,"DELETE_ENDPOINT","/range/kv/delete");let Bn=Er;const vn=t=>new R({type:"range",key:t});class Io{constructor(e,r=ne.ZERO,n,i,a,o,l,u,d,f,h){c(this,"key"),c(this,"name"),c(this,"kv"),c(this,"timeRange"),c(this,"color"),c(this,"channels"),c(this,"aliaser"),c(this,"frameClient"),c(this,"labelClient"),c(this,"ontologyClient"),c(this,"rangeClient"),this.key=n,this.name=e,this.timeRange=r,this.frameClient=a,this.color=i,this.kv=o,this.aliaser=l,this.channels=u,this.labelClient=d,this.ontologyClient=f,this.rangeClient=h}get ontologyID(){return new R({key:this.key,type:"range"})}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new we(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:r})}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})).map(r=>r.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(vn(this.key))}async addLabel(...e){await this.labelClient.label(vn(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(vn(this.key),e)}async openChildRangeTracker(){const e=new Ze.Observer,r=(await this.retrieveChildren()).map(i=>{const a=new R({key:i.key,type:"range"});return{id:a,key:a.toString(),name:i.name,data:i.payload}}),n=await this.ontologyClient.openDependentTracker(this.ontologyID,r);return n.onChange(i=>e.notify(this.rangeClient.resourcesToRanges(i))),e.setCloser(async()=>await n.close()),e}async openParentRangeTracker(){const e=new Ze.Observer,r=await this.retrieveParent();if(r==null)return null;const n=new R({key:r.key,type:"range"}),i={id:n,key:n.toString(),name:r.name,data:r.payload},a=await this.ontologyClient.openDependentTracker(this.ontologyID,[i],"parent","to");return a.onChange(o=>{const l=this.rangeClient.resourcesToRanges(o);if(l.length===0)return;const u=l[0];e.notify(u)}),e.setCloser(async()=>await a.close()),e}}const ag=s.z.object({keys:de.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:ne.z.optional(),limit:s.z.number().int().optional(),offset:s.z.number().int().optional()}),og="/range/retrieve",cg=s.z.object({ranges:Ue(qt)});let Ao=class{constructor(t,e,r,n,i,a){c(this,"type","range"),c(this,"frameClient"),c(this,"writer"),c(this,"unaryClient"),c(this,"channels"),c(this,"labelClient"),c(this,"ontologyClient"),this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.labelClient=i,this.ontologyClient=a}async create(t,e){const r=!Array.isArray(t),n=this.sugar(await this.writer.create(N(t),e));return r?n[0]:n}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(N(t))}async search(t){return this.sugar(await this.execRetrieve({term:t}))}async page(t,e){return this.sugar(await this.execRetrieve({offset:t,limit:e}))}async retrieve(t){if(typeof t=="object"&&"start"in t)return await this.execRetrieve({overlapsWith:new ne(t)});const{single:e,actual:r,variant:n,normalized:i,empty:a}=zo(t);if(a)return[];const o=await this.execRetrieve({[n]:i});if(!e)return o;if(o.length===0)throw new Rr(`range matching ${r} not found`);if(o.length>1)throw new jr(`multiple ranges matching ${r} found`);return o[0]}getKV(t){return new Bn(t,this.unaryClient,this.frameClient)}async execRetrieve(t){const{ranges:e}=await v(this.unaryClient,og,t,ag,cg);return this.sugar(e)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents({key:t,type:"range"});if(e.length===0)return null;const r=e[0];return r.id.type!=="range"?null:await this.retrieve(r.id.key)}sugar(t){return t.map(e=>new Io(e.name,e.timeRange,e.key,e.color,this.frameClient,new Bn(e.key,this.unaryClient,this.frameClient),new Xy(e.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this))}async openTracker(){return await rt(this.frameClient,"sy_range_set","sy_range_delete",(t,e)=>t==="delete"?e.toStrings().map(r=>({variant:t,key:r,value:void 0})):this.sugar(e.parseJSON(qt)).map(r=>({variant:t,key:r.key,value:r})))}resourcesToRanges(t){return this.sugar(t.map(e=>{var r,n;return{key:e.id.key,name:(r=e.data)==null?void 0:r.name,timeRange:new ne((n=e.data)==null?void 0:n.timeRange)}}))}};const lg=s.z.object({ranges:qt.array()}),ug=s.z.object({parent:fe.optional(),ranges:So.array()}),hg=s.z.object({keys:de.array()}),dg=s.z.object({}),fg=s.z.object({key:de,name:s.z.string()}),yg=s.z.object({}),gg="/range/create",pg="/range/delete",mg="/range/rename";let ko=class{constructor(t){c(this,"client"),this.client=t}async rename(t,e){await v(this.client,mg,{key:t,name:e},fg,yg)}async create(t,e){return(await v(this.client,gg,{ranges:t,...e},ug,lg)).ranges}async delete(t){await v(this.client,pg,{keys:t},hg,dg)}};const wg=Object.freeze(Object.defineProperty({__proto__:null,Client:Ao,KV:Bn,Range:Io,RangeAliasOntologyType:Eo,RangeOntologyType:No,Writer:ko,analyzeParams:zo,keyZ:de,newPayloadZ:So,payloadZ:qt,rangeAliasOntologyID:Yy,rangeOntologyID:Ly},Symbol.toStringTag,{value:"Module"})),bg="/api/v1/";class vg{constructor(e,r=!1){c(this,"url"),c(this,"unary"),c(this,"stream"),c(this,"secure"),this.secure=r,this.url=e.child(bg);const n=new tt.JSONCodec;this.unary=new Fu(this.url,n,this.secure),this.stream=new Xu(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const gs=s.z.string().uuid(),ps=s.z.object({key:s.z.string(),name:s.z.string(),data:ts.or(s.z.string().transform(t=>JSON.parse(t)))}),Og=s.z.object({keys:s.z.string().array()}),Tg=s.z.object({linePlots:ps.array()});let Sg=class{constructor(t){c(this,"ENDPOINT","/workspace/lineplot/retrieve"),c(this,"client"),this.client=t}async retrieve(t){const e=N(t);return(await v(this.client,this.ENDPOINT,{keys:e},Og,Tg)).linePlots}};const Ve=s.z.string().uuid(),xo=t=>JSON.parse(t),Co=s.z.object({name:s.z.string(),key:Ve,layout:ts.or(s.z.string().transform(t=>xo(t)))}),Ro=Co.omit({layout:!0}).extend({layout:s.z.string().transform(t=>xo(t))}),zg=ps.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Ng=s.z.object({workspace:Ve,linePlots:zg.array()}),Eg=s.z.object({linePlots:ps.array()}),Ig=s.z.object({keys:gs.array()}),Ag=s.z.object({}),kg=s.z.object({key:gs,name:s.z.string()}),xg=s.z.object({}),Cg=s.z.object({key:gs,data:s.z.string()}),Rg=s.z.object({}),jg="/workspace/lineplot/create",$g="/workspace/lineplot/delete",Mg="/workspace/lineplot/rename",Dg="/workspace/lineplot/set-data";let Pg=class{constructor(t){c(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await v(this.client,jg,{workspace:t,linePlots:[r]},Ng,Eg)).linePlots[0]}async delete(t){const e=N(t);await v(this.client,$g,{keys:e},Ig,Ag)}async rename(t,e){await v(this.client,Mg,{key:t,name:e},kg,xg)}async setData(t,e){await v(this.client,Dg,{key:t,data:JSON.stringify(e)},Cg,Rg)}},Bg=class{constructor(t){c(this,"writer"),c(this,"retriever"),this.writer=new Pg(t),this.retriever=new Sg(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}};const Ug=s.z.object({keys:Ve.array().optional(),search:s.z.string().optional(),author:s.z.string().uuid().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Lg=s.z.object({workspaces:Ue(Ro)});var Ht;let Yg=(Ht=class{constructor(t){c(this,"client"),this.client=t}async retrieve(t){const e=N(t);return await this.execute({keys:e})}async retrieveByAuthor(t){return await this.execute({author:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){return(await v(this.client,Ht.ENDPOINT,t,Ug,Lg)).workspaces}},c(Ht,"ENDPOINT","/workspace/retrieve"),Ht);const Hr=s.z.string().uuid(),qg=s.z.object({key:s.z.string(),name:s.z.string(),data:ts.or(s.z.string().transform(t=>JSON.parse(t))),snapshot:s.z.boolean()}),ms=s.z.object({key:s.z.string(),name:s.z.string(),snapshot:s.z.boolean(),data:s.z.string().transform(t=>JSON.parse(t))}),Fg=s.z.object({keys:s.z.string().array()}),_g=s.z.object({schematics:ms.array()});class Wg{constructor(e){c(this,"ENDPOINT","/workspace/schematic/retrieve"),c(this,"client"),this.client=e}async retrieve(e){return(await v(this.client,this.ENDPOINT,{keys:N(e)},Fg,_g)).schematics}}const Gg=qg.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Zg=s.z.object({workspace:Ve,schematics:Gg.array()}),Vg=s.z.object({schematics:ms.array()}),Kg=s.z.object({keys:Hr.array()}),Jg=s.z.object({}),Hg=s.z.object({key:Hr,name:s.z.string()}),wi=s.z.object({}),Xg=s.z.object({key:Hr,data:s.z.string()});s.z.object({});const Qg=s.z.object({key:Hr,name:s.z.string(),snapshot:s.z.boolean()}),ep=s.z.object({schematic:ms}),tp="/workspace/schematic/create",rp="/workspace/schematic/delete",np="/workspace/schematic/rename",sp="/workspace/schematic/set-data",ip="/workspace/schematic/copy";let ap=class{constructor(t){c(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await v(this.client,tp,{workspace:t,schematics:[r]},Zg,Vg)).schematics[0]}async copy(t,e,r){return(await v(this.client,ip,{key:t,name:e,snapshot:r},Qg,ep)).schematic}async delete(t){const e=N(t);await v(this.client,rp,{keys:e},Kg,Jg)}async rename(t,e){await v(this.client,np,{key:t,name:e},Hg,wi)}async setData(t,e){await v(this.client,sp,{key:t,data:JSON.stringify(e)},Xg,wi)}},op=class{constructor(t){c(this,"writer"),c(this,"retriever"),this.writer=new ap(t),this.retriever=new Wg(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}async copy(t,e,r){return await this.writer.copy(t,e,r)}};const cp=Co.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),lp=s.z.object({workspaces:cp.array()}),up=s.z.object({workspaces:Ro.array()}),hp=s.z.object({keys:Ve.array()}),dp=s.z.object({}),fp=s.z.object({key:Ve,name:s.z.string()}),yp=s.z.object({}),gp=s.z.object({key:Ve,layout:s.z.string()}),pp=s.z.object({}),mp="/workspace/create",wp="/workspace/delete",bp="/workspace/rename",vp="/workspace/set-layout";class Op{constructor(e){c(this,"client"),this.client=e}async create(e){return(await v(this.client,mp,{workspaces:N(e)},lp,up)).workspaces}async delete(e){await v(this.client,wp,{keys:N(e)},hp,dp)}async rename(e,r){await v(this.client,bp,{key:e,name:r},fp,yp)}async setLayout(e,r){await v(this.client,vp,{key:e,layout:JSON.stringify(r)},gp,pp)}}class Tp{constructor(e){c(this,"type","workspace"),c(this,"schematic"),c(this,"linePlot"),c(this,"retriever"),c(this,"writer"),this.schematic=new op(e),this.linePlot=new Bg(e),this.retriever=new Yg(e),this.writer=new Op(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const r=Array.isArray(e),n=await this.retriever.retrieve(e);return r?n:n[0]}async page(e,r){return await this.retriever.page(e,r)}async create(e){const r=Array.isArray(e),n=await this.writer.create(e);return r?n:n[0]}async rename(e,r){await this.writer.rename(e,r)}async setLayout(e,r){await this.writer.setLayout(e,r)}async delete(...e){await this.writer.delete(e)}}const jo=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:A.z.default(A.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional()});class $o extends bo{constructor(e){const r=jo.parse(e),{host:n,port:i,username:a,password:o,connectivityPollFrequency:l,secure:u}=r,d=new vg(new od({host:n,port:Number(i)}),u);d.use(gd);let f;a!=null&&o!=null&&(f=new wf(d.unary,{username:a,password:o}),d.use(f.middleware()));const h=new ss(new ns(d.unary)),D=new io(d.unary,h);super(d.stream,d.unary,h),c(this,"createdAt"),c(this,"props"),c(this,"ranges"),c(this,"channels"),c(this,"auth"),c(this,"user"),c(this,"access"),c(this,"connectivity"),c(this,"ontology"),c(this,"workspaces"),c(this,"labels"),c(this,"hardware"),c(this,"control"),c(this,"transport"),this.createdAt=E.now(),this.props=r,this.auth=f,this.transport=d,this.channels=new so(this,h,d.unary,D),this.connectivity=new uo(d.unary,l,r.name),this.control=new Oo(this),this.ontology=new jd(d.unary,this);const W=new ko(this.transport.unary);this.labels=new By(this.transport.unary,this,this.ontology),this.ranges=new Ao(this,W,this.transport.unary,h,this.labels,this.ontology),this.access=new ff(this.transport.unary),this.user=new gf(this.transport.unary),this.workspaces=new Tp(this.transport.unary);const se=new ty(this.transport.unary,this),j=new Ty(this.transport.unary,this),ec=new ly(this.transport.unary,this,j);this.hardware=new _f(j,ec,se)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}c($o,"connectivity",uo);const Sp=Qe.Authority,Un=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof s.z.ZodError){const i=n.errors.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${r} - ${i.join(`
50
+ `)}`)}else throw n}};var zp=Object.defineProperty,Np=(t,e,r)=>e in t?zp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,H=(t,e,r)=>Np(t,typeof e!="symbol"?e+"":e,r);const Ln=class Mo{constructor(e,r,n="",i=!1){H(this,"_noop",!1),H(this,"key"),H(this,"path"),H(this,"serviceName"),this.key=e,this.path=r,this.serviceName=n,this._noop=i}child(e){return new Mo(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};H(Ln,"NOOP",new Ln("","",""));let ws=Ln;const Yn=["debug","info","warn","error"],Ep=t=>{const e=Yn.indexOf(t);return({level:r})=>Yn.indexOf(r)>=e},Ip=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(i=>n.startsWith(i))||r!=null&&r.some(i=>n.startsWith(i)))},qn=class Do{constructor(e={}){H(this,"meta",ws.NOOP),H(this,"filters");const{filters:r=[]}=e;this.filters=r}filter(e){return!this.meta.noop&&this.filters.every(r=>r({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const r=new Do({filters:this.filters});return r.meta=e,r}debug(e,r,n=!1){!this.filter("debug")&&!n||(r==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,Xt(r)))}info(e,r,n=!1){!this.filter("info")&&!n||(r==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,Xt(r)))}warn(e,r,n=!1){!this.filter("warn")&&!n||(r==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,Xt(r)))}error(e,r,n=!1){!this.filter("error")&&!n||(r==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,Xt(r)))}};H(qn,"NOOP",new qn);let Po=qn;const Xt=t=>typeof t=="function"?t():t;var Ap=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},We="1.8.0",bi=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function kp(t){var e=new Set([t]),r=new Set,n=t.match(bi);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(l){return l===t};function a(l){return r.add(l),!1}function o(l){return e.add(l),!0}return function(l){if(e.has(l))return!0;if(r.has(l))return!1;var u=l.match(bi);if(!u)return a(l);var d={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return d.prerelease!=null||i.major!==d.major?a(l):i.major===0?i.minor===d.minor&&i.patch<=d.patch?o(l):a(l):i.minor<=d.minor?o(l):a(l)}}var xp=kp(We),Cp=We.split(".")[0],xt=Symbol.for("opentelemetry.js.api."+Cp),Ct=Ap;function bs(t,e,r,n){var i;n===void 0&&(n=!1);var a=Ct[xt]=(i=Ct[xt])!==null&&i!==void 0?i:{version:We};if(!n&&a[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(a.version!==We){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+t+" does not match previously registered API v"+We);return r.error(o.stack||o.message),!1}return a[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+We+"."),!0}function Rt(t){var e,r,n=(e=Ct[xt])===null||e===void 0?void 0:e.version;if(!(!n||!xp(n)))return(r=Ct[xt])===null||r===void 0?void 0:r[t]}function vs(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+We+".");var r=Ct[xt];r&&delete r[t]}var Rp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},jp=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},$p=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return at("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return at("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return at("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return at("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return at("verbose",this._namespace,e)},t}();function at(t,e,r){var n=Rt("diag");if(n)return r.unshift(e),n[t].apply(n,jp([],Rp(r),!1))}var ye;(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"})(ye||(ye={}));function Mp(t,e){t<ye.NONE?t=ye.NONE:t>ye.ALL&&(t=ye.ALL),e=e||{};function r(n,i){var a=e[n];return typeof a=="function"&&t>=i?a.bind(e):function(){}}return{error:r("error",ye.ERROR),warn:r("warn",ye.WARN),info:r("info",ye.INFO),debug:r("debug",ye.DEBUG),verbose:r("verbose",ye.VERBOSE)}}var Dp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Pp=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},Bp="diag",jt=function(){function t(){function e(i){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var l=Rt("diag");if(l)return l[i].apply(l,Pp([],Dp(a),!1))}}var r=this,n=function(i,a){var o,l,u;if(a===void 0&&(a={logLevel:ye.INFO}),i===r){var d=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=d.stack)!==null&&o!==void 0?o:d.message),!1}typeof a=="number"&&(a={logLevel:a});var f=Rt("diag"),h=Mp((l=a.logLevel)!==null&&l!==void 0?l:ye.INFO,i);if(f&&!a.suppressOverrideMessage){var D=(u=new Error().stack)!==null&&u!==void 0?u:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+D),h.warn("Current logger will overwrite one already registered from "+D)}return bs("diag",h,r,!0)};r.setLogger=n,r.disable=function(){vs(Bp,r)},r.createComponentLogger=function(i){return new $p(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),Up=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Lp=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Yp=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=Up(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var a=new t(this._entries);try{for(var o=Lp(n),l=o.next();!l.done;l=o.next()){var u=l.value;a._entries.delete(u)}}catch(d){e={error:d}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return a},t.prototype.clear=function(){return new t},t}();jt.instance();function qp(t){return t===void 0&&(t={}),new Yp(new Map(Object.entries(t)))}function Fp(t){return Symbol.for(t)}var _p=function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var a=new t(r._currentContext);return a._currentContext.set(n,i),a},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t}(),Wp=new _p,Gp={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Zp={set:function(t,e,r){t!=null&&(t[e]=r)}},Vp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Kp=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},Jp=function(){function t(){}return t.prototype.active=function(){return Wp},t.prototype.with=function(e,r,n){for(var i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return r.call.apply(r,Kp([n],Vp(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),Hp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Xp=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},On="context",Qp=new Jp,Bo=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return bs(On,e,jt.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Xp([e,r,n],Hp(a),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Rt(On)||Qp},t.prototype.disable=function(){this._getContextManager().disable(),vs(On,jt.instance())},t}(),Fn;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Fn||(Fn={}));var em=Bo.getInstance(),tm=function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t}(),Os=Fp("OpenTelemetry Baggage Key");function Uo(t){return t.getValue(Os)||void 0}function rm(){return Uo(Bo.getInstance().active())}function nm(t,e){return t.setValue(Os,e)}function sm(t){return t.deleteValue(Os)}var Tn="propagation",im=new tm,am=function(){function t(){this.createBaggage=qp,this.getBaggage=Uo,this.getActiveBaggage=rm,this.setBaggage=nm,this.deleteBaggage=sm}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return bs(Tn,e,jt.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Zp),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Gp),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){vs(Tn,jt.instance())},t.prototype._getGlobalPropagator=function(){return Rt(Tn)||im},t}(),om=am.getInstance();const vi=["bench","debug","prod"],cm=t=>e=>vi.indexOf(e)>=vi.indexOf(t),_n=class Lo{constructor(e,r=cm("debug")){H(this,"meta",ws.NOOP),H(this,"tracer"),H(this,"filter"),this.tracer=e,this.filter=r}child(e){const r=new Lo(this.tracer,this.filter);return r.meta=e,r}debug(e,r){return this.trace(e,"debug",r)}bench(e,r){return this.trace(e,"bench",r)}prod(e,r){return this.trace(e,"prod",r)}trace(e,r,n){return this.meta.noop||!this.filter(r)?n(new Fo(e)):this.tracer.startActiveSpan(e,i=>{const a=new qo(e,i),o=n(a);return i.end(),o})}propagate(e){if(this.meta.noop)return;const r=em.active();om.inject(r,e,{set:(n,i,a)=>{n[i]=a}})}};H(_n,"NOOP",new _n);let Yo=_n;class qo{constructor(e,r){H(this,"key"),H(this,"otel"),this.key=e,this.otel=r}set(e,r){this.otel.setAttribute(e,r)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Fn.ERROR}))}}class Fo{constructor(e){H(this,"key"),this.key=e}set(){}recordError(e){}}const Wn=class _o{constructor({key:e="",serviceName:r="",logger:n=Po.NOOP,tracer:i=Yo.NOOP,noop:a=!1,__meta:o}){H(this,"meta"),H(this,"T"),H(this,"L"),this.meta=o??new ws(e,e,r,a),this.T=i.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new _o({__meta:r,tracer:this.T,logger:this.L})}};H(Wn,"NOOP",new Wn({noop:!0}));let Ts=Wn;const lm=Ts.NOOP,Wo=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Ts,LOG_LEVELS:Yn,Logger:Po,NOOP:lm,NoopSpan:Fo,Tracer:Yo,_Span:qo,logLevelKeyFiler:Ip,logThresholdFilter:Ep},Symbol.toStringTag,{value:"Module"})),um=new Error("request for lock canceled");var hm=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class dm{constructor(e,r=um){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,i)=>{const a={resolve:n,reject:i,weight:e,priority:r},o=Go(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return hm(this,arguments,void 0,function*(r,n=1,i=0){const[a,o]=yield this.acquire(n,i);try{return yield r(a)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),fm(this._weightedWaiters[e-1],{resolve:n,priority:r})})}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 r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const i=n.findIndex(a=>a.priority<=e);(i===-1?n:n.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function fm(t,e){const r=Go(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Go(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var ym=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class Zo{constructor(e){this._semaphore=new dm(1,e)}acquire(){return ym(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}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 Xr{constructor(e,r,n=new Map){P(this,"providers");P(this,"registry");P(this,"sender");P(this,"changedKeys");this.providers=n,this.registry=r,this.changedKeys=[],this.sender=e}propagateState(e,r,n=[]){this.sender.send({key:e,state:r},n)}copyAndMerge(e){const r=new Xr(this.sender,this.registry,new Map);return e==null||e.providers.forEach((n,i)=>r.providers.set(i,n)),this.providers.forEach((n,i)=>r.providers.set(i,n)),r.changedKeys=[],r}get changed(){return this.changedKeys.length>0}set(e,r,n=!0){this.providers.set(e,r),n&&this.changedKeys.push(e)}setIfNotHas(e,r){this.providers.has(e)||this.set(e,r)}async create(e){const r=this.registry[e.type];if(r==null)throw new Error(`[AetherRoot.create] - could not find component ${e.type}`);const n=new r(e);return await n.internalUpdate(e),n}getOptional(e){return this.providers.get(e)??null}has(e){return this.providers.has(e)}get(e){const r=this.getOptional(e);if(r==null)throw new Error(`[AetherRoot.get] - could not find provider ${e}`);return r}}class Ss{constructor(e){P(this,"type");P(this,"key");P(this,"_ctx");P(this,"_internalState");P(this,"_state");P(this,"_prevState");P(this,"_deleted",!1);P(this,"instrumentation");P(this,"schema");this.type=e.type,this.key=e.path[0],this._ctx=e.ctx,this._internalState={},this.instrumentation=e.instrumentation.child(`${this.type}(${this.key})`)}get _schema(){if(this.schema==null)throw new Z(`[AetherLeaf] - expected subclass to define component schema, but none was found.
51
+ Make sure to defne a property 'schema' on the class.`);return this.schema}setState(e){const r=Kn(e,this._state);this._prevState={...this._state},this._state=Un(this._schema,r,`${this.type}:${this.key}`),this.ctx.propagateState(this.key,r)}get ctx(){if(this._ctx==null)throw new me("context not defined");return this._ctx}get state(){if(this._state==null)throw new me("state not defined");return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}async internalUpdate({variant:e,path:r,ctx:n,state:i}){if(!this.deleted){if(this._ctx=n,e==="state"){this.validatePath(r);const a=Un(this._schema,i,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:Ni.difference(this.state,a)})):this.instrumentation.L.debug("setting initial state",{state:i}),this._prevState=this._state??a,this._state=a}else this.instrumentation.L.debug("updating context");await this.afterUpdate()}}async internalDelete(e){this.validatePath(e),this._deleted=!0,await this.afterDelete()}beforeUpdate(){}async afterUpdate(){}async afterDelete(){}validatePath(e){if(e.length===0)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`)}}class Ft extends Ss{constructor(r){super(r);P(this,"_children");this._children=new Map}get children(){return Array.from(this._children.values())}async internalUpdate(r){const{variant:n,path:i}=r;if(n==="context")return this._ctx=r.ctx.copyAndMerge(this._ctx),await this.updateContext({...r,ctx:this.ctx});const[a,o]=this.getRequiredKey(i),l={...r,ctx:this.ctx};return o.length===0?await this.updateThis(a,l):await this.updateChild(o,l)}async updateContext(r){await super.internalUpdate(r);for(const n of this.children)await n.internalUpdate({...r,ctx:this.ctx,variant:"context"})}async updateChild(r,n){const i=r[0],a=this.getChild(i);if(a!=null)return await a.internalUpdate({...n,path:r});if(r.length>1)throw new Error(`[Composite.setState] - ${this.type}:${this.key} could not find child with key ${i} while updating `);this._children.set(i,await n.ctx.create({...n,path:r}))}async updateThis(r,n){const i=n.ctx.copyAndMerge(this._ctx);if(r!==this.key)throw new me(`[Composite.update] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`);if(await super.internalUpdate({...n,ctx:i}),!!i.changed){this.instrumentation.L.debug("context changed",{changedKeys:i.changedKeys});for(const a of this.children)await a.internalUpdate({...n,ctx:this.ctx,variant:"context"})}}async internalDelete(r){const[n,i]=this.getRequiredKey(r);if(i.length===0){if(n!==this.key)throw new Error(`[Composite.delete] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`);const o=this.children;this._children=new Map;for(const l of o)await l.internalDelete([l.key]);await super.internalDelete([this.key])}const a=this.getChild(i[0]);a!=null&&(i.length>1?await a.internalDelete(i):(this._children.delete(a.key),await a.internalDelete(i)))}getRequiredKey(r,n){const[i,...a]=r;if(i==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path`+(n!=null?` for ${n}`:""));return[i,a]}getChild(r){return this._children.get(r)??null}childrenOfType(...r){return this.children.filter(n=>r.includes(n.type))}}const gm=s.z.object({}),Ee=class Ee extends Ft{constructor({worker:r,registry:n,instrumentation:i=Wo.Instrumentation.NOOP}){const o={ctx:new Xr(r,n,new Map),...Ee.ZERO_UPDATE,instrumentation:i};super(o);P(this,"wrap");P(this,"schema",Ee.schema);P(this,"mu",new Zo);this.mu.runExclusive(async()=>await this.internalUpdate(o)),this.wrap=r,this.wrap.handle(l=>{this.mu.runExclusive(async()=>await this.handle(l))})}async handle(r){if(r.variant==="delete")await this.internalDelete(r.path);else{const n={...r,variant:"state",ctx:this.ctx,instrumentation:this.instrumentation};await this.internalUpdate(n)}}};P(Ee,"TYPE","root"),P(Ee,"KEY","root"),P(Ee,"ZERO_UPDATE",{path:[Ee.KEY],type:Ee.TYPE,variant:"state",state:{}}),P(Ee,"schema",gm);let Dr=Ee;const Vo=t=>new Dr(t),pm=Object.freeze(Object.defineProperty({__proto__:null,Composite:Ft,Context:Xr,Leaf:Ss,Root:Dr,render:Vo},Symbol.toStringTag,{value:"Module"})),Ko="pluto-theming-context",mm=s.z.object({theme:qi}),It=class It extends Ft{constructor(){super(...arguments);P(this,"schema",It.z)}async afterUpdate(){this.ctx.set(Ko,this.state.theme)}};P(It,"TYPE","theming.Provider"),P(It,"z",mm);let $t=It;const wm=t=>t.get(Ko),bm={[$t.TYPE]:$t},Jo=["success","error","warning","info","loading","disabled","secondary"],Ho=s.z.enum(Jo),Xo=s.z.object({key:s.z.string(),variant:Ho,message:s.z.string(),description:s.z.string().optional(),time:_.z,data:s.z.record(s.z.unknown()).optional()}),Qo=s.z.object({statuses:Xo.array()}),zs="status.aggregator";class Pr extends Ft{constructor(){super(...arguments);P(this,"schema",Qo)}async afterUpdate(){this.ctx.set(zs,this)}add(r){const n=_.now();this.setState(i=>({...i,statuses:[...i.statuses,{time:n,key:n.toString(),...r}]}))}}P(Pr,"TYPE","status.Aggregator");const vm=t=>{const e=t.get(zs);return e.add.bind(e)},Om=t=>{const e=t.getOptional(zs);return e!=null?e.add.bind(e):()=>{}},Tm={[Pr.TYPE]:Pr};exports.$=Pc;exports.$e=_e;exports.A=Jc;exports.Aggregator=Pr;exports.B=Ts;exports.By=Ff;exports.C=pl;exports.C$1=Ur;exports.ComponentSizeLevels=Yi;exports.Composite=Ft;exports.E=vc;exports.F=ne;exports.G=yl;exports.I=ce;exports.L=gl;exports.LEVELS=Li;exports.Leaf=Ss;exports.LevelComponentSizes=vl;exports.Mutex=Zo;exports.N=A;exports.N$1=ki;exports.N$2=dl;exports.Provider=$t;exports.Q=we;exports.REGISTRY=bm;exports.REGISTRY$1=Tm;exports.S=hc;exports.S$1=E;exports.SYNNAX_DARK=_i;exports.SYNNAX_LIGHT=Fi;exports.SYNNAX_THEMES=kl;exports.Se=me;exports.U=At;exports.VARIANTS=Jo;exports.Zy=Bf;exports._=Ni;exports.aether=pm;exports.aggregatorStateZ=Qo;exports.c=Si;exports.commonjsGlobal=nc;exports.cy=jo;exports.d=$;exports.dimensions=Tl;exports.ed=wg;exports.executeInitialSetter=Mt;exports.executeSetter=Kn;exports.fontString=jl;exports.g=Wo;exports.getAugmentedNamespace=ic;exports.getDefaultExportFromCjs=sc;exports.isSetter=Vn;exports.j=Z;exports.l=il;exports.levelZ=bl;exports.ly=$o;exports.m=_;exports.mt=Dc;exports.n=Xc;exports.o=Hc;exports.o$1=Oc;exports.od=Sp;exports.prettyParse=Un;exports.r=Tc;exports.render=Vo;exports.specZ=Me;exports.specZ$1=Xo;exports.state=wl;exports.themeZ=qi;exports.u=Zn;exports.use=wm;exports.useAggregate=vm;exports.useOptionalAggregate=Om;exports.usePassthrough=Bi;exports.usePurePassthrough=Ui;exports.variantZ=Ho;exports.w=G;exports.w$1=Ri;exports.wt=Bc;exports.xy=tf;exports.yt=_c;