@synnaxlabs/pluto 0.48.0 → 0.49.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 (465) hide show
  1. package/dist/{Animated-CC7iS0zH.js → Animated-38tdmPR0.js} +116 -120
  2. package/dist/{Animated-DfDp0-ep.js → Animated-Bp6IK3ct.js} +3 -3
  3. package/dist/Animated-D-pQ3CYh.cjs +1 -0
  4. package/dist/{Animated--SNIwznU.cjs → Animated-Dsn1pmhz.cjs} +1 -1
  5. package/dist/Box-4l6DWG-3.cjs +1 -0
  6. package/dist/{Box-CoQUaJk2.js → Box-BVyAHr2f.js} +17 -17
  7. package/dist/Button-CoOYEk1J.js +308 -0
  8. package/dist/Button-D5aoG3sV.cjs +1 -0
  9. package/dist/Dialog-JwJQD3xZ.cjs +1 -0
  10. package/dist/{Dialog-CBDFqieV.js → Dialog-puVY-0Mt.js} +14 -14
  11. package/dist/Editable-DEbVpi5i.js +201 -0
  12. package/dist/Editable-DI0-D1K5.cjs +1 -0
  13. package/dist/Haul-9RVCn3cI.cjs +1 -0
  14. package/dist/{Haul-Be1j5BU3.js → Haul-Db9j45Fu.js} +53 -49
  15. package/dist/Items-BCG7kyaR.cjs +4 -0
  16. package/dist/{Items-mikdEpyC.js → Items-BVKW0udb.js} +276 -214
  17. package/dist/Menu-BYca9tGe.cjs +1 -0
  18. package/dist/Menu-CQsrN_mP.js +134 -0
  19. package/dist/Provider-DBg-Li_7.cjs +5 -0
  20. package/dist/{Provider-DScd3hYf.js → Provider-DQM7IBoi.js} +182 -177
  21. package/dist/{Tags-DvPUmH2r.js → Tags-B8l5Dvw-.js} +419 -408
  22. package/dist/Tags-CQFa3kY-.cjs +1 -0
  23. package/dist/{Text-BbbqH88W.js → Text-90J6p5Uj.js} +993 -931
  24. package/dist/Text-DeWvfrdF.cjs +1 -0
  25. package/dist/{Video-DRSEX8t7.cjs → Video-Bmg4gwom.cjs} +1 -1
  26. package/dist/{Video-_DrutSeT.js → Video-CLpcYcKf.js} +1 -1
  27. package/dist/button.cjs +1 -1
  28. package/dist/button.js +1 -1
  29. package/dist/color.cjs +1 -1
  30. package/dist/color.js +1 -1
  31. package/dist/css-BVgFAmaj.cjs +8 -0
  32. package/dist/{css-Cn63X_Yv.js → css-bahPRiQI.js} +2057 -1572
  33. package/dist/css.cjs +1 -1
  34. package/dist/css.js +2 -2
  35. package/dist/dialog.cjs +1 -1
  36. package/dist/dialog.js +1 -1
  37. package/dist/dimensions-SDA3fM2T.cjs +1 -0
  38. package/dist/{dimensions-Dclfavlh.js → dimensions-qcyzaTKI.js} +5 -5
  39. package/dist/eraser-Cbfc1frM.cjs +11 -0
  40. package/dist/{eraser-Bpl4bpBx.js → eraser-Dz6nZuPp.js} +32 -32
  41. package/dist/ether.cjs +1 -1
  42. package/dist/ether.js +64 -62
  43. package/dist/{external-y1Apm7j1.js → external-04ve_X21.js} +105 -112
  44. package/dist/external-B3b7kdID.cjs +1 -0
  45. package/dist/{external-CJFfVl_u.cjs → external-Bixqkw5N.cjs} +1 -1
  46. package/dist/{external-8H4eB7TN.js → external-CB3VxPJp.js} +17 -18
  47. package/dist/{external-B3jTkhc4.cjs → external-CMs_BCc5.cjs} +5 -5
  48. package/dist/{external-D6TsHpoG.js → external-CnWQzZlQ.js} +117 -115
  49. package/dist/{external-6rS2YiWR.js → external-CrXS1qj_.js} +14 -14
  50. package/dist/{external-DUGcSVbJ.cjs → external-CwYoEhB2.cjs} +1 -1
  51. package/dist/{external-Caetm5fI.js → external-Cxojc4yT.js} +18 -18
  52. package/dist/external-D2deiHyL.js +69 -0
  53. package/dist/{external-CFdDgpzj.cjs → external-D2tzyCDs.cjs} +1 -1
  54. package/dist/external-DDHknds-.cjs +1 -0
  55. package/dist/{external-C0_sN1J0.js → external-DJWZ43k0.js} +1 -1
  56. package/dist/{external-X_eFMRtE.js → external-DP9FiRHq.js} +3 -3
  57. package/dist/{external-CFZ33YbY.cjs → external-DUVDOJfj.cjs} +1 -1
  58. package/dist/external-DcMOF1Je.cjs +1 -0
  59. package/dist/{external-1uZLLxz-.js → external-Hhx8JoAS.js} +712 -713
  60. package/dist/{external-B8hxM_jw.cjs → external-JpvbclD8.cjs} +2 -2
  61. package/dist/external-PA6ulZR9.cjs +1 -0
  62. package/dist/external-RkrrZXG5.cjs +1 -0
  63. package/dist/external-TI-6Umwm.js +92 -0
  64. package/dist/external-kwuGKgyL.cjs +1 -0
  65. package/dist/{external-Bq4gfE5e.js → external-m-0q-0os.js} +12 -12
  66. package/dist/{external-BOWnCKIe.js → external-xJ67ivgR.js} +3 -3
  67. package/dist/flex.cjs +1 -1
  68. package/dist/flex.js +1 -1
  69. package/dist/{fontString-BcSXNOgW.cjs → fontString-62eEvw4b.cjs} +1 -1
  70. package/dist/{fontString-D7EMGjIw.js → fontString-qfWSw62X.js} +3 -3
  71. package/dist/header.cjs +1 -1
  72. package/dist/header.js +1 -1
  73. package/dist/hooks-CRSphXSb.cjs +1 -0
  74. package/dist/hooks-Dh0v1QWQ.js +73 -0
  75. package/dist/index.cjs +8 -8
  76. package/dist/index.js +23420 -22899
  77. package/dist/input.cjs +1 -1
  78. package/dist/input.js +1 -1
  79. package/dist/list.cjs +1 -1
  80. package/dist/list.js +1 -1
  81. package/dist/menu.cjs +1 -1
  82. package/dist/menu.js +1 -1
  83. package/dist/pluto.css +1 -1
  84. package/dist/{provider-B6SgG_sT.js → provider-ClhgBr_F.js} +5007 -4824
  85. package/dist/provider-DHDqgF1B.cjs +76 -0
  86. package/dist/src/access/aether/external.d.ts +3 -0
  87. package/dist/src/access/aether/external.d.ts.map +1 -0
  88. package/dist/src/access/aether/index.d.ts +2 -0
  89. package/dist/src/access/aether/index.d.ts.map +1 -0
  90. package/dist/src/access/external.d.ts +4 -0
  91. package/dist/src/access/external.d.ts.map +1 -0
  92. package/dist/src/access/index.d.ts +2 -0
  93. package/dist/src/access/index.d.ts.map +1 -0
  94. package/dist/src/access/policy/CreateIcon.d.ts +3 -0
  95. package/dist/src/access/policy/CreateIcon.d.ts.map +1 -0
  96. package/dist/src/access/policy/Select.d.ts +12 -0
  97. package/dist/src/access/policy/Select.d.ts.map +1 -0
  98. package/dist/src/access/policy/aether/index.d.ts +2 -0
  99. package/dist/src/access/policy/aether/index.d.ts.map +1 -0
  100. package/dist/src/access/policy/aether/queries.d.ts +18 -0
  101. package/dist/src/access/policy/aether/queries.d.ts.map +1 -0
  102. package/dist/src/access/policy/external.d.ts +5 -0
  103. package/dist/src/access/policy/external.d.ts.map +1 -0
  104. package/dist/src/access/policy/index.d.ts +2 -0
  105. package/dist/src/access/policy/index.d.ts.map +1 -0
  106. package/dist/src/access/policy/queries.d.ts +102 -0
  107. package/dist/src/access/policy/queries.d.ts.map +1 -0
  108. package/dist/src/access/policy/queries.spec.d.ts.map +1 -0
  109. package/dist/src/access/policy/types.d.ts +2 -0
  110. package/dist/src/access/policy/types.d.ts.map +1 -0
  111. package/dist/src/access/queries.d.ts +36 -0
  112. package/dist/src/access/queries.d.ts.map +1 -0
  113. package/dist/src/access/queries.spec.d.ts.map +1 -0
  114. package/dist/src/access/role/CreateIcon.d.ts +3 -0
  115. package/dist/src/access/role/CreateIcon.d.ts.map +1 -0
  116. package/dist/src/access/role/Select.d.ts +9 -0
  117. package/dist/src/access/role/Select.d.ts.map +1 -0
  118. package/dist/src/access/role/aether/index.d.ts +2 -0
  119. package/dist/src/access/role/aether/index.d.ts.map +1 -0
  120. package/dist/src/access/role/aether/queries.d.ts +14 -0
  121. package/dist/src/access/role/aether/queries.d.ts.map +1 -0
  122. package/dist/src/access/role/external.d.ts +4 -0
  123. package/dist/src/access/role/external.d.ts.map +1 -0
  124. package/dist/src/access/role/index.d.ts +2 -0
  125. package/dist/src/access/role/index.d.ts.map +1 -0
  126. package/dist/src/access/role/queries.d.ts +57 -0
  127. package/dist/src/access/role/queries.d.ts.map +1 -0
  128. package/dist/src/access/role/queries.spec.d.ts.map +1 -0
  129. package/dist/src/aether/main.d.ts +0 -1
  130. package/dist/src/aether/main.d.ts.map +1 -1
  131. package/dist/src/alamos/Provider.d.ts +0 -5
  132. package/dist/src/alamos/Provider.d.ts.map +1 -1
  133. package/dist/src/alamos/aether/alamos.d.ts +4 -4
  134. package/dist/src/arc/queries.d.ts +6 -6
  135. package/dist/src/arc/queries.d.ts.map +1 -1
  136. package/dist/src/button/Button.d.ts +1 -1
  137. package/dist/src/button/Button.d.ts.map +1 -1
  138. package/dist/src/channel/queries.d.ts +25 -25
  139. package/dist/src/channel/queries.d.ts.map +1 -1
  140. package/dist/src/color/Provider.d.ts +2 -1
  141. package/dist/src/color/Provider.d.ts.map +1 -1
  142. package/dist/src/context/context.d.ts +28 -0
  143. package/dist/src/context/context.d.ts.map +1 -0
  144. package/dist/src/context/context.spec.d.ts +2 -0
  145. package/dist/src/context/context.spec.d.ts.map +1 -0
  146. package/dist/src/context/index.d.ts +2 -0
  147. package/dist/src/context/index.d.ts.map +1 -0
  148. package/dist/src/{hardware/device → device}/Select.d.ts +2 -2
  149. package/dist/src/device/Select.d.ts.map +1 -0
  150. package/dist/src/{hardware/device → device}/StatusIndicator.d.ts +1 -1
  151. package/dist/src/device/StatusIndicator.d.ts.map +1 -0
  152. package/dist/src/device/external.d.ts.map +1 -0
  153. package/dist/src/device/index.d.ts.map +1 -0
  154. package/dist/src/{hardware/device → device}/queries.d.ts +10 -14
  155. package/dist/src/device/queries.d.ts.map +1 -0
  156. package/dist/src/device/queries.spec.d.ts +2 -0
  157. package/dist/src/device/queries.spec.d.ts.map +1 -0
  158. package/dist/src/dialog/Frame.d.ts +8 -7
  159. package/dist/src/dialog/Frame.d.ts.map +1 -1
  160. package/dist/src/flex/Box.d.ts +4 -4
  161. package/dist/src/flux/Provider.d.ts.map +1 -1
  162. package/dist/src/flux/core/client.d.ts.map +1 -1
  163. package/dist/src/flux/core/store.d.ts +7 -7
  164. package/dist/src/flux/core/store.d.ts.map +1 -1
  165. package/dist/src/flux/core/streamer.d.ts +2 -2
  166. package/dist/src/flux/core/streamer.d.ts.map +1 -1
  167. package/dist/src/flux/form.d.ts +2 -2
  168. package/dist/src/flux/form.d.ts.map +1 -1
  169. package/dist/src/flux/list.d.ts +3 -3
  170. package/dist/src/flux/list.d.ts.map +1 -1
  171. package/dist/src/flux/retrieve.d.ts +2 -2
  172. package/dist/src/flux/retrieve.d.ts.map +1 -1
  173. package/dist/src/flux/update.d.ts +27 -26
  174. package/dist/src/flux/update.d.ts.map +1 -1
  175. package/dist/src/form/Context.d.ts +4 -3
  176. package/dist/src/form/Context.d.ts.map +1 -1
  177. package/dist/src/form/Field.d.ts +2 -2
  178. package/dist/src/form/Field.d.ts.map +1 -1
  179. package/dist/src/form/use.d.ts.map +1 -1
  180. package/dist/src/form/useField.d.ts.map +1 -1
  181. package/dist/src/group/queries.d.ts +3 -3
  182. package/dist/src/group/queries.d.ts.map +1 -1
  183. package/dist/src/haul/Haul.d.ts +7 -7
  184. package/dist/src/haul/Haul.d.ts.map +1 -1
  185. package/dist/src/header/Header.d.ts +2 -1
  186. package/dist/src/header/Header.d.ts.map +1 -1
  187. package/dist/src/hooks/index.d.ts +0 -1
  188. package/dist/src/hooks/index.d.ts.map +1 -1
  189. package/dist/src/hooks/useAsyncEffect.d.ts +2 -2
  190. package/dist/src/hooks/useAsyncEffect.d.ts.map +1 -1
  191. package/dist/src/hooks/useDestructors.d.ts +2 -2
  192. package/dist/src/hooks/useDestructors.d.ts.map +1 -1
  193. package/dist/src/icon/registry.d.ts +15 -0
  194. package/dist/src/icon/registry.d.ts.map +1 -1
  195. package/dist/src/index.d.ts +5 -3
  196. package/dist/src/index.d.ts.map +1 -1
  197. package/dist/src/input/Text.d.ts +1 -1
  198. package/dist/src/input/Text.d.ts.map +1 -1
  199. package/dist/src/label/queries.d.ts +6 -6
  200. package/dist/src/label/queries.d.ts.map +1 -1
  201. package/dist/src/lineplot/Legend.d.ts +2 -2
  202. package/dist/src/lineplot/Legend.d.ts.map +1 -1
  203. package/dist/src/lineplot/LinePlot.d.ts +5 -5
  204. package/dist/src/lineplot/LinePlot.d.ts.map +1 -1
  205. package/dist/src/lineplot/aether/LinePlot.d.ts +8 -8
  206. package/dist/src/lineplot/aether/XAxis.d.ts +26 -26
  207. package/dist/src/lineplot/aether/YAxis.d.ts +28 -28
  208. package/dist/src/lineplot/aether/axis.d.ts +13 -13
  209. package/dist/src/lineplot/queries.d.ts +3 -3
  210. package/dist/src/lineplot/queries.d.ts.map +1 -1
  211. package/dist/src/lineplot/range/aether/annotation.d.ts +4 -4
  212. package/dist/src/lineplot/range/aether/provider.d.ts +2 -2
  213. package/dist/src/lineplot/range/aether/provider.d.ts.map +1 -1
  214. package/dist/src/lineplot/tooltip/aether/tooltip.d.ts +26 -26
  215. package/dist/src/list/Frame.d.ts +2 -1
  216. package/dist/src/list/Frame.d.ts.map +1 -1
  217. package/dist/src/list/Items.d.ts.map +1 -1
  218. package/dist/src/log/Log.d.ts +2 -2
  219. package/dist/src/log/Log.d.ts.map +1 -1
  220. package/dist/src/log/aether/Log.d.ts +32 -32
  221. package/dist/src/log/aether/Log.d.ts.map +1 -1
  222. package/dist/src/log/queries.d.ts +3 -3
  223. package/dist/src/log/queries.d.ts.map +1 -1
  224. package/dist/src/menu/Divider.d.ts +3 -0
  225. package/dist/src/menu/Divider.d.ts.map +1 -0
  226. package/dist/src/menu/Menu.d.ts +2 -2
  227. package/dist/src/menu/Menu.d.ts.map +1 -1
  228. package/dist/src/menu/external.d.ts +1 -0
  229. package/dist/src/menu/external.d.ts.map +1 -1
  230. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  231. package/dist/src/ontology/queries.d.ts +7 -7
  232. package/dist/src/ontology/queries.d.ts.map +1 -1
  233. package/dist/src/pluto/Pluto.d.ts +9 -5
  234. package/dist/src/pluto/Pluto.d.ts.map +1 -1
  235. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  236. package/dist/src/{hardware/rack → rack}/Select.d.ts +3 -3
  237. package/dist/src/rack/Select.d.ts.map +1 -0
  238. package/dist/src/{hardware/rack → rack}/StatusIndicator.d.ts +1 -1
  239. package/dist/src/rack/StatusIndicator.d.ts.map +1 -0
  240. package/dist/src/rack/external.d.ts.map +1 -0
  241. package/dist/src/rack/index.d.ts.map +1 -0
  242. package/dist/src/{hardware/rack → rack}/queries.d.ts +7 -9
  243. package/dist/src/rack/queries.d.ts.map +1 -0
  244. package/dist/src/rack/queries.spec.d.ts +2 -0
  245. package/dist/src/rack/queries.spec.d.ts.map +1 -0
  246. package/dist/src/ranger/queries.d.ts +7 -7
  247. package/dist/src/ranger/queries.d.ts.map +1 -1
  248. package/dist/src/schematic/queries.d.ts +5 -5
  249. package/dist/src/schematic/queries.d.ts.map +1 -1
  250. package/dist/src/schematic/symbol/Primitives.d.ts +2 -2
  251. package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
  252. package/dist/src/schematic/symbol/queries.d.ts +8 -8
  253. package/dist/src/schematic/symbol/queries.d.ts.map +1 -1
  254. package/dist/src/schematic/symbol/registry.d.ts +2 -2
  255. package/dist/src/select/Frame.d.ts.map +1 -1
  256. package/dist/src/select/Static.d.ts +2 -2
  257. package/dist/src/select/Static.d.ts.map +1 -1
  258. package/dist/src/select/use.d.ts +2 -2
  259. package/dist/src/select/use.d.ts.map +1 -1
  260. package/dist/src/showcase/InputShowcase.d.ts +7 -7
  261. package/dist/src/showcase/InputShowcase.d.ts.map +1 -1
  262. package/dist/src/showcase/TagShowcase.d.ts.map +1 -1
  263. package/dist/src/state/state.d.ts +2 -1
  264. package/dist/src/state/state.d.ts.map +1 -1
  265. package/dist/src/state/state.spec.d.ts +2 -0
  266. package/dist/src/state/state.spec.d.ts.map +1 -0
  267. package/dist/src/status/aether/errorHandler.d.ts.map +1 -1
  268. package/dist/src/status/core/Aggregator.d.ts +2 -2
  269. package/dist/src/status/core/Aggregator.d.ts.map +1 -1
  270. package/dist/src/status/core/Notification.d.ts.map +1 -1
  271. package/dist/src/status/queries.d.ts +13 -13
  272. package/dist/src/status/queries.d.ts.map +1 -1
  273. package/dist/src/store/store.d.ts +2 -2
  274. package/dist/src/store/store.d.ts.map +1 -1
  275. package/dist/src/synnax/Provider.d.ts.map +1 -1
  276. package/dist/src/synnax/aether/provider.d.ts +3 -3
  277. package/dist/src/table/aether/Table.d.ts +12 -12
  278. package/dist/src/table/cells/Cells.d.ts +7 -7
  279. package/dist/src/table/queries.d.ts +3 -3
  280. package/dist/src/table/queries.d.ts.map +1 -1
  281. package/dist/src/tabs/useContext.d.ts +4 -4
  282. package/dist/src/tabs/useContext.d.ts.map +1 -1
  283. package/dist/src/tag/Tag.d.ts +2 -2
  284. package/dist/src/tag/Tag.d.ts.map +1 -1
  285. package/dist/src/task/index.d.ts.map +1 -0
  286. package/dist/src/{hardware/task → task}/queries.d.ts +14 -33
  287. package/dist/src/task/queries.d.ts.map +1 -0
  288. package/dist/src/task/queries.spec.d.ts +2 -0
  289. package/dist/src/task/queries.spec.d.ts.map +1 -0
  290. package/dist/src/telem/aether/context.d.ts +2 -2
  291. package/dist/src/telem/aether/context.d.ts.map +1 -1
  292. package/dist/src/telem/aether/pipeline.d.ts +2 -2
  293. package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
  294. package/dist/src/telem/aether/remote.d.ts +4 -4
  295. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  296. package/dist/src/telem/aether/static.d.ts +11 -11
  297. package/dist/src/telem/aether/telem.d.ts +2 -2
  298. package/dist/src/telem/aether/telem.d.ts.map +1 -1
  299. package/dist/src/telem/aether/transformers.d.ts +30 -30
  300. package/dist/src/telem/client/client.d.ts +4 -4
  301. package/dist/src/telem/client/client.d.ts.map +1 -1
  302. package/dist/src/telem/client/streamer.d.ts +2 -2
  303. package/dist/src/telem/client/streamer.d.ts.map +1 -1
  304. package/dist/src/telem/control/Controller.d.ts +2 -1
  305. package/dist/src/telem/control/Controller.d.ts.map +1 -1
  306. package/dist/src/telem/control/aether/chip.d.ts +10 -10
  307. package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
  308. package/dist/src/telem/control/aether/controller.d.ts +3 -3
  309. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  310. package/dist/src/telem/control/aether/indicator.d.ts +13 -13
  311. package/dist/src/telem/control/aether/legend.d.ts +4 -4
  312. package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
  313. package/dist/src/telem/control/aether/state.d.ts +3 -3
  314. package/dist/src/telem/control/aether/state.d.ts.map +1 -1
  315. package/dist/src/testutil/Synnax.d.ts +0 -5
  316. package/dist/src/testutil/Synnax.d.ts.map +1 -1
  317. package/dist/src/text/Text.d.ts +2 -1
  318. package/dist/src/text/Text.d.ts.map +1 -1
  319. package/dist/src/text/core/types.d.ts +2 -2
  320. package/dist/src/theming/Provider.d.ts +2 -1
  321. package/dist/src/theming/Provider.d.ts.map +1 -1
  322. package/dist/src/theming/aether/provider.d.ts +141 -141
  323. package/dist/src/theming/core/theme.d.ts +135 -135
  324. package/dist/src/theming/core/theme.d.ts.map +1 -1
  325. package/dist/src/tooltip/Config.d.ts +4 -3
  326. package/dist/src/tooltip/Config.d.ts.map +1 -1
  327. package/dist/src/tree/Context.d.ts +2 -12
  328. package/dist/src/tree/Context.d.ts.map +1 -1
  329. package/dist/src/tree/Tree.d.ts.map +1 -1
  330. package/dist/src/triggers/Provider.d.ts +4 -3
  331. package/dist/src/triggers/Provider.d.ts.map +1 -1
  332. package/dist/src/triggers/triggers.d.ts +21 -21
  333. package/dist/src/user/CreateIcon.d.ts +3 -0
  334. package/dist/src/user/CreateIcon.d.ts.map +1 -0
  335. package/dist/src/user/external.d.ts +1 -0
  336. package/dist/src/user/external.d.ts.map +1 -1
  337. package/dist/src/user/queries.d.ts +6 -4
  338. package/dist/src/user/queries.d.ts.map +1 -1
  339. package/dist/src/viewport/use.d.ts +1 -1
  340. package/dist/src/vis/axis/axis.d.ts +5 -5
  341. package/dist/src/vis/axis/ticks.d.ts +2 -2
  342. package/dist/src/vis/button/aether/button.d.ts +8 -8
  343. package/dist/src/vis/canvas/aether/canvas.d.ts +4 -4
  344. package/dist/src/vis/diagram/Diagram.d.ts +2 -6
  345. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  346. package/dist/src/vis/diagram/aether/Diagram.d.ts +9 -9
  347. package/dist/src/vis/diagram/align.d.ts +7 -2
  348. package/dist/src/vis/diagram/align.d.ts.map +1 -1
  349. package/dist/src/vis/draw2d/canvas.d.ts +2 -2
  350. package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
  351. package/dist/src/vis/eraser/aether/eraser.d.ts +2 -2
  352. package/dist/src/vis/gauge/aether/gauge.d.ts +60 -60
  353. package/dist/src/vis/gauge/use.d.ts +18 -18
  354. package/dist/src/vis/legend/Container.d.ts +3 -29
  355. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  356. package/dist/src/vis/legend/Entries.d.ts +2 -2
  357. package/dist/src/vis/legend/Entries.d.ts.map +1 -1
  358. package/dist/src/vis/legend/Simple.d.ts +2 -2
  359. package/dist/src/vis/legend/Simple.d.ts.map +1 -1
  360. package/dist/src/vis/light/aether/light.d.ts +6 -6
  361. package/dist/src/vis/light/aether/light.d.ts.map +1 -1
  362. package/dist/src/vis/line/Line.d.ts +2 -2
  363. package/dist/src/vis/line/Line.d.ts.map +1 -1
  364. package/dist/src/vis/line/aether/line.d.ts +5 -5
  365. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  366. package/dist/src/vis/measure/aether/measure.d.ts +28 -28
  367. package/dist/src/vis/render/GLProgram.d.ts +2 -2
  368. package/dist/src/vis/render/GLProgram.d.ts.map +1 -1
  369. package/dist/src/vis/render/context.d.ts +2 -2
  370. package/dist/src/vis/render/context.d.ts.map +1 -1
  371. package/dist/src/vis/render/performance.d.ts +2 -2
  372. package/dist/src/vis/render/performance.d.ts.map +1 -1
  373. package/dist/src/vis/rule/aether/aether.d.ts +6 -6
  374. package/dist/src/vis/setpoint/aether/setpoint.d.ts +10 -10
  375. package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
  376. package/dist/src/vis/toggle/aether/toggle.d.ts +10 -10
  377. package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
  378. package/dist/src/vis/value/aether/value.d.ts +75 -75
  379. package/dist/src/vis/value/use.d.ts +23 -23
  380. package/dist/src/worker/Context.d.ts +2 -0
  381. package/dist/src/worker/Context.d.ts.map +1 -1
  382. package/dist/src/workspace/queries.d.ts +10 -8
  383. package/dist/src/workspace/queries.d.ts.map +1 -1
  384. package/dist/tabs.cjs +1 -1
  385. package/dist/tabs.js +1 -1
  386. package/dist/text.cjs +1 -1
  387. package/dist/text.js +2 -2
  388. package/dist/theming.cjs +1 -1
  389. package/dist/theming.js +2 -2
  390. package/dist/tree.cjs +1 -1
  391. package/dist/tree.js +1 -1
  392. package/dist/triggers.cjs +1 -1
  393. package/dist/triggers.js +1 -1
  394. package/dist/types-8-Mr79SF.cjs +1 -0
  395. package/dist/types-DGaZ_JZb.js +82 -0
  396. package/dist/{units-cBd5OJg4.js → units-CgMHbHoA.js} +1 -1
  397. package/dist/units-InoNiVrK.cjs +1 -0
  398. package/dist/{value-UJNdARAu.js → value-CzFrd9p6.js} +2213 -2186
  399. package/dist/value-QHhF9WPA.cjs +53 -0
  400. package/dist/video.cjs +1 -1
  401. package/dist/video.js +1 -1
  402. package/package.json +8 -8
  403. package/dist/Animated-TMpTdCqK.cjs +0 -1
  404. package/dist/Box-Ds_D3xR_.cjs +0 -1
  405. package/dist/Button-BaMa3eGI.cjs +0 -1
  406. package/dist/Button-NgDHbsf8.js +0 -306
  407. package/dist/Dialog-BL8T9CVw.cjs +0 -1
  408. package/dist/Editable-C7KPD0hC.js +0 -193
  409. package/dist/Editable-CWt3zqDm.cjs +0 -1
  410. package/dist/Haul-D1WaI_xE.cjs +0 -1
  411. package/dist/Items-BYlg9bb-.cjs +0 -4
  412. package/dist/Menu-CcWs0t21.js +0 -156
  413. package/dist/Menu-DJoh8bH7.cjs +0 -1
  414. package/dist/Provider-fx1wTnXk.cjs +0 -5
  415. package/dist/Tags-KHafaGjR.cjs +0 -1
  416. package/dist/Text-CZrjPRjJ.cjs +0 -1
  417. package/dist/css-C_YE-5Xa.cjs +0 -8
  418. package/dist/debounce-CW9Q-DsR.js +0 -17
  419. package/dist/debounce-heEWeOqL.cjs +0 -1
  420. package/dist/deep-7SxmCL0x.cjs +0 -1
  421. package/dist/deep-szN5DCOH.js +0 -349
  422. package/dist/dimensions-DFDTcQRG.cjs +0 -1
  423. package/dist/eraser-Bqibt23a.cjs +0 -11
  424. package/dist/external-19BIaQc6.cjs +0 -1
  425. package/dist/external-AInsIJp-.cjs +0 -1
  426. package/dist/external-Bi-OQCBH.js +0 -45
  427. package/dist/external-CN15E8ls.cjs +0 -1
  428. package/dist/external-CfEVFfhL.cjs +0 -1
  429. package/dist/external-D7WE6Leo.cjs +0 -1
  430. package/dist/external-DwhfVdFp.js +0 -88
  431. package/dist/external-pRQzznIG.cjs +0 -1
  432. package/dist/hooks-BmUn8s1r.js +0 -74
  433. package/dist/hooks-CutQY1o9.cjs +0 -1
  434. package/dist/provider-C9Beoajx.cjs +0 -72
  435. package/dist/src/hardware/device/Select.d.ts.map +0 -1
  436. package/dist/src/hardware/device/StatusIndicator.d.ts.map +0 -1
  437. package/dist/src/hardware/device/external.d.ts.map +0 -1
  438. package/dist/src/hardware/device/index.d.ts.map +0 -1
  439. package/dist/src/hardware/device/queries.d.ts.map +0 -1
  440. package/dist/src/hardware/device/queries.spec.d.ts.map +0 -1
  441. package/dist/src/hardware/rack/Select.d.ts.map +0 -1
  442. package/dist/src/hardware/rack/StatusIndicator.d.ts.map +0 -1
  443. package/dist/src/hardware/rack/external.d.ts.map +0 -1
  444. package/dist/src/hardware/rack/index.d.ts.map +0 -1
  445. package/dist/src/hardware/rack/queries.d.ts.map +0 -1
  446. package/dist/src/hardware/rack/queries.spec.d.ts.map +0 -1
  447. package/dist/src/hardware/task/index.d.ts.map +0 -1
  448. package/dist/src/hardware/task/queries.d.ts.map +0 -1
  449. package/dist/src/hardware/task/queries.spec.d.ts.map +0 -1
  450. package/dist/src/hooks/useRequiredContext.d.ts +0 -2
  451. package/dist/src/hooks/useRequiredContext.d.ts.map +0 -1
  452. package/dist/src/hooks/useRequiredContext.spec.d.ts +0 -2
  453. package/dist/src/hooks/useRequiredContext.spec.d.ts.map +0 -1
  454. package/dist/types-BNX_Jj6k.js +0 -80
  455. package/dist/types-D-yz1qsT.cjs +0 -1
  456. package/dist/units-zxke9Ng2.cjs +0 -1
  457. package/dist/value-Ce4T858D.cjs +0 -53
  458. /package/dist/src/{hardware/device → access/policy}/queries.spec.d.ts +0 -0
  459. /package/dist/src/{hardware/rack → access}/queries.spec.d.ts +0 -0
  460. /package/dist/src/{hardware/task → access/role}/queries.spec.d.ts +0 -0
  461. /package/dist/src/{hardware/device → device}/external.d.ts +0 -0
  462. /package/dist/src/{hardware/device → device}/index.d.ts +0 -0
  463. /package/dist/src/{hardware/rack → rack}/external.d.ts +0 -0
  464. /package/dist/src/{hardware/rack → rack}/index.d.ts +0 -0
  465. /package/dist/src/{hardware/task → task}/index.d.ts +0 -0
@@ -1,72 +0,0 @@
1
- "use strict";const a=require("zod"),A=require("./css-C_YE-5Xa.cjs"),Fe=require("./types-D-yz1qsT.cjs"),Rh=require("./deep-7SxmCL0x.cjs"),Dh=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},co=t=>{const e=(r,n=ls)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!Dn(r))return r;n=qh(n);const s={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let c=i[o];const l=t(o);n.recursive&&(Dn(c)?Ka(c)||(c=e(c,n)):n.recursiveInArray&&Ga(c)&&(c=[...c].map(u=>{let h=u;return Dn(u)?Ka(h)||(h=e(u,n)):Ga(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},lo=co(Dh),Lh=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Bh=co(Lh),Fh=[Number,String,Uint8Array],ls={recursive:!0,recursiveInArray:!0},qh=(t=ls)=>(t.recursive==null?t=ls:t.recursiveInArray??=!1,t),Ga=t=>t!=null&&Array.isArray(t),Dn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Ka=t=>Fh.some(e=>t instanceof e);let Yh=class{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=lo(r);return e!=null?e.parse(n):n}encodeString(t){const e=Bh(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}};const us=new Yh,pe=t=>t!=null&&typeof t=="object"&&"value"in t;let Dt=class{value;constructor(t){this.value=t}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}};const Vh=t=>t!=null&&typeof t=="object"&&"toString"in t,Hh=(t,e=!1)=>{const r=Vh(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?Wh(n):n},Wh=t=>(e,r)=>t(r,e),pn=a.z.tuple([a.z.number(),a.z.number()]);a.z.tuple([a.z.bigint(),a.z.bigint()]);const uo=a.z.object({width:a.z.number(),height:a.z.number()}),Gh=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),Kh=["width","height"];a.z.enum(Kh);const Jh=["start","center","end"],Xh=["signedWidth","signedHeight"];a.z.enum(Xh);const nn=a.z.object({x:a.z.number(),y:a.z.number()}),Qh=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),ed=["x","y"],ho=a.z.enum(ed),fo=["top","right","bottom","left"];a.z.enum(fo);const td=["left","right"],po=a.z.enum(td),rd=["top","bottom"],yo=a.z.enum(rd),mo=["center"],Ja=a.z.enum(mo),nd=[...fo,...mo],go=a.z.enum(nd);a.z.enum(Jh);const sd=["first","last"];a.z.enum(sd);const ad=a.z.object({lower:a.z.number(),upper:a.z.number()}),id=a.z.object({lower:a.z.bigint(),upper:a.z.bigint()});a.z.union([ad,pn]);a.z.union([id,pn]);a.z.enum([...ho.options,...go.options]);a.z.enum(["x","left","right"]);a.z.enum(["y","top","bottom"]);a.z.union([ho,go,a.z.instanceof(String)]);const yn=t=>(e,r)=>{if(typeof e=="bigint"){if(od(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},mn=yn((t,e)=>t-e),gn=yn((t,e)=>t+e),od=t=>typeof t=="bigint"?!0:Number.isInteger(t),Ie=yn((t,e)=>t*e),wn=yn((t,e)=>t/e),lt=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},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 n.lower=t.lower,n.upper=t.upper;return r?.makeValid?cd(n):n},cd=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,Xa=(t,e)=>{const r=lt(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e};a.z.object({x:po.or(Ja),y:yo.or(Ja)});const ld=a.z.object({x:po,y:yo}),ud=Object.freeze({x:"left",y:"top"}),hd=(t,e)=>t.x===e.x&&t.y===e.y,Qa=a.z.union([a.z.number(),nn,pn,uo,Gh,Qh]),dd=(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}},ei=Object.freeze({x:0,y:0}),Lr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:Lr,left:Lr,width:Lr,height:Lr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:nn,two:nn,root:ld});const Xs=(t,e,r=0,n=0,s)=>{const i={one:{...ei},two:{...ei},root:s??ud};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Ln=t=>{const e=Xs(t);return{lower:e.one.x,upper:e.two.x}},Bn=t=>{const e=Xs(t);return{lower:e.one.y,upper:e.two.y}},fd=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,pd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([uo,pd,nn,pn]);const yd=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;a.z.object({offset:Qa,scale:Qa});a.z.object({offset:a.z.number(),scale:a.z.number()});const md=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],gd=t=>(e,r,n,s)=>[e,s?n/t:n*t],wd=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,l=i-s,u=c-o;if(r==="dimension")return[t,n*(u/l)];const h=(n-s)*(u/l)+o;return[t,h]},bd=t=>(e,r,n)=>[t,n],vd=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},zd=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=yd(n,s,i),[e,n]};let ti=class Tt{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new Tt().translate(e)}static magnify(e){return new Tt().magnify(e)}static scale(e,r){return new Tt().scale(e,r)}translate(e){const r=this.new(),n=md(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=gd(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=lt(e,r),s=this.new(),i=wd(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=lt(e,r),s=this.new(),i=zd(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=lt(e,r),s=this.new(),i=bd(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=vd();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Tt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new Tt};(class ke{x;y;currRoot;constructor(e=new ti,r=new ti,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new ke().translate(e,r)}static translateX(e){return new ke().translateX(e)}static translateY(e){return new ke().translateY(e)}static clamp(e){return new ke().clamp(e)}static magnify(e){return new ke().magnify(e)}static scale(e){return new ke().scale(e)}static reBound(e){return new ke().reBound(e)}translate(e,r){const n=dd(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(fd(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!hd(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(Ln(e)),r.y=r.y.scale(Bn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(Ln(e)),r.y=this.y.reBound(Bn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Ln(e)),r.y=this.y.clamp(Bn(e)),r}copy(){const e=new ke;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return Xs(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})}}static IDENTITY=new ke});let wo=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const bo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Td=`0123456789${bo}`,Od=11,Sd=wo(bo,1),kd=wo(Td,Od-1),Nd=()=>`${Sd()}${kd()}`,Ed=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Ad=a.z.enum(["static","dynamic"]),hs=2n**63n-1n,Id=2**63-1,ri=365,Br=30,xd=a.z.union([a.z.tuple([a.z.int()]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12)]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12),a.z.int().min(1).max(31)])]),vo=(t,e)=>{const r=new P(e);if(![U.DAY,U.HOUR,U.MINUTE,U.SECOND,U.MILLISECOND,U.MICROSECOND,U.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof P?new P(n):new U(n)};let P=class z extends Dt{constructor(e,r="UTC"){if(e==null)super(z.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*z.MILLISECOND.valueOf());else if(typeof e=="string")super(z.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(z.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===Id?e=hs:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),pe(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new z(BigInt(s.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let l=z.hours(parseInt(n??"00")).add(z.minutes(parseInt(s??"00"))).add(z.seconds(parseInt(o??"00"))).add(z.milliseconds(parseInt(c??"00")));return r==="local"&&(l=l.add(z.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,r);if(e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let s=e,i=0;if(e.includes(".")){const u=e.split(".");s=u[0];const h=u[1]||"0";i=parseInt(h.padEnd(3,"0").slice(0,3))}const o=r==="local"?new Date(s.replace("T"," ")):new Date(`${s}Z`),c=BigInt(o.getTime())*z.MILLISECOND.valueOf(),l=BigInt(i)*z.MILLISECOND.valueOf();return c+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new z(BigInt(n.getTime())*z.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new U(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new er(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(gn(this.valueOf(),new U(e).valueOf()))}sub(e){return new z(mn(this.valueOf(),new U(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(U.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(U.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(U.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(U.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(z.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(z.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new z(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new z(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new z(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new z(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new z(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new z(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new z(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new z(r)}toString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}remainder(e){return vo(this,e)}get isToday(){return this.truncate(U.DAY).equals(z.now().truncate(U.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(U.days(30))?"shortDate":e.greaterThanOrEqual(U.DAY)?"dateTime":e.greaterThanOrEqual(U.HOUR)?"time":e.greaterThanOrEqual(U.SECOND)?"preciseTime":"ISOTime"}static now(){return new z(new Date)}static max(...e){let r=z.MIN;for(const n of e){const s=new z(n);s.after(r)&&(r=s)}return r}static min(...e){let r=z.MAX;for(const n of e){const s=new z(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new z(e,r)}static NANOSECOND=z.nanoseconds(1);static microseconds(e,r="UTC"){return z.nanoseconds(e*1e3,r)}static MICROSECOND=z.microseconds(1);static milliseconds(e,r="UTC"){return z.microseconds(e*1e3,r)}static MILLISECOND=z.milliseconds(1);static seconds(e,r="UTC"){return z.milliseconds(e*1e3,r)}static SECOND=z.seconds(1);static minutes(e,r="UTC"){return z.seconds(e*60,r)}static MINUTE=z.minutes(1);static hours(e,r="UTC"){return z.minutes(e*60,r)}static HOUR=z.hours(1);static days(e,r="UTC"){return z.hours(e*24,r)}static DAY=z.days(1);static MAX=new z(hs);static MIN=new z(0);static ZERO=new z(0);static z=a.z.union([a.z.instanceof(z),a.z.object({value:a.z.bigint()}).transform(e=>new z(e.value)),a.z.string().transform(e=>new z(BigInt(e))),a.z.number().transform(e=>new z(e)),a.z.bigint().transform(e=>new z(e)),a.z.date().transform(e=>new z(e)),a.z.custom(e=>e instanceof U).transform(e=>new z(e)),xd.transform(e=>new z(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}},U=class S extends Dt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),pe(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof S?e:e instanceof Fn?e.period:e instanceof P?new S(e):(pe(e)&&(e=e.value),["number","bigint"].includes(typeof e)?S.seconds(e):new S(e))}static fromMilliseconds(e){return e instanceof S?e:e instanceof Fn?e.period:e instanceof P?new S(e):(pe(e)&&(e=e.value),["number","bigint"].includes(typeof e)?S.milliseconds(e):new S(e))}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 vo(this,e)}truncate(e){return new S(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(S.DAY),n=this.truncate(S.HOUR),s=this.truncate(S.MINUTE),i=this.truncate(S.SECOND),o=this.truncate(S.MILLISECOND),c=this.truncate(S.MICROSECOND),l=this.truncate(S.NANOSECOND),u=r,h=n.sub(r),f=s.sub(n),d=i.sub(s),v=o.sub(i),x=c.sub(o),j=l.sub(c);let w="";return u.isZero||(w+=`${u.days}d `),h.isZero||(w+=`${h.hours}h `),f.isZero||(w+=`${f.minutes}m `),d.isZero||(w+=`${d.seconds}s `),v.isZero||(w+=`${v.milliseconds}ms `),x.isZero||(w+=`${x.microseconds}µs `),j.isZero||(w+=`${j.nanoseconds}ns`),w.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new S(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(S.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,c=r.seconds,l=Math.floor(s/ri),u=Math.floor(s/Br),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),v=Math.floor(o),x=Math.floor(c),j=n?"-":"";if(l>=1){let w=`${l}y`;if(l<2){const O=Math.floor(s%ri/Br);O>0&&(w+=` ${O}mo`)}return j+w}if(h>=1&&s<Br&&s%7===0){let w=`${h}w`;const O=Math.floor(s%7),I=Math.floor(i-h*7*24);return h<2&&(O>0?w+=` ${O}d`:I>0&&I<24&&(w+=` ${I}h`)),j+w}if(u>=1){let w=`${u}mo`;if(u<3){const O=Math.floor(s%Br);O>0&&(w+=` ${O}d`)}return j+w}if(h>=1){let w=`${h}w`;const O=Math.floor(s%7),I=Math.floor(i-h*7*24);return h<2&&(O>0?w+=` ${O}d`:I>0&&I<24&&(w+=` ${I}h`)),j+w}if(f>=1){let w=`${f}d`;const O=Math.floor(i-f*24);return f<2&&O>0&&(w+=` ${O}h`),j+w}if(d>=1){let w=`${d}h`;if(d<3){const O=Math.floor(o-d*60);O>0&&(w+=` ${O}m`)}return j+w}if(v>=1){let w=`${v}m`;if(v<5){const O=Math.floor(c-v*60);O>0&&(w+=` ${O}s`)}return j+w}return`${j}${x}s`}mult(e){return new S(Ie(this.valueOf(),e))}div(e){return new S(wn(this.valueOf(),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()===0n}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 NANOSECOND=S.nanoseconds(1);static microseconds(e=1){return S.nanoseconds(Ie(e,1e3))}static MICROSECOND=S.microseconds(1);static milliseconds(e=1){return S.microseconds(Ie(e,1e3))}static MILLISECOND=S.milliseconds(1);static seconds(e=1){return S.milliseconds(Ie(e,1e3))}static SECOND=S.seconds(1);static minutes(e=1){return S.seconds(Ie(e,60))}static MINUTE=S.minutes(1);static hours(e){return S.minutes(Ie(e,60))}static HOUR=S.hours(1);static days(e){return S.hours(Ie(e,24))}static DAY=S.days(1);static MAX=new S(hs);static MIN=new S(0);static ZERO=new S(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new S(e.value)),a.z.string().transform(e=>new S(BigInt(e))),a.z.number().transform(e=>new S(e)),a.z.bigint().transform(e=>new S(e)),a.z.instanceof(S),a.z.instanceof(P).transform(e=>new S(e)),a.z.custom(e=>e instanceof Fn).transform(e=>new S(e))])},Fn=class he extends Dt{constructor(e){pe(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new he(e).valueOf()}get period(){return U.seconds(1/this.valueOf())}sampleCount(e){return new U(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new te(r).valueOf()}span(e){return U.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new te(r).valueOf())}add(e){return new he(gn(this.valueOf(),new he(e).valueOf()))}sub(e){return new he(mn(this.valueOf(),new he(e).valueOf()))}mult(e){return new he(Ie(this.valueOf(),e))}div(e){return new he(wn(this.valueOf(),e))}static hz(e){return new he(e)}static khz(e){return he.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new he(e)),a.z.instanceof(he)])},te=class se extends Dt{constructor(e){pe(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new ds(e*this.valueOf())}add(e){return new se(gn(this.valueOf(),new se(e).valueOf()))}sub(e){return new se(mn(this.valueOf(),new se(e).valueOf()))}mult(e){return new se(Ie(this.valueOf(),e))}div(e){return new se(wn(this.valueOf(),e))}static UNKNOWN=new se(0);static BIT128=new se(16);static BIT64=new se(8);static BIT32=new se(4);static BIT16=new se(2);static BIT8=new se(1);static z=a.z.union([a.z.number().transform(e=>new se(e)),a.z.instanceof(se)])},er=class Ne{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new P(e.start),this.end=new P(e.end)):(this.start=new P(e),this.end=new P(r))}get span(){return new U(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.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Ne(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=U.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=U.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=P.max(n.start,e.start),i=P.min(n.end,e.end);return i.before(s)?!1:new U(i.sub(s)).greaterThanOrEqual(r)}contains(e){return e instanceof Ne?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new Ne(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new Ne(P.min(...e.map(r=>r.start)),P.max(...e.map(r=>r.end)))}static MAX=new Ne(P.MIN,P.MAX);static ZERO=new Ne(P.ZERO,P.ZERO);static z=a.z.union([a.z.object({start:P.z,end:P.z}).transform(e=>new Ne(e.start,e.end)),a.z.instanceof(Ne)]);static sort(e,r){return P.sort(e.start,r.start)||P.sort(e.end,r.end)}static simplify(e){return e.map(r=>r.makeValid()).sort((r,n)=>Ne.sort(r,n)).reduce((r,n)=>{if(n.span.isZero)return r;if(r.length===0)return r.push(n),r;const s=r[r.length-1];return s.overlapsWith(n)||s.end.equals(n.start)?s.end=P.max(s.end,n.end):r.push(n),r},[])}},q=class y extends Dt{constructor(e){if(pe(e)&&(e=e.value),e instanceof y||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=y.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=y.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(e=!1){return e?y.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(y.JSON)||this.equals(y.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(y.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=y.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(y.UINT8)||this.equals(y.UINT16)||this.equals(y.UINT32)||this.equals(y.UINT64)}get isSignedInteger(){return this.equals(y.INT8)||this.equals(y.INT16)||this.equals(y.INT32)||this.equals(y.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(y.INT32)&&e.equals(y.FLOAT64)||this.equals(y.INT8)&&e.equals(y.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return y.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new y("unknown");static FLOAT64=new y("float64");static FLOAT32=new y("float32");static INT64=new y("int64");static INT32=new y("int32");static INT16=new y("int16");static INT8=new y("int8");static UINT64=new y("uint64");static UINT32=new y("uint32");static UINT16=new y("uint16");static UINT8=new y("uint8");static BOOLEAN=new y("boolean");static TIMESTAMP=new y("timestamp");static UUID=new y("uuid");static STRING=new y("string");static JSON=new y("json");static ARRAY_CONSTRUCTORS=new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]]);static DENSITIES=new Map([[y.UINT8.toString(),te.BIT8],[y.UINT16.toString(),te.BIT16],[y.UINT32.toString(),te.BIT32],[y.UINT64.toString(),te.BIT64],[y.FLOAT32.toString(),te.BIT32],[y.FLOAT64.toString(),te.BIT64],[y.INT8.toString(),te.BIT8],[y.INT16.toString(),te.BIT16],[y.INT32.toString(),te.BIT32],[y.INT64.toString(),te.BIT64],[y.TIMESTAMP.toString(),te.BIT64],[y.STRING.toString(),te.UNKNOWN],[y.JSON.toString(),te.UNKNOWN],[y.UUID.toString(),te.BIT128]]);static ALL=[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON];static SHORT_STRINGS=new Map([[y.UINT8.toString(),"u8"],[y.UINT16.toString(),"u16"],[y.UINT32.toString(),"u32"],[y.UINT64.toString(),"u64"],[y.INT8.toString(),"i8"],[y.INT16.toString(),"i16"],[y.INT32.toString(),"i32"],[y.INT64.toString(),"i64"],[y.FLOAT32.toString(),"f32"],[y.FLOAT64.toString(),"f64"],[y.BOOLEAN.toString(),"bool"],[y.TIMESTAMP.toString(),"ts"],[y.UUID.toString(),"uuid"],[y.STRING.toString(),"str"],[y.JSON.toString(),"json"]]);static BIG_INT_TYPES=[y.INT64,y.UINT64,y.TIMESTAMP];static z=a.z.union([a.z.string().transform(e=>new y(e)),a.z.instanceof(y)])},ds=class $ extends Dt{constructor(e){pe(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return pe(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return pe(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return pe(e)&&(e=e.value),new $(gn(this.valueOf(),e.valueOf()))}sub(e){return pe(e)&&(e=e.value),new $(mn(this.valueOf(),e.valueOf()))}mult(e){return new $(Ie(this.valueOf(),e))}div(e){return new $(wn(this.valueOf(),e))}truncate(e){return new $(Math.trunc(this.valueOf()/new $(e).valueOf())*new $(e).valueOf())}remainder(e){return $.bytes(this.valueOf()%new $(e).valueOf())}get gigabytes(){return this.valueOf()/$.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/$.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/$.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/$.TERABYTE.valueOf()}toString(){const e=this.truncate($.TERABYTE),r=this.truncate($.GIGABYTE),n=this.truncate($.MEGABYTE),s=this.truncate($.KILOBYTE),i=this.truncate($.BYTE),o=e,c=r.sub(e),l=n.sub(r),u=s.sub(n),h=i.sub(s);let f="";return o.isZero||(f+=`${o.terabytes}TB `),c.isZero||(f+=`${c.gigabytes}GB `),l.isZero||(f+=`${l.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new $(e)}static BYTE=new $(1);static kilobytes(e=1){return $.bytes(new $(e).valueOf()*1e3)}static KILOBYTE=$.kilobytes(1);static megabytes(e=1){return $.kilobytes(new $(e).valueOf()*1e3)}static MEGABYTE=$.megabytes(1);static gigabytes(e=1){return $.megabytes(new $(e).valueOf()*1e3)}static GIGABYTE=$.gigabytes(1);static terabytes(e){return $.gigabytes(new $(e).valueOf()*1e3)}static TERABYTE=$.terabytes(1);static ZERO=new $(0);static z=a.z.union([a.z.number().transform(e=>new $(e)),a.z.instanceof($)]);get isZero(){return this.valueOf()===0}};a.z.object({start:a.z.number(),end:a.z.number()});a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);const zo=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof P||t instanceof U||t instanceof Date},Cd=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):Qr(r,-n),Qr=(t,e)=>e==0?t:t==0?e:typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:Number(t)+Number(e),jd=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function $d(t){return typeof t=="string"&&jd.test(t)}const J=[];for(let t=0;t<256;++t)J.push((t+256).toString(16).slice(1));function Md(t,e=0){return(J[t[e+0]]+J[t[e+1]]+J[t[e+2]]+J[t[e+3]]+"-"+J[t[e+4]]+J[t[e+5]]+"-"+J[t[e+6]]+J[t[e+7]]+"-"+J[t[e+8]]+J[t[e+9]]+"-"+J[t[e+10]]+J[t[e+11]]+J[t[e+12]]+J[t[e+13]]+J[t[e+14]]+J[t[e+15]]).toLowerCase()}function Ud(t,e=0){const r=Md(t,e);if(!$d(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const To=(t,e)=>Ud(t,e),Re=-1,Zd=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Pd=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),fs=10,_d=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Oo="sy_x_telem_series";let So=class qe{key;discriminator=Oo;dataType;sampleOffset;gl;_data;timeRange=er.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Re;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:er.z.optional(),dataType:q.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([Zd,Pd,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:Ad.optional().default("static").optional()});static z=qe.crudeZ.transform(e=>new qe(e));constructor(e){Rd(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:c=1n,key:l=Nd(),data:u}=e;if(Dd(u)){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.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=zo(u),f=Array.isArray(u);if(r!=null)this.dataType=new q(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||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=q.STRING;else if(typeof d=="number")this.dataType=q.FLOAT64;else if(typeof d=="bigint")this.dataType=q.INT64;else if(typeof d=="boolean")this.dataType=q.BOOLEAN;else if(d instanceof P||d instanceof Date||d instanceof P)this.dataType=q.TIMESTAMP;else if(typeof d=="object")this.dataType=q.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new q(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const v=d[0];(v instanceof P||v instanceof Date||v instanceof U)&&(d=d.map(x=>new P(x).valueOf())),this.dataType.equals(q.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
2
- `)}
3
- `).buffer):this.dataType.equals(q.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(x=>us.encodeString(x)).join(`
4
- `)}
5
- `).buffer):this.dataType.usesBigInt&&typeof v=="number"?this._data=new this.dataType.Array(d.map(x=>BigInt(Math.round(x)))).buffer:!this.dataType.usesBigInt&&typeof v=="bigint"?this._data=new this.dataType.Array(d.map(Number)).buffer:this._data=new this.dataType.Array(d).buffer}this.key=l,this.alignment=o,this.alignmentMultiple=c,this.sampleOffset=s??0,this.timeRange=n??er.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new q(r).Array(e),i=new qe({data:s.buffer,dataType:r,...n});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn("cannot release a series 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===Re)return 0;const r=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,r);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===Re)return 0;const r=this.capacity-this.writePos,n=e.sub(0,r);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.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===Re?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
6
- `).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(q.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(us.decodeString(r)))}get byteCapacity(){return new ds(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Re?this.byteCapacity:this.dataType.isVariable?new ds(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Re?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const r=[0];return this.data.forEach((n,s)=>{n===fs&&(e++,r.push(s+1))}),this._cachedIndexes=r,this.cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=Cd(this.dataType,e,this.data[s],r);return new qe({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(q.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){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.calcRawMax(),Qr(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(q.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){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.calcRawMin(),Qr(this.cachedMin,this.sampleOffset))}get bounds(){return lt(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){const r=e.cachedMin??e.calcRawMin();r<this.cachedMin&&(this.cachedMin=r)}if(this.cachedMax!=null){const r=e.cachedMax??e.calcRawMax();r>this.cachedMax&&(this.cachedMax=r)}}atAlignment(e,r){const n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(r===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,r)}at(e,r=!1){if(this.dataType.isVariable)return this.atVariable(e,r??!1);if(this.dataType.equals(q.UUID))return this.atUUID(e,r);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return Qr(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=To(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(r)throw new Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,r){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],s=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]===fs){if(e===0){s=o;break}n=o+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(n,s);return this.dataType.equals(q.STRING)?new TextDecoder().decode(i):lo(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=Hh(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=s(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(q.FLOAT32)&&!this.dataType.equals(q.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:s}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Re){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Re}as(e){return _d(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:si(this.alignmentBounds.lower),upper:si(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return lt(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}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 Ld(this);return this.dataType.equals(q.JSON)?new Bd(e):e}return this.dataType.equals(q.UUID)?new Fd(this):new qd(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new ni(this,e,r??this.length)}subAlignmentIterator(e,r){const n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),s=Math.ceil(Number(r-this.alignment)/Number(this.alignmentMultiple));return new ni(this,n,s)}subBytes(e,r){if(e>=0&&(r==null||r>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,r);return new qe({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,r,n){if(r<=0&&(n==null||n>=this.length))return this;let s;return e?s=this.data.subarray(r,n):s=this.data.slice(r,n),new qe({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new qe({data:this.buffer,dataType:this.dataType,timeRange:er.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)e+=`${this.at(r)?.toString()}`,e+=",";e+="...,";for(let r=-5;r<0;r++)e+=this.at(r)?.toString(),r<-1&&(e+=",")}return e+="])",e}};const Rd=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof So?!0:zo(t),Dd=Ed(Oo,So);class ni{series;end;index;constructor(e,r,n){this.series=e;const s=lt(0,e.length+1);this.end=Xa(s,n),this.index=Xa(s,r)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}let Ld=class{series;index;decoder;constructor(t){if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==fs;)this.index++;const r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}},Bd=class ko{wrapped;static schema=a.z.record(a.z.string(),a.z.unknown());constructor(e){this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:us.decodeString(e.value,ko.schema)}}},Fd=class{series;index;data;density;constructor(t){if(!t.dataType.equals(q.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=t,this.index=0,this.data=new Uint8Array(t.buffer),this.density=q.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=To(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}},qd=class{series;index;constructor(t){this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}};const si=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}};a.z.object({key:a.z.string(),value:a.z.string()});a.z.record(a.z.union([a.z.number(),a.z.string(),a.z.symbol()]),a.z.unknown());const Yd=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Yd();const Vd=["macOS","Windows","Linux"],Hd=["macos","windows","linux"],Wd={macos:"macOS",windows:"Windows",linux:"Linux"};a.z.enum(Vd).or(a.z.enum(Hd).transform(t=>Wd[t]));const Gd=(...t)=>t.map(No).join(""),No=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Kd=t=>t.endsWith("/")?t.slice(0,-1):t,Jd=(t,e="")=>t===null?"":`?${Object.entries(t).filter(([,r])=>r==null?!1:Array.isArray(r)?r.length>0:!0).map(([r,n])=>`${e}${r}=${n}`).join("&")}`;let Xd=class en{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){this.protocol=n,this.host=e,this.port=r,this.path=No(s)}replace(e){return new en({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new en({...this,pathPrefix:Gd(this.path,e)})}toString(){return Kd(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new en({host:"unknown",port:0})};const Qd=async t=>await new Promise(e=>setTimeout(e,U.fromMilliseconds(t).milliseconds));class ef{config;retries;interval;constructor(e){this.config={baseInterval:new U(e?.baseInterval??U.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??Qd},this.retries=0,this.interval=new U(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:r,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(r),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}}const tf=a.z.object({baseInterval:U.z.optional(),maxRetries:a.z.number().optional(),scale:a.z.number().optional()}),rf=Object.freeze(Object.defineProperty({__proto__:null,Breaker:ef,breakerConfigZ:tf},Symbol.toStringTag,{value:"Module"})),nf=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Eo=a.z.string().regex(nf),It=a.z.number().min(0).max(255),Ao=a.z.number().min(0).max(1),Io=a.z.tuple([It,It,It,Ao]),sf=a.z.tuple([It,It,It]),af=a.z.object({rgba255:Io}),of=a.z.number().min(0).max(360),cf=a.z.number().min(0).max(100),lf=a.z.number().min(0).max(100),uf=a.z.tuple([of,cf,lf,Ao]),Qs=a.z.union([Eo,sf,Io,uf,af]),hf=Qs.transform(t=>ea(t)),ea=(t,e=1)=>{if(t=Qs.parse(t),typeof t=="string")return df(t,e);if(Array.isArray(t)){if(t.length<3||t.length>4)throw new Error(`Invalid color: [${t.join(", ")}]`);return t.length===3?[...t,e]:t}return t.rgba255},df=(t,e=1)=>(t=Eo.parse(t),t=ff(t),[Fr(t,0),Fr(t,2),Fr(t,4),t.length===8?Fr(t,6)/255:e]),Fr=(t,e)=>parseInt(t.slice(e,e+2),16),ff=t=>t.startsWith("#")?t.slice(1):t;ea("#000000");ea("#ffffff");const pf=a.z.object({key:a.z.string(),color:Qs,position:a.z.number(),switched:a.z.boolean().optional()});a.z.array(pf);const yf=a.z.object({key:a.z.string(),name:a.z.string(),color:hf});a.z.object({key:a.z.string(),name:a.z.string(),swatches:a.z.array(yf)});a.z.int().min(0).max(255);a.z.object({name:a.z.string(),key:a.z.string()});const mf=t=>Object.getOwnPropertySymbols(globalThis).includes(t),gf=(t,e)=>{const r=Symbol.for(t);if(!mf(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},xo="sy_x_error",wf=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(t):e instanceof Error?e.message.startsWith(t):typeof e!="string"?!1:e.startsWith(t),Tr=t=>class tr extends Error{static discriminator=xo;discriminator=tr.discriminator;static TYPE=t;type=tr.TYPE;static matches=wf(t);matches=tr.matches;constructor(r,n){super(r,n),this.name=tr.TYPE}static sub(r){return Tr(`${t}.${r}`)}},Co=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==xo)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},Ot="unknown",ps="nil";let bf=class{providers=[];register(t){this.providers.push(t)}encode(t){if(t==null)return{type:ps,data:""};if(Co(t))for(const e of this.providers){const r=e.encode(t);if(r!=null)return r}if(t instanceof Error)return{type:Ot,data:t.message};if(typeof t=="string")return{type:Ot,data:t};try{return{type:Ot,data:JSON.stringify(t)}}catch{return{type:Ot,data:"unable to encode error information"}}}decode(t){if(t==null||t.type===ps)return null;if(t.type===Ot)return new ys(t.data);for(const e of this.providers){const r=e.decode(t);if(r!=null)return r}return new ys(t.data)}};const ta=gf("synnax-error-registry",()=>new bf),vf=({encode:t,decode:e})=>ta().register({encode:t,decode:e}),zf=t=>ta().encode(t),Tf=t=>t==null?null:ta().decode(t);let ys=class extends Tr("unknown"){};const Of=a.z.object({type:a.z.string(),data:a.z.string()});class Sf extends Tr("canceled"){}let kf=class extends Tr("not_implemented"){};const Ge=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Sf,NONE:ps,NotImplemented:kf,UNKNOWN:Ot,Unknown:ys,createTyped:Tr,decode:Tf,encode:zf,isTyped:Co,payloadZ:Of,register:vf},Symbol.toStringTag,{value:"Module"})),Nf=a.object({jsonrpc:a.literal("2.0"),method:a.string(),params:a.any().optional(),id:a.union([a.string(),a.number(),a.null()]).optional()}),jo=a.object({jsonrpc:a.literal("2.0"),id:a.union([a.string(),a.number(),a.null()])}),Ef=jo.extend({result:a.json()}),Af=jo.extend({error:a.object({code:a.number().int(),message:a.string().optional(),data:a.json().optional()})}),If=a.union([Ef,Af]);a.union([Nf,If]);const xf=a.uuid();a.object({key:xf,name:a.string().min(1),color:a.string()});a.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/);const Cf=["standard","scientific","engineering"];a.z.enum(Cf);a.z.enum(["success","info","warning","error","loading","disabled"]);a.z.object({stack:a.z.string(),error:a.z.instanceof(Error)});let Or=class extends Ge.createTyped("freighter"){},ze=class extends Or.sub("eof"){constructor(){super("EOF")}},$t=class extends Or.sub("stream_closed"){constructor(){super("StreamClosed")}},Ke=class extends Or.sub("unreachable"){url;constructor(t={}){const{message:e="Unreachable",url:r=Xd.UNKNOWN}=t;super(e),this.url=r}};const jf=t=>{if(!t.type.startsWith(Or.TYPE))return null;if(ze.matches(t))return{type:ze.TYPE,data:"EOF"};if($t.matches(t))return{type:$t.TYPE,data:"StreamClosed"};if(Ke.matches(t))return{type:Ke.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},$f=t=>{if(!t.type.startsWith(Or.TYPE))return null;switch(t.type){case ze.TYPE:return new ze;case $t.TYPE:return new $t;case Ke.TYPE:return new Ke;default:throw new Ge.Unknown(`Unknown error type: ${t.data}`)}};Ge.register({encode:jf,decode:$f});class $o{middleware=[];use(...e){this.middleware.push(...e)}async executeMiddleware(e,r){let n=0;const s=async i=>{if(n===this.middleware.length)return await r(i);const o=this.middleware[n];return n++,await o(i,s)};return await s(e)}}const Mo="Content-Type",Mf=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","EPIPE","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]),Uf=t=>{const e=t?.cause?.code??t?.code??t?.errno;if(typeof e=="string"&&Mf.has(e))return!0;if(t.name==="TypeError"){const r=String(t.message||"").toLowerCase();if(/load failed|failed to fetch|networkerror|network error/.test(r))return!0}return t?.name==="AbortError"||t?.code,!1},Zf=400;class Pf extends $o{endpoint;encoder;constructor(e,r,n=!1){return super(),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=r,new Proxy(this,{get:(s,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(s,i,o)})}get headers(){return{[Mo]:this.encoder.contentType}}async send(e,r,n,s){r=n?.parse(r);let i=null;const o=this.endpoint.child(e),c={};c.method="POST",c.body=this.encoder.encode(r??{});const[,l]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async u=>{const h={...u,params:{}};c.headers={...this.headers,...u.params};let f;try{f=await fetch(u.target,c)}catch(v){if(!(v instanceof Error))throw v;return[h,Uf(v)?new Ke({url:o}):v]}const d=await f.arrayBuffer();if(f?.ok)return s!=null&&(i=this.encoder.decode(d,s)),[h,null];try{if(f.status!==Zf)return[h,new Error(f.statusText)];const v=this.encoder.decode(d,Ge.payloadZ),x=Ge.decode(v);return[h,x]}catch(v){return[h,new Error(`[freighter] - failed to decode error: ${f.statusText}: ${v.message}`)]}});if(l!=null)return[null,l];if(i==null)throw new Error("Response must be defined");return[i,null]}}const _f=(t,e)=>{class r{wrapped;constructor(s){this.wrapped=s}use(...s){this.wrapped.use(...s)}async send(s,i,o,c){const l=new rf.Breaker(e);do{const[u,h]=await this.wrapped.send(s,i,o,c);if(h==null)return[u,null];if(!Ke.matches(h))return[null,h];if(console.warn(`[freighter] ${l.retryMessage}`,h),!await l.wait())return[u,h]}while(!0)}}return new r(t)},g=async(t,e,r,n,s)=>{const[i,o]=await t.send(e,r,n,s);if(o!=null)throw o;return i},Rf=a.z.object({type:a.z.enum(["data","close","open"]),payload:a.z.unknown(),error:a.z.optional(Ge.payloadZ)});class Df{codec;reqSchema;resSchema;ws;serverClosed;sendClosed;receiveDataQueue=[];receiveCallbacksQueue=[];constructor(e,r,n,s){this.codec=r,this.reqSchema=n,this.resSchema=s,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 Ge.decode(e.error)}return null}send(e){if(this.serverClosed!=null)return new ze;if(this.sendClosed)throw new $t;return this.ws.send(this.codec.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");if(this.serverClosed=Ge.decode(e.error),this.serverClosed==null)throw new Error("Message error must be defined");return[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.codec.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,r)=>this.receiveCallbacksQueue.push({resolve:e,reject:r}))}addMessage(e){const r=this.receiveCallbacksQueue.shift();r!=null?r.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(e){this.addMessage(this.codec.decode(e.data,Rf))}onClose(e){this.addMessage({type:"close",error:{type:e.code===Bf?ze.TYPE:$t.TYPE,data:""}})}}const Lf="freighterctx",Bf=1e3;let Ff=class ms extends $o{baseUrl;encoder;secure;static MESSAGE_TYPE="arraybuffer";constructor(e,r,n=!1){super(),this.secure=n,this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=r}withCodec(e){const r=new ms(this.baseUrl,e,this.secure);return r.use(...this.middleware),r}async stream(e,r,n){let s;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const c=new WebSocket(this.buildURL(e,o)),l={...o,params:{}};c.binaryType=ms.MESSAGE_TYPE;const u=await this.wrapSocket(c,r,n);return u instanceof Error?[l,u]:(s=u,[l,null])});if(i!=null)throw i;return s}buildURL(e,r){const n=Jd({[Mo]:this.encoder.contentType,...r.params},Lf);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(s=>{e.onopen=()=>{const i=new Df(e,this.encoder,r,n);i.receiveOpenAck().then(o=>{o!=null?s(o):s(i)}).catch(o=>s(o))},e.onerror=i=>{const o=i;s(new Error(o.message))}})}};const Uo=t=>a.union([a.union([a.null(),a.undefined()]).transform(()=>[]),t.array()]),qf=t=>Array.isArray(t)?t:t==null?[]:[t],Zo=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>Zo(s,i),t??[]);if(t==null)return[e];const r=t.findIndex(s=>s==e),n=[...t];return r===-1?n.push(e):n[r]=e,n},Yf=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r)):t.filter(r=>r!=e)}),Po=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>Po(s,i),t??[]);if(t==null)return[e];const r=t.findIndex(s=>s.key===e.key),n=[...t];return r===-1?n.push(e):n[r]=e,n},Vf=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r.key)):t.filter(r=>r.key!==e)}),b=Object.freeze(Object.defineProperty({__proto__:null,nullableZ:Uo,remove:Yf,removeKeyed:Vf,toArray:qf,upsert:Zo,upsertKeyed:Po},Symbol.toStringTag,{value:"Module"})),Hf=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},bn=t=>{const e=(r,n=gs)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!qn(r))return r;n=Kf(n);const s={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let c=i[o];const l=t(o);n.recursive&&(qn(c)?ii(c)||(c=e(c,n)):n.recursiveInArray&&ai(c)&&(c=[...c].map(u=>{let h=u;return qn(u)?ii(h)||(h=e(u,n)):ai(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},ra=bn(Hf),Wf=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),_o=bn(Wf),Ro=t=>t.length===0?t:t[0].toUpperCase()+t.slice(1),Gf=[Number,String,Uint8Array],gs={recursive:!0,recursiveInArray:!0},Kf=(t=gs)=>(t.recursive==null?t=gs:t.recursiveInArray??=!1,t),ai=t=>t!=null&&Array.isArray(t),qn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ii=t=>Gf.some(e=>t instanceof e),Jf=t=>t.replace(/[\s_]+/g,"-").replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}-${n.toLowerCase()}`).toLowerCase(),Xf=bn(Jf),Qf=t=>{if(t.length===0)return t;let e=t.replace(/[_-]/g," ");return e=e.replace(/([a-z0-9])([A-Z])/g,(r,n,s)=>`${n} ${s}`),e=e.replace(/([A-Z]+)([A-Z][a-z])/g,(r,n,s)=>`${n} ${s}`),e=e.replace(/\s+/g," ").trim(),e=e.replace(/\b\w/g,r=>r.toUpperCase()),e},ep=bn(Qf),tp=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:_o,capitalize:Ro,snakeToCamel:ra,toKebab:Xf,toProperNoun:ep},Symbol.toStringTag,{value:"Module"})),Do=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);let Lo=class{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=ra(r);return e!=null?e.parse(n):n}encodeString(t){const e=_o(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}},Bo=class{contentType="text/csv";encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e)}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!Do(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),r=[e.join(",")];return t.forEach(n=>{const s=e.map(i=>JSON.stringify(n[i]??""));r.push(s.join(","))}),r.join(`
7
- `)}decodeString(t,e){const[r,...n]=t.trim().split(`
8
- `).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const s=r.split(",").map(o=>o.trim()),i={};return s.forEach(o=>{i[o]=[]}),n.forEach(o=>{const c=o.split(",").map(l=>l.trim());s.forEach((l,u)=>{const h=this.parseValue(c[u]);h!=null&&i[l].push(h)})}),e!=null?e.parse(i):i}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}},Fo=class{contentType="text/plain";encode(t){if(typeof t!="string")throw new Error("TextCodec.encode payload must be a string");return new TextEncoder().encode(t)}decode(t,e){const r=new TextDecoder().decode(t);return e!=null?e.parse(r):r}};const or=new Lo,rp=new Bo,np=new Fo,sp=[or],pt=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:Bo,CSV_CODEC:rp,ENCODERS:sp,JSONCodec:Lo,JSON_CODEC:or,TEXT_CODEC:np,TextCodec:Fo},Symbol.toStringTag,{value:"Module"})),ws=t=>[...new Set(t)],ap=(t,e,r=!0)=>{const n=new Map;return t.forEach(s=>{const i=e(s);if(n.has(i)){if(r)return;n.delete(i)}n.set(i,s)}),Array.from(n.values())},oi=Object.freeze(Object.defineProperty({__proto__:null,by:ap,unique:ws},Symbol.toStringTag,{value:"Module"})),ye=t=>t!=null&&typeof t=="object"&&"value"in t;let Lt=class{value;constructor(t){this.value=t}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}};const ip=t=>t!=null&&typeof t=="object"&&"toString"in t,Sr=(t,e=!1)=>{const r=ip(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?Yo(n):n},op=(t,e,r)=>{const n=Sr(e[t],r);return(s,i)=>n(s[t],i[t])},cp=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,qo=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=Sr(t[0]),n=[...t].sort(r),s=[...e].sort(r);return n.every((i,o)=>i===s[o])?0:-1},lp=(t,e)=>{const r=ws(t),n=ws(e);return qo(r,n)},up=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,Yo=t=>(e,r)=>t(r,e),yt=0,Me=-1,Ue=1,Vo=t=>t<yt,Ho=t=>t>yt,hp=t=>t>=yt,Wo=t=>t===yt,dp=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.-]+/g,"").match(r),s=e.replace(/[\s_.-]+/g,"").match(r);if(!n||!s)return 0;for(let i=0;i<Math.min(n.length,s.length);i++){const o=n[i],c=s[i];if(isNaN(Number(o))&&isNaN(Number(c))){const l=o.localeCompare(c);if(l!==0)return l}else if(!isNaN(Number(o))&&!isNaN(Number(c))){const l=Number(o)-Number(c);if(l!==0)return l}else return isNaN(Number(o))?-1:1}return n.length-s.length},vn=a.z.tuple([a.z.number(),a.z.number()]);a.z.tuple([a.z.bigint(),a.z.bigint()]);const Go=a.z.object({width:a.z.number(),height:a.z.number()}),fp=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),pp=["width","height"];a.z.enum(pp);const yp=["start","center","end"],mp=["signedWidth","signedHeight"];a.z.enum(mp);const cr=a.z.object({x:a.z.number(),y:a.z.number()}),Ko=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),Jo=["x","y"],Xo=a.z.enum(Jo),na=["top","right","bottom","left"],gp=a.z.enum(na),Qo=["left","right"],sa=a.z.enum(Qo),ec=["top","bottom"],aa=a.z.enum(ec),ia=["center"],bs=a.z.enum(ia),wp=[...na,...ia],oa=a.z.enum(wp);a.z.enum(yp);const bp=["first","last"];a.z.enum(bp);const vp=a.z.object({lower:a.z.number(),upper:a.z.number()}),zp=a.z.object({lower:a.z.bigint(),upper:a.z.bigint()});a.z.union([vp,vn]);a.z.union([zp,vn]);a.z.enum([...Xo.options,...oa.options]);a.z.enum(["x","left","right"]);a.z.enum(["y","top","bottom"]);const Tp=a.z.union([Xo,oa,a.z.instanceof(String)]),Bt=t=>(e,r)=>{if(typeof e=="bigint"){if(sn(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},We=Bt((t,e)=>t-e),Ft=Bt((t,e)=>t+e),Op=(t,e,r=1e-4)=>Math.abs(t-e)<r,vs=(t,e)=>{const r=typeof t=="bigint",n=typeof e=="bigint";return r&&n?t===e:r&&sn(e)?t===BigInt(e):n&&sn(t)?e===BigInt(t):t===e},Sp=t=>{const e=10**Math.floor(Math.log10(t));return Math.round(t/e)*e},tc=Bt((t,e)=>t<=e?t:e),sn=t=>typeof t=="bigint"?!0:Number.isInteger(t),kp=Bt((t,e)=>t>=e?t:e),rc=t=>typeof t=="bigint"?t<0n?-t:t:t<0?-t:t,be=Bt((t,e)=>t*e),kr=Bt((t,e)=>t/e),K=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},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 n.lower=t.lower,n.upper=t.upper;return r?.makeValid?Np(n):n},Np=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,ci=(t,e)=>{const r=K(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e},qr=(t,e)=>{const r=K(t);if(typeof e=="number"||typeof e=="bigint")return e>=r.lower&&e<r.upper;const n=K(e);return n.lower>=r.lower&&n.upper<=r.upper},nc=t=>{const e=K(t);return e.upper-e.lower},Ep=t=>({lower:Math.min(...t.map(e=>K(e).lower)),upper:Math.max(...t.map(e=>K(e).upper))}),Ap=(t,e,r)=>{const n=t.map(c=>K(c)),s=r>0?1:r<0?-1:0;if(s===0)return e;let i=r,o=e;for(;vs(i,0)===!1;){const c=n.findIndex(l=>s>0?o>=l.lower&&o<l.upper:o>l.lower&&o<=l.upper);if(c!==-1){const l=n[c];let u;if(s>0?u=We(l.upper,o):u=We(o,l.lower),u>0){const h=tc(rc(i),u);if(o=Ft(o,s>0?h:-h),i=We(i,s>0?h:-h),vs(i,0))return o;continue}}if(s>0){const l=n.filter(u=>u.lower>o);if(l.length>0)o=l[0].lower;else return o}else{const l=n.filter(u=>u.upper<o);if(l.length>0)o=l[l.length-1].upper;else return o}}return o},Ip=(t,e,r)=>{const n=t.map(o=>K(o));if(e===r)return typeof e=="bigint"?0n:0;const s=e<r?K([e,r]):K([r,e]);let i=typeof e=="bigint"?0n:0;for(const o of n){const c=o.lower>s.lower?o.lower:s.lower,l=o.upper<s.upper?o.upper:s.upper;if(c<l){const u=l-c;i=i+u}}return i},xp=sa,Cp=aa,jp=bs,$p={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},Mp={top:"left",right:"top",bottom:"right",left:"bottom",center:"center"},Up=Tp,Je=t=>t instanceof String||!Jo.includes(t)?t:t==="x"?"left":"top",Zp=t=>$p[Je(t)],Pp=t=>Mp[Je(t)],lr=t=>{const e=Je(t);return e==="top"||e==="bottom"?"y":"x"},_p=a.z.object({x:sa.or(bs),y:aa.or(bs)}),sc=a.z.object({x:sa,y:aa}),ca=Object.freeze({x:"left",y:"top"}),ac=Object.freeze({x:"right",y:"top"}),ic=Object.freeze({x:"left",y:"bottom"}),oc=Object.freeze({x:"right",y:"bottom"}),la=Object.freeze({x:"center",y:"center"}),cc=Object.freeze({x:"center",y:"top"}),lc=Object.freeze({x:"center",y:"bottom"}),uc=Object.freeze({x:"right",y:"center"}),hc=Object.freeze({x:"left",y:"center"}),Rp=Object.freeze([hc,uc,cc,lc,ca,ac,ic,oc,la]),dc=(t,e)=>t.x===e.x&&t.y===e.y,Dp=(t,e)=>{if(typeof e=="object"){let r=!0;return"x"in e&&(t.x===e.x||(r=!1)),"y"in e&&(t.y===e.y||(r=!1)),r}return t.x===e||t.y===e},Lp=t=>[t.x,t.y],tn=t=>lr(Je(t))==="x",Bp=t=>lr(Je(t))==="y",Fp=t=>`${t.x}${Ro(t.y)}`,qp=(t,e)=>{let r,n;if(typeof t=="object"&&"x"in t?(r=t.x,n=t.y):(r=Je(t),n=Je(e??t)),lr(r)===lr(n)&&r!=="center"&&n!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${r.toString()} - ${n.toString()}`);const s={...la};return r==="center"?tn(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:n==="center"?tn(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:tn(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r],s},Yp=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:lc,BOTTOM_LEFT:ic,BOTTOM_RIGHT:oc,CENTER:la,CENTER_LEFT:hc,CENTER_LOCATIONS:ia,CENTER_RIGHT:uc,OUTER_LOCATIONS:na,TOP_CENTER:cc,TOP_LEFT:ca,TOP_RIGHT:ac,XY_LOCATIONS:Rp,X_LOCATIONS:Qo,Y_LOCATIONS:ec,center:jp,construct:Je,constructXY:qp,corner:sc,crude:Up,direction:lr,isX:tn,isY:Bp,location:oa,outer:gp,rotate90:Pp,swap:Zp,x:xp,xy:_p,xyCouple:Lp,xyEquals:dc,xyMatches:Dp,xyToString:Fp,y:Cp},Symbol.toStringTag,{value:"Module"})),zs=a.z.union([a.z.number(),cr,vn,Go,fp,Ko]),R=(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}},ht=Object.freeze({x:0,y:0}),Vp=Object.freeze({x:1,y:1}),Hp=Object.freeze({x:1/0,y:1/0}),Wp=Object.freeze({x:NaN,y:NaN}),fc=(t,e,r=0)=>{const n=R(t),s=R(e);return r===0?n.x===s.x&&n.y===s.y:Math.abs(n.x-s.x)<=r&&Math.abs(n.y-s.y)<=r},Gp=t=>fc(t,ht),ua=(t,e,r)=>{const n=R(t),s=R(e,r);return{x:n.x*s.x,y:n.y*s.y}},pc=(t,e)=>{const r=R(t);return{x:r.x+e,y:r.y}},yc=(t,e)=>{const r=R(t);return{x:r.x,y:r.y+e}},mc=(t,e,r,...n)=>{if(typeof e=="string"){if(typeof r!="number")throw new Error("The value must be a number.");return e==="x"?pc(t,r):yc(t,r)}if(typeof e=="object"&&"x"in e&&typeof e.x=="string"){const s=R(r),i=R(t);return e.x==="left"?s.x=-s.x:e.x==="center"&&(s.x=0),e.y==="top"?s.y=-s.y:e.y==="center"&&(s.y=0),{x:i.x+s.x,y:i.y+s.y}}return[t,e,r??ht,...n].reduce((s,i)=>{const o=R(i);return{x:s.x+o.x,y:s.y+o.y}},ht)},Kp=(t,e,r)=>{const n=R(t);return e==="x"?{x:r,y:n.y}:{x:n.x,y:r}},Jp=(t,e)=>{const r=R(t),n=R(e);return Math.sqrt((r.x-n.x)**2+(r.y-n.y)**2)},Xp=(t,e)=>{const r=R(t),n=R(e);return{x:n.x-r.x,y:n.y-r.y}},Qp=t=>{const e=R(t);return Number.isNaN(e.x)||Number.isNaN(e.y)},ey=t=>{const e=R(t);return Number.isFinite(e.x)&&Number.isFinite(e.y)},ty=t=>{const e=R(t);return[e.x,e.y]},ry=t=>{const e=R(t);return{left:e.x,top:e.y}},ny=(t,e=0)=>{const r=R(t);return{x:Number(r.x.toFixed(e)),y:Number(r.y.toFixed(e))}},rr=(t,e)=>{const r=R(t),n=R(e);return{x:r.x-n.x,y:r.y-n.y}},nr=t=>{const e=R(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:-e.y/r,y:e.x/r}},gc=t=>{const e=R(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:e.x/r,y:e.y/r}},wc=(...t)=>{const e=t.reduce((r,n)=>mc(r,n),ht);return ua(e,1/t.length)},sy=(t,e)=>{const r=[];for(let n=0;n<t.length;n++){const s=t[n];let i,o,c,l;if(n===0){const u=t[n+1],h=rr(u,s);o=nr(h),c=o,l=e}else if(n===t.length-1){const u=t[n-1],h=rr(s,u);i=nr(h),c=i,l=e}else{const u=t[n-1],h=t[n+1],f=rr(s,u),d=rr(h,s);i=nr(f),o=nr(d);const v=Math.acos((f.x*d.x+f.y*d.y)/(Math.hypot(f.x,f.y)*Math.hypot(d.x,d.y))),x=Math.sin(v/2);x===0?l=e:l=e/x,c=gc(wc(i,o))}r.push(ua(c,l))}return r},ay=t=>{const e=R(t);return{x:e.y,y:e.x}},iy=t=>{const e=R(t);return{x:Math.round(e.x),y:Math.round(e.y)}},oy=t=>{const e=R(t);return{x:1/e.x,y:1/e.y}},ha=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Hp,NAN:Wp,ONE:Vp,ZERO:ht,average:wc,calculateMiters:sy,clientXY:Ko,construct:R,couple:ty,crudeZ:zs,css:ry,distance:Jp,equals:fc,isFinite:ey,isNan:Qp,isZero:Gp,normal:nr,normalize:gc,reciprocal:oy,round:iy,scale:ua,set:Kp,sub:rr,swap:ay,translate:mc,translateX:pc,translateY:yc,translation:Xp,truncate:ny,xy:cr},Symbol.toStringTag,{value:"Module"})),Yr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:Yr,left:Yr,width:Yr,height:Yr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:cr,two:cr,root:sc});const da=(t,e,r=0,n=0,s)=>{const i={one:{...ht},two:{...ht},root:s??ca};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Yn=t=>{const e=da(t);return{lower:e.one.x,upper:e.two.x}},Vn=t=>{const e=da(t);return{lower:e.one.y,upper:e.two.y}},cy=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,ly=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([Go,ly,cr,vn]);const uy=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;a.z.object({offset:zs,scale:zs});a.z.object({offset:a.z.number(),scale:a.z.number()});const hy=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],dy=t=>(e,r,n,s)=>[e,s?n/t:n*t],fy=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,l=i-s,u=c-o;if(r==="dimension")return[t,n*(u/l)];const h=(n-s)*(u/l)+o;return[t,h]},py=t=>(e,r,n)=>[t,n],yy=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},my=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=uy(n,s,i),[e,n]};let li=class St{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new St().translate(e)}static magnify(e){return new St().magnify(e)}static scale(e,r){return new St().scale(e,r)}translate(e){const r=this.new(),n=hy(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=dy(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=K(e,r),s=this.new(),i=fy(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=K(e,r),s=this.new(),i=my(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=K(e,r),s=this.new(),i=py(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=yy();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new St;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new St};(class Ee{x;y;currRoot;constructor(e=new li,r=new li,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ee().translate(e,r)}static translateX(e){return new Ee().translateX(e)}static translateY(e){return new Ee().translateY(e)}static clamp(e){return new Ee().clamp(e)}static magnify(e){return new Ee().magnify(e)}static scale(e){return new Ee().scale(e)}static reBound(e){return new Ee().reBound(e)}translate(e,r){const n=R(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(cy(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!dc(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(Yn(e)),r.y=r.y.scale(Vn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(Yn(e)),r.y=this.y.reBound(Vn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Yn(e)),r.y=this.y.clamp(Vn(e)),r}copy(){const e=new Ee;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 da(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})}}static IDENTITY=new Ee});let bc=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const vc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",gy=`0123456789${vc}`,zc=11,wy=bc(vc,1),by=bc(gy,zc-1),fa=()=>`${wy()}${by()}`,vy=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:zc,create:fa},Symbol.toStringTag,{value:"Module"})),zy=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Ty=a.z.enum(["static","dynamic"]),Oy=2**8-1,Sy=2**16-1,ky=2**32-1,Ny=2n**64n-1n,Ey=2**64-1,Ay=-128,Iy=2**7-1,xy=-32768,Cy=2**15-1,jy=-2147483648,$y=2**31-1,My=-(2n**63n),an=2n**63n-1n,Uy=-9223372036854776e3,Tc=2**63-1,ui=365,Vr=30,Zy=a.z.union([a.z.tuple([a.z.int()]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12)]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12),a.z.int().min(1).max(31)])]),Oc=(t,e)=>{const r=new C(e);if(![N.DAY,N.HOUR,N.MINUTE,N.SECOND,N.MILLISECOND,N.MICROSECOND,N.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof C?new C(n):new N(n)};let C=class T extends Lt{constructor(e,r="UTC"){if(e==null)super(T.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*T.MILLISECOND.valueOf());else if(typeof e=="string")super(T.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(T.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=T.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===Tc?e=an:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=T.MAX:e=T.MIN)),ye(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(s.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let l=T.hours(parseInt(n??"00")).add(T.minutes(parseInt(s??"00"))).add(T.seconds(parseInt(o??"00"))).add(T.milliseconds(parseInt(c??"00")));return r==="local"&&(l=l.add(T.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return T.parseTimeString(e,r);if(e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let s=e,i=0;if(e.includes(".")){const u=e.split(".");s=u[0];const h=u[1]||"0";i=parseInt(h.padEnd(3,"0").slice(0,3))}const o=r==="local"?new Date(s.replace("T"," ")):new Date(`${s}Z`),c=BigInt(o.getTime())*T.MILLISECOND.valueOf(),l=BigInt(i)*T.MILLISECOND.valueOf();return c+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new T(BigInt(n.getTime())*T.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(T.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new N(BigInt(new Date().getTimezoneOffset())*T.MINUTE.valueOf())}static since(e){return new T().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new T(e).valueOf()}span(e){return this.range(e).span}range(e){return new B(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new T(e).valueOf()}afterEq(e){return this.valueOf()>=new T(e).valueOf()}before(e){return this.valueOf()<new T(e).valueOf()}beforeEq(e){return this.valueOf()<=new T(e).valueOf()}add(e){return new T(Ft(this.valueOf(),new N(e).valueOf()))}sub(e){return new T(We(this.valueOf(),new N(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(N.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(N.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(N.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(N.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new T(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new T(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new T(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new T(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new T(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new T(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new T(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new T(r)}toString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}remainder(e){return Oc(this,e)}get isToday(){return this.truncate(N.DAY).equals(T.now().truncate(N.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(N.days(30))?"shortDate":e.greaterThanOrEqual(N.DAY)?"dateTime":e.greaterThanOrEqual(N.HOUR)?"time":e.greaterThanOrEqual(N.SECOND)?"preciseTime":"ISOTime"}static now(){return new T(new Date)}static max(...e){let r=T.MIN;for(const n of e){const s=new T(n);s.after(r)&&(r=s)}return r}static min(...e){let r=T.MAX;for(const n of e){const s=new T(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new T(e,r)}static NANOSECOND=T.nanoseconds(1);static microseconds(e,r="UTC"){return T.nanoseconds(e*1e3,r)}static MICROSECOND=T.microseconds(1);static milliseconds(e,r="UTC"){return T.microseconds(e*1e3,r)}static MILLISECOND=T.milliseconds(1);static seconds(e,r="UTC"){return T.milliseconds(e*1e3,r)}static SECOND=T.seconds(1);static minutes(e,r="UTC"){return T.seconds(e*60,r)}static MINUTE=T.minutes(1);static hours(e,r="UTC"){return T.minutes(e*60,r)}static HOUR=T.hours(1);static days(e,r="UTC"){return T.hours(e*24,r)}static DAY=T.days(1);static MAX=new T(an);static MIN=new T(0);static ZERO=new T(0);static z=a.z.union([a.z.instanceof(T),a.z.object({value:a.z.bigint()}).transform(e=>new T(e.value)),a.z.string().transform(e=>new T(BigInt(e))),a.z.number().transform(e=>new T(e)),a.z.bigint().transform(e=>new T(e)),a.z.date().transform(e=>new T(e)),a.z.custom(e=>e instanceof N).transform(e=>new T(e)),Zy.transform(e=>new T(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}},N=class k extends Lt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),ye(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof k?e:e instanceof Hn?e.period:e instanceof C?new k(e):(ye(e)&&(e=e.value),["number","bigint"].includes(typeof e)?k.seconds(e):new k(e))}static fromMilliseconds(e){return e instanceof k?e:e instanceof Hn?e.period:e instanceof C?new k(e):(ye(e)&&(e=e.value),["number","bigint"].includes(typeof e)?k.milliseconds(e):new k(e))}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 Oc(this,e)}truncate(e){return new k(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(k.DAY),n=this.truncate(k.HOUR),s=this.truncate(k.MINUTE),i=this.truncate(k.SECOND),o=this.truncate(k.MILLISECOND),c=this.truncate(k.MICROSECOND),l=this.truncate(k.NANOSECOND),u=r,h=n.sub(r),f=s.sub(n),d=i.sub(s),v=o.sub(i),x=c.sub(o),j=l.sub(c);let w="";return u.isZero||(w+=`${u.days}d `),h.isZero||(w+=`${h.hours}h `),f.isZero||(w+=`${f.minutes}m `),d.isZero||(w+=`${d.seconds}s `),v.isZero||(w+=`${v.milliseconds}ms `),x.isZero||(w+=`${x.microseconds}µs `),j.isZero||(w+=`${j.nanoseconds}ns`),w.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new k(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(k.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,c=r.seconds,l=Math.floor(s/ui),u=Math.floor(s/Vr),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),v=Math.floor(o),x=Math.floor(c),j=n?"-":"";if(l>=1){let w=`${l}y`;if(l<2){const O=Math.floor(s%ui/Vr);O>0&&(w+=` ${O}mo`)}return j+w}if(h>=1&&s<Vr&&s%7===0){let w=`${h}w`;const O=Math.floor(s%7),I=Math.floor(i-h*7*24);return h<2&&(O>0?w+=` ${O}d`:I>0&&I<24&&(w+=` ${I}h`)),j+w}if(u>=1){let w=`${u}mo`;if(u<3){const O=Math.floor(s%Vr);O>0&&(w+=` ${O}d`)}return j+w}if(h>=1){let w=`${h}w`;const O=Math.floor(s%7),I=Math.floor(i-h*7*24);return h<2&&(O>0?w+=` ${O}d`:I>0&&I<24&&(w+=` ${I}h`)),j+w}if(f>=1){let w=`${f}d`;const O=Math.floor(i-f*24);return f<2&&O>0&&(w+=` ${O}h`),j+w}if(d>=1){let w=`${d}h`;if(d<3){const O=Math.floor(o-d*60);O>0&&(w+=` ${O}m`)}return j+w}if(v>=1){let w=`${v}m`;if(v<5){const O=Math.floor(c-v*60);O>0&&(w+=` ${O}s`)}return j+w}return`${j}${x}s`}mult(e){return new k(be(this.valueOf(),e))}div(e){return new k(kr(this.valueOf(),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()===0n}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 NANOSECOND=k.nanoseconds(1);static microseconds(e=1){return k.nanoseconds(be(e,1e3))}static MICROSECOND=k.microseconds(1);static milliseconds(e=1){return k.microseconds(be(e,1e3))}static MILLISECOND=k.milliseconds(1);static seconds(e=1){return k.milliseconds(be(e,1e3))}static SECOND=k.seconds(1);static minutes(e=1){return k.seconds(be(e,60))}static MINUTE=k.minutes(1);static hours(e){return k.minutes(be(e,60))}static HOUR=k.hours(1);static days(e){return k.hours(be(e,24))}static DAY=k.days(1);static MAX=new k(an);static MIN=new k(0);static ZERO=new k(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new k(e.value)),a.z.string().transform(e=>new k(BigInt(e))),a.z.number().transform(e=>new k(e)),a.z.bigint().transform(e=>new k(e)),a.z.instanceof(k),a.z.instanceof(C).transform(e=>new k(e)),a.z.custom(e=>e instanceof Hn).transform(e=>new k(e))])},Hn=class de extends Lt{constructor(e){ye(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new de(e).valueOf()}get period(){return N.seconds(1/this.valueOf())}sampleCount(e){return new N(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new re(r).valueOf()}span(e){return N.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new re(r).valueOf())}add(e){return new de(Ft(this.valueOf(),new de(e).valueOf()))}sub(e){return new de(We(this.valueOf(),new de(e).valueOf()))}mult(e){return new de(be(this.valueOf(),e))}div(e){return new de(kr(this.valueOf(),e))}static hz(e){return new de(e)}static khz(e){return de.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new de(e)),a.z.instanceof(de)])},re=class ae extends Lt{constructor(e){ye(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new Mt(e*this.valueOf())}add(e){return new ae(Ft(this.valueOf(),new ae(e).valueOf()))}sub(e){return new ae(We(this.valueOf(),new ae(e).valueOf()))}mult(e){return new ae(be(this.valueOf(),e))}div(e){return new ae(kr(this.valueOf(),e))}static UNKNOWN=new ae(0);static BIT128=new ae(16);static BIT64=new ae(8);static BIT32=new ae(4);static BIT16=new ae(2);static BIT8=new ae(1);static z=a.z.union([a.z.number().transform(e=>new ae(e)),a.z.instanceof(ae)])},B=class Ae{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new C(e.start),this.end=new C(e.end)):(this.start=new C(e),this.end=new C(r))}get span(){return new N(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.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Ae(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=N.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=N.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=C.max(n.start,e.start),i=C.min(n.end,e.end);return i.before(s)?!1:new N(i.sub(s)).greaterThanOrEqual(r)}contains(e){return e instanceof Ae?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new Ae(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new Ae(C.min(...e.map(r=>r.start)),C.max(...e.map(r=>r.end)))}static MAX=new Ae(C.MIN,C.MAX);static ZERO=new Ae(C.ZERO,C.ZERO);static z=a.z.union([a.z.object({start:C.z,end:C.z}).transform(e=>new Ae(e.start,e.end)),a.z.instanceof(Ae)]);static sort(e,r){return C.sort(e.start,r.start)||C.sort(e.end,r.end)}static simplify(e){return e.map(r=>r.makeValid()).sort((r,n)=>Ae.sort(r,n)).reduce((r,n)=>{if(n.span.isZero)return r;if(r.length===0)return r.push(n),r;const s=r[r.length-1];return s.overlapsWith(n)||s.end.equals(n.start)?s.end=C.max(s.end,n.end):r.push(n),r},[])}},Z=class m extends Lt{constructor(e){if(ye(e)&&(e=e.value),e instanceof m||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=m.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=m.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(e=!1){return e?m.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(m.JSON)||this.equals(m.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(m.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=m.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(m.UINT8)||this.equals(m.UINT16)||this.equals(m.UINT32)||this.equals(m.UINT64)}get isSignedInteger(){return this.equals(m.INT8)||this.equals(m.INT16)||this.equals(m.INT32)||this.equals(m.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(m.INT32)&&e.equals(m.FLOAT64)||this.equals(m.INT8)&&e.equals(m.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return m.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new m("unknown");static FLOAT64=new m("float64");static FLOAT32=new m("float32");static INT64=new m("int64");static INT32=new m("int32");static INT16=new m("int16");static INT8=new m("int8");static UINT64=new m("uint64");static UINT32=new m("uint32");static UINT16=new m("uint16");static UINT8=new m("uint8");static BOOLEAN=new m("boolean");static TIMESTAMP=new m("timestamp");static UUID=new m("uuid");static STRING=new m("string");static JSON=new m("json");static ARRAY_CONSTRUCTORS=new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]]);static DENSITIES=new Map([[m.UINT8.toString(),re.BIT8],[m.UINT16.toString(),re.BIT16],[m.UINT32.toString(),re.BIT32],[m.UINT64.toString(),re.BIT64],[m.FLOAT32.toString(),re.BIT32],[m.FLOAT64.toString(),re.BIT64],[m.INT8.toString(),re.BIT8],[m.INT16.toString(),re.BIT16],[m.INT32.toString(),re.BIT32],[m.INT64.toString(),re.BIT64],[m.TIMESTAMP.toString(),re.BIT64],[m.STRING.toString(),re.UNKNOWN],[m.JSON.toString(),re.UNKNOWN],[m.UUID.toString(),re.BIT128]]);static ALL=[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON];static SHORT_STRINGS=new Map([[m.UINT8.toString(),"u8"],[m.UINT16.toString(),"u16"],[m.UINT32.toString(),"u32"],[m.UINT64.toString(),"u64"],[m.INT8.toString(),"i8"],[m.INT16.toString(),"i16"],[m.INT32.toString(),"i32"],[m.INT64.toString(),"i64"],[m.FLOAT32.toString(),"f32"],[m.FLOAT64.toString(),"f64"],[m.BOOLEAN.toString(),"bool"],[m.TIMESTAMP.toString(),"ts"],[m.UUID.toString(),"uuid"],[m.STRING.toString(),"str"],[m.JSON.toString(),"json"]]);static BIG_INT_TYPES=[m.INT64,m.UINT64,m.TIMESTAMP];static z=a.z.union([a.z.string().transform(e=>new m(e)),a.z.instanceof(m)])},Mt=class M extends Lt{constructor(e){ye(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return ye(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return ye(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return ye(e)&&(e=e.value),new M(Ft(this.valueOf(),e.valueOf()))}sub(e){return ye(e)&&(e=e.value),new M(We(this.valueOf(),e.valueOf()))}mult(e){return new M(be(this.valueOf(),e))}div(e){return new M(kr(this.valueOf(),e))}truncate(e){return new M(Math.trunc(this.valueOf()/new M(e).valueOf())*new M(e).valueOf())}remainder(e){return M.bytes(this.valueOf()%new M(e).valueOf())}get gigabytes(){return this.valueOf()/M.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/M.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/M.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/M.TERABYTE.valueOf()}toString(){const e=this.truncate(M.TERABYTE),r=this.truncate(M.GIGABYTE),n=this.truncate(M.MEGABYTE),s=this.truncate(M.KILOBYTE),i=this.truncate(M.BYTE),o=e,c=r.sub(e),l=n.sub(r),u=s.sub(n),h=i.sub(s);let f="";return o.isZero||(f+=`${o.terabytes}TB `),c.isZero||(f+=`${c.gigabytes}GB `),l.isZero||(f+=`${l.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new M(e)}static BYTE=new M(1);static kilobytes(e=1){return M.bytes(new M(e).valueOf()*1e3)}static KILOBYTE=M.kilobytes(1);static megabytes(e=1){return M.kilobytes(new M(e).valueOf()*1e3)}static MEGABYTE=M.megabytes(1);static gigabytes(e=1){return M.megabytes(new M(e).valueOf()*1e3)}static GIGABYTE=M.gigabytes(1);static terabytes(e){return M.gigabytes(new M(e).valueOf()*1e3)}static TERABYTE=M.terabytes(1);static ZERO=new M(0);static z=a.z.union([a.z.number().transform(e=>new M(e)),a.z.instanceof(M)]);get isZero(){return this.valueOf()===0}};a.z.object({start:a.z.number(),end:a.z.number()});a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);const Sc=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof C||t instanceof N||t instanceof Date},Py=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):rn(r,-n),rn=(t,e)=>e==0?t:t==0?e:typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:Number(t)+Number(e),_y=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Ry(t){return typeof t=="string"&&_y.test(t)}const X=[];for(let t=0;t<256;++t)X.push((t+256).toString(16).slice(1));function Dy(t,e=0){return(X[t[e+0]]+X[t[e+1]]+X[t[e+2]]+X[t[e+3]]+"-"+X[t[e+4]]+X[t[e+5]]+"-"+X[t[e+6]]+X[t[e+7]]+"-"+X[t[e+8]]+X[t[e+9]]+"-"+X[t[e+10]]+X[t[e+11]]+X[t[e+12]]+X[t[e+13]]+X[t[e+14]]+X[t[e+15]]).toLowerCase()}function Ly(t,e=0){const r=Dy(t,e);if(!Ry(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const kc=(t,e)=>Ly(t,e),De=-1,Ts={[Symbol.iterator]:()=>Ts,next:()=>({done:!0,value:void 0})},By=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Fy=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),Os=10,Nc=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Ec="sy_x_telem_series";let Ve=class Ye{key;discriminator=Ec;dataType;sampleOffset;gl;_data;timeRange=B.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=De;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:B.z.optional(),dataType:Z.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([By,Fy,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:Ty.optional().default("static").optional()});static z=Ye.crudeZ.transform(e=>new Ye(e));constructor(e){qy(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:c=1n,key:l=fa(),data:u}=e;if(Ac(u)){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.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=Sc(u),f=Array.isArray(u);if(r!=null)this.dataType=new Z(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||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=Z.STRING;else if(typeof d=="number")this.dataType=Z.FLOAT64;else if(typeof d=="bigint")this.dataType=Z.INT64;else if(typeof d=="boolean")this.dataType=Z.BOOLEAN;else if(d instanceof C||d instanceof Date||d instanceof C)this.dataType=Z.TIMESTAMP;else if(typeof d=="object")this.dataType=Z.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new Z(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const v=d[0];(v instanceof C||v instanceof Date||v instanceof N)&&(d=d.map(x=>new C(x).valueOf())),this.dataType.equals(Z.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
9
- `)}
10
- `).buffer):this.dataType.equals(Z.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(x=>or.encodeString(x)).join(`
11
- `)}
12
- `).buffer):this.dataType.usesBigInt&&typeof v=="number"?this._data=new this.dataType.Array(d.map(x=>BigInt(Math.round(x)))).buffer:!this.dataType.usesBigInt&&typeof v=="bigint"?this._data=new this.dataType.Array(d.map(Number)).buffer:this._data=new this.dataType.Array(d).buffer}this.key=l,this.alignment=o,this.alignmentMultiple=c,this.sampleOffset=s??0,this.timeRange=n??B.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new Z(r).Array(e),i=new Ye({data:s.buffer,dataType:r,...n});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn("cannot release a series 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===De)return 0;const r=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,r);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===De)return 0;const r=this.capacity-this.writePos,n=e.sub(0,r);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.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===De?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
13
- `).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(Z.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(or.decodeString(r)))}get byteCapacity(){return new Mt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===De?this.byteCapacity:this.dataType.isVariable?new Mt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===De?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const r=[0];return this.data.forEach((n,s)=>{n===Os&&(e++,r.push(s+1))}),this._cachedIndexes=r,this.cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=Py(this.dataType,e,this.data[s],r);return new Ye({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(Z.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){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.calcRawMax(),rn(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(Z.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){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.calcRawMin(),rn(this.cachedMin,this.sampleOffset))}get bounds(){return K(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){const r=e.cachedMin??e.calcRawMin();r<this.cachedMin&&(this.cachedMin=r)}if(this.cachedMax!=null){const r=e.cachedMax??e.calcRawMax();r>this.cachedMax&&(this.cachedMax=r)}}atAlignment(e,r){const n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(r===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,r)}at(e,r=!1){if(this.dataType.isVariable)return this.atVariable(e,r??!1);if(this.dataType.equals(Z.UUID))return this.atUUID(e,r);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return rn(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=kc(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(r)throw new Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,r){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],s=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]===Os){if(e===0){s=o;break}n=o+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(n,s);return this.dataType.equals(Z.STRING)?new TextDecoder().decode(i):ra(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=Sr(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=s(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(Z.FLOAT32)&&!this.dataType.equals(Z.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:s}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==De){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=De}as(e){return Nc(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:di(this.alignmentBounds.lower),upper:di(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return K(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}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 Yy(this);return this.dataType.equals(Z.JSON)?new Vy(e):e}return this.dataType.equals(Z.UUID)?new Hy(this):new Wy(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new hi(this,e,r??this.length)}subAlignmentIterator(e,r){const n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),s=Math.ceil(Number(r-this.alignment)/Number(this.alignmentMultiple));return new hi(this,n,s)}subBytes(e,r){if(e>=0&&(r==null||r>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,r);return new Ye({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,r,n){if(r<=0&&(n==null||n>=this.length))return this;let s;return e?s=this.data.subarray(r,n):s=this.data.slice(r,n),new Ye({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new Ye({data:this.buffer,dataType:this.dataType,timeRange:B.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)e+=`${this.at(r)?.toString()}`,e+=",";e+="...,";for(let r=-5;r<0;r++)e+=this.at(r)?.toString(),r<-1&&(e+=",")}return e+="])",e}};const qy=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Ve?!0:Sc(t),Ac=zy(Ec,Ve);class hi{series;end;index;constructor(e,r,n){this.series=e;const s=K(0,e.length+1);this.end=ci(s,n),this.index=ci(s,r)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}let Yy=class{series;index;decoder;constructor(t){if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==Os;)this.index++;const r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}},Vy=class Ic{wrapped;static schema=a.z.record(a.z.string(),a.z.unknown());constructor(e){this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:or.decodeString(e.value,Ic.schema)}}};class Hy{series;index;data;density;constructor(e){if(!e.dataType.equals(Z.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=e,this.index=0,this.data=new Uint8Array(e.buffer),this.density=Z.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const e=kc(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}}let Wy=class{series;index;constructor(t){this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}};class Gy{series;constructor(e=[]){if(e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){return Nc(e,this.dataType),this}get dataType(){return this.series.length===0?Z.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?B.ZERO:new B(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?K(0n,0n):K(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){const r=()=>new Error(`cannot push a ${e.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=e.dataType.equals(this.dataType);if(Ac(e)){if(this.series.length!==0&&!n)throw r();this.series.push(e)}else{if(this.series.length!==0&&e.series.length!==0&&!n)throw r();this.series.push(...e.series)}}get length(){return this.series.reduce((e,r)=>e+r.length,0)}atAlignment(e,r){for(const n of this.series)if(qr(n.alignmentBounds,e))return n.atAlignment(e,r);if(r)throw new Error(`[series] - no value at alignment ${e}`)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,r){return new Wn(this,e,r??this.length)}subAlignmentIterator(e,r){if(e>=this.alignmentBounds.upper||r<=this.alignmentBounds.lower)return Ts;let n=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)n+=o.length;else if(qr(o.alignmentBounds,e)){n+=Math.ceil(Number(e-o.alignment)/Number(o.alignmentMultiple));break}}let s=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(r<o.alignment)break;if(r>=o.alignmentBounds.upper)s+=o.length;else if(qr(o.alignmentBounds,r)){s+=Math.ceil(Number(r-o.alignment)/Number(o.alignmentMultiple));break}}return new Wn(this,n,s)}subAlignmentSpanIterator(e,r){if(e>=this.alignmentBounds.upper)return Ts;r=Math.min(r,Number(this.distance(e,this.alignmentBounds.upper)));let n=0;for(let s=0;s<this.series.length;s++){const i=this.series[s];if(e<i.alignment)break;if(e>=i.alignmentBounds.upper)n+=i.length;else if(qr(i.alignmentBounds,e)){n+=Number(e-i.alignment);break}}return new Wn(this,n,n+r)}updateGLBuffer(e){this.series.forEach(r=>r.updateGLBuffer(e))}get bounds(){return Ep(this.series.map(e=>e.bounds))}get byteLength(){return new Mt(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,r){const n=this.series.map(s=>s.alignmentBounds);return Ap(n,e,r)}acquire(e){this.series.forEach(r=>r.acquire(e))}release(){this.series.forEach(e=>e.release())}distance(e,r){const n=this.series.map(s=>s.alignmentBounds);return Ip(n,e,r)}parseJSON(e){if(!this.dataType.equals(Z.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(r=>r.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Ky(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}}let Ky=class{series;seriesIndex;internal;constructor(t){this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}},Wn=class{series;index;end;constructor(t,e,r){this.series=t,this.end=r,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 di=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}},xc=(t,e,r)=>{let n=0,s=t.length;const i=r??Sr(e);for(;n<s;){const o=Math.floor((n+s)/2),c=i(t[o],e);if(c===0)return o;c<0?n=o+1:s=o}return n},Jy=(t,e,r)=>{const n=xc(t,e,r);t.splice(n,0,e)},fi=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:yt,GREATER_THAN:Ue,LESS_THAN:Me,insert:Jy,isEqualTo:Wo,isGreaterThan:Ho,isGreaterThanEqual:hp,isLessThan:Vo,newF:Sr,newFieldF:op,order:up,primitiveArrays:cp,reverseF:Yo,search:xc,stringsWithNumbers:dp,uniqueUnorderedPrimitiveArrays:lp,unorderedPrimitiveArrays:qo},Symbol.toStringTag,{value:"Module"})),Xy=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Qy=(t,e,r=".")=>{const n=t.split(r);return n.map((s,i)=>{const o=e(s,i,n);return o==null?null:typeof o=="string"?o:o.join(r)}).filter(s=>s!=null).join(r)},em=(t,e)=>{if(!Array.isArray(t))return t[e];const r=t[e];if(r!=null||t.length==0)return r;const n=t[0];if(typeof n=="object"&&"key"in n)return t.find(s=>s.key===e)},tm=((t,e,r={optional:!1})=>{const{optional:n,getter:s=em}=r;if(e==="")return t;const i=e.split(".");if(i.length===1){const c=s(t,i[0]);if(c===void 0){if(n)return null;throw new Error(`Path ${e} does not exist. ${i[0]} is undefined`)}return c}const o=(c,l)=>{if(l>=i.length)return c;for(let u=i.length-l;u>=1;u--){const h=i.slice(l,l+u).join("."),f=s(c,h);if(f!==void 0){if(l+u===i.length)return f;if(f===null){if(n)return null;throw new Error(`Path ${e} does not exist. ${h} is null`)}return o(f,l+u)}}if(n)return null;throw new Error(`Path ${e} does not exist. ${i[l]} is undefined`)};return o(t,0)});a.z.object({key:a.z.string(),value:a.z.string()});let rm=class{handlers;transform;closer;constructor(t,e){this.transform=t,this.handlers=e??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){let e=t;if(this.transform!=null){const[r,n]=this.transform(t);if(!n)return;e=r}this.handlers.forEach((r,n)=>n(e))}setCloser(t){this.closer=t}async close(){return await this.closer?.()}},nm=class{handlers;constructor(t){this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((e,r)=>r(t))}};const sm=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:nm,Observer:rm},Symbol.toStringTag,{value:"Module"})),am=a.z.record(a.z.union([a.z.number(),a.z.string(),a.z.symbol()]),a.z.unknown()),pa=t=>Object.entries(t),im=(t,e)=>Object.fromEntries(pa(t).map(([r,n])=>[r,e(n,r)])),om=t=>Object.fromEntries(pa(t).filter(([e,r])=>r!==void 0)),cm=(t,...e)=>{const r={...t};for(const n of e)delete r[n];return r},Te=Object.freeze(Object.defineProperty({__proto__:null,entries:pa,map:im,omit:cm,purgeUndefined:om,unknownZ:am},Symbol.toStringTag,{value:"Module"})),lm=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";lm();const um=["macOS","Windows","Linux"],hm=["macos","windows","linux"],dm={macos:"macOS",windows:"Windows",linux:"Linux"};a.z.enum(um).or(a.z.enum(hm).transform(t=>dm[t]));const fm=(...t)=>t.map(Cc).join(""),Cc=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),pm=t=>t.endsWith("/")?t.slice(0,-1):t;class xt{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){this.protocol=n,this.host=e,this.port=r,this.path=Cc(s)}replace(e){return new xt({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new xt({...this,pathPrefix:fm(this.path,e)})}toString(){return pm(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new xt({host:"unknown",port:0})}const ym=t=>t.nullable().transform(e=>e===null?void 0:e).optional(),mm=t=>a.array(t).or(t.transform(e=>[e])),jc=t=>Qy(t,(e,r,n)=>{const s=r===n.length-1,i=!isNaN(parseInt(e)),o=!isNaN(parseInt(n[r+1]));return i&&(e="element"),s||o?e:[e,"shape"]}),pi=(t,e)=>{if(t==null)return null;const r=t[e];return r==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:r},gm=((t,e,r)=>e===""?t:tm(pi(t,"shape"),jc(e),{...r,getter:pi})),ir=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:gm,getFieldSchemaPath:jc,nullToUndefined:ym,toArray:mm},Symbol.toStringTag,{value:"Module"})),Ss=2,ks=3,$c=2,wm=(t,e)=>{if(Number.isNaN(t)||!Number.isFinite(t))return t;const r=nc(e);if(r==0)return t;let n;r>=1e3?n=Ss:r>=1?n=ks:n=Math.ceil(-Math.log10(r))+$c;const s=10**n;return Math.round(t*s)/s},bm=5,vm=1e-10,zm=(t,e)=>{if(Number.isNaN(t)||!Number.isFinite(t))return t;const r=Math.abs(t);if(r===0)return 0;let n=!1,s=0;if(e!=null){s=nc(e);const c=s/r;n=s>0&&c>vm}if(n){let c;s>=1e3?c=Ss:s>=1?c=ks:c=Math.ceil(-Math.log10(s))+$c;const l=10**c;return Math.round(t*l)/l}if(r>=1e3){const c=10**Ss;return Math.round(t*c)/c}if(r>=1){const c=10**ks;return Math.round(t*c)/c}const i=Math.floor(Math.log10(r)),o=10**(bm-i-1);return Math.round(t*o)/o},Ns=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:Cy,MAX_INT32:$y,MAX_INT64:an,MAX_INT64_NUMBER:Tc,MAX_INT8:Iy,MAX_UINT16:Sy,MAX_UINT32:ky,MAX_UINT64:Ny,MAX_UINT64_NUMBER:Ey,MAX_UINT8:Oy,MIN_INT16:xy,MIN_INT32:jy,MIN_INT64:My,MIN_INT64_NUMBER:Uy,MIN_INT8:Ay,abs:rc,add:Ft,closeTo:Op,div:kr,equal:vs,isInteger:sn,max:kp,min:tc,mult:be,roundBySpan:wm,roundToNearestMagnitude:Sp,smartRound:zm,sub:We},Symbol.toStringTag,{value:"Module"})),Tm=async t=>await new Promise(e=>setTimeout(e,N.fromMilliseconds(t).milliseconds));class Om{config;retries;interval;constructor(e){this.config={baseInterval:new N(e?.baseInterval??N.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??Tm},this.retries=0,this.interval=new N(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:r,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(r),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}}const Sm=a.z.object({baseInterval:N.z.optional(),maxRetries:a.z.number().optional(),scale:a.z.number().optional()}),ya=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Om,breakerConfigZ:Sm},Symbol.toStringTag,{value:"Module"})),km=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Mc=a.z.string().regex(km),Ct=a.z.number().min(0).max(255),Uc=a.z.number().min(0).max(1),Zc=a.z.tuple([Ct,Ct,Ct,Uc]),Nm=a.z.tuple([Ct,Ct,Ct]),Em=a.z.object({rgba255:Zc}),Am=a.z.number().min(0).max(360),Im=a.z.number().min(0).max(100),xm=a.z.number().min(0).max(100),Cm=a.z.tuple([Am,Im,xm,Uc]),ma=a.z.union([Mc,Nm,Zc,Cm,Em]),jm=ma.transform(t=>ga(t)),ga=(t,e=1)=>{if(t=ma.parse(t),typeof t=="string")return $m(t,e);if(Array.isArray(t)){if(t.length<3||t.length>4)throw new Error(`Invalid color: [${t.join(", ")}]`);return t.length===3?[...t,e]:t}return t.rgba255},$m=(t,e=1)=>(t=Mc.parse(t),t=Mm(t),[Hr(t,0),Hr(t,2),Hr(t,4),t.length===8?Hr(t,6)/255:e]),Hr=(t,e)=>parseInt(t.slice(e,e+2),16),Mm=t=>t.startsWith("#")?t.slice(1):t;ga("#000000");ga("#ffffff");const Um=a.z.object({key:a.z.string(),color:ma,position:a.z.number(),switched:a.z.boolean().optional()});a.z.array(Um);const Zm=a.z.object({key:a.z.string(),name:a.z.string(),color:jm});a.z.object({key:a.z.string(),name:a.z.string(),swatches:a.z.array(Zm)});const Pc=a.z.int().min(0).max(255),_c=255,Rc=0,Pm={lower:Rc,upper:_c+1},Dc=a.z.object({name:a.z.string(),key:a.z.string()}),ur=t=>a.z.object({subject:Dc,resource:t,authority:Pc}),_m=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),Lc=t=>a.z.object({from:ur(t),to:a.z.null()}),Bc=t=>a.z.object({from:a.z.null(),to:ur(t)}),Rm=t=>a.z.union([Lc(t),Bc(t),a.z.object({from:ur(t),to:ur(t)})]),me=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:_c,AUTHORITY_BOUNDS:Pm,ZERO_AUTHORITY:Rc,acquireZ:Bc,authorityZ:Pc,filterTransfersByChannelKey:_m,releaseZ:Lc,stateZ:ur,subjectZ:Dc,transferZ:Rm},Symbol.toStringTag,{value:"Module"})),Dm=t=>Object.getOwnPropertySymbols(globalThis).includes(t),Lm=(t,e)=>{const r=Symbol.for(t);if(!Dm(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},Fc="sy_x_error",Bm=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(t):e instanceof Error?e.message.startsWith(t):typeof e!="string"?!1:e.startsWith(t),Nr=t=>class sr extends Error{static discriminator=Fc;discriminator=sr.discriminator;static TYPE=t;type=sr.TYPE;static matches=Bm(t);matches=sr.matches;constructor(r,n){super(r,n),this.name=sr.TYPE}static sub(r){return Nr(`${t}.${r}`)}},qc=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==Fc)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},kt="unknown",Es="nil";class Fm{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Es,data:""};if(qc(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:kt,data:e.message};if(typeof e=="string")return{type:kt,data:e};try{return{type:kt,data:JSON.stringify(e)}}catch{return{type:kt,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===Es)return null;if(e.type===kt)return new As(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new As(e.data)}}const wa=Lm("synnax-error-registry",()=>new Fm),qm=({encode:t,decode:e})=>wa().register({encode:t,decode:e}),Ym=t=>wa().encode(t),Vm=t=>t==null?null:wa().decode(t);class As extends Nr("unknown"){}const Hm=a.z.object({type:a.z.string(),data:a.z.string()});class Wm extends Nr("canceled"){}class Gm extends Nr("not_implemented"){}const Pe=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Wm,NONE:Es,NotImplemented:Gm,UNKNOWN:kt,Unknown:As,createTyped:Nr,decode:Vm,encode:Ym,isTyped:qc,payloadZ:Hm,register:qm},Symbol.toStringTag,{value:"Module"})),Km=a.object({jsonrpc:a.literal("2.0"),method:a.string(),params:a.any().optional(),id:a.union([a.string(),a.number(),a.null()]).optional()}),Yc=a.object({jsonrpc:a.literal("2.0"),id:a.union([a.string(),a.number(),a.null()])}),Jm=Yc.extend({result:a.json()}),Xm=Yc.extend({error:a.object({code:a.number().int(),message:a.string().optional(),data:a.json().optional()})}),Qm=a.union([Jm,Xm]);a.union([Km,Qm]);const Vc=a.uuid(),Hc=a.object({key:Vc,name:a.string().min(1),color:a.string()}),Wc=Object.freeze(Object.defineProperty({__proto__:null,keyZ:Vc,labelZ:Hc},Symbol.toStringTag,{value:"Module"})),Is=a.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),eg=(t,e)=>{const r=t.split("."),n=e.split("."),s=Math.max(r.length,n.length);for(let i=0;i<s;i++){const o=r[i],c=n[i];if(o===void 0)return Me;if(c===void 0)return Ue;const l=/^\d+$/.test(o),u=/^\d+$/.test(c);if(l&&!u)return Me;if(!l&&u)return Ue;if(l&&u){const h=parseInt(o),f=parseInt(c);if(h<f)return Me;if(h>f)return Ue}else{if(o<c)return Me;if(o>c)return Ue}}return yt},Er=((t,e,r={})=>{r.checkMajor??=!0,r.checkMinor??=!0,r.checkPatch??=!0;const n=Is.parse(t),s=Is.parse(e),[i,o]=n.split("-"),[c,l]=s.split("-"),[u,h,f]=i.split(".").map(Number),[d,v,x]=c.split(".").map(Number);if(r.checkMajor){if(u<d)return Me;if(u>d)return Ue}if(r.checkMinor){if(h<v)return Me;if(h>v)return Ue}if(r.checkPatch){if(f<x)return Me;if(f>x)return Ue}return o===void 0&&l===void 0?yt:o===void 0?Ue:l===void 0?Me:eg(o,l)}),tg=(t,e,r={})=>Wo(Er(t,e,r)),Gc=(t,e,r={})=>Ho(Er(t,e,r)),rg=(t,e,r={})=>Vo(Er(t,e,r)),ng=({name:t,migrate:e})=>r=>{try{const n=e(r);return console.log(`${t} migrated: ${r.version} -> ${n.version}`),n}catch(n){throw console.log(`${t} failed to migrate from ${r.version}`),console.error(n),n}},sg=({name:t,migrations:e,targetSchema:r,defaultVersion:n,def:s})=>{const i=Object.keys(e).sort(Er).pop();if(i==null)return u=>{if(u.version??=n,u.version!==s.version)return console.log(`${t} version ${u.version} is newer than latest version of ${s.version}.
14
- Returning default instead.
15
- `),s;try{return r!=null?r.parse(u):u}catch(h){return console.log(`${t} failed to parse default. Exiting with default`),console.error(h),s}};const o=Object.keys(e).length;let c=!1;const l=u=>{try{if(o===0||Gc(u.version,i))return console.log(c?`${t} ${u.version} now up to date`:`${t} version ${u.version} is up to date with target version ${s.version}`),u;const h=u.version,f=e[h],d=f(u);return c=!0,l(d)}catch(h){return console.log(`${t} failed to migrate from ${u.version} to ${i}`),console.error(h),s}};return u=>{try{if(u.version==null)if(n!=null)console.log(`${t} version is null. Setting version to default of ${n}`),u.version=n;else return console.log(`${t} version is null and no default version set. Exiting with default`),s;return l(u)}catch(h){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(h),s}}},yi=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:Er,createMigration:ng,migrator:sg,semVerNewer:Gc,semVerOlder:rg,semVerZ:Is,versionsEqual:tg},Symbol.toStringTag,{value:"Module"})),ag=["standard","scientific","engineering"];a.z.enum(ag);const Kc=a.z.enum(["success","info","warning","error","loading","disabled"]),ig=t=>a.z.object({key:a.z.string(),name:a.z.string().default(""),variant:Kc,message:a.z.string(),description:a.z.string().optional(),time:C.z,labels:Uo(Hc).optional(),details:t??a.z.unknown().optional()}),og=a.z.object({stack:a.z.string(),error:a.z.instanceof(Error)}),cg=(t,e)=>{if(!(t instanceof Error))throw t;return Jc({variant:"error",message:e??t.message,description:e!=null?t.message:void 0,details:{stack:t.stack??"",error:t}})},Jc=t=>({key:fa(),time:C.now(),name:"",...t}),lg=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?t:void 0:e===t?t:void 0},ug=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?void 0:t:e===t?void 0:t},qt=Object.freeze(Object.defineProperty({__proto__:null,create:Jc,exceptionDetailsSchema:og,fromException:cg,keepVariants:lg,removeVariants:ug,statusZ:ig,variantZ:Kc},Symbol.toStringTag,{value:"Module"})),hg=(t,e)=>{if(!e.has(t))return t;let r=t,n=1,s=t;for(;e.has(s);){const i=s.match(dg);i?(r=s.slice(0,i.index).trim(),n=parseInt(i[1])+1):(r=s,n=1),s=`${r} (${n})`}return s},dg=/\((\d+)\)$/,fg=(t,e="")=>{if(typeof t=="string")return t;const r=t.length;return r===0?e:r===1?t[0]:r===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[r-1]}`},pg=t=>{const e=t.split(" "),r=new Set,n=e.map(o=>o.charAt(0).toLowerCase()).join("");r.add(n.replace(/-/g,"_")),r.add(n.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const s=/\d+/g;t.match(s)&&e.forEach((o,c)=>{if(s.test(o)){const l=e.map((u,h)=>h!==c?u.charAt(0).toLowerCase():u).join("");r.add(l.replace(/-/g,"_")),r.add(l.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const i=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return r.add(i.join("").replace(/-/g,"_")),r.add(i.join("_").replace(/-/g,"_")),Array.from(r).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},yg=(t,e)=>t.startsWith(e)?t.slice(e.length):t,xs=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:pg,deduplicateFileName:hg,naturalLanguageJoin:fg,trimPrefix:yg},Symbol.toStringTag,{value:"Module"})),mg="all",gg="create",wg="delete",bg="retrieve",vg="update",Cs=a.z.enum([mg,gg,wg,bg,vg]);class Ce extends Pe.createTyped("sy"){}let V=class extends Ce.sub("validation"){};class hr extends V.sub("path"){path;error;static encodedSchema=a.z.object({path:a.z.string().array(),error:Pe.payloadZ});constructor(e,r){const n=b.toArray(e);super(`${n.join(".")}: ${r.message}`),this.path=n.flatMap(s=>s.split(".")),this.error=r}static decode(e){const r=hr.encodedSchema.parse(JSON.parse(e.data));return new hr(r.path,Pe.decode(r.error))}}class on extends Ce.sub("auth"){}class js extends on.sub("invalid_token"){}class $s extends on.sub("expired_token"){}class le extends Ce.sub("unexpected"){constructor(e){super(`
16
- Unexpected error encountered:
17
-
18
- ${e}
19
-
20
- Please report this to the Synnax team.
21
- `)}}class Xe extends Ce.sub("query"){}class Ut extends Xe.sub("not_found"){}class cn extends Xe.sub("multiple_results"){}class mi extends Ce.sub("route"){path;constructor(e,r){super(e),this.path=r}}class Ms extends Ce.sub("control"){}class gi extends Ms.sub("unauthorized"){}class zg extends Ce.sub("disconnected"){constructor(e="Operation failed because no Core is connected."){super(e)}}class RA extends Ce.sub("contiguity"){}const Tg=t=>t.type.startsWith(Ce.TYPE)?t.type.startsWith(V.TYPE)?t.type===hr.TYPE?hr.decode(t):new V(t.data):t.type.startsWith(on.TYPE)?t.type.startsWith(js.TYPE)?new js(t.data):t.type.startsWith($s.TYPE)?new $s(t.data):new on(t.data):t.type.startsWith(le.TYPE)?new le(t.data):t.type.startsWith(Xe.TYPE)?t.type.startsWith(Ut.TYPE)?new Ut(t.data):t.type.startsWith(cn.TYPE)?new cn(t.data):new Xe(t.data):t.type.startsWith(Ms.TYPE)?t.type.startsWith(gi.TYPE)?new gi(t.data):new Ms(t.data):t.type.startsWith(mi.TYPE)?new mi(t.data,t.data):new le(t.data):null,Og=()=>{throw new Pe.NotImplemented};Pe.register({encode:Og,decode:Tg});const Sg=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof Ke?[r,new Ke({message:`Cannot reach Core at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]},Ar=a.z.uuid(),Xc=a.z.string(),zn=a.z.object({key:Ar,name:Xc}),kg=t=>({type:"group",key:t}),Tn=a.z.enum(["label","log","allow_all","builtin","cluster","channel","node","group","range","framer","range-alias","user","workspace","schematic","lineplot","rack","device","task","policy","table","arc","schematic_symbol","status"]),Qc=a.z.string().transform(t=>{const[e,r]=t.split(":");return{type:Tn.parse(e),key:r??""}}),_=a.z.object({type:Tn,key:a.z.string()}).or(Qc),Ng={type:"builtin",key:"root"},Zt=(t=>(typeof t=="string"&&(t=Qc.parse(t)),Array.isArray(t)?t.map(e=>Zt(e)):`${t.type}:${t.key}`)),Eg=(t,e)=>t.type===e.type&&t.key===e.key,el=t=>{const e=b.toArray(t);return e.length===0?[]:typeof e[0]=="object"&&"id"in e[0]?e.map(({id:r})=>r):e.map(r=>_.parse(r))},tl=a.z.object({id:_,name:a.z.string(),data:Te.unknownZ.optional().nullable()}).transform(t=>({key:Zt(t.id),...t})),Ag=t=>t==="to"?"from":"to",Ig=a.z.object({from:_,type:a.z.string(),to:_}).or(a.z.string().transform(t=>{const[e,r,n]=t.split("->");return{from:_.parse(e),type:r,to:_.parse(n)}})),xg=t=>`${Zt(t.from)}->${t.type}->${Zt(t.to)}`,Cg="parent",jg=(t,e)=>!(e.type!=null&&e.type!==t.type||e.from?.type!=null&&e.from.type!==t.from.type||e.to?.type!=null&&e.to.type!==t.to.type||e.from?.key!=null&&e.from.key!==t.from.key||e.to?.key!=null&&e.to.key!==t.to.key),$g="sy_group_set",Mg="sy_group_delete",Ug=a.object({group:zn}),Zg=a.object({parent:_,key:Ar.optional(),name:a.string()}),Pg=a.object({key:Ar,name:a.string()}),_g=a.object({keys:a.array(Ar)}),Rg="/ontology/create-group",Dg="/ontology/rename-group",Lg="/ontology/delete-group";let rl=class{client;constructor(t){this.client=t}async create(t){return(await g(this.client,Rg,t,Zg,Ug)).group}async rename(t,e){await g(this.client,Dg,{key:t,name:e},Pg,a.object({}))}async delete(t){await g(this.client,Lg,{keys:b.toArray(t)},_g,a.object({}))}};const Bg=Object.freeze(Object.defineProperty({__proto__:null,Client:rl,DELETE_CHANNEL_NAME:Mg,SET_CHANNEL_NAME:$g,groupZ:zn,keyZ:Ar,nameZ:Xc,ontologyID:kg},Symbol.toStringTag,{value:"Module"})),Fg="/ontology/add-children",qg="/ontology/remove-children",Yg="/ontology/move-children",wi=a.z.object({id:_,children:_.array()}),Vg=a.z.object({from:_,to:_,children:_.array()}),Gn=a.z.object({});let Hg=class{client;constructor(t){this.client=t}async addChildren(t,...e){await g(this.client,Fg,{id:t,children:e},wi,Gn)}async removeChildren(t,...e){await g(this.client,qg,{id:t,children:e},wi,Gn)}async moveChildren(t,e,...r){await g(this.client,Yg,{from:t,to:e,children:r},Vg,Gn)}};const Wg="/ontology/retrieve",Gg=a.z.object({ids:_.array().optional(),children:a.z.boolean().optional(),parents:a.z.boolean().optional(),excludeFieldData:a.z.boolean().optional(),searchTerm:a.z.string().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),types:Tn.array().optional()}),Kg=a.z.object({resources:tl.array()});let nl=class{type="ontology";groups;client;writer;framer;constructor(t,e){this.client=t,this.writer=new Hg(t),this.groups=new rl(t),this.framer=e}async retrieve(t,e){if(!Array.isArray(t)&&typeof t=="object"&&!("key"in t))return this.execRetrieve(t);const r=el(t),n=await this.execRetrieve({ids:r,...e});if(Array.isArray(t))return n;if(n.length===0)throw new Xe(`No resource found with ID ${xs.naturalLanguageJoin(r.map(s=>Zt(s)))}`);return n[0]}async retrieveChildren(t,e){return await this.execRetrieve({ids:b.toArray(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:b.toArray(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...r){return await this.writer.moveChildren(t,e,...r)}async execRetrieve(t){const{resources:e}=await g(this.client,Wg,t,Gg,Kg);return e}};const Jg="sy_ontology_resource_set",Xg="sy_ontology_resource_delete",Qg="sy_ontology_relationship_set",ew="sy_ontology_relationship_delete",tw=Object.freeze(Object.defineProperty({__proto__:null,Client:nl,PARENT_OF_RELATIONSHIP_TYPE:Cg,RELATIONSHIP_DELETE_CHANNEL_NAME:ew,RELATIONSHIP_SET_CHANNEL_NAME:Qg,RESOURCE_DELETE_CHANNEL_NAME:Xg,RESOURCE_SET_CHANNEL_NAME:Jg,ROOT_ID:Ng,idToString:Zt,idZ:_,idsEqual:Eg,matchRelationship:jg,oppositeRelationshipDirection:Ag,parseIDs:el,relationshipToString:xg,relationshipZ:Ig,resourceTypeZ:Tn,resourceZ:tl},Symbol.toStringTag,{value:"Module"})),Ir=a.z.uuid(),ba=a.z.object({key:Ir,subjects:b.nullableZ(_),objects:b.nullableZ(_),actions:b.nullableZ(Cs)}),rw=a.z.object({key:Ir.optional(),subjects:_.array().or(_),objects:_.array().or(_),actions:Cs.array().or(Cs)}),nw=a.z.object({keys:Ir.array().optional(),subjects:_.array().optional()}),sw=a.z.object({key:Ir}).transform(({key:t})=>({keys:[t]})),aw=a.z.union([a.z.object({for:_}).transform(({for:t})=>({subjects:[t]})),a.z.object({for:_.array()}).transform(({for:t})=>({subjects:t})),nw]),iw=a.z.union([sw,aw]),ow=a.z.object({policies:b.nullableZ(ba)}),cw=a.z.object({policies:ba.partial({key:!0}).array()}),lw=a.z.object({policies:ba.array()}),uw=a.z.object({keys:Ir.array()}),hw=a.z.object({}),dw="/access/policy/retrieve",fw="/access/policy/create",pw="/access/policy/delete";let yw=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=rw.array().parse(b.toArray(t)).map(s=>({objects:b.toArray(s.objects),actions:b.toArray(s.actions),subjects:b.toArray(s.subjects)})),n=await g(this.client,fw,{policies:r},cw,lw);return e?n.policies:n.policies[0]}async retrieve(t){const e="key"in t,r=await g(this.client,dw,t,iw,ow);return e?r.policies[0]:r.policies}async delete(t){await g(this.client,pw,{keys:b.toArray(t)},uw,hw)}},mw=class{policy;constructor(t){this.policy=new yw(t)}};function p(t,e,r){function n(c,l){var u;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(u=c._zod).traits??(u.traits=new Set),c._zod.traits.add(t),e(c,l);for(const h in o.prototype)h in c||Object.defineProperty(c,h,{value:o.prototype[h].bind(c)});c._zod.constr=o,c._zod.def=l}const s=r?.Parent??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(c){var l;const u=r?.Parent?new i:this;n(u,c),(l=u._zod).deferred??(l.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class jt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class sl extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const al={};function dt(t){return al}function gw(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,n])=>e.indexOf(+r)===-1).map(([r,n])=>n)}function Us(t,e){return typeof e=="bigint"?e.toString():e}function va(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function za(t){return t==null}function Ta(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function ww(t,e){const r=(t.toString().split(".")[1]||"").length,n=e.toString();let s=(n.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(s=Number.parseInt(l[1]))}const i=r>s?r:s,o=Number.parseInt(t.toFixed(i).replace(".","")),c=Number.parseInt(e.toFixed(i).replace(".",""));return o%c/10**i}const bi=Symbol("evaluating");function L(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==bi)return n===void 0&&(n=bi,n=r()),n},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function mt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function gt(...t){const e={};for(const r of t){const n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function vi(t){return JSON.stringify(t)}const il="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const bw=va(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function dr(t){if(ln(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(ln(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function ol(t){return dr(t)?{...t}:Array.isArray(t)?[...t]:t}const vw=new Set(["string","number","symbol"]);function On(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qe(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function E(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function zw(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const Tw={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ow(t,e){const r=t._zod.def,n=gt(t._zod.def,{get shape(){const s={};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&(s[i]=r.shape[i])}return mt(this,"shape",s),s},checks:[]});return Qe(t,n)}function Sw(t,e){const r=t._zod.def,n=gt(t._zod.def,{get shape(){const s={...t._zod.def.shape};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&delete s[i]}return mt(this,"shape",s),s},checks:[]});return Qe(t,n)}function kw(t,e){if(!dr(e))throw new Error("Invalid input to extend: expected a plain object");const r=t._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=gt(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return mt(this,"shape",s),s},checks:[]});return Qe(t,n)}function Nw(t,e){if(!dr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...t._zod.def,get shape(){const n={...t._zod.def.shape,...e};return mt(this,"shape",n),n},checks:t._zod.def.checks};return Qe(t,r)}function Ew(t,e){const r=gt(t._zod.def,{get shape(){const n={...t._zod.def.shape,...e._zod.def.shape};return mt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:[]});return Qe(t,r)}function Aw(t,e,r){const n=gt(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=t?new t({type:"optional",innerType:s[o]}):s[o])}else for(const o in s)i[o]=t?new t({type:"optional",innerType:s[o]}):s[o];return mt(this,"shape",i),i},checks:[]});return Qe(e,n)}function Iw(t,e,r){const n=gt(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return mt(this,"shape",i),i},checks:[]});return Qe(e,n)}function Et(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function cl(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Wr(t){return typeof t=="string"?t:t?.message}function ft(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Wr(t.inst?._zod.def?.error?.(t))??Wr(e?.error?.(t))??Wr(r.customError?.(t))??Wr(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Oa(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function fr(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const ll=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Us,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},ul=p("$ZodError",ll),hl=p("$ZodError",ll,{Parent:Error});function xw(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function Cw(t,e=r=>r.message){const r={_errors:[]},n=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>n({issues:o}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(e(i));else{let o=r,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(t),r}const Sa=t=>(e,r,n,s)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new jt;if(o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>ft(l,i,dt())));throw il(c,s?.callee),c}return o.value},ka=t=>async(e,r,n,s)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>ft(l,i,dt())));throw il(c,s?.callee),c}return o.value},Sn=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new jt;return i.issues.length?{success:!1,error:new(t??ul)(i.issues.map(o=>ft(o,s,dt())))}:{success:!0,data:i.value}},jw=Sn(hl),kn=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>ft(o,s,dt())))}:{success:!0,data:i.value}},$w=kn(hl),Mw=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Sa(t)(e,r,s)},Uw=t=>(e,r,n)=>Sa(t)(e,r,n),Zw=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ka(t)(e,r,s)},Pw=t=>async(e,r,n)=>ka(t)(e,r,n),_w=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Sn(t)(e,r,s)},Rw=t=>(e,r,n)=>Sn(t)(e,r,n),Dw=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return kn(t)(e,r,s)},Lw=t=>async(e,r,n)=>kn(t)(e,r,n),Bw=/^[cC][^\s-]{8,}$/,Fw=/^[0-9a-z]+$/,qw=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yw=/^[0-9a-vA-V]{20}$/,Vw=/^[A-Za-z0-9]{27}$/,Hw=/^[a-zA-Z0-9_-]{21}$/,Ww=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gw=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zi=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Kw=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Jw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Xw(){return new RegExp(Jw,"u")}const Qw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,eb=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,tb=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,rb=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nb=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dl=/^[A-Za-z0-9_-]*$/,sb=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ab=/^\+(?:[0-9]){6,14}[0-9]$/,fl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ib=new RegExp(`^${fl}$`);function pl(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ob(t){return new RegExp(`^${pl(t)}$`)}function cb(t){const e=pl({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${fl}T(?:${n})$`)}const lb=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},ub=/^-?\d+$/,hb=/^-?\d+(?:\.\d+)?/,db=/^(?:true|false)$/i,fb=/^[^A-Z]*$/,pb=/^[^a-z]*$/,ie=p("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),yl={number:"number",bigint:"bigint",object:"date"},ml=p("$ZodCheckLessThan",(t,e)=>{ie.init(t,e);const r=yl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),gl=p("$ZodCheckGreaterThan",(t,e)=>{ie.init(t,e);const r=yl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),yb=p("$ZodCheckMultipleOf",(t,e)=>{ie.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):ww(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),mb=p("$ZodCheckNumberFormat",(t,e)=>{ie.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,i]=Tw[e.format];t._zod.onattach.push(o=>{const c=o._zod.bag;c.format=e.format,c.minimum=s,c.maximum=i,r&&(c.pattern=ub)}),t._zod.check=o=>{const c=o.value;if(r){if(!Number.isInteger(c)){o.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:c,inst:t});return}if(!Number.isSafeInteger(c)){c>0?o.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):o.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}c<s&&o.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),c>i&&o.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inst:t})}}),gb=p("$ZodCheckMaxLength",(t,e)=>{var r;ie.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!za(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const i=Oa(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),wb=p("$ZodCheckMinLength",(t,e)=>{var r;ie.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!za(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const i=Oa(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),bb=p("$ZodCheckLengthEquals",(t,e)=>{var r;ie.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!za(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,i=s.length;if(i===e.length)return;const o=Oa(s),c=i>e.length;n.issues.push({origin:o,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Nn=p("$ZodCheckStringFormat",(t,e)=>{var r,n;ie.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),vb=p("$ZodCheckRegex",(t,e)=>{Nn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),zb=p("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=fb),Nn.init(t,e)}),Tb=p("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=pb),Nn.init(t,e)}),Ob=p("$ZodCheckIncludes",(t,e)=>{ie.init(t,e);const r=On(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),Sb=p("$ZodCheckStartsWith",(t,e)=>{ie.init(t,e);const r=new RegExp(`^${On(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),kb=p("$ZodCheckEndsWith",(t,e)=>{ie.init(t,e);const r=new RegExp(`.*${On(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),Nb=p("$ZodCheckOverwrite",(t,e)=>{ie.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class Eb{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
22
- `).filter(i=>i),n=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(n)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const e=Function,r=this?.args,n=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,n.join(`
23
- `))}}const Ab={major:4,minor:1,patch:12},H=p("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Ab;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const s of n)for(const i of s._zod.onattach)i(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const s=(o,c,l)=>{let u=Et(o),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(o))continue}else if(u)continue;const d=o.issues.length,v=f._zod.check(o);if(v instanceof Promise&&l?.async===!1)throw new jt;if(h||v instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await v,o.issues.length!==d&&(u||(u=Et(o,d)))});else{if(o.issues.length===d)continue;u||(u=Et(o,d))}}return h?h.then(()=>o):o},i=(o,c,l)=>{if(Et(o))return o.aborted=!0,o;const u=s(c,n,l);if(u instanceof Promise){if(l.async===!1)throw new jt;return u.then(h=>t._zod.parse(h,l))}return t._zod.parse(u,l)};t._zod.run=(o,c)=>{if(c.skipChecks)return t._zod.parse(o,c);if(c.direction==="backward"){const u=t._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(h=>i(h,o,c)):i(u,o,c)}const l=t._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new jt;return l.then(u=>s(u,n,c))}return s(l,n,c)}}t["~standard"]={validate:s=>{try{const i=jw(t,s);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return $w(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Na=p("$ZodString",(t,e)=>{H.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??lb(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),F=p("$ZodStringFormat",(t,e)=>{Nn.init(t,e),Na.init(t,e)}),Ib=p("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Gw),F.init(t,e)}),xb=p("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=zi(r))}else e.pattern??(e.pattern=zi());F.init(t,e)}),Cb=p("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Kw),F.init(t,e)}),jb=p("$ZodURL",(t,e)=>{F.init(t,e),t._zod.check=r=>{try{const n=r.value.trim(),s=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:sb.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=s.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),$b=p("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Xw()),F.init(t,e)}),Mb=p("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Hw),F.init(t,e)}),Ub=p("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Bw),F.init(t,e)}),Zb=p("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Fw),F.init(t,e)}),Pb=p("$ZodULID",(t,e)=>{e.pattern??(e.pattern=qw),F.init(t,e)}),_b=p("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Yw),F.init(t,e)}),Rb=p("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Vw),F.init(t,e)}),Db=p("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=cb(e)),F.init(t,e)}),Lb=p("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=ib),F.init(t,e)}),Bb=p("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=ob(e)),F.init(t,e)}),Fb=p("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Ww),F.init(t,e)}),qb=p("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Qw),F.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Yb=p("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=eb),F.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Vb=p("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=tb),F.init(t,e)}),Hb=p("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=rb),F.init(t,e),t._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[s,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function wl(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const Wb=p("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=nb),F.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{wl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Gb(t){if(!dl.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return wl(r)}const Kb=p("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=dl),F.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{Gb(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Jb=p("$ZodE164",(t,e)=>{e.pattern??(e.pattern=ab),F.init(t,e)});function Xb(t,e=null){try{const r=t.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const Qb=p("$ZodJWT",(t,e)=>{F.init(t,e),t._zod.check=r=>{Xb(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),bl=p("$ZodNumber",(t,e)=>{H.init(t,e),t._zod.pattern=t._zod.bag.pattern??hb,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),r}}),ev=p("$ZodNumber",(t,e)=>{mb.init(t,e),bl.init(t,e)}),tv=p("$ZodBoolean",(t,e)=>{H.init(t,e),t._zod.pattern=db,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),rv=p("$ZodUnknown",(t,e)=>{H.init(t,e),t._zod.parse=r=>r}),nv=p("$ZodNever",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Ti(t,e,r){t.issues.length&&e.issues.push(...cl(r,t.issues)),e.value[r]=t.value}const sv=p("$ZodArray",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const c=s[o],l=e.element._zod.run({value:c,issues:[]},n);l instanceof Promise?i.push(l.then(u=>Ti(u,r,o))):Ti(l,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function un(t,e,r,n){t.issues.length&&e.issues.push(...cl(r,t.issues)),t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}function vl(t){const e=Object.keys(t.shape);for(const n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=zw(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function zl(t,e,r,n,s,i){const o=[],c=s.keySet,l=s.catchall._zod,u=l.def.type;for(const h of Object.keys(e)){if(c.has(h))continue;if(u==="never"){o.push(h);continue}const f=l.run({value:e[h],issues:[]},n);f instanceof Promise?t.push(f.then(d=>un(d,r,h,e))):un(f,r,h,e)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),t.length?Promise.all(t).then(()=>r):r}const av=p("$ZodObject",(t,e)=>{if(H.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const o=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...o};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=va(()=>vl(e));L(t._zod,"propValues",()=>{const o=e.shape,c={};for(const l in o){const u=o[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(const h of u.values)c[l].add(h)}}return c});const n=ln,s=e.catchall;let i;t._zod.parse=(o,c)=>{i??(i=r.value);const l=o.value;if(!n(l))return o.issues.push({expected:"object",code:"invalid_type",input:l,inst:t}),o;o.value={};const u=[],h=i.shape;for(const f of i.keys){const d=h[f]._zod.run({value:l[f],issues:[]},c);d instanceof Promise?u.push(d.then(v=>un(v,o,f,l))):un(d,o,f,l)}return s?zl(u,l,o,c,r.value,t):u.length?Promise.all(u).then(()=>o):o}}),iv=p("$ZodObjectJIT",(t,e)=>{av.init(t,e);const r=t._zod.parse,n=va(()=>vl(e)),s=f=>{const d=new Eb(["shape","payload","ctx"]),v=n.value,x=I=>{const G=vi(I);return`shape[${G}]._zod.run({ value: input[${G}], issues: [] }, ctx)`};d.write("const input = payload.value;");const j=Object.create(null);let w=0;for(const I of v.keys)j[I]=`key_${w++}`;d.write("const newResult = {};");for(const I of v.keys){const G=j[I],ne=vi(I);d.write(`const ${G} = ${x(I)};`),d.write(`
24
- if (${G}.issues.length) {
25
- payload.issues = payload.issues.concat(${G}.issues.map(iss => ({
26
- ...iss,
27
- path: iss.path ? [${ne}, ...iss.path] : [${ne}]
28
- })));
29
- }
30
-
31
-
32
- if (${G}.value === undefined) {
33
- if (${ne} in input) {
34
- newResult[${ne}] = undefined;
35
- }
36
- } else {
37
- newResult[${ne}] = ${G}.value;
38
- }
39
-
40
- `)}d.write("payload.value = newResult;"),d.write("return payload;");const O=d.compile();return(I,G)=>O(f,I,G)};let i;const o=ln,c=!al.jitless,l=c&&bw.value,u=e.catchall;let h;t._zod.parse=(f,d)=>{h??(h=n.value);const v=f.value;return o(v)?c&&l&&d?.async===!1&&d.jitless!==!0?(i||(i=s(e.shape)),f=i(f,d),u?zl([],v,f,d,h,t):f):r(f,d):(f.issues.push({expected:"object",code:"invalid_type",input:v,inst:t}),f)}});function Oi(t,e,r,n){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!Et(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(i=>i.issues.map(o=>ft(o,n,dt())))}),e)}const ov=p("$ZodUnion",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),L(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),L(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),L(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Ta(i.source)).join("|")})$`)}});const r=e.options.length===1,n=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(r)return n(s,i);let o=!1;const c=[];for(const l of e.options){const u=l._zod.run({value:s.value,issues:[]},i);if(u instanceof Promise)c.push(u),o=!0;else{if(u.issues.length===0)return u;c.push(u)}}return o?Promise.all(c).then(l=>Oi(l,s,t,i)):Oi(c,s,t,i)}}),cv=p("$ZodIntersection",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,i=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,l])=>Si(r,c,l)):Si(r,i,o)}});function Zs(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(dr(t)&&dr(e)){const r=Object.keys(e),n=Object.keys(t).filter(i=>r.indexOf(i)!==-1),s={...t,...e};for(const i of n){const o=Zs(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<t.length;n++){const s=t[n],i=e[n],o=Zs(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Si(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Et(t))return t;const n=Zs(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}const lv=p("$ZodEnum",(t,e)=>{H.init(t,e);const r=gw(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(s=>vw.has(typeof s)).map(s=>typeof s=="string"?On(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:r,input:o,inst:t}),s}}),uv=p("$ZodTransform",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new sl(t.constructor.name);const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new jt;return r.value=s,r}});function ki(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const hv=p("$ZodOptional",(t,e)=>{H.init(t,e),t._zod.optin="optional",t._zod.optout="optional",L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ta(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>ki(i,r.value)):ki(s,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),dv=p("$ZodNullable",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ta(r.source)}|null)$`):void 0}),L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),fv=p("$ZodDefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ni(i,e)):Ni(s,e)}});function Ni(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const pv=p("$ZodPrefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),yv=p("$ZodNonOptional",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ei(i,t)):Ei(s,t)}});function Ei(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const mv=p("$ZodCatch",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>(r.value=i.value,i.issues.length&&(r.value=e.catchValue({...r,error:{issues:i.issues.map(o=>ft(o,n,dt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>ft(i,n,dt()))},input:r.value}),r.issues=[]),r)}}),gv=p("$ZodPipe",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>e.in._zod.values),L(t._zod,"optin",()=>e.in._zod.optin),L(t._zod,"optout",()=>e.out._zod.optout),L(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=e.out._zod.run(r,n);return i instanceof Promise?i.then(o=>Gr(o,e.in,n)):Gr(i,e.in,n)}const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(i=>Gr(i,e.out,n)):Gr(s,e.out,n)}});function Gr(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}const wv=p("$ZodReadonly",(t,e)=>{H.init(t,e),L(t._zod,"propValues",()=>e.innerType._zod.propValues),L(t._zod,"values",()=>e.innerType._zod.values),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(Ai):Ai(s)}});function Ai(t){return t.value=Object.freeze(t.value),t}const bv=p("$ZodCustom",(t,e)=>{ie.init(t,e),H.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(i=>Ii(i,r,n,t));Ii(s,r,n,t)}});function Ii(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(fr(s))}}class vv{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){const n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function zv(){return new vv}const Kr=zv();function Tv(t,e){return new t({type:"string",...E(e)})}function Ov(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...E(e)})}function xi(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...E(e)})}function Tl(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...E(e)})}function Sv(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(e)})}function kv(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(e)})}function Nv(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(e)})}function Ev(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...E(e)})}function Av(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...E(e)})}function Iv(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(e)})}function xv(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...E(e)})}function Cv(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(e)})}function jv(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...E(e)})}function $v(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...E(e)})}function Mv(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(e)})}function Uv(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(e)})}function Zv(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(e)})}function Pv(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(e)})}function _v(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(e)})}function Rv(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...E(e)})}function Dv(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...E(e)})}function Lv(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...E(e)})}function Bv(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...E(e)})}function Fv(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(e)})}function qv(t,e){return new t({type:"string",format:"date",check:"string_format",...E(e)})}function Yv(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...E(e)})}function Vv(t,e){return new t({type:"string",format:"duration",check:"string_format",...E(e)})}function Hv(t,e){return new t({type:"number",checks:[],...E(e)})}function Wv(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...E(e)})}function Gv(t,e){return new t({type:"boolean",...E(e)})}function Kv(t){return new t({type:"unknown"})}function Jv(t,e){return new t({type:"never",...E(e)})}function Ci(t,e){return new ml({check:"less_than",...E(e),value:t,inclusive:!1})}function Kn(t,e){return new ml({check:"less_than",...E(e),value:t,inclusive:!0})}function ji(t,e){return new gl({check:"greater_than",...E(e),value:t,inclusive:!1})}function Jn(t,e){return new gl({check:"greater_than",...E(e),value:t,inclusive:!0})}function $i(t,e){return new yb({check:"multiple_of",...E(e),value:t})}function Ol(t,e){return new gb({check:"max_length",...E(e),maximum:t})}function hn(t,e){return new wb({check:"min_length",...E(e),minimum:t})}function Sl(t,e){return new bb({check:"length_equals",...E(e),length:t})}function Xv(t,e){return new vb({check:"string_format",format:"regex",...E(e),pattern:t})}function Qv(t){return new zb({check:"string_format",format:"lowercase",...E(t)})}function ez(t){return new Tb({check:"string_format",format:"uppercase",...E(t)})}function tz(t,e){return new Ob({check:"string_format",format:"includes",...E(e),includes:t})}function rz(t,e){return new Sb({check:"string_format",format:"starts_with",...E(e),prefix:t})}function nz(t,e){return new kb({check:"string_format",format:"ends_with",...E(e),suffix:t})}function xr(t){return new Nb({check:"overwrite",tx:t})}function sz(t){return xr(e=>e.normalize(t))}function az(){return xr(t=>t.trim())}function iz(){return xr(t=>t.toLowerCase())}function oz(){return xr(t=>t.toUpperCase())}function cz(t,e,r){return new t({type:"array",element:e,...E(r)})}function lz(t,e,r){return new t({type:"custom",check:"custom",fn:e,...E(r)})}function uz(t){const e=hz(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(fr(n,r.value,e._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(fr(s))}},t(r.value,r)));return e}function hz(t,e){const r=new ie({check:"custom",...E(e)});return r._zod.check=t,r}const dz=p("ZodISODateTime",(t,e)=>{Db.init(t,e),Y.init(t,e)});function fz(t){return Fv(dz,t)}const pz=p("ZodISODate",(t,e)=>{Lb.init(t,e),Y.init(t,e)});function yz(t){return qv(pz,t)}const mz=p("ZodISOTime",(t,e)=>{Bb.init(t,e),Y.init(t,e)});function gz(t){return Yv(mz,t)}const wz=p("ZodISODuration",(t,e)=>{Fb.init(t,e),Y.init(t,e)});function bz(t){return Vv(wz,t)}const vz=(t,e)=>{ul.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Cw(t,r)},flatten:{value:r=>xw(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,Us,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,Us,2)}},isEmpty:{get(){return t.issues.length===0}}})},we=p("ZodError",vz,{Parent:Error}),zz=Sa(we),Tz=ka(we),Oz=Sn(we),Sz=kn(we),kz=Mw(we),Nz=Uw(we),Ez=Zw(we),Az=Pw(we),Iz=_w(we),xz=Rw(we),Cz=Dw(we),jz=Lw(we),W=p("ZodType",(t,e)=>(H.init(t,e),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone(gt(e,{checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]})),t.clone=(r,n)=>Qe(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>zz(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Oz(t,r,n),t.parseAsync=async(r,n)=>Tz(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Sz(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>kz(t,r,n),t.decode=(r,n)=>Nz(t,r,n),t.encodeAsync=async(r,n)=>Ez(t,r,n),t.decodeAsync=async(r,n)=>Az(t,r,n),t.safeEncode=(r,n)=>Iz(t,r,n),t.safeDecode=(r,n)=>xz(t,r,n),t.safeEncodeAsync=async(r,n)=>Cz(t,r,n),t.safeDecodeAsync=async(r,n)=>jz(t,r,n),t.refine=(r,n)=>t.check(ST(r,n)),t.superRefine=r=>t.check(kT(r)),t.overwrite=r=>t.check(xr(r)),t.optional=()=>_i(t),t.nullable=()=>Ri(t),t.nullish=()=>_i(Ri(t)),t.nonoptional=r=>gT(t,r),t.array=()=>sT(t),t.or=r=>Ea([t,r]),t.and=r=>cT(t,r),t.transform=r=>Di(t,hT(r)),t.default=r=>pT(t,r),t.prefault=r=>mT(t,r),t.catch=r=>bT(t,r),t.pipe=r=>Di(t,r),t.readonly=()=>TT(t),t.describe=r=>{const n=t.clone();return Kr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Kr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Kr.get(t);const n=t.clone();return Kr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),kl=p("_ZodString",(t,e)=>{Na.init(t,e),W.init(t,e);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Xv(...n)),t.includes=(...n)=>t.check(tz(...n)),t.startsWith=(...n)=>t.check(rz(...n)),t.endsWith=(...n)=>t.check(nz(...n)),t.min=(...n)=>t.check(hn(...n)),t.max=(...n)=>t.check(Ol(...n)),t.length=(...n)=>t.check(Sl(...n)),t.nonempty=(...n)=>t.check(hn(1,...n)),t.lowercase=n=>t.check(Qv(n)),t.uppercase=n=>t.check(ez(n)),t.trim=()=>t.check(az()),t.normalize=(...n)=>t.check(sz(...n)),t.toLowerCase=()=>t.check(iz()),t.toUpperCase=()=>t.check(oz())}),$z=p("ZodString",(t,e)=>{Na.init(t,e),kl.init(t,e),t.email=r=>t.check(Ov(Mz,r)),t.url=r=>t.check(Ev(Zz,r)),t.jwt=r=>t.check(Bv(Jz,r)),t.emoji=r=>t.check(Av(Pz,r)),t.guid=r=>t.check(xi(Mi,r)),t.uuid=r=>t.check(Tl(ar,r)),t.uuidv4=r=>t.check(Sv(ar,r)),t.uuidv6=r=>t.check(kv(ar,r)),t.uuidv7=r=>t.check(Nv(ar,r)),t.nanoid=r=>t.check(Iv(_z,r)),t.guid=r=>t.check(xi(Mi,r)),t.cuid=r=>t.check(xv(Rz,r)),t.cuid2=r=>t.check(Cv(Dz,r)),t.ulid=r=>t.check(jv(Lz,r)),t.base64=r=>t.check(Rv(Wz,r)),t.base64url=r=>t.check(Dv(Gz,r)),t.xid=r=>t.check($v(Bz,r)),t.ksuid=r=>t.check(Mv(Fz,r)),t.ipv4=r=>t.check(Uv(qz,r)),t.ipv6=r=>t.check(Zv(Yz,r)),t.cidrv4=r=>t.check(Pv(Vz,r)),t.cidrv6=r=>t.check(_v(Hz,r)),t.e164=r=>t.check(Lv(Kz,r)),t.datetime=r=>t.check(fz(r)),t.date=r=>t.check(yz(r)),t.time=r=>t.check(gz(r)),t.duration=r=>t.check(bz(r))});function ge(t){return Tv($z,t)}const Y=p("ZodStringFormat",(t,e)=>{F.init(t,e),kl.init(t,e)}),Mz=p("ZodEmail",(t,e)=>{Cb.init(t,e),Y.init(t,e)}),Mi=p("ZodGUID",(t,e)=>{Ib.init(t,e),Y.init(t,e)}),ar=p("ZodUUID",(t,e)=>{xb.init(t,e),Y.init(t,e)});function Uz(t){return Tl(ar,t)}const Zz=p("ZodURL",(t,e)=>{jb.init(t,e),Y.init(t,e)}),Pz=p("ZodEmoji",(t,e)=>{$b.init(t,e),Y.init(t,e)}),_z=p("ZodNanoID",(t,e)=>{Mb.init(t,e),Y.init(t,e)}),Rz=p("ZodCUID",(t,e)=>{Ub.init(t,e),Y.init(t,e)}),Dz=p("ZodCUID2",(t,e)=>{Zb.init(t,e),Y.init(t,e)}),Lz=p("ZodULID",(t,e)=>{Pb.init(t,e),Y.init(t,e)}),Bz=p("ZodXID",(t,e)=>{_b.init(t,e),Y.init(t,e)}),Fz=p("ZodKSUID",(t,e)=>{Rb.init(t,e),Y.init(t,e)}),qz=p("ZodIPv4",(t,e)=>{qb.init(t,e),Y.init(t,e)}),Yz=p("ZodIPv6",(t,e)=>{Yb.init(t,e),Y.init(t,e)}),Vz=p("ZodCIDRv4",(t,e)=>{Vb.init(t,e),Y.init(t,e)}),Hz=p("ZodCIDRv6",(t,e)=>{Hb.init(t,e),Y.init(t,e)}),Wz=p("ZodBase64",(t,e)=>{Wb.init(t,e),Y.init(t,e)}),Gz=p("ZodBase64URL",(t,e)=>{Kb.init(t,e),Y.init(t,e)}),Kz=p("ZodE164",(t,e)=>{Jb.init(t,e),Y.init(t,e)}),Jz=p("ZodJWT",(t,e)=>{Qb.init(t,e),Y.init(t,e)}),Nl=p("ZodNumber",(t,e)=>{bl.init(t,e),W.init(t,e),t.gt=(n,s)=>t.check(ji(n,s)),t.gte=(n,s)=>t.check(Jn(n,s)),t.min=(n,s)=>t.check(Jn(n,s)),t.lt=(n,s)=>t.check(Ci(n,s)),t.lte=(n,s)=>t.check(Kn(n,s)),t.max=(n,s)=>t.check(Kn(n,s)),t.int=n=>t.check(Zi(n)),t.safe=n=>t.check(Zi(n)),t.positive=n=>t.check(ji(0,n)),t.nonnegative=n=>t.check(Jn(0,n)),t.negative=n=>t.check(Ci(0,n)),t.nonpositive=n=>t.check(Kn(0,n)),t.multipleOf=(n,s)=>t.check($i(n,s)),t.step=(n,s)=>t.check($i(n,s)),t.finite=()=>t;const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function Ui(t){return Hv(Nl,t)}const Xz=p("ZodNumberFormat",(t,e)=>{ev.init(t,e),Nl.init(t,e)});function Zi(t){return Wv(Xz,t)}const Qz=p("ZodBoolean",(t,e)=>{tv.init(t,e),W.init(t,e)});function Cr(t){return Gv(Qz,t)}const eT=p("ZodUnknown",(t,e)=>{rv.init(t,e),W.init(t,e)});function Pi(){return Kv(eT)}const tT=p("ZodNever",(t,e)=>{nv.init(t,e),W.init(t,e)});function rT(t){return Jv(tT,t)}const nT=p("ZodArray",(t,e)=>{sv.init(t,e),W.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(hn(r,n)),t.nonempty=r=>t.check(hn(1,r)),t.max=(r,n)=>t.check(Ol(r,n)),t.length=(r,n)=>t.check(Sl(r,n)),t.unwrap=()=>t.element});function sT(t,e){return cz(nT,t,e)}const aT=p("ZodObject",(t,e)=>{iv.init(t,e),W.init(t,e),L(t,"shape",()=>e.shape),t.keyof=()=>lT(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Pi()}),t.loose=()=>t.clone({...t._zod.def,catchall:Pi()}),t.strict=()=>t.clone({...t._zod.def,catchall:rT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>kw(t,r),t.safeExtend=r=>Nw(t,r),t.merge=r=>Ew(t,r),t.pick=r=>Ow(t,r),t.omit=r=>Sw(t,r),t.partial=(...r)=>Aw(El,t,r[0]),t.required=(...r)=>Iw(Al,t,r[0])});function ee(t,e){const r={type:"object",shape:t??{},...E(e)};return new aT(r)}const iT=p("ZodUnion",(t,e)=>{ov.init(t,e),W.init(t,e),t.options=e.options});function Ea(t,e){return new iT({type:"union",options:t,...E(e)})}const oT=p("ZodIntersection",(t,e)=>{cv.init(t,e),W.init(t,e)});function cT(t,e){return new oT({type:"intersection",left:t,right:e})}const Ps=p("ZodEnum",(t,e)=>{lv.init(t,e),W.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const i={};for(const o of n)if(r.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ps({...e,checks:[],...E(s),entries:i})},t.exclude=(n,s)=>{const i={...e.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ps({...e,checks:[],...E(s),entries:i})}});function lT(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Ps({type:"enum",entries:r,...E(e)})}const uT=p("ZodTransform",(t,e)=>{uv.init(t,e),W.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new sl(t.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(fr(i,r.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),r.issues.push(fr(o))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(i=>(r.value=i,r)):(r.value=s,r)}});function hT(t){return new uT({type:"transform",transform:t})}const El=p("ZodOptional",(t,e)=>{hv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function _i(t){return new El({type:"optional",innerType:t})}const dT=p("ZodNullable",(t,e)=>{dv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ri(t){return new dT({type:"nullable",innerType:t})}const fT=p("ZodDefault",(t,e)=>{fv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function pT(t,e){return new fT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():ol(e)}})}const yT=p("ZodPrefault",(t,e)=>{pv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function mT(t,e){return new yT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():ol(e)}})}const Al=p("ZodNonOptional",(t,e)=>{yv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function gT(t,e){return new Al({type:"nonoptional",innerType:t,...E(e)})}const wT=p("ZodCatch",(t,e)=>{mv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function bT(t,e){return new wT({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const vT=p("ZodPipe",(t,e)=>{gv.init(t,e),W.init(t,e),t.in=e.in,t.out=e.out});function Di(t,e){return new vT({type:"pipe",in:t,out:e})}const zT=p("ZodReadonly",(t,e)=>{wv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function TT(t){return new zT({type:"readonly",innerType:t})}const OT=p("ZodCustom",(t,e)=>{bv.init(t,e),W.init(t,e)});function ST(t,e={}){return lz(OT,t,e)}function kT(t){return uz(t)}const En=a.z.string(),jr=t=>qt.statusZ(t),Il=t=>jr(t).omit({labels:!0}).partial({key:!0}),NT="sy_status_set",ET="sy_status_delete",AT=t=>({type:"status",key:t}),je=t=>t?JSON.parse(t):{},Aa=ee({key:ge(),type:ge(),config:Te.unknownZ.or(ge().transform(je))}),xl=Aa.extend({position:ha.xy}),_s=ee({param:ge(),node:ge()}),Ia=ee({source:_s,target:_s}),IT=ee({nodes:Aa.array(),edges:Ia.array()}),Cl=ee({nodes:xl.array(),edges:Ia.array()}),jl=ee({raw:ge()}),$r=Uz(),$l=ee({running:Cr()}),Ml=jr($l),An=ee({key:$r,name:ge(),graph:Cl,text:jl,deploy:Cr(),version:ge(),status:Ml.optional().nullable()}),Ul=An.partial({key:!0}).omit({status:!0}),Zl="arc",xT=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let s=b.toArray(t);const i=s[0],o=typeof i;let c;return o==="string"&&r&&!isNaN(parseInt(i))&&"number"in e?(c=e.number,s=s.map(l=>parseInt(l))):c=e[o],{single:n,variant:c,normalized:s,actual:t}},ue=(t,e,r,n)=>{if(n){if(r.length===0)throw new Ut(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new cn(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},CT="sy_arc_set",jT="sy_arc_delete",$T="/arc/retrieve",MT="/arc/create",UT="/arc/delete",ZT="/arc/lsp",PT=ee({keys:$r.array().optional(),names:ge().array().optional(),searchTerm:ge().optional(),limit:Ui().optional(),offset:Ui().optional(),includeStatus:Cr().optional()}),_T=ee({arcs:Ul.array()}),RT=ee({keys:$r.array()}),DT=ee({arcs:b.nullableZ(An)}),LT=ee({arcs:An.array()}),BT=ee({}),Rs=ee({content:ge()}),FT=ee({key:$r,includeStatus:Cr().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),qT=ee({name:ge(),includeStatus:Cr().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),Pl=Ea([FT,qT]),YT=Ea([Pl,PT]);let _l=class{client;streamClient;constructor(t,e){this.client=t,this.streamClient=e}async create(t){const e=Array.isArray(t),r=await g(this.client,MT,{arcs:b.toArray(t)},_T,LT);return e?r.arcs:r.arcs[0]}async retrieve(t){const e="key"in t||"name"in t,r=await g(this.client,$T,t,YT,DT);return ue("Arc",t,r.arcs,e),e?r.arcs[0]:r.arcs}async delete(t){await g(this.client,UT,{keys:b.toArray(t)},RT,BT)}async openLSP(){return await this.streamClient.stream(ZT,Rs,Rs)}};const VT=t=>({type:Zl,key:t}),HT=Object.freeze(Object.defineProperty({__proto__:null,Client:_l,DELETE_CHANNEL_NAME:jT,ONTOLOGY_TYPE:Zl,SET_CHANNEL_NAME:CT,arcZ:An,edgeZ:Ia,graphNodeZ:xl,graphZ:Cl,handleZ:_s,irNodeZ:Aa,irZ:IT,keyZ:$r,lspMessageZ:Rs,newZ:Ul,ontologyID:VT,singleRetrieveArgsZ:Pl,statusDetailsZ:$l,statusZ:Ml,textZ:jl},Symbol.toStringTag,{value:"Module"})),Li="Channel key must be a valid uint32.",D=a.z.uint32().or(a.z.string().refine(t=>!isNaN(Number(t)),{message:Li}).transform(Number).refine(t=>t<Ns.MAX_UINT32,{message:Li})),Ze=a.z.string(),Rl=["min","max","avg","none"],Dl=a.z.enum(Rl),xa=a.z.object({type:Dl,resetChannel:D.optional(),duration:N.z.optional()}),Ll=qt.statusZ(),Yt=a.z.object({name:Ze,key:D,dataType:Z.z,leaseholder:a.z.number(),index:D,isIndex:a.z.boolean(),internal:a.z.boolean(),virtual:a.z.boolean(),alias:a.z.string().optional(),expression:a.z.string().default(""),status:Ll.optional(),operations:b.nullableZ(xa),requires:b.nullableZ(D)}),Bl=Yt.extend({key:D.optional(),leaseholder:a.z.number().optional(),index:D.optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional().default(!1),virtual:a.z.boolean().optional().default(!1),expression:a.z.string().optional().default(""),operations:b.nullableZ(xa).optional(),requires:b.nullableZ(D).optional()}),wt=a.z.union([ir.toArray(D),ir.toArray(Ze),ir.toArray(Yt).transform(t=>t.map(e=>e.key))]),WT=new Error("request for lock canceled");var GT=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class KT{constructor(e,r=WT){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,s)=>{const i={resolve:n,reject:s,weight:e,priority:r},o=Fl(this._queue,c=>r<=c.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return GT(this,arguments,void 0,function*(r,n=1,s=0){const[i,o]=yield this.acquire(n,s);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),JT(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const s=n.findIndex(i=>i.priority<=e);(s===-1?n:n.splice(0,s)).forEach((i=>i.resolve()))}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function JT(t,e){const r=Fl(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Fl(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var XT=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class QT{constructor(e){this._semaphore=new KT(1,e)}acquire(){return XT(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const eO=a.z.object({leaseholder:a.z.number().optional(),keys:D.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),rangeKey:a.z.string().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),dataTypes:Z.z.array().optional(),notDataTypes:Z.z.array().optional(),virtual:a.z.boolean().optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional(),calculated:a.z.boolean().optional(),legacyCalculated:a.z.boolean().optional()}),tO=a.z.object({channels:b.nullableZ(Yt)}),ve=t=>(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"?t=t.map(e=>e.key):typeof t=="object"&&"key"in t&&(t=[t.key]),xT(t,{number:"keys",string:"names"}));class Mr{static ENDPOINT="/channel/retrieve";client;constructor(e){this.client=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.execute(e);const n=ve(e),{variant:s}=n;let{normalized:i}=n;return s==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[s]:i,...r})}async execute(e){const[r,n]=await this.client.send(Mr.ENDPOINT,e,eO,tO);if(n!=null)throw n;return r.channels}}class Ca{cache;namesToKeys;wrapped;constructor(e){this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:n}=ve(e),s=[],i=[];if(n.forEach(c=>{const l=this.get(c);l!=null?s.push(...l):i.push(c)}),i.length===0)return s;const o=await this.wrapped.retrieve(i,r);return this.set(o),s.concat(o)}delete(e){const{variant:r,normalized:n}=ve(e);r==="names"?n.forEach(s=>{const i=this.namesToKeys.get(s);i!=null&&(i.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(s))}):n.forEach(s=>{const i=this.cache.get(s);i!=null&&(this.cache.delete(s),this.namesToKeys.delete(i.name))})}rename(e,r){e.forEach((n,s)=>{const i=r[s],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(n),c.size===0&&this.namesToKeys.delete(o.name)),o.name=i,this.cache.set(n,o);const l=this.namesToKeys.get(i);l==null?this.namesToKeys.set(i,new Set([n])):l.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const s=this.cache.get(e);return s==null?void 0:[s]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(s=>{const i=this.cache.get(s);i!=null&&n.push(i)}),n.length!==0)return n}}class ql{mu=new QT;requests=new Map;wrapped;debouncedRun;constructor(e,r){this.wrapped=e,this.debouncedRun=Xy(()=>{this.run()},r)}async retrieve(e){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:r,variant:n}=ve(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((s,i)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:s,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(s=>e.add(s)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(r.filter(i=>s.includes(i.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const Yl=async(t,e)=>{const{normalized:r}=ve(e),n=await t.retrieve(r),s=[];if(r.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&s.push(i)}),s.length>0)throw new Xe(`Could not find channels: ${JSON.stringify(s)}`);return n},rO="sy_channel_set",nO="sy_channel_delete";class Ds{_frameClient;key;name;dataType;leaseholder;index;isIndex;internal;alias;virtual;expression;operations;requires;status;constructor({dataType:e,name:r,leaseholder:n=0,key:s=0,isIndex:i=!1,index:o=0,internal:c=!1,virtual:l=!1,frameClient:u,alias:h,status:f,expression:d="",operations:v=[],requires:x=[]}){this.key=D.parse(s),this.name=r,this.dataType=new Z(e),this.leaseholder=n,this.index=D.parse(o),this.isIndex=i,this.internal=c,this.alias=h,this.virtual=l,this.expression=d,this.operations=v,this.requires=x,f!=null&&(this.status=qt.create(f)),this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new V("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Yt.parse({key:this.key,name:this.name,dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,requires:this.requires,expression:this.expression,status:this.status,operations:this.operations})}get isCalculated(){return pr(this.payload)}get ontologyID(){return Hl(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const sO="sy_calculation_status",aO="/channel/retrieve-group",iO=a.z.object({}),oO=a.z.object({group:zn});let Vl=class{frameClient;client;retriever;writer;constructor(t,e,r,n){this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let s=b.toArray(t),i=[];if(r){const o=await this.retriever.retrieve(s.map(l=>l.name)),c=new Set(o.map(l=>l.name));s=s.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(s))),n?i[0]:i}async retrieve(t,e){if(typeof t=="object"&&!Array.isArray(t))return this.sugar(await this.retriever.retrieve(t));const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return ue("channel",t,n,r),r?n[0]:n}async delete(t){const{normalized:e,variant:r}=ve(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(b.toArray(t),b.toArray(e))}createDebouncedBatchRetriever(t=10){return new Ca(new ql(new Mr(this.client),t))}sugar(t){const{frameClient:e}=this;return Array.isArray(t)?t.map(r=>new Ds({...r,frameClient:e})):new Ds({...t,frameClient:e})}async retrieveGroup(){return(await g(this.client,aO,{},iO,oO)).group}};const pr=({virtual:t,expression:e})=>t&&e!=="",cO=t=>pr(t)&&t.requires.length>0,Hl=t=>({type:"channel",key:t.toString()}),Wl=async(t,e)=>{if(!pr(e))return e.index;for(const r of e.requires){const n=await t(r);if(n==null)return null;if(!n.virtual)return n.index}for(const r of e.requires){const n=await t(r);if(n==null)return null;if(pr(n)){const s=await Wl(t,n);if(s!=null)return s}}return null},lO=a.z.object({channels:Bl.array()}),uO=a.z.object({channels:Yt.array()}),hO=a.z.object({keys:D.array().optional(),names:Ze.array().optional()}),dO=a.z.object({}),fO=a.z.object({keys:D.array(),names:Ze.array()}),pO=a.z.object({}),yO="/channel/create",mO="/channel/delete",gO="/channel/rename";let Gl=class{client;cache;constructor(t,e){this.client=t,this.cache=e}async create(t){const{channels:e}=await g(this.client,yO,{channels:t.map(r=>({...r,dataType:r.dataType}))},lO,uO);return this.cache.set(e),e}async delete(t){const e=D.array().parse(t.keys??[]);await g(this.client,mO,t,hO,dO),e.length>0&&this.cache.delete(e),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await g(this.client,gO,{keys:t,names:e},fO,pO),this.cache.rename(t,e)}};const wO=Object.freeze(Object.defineProperty({__proto__:null,CALCULATION_STATUS_CHANNEL_NAME:sO,CacheRetriever:Ca,Channel:Ds,Client:Vl,ClusterRetriever:Mr,DELETE_CHANNEL_NAME:nO,DebouncedBatchRetriever:ql,OPERATION_TYPES:Rl,SET_CHANNEL_NAME:rO,Writer:Gl,analyzeParams:ve,isCalculated:pr,isLegacyCalculated:cO,keyZ:D,nameZ:Ze,newZ:Bl,ontologyID:Hl,operationType:Dl,operationZ:xa,paramsZ:wt,payloadZ:Yt,resolveLegacyCalculatedIndex:Wl,retrieveRequired:Yl,statusZ:Ll},Symbol.toStringTag,{value:"Module"})),et=a.z.uuid(),Ur=a.z.object({key:et,username:a.z.string().min(1,"Username is required"),firstName:a.z.string().default(""),lastName:a.z.string().default(""),rootUser:a.z.boolean().default(!0)}),Kl=Ur.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:a.z.string().min(1)}),bO=a.z.object({keys:et.array().optional(),usernames:a.z.string().array().optional()}),vO=a.z.object({key:et}).transform(({key:t})=>({keys:[t]})),zO=a.z.object({username:a.z.string()}).transform(({username:t})=>({usernames:[t]})),TO=a.z.object({usernames:a.z.string().array()}).transform(({usernames:t})=>({usernames:t})),OO=a.z.union([vO,zO,TO,bO]),SO=a.z.object({users:b.nullableZ(Ur)}),kO=a.z.object({users:Kl.array()}),NO=a.z.object({users:Ur.array()}),EO=a.z.object({key:et,username:a.z.string().min(1)}),AO=a.z.object({}),IO=a.z.object({key:et,firstName:a.z.string().optional(),lastName:a.z.string().optional()}),xO=a.z.object({}),CO=a.z.object({keys:et.array()}),jO=a.z.object({}),$O="/user/retrieve",MO="/user/create",UO="/user/change-username",ZO="/user/rename",PO="/user/delete";let Jl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await g(this.client,MO,{users:b.toArray(t)},kO,NO);return e?r.users:r.users[0]}async changeUsername(t,e){await g(this.client,UO,{key:t,username:e},EO,AO)}async retrieve(t){const e="key"in t||"username"in t,r=await g(this.client,$O,t,OO,SO);if(!e)return r.users;if(r.users.length===0){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new Ut(`No user with ${n} found`)}if(r.users.length>1){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new cn(`Multiple users found with ${n}`)}return r.users[0]}async rename(t,e,r){await g(this.client,ZO,{key:t,firstName:e,lastName:r},IO,xO)}async delete(t){await g(this.client,PO,{keys:b.toArray(t)},CO,jO)}};const _O=t=>({type:"user",key:t}),RO=Object.freeze(Object.defineProperty({__proto__:null,Client:Jl,keyZ:et,newZ:Kl,ontologyID:_O,userZ:Ur},Symbol.toStringTag,{value:"Module"})),DO=a.z.object({username:a.z.string(),password:a.z.string()}),LO=a.z.object({token:a.z.string(),user:Ur}),Bi="/auth/login",BO=3,FO="/auth/change-password",qO=a.z.object({username:a.z.string(),password:a.z.string(),newPassword:a.z.string().min(1)}),YO=a.z.object({}),VO=[js,$s];let HO=class{token;client;credentials;authenticating;authenticated;user;retryCount;constructor(t,e){this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await g(this.client,FO,{username:this.credentials.username,password:this.credentials.password,newPassword:t},qO,YO),this.credentials.password=t}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(Bi)){this.authenticating??=new Promise((o,c)=>{this.client.send(Bi,this.credentials,DO,LO).then(([l,u])=>{if(u!=null)return o(u);this.token=l?.token,this.user=l?.user,this.authenticated=!0,o(null)}).catch(c)});const i=await this.authenticating;if(i!=null)return[e,i]}e.params.Authorization=`Bearer ${this.token}`;const[n,s]=await r(e);return VO.some(i=>i.matches(s))&&this.retryCount<BO?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,s])};return t}};const WO=a.z.enum(["disconnected","connecting","connected","failed"]),GO=a.z.object({status:WO,error:a.z.instanceof(Error).optional(),message:a.z.string().optional(),clusterKey:a.z.string(),clientVersion:a.z.string(),clientServerCompatible:a.z.boolean(),nodeVersion:a.z.string().optional()}),KO=a.z.object({clusterKey:a.z.string(),nodeVersion:a.z.string().optional()}),JO=a.z.void(),Fi={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.48.0"},qi=(t,e,r)=>{const n=r?"Core":"client";return`Synnax Core version ${t!=null?`${t} `:""}is too ${r?"old":"new"} for client version ${e}.
41
- This may cause compatibility issues. We recommend updating the ${n}. For more information, see
42
- https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${n}-version`};class Ls{static DEFAULT=Fi;_state;pollFrequency=N.seconds(30);client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=GO;versionWarned=!1;constructor(e,r=N.seconds(30),n,s){this._state={...Fi},this.client=e,this.pollFrequency=r,this.clientVersion=n,this.name=s,this.check(),this.start()}stop(){this.interval!=null&&clearInterval(this.interval)}async check(){const e=this._state.status;try{const r=await g(this.client,"/connectivity/check",void 0,JO,KO),n=r.nodeVersion,s=this.clientVersion,i=this.versionWarned;n==null?(this._state.clientServerCompatible=!1,i||(console.warn(qi(null,s,!0)),this.versionWarned=!0)):yi.versionsEqual(s,n,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,i||(console.warn(qi(n,s,yi.semVerNewer(s,n))),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=this.state.error?.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(r=>r(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}start(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}}const XO=a.z.object({keys:D.array().optional(),bounds:B.z,names:Ze.array().optional()}),QO=a.z.object({});class eS{client;constructor(e){this.client=e}async delete(e){await g(this.client,"/frame/delete",e,XO,QO)}}const Yi=t=>{const e=b.toArray(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Vi=(t,e)=>{const r=b.toArray(t);if(r.length===e.length)return;const n=Yi(t);throw Yi===null?new V("[Frame] - channel keys or names must be provided when constructing a frame."):new V(`[Frame] - ${n}s and series must be the same length.
43
- Got ${r.length} ${n}s and ${e.length} series.`)};let ce=class at{columns=[];series=[];constructor(e=[],r=[]){if(e instanceof at){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,s)=>this.push(s,...b.toArray(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e;n.series??=[],n.keys??=[];const s=n.series.map(i=>Xl(i));Vi(n.keys,s),n.keys.forEach((i,o)=>this.push(i,s[o]))}else Object.entries(e).forEach(([n,s])=>{const i=parseInt(n);if(!isNaN(i))return this.push(i,...b.toArray(s));this.push(n,...b.toArray(s))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=b.toArray(r),s=b.toArray(e);Vi(s,n),n.forEach((i,o)=>this.push(s[o],i));return}throw new V(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
44
- payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
45
- 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 oi.unique(this.keys)}get names(){if(this.colType==="key")throw new le("colType is not name");return this.columns??[]}get uniqueNames(){return oi.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Ql(e)),keys:[...this.keys]}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(r=>r.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return B.ZERO;const n=C.min(...this.series.map(i=>i.timeRange.start)),s=C.max(...this.series.map(i=>i.timeRange.end));return new B(n,s)}const r=this.get(e);return r==null?B.ZERO:r.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(r=>e.includes(r)):new Gy(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof at){if(e.colType!=null&&this.colType!==null&&e.colType!==this.colType)throw new V("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...r),typeof e=="string"&&this.colType==="key")throw new V("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new V("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new at([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const r=new at;return this.forEach((n,s,i)=>r.push(...e(n,s,i))),r}mapFilter(e){const r=new at;return this.forEach((n,s,i)=>{const[o,c,l]=e(n,s,i);l&&r.push(o,c)}),r}forEach(e){this.columns.forEach((r,n)=>{const s=this.series[n];e(r,s,n)})}at(e,r=!1){const n={};return this.uniqueColumns.forEach(s=>{n[s]=this.get(s).at(e,r)}),n}filter(e){const r=new at;return this.columns.forEach((n,s)=>{const i=this.series[s];e(n,i,s)&&r.push(n,i)}),r}get byteLength(){return new Mt(this.series.reduce((e,r)=>e.add(r.byteLength),Mt.ZERO))}get digest(){const e={};return this.keys.forEach((r,n)=>{const s=this.series[n].digest;r in e?e[r].push(s):e[r]=[s]}),e}get length(){return this.series.reduce((e,r)=>e+r.length,0)}toString(){let e=`Frame{
46
- `;return this.uniqueColumns.forEach(r=>{e+=` ${r}: ${this.get(r).series.map(n=>n.toString()).join(",")}
47
- `}),e+="}",e}};const In=a.z.object({keys:a.z.union([a.z.null().transform(()=>[]),a.z.number().array().optional().default([])]),series:a.z.union([a.z.null().transform(()=>[]),Ve.crudeZ.array().optional().default([])])}),Xl=t=>{const{dataType:e,data:r,timeRange:n,alignment:s}=t;return new Ve({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},Ql=t=>({timeRange:t.timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});var xe=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.SetAuthority=3]="SetAuthority",t))(xe||{});const Hi=t=>t.data.byteLength/t.dataType.density.valueOf(),tS=t=>{const{keys:e,series:r}=t;e.forEach((n,s)=>{r[s].key=n}),r.sort((n,s)=>n.key-s.key),e.sort((n,s)=>n-s),r.forEach(n=>delete n.key)},Wi=5,Gi=4,Ki=3,Ji=2,Xi=1,Qi=0,Se=Z.TIMESTAMP.density.valueOf(),Le=8,Be=4,Xn=4,Qn=4,rS=1;class eu{contentType="application/sy-framer";states=new Map;currState;seqNum=0;constructor(e=[],r=[]){(e.length>0||r.length>0)&&this.update(e,r)}update(e,r){this.seqNum++;const n={keys:e,keyDataTypes:new Map,hasVariableDataTypes:!1};e.forEach((s,i)=>{const o=r[i];n.keyDataTypes.set(s,o),o.isVariable&&(n.hasVariableDataTypes=!0)}),n.keys.sort(),this.states.set(this.seqNum,n),this.currState=n}throwIfNotUpdated(e){if(this.seqNum<1)throw new V(`
48
- The codec has not been updated with a list of channels and data types.
49
- Please call the update method before calling ${e}.
50
- `)}encode(e,r=0){this.throwIfNotUpdated("encode");let n=e;e!=null&&typeof e=="object"&&"toPayload"in e&&(n=e.toPayload()),tS(n);let s=-1,i,o,c,l=r+rS+Qn,u=!this.currState?.hasVariableDataTypes,h=!0,f=!0,d=!0,v=!0,x=!0;n.keys.length!==this.currState?.keys.length&&(d=!1,l+=n.keys.length*Xn),n.series.forEach((I,G)=>{const ne=Hi(I),Wt=n.keys[G],nt=this.currState?.keyDataTypes.get(Wt);if(nt==null)throw new V(`Channel ${Wt} was not provided in the list of channels when opening the writer`);if(!nt.equals(I.dataType))throw new V(`Series data type of ${I.dataType.toString()} does not match the data type of ${nt.toString()} for channel ${Wt}`);if(l+=I.data.byteLength,s===-1){s=ne,i=I.timeRange?.start,o=I.timeRange?.end,c=BigInt(I.alignment??0n);return}s!==ne&&(u=!1),(i?.valueOf()!==I.timeRange?.start.valueOf()||o?.valueOf()!==I.timeRange?.end.valueOf())&&(h=!1),c!==BigInt(I.alignment??0)&&(v=!1)}),f=h&&i==null&&o==null,x=v&&(c===void 0||c===0n),u?l+=Be:l+=n.keys.length*Be,f||(h?l+=Se*2:l+=n.keys.length*Se*2),x||(v?l+=Le:l+=n.keys.length*Le);const j=new Uint8Array(l),w=new DataView(j.buffer);let O=r;return j[O]=Number(x)<<Wi|Number(v)<<Gi|Number(u)<<Ki|Number(h)<<Ji|Number(f)<<Xi|Number(d)<<Qi,O++,w.setUint32(O,this.seqNum,!0),O+=Qn,u&&(w.setUint32(O,s,!0),O+=Be),h&&!f&&(w.setBigUint64(O,i?.valueOf()??0n,!0),w.setBigUint64(O,o?.valueOf()??0n,!0),O+=Se*2),v&&!x&&(w.setBigUint64(O,c??0n,!0),O+=Le),n.series.forEach((I,G)=>{if(d||(w.setUint32(O,n.keys[G],!0),O+=Xn),!u){let ne=I.data.byteLength;I.dataType.isVariable||(ne=Hi(I)),w.setUint32(O,ne,!0),O+=Be}j.set(new Uint8Array(I.data),O),O+=I.data.byteLength,!h&&!f&&(w.setBigUint64(O,I.timeRange?.start.valueOf()??0n,!0),w.setBigUint64(O,I.timeRange?.end.valueOf()??0n,!0),O+=Se*2),!v&&!x&&(w.setBigUint64(O,I.alignment??0n,!0),O+=Le)}),j}decode(e,r=0){this.throwIfNotUpdated("decode");const n=e instanceof Uint8Array?e:new Uint8Array(e),s={keys:[],series:[]};let i=r,o=0,c=0,l,u,h;const f=new DataView(n.buffer,n.byteOffset,n.byteLength),d=!!(n[i]>>Wi&1),v=!!(n[i]>>Gi&1),x=!!(n[i]>>Ki&1),j=!!(n[i]>>Ji&1),w=!!(n[i]>>Xi&1),O=!!(n[i]>>Qi&1);i++;const I=f.getUint32(i,!0);i+=Qn;const G=this.states.get(I);if(G==null)return s;if(x){if(i+Be>f.byteLength)return s;o=f.getUint32(i,!0),i+=Be}if(j&&!w){if(i+Se>f.byteLength)return s;l=new C(f.getBigUint64(i,!0)),i+=Se,u=new C(f.getBigUint64(i,!0)),i+=Se}if(v&&!d){if(i+Le>f.byteLength)return s;h=f.getBigUint64(i,!0),i+=Le}return O&&(s.keys=[...G.keys]),G.keys.forEach((ne,Wt)=>{if(!O){if(i>=f.byteLength||f.getUint32(i,!0)!==ne)return;i+=Xn,s.keys.push(ne)}const nt=G.keyDataTypes.get(ne);if(c=0,x)c=o;else{if(i+Be>f.byteLength)return;c=f.getUint32(i,!0),i+=Be}let Dr=c;if(nt.isVariable||(Dr*=nt.density.valueOf()),i+Dr>f.byteLength){s.keys.splice(Wt,1);return}const st={dataType:nt,data:n.slice(i,i+Dr).buffer};if(i+=Dr,!j&&!w){if(i+Se*2>f.byteLength)return;const Ph=f.getBigUint64(i,!0);i+=Se;const _h=f.getBigUint64(i,!0);i+=Se,st.timeRange=new B({start:Ph,end:_h})}else w?st.timeRange=new B({start:0n,end:0n}):st.timeRange=new B({start:l?.valueOf()??0n,end:u?.valueOf()??0n});if(!v&&!d){if(i+Le>f.byteLength)return;h=f.getBigUint64(i,!0),i+=Le,st.alignment=h}else d?st.alignment=0n:st.alignment=h;s.series.push(st)}),s}}const ja=254,nS=new Uint8Array([ja]),sS=255,aS=new Uint8Array([sS]),tu="application/sy-framer";class iS{contentType=tu;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=pt.JSON_CODEC}encode(e){const r=e;if(r.type=="close"||r.payload?.command!=xe.Write){const s=this.lowPerfCodec.encode(r),i=new Uint8Array({length:s.byteLength+1});return i.set(nS,0),i.set(new Uint8Array(s),1),i}const n=this.base.encode(r.payload?.frame,1);return n.set(aS,0),n}decode(e,r){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===ja)return this.lowPerfCodec.decode(e.slice(1),r);const n={type:"data"},s=this.base.decode(e,1);return n.payload={command:xe.Write,frame:s},n}}class oS{contentType=tu;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=pt.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,r){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===ja?this.lowPerfCodec.decode(e.slice(1),r):{type:"data",payload:{frame:this.base.decode(e,1)}}}}class xn{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=new Set,this.codec=new eu}static async open(e,r){const n=new xn(e);return await n.update(r),n}async update(e){const{variant:r,normalized:n}=ve(e),s=await this.retriever.retrieve(n),i=s.map(c=>c.key);if(fi.uniqueUnorderedPrimitiveArrays(Array.from(this.keys),i)===fi.EQUAL)return!1;if(this.codec.update(i,s.map(c=>c.dataType)),r==="keys")return this.adapter=null,this.keys=new Set(n),!0;const o=new Map;return this.adapter=o,n.forEach(c=>{const l=s.find(u=>u.name===c);if(l==null)throw new Error(`Channel ${c} not found`);o.set(l.key,l.name)}),this.keys=new Set(this.adapter.keys()),!0}adapt(e){if(this.adapter==null){let n=!1;return e.forEach(s=>{this.keys.has(s)||(n=!0)}),n?e.filter(s=>this.keys.has(s)):e}const r=this.adapter;return e.mapFilter((n,s)=>{if(typeof n=="number"){const i=r.get(n);return i==null?[n,s,!1]:[i,s,!0]}return[n,s,!0]})}}class $a{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new eu}static async open(e,r){const n=new $a(e);return await n.update(r),n}async adaptParams(e){const r=wt.parse(e);return await Promise.all(r.map(async n=>await this.adaptToKey(n)))}async update(e){const r=await Yl(this.retriever,e),n=r.map(l=>l.key),s=new Set(this.keys),i=new Set(n),o=!i.isSubsetOf(s),c=!s.isSubsetOf(i);return o||c?(this.adapter=new Map(r.map(l=>[l.name,l.key])),this.keys=n,this.codec.update(this.keys,r.map(l=>l.dataType)),!0):!1}async fetchChannel(e){const r=await this.retriever.retrieve(e);if(r.length===0)throw new Error(`Channel ${JSON.stringify(e)} not found`);return r[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}encode(e){return this.codec.encode(e.toPayload())}async adapt(e,r){if(typeof e=="string"||typeof e=="number"){if(r==null)throw new V(`
51
- Received a single channel name or key but no series.
52
- `);if(Array.isArray(r)){if(r.some(l=>l instanceof Ve||Array.isArray(l)))throw new V(`
53
- Received a single channel name or key but multiple series.
54
- `);r=r}const o=await this.fetchChannel(e),c=new Ve({data:r,dataType:o.dataType});return new ce(o.key,c)}if(Array.isArray(e)){if(r==null)throw new V(`
55
- Received an array of channel names or keys but no series.
56
- `);if(!Array.isArray(r))throw new V(`
57
- Received an array of channel names or keys but no array of series.
58
- `);const o=[],c=[];for(let l=0;l<e.length;l++){const u=await this.fetchChannel(e[l]);if(l>=r.length)throw new V(`
59
- Received an array of channel names or keys but not enough series.
60
- `);const h=new Ve({data:r[l],dataType:u.dataType});o.push(u.key),c.push(h)}return new ce(o,c)}if(e instanceof ce||e instanceof Map){const o=new ce(e);if(this.adapter==null)return o;const c=o.columns.map(l=>{const u=typeof l=="string"?this.adapter?.get(l):l;if(u==null)throw new V(`
61
- Channel ${l} was not provided in the list of channels when opening the writer
62
- `);return u});return new ce(c,o.series)}const n=[],s=[],i=Object.entries(e);for(let o=0;o<i.length;o++){const[c,l]=i[o],u=await this.fetchChannel(c),h=new Ve({data:l,dataType:u.dataType});n.push(u.key),s.push(h)}return new ce(n,s)}}class ru{name;stream;constructor(e,r){this.stream=r,this.name=e}async receive(){const[e,r]=await this.stream.receive();if(r!=null)throw r;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,r]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on ${JSON.stringify(e)} closure.
63
- Please report this error to the Synnax team.`),r!=null){if(ze.matches(r))return;throw r}}}closeSend(){this.stream.closeSend()}send(e){const r=this.stream.send(e);if(r!=null)throw r}}const dn=new N(-1);var Ma=(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))(Ma||{}),nu=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(nu||{});const cS=a.z.object({command:a.z.enum(Ma),span:N.z.optional(),bounds:B.z.optional(),stamp:C.z.optional(),keys:D.array().optional(),chunkSize:a.z.number().optional()}),lS=a.z.object({variant:a.z.enum(nu),ack:a.z.boolean(),command:a.z.enum(Ma),error:Pe.payloadZ.optional().nullable(),frame:In.optional()});class Cn{stream;adapter;value;constructor(e,r){this.stream=new ru("Iterator",e),this.value=new ce,this.adapter=r}static async _open(e,r,n,s,i={}){const o=await xn.open(n,r),c=await s.stream("/frame/iterate",cS,lS),l=new Cn(c,o);return await l.execute({command:0,keys:Array.from(o.keys),bounds:new B(e),chunkSize:i.chunkSize??1e5}),l}async next(e=dn){return await this.execute({command:1,span:new N(e)})}async prev(e=dn){return await this.execute({command:2,span:new N(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 C(e)})}async seekGE(e){return await this.execute({command:6,stamp:new C(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new uS(this)}async execute(e){for(this.stream.send(e),this.value=new ce;;){const r=await this.stream.receive();if(r.variant===1)return r.ack;this.value.push(this.adapter.adapt(new ce(r.frame)))}}}class uS{iter;open=!1;constructor(e){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 hS=a.z.object({keys:a.z.number().array(),downsampleFactor:a.z.number()}),dS=a.z.object({frame:In}),eo=a.z.object({channels:wt,downsampleFactor:a.z.number().optional().default(1),useHighPerformanceCodec:a.z.boolean().optional().default(!0)}),Ua=eo.or(wt.transform(t=>eo.parse({channels:t}))),su=(t,e)=>async r=>{const n=Ua.parse(r),s=await xn.open(t,n.channels);n.useHighPerformanceCodec&&(e=e.withCodec(new oS(s.codec)));const i=await e.stream("/frame/stream",hS,dS),o=new fS(i,s);i.send({keys:Array.from(s.keys),downsampleFactor:n.downsampleFactor});const[,c]=await i.receive();if(c!=null)throw c;return o},au=async(t,e,r)=>await su(t,e)(r);class fS{stream;adapter;downsampleFactor;constructor(e,r){this.stream=new ru("Streamer",e),this.adapter=r,this.downsampleFactor=1}get keys(){return Array.from(this.adapter.keys)}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(ze.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ce((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e)&&this.stream.send({keys:Array.from(this.adapter.keys),downsampleFactor:this.downsampleFactor})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class jn{wrapped_=null;breaker;opener;config;constructor(e,r,n={}){this.opener=e,this.config=Ua.parse(r);const{maxRetries:s=5e3,baseInterval:i=N.seconds(1),scale:o=1}=n??{};this.breaker=new ya.Breaker({maxRetries:s,baseInterval:i,scale:o})}static async open(e,r,n){const s=new jn(e,r,n);return await s.runStreamer(),s}async runStreamer(){for(;;)try{this.wrapped_!=null&&this.wrapped_.close(),this.wrapped_=await this.opener(this.config),this.breaker.reset();return}catch(e){if(this.wrapped_=null,!await this.breaker.wait())throw e;console.error("failed to open streamer",e);continue}}get wrapped(){if(this.wrapped_==null)throw new Error("stream closed");return this.wrapped_}async update(e){this.config.channels=wt.parse(e);try{await this.wrapped.update(e)}catch{return await this.runStreamer(),await this.update(e)}}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(ze.matches(e))return{done:!0,value:void 0};throw e}}async read(){try{const e=await this.wrapped.read();return this.breaker.reset(),e}catch(e){if(ze.matches(e))throw e;return await this.runStreamer(),await this.read()}}close(){this.wrapped.close()}get keys(){return this.wrapped.keys}[Symbol.asyncIterator](){return this}}class iu extends sm.Observer{streamer;closePromise;constructor(e,r){super(r),this.streamer=e,this.closePromise=this.stream()}async update(e){await this.streamer.update(e)}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}var yr=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(yr||{});const pS=new N(-1);class Bs extends Ce.sub("writer_closed"){constructor(){super("WriterClosed")}}const yS=a.z.enum(yr).or(a.z.enum(["persist","stream","persistStream"]).transform(t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1}})),ou=a.z.object({start:C.z.optional(),controlSubject:me.subjectZ.optional(),authorities:a.z.union([me.authorityZ.transform(t=>[t]),me.authorityZ.array()]).default([me.ABSOLUTE_AUTHORITY]),mode:yS.default(1),errOnUnauthorized:a.z.boolean().default(!1),enableAutoCommit:a.z.boolean().default(!0),autoIndexPersistInterval:N.z.default(N.SECOND),useHighPerformanceCodec:a.z.boolean().default(!0)}),mS=ou.extend({keys:D.array().optional()}),to=ou.extend({channels:wt}),cu=to.or(wt.transform(t=>to.parse({channels:t,start:C.now()}))),gS=a.z.object({command:a.z.enum(xe),config:mS.optional(),frame:In.optional(),buffer:a.z.instanceof(Uint8Array).optional()}),wS=a.z.object({command:a.z.enum(xe),end:C.z,err:Pe.payloadZ.optional()}),bS=a.z.tuple([a.z.union([a.z.record(D.or(Ze),me.authorityZ),D.or(Ze),me.authorityZ]),me.authorityZ.optional()]).transform(([t,e])=>{if(me.authorityZ.safeParse(t).success)return{keys:[],authorities:[t]};if(D.or(Ze).safeParse(t).success){if(e==null)throw new Error("authority is required when setting authority for a single channel");return{keys:[t],authorities:[e]}}const r=t;return{keys:Object.keys(r),authorities:Object.values(r)}});let lu=class uu{stream;adapter;closeErr=null;constructor(e,r){this.stream=e,this.adapter=r}static async _open(e,r,n){const s=cu.parse(n),i=await $a.open(e,s.channels);s.useHighPerformanceCodec&&(r=r.withCodec(new iS(i.codec)));const o=await r.stream("/frame/write",gS,wS),c=new uu(o,i);return await c.execute({command:xe.Open,config:{...s,keys:i.keys}}),c}async write(e,r){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();const n=await this.adapter.adapt(e,r);this.stream.send({command:xe.Write,frame:n.toPayload()})}async setAuthority(e,r){if(this.closeErr!=null)throw this.closeErr;const n=bS.parse([e,r]),s={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:xe.SetAuthority,config:s})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),C.ZERO):(await this.execute({command:xe.Commit})).end}async close(){await this.closeInternal(null)}async closeInternal(e){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=e,this.stream.closeSend();;){if(this.closeErr!=null){if(Bs.matches(this.closeErr))return null;throw this.closeErr}const[r,n]=await this.stream.receive();n!=null?this.closeErr=ze.matches(n)?new Bs:n:this.closeErr=Pe.decode(r?.err)}}async execute(e){const r=this.stream.send(e);for(r!=null&&await this.closeInternal(r);;){const[n,s]=await this.stream.receive();s!=null&&await this.closeInternal(s);const i=Pe.decode(n?.err);if(i!=null&&await this.closeInternal(i),n?.command==e.command)return n}}};const vS=t=>({type:"framer",key:t.toString()});let hu=class{streamClient;retriever;deleter;constructor(t,e,r){this.streamClient=t,this.retriever=r,this.deleter=new eS(e)}async openIterator(t,e,r){return await Cn._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return await lu._open(this.retriever,this.streamClient,t)}async openStreamer(t){return await au(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const s=e,i=await this.openWriter({start:t,channels:Object.keys(s),mode:yr.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:N.MAX});return await i.write(s),await i.close()}const n=await this.openWriter({start:t,channels:e,mode:yr.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:N.MAX});await n.write(e,r),await n.close()}async read(t,e){const{single:r}=ve(e),n=await this.readFrame(t,e);return r?n.get(e):n}async readFrame(t,e){const r=await this.openIterator(t,e),n=new ce;try{for await(const s of r)n.push(s)}finally{await r.close()}return n}async readLatest(t,e=1){const{single:r}=ve(t),n=await this.readLatestNFrame(t,e);return r?n.get(t):n}async readLatestNFrame(t,e){const r=await this.openIterator(B.MAX,t,{chunkSize:e}),n=new ce;if(e>0)try{await r.seekLast(),await r.prev(dn),n.push(r.value)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=ve(t),s=new B(e);return n==="keys"?await this.deleter.delete({keys:r,bounds:s}):await this.deleter.delete({names:r,bounds:s})}};const zS=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:pS,AUTO_SPAN:dn,Client:hu,Frame:ce,HardenedStreamer:jn,Iterator:Cn,ObservableStreamer:iu,Writer:lu,WriterClosedError:Bs,WriterCommand:xe,WriterMode:yr,createStreamOpener:su,frameZ:In,ontologyID:vS,openStreamer:au,seriesFromPayload:Xl,seriesToPayload:Ql,streamerConfigZ:Ua,writerConfigZ:cu},Symbol.toStringTag,{value:"Module"})),TS=me.ABSOLUTE_AUTHORITY,OS=me.ZERO_AUTHORITY,SS=me.stateZ(a.z.number()),kS=t=>t.to==null?`${t.from?.resource} - ${t.from?.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()})`,NS=a.z.object({transfers:a.z.array(me.transferZ(D))});class du extends iu{states;codec;constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer,NS);return this.merge(n),[n.transfers,!0]}),this.states=new Map,this.codec=new pt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(r=>e.set(r.subject.key,r.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(r=>{r.from==null&&r.to==null&&console.warn("Invalid transfer: ",r),r.to==null?this.states.delete(r.from.resource):this.states.set(r.to.resource,r.to)})}}const fu="sy_node_1_control";let pu=class{framer;constructor(t){this.framer=t}async openStateTracker(){const t=await jn.open(async e=>await this.framer.openStreamer(e),fu);return new du(t)}};const ES=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:TS,CONTROL_STATE_CHANNEL_NAME:fu,Client:pu,StateTracker:du,ZERO_AUTHORITY:OS,stateZ:SS,transferString:kS},Symbol.toStringTag,{value:"Module"}));let AS=class{tasks;racks;devices;constructor(t,e,r){this.tasks=t,this.racks=e,this.devices=r}};const Oe=a.z.uint32(),yu=a.z.object({rack:Oe}),mu=qt.statusZ(yu),$n=a.z.object({key:Oe,name:a.z.string(),status:ir.nullToUndefined(mu)}),gu=$n.partial({key:!0}),wu=t=>t?pt.JSON_CODEC.decodeString(t,Te.unknownZ):{},Vt=a.z.string(),bu=a.z.object({rack:Oe,device:Vt}),vu=qt.statusZ(bu),Mn=a.z.object({key:Vt,rack:Oe.min(1,"Must select a location to connect from"),name:a.z.string().min(1,"Name is required"),make:a.z.string().min(1,"Make is required"),model:a.z.string().min(1,"Model is required"),location:a.z.string().min(1,"Location is required"),configured:a.z.boolean().optional(),properties:Te.unknownZ.or(a.z.string().transform(wu)),status:ir.nullToUndefined(vu)}),zu=Mn.extend({properties:a.z.unknown().transform(t=>pt.JSON_CODEC.encodeString(t))}),IS="sy_device_set",xS="sy_device_delete",CS="sy_device_status",jS="/hardware/device/retrieve",$S="/hardware/device/create",MS="/hardware/device/delete",US=a.z.object({devices:zu.array()}),ZS=a.z.object({devices:Mn.array()}),PS=a.z.object({keys:Vt.array()}),_S=a.z.object({}),RS=a.z.object({keys:Vt.array().optional(),names:a.z.string().array().optional(),makes:a.z.string().array().optional(),models:a.z.string().array().optional(),locations:a.z.string().array().optional(),racks:Oe.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),includeStatus:a.z.boolean().optional()}),DS=a.z.object({devices:b.nullableZ(Mn)}),LS=a.z.object({key:Vt,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),BS=a.z.union([LS,RS]);let Tu=class{client;constructor(t){this.client=t}async retrieve(t){const e=typeof t=="object"&&"key"in t,r=await g(this.client,jS,t,BS,DS);ue("Device",t,r.devices,e);const n=r.devices;return e?n[0]:n}async create(t){const e=!Array.isArray(t),r=(await g(this.client,$S,{devices:b.toArray(t)},US,ZS)).devices;return e?r[0]:r}async delete(t){await g(this.client,MS,{keys:b.toArray(t)},PS,_S)}};const FS=t=>({type:"device",key:t}),qS=Object.freeze(Object.defineProperty({__proto__:null,Client:Tu,DELETE_CHANNEL_NAME:xS,SET_CHANNEL_NAME:IS,STATUS_CHANNEL_NAME:CS,deviceZ:Mn,keyZ:Vt,newZ:zu,ontologyID:FS,statusDetailsSchema:bu,statusZ:vu},Symbol.toStringTag,{value:"Module"})),YS="/hardware/rack/retrieve",VS="/hardware/rack/create",HS="/hardware/rack/delete",WS="sy_rack_status",GS="sy_rack_set",KS="sy_rack_delete",JS=a.z.object({keys:Oe.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),embedded:a.z.boolean().optional(),hostIsNode:a.z.boolean().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),includeStatus:a.z.boolean().optional()}),XS=a.z.object({racks:b.nullableZ($n)}),QS=a.z.union([a.z.object({key:Oe,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),a.z.object({name:a.z.string(),includeStatus:a.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e}))]),e0=JS,t0=a.z.union([QS,e0]),r0=a.z.object({racks:gu.array()}),n0=a.z.object({racks:$n.array()}),s0=a.z.object({keys:Oe.array()}),a0=a.z.object({});let Ou=class{client;tasks;constructor(t,e){this.client=t,this.tasks=e}async delete(t){await g(this.client,HS,{keys:b.toArray(t)},s0,a0)}async create(t){const e=!Array.isArray(t),r=await g(this.client,VS,{racks:b.toArray(t)},r0,n0),n=this.sugar(r.racks);return e?n[0]:n}async retrieve(t){const e="key"in t||"name"in t,r=await g(this.client,YS,t,t0,XS),n=this.sugar(r.racks);return ue("Rack",t,n,e),e?n[0]:n}sugar(t){const e=!Array.isArray(t),r=b.toArray(t).map(({key:n,name:s,status:i})=>new Su(n,s,this.tasks,i));return e?r[0]:r}};class Su{key;name;status;tasks;constructor(e,r,n,s){this.key=e,this.name=r,this.tasks=n,this.status=s}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async createTask(e,r){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e,r)}async deleteTask(e){await this.tasks.delete([e])}get payload(){return{key:this.key,name:this.name,status:this.status}}}const i0=t=>({type:"rack",key:t.toString()}),o0=Object.freeze(Object.defineProperty({__proto__:null,Client:Ou,DELETE_CHANNEL_NAME:KS,Rack:Su,SET_CHANNEL_NAME:GS,STATUS_CHANNEL_NAME:WS,keyZ:Oe,newZ:gu,ontologyID:i0,rackZ:$n,statusDetailsSchema:yu,statusZ:mu},Symbol.toStringTag,{value:"Module"})),_e=a.z.union([a.z.string(),a.z.bigint().transform(t=>t.toString()),a.z.number().transform(t=>t.toString())]),ku=t=>a.z.object({task:_e,running:a.z.boolean(),data:t}),Za=t=>qt.statusZ(ku(t)),Zr=(t={typeSchema:a.z.string(),configSchema:a.z.unknown(),statusDataSchema:a.z.unknown()})=>a.z.object({key:_e,name:a.z.string(),type:t.typeSchema,internal:a.z.boolean().optional(),config:a.z.string().transform(wu).or(t.configSchema),status:Za(t.statusDataSchema).optional().nullable(),snapshot:a.z.boolean().optional()}),Nu=t=>Zr(t).omit({key:!0}).extend({key:_e.transform(e=>e.toString()).optional(),config:a.z.unknown().transform(e=>pt.JSON_CODEC.encodeString(e))}),c0=a.z.object({task:_e,type:a.z.string(),key:a.z.string(),args:Te.unknownZ.or(a.z.string().transform(je)).or(a.z.array(a.z.unknown())).or(a.z.null()).optional()}),l0=t=>Number(BigInt(t)>>32n),Fs="sy_task_status",qs="sy_task_cmd",u0="sy_task_set",h0="sy_task_delete",ot=new Error("Task not created"),Eu=async(t,e)=>{const r=await e.retrieveParents(Pa(t));return r.length===0?null:r[0]};class Au{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw ot;return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw ot;return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw ot;return this.rangeClient_}constructor({key:e,type:r,name:n,config:s,internal:i=!1,snapshot:o=!1,status:c},l,u,h,f){this.key=e,this.name=n,this.type=r,this.config=s,this.schemas=l??{typeSchema:a.z.string(),configSchema:a.z.unknown(),statusDataSchema:a.z.unknown()},this.internal=i,this.snapshot=o,this.status=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,status:this.status,internal:this.internal}}get ontologyID(){return Pa(this.key)}async executeCommand(e){return await Cu({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await ju({...e,frameClient:this.frameClient,task:this.key,name:this.name,statusDataZ:this.schemas?.statusDataSchema})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw ot;return this.snapshot?await Eu(this.key,this.ontologyClient):null}}const d0=a.z.object({rack:Oe.optional(),keys:_e.array().optional(),names:a.z.string().array().optional(),types:a.z.string().array().optional(),includeStatus:a.z.boolean().optional(),internal:a.z.boolean().optional(),snapshot:a.z.boolean().optional(),searchTerm:a.z.string().optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),Iu=a.z.union([a.z.object({key:_e,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),a.z.object({name:a.z.string(),includeStatus:a.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),a.z.object({type:a.z.string(),rack:Oe.optional()}).transform(({type:t,rack:e})=>({types:[t],rack:e}))]),f0=d0,p0=a.z.union([Iu,f0]),y0=t=>a.z.object({tasks:b.nullableZ(Zr(t))}),m0="/hardware/task/retrieve",g0="/hardware/task/create",w0="/hardware/task/delete",b0="/hardware/task/copy",v0=t=>a.z.object({tasks:Nu(t).array()}),z0=t=>a.z.object({tasks:Zr(t).array()}),T0=a.z.object({keys:_e.array()}),O0=a.z.object({}),S0=a.z.object({key:_e,name:a.z.string(),snapshot:a.z.boolean()}),k0=t=>a.z.object({task:Zr(t)});let xu=class{type="task";client;frameClient;ontologyClient;rangeClient;constructor(t,e,r,n){this.client=t,this.frameClient=e,this.ontologyClient=r,this.rangeClient=n}async create(t,e){const r=!Array.isArray(t),n=v0(e),s=z0(e),i=await g(this.client,g0,{tasks:b.toArray(t)},n,s),o=this.sugar(i.tasks,e);return r?o[0]:o}async delete(t){await g(this.client,w0,{keys:b.toArray(t)},T0,O0)}async retrieve({schemas:t,...e}){const r=Iu.safeParse(e).success,n=(await g(this.client,m0,e,p0,y0(t))).tasks,s=this.sugar(n,t);return ue("Task",e,s,r),r?s[0]:s}async copy(t,e,r){const n=k0(),s=await g(this.client,b0,{key:t,name:e,snapshot:r},S0,n);return this.sugar(s.task)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw ot;return await Eu(t,this.ontologyClient)}sugar(t,e){const r=!Array.isArray(t),n=b.toArray(t).map(({key:s,name:i,type:o,config:c,status:l,internal:u,snapshot:h})=>new Au({key:s,name:i,type:o,config:c,internal:u,snapshot:h,status:l},e,this.frameClient,this.ontologyClient,this.rangeClient));return r?n[0]:n}async executeCommand(t){return"commands"in t?await _a({...t,frameClient:this.frameClient}):await Cu({...t,frameClient:this.frameClient})}async executeCommandSync(t){if("commands"in t){const r=async()=>{const{commands:n}=t;return(await this.retrieve({keys:n.map(s=>s.task)})).map(s=>s.name)};return await $u({...t,frameClient:this.frameClient,name:r})}const e=async()=>{const{task:r}=t;return(await this.retrieve({key:r})).name};return await ju({frameClient:this.frameClient,name:e,...t})}};const Pa=t=>({type:"task",key:t}),Cu=async({frameClient:t,task:e,type:r,args:n})=>(await _a({frameClient:t,commands:[{args:n,task:e,type:r}]}))[0],_a=async({frameClient:t,commands:e})=>{if(t==null)throw ot;const r=await t.openWriter(qs),n=e.map(s=>({...s,key:vy.create()}));return await r.write(qs,n),await r.close(),n.map(s=>s.key)},ju=async({frameClient:t,task:e,type:r,timeout:n,name:s,statusDataZ:i,args:o})=>(await $u({frameClient:t,commands:[{args:o,task:e,type:r}],timeout:n,statusDataZ:i,name:s}))[0],$u=async({frameClient:t,commands:e,timeout:r=N.seconds(10),statusDataZ:n,name:s})=>{if(t==null)throw ot;const i=await t.openStreamer(Fs),o=await _a({frameClient:t,commands:e}),c=new N(r);let l=[],u;const h=new Promise((f,d)=>{u=setTimeout(()=>{(async()=>{const v=e.map(x=>x.task);d(await N0("command",s,c,v))})()},c.milliseconds)});try{for(;;){const f=await Promise.race([i.read(),h]),d=Za(n).parse(f.at(-1)[Fs]);if(o.includes(d.key)&&(l=[...l.filter(v=>v.key!==d.key),d],l.length===o.length))return l}}finally{clearTimeout(u),i.close()}},N0=async(t,e,r,n)=>{const s=tp.capitalize(t),i=r.toString();try{let o;typeof e=="string"?o=[e]:Array.isArray(e)?o=e:o=b.toArray(await e());const c=xs.naturalLanguageJoin(o);return new Error(`${s} command to ${c} timed out after ${i}`)}catch(o){return console.error("Failed to retrieve task name for timeout error:",o),new Error(`${s} command to task with key ${xs.naturalLanguageJoin(n)} timed out after ${i}`)}},E0=Object.freeze(Object.defineProperty({__proto__:null,COMMAND_CHANNEL_NAME:qs,Client:xu,DELETE_CHANNEL_NAME:h0,SET_CHANNEL_NAME:u0,STATUS_CHANNEL_NAME:Fs,Task:Au,commandZ:c0,keyZ:_e,newZ:Nu,ontologyID:Pa,rackKey:l0,statusDetailsZ:ku,statusZ:Za,taskZ:Zr},Symbol.toStringTag,{value:"Module"})),tt=Wc.keyZ,Pr=Wc.labelZ,A0="labeled_by",I0="sy_label_set",x0="sy_label_delete",Mu=Pr.extend({key:tt.optional()}),C0=a.object({labels:Mu.array()}),j0=a.object({labels:Pr.array()}),$0=a.object({keys:tt.array()}),Uu=a.object({id:_,labels:tt.array(),replace:a.boolean().optional()}),M0=Uu.omit({replace:!0}),es=a.object({}),U0="/label/create",Z0="/label/delete",P0="/label/set",_0="/label/remove",R0="/label/retrieve",D0=a.object({keys:tt.array().optional(),for:_.optional(),searchTerm:a.string().optional(),offset:a.number().optional(),limit:a.number().optional()}),L0=a.object({key:tt}).transform(({key:t})=>({keys:[t]})),B0=a.union([L0,D0]),F0=a.object({labels:b.nullableZ(Pr)});let Zu=class{type="label";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await g(this.client,R0,t,B0,F0);return ue("Label",t,r.labels,e),e?r.labels[0]:r.labels}async label(t,e,r={}){await g(this.client,P0,{id:t,labels:e,replace:r.replace},Uu,es)}async remove(t,e){await g(this.client,_0,{id:t,labels:e},M0,es)}async create(t){const e=Array.isArray(t),r=await g(this.client,U0,{labels:b.toArray(t)},C0,j0);return e?r.labels:r.labels[0]}async delete(t){await g(this.client,Z0,{keys:b.toArray(t)},$0,es)}};const q0=t=>({type:"label",key:t}),Y0=Object.freeze(Object.defineProperty({__proto__:null,Client:Zu,DELETE_CHANNEL_NAME:x0,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:A0,SET_CHANNEL_NAME:I0,keyZ:tt,labelZ:Pr,newZ:Mu,ontologyID:q0},Symbol.toStringTag,{value:"Module"})),Q=a.z.uuid(),Ra=a.z.string().min(1),_r=a.z.object({key:Q,name:Ra,timeRange:B.z.refine(({isValid:t})=>t,{error:"Time range start time must be before or equal to time range end time"}).refine(({end:t})=>t.valueOf()<=Ns.MAX_INT64,{error:"Time range end time must be less than or equal to the maximum value of an int64"}).refine(({start:t})=>t.valueOf()>=Ns.MIN_INT64,{error:"Time range start time must be greater than or equal to the minimum value of an int64"}),color:a.z.string().optional(),labels:Pr.array().or(a.z.null().transform(()=>{})).optional(),get parent(){return _r.optional().nullable().transform(t=>t===void 0?null:t)}}),Pu=_r.omit({parent:!0,labels:!0}).partial({key:!0}),V0="sy_range_alias_set",H0="sy_range_alias_delete",W0=a.z.object({range:Q,aliases:a.z.string().array()}),G0=a.z.object({aliases:a.z.record(a.z.string(),D)}),K0=a.z.object({range:Q,aliases:a.z.record(D,a.z.string())}),J0=a.z.unknown(),X0=a.z.object({range:Q,channels:D.array()}),Q0=a.z.unknown(),ek=a.z.object({range:Q}),tk=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())}),rk=a.z.object({range:Q,channels:D.array()}),nk=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())});let it=class Nt{static SET_ENDPOINT="/range/alias/set";static RESOLVE_ENDPOINT="/range/alias/resolve";static LIST_ENDPOINT="/range/alias/list";static RETRIEVE_ENDPOINT="/range/alias/retrieve";static DELETE_ENDPOINT="/range/alias/delete";frameClient;cache=new Map;client;rangeKey;constructor(e,r,n){this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=r}async resolve(e){const r=[],n=typeof e=="string",s={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?s[o]=c:r.push(o)});if(r.length===0)return s;const i=await g(this.client,Nt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:r},W0,G0);return Object.entries(i.aliases).forEach(([o,c])=>this.cache.set(o,c)),n?i.aliases[r[0]]:{...s,...i.aliases}}async set(e){await g(this.client,Nt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},K0,J0)}async list(){return(await g(this.client,Nt.LIST_ENDPOINT,{range:this.rangeKey},ek,tk)).aliases}async retrieve(e){const r=typeof e=="number",n=await g(this.client,Nt.RETRIEVE_ENDPOINT,{range:this.rangeKey,channels:b.toArray(e)},rk,nk);return r?n.aliases[e]:n.aliases}async delete(e){await g(this.client,Nt.DELETE_ENDPOINT,{range:this.rangeKey,channels:b.toArray(e)},X0,Q0)}};const sk=a.z.object({alias:a.z.string().optional(),channel:D,range:Q}),_u="---",ak=t=>`${t.range}${_u}${t.channel}`,ik=t=>{const[e,r]=t.split(_u);return{range:e,channel:Number(r)}},ok="sy_range_kv_set",ck="sy_range_kv_delete",Da=a.z.object({range:Q,key:a.z.string(),value:a.z.string()}),lk=({range:t,key:e})=>`${t}<--->${e}`,uk=a.z.object({range:Q,keys:a.z.string().array()}),hk=a.z.object({pairs:b.nullableZ(Da)}),dk=a.z.object({range:Q,pairs:Da.array()}),fk=a.z.object({range:Q,keys:a.z.string().array()});class ut{static GET_ENDPOINT="/range/kv/get";static SET_ENDPOINT="/range/kv/set";static DELETE_ENDPOINT="/range/kv/delete";rangeKey;client;constructor(e,r){this.rangeKey=e,this.client=r}async get(e){const r=await g(this.client,ut.GET_ENDPOINT,{range:this.rangeKey,keys:b.toArray(e)},uk,hk);return typeof e=="string"?r.pairs[0].value:Object.fromEntries(r.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,r=""){let n;Do(e)?n=Object.entries(e).map(([s,i])=>({range:this.rangeKey,key:s,value:i})):n=[{range:this.rangeKey,key:e,value:r}],await g(this.client,ut.SET_ENDPOINT,{range:this.rangeKey,pairs:n},dk,a.z.unknown())}async delete(e){await g(this.client,ut.DELETE_ENDPOINT,{range:this.rangeKey,keys:b.toArray(e)},fk,a.z.unknown())}}const pk="sy_range_set",yk="sy_range_delete";class Ru{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:r=B.ZERO,key:n,color:s,parent:i,labels:o},{frameClient:c,kv:l,aliaser:u,channels:h,labelClient:f,ontologyClient:d,rangeClient:v}){this.key=n,this.name=e,this.timeRange=r,this.parent=i,this.labels=o,this.frameClient=c,this.color=s,this.kv=l,this.aliaser=u,this.channels=h,this.labelClient=f,this.ontologyClient=d,this.rangeClient=v}get ontologyID(){return At(this.key)}get payload(){let e=null;return this.parent!=null&&("payload"in this.parent?e=this.parent.payload:e=this.parent),{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color,labels:this.labels,parent:e}}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new Xe(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:r})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(r=>r.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async retrieveLabels(){return await this.labelClient.retrieve({for:At(this.key)})}async addLabel(...e){await this.labelClient.label(At(this.key),e)}async removeLabel(...e){await this.labelClient.remove(At(this.key),e)}static sort(e,r){return B.sort(e.timeRange,r.timeRange)}}const mk=a.z.object({keys:Q.array().optional(),names:a.z.array(a.z.string()).optional(),searchTerm:a.z.string().optional(),overlapsWith:B.z.optional(),limit:a.z.number().int().optional(),offset:a.z.number().int().optional(),hasLabels:tt.array().optional(),includeLabels:a.z.boolean().optional(),includeParent:a.z.boolean().optional()}),gk=mk.or(Q.array().transform(t=>({keys:t}))).or(Q.transform(t=>({keys:[t]}))).or(a.z.string().transform(t=>({names:[t]}))).or(a.z.string().array().transform(t=>({names:t}))).or(B.z.transform(t=>({overlapsWith:t}))),wk="/range/retrieve",bk=a.z.object({ranges:b.nullableZ(_r)});let Du=class{type="range";frameClient;writer;unaryClient;channels;labelClient;ontologyClient;constructor(t,e,r,n,s,i){this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.labelClient=s,this.ontologyClient=i}async create(t,e){const r=!Array.isArray(t),n=this.sugarMany(await this.writer.create(b.toArray(t),e));return r?n[0]:n}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(b.toArray(t))}async retrieve(t){const e=typeof t=="string",{ranges:r}=await g(this.unaryClient,wk,t,gk,bk);return ue("Range",t,r,e),e?this.sugarMany(r)[0]:this.sugarMany(r)}getKV(t){return new ut(t,this.unaryClient)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents(At(t));if(e.length===0)return null;const r=e[0];return r.id.type!=="range"?null:await this.retrieve(r.id.key)}sugarOntologyResource(t){return this.sugarOne(Lu(t))}async retrieveAlias(t,e){return await new it(t,this.frameClient,this.unaryClient).retrieve(e)}async retrieveAliases(t,e){return await new it(t,this.frameClient,this.unaryClient).retrieve(e)}async listAliases(t){return await new it(t,this.frameClient,this.unaryClient).list()}async setAlias(t,e,r){await new it(t,this.frameClient,this.unaryClient).set({[e]:r})}async deleteAlias(t,e){await new it(t,this.frameClient,this.unaryClient).delete(e)}sugarOne(t){return new Ru(t,{frameClient:this.frameClient,kv:new ut(t.key,this.unaryClient),aliaser:new it(t.key,this.frameClient,this.unaryClient),channels:this.channels,labelClient:this.labelClient,ontologyClient:this.ontologyClient,rangeClient:this})}sugarMany(t){return t.map(e=>this.sugarOne(e))}resourceToRange(t){return this.sugarOne({key:t.id.key,name:t.data?.name,timeRange:new B(t.data?.timeRange),color:t.data?.color,labels:[],parent:null})}};const At=t=>({type:"range",key:t}),vk=t=>({type:"range-alias",key:t}),Lu=({data:t,id:{key:e},name:r})=>{const n=B.z.parse(t?.timeRange);return{key:e,name:r,timeRange:n,color:typeof t?.color=="string"?t.color:void 0,labels:[],parent:null}},zk=a.z.object({ranges:_r.array()}),Tk=a.z.object({parent:_.optional(),ranges:Pu.array()}),Ok=a.z.object({keys:Q.array()}),Sk=a.z.object({}),kk=a.z.object({key:Q,name:Ra}),Nk=a.z.object({}),Ek="/range/create",Ak="/range/delete",Ik="/range/rename";class Bu{client;constructor(e){this.client=e}async rename(e,r){await g(this.client,Ik,{key:e,name:r},kk,Nk)}async create(e,r){return(await g(this.client,Ek,{ranges:e,...r},Tk,zk)).ranges}async delete(e){await g(this.client,Ak,{keys:e},Ok,Sk)}}const xk=Object.freeze(Object.defineProperty({__proto__:null,Aliaser:it,Client:Du,DELETE_ALIAS_CHANNEL_NAME:H0,DELETE_CHANNEL_NAME:yk,KV:ut,KV_DELETE_CHANNEL:ck,KV_SET_CHANNEL:ok,Range:Ru,SET_ALIAS_CHANNEL_NAME:V0,SET_CHANNEL_NAME:pk,Writer:Bu,aliasKey:ak,aliasOntologyID:vk,aliasZ:sk,convertOntologyResourceToPayload:Lu,decodeDeleteAliasChange:ik,keyZ:Q,kvPairKey:lk,kvPairZ:Da,nameZ:Ra,newZ:Pu,ontologyID:At,payloadZ:_r},Symbol.toStringTag,{value:"Module"})),Ck=t=>a.object({parent:_.optional(),statuses:Il(t).array()}),jk=t=>a.object({statuses:jr(t).array()}),$k=a.object({keys:En.array()}),Mk=a.object({}),Uk="/status/set",Zk="/status/delete",Pk="/status/retrieve",_k=a.object({keys:En.array().optional(),searchTerm:a.string().optional(),offset:a.number().optional(),limit:a.number().optional(),includeLabels:a.boolean().optional(),hasLabels:tt.array().optional()}),Rk=a.object({key:En,includeLabels:a.boolean().optional()}).transform(({key:t,includeLabels:e})=>({keys:[t],includeLabels:e})),Dk=a.union([Rk,_k]),Lk=t=>a.object({statuses:b.nullableZ(jr(t))});let Fu=class{type="status";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await g(this.client,Pk,t,Dk,Lk(t.detailsSchema));ue("Status",t,r.statuses,e);const n=r.statuses;return e?n[0]:n}async set(t,e={}){const r=Array.isArray(t),n=(await g(this.client,Uk,{statuses:b.toArray(t),parent:e.parent},Ck(e.detailsSchema),jk(e.detailsSchema))).statuses;return r?n:n[0]}async delete(t){await g(this.client,Zk,{keys:b.toArray(t)},$k,Mk)}};const Bk=Object.freeze(Object.defineProperty({__proto__:null,Client:Fu,DELETE_CHANNEL_NAME:ET,SET_CHANNEL_NAME:NT,keyZ:En,newZ:Il,ontologyID:AT,statusZ:jr},Symbol.toStringTag,{value:"Module"})),Fk="/api/v1/";class qu{url;unary;stream;secure;constructor(e,r={},n=!1){this.secure=n,this.url=e.child(Fk);const s=new pt.JSONCodec;this.unary=_f(new Pf(this.url,s,this.secure),r),this.stream=new Ff(this.url,s,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const bt=a.z.uuid(),Un=a.z.object({key:bt,name:a.z.string(),data:Te.unknownZ.or(a.z.string().transform(je))}),Yu=Un.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),$e=a.z.uuid(),Zn=a.z.object({key:$e,name:a.z.string().min(1,"Name is required"),layout:Te.unknownZ.or(a.z.string().transform(je))}),Vu=Zn.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),Hu=Zn.omit({layout:!0}).extend({layout:a.z.string().transform(je)}),qk="/workspace/lineplot/retrieve",Yk="/workspace/lineplot/create",Vk="/workspace/lineplot/rename",Hk="/workspace/lineplot/set-data",Wk="/workspace/lineplot/delete",Gk=a.z.object({key:bt,name:a.z.string()}),Kk=a.z.object({key:bt,data:a.z.string()}),Jk=a.z.object({keys:bt.array()}),Xk=a.z.object({keys:bt.array()}),Wu=a.z.object({key:bt}).transform(({key:t})=>({keys:[t]})),Gu=a.z.union([Wu,Xk]),Qk=a.z.object({linePlots:b.nullableZ(Un)}),eN=a.z.object({workspace:$e,linePlots:Yu.array()}),tN=a.z.object({linePlots:Un.array()}),ts=a.z.object({});let Ku=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await g(this.client,Yk,{workspace:t,linePlots:b.toArray(e)},eN,tN);return r?n.linePlots:n.linePlots[0]}async rename(t,e){await g(this.client,Vk,{key:t,name:e},Gk,ts)}async setData(t,e){await g(this.client,Hk,{key:t,data:JSON.stringify(e)},Kk,ts)}async retrieve(t){const e=Wu.safeParse(t).success,r=await g(this.client,qk,t,Gu,Qk);return ue("LinePlot",t,r.linePlots,e),e?r.linePlots[0]:r.linePlots}async delete(t){await g(this.client,Wk,{keys:b.toArray(t)},Jk,ts)}};const rN=t=>({type:"lineplot",key:t}),nN=Object.freeze(Object.defineProperty({__proto__:null,Client:Ku,keyZ:bt,linePlotZ:Un,newZ:Yu,ontologyID:rN,retrieveArgsZ:Gu},Symbol.toStringTag,{value:"Module"})),vt=a.z.uuid(),Pn=a.z.object({key:vt,name:a.z.string(),data:Te.unknownZ.or(a.z.string().transform(je))}),Ju=Pn.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),sN="/workspace/log/retrieve",aN="/workspace/log/create",iN="/workspace/log/rename",oN="/workspace/log/set-data",cN="/workspace/log/delete",lN=a.z.object({key:vt,name:a.z.string()}),uN=a.z.object({key:vt,data:a.z.string()}),hN=a.z.object({keys:vt.array()}),dN=a.z.object({keys:vt.array()}),Xu=a.z.object({key:vt}).transform(({key:t})=>({keys:[t]})),Qu=a.z.union([Xu,dN]),fN=a.z.object({logs:b.nullableZ(Pn)}),pN=a.z.object({workspace:$e,logs:Ju.array()}),yN=a.z.object({logs:Pn.array()}),rs=a.z.object({});let eh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await g(this.client,aN,{workspace:t,logs:b.toArray(e)},pN,yN);return r?n.logs:n.logs[0]}async rename(t,e){await g(this.client,iN,{key:t,name:e},lN,rs)}async setData(t,e){await g(this.client,oN,{key:t,data:JSON.stringify(e)},uN,rs)}async retrieve(t){const e=Xu.safeParse(t).success,r=await g(this.client,sN,t,Qu,fN);return ue("Log",t,r.logs,e),e?r.logs[0]:r.logs}async delete(t){await g(this.client,cN,{keys:b.toArray(t)},hN,rs)}};const mN=t=>({type:"log",key:t}),gN=Object.freeze(Object.defineProperty({__proto__:null,Client:eh,keyZ:vt,logZ:Pn,newZ:Ju,ontologyID:mN,retrieveArgsZ:Qu},Symbol.toStringTag,{value:"Module"})),rt=a.z.uuid(),_n=a.z.object({key:rt,name:a.z.string(),data:Te.unknownZ.or(a.z.string().transform(je)),snapshot:a.z.boolean()}),th=_n.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),La=_n.extend({data:a.z.string().transform(je)}),Ht=a.z.uuid(),rh=a.z.object({key:a.z.string(),name:a.z.string(),selectors:a.z.string().array().default([]),strokeColor:a.z.string().optional(),fillColor:a.z.string().optional()}),nh=a.z.object({key:a.z.string(),name:a.z.string(),regions:rh.array()}),sh=a.z.object({key:a.z.string(),position:ha.xy,orientation:Yp.outer}),wN=a.z.object({zoom:a.z.number().positive().default(1),position:ha.xy}),ah=a.z.object({svg:a.z.string().min(1,"SVG is required"),states:nh.array(),variant:a.z.string().min(1,"Variant is required"),handles:sh.array(),scale:a.z.number().positive().default(1),scaleStroke:a.z.boolean().default(!1),previewViewport:wN.default({zoom:1,position:{x:0,y:0}})}),Rn=a.z.object({key:Ht,version:a.z.literal(1).optional().default(1),name:a.z.string().min(1,"Name is required"),data:ah}),ih=Rn.partial({key:!0}),bN="/workspace/schematic/symbol/retrieve",vN="/workspace/schematic/symbol/create",zN="/workspace/schematic/symbol/rename",TN="/workspace/schematic/symbol/delete",ON="/workspace/schematic/symbol/retrieve_group",SN=a.z.object({symbols:ih.array(),parent:_}),kN=a.z.object({key:Ht,name:a.z.string()}),NN=a.z.object({keys:Ht.array()}),EN=a.z.object({keys:Ht.array().optional(),searchTerm:a.z.string().optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),AN=a.z.object({key:Ht}).transform(({key:t})=>({keys:[t]})),IN=a.z.union([AN,EN]),xN=a.z.object({symbols:b.nullableZ(Rn)}),CN=a.z.object({symbols:Rn.array()}),ro=a.z.object({}),jN=a.z.object({}),$N=a.z.object({group:zn}),MN="sy_schematic_symbol_set",UN="sy_schematic_symbol_delete";let oh=class{client;constructor(t){this.client=t}async create(t){const e="symbols"in t,r=e?t.symbols:[t],n=await g(this.client,vN,{symbols:r,parent:t.parent},SN,CN);return e?n.symbols:n.symbols[0]}async rename(t,e){await g(this.client,zN,{key:t,name:e},kN,ro)}async retrieve(t){const e="key"in t,r=await g(this.client,bN,t,IN,xN);return ue("Schematic Symbol",t,r.symbols,e),e?r.symbols[0]:r.symbols}async delete(t){await g(this.client,TN,{keys:b.toArray(t)},NN,ro)}async retrieveGroup(){return(await g(this.client,ON,{},jN,$N)).group}};const ZN=t=>({type:"schematic_symbol",key:t}),PN=Object.freeze(Object.defineProperty({__proto__:null,Client:oh,DELETE_CHANNEL_NAME:UN,SET_CHANNEL_NAME:MN,handleZ:sh,keyZ:Ht,newZ:ih,ontologyID:ZN,regionZ:rh,specZ:ah,stateZ:nh,symbolZ:Rn},Symbol.toStringTag,{value:"Module"})),_N="/workspace/schematic/retrieve",RN="/workspace/schematic/create",DN="/workspace/schematic/rename",LN="/workspace/schematic/set-data",BN="/workspace/schematic/delete",FN="/workspace/schematic/copy",qN=a.z.object({key:rt,name:a.z.string()}),YN=a.z.object({key:rt,data:a.z.string()}),VN=a.z.object({keys:rt.array()}),HN=a.z.object({key:rt,name:a.z.string(),snapshot:a.z.boolean()}),WN=a.z.object({keys:rt.array()}),ch=a.z.object({key:rt}).transform(({key:t})=>({keys:[t]})),lh=a.z.union([ch,WN]),GN=a.z.object({schematics:b.nullableZ(La)}),KN=a.z.object({workspace:$e,schematics:th.array()}),JN=a.z.object({schematics:La.array()}),XN=a.z.object({schematic:_n}),ns=a.z.object({});let uh=class{symbols;client;constructor(t){this.client=t,this.symbols=new oh(t)}async create(t,e){const r=Array.isArray(e),n=await g(this.client,RN,{workspace:t,schematics:b.toArray(e)},KN,JN);return r?n.schematics:n.schematics[0]}async rename(t,e){await g(this.client,DN,{key:t,name:e},qN,ns)}async setData(t,e){await g(this.client,LN,{key:t,data:JSON.stringify(e)},YN,ns)}async retrieve(t){const e=ch.safeParse(t).success,r=await g(this.client,_N,t,lh,GN);return ue("Schematic",t,r.schematics,e),e?r.schematics[0]:r.schematics}async delete(t){await g(this.client,BN,{keys:b.toArray(t)},VN,ns)}async copy(t){return(await g(this.client,FN,t,HN,XN)).schematic}};const QN=t=>({type:"schematic",key:t}),eE=Object.freeze(Object.defineProperty({__proto__:null,Client:uh,keyZ:rt,newZ:th,ontologyID:QN,remoteZ:La,retrieveArgsZ:lh,schematicZ:_n,symbol:PN},Symbol.toStringTag,{value:"Module"})),zt=a.z.uuid(),Ba=a.z.object({key:zt,name:a.z.string(),data:Te.unknownZ.or(a.z.string().transform(je))}),hh=Ba.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Fa=Ba.extend({data:a.z.string().transform(je)}),tE="/workspace/table/retrieve",rE="/workspace/table/create",nE="/workspace/table/rename",sE="/workspace/table/set-data",aE="/workspace/table/delete",iE=a.z.object({key:zt,name:a.z.string()}),oE=a.z.object({key:zt,data:a.z.string()}),cE=a.z.object({keys:zt.array()}),lE=a.z.object({keys:zt.array()}),dh=a.z.object({key:zt}).transform(({key:t})=>({keys:[t]})),fh=a.z.union([dh,lE]),uE=a.z.object({tables:b.nullableZ(Fa)}),hE=a.z.object({workspace:$e,tables:hh.array()}),dE=a.z.object({tables:Fa.array()}),ss=a.z.object({});let ph=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await g(this.client,rE,{workspace:t,tables:b.toArray(e)},hE,dE);return r?n.tables:n.tables[0]}async rename(t,e){await g(this.client,nE,{key:t,name:e},iE,ss)}async setData(t,e){await g(this.client,sE,{key:t,data:JSON.stringify(e)},oE,ss)}async retrieve(t){const e=dh.safeParse(t).success,r=await g(this.client,tE,t,fh,uE);return ue("Table",t,r.tables,e),e?r.tables[0]:r.tables}async delete(t){await g(this.client,aE,{keys:b.toArray(t)},cE,ss)}};const fE=t=>({type:"table",key:t}),pE=Object.freeze(Object.defineProperty({__proto__:null,Client:ph,keyZ:zt,newZ:hh,ontologyID:fE,remoteZ:Fa,retrieveArgsZ:fh,tableZ:Ba},Symbol.toStringTag,{value:"Module"})),no="/workspace/retrieve",yE="/workspace/create",mE="/workspace/rename",gE="/workspace/set-layout",wE="/workspace/delete",so=a.z.object({keys:$e.array().optional(),searchTerm:a.z.string().optional(),author:et.optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),bE=a.z.object({workspaces:Vu.array()}),vE=a.z.object({key:$e,name:a.z.string()}),zE=a.z.object({key:$e,layout:Te.unknownZ.transform(t=>JSON.stringify(t))}),TE=a.z.object({keys:$e.array()}),ao=a.z.object({workspaces:b.nullableZ(Zn)}),OE=a.z.object({workspaces:Hu.array()}),as=a.z.object({}),SE="sy_workspace_set",kE="sy_workspace_delete";class yh{schematics;lineplots;logs;tables;client;constructor(e){this.client=e,this.schematics=new uh(e),this.lineplots=new Ku(e),this.logs=new eh(e),this.tables=new ph(e)}async create(e){const r=Array.isArray(e),n=await g(this.client,yE,{workspaces:b.toArray(e)},bE,OE);return r?n.workspaces:n.workspaces[0]}async rename(e,r){await g(this.client,mE,{key:e,name:r},vE,as)}async setLayout(e,r){await g(this.client,gE,{key:e,layout:r},zE,as)}async retrieve(e){let r;const n=typeof e!="string";typeof e=="string"||Array.isArray(e)?r={keys:b.toArray(e)}:r=e;const s=await g(this.client,no,r,so,ao);return n?s.workspaces:s.workspaces[0]}async retrieveByAuthor(e){return(await g(this.client,no,{author:e},so,ao)).workspaces}async delete(e){await g(this.client,wE,{keys:b.toArray(e)},TE,as)}}const NE=t=>({type:"workspace",key:t}),EE=Object.freeze(Object.defineProperty({__proto__:null,Client:yh,DELETE_CHANNEL_NAME:kE,SET_CHANNEL_NAME:SE,keyZ:$e,newZ:Vu,ontologyID:NE,remoteZ:Hu,workspaceZ:Zn},Symbol.toStringTag,{value:"Module"})),mh=a.z.object({host:a.z.string({error:"Host is required"}).min(1,"Host is required"),port:a.z.number({error:"Port is required"}).or(a.z.string({error:"Port is required"})),username:a.z.string().min(1,"Username is required"),password:a.z.string().min(1,"Password is required"),connectivityPollFrequency:N.z.default(N.seconds(30)),secure:a.z.boolean().optional().default(!1),name:a.z.string().optional(),retry:ya.breakerConfigZ.optional()});class AE extends hu{createdAt;params;ranges;channels;auth;users;access;connectivity;ontology;workspaces;labels;statuses;hardware;control;arcs;static connectivity=Ls;transport;clientVersion="0.48.0";constructor(e){const r=mh.parse(e),{host:n,port:s,username:i,password:o,connectivityPollFrequency:c,secure:l,retry:u}=r,h=new qu(new xt({host:n,port:Number(s)}),u,l);h.use(Sg);let f;i!=null&&o!=null&&(f=new HO(h.unary,{username:i,password:o}),h.use(f.middleware()));const d=new Ca(new Mr(h.unary)),v=new Gl(h.unary,d);super(h.stream,h.unary,d),this.createdAt=C.now(),this.params=r,this.auth=f,this.transport=h,this.channels=new Vl(this,d,h.unary,v),this.connectivity=new Ls(h.unary,c,this.clientVersion,r.name),this.control=new pu(this),this.ontology=new nl(h.unary,this);const x=new Bu(this.transport.unary);this.labels=new Zu(this.transport.unary),this.statuses=new Fu(this.transport.unary),this.ranges=new Du(this,x,this.transport.unary,d,this.labels,this.ontology),this.access=new mw(this.transport.unary),this.users=new Jl(this.transport.unary),this.workspaces=new yh(this.transport.unary);const j=new Tu(this.transport.unary),w=new xu(this.transport.unary,this,this.ontology,this.ranges),O=new Ou(this.transport.unary,w);this.hardware=new AS(w,O,j),this.arcs=new _l(this.transport.unary,this.transport.stream)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}}const IE=async t=>await gh(t).check(),gh=t=>{const{host:e,port:r,secure:n,name:s,retry:i}=t,o=ya.breakerConfigZ.optional().parse(i),c=new xt({host:e,port:Number(r)}),l=new qu(c,o,n);return new Ls(l.unary,void 0,"0.48.0",s)};N.seconds(1);let xE=class{sender;handlers;constructor(e){this.sender=e,this.handlers=new Map}handle({data:e}){const r=this.handlers.get(e.type)?.handler;r==null?console.warn(`No handler for ${e.type}`):r(e.payload)}route(e){const r=CE(e,this.sender),n=new jE(r);return this.handlers.set(e,n),n}};const CE=(t,e)=>(r,n)=>e({type:t,payload:r},n);class jE{_send;handler;constructor(e){this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}}const Ys=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof a.z.ZodError){const s=n.issues.map(i=>i.path.length===0?i.message:`${i.path.join(".")}: ${i.message}`);throw new Error(`${r} - ${s.join(`
64
- `)}`)}else throw n}},$E=a.z.object({l0:A.zr.colorZ,l1:A.zr.colorZ,l2:A.zr.colorZ,l3:A.zr.colorZ,l4:A.zr.colorZ,l5:A.zr.colorZ,l6:A.zr.colorZ,l7:A.zr.colorZ,l8:A.zr.colorZ,l9:A.zr.colorZ,l10:A.zr.colorZ,l11:A.zr.colorZ}),fe=(t,e)=>[t[0],t[1],e,t[3]],ME=a.z.object({m2:A.zr.colorZ,m1:A.zr.colorZ,z:A.zr.colorZ,p1:A.zr.colorZ,p2:A.zr.colorZ}),Jr=ME.or(A.zr.colorZ.transform(t=>{const e=A.zr.hsla(t);return{m2:A.zr.fromHSLA(fe(e,40)),m1:A.zr.fromHSLA(fe(e,45)),z:t,p1:A.zr.fromHSLA(fe(e,55)),p2:A.zr.fromHSLA(fe(e,65))}})),wh=a.z.object({name:a.z.string(),key:a.z.string(),colors:a.z.object({border:A.zr.colorZ,primary:Jr,gray:$E,error:Jr,secondary:Jr,warning:Jr,palettes:a.z.record(a.z.string(),A.zr.paletteZ),visualization:a.z.object({palettes:a.z.record(a.z.string(),a.z.array(A.zr.colorZ))}).optional().default({palettes:{}}),white:A.zr.colorZ,black:A.zr.colorZ,text:A.zr.colorZ,textInverted:A.zr.colorZ,textOnPrimary:A.zr.colorZ.optional().default(A.zr.ZERO),logo:a.z.string()}),sizes:a.z.object({base:a.z.number(),border:a.z.object({radius:a.z.number(),width:a.z.number(),thickWidth:a.z.number()}),schematic:a.z.object({elementStrokeWidth:a.z.number()})}),typography:a.z.object({family:a.z.string(),codeFamily:a.z.string(),h1:Fe.specZ,h2:Fe.specZ,h3:Fe.specZ,h4:Fe.specZ,h5:Fe.specZ,p:Fe.specZ,small:Fe.specZ})}).transform(t=>((t.colors.textOnPrimary==null||A.zr.isZero(t.colors.textOnPrimary))&&(t.colors.textOnPrimary=A.zr.pickByContrast(t.colors.primary.z,t.colors.text,t.colors.textInverted)),t)),UE='"Inter Variable", sans-serif',ZE='"Geist Mono", monospace',PE=6,Gt=[357,91,55,1],Kt=[48,90,55,1],_E=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],Jt=Object.fromEntries(_E.map((t,e)=>[`l${e}`,t])),RE=()=>typeof window>"u"?!1:window.devicePixelRatio>1,DE=RE(),Vs={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#356fc5",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:Jt,border:Jt.l4,error:{m2:A.zr.fromHSLA(fe(Gt,30)),m1:A.zr.fromHSLA(fe(Gt,40)),z:A.zr.fromHSLA(Gt),p1:A.zr.fromHSLA(fe(Gt,65)),p2:A.zr.fromHSLA(fe(Gt,77))},warning:{m2:A.zr.fromHSLA(fe(Kt,30)),m1:A.zr.fromHSLA(fe(Kt,40)),z:A.zr.fromHSLA(Kt),p1:A.zr.fromHSLA(fe(Kt,65)),p2:A.zr.fromHSLA(fe(Kt,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:Jt.l11,textInverted:Jt.l0,textOnPrimary:Jt.l0},sizes:{base:PE,border:{radius:3,width:DE?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:UE,codeFamily:ZE,h1:{size:5.5,weight:"500",lineHeight:5.5*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.6666,weight:"medium",lineHeight:2.6666*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:2.3333333}}},bh=Object.freeze({...Vs,key:"synnaxLight",name:"Synnax Light"}),LE=["#020202","#080808","#151515","#202020","#272727","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],Xt=Object.fromEntries(LE.map((t,e)=>[`l${e}`,t])),vh=Object.freeze({...Vs,key:"synnaxDark",name:"Synnax Dark",colors:{...Vs.colors,gray:Xt,logo:"var(--pluto-text-color)",border:Xt.l4,text:Xt.l11,textInverted:Xt.l0,textOnPrimary:Xt.l11}}),BE={synnaxDark:vh,synnaxLight:bh},zh=["tiny","small","medium","large","huge"],Th=a.z.enum(zh),FE=t=>Th.safeParse(t).success;class Pt{_noop=!1;key;path;serviceName;constructor(e,r,n="",s=!1){this.key=e,this.path=r,this.serviceName=n,this._noop=s}child(e){return new Pt(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new Pt("","","")}const Hs=["debug","info","warn","error"],Oh=t=>{const e=Hs.indexOf(t);return({level:r})=>Hs.indexOf(r)>=e},qE=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(s=>n.startsWith(s))||r!=null&&r.some(s=>n.startsWith(s)))};class _t{meta=Pt.NOOP;filters;constructor(e={}){const{filters:r=[]}=e;this.filters=r}filter(e){return!this.meta.noop&&this.filters.every(r=>r({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const r=new _t({filters:this.filters});return r.meta=e,r}debug(e,r,n=!1){!this.filter("debug")&&!n||(r==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,Xr(r)))}info(e,r,n=!1){!this.filter("info")&&!n||(r==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,Xr(r)))}warn(e,r,n=!1){!this.filter("warn")&&!n||(r==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,Xr(r)))}error(e,r,n=!1){!this.filter("error")&&!n||(r==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,Xr(r)))}static NOOP=new _t}const Xr=t=>typeof t=="function"?t():t;var YE=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},ct="1.9.0",io=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function VE(t){var e=new Set([t]),r=new Set,n=t.match(io);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(c){return r.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(io);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var HE=VE(ct),WE=ct.split(".")[0],mr=Symbol.for("opentelemetry.js.api."+WE),gr=YE;function qa(t,e,r,n){var s;n===void 0&&(n=!1);var i=gr[mr]=(s=gr[mr])!==null&&s!==void 0?s:{version:ct};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==ct){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+ct);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+ct+"."),!0}function wr(t){var e,r,n=(e=gr[mr])===null||e===void 0?void 0:e.version;if(!(!n||!HE(n)))return(r=gr[mr])===null||r===void 0?void 0:r[t]}function Ya(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+ct+".");var r=gr[mr];r&&delete r[t]}var GE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},KE=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},JE=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Qt("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Qt("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Qt("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Qt("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Qt("verbose",this._namespace,e)},t})();function Qt(t,e,r){var n=wr("diag");if(n)return r.unshift(e),n[t].apply(n,KE([],GE(r),!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 XE(t,e){t<oe.NONE?t=oe.NONE:t>oe.ALL&&(t=oe.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",oe.ERROR),warn:r("warn",oe.WARN),info:r("info",oe.INFO),debug:r("debug",oe.DEBUG),verbose:r("verbose",oe.VERBOSE)}}var QE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},eA=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},tA="diag",br=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var c=wr("diag");if(c)return c[s].apply(c,eA([],QE(i),!1))}}var r=this,n=function(s,i){var o,c,l;if(i===void 0&&(i={logLevel:oe.INFO}),s===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=u.stack)!==null&&o!==void 0?o:u.message),!1}typeof i=="number"&&(i={logLevel:i});var h=wr("diag"),f=XE((c=i.logLevel)!==null&&c!==void 0?c:oe.INFO,s);if(h&&!i.suppressOverrideMessage){var d=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";h.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return qa("diag",f,r,!0)};r.setLogger=n,r.disable=function(){Ya(tA,r)},r.createComponentLogger=function(s){return new JE(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})(),rA=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},nA=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},sA=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=rA(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=nA(n),c=o.next();!c.done;c=o.next()){var l=c.value;i._entries.delete(l)}}catch(u){e={error:u}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();br.instance();function aA(t){return t===void 0&&(t={}),new sA(new Map(Object.entries(t)))}function iA(t){return Symbol.for(t)}var oA=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),cA=new oA,lA={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},uA={set:function(t,e,r){t!=null&&(t[e]=r)}},hA=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},dA=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},fA=(function(){function t(){}return t.prototype.active=function(){return cA},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,dA([n],hA(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})(),pA=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},yA=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},is="context",mA=new fA,Sh=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return qa(is,e,br.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,yA([e,r,n],pA(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return wr(is)||mA},t.prototype.disable=function(){this._getContextManager().disable(),Ya(is,br.instance())},t})(),Ws;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Ws||(Ws={}));var gA=Sh.getInstance(),wA=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})(),Va=iA("OpenTelemetry Baggage Key");function kh(t){return t.getValue(Va)||void 0}function bA(){return kh(Sh.getInstance().active())}function vA(t,e){return t.setValue(Va,e)}function zA(t){return t.deleteValue(Va)}var os="propagation",TA=new wA,OA=(function(){function t(){this.createBaggage=aA,this.getBaggage=kh,this.getActiveBaggage=bA,this.setBaggage=vA,this.deleteBaggage=zA}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return qa(os,e,br.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=uA),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=lA),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){Ya(os,br.instance())},t.prototype._getGlobalPropagator=function(){return wr(os)||TA},t})(),SA=OA.getInstance();const oo=["bench","debug","prod"],kA=t=>e=>oo.indexOf(e)>=oo.indexOf(t);class vr{meta=Pt.NOOP;otelTracer;filter;constructor(e,r=kA("debug")){this.otelTracer=e,this.filter=r}child(e){const r=new vr(this.otelTracer,this.filter);return r.meta=e,r}debug(e,r){return this.trace(e,"debug",r)}bench(e,r){return this.trace(e,"bench",r)}prod(e,r){return this.trace(e,"prod",r)}trace(e,r,n){const s=this.meta.noop||!this.filter(r)||this.otelTracer==null;if(n==null){if(s)return()=>{};const i=new Gs(e,this.otelTracer.startSpan(e));return i.start(),()=>i.end()}return s?n(new Nh(e)):this.otelTracer.startActiveSpan(e,i=>{const o=new Gs(e,i);return n(o)})}propagate(e){if(this.meta.noop)return;const r=gA.active();SA.inject(r,e,{set:(n,s,i)=>{n[s]=i}})}static NOOP=new vr}class Gs{key;otel;constructor(e,r){this.key=e,this.otel=r}set(e,r){this.otel.setAttribute(e,r)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Ws.ERROR}))}start(){performance.mark(`alamos.trace.start.${this.key}`)}end(){try{performance.mark(`alamos.trace.end.${this.key}`);const e=performance.measure(`alamos.trace.duration.${this.key}`,`alamos.trace.start.${this.key}`,`alamos.trace.end.${this.key}`);this.set("duration",e.duration),this.otel.end()}catch(e){console.error(e)}}}class Nh{key;constructor(e){this.key=e}set(){}recordError(e){}}class Rt{meta;T;L;constructor({key:e="",serviceName:r="",logger:n=_t.NOOP,tracer:s=vr.NOOP,noop:i=!1,__meta:o}){this.meta=o??new Pt(e,e,r,i),this.T=s.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new Rt({__meta:r,tracer:this.T,logger:this.L})}static NOOP=new Rt({noop:!0})}const NA=Rt.NOOP,Eh=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Rt,LOG_LEVELS:Hs,Logger:_t,NOOP:NA,NoopSpan:Nh,Tracer:vr,_Span:Gs,logLevelKeyFiler:qE,logThresholdFilter:Oh},Symbol.toStringTag,{value:"Module"})),cs=(t,e)=>t instanceof Error?(t.message=`[${e}] - ${t.message}`,t):new Error(e??"unknown error",{cause:t});class Ha{type;key;sender;_internalState;_state;_prevState;_deleted=!1;parentCtxValues;childCtxValues;childCtxChangedKeys;instrumentation;schema=void 0;constructor({key:e,type:r,sender:n,instrumentation:s,parentCtxValues:i}){this.type=r,this.key=e,this.sender=n,this._internalState={},this.instrumentation=s.child(this.toString()),this.parentCtxValues=new Map,i?.forEach((o,c)=>this.parentCtxValues.set(c,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}get _schema(){if(this.schema==null)throw new V(`[AetherLeaf] - expected subclass to define component schema, but none was found.
65
- Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const r=Fe.executeSetter(e,this.state);this._prevState=A.en(this._state),this._state=Ys(this._schema,r,`${this.toString()}`),this.sender.send({variant:"update",key:this.key,state:this._state})}get state(){if(this._state==null)throw new le(`[AetherLeaf] - state not defined in ${this.toString()}`);return this._state}get internal(){return this._internalState}get prevState(){if(this._prevState===void 0)throw new Error("prevState not defined");return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>{const r=this.parentCtxValues.get(e);if(r===void 0)throw new Ut(`Context value for ${e} not found on ${this.toString()}`);return r},getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),wasSetPreviously:e=>this.childCtxValues.has(e),set:(e,r,n=!0)=>{this.childCtxValues.set(e,r),n&&this.childCtxChangedKeys.add(e)}}}toString(){return`${this.type}(${this.key})`}_updateState({path:e,state:r}){if(!this.deleted)try{const n=this.instrumentation.T.debug(`${this.toString()}:updateState`);this.validatePath(e);const s=Ys(this._schema,r,`${this.toString()}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:Rh.T.difference(this.state,s)})):this.instrumentation.L.debug("setting initial state",{state:r,path:e}),this._prevState=this._state??s,this._state=s,this.afterUpdate(this.ctx),n()}catch(n){throw cs(n,`${this.toString()}.updateState`)}}_updateContext(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:updateContext`);e.forEach((n,s)=>this.parentCtxValues.set(s,n)),this.afterUpdate(this.ctx),r()}catch(r){throw cs(r,`${this.type}.${this.key}.updateContext`)}}_delete(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:delete`);this.validatePath(e),this._deleted=!0,this.afterDelete(this.ctx),r()}catch(r){throw cs(r,`[${this.toString()}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new le(`[Leaf.setState] - ${this.toString()} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new le(`[Leaf.setState] - ${this.toString()} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new le(`[Leaf.setState] - ${this.toString()} received a key ${r} but expected ${this.key}`)}}class Rr extends Ha{_children=new Map;get children(){return Array.from(this._children.values())}getChild(e){return this._children.get(e)??null}childrenOfType(...e){return this.children.filter(r=>e.includes(r.type))}_updateState(e){const{path:r,type:n,create:s}=e;if(this.deleted)return;const i=this.parsePath(r);if(i.length===0){if(this.childCtxChangedKeys.clear(),super._updateState(e),this.childCtxChangedKeys.size==0)return;this.updateChildContexts();return}const c=i[0],l=this.getChild(c);if(l!=null)return l._updateState({...e,path:i});if(i.length>1){const h=r.slice(0,r.indexOf(c)+1).join("."),f=r.join(".");throw new le(`Child of ${this.toString()} at path ${h} does not exist,
66
- but an extended path ${f} was provided. This means that the aether
67
- tree is attempting to create a new child of type ${n} (or nested children)
68
- on a child that does not exist.
69
-
70
- Children present: ${this.children.map(d=>`${d.type}:${d.key}`).join(".")}
71
-
72
- `)}const u=s(this.childCtx());u._updateState({...e,path:i}),this._children.set(c,u)}_updateContext(e){super._updateContext(e),this.updateChildContexts()}childCtx(){return{get:e=>this.childCtxValues.get(e)??this.parentCtxValues.get(e),forEach:e=>{this.childCtxValues.forEach((r,n)=>e(r,n,this.childCtxValues)),this.parentCtxValues.forEach((r,n)=>{this.childCtxValues.has(n)||e(r,n,this.parentCtxValues)})}}}updateChildContexts(){const e=this.childCtx();this.children.forEach(r=>r._updateContext(e))}_delete(e){const r=this.parsePath(e);if(r.length===0){for(const s of this.children)s._delete([s.key]);this._children.clear(),super._delete([this.key])}const n=this.getChild(r[0]);if(n!=null){if(r.length>1)return n._delete(r);this._children.delete(n.key),n._delete(r)}}parsePath(e,r){const[n,...s]=e;if(n==null)throw new Error(`Composite ${this.toString()} received an empty path${r!=null?` for ${r}`:""}`);if(n!==this.key)throw new le(`[Composite.getRequiredKey] - ${this.toString()} received a key ${n} but expected ${this.key}`);return s}}const EA=a.z.object({}),AA=()=>{throw new Error("should not call create")};class He extends Rr{static TYPE="root";static KEY="root";comms;registry;schema=EA;constructor({comms:e,instrumentation:r=Eh.Instrumentation.NOOP,registry:n}){super({key:He.KEY,type:He.TYPE,sender:e,instrumentation:r,parentCtxValues:null}),this.comms=e,this.registry=n}static render(e){const r=new He(e);return r._updateState({path:[He.KEY],type:"",state:{},create:AA}),r.comms.handle(n=>{try{r.handle(n)}catch(s){const i={name:"unknown",message:JSON.stringify(s),stack:"unknown"};s instanceof Error&&(i.name=s.name,i.message=s.message,i.stack=s.stack),r.comms.send({variant:"error",error:i})}}),r}handle(e){const{path:r,variant:n,type:s}=e;if(n==="delete"){this._delete(r);return}const{state:i}=e;this._updateState({path:r,type:s,state:i,create:o=>{const c=r[r.length-1];return this.create({key:c,type:s,parentCtxValues:o})}})}create({key:e,type:r,parentCtxValues:n}){const s=this.registry[r];if(s==null)throw new le(`[Root.create] - ${r} not found in registry`);return new s({key:e,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:n})}}const Ah=He.render.bind(He),IA=Object.freeze(Object.defineProperty({__proto__:null,Composite:Rr,Leaf:Ha,Root:He,render:Ah},Symbol.toStringTag,{value:"Module"})),xA=(t,e)=>Array.isArray(e)?e.some(r=>r.matches(t)):e?.matches(t)??!1,Ih=(t,e,r)=>{const n=A.tn.fromException(t,e);return console.error(n),xA(t,r)?null:n},xh=(t,e,r,n)=>{if(typeof t=="function")return!0;const s=Ih(t,r,n);return s!=null&&e(s),!1},Ch=async(t,e,r,n)=>{try{const s=t();s!=null&&await s}catch(s){const i=Ih(s,r,n);if(i!=null)return e(i)}},jh=t=>(e,r,n)=>{xh(e,t,r,n)&&Ch(e,t,r,n)},$h=t=>async(e,r,n)=>{xh(e,t,r,n)&&await Ch(e,t,r,n)},Mh=a.z.object({statuses:A.tn.statusZ().array()}),fn="status.aggregator";class Ks extends Rr{static TYPE="status.Aggregator";schema=Mh;afterUpdate(e){e.wasSetPreviously(fn)||e.set(fn,{add:this.add.bind(this),create:A.tn.create})}add(e){this.setState(r=>({...r,statuses:[...r.statuses,A.tn.create(e)]}))}}const Wa=t=>t.get(fn).add,CA=t=>{const e=t.getOptional(fn);return e!=null?e.add:()=>{}},Uh=t=>jh(Wa(t)),jA=t=>$h(Wa(t)),$A={[Ks.TYPE]:Ks},Js="pluto-theming-context",Zh=a.z.object({name:a.z.string(),url:a.z.string()}),MA=a.z.object({theme:wh,fontURLs:a.z.array(Zh)});class zr extends Rr{static TYPE="theming.Provider";static z=MA;schema=zr.z;afterUpdate(e){if(e.getOptional(Js)!=null&&this.state.theme.key===this.prevState.theme.key)return;e.set(Js,this.state.theme),Uh(e)(async()=>{await this.loadFonts()},"failed to load theme fonts")}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:e,url:r})=>{const n=new FontFace(e,`url(${r})`);try{await n.load(),self.fonts.add(n)}catch(s){console.error(s)}}))}}const UA=t=>t.get(Js),ZA={[zr.TYPE]:zr};exports.$I=zg;exports.A=N;exports.AI=Bg;exports.Aggregator=Ks;exports.BI=RO;exports.Composite=Rr;exports.DI=HT;exports.G=V;exports.Leaf=Ha;exports.Mn=Ut;exports.O=Rt;exports.Provider=zr;exports.QS=AE;exports.REGISTRY=ZA;exports.REGISTRY$1=$A;exports.SIZES=zh;exports.SYNNAX_DARK=vh;exports.SYNNAX_LIGHT=bh;exports.SYNNAX_THEMES=BE;exports.WI=ES;exports.XI=qS;exports.XS=mh;exports.YI=zS;exports.ZI=tw;exports._=_t;exports.aA=xk;exports.aether=IA;exports.aggregatorStateZ=Mh;exports.bA=IE;exports.be=Oh;exports.cA=Bk;exports.createAsyncErrorHandler=$h;exports.createErrorHandler=jh;exports.d=xE;exports.eA=o0;exports.eI=gh;exports.fA=gN;exports.fontSpecZ=Zh;exports.g=Eh;exports.gA=pE;exports.isSize=FE;exports.j=Z;exports.lA=nN;exports.nA=E0;exports.p=C;exports.prettyParse=Ys;exports.qt=le;exports.render=Ah;exports.rt=Xe;exports.sA=Y0;exports.size=Th;exports.themeZ=wh;exports.use=UA;exports.useAdder=Wa;exports.useAsyncErrorHandler=jA;exports.useErrorHandler=Uh;exports.useOptionalAdder=CA;exports.wA=EE;exports.yA=eE;exports.zI=wO;