@synnaxlabs/pluto 0.40.1 → 0.41.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 (352) hide show
  1. package/dist/{Center-CFEPOi_x.js → Center-Dr9Np3yZ.js} +3 -3
  2. package/dist/Center-sJghNsrv.cjs +1 -0
  3. package/dist/ContextMenu-DCxj35_j.cjs +1 -0
  4. package/dist/ContextMenu-GUed89mt.js +96 -0
  5. package/dist/DateTime-D6J8sRSH.cjs +1 -0
  6. package/dist/{DateTime-Djw6pb3W.js → DateTime-DEbT6v4l.js} +2 -2
  7. package/dist/{Divider-CMyzWvRC.js → Divider-Bpe7zJig.js} +585 -506
  8. package/dist/Divider-CloQr3vQ.cjs +22 -0
  9. package/dist/Dropdown-4Cti-bbQ.js +328 -0
  10. package/dist/Dropdown-C7Im-qW-.cjs +1 -0
  11. package/dist/{Haul-CaLW9ULm.js → Haul-Bw54Yj6J.js} +9 -9
  12. package/dist/{Haul-4OcHX8__.cjs → Haul-hv7TLQ7N.cjs} +1 -1
  13. package/dist/Item-9WCCzBv2.js +110 -0
  14. package/dist/Item-piF6rFAm.cjs +1 -0
  15. package/dist/{Keyboard--YA9DHRz.js → Keyboard-634856lT.js} +11 -9
  16. package/dist/Keyboard-CZFi6COK.cjs +1 -0
  17. package/dist/{Link-BT_Kwmlr.js → Link-BEheZd26.js} +1 -1
  18. package/dist/{Link-Bhto2KVL.cjs → Link-fkoogssj.cjs} +1 -1
  19. package/dist/Pack-D6Z6WuZl.cjs +1 -0
  20. package/dist/Pack-DhZO_rza.js +48 -0
  21. package/dist/Provider-DNTq46b0.cjs +1 -0
  22. package/dist/Provider-UAXPVomG.js +452 -0
  23. package/dist/Space-BtaH1buB.cjs +1 -0
  24. package/dist/Space-DunsWl06.js +100 -0
  25. package/dist/{Text-B7AC8Z1e.js → Text-3PiRcn8q.js} +313 -299
  26. package/dist/Text-BTEov6di.cjs +1 -0
  27. package/dist/Text-CaRMYy3U.js +135 -0
  28. package/dist/Text-DNspRcte.js +36 -0
  29. package/dist/Text-DylGoRKw.cjs +4 -0
  30. package/dist/Text-X_BHez8W.cjs +1 -0
  31. package/dist/Toggle-BKKBcuTj.cjs +1 -0
  32. package/dist/Toggle-CZd8L4GI.js +379 -0
  33. package/dist/{Video-TjJf_tXI.js → Video-4XQ1qozd.js} +1 -1
  34. package/dist/{Video-hdvNT3La.cjs → Video-BM9uJLaQ.cjs} +1 -1
  35. package/dist/WithIcon-CC-RSx6r.js +93 -0
  36. package/dist/WithIcon-Dn8eAoMj.cjs +1 -0
  37. package/dist/{aggregator-QqWwGnYH.cjs → aggregator-74jWxDne.cjs} +1 -1
  38. package/dist/{aggregator-AgOKLWHz.js → aggregator-DMvP8cai.js} +6 -6
  39. package/dist/align.cjs +1 -1
  40. package/dist/align.js +1 -1
  41. package/dist/button.cjs +1 -1
  42. package/dist/button.js +1 -1
  43. package/dist/color.cjs +1 -1
  44. package/dist/color.js +1 -1
  45. package/dist/css-Cj2UCGXB.cjs +1 -0
  46. package/dist/{css-rxwBYwM1.js → css-Dyt-QnKy.js} +467 -462
  47. package/dist/css.cjs +1 -1
  48. package/dist/css.js +2 -2
  49. package/dist/{deep-T1-57GfG.js → deep-Cvb4bVYY.js} +1 -1
  50. package/dist/{deep-DsH2ji6Z.cjs → deep-ICSlPm58.cjs} +1 -1
  51. package/dist/{dimensions-C9PXLcE0.js → dimensions-Cc0z-IDd.js} +1 -1
  52. package/dist/dimensions-Djqdrqi0.cjs +1 -0
  53. package/dist/dropdown.cjs +1 -1
  54. package/dist/dropdown.js +1 -1
  55. package/dist/{eraser-D2I1qgOg.cjs → eraser-9-LOWZvk.cjs} +3 -3
  56. package/dist/{eraser-Dmishn8h.js → eraser-BjtEI-1I.js} +10 -10
  57. package/dist/ether.cjs +1 -1
  58. package/dist/ether.js +32 -31
  59. package/dist/{external-Cs8oKwvw.cjs → external-B-Cao-ae.cjs} +1 -1
  60. package/dist/external-B-UNCzPY.cjs +1 -0
  61. package/dist/external-B18FBGpk.cjs +1 -0
  62. package/dist/{external-upiAayc4.js → external-BCUxzSzk.js} +32 -31
  63. package/dist/{external-DCflyFdb.js → external-BFOrrNde.js} +3 -3
  64. package/dist/external-BG1mV1W8.cjs +1 -0
  65. package/dist/{external-_b4lTCfZ.js → external-BIwhkj24.js} +455 -453
  66. package/dist/external-BWeX0nyq.js +399 -0
  67. package/dist/{external-CcIx4j5m.js → external-BY2AjzRx.js} +10 -10
  68. package/dist/external-BbmpRAH3.cjs +1 -0
  69. package/dist/{external-JNlv7kxI.js → external-BbrPEGJw.js} +2 -2
  70. package/dist/external-BlUic3Vz.js +29 -0
  71. package/dist/{external-C3e9emVy.js → external-C0ZRdtdj.js} +21 -20
  72. package/dist/{external-D12g_huj.js → external-CH66YjTZ.js} +18 -17
  73. package/dist/{external-DTjOTICM.js → external-CVGidiDt.js} +2 -2
  74. package/dist/{external-D_21zZAf.cjs → external-CnxSp7fm.cjs} +1 -1
  75. package/dist/{external-BWb18P9x.cjs → external-D2vS6j9c.cjs} +2 -2
  76. package/dist/external-DHmQqAfL.js +435 -0
  77. package/dist/{external-B9nbHICv.js → external-DNF8yEwq.js} +3261 -3282
  78. package/dist/{external-DkQnAvKo.cjs → external-DRGfSFQT.cjs} +1 -1
  79. package/dist/{external-dLVcM8tt.cjs → external-DVajt6X6.cjs} +1 -1
  80. package/dist/external-DX4m-5qT.cjs +1 -0
  81. package/dist/external-DlywBW-S.cjs +1 -0
  82. package/dist/{external-ClyfPgqG.cjs → external-kZf9CjYn.cjs} +14 -14
  83. package/dist/{font-CcRdsA3n.js → font-BXKdXsr5.js} +2 -2
  84. package/dist/{font-Bas26Jn-.cjs → font-DCE90lco.cjs} +1 -1
  85. package/dist/fontString-BBvH9Ypy.cjs +1 -0
  86. package/dist/fontString-C7Q9Laqk.js +28 -0
  87. package/dist/header.cjs +1 -1
  88. package/dist/header.js +1 -1
  89. package/dist/hooks-BQJQyGWV.js +293 -0
  90. package/dist/hooks-ClXSlga9.cjs +1 -0
  91. package/dist/{state-CUPEHHgf.js → index-CSKP1UPN.js} +292 -354
  92. package/dist/index-Ch3utIMa.cjs +15 -0
  93. package/dist/index.cjs +7 -7
  94. package/dist/index.js +7413 -6474
  95. package/dist/input.cjs +1 -1
  96. package/dist/input.js +1 -1
  97. package/dist/list.cjs +1 -1
  98. package/dist/list.js +1 -1
  99. package/dist/menu.cjs +1 -1
  100. package/dist/menu.js +1 -1
  101. package/dist/pluto.css +1 -1
  102. package/dist/{provider-Dq9t3iAH.js → provider-CH0eoGfz.js} +2131 -2085
  103. package/dist/provider-D054LCpB.cjs +53 -0
  104. package/dist/src/aether/main.d.ts +48 -0
  105. package/dist/src/aether/main.d.ts.map +1 -1
  106. package/dist/src/align/Center.d.ts +2 -2
  107. package/dist/src/align/Center.d.ts.map +1 -1
  108. package/dist/src/align/Pack.d.ts +3 -3
  109. package/dist/src/align/Pack.d.ts.map +1 -1
  110. package/dist/src/align/Space.d.ts +25 -10
  111. package/dist/src/align/Space.d.ts.map +1 -1
  112. package/dist/src/align/Stack.d.ts +7 -0
  113. package/dist/src/align/Stack.d.ts.map +1 -0
  114. package/dist/src/align/external.d.ts +1 -0
  115. package/dist/src/align/external.d.ts.map +1 -1
  116. package/dist/src/breadcrumb/Breadcrumb.d.ts +2 -2
  117. package/dist/src/breadcrumb/Breadcrumb.d.ts.map +1 -1
  118. package/dist/src/button/Button.d.ts +2 -4
  119. package/dist/src/button/Button.d.ts.map +1 -1
  120. package/dist/src/button/Icon.d.ts +4 -1
  121. package/dist/src/button/Icon.d.ts.map +1 -1
  122. package/dist/src/button/Toggle.d.ts +0 -1
  123. package/dist/src/button/Toggle.d.ts.map +1 -1
  124. package/dist/src/caret/Animated.d.ts +3 -2
  125. package/dist/src/caret/Animated.d.ts.map +1 -1
  126. package/dist/src/channel/LinePlot.d.ts +1 -1
  127. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  128. package/dist/src/channel/Select.d.ts +3 -3
  129. package/dist/src/channel/Select.d.ts.map +1 -1
  130. package/dist/src/color/Picker.d.ts.map +1 -1
  131. package/dist/src/css/css.d.ts +2 -1
  132. package/dist/src/css/css.d.ts.map +1 -1
  133. package/dist/src/divider/Divider.d.ts +4 -4
  134. package/dist/src/divider/Divider.d.ts.map +1 -1
  135. package/dist/src/dropdown/Dropdown.d.ts +2 -1
  136. package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
  137. package/dist/src/generic/Generic.d.ts +4 -5
  138. package/dist/src/generic/Generic.d.ts.map +1 -1
  139. package/dist/src/hardware/device/Select.d.ts.map +1 -1
  140. package/dist/src/icon/Icon.d.ts.map +1 -1
  141. package/dist/src/input/DateTime.d.ts.map +1 -1
  142. package/dist/src/input/Item.d.ts +1 -1
  143. package/dist/src/input/Item.d.ts.map +1 -1
  144. package/dist/src/input/Text.d.ts +1 -1
  145. package/dist/src/input/Text.d.ts.map +1 -1
  146. package/dist/src/input/types.d.ts +0 -1
  147. package/dist/src/input/types.d.ts.map +1 -1
  148. package/dist/src/list/Column.d.ts +3 -3
  149. package/dist/src/list/Column.d.ts.map +1 -1
  150. package/dist/src/list/Core.d.ts +1 -1
  151. package/dist/src/list/Core.d.ts.map +1 -1
  152. package/dist/src/list/Hover.d.ts +3 -2
  153. package/dist/src/list/Hover.d.ts.map +1 -1
  154. package/dist/src/list/Item.d.ts +1 -1
  155. package/dist/src/list/Item.d.ts.map +1 -1
  156. package/dist/src/main.d.ts.map +1 -1
  157. package/dist/src/menu/ContextMenu.d.ts +5 -3
  158. package/dist/src/menu/ContextMenu.d.ts.map +1 -1
  159. package/dist/src/menu/Item.d.ts.map +1 -1
  160. package/dist/src/menu/Menu.d.ts +3 -2
  161. package/dist/src/menu/Menu.d.ts.map +1 -1
  162. package/dist/src/modal/Modal.d.ts +7 -3
  163. package/dist/src/modal/Modal.d.ts.map +1 -1
  164. package/dist/src/mosaic/Mosaic.d.ts +5 -3
  165. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  166. package/dist/src/mosaic/tree.d.ts +4 -3
  167. package/dist/src/mosaic/tree.d.ts.map +1 -1
  168. package/dist/src/mosaic/types.d.ts +6 -6
  169. package/dist/src/nav/Bar.d.ts +2 -1
  170. package/dist/src/nav/Bar.d.ts.map +1 -1
  171. package/dist/src/nav/Drawer.d.ts +3 -2
  172. package/dist/src/nav/Drawer.d.ts.map +1 -1
  173. package/dist/src/notation/Select.d.ts +2 -3
  174. package/dist/src/notation/Select.d.ts.map +1 -1
  175. package/dist/src/notation/index.d.ts +1 -1
  176. package/dist/src/notation/index.d.ts.map +1 -1
  177. package/dist/src/os/Controls/Windows.d.ts +1 -1
  178. package/dist/src/os/Controls/Windows.d.ts.map +1 -1
  179. package/dist/src/os/Controls/types.d.ts +2 -0
  180. package/dist/src/os/Controls/types.d.ts.map +1 -1
  181. package/dist/src/ranger/TimeRangeChip.d.ts +2 -1
  182. package/dist/src/ranger/TimeRangeChip.d.ts.map +1 -1
  183. package/dist/src/resize/Core.d.ts +5 -4
  184. package/dist/src/resize/Core.d.ts.map +1 -1
  185. package/dist/src/resize/Multiple.d.ts.map +1 -1
  186. package/dist/src/resize/Single.d.ts.map +1 -1
  187. package/dist/src/select/Button.d.ts.map +1 -1
  188. package/dist/src/select/List.d.ts.map +1 -1
  189. package/dist/src/select/Multiple.d.ts.map +1 -1
  190. package/dist/src/status/Notification.d.ts.map +1 -1
  191. package/dist/src/status/aether/aggregator.d.ts +8 -8
  192. package/dist/src/status/aether/types.d.ts +2 -2
  193. package/dist/src/status/colors.d.ts +1 -1
  194. package/dist/src/status/colors.d.ts.map +1 -1
  195. package/dist/src/table/aether/Table.d.ts +3 -3
  196. package/dist/src/table/cells/Cells.d.ts +2 -2
  197. package/dist/src/tabs/Selector.d.ts +5 -2
  198. package/dist/src/tabs/Selector.d.ts.map +1 -1
  199. package/dist/src/tabs/Tabs.d.ts +2 -3
  200. package/dist/src/tabs/Tabs.d.ts.map +1 -1
  201. package/dist/src/tabs/types.d.ts +4 -4
  202. package/dist/src/tag/Tag.d.ts.map +1 -1
  203. package/dist/src/telem/aether/transformers.d.ts +6 -6
  204. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  205. package/dist/src/telem/control/aether/chip.d.ts +8 -8
  206. package/dist/src/telem/control/aether/indicator.d.ts +8 -8
  207. package/dist/src/text/Editable.d.ts.map +1 -1
  208. package/dist/src/text/Keyboard.d.ts +1 -1
  209. package/dist/src/text/Keyboard.d.ts.map +1 -1
  210. package/dist/src/text/WithIcon.d.ts +3 -2
  211. package/dist/src/text/WithIcon.d.ts.map +1 -1
  212. package/dist/src/text/core/types.d.ts.map +1 -1
  213. package/dist/src/theming/Provider.d.ts.map +1 -1
  214. package/dist/src/theming/aether/provider.d.ts +650 -530
  215. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  216. package/dist/src/theming/core/fontString.d.ts.map +1 -1
  217. package/dist/src/theming/core/theme.d.ts +229 -187
  218. package/dist/src/theming/core/theme.d.ts.map +1 -1
  219. package/dist/src/theming/css.d.ts +1 -1
  220. package/dist/src/theming/css.d.ts.map +1 -1
  221. package/dist/src/theming/static/generate.d.ts +2 -0
  222. package/dist/src/theming/static/generate.d.ts.map +1 -0
  223. package/dist/src/tooltip/Dialog.d.ts.map +1 -1
  224. package/dist/src/tree/Tree.d.ts +1 -1
  225. package/dist/src/tree/Tree.d.ts.map +1 -1
  226. package/dist/src/tree/core.d.ts +2 -2
  227. package/dist/src/tree/core.d.ts.map +1 -1
  228. package/dist/src/triggers/Provider.d.ts.map +1 -1
  229. package/dist/src/triggers/Text.d.ts.map +1 -1
  230. package/dist/src/triggers/hooks.d.ts +1 -0
  231. package/dist/src/triggers/hooks.d.ts.map +1 -1
  232. package/dist/src/util/component.d.ts +2 -2
  233. package/dist/src/util/component.d.ts.map +1 -1
  234. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  235. package/dist/src/vis/diagram/aether/Diagram.d.ts +3 -3
  236. package/dist/src/vis/diagram/aether/types.d.ts +8 -8
  237. package/dist/src/vis/draw2d/index.d.ts +16 -1
  238. package/dist/src/vis/draw2d/index.d.ts.map +1 -1
  239. package/dist/src/vis/eraser/use.d.ts +2 -2
  240. package/dist/src/vis/eraser/use.d.ts.map +1 -1
  241. package/dist/src/vis/legend/Container.d.ts +6 -6
  242. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  243. package/dist/src/vis/legend/Simple.d.ts +9 -1
  244. package/dist/src/vis/legend/Simple.d.ts.map +1 -1
  245. package/dist/src/vis/line/aether/line.d.ts +3 -2
  246. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  247. package/dist/src/vis/lineplot/Legend.d.ts.map +1 -1
  248. package/dist/src/vis/lineplot/aether/XAxis.d.ts +6 -6
  249. package/dist/src/vis/lineplot/aether/YAxis.d.ts +6 -6
  250. package/dist/src/vis/lineplot/aether/axis.d.ts +3 -3
  251. package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
  252. package/dist/src/vis/lineplot/range/aether/annotation.d.ts +6 -6
  253. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
  254. package/dist/src/vis/log/Log.d.ts.map +1 -1
  255. package/dist/src/vis/log/aether/Log.d.ts +12 -12
  256. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  257. package/dist/src/vis/schematic/Forms.d.ts +7 -1
  258. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  259. package/dist/src/vis/schematic/Symbols.d.ts +54 -5
  260. package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
  261. package/dist/src/vis/schematic/primitives/Primitives.d.ts +41 -1
  262. package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
  263. package/dist/src/vis/schematic/registry.d.ts +1 -1
  264. package/dist/src/vis/schematic/registry.d.ts.map +1 -1
  265. package/dist/src/vis/value/Form.d.ts.map +1 -1
  266. package/dist/src/vis/value/aether/value.d.ts +6 -6
  267. package/dist/src/vis/value/aether/value.d.ts.map +1 -1
  268. package/dist/src/vis/value/use.d.ts +2 -2
  269. package/dist/state-Bd_8X2jl.cjs +1 -0
  270. package/dist/state-CjGemC7S.js +88 -0
  271. package/dist/tabs.cjs +1 -1
  272. package/dist/tabs.js +1 -1
  273. package/dist/text.cjs +1 -1
  274. package/dist/text.js +2 -2
  275. package/dist/theme.css +1600 -0
  276. package/dist/theming.cjs +1 -1
  277. package/dist/theming.js +2 -2
  278. package/dist/{transformColorsToHex-B2Bui-Wf.cjs → transformColorsToHex-DE7uEs1w.cjs} +1 -1
  279. package/dist/{transformColorsToHex-B6dG2LA6.js → transformColorsToHex-UBrryWh5.js} +1 -1
  280. package/dist/tree.cjs +1 -1
  281. package/dist/tree.js +1 -1
  282. package/dist/triggers.cjs +1 -1
  283. package/dist/triggers.js +1 -1
  284. package/dist/{units-CvIf5nF_.cjs → units-DjoHPrqM.cjs} +1 -1
  285. package/dist/{units-D7qkgH-s.js → units-MBd0L3ff.js} +1 -1
  286. package/dist/useClickOutside-4k9PAT_i.cjs +1 -0
  287. package/dist/{useClickOutside-N6MHxbOe.js → useClickOutside-BYjsXGgb.js} +28 -28
  288. package/dist/{useDebouncedCallback-vg2DKTH7.cjs → useDebouncedCallback-BBsAgC9k.cjs} +1 -1
  289. package/dist/{useDebouncedCallback-D4Ec7whQ.js → useDebouncedCallback-Dg4BDGP-.js} +1 -1
  290. package/dist/{useMemoCompare-Cq_C2ddc.js → useMemoCompare-BEDaTIXL.js} +2 -2
  291. package/dist/useMemoCompare-DORTZbzY.cjs +1 -0
  292. package/dist/useVirtualCursorDragWebKit-BSafZVD_.cjs +1 -0
  293. package/dist/{useVirtualCursorDragWebKit-BBTGd7Xe.js → useVirtualCursorDragWebKit-BixysrXI.js} +25 -24
  294. package/dist/{value-Dk2DJbst.js → value-CudL8z5e.js} +1626 -1580
  295. package/dist/value-DT0qJqgQ.cjs +57 -0
  296. package/dist/video.cjs +1 -1
  297. package/dist/video.js +1 -1
  298. package/package.json +22 -20
  299. package/dist/Center-bD2cOjI8.cjs +0 -1
  300. package/dist/ContextMenu-BXNN2_7t.js +0 -101
  301. package/dist/ContextMenu-CNSewKSD.cjs +0 -1
  302. package/dist/DateTime-BfnGq6C2.cjs +0 -1
  303. package/dist/Divider-CJNDIsD4.cjs +0 -22
  304. package/dist/Dropdown-CL7BefC8.cjs +0 -1
  305. package/dist/Dropdown-D-aMufnM.js +0 -261
  306. package/dist/Item-CW2A2nuL.js +0 -108
  307. package/dist/Item-CpAZC-dF.cjs +0 -1
  308. package/dist/Keyboard-DHGtnfsf.cjs +0 -1
  309. package/dist/Pack-C4NdZWyf.cjs +0 -1
  310. package/dist/Pack-UzJJ9OhY.js +0 -46
  311. package/dist/Provider-BH1uv6QX.js +0 -436
  312. package/dist/Provider-lJARiq5i.cjs +0 -1
  313. package/dist/Space-BrQoodma.cjs +0 -1
  314. package/dist/Space-I_hidXYi.js +0 -76
  315. package/dist/Text-C-o1z9sP.js +0 -124
  316. package/dist/Text-C_j_F67Q.cjs +0 -1
  317. package/dist/Text-ClTuQXMF.cjs +0 -4
  318. package/dist/Text-DEbr1cmH.cjs +0 -1
  319. package/dist/Text-DVv04lTs.js +0 -32
  320. package/dist/Toggle-CYB9Vt6b.cjs +0 -1
  321. package/dist/Toggle-v77mEVLE.js +0 -356
  322. package/dist/WithIcon-BnDZ-Qu7.js +0 -92
  323. package/dist/WithIcon-tr8ELI3W.cjs +0 -1
  324. package/dist/css-CU7tous7.cjs +0 -1
  325. package/dist/dimensions-e5IPRZhn.cjs +0 -1
  326. package/dist/external-B1ttDWzy.cjs +0 -1
  327. package/dist/external-BdxbwUpI.js +0 -343
  328. package/dist/external-BpvGU0dZ.cjs +0 -1
  329. package/dist/external-C7Hy9XdI.js +0 -418
  330. package/dist/external-CqhOyYDl.cjs +0 -1
  331. package/dist/external-Csg4_wkz.js +0 -15
  332. package/dist/external-CwvJvXL5.cjs +0 -1
  333. package/dist/external-Cztvb3-K.cjs +0 -1
  334. package/dist/external-DMEzx_kb.cjs +0 -1
  335. package/dist/fontString-C7H8Imxd.cjs +0 -1
  336. package/dist/fontString-DdV9bi9l.js +0 -12
  337. package/dist/hooks-B7ZV7Hz6.js +0 -293
  338. package/dist/hooks-CJnV8Pt4.cjs +0 -1
  339. package/dist/provider-BrBEjlx5.cjs +0 -53
  340. package/dist/src/notation/external.d.ts +0 -3
  341. package/dist/src/notation/external.d.ts.map +0 -1
  342. package/dist/src/notation/notation.d.ts +0 -33
  343. package/dist/src/notation/notation.d.ts.map +0 -1
  344. package/dist/src/notation/notation.spec.d.ts +0 -2
  345. package/dist/src/notation/notation.spec.d.ts.map +0 -1
  346. package/dist/state-LaBGf4_k.cjs +0 -15
  347. package/dist/useClickOutside-PFl3AvPU.cjs +0 -1
  348. package/dist/useMemoCompare-BGEWpAJU.cjs +0 -1
  349. package/dist/useVirtualCursorDragWebKit-Rnok8Nft.cjs +0 -1
  350. package/dist/value-C6JZdCF2.cjs +0 -57
  351. /package/dist/{Pack-BbwDtaE6.cjs → Stack-BbwDtaE6.cjs} +0 -0
  352. /package/dist/{Pack-D50qN0Vu.js → Stack-D50qN0Vu.js} +0 -0
@@ -1,53 +0,0 @@
1
- "use strict";var el=Object.defineProperty;var tl=(t,e,n)=>e in t?el(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $=(t,e,n)=>tl(t,typeof e!="symbol"?e+"":e,n);const s=require("zod"),nl=require("./deep-DsH2ji6Z.cjs"),xe=require("./state-LaBGf4_k.cjs"),T=require("./css-CU7tous7.cjs");var rl=Object.defineProperty,sl=(t,e,n)=>e in t?rl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,An=(t,e,n)=>sl(t,typeof e!="symbol"?e+"":e,n);let il=class{constructor(e){An(this,"sender"),An(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var n;const r=(n=this.handlers.get(e.type))==null?void 0:n.handler;r==null?console.warn(`No handler for ${e.type}`):r(e.payload)}route(e){const n=al(e,this.sender),r=new ol(n);return this.handlers.set(e,r),r}};const al=(t,e)=>(n,r)=>e({type:t,payload:n},r);let ol=class{constructor(e){An(this,"_send"),An(this,"handler"),this._send=e,this.handler=null}send(e,n=[]){this._send(e,n)}handle(e){this.handler=e}};var ll=Object.defineProperty,cl=(t,e,n)=>e in t?ll(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e,n)=>cl(t,typeof e!="symbol"?e+"":e,n);const b=t=>Array.isArray(t)?t:[t],ul="policy",Ui="allow_all";var hl=Object.defineProperty,dl=(t,e,n)=>e in t?hl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e,n)=>dl(t,typeof e!="symbol"?e+"":e,n);const fl=t=>{const e=t.replace(/_[a-z]/g,n=>n[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},$i=t=>{const e=(n,r=Ir)=>{if(typeof n=="string")return t(n);if(Array.isArray(n))return n.map(o=>e(o,r));if(!er(n))return n;r=gl(r);const i={},a=n;return Object.keys(a).forEach(o=>{let c=a[o];const u=t(o);r.recursive&&(er(c)?Ms(c,r.keepTypesOnRecursion)||(c=e(c,r)):r.recursiveInArray&&Ps(c)&&(c=[...c].map(h=>{let f=h;return er(h)?Ms(f,r.keepTypesOnRecursion)||(f=e(h,r)):Ps(h)&&(f=e({key:h},r).key),f}))),i[u]=c}),i};return e},Li=$i(fl),yl=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,n,r)=>`${n}_${r.toLowerCase()}`),pl=$i(yl),Ir={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},gl=(t=Ir)=>(t.recursive==null?t=Ir:t.recursiveInArray??(t.recursiveInArray=!1),t),Ps=t=>t!=null&&Array.isArray(t),er=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Ms=(t,e)=>(e||[]).some(n=>t instanceof n),_i=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var ml=Object.defineProperty,wl=(t,e,n)=>e in t?ml(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Nt=(t,e,n)=>wl(t,typeof e!="symbol"?e+"":e,n);let bl=class{constructor(){Nt(this,"contentType","application/json"),Nt(this,"decoder"),Nt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const n=JSON.parse(t),r=Li(n);return e!=null?e.parse(r):r}encodeString(t){const e=pl(t);return JSON.stringify(e,(n,r)=>ArrayBuffer.isView(r)?Array.from(r):_i(r)&&"encode_value"in r?typeof r.value=="bigint"?r.value.toString():r.value:typeof r=="bigint"?r.toString():r)}static registerCustomType(){}},vl=class{constructor(){Nt(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const n=new TextDecoder().decode(t);return this.decodeString(n,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!_i(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),n=[e.join(",")];return t.forEach(r=>{const i=e.map(a=>JSON.stringify(r[a]??""));n.push(i.join(","))}),n.join(`
2
- `)}decodeString(t,e){const[n,...r]=t.trim().split(`
3
- `).map(o=>o.trim());if(n.length===0)return e!=null?e.parse({}):{};const i=n.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),r.forEach(o=>{const c=o.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(c[h]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},Ol=class{constructor(){Nt(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const n=new TextDecoder().decode(t);return e!=null?e.parse(n):n}};const sn=new bl;new vl;new Ol;const Tl=t=>t!=null&&typeof t=="object"&&"toString"in t,zl=(t,e=!1)=>{const n=Tl(t)?"stringer":typeof t;let r;switch(n){case"string":r=(i,a)=>i.localeCompare(a);break;case"stringer":r=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":r=(i,a)=>Number(i)-Number(a);break;case"bigint":r=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":r=(i,a)=>Number(i)-Number(a);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return e?Sl(r):r},Sl=t=>(e,n)=>t(n,e),Dn=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const qi=s.z.object({width:s.z.number(),height:s.z.number()}),kl=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Nl=["width","height"];s.z.enum(Nl);const El=["start","center","end"],Il=["signedWidth","signedHeight"];s.z.enum(Il);const Cn=s.z.object({x:s.z.number(),y:s.z.number()}),xl=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Al=["x","y"],Yi=s.z.enum(Al),Fi=["top","right","bottom","left"];s.z.enum(Fi);const Cl=["left","right"],Wi=s.z.enum(Cl),jl=["top","bottom"],Vi=s.z.enum(jl),Gi=["center"],Bs=s.z.enum(Gi),Rl=[...Fi,...Gi],Zi=s.z.enum(Rl);s.z.enum(El);const Pl=["first","last"];s.z.enum(Pl);const Ml=s.z.object({lower:s.z.number(),upper:s.z.number()}),Bl=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Ml,Dn]);s.z.union([Bl,Dn]);s.z.enum([...Yi.options,...Zi.options]);s.z.union([Yi,Zi,s.z.instanceof(String)]);const Dl=t=>typeof t=="bigint"||t instanceof BigInt,Le=(t,e)=>Dl(t)?t.valueOf()*BigInt(e.valueOf()):t.valueOf()*Number(e.valueOf()),De=(t,e)=>{const n={};if(typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else return Ds(t);return Ds(n)},Ds=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,Us=(t,e)=>{const n=De(t);return e<n.lower?n.lower:e>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):e};s.z.object({x:Wi.or(Bs),y:Vi.or(Bs)});const Ul=s.z.object({x:Wi,y:Vi}),$l=Object.freeze({x:"left",y:"top"}),Ll=(t,e)=>t.x===e.x&&t.y===e.y,$s=s.z.union([s.z.number(),Cn,Dn,qi,kl,xl]),_l=(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}},Ls=Object.freeze({x:0,y:0}),Jt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Jt,left:Jt,width:Jt,height:Jt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Cn,two:Cn,root:Ul});const ts=(t,e,n=0,r=0,i)=>{const a={one:{...Ls},two:{...Ls},root:i??$l};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+n,y:a.one.y+r},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+n}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},tr=t=>{const e=ts(t);return{lower:e.one.x,upper:e.two.x}},nr=t=>{const e=ts(t);return{lower:e.one.y,upper:e.two.y}},ql=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Yl=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([qi,Yl,Cn,Dn]);var Fl=Object.defineProperty,Wl=(t,e,n)=>e in t?Fl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Te=(t,e,n)=>Wl(t,typeof e!="symbol"?e+"":e,n);const Vl=(t,e,n)=>e!==void 0&&t<e?e:n!==void 0&&t>n?n:t;s.z.object({offset:$s,scale:$s});s.z.object({offset:s.z.number(),scale:s.z.number()});const Gl=t=>(e,n,r,i)=>n==="dimension"?[e,r]:[e,i?r-t:r+t],Zl=t=>(e,n,r,i)=>[e,i?r/t:r*t],Kl=t=>(e,n,r)=>{if(e===null)return[t,r];const{lower:i,upper:a}=e,{lower:o,upper:c}=t,u=a-i,h=c-o;if(n==="dimension")return[t,r*(h/u)];const f=(r-i)*(h/u)+o;return[t,f]},Jl=t=>(e,n,r)=>[t,r],Hl=()=>(t,e,n)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,n];const{lower:r,upper:i}=t;return[t,i-(n-r)]},Xl=t=>(e,n,r)=>{const{lower:i,upper:a}=t;return r=Vl(r,i,a),[e,r]},xr=class ct{constructor(){Te(this,"ops",[]),Te(this,"currBounds",null),Te(this,"currType",null),Te(this,"reversed",!1),this.ops=[]}static translate(e){return new ct().translate(e)}static magnify(e){return new ct().magnify(e)}static scale(e,n){return new ct().scale(e,n)}translate(e){const n=this.new(),r=Gl(e);return r.type="translate",n.ops.push(r),n}magnify(e){const n=this.new(),r=Zl(e);return r.type="magnify",n.ops.push(r),n}scale(e,n){const r=De(e,n),i=this.new(),a=Kl(r);return a.type="scale",i.ops.push(a),i}clamp(e,n){const r=De(e,n),i=this.new(),a=Xl(r);return a.type="clamp",i.ops.push(a),i}reBound(e,n){const r=De(e,n),i=this.new(),a=Jl(r);return a.type="re-bound",i.ops.push(a),i}invert(){const e=Hl();e.type="invert";const n=this.new();return n.ops.push(e),n}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new ct;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,n){return this.currBounds=null,this.ops.reduce(([r,i],a)=>a(r,e,i,this.reversed),[null,n])[1]}reverse(){const e=this.new();e.ops.reverse();const n=[];return e.ops.forEach((r,i)=>{if(r.type==="scale"||n.some(([o,c])=>i>=o&&i<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>i);a!==-1&&n.push([i,a])}),n.forEach(([r,i])=>{const a=e.ops.slice(r,i);a.unshift(e.ops[i]),e.ops.splice(r,i-r+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};Te(xr,"IDENTITY",new xr);let _s=xr;const qs=class ve{constructor(e=new _s,n=new _s,r=null){Te(this,"x"),Te(this,"y"),Te(this,"currRoot"),this.x=e,this.y=n,this.currRoot=r}static translate(e,n){return new ve().translate(e,n)}static translateX(e){return new ve().translateX(e)}static translateY(e){return new ve().translateY(e)}static clamp(e){return new ve().clamp(e)}static magnify(e){return new ve().magnify(e)}static scale(e){return new ve().scale(e)}static reBound(e){return new ve().reBound(e)}translate(e,n){const r=_l(e,n),i=this.copy();return i.x=this.x.translate(r.x),i.y=this.y.translate(r.y),i}translateX(e){const n=this.copy();return n.x=this.x.translate(e),n}translateY(e){const n=this.copy();return n.y=this.y.translate(e),n}magnify(e){const n=this.copy();return n.x=this.x.magnify(e.x),n.y=this.y.magnify(e.y),n}scale(e){const n=this.copy();if(ql(e)){const r=this.currRoot;return n.currRoot=e.root,r!=null&&!Ll(r,e.root)&&(r.x!==e.root.x&&(n.x=n.x.invert()),r.y!==e.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(tr(e)),n.y=n.y.scale(nr(e)),n}return n.x=n.x.scale(e.width),n.y=n.y.scale(e.height),n}reBound(e){const n=this.copy();return n.x=this.x.reBound(tr(e)),n.y=this.y.reBound(nr(e)),n}clamp(e){const n=this.copy();return n.x=this.x.clamp(tr(e)),n.y=this.y.clamp(nr(e)),n}copy(){const e=new ve;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ts(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};Te(qs,"IDENTITY",new qs);var Ql=Object.defineProperty,ec=(t,e,n)=>e in t?Ql(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e,n)=>ec(t,typeof e!="symbol"?e+"":e,n);let tc=(t,e=21)=>(n=e)=>{let r="",i=n|0;for(;i--;)r+=t[Math.random()*t.length|0];return r};const nc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",rc=tc(nc,11),sc=()=>rc(),ic=s.z.enum(["static","dynamic"]),Ki=(t,e)=>{const n=new U(e);if(![D.DAY,D.HOUR,D.MINUTE,D.SECOND,D.MILLISECOND,D.MICROSECOND,D.NANOSECOND].some(i=>i.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=t.valueOf()%n.valueOf();return t instanceof U?new U(r):new D(r)},R=class v{constructor(e,n="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=v.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*v.MILLISECOND.valueOf();else if(typeof e=="string")this.value=v.parseDateTimeString(e,n).valueOf();else if(Array.isArray(e))this.value=v.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),n==="local"&&(r=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,n=1,r=1]){const i=new Date(e,n-1,r,0,0,0,0);return new v(BigInt(i.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,n="UTC"){const[r,i,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let u=v.hours(parseInt(r??"00")).add(v.minutes(parseInt(i??"00"))).add(v.seconds(parseInt(o??"00"))).add(v.milliseconds(parseInt(c??"00")));return n==="local"&&(u=u.add(v.utcOffset)),u.valueOf()}static parseDateTimeString(e,n="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,n);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new v(BigInt(r.getTime())*v.MILLISECOND.valueOf(),n).valueOf()}fString(e="ISO",n="UTC"){switch(e){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(v.utcOffset).date().toISOString()}timeString(e=!1,n="UTC"){const r=this.toISOString(n);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),n=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new D(BigInt(new Date().getTimezoneOffset())*v.MINUTE.valueOf())}static since(e){return new v().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new v(e).valueOf()}span(e){return this.range(e).span}range(e){return new ns(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new v(e).valueOf()}afterEq(e){return this.valueOf()>=new v(e).valueOf()}before(e){return this.valueOf()<new v(e).valueOf()}beforeEq(e){return this.valueOf()<=new v(e).valueOf()}add(e){return new v(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new v(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(D.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(D.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(D.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(D.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(v.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const n=this.date();return n.setFullYear(e),new v(n)}get month(){return this.date().getMonth()}setMonth(e){const n=this.date();return n.setMonth(e),new v(n)}get day(){return this.date().getDate()}setDay(e){const n=this.date();return n.setDate(e),new v(n)}get hour(){return this.date().getHours()}setHour(e){const n=this.date();return n.setHours(e),new v(n)}get minute(){return this.date().getMinutes()}setMinute(e){const n=this.date();return n.setMinutes(e),new v(n)}get second(){return this.date().getSeconds()}setSecond(e){const n=this.date();return n.setSeconds(e),new v(n)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const n=this.date();return n.setMilliseconds(e),new v(n)}toString(){return this.date().toISOString()}remainder(e){return Ki(this,e)}get isToday(){return this.truncate(D.DAY).equals(v.now().truncate(D.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new v(new Date)}static max(...e){let n=v.MIN;for(const r of e){const i=new v(r);i.after(n)&&(n=i)}return n}static min(...e){let n=v.MAX;for(const r of e){const i=new v(r);i.before(n)&&(n=i)}return n}static nanoseconds(e){return new v(e)}static microseconds(e){return v.nanoseconds(e*1e3)}static milliseconds(e){return v.microseconds(e*1e3)}static seconds(e){return v.milliseconds(e*1e3)}static minutes(e){return v.seconds(e*60)}static hours(e){return v.minutes(e*60)}static days(e){return v.hours(e*24)}};m(R,"NANOSECOND",R.nanoseconds(1)),m(R,"MICROSECOND",R.microseconds(1)),m(R,"MILLISECOND",R.milliseconds(1)),m(R,"SECOND",R.seconds(1)),m(R,"MINUTE",R.minutes(1)),m(R,"HOUR",R.hours(1)),m(R,"DAY",R.days(1)),m(R,"MAX",new R((1n<<63n)-1n)),m(R,"MIN",new R(0)),m(R,"ZERO",new R(0)),m(R,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new R(t.value)),s.z.string().transform(t=>new R(BigInt(t))),s.z.instanceof(Number).transform(t=>new R(t)),s.z.number().transform(t=>new R(t)),s.z.instanceof(R)]));let U=R;const P=class S{constructor(e){m(this,"value"),m(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof S?e:e instanceof Ys?e.period:e instanceof U?new S(e):["number","bigint"].includes(typeof e)?S.seconds(e):new S(e)}static fromMilliseconds(e){return e instanceof S?e:e instanceof Ys?e.period:e instanceof U?new S(e):["number","bigint"].includes(typeof e)?S.milliseconds(e):new S(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new S(e).valueOf()}greaterThan(e){return this.valueOf()>new S(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new S(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new S(e).valueOf()}remainder(e){return Ki(this,e)}truncate(e){return new S(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(S.DAY),n=this.truncate(S.HOUR),r=this.truncate(S.MINUTE),i=this.truncate(S.SECOND),a=this.truncate(S.MILLISECOND),o=this.truncate(S.MICROSECOND),c=this.truncate(S.NANOSECOND),u=e,h=n.sub(e),f=r.sub(n),d=i.sub(r),N=a.sub(i),x=o.sub(a),ae=c.sub(o);let Y="";return u.isZero||(Y+=`${u.days}d `),h.isZero||(Y+=`${h.hours}h `),f.isZero||(Y+=`${f.minutes}m `),d.isZero||(Y+=`${d.seconds}s `),N.isZero||(Y+=`${N.milliseconds}ms `),x.isZero||(Y+=`${x.microseconds}µs `),ae.isZero||(Y+=`${ae.nanoseconds}ns`),Y.trim()}mult(e){return new S(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(S.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(S.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(S.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(S.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(S.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(S.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new S(e).valueOf()}add(e){return new S(this.valueOf()+new S(e).valueOf())}sub(e){return new S(this.valueOf()-new S(e).valueOf())}static nanoseconds(e=1){return new S(e)}static microseconds(e=1){return S.nanoseconds(Le(e,1e3))}static milliseconds(e=1){return S.microseconds(Le(e,1e3))}static seconds(e=1){return S.milliseconds(Le(e,1e3))}static minutes(e=1){return S.seconds(Le(e,60))}static hours(e){return S.minutes(Le(e,60))}static days(e){return S.hours(Le(e,24))}};m(P,"NANOSECOND",P.nanoseconds(1)),m(P,"MICROSECOND",P.microseconds(1)),m(P,"MILLISECOND",P.milliseconds(1)),m(P,"SECOND",P.seconds(1)),m(P,"MINUTE",P.minutes(1)),m(P,"HOUR",P.hours(1)),m(P,"DAY",P.days(1)),m(P,"MAX",new P((1n<<63n)-1n)),m(P,"MIN",new P(0)),m(P,"ZERO",new P(0)),m(P,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new P(t.value)),s.z.string().transform(t=>new P(BigInt(t))),s.z.instanceof(Number).transform(t=>new P(t)),s.z.number().transform(t=>new P(t)),s.z.instanceof(P)]));let D=P;const ut=class an extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new an(e).valueOf()}get period(){return D.seconds(1/this.valueOf())}sampleCount(e){return new D(e).seconds*this.valueOf()}byteCount(e,n){return this.sampleCount(e)*new te(n).valueOf()}span(e){return D.seconds(e/this.valueOf())}byteSpan(e,n){return this.span(e.valueOf()/n.valueOf())}static hz(e){return new an(e)}static khz(e){return an.hz(e*1e3)}};m(ut,"z",s.z.union([s.z.number().transform(t=>new ut(t)),s.z.instanceof(Number).transform(t=>new ut(t)),s.z.instanceof(ut)]));let Ys=ut;const G=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ar(e*this.valueOf())}};m(G,"UNKNOWN",new G(0)),m(G,"BIT128",new G(16)),m(G,"BIT64",new G(8)),m(G,"BIT32",new G(4)),m(G,"BIT16",new G(2)),m(G,"BIT8",new G(1)),m(G,"z",s.z.union([s.z.number().transform(t=>new G(t)),s.z.instanceof(Number).transform(t=>new G(t)),s.z.instanceof(G)]));let te=G;const fe=class on{constructor(e,n){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new U(e.start),this.end=new U(e.end)):(this.start=new U(e),this.end=new U(n))}get span(){return new D(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new on(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,n=D.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const i=U.max(r.start,e.start),a=U.min(r.end,e.end);return a.before(i)?!1:new D(a.sub(i)).greaterThanOrEqual(n)}roughlyEquals(e,n){let r=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=n.valueOf()&&i<=n.valueOf()}contains(e){return e instanceof on?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const n=new on(this.start,this.end);return e.start.after(this.start)&&(n.start=e.start),e.start.after(this.end)&&(n.end=e.start),e.end.before(this.end)&&(n.end=e.end),e.end.before(this.start)&&(n.start=e.end),n}};m(fe,"MAX",new fe(U.MIN,U.MAX)),m(fe,"MIN",new fe(U.MAX,U.MIN)),m(fe,"ZERO",new fe(U.ZERO,U.ZERO)),m(fe,"z",s.z.union([s.z.object({start:U.z,end:U.z}).transform(t=>new fe(t.start,t.end)),s.z.instanceof(fe)]));let ns=fe;const p=class L extends String{constructor(e){if(e instanceof L||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const n=L.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(n!=null){super(n.valueOf());return}throw super(L.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=L.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(n=>this.equals(n))}toString(){return this.valueOf()}get isVariable(){return this.equals(L.JSON)||this.equals(L.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(L.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=L.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(L.UINT8)||this.equals(L.UINT16)||this.equals(L.UINT32)||this.equals(L.UINT64)}get isSigned(){return this.equals(L.INT8)||this.equals(L.INT16)||this.equals(L.INT32)||this.equals(L.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(L.INT32)&&e.equals(L.FLOAT64)||this.equals(L.INT8)&&e.equals(L.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return L.BIG_INT_TYPES.some(e=>e.equals(this))}};m(p,"UNKNOWN",new p("unknown")),m(p,"FLOAT64",new p("float64")),m(p,"FLOAT32",new p("float32")),m(p,"INT64",new p("int64")),m(p,"INT32",new p("int32")),m(p,"INT16",new p("int16")),m(p,"INT8",new p("int8")),m(p,"UINT64",new p("uint64")),m(p,"UINT32",new p("uint32")),m(p,"UINT16",new p("uint16")),m(p,"UINT8",new p("uint8")),m(p,"BOOLEAN",p.UINT8),m(p,"TIMESTAMP",new p("timestamp")),m(p,"UUID",new p("uuid")),m(p,"STRING",new p("string")),m(p,"JSON",new p("json")),m(p,"ARRAY_CONSTRUCTORS",new Map([[p.UINT8.toString(),Uint8Array],[p.UINT16.toString(),Uint16Array],[p.UINT32.toString(),Uint32Array],[p.UINT64.toString(),BigUint64Array],[p.FLOAT32.toString(),Float32Array],[p.FLOAT64.toString(),Float64Array],[p.INT8.toString(),Int8Array],[p.INT16.toString(),Int16Array],[p.INT32.toString(),Int32Array],[p.INT64.toString(),BigInt64Array],[p.TIMESTAMP.toString(),BigInt64Array],[p.STRING.toString(),Uint8Array],[p.JSON.toString(),Uint8Array],[p.UUID.toString(),Uint8Array]])),m(p,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,p.UINT8],[Uint16Array.name,p.UINT16],[Uint32Array.name,p.UINT32],[BigUint64Array.name,p.UINT64],[Float32Array.name,p.FLOAT32],[Float64Array.name,p.FLOAT64],[Int8Array.name,p.INT8],[Int16Array.name,p.INT16],[Int32Array.name,p.INT32],[BigInt64Array.name,p.INT64]])),m(p,"DENSITIES",new Map([[p.UINT8.toString(),te.BIT8],[p.UINT16.toString(),te.BIT16],[p.UINT32.toString(),te.BIT32],[p.UINT64.toString(),te.BIT64],[p.FLOAT32.toString(),te.BIT32],[p.FLOAT64.toString(),te.BIT64],[p.INT8.toString(),te.BIT8],[p.INT16.toString(),te.BIT16],[p.INT32.toString(),te.BIT32],[p.INT64.toString(),te.BIT64],[p.TIMESTAMP.toString(),te.BIT64],[p.STRING.toString(),te.UNKNOWN],[p.JSON.toString(),te.UNKNOWN],[p.UUID.toString(),te.BIT128]])),m(p,"ALL",[p.UNKNOWN,p.FLOAT64,p.FLOAT32,p.INT64,p.INT32,p.INT16,p.INT8,p.UINT64,p.UINT32,p.UINT16,p.UINT8,p.TIMESTAMP,p.UUID,p.STRING,p.JSON]),m(p,"BIG_INT_TYPES",[p.INT64,p.UINT64,p.TIMESTAMP]),m(p,"z",s.z.union([s.z.string().transform(t=>new p(t)),s.z.instanceof(p)]));let j=p;const X=class F extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return F.bytes(this.valueOf()+e.valueOf())}sub(e){return F.bytes(this.valueOf()-e.valueOf())}truncate(e){return new F(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return F.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/F.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/F.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/F.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/F.TERABYTE.valueOf()}toString(){const e=this.truncate(F.TERABYTE),n=this.truncate(F.GIGABYTE),r=this.truncate(F.MEGABYTE),i=this.truncate(F.KILOBYTE),a=this.truncate(F.BYTE),o=e,c=n.sub(e),u=r.sub(n),h=i.sub(r),f=a.sub(i);let d="";return o.isZero||(d+=`${o.terabytes}TB `),c.isZero||(d+=`${c.gigabytes}GB `),u.isZero||(d+=`${u.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new F(e)}static kilobytes(e=1){return F.bytes(e.valueOf()*1e3)}static megabytes(e=1){return F.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return F.megabytes(e.valueOf()*1e3)}static terabytes(e){return F.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(X,"BYTE",new X(1)),m(X,"KILOBYTE",X.kilobytes(1)),m(X,"MEGABYTE",X.megabytes(1)),m(X,"GIGABYTE",X.gigabytes(1)),m(X,"TERABYTE",X.terabytes(1)),m(X,"ZERO",new X(0)),m(X,"z",s.z.union([s.z.number().transform(t=>new X(t)),s.z.instanceof(X)]));let Ar=X;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const Ji=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof U||t instanceof D||t instanceof Date},ac=(t,e,n,r=0)=>t.usesBigInt&&!e.usesBigInt?Number(n)-Number(r):!t.usesBigInt&&e.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):ht(n,-r).valueOf(),ht=(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),oc=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof uc?!0:Ji(t),Ne=-1,lc=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),cc=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),Cr=10,dt=class ye{constructor(e){m(this,"key",""),m(this,"isSynnaxSeries",!0),m(this,"dataType"),m(this,"sampleOffset"),m(this,"gl"),m(this,"_data"),m(this,"_timeRange"),m(this,"alignment",0n),m(this,"_cachedMin"),m(this,"_cachedMax"),m(this,"writePos",Ne),m(this,"_refCount",0),m(this,"_cachedLength"),m(this,"_cachedIndexes"),oc(e)&&(e={data:e});const{dataType:n,timeRange:r,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:c=sc()}=e,u=e.data??[];if(u instanceof ye||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this._timeRange=d._timeRange,this.alignment=d.alignment,this._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=Ji(u),f=Array.isArray(u);if(n!=null)this.dataType=new j(n);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=j.STRING;else if(typeof d=="number")this.dataType=j.FLOAT64;else if(typeof d=="bigint")this.dataType=j.INT64;else if(typeof d=="boolean")this.dataType=j.BOOLEAN;else if(d instanceof U||d instanceof Date||d instanceof U)this.dataType=j.TIMESTAMP;else if(typeof d=="object")this.dataType=j.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new j(u)}if(!f&&!h)this._data=u;else{let d=h?[u]:u;const N=d[0];(N instanceof U||N instanceof Date||N instanceof D)&&(d=d.map(x=>new U(x).valueOf())),this.dataType.equals(j.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
4
- `)}
5
- `).buffer):this.dataType.equals(j.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(x=>sn.encodeString(x)).join(`
6
- `)}
7
- `).buffer):this.dataType.usesBigInt&&typeof N=="number"?this._data=new this.dataType.Array(d.map(x=>BigInt(Math.round(x)))).buffer:!this.dataType.usesBigInt&&typeof N=="bigint"?this._data=new this.dataType.Array(d.map(x=>Number(x))).buffer:this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:n,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new j(n).Array(e),a=new ye({data:i.buffer,dataType:n,...r});return a.writePos=0,a}static createTimestamps(e,n,r){const i=r.spanRange(n.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(r.add(n.span(o)).valueOf());return new ye({data:a,dataType:j.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,n){const r=new TextEncoder().encode(`${e.join(`
8
- `)}
9
- `);return new ye({data:r,dataType:j.STRING,timeRange:n})}static fromJSON(e,n){const r=new TextEncoder().encode(`${e.map(i=>sn.encodeString(i)).join(`
10
- `)}
11
- `);return new ye({data:r,dataType:j.JSON,timeRange:n})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ne)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===Ne)return 0;const n=this.capacity-this.writePos,r=e.sub(0,n);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ne?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(j.STRING,j.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
12
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(j.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=j.UUID.density.valueOf(),n=Array(this.length);for(let r=0;r<this.length;r++){const i=this.underlyingData.slice(r*e,(r+1)*e),a=Array.from(new Uint8Array(i.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");n[r]=a}return n}parseJSON(e){if(!this.dataType.equals(j.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
13
- `).slice(0,-1).map(n=>e.parse(sn.decodeString(n)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Ar(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ne?this.byteCapacity:this.dataType.isVariable?new Ar(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ne?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const n=[0];return this.data.forEach((r,i)=>{r===Cr&&(e++,n.push(i+1))}),this._cachedIndexes=n,this._cachedLength=e,e}convert(e,n=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let i=0;i<this.length;i++)r[i]=ac(this.dataType,e,this.data[i],n);return new ye({data:r.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(j.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}else{const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),ht(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(j.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}else{const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),ht(this._cachedMin,this.sampleOffset))}get bounds(){return De(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const n=e._cachedMin??e.calcRawMin();n<this._cachedMin&&(this._cachedMin=n)}if(this._cachedMax!=null){const n=e._cachedMax??e.calcRawMax();n>this._cachedMax&&(this._cachedMax=n)}}enrich(){this.max,this.min}get range(){return ht(this.max,-this.min)}atAlignment(e,n){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(e,n){if(this.dataType.isVariable)return this.atVariable(e,n??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${e}`);return}return ht(r,this.sampleOffset)}atVariable(e,n){let r=0,i=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],i=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===Cr){if(e===0){i=o;break}r=o+1,e--}if(i===0&&(i=this.data.length),r>=i||e>0){if(n)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(r,i);return this.dataType.equals(j.STRING)?new TextDecoder().decode(a):Li(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let n=0,r=this.length-1;const i=zl(e);for(;n<=r;){const a=Math.floor((n+r)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?n=a+1:r=a-1}return n}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(j.FLOAT32)&&!this.dataType.equals(j.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:i}=this.gl;if(n==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ne){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ne}as(e){if(e==="string"){if(!this.dataType.equals(j.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(j.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:{lower:Ks(this.alignmentBounds.lower),upper:Ks(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return De(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 hc(this);return this.dataType.equals(j.JSON)?new dc(e):e}return new fc(this)}slice(e,n){return this.sliceSub(!1,e,n)}sub(e,n){return this.sliceSub(!0,e,n)}subIterator(e,n){return new Fs(this,e,n??this.length)}subAlignmentIterator(e,n){return new Fs(this,Number(e-this.alignment),Number(n-this.alignment))}subBytes(e,n){if(e>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,n);return new ye({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return e?i=this.data.subarray(n,r):i=this.data.slice(n,r),new ye({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(e){return new ye({data:this.buffer,dataType:this.dataType,timeRange:ns.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};m(dt,"crudeZ",s.z.object({timeRange:ns.z.optional(),dataType:j.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([lc,cc,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:ic.optional().default("static").optional()})),m(dt,"z",dt.crudeZ.transform(t=>new dt(t)));let uc=dt;class Fs{constructor(e,n,r){m(this,"series"),m(this,"end"),m(this,"index"),this.series=e;const i=De(0,e.length);this.end=Us(i,r),this.index=Us(i,n)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class hc{constructor(e){if(m(this,"series"),m(this,"index"),m(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==Cr;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var Ws,Vs;class dc{constructor(e){m(this,"wrapped"),m(this,Ws,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:sn.decodeString(e.value)}}[(Vs=Symbol.iterator,Ws=Symbol.toStringTag,Vs)](){return this}}var Gs,Zs;class fc{constructor(e){m(this,"series"),m(this,"index"),m(this,Gs,"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)}}[(Zs=Symbol.iterator,Gs=Symbol.toStringTag,Zs)](){return this}}const Ks=t=>{const e=t>>32n,n=t&0xffffffffn;return{domain:e,sample:n}};s.z.object({key:s.z.string(),value:s.z.string()});s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const Hi=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",yc=Hi(),Xi=["macOS","Windows","Linux"],pc=["macos","windows","linux"],gc={macos:"macOS",windows:"Windows",linux:"Linux"},mc=s.z.enum(Xi).or(s.z.enum(pc).transform(t=>gc[t])),wc=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"macOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"};let rr;const bc=(t={})=>{const{force:e,default:n}=t;return e??rr??(rr=wc(),rr??n)},Qi=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Xi,RUNTIME:yc,detect:Hi,getOS:bc,osZ:mc},Symbol.toStringTag,{value:"Module"}));var vc=Object.defineProperty,Oc=(t,e,n)=>e in t?vc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ft=(t,e,n)=>Oc(t,typeof e!="symbol"?e+"":e,n);const Tc=(...t)=>t.map(ea).join(""),ea=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),zc=t=>t.endsWith("/")?t.slice(0,-1):t,Sc=(t,e="")=>t===null?"":`?${Object.entries(t).filter(([,n])=>n==null?!1:Array.isArray(n)?n.length>0:!0).map(([n,r])=>`${e}${n}=${r}`).join("&")}`,jr=class Rr{constructor({host:e,port:n,protocol:r="",pathPrefix:i=""}){ft(this,"protocol"),ft(this,"host"),ft(this,"port"),ft(this,"path"),this.protocol=r,this.host=e,this.port=n,this.path=ea(i)}replace(e){return new Rr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Rr({...this,pathPrefix:Tc(this.path,e)})}toString(){return zc(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};ft(jr,"UNKNOWN",new jr({host:"unknown",port:0}));let kc=jr;const Nc=-128,Ec=127;s.z.number().int().min(Nc).max(Ec);const Ic=-32768,xc=32767;s.z.number().int().min(Ic).max(xc);const Ac=-2147483648,Cc=2147483647;s.z.number().int().min(Ac).max(Cc);const jc=-9223372036854775808n,Rc=9223372036854775807n;s.z.bigint().min(jc).max(Rc);const Pc=255;s.z.number().int().min(0).max(Pc);const Mc=65535;s.z.number().int().min(0).max(Mc);const Bc=4294967295;s.z.number().int().min(0).max(Bc);const Dc=18446744073709551615n;s.z.bigint().min(0n).max(Dc);var Uc=Object.defineProperty,$c=(t,e,n)=>e in t?Uc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,yt=(t,e,n)=>$c(t,typeof e!="symbol"?e+"":e,n);const Lc=async t=>await new Promise(e=>setTimeout(e,D.fromMilliseconds(t).milliseconds)),_c=s.z.object({interval:D.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),qc=(t={})=>{const e=t.sleepFn||Lc,n=t.maxRetries??5,r=t.scale??1;let i=0,a=new D(t.interval??D.milliseconds(1));return async()=>i>=n?!1:(await e(a),a=a.mult(r),i++,!0)},Yc=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:_c,create:qc},Symbol.toStringTag,{value:"Module"})),be=class extends Number{};yt(be,"ABSOLUTE",255),yt(be,"MINIMUM",0),yt(be,"BOUNDS",{lower:be.MINIMUM,upper:be.ABSOLUTE+1}),yt(be,"z",s.z.union([s.z.instanceof(be),s.z.number().int().min(0).max(255).transform(t=>new be(t)),s.z.instanceof(Number).transform(t=>new be(t))]));s.z.object({name:s.z.string(),key:s.z.string()});const ta=class pt extends Error{constructor(){super(pt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(pt.MESSAGE):e instanceof pt||e.message.includes(pt.MESSAGE)}};yt(ta,"MESSAGE","canceled");let Fc=ta;new Fc;s.z.string().regex(/^\d+\.\d+\.\d+$/);const ee=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(t):e instanceof Error?e.message.includes(t):typeof e!="string"?!1:e.includes(t);let de=class extends Error{constructor(){super(...arguments),A(this,"discriminator","FreighterError"),A(this,"type","")}};const Wc=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},Js="unknown",Hs="nil",Vc="freighter",Ut=s.z.object({type:s.z.string(),data:s.z.string()});class Gc{constructor(){A(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Hs,data:""};if(Wc(e))for(const n of this.providers){const r=n.encode(e);if(r!=null)return r}return{type:Js,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Hs)return null;if(e.type===Js)return new Xs(e.data);for(const n of this.providers){const r=n.decode(e);if(r!=null)return r}return new Xs(e.data)}}const na=new Gc,ra=({encode:t,decode:e})=>na.register({encode:t,decode:e}),jn=t=>na.decode(t);class Xs extends de{constructor(){super(...arguments),A(this,"type","unknown")}}const Un="freighter.",ln=class sa extends de{constructor(){super("EOF"),A(this,"type",sa.TYPE)}};A(ln,"TYPE",`${Un}eof`),A(ln,"matches",ee(ln.TYPE));let je=ln;const cn=class ia extends de{constructor(){super("StreamClosed"),A(this,"type",ia.TYPE)}};A(cn,"TYPE",`${Un}stream_closed`),A(cn,"matches",ee(cn.TYPE));let Ve=cn;const un=class aa extends de{constructor(e={}){const{message:n="Unreachable",url:r=kc.UNKNOWN}=e;super(n),A(this,"type",aa.TYPE),A(this,"url"),this.url=r}};A(un,"TYPE",`${Un}unreachable`),A(un,"matches",ee(un.TYPE));let Re=un;const Zc=t=>{if(!t.type.startsWith(Vc))return null;if(je.matches(t))return{type:je.TYPE,data:"EOF"};if(Ve.matches(t))return{type:Ve.TYPE,data:"StreamClosed"};if(Re.matches(t))return{type:Re.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},Kc=t=>{if(!t.type.startsWith(Un))return null;switch(t.type){case je.TYPE:return new je;case Ve.TYPE:return new Ve;case Re.TYPE:return new Re;default:throw new Error(`Unknown error type: ${t.data}`)}};ra({encode:Zc,decode:Kc});let oa=class{constructor(){A(this,"middleware",[])}use(...t){this.middleware.push(...t)}async executeMiddleware(t,e){let n=0;const r=async i=>{if(n===this.middleware.length)return await e(i);const a=this.middleware[n];return n++,await a(i,r)};return await r(t)}};const la="Content-Type",Qs=t=>{if(Qi.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(t==="http")return e;const n=require("https"),r=new n.Agent({rejectUnauthorized:!1});return async(i,a)=>await e(i,{...a,agent:r})};class Jc extends oa{constructor(e,n,r=!1){return super(),A(this,"endpoint"),A(this,"encoder"),A(this,"fetch"),this.endpoint=e.replace({protocol:r?"https":"http"}),this.encoder=n,this.fetch=Qs(this.endpoint.protocol),new Proxy(this,{get:(i,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(i,a,o)})}get headers(){return{[la]:this.encoder.contentType}}async send(e,n,r,i){n=r==null?void 0:r.parse(n);let a=null;const o=this.endpoint.child(e),c={};c.method="POST",c.body=this.encoder.encode(n??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async h=>{const f={...h,params:{}};c.headers={...this.headers,...h.params};let d;try{d=await Qs(h.protocol)(h.target,c)}catch(x){let ae=x;return ae.message==="Load failed"&&(ae=new Re({url:o})),[f,ae]}const N=await d.arrayBuffer();if(d!=null&&d.ok)return i!=null&&(a=this.encoder.decode(N,i)),[f,null];try{if(d.status!==400)return[f,new Error(d.statusText)];const x=this.encoder.decode(N,Ut),ae=jn(x);return[f,ae]}catch(x){return[f,new Error(`[freighter] - failed to decode error: ${d.statusText}: ${x.message}`)]}});return[a,u]}}const Hc=(t,e)=>{class n{constructor(i){A(this,"wrapped"),this.wrapped=i}use(...i){this.wrapped.use(...i)}async send(i,a,o,c){const u=Yc.create(e);do{const[h,f]=await this.wrapped.send(i,a,o,c);if(f==null||!Re.matches(f))return[h,f];if(!await u())return[h,f]}while(!0)}}return new n(t)},w=async(t,e,n,r,i)=>{const[a,o]=await t.send(e,n,r,i);if(o!=null)throw o;return a},Xc=()=>Qi.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),Qc=s.z.object({type:s.z.enum(["data","close","open"]),payload:s.z.unknown().optional(),error:s.z.optional(Ut)});class eu{constructor(e,n,r,i){A(this,"encoder"),A(this,"reqSchema"),A(this,"resSchema"),A(this,"ws"),A(this,"serverClosed"),A(this,"sendClosed"),A(this,"receiveDataQueue",[]),A(this,"receiveCallbacksQueue",[]),this.encoder=n,this.reqSchema=r,this.resSchema=i,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const e=await this.receiveMsg();if(e.type!=="open"){if(e.error==null)throw new Error("Message error must be defined");return jn(e.error)}return null}send(e){if(this.serverClosed!=null)return new je;if(this.sendClosed)throw new Ve;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=jn(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,n)=>this.receiveCallbacksQueue.push({resolve:e,reject:n}))}addMessage(e){const n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,Qc)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:iu(e)?je.TYPE:Ve.TYPE,data:""}})}}const tu="freighterctx",nu=1e3,ru=1001,su=[nu,ru],iu=t=>su.includes(t.code),ca=class ua extends oa{constructor(e,n,r=!1){super(),A(this,"baseUrl"),A(this,"encoder"),this.baseUrl=e.replace({protocol:r?"wss":"ws"}),this.encoder=n}async stream(e,n,r){const i=Xc();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async c=>{const u=i(this.buildURL(e,c)),h={...c,params:{}};u.binaryType=ua.MESSAGE_TYPE;const f=await this.wrapSocket(u,n,r);return f instanceof Error?[h,f]:(a=f,[h,null])});if(o!=null)throw o;return a}buildURL(e,n){const r=Sc({[la]:this.encoder.contentType,...n.params},tu);return this.baseUrl.child(e).toString()+r}async wrapSocket(e,n,r){return await new Promise(i=>{e.onopen=()=>{const a=new eu(e,this.encoder,n,r);a.receiveOpenAck().then(o=>{o!=null?i(o):i(a)}).catch(o=>i(o))},e.onerror=a=>{const o=a;i(new Error(o.message))}})}};A(ca,"MESSAGE_TYPE","arraybuffer");let au=ca;const ou="all",lu="create",cu="delete",uu="retrieve",hu="update",Pr=s.z.enum([ou,lu,cu,uu,hu]),du=t=>{const e=t.replace(/_[a-z]/g,n=>n[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},ha=t=>{const e=(n,r=Mr)=>{if(typeof n=="string")return t(n);if(Array.isArray(n))return n.map(o=>e(o,r));if(!sr(n))return n;r=pu(r);const i={},a=n;return Object.keys(a).forEach(o=>{let c=a[o];const u=t(o);r.recursive&&(sr(c)?ti(c,r.keepTypesOnRecursion)||(c=e(c,r)):r.recursiveInArray&&ei(c)&&(c=[...c].map(h=>{let f=h;return sr(h)?ti(f,r.keepTypesOnRecursion)||(f=e(h,r)):ei(h)&&(f=e({key:h},r).key),f}))),i[u]=c}),i};return e},da=ha(du),fu=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,n,r)=>`${n}_${r.toLowerCase()}`),yu=ha(fu),Mr={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},pu=(t=Mr)=>(t.recursive==null?t=Mr:t.recursiveInArray??(t.recursiveInArray=!1),t),ei=t=>t!=null&&Array.isArray(t),sr=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ti=(t,e)=>(e||[]).some(n=>t instanceof n),rs=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var gu=Object.defineProperty,mu=(t,e,n)=>e in t?gu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Et=(t,e,n)=>mu(t,typeof e!="symbol"?e+"":e,n);let fa=class{constructor(){Et(this,"contentType","application/json"),Et(this,"decoder"),Et(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const n=JSON.parse(t),r=da(n);return e!=null?e.parse(r):r}encodeString(t){const e=yu(t);return JSON.stringify(e,(n,r)=>ArrayBuffer.isView(r)?Array.from(r):rs(r)&&"encode_value"in r?typeof r.value=="bigint"?r.value.toString():r.value:typeof r=="bigint"?r.toString():r)}static registerCustomType(){}},ya=class{constructor(){Et(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const n=new TextDecoder().decode(t);return this.decodeString(n,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!rs(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),n=[e.join(",")];return t.forEach(r=>{const i=e.map(a=>JSON.stringify(r[a]??""));n.push(i.join(","))}),n.join(`
14
- `)}decodeString(t,e){const[n,...r]=t.trim().split(`
15
- `).map(o=>o.trim());if(n.length===0)return e!=null?e.parse({}):{};const i=n.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),r.forEach(o=>{const c=o.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(c[h]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},pa=class{constructor(){Et(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const n=new TextDecoder().decode(t);return e!=null?e.parse(n):n}};const We=new fa,wu=new ya,bu=new pa,vu=[We],$t=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:ya,CSV_CODEC:wu,ENCODERS:vu,JSONCodec:fa,JSON_CODEC:We,TEXT_CODEC:bu,TextCodec:pa},Symbol.toStringTag,{value:"Module"})),Ou=t=>[...new Set(t)],Tu=(t,e,n=!0)=>{const r=new Map;return t.forEach(i=>{const a=e(i);if(r.has(a)){if(n)return;r.delete(a)}r.set(a,i)}),Array.from(r.values())},ni=Object.freeze(Object.defineProperty({__proto__:null,by:Tu,unique:Ou},Symbol.toStringTag,{value:"Module"})),zu=t=>t!=null&&typeof t=="object"&&"toString"in t,Su=(t,e=!1)=>{const n=zu(t)?"stringer":typeof t;let r;switch(n){case"string":r=(i,a)=>i.localeCompare(a);break;case"stringer":r=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":r=(i,a)=>Number(i)-Number(a);break;case"bigint":r=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":r=(i,a)=>Number(i)-Number(a);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return e?ku(r):r},ku=t=>(e,n)=>t(n,e),$n=0,ir=-1,ar=1,Nu=t=>t<$n,Eu=t=>t>$n,Iu=t=>t===$n,Ln=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const ga=s.z.object({width:s.z.number(),height:s.z.number()}),xu=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Au=["width","height"];s.z.enum(Au);const Cu=["start","center","end"],ju=["signedWidth","signedHeight"];s.z.enum(ju);const Rn=s.z.object({x:s.z.number(),y:s.z.number()}),Ru=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Pu=["x","y"],ma=s.z.enum(Pu),wa=["top","right","bottom","left"];s.z.enum(wa);const Mu=["left","right"],ba=s.z.enum(Mu),Bu=["top","bottom"],va=s.z.enum(Bu),Oa=["center"],ri=s.z.enum(Oa),Du=[...wa,...Oa],Ta=s.z.enum(Du);s.z.enum(Cu);const Uu=["first","last"];s.z.enum(Uu);const $u=s.z.object({lower:s.z.number(),upper:s.z.number()}),Lu=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([$u,Ln]);s.z.union([Lu,Ln]);s.z.enum([...ma.options,...Ta.options]);s.z.union([ma,Ta,s.z.instanceof(String)]);const Qe=t=>typeof t=="bigint"||t instanceof BigInt,or=(t,e)=>Qe(t)?t.valueOf()-BigInt(e.valueOf().valueOf()):t.valueOf()-Number(e.valueOf()),_u=(t,e)=>Qe(t)?t.valueOf()+BigInt(e.valueOf().valueOf()):t+Number(e.valueOf()),si=(t,e)=>Qe(t)?t===BigInt(e.valueOf().valueOf()):t===Number(e.valueOf()),qu=(t,e)=>Qe(t)?t.valueOf()<BigInt(e.valueOf())?t:BigInt(e.valueOf()):t.valueOf()<Number(e.valueOf())?t:Number(e.valueOf()),Yu=t=>Qe(t)||t instanceof BigInt?t.valueOf()<0n?-t:t:t.valueOf()<0?-t:t,_e=(t,e)=>Qe(t)?t.valueOf()*BigInt(e.valueOf()):t.valueOf()*Number(e.valueOf()),re=(t,e)=>{const n={};if(typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else return ii(t);return ii(n)},ii=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,ai=(t,e)=>{const n=re(t);return e<n.lower?n.lower:e>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):e},Ht=(t,e)=>{const n=re(t);if(typeof e=="number"||typeof e=="bigint")return e>=n.lower&&e<n.upper;const r=re(e);return r.lower>=n.lower&&r.upper<=n.upper},Fu=(t,e,n)=>{const r=t.map(c=>re(c)),i=n>0?1:n<0?-1:0;if(i===0)return e;let a=n,o=e;for(;si(a,0)===!1;){const c=r.findIndex(u=>i>0?o>=u.lower&&o<u.upper:o>u.lower&&o<=u.upper);if(c!==-1){const u=r[c];let h;if(i>0?h=or(u.upper,o):h=or(o,u.lower),h>0){const f=qu(Yu(a),h);if(o=_u(o,i>0?f:-f),a=or(a,i>0?f:-f),si(a,0))return o;continue}}if(i>0){const u=r.filter(h=>h.lower>o);if(u.length>0)o=u[0].lower;else return o}else{const u=r.filter(h=>h.upper<o);if(u.length>0)o=u[u.length-1].upper;else return o}}return o},Wu=(t,e,n)=>{const r=t.map(o=>re(o));if(e===n)return typeof e=="bigint"?0n:0;const i=e<n?re([e,n]):re([n,e]);let a=typeof e=="bigint"?0n:0;for(const o of r){const c=o.lower>i.lower?o.lower:i.lower,u=o.upper<i.upper?o.upper:i.upper;if(c<u){const h=u-c;a=a+h}}return a};s.z.object({x:ba.or(ri),y:va.or(ri)});const Vu=s.z.object({x:ba,y:va}),Gu=Object.freeze({x:"left",y:"top"}),Zu=(t,e)=>t.x===e.x&&t.y===e.y,oi=s.z.union([s.z.number(),Rn,Ln,ga,xu,Ru]),Ku=(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}},li=Object.freeze({x:0,y:0}),Xt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Xt,left:Xt,width:Xt,height:Xt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Rn,two:Rn,root:Vu});const ss=(t,e,n=0,r=0,i)=>{const a={one:{...li},two:{...li},root:i??Gu};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+n,y:a.one.y+r},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+n}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},lr=t=>{const e=ss(t);return{lower:e.one.x,upper:e.two.x}},cr=t=>{const e=ss(t);return{lower:e.one.y,upper:e.two.y}},Ju=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Hu=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([ga,Hu,Rn,Ln]);var Xu=Object.defineProperty,Qu=(t,e,n)=>e in t?Xu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ze=(t,e,n)=>Qu(t,typeof e!="symbol"?e+"":e,n);const eh=(t,e,n)=>e!==void 0&&t<e?e:n!==void 0&&t>n?n:t;s.z.object({offset:oi,scale:oi});s.z.object({offset:s.z.number(),scale:s.z.number()});const th=t=>(e,n,r,i)=>n==="dimension"?[e,r]:[e,i?r-t:r+t],nh=t=>(e,n,r,i)=>[e,i?r/t:r*t],rh=t=>(e,n,r)=>{if(e===null)return[t,r];const{lower:i,upper:a}=e,{lower:o,upper:c}=t,u=a-i,h=c-o;if(n==="dimension")return[t,r*(h/u)];const f=(r-i)*(h/u)+o;return[t,f]},sh=t=>(e,n,r)=>[t,r],ih=()=>(t,e,n)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,n];const{lower:r,upper:i}=t;return[t,i-(n-r)]},ah=t=>(e,n,r)=>{const{lower:i,upper:a}=t;return r=eh(r,i,a),[e,r]},Br=class gt{constructor(){ze(this,"ops",[]),ze(this,"currBounds",null),ze(this,"currType",null),ze(this,"reversed",!1),this.ops=[]}static translate(e){return new gt().translate(e)}static magnify(e){return new gt().magnify(e)}static scale(e,n){return new gt().scale(e,n)}translate(e){const n=this.new(),r=th(e);return r.type="translate",n.ops.push(r),n}magnify(e){const n=this.new(),r=nh(e);return r.type="magnify",n.ops.push(r),n}scale(e,n){const r=re(e,n),i=this.new(),a=rh(r);return a.type="scale",i.ops.push(a),i}clamp(e,n){const r=re(e,n),i=this.new(),a=ah(r);return a.type="clamp",i.ops.push(a),i}reBound(e,n){const r=re(e,n),i=this.new(),a=sh(r);return a.type="re-bound",i.ops.push(a),i}invert(){const e=ih();e.type="invert";const n=this.new();return n.ops.push(e),n}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new gt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,n){return this.currBounds=null,this.ops.reduce(([r,i],a)=>a(r,e,i,this.reversed),[null,n])[1]}reverse(){const e=this.new();e.ops.reverse();const n=[];return e.ops.forEach((r,i)=>{if(r.type==="scale"||n.some(([o,c])=>i>=o&&i<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>i);a!==-1&&n.push([i,a])}),n.forEach(([r,i])=>{const a=e.ops.slice(r,i);a.unshift(e.ops[i]),e.ops.splice(r,i-r+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};ze(Br,"IDENTITY",new Br);let ci=Br;const ui=class Oe{constructor(e=new ci,n=new ci,r=null){ze(this,"x"),ze(this,"y"),ze(this,"currRoot"),this.x=e,this.y=n,this.currRoot=r}static translate(e,n){return new Oe().translate(e,n)}static translateX(e){return new Oe().translateX(e)}static translateY(e){return new Oe().translateY(e)}static clamp(e){return new Oe().clamp(e)}static magnify(e){return new Oe().magnify(e)}static scale(e){return new Oe().scale(e)}static reBound(e){return new Oe().reBound(e)}translate(e,n){const r=Ku(e,n),i=this.copy();return i.x=this.x.translate(r.x),i.y=this.y.translate(r.y),i}translateX(e){const n=this.copy();return n.x=this.x.translate(e),n}translateY(e){const n=this.copy();return n.y=this.y.translate(e),n}magnify(e){const n=this.copy();return n.x=this.x.magnify(e.x),n.y=this.y.magnify(e.y),n}scale(e){const n=this.copy();if(Ju(e)){const r=this.currRoot;return n.currRoot=e.root,r!=null&&!Zu(r,e.root)&&(r.x!==e.root.x&&(n.x=n.x.invert()),r.y!==e.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(lr(e)),n.y=n.y.scale(cr(e)),n}return n.x=n.x.scale(e.width),n.y=n.y.scale(e.height),n}reBound(e){const n=this.copy();return n.x=this.x.reBound(lr(e)),n.y=this.y.reBound(cr(e)),n}clamp(e){const n=this.copy();return n.x=this.x.clamp(lr(e)),n.y=this.y.clamp(cr(e)),n}copy(){const e=new Oe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ss(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};ze(ui,"IDENTITY",new ui);var oh=Object.defineProperty,lh=(t,e,n)=>e in t?oh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e,n)=>lh(t,typeof e!="symbol"?e+"":e,n);let ch=(t,e=21)=>(n=e)=>{let r="",i=n|0;for(;i--;)r+=t[Math.random()*t.length|0];return r};const uh="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",hh=ch(uh,11),za=()=>hh(),dh=Object.freeze(Object.defineProperty({__proto__:null,create:za},Symbol.toStringTag,{value:"Module"})),fh=s.z.enum(["static","dynamic"]),Sa=(t,e)=>{const n=new I(e);if(![z.DAY,z.HOUR,z.MINUTE,z.SECOND,z.MILLISECOND,z.MICROSECOND,z.NANOSECOND].some(i=>i.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=t.valueOf()%n.valueOf();return t instanceof I?new I(r):new z(r)},M=class O{constructor(e,n="UTC"){if(y(this,"value"),y(this,"encodeValue",!0),e==null)this.value=O.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*O.MILLISECOND.valueOf();else if(typeof e=="string")this.value=O.parseDateTimeString(e,n).valueOf();else if(Array.isArray(e))this.value=O.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),n==="local"&&(r=O.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=O.MAX:e=O.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,n=1,r=1]){const i=new Date(e,n-1,r,0,0,0,0);return new O(BigInt(i.getTime())*O.MILLISECOND.valueOf()).truncate(O.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,n="UTC"){const[r,i,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let u=O.hours(parseInt(r??"00")).add(O.minutes(parseInt(i??"00"))).add(O.seconds(parseInt(o??"00"))).add(O.milliseconds(parseInt(c??"00")));return n==="local"&&(u=u.add(O.utcOffset)),u.valueOf()}static parseDateTimeString(e,n="UTC"){if(!e.includes("/")&&!e.includes("-"))return O.parseTimeString(e,n);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new O(BigInt(r.getTime())*O.MILLISECOND.valueOf(),n).valueOf()}fString(e="ISO",n="UTC"){switch(e){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(O.utcOffset).date().toISOString()}timeString(e=!1,n="UTC"){const r=this.toISOString(n);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),n=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new z(BigInt(new Date().getTimezoneOffset())*O.MINUTE.valueOf())}static since(e){return new O().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new O(e).valueOf()}span(e){return this.range(e).span}range(e){return new K(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new O(e).valueOf()}afterEq(e){return this.valueOf()>=new O(e).valueOf()}before(e){return this.valueOf()<new O(e).valueOf()}beforeEq(e){return this.valueOf()<=new O(e).valueOf()}add(e){return new O(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new O(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(z.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(z.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(z.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(z.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(O.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(O.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const n=this.date();return n.setFullYear(e),new O(n)}get month(){return this.date().getMonth()}setMonth(e){const n=this.date();return n.setMonth(e),new O(n)}get day(){return this.date().getDate()}setDay(e){const n=this.date();return n.setDate(e),new O(n)}get hour(){return this.date().getHours()}setHour(e){const n=this.date();return n.setHours(e),new O(n)}get minute(){return this.date().getMinutes()}setMinute(e){const n=this.date();return n.setMinutes(e),new O(n)}get second(){return this.date().getSeconds()}setSecond(e){const n=this.date();return n.setSeconds(e),new O(n)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const n=this.date();return n.setMilliseconds(e),new O(n)}toString(){return this.date().toISOString()}remainder(e){return Sa(this,e)}get isToday(){return this.truncate(z.DAY).equals(O.now().truncate(z.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new O(new Date)}static max(...e){let n=O.MIN;for(const r of e){const i=new O(r);i.after(n)&&(n=i)}return n}static min(...e){let n=O.MAX;for(const r of e){const i=new O(r);i.before(n)&&(n=i)}return n}static nanoseconds(e){return new O(e)}static microseconds(e){return O.nanoseconds(e*1e3)}static milliseconds(e){return O.microseconds(e*1e3)}static seconds(e){return O.milliseconds(e*1e3)}static minutes(e){return O.seconds(e*60)}static hours(e){return O.minutes(e*60)}static days(e){return O.hours(e*24)}};y(M,"NANOSECOND",M.nanoseconds(1)),y(M,"MICROSECOND",M.microseconds(1)),y(M,"MILLISECOND",M.milliseconds(1)),y(M,"SECOND",M.seconds(1)),y(M,"MINUTE",M.minutes(1)),y(M,"HOUR",M.hours(1)),y(M,"DAY",M.days(1)),y(M,"MAX",new M((1n<<63n)-1n)),y(M,"MIN",new M(0)),y(M,"ZERO",new M(0)),y(M,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new M(t.value)),s.z.string().transform(t=>new M(BigInt(t))),s.z.instanceof(Number).transform(t=>new M(t)),s.z.number().transform(t=>new M(t)),s.z.instanceof(M)]));let I=M;const B=class k{constructor(e){y(this,"value"),y(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof k?e:e instanceof At?e.period:e instanceof I?new k(e):["number","bigint"].includes(typeof e)?k.seconds(e):new k(e)}static fromMilliseconds(e){return e instanceof k?e:e instanceof At?e.period:e instanceof I?new k(e):["number","bigint"].includes(typeof e)?k.milliseconds(e):new k(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new k(e).valueOf()}greaterThan(e){return this.valueOf()>new k(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new k(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new k(e).valueOf()}remainder(e){return Sa(this,e)}truncate(e){return new k(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(k.DAY),n=this.truncate(k.HOUR),r=this.truncate(k.MINUTE),i=this.truncate(k.SECOND),a=this.truncate(k.MILLISECOND),o=this.truncate(k.MICROSECOND),c=this.truncate(k.NANOSECOND),u=e,h=n.sub(e),f=r.sub(n),d=i.sub(r),N=a.sub(i),x=o.sub(a),ae=c.sub(o);let Y="";return u.isZero||(Y+=`${u.days}d `),h.isZero||(Y+=`${h.hours}h `),f.isZero||(Y+=`${f.minutes}m `),d.isZero||(Y+=`${d.seconds}s `),N.isZero||(Y+=`${N.milliseconds}ms `),x.isZero||(Y+=`${x.microseconds}µs `),ae.isZero||(Y+=`${ae.nanoseconds}ns`),Y.trim()}mult(e){return new k(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(k.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(k.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(k.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(k.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(k.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(k.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new k(e).valueOf()}add(e){return new k(this.valueOf()+new k(e).valueOf())}sub(e){return new k(this.valueOf()-new k(e).valueOf())}static nanoseconds(e=1){return new k(e)}static microseconds(e=1){return k.nanoseconds(_e(e,1e3))}static milliseconds(e=1){return k.microseconds(_e(e,1e3))}static seconds(e=1){return k.milliseconds(_e(e,1e3))}static minutes(e=1){return k.seconds(_e(e,60))}static hours(e){return k.minutes(_e(e,60))}static days(e){return k.hours(_e(e,24))}};y(B,"NANOSECOND",B.nanoseconds(1)),y(B,"MICROSECOND",B.microseconds(1)),y(B,"MILLISECOND",B.milliseconds(1)),y(B,"SECOND",B.seconds(1)),y(B,"MINUTE",B.minutes(1)),y(B,"HOUR",B.hours(1)),y(B,"DAY",B.days(1)),y(B,"MAX",new B((1n<<63n)-1n)),y(B,"MIN",new B(0)),y(B,"ZERO",new B(0)),y(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 z=B;const mt=class hn extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new hn(e).valueOf()}get period(){return z.seconds(1/this.valueOf())}sampleCount(e){return new z(e).seconds*this.valueOf()}byteCount(e,n){return this.sampleCount(e)*new ne(n).valueOf()}span(e){return z.seconds(e/this.valueOf())}byteSpan(e,n){return this.span(e.valueOf()/n.valueOf())}static hz(e){return new hn(e)}static khz(e){return hn.hz(e*1e3)}};y(mt,"z",s.z.union([s.z.number().transform(t=>new mt(t)),s.z.instanceof(Number).transform(t=>new mt(t)),s.z.instanceof(mt)]));let At=mt;const Z=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ge(e*this.valueOf())}};y(Z,"UNKNOWN",new Z(0)),y(Z,"BIT128",new Z(16)),y(Z,"BIT64",new Z(8)),y(Z,"BIT32",new Z(4)),y(Z,"BIT16",new Z(2)),y(Z,"BIT8",new Z(1)),y(Z,"z",s.z.union([s.z.number().transform(t=>new Z(t)),s.z.instanceof(Number).transform(t=>new Z(t)),s.z.instanceof(Z)]));let ne=Z;const pe=class dn{constructor(e,n){y(this,"start"),y(this,"end"),typeof e=="object"&&"start"in e?(this.start=new I(e.start),this.end=new I(e.end)):(this.start=new I(e),this.end=new I(n))}get span(){return new z(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new dn(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,n=z.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const i=I.max(r.start,e.start),a=I.min(r.end,e.end);return a.before(i)?!1:new z(a.sub(i)).greaterThanOrEqual(n)}roughlyEquals(e,n){let r=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=n.valueOf()&&i<=n.valueOf()}contains(e){return e instanceof dn?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const n=new dn(this.start,this.end);return e.start.after(this.start)&&(n.start=e.start),e.start.after(this.end)&&(n.end=e.start),e.end.before(this.end)&&(n.end=e.end),e.end.before(this.start)&&(n.start=e.end),n}};y(pe,"MAX",new pe(I.MIN,I.MAX)),y(pe,"MIN",new pe(I.MAX,I.MIN)),y(pe,"ZERO",new pe(I.ZERO,I.ZERO)),y(pe,"z",s.z.union([s.z.object({start:I.z,end:I.z}).transform(t=>new pe(t.start,t.end)),s.z.instanceof(pe)]));let K=pe;const yh=(t,e)=>t.start.before(e.start)?-1:t.start.after(e.start)?1:t.end.before(e.end)?-1:t.end.after(e.end)?1:0,g=class _ extends String{constructor(e){if(e instanceof _||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const n=_.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(n!=null){super(n.valueOf());return}throw super(_.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=_.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(n=>this.equals(n))}toString(){return this.valueOf()}get isVariable(){return this.equals(_.JSON)||this.equals(_.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(_.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=_.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(_.UINT8)||this.equals(_.UINT16)||this.equals(_.UINT32)||this.equals(_.UINT64)}get isSigned(){return this.equals(_.INT8)||this.equals(_.INT16)||this.equals(_.INT32)||this.equals(_.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(_.INT32)&&e.equals(_.FLOAT64)||this.equals(_.INT8)&&e.equals(_.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return _.BIG_INT_TYPES.some(e=>e.equals(this))}};y(g,"UNKNOWN",new g("unknown")),y(g,"FLOAT64",new g("float64")),y(g,"FLOAT32",new g("float32")),y(g,"INT64",new g("int64")),y(g,"INT32",new g("int32")),y(g,"INT16",new g("int16")),y(g,"INT8",new g("int8")),y(g,"UINT64",new g("uint64")),y(g,"UINT32",new g("uint32")),y(g,"UINT16",new g("uint16")),y(g,"UINT8",new g("uint8")),y(g,"BOOLEAN",g.UINT8),y(g,"TIMESTAMP",new g("timestamp")),y(g,"UUID",new g("uuid")),y(g,"STRING",new g("string")),y(g,"JSON",new g("json")),y(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),y(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),y(g,"DENSITIES",new Map([[g.UINT8.toString(),ne.BIT8],[g.UINT16.toString(),ne.BIT16],[g.UINT32.toString(),ne.BIT32],[g.UINT64.toString(),ne.BIT64],[g.FLOAT32.toString(),ne.BIT32],[g.FLOAT64.toString(),ne.BIT64],[g.INT8.toString(),ne.BIT8],[g.INT16.toString(),ne.BIT16],[g.INT32.toString(),ne.BIT32],[g.INT64.toString(),ne.BIT64],[g.TIMESTAMP.toString(),ne.BIT64],[g.STRING.toString(),ne.UNKNOWN],[g.JSON.toString(),ne.UNKNOWN],[g.UUID.toString(),ne.BIT128]])),y(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),y(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),y(g,"z",s.z.union([s.z.string().transform(t=>new g(t)),s.z.instanceof(g)]));let E=g;const Q=class W extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return W.bytes(this.valueOf()+e.valueOf())}sub(e){return W.bytes(this.valueOf()-e.valueOf())}truncate(e){return new W(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return W.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/W.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/W.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/W.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/W.TERABYTE.valueOf()}toString(){const e=this.truncate(W.TERABYTE),n=this.truncate(W.GIGABYTE),r=this.truncate(W.MEGABYTE),i=this.truncate(W.KILOBYTE),a=this.truncate(W.BYTE),o=e,c=n.sub(e),u=r.sub(n),h=i.sub(r),f=a.sub(i);let d="";return o.isZero||(d+=`${o.terabytes}TB `),c.isZero||(d+=`${c.gigabytes}GB `),u.isZero||(d+=`${u.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new W(e)}static kilobytes(e=1){return W.bytes(e.valueOf()*1e3)}static megabytes(e=1){return W.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return W.megabytes(e.valueOf()*1e3)}static terabytes(e){return W.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};y(Q,"BYTE",new Q(1)),y(Q,"KILOBYTE",Q.kilobytes(1)),y(Q,"MEGABYTE",Q.megabytes(1)),y(Q,"GIGABYTE",Q.gigabytes(1)),y(Q,"TERABYTE",Q.terabytes(1)),y(Q,"ZERO",new Q(0)),y(Q,"z",s.z.union([s.z.number().transform(t=>new Q(t)),s.z.instanceof(Q)]));let Ge=Q;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const ka=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof I||t instanceof z||t instanceof Date},ph=(t,e,n,r=0)=>t.usesBigInt&&!e.usesBigInt?Number(n)-Number(r):!t.usesBigInt&&e.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):wt(n,-r).valueOf(),wt=(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),gh=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Me?!0:ka(t),Ee=-1,Dr={[Symbol.iterator]:()=>Dr,next:()=>({done:!0,value:void 0})},mh=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),wh=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),Ur=10,bt=class ge{constructor(e){y(this,"key",""),y(this,"isSynnaxSeries",!0),y(this,"dataType"),y(this,"sampleOffset"),y(this,"gl"),y(this,"_data"),y(this,"_timeRange"),y(this,"alignment",0n),y(this,"_cachedMin"),y(this,"_cachedMax"),y(this,"writePos",Ee),y(this,"_refCount",0),y(this,"_cachedLength"),y(this,"_cachedIndexes"),gh(e)&&(e={data:e});const{dataType:n,timeRange:r,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:c=za()}=e,u=e.data??[];if(u instanceof ge||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this._timeRange=d._timeRange,this.alignment=d.alignment,this._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=ka(u),f=Array.isArray(u);if(n!=null)this.dataType=new E(n);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=E.STRING;else if(typeof d=="number")this.dataType=E.FLOAT64;else if(typeof d=="bigint")this.dataType=E.INT64;else if(typeof d=="boolean")this.dataType=E.BOOLEAN;else if(d instanceof I||d instanceof Date||d instanceof I)this.dataType=E.TIMESTAMP;else if(typeof d=="object")this.dataType=E.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new E(u)}if(!f&&!h)this._data=u;else{let d=h?[u]:u;const N=d[0];(N instanceof I||N instanceof Date||N instanceof z)&&(d=d.map(x=>new I(x).valueOf())),this.dataType.equals(E.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
16
- `)}
17
- `).buffer):this.dataType.equals(E.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(x=>We.encodeString(x)).join(`
18
- `)}
19
- `).buffer):this.dataType.usesBigInt&&typeof N=="number"?this._data=new this.dataType.Array(d.map(x=>BigInt(Math.round(x)))).buffer:!this.dataType.usesBigInt&&typeof N=="bigint"?this._data=new this.dataType.Array(d.map(x=>Number(x))).buffer:this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:n,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new E(n).Array(e),a=new ge({data:i.buffer,dataType:n,...r});return a.writePos=0,a}static createTimestamps(e,n,r){const i=r.spanRange(n.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(r.add(n.span(o)).valueOf());return new ge({data:a,dataType:E.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,n){const r=new TextEncoder().encode(`${e.join(`
20
- `)}
21
- `);return new ge({data:r,dataType:E.STRING,timeRange:n})}static fromJSON(e,n){const r=new TextEncoder().encode(`${e.map(i=>We.encodeString(i)).join(`
22
- `)}
23
- `);return new ge({data:r,dataType:E.JSON,timeRange:n})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ee)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===Ee)return 0;const n=this.capacity-this.writePos,r=e.sub(0,n);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ee?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(E.STRING,E.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
24
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(E.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=E.UUID.density.valueOf(),n=Array(this.length);for(let r=0;r<this.length;r++){const i=this.underlyingData.slice(r*e,(r+1)*e),a=Array.from(new Uint8Array(i.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");n[r]=a}return n}parseJSON(e){if(!this.dataType.equals(E.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
25
- `).slice(0,-1).map(n=>e.parse(We.decodeString(n)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Ge(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ee?this.byteCapacity:this.dataType.isVariable?new Ge(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ee?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const n=[0];return this.data.forEach((r,i)=>{r===Ur&&(e++,n.push(i+1))}),this._cachedIndexes=n,this._cachedLength=e,e}convert(e,n=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let i=0;i<this.length;i++)r[i]=ph(this.dataType,e,this.data[i],n);return new ge({data:r.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(E.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}else{const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),wt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(E.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}else{const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),wt(this._cachedMin,this.sampleOffset))}get bounds(){return re(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const n=e._cachedMin??e.calcRawMin();n<this._cachedMin&&(this._cachedMin=n)}if(this._cachedMax!=null){const n=e._cachedMax??e.calcRawMax();n>this._cachedMax&&(this._cachedMax=n)}}enrich(){this.max,this.min}get range(){return wt(this.max,-this.min)}atAlignment(e,n){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(e,n){if(this.dataType.isVariable)return this.atVariable(e,n??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${e}`);return}return wt(r,this.sampleOffset)}atVariable(e,n){let r=0,i=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],i=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===Ur){if(e===0){i=o;break}r=o+1,e--}if(i===0&&(i=this.data.length),r>=i||e>0){if(n)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(r,i);return this.dataType.equals(E.STRING)?new TextDecoder().decode(a):da(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let n=0,r=this.length-1;const i=Su(e);for(;n<=r;){const a=Math.floor((n+r)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?n=a+1:r=a-1}return n}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(E.FLOAT32)&&!this.dataType.equals(E.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:i}=this.gl;if(n==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ee){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ee}as(e){if(e==="string"){if(!this.dataType.equals(E.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(E.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:{lower:wi(this.alignmentBounds.lower),upper:wi(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return re(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new bh(this);return this.dataType.equals(E.JSON)?new vh(e):e}return new Oh(this)}slice(e,n){return this.sliceSub(!1,e,n)}sub(e,n){return this.sliceSub(!0,e,n)}subIterator(e,n){return new hi(this,e,n??this.length)}subAlignmentIterator(e,n){return new hi(this,Number(e-this.alignment),Number(n-this.alignment))}subBytes(e,n){if(e>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,n);return new ge({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return e?i=this.data.subarray(n,r):i=this.data.slice(n,r),new ge({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(e){return new ge({data:this.buffer,dataType:this.dataType,timeRange:K.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};y(bt,"crudeZ",s.z.object({timeRange:K.z.optional(),dataType:E.z,alignment:s.z.coerce.bigint().optional(),data:s.z.union([mh,wh,s.z.instanceof(ArrayBuffer),s.z.instanceof(Uint8Array)]),glBufferUsage:fh.optional().default("static").optional()})),y(bt,"z",bt.crudeZ.transform(t=>new bt(t)));let Me=bt,hi=class{constructor(t,e,n){y(this,"series"),y(this,"end"),y(this,"index"),this.series=t;const r=re(0,t.length);this.end=ai(r,n),this.index=ai(r,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};class bh{constructor(e){if(y(this,"series"),y(this,"index"),y(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==Ur;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var di,fi;class vh{constructor(e){y(this,"wrapped"),y(this,di,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:We.decodeString(e.value)}}[(fi=Symbol.iterator,di=Symbol.toStringTag,fi)](){return this}}var yi,pi;class Oh{constructor(e){y(this,"series"),y(this,"index"),y(this,yi,"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)}}[(pi=Symbol.iterator,yi=Symbol.toStringTag,pi)](){return this}}class Th{constructor(e){if(y(this,"series"),e.length!==0){const n=e[0].dataType;for(let r=1;r<e.length;r++)if(!e[r].dataType.equals(n))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new E(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?E.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?K.ZERO:new K(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?re(0n,0n):re(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,n)=>e+n.length,0)}atAlignment(e,n){if(this.series.length===0){if(n)throw new Error(`[series] - no value at alignment ${e}`);return}for(const r of this.series)if(Ht(r.alignmentBounds,e))return r.atAlignment(e,n);if(n)throw new Error(`[series] - no value at alignment ${e}`)}at(e,n=!1){e<0&&(e=this.length+e);for(const r of this.series){if(e<r.length)return r.at(e,n);e-=r.length}if(n)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,n){return new ur(this,e,n??this.length)}subAlignmentIterator(e,n){if(e>=this.alignmentBounds.upper||n<=this.alignmentBounds.lower)return Dr;let r=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)r+=o.length;else if(Ht(o.alignmentBounds,e)){r+=Number(e-o.alignment);break}}let i=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(n<o.alignment)break;if(n>=o.alignmentBounds.upper)i+=o.length;else if(Ht(o.alignmentBounds,n)){i+=Number(n-o.alignment);break}}return new ur(this,r,i)}subAlignmentSpanIterator(e,n){if(e>=this.alignmentBounds.upper)return Dr;let r=0;for(let i=0;i<this.series.length;i++){const a=this.series[i];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)r+=a.length;else if(Ht(a.alignmentBounds,e)){r+=Number(e-a.alignment);break}}return new ur(this,r,r+n)}get byteLength(){return new Ge(this.series.reduce((e,n)=>e+n.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let n=0;for(const r of this.series)e.set(r.data,n),n+=r.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,n){const r=this.series.map(i=>i.alignmentBounds);return Fu(r,e,n)}distance(e,n){const r=this.series.map(i=>i.alignmentBounds);return Wu(r,e,n)}parseJSON(e){if(!this.dataType.equals(E.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(n=>n.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new zh(this.series)}}var gi,mi;class zh{constructor(e){y(this,"series"),y(this,"seriesIndex"),y(this,"internal"),y(this,gi,"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())}[(mi=Symbol.iterator,gi=Symbol.toStringTag,mi)](){return this}}let ur=class{constructor(t,e,n){y(this,"series"),y(this,"index"),y(this,"end"),this.series=t,this.end=n,this.index=e}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};const wi=t=>{const e=t>>32n,n=t&0xffffffffn;return{domain:e,sample:n}},Sh=(t,e)=>{let n=null;return e===0?t:(...r)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...r),e)}},kh=(t,e,n=".")=>{const r=t.split(n);return r.map((i,a)=>{const o=e(i,a,r);return o==null?null:typeof o=="string"?o:o.join(n)}).filter(i=>i!=null).join(n)},Nh=(t,e,n={optional:!1,separator:"."})=>{n.separator??(n.separator=".");const{optional:r,getter:i=(c,u)=>c[u]}=n,a=e.split(n.separator);if(a.length===1&&a[0]==="")return t;let o=t;for(const c of a){const u=i(o,c);if(u==null){if(r)return null;throw new Error(`Path ${e} does not exist. ${c} is null`)}o=u}return o};s.z.object({key:s.z.string(),value:s.z.string()});var Eh=Object.defineProperty,Ih=(t,e,n)=>e in t?Eh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fn=(t,e,n)=>Ih(t,typeof e!="symbol"?e+"":e,n);let xh=class{constructor(t,e){fn(this,"handlers"),fn(this,"transform"),fn(this,"closer"),this.transform=t,this.handlers=e??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){let e=t;if(this.transform!=null){const[n,r]=this.transform(t);if(!r)return;e=n}this.handlers.forEach((n,r)=>r(e))}setCloser(t){this.closer=t}async close(){var t;return await((t=this.closer)==null?void 0:t.call(this))}},Ah=class{constructor(t){fn(this,"handlers"),this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((e,n)=>n(t))}};const Ue=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Ah,Observer:xh},Symbol.toStringTag,{value:"Module"})),Lt=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),Ch=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Ch();const jh=["macOS","Windows","Linux"],Rh=["macos","windows","linux"],Ph={macos:"macOS",windows:"Windows",linux:"Linux"};s.z.enum(jh).or(s.z.enum(Rh).transform(t=>Ph[t]));var Mh=Object.defineProperty,Bh=(t,e,n)=>e in t?Mh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,vt=(t,e,n)=>Bh(t,typeof e!="symbol"?e+"":e,n);const Dh=(...t)=>t.map(Na).join(""),Na=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Uh=t=>t.endsWith("/")?t.slice(0,-1):t,$r=class Lr{constructor({host:e,port:n,protocol:r="",pathPrefix:i=""}){vt(this,"protocol"),vt(this,"host"),vt(this,"port"),vt(this,"path"),this.protocol=r,this.host=e,this.port=n,this.path=Na(i)}replace(e){return new Lr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Lr({...this,pathPrefix:Dh(this.path,e)})}toString(){return Uh(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};vt($r,"UNKNOWN",new $r({host:"unknown",port:0}));let $h=$r;const Lh=-128,_h=127,qh=s.z.number().int().min(Lh).max(_h),Yh=-32768,Fh=32767,Wh=s.z.number().int().min(Yh).max(Fh),Vh=-2147483648,Gh=2147483647,Zh=s.z.number().int().min(Vh).max(Gh),Kh=-9223372036854775808n,Jh=9223372036854775807n,Hh=s.z.bigint().min(Kh).max(Jh),Xh=255,Qh=s.z.number().int().min(0).max(Xh),ed=65535,td=s.z.number().int().min(0).max(ed),nd=4294967295,rd=s.z.number().int().min(0).max(nd),sd=18446744073709551615n,id=s.z.bigint().min(0n).max(sd),Ea=t=>kh(t,(e,n,r)=>{const i=n===r.length-1,a=!isNaN(parseInt(e)),o=!isNaN(parseInt(r[n+1]));return a&&(e="element"),i||o?e:[e,"shape"]}),bi=(t,e)=>{if(t==null)return null;const n=t[e];return n==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:n},ad=(t,e,n)=>Nh(bi(t,"shape"),Ea(e),{...n,getter:bi}),od=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:ad,getFieldSchemaPath:Ea,int16:Wh,int32:Zh,int64:Hh,int8:qh,uint16:td,uint32:rd,uint64:id,uint8:Qh},Symbol.toStringTag,{value:"Module"}));var ld=Object.defineProperty,cd=(t,e,n)=>e in t?ld(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ot=(t,e,n)=>cd(t,typeof e!="symbol"?e+"":e,n);const ud=async t=>await new Promise(e=>setTimeout(e,z.fromMilliseconds(t).milliseconds)),hd=s.z.object({interval:z.z.optional(),maxRetries:s.z.number().optional(),scale:s.z.number().optional()}),dd=(t={})=>{const e=t.sleepFn||ud,n=t.maxRetries??5,r=t.scale??1;let i=0,a=new z(t.interval??z.milliseconds(1));return async()=>i>=n?!1:(await e(a),a=a.mult(r),i++,!0)},fd=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:hd,create:dd},Symbol.toStringTag,{value:"Module"})),me=class extends Number{};Ot(me,"ABSOLUTE",255),Ot(me,"MINIMUM",0),Ot(me,"BOUNDS",{lower:me.MINIMUM,upper:me.ABSOLUTE+1}),Ot(me,"z",s.z.union([s.z.instanceof(me),s.z.number().int().min(0).max(255).transform(t=>new me(t)),s.z.instanceof(Number).transform(t=>new me(t))]));let Ia=me;const xa=s.z.object({name:s.z.string(),key:s.z.string()}),yd=t=>s.z.object({subject:xa,resource:t,authority:Ia.z}),pd=(...t)=>e=>e.filter(n=>{let r=!1;return n.to!=null&&(r=t.includes(n.to.resource)),n.from!=null&&!r&&(r=t.includes(n.from.resource)),r}),Ze=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ia,filterTransfersByChannelKey:pd,stateZ:yd,subjectZ:xa},Symbol.toStringTag,{value:"Module"})),Aa=class Tt extends Error{constructor(){super(Tt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(Tt.MESSAGE):e instanceof Tt||e.message.includes(Tt.MESSAGE)}};Ot(Aa,"MESSAGE","canceled");let gd=Aa;new gd;const _r=s.z.string().regex(/^\d+\.\d+\.\d+$/),_t=(t,e,n={})=>{n.checkMajor??(n.checkMajor=!0),n.checkMinor??(n.checkMinor=!0),n.checkPatch??(n.checkPatch=!0);const r=_r.parse(t),i=_r.parse(e),[a,o,c]=r.split(".").map(Number),[u,h,f]=i.split(".").map(Number);if(n.checkMajor){if(a<u)return ir;if(a>u)return ar}if(n.checkMinor){if(o<h)return ir;if(o>h)return ar}if(n.checkPatch){if(c<f)return ir;if(c>f)return ar}return $n},md=(t,e,n={})=>Iu(_t(t,e,n)),Ca=(t,e,n={})=>Eu(_t(t,e,n)),wd=(t,e,n={})=>Nu(_t(t,e,n)),bd=({name:t,migrate:e})=>n=>{try{const r=e(n);return console.log(`${t} migrated: ${n.version} -> ${r.version}`),r}catch(r){throw console.log(`${t} failed to migrate from ${n.version}`),console.error(r),r}},vd=({name:t,migrations:e,targetSchema:n,defaultVersion:r,def:i})=>{const a=Object.keys(e).sort(_t).pop();if(a==null)return h=>{if(h.version??(h.version=r),h.version!==i.version)return console.log(`${t} version ${h.version} is newer than latest version of ${i.version}.
26
- Returning default instead.
27
- `),i;try{return n!=null?n.parse(h):h}catch(f){return console.log(`${t} failed to parse default. Exiting with default`),console.error(f),i}};const o=Object.keys(e).length;let c=!1;const u=h=>{try{if(o===0||Ca(h.version,a))return console.log(c?`${t} ${h.version} now up to date`:`${t} version ${h.version} is up to date with target version ${i.version}`),h;const f=h.version,d=e[f],N=d(h);return c=!0,u(N)}catch(f){return console.log(`${t} failed to migrate from ${h.version} to ${a}`),console.error(f),i}};return h=>{try{if(h.version==null)if(r!=null)console.log(`${t} version is null. Setting version to default of ${r}`),h.version=r;else return console.log(`${t} version is null and no default version set. Exiting with default`),i;return u(h)}catch(f){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(f),i}}},vi=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:_t,createMigration:bd,migrator:vd,semVerNewer:Ca,semVerOlder:wd,semVerZ:_r,versionsEqual:md},Symbol.toStringTag,{value:"Module"})),Od=(t,e="")=>{const n=t.length;return n===0?e:n===1?t[0]:n===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[n-1]}`},Td=t=>{const e=t.split(" "),n=new Set,r=e.map(o=>o.charAt(0).toLowerCase()).join("");n.add(r.replace(/-/g,"_")),n.add(r.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const i=/\d+/g;t.match(i)&&e.forEach((o,c)=>{if(i.test(o)){const u=e.map((h,f)=>f!==c?h.charAt(0).toLowerCase():h).join("");n.add(u.replace(/-/g,"_")),n.add(u.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const a=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return n.add(a.join("").replace(/-/g,"_")),n.add(a.join("_").replace(/-/g,"_")),Array.from(n).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},zd=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Td,naturalLanguageJoin:Od},Symbol.toStringTag,{value:"Module"})),Pe="sy.",yn=class ja extends de{constructor(){super(...arguments),l(this,"type",ja.TYPE)}};l(yn,"TYPE",`${Pe}validation`),l(yn,"matches",ee(yn.TYPE));let q=yn;const pn=class Ra extends q{constructor(e,n){super(`${e}: ${n}`),l(this,"type",Ra.TYPE),l(this,"field"),l(this,"message"),this.field=e,this.message=n}};l(pn,"TYPE",`${q.TYPE}.field`),l(pn,"matches",ee(pn.TYPE));let Oi=pn;const gn=class Pa extends de{constructor(){super(...arguments),l(this,"type",Pa.TYPE)}};l(gn,"TYPE",`${Pe}auth`),l(gn,"matches",ee(gn.TYPE));let Ke=gn;const mn=class Ma extends Ke{constructor(){super(...arguments),l(this,"type",Ma.TYPE)}};l(mn,"TYPE",`${Ke.TYPE}.invalid-token`),l(mn,"matches",ee(mn.TYPE));let qr=mn;const wn=class Ba extends Ke{constructor(){super(...arguments),l(this,"type",Ba.TYPE)}};l(wn,"TYPE",`${Ke.TYPE}.expired-token`),l(wn,"matches",ee(wn.TYPE));let Yr=wn;const bn=class Da extends de{constructor(e){super(`
28
- Unexpected error encountered:
29
-
30
- ${e}
31
-
32
- Please report this to the Synnax team.
33
- `),l(this,"type",Da.TYPE)}};l(bn,"TYPE",`${Pe}unexpected`),l(bn,"matches",ee(bn.TYPE));let le=bn;const vn=class Ua extends de{constructor(){super(...arguments),l(this,"type",Ua.TYPE)}};l(vn,"TYPE",`${Pe}query`),l(vn,"matches",ee(vn.TYPE));let he=vn;const On=class $a extends he{constructor(){super(...arguments),l(this,"type",$a.TYPE)}};l(On,"TYPE",`${he.TYPE}.not_found`),l(On,"matches",ee(On.TYPE));let Je=On;const Tn=class La extends he{constructor(){super(...arguments),l(this,"type",La.TYPE)}};l(Tn,"TYPE",`${he.TYPE}.multiple_results`),l(Tn,"matches",ee(Tn.TYPE));let He=Tn;const zn=class _a extends de{constructor(e,n){super(e),l(this,"type",_a.TYPE),l(this,"path"),this.path=n}};l(zn,"TYPE",`${Pe}route`),l(zn,"matches",ee(zn.TYPE));let Ti=zn;const Sn=class qa extends de{constructor(){super(...arguments),l(this,"type",qa.TYPE)}};l(Sn,"TYPE",`${Pe}control`),l(Sn,"matches",ee(Sn.TYPE));let Pn=Sn;const kn=class Ya extends Pn{constructor(){super(...arguments),l(this,"type",Ya.TYPE)}};l(kn,"TYPE",`${Pn.TYPE}.unauthorized`),l(kn,"matches",ee(kn.TYPE));let zi=kn;const hr=class Fa extends de{constructor(){super(...arguments),l(this,"type",Fa.TYPE)}};l(hr,"TYPE",`${Pe}contiguity`),l(hr,"matches",ee(hr.TYPE));const Sd=t=>{if(!t.type.startsWith(Pe))return null;if(t.type.startsWith(q.TYPE)){if(t.type===Oi.TYPE){const e=t.data.split(": ");return e.length<2?new q(t.data):new Oi(e[0],e[1])}return new q(t.data)}return t.type.startsWith(Ke.TYPE)?t.type.startsWith(qr.TYPE)?new qr(t.data):t.type.startsWith(Yr.TYPE)?new Yr(t.data):new Ke(t.data):t.type.startsWith(le.TYPE)?new le(t.data):t.type.startsWith(he.TYPE)?t.type.startsWith(Je.TYPE)?new Je(t.data):t.type.startsWith(He.TYPE)?new He(t.data):new he(t.data):t.type.startsWith(Pn.TYPE)?t.type.startsWith(zi.TYPE)?new zi(t.data):new Pn(t.data):t.type.startsWith(Ti.TYPE)?new Ti(t.data,t.data):new le(t.data)},kd=()=>{throw new Error("Not implemented")};ra({encode:kd,decode:Sd});const Nd=async(t,e)=>{const[n,r]=await e(t);return r==null?[n,r]:r instanceof Re?[n,new Re({message:`Cannot reach cluster at ${r.url.host}:${r.url.port}`,url:r.url})]:[n,r]},_n=s.z.string().uuid(),is=s.z.string(),Wa=s.z.object({key:_n,name:is}),Va="group",J=t=>s.z.union([s.z.union([s.z.null(),s.z.undefined()]).transform(()=>[]),t.array()]),H=s.z.number(),qt=s.z.string(),Yt=s.z.object({name:qt,key:H,rate:At.z,dataType:E.z,leaseholder:s.z.number(),index:H,isIndex:s.z.boolean(),internal:s.z.boolean(),virtual:s.z.boolean(),alias:s.z.string().optional(),expression:s.z.string().default(""),requires:J(H)}),Ga=Yt.extend({key:H.optional(),leaseholder:s.z.number().optional(),index:H.optional(),rate:At.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1),expression:s.z.string().optional().default(""),requires:J(H).optional().default([])}),qn="channel",Ed="framer",Si=t=>{const e=b(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ki=(t,e)=>{const n=b(t);if(n.length===e.length)return;const r=Si(t);throw Si===null?new q("[Frame] - channel keys or names must be provided when constructing a frame."):new q(`[Frame] - ${r}s and series must be the same length.
34
- Got ${n.length} ${r}s and ${e.length} series.`)};let ue=class qe{constructor(e=[],n=[]){if(l(this,"columns",[]),l(this,"series",[]),e instanceof qe){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((r,i)=>this.push(i,...b(r)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const r=e;r.series??(r.series=[]),r.keys??(r.keys=[]);const i=r.series.map(a=>Id(a));ki(r.keys,i),r.keys.forEach((a,o)=>this.push(a,i[o]))}else Object.entries(e).forEach(([r,i])=>{const a=parseInt(r);if(!isNaN(a))return this.push(a,...b(i));this.push(r,...b(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const r=b(n),i=b(e);ki(i,r),r.forEach((a,o)=>this.push(i[o],a));return}throw new q(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
35
- payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
36
- name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new le("colType is not key");return this.columns??[]}get uniqueKeys(){return ni.unique(this.keys)}get names(){if(this.colType==="key")throw new le("colType is not name");return this.columns??[]}get uniqueNames(){return ni.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>xd(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(n=>n.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return K.ZERO;const r=I.min(...this.series.map(a=>a.timeRange.start)),i=I.max(...this.series.map(a=>a.timeRange.end));return new K(r,i)}const n=this.get(e);return n==null?K.ZERO:n.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(n=>e.includes(n)):new Th(this.series.filter((n,r)=>this.columns[r]===e))}push(e,...n){if(e instanceof qe){if(this.colType!==null&&e.colType!==this.colType)throw new q("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...n),typeof e=="string"&&this.colType==="key")throw new q("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new q("keyVariant must match");this.columns.push(...Array.from({length:n.length},()=>e))}}concat(e){return new qe([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const n=new qe;return this.forEach((r,i,a)=>n.push(...e(r,i,a))),n}forEach(e){this.columns.forEach((n,r)=>{const i=this.series[r];e(n,i,r)})}at(e,n=!1){const r={};return this.uniqueColumns.forEach(i=>{r[i]=this.get(i).at(e,n)}),r}filter(e){const n=new qe;return this.columns.forEach((r,i)=>{const a=this.series[i];e(r,a,i)&&n.push(r,a)}),n}get byteLength(){return new Ge(this.series.reduce((e,n)=>e.add(n.byteLength),Ge.ZERO))}get digest(){const e={};return this.keys.forEach((n,r)=>{const i=this.series[r].digest;n in e?e[n].push(i):e[n]=[i]}),e}get length(){return this.series.reduce((e,n)=>e+n.length,0)}};const as=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(()=>[]),Me.crudeZ.array().optional().default([])])}),Id=t=>{const{dataType:e,data:n,timeRange:r,alignment:i}=t;return new Me({data:n,dataType:e,timeRange:r,glBufferUsage:"static",alignment:i})},xd=t=>({timeRange:t._timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment}),Ft=od.uint32,os=s.z.object({key:Ft,name:s.z.string()}),Ad=os.partial({key:!0}),Za="rack",Ka=t=>t?$t.JSON_CODEC.decodeString(t):{},ls=s.z.string(),Yn=s.z.object({key:ls,rack:Ft,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(Ka))}),Cd=Yn.extend({properties:s.z.unknown().transform(t=>$t.JSON_CODEC.encodeString(t))}),Ja="device",we=t=>t?JSON.parse(t):{},$e=s.z.union([s.z.string(),s.z.bigint().transform(t=>t.toString()),s.z.number().transform(t=>t.toString())]),jd=s.z.enum(["info","success","error","warning"]),Mn=s.z.object({task:$e,variant:jd,key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(we)).or(s.z.array(s.z.unknown())).or(s.z.null())}),Fn=s.z.object({key:$e,name:s.z.string(),type:s.z.string(),internal:s.z.boolean().optional(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(Ka)),state:Mn.optional().nullable(),snapshot:s.z.boolean().optional()}),Rd=Fn.omit({key:!0}).extend({key:$e.transform(t=>t.toString()).optional(),config:s.z.unknown().transform(t=>$t.JSON_CODEC.encodeString(t))}),Ha=s.z.object({task:$e,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(we)).or(s.z.array(s.z.unknown())).or(s.z.null()).optional()}),cs="task",Wt=s.z.string().uuid(),Wn=s.z.object({key:Wt,name:s.z.string().min(1),color:s.z.string()}),Xa="label",se=s.z.string().uuid(),us=s.z.string().min(1),Vt=s.z.object({key:se,name:us,timeRange:K.z,color:s.z.string().optional()}),Qa=Vt.partial({key:!0}),eo=t=>{const e=b(t),n=e.length===0;let r=!1;return n||(r=se.safeParse(e[0]).success),{single:!Array.isArray(t),variant:r?"keys":"names",normalized:e,actual:t,empty:n}},hs="range",ds="range-alias",et=s.z.string().uuid(),Vn=s.z.object({key:et,username:s.z.string().min(1),firstName:s.z.string().default(""),lastName:s.z.string().default(""),rootUser:s.z.boolean().default(!0)}),Pd=Vn.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:s.z.string().min(1)}),Md="user",Gt=s.z.string().uuid(),fs=s.z.object({key:Gt,name:s.z.string(),data:Lt.or(s.z.string().transform(we))}),Bd=fs.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Dd="lineplot",Zt=s.z.string().uuid(),ys=s.z.object({key:Zt,name:s.z.string(),data:Lt.or(s.z.string().transform(we))}),Ud=ys.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),$d="log",ke=s.z.string().uuid(),ps=s.z.object({key:ke,name:s.z.string(),layout:Lt.or(s.z.string().transform(we))}),to="workspace",Ld=ps.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),_d=ps.omit({layout:!0}).extend({layout:s.z.string().transform(we)}),tt=s.z.string().uuid(),gs=s.z.object({key:tt,name:s.z.string(),data:Lt.or(s.z.string().transform(we)),snapshot:s.z.boolean()}),qd=gs.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),no=gs.extend({data:s.z.string().transform(we)}),Yd="schematic",Kt=s.z.string().uuid(),ro=s.z.object({key:Kt,name:s.z.string(),data:Lt.or(s.z.string().transform(we))}),Fd=ro.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),so=ro.extend({data:s.z.string().transform(we)}),Wd="table",io="builtin",Vd="cluster",Gd="node",Gn=s.z.enum([Xa,$d,Ui,io,Vd,qn,Gd,Va,hs,Ed,ds,Md,to,Yd,Dd,Za,Ja,cs,ul,Wd]),ie=s.z.object({type:Gn,key:s.z.string()}),Zd=s.z.string().transform(t=>{const[e,n]=t.split(":");return{type:Gn.parse(e),key:n??""}}),zt=s.z.union([Zd,ie]),Nn=class ao{constructor(e){if(l(this,"type"),l(this,"key"),e instanceof ao){this.type=e.type,this.key=e.key;return}if(typeof e=="string"){const[n,r]=e.split(":");this.type=n,this.key=r??"";return}this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}isType(){return this.key===""}matchesType(e){return this.type===e&&this.isType()}get payload(){return{type:this.type,key:this.key}}};l(Nn,"z",s.z.union([s.z.instanceof(Nn),zt.transform(t=>new Nn(t))]));let C=Nn;new C({type:io,key:"root"});const Kd=s.z.object({type:s.z.number()}),Jd=s.z.object({type:Gn,fields:s.z.record(Kd)}),Hd=s.z.object({id:C.z,name:s.z.string(),schema:Jd.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(t=>({key:t.id.toString(),...t}));s.z.object({from:C.z,type:s.z.string(),to:C.z});const Ni=t=>{const[e,n,r]=t.split("->");return{from:new C(e),type:n,to:new C(r)}};class oo{constructor(e,n){l(this,"key"),l(this,"name"),this.key=n,this.name=e}get ontologyID(){return Xd(this.key)}}const Xd=t=>new C({type:Va,key:t}),Qd=s.z.object({group:Wa}),ef=s.z.object({parent:ie,key:_n.optional(),name:is}),tf=s.z.object({key:_n,name:is}),nf=s.z.object({keys:s.z.array(_n)});var Ie;let rf=(Ie=class{constructor(t){l(this,"client"),this.client=t}async create(t,e,n){return(await w(this.client,Ie.CREATE_ENDPOINT,{parent:t,name:e,key:n},ef,Qd)).group}async rename(t,e){await w(this.client,Ie.RENAME_ENDPOINT,{key:t,name:e},tf,s.z.object({}))}async delete(t){await w(this.client,Ie.DELETE_ENDPOINT,{keys:t},nf,s.z.object({}))}},l(Ie,"CREATE_ENDPOINT","/ontology/create-group"),l(Ie,"RENAME_ENDPOINT","/ontology/rename-group"),l(Ie,"DELETE_ENDPOINT","/ontology/delete-group"),Ie),sf=class{constructor(t){l(this,"creator"),this.creator=new rf(t)}async create(t,e,n){return this.sugar(await this.creator.create(t,e,n))}async rename(t,e){return await this.creator.rename(t,e)}async delete(...t){return await this.creator.delete(t)}sugar(t){return new oo(t.name,t.key)}};const af="/ontology/add-children",of="/ontology/remove-children",lf="/ontology/move-children",Ei=s.z.object({id:ie,children:ie.array()}),cf=s.z.object({from:ie,to:ie,children:ie.array()}),dr=s.z.object({});let uf=class{constructor(t){l(this,"client"),this.client=t}async addChildren(t,...e){await w(this.client,af,{id:new C(t).payload,children:e.map(n=>new C(n).payload)},Ei,dr)}async removeChildren(t,...e){await w(this.client,of,{id:new C(t).payload,children:e.map(n=>new C(n).payload)},Ei,dr)}async moveChildren(t,e,...n){const r={from:new C(t).payload,to:new C(e).payload,children:n.map(i=>new C(i).payload)};await w(this.client,lf,r,cf,dr)}};const hf="/ontology/retrieve",df=s.z.object({ids:ie.array().optional(),children:s.z.boolean().optional(),parents:s.z.boolean().optional(),includeSchema:s.z.boolean().optional(),excludeFieldData:s.z.boolean().optional(),term:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),types:Gn.array().optional()}),ff=s.z.object({resources:Hd.array()}),fr=t=>b(t).map(e=>new C(e).payload);let yf=class{constructor(t,e){l(this,"type","ontology"),l(this,"groups"),l(this,"client"),l(this,"writer"),l(this,"framer"),this.client=t,this.writer=new uf(t),this.groups=new sf(t),this.framer=e}async search(t,e){return await this.execRetrieve({term:t,...e})}async retrieve(t,e){const n=await this.execRetrieve({ids:fr(t),...e});if(Array.isArray(t))return n;if(n.length===0)throw new he(`No resource found with ID ${zd.naturalLanguageJoin(b(t).map(r=>new C(r).toString()))}`);return n[0]}async page(t,e,n){return await this.execRetrieve({offset:t,limit:e,...n})}async retrieveChildren(t,e){return await this.execRetrieve({ids:fr(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:fr(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...n){return await this.writer.moveChildren(t,e,...n)}async openChangeTracker(){return await Zn.open(this.framer,this)}async openDependentTracker(t){return await ms.open(t,this.framer,this)}newSearcherWithOptions(t){return{type:this.type,search:e=>this.search(e,t),retrieve:e=>this.retrieve(e,t),page:(e,n)=>this.page(e,n,t)}}async execRetrieve(t){const{resources:e}=await w(this.client,hf,t,df,ff);return e}};const Ii="sy_ontology_resource_set",xi="sy_ontology_resource_delete",Ai="sy_ontology_relationship_set",Ci="sy_ontology_relationship_delete";class Zn{constructor(e,n){l(this,"relationships"),l(this,"resources"),l(this,"resourceObs"),l(this,"relationshipObs"),l(this,"streamer"),l(this,"client"),l(this,"closePromise"),this.relationshipObs=new Ue.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Ue.Observer,this.resources=this.resourceObs,this.client=n,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const n=await this.parseResourceSets(e),r=this.parseResourceDeletes(e);n.concat(r).length>0&&this.resourceObs.notify(n.concat(r));const i=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);i.concat(a).length>0&&this.relationshipObs.notify(i.concat(a))}parseRelationshipSets(e){const n=e.get(Ai);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"set",key:Ni(r),value:void 0}))}parseRelationshipDeletes(e){const n=e.get(Ci);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"delete",key:Ni(r)}))}async parseResourceSets(e){const n=e.get(Ii);if(n.length===0)return[];const r=Array.from(n.as("string")).map(i=>new C(i));try{return(await this.client.retrieve(r)).map(i=>({variant:"set",key:i.id,value:i}))}catch(i){if(i instanceof he)return[];throw i}}parseResourceDeletes(e){const n=e.get(xi);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"delete",key:new C(r)}))}static async open(e,n){const r=await e.openStreamer([Ii,xi,Ai,Ci]);return new Zn(r,n)}}const ji=t=>t==="from"?"to":"from";class ms extends Ue.Observer{constructor({target:e,dependents:n,relationshipType:r="parent",relationshipDirection:i="from",resourceType:a},o,c){super(),l(this,"internal"),l(this,"target"),l(this,"relDir"),l(this,"resourceType"),l(this,"dependents"),l(this,"client"),l(this,"relType"),l(this,"handleResourceChange",u=>{this.dependents=this.dependents.map(h=>{const f=u.find(d=>d.key.toString()==h.id.toString());return f==null||f.variant==="delete"?h:f.value}),this.notify(this.dependents)}),l(this,"handleRelationshipChange",u=>{const h=u.filter(d=>d.variant==="delete"&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[ji(this.relDir)].type===this.resourceType));this.dependents=this.dependents.filter(d=>!h.some(N=>N.key.to.toString()===d.id.toString()&&N.key.type===this.relType));const f=u.filter(d=>d.variant==="set"&&d.key.type===this.relType&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[ji(this.relDir)].type===this.resourceType));if(f.length===0)return this.notify(this.dependents);this.client.retrieve(f.map(d=>d.key.to)).then(d=>{this.dependents=this.dependents.concat(d),this.notify(this.dependents)}).catch(console.error)}),this.resourceType=a,this.internal=o,this.target=e,this.dependents=n,this.resourceType!=null&&(this.dependents=this.dependents.filter(u=>u.id.type===this.resourceType)),this.client=c,this.relType=r,this.relDir=i,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,n,r){const i=await Zn.open(n,r);return new ms(e,i,r)}async close(){await this.internal.close()}}const Kn=s.z.string().uuid(),ws=s.z.object({key:Kn,subjects:J(ie),objects:J(ie),actions:J(Pr)}),pf=s.z.object({key:Kn.optional(),subjects:zt.array().or(zt),objects:zt.array().or(zt),actions:Pr.array().or(Pr)}),gf=s.z.object({keys:Kn.array().optional(),subjects:ie.array().optional()}),mf=s.z.object({policies:J(ws)}),wf="/access/policy/retrieve";let bf=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){return(await w(this.client,wf,t,gf,mf)).policies}};const vf=s.z.object({policies:ws.partial({key:!0}).array()}),Of=s.z.object({policies:ws.array()}),Tf=s.z.object({keys:Kn.array()}),zf=s.z.object({}),Sf="/access/policy/create",kf="/access/policy/delete";let Nf=class{constructor(t){l(this,"client"),this.client=t}async create(t){const e=pf.array().parse(b(t)).map(n=>({objects:b(n.objects),actions:b(n.actions),subjects:b(n.subjects)}));return(await w(this.client,Sf,{policies:e},vf,Of)).policies}async delete(t){await w(this.client,kf,{keys:b(t)},Tf,zf)}},Ef=class{constructor(t){l(this,"retriever"),l(this,"writer"),this.retriever=new bf(t),this.writer=new Nf(t)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve({keys:b(t)});return e?n:n[0]}async retrieveFor(t){const e=b(t).map(n=>new C(n).payload);return await this.retriever.retrieve({subjects:e})}async delete(t){await this.writer.delete(t)}};new C({type:Ui,key:""});let If=class{constructor(t){l(this,"policy"),this.policy=new Ef(t)}};const xf=new Error("request for lock canceled");var Af=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Cf{constructor(e,n=xf){this._value=e,this._cancelError=n,this._queue=[],this._weightedWaiters=[]}acquire(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,i)=>{const a={resolve:r,reject:i,weight:e,priority:n},o=lo(this._queue,c=>n<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Af(this,arguments,void 0,function*(n,r=1,i=0){const[a,o]=yield this.acquire(r,i);try{return yield n(a)}finally{o()}})}waitForUnlock(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,n)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),jf(this._weightedWaiters[e-1],{resolve:r,priority:n})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const n=this._value;this._value-=e.weight,e.resolve([n,this._newReleaser(e.weight)])}_newReleaser(e){let n=!1;return()=>{n||(n=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const n=this._weightedWaiters[e-1];n&&(n.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let n=this._value;n>0;n--){const r=this._weightedWaiters[n-1];if(!r)continue;const i=r.findIndex(a=>a.priority<=e);(i===-1?r:r.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,n){return(this._queue.length===0||this._queue[0].priority<n)&&e<=this._value}}function jf(t,e){const n=lo(t,r=>e.priority<=r.priority);t.splice(n+1,0,e)}function lo(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}var Rf=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Pf{constructor(e){this._semaphore=new Cf(1,e)}acquire(){return Rf(this,arguments,void 0,function*(e=0){const[,n]=yield this._semaphore.acquire(1,e);return n})}runExclusive(e,n=0){return this._semaphore.runExclusive(()=>e(),1,n)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Jn=(t,e,{convertNumericStrings:n=!0}={})=>{const r=!Array.isArray(t);let i=b(t);const a=i[0],o=typeof a;let c;return o==="string"&&n&&!isNaN(parseInt(a))&&"number"in e?(c=e.number,i=i.map(u=>parseInt(u))):c=e[o],{single:r,variant:c,normalized:i,actual:t}},Hn=(t,e,n,r)=>{if(r){if(n.length===0)throw new Je(`${t} not found matching ${JSON.stringify(e)}`);if(n.length>1)throw new He(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${n.length}`)}},Mf=s.z.object({leaseholder:s.z.number().optional(),keys:H.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),rangeKey:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),dataTypes:E.z.array().optional(),notDataTypes:E.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),Bf=s.z.object({channels:J(Yt)}),Se=t=>Jn(t,{number:"keys",string:"names"}),co=class uo{constructor(e){l(this,"client"),this.client=e}async search(e,n){return await this.execute({search:e,...n})}async retrieve(e,n){const r=Se(e),{variant:i}=r;let{normalized:a}=r;return i==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[i]:a,...n})}async page(e,n,r){return await this.execute({offset:e,limit:n,...r})}async execute(e){const[n,r]=await this.client.send(uo.ENDPOINT,e,Mf,Bf);if(r!=null)throw r;return n.channels}};l(co,"ENDPOINT","/channel/retrieve");let bs=co;class vs{constructor(e){l(this,"cache"),l(this,"namesToKeys"),l(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,n){return await this.wrapped.search(e,n)}async page(e,n,r){return await this.wrapped.page(e,n,r)}async retrieve(e,n){const{normalized:r}=Jn(e,{string:"names",number:"keys"}),i=[],a=[];if(r.forEach(c=>{const u=this.get(c);u!=null?i.push(...u):a.push(c)}),a.length===0)return i;const o=await this.wrapped.retrieve(a,n);return this.set(o),i.concat(o)}delete(e){const{variant:n,normalized:r}=Se(e);n==="names"?r.forEach(i=>{const a=this.namesToKeys.get(i);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(i))}):r.forEach(i=>{const a=this.cache.get(i);a!=null&&(this.cache.delete(i),this.namesToKeys.delete(a.name))})}rename(e,n){e.forEach((r,i)=>{const a=n[i],o=this.cache.get(r);if(o==null)return;this.cache.delete(r);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(r),c.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(r,o);const u=this.namesToKeys.get(a);u==null?this.namesToKeys.set(a,new Set([r])):u.add(r)})}set(e){e.forEach(n=>{this.cache.set(n.key,n);const r=this.namesToKeys.get(n.name);r==null?this.namesToKeys.set(n.name,new Set([n.key])):r.add(n.key)})}get(e){if(typeof e=="number"){const i=this.cache.get(e);return i==null?void 0:[i]}const n=this.namesToKeys.get(e);if(n==null)return;const r=[];if(n.forEach(i=>{const a=this.cache.get(i);a!=null&&r.push(a)}),r.length!==0)return r}}class ho{constructor(e,n){l(this,"mu",new Pf),l(this,"requests",new Map),l(this,"wrapped"),l(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Sh(()=>{this.run()},n)}async search(e,n){return await this.wrapped.search(e,n)}async page(e,n,r){return await this.wrapped.page(e,n,r)}async retrieve(e){const{normalized:n,variant:r}=Se(e);return r==="names"?await this.wrapped.retrieve(n):await new Promise((i,a)=>{this.mu.runExclusive(()=>{this.requests.set(n,{resolve:i,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((n,r)=>r.forEach(i=>e.add(i)));try{const n=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((r,i)=>r.resolve(n.filter(a=>i.includes(a.key))))}catch(n){this.requests.forEach(r=>r.reject(n))}finally{this.requests.clear()}})}}const fo=async(t,e)=>{const{normalized:n}=Se(e),r=await t.retrieve(n),i=[];if(n.forEach(a=>{r.find(o=>o.name===a||o.key===a)==null&&i.push(a)}),i.length>0)throw new he(`Could not find channels: ${JSON.stringify(i)}`);return r};class yo{constructor({dataType:e,rate:n,name:r,leaseholder:i=0,key:a=0,isIndex:o=!1,index:c=0,internal:u=!1,virtual:h=!1,frameClient:f,alias:d,expression:N="",requires:x=[]}){l(this,"_frameClient"),l(this,"key"),l(this,"name"),l(this,"rate"),l(this,"dataType"),l(this,"leaseholder"),l(this,"index"),l(this,"isIndex"),l(this,"internal"),l(this,"alias"),l(this,"virtual"),l(this,"expression"),l(this,"requires"),this.key=a,this.name=r,this.rate=new At(n??0),this.dataType=new E(e),this.leaseholder=i,this.index=c,this.isIndex=o,this.internal=u,this.alias=d,this.virtual=h,this.expression=N,this.requires=x??[],this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new q("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Yt.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,requires:this.requires})}get isCalculated(){return Bn(this.payload)}get ontologyID(){return mo(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,n){return await this.framer.write(e,this.key,n)}}const Df="/channel/retrieve-group",Uf=s.z.object({}),$f=s.z.object({group:Wa});let po=class{constructor(t,e,n,r){l(this,"type",qn),l(this,"frameClient"),l(this,"client"),l(this,"retriever"),l(this,"writer"),this.frameClient=t,this.retriever=e,this.client=n,this.writer=r}async create(t,e={}){const{retrieveIfNameExists:n=!1}=e,r=!Array.isArray(t);let i=b(t),a=[];if(n){const o=await this.retriever.retrieve(i.map(u=>u.name)),c=new Set(o.map(u=>u.name));i=i.filter(u=>!c.has(u.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(i))),r?a[0]:a}async retrieve(t,e){const n=!Array.isArray(t),r=this.sugar(await this.retriever.retrieve(t,e));return Hn("channel",t,r,n),n?r[0]:r}async search(t,e){return this.sugar(await this.retriever.search(t,e))}async delete(t){const{normalized:e,variant:n}=Se(t);return n==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(b(t),b(e))}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,n)=>await this.page(e,n,t)}}async page(t,e,n){return this.sugar(await this.retriever.page(t,e,n))}createDebouncedBatchRetriever(t=10){return new vs(new ho(new bs(this.client),t))}sugar(t){const{frameClient:e}=this;return t.map(n=>new yo({...n,frameClient:e}))}async retrieveGroup(){const t=await w(this.client,Df,{},Uf,$f);return new oo(t.group.name,t.group.key)}};const Bn=({virtual:t,expression:e})=>t&&e!=="",go=async(t,e)=>{if(!Bn(e))return e.index;for(const n of e.requires){const r=await t(n);if(r==null)return null;if(!r.virtual)return r.index}for(const n of e.requires){const r=await t(n);if(r==null)return null;if(Bn(r)){const i=await go(t,r);if(i!=null)return i}}return null},mo=t=>new C({type:qn,key:t.toString()}),Lf=s.z.object({channels:Ga.array()}),_f=s.z.object({channels:Yt.array()}),qf=s.z.object({keys:H.array().optional(),names:qt.array().optional()}),Yf=s.z.object({}),Ff=s.z.object({keys:H.array(),names:qt.array()}),Wf=s.z.object({}),Vf="/channel/create",Gf="/channel/delete",Zf="/channel/rename";let wo=class{constructor(t,e){l(this,"client"),l(this,"cache"),this.client=t,this.cache=e}async create(t){const{channels:e}=await w(this.client,Vf,{channels:t},Lf,_f);return this.cache.set(e),e}async delete(t){await w(this.client,Gf,t,qf,Yf),t.keys!=null&&this.cache.delete(t.keys),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await w(this.client,Zf,{keys:t,names:e},Ff,Wf),this.cache.rename(t,e)}};const Kf=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:vs,Channel:yo,Client:po,ClusterRetriever:bs,DebouncedBatchRetriever:ho,ONTOLOGY_TYPE:qn,Writer:wo,analyzeParams:Se,channelZ:Yt,isCalculated:Bn,keyZ:H,nameZ:qt,newZ:Ga,ontologyID:mo,resolveCalculatedIndex:go,retrieveRequired:fo},Symbol.toStringTag,{value:"Module"})),Jf=s.z.object({keys:et.array().optional(),usernames:s.z.string().array().optional()}),Hf=s.z.object({users:J(Vn)}),Xf="/user/retrieve";let Qf=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){return(await w(this.client,Xf,t,Jf,Hf)).users}};const ey=s.z.object({users:Pd.array()}),ty=s.z.object({users:Vn.array()}),ny=s.z.object({key:et,username:s.z.string().min(1)}),ry=s.z.object({}),sy=s.z.object({key:et,firstName:s.z.string().optional(),lastName:s.z.string().optional()}),iy=s.z.object({}),ay=s.z.object({keys:et.array()}),oy=s.z.object({}),ly="/user/create",cy="/user/change-username",uy="/user/rename",hy="/user/delete";let dy=class{constructor(t){l(this,"client"),this.client=t}async create(t){return(await w(this.client,ly,{users:b(t)},ey,ty)).users}async changeUsername(t,e){await w(this.client,cy,{key:t,username:e},ny,ry)}async rename(t,e,n){await w(this.client,uy,{key:t,firstName:e,lastName:n},sy,iy)}async delete(t){await w(this.client,hy,{keys:b(t)},ay,oy)}},fy=class{constructor(t){l(this,"reader"),l(this,"writer"),this.writer=new dy(t),this.reader=new Qf(t)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async changeUsername(t,e){await this.writer.changeUsername(t,e)}async retrieve(t){const e=Array.isArray(t),n=await this.reader.retrieve({keys:b(t)});if(e)return n;if(n.length===0)throw new Je(`No user with key ${t} found`);if(n.length>1)throw new He(`Multiple users found with key ${t}`);return n[0]}async retrieveByName(t){const e=Array.isArray(t),n=await this.reader.retrieve({usernames:b(t)});if(e)return n;if(n.length===0)throw new Je(`No user with username ${t} found`);if(n.length>1)throw new He(`Multiple users found with username ${t}`);return n[0]}async rename(t,e,n){await this.writer.rename(t,e,n)}async delete(t){await this.writer.delete(t)}};const yy=s.z.object({username:s.z.string(),password:s.z.string()}),py=s.z.object({token:s.z.string(),user:Vn}),Ri="/auth/login",gy=3,my="/auth/change-password",wy=s.z.object({username:s.z.string(),password:s.z.string(),newPassword:s.z.string().min(1)}),by=s.z.object({}),vy=[qr,Yr];let Oy=class{constructor(t,e){l(this,"token"),l(this,"client"),l(this,"credentials"),l(this,"authenticating"),l(this,"authenticated"),l(this,"user"),l(this,"retryCount"),this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,my,{username:this.credentials.username,password:this.credentials.password,newPassword:t},wy,by),this.credentials.password=t}middleware(){const t=async(e,n)=>{if(!this.authenticated&&!e.target.endsWith(Ri)){this.authenticating??(this.authenticating=new Promise((o,c)=>{this.client.send(Ri,this.credentials,yy,py).then(([u,h])=>{if(h!=null)return o(h);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}).catch(c)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[r,i]=await n(e);return vy.some(a=>a.matches(i))&&this.retryCount<gy?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,n)):(this.retryCount=0,[r,i])};return t}};const Ty=s.z.enum(["disconnected","connecting","connected","failed"]),zy=s.z.object({status:Ty,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string(),clientVersion:s.z.string(),clientServerCompatible:s.z.boolean(),nodeVersion:s.z.string().optional()}),Sy=s.z.object({clusterKey:s.z.string(),nodeVersion:s.z.string().optional()}),bo={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.40.0"},Pi=(t,e,n)=>{const r=n?"cluster":"client";return`Synnax cluster node version ${t!=null?`${t} `:""}is too ${n?"old":"new"} for client version ${e}.
37
- This may cause compatibility issues. We recommend updating the ${r}. For more information, see
38
- https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${r}-version`},En=class vo{constructor(e,n=z.seconds(30),r,i){l(this,"_state"),l(this,"pollFrequency",z.seconds(30)),l(this,"client"),l(this,"name"),l(this,"interval"),l(this,"clientVersion"),l(this,"onChangeHandlers",[]),l(this,"versionWarned",!1),this._state={...bo},this.client=e,this.pollFrequency=n,this.clientVersion=r,this.name=i,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const n=this._state.status;try{const[r,i]=await this.client.send(vo.ENDPOINT,{},s.z.object({}),Sy);if(i!=null)throw i;const a=r.nodeVersion,o=this.clientVersion,c=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,c||(console.warn(Pi(null,o,!0)),this.versionWarned=!0)):vi.versionsEqual(o,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,c||(console.warn(Pi(a,o,vi.semVerNewer(o,a))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=r.clusterKey,this._state.nodeVersion=r.nodeVersion,this._state.clientVersion=this.clientVersion}catch(r){this._state.status="failed",this._state.error=r,this._state.message=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&n!==this._state.status&&this.onChangeHandlers.forEach(r=>r(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};l(En,"ENDPOINT","/connectivity/check"),l(En,"DEFAULT",bo),l(En,"connectionStateZ",zy);let Oo=En;const ky=s.z.object({keys:H.array().optional(),bounds:K.z,names:qt.array().optional()}),Ny=s.z.object({}),Ey="/frame/delete";class Iy{constructor(e){l(this,"client"),this.client=e}async delete(e){await w(this.client,Ey,e,ky,Ny)}}class Xn{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,n){const r=new Xn(e);return await r.update(n),r}async update(e){const{variant:n,normalized:r}=Se(e);if(n==="keys"){this.adapter=null,this.keys=r;return}const i=await this.retriever.retrieve(r),a=new Map;this.adapter=a,r.forEach(o=>{const c=i.find(u=>u.name===o);if(c==null)throw new Error(`Channel ${o} not found`);a.set(c.key,c.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const n=this.adapter;return e.map((r,i)=>{if(typeof r=="number"){const a=n.get(r);if(a==null)throw new Error(`Channel ${r} not found`);return[a,i]}return[r,i]})}}class Os{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,n){const r=new Os(e);return await r.update(n),r}async adaptObjectKeys(e){const n={};for(const[r,i]of Object.entries(e))n[await this.adaptToKey(r)]=i;return n}async update(e){const n=await fo(this.retriever,e);this.adapter=new Map(n.map(r=>[r.name,r.key])),this.keys=n.map(r=>r.key)}async fetchChannel(e){const n=await this.retriever.retrieve(e);if(n.length===0)throw new Error(`Channel ${e} not found`);return n[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}async adapt(e,n){if(typeof e=="string"||typeof e=="number"){if(n==null)throw new q(`
39
- Received a single channel name or key but no series.
40
- `);if(Array.isArray(n)){if(n.some(u=>u instanceof Me||Array.isArray(u)))throw new q(`
41
- Received a single channel name or key but multiple series.
42
- `);n=n}const o=await this.fetchChannel(e),c=new Me({data:n,dataType:o.dataType});return new ue(o.key,c)}if(Array.isArray(e)){if(n==null)throw new q(`
43
- Received an array of channel names or keys but no series.
44
- `);if(!Array.isArray(n))throw new q(`
45
- Received an array of channel names or keys but no array of series.
46
- `);const o=[],c=[];for(let u=0;u<e.length;u++){const h=await this.fetchChannel(e[u]);if(u>=n.length)throw new q(`
47
- Received an array of channel names or keys but not enough series.
48
- `);const f=new Me({data:n[u],dataType:h.dataType});o.push(h.key),c.push(f)}return new ue(o,c)}if(e instanceof ue||e instanceof Map){const o=new ue(e);if(this.adapter==null)return o;const c=o.columns.map(u=>{var h;const f=typeof u=="string"?(h=this.adapter)==null?void 0:h.get(u):u;if(f==null)throw new q(`
49
- Channel ${u} was not provided in the list of channels when opening the writer
50
- `);return f});return new ue(c,o.series)}const r=[],i=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[c,u]=a[o],h=await this.fetchChannel(c),f=new Me({data:u,dataType:h.dataType});r.push(h.key),i.push(f)}return new ue(r,i)}}class Ts{constructor(e,n){l(this,"name"),l(this,"stream"),this.stream=n,this.name=e}async receive(){const[e,n]=await this.stream.receive();if(n!=null)throw n;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,n]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
51
- Please report this error to the Synnax team. ${JSON.stringify(e)}`),n!=null){if(je.matches(n))return;throw n}}}closeSend(){this.stream.closeSend()}send(e){const n=this.stream.send(e);if(n!=null)throw n}}const Mi=new z(-1);var zs=(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))(zs||{}),To=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(To||{});const xy=s.z.object({command:s.z.nativeEnum(zs),span:z.z.optional(),bounds:K.z.optional(),stamp:I.z.optional(),keys:H.array().optional(),chunkSize:s.z.number().optional()}),Ay=s.z.object({variant:s.z.nativeEnum(To),ack:s.z.boolean(),command:s.z.nativeEnum(zs),error:Ut.optional().nullable(),frame:as.optional()}),zo=class Fr{constructor(e,n){l(this,"stream"),l(this,"adapter"),l(this,"value"),this.stream=new Ts("Iterator",e),this.value=new ue,this.adapter=n}static async _open(e,n,r,i,a={}){const o=await Xn.open(r,n),c=await i.stream(Fr.ENDPOINT,xy,Ay),u=new Fr(c,o);return await u.execute({command:0,keys:o.keys,bounds:new K(e),chunkSize:a.chunkSize??1e5}),u}async next(e=Mi){return await this.execute({command:1,span:new z(e)})}async prev(e=Mi){return await this.execute({command:2,span:new z(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 I(e)})}async seekGE(e){return await this.execute({command:6,stamp:new I(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new jy(this)}async execute(e){for(this.stream.send(e),this.value=new ue;;){const n=await this.stream.receive();if(n.variant===1)return n.ack;this.value.push(this.adapter.adapt(new ue(n.frame)))}}};l(zo,"ENDPOINT","/frame/iterate");let Cy=zo;class jy{constructor(e){l(this,"iter"),l(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Ry=s.z.object({keys:s.z.number().array(),downsampleFactor:s.z.number()}),Py=s.z.object({frame:as,error:Ut.optional().nullable()}),My="/frame/stream";class Ss{constructor(e,n){l(this,"stream"),l(this,"adapter"),l(this,"downsampleFactor"),this.stream=new Ts("Streamer",e),this.adapter=n,this.downsampleFactor=1}get keys(){return this.adapter.keys}static async _open(e,n,{channels:r,downsampleFactor:i}){const a=await Xn.open(e,r),o=await n.stream(My,Ry,Py),c=new Ss(o,a);o.send({keys:a.keys,downsampleFactor:i??1});const[,u]=await o.receive();if(u!=null)throw u;return c}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(je.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ue((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys,downsampleFactor:this.downsampleFactor})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class Xe extends Ue.Observer{constructor(e,n){super(n),l(this,"streamer"),l(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}var ks=(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))(ks||{}),Ct=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(Ct||{});const By=t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof t=="number"&&t in Ct)return t;throw new Error(`invalid writer mode: ${t}`)}};new z(-1);const Dy=s.z.object({start:I.z.optional(),controlSubject:Ze.subjectZ.optional(),keys:H.array().optional(),authorities:Ze.Authority.z.array().optional(),mode:s.z.nativeEnum(Ct).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:z.z.optional()}),Uy=s.z.object({command:s.z.nativeEnum(ks),config:Dy.optional(),frame:as.optional()}),$y=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(ks),error:Ut.optional().nullable()});var rt;let Ly=(rt=class{constructor(t,e){l(this,"stream"),l(this,"adapter"),l(this,"errAccumulated",!1),this.stream=new Ts("Writer",t),this.adapter=e}static async _open(t,e,{channels:n,start:r=I.now(),authorities:i=Ze.Authority.ABSOLUTE,controlSubject:a,mode:o=1,errOnUnauthorized:c=!1,enableAutoCommit:u=!1,autoIndexPersistInterval:h=z.SECOND}){const f=await Os.open(t,n),d=await e.stream(rt.ENDPOINT,Uy,$y),N=new rt(d,f);return await N.execute({command:0,config:{start:new I(r),keys:f.keys,controlSubject:a,authorities:b(i),mode:By(o),errOnUnauthorized:c,enableAutoCommit:u,autoIndexPersistInterval:h}}),N}async checkForAccumulatedError(){if(!this.errAccumulated&&this.stream.received())for(this.errAccumulated=!0;this.stream.received();)await this.stream.receive();return this.errAccumulated}async write(t,e){if(await this.checkForAccumulatedError())return!1;const n=await this.adapter.adapt(t,e);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(t,e){if(await this.checkForAccumulatedError())return!1;let n;if(typeof t=="number"&&e==null)n={keys:[],authorities:[t]};else{let r;typeof t=="string"||typeof t=="number"?r={[t]:e}:r=t,r=await this.adapter.adaptObjectKeys(r),n={keys:Object.keys(r).map(i=>Number(i)),authorities:Object.values(r)}}return(await this.execute({command:4,config:n})).ack}async commit(){return await this.checkForAccumulatedError()?!1:(await this.execute({command:2})).ack}async error(){const t=await this.execute({command:3});return t.error!=null?jn(t.error):null}async close(){await this.stream.closeAndAck()}async execute(t){for(this.stream.send(t);;){const e=await this.stream.receive();if(e.command===t.command)return e;console.warn("writer received unexpected response",e)}}get errorAccumulated(){return this.stream.received()}},l(rt,"ENDPOINT","/frame/write"),rt),_y=class{constructor(t,e,n){l(this,"streamClient"),l(this,"retriever"),l(this,"deleter"),this.streamClient=t,this.retriever=n,this.deleter=new Iy(e)}async openIterator(t,e,n){return await Cy._open(t,e,this.retriever,this.streamClient,n)}async openWriter(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await Ly._open(this.retriever,this.streamClient,t)}async openStreamer(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t,downsampleFactor:1}),await Ss._open(this.retriever,this.streamClient,t)}async write(t,e,n){if(n==null){const i=e,a=await this.openWriter({start:t,channels:Object.keys(i),mode:Ct.Persist});try{await a.write(i),await a.commit()}finally{await a.close()}return}const r=await this.openWriter({start:t,channels:e,mode:Ct.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:z.MAX});try{await r.write(e,n)}finally{await r.close()}}async read(t,e){const{single:n}=Se(e),r=await this.readFrame(t,e);return n?r.get(e):r}async readFrame(t,e){const n=await this.openIterator(t,e),r=new ue;try{for await(const i of n)r.push(i)}finally{await n.close()}return r}async delete(t,e){const{normalized:n,variant:r}=Se(t);return r==="keys"?await this.deleter.delete({keys:n,bounds:e}):await this.deleter.delete({names:n,bounds:e})}};const qy=Ze.Authority,Yy=Ze.stateZ(s.z.number()),Fy=t=>{var e,n;return t.to==null?`${(e=t.from)==null?void 0:e.resource} - ${(n=t.from)==null?void 0:n.subject.name} -> released`:t.from==null?`${t.to.resource} - released -> ${t.to.subject.name} (${t.to.authority.toString()})`:`${t.to.resource} - ${t.from.subject.name} -> ${t.to.subject.name} (${t.to.authority.toString()})`};class So extends Xe{constructor(e){super(e,n=>{const r=this.codec.decode(n.series[0].buffer);return this.merge(r),[r.transfers,!0]}),l(this,"states"),l(this,"codec"),this.states=new Map,this.codec=new $t.JSONCodec}subjects(){const e=new Map;return this.states.forEach(n=>e.set(n.subject.key,n.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(n=>{n.from==null&&n.to==null&&console.warn("Invalid transfer: ",n),n.to==null?this.states.delete(n.from.resource):this.states.set(n.to.resource,n.to)})}}const Wy="sy_node_1_control";let ko=class{constructor(t){l(this,"framer"),this.framer=t}async openStateTracker(){const t=await this.framer.openStreamer(Wy);return new So(t)}};const Vy=Object.freeze(Object.defineProperty({__proto__:null,Authority:qy,Client:ko,StateTracker:So,stateZ:Yy,transferString:Fy},Symbol.toStringTag,{value:"Module"}));let Gy=class{constructor(t,e,n){l(this,"tasks"),l(this,"racks"),l(this,"devices"),this.tasks=t,this.racks=e,this.devices=n}};const nt=async(t,e,n,r)=>{const i=await t.openStreamer([e,n]),a=o=>{const c=[];return n!=null&&c.push(...o.get(n).series.flatMap(u=>r("delete",u))),e!=null&&c.push(...o.get(e).series.flatMap(u=>r("set",u))),[c,c.length>0]};return new Xe(i,a)},Zy="sy_device_set",Ky="sy_device_delete",yr="/hardware/device/retrieve",Jy="/hardware/device/create",Hy="/hardware/device/delete",Xy=s.z.object({devices:Cd.array()}),Qy=s.z.object({devices:Yn.array()}),ep=s.z.object({keys:ls.array()}),tp=s.z.object({}),pr=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:ls.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional(),ignoreNotFound:s.z.boolean().optional()}),gr=s.z.object({devices:J(Yn)});let np=class{constructor(t,e){l(this,"type",Ja),l(this,"client"),l(this,"frameClient"),this.client=t,this.frameClient=e}async retrieve(t,e){const n=!Array.isArray(t),r=await w(this.client,yr,{keys:b(t),...e},pr,gr);return Hn("Device",t,r.devices,n),n?r.devices[0]:r.devices}async search(t,e){return(await w(this.client,yr,{search:t,...e},pr,gr)).devices}async page(t,e,n){return(await w(this.client,yr,{offset:t,limit:e,...n},pr,gr)).devices}async create(t){const e=!Array.isArray(t),n=await w(this.client,Jy,{devices:b(t)},Xy,Qy);return e?n.devices[0]:n.devices}async delete(t){await w(this.client,Hy,{keys:b(t)},ep,tp)}async openDeviceTracker(){return await nt(this.frameClient,Zy,Ky,rp)}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,n)=>await this.page(e,n,t)}}};const rp=(t,e)=>t==="delete"?e.toStrings().map(n=>({variant:t,key:n,value:void 0})):e.parseJSON(Yn).map(n=>({variant:t,key:n.key,value:n})),mr="/hardware/rack/retrieve",sp="/hardware/rack/create",ip="/hardware/rack/delete",wr=s.z.object({keys:Ft.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),br=s.z.object({racks:J(os)}),ap=s.z.object({racks:Ad.array()}),op=s.z.object({racks:os.array()}),lp=s.z.object({keys:Ft.array()}),cp=s.z.object({});let up=class{constructor(t,e){l(this,"type",Za),l(this,"client"),l(this,"tasks"),this.client=t,this.tasks=e}async delete(t){await w(this.client,ip,{keys:b(t)},lp,cp)}async create(t){const e=!Array.isArray(t),n=await w(this.client,sp,{racks:b(t)},ap,op),r=this.sugar(n.racks);return e?r[0]:r}async search(t){const e=await w(this.client,mr,{search:t},wr,br);return this.sugar(e.racks)}async page(t,e){const n=await w(this.client,mr,{offset:t,limit:e},wr,br);return this.sugar(n.racks)}async retrieve(t){const{variant:e,normalized:n,single:r}=Jn(t,{string:"names",number:"keys"}),i=await w(this.client,mr,{[e]:n},wr,br),a=this.sugar(i.racks);return Hn("Rack",t,a,r),r?a[0]:a}sugar(t){return t.map(({key:e,name:n})=>new hp(e,n,this.tasks))}};class hp{constructor(e,n,r){l(this,"key"),l(this,"name"),l(this,"tasks"),this.key=e,this.name=n,this.tasks=r}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async retrieveTaskByType(e){return await this.tasks.retrieveByType(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const It="sy_task_state",Fe="sy_task_cmd",dp="sy_task_set",fp="sy_task_delete",Ye=new Error("Task not created"),No=async(t,e)=>{const n=await e.retrieveParents(t);return n.length===0?null:n[0]};class yp{constructor(e,n,r,i,a=!1,o=!1,c,u=null,h=null,f=null){l(this,"key"),l(this,"name"),l(this,"internal"),l(this,"type"),l(this,"config"),l(this,"snapshot"),l(this,"state"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=e,this.name=n,this.type=r,this.config=i,this.internal=a,this.snapshot=o,c!==null&&(this.state=c),this.frameClient=u,this.ontologyClient=h,this.rangeClient=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}get ontologyID(){return Ip(this.key)}async executeCommand(e,n){if(this.frameClient==null)throw Ye;const r=await this.frameClient.openWriter(Fe),i=dh.create();return await r.write(Fe,[{task:this.key,type:e,key:i,args:n}]),await r.close(),i}async executeCommandSync(e,n,r){if(this.frameClient==null)throw Ye;const i=await this.frameClient.openStreamer(It),a=await this.executeCommand(e,n);let o;const c=new Promise(u=>setTimeout(()=>u(!1),new z(r).milliseconds));for(;;){const u=await Promise.any([i.read(),c]);if(u===!1)throw new Error("Command timed out");const h=Mn.safeParse(u.at(-1).sy_task_state);if(h.success){if(o=h.data,o.key===a)break}else throw h.error}return i.close(),o}async openStateObserver(){if(this.frameClient==null)throw Ye;return new Xe(await this.frameClient.openStreamer(It),e=>{const n=e.get(It);if(n.length===0)return[null,!1];const r=Mn.safeParse(n.at(-1));if(!r.success)return console.error(r.error),[null,!1];const i=r.data;return i.task!==this.key?[null,!1]:[i,!0]})}async openCommandObserver(){if(this.frameClient==null)throw Ye;return new Xe(await this.frameClient.openStreamer(Fe),e=>{const n=e.get(Fe);if(n.length===0)return[null,!1];const r=Ha.safeParse(n.at(-1));if(!r.success)return console.error(r.error),[null,!1];const i=r.data;return i.task!==this.key?[null,!1]:[i,!0]})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw Ye;return this.snapshot?await No(this.key,this.ontologyClient):null}}const pp=s.z.object({rack:Ft.optional(),keys:$e.array().optional(),names:s.z.string().array().optional(),types:s.z.string().array().optional(),includeState:s.z.boolean().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),gp=s.z.object({tasks:J(Fn)}),mp="/hardware/task/retrieve",wp="/hardware/task/create",bp="/hardware/task/delete",vp="/hardware/task/copy",Op=s.z.object({tasks:Rd.array()}),Tp=s.z.object({tasks:Fn.array()}),zp=s.z.object({keys:$e.array()}),Sp=s.z.object({}),kp=s.z.object({key:$e,name:s.z.string(),snapshot:s.z.boolean()}),Np=s.z.object({task:Fn});let Ep=class{constructor(t,e,n,r){l(this,"type",cs),l(this,"client"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.client=t,this.frameClient=e,this.ontologyClient=n,this.rangeClient=r}async create(t){const e=!Array.isArray(t),n=await w(this.client,wp,{tasks:b(t)},Op,Tp),r=this.sugar(n.tasks);return e?r[0]:r}async delete(t){await w(this.client,bp,{keys:b(t)},zp,Sp)}async search(t){return await this.execRetrieve({keys:[t]})}async page(t,e){return await this.execRetrieve({offset:t,limit:e})}async list(t={}){return this.sugar(await this.execRetrieve(t))}async retrieve(t,e){const{single:n,normalized:r,variant:i}=Jn(t,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};i==="rack"?a.rack=t:a.keys=r;const o=await this.execRetrieve(a),c=this.sugar(o);return n&&i!=="rack"?c[0]:c}async copy(t,e,n){const r=await w(this.client,vp,{key:t,name:e,snapshot:n},kp,Np);return this.sugar([r.task])[0]}async retrieveByName(t,e){const n=await this.execRetrieve({names:[t],rack:e});return Hn("Task",t,n,!0),this.sugar(n)[0]}async retrieveByType(t,e){const n=await this.execRetrieve({types:[t],rack:e});return this.sugar(n)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw Ye;return await No(t,this.ontologyClient)}async execRetrieve(t){return(await w(this.client,mp,t,pp,gp)).tasks}sugar(t){const e=!Array.isArray(t),n=b(t).map(({key:r,name:i,type:a,config:o,state:c,internal:u,snapshot:h})=>new yp(r,i,a,o,u,h,c,this.frameClient,this.ontologyClient,this.rangeClient));return e?n[0]:n}async openTracker(){return await nt(this.frameClient,dp,fp,(t,e)=>Array.from(e).map(n=>({variant:t,key:n.toString(),value:n.toString()})))}async openStateObserver(){return new Xe(await this.frameClient.openStreamer(It),t=>{const e=t.get(It);if(e.length===0)return[null,!1];const n=Mn.safeParse(e.at(-1));return n.success?[n.data,!0]:(console.error(n.error),[null,!1])})}async openCommandObserver(){return new Xe(await this.frameClient.openStreamer(Fe),t=>{const e=t.get(Fe);if(e.length===0)return[null,!1];const n=Ha.safeParse(e.at(-1));return n.success?[n.data,!0]:(console.error(n.error),[null,!1])})}};const Ip=t=>new C({type:cs,key:t}),xp=s.z.object({keys:Wt.array().optional(),for:ie.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Ap=s.z.object({labels:J(Wn)}),Eo=class Io{constructor(e){l(this,"client"),this.client=e}async retrieve(e){return await this.execute({keys:b(e)})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,n){return await this.execute({offset:e,limit:n})}async execute(e){const[n,r]=await this.client.send(Io.ENDPOINT,e,xp,Ap);if(r!=null)throw r;return n.labels}};l(Eo,"ENDPOINT","/label/retrieve");let Cp=Eo;const jp=Wn.extend({key:Wt.optional()}),Rp=s.z.object({labels:jp.array()}),Pp=s.z.object({labels:Wn.array()}),Mp=s.z.object({keys:Wt.array()}),xo=s.z.object({id:ie,labels:Wt.array(),replace:s.z.boolean().optional()}),Bp=xo.omit({replace:!0}),vr=s.z.object({}),Dp="/label/create",Up="/label/delete",$p="/label/set",Lp="/label/remove";let _p=class{constructor(t){l(this,"client"),this.client=t}async create(t){return(await w(this.client,Dp,{labels:b(t)},Rp,Pp)).labels}async delete(t){await w(this.client,Up,{keys:b(t)},Mp,vr)}async set(t,e,{replace:n}={}){await w(this.client,$p,{id:t,labels:e,replace:n},xo,vr)}async remove(t,e){await w(this.client,Lp,{id:t,labels:e},Bp,vr)}};const qp="sy_label_set",Yp="sy_label_delete";let Fp=class{constructor(t,e,n){l(this,"type","label"),l(this,"retriever"),l(this,"writer"),l(this,"frameClient"),l(this,"ontology"),this.writer=new _p(t),this.retriever=new Cp(t),this.frameClient=e,this.ontology=n}async search(t){return await this.retriever.search(t)}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve(t);return e?n:n[0]}async retrieveFor(t){return await this.retriever.retrieveFor(new C(t))}async label(t,e,n={}){await this.writer.set(new C(t),e,n)}async removeLabels(t,e){await this.writer.remove(new C(t),e)}async page(t,e){return await this.retriever.page(t,e)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async delete(t){await this.writer.delete(t)}async openChangeTracker(){return await nt(this.frameClient,qp,Yp,Wp)}async trackLabelsOf(t){const e=new Ue.Observer,n=(await this.retrieveFor(t)).map(r=>({id:Vp(r.key),key:r.key,name:r.name,data:r}));return(await this.ontology.openDependentTracker({target:new C(t),dependents:n,relationshipType:"labeled_by"})).onChange(r=>e.notify(r.map(i=>{var a,o;return{key:i.id.key,color:(a=i.data)==null?void 0:a.color,name:(o=i.data)==null?void 0:o.name}}))),e}};const Wp=(t,e)=>t==="delete"?e.toUUIDs().map(n=>({variant:t,key:n})):e.parseJSON(Wn).map(n=>({variant:t,key:n.key,value:n})),Vp=t=>new C({type:Xa,key:t}),Gp="sy_range_alias_set",Zp="sy_range_alias_delete",Kp=s.z.object({range:se,aliases:s.z.string().array()}),Jp=s.z.object({aliases:s.z.record(s.z.string(),H)}),Hp=s.z.object({range:se,aliases:s.z.record(H.or(s.z.string()),s.z.string())}),Xp=s.z.unknown(),Qp=s.z.object({range:se,channels:H.array()}),eg=s.z.unknown(),tg=s.z.object({range:se}),ng=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),St=class kt{constructor(e,n,r){l(this,"frameClient"),l(this,"cache",new Map),l(this,"client"),l(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=r,this.frameClient=n}async resolve(e){const n=[],r=typeof e=="string",i={};if(r){const o=this.cache.get(e);if(o!=null)return o;n.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?i[o]=c:n.push(o)});if(n.length===0)return i;const a=await w(this.client,kt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:n},Kp,Jp);return Object.entries(a.aliases).forEach(([o,c])=>this.cache.set(o,c)),r?a.aliases[n[0]]:{...i,...a.aliases}}async set(e){await w(this.client,kt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Hp,Xp)}async list(){return(await w(this.client,kt.LIST_ENDPOINT,{range:this.rangeKey},tg,ng)).aliases}async delete(e){await w(this.client,kt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Qp,eg)}async openChangeTracker(){return await nt(this.frameClient,Gp,Zp,ag(this.rangeKey))}};l(St,"SET_ENDPOINT","/range/alias/set"),l(St,"RESOLVE_ENDPOINT","/range/alias/resolve"),l(St,"LIST_ENDPOINT","/range/alias/list"),l(St,"DELETE_ENDPOINT","/range/alias/delete");let rg=St;const sg=s.z.object({range:se,channel:H,alias:s.z.string()}),ig="---",ag=t=>(e,n)=>e==="delete"?n.toStrings().filter(r=>r.split(ig)[0]===t).map(r=>({variant:e,key:r,value:void 0})):n.parseJSON(sg).map(r=>({variant:e,key:r.alias,value:r})),Ns=s.z.object({range:se,key:s.z.string(),value:s.z.string()}),og=s.z.object({range:se,keys:s.z.string().array()}),lg=s.z.object({pairs:J(Ns)}),cg=s.z.object({range:se,pairs:Ns.array()}),ug=s.z.object({range:se,keys:s.z.string().array()}),In=class xn{constructor(e,n,r){l(this,"rangeKey"),l(this,"client"),l(this,"frameClient"),this.rangeKey=e,this.client=n,this.frameClient=r}async get(e){const n=await w(this.client,xn.GET_ENDPOINT,{range:this.rangeKey,keys:b(e)},og,lg);return typeof e=="string"?n.pairs[0].value:Object.fromEntries(n.pairs.map(r=>[r.key,r.value]))}async list(){return this.get([])}async set(e,n=""){let r;rs(e)?r=Object.entries(e).map(([i,a])=>({range:this.rangeKey,key:i,value:a})):r=[{range:this.rangeKey,key:e,value:n}],await w(this.client,xn.SET_ENDPOINT,{range:this.rangeKey,pairs:r},cg,s.z.unknown())}async delete(e){await w(this.client,xn.DELETE_ENDPOINT,{range:this.rangeKey,keys:b(e)},ug,s.z.unknown())}async openTracker(){return await nt(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,n)=>e==="delete"?n.toStrings().map(r=>{const[i,a]=r.split("<--->",2);return{variant:e,key:r,value:{range:i,key:a,value:""}}}):n.parseJSON(Ns).map(r=>({variant:e,key:`${r.range}${r.key}`,value:r})))}};l(In,"GET_ENDPOINT","/range/kv/get"),l(In,"SET_ENDPOINT","/range/kv/set"),l(In,"DELETE_ENDPOINT","/range/kv/delete");let Wr=In;class Ao{constructor(e,n=K.ZERO,r,i,a,o,c,u,h,f,d){l(this,"key"),l(this,"name"),l(this,"kv"),l(this,"timeRange"),l(this,"color"),l(this,"channels"),l(this,"aliaser"),l(this,"frameClient"),l(this,"labelClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=r,this.name=e,this.timeRange=n,this.frameClient=a,this.color=i,this.kv=o,this.aliaser=c,this.channels=u,this.labelClient=h,this.ontologyClient=f,this.rangeClient=d}get ontologyID(){return Ae(this.key)}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,n){const r=await this.channels.retrieve(e);if(r.length===0)throw new he(`Channel ${e} does not exist`);await this.aliaser.set({[r[0].key]:n})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(n=>n.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ae(this.key))}async addLabel(...e){await this.labelClient.label(Ae(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ae(this.key),e)}async openChildRangeTracker(){const e=new Ue.Observer,n=(await this.retrieveChildren()).map(i=>{const a=Ae(i.key);return{id:a,key:a.toString(),name:i.name,data:i.payload}}),r=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:n,resourceType:"range"});return r.onChange(i=>e.notify(this.rangeClient.resourcesToRanges(i))),e.setCloser(async()=>await r.close()),e}async openParentRangeTracker(){const e=new Ue.Observer,n=await this.retrieveParent();if(n==null)return null;const r=Ae(n.key),i={id:r,key:r.toString(),name:n.name,data:n.payload},a=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:[i],relationshipDirection:"to"});return a.onChange(o=>{const c=this.rangeClient.resourcesToRanges(o);if(c.length===0)return;const u=c[0];e.notify(u)}),e.setCloser(async()=>await a.close()),e}}const hg=(t,e)=>yh(t.timeRange,e.timeRange),dg=s.z.object({keys:se.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:K.z.optional(),limit:s.z.number().int().optional(),offset:s.z.number().int().optional()}),fg="/range/retrieve",yg=s.z.object({ranges:J(Vt)});let Co=class{constructor(t,e,n,r,i,a){l(this,"type","range"),l(this,"frameClient"),l(this,"writer"),l(this,"unaryClient"),l(this,"channels"),l(this,"labelClient"),l(this,"ontologyClient"),this.frameClient=t,this.writer=e,this.unaryClient=n,this.channels=r,this.labelClient=i,this.ontologyClient=a}async create(t,e){const n=!Array.isArray(t),r=this.sugarMany(await this.writer.create(b(t),e));return n?r[0]:r}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(b(t))}async search(t){return this.sugarMany(await this.execRetrieve({term:t}))}async page(t,e){return this.sugarMany(await this.execRetrieve({offset:t,limit:e}))}async retrieve(t){if(typeof t=="object"&&"start"in t)return await this.execRetrieve({overlapsWith:new K(t)});const{single:e,actual:n,variant:r,normalized:i,empty:a}=eo(t);if(a)return[];const o=await this.execRetrieve({[r]:i});if(!e)return o;if(o.length===0)throw new Je(`range matching ${n} not found`);if(o.length>1)throw new He(`multiple ranges matching ${n} found`);return o[0]}getKV(t){return new Wr(t,this.unaryClient,this.frameClient)}async execRetrieve(t){const{ranges:e}=await w(this.unaryClient,fg,t,dg,yg);return this.sugarMany(e)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents(Ae(t));if(e.length===0)return null;const n=e[0];return n.id.type!=="range"?null:await this.retrieve(n.id.key)}sugarOne(t){return new Ao(t.name,t.timeRange,t.key,t.color,this.frameClient,new Wr(t.key,this.unaryClient,this.frameClient),new rg(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this)}sugarMany(t){return t.map(e=>this.sugarOne(e))}async openTracker(){return await nt(this.frameClient,"sy_range_set","sy_range_delete",(t,e)=>t==="delete"?e.toStrings().map(n=>({variant:t,key:n,value:void 0})):this.sugarMany(e.parseJSON(Vt)).map(n=>({variant:t,key:n.key,value:n})))}resourcesToRanges(t){return t.map(e=>this.resourceToRange(e))}resourceToRange(t){var e,n,r;return this.sugarOne({key:t.id.key,name:(e=t.data)==null?void 0:e.name,timeRange:new K((n=t.data)==null?void 0:n.timeRange),color:(r=t.data)==null?void 0:r.color})}};const Ae=t=>new C({type:hs,key:t}),pg=t=>new C({type:ds,key:t}),gg=s.z.object({ranges:Vt.array()}),mg=s.z.object({parent:ie.optional(),ranges:Qa.array()}),wg=s.z.object({keys:se.array()}),bg=s.z.object({}),vg=s.z.object({key:se,name:us}),Og=s.z.object({}),Tg="/range/create",zg="/range/delete",Sg="/range/rename";class jo{constructor(e){l(this,"client"),this.client=e}async rename(e,n){await w(this.client,Sg,{key:e,name:n},vg,Og)}async create(e,n){return(await w(this.client,Tg,{ranges:e,...n},mg,gg)).ranges}async delete(e){await w(this.client,zg,{keys:e},wg,bg)}}const kg=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_ONTOLOGY_TYPE:ds,Client:Co,KV:Wr,ONTOLOGY_TYPE:hs,Range:Ao,Writer:jo,aliasOntologyID:pg,analyzeParams:eo,keyZ:se,nameZ:us,newZ:Qa,ontologyID:Ae,payloadZ:Vt,sort:hg},Symbol.toStringTag,{value:"Module"})),Ng="/api/v1/";class Eg{constructor(e,n={},r=!1){l(this,"url"),l(this,"unary"),l(this,"stream"),l(this,"secure"),this.secure=r,this.url=e.child(Ng);const i=new $t.JSONCodec;this.unary=Hc(new Jc(this.url,i,this.secure),n),this.stream=new au(this.url,i,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Ig="/workspace/lineplot/retrieve",xg="/workspace/lineplot/create",Ag="/workspace/lineplot/rename",Cg="/workspace/lineplot/set-data",jg="/workspace/lineplot/delete",Rg=s.z.object({keys:Gt.array()}),Pg=s.z.object({workspace:ke,linePlots:Bd.array()}),Mg=s.z.object({key:Gt,name:s.z.string()}),Bg=s.z.object({key:Gt,data:s.z.string()}),Dg=s.z.object({keys:Gt.array()}),Ug=s.z.object({linePlots:J(fs)}),$g=s.z.object({linePlots:fs.array()}),Or=s.z.object({});let Lg=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,xg,{workspace:t,linePlots:b(e)},Pg,$g);return n?r.linePlots:r.linePlots[0]}async rename(t,e){await w(this.client,Ag,{key:t,name:e},Mg,Or)}async setData(t,e){await w(this.client,Cg,{key:t,data:JSON.stringify(e)},Bg,Or)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,Ig,{keys:b(t)},Rg,Ug);return e?n.linePlots:n.linePlots[0]}async delete(t){await w(this.client,jg,{keys:b(t)},Dg,Or)}};const _g="/workspace/log/retrieve",qg="/workspace/log/create",Yg="/workspace/log/rename",Fg="/workspace/log/set-data",Wg="/workspace/log/delete",Vg=s.z.object({keys:Zt.array()}),Gg=s.z.object({workspace:ke,logs:Ud.array()}),Zg=s.z.object({key:Zt,name:s.z.string()}),Kg=s.z.object({key:Zt,data:s.z.string()}),Jg=s.z.object({keys:Zt.array()}),Hg=s.z.object({logs:ys.array()}),Xg=s.z.object({logs:ys.array()}),Tr=s.z.object({});let Qg=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,qg,{workspace:t,logs:b(e)},Gg,Xg);return n?r.logs:r.logs[0]}async rename(t,e){await w(this.client,Yg,{key:t,name:e},Zg,Tr)}async setData(t,e){await w(this.client,Fg,{key:t,data:JSON.stringify(e)},Kg,Tr)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,_g,{keys:b(t)},Vg,Hg);return e?n.logs:n.logs[0]}async delete(t){await w(this.client,Wg,{keys:b(t)},Jg,Tr)}};const em="/workspace/schematic/retrieve",tm="/workspace/schematic/create",nm="/workspace/schematic/rename",rm="/workspace/schematic/set-data",sm="/workspace/schematic/delete",im="/workspace/schematic/copy",am=s.z.object({keys:tt.array()}),om=s.z.object({workspace:ke,schematics:qd.array()}),lm=s.z.object({key:tt,name:s.z.string()}),cm=s.z.object({key:tt,data:s.z.string()}),um=s.z.object({keys:tt.array()}),hm=s.z.object({key:tt,name:s.z.string(),snapshot:s.z.boolean()}),dm=s.z.object({schematics:J(no)}),fm=s.z.object({schematics:no.array()}),ym=s.z.object({schematic:gs}),zr=s.z.object({});let pm=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,tm,{workspace:t,schematics:b(e)},om,fm);return n?r.schematics:r.schematics[0]}async rename(t,e){await w(this.client,nm,{key:t,name:e},lm,zr)}async setData(t,e){await w(this.client,rm,{key:t,data:JSON.stringify(e)},cm,zr)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,em,{keys:b(t)},am,dm);return e?n.schematics:n.schematics[0]}async delete(t){await w(this.client,sm,{keys:b(t)},um,zr)}async copy(t,e,n){return(await w(this.client,im,{key:t,name:e,snapshot:n},hm,ym)).schematic}};const gm="/workspace/table/retrieve",mm="/workspace/table/create",wm="/workspace/table/rename",bm="/workspace/table/set-data",vm="/workspace/table/delete",Om=s.z.object({keys:Kt.array()}),Tm=s.z.object({workspace:ke,tables:Fd.array()}),zm=s.z.object({key:Kt,name:s.z.string()}),Sm=s.z.object({key:Kt,data:s.z.string()}),km=s.z.object({keys:Kt.array()}),Nm=s.z.object({tables:so.array()}),Em=s.z.object({tables:so.array()}),Sr=s.z.object({});let Im=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n=Array.isArray(e),r=await w(this.client,mm,{workspace:t,tables:b(e)},Tm,Em);return n?r.tables:r.tables[0]}async rename(t,e){await w(this.client,wm,{key:t,name:e},zm,Sr)}async setData(t,e){await w(this.client,bm,{key:t,data:JSON.stringify(e)},Sm,Sr)}async retrieve(t){const e=Array.isArray(t),n=await w(this.client,gm,{keys:b(t)},Om,Nm);return e?n.tables:n.tables[0]}async delete(t){await w(this.client,vm,{keys:b(t)},km,Sr)}};const Qt="/workspace/retrieve",xm="/workspace/create",Am="/workspace/rename",Cm="/workspace/set-layout",jm="/workspace/delete",en=s.z.object({keys:ke.array().optional(),search:s.z.string().optional(),author:et.optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Rm=s.z.object({workspaces:Ld.array()}),Pm=s.z.object({key:ke,name:s.z.string()}),Mm=s.z.object({key:ke,layout:s.z.string()}),Bm=s.z.object({keys:ke.array()}),tn=s.z.object({workspaces:J(ps)}),Dm=s.z.object({workspaces:_d.array()}),kr=s.z.object({});class Um{constructor(e){l(this,"type",to),l(this,"schematic"),l(this,"linePlot"),l(this,"log"),l(this,"table"),l(this,"client"),this.client=e,this.schematic=new pm(e),this.linePlot=new Lg(e),this.log=new Qg(e),this.table=new Im(e)}async create(e){const n=Array.isArray(e),r=await w(this.client,xm,{workspaces:b(e)},Rm,Dm);return n?r.workspaces:r.workspaces[0]}async rename(e,n){await w(this.client,Am,{key:e,name:n},Pm,kr)}async setLayout(e,n){await w(this.client,Cm,{key:e,layout:JSON.stringify(n)},Mm,kr)}async retrieve(e){const n=Array.isArray(e),r=await w(this.client,Qt,{keys:b(e)},en,tn);return n?r.workspaces:r.workspaces[0]}async retrieveByAuthor(e){return(await w(this.client,Qt,{author:e},en,tn)).workspaces}async search(e){return(await w(this.client,Qt,{search:e},en,tn)).workspaces}async page(e,n){return(await w(this.client,Qt,{offset:e,limit:n},en,tn)).workspaces}async delete(e){await w(this.client,jm,{keys:b(e)},Bm,kr)}}const Ro=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:z.z.default(z.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional(),retry:fd.breakerConfig.optional()});class Po extends _y{constructor(e){const n=Ro.parse(e),{host:r,port:i,username:a,password:o,connectivityPollFrequency:c,secure:u,retry:h}=n,f=new Eg(new $h({host:r,port:Number(i)}),h,u);f.use(Nd);let d;a!=null&&o!=null&&(d=new Oy(f.unary,{username:a,password:o}),f.use(d.middleware()));const N=new vs(new bs(f.unary)),x=new wo(f.unary,N);super(f.stream,f.unary,N),l(this,"createdAt"),l(this,"props"),l(this,"ranges"),l(this,"channels"),l(this,"auth"),l(this,"user"),l(this,"access"),l(this,"connectivity"),l(this,"ontology"),l(this,"workspaces"),l(this,"labels"),l(this,"hardware"),l(this,"control"),l(this,"transport"),l(this,"clientVersion","0.40.0"),this.createdAt=I.now(),this.props=n,this.auth=d,this.transport=f,this.channels=new po(this,N,f.unary,x),this.connectivity=new Oo(f.unary,c,this.clientVersion,n.name),this.control=new ko(this),this.ontology=new yf(f.unary,this);const ae=new jo(this.transport.unary);this.labels=new Fp(this.transport.unary,this,this.ontology),this.ranges=new Co(this,ae,this.transport.unary,N,this.labels,this.ontology),this.access=new If(this.transport.unary),this.user=new fy(this.transport.unary),this.workspaces=new Um(this.transport.unary);const Y=new np(this.transport.unary,this),Rs=new Ep(this.transport.unary,this,this.ontology,this.ranges),Qo=new up(this.transport.unary,Rs);this.hardware=new Gy(Rs,Qo,Y)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}l(Po,"connectivity",Oo);const $m=Ze.Authority,Vr=(t,e,n="")=>{try{return t.parse(e)}catch(r){if(r instanceof s.z.ZodError){const i=r.errors.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${n} - ${i.join(`
52
- `)}`)}else throw r}},Lm=s.z.object({l0:T.Color.z,l1:T.Color.z,l2:T.Color.z,l3:T.Color.z,l4:T.Color.z,l5:T.Color.z,l6:T.Color.z,l7:T.Color.z,l8:T.Color.z,l9:T.Color.z,l10:T.Color.z}),ce=(t,e)=>[t[0],t[1],e,t[3]],_m=s.z.object({m2:T.Color.z,m1:T.Color.z,z:T.Color.z,p1:T.Color.z,p2:T.Color.z}),nn=_m.or(T.Color.z.transform(t=>{const e=t.hsla;return{m2:new T.Color(T.fromHSLA(ce(e,40))),m1:new T.Color(T.fromHSLA(ce(e,45))),z:t,p1:new T.Color(T.fromHSLA(ce(e,55))),p2:new T.Color(T.fromHSLA(ce(e,65)))}})),Mo=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:T.Color.z,primary:nn,gray:Lm,error:nn,secondary:nn,warning:nn,palettes:s.z.record(T.paletteZ),visualization:s.z.object({palettes:s.z.record(s.z.array(T.Color.z))}).optional().default({palettes:{}}),white:T.Color.z,black:T.Color.z,text:T.Color.z,textInverted:T.Color.z,textOnPrimary:T.Color.z.optional().default(T.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(),codeFamily:s.z.string(),h1:xe.specZ,h2:xe.specZ,h3:xe.specZ,h4:xe.specZ,h5:xe.specZ,p:xe.specZ,small:xe.specZ})}).transform(t=>((t.colors.textOnPrimary==null||t.colors.textOnPrimary.isZero)&&(t.colors.textOnPrimary=t.colors.primary.z.pickByContrast(t.colors.text,t.colors.textInverted)),t)),qm="'Inter Variable', sans-serif",Ym="'Geist Mono', monospace",Fm=6,st=[357,91,55,1],it=[58,100,50,1],Wm=["#FDFDFD","#f9f9f9","#F2F2F2","#E6E6E6","#D8D8D8","#ADADAD","#878787","#636363","#444444","#1C1C1C","#050505"],at=Object.fromEntries(Wm.map((t,e)=>[`l${e}`,t])),Gr={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:at,border:at.l3,error:{m2:T.fromHSLA(ce(st,30)),m1:T.fromHSLA(ce(st,40)),z:T.fromHSLA(st),p1:T.fromHSLA(ce(st,65)),p2:T.fromHSLA(ce(st,77))},warning:{m2:T.fromHSLA(ce(it,30)),m1:T.fromHSLA(ce(it,40)),z:T.fromHSLA(it),p1:T.fromHSLA(ce(it,65)),p2:T.fromHSLA(ce(it,75))},palettes:{recent:{key:"recent",name:"Recent",swatches:[]}},visualization:{palettes:{default:["#DC136C","#20A4F3","#7AC74F","#FFC43D","#FE5F55","#8075FF","#D90429","#f7aef8","#f18f01","#791e94","#279af1","#d9fff5","#ff6b6b","#52ffb8"]}},logo:"url(#synnax-linear-gradient)",white:"#FFFFFF",black:"#000000",text:at.l9,textInverted:at.l0,textOnPrimary:at.l0},sizes:{base:Fm,border:{radius:3,width:1},schematic:{elementStrokeWidth:2}},typography:{family:qm,codeFamily:Ym,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.6666,weight:"medium",lineHeight:2.6666*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:1.9166666*1.5}}},Bo=Object.freeze({...Gr,key:"synnaxLight",name:"Synnax Light"}),Vm=["#020202","#0C0C0C","#161616","#252525","#323232","#464646","#646464","#989898","#b2b1b1","#d8d8d8","#FDFDFD"],ot=Object.fromEntries(Vm.map((t,e)=>[`l${e}`,t])),Do=Object.freeze({...Gr,key:"synnaxDark",name:"Synnax Dark",colors:{...Gr.colors,gray:ot,logo:"var(--pluto-text-color)",border:ot.l3,text:ot.l9,textInverted:ot.l0,textOnPrimary:ot.l10}}),Gm={synnaxDark:Do,synnaxLight:Bo},Zm=["small","medium","large","huge"],Km=s.z.enum(Zm),Jm=t=>Km.safeParse(t).success;var Hm=Object.defineProperty,Xm=(t,e,n)=>e in t?Hm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,V=(t,e,n)=>Xm(t,typeof e!="symbol"?e+"":e,n);const Zr=class Uo{constructor(e,n,r="",i=!1){V(this,"_noop",!1),V(this,"key"),V(this,"path"),V(this,"serviceName"),this.key=e,this.path=n,this.serviceName=r,this._noop=i}child(e){return new Uo(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};V(Zr,"NOOP",new Zr("","",""));let Es=Zr;const Kr=["debug","info","warn","error"],Qm=t=>{const e=Kr.indexOf(t);return({level:n})=>Kr.indexOf(n)>=e},ew=t=>{const{include:e,exclude:n}=t;return({path:r})=>!(e!=null&&!e.some(i=>r.startsWith(i))||n!=null&&n.some(i=>r.startsWith(i)))},Jr=class $o{constructor(e={}){V(this,"meta",Es.NOOP),V(this,"filters");const{filters:n=[]}=e;this.filters=n}filter(e){return!this.meta.noop&&this.filters.every(n=>n({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const n=new $o({filters:this.filters});return n.meta=e,n}debug(e,n,r=!1){!this.filter("debug")&&!r||(n==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,rn(n)))}info(e,n,r=!1){!this.filter("info")&&!r||(n==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,rn(n)))}warn(e,n,r=!1){!this.filter("warn")&&!r||(n==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,rn(n)))}error(e,n,r=!1){!this.filter("error")&&!r||(n==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,rn(n)))}};V(Jr,"NOOP",new Jr);let Lo=Jr;const rn=t=>typeof t=="function"?t():t;var tw=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Be="1.9.0",Bi=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function nw(t){var e=new Set([t]),n=new Set,r=t.match(Bi);if(!r)return function(){return!1};var i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(c){return c===t};function a(c){return n.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(n.has(c))return!1;var u=c.match(Bi);if(!u)return a(c);var h={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return h.prerelease!=null||i.major!==h.major?a(c):i.major===0?i.minor===h.minor&&i.patch<=h.patch?o(c):a(c):i.minor<=h.minor?o(c):a(c)}}var rw=nw(Be),sw=Be.split(".")[0],jt=Symbol.for("opentelemetry.js.api."+sw),Rt=tw;function Is(t,e,n,r){var i;r===void 0&&(r=!1);var a=Rt[jt]=(i=Rt[jt])!==null&&i!==void 0?i:{version:Be};if(!r&&a[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return n.error(o.stack||o.message),!1}if(a.version!==Be){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+t+" does not match previously registered API v"+Be);return n.error(o.stack||o.message),!1}return a[t]=e,n.debug("@opentelemetry/api: Registered a global for "+t+" v"+Be+"."),!0}function Pt(t){var e,n,r=(e=Rt[jt])===null||e===void 0?void 0:e.version;if(!(!r||!rw(r)))return(n=Rt[jt])===null||n===void 0?void 0:n[t]}function xs(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Be+".");var n=Rt[jt];n&&delete n[t]}var iw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},aw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},ow=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return lt("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return lt("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return lt("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return lt("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return lt("verbose",this._namespace,e)},t}();function lt(t,e,n){var r=Pt("diag");if(r)return n.unshift(e),r[t].apply(r,aw([],iw(n),!1))}var oe;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(oe||(oe={}));function lw(t,e){t<oe.NONE?t=oe.NONE:t>oe.ALL&&(t=oe.ALL),e=e||{};function n(r,i){var a=e[r];return typeof a=="function"&&t>=i?a.bind(e):function(){}}return{error:n("error",oe.ERROR),warn:n("warn",oe.WARN),info:n("info",oe.INFO),debug:n("debug",oe.DEBUG),verbose:n("verbose",oe.VERBOSE)}}var cw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},uw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},hw="diag",Mt=function(){function t(){function e(i){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var c=Pt("diag");if(c)return c[i].apply(c,uw([],cw(a),!1))}}var n=this,r=function(i,a){var o,c,u;if(a===void 0&&(a={logLevel:oe.INFO}),i===n){var h=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((o=h.stack)!==null&&o!==void 0?o:h.message),!1}typeof a=="number"&&(a={logLevel:a});var f=Pt("diag"),d=lw((c=a.logLevel)!==null&&c!==void 0?c:oe.INFO,i);if(f&&!a.suppressOverrideMessage){var N=(u=new Error().stack)!==null&&u!==void 0?u:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+N),d.warn("Current logger will overwrite one already registered from "+N)}return Is("diag",d,n,!0)};n.setLogger=r,n.disable=function(){xs(hw,n)},n.createComponentLogger=function(i){return new ow(i)},n.verbose=e("verbose"),n.debug=e("debug"),n.info=e("info"),n.warn=e("warn"),n.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),dw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},fw=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},yw=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var n=this._entries.get(e);if(n)return Object.assign({},n)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var n=dw(e,2),r=n[0],i=n[1];return[r,i]})},t.prototype.setEntry=function(e,n){var r=new t(this._entries);return r._entries.set(e,n),r},t.prototype.removeEntry=function(e){var n=new t(this._entries);return n._entries.delete(e),n},t.prototype.removeEntries=function(){for(var e,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=new t(this._entries);try{for(var o=fw(r),c=o.next();!c.done;c=o.next()){var u=c.value;a._entries.delete(u)}}catch(h){e={error:h}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return a},t.prototype.clear=function(){return new t},t}();Mt.instance();function pw(t){return t===void 0&&(t={}),new yw(new Map(Object.entries(t)))}function gw(t){return Symbol.for(t)}var mw=function(){function t(e){var n=this;n._currentContext=e?new Map(e):new Map,n.getValue=function(r){return n._currentContext.get(r)},n.setValue=function(r,i){var a=new t(n._currentContext);return a._currentContext.set(r,i),a},n.deleteValue=function(r){var i=new t(n._currentContext);return i._currentContext.delete(r),i}}return t}(),ww=new mw,bw={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},vw={set:function(t,e,n){t!=null&&(t[e]=n)}},Ow=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Tw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},zw=function(){function t(){}return t.prototype.active=function(){return ww},t.prototype.with=function(e,n,r){for(var i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return n.call.apply(n,Tw([r],Ow(i),!1))},t.prototype.bind=function(e,n){return n},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),Sw=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},kw=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},Nr="context",Nw=new zw,_o=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Is(Nr,e,Mt.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,n,r){for(var i,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,kw([e,n,r],Sw(a),!1))},t.prototype.bind=function(e,n){return this._getContextManager().bind(e,n)},t.prototype._getContextManager=function(){return Pt(Nr)||Nw},t.prototype.disable=function(){this._getContextManager().disable(),xs(Nr,Mt.instance())},t}(),Hr;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Hr||(Hr={}));var Ew=_o.getInstance(),Iw=function(){function t(){}return t.prototype.inject=function(e,n){},t.prototype.extract=function(e,n){return e},t.prototype.fields=function(){return[]},t}(),As=gw("OpenTelemetry Baggage Key");function qo(t){return t.getValue(As)||void 0}function xw(){return qo(_o.getInstance().active())}function Aw(t,e){return t.setValue(As,e)}function Cw(t){return t.deleteValue(As)}var Er="propagation",jw=new Iw,Rw=function(){function t(){this.createBaggage=pw,this.getBaggage=qo,this.getActiveBaggage=xw,this.setBaggage=Aw,this.deleteBaggage=Cw}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Is(Er,e,Mt.instance())},t.prototype.inject=function(e,n,r){return r===void 0&&(r=vw),this._getGlobalPropagator().inject(e,n,r)},t.prototype.extract=function(e,n,r){return r===void 0&&(r=bw),this._getGlobalPropagator().extract(e,n,r)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){xs(Er,Mt.instance())},t.prototype._getGlobalPropagator=function(){return Pt(Er)||jw},t}(),Pw=Rw.getInstance();const Di=["bench","debug","prod"],Mw=t=>e=>Di.indexOf(e)>=Di.indexOf(t),Xr=class Yo{constructor(e,n=Mw("debug")){V(this,"meta",Es.NOOP),V(this,"tracer"),V(this,"filter"),this.tracer=e,this.filter=n}child(e){const n=new Yo(this.tracer,this.filter);return n.meta=e,n}debug(e,n){return this.trace(e,"debug",n)}bench(e,n){return this.trace(e,"bench",n)}prod(e,n){return this.trace(e,"prod",n)}trace(e,n,r){return this.meta.noop||!this.filter(n)?r(new Vo(e)):this.tracer.startActiveSpan(e,i=>{const a=new Wo(e,i),o=r(a);return i.end(),o})}propagate(e){if(this.meta.noop)return;const n=Ew.active();Pw.inject(n,e,{set:(r,i,a)=>{r[i]=a}})}};V(Xr,"NOOP",new Xr);let Fo=Xr;class Wo{constructor(e,n){V(this,"key"),V(this,"otel"),this.key=e,this.otel=n}set(e,n){this.otel.setAttribute(e,n)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Hr.ERROR}))}}class Vo{constructor(e){V(this,"key"),this.key=e}set(){}recordError(e){}}const Qr=class Go{constructor({key:e="",serviceName:n="",logger:r=Lo.NOOP,tracer:i=Fo.NOOP,noop:a=!1,__meta:o}){V(this,"meta"),V(this,"T"),V(this,"L"),this.meta=o??new Es(e,e,n,a),this.T=i.child(this.meta),this.L=r.child(this.meta)}child(e){const n=this.meta.child(e);return new Go({__meta:n,tracer:this.T,logger:this.L})}};V(Qr,"NOOP",new Qr({noop:!0}));let Cs=Qr;const Bw=Cs.NOOP,Zo=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Cs,LOG_LEVELS:Kr,Logger:Lo,NOOP:Bw,NoopSpan:Vo,Tracer:Fo,_Span:Wo,logLevelKeyFiler:ew,logThresholdFilter:Qm},Symbol.toStringTag,{value:"Module"})),Dw=new Error("request for lock canceled");var Uw=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class $w{constructor(e,n=Dw){this._value=e,this._cancelError=n,this._queue=[],this._weightedWaiters=[]}acquire(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,i)=>{const a={resolve:r,reject:i,weight:e,priority:n},o=Ko(this._queue,c=>n<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Uw(this,arguments,void 0,function*(n,r=1,i=0){const[a,o]=yield this.acquire(r,i);try{return yield n(a)}finally{o()}})}waitForUnlock(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,n)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Lw(this._weightedWaiters[e-1],{resolve:r,priority:n})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const n=this._value;this._value-=e.weight,e.resolve([n,this._newReleaser(e.weight)])}_newReleaser(e){let n=!1;return()=>{n||(n=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const n=this._weightedWaiters[e-1];n&&(n.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let n=this._value;n>0;n--){const r=this._weightedWaiters[n-1];if(!r)continue;const i=r.findIndex(a=>a.priority<=e);(i===-1?r:r.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,n){return(this._queue.length===0||this._queue[0].priority<n)&&e<=this._value}}function Lw(t,e){const n=Ko(t,r=>e.priority<=r.priority);t.splice(n+1,0,e)}function Ko(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}var _w=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Jo{constructor(e){this._semaphore=new $w(1,e)}acquire(){return _w(this,arguments,void 0,function*(e=0){const[,n]=yield this._semaphore.acquire(1,e);return n})}runExclusive(e,n=0){return this._semaphore.runExclusive(()=>e(),1,n)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class js{constructor({key:e,type:n,sender:r,instrumentation:i,parentCtxValues:a}){$(this,"type");$(this,"key");$(this,"sender");$(this,"_internalState");$(this,"_state");$(this,"_prevState");$(this,"_deleted",!1);$(this,"parentCtxValues");$(this,"childCtxValues");$(this,"childCtxChangedKeys");$(this,"instrumentation");$(this,"schema");this.type=n,this.key=e,this.sender=r,this._internalState={},this.instrumentation=i.child(`${this.type}(${this.key})`),this.parentCtxValues=new Map,a==null||a.forEach((o,c)=>this.parentCtxValues.set(c,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}get _schema(){if(this.schema==null)throw new q(`[AetherLeaf] - expected subclass to define component schema, but none was found.
53
- Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const n=xe.executeSetter(e,this._state);this._prevState={...this._state},this._state=Vr(this._schema,n,`${this.type}:${this.key}`),this.sender.send({key:this.key,state:n})}get state(){if(this._state==null)throw new le(`[AetherLeaf] - state not defined in ${this.type}:${this.key}`);return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>this.parentCtxValues.get(e),getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),setPreviously:e=>this.childCtxValues.has(e),set:(e,n,r=!0)=>{this.childCtxValues.set(e,n),r&&this.childCtxChangedKeys.add(e)}}}async _updateState(e,n,r){if(this.deleted)return;this.validatePath(e);const i=Vr(this._schema,n,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:nl.I.difference(this.state,i)})):this.instrumentation.L.debug("setting initial state",{state:n}),this._prevState=this._state??i,this._state=i,await this.afterUpdate(this.ctx)}async _updateContext(e){e.forEach((n,r)=>this.parentCtxValues.set(r,n)),await this.afterUpdate(this.ctx)}async _delete(e){this.validatePath(e),this._deleted=!0,await this.afterDelete(this.ctx)}async afterUpdate(e){}async afterDelete(e){}validatePath(e){if(e.length===0)throw new le(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const n=e[e.length-1];if(e.length>1)throw new le(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(n!==this.key)throw new le(`[Leaf.setState] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`)}}class Qn extends js{constructor(){super(...arguments);$(this,"_children",new Map)}get children(){return Array.from(this._children.values())}getChild(n){return this._children.get(n)??null}childrenOfType(...n){return this.children.filter(r=>n.includes(r.type))}async _updateState(n,r,i){if(this.deleted)return;const a=this.parsePath(n);if(a.length===0){if(this.childCtxChangedKeys.clear(),await super._updateState(n,r,i),this.childCtxChangedKeys.size==0)return;await this.updateChildContexts();return}const c=a[0],u=this.getChild(c);if(u!=null)return u._updateState(a,r,i);if(a.length>1)throw new le(`[Composite.update] - ${this.type}:${this.key} received a subPath ${a.join(".")} but found now child with key ${c}`);const h=i(this.childCtx());await h._updateState(a,r,i),this._children.set(c,h)}async _updateContext(n){await super._updateContext(n),await this.updateChildContexts()}childCtx(){return{get:n=>this.childCtxValues.get(n)??this.parentCtxValues.get(n),forEach:n=>{this.childCtxValues.forEach((r,i)=>n(r,i,this.childCtxValues)),this.parentCtxValues.forEach((r,i)=>{this.childCtxValues.has(i)||n(r,i,this.parentCtxValues)})}}}async updateChildContexts(){for(const n of this.children)await n._updateContext(this.childCtx())}async _delete(n){const r=this.parsePath(n);if(r.length===0){for(const a of this.children)await a._delete([a.key]);this._children.clear(),await super._delete([this.key])}const i=this.getChild(r[0]);if(i!=null){if(r.length>1)return await i._delete(r);this._children.delete(i.key),await i._delete(r)}}parsePath(n,r){const[i,...a]=n;if(i==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path${r!=null?` for ${r}`:""}`);if(i!==this.key)throw new le(`[Composite.getRequiredKey] - ${this.type}:${this.key} received a key ${i} but expected ${this.key}`);return a}}const qw=s.z.object({}),Yw=()=>{throw new Error("should not call create")},Ce=class Ce extends Qn{constructor({comms:n,instrumentation:r=Zo.Instrumentation.NOOP,registry:i}){super({key:Ce.KEY,type:Ce.TYPE,sender:n,instrumentation:r,parentCtxValues:null});$(this,"comms");$(this,"registry");$(this,"mu",new Jo);$(this,"schema",qw);this.comms=n,this.registry=i}static async render(n){const r=new Ce(n);return await r._updateState([Ce.KEY],{},Yw),r.comms.handle(i=>{r.mu.runExclusive(async()=>{await r.handle(i)})}),r}async handle(n){const{path:r,variant:i,type:a}=n;i==="delete"?await this._delete(r):await this._updateState(r,n.state,o=>{const c=r[r.length-1];return this.create({key:c,type:a,parentCtxValues:o})})}create({key:n,type:r,parentCtxValues:i}){const a=this.registry[r];if(a==null)throw new le(`[Root.create] - ${r} not found in registry`);return new a({key:n,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:i})}};$(Ce,"TYPE","root"),$(Ce,"KEY","root");let Bt=Ce;const Ho=Bt.render.bind(Bt),Fw=Object.freeze(Object.defineProperty({__proto__:null,Composite:Qn,Leaf:js,Root:Bt,render:Ho},Symbol.toStringTag,{value:"Module"})),es="pluto-theming-context",Xo=s.z.object({name:s.z.string(),url:s.z.string()}),Ww=s.z.object({theme:Mo,fontURLs:s.z.array(Xo)}),xt=class xt extends Qn{constructor(){super(...arguments);$(this,"schema",xt.z)}async afterUpdate(n){n.getOptional(es)!=null&&this.state.theme.key===this.prevState.theme.key||(n.set(es,this.state.theme),await this.loadFonts())}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:n,url:r})=>{const i=new FontFace(n,`url(${r})`);await i.load(),self.fonts.add(i)}))}};$(xt,"TYPE","theming.Provider"),$(xt,"z",Ww);let Dt=xt;const Vw=t=>t.get(es),Gw={[Dt.TYPE]:Dt};exports.Am=$m;exports.B=Cs;exports.Composite=Qn;exports.H=K;exports.Jg=Kf;exports.L=q;exports.Leaf=js;exports.Me=le;exports.Mutex=Jo;exports.Provider=Dt;exports.REGISTRY=Gw;exports.S=z;exports.SYNNAX_DARK=Do;exports.SYNNAX_LIGHT=Bo;exports.SYNNAX_THEMES=Gm;exports.aether=Fw;exports.bg=Po;exports.bm=kg;exports.fontSpecZ=Xo;exports.g=Zo;exports.ie=he;exports.im=Vy;exports.isComponentSize=Jm;exports.k=I;exports.l=il;exports.prettyParse=Vr;exports.render=Ho;exports.themeZ=Mo;exports.use=Vw;exports.wg=Ro;
@@ -1,3 +0,0 @@
1
- export * from './notation';
2
- export * from './Select';
3
- //# sourceMappingURL=external.d.ts.map