@synnaxlabs/pluto 0.49.0 → 0.50.1

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 (503) hide show
  1. package/dist/{Animated-Bp6IK3ct.js → Animated-BbeJdao0.js} +3 -3
  2. package/dist/{Animated-38tdmPR0.js → Animated-C4xrEVd-.js} +50 -50
  3. package/dist/Animated-Dvm2k_z_.cjs +1 -0
  4. package/dist/{Animated-Dsn1pmhz.cjs → Animated-umWjgTzy.cjs} +1 -1
  5. package/dist/{Box-4l6DWG-3.cjs → Box-D27bV7QJ.cjs} +1 -1
  6. package/dist/{Box-BVyAHr2f.js → Box-DLO7l9hM.js} +9 -9
  7. package/dist/Button-BSek5HG5.cjs +1 -0
  8. package/dist/{Button-CoOYEk1J.js → Button-DLtxKGH5.js} +98 -98
  9. package/dist/{Dialog-JwJQD3xZ.cjs → Dialog-BpjxXSmw.cjs} +1 -1
  10. package/dist/{Dialog-puVY-0Mt.js → Dialog-BspO7uo8.js} +3 -3
  11. package/dist/{Editable-DI0-D1K5.cjs → Editable-C-z-stcD.cjs} +1 -1
  12. package/dist/{Editable-DEbVpi5i.js → Editable-DjQORuR1.js} +3 -3
  13. package/dist/{Haul-Db9j45Fu.js → Haul-DBy-2ds_.js} +24 -24
  14. package/dist/Haul-WgPKptr9.cjs +1 -0
  15. package/dist/{Items-BCG7kyaR.cjs → Items-07R286kW.cjs} +2 -2
  16. package/dist/{Items-BVKW0udb.js → Items-CX11yLMf.js} +25 -23
  17. package/dist/Menu-58O-OOPJ.cjs +1 -0
  18. package/dist/Menu-GBo3ayoP.js +135 -0
  19. package/dist/Provider-BA3zQVbv.cjs +1 -0
  20. package/dist/{Provider-DQM7IBoi.js → Provider-BkxUzTWS.js} +399 -320
  21. package/dist/Tags-DWsEZD9t.cjs +1 -0
  22. package/dist/{Tags-B8l5Dvw-.js → Tags-V7sNuGZv.js} +187 -182
  23. package/dist/{Text-DeWvfrdF.cjs → Text-DW5FpCk9.cjs} +1 -1
  24. package/dist/{Text-90J6p5Uj.js → Text-XeD58Fq8.js} +625 -600
  25. package/dist/{Video-CLpcYcKf.js → Video-C56z7qvH.js} +1 -1
  26. package/dist/{Video-Bmg4gwom.cjs → Video-CBPTBLTB.cjs} +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-bahPRiQI.js → css-BkBrZtKZ.js} +562 -569
  32. package/dist/{css-BVgFAmaj.cjs → css-D3NdC2sx.cjs} +4 -4
  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 → dimensions-C7b02rFi.cjs} +1 -1
  38. package/dist/{dimensions-qcyzaTKI.js → dimensions-qj2CkPTy.js} +6 -6
  39. package/dist/{eraser-Cbfc1frM.cjs → eraser-Bocga8Eb.cjs} +3 -3
  40. package/dist/{eraser-Dz6nZuPp.js → eraser-DuAfpO0P.js} +38 -38
  41. package/dist/ether.cjs +1 -1
  42. package/dist/ether.js +54 -55
  43. package/dist/{external-CMs_BCc5.cjs → external-5_uHky7w.cjs} +2 -2
  44. package/dist/{external-m-0q-0os.js → external-B-JsNciM.js} +5 -5
  45. package/dist/{external-CwYoEhB2.cjs → external-B3o5P8Yw.cjs} +1 -1
  46. package/dist/{external-Bixqkw5N.cjs → external-B9omdiDK.cjs} +1 -1
  47. package/dist/{external-kwuGKgyL.cjs → external-BIbdeWQE.cjs} +1 -1
  48. package/dist/external-BRA_zA83.cjs +1 -0
  49. package/dist/{external-PA6ulZR9.cjs → external-Bjh6lsVm.cjs} +1 -1
  50. package/dist/external-BwRkgEyo.cjs +1 -0
  51. package/dist/{external-TI-6Umwm.js → external-CLQdSLv0.js} +6 -6
  52. package/dist/{external-DJWZ43k0.js → external-CdHyPhLI.js} +1 -1
  53. package/dist/{external-CB3VxPJp.js → external-Ct1k30Nd.js} +24 -24
  54. package/dist/external-Ct2A_YCT.cjs +1 -0
  55. package/dist/{external-04ve_X21.js → external-DNbIzfVy.js} +45 -44
  56. package/dist/{external-B3b7kdID.cjs → external-DT82RBon.cjs} +1 -1
  57. package/dist/{external-Cxojc4yT.js → external-DXWEyk9d.js} +11 -11
  58. package/dist/{external-D2tzyCDs.cjs → external-DojNoICL.cjs} +1 -1
  59. package/dist/{external-CnWQzZlQ.js → external-Dp5OkGYV.js} +69 -68
  60. package/dist/{external-xJ67ivgR.js → external-DxmgAHkn.js} +3 -3
  61. package/dist/{external-DUVDOJfj.cjs → external-DyTk_hS7.cjs} +1 -1
  62. package/dist/{external-DP9FiRHq.js → external-MvcifV4O.js} +3 -3
  63. package/dist/external-PXU0gc_j.cjs +84 -0
  64. package/dist/{external-CrXS1qj_.js → external-g_vt4Lku.js} +13386 -12955
  65. package/dist/{external-D2deiHyL.js → external-sYHm9OG8.js} +10 -9
  66. package/dist/{external-Hhx8JoAS.js → external-xfkS0zGI.js} +12 -12
  67. package/dist/flex.cjs +1 -1
  68. package/dist/flex.js +1 -1
  69. package/dist/{fontString-qfWSw62X.js → fontString-CSWLcJcC.js} +3 -3
  70. package/dist/{fontString-62eEvw4b.cjs → fontString-TocVNWmy.cjs} +1 -1
  71. package/dist/header.cjs +1 -1
  72. package/dist/header.js +1 -1
  73. package/dist/{hooks-Dh0v1QWQ.js → hooks-BeSuo_di.js} +25 -25
  74. package/dist/hooks-Eb94kuDd.cjs +1 -0
  75. package/dist/index.cjs +23 -15
  76. package/dist/index.js +11147 -10778
  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-ClhgBr_F.js → provider-D0K9E52u.js} +4030 -3699
  85. package/dist/provider-DksyuJua.cjs +78 -0
  86. package/dist/src/access/policy/Select.d.ts.map +1 -1
  87. package/dist/src/access/policy/aether/queries.d.ts.map +1 -1
  88. package/dist/src/access/policy/queries.d.ts +8 -6
  89. package/dist/src/access/policy/queries.d.ts.map +1 -1
  90. package/dist/src/access/role/Select.d.ts +2 -2
  91. package/dist/src/access/role/Select.d.ts.map +1 -1
  92. package/dist/src/access/role/queries.d.ts +2 -2
  93. package/dist/src/access/role/queries.d.ts.map +1 -1
  94. package/dist/src/aether/aether/aether.d.ts +86 -10
  95. package/dist/src/aether/aether/aether.d.ts.map +1 -1
  96. package/dist/src/aether/aether/aether.spec.d.ts.map +1 -1
  97. package/dist/src/aether/main.d.ts +34 -11
  98. package/dist/src/aether/main.d.ts.map +1 -1
  99. package/dist/src/aether/message.d.ts +31 -6
  100. package/dist/src/aether/message.d.ts.map +1 -1
  101. package/dist/src/aether/test/index.d.ts +2 -0
  102. package/dist/src/aether/test/index.d.ts.map +1 -0
  103. package/dist/src/aether/test/provider.d.ts +4 -0
  104. package/dist/src/aether/test/provider.d.ts.map +1 -0
  105. package/dist/src/aether/test/provider.spec.d.ts +2 -0
  106. package/dist/src/aether/test/provider.spec.d.ts.map +1 -0
  107. package/dist/src/arc/handle/Base.d.ts +8 -0
  108. package/dist/src/arc/handle/{Core.d.ts.map → Base.d.ts.map} +1 -1
  109. package/dist/src/arc/handle/Sink.d.ts +2 -2
  110. package/dist/src/arc/handle/Source.d.ts +2 -2
  111. package/dist/src/arc/queries.d.ts +33 -10
  112. package/dist/src/arc/queries.d.ts.map +1 -1
  113. package/dist/src/button/Button.d.ts +2 -2
  114. package/dist/src/button/Button.d.ts.map +1 -1
  115. package/dist/src/button/Toggle.d.ts.map +1 -1
  116. package/dist/src/channel/LinePlot.d.ts +7 -6
  117. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  118. package/dist/src/channel/Select.d.ts.map +1 -1
  119. package/dist/src/channel/queries.d.ts +6 -5
  120. package/dist/src/channel/queries.d.ts.map +1 -1
  121. package/dist/src/color/BaseSwatch.d.ts.map +1 -1
  122. package/dist/src/color/Picker.d.ts.map +1 -1
  123. package/dist/src/color/Swatch.d.ts.map +1 -1
  124. package/dist/src/component/SelectSize.d.ts.map +1 -1
  125. package/dist/src/css/bem.d.ts +2 -2
  126. package/dist/src/css/css.d.ts +1 -1
  127. package/dist/src/device/Select.d.ts.map +1 -1
  128. package/dist/src/device/queries.d.ts +8 -8
  129. package/dist/src/device/queries.d.ts.map +1 -1
  130. package/dist/src/dialog/Frame.d.ts.map +1 -1
  131. package/dist/src/direction/Select.d.ts +2 -2
  132. package/dist/src/direction/Select.d.ts.map +1 -1
  133. package/dist/src/errors/Boundary.d.ts +29 -0
  134. package/dist/src/errors/Boundary.d.ts.map +1 -0
  135. package/dist/src/errors/Fallback.d.ts +32 -0
  136. package/dist/src/errors/Fallback.d.ts.map +1 -0
  137. package/dist/src/errors/errors.spec.d.ts +2 -0
  138. package/dist/src/errors/errors.spec.d.ts.map +1 -0
  139. package/dist/src/errors/external.d.ts +3 -0
  140. package/dist/src/errors/external.d.ts.map +1 -0
  141. package/dist/src/errors/index.d.ts +2 -0
  142. package/dist/src/errors/index.d.ts.map +1 -0
  143. package/dist/src/flux/Provider.d.ts +2 -2
  144. package/dist/src/flux/aether/external.d.ts +4 -4
  145. package/dist/src/flux/aether/provider.d.ts +7 -7
  146. package/dist/src/flux/{core → base}/client.d.ts.map +1 -1
  147. package/dist/src/flux/{core → base}/external.d.ts.map +1 -1
  148. package/dist/src/flux/base/index.d.ts +2 -0
  149. package/dist/src/flux/base/index.d.ts.map +1 -0
  150. package/dist/src/flux/{core → base}/store.d.ts.map +1 -1
  151. package/dist/src/flux/base/store.spec.d.ts.map +1 -0
  152. package/dist/src/flux/{core → base}/streamer.d.ts +1 -1
  153. package/dist/src/flux/{core → base}/streamer.d.ts.map +1 -1
  154. package/dist/src/flux/base/streamer.spec.d.ts.map +1 -0
  155. package/dist/src/flux/{core → base}/types.d.ts.map +1 -1
  156. package/dist/src/flux/external.d.ts +3 -3
  157. package/dist/src/flux/form.d.ts +13 -13
  158. package/dist/src/flux/form.d.ts.map +1 -1
  159. package/dist/src/flux/list.d.ts +11 -11
  160. package/dist/src/flux/list.d.ts.map +1 -1
  161. package/dist/src/flux/retrieve.d.ts +20 -20
  162. package/dist/src/flux/retrieve.d.ts.map +1 -1
  163. package/dist/src/flux/update.d.ts +23 -22
  164. package/dist/src/flux/update.d.ts.map +1 -1
  165. package/dist/src/form/Field.d.ts.map +1 -1
  166. package/dist/src/form/external.d.ts +0 -1
  167. package/dist/src/form/external.d.ts.map +1 -1
  168. package/dist/src/form/useField.d.ts.map +1 -1
  169. package/dist/src/group/queries.d.ts +5 -5
  170. package/dist/src/group/queries.d.ts.map +1 -1
  171. package/dist/src/haul/Haul.d.ts +3 -3
  172. package/dist/src/haul/Haul.d.ts.map +1 -1
  173. package/dist/src/header/ButtonTitle.d.ts.map +1 -1
  174. package/dist/src/icon/Icon.d.ts +1 -1
  175. package/dist/src/icon/Icon.d.ts.map +1 -1
  176. package/dist/src/icon/registry.d.ts +5 -0
  177. package/dist/src/icon/registry.d.ts.map +1 -1
  178. package/dist/src/index.d.ts +2 -1
  179. package/dist/src/index.d.ts.map +1 -1
  180. package/dist/src/input/Boolean.d.ts.map +1 -1
  181. package/dist/src/input/Date.d.ts.map +1 -1
  182. package/dist/src/input/DateTime.d.ts.map +1 -1
  183. package/dist/src/input/DragButton.d.ts.map +1 -1
  184. package/dist/src/input/HelpText.d.ts.map +1 -1
  185. package/dist/src/input/Label.d.ts.map +1 -1
  186. package/dist/src/input/Numeric.d.ts.map +1 -1
  187. package/dist/src/input/Text.d.ts.map +1 -1
  188. package/dist/src/input/Time.d.ts.map +1 -1
  189. package/dist/src/label/Select.d.ts.map +1 -1
  190. package/dist/src/label/queries.d.ts +3 -3
  191. package/dist/src/label/queries.d.ts.map +1 -1
  192. package/dist/src/lineplot/Axis.d.ts.map +1 -1
  193. package/dist/src/lineplot/Legend.d.ts +2 -2
  194. package/dist/src/lineplot/Line.d.ts +2 -2
  195. package/dist/src/lineplot/LinePlot.d.ts +9 -3
  196. package/dist/src/lineplot/LinePlot.d.ts.map +1 -1
  197. package/dist/src/lineplot/Viewport.d.ts +2 -2
  198. package/dist/src/lineplot/aether/LinePlot.d.ts +17 -5
  199. package/dist/src/lineplot/aether/LinePlot.d.ts.map +1 -1
  200. package/dist/src/lineplot/aether/XAxis.d.ts +2 -2
  201. package/dist/src/lineplot/aether/YAxis.d.ts +2 -2
  202. package/dist/src/lineplot/aether/axis.d.ts +4 -4
  203. package/dist/src/lineplot/aether/external.d.ts +0 -1
  204. package/dist/src/lineplot/aether/external.d.ts.map +1 -1
  205. package/dist/src/lineplot/external.d.ts +0 -1
  206. package/dist/src/lineplot/external.d.ts.map +1 -1
  207. package/dist/src/lineplot/queries.d.ts +3 -3
  208. package/dist/src/lineplot/queries.d.ts.map +1 -1
  209. package/dist/src/lineplot/range/Annotation.d.ts.map +1 -1
  210. package/dist/src/lineplot/tooltip/Tooltip.d.ts.map +1 -1
  211. package/dist/src/list/Frame.d.ts +2 -2
  212. package/dist/src/list/Frame.d.ts.map +1 -1
  213. package/dist/src/list/Items.d.ts.map +1 -1
  214. package/dist/src/list/useKeysData.d.ts.map +1 -1
  215. package/dist/src/log/Log.d.ts.map +1 -1
  216. package/dist/src/log/queries.d.ts +3 -3
  217. package/dist/src/log/queries.d.ts.map +1 -1
  218. package/dist/src/menu/ContextMenu.d.ts +3 -2
  219. package/dist/src/menu/ContextMenu.d.ts.map +1 -1
  220. package/dist/src/menu/Menu.d.ts.map +1 -1
  221. package/dist/src/mosaic/Mosaic.d.ts.map +1 -1
  222. package/dist/src/nav/Bar.d.ts +3 -3
  223. package/dist/src/nav/Drawer.d.ts.map +1 -1
  224. package/dist/src/notation/Select.d.ts +2 -2
  225. package/dist/src/notation/Select.d.ts.map +1 -1
  226. package/dist/src/ontology/aether/queries.d.ts.map +1 -1
  227. package/dist/src/ontology/queries.d.ts +3 -3
  228. package/dist/src/ontology/queries.d.ts.map +1 -1
  229. package/dist/src/pluto/Pluto.d.ts +2 -0
  230. package/dist/src/pluto/Pluto.d.ts.map +1 -1
  231. package/dist/src/rack/Select.d.ts.map +1 -1
  232. package/dist/src/rack/queries.d.ts +2 -2
  233. package/dist/src/rack/queries.d.ts.map +1 -1
  234. package/dist/src/ranger/Breadcrumb.d.ts +2 -2
  235. package/dist/src/ranger/Select.d.ts +2 -2
  236. package/dist/src/ranger/Select.d.ts.map +1 -1
  237. package/dist/src/ranger/SelectStage.d.ts.map +1 -1
  238. package/dist/src/ranger/queries.d.ts +5 -5
  239. package/dist/src/ranger/queries.d.ts.map +1 -1
  240. package/dist/src/resize/{Core.d.ts → Base.d.ts} +3 -3
  241. package/dist/src/resize/{Core.d.ts.map → Base.d.ts.map} +1 -1
  242. package/dist/src/resize/Single.d.ts +2 -2
  243. package/dist/src/resize/Single.d.ts.map +1 -1
  244. package/dist/src/resize/external.d.ts +1 -1
  245. package/dist/src/schematic/Schematic.d.ts.map +1 -1
  246. package/dist/src/schematic/edge/paths.d.ts.map +1 -1
  247. package/dist/src/schematic/queries.d.ts +5 -5
  248. package/dist/src/schematic/queries.d.ts.map +1 -1
  249. package/dist/src/schematic/symbol/Primitives.d.ts +5 -5
  250. package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
  251. package/dist/src/schematic/symbol/SelectOrientation.d.ts +2 -2
  252. package/dist/src/schematic/symbol/SelectOrientation.d.ts.map +1 -1
  253. package/dist/src/schematic/symbol/Symbols.d.ts +13 -13
  254. package/dist/src/schematic/symbol/Symbols.d.ts.map +1 -1
  255. package/dist/src/schematic/symbol/external.d.ts +1 -0
  256. package/dist/src/schematic/symbol/external.d.ts.map +1 -1
  257. package/dist/src/schematic/symbol/queries.d.ts +8 -6
  258. package/dist/src/schematic/symbol/queries.d.ts.map +1 -1
  259. package/dist/src/schematic/symbol/registry.d.ts +1 -1
  260. package/dist/src/select/Button.d.ts +3 -3
  261. package/dist/src/select/Button.d.ts.map +1 -1
  262. package/dist/src/select/Dialog.d.ts +3 -3
  263. package/dist/src/select/Dialog.d.ts.map +1 -1
  264. package/dist/src/select/Frame.d.ts +1 -1
  265. package/dist/src/select/Frame.d.ts.map +1 -1
  266. package/dist/src/select/Multiple.d.ts +3 -3
  267. package/dist/src/select/Multiple.d.ts.map +1 -1
  268. package/dist/src/select/MultipleTrigger.d.ts.map +1 -1
  269. package/dist/src/select/Single.d.ts.map +1 -1
  270. package/dist/src/select/Static.d.ts.map +1 -1
  271. package/dist/src/select/flex/Alignment.d.ts.map +1 -1
  272. package/dist/src/select/text/Level.d.ts +1 -1
  273. package/dist/src/select/text/Weight.d.ts +1 -1
  274. package/dist/src/select/use.d.ts.map +1 -1
  275. package/dist/src/showcase/InputShowcase.d.ts.map +1 -1
  276. package/dist/src/state/state.d.ts.map +1 -1
  277. package/dist/src/status/Select.d.ts +2 -2
  278. package/dist/src/status/Select.d.ts.map +1 -1
  279. package/dist/src/status/SelectVariant.d.ts +2 -2
  280. package/dist/src/status/SelectVariant.d.ts.map +1 -1
  281. package/dist/src/status/aether/aggregator.d.ts +1 -1
  282. package/dist/src/status/{core → base}/Aggregator.d.ts.map +1 -1
  283. package/dist/src/status/base/Aggregator.spec.d.ts.map +1 -0
  284. package/dist/src/status/{core → base}/CreateIcon.d.ts.map +1 -1
  285. package/dist/src/status/{core → base}/Indicator.d.ts.map +1 -1
  286. package/dist/src/status/{core → base}/Notification.d.ts.map +1 -1
  287. package/dist/src/status/base/Notification.spec.d.ts.map +1 -0
  288. package/dist/src/status/{core → base}/Summary.d.ts.map +1 -1
  289. package/dist/src/status/{core → base}/colors.d.ts.map +1 -1
  290. package/dist/src/status/{core → base}/external.d.ts.map +1 -1
  291. package/dist/src/status/base/index.d.ts.map +1 -0
  292. package/dist/src/status/external.d.ts +1 -1
  293. package/dist/src/status/queries.d.ts +3 -3
  294. package/dist/src/status/queries.d.ts.map +1 -1
  295. package/dist/src/steps/Steps.d.ts.map +1 -1
  296. package/dist/src/table/Table.d.ts.map +1 -1
  297. package/dist/src/table/cells/Forms.d.ts.map +1 -1
  298. package/dist/src/table/queries.d.ts +3 -3
  299. package/dist/src/table/queries.d.ts.map +1 -1
  300. package/dist/src/tabs/Selector.d.ts.map +1 -1
  301. package/dist/src/tabs/Tabs.d.ts.map +1 -1
  302. package/dist/src/tag/Tag.d.ts.map +1 -1
  303. package/dist/src/task/queries.d.ts +7 -6
  304. package/dist/src/task/queries.d.ts.map +1 -1
  305. package/dist/src/telem/SelectDataType.d.ts.map +1 -1
  306. package/dist/src/telem/aether/context.d.ts +2 -2
  307. package/dist/src/telem/aether/context.d.ts.map +1 -1
  308. package/dist/src/telem/aether/factory.d.ts +2 -2
  309. package/dist/src/telem/aether/factory.d.ts.map +1 -1
  310. package/dist/src/telem/aether/provider.d.ts +4 -14
  311. package/dist/src/telem/aether/provider.d.ts.map +1 -1
  312. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  313. package/dist/src/telem/aether/test/external.d.ts +4 -0
  314. package/dist/src/telem/aether/test/external.d.ts.map +1 -0
  315. package/dist/src/telem/aether/test/factory.d.ts +11 -0
  316. package/dist/src/telem/aether/test/factory.d.ts.map +1 -0
  317. package/dist/src/telem/aether/test/factory.spec.d.ts +2 -0
  318. package/dist/src/telem/aether/test/factory.spec.d.ts.map +1 -0
  319. package/dist/src/telem/aether/test/index.d.ts +2 -0
  320. package/dist/src/telem/aether/test/index.d.ts.map +1 -0
  321. package/dist/src/telem/aether/test/sink.d.ts +18 -0
  322. package/dist/src/telem/aether/test/sink.d.ts.map +1 -0
  323. package/dist/src/telem/aether/test/sink.spec.d.ts +2 -0
  324. package/dist/src/telem/aether/test/sink.spec.d.ts.map +1 -0
  325. package/dist/src/telem/aether/test/source.d.ts +17 -0
  326. package/dist/src/telem/aether/test/source.d.ts.map +1 -0
  327. package/dist/src/telem/aether/test/source.spec.d.ts +2 -0
  328. package/dist/src/telem/aether/test/source.spec.d.ts.map +1 -0
  329. package/dist/src/telem/client/cache/cache.d.ts.map +1 -1
  330. package/dist/src/telem/control/Chip.d.ts.map +1 -1
  331. package/dist/src/telem/control/Controller.d.ts +2 -0
  332. package/dist/src/telem/control/Controller.d.ts.map +1 -1
  333. package/dist/src/telem/control/Indicator.d.ts.map +1 -1
  334. package/dist/src/telem/control/Legend.d.ts +2 -2
  335. package/dist/src/telem/control/aether/controller.d.ts +17 -6
  336. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  337. package/dist/src/telem/test/external.d.ts +2 -0
  338. package/dist/src/telem/test/external.d.ts.map +1 -0
  339. package/dist/src/telem/test/index.d.ts +2 -0
  340. package/dist/src/telem/test/index.d.ts.map +1 -0
  341. package/dist/src/telem/test/wrapper.d.ts +9 -0
  342. package/dist/src/telem/test/wrapper.d.ts.map +1 -0
  343. package/dist/src/telem/text/TimeRange.d.ts.map +1 -1
  344. package/dist/src/text/Text.d.ts +1 -1
  345. package/dist/src/text/Text.d.ts.map +1 -1
  346. package/dist/src/text/{core → base}/dimensions.d.ts +5 -5
  347. package/dist/src/text/{core → base}/dimensions.d.ts.map +1 -1
  348. package/dist/src/text/base/dimensions.spec.d.ts.map +1 -0
  349. package/dist/src/text/base/external.d.ts.map +1 -0
  350. package/dist/src/text/base/index.d.ts.map +1 -0
  351. package/dist/src/text/{core → base}/types.d.ts.map +1 -1
  352. package/dist/src/text/external.d.ts +2 -2
  353. package/dist/src/theming/aether/external.d.ts +2 -2
  354. package/dist/src/theming/aether/provider.d.ts +64 -1
  355. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  356. package/dist/src/theming/{core → base}/fontString.d.ts +1 -1
  357. package/dist/src/theming/{core → base}/fontString.d.ts.map +1 -1
  358. package/dist/src/theming/{core → base}/theme.d.ts +39 -0
  359. package/dist/src/theming/{core → base}/theme.d.ts.map +1 -1
  360. package/dist/src/theming/css.d.ts +1 -1
  361. package/dist/src/theming/css.d.ts.map +1 -1
  362. package/dist/src/theming/external.d.ts +1 -1
  363. package/dist/src/tooltip/Config.d.ts.map +1 -1
  364. package/dist/src/tree/Context.d.ts +1 -1
  365. package/dist/src/tree/Tree.d.ts +1 -1
  366. package/dist/src/tree/Tree.d.ts.map +1 -1
  367. package/dist/src/tree/{core.d.ts → base.d.ts} +1 -1
  368. package/dist/src/tree/{core.d.ts.map → base.d.ts.map} +1 -1
  369. package/dist/src/tree/base.spec.d.ts +2 -0
  370. package/dist/src/tree/base.spec.d.ts.map +1 -0
  371. package/dist/src/tree/external.d.ts +2 -1
  372. package/dist/src/tree/external.d.ts.map +1 -1
  373. package/dist/src/triggers/Text.d.ts +2 -2
  374. package/dist/src/user/queries.d.ts +4 -4
  375. package/dist/src/user/queries.d.ts.map +1 -1
  376. package/dist/src/view/index.d.ts +2 -0
  377. package/dist/src/view/index.d.ts.map +1 -0
  378. package/dist/src/view/queries.d.ts +35 -0
  379. package/dist/src/view/queries.d.ts.map +1 -0
  380. package/dist/src/view/queries.spec.d.ts +2 -0
  381. package/dist/src/view/queries.spec.d.ts.map +1 -0
  382. package/dist/src/viewport/Mask.d.ts.map +1 -1
  383. package/dist/src/viewport/SelectMode.d.ts.map +1 -1
  384. package/dist/src/vis/button/aether/button.d.ts +15 -6
  385. package/dist/src/vis/button/aether/button.d.ts.map +1 -1
  386. package/dist/src/vis/button/aether/button.spec.d.ts +2 -0
  387. package/dist/src/vis/button/aether/button.spec.d.ts.map +1 -0
  388. package/dist/src/vis/button/use.d.ts +1 -1
  389. package/dist/src/vis/button/use.d.ts.map +1 -1
  390. package/dist/src/vis/diagram/Diagram.d.ts +6 -6
  391. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  392. package/dist/src/vis/diagram/aether/types.d.ts +2 -2
  393. package/dist/src/vis/diagram/align.d.ts.map +1 -1
  394. package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
  395. package/dist/src/vis/draw2d/index.d.ts +1 -1
  396. package/dist/src/vis/draw2d/index.d.ts.map +1 -1
  397. package/dist/src/vis/gauge/aether/gauge.d.ts +1 -1
  398. package/dist/src/vis/gauge/use.d.ts +2 -2
  399. package/dist/src/vis/input/aether/input.d.ts +11 -6
  400. package/dist/src/vis/input/aether/input.d.ts.map +1 -1
  401. package/dist/src/vis/input/use.d.ts.map +1 -1
  402. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  403. package/dist/src/vis/legend/Grouped.d.ts.map +1 -1
  404. package/dist/src/vis/legend/Simple.d.ts.map +1 -1
  405. package/dist/src/vis/line/Line.d.ts.map +1 -1
  406. package/dist/src/vis/measure/aether/measure.d.ts +1 -1
  407. package/dist/src/vis/render/loop.d.ts +1 -1
  408. package/dist/src/vis/rule/Rule.d.ts.map +1 -1
  409. package/dist/src/vis/setpoint/aether/setpoint.d.ts +11 -6
  410. package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
  411. package/dist/src/vis/setpoint/use.d.ts.map +1 -1
  412. package/dist/src/vis/text/atlas.d.ts.map +1 -1
  413. package/dist/src/vis/toggle/aether/toggle.d.ts +12 -3
  414. package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
  415. package/dist/src/vis/toggle/aether/toggle.spec.d.ts +2 -0
  416. package/dist/src/vis/toggle/aether/toggle.spec.d.ts.map +1 -0
  417. package/dist/src/vis/toggle/use.d.ts +1 -1
  418. package/dist/src/vis/toggle/use.d.ts.map +1 -1
  419. package/dist/src/vis/value/use.d.ts +2 -2
  420. package/dist/src/workspace/queries.d.ts +7 -7
  421. package/dist/src/workspace/queries.d.ts.map +1 -1
  422. package/dist/tabs.cjs +1 -1
  423. package/dist/tabs.js +1 -1
  424. package/dist/text.cjs +1 -1
  425. package/dist/text.js +2 -2
  426. package/dist/theme.css +136 -124
  427. package/dist/theming.cjs +1 -1
  428. package/dist/theming.js +2 -2
  429. package/dist/tree.cjs +1 -1
  430. package/dist/tree.js +1 -1
  431. package/dist/triggers.cjs +1 -1
  432. package/dist/triggers.js +1 -1
  433. package/dist/types-B5-Tni3G.js +82 -0
  434. package/dist/types-C0tUDfsz.cjs +1 -0
  435. package/dist/units-Bd_mf9Ye.cjs +1 -0
  436. package/dist/{units-CgMHbHoA.js → units-CEfK1L7C.js} +1 -1
  437. package/dist/{value-CzFrd9p6.js → value-BmuhX6zs.js} +2278 -2285
  438. package/dist/value-CZfzRi_x.cjs +53 -0
  439. package/dist/video.cjs +1 -1
  440. package/dist/video.js +1 -1
  441. package/package.json +25 -23
  442. package/dist/Animated-D-pQ3CYh.cjs +0 -1
  443. package/dist/Button-D5aoG3sV.cjs +0 -1
  444. package/dist/Haul-9RVCn3cI.cjs +0 -1
  445. package/dist/Menu-BYca9tGe.cjs +0 -1
  446. package/dist/Menu-CQsrN_mP.js +0 -134
  447. package/dist/Provider-DBg-Li_7.cjs +0 -5
  448. package/dist/Tags-CQFa3kY-.cjs +0 -1
  449. package/dist/external-DDHknds-.cjs +0 -1
  450. package/dist/external-DcMOF1Je.cjs +0 -1
  451. package/dist/external-JpvbclD8.cjs +0 -79
  452. package/dist/external-RkrrZXG5.cjs +0 -1
  453. package/dist/hooks-CRSphXSb.cjs +0 -1
  454. package/dist/provider-DHDqgF1B.cjs +0 -76
  455. package/dist/src/arc/handle/Core.d.ts +0 -8
  456. package/dist/src/flux/core/index.d.ts +0 -2
  457. package/dist/src/flux/core/index.d.ts.map +0 -1
  458. package/dist/src/flux/core/store.spec.d.ts.map +0 -1
  459. package/dist/src/flux/core/streamer.spec.d.ts.map +0 -1
  460. package/dist/src/form/synced.d.ts +0 -26
  461. package/dist/src/form/synced.d.ts.map +0 -1
  462. package/dist/src/lineplot/aether/BoundQuerier.d.ts +0 -35
  463. package/dist/src/lineplot/aether/BoundQuerier.d.ts.map +0 -1
  464. package/dist/src/lineplot/useBoundQuerier.d.ts +0 -11
  465. package/dist/src/lineplot/useBoundQuerier.d.ts.map +0 -1
  466. package/dist/src/observe/index.d.ts +0 -2
  467. package/dist/src/observe/index.d.ts.map +0 -1
  468. package/dist/src/observe/use.d.ts +0 -8
  469. package/dist/src/observe/use.d.ts.map +0 -1
  470. package/dist/src/status/core/Aggregator.spec.d.ts.map +0 -1
  471. package/dist/src/status/core/Notification.spec.d.ts.map +0 -1
  472. package/dist/src/status/core/index.d.ts.map +0 -1
  473. package/dist/src/testutil/Aether.d.ts +0 -4
  474. package/dist/src/testutil/Aether.d.ts.map +0 -1
  475. package/dist/src/text/core/dimensions.spec.d.ts.map +0 -1
  476. package/dist/src/text/core/external.d.ts.map +0 -1
  477. package/dist/src/text/core/index.d.ts.map +0 -1
  478. package/dist/src/tree/core.spec.d.ts +0 -2
  479. package/dist/src/tree/core.spec.d.ts.map +0 -1
  480. package/dist/types-8-Mr79SF.cjs +0 -1
  481. package/dist/types-DGaZ_JZb.js +0 -82
  482. package/dist/units-InoNiVrK.cjs +0 -1
  483. package/dist/value-QHhF9WPA.cjs +0 -53
  484. /package/dist/src/flux/{core → base}/client.d.ts +0 -0
  485. /package/dist/src/flux/{core → base}/external.d.ts +0 -0
  486. /package/dist/src/flux/{core → base}/store.d.ts +0 -0
  487. /package/dist/src/flux/{core → base}/store.spec.d.ts +0 -0
  488. /package/dist/src/flux/{core → base}/streamer.spec.d.ts +0 -0
  489. /package/dist/src/flux/{core → base}/types.d.ts +0 -0
  490. /package/dist/src/status/{core → base}/Aggregator.d.ts +0 -0
  491. /package/dist/src/status/{core → base}/Aggregator.spec.d.ts +0 -0
  492. /package/dist/src/status/{core → base}/CreateIcon.d.ts +0 -0
  493. /package/dist/src/status/{core → base}/Indicator.d.ts +0 -0
  494. /package/dist/src/status/{core → base}/Notification.d.ts +0 -0
  495. /package/dist/src/status/{core → base}/Notification.spec.d.ts +0 -0
  496. /package/dist/src/status/{core → base}/Summary.d.ts +0 -0
  497. /package/dist/src/status/{core → base}/colors.d.ts +0 -0
  498. /package/dist/src/status/{core → base}/external.d.ts +0 -0
  499. /package/dist/src/status/{core → base}/index.d.ts +0 -0
  500. /package/dist/src/text/{core → base}/dimensions.spec.d.ts +0 -0
  501. /package/dist/src/text/{core → base}/external.d.ts +0 -0
  502. /package/dist/src/text/{core → base}/index.d.ts +0 -0
  503. /package/dist/src/text/{core → base}/types.d.ts +0 -0
@@ -1,76 +0,0 @@
1
- "use strict";const a=require("zod"),A=require("./css-BVgFAmaj.cjs"),We=require("./types-8-Mr79SF.cjs"),id=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)},fo=t=>{const e=(r,n=is)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!Zn(r))return r;n=ud(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&&(Zn(c)?oi(c)||(c=e(c,n)):n.recursiveInArray&&ii(c)&&(c=[...c].map(u=>{let h=u;return Zn(u)?oi(h)||(h=e(u,n)):ii(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},po=fo(id),od=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),cd=fo(od),ld=[Number,String,Uint8Array],is={recursive:!0,recursiveInArray:!0},ud=(t=is)=>(t.recursive==null?t=is:t.recursiveInArray??=!1,t),ii=t=>t!=null&&Array.isArray(t),Zn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),oi=t=>ld.some(e=>t instanceof e);let hd=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=po(r);return e!=null?e.parse(n):n}encodeString(t){const e=cd(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}};const os=new hd,ye=t=>t!=null&&typeof t=="object"&&"value"in t;class Vt{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const dd=t=>t!=null&&typeof t=="object"&&"toString"in t,fd=(t,e=!1)=>{const r=dd(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?pd(n):n},pd=t=>(e,r)=>t(r,e);let yo=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const mo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",yd=`0123456789${mo}`,md=11,gd=yo(mo,1),wd=yo(yd,md-1),bd=()=>`${gd()}${wd()}`,vd=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,zd=2**12-1,cs=2n**63n-1n,Od=2**63-1,yn=t=>(e,r)=>{if(typeof e=="bigint"){if(Td(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))},Nr=yn((t,e)=>t-e),yt=yn((t,e)=>t+e),Td=t=>typeof t=="bigint"?!0:Number.isInteger(t),xe=yn((t,e)=>t*e),mn=yn((t,e)=>t/e),go=a.z.tuple([a.z.number(),a.z.number()]),wo=a.z.object({width:a.z.number(),height:a.z.number()}),kd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),Sd=["start","center","end"],ur=a.z.object({x:a.z.number(),y:a.z.number()}),Nd=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),Ed=["x","y"],bo=a.z.enum(Ed),vo=["top","right","bottom","left"];a.z.enum(vo);const Ad=["left","right"],zo=a.z.enum(Ad),xd=["top","bottom"],Oo=a.z.enum(xd),To=["center"],ci=a.z.enum(To),Id=[...vo,...To],ko=a.z.enum(Id);a.z.enum(Sd);const Cd=["first","last"];a.z.enum(Cd);a.z.object({lower:a.z.number(),upper:a.z.number()});a.z.enum([...bo.options,...ko.options]);a.z.union([bo,ko,a.z.instanceof(String)]);const mt=(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?jd(n):n},jd=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,li=(t,e)=>{const r=mt(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e};a.z.object({x:zo.or(ci),y:Oo.or(ci)});const So=a.z.object({x:zo,y:Oo}),Md=Object.freeze({x:"left",y:"top"}),$d=(t,e)=>t.x===e.x&&t.y===e.y,ui=a.z.union([a.z.number(),ur,go,wo,kd,Nd]),Ud=(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}},hi=Object.freeze({x:0,y:0}),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:ur,two:ur,root:So});const Ks=(t,e,r=0,n=0,s)=>{const i={one:{...hi},two:{...hi},root:s??Md};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))},Rn=t=>{const e=Ks(t);return{lower:e.one.x,upper:e.two.x}},Dn=t=>{const e=Ks(t);return{lower:e.one.y,upper:e.two.y}},_d=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([wo,Pd,ur,go]);const Zd=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;a.z.object({offset:ui,scale:ui});a.z.object({offset:a.z.number(),scale:a.z.number()});const Rd=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],Dd=t=>(e,r,n,s)=>[e,s?n/t:n*t],Ld=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],Fd=()=>(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)]},qd=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=Zd(n,s,i),[e,n]};class Je{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new Je().translate(e)}static magnify(e){return new Je().magnify(e)}static scale(e,r){return new Je().scale(e,r)}translate(e){const r=this.new(),n=Rd(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Dd(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=mt(e,r),s=this.new(),i=Ld(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=mt(e,r),s=this.new(),i=qd(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=mt(e,r),s=this.new(),i=Bd(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=Fd();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 Je;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 Je}let XE=class Se{x;y;currRoot;constructor(e=new Je,r=new Je,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Se().translate(e,r)}static translateX(e){return new Se().translateX(e)}static translateY(e){return new Se().translateY(e)}static clamp(e){return new Se().clamp(e)}static magnify(e){return new Se().magnify(e)}static scale(e){return new Se().scale(e)}static reBound(e){return new Se().reBound(e)}translate(e,r){const n=Ud(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(_d(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!$d(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(Rn(e)),r.y=r.y.scale(Dn(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(Rn(e)),r.y=this.y.reBound(Dn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Rn(e)),r.y=this.y.clamp(Dn(e)),r}copy(){const e=new Se;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 Ks(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 Se};const Yd=ur.extend({root:So,units:a.object({x:a.enum(["px","decimal"]),y:a.enum(["px","decimal"])})});Yd.partial({root:!0,units:!0});const Vd=a.z.enum(["static","dynamic"]),di=365,Vr=30,Hd=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)])]),No=(t,e)=>{const r=new P(e);if(![g.DAY,g.HOUR,g.MINUTE,g.SECOND,g.MILLISECOND,g.MICROSECOND,g.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 g(n)};let P=class z extends Vt{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===Od?e=cs:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.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 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 g(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 sr(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(yt(this.valueOf(),new g(e).valueOf()))}sub(e){return new z(Nr(this.valueOf(),new g(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.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 No(this,e)}get isToday(){return this.truncate(g.DAY).equals(z.now().truncate(g.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(g.days(30))?"shortDate":e.greaterThanOrEqual(g.DAY)?"dateTime":e.greaterThanOrEqual(g.HOUR)?"time":e.greaterThanOrEqual(g.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(cs);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 g).transform(e=>new z(e)),Hd.transform(e=>new z(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}};class g extends Vt{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 g?e:e instanceof Ln?e.period:e instanceof P?new g(e):(ye(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.seconds(e):new g(e))}static fromMilliseconds(e){return e instanceof g?e:e instanceof Ln?e.period:e instanceof P?new g(e):(ye(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.milliseconds(e):new g(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new g(e).valueOf()}greaterThan(e){return this.valueOf()>new g(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new g(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new g(e).valueOf()}remainder(e){return No(this,e)}truncate(e){return new g(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(g.DAY),n=this.truncate(g.HOUR),s=this.truncate(g.MINUTE),i=this.truncate(g.SECOND),o=this.truncate(g.MILLISECOND),c=this.truncate(g.MICROSECOND),l=this.truncate(g.NANOSECOND),u=r,h=n.sub(r),f=s.sub(n),d=i.sub(s),T=o.sub(i),I=c.sub(o),$=l.sub(c);let b="";return u.isZero||(b+=`${u.days}d `),h.isZero||(b+=`${h.hours}h `),f.isZero||(b+=`${f.minutes}m `),d.isZero||(b+=`${d.seconds}s `),T.isZero||(b+=`${T.milliseconds}ms `),I.isZero||(b+=`${I.microseconds}µs `),$.isZero||(b+=`${$.nanoseconds}ns`),b.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new g(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(g.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,c=r.seconds,l=Math.floor(s/di),u=Math.floor(s/Vr),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),T=Math.floor(o),I=Math.floor(c),$=n?"-":"";if(l>=1){let b=`${l}y`;if(l<2){const k=Math.floor(s%di/Vr);k>0&&(b+=` ${k}mo`)}return $+b}if(h>=1&&s<Vr&&s%7===0){let b=`${h}w`;const k=Math.floor(s%7),x=Math.floor(i-h*7*24);return h<2&&(k>0?b+=` ${k}d`:x>0&&x<24&&(b+=` ${x}h`)),$+b}if(u>=1){let b=`${u}mo`;if(u<3){const k=Math.floor(s%Vr);k>0&&(b+=` ${k}d`)}return $+b}if(h>=1){let b=`${h}w`;const k=Math.floor(s%7),x=Math.floor(i-h*7*24);return h<2&&(k>0?b+=` ${k}d`:x>0&&x<24&&(b+=` ${x}h`)),$+b}if(f>=1){let b=`${f}d`;const k=Math.floor(i-f*24);return f<2&&k>0&&(b+=` ${k}h`),$+b}if(d>=1){let b=`${d}h`;if(d<3){const k=Math.floor(o-d*60);k>0&&(b+=` ${k}m`)}return $+b}if(T>=1){let b=`${T}m`;if(T<5){const k=Math.floor(c-T*60);k>0&&(b+=` ${k}s`)}return $+b}return`${$}${I}s`}mult(e){return new g(xe(this.valueOf(),e))}div(e){return new g(mn(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new g(e).valueOf()}add(e){return new g(this.valueOf()+new g(e).valueOf())}sub(e){return new g(this.valueOf()-new g(e).valueOf())}static nanoseconds(e=1){return new g(e)}static NANOSECOND=g.nanoseconds(1);static microseconds(e=1){return g.nanoseconds(xe(e,1e3))}static MICROSECOND=g.microseconds(1);static milliseconds(e=1){return g.microseconds(xe(e,1e3))}static MILLISECOND=g.milliseconds(1);static seconds(e=1){return g.milliseconds(xe(e,1e3))}static SECOND=g.seconds(1);static minutes(e=1){return g.seconds(xe(e,60))}static MINUTE=g.minutes(1);static hours(e){return g.minutes(xe(e,60))}static HOUR=g.hours(1);static days(e){return g.hours(xe(e,24))}static DAY=g.days(1);static MAX=new g(cs);static MIN=new g(0);static ZERO=new g(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new g(e.value)),a.z.string().transform(e=>new g(BigInt(e))),a.z.number().transform(e=>new g(e)),a.z.bigint().transform(e=>new g(e)),a.z.instanceof(g),a.z.instanceof(P).transform(e=>new g(e)),a.z.custom(e=>e instanceof Ln).transform(e=>new g(e))])}let Ln=class de extends Vt{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 g.seconds(1/this.valueOf())}sampleCount(e){return new g(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new te(r).valueOf()}span(e){return g.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new te(r).valueOf())}add(e){return new de(yt(this.valueOf(),new de(e).valueOf()))}sub(e){return new de(Nr(this.valueOf(),new de(e).valueOf()))}mult(e){return new de(xe(this.valueOf(),e))}div(e){return new de(mn(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)])},te=class se extends Vt{constructor(e){ye(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new ls(e*this.valueOf())}add(e){return new se(yt(this.valueOf(),new se(e).valueOf()))}sub(e){return new se(Nr(this.valueOf(),new se(e).valueOf()))}mult(e){return new se(xe(this.valueOf(),e))}div(e){return new se(mn(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)])},sr=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 g(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.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=g.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=g.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=P.max(n.start,e.start),i=P.min(n.end,e.end);return i.before(s)?!1:new g(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},[])}},F=class y extends Vt{constructor(e){if(ye(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)])},ls=class j extends Vt{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 j(yt(this.valueOf(),e.valueOf()))}sub(e){return ye(e)&&(e=e.value),new j(Nr(this.valueOf(),e.valueOf()))}mult(e){return new j(xe(this.valueOf(),e))}div(e){return new j(mn(this.valueOf(),e))}truncate(e){return new j(Math.trunc(this.valueOf()/new j(e).valueOf())*new j(e).valueOf())}remainder(e){return j.bytes(this.valueOf()%new j(e).valueOf())}get gigabytes(){return this.valueOf()/j.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/j.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/j.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/j.TERABYTE.valueOf()}toString(){const e=this.truncate(j.TERABYTE),r=this.truncate(j.GIGABYTE),n=this.truncate(j.MEGABYTE),s=this.truncate(j.KILOBYTE),i=this.truncate(j.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 j(e)}static BYTE=new j(1);static kilobytes(e=1){return j.bytes(new j(e).valueOf()*1e3)}static KILOBYTE=j.kilobytes(1);static megabytes(e=1){return j.kilobytes(new j(e).valueOf()*1e3)}static MEGABYTE=j.megabytes(1);static gigabytes(e=1){return j.megabytes(new j(e).valueOf()*1e3)}static GIGABYTE=j.gigabytes(1);static terabytes(e){return j.gigabytes(new j(e).valueOf()*1e3)}static TERABYTE=j.terabytes(1);static ZERO=new j(0);static z=a.z.union([a.z.number().transform(e=>new j(e)),a.z.instanceof(j)]);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 Eo=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof P||t instanceof g||t instanceof Date},Wd=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):Nr(r,n),Gd=/^(?:[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 Kd(t){return typeof t=="string"&&Gd.test(t)}const X=[];for(let t=0;t<256;++t)X.push((t+256).toString(16).slice(1));function Jd(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 Xd(t,e=0){const r=Jd(t,e);if(!Kd(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Ao=(t,e)=>Xd(t,e),qe=-1,Qd=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),ef=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),us=10,tf=(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`)},xo="sy_x_telem_series";let Io=class Ge{key;discriminator=xo;dataType;sampleOffset;gl;_data;timeRange=sr.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=qe;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:sr.z.optional(),dataType:F.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([Qd,ef,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:Vd.default("static").optional()});static z=Ge.crudeZ.transform(e=>new Ge(e));constructor(e){rf(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=bd(),data:u}=e;if(nf(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=Eo(u),f=Array.isArray(u);if(r!=null)this.dataType=new F(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=F.STRING;else if(typeof d=="number")this.dataType=F.FLOAT64;else if(typeof d=="bigint")this.dataType=F.INT64;else if(typeof d=="boolean")this.dataType=F.BOOLEAN;else if(d instanceof P||d instanceof Date||d instanceof P)this.dataType=F.TIMESTAMP;else if(typeof d=="object")this.dataType=F.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new F(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 T=d[0];(T instanceof P||T instanceof Date||T instanceof g)&&(d=d.map(I=>new P(I).valueOf())),this.dataType.equals(F.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
2
- `)}
3
- `).buffer):this.dataType.equals(F.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(I=>os.encodeString(I)).join(`
4
- `)}
5
- `).buffer):this.dataType.usesBigInt&&typeof T=="number"?this._data=new this.dataType.Array(d.map(I=>BigInt(Math.round(I)))).buffer:!this.dataType.usesBigInt&&typeof T=="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??sr.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 F(r).Array(e),i=new Ge({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===qe)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===qe)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===qe?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(F.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(os.decodeString(r)))}get byteCapacity(){return new ls(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===qe?this.byteCapacity:this.dataType.isVariable?new ls(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===qe?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===us&&(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]=Wd(this.dataType,e,this.data[s],r);return new Ge({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(F.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(),yt(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(F.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(),yt(this.cachedMin,this.sampleOffset))}get bounds(){return mt(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(F.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 yt(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=Ao(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]===us){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(F.STRING)?new TextDecoder().decode(i):po(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=fd(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(F.FLOAT32)&&!this.dataType.equals(F.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!==qe){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=qe}as(e){return tf(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:pi(this.alignmentBounds.lower),upper:pi(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return mt(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 sf(this);return this.dataType.equals(F.JSON)?new Js(e):e}return this.dataType.equals(F.UUID)?new af(this):new of(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new fi(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 fi(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 Ge({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 Ge({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new Ge({data:this.buffer,dataType:this.dataType,timeRange:sr.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 rf=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Io?!0:Eo(t),nf=vd(xo,Io);class fi{series;end;index;constructor(e,r,n){this.series=e;const s=mt(0,e.length+1);this.end=li(s,n),this.index=li(s,r)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class sf{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==us;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}}class Js{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:os.decodeString(e.value,Js.schema)}}}let af=class{series;index;data;density;constructor(t){if(!t.dataType.equals(F.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=F.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=Ao(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}};class of{series;index;constructor(e){this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}const pi=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}},cf=async t=>await new Promise(e=>setTimeout(e,g.fromMilliseconds(t).milliseconds));let lf=class{config;retries;interval;constructor(t){this.config={baseInterval:new g(t?.baseInterval??g.seconds(1)),maxRetries:t?.maxRetries??5,scale:t?.scale??1,sleepFn:t?.sleepFn??cf},this.retries=0,this.interval=new g(this.config.baseInterval)}async wait(){const{maxRetries:t,scale:e,sleepFn:r}=this.config;return this.retries>=t?!1:(await r(this.interval),this.interval=this.interval.mult(e),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 uf=a.z.object({baseInterval:g.z.optional(),maxRetries:a.z.number().optional(),scale:a.z.number().optional()}),hf=Object.freeze(Object.defineProperty({__proto__:null,Breaker:lf,breakerConfigZ:uf},Symbol.toStringTag,{value:"Module"})),df=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Co=a.z.string().regex(df),Ut=a.z.number().min(0).max(255),jo=a.z.number().min(0).max(1),Mo=a.z.tuple([Ut,Ut,Ut,jo]),ff=a.z.tuple([Ut,Ut,Ut]),pf=a.z.object({rgba255:Mo}),yf=a.z.number().min(0).max(360),mf=a.z.number().min(0).max(100),gf=a.z.number().min(0).max(100),wf=a.z.tuple([yf,mf,gf,jo]),Xs=a.z.union([Co,ff,Mo,wf,pf]),bf=Xs.transform(t=>Qs(t)),Qs=(t,e=1)=>{if(t=Xs.parse(t),typeof t=="string")return vf(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},vf=(t,e=1)=>(t=Co.parse(t),t=zf(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),zf=t=>t.startsWith("#")?t.slice(1):t;Qs("#000000");Qs("#ffffff");const Of=a.z.object({key:a.z.string(),color:Xs,position:a.z.number(),switched:a.z.boolean().optional()});a.z.array(Of);const Tf=a.z.object({key:a.z.string(),name:a.z.string(),color:bf});a.z.object({key:a.z.string(),name:a.z.string(),swatches:a.z.array(Tf)});a.z.int().min(0).max(255);a.z.object({name:a.z.string(),key:a.z.string()});const kf=t=>Object.getOwnPropertySymbols(globalThis).includes(t),Sf=(t,e)=>{const r=Symbol.for(t);if(!kf(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},$o="sy_x_error",Nf=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),Er=t=>class ar extends Error{static discriminator=$o;discriminator=ar.discriminator;static TYPE=t;type=ar.TYPE;static matches=Nf(t);matches=ar.matches;constructor(r,n){super(r,n),this.name=ar.TYPE}static sub(r){return Er(`${t}.${r}`)}},Uo=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==$o)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},jt="unknown",hs="nil";class Ef{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:hs,data:""};if(Uo(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:jt,data:e.message};if(typeof e=="string")return{type:jt,data:e};try{return{type:jt,data:JSON.stringify(e)}}catch{return{type:jt,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===hs)return null;if(e.type===jt)return new ds(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new ds(e.data)}}const ea=Sf("synnax-error-registry",()=>new Ef),Af=({encode:t,decode:e})=>ea().register({encode:t,decode:e}),xf=t=>ea().encode(t),If=t=>t==null?null:ea().decode(t);let ds=class extends Er("unknown"){};const Cf=a.z.object({type:a.z.string(),data:a.z.string()});class jf extends Er("canceled"){}let Mf=class extends Er("not_implemented"){};const tt=Object.freeze(Object.defineProperty({__proto__:null,Canceled:jf,NONE:hs,NotImplemented:Mf,UNKNOWN:jt,Unknown:ds,createTyped:Er,decode:If,encode:xf,isTyped:Uo,payloadZ:Cf,register:Af},Symbol.toStringTag,{value:"Module"})),$f=a.object({jsonrpc:a.literal("2.0"),method:a.string(),params:a.any().optional(),id:a.union([a.string(),a.number(),a.null()]).optional()}),_o=a.object({jsonrpc:a.literal("2.0"),id:a.union([a.string(),a.number(),a.null()])}),Uf=_o.extend({result:a.json()}),_f=_o.extend({error:a.object({code:a.number().int(),message:a.string().optional(),data:a.json().optional()})}),Pf=a.union([Uf,_f]);a.union([$f,Pf]);a.z.object({key:a.z.string(),value:a.z.string()});const Zf=a.uuid();a.object({key:Zf,name:a.string().min(1),color:a.string()});a.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/);const Rf=["standard","scientific","engineering"];a.z.enum(Rf);a.z.record(a.z.union([a.z.number(),a.z.string(),a.z.symbol()]),a.z.unknown());const Df=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Df();const Lf=["macOS","Windows","Linux"],Bf=["macos","windows","linux"],Ff={macos:"macOS",windows:"Windows",linux:"Linux"};a.z.enum(Lf).or(a.z.enum(Bf).transform(t=>Ff[t]));a.z.enum(["success","info","warning","error","loading","disabled"]);a.z.object({stack:a.z.string(),error:a.z.instanceof(Error)});const qf=(...t)=>t.map(Po).join(""),Po=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Yf=t=>t.endsWith("/")?t.slice(0,-1):t,Vf=(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 Hf=class nn{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){this.protocol=n,this.host=e,this.port=r,this.path=Po(s)}replace(e){return new nn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new nn({...this,pathPrefix:qf(this.path,e)})}toString(){return Yf(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new nn({host:"unknown",port:0})};a.z.int().min(0).max(zd);class Ar extends tt.createTyped("freighter"){}let ze=class extends Ar.sub("eof"){constructor(){super("EOF")}},Rt=class extends Ar.sub("stream_closed"){constructor(){super("StreamClosed")}},rt=class extends Ar.sub("unreachable"){url;constructor(t={}){const{message:e="Unreachable",url:r=Hf.UNKNOWN}=t;super(e),this.url=r}};const Wf=t=>{if(!t.type.startsWith(Ar.TYPE))return null;if(ze.matches(t))return{type:ze.TYPE,data:"EOF"};if(Rt.matches(t))return{type:Rt.TYPE,data:"StreamClosed"};if(rt.matches(t))return{type:rt.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},Gf=t=>{if(!t.type.startsWith(Ar.TYPE))return null;switch(t.type){case ze.TYPE:return new ze;case Rt.TYPE:return new Rt;case rt.TYPE:return new rt;default:throw new tt.Unknown(`Unknown error type: ${t.data}`)}};tt.register({encode:Wf,decode:Gf});let Zo=class{middleware=[];use(...t){this.middleware.push(...t)}async executeMiddleware(t,e){let r=0;const n=async s=>{if(r===this.middleware.length)return await e(s);const i=this.middleware[r];return r++,await i(s,n)};return await n(t)}};const Ro="Content-Type",Kf=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","EPIPE","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]),Jf=t=>{const e=t?.cause?.code??t?.code??t?.errno;if(typeof e=="string"&&Kf.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},Xf=400;let Qf=class extends Zo{endpoint;encoder;constructor(t,e,r=!1){return super(),this.endpoint=t.replace({protocol:r?"https":"http"}),this.encoder=e,new Proxy(this,{get:(n,s,i)=>s==="endpoint"?this.endpoint:Reflect.get(n,s,i)})}get headers(){return{[Ro]:this.encoder.contentType}}async send(t,e,r,n){e=r?.parse(e);let s=null;const i=this.endpoint.child(t),o={};o.method="POST",o.body=this.encoder.encode(e??{});const[,c]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const u={...l,params:{}};o.headers={...this.headers,...l.params};let h;try{h=await fetch(l.target,o)}catch(d){if(!(d instanceof Error))throw d;return[u,Jf(d)?new rt({url:i}):d]}const f=await h.arrayBuffer();if(h?.ok)return n!=null&&(s=this.encoder.decode(f,n)),[u,null];try{if(h.status!==Xf)return[u,new Error(h.statusText)];const d=this.encoder.decode(f,tt.payloadZ),T=tt.decode(d);return[u,T]}catch(d){return[u,new Error(`[freighter] - failed to decode error: ${h.statusText}: ${d.message}`)]}});if(c!=null)return[null,c];if(s==null)throw new Error("Response must be defined");return[s,null]}};const ep=(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 hf.Breaker(e);do{const[u,h]=await this.wrapped.send(s,i,o,c);if(h==null)return[u,null];if(!rt.matches(h))return[null,h];if(console.warn(`[freighter] ${l.retryMessage}`,h),!await l.wait())return[u,h]}while(!0)}}return new r(t)},w=async(t,e,r,n,s)=>{const[i,o]=await t.send(e,r,n,s);if(o!=null)throw o;return i},tp=a.z.object({type:a.z.enum(["data","close","open"]),payload:a.z.unknown(),error:a.z.optional(tt.payloadZ)});let rp=class{codec;reqSchema;resSchema;ws;serverClosed;sendClosed;receiveDataQueue=[];receiveCallbacksQueue=[];constructor(t,e,r,n){this.codec=e,this.reqSchema=r,this.resSchema=n,this.ws=t,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const t=await this.receiveMsg();if(t.type!=="open"){if(t.error==null)throw new Error("Message error must be defined");return tt.decode(t.error)}return null}send(t){if(this.serverClosed!=null)return new ze;if(this.sendClosed)throw new Rt;return this.ws.send(this.codec.encode({type:"data",payload:t})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const t=await this.receiveMsg();if(t.type==="close"){if(t.error==null)throw new Error("Message error must be defined");if(this.serverClosed=tt.decode(t.error),this.serverClosed==null)throw new Error("Message error must be defined");return[null,this.serverClosed]}return[this.resSchema.parse(t.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const t={type:"close"};try{this.ws.send(this.codec.encode(t))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,e)=>this.receiveCallbacksQueue.push({resolve:t,reject:e}))}addMessage(t){const e=this.receiveCallbacksQueue.shift();e!=null?e.resolve(t):this.receiveDataQueue.push(t)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(t){this.addMessage(this.codec.decode(t.data,tp))}onClose(t){this.addMessage({type:"close",error:{type:t.code===sp?ze.TYPE:Rt.TYPE,data:""}})}};const np="freighterctx",sp=1e3;let ap=class fs extends Zo{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 fs(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=fs.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=Vf({[Ro]:this.encoder.contentType,...r.params},np);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(s=>{e.onopen=()=>{const i=new rp(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 Do=t=>a.union([a.union([a.null(),a.undefined()]).transform(()=>[]),t.array()]),ip=t=>Array.isArray(t)?t:t==null?[]:[t],Lo=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>Lo(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},op=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r)):t.filter(r=>r!=e)}),Bo=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>Bo(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},cp=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r.key)):t.filter(r=>r.key!==e)}),v=Object.freeze(Object.defineProperty({__proto__:null,nullableZ:Do,remove:op,removeKeyed:cp,toArray:ip,upsert:Lo,upsertKeyed:Bo},Symbol.toStringTag,{value:"Module"})),lp=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)},gn=t=>{const e=(r,n=ps)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!Bn(r))return r;n=dp(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&&(Bn(c)?mi(c)||(c=e(c,n)):n.recursiveInArray&&yi(c)&&(c=[...c].map(u=>{let h=u;return Bn(u)?mi(h)||(h=e(u,n)):yi(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},ta=gn(lp),up=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Fo=gn(up),qo=t=>t.length===0?t:t[0].toUpperCase()+t.slice(1),hp=[Number,String,Uint8Array],ps={recursive:!0,recursiveInArray:!0},dp=(t=ps)=>(t.recursive==null?t=ps:t.recursiveInArray??=!1,t),yi=t=>t!=null&&Array.isArray(t),Bn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),mi=t=>hp.some(e=>t instanceof e),fp=t=>t.replace(/[\s_]+/g,"-").replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}-${n.toLowerCase()}`).toLowerCase(),pp=gn(fp),yp=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},mp=gn(yp),gp=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:Fo,capitalize:qo,snakeToCamel:ta,toKebab:pp,toProperNoun:mp},Symbol.toStringTag,{value:"Module"})),wp=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);class Yo{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e))}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=JSON.parse(e),s=ta(n);return r!=null?r.parse(s):s}encodeString(e){const r=Fo(e);return JSON.stringify(r,(n,s)=>ArrayBuffer.isView(s)?Array.from(s):typeof s=="bigint"?s.toString():s)}}class Vo{contentType="text/csv";encode(e){const r=this.encodeString(e);return new TextEncoder().encode(r)}decode(e,r){const n=new TextDecoder().decode(e);return this.decodeString(n,r)}encodeString(e){if(!Array.isArray(e)||e.length===0||!wp(e[0]))throw new Error("Payload must be an array of objects");const r=Object.keys(e[0]),n=[r.join(",")];return e.forEach(s=>{const i=r.map(o=>JSON.stringify(s[o]??""));n.push(i.join(","))}),n.join(`
7
- `)}decodeString(e,r){const[n,...s]=e.trim().split(`
8
- `).map(c=>c.trim());if(n.length===0)return r!=null?r.parse({}):{};const i=n.split(",").map(c=>c.trim()),o={};return i.forEach(c=>{o[c]=[]}),s.forEach(c=>{const l=c.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(l[h]);f!=null&&o[u].push(f)})}),r!=null?r.parse(o):o}parseValue(e){if(e==null||e.length===0)return null;const r=Number(e);return isNaN(r)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:r}}class Ho{contentType="text/plain";encode(e){if(typeof e!="string")throw new Error("TextCodec.encode payload must be a string");return new TextEncoder().encode(e)}decode(e,r){const n=new TextDecoder().decode(e);return r!=null?r.parse(n):n}}const hr=new Yo,bp=new Vo,vp=new Ho,zp=[hr],Ot=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:Vo,CSV_CODEC:bp,ENCODERS:zp,JSONCodec:Yo,JSON_CODEC:hr,TEXT_CODEC:vp,TextCodec:Ho},Symbol.toStringTag,{value:"Module"})),le=t=>t!=null&&typeof t=="object"&&"value"in t;class Tt{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const ra=t=>t!=null&&typeof t=="object"&&"toString"in t,Wo=t=>{if(ra(t))return t?.toString().length===0;switch(typeof t){case"string":return t.length===0;case"number":return t===0;case"bigint":return t===0n;case"boolean":return!t;case"undefined":return!0;case"object":return t==null;default:return!1}},Op=t=>!Wo(t),Tp=Object.freeze(Object.defineProperty({__proto__:null,ValueExtension:Tt,isCrudeValueExtension:le,isNonZero:Op,isStringer:ra,isZero:Wo},Symbol.toStringTag,{value:"Module"})),ys=t=>[...new Set(t)],kp=(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())},gi=Object.freeze(Object.defineProperty({__proto__:null,by:kp,unique:ys},Symbol.toStringTag,{value:"Module"})),xr=(t,e=!1)=>{const r=ra(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?Ko(n):n},Sp=(t,e,r)=>{const n=xr(e[t],r);return(s,i)=>n(s[t],i[t])},Np=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,Go=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=xr(t[0]),n=[...t].sort(r),s=[...e].sort(r);return n.every((i,o)=>i===s[o])?0:-1},Ep=(t,e)=>{const r=ys(t),n=ys(e);return Go(r,n)},Ap=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,Ko=t=>(e,r)=>t(r,e),kt=0,_e=-1,Pe=1,Jo=t=>t<kt,Xo=t=>t>kt,xp=t=>t>=kt,Qo=t=>t===kt,Ip=(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},ec=(t,e,r)=>{let n=0,s=t.length;const i=r??xr(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},Cp=(t,e,r)=>{const n=ec(t,e,r);t.splice(n,0,e)},wi=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:kt,GREATER_THAN:Pe,LESS_THAN:_e,insert:Cp,isEqualTo:Qo,isGreaterThan:Xo,isGreaterThanEqual:xp,isLessThan:Jo,newF:xr,newFieldF:Sp,order:Ap,primitiveArrays:Np,reverseF:Ko,search:ec,stringsWithNumbers:Ip,uniqueUnorderedPrimitiveArrays:Ep,unorderedPrimitiveArrays:Go},Symbol.toStringTag,{value:"Module"}));let tc=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const rc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",jp=`0123456789${rc}`,nc=11,Mp=tc(rc,1),$p=tc(jp,nc-1),na=()=>`${Mp()}${$p()}`,Up=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:nc,create:na},Symbol.toStringTag,{value:"Module"})),_p=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Pp=2**8-1,sc=2**12-1,Zp=2**16-1,Rp=2**32-1,Dp=2n**64n-1n,Lp=2**64-1,Bp=-128,Fp=2**7-1,qp=-32768,Yp=2**15-1,Vp=-2147483648,Hp=2**31-1,Wp=-(2n**63n),an=2n**63n-1n,Gp=-9223372036854776e3,ac=2**63-1,Ht=t=>(e,r)=>{if(typeof e=="bigint"){if(on(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))},Ze=Ht((t,e)=>t-e),Re=Ht((t,e)=>t+e),Kp=(t,e,r=1e-4)=>Math.abs(t-e)<r,ms=(t,e)=>{const r=typeof t=="bigint",n=typeof e=="bigint";return r&&n?t===e:r&&on(e)?t===BigInt(e):n&&on(t)?e===BigInt(t):t===e},Jp=t=>{const e=10**Math.floor(Math.log10(t));return Math.round(t/e)*e},ic=Ht((t,e)=>t<=e?t:e),on=t=>typeof t=="bigint"?!0:Number.isInteger(t),Xp=Ht((t,e)=>t>=e?t:e),oc=t=>typeof t=="bigint"?t<0n?-t:t:t<0?-t:t,be=Ht((t,e)=>t*e),Ir=Ht((t,e)=>t/e),cc=a.z.tuple([a.z.number(),a.z.number()]),lc=a.z.object({width:a.z.number(),height:a.z.number()}),Qp=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),ey=["start","center","end"],Dt=a.z.object({x:a.z.number(),y:a.z.number()}),uc=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),sa=["x","y"],hc=a.z.enum(sa),aa=["top","right","bottom","left"],ty=a.z.enum(aa),dc=["left","right"],ia=a.z.enum(dc),oa=["top","bottom"],ca=a.z.enum(oa),la=["center"],gs=a.z.enum(la),ry=[...aa,...la],ua=a.z.enum(ry);a.z.enum(ey);const ny=["first","last"];a.z.enum(ny);a.z.object({lower:a.z.number(),upper:a.z.number()});a.z.enum([...hc.options,...ua.options]);const sy=a.z.union([hc,ua,a.z.instanceof(String)]),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?ay(n):n},ay=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,bi=(t,e)=>{const r=K(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e},Wr=(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},fc=t=>{const e=K(t);return e.upper-e.lower},iy=t=>({lower:Math.min(...t.map(e=>K(e).lower)),upper:Math.max(...t.map(e=>K(e).upper))}),oy=(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(;ms(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=Ze(l.upper,o):u=Ze(o,l.lower),u>0){const h=ic(oc(i),u);if(o=Re(o,s>0?h:-h),i=Ze(i,s>0?h:-h),ms(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},cy=(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},ws=2,bs=3,pc=2,ly=(t,e)=>{if(Number.isNaN(t)||!Number.isFinite(t))return t;const r=fc(e);if(r==0)return t;let n;r>=1e3?n=ws:r>=1?n=bs:n=Math.ceil(-Math.log10(r))+pc;const s=10**n;return Math.round(t*s)/s},uy=5,hy=1e-10,dy=(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=fc(e);const c=s/r;n=s>0&&c>hy}if(n){let c;s>=1e3?c=ws:s>=1?c=bs:c=Math.ceil(-Math.log10(s))+pc;const l=10**c;return Math.round(t*l)/l}if(r>=1e3){const c=10**ws;return Math.round(t*c)/c}if(r>=1){const c=10**bs;return Math.round(t*c)/c}const i=Math.floor(Math.log10(r)),o=10**(uy-i-1);return Math.round(t*o)/o},vs=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:Yp,MAX_INT32:Hp,MAX_INT64:an,MAX_INT64_NUMBER:ac,MAX_INT8:Fp,MAX_UINT12:sc,MAX_UINT16:Zp,MAX_UINT32:Rp,MAX_UINT64:Dp,MAX_UINT64_NUMBER:Lp,MAX_UINT8:Pp,MIN_INT16:qp,MIN_INT32:Vp,MIN_INT64:Wp,MIN_INT64_NUMBER:Gp,MIN_INT8:Bp,abs:oc,add:Re,closeTo:Kp,div:Ir,equal:ms,isInteger:on,max:Xp,min:ic,mult:be,roundBySpan:ly,roundToNearestMagnitude:Jp,smartRound:dy,sub:Ze},Symbol.toStringTag,{value:"Module"})),fy=t=>sa.includes(t)?t:oa.includes(t)?"y":"x",py=ia,yy=ca,my=gs,gy={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},wy={top:{clockwise:"left",counterclockwise:"right"},right:{clockwise:"top",counterclockwise:"bottom"},bottom:{clockwise:"right",counterclockwise:"left"},left:{clockwise:"bottom",counterclockwise:"top"}},by=sy,wt=t=>t instanceof String||!sa.includes(t)?t:t==="x"?"left":"top",vy=t=>gy[wt(t)],zy=(t,e)=>wy[t][e],dr=t=>{const e=wt(t);return e==="top"||e==="bottom"?"y":"x"},Oy=a.z.object({x:ia.or(gs),y:ca.or(gs)}),ha=a.z.object({x:ia,y:ca}),da=Object.freeze({x:"left",y:"top"}),yc=Object.freeze({x:"right",y:"top"}),mc=Object.freeze({x:"left",y:"bottom"}),gc=Object.freeze({x:"right",y:"bottom"}),fa=Object.freeze({x:"center",y:"center"}),wc=Object.freeze({x:"center",y:"top"}),bc=Object.freeze({x:"center",y:"bottom"}),vc=Object.freeze({x:"right",y:"center"}),zc=Object.freeze({x:"left",y:"center"}),Ty=Object.freeze([zc,vc,wc,bc,da,yc,mc,gc,fa]),Oc=(t,e)=>t.x===e.x&&t.y===e.y,ky=(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},Sy=t=>[t.x,t.y],sn=t=>dr(wt(t))==="x",Ny=t=>dr(wt(t))==="y",Ey=t=>`${t.x}${qo(t.y)}`,Ay=(t,e)=>{let r,n;if(typeof t=="object"&&"x"in t?(r=t.x,n=t.y):(r=wt(t),n=wt(e??t)),dr(r)===dr(n)&&r!=="center"&&n!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${r.toString()} - ${n.toString()}`);const s={...fa};return r==="center"?sn(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:n==="center"?sn(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:sn(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r],s},xy=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:bc,BOTTOM_LEFT:mc,BOTTOM_RIGHT:gc,CENTER:fa,CENTER_LEFT:zc,CENTER_LOCATIONS:la,CENTER_RIGHT:vc,OUTER_LOCATIONS:aa,TOP_CENTER:wc,TOP_LEFT:da,TOP_RIGHT:yc,XY_LOCATIONS:Ty,X_LOCATIONS:dc,Y_LOCATIONS:oa,center:my,construct:wt,constructXY:Ay,corner:ha,crude:by,direction:dr,isX:sn,isY:Ny,location:ua,outer:ty,rotate:zy,swap:vy,x:py,xy:Oy,xyCouple:Sy,xyEquals:Oc,xyMatches:ky,xyToString:Ey,y:yy},Symbol.toStringTag,{value:"Module"})),zs=a.z.union([a.z.number(),Dt,cc,lc,Qp,uc]),_=(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}},bt=Object.freeze({x:0,y:0}),Iy=Object.freeze({x:1,y:1}),Cy=Object.freeze({x:1/0,y:1/0}),jy=Object.freeze({x:NaN,y:NaN}),Tc=(t,e,r=0)=>{const n=_(t),s=_(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},My=t=>Tc(t,bt),pa=(t,e,r)=>{const n=_(t),s=_(e,r);return{x:n.x*s.x,y:n.y*s.y}},kc=(t,e)=>{const r=_(t);return{x:r.x+e,y:r.y}},Sc=(t,e)=>{const r=_(t);return{x:r.x,y:r.y+e}},Nc=(t,e,r,...n)=>{if(typeof e=="string"){if(typeof r!="number")throw new Error("The value must be a number.");return e==="x"?kc(t,r):Sc(t,r)}if(typeof e=="object"&&"x"in e&&typeof e.x=="string"){const s=_(r),i=_(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??bt,...n].reduce((s,i)=>{const o=_(i);return{x:s.x+o.x,y:s.y+o.y}},bt)},$y=(t,e,r)=>{const n=_(t);return fy(e)==="x"?{x:r,y:n.y}:{x:n.x,y:r}},Uy=(t,e)=>{const r=_(t),n=_(e);return Math.sqrt((r.x-n.x)**2+(r.y-n.y)**2)},_y=(t,e)=>{const r=_(t),n=_(e);return{x:n.x-r.x,y:n.y-r.y}},Py=t=>{const e=_(t);return Number.isNaN(e.x)||Number.isNaN(e.y)},Zy=t=>{const e=_(t);return Number.isFinite(e.x)&&Number.isFinite(e.y)},Ry=t=>{const e=_(t);return[e.x,e.y]},Dy=t=>{const e=_(t);return{left:e.x,top:e.y}},Ly=(t,e=0)=>{const r=_(t);return{x:Number(r.x.toFixed(e)),y:Number(r.y.toFixed(e))}},ir=(t,e)=>{const r=_(t),n=_(e);return{x:r.x-n.x,y:r.y-n.y}},or=t=>{const e=_(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:-e.y/r,y:e.x/r}},Ec=t=>{const e=_(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:e.x/r,y:e.y/r}},Ac=(...t)=>{const e=t.reduce((r,n)=>Nc(r,n),bt);return pa(e,1/t.length)},By=(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=ir(u,s);o=or(h),c=o,l=e}else if(n===t.length-1){const u=t[n-1],h=ir(s,u);i=or(h),c=i,l=e}else{const u=t[n-1],h=t[n+1],f=ir(s,u),d=ir(h,s);i=or(f),o=or(d);const T=Math.acos((f.x*d.x+f.y*d.y)/(Math.hypot(f.x,f.y)*Math.hypot(d.x,d.y))),I=Math.sin(T/2);I===0?l=e:l=e/I,c=Ec(Ac(i,o))}r.push(pa(c,l))}return r},Fy=t=>{const e=_(t);return{x:e.y,y:e.x}},qy=t=>{const e=_(t);return{x:Math.round(e.x),y:Math.round(e.y)}},Yy=t=>{const e=_(t);return{x:1/e.x,y:1/e.y}},Vy=(t,e,r)=>{const n=_(t),s=_(e),i=r==="clockwise"?Math.PI/2:-Math.PI/2,o=n.x-s.x,c=n.y-s.y,l=o*Math.cos(i)-c*Math.sin(i),u=o*Math.sin(i)+c*Math.cos(i);return{x:l+s.x,y:u+s.y}},ya=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Cy,NAN:jy,ONE:Iy,ZERO:bt,average:Ac,calculateMiters:By,clientXY:uc,construct:_,couple:Ry,crudeZ:zs,css:Dy,distance:Uy,equals:Tc,isFinite:Zy,isNan:Py,isZero:My,normal:or,normalize:Ec,reciprocal:Yy,rotate:Vy,round:qy,scale:pa,set:$y,sub:ir,swap:Fy,translate:Nc,translateX:kc,translateY:Sc,translation:_y,truncate:Ly,xy:Dt},Symbol.toStringTag,{value:"Module"})),Gr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:Gr,left:Gr,width:Gr,height:Gr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:Dt,two:Dt,root:ha});const ma=(t,e,r=0,n=0,s)=>{const i={one:{...bt},two:{...bt},root:s??da};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))},Fn=t=>{const e=ma(t);return{lower:e.one.x,upper:e.two.x}},qn=t=>{const e=ma(t);return{lower:e.one.y,upper:e.two.y}},Hy=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Wy=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([lc,Wy,Dt,cc]);const Gy=(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 Ky=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],Jy=t=>(e,r,n,s)=>[e,s?n/t:n*t],Xy=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]},Qy=t=>(e,r,n)=>[t,n],em=()=>(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)]},tm=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=Gy(n,s,i),[e,n]};class Xe{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new Xe().translate(e)}static magnify(e){return new Xe().magnify(e)}static scale(e,r){return new Xe().scale(e,r)}translate(e){const r=this.new(),n=Ky(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Jy(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=K(e,r),s=this.new(),i=Xy(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=K(e,r),s=this.new(),i=tm(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=K(e,r),s=this.new(),i=Qy(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=em();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 Xe;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 Xe}let eA=class Ee{x;y;currRoot;constructor(e=new Xe,r=new Xe,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=_(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(Hy(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Oc(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(Fn(e)),r.y=r.y.scale(qn(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(Fn(e)),r.y=this.y.reBound(qn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Fn(e)),r.y=this.y.clamp(qn(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 ma(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};const rm=Dt.extend({root:ha,units:a.object({x:a.enum(["px","decimal"]),y:a.enum(["px","decimal"])})});rm.partial({root:!0,units:!0});const nm=a.z.enum(["static","dynamic"]),vi=365,Kr=30,sm=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)])]),xc=(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 O extends Tt{constructor(e,r="UTC"){if(e==null)super(O.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*O.MILLISECOND.valueOf());else if(typeof e=="string")super(O.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(O.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=O.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===ac?e=an:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=O.MAX:e=O.MIN)),le(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 O(BigInt(s.getTime())*O.MILLISECOND.valueOf()).truncate(O.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=O.hours(parseInt(n??"00")).add(O.minutes(parseInt(s??"00"))).add(O.seconds(parseInt(o??"00"))).add(O.milliseconds(parseInt(c??"00")));return r==="local"&&(l=l.add(O.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return O.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())*O.MILLISECOND.valueOf(),l=BigInt(i)*O.MILLISECOND.valueOf();return c+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new O(BigInt(n.getTime())*O.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(O.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())*O.MINUTE.valueOf())}static since(e){return new O().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new O(e).valueOf()}span(e){return this.range(e).span}range(e){return new D(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new O(e).valueOf()}afterEq(e){return this.valueOf()>=new O(e).valueOf()}before(e){return this.valueOf()<new O(e).valueOf()}beforeEq(e){return this.valueOf()<=new O(e).valueOf()}add(e){return new O(Re(this.valueOf(),new N(e).valueOf()))}sub(e){return new O(Ze(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(O.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(O.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 O(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new O(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new O(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new O(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new O(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new O(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new O(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new O(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 xc(this,e)}get isToday(){return this.truncate(N.DAY).equals(O.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 O(new Date)}static max(...e){let r=O.MIN;for(const n of e){const s=new O(n);s.after(r)&&(r=s)}return r}static min(...e){let r=O.MAX;for(const n of e){const s=new O(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new O(e,r)}static NANOSECOND=O.nanoseconds(1);static microseconds(e,r="UTC"){return O.nanoseconds(e*1e3,r)}static MICROSECOND=O.microseconds(1);static milliseconds(e,r="UTC"){return O.microseconds(e*1e3,r)}static MILLISECOND=O.milliseconds(1);static seconds(e,r="UTC"){return O.milliseconds(e*1e3,r)}static SECOND=O.seconds(1);static minutes(e,r="UTC"){return O.seconds(e*60,r)}static MINUTE=O.minutes(1);static hours(e,r="UTC"){return O.minutes(e*60,r)}static HOUR=O.hours(1);static days(e,r="UTC"){return O.hours(e*24,r)}static DAY=O.days(1);static MAX=new O(an);static MIN=new O(0);static ZERO=new O(0);static z=a.z.union([a.z.instanceof(O),a.z.object({value:a.z.bigint()}).transform(e=>new O(e.value)),a.z.string().transform(e=>new O(BigInt(e))),a.z.number().transform(e=>new O(e)),a.z.bigint().transform(e=>new O(e)),a.z.date().transform(e=>new O(e)),a.z.custom(e=>e instanceof N).transform(e=>new O(e)),sm.transform(e=>new O(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}},N=class S extends Tt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),le(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof S?e:e instanceof gt?e.period:e instanceof C?new S(e):(le(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 gt?e.period:e instanceof C?new S(e):(le(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 xc(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),T=o.sub(i),I=c.sub(o),$=l.sub(c);let b="";return u.isZero||(b+=`${u.days}d `),h.isZero||(b+=`${h.hours}h `),f.isZero||(b+=`${f.minutes}m `),d.isZero||(b+=`${d.seconds}s `),T.isZero||(b+=`${T.milliseconds}ms `),I.isZero||(b+=`${I.microseconds}µs `),$.isZero||(b+=`${$.nanoseconds}ns`),b.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/vi),u=Math.floor(s/Kr),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),T=Math.floor(o),I=Math.floor(c),$=n?"-":"";if(l>=1){let b=`${l}y`;if(l<2){const k=Math.floor(s%vi/Kr);k>0&&(b+=` ${k}mo`)}return $+b}if(h>=1&&s<Kr&&s%7===0){let b=`${h}w`;const k=Math.floor(s%7),x=Math.floor(i-h*7*24);return h<2&&(k>0?b+=` ${k}d`:x>0&&x<24&&(b+=` ${x}h`)),$+b}if(u>=1){let b=`${u}mo`;if(u<3){const k=Math.floor(s%Kr);k>0&&(b+=` ${k}d`)}return $+b}if(h>=1){let b=`${h}w`;const k=Math.floor(s%7),x=Math.floor(i-h*7*24);return h<2&&(k>0?b+=` ${k}d`:x>0&&x<24&&(b+=` ${x}h`)),$+b}if(f>=1){let b=`${f}d`;const k=Math.floor(i-f*24);return f<2&&k>0&&(b+=` ${k}h`),$+b}if(d>=1){let b=`${d}h`;if(d<3){const k=Math.floor(o-d*60);k>0&&(b+=` ${k}m`)}return $+b}if(T>=1){let b=`${T}m`;if(T<5){const k=Math.floor(c-T*60);k>0&&(b+=` ${k}s`)}return $+b}return`${$}${I}s`}mult(e){return new S(be(this.valueOf(),e))}div(e){return new S(Ir(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(be(e,1e3))}static MICROSECOND=S.microseconds(1);static milliseconds(e=1){return S.microseconds(be(e,1e3))}static MILLISECOND=S.milliseconds(1);static seconds(e=1){return S.milliseconds(be(e,1e3))}static SECOND=S.seconds(1);static minutes(e=1){return S.seconds(be(e,60))}static MINUTE=S.minutes(1);static hours(e){return S.minutes(be(e,60))}static HOUR=S.hours(1);static days(e){return S.hours(be(e,24))}static DAY=S.days(1);static MAX=new S(an);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(C).transform(e=>new S(e)),a.z.custom(e=>e instanceof gt).transform(e=>new S(e))])},gt=class fe extends Tt{constructor(e){le(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new fe(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 fe(Re(this.valueOf(),new fe(e).valueOf()))}sub(e){return new fe(Ze(this.valueOf(),new fe(e).valueOf()))}mult(e){return new fe(be(this.valueOf(),e))}div(e){return new fe(Ir(this.valueOf(),e))}static hz(e){return new fe(e)}static khz(e){return fe.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new fe(e)),a.z.instanceof(fe)])},re=class ae extends Tt{constructor(e){le(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new Lt(e*this.valueOf())}add(e){return new ae(Re(this.valueOf(),new ae(e).valueOf()))}sub(e){return new ae(Ze(this.valueOf(),new ae(e).valueOf()))}mult(e){return new ae(be(this.valueOf(),e))}div(e){return new ae(Ir(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)])},D=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},[])}},U=class m extends Tt{constructor(e){if(le(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)])},Lt=class M extends Tt{constructor(e){le(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return le(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return le(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return le(e)&&(e=e.value),new M(Re(this.valueOf(),e.valueOf()))}sub(e){return le(e)&&(e=e.value),new M(Ze(this.valueOf(),e.valueOf()))}mult(e){return new M(be(this.valueOf(),e))}div(e){return new M(Ir(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 Ic=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof C||t instanceof N||t instanceof Date},am=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):Ze(r,n),im=/^(?:[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 om(t){return typeof t=="string"&&im.test(t)}const Q=[];for(let t=0;t<256;++t)Q.push((t+256).toString(16).slice(1));function cm(t,e=0){return(Q[t[e+0]]+Q[t[e+1]]+Q[t[e+2]]+Q[t[e+3]]+"-"+Q[t[e+4]]+Q[t[e+5]]+"-"+Q[t[e+6]]+Q[t[e+7]]+"-"+Q[t[e+8]]+Q[t[e+9]]+"-"+Q[t[e+10]]+Q[t[e+11]]+Q[t[e+12]]+Q[t[e+13]]+Q[t[e+14]]+Q[t[e+15]]).toLowerCase()}function lm(t,e=0){const r=cm(t,e);if(!om(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Cc=(t,e)=>lm(t,e),Ye=-1,Os={[Symbol.iterator]:()=>Os,next:()=>({done:!0,value:void 0})},um=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),hm=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),Ts=10,jc=(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`)},Mc="sy_x_telem_series";let Qe=class Ke{key;discriminator=Mc;dataType;sampleOffset;gl;_data;timeRange=D.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ye;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:D.z.optional(),dataType:U.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([um,hm,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:nm.default("static").optional()});static z=Ke.crudeZ.transform(e=>new Ke(e));constructor(e){dm(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=na(),data:u}=e;if($c(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=Ic(u),f=Array.isArray(u);if(r!=null)this.dataType=new U(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=U.STRING;else if(typeof d=="number")this.dataType=U.FLOAT64;else if(typeof d=="bigint")this.dataType=U.INT64;else if(typeof d=="boolean")this.dataType=U.BOOLEAN;else if(d instanceof C||d instanceof Date||d instanceof C)this.dataType=U.TIMESTAMP;else if(typeof d=="object")this.dataType=U.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new U(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const T=d[0];(T instanceof C||T instanceof Date||T instanceof N)&&(d=d.map(I=>new C(I).valueOf())),this.dataType.equals(U.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
9
- `)}
10
- `).buffer):this.dataType.equals(U.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(I=>hr.encodeString(I)).join(`
11
- `)}
12
- `).buffer):this.dataType.usesBigInt&&typeof T=="number"?this._data=new this.dataType.Array(d.map(I=>BigInt(Math.round(I)))).buffer:!this.dataType.usesBigInt&&typeof T=="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??D.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 U(r).Array(e),i=new Ke({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===Ye)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===Ye)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===Ye?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(U.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(hr.decodeString(r)))}get byteCapacity(){return new Lt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ye?this.byteCapacity:this.dataType.isVariable?new Lt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ye?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===Ts&&(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]=am(this.dataType,e,this.data[s],r);return new Ke({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(U.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(),Re(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(U.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((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(),Re(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(U.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 Re(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=Cc(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]===Ts){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(U.STRING)?new TextDecoder().decode(i):ta(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=xr(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(U.FLOAT32)&&!this.dataType.equals(U.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!==Ye){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=Ye}as(e){return jc(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Oi(this.alignmentBounds.lower),upper:Oi(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 fm(this);return this.dataType.equals(U.JSON)?new ga(e):e}return this.dataType.equals(U.UUID)?new pm(this):new ym(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new zi(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 zi(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 Ke({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 Ke({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new Ke({data:this.buffer,dataType:this.dataType,timeRange:D.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 dm=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Qe?!0:Ic(t),$c=_p(Mc,Qe);class zi{series;end;index;constructor(e,r,n){this.series=e;const s=K(0,e.length+1);this.end=bi(s,n),this.index=bi(s,r)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class fm{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==Ts;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}}class ga{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:hr.decodeString(e.value,ga.schema)}}}class pm{series;index;data;density;constructor(e){if(!e.dataType.equals(U.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=U.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const e=Cc(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}}class ym{series;index;constructor(e){this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class mm{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 jc(e,this.dataType),this}get dataType(){return this.series.length===0?U.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?D.ZERO:new D(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($c(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(Wr(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 Yn(this,e,r??this.length)}subAlignmentIterator(e,r){if(e>=this.alignmentBounds.upper||r<=this.alignmentBounds.lower)return Os;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(Wr(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(Wr(o.alignmentBounds,r)){s+=Math.ceil(Number(r-o.alignment)/Number(o.alignmentMultiple));break}}return new Yn(this,n,s)}subAlignmentSpanIterator(e,r){if(e>=this.alignmentBounds.upper)return Os;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(Wr(i.alignmentBounds,e)){n+=Number(e-i.alignment);break}}return new Yn(this,n,n+r)}updateGLBuffer(e){this.series.forEach(r=>r.updateGLBuffer(e))}get bounds(){return iy(this.series.map(e=>e.bounds))}get byteLength(){return new Lt(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 oy(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 cy(n,e,r)}parseJSON(e){if(!this.dataType.equals(U.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 gm(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}}class gm{series;seriesIndex;internal;constructor(e){this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}class Yn{series;index;end;constructor(e,r,n){this.series=e,this.end=n,this.index=r}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 Oi=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}},wm=async t=>await new Promise(e=>setTimeout(e,N.fromMilliseconds(t).milliseconds));class bm{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??wm},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 vm=a.z.object({baseInterval:N.z.optional(),maxRetries:a.z.number().optional(),scale:a.z.number().optional()}),wa=Object.freeze(Object.defineProperty({__proto__:null,Breaker:bm,breakerConfigZ:vm},Symbol.toStringTag,{value:"Module"})),zm=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Uc=a.z.string().regex(zm),_t=a.z.number().min(0).max(255),_c=a.z.number().min(0).max(1),Pc=a.z.tuple([_t,_t,_t,_c]),Om=a.z.tuple([_t,_t,_t]),Tm=a.z.object({rgba255:Pc}),km=a.z.number().min(0).max(360),Sm=a.z.number().min(0).max(100),Nm=a.z.number().min(0).max(100),Em=a.z.tuple([km,Sm,Nm,_c]),ba=a.z.union([Uc,Om,Pc,Em,Tm]),Am=ba.transform(t=>va(t)),va=(t,e=1)=>{if(t=ba.parse(t),typeof t=="string")return xm(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},xm=(t,e=1)=>(t=Uc.parse(t),t=Im(t),[Jr(t,0),Jr(t,2),Jr(t,4),t.length===8?Jr(t,6)/255:e]),Jr=(t,e)=>parseInt(t.slice(e,e+2),16),Im=t=>t.startsWith("#")?t.slice(1):t;va("#000000");va("#ffffff");const Cm=a.z.object({key:a.z.string(),color:ba,position:a.z.number(),switched:a.z.boolean().optional()});a.z.array(Cm);const jm=a.z.object({key:a.z.string(),name:a.z.string(),color:Am});a.z.object({key:a.z.string(),name:a.z.string(),swatches:a.z.array(jm)});const Zc=a.z.int().min(0).max(255),Rc=255,Dc=0,Mm={lower:Dc,upper:Rc+1},Lc=a.z.object({name:a.z.string(),key:a.z.string()}),fr=t=>a.z.object({subject:Lc,resource:t,authority:Zc}),$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}),Bc=t=>a.z.object({from:fr(t),to:a.z.null()}),Fc=t=>a.z.object({from:a.z.null(),to:fr(t)}),Um=t=>a.z.union([Bc(t),Fc(t),a.z.object({from:fr(t),to:fr(t)})]),me=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:Rc,AUTHORITY_BOUNDS:Mm,ZERO_AUTHORITY:Dc,acquireZ:Fc,authorityZ:Zc,filterTransfersByChannelKey:$m,releaseZ:Bc,stateZ:fr,subjectZ:Lc,transferZ:Um},Symbol.toStringTag,{value:"Module"})),_m=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},ks=".",Pm=(t,e,r=ks)=>{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)},Zm=(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)},Rm=((t,e,r={optional:!1})=>{const{optional:n,getter:s=Zm}=r;if(e==="")return t;const i=e.split(ks);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(ks),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)}),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]},qc="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),Cr=t=>class cr extends Error{static discriminator=qc;discriminator=cr.discriminator;static TYPE=t;type=cr.TYPE;static matches=Bm(t);matches=cr.matches;constructor(r,n){super(r,n),this.name=cr.TYPE}static sub(r){return Cr(`${t}.${r}`)}},Yc=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==qc)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},Mt="unknown",Ss="nil";class Fm{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Ss,data:""};if(Yc(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:Mt,data:e.message};if(typeof e=="string")return{type:Mt,data:e};try{return{type:Mt,data:JSON.stringify(e)}}catch{return{type:Mt,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===Ss)return null;if(e.type===Mt)return new Ns(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Ns(e.data)}}const za=Lm("synnax-error-registry",()=>new Fm),qm=({encode:t,decode:e})=>za().register({encode:t,decode:e}),Ym=t=>za().encode(t),Vm=t=>t==null?null:za().decode(t);class Ns extends Cr("unknown"){}const Hm=a.z.object({type:a.z.string(),data:a.z.string()});class Wm extends Cr("canceled"){}class Gm extends Cr("not_implemented"){}const Le=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Wm,NONE:Ss,NotImplemented:Gm,UNKNOWN:Mt,Unknown:Ns,createTyped:Cr,decode:Vm,encode:Ym,isTyped:Yc,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()}),Vc=a.object({jsonrpc:a.literal("2.0"),id:a.union([a.string(),a.number(),a.null()])}),Jm=Vc.extend({result:a.json()}),Xm=Vc.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]);a.z.object({key:a.z.string(),value:a.z.string()});const Hc=a.uuid(),Wc=a.object({key:Hc,name:a.string().min(1),color:a.string()}),Gc=Object.freeze(Object.defineProperty({__proto__:null,keyZ:Hc,labelZ:Wc},Symbol.toStringTag,{value:"Module"})),Es=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 _e;if(c===void 0)return Pe;const l=/^\d+$/.test(o),u=/^\d+$/.test(c);if(l&&!u)return _e;if(!l&&u)return Pe;if(l&&u){const h=parseInt(o),f=parseInt(c);if(h<f)return _e;if(h>f)return Pe}else{if(o<c)return _e;if(o>c)return Pe}}return kt},jr=((t,e,r={})=>{r.checkMajor??=!0,r.checkMinor??=!0,r.checkPatch??=!0;const n=Es.parse(t),s=Es.parse(e),[i,o]=n.split("-"),[c,l]=s.split("-"),[u,h,f]=i.split(".").map(Number),[d,T,I]=c.split(".").map(Number);if(r.checkMajor){if(u<d)return _e;if(u>d)return Pe}if(r.checkMinor){if(h<T)return _e;if(h>T)return Pe}if(r.checkPatch){if(f<I)return _e;if(f>I)return Pe}return o===void 0&&l===void 0?kt:o===void 0?Pe:l===void 0?_e:eg(o,l)}),tg=(t,e,r={})=>Qo(jr(t,e,r)),Kc=(t,e,r={})=>Xo(jr(t,e,r)),rg=(t,e,r={})=>Jo(jr(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(jr).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||Kc(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}}},Ti=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:jr,createMigration:ng,migrator:sg,semVerNewer:Kc,semVerOlder:rg,semVerZ:Es,versionsEqual:tg},Symbol.toStringTag,{value:"Module"})),ag=["standard","scientific","engineering"];a.z.enum(ag);class ig{handlers;transform;closer;constructor(e,r){this.transform=e,this.handlers=r??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let r=e;if(this.transform!=null){const[n,s]=this.transform(e);if(!s)return;r=n}this.handlers.forEach((n,s)=>s(r))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}}class og{handlers;constructor(e){this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((r,n)=>n(e))}}const cg=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:og,Observer:ig},Symbol.toStringTag,{value:"Module"})),lg=a.z.record(a.z.union([a.z.number(),a.z.string(),a.z.symbol()]),a.z.unknown()),Oa=t=>Object.entries(t),ug=(t,e)=>Object.fromEntries(Oa(t).map(([r,n])=>[r,e(n,r)])),hg=t=>Object.fromEntries(Oa(t).filter(([e,r])=>r!==void 0)),dg=(t,...e)=>{const r={...t};for(const n of e)delete r[n];return r},Oe=Object.freeze(Object.defineProperty({__proto__:null,entries:Oa,map:ug,omit:dg,purgeUndefined:hg,unknownZ:lg},Symbol.toStringTag,{value:"Module"})),fg=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";fg();const pg=["macOS","Windows","Linux"],yg=["macos","windows","linux"],mg={macos:"macOS",windows:"Windows",linux:"Linux"};a.z.enum(pg).or(a.z.enum(yg).transform(t=>mg[t]));const Jc=a.z.enum(["success","info","warning","error","loading","disabled"]),gg=t=>a.z.object({key:a.z.string(),name:a.z.string().default(""),variant:Jc,message:a.z.string(),description:a.z.string().optional(),time:C.z,labels:Do(Wc).optional(),details:t??a.z.unknown().optional()}),wg=a.z.object({stack:a.z.string(),error:a.z.instanceof(Error)}),bg=(t,e)=>{if(!(t instanceof Error))throw t;return Xc({variant:"error",message:e??t.message,description:e!=null?t.message:void 0,details:{stack:t.stack??"",error:t}})},Xc=t=>({key:na(),time:C.now(),name:"",...t}),vg=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?t:void 0:e===t?t:void 0},zg=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?void 0:t:e===t?void 0:t},St=Object.freeze(Object.defineProperty({__proto__:null,create:Xc,exceptionDetailsSchema:wg,fromException:bg,keepVariants:vg,removeVariants:zg,statusZ:gg,variantZ:Jc},Symbol.toStringTag,{value:"Module"})),Og=(t,e)=>{if(!e.has(t))return t;let r=t,n=1,s=t;for(;e.has(s);){const i=s.match(Tg);i?(r=s.slice(0,i.index).trim(),n=parseInt(i[1])+1):(r=s,n=1),s=`${r} (${n})`}return s},Tg=/\((\d+)\)$/,kg=(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]}`},Sg=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))},Ng=(t,e)=>t.startsWith(e)?t.slice(e.length):t,As=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Sg,deduplicateFileName:Og,naturalLanguageJoin:kg,trimPrefix:Ng},Symbol.toStringTag,{value:"Module"})),Eg=(...t)=>t.map(Qc).join(""),Qc=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Ag=t=>t.endsWith("/")?t.slice(0,-1):t;class Pt{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){this.protocol=n,this.host=e,this.port=r,this.path=Qc(s)}replace(e){return new Pt({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Pt({...this,pathPrefix:Eg(this.path,e)})}toString(){return Ag(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Pt({host:"unknown",port:0})}const xg=t=>t.nullable().transform(e=>e===null?void 0:e).optional(),Ig=a.z.int().min(0).max(sc),Cg=t=>a.array(t).or(t.transform(e=>[e])),el=t=>Pm(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"]}),ki=(t,e)=>{if(t==null)return null;const r=t[e];return r==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:r},jg=((t,e,r)=>e===""?t:Rm(ki(t,"shape"),el(e),{...r,getter:ki})),Ce=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:jg,getFieldSchemaPath:el,nullToUndefined:xg,toArray:Cg,uint12:Ig},Symbol.toStringTag,{value:"Module"})),Ta=a.z.enum(["create","delete","retrieve","update"]);class je extends Le.createTyped("sy"){}let Y=class extends je.sub("validation"){};class pr extends Y.sub("path"){path;error;static encodedSchema=a.z.object({path:a.z.string().array(),error:Le.payloadZ});constructor(e,r){const n=v.toArray(e);super(`${n.join(".")}: ${r.message}`),this.path=n.flatMap(s=>s.split(".")),this.error=r}static decode(e){const r=pr.encodedSchema.parse(JSON.parse(e.data));return new pr(r.path,Le.decode(r.error))}}class yr extends je.sub("auth"){}class xs extends yr.sub("invalid_token"){}class Is extends yr.sub("expired_token"){}class rA extends yr.sub("access_denied"){}class ue extends je.sub("unexpected"){constructor(e){super(`
16
- Unexpected error encountered:
17
-
18
- ${e}
19
-
20
- Please report this to the Synnax team.
21
- `)}}class nt extends je.sub("query"){}class Bt extends nt.sub("not_found"){}class cn extends nt.sub("multiple_results"){}class Si extends je.sub("route"){path;constructor(e,r){super(e),this.path=r}}class Cs extends je.sub("control"){}class Ni extends Cs.sub("unauthorized"){}class Mg extends je.sub("disconnected"){constructor(e="Operation failed because no Core is connected."){super(e)}}class nA extends je.sub("contiguity"){}const $g=t=>t.type.startsWith(je.TYPE)?t.type.startsWith(Y.TYPE)?t.type===pr.TYPE?pr.decode(t):new Y(t.data):t.type.startsWith(yr.TYPE)?t.type.startsWith(xs.TYPE)?new xs(t.data):t.type.startsWith(Is.TYPE)?new Is(t.data):new yr(t.data):t.type.startsWith(ue.TYPE)?new ue(t.data):t.type.startsWith(nt.TYPE)?t.type.startsWith(Bt.TYPE)?new Bt(t.data):t.type.startsWith(cn.TYPE)?new cn(t.data):new nt(t.data):t.type.startsWith(Cs.TYPE)?t.type.startsWith(Ni.TYPE)?new Ni(t.data):new Cs(t.data):t.type.startsWith(Si.TYPE)?new Si(t.data,t.data):new ue(t.data):null,Ug=()=>{throw new Le.NotImplemented};Le.register({encode:Ug,decode:$g});const _g=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof rt?[r,new rt({message:`Cannot reach Core at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]},wn=a.z.enum(["label","log","builtin","cluster","channel","node","group","range","framer","range-alias","user","workspace","schematic","lineplot","rack","device","task","policy","role","table","arc","schematic_symbol","status"]),tl=a.z.string().transform(t=>{const[e,r]=t.split(":");return{type:wn.parse(e),key:r??""}}),L=a.z.object({type:wn,key:a.z.string()}).or(tl),Pg={type:"builtin",key:"root"},H=t=>{const e=r=>({type:t,key:Tp.isZero(r)?"":r.toString()});return(r=>Array.isArray(r)?r.map(e):e(r))},Be=(t=>(typeof t=="string"&&(t=tl.parse(t)),Array.isArray(t)?t.map(e=>Be(e)):`${t.type}:${t.key}`)),Zg=(t,e)=>t.type===e.type&&t.key===e.key,rl=t=>{const e=v.toArray(t);return e.length===0?[]:typeof e[0]=="object"&&"id"in e[0]?e.map(({id:r})=>r):e.map(r=>L.parse(r))},nl=a.z.object({id:L,name:a.z.string(),data:Oe.unknownZ.optional().nullable()}).transform(t=>({key:Be(t.id),...t})),Rg=t=>t==="to"?"from":"to",Dg=a.z.object({from:L,type:a.z.string(),to:L}).or(a.z.string().transform(t=>{const[e,r,n]=t.split("->");return{from:L.parse(e),type:r,to:L.parse(n)}})),Lg=t=>`${Be(t.from)}->${t.type}->${Be(t.to)}`,Bg="parent",Fg=(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),Mr=a.z.uuid(),sl=a.z.string(),bn=a.z.object({key:Mr,name:sl}),qg=H("group"),Yg="sy_group_set",Vg="sy_group_delete",Hg=a.object({group:bn}),Wg=a.object({parent:L,key:Mr.optional(),name:a.string()}),Gg=a.object({key:Mr,name:a.string()}),Kg=a.object({keys:a.array(Mr)});let al=class{client;constructor(t){this.client=t}async create(t){return(await w(this.client,"/ontology/create-group",t,Wg,Hg)).group}async rename(t,e){await w(this.client,"/ontology/rename-group",{key:t,name:e},Gg,a.object({}))}async delete(t){await w(this.client,"/ontology/delete-group",{keys:v.toArray(t)},Kg,a.object({}))}};const Jg=Object.freeze(Object.defineProperty({__proto__:null,Client:al,DELETE_CHANNEL_NAME:Vg,SET_CHANNEL_NAME:Yg,groupZ:bn,keyZ:Mr,nameZ:sl,ontologyID:qg},Symbol.toStringTag,{value:"Module"})),Ei=a.z.object({id:L,children:L.array()}),Xg=a.z.object({from:L,to:L,children:L.array()}),Vn=a.z.object({});let Qg=class{client;constructor(t){this.client=t}async addChildren(t,...e){await w(this.client,"/ontology/add-children",{id:t,children:e},Ei,Vn)}async removeChildren(t,...e){await w(this.client,"/ontology/remove-children",{id:t,children:e},Ei,Vn)}async moveChildren(t,e,...r){await w(this.client,"/ontology/move-children",{from:t,to:e,children:r},Xg,Vn)}};const ew=a.z.object({ids:L.array().optional(),children:a.z.boolean().optional(),parents:a.z.boolean().optional(),excludeFieldData:a.z.boolean().optional(),types:wn.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.int().optional(),offset:a.z.int().optional()}),tw=a.z.object({resources:nl.array()});let il=class{type="ontology";groups;client;writer;framer;constructor(t,e){this.client=t,this.writer=new Qg(t),this.groups=new al(t),this.framer=e}async retrieve(t,e){if(!Array.isArray(t)&&typeof t=="object"&&!("key"in t))return this.execRetrieve(t);const r=rl(t),n=await this.execRetrieve({ids:r,...e});if(Array.isArray(t))return n;if(n.length===0)throw new nt(`No resource found with ID ${As.naturalLanguageJoin(r.map(s=>Be(s)))}`);return n[0]}async retrieveChildren(t,e){return await this.execRetrieve({ids:v.toArray(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:v.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 w(this.client,"/ontology/retrieve",t,ew,tw);return e}};const rw="sy_ontology_resource_set",nw="sy_ontology_resource_delete",sw="sy_ontology_relationship_set",aw="sy_ontology_relationship_delete",iw=Object.freeze(Object.defineProperty({__proto__:null,Client:il,PARENT_OF_RELATIONSHIP_TYPE:Bg,RELATIONSHIP_DELETE_CHANNEL_NAME:aw,RELATIONSHIP_SET_CHANNEL_NAME:sw,RESOURCE_DELETE_CHANNEL_NAME:nw,RESOURCE_SET_CHANNEL_NAME:rw,ROOT_ID:Pg,createIDFactory:H,idToString:Be,idZ:L,idsEqual:Zg,matchRelationship:Fg,oppositeRelationshipDirection:Rg,parseIDs:rl,relationshipToString:Lg,relationshipZ:Dg,resourceTypeZ:wn,resourceZ:nl},Symbol.toStringTag,{value:"Module"})),Wt=a.z.uuid(),ka=a.z.object({key:Wt,name:a.z.string(),objects:v.nullableZ(L),actions:v.nullableZ(Ta),internal:a.z.boolean()}),Sa=a.z.object({key:Wt.optional(),name:a.z.string(),objects:Ce.toArray(L),actions:Ce.toArray(Ta)}),ol=H("policy"),ow=ol(""),cw="sy_policy_set",lw="sy_policy_delete",uw=a.z.object({keys:Wt.array().optional(),subjects:L.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),hw=a.z.object({key:Wt}).transform(({key:t})=>({keys:[t]})),dw=a.z.union([a.z.object({for:L}).transform(({for:t})=>({subjects:[t]})),a.z.object({for:L.array()}).transform(({for:t})=>({subjects:t})),uw]),fw=a.z.union([hw,dw]),pw=a.z.object({policies:v.nullableZ(ka)}),yw=Sa.transform(t=>({policies:[t]})),cl=Sa.array().transform(t=>({policies:t})),ll=a.z.union([yw,cl]),mw=a.z.object({policies:ka.array()}),gw=a.z.object({keys:Wt.array()}),ww=a.z.object({});let ul=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/policy/create",t,ll,mw);return e?r.policies:r.policies[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/policy/retrieve",t,fw,pw);return e?r.policies[0]:r.policies}async delete(t){await w(this.client,"/access/policy/delete",{keys:v.toArray(t)},gw,ww)}};const bw=Object.freeze(Object.defineProperty({__proto__:null,Client:ul,DELETE_CHANNEL_NAME:lw,SET_CHANNEL_NAME:cw,TYPE_ONTOLOGY_ID:ow,createArgsZ:ll,keyZ:Wt,multipleCreateArgsZ:cl,newZ:Sa,ontologyID:ol,policyZ:ka},Symbol.toStringTag,{value:"Module"})),st=a.z.uuid(),vn=a.z.object({key:st,name:a.z.string(),description:a.z.string().optional(),internal:a.z.boolean().optional()}),Na=vn.partial({key:!0}),hl=H("role"),vw=hl(""),Me=a.z.uuid(),$r=a.z.object({key:Me,username:a.z.string().min(1,"Username is required"),firstName:a.z.string().default(""),lastName:a.z.string().default(""),rootUser:a.z.boolean().default(!1)}),dl=$r.omit({rootUser:!0}).partial({key:!0,firstName:!0,lastName:!0}).extend({password:a.z.string().min(1)}),zw=a.z.object({keys:Me.array().optional(),usernames:a.z.string().array().optional()}),Ow=a.z.object({key:Me}).transform(({key:t})=>({keys:[t]})),Tw=a.z.object({username:a.z.string()}).transform(({username:t})=>({usernames:[t]})),kw=a.z.object({usernames:a.z.string().array()}).transform(({usernames:t})=>({usernames:t})),Sw=a.z.union([Ow,Tw,kw,zw]),Nw=a.z.object({users:v.nullableZ($r)}),Ew=a.z.object({users:dl.array()}),Aw=a.z.object({users:$r.array()}),xw=a.z.object({key:Me,username:a.z.string().min(1)}),Iw=a.z.object({}),Cw=a.z.object({key:Me,firstName:a.z.string().optional(),lastName:a.z.string().optional()}),jw=a.z.object({}),Mw=a.z.object({keys:Me.array()}),$w=a.z.object({}),Uw="sy_user_set",_w="sy_user_delete";let fl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/user/create",{users:v.toArray(t)},Ew,Aw);return e?r.users:r.users[0]}async changeUsername(t,e){await w(this.client,"/user/change-username",{key:t,username:e},xw,Iw)}async retrieve(t){const e="key"in t||"username"in t,r=await w(this.client,"/user/retrieve",t,Sw,Nw);if(!e)return r.users;if(r.users.length===0){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new Bt(`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 w(this.client,"/user/rename",{key:t,firstName:e,lastName:r},Cw,jw)}async delete(t){await w(this.client,"/user/delete",{keys:v.toArray(t)},Mw,$w)}};const pl=H("user"),Pw=pl(""),Zw=Object.freeze(Object.defineProperty({__proto__:null,Client:fl,DELETE_CHANNEL_NAME:_w,SET_CHANNEL_NAME:Uw,TYPE_ONTOLOGY_ID:Pw,keyZ:Me,newZ:dl,ontologyID:pl,userZ:$r},Symbol.toStringTag,{value:"Module"})),Rw=a.z.object({keys:st.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),Dw=a.z.object({key:st}).transform(({key:t})=>({keys:[t]})),Lw=Na.transform(t=>({roles:[t]})),yl=Na.array().transform(t=>({roles:t})),ml=a.z.union([Lw,yl]),Bw=a.z.object({roles:vn.array()}),Fw=a.z.object({roles:v.nullableZ(vn)}),gl=a.z.union([Dw,Rw]),qw=a.z.object({}),Yw=st.transform(t=>({keys:[t]})).or(st.array().transform(t=>({keys:t}))),Vw=a.z.object({user:Me,role:st}),Hw=a.z.object({}),Ww=a.z.object({user:Me,role:st}),Gw=a.z.object({}),Kw="sy_role_set",Jw="sy_role_delete";let wl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/role/create",t,ml,Bw);return e?r.roles:r.roles[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/role/retrieve",t,gl,Fw);return e?r.roles[0]:r.roles}async delete(t){await w(this.client,"/access/role/delete",t,Yw,qw)}async assign(t){await w(this.client,"/access/role/assign",t,Vw,Hw)}async unassign(t){await w(this.client,"/access/role/unassign",t,Ww,Gw)}};const Xw=Object.freeze(Object.defineProperty({__proto__:null,Client:wl,DELETE_CHANNEL_NAME:Jw,SET_CHANNEL_NAME:Kw,TYPE_ONTOLOGY_ID:vw,createArgsZ:ml,keyZ:st,multipleCreateArgsZ:yl,newZ:Na,ontologyID:hl,retrieveArgsZ:gl,roleZ:vn},Symbol.toStringTag,{value:"Module"}));let bl=class{policies;roles;constructor(t){this.policies=new ul(t),this.roles=new wl(t)}};const Qw=(t,e)=>{const r=v.toArray(t.objects),{action:n}=t;for(const s of r){let i=!1;for(const o of e)if(o.actions.includes(n)){for(const c of o.objects)if(c.key===""){if(c.type===s.type){i=!0;break}}else if(c.type===s.type&&c.key===s.key){i=!0;break}if(i)break}if(!i)return!1}return!0},eb=Object.freeze(Object.defineProperty({__proto__:null,Client:bl,actionZ:Ta,allowRequest:Qw,policy:bw,role:Xw},Symbol.toStringTag,{value:"Module"}));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 Zt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class vl extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const zl={};function vt(t){return zl}function tb(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 js(t,e){return typeof e=="bigint"?e.toString():e}function Ea(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Aa(t){return t==null}function xa(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function rb(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 Ai=Symbol("evaluating");function R(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==Ai)return n===void 0&&(n=Ai,n=r()),n},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Nt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Et(...t){const e={};for(const r of t){const n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function xi(t){return JSON.stringify(t)}const Ol="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const nb=Ea(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function mr(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 Tl(t){return mr(t)?{...t}:Array.isArray(t)?[...t]:t}const sb=new Set(["string","number","symbol"]);function zn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function at(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 ab(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const ib={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 ob(t,e){const r=t._zod.def,n=Et(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 Nt(this,"shape",s),s},checks:[]});return at(t,n)}function cb(t,e){const r=t._zod.def,n=Et(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 Nt(this,"shape",s),s},checks:[]});return at(t,n)}function lb(t,e){if(!mr(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=Et(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return Nt(this,"shape",s),s},checks:[]});return at(t,n)}function ub(t,e){if(!mr(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 Nt(this,"shape",n),n},checks:t._zod.def.checks};return at(t,r)}function hb(t,e){const r=Et(t._zod.def,{get shape(){const n={...t._zod.def.shape,...e._zod.def.shape};return Nt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:[]});return at(t,r)}function db(t,e,r){const n=Et(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 Nt(this,"shape",i),i},checks:[]});return at(e,n)}function fb(t,e,r){const n=Et(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 Nt(this,"shape",i),i},checks:[]});return at(e,n)}function $t(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 kl(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Xr(t){return typeof t=="string"?t:t?.message}function zt(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Xr(t.inst?._zod.def?.error?.(t))??Xr(e?.error?.(t))??Xr(r.customError?.(t))??Xr(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Ia(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function gr(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const Sl=(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,js,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Nl=p("$ZodError",Sl),El=p("$ZodError",Sl,{Parent:Error});function pb(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 yb(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 Ca=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 Zt;if(o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>zt(l,i,vt())));throw Ol(c,s?.callee),c}return o.value},ja=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=>zt(l,i,vt())));throw Ol(c,s?.callee),c}return o.value},On=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 Zt;return i.issues.length?{success:!1,error:new(t??Nl)(i.issues.map(o=>zt(o,s,vt())))}:{success:!0,data:i.value}},mb=On(El),Tn=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=>zt(o,s,vt())))}:{success:!0,data:i.value}},gb=Tn(El),wb=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ca(t)(e,r,s)},bb=t=>(e,r,n)=>Ca(t)(e,r,n),vb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ja(t)(e,r,s)},zb=t=>async(e,r,n)=>ja(t)(e,r,n),Ob=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return On(t)(e,r,s)},Tb=t=>(e,r,n)=>On(t)(e,r,n),kb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Tn(t)(e,r,s)},Sb=t=>async(e,r,n)=>Tn(t)(e,r,n),Nb=/^[cC][^\s-]{8,}$/,Eb=/^[0-9a-z]+$/,Ab=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xb=/^[0-9a-vA-V]{20}$/,Ib=/^[A-Za-z0-9]{27}$/,Cb=/^[a-zA-Z0-9_-]{21}$/,jb=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mb=/^([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})$/,Ii=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)$/,$b=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ub="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _b(){return new RegExp(Ub,"u")}const Pb=/^(?:(?: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])$/,Zb=/^(([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}|:))$/,Rb=/^((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])$/,Db=/^(([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])$/,Lb=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Al=/^[A-Za-z0-9_-]*$/,Bb=/^(?=.{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])?)*\.?$/,Fb=/^\+(?:[0-9]){6,14}[0-9]$/,xl="(?:(?:\\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])))",qb=new RegExp(`^${xl}$`);function Il(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 Yb(t){return new RegExp(`^${Il(t)}$`)}function Vb(t){const e=Il({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(`^${xl}T(?:${n})$`)}const Hb=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Wb=/^-?\d+$/,Gb=/^-?\d+(?:\.\d+)?/,Kb=/^(?:true|false)$/i,Jb=/^[^A-Z]*$/,Xb=/^[^a-z]*$/,ie=p("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Cl={number:"number",bigint:"bigint",object:"date"},jl=p("$ZodCheckLessThan",(t,e)=>{ie.init(t,e);const r=Cl[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})}}),Ml=p("$ZodCheckGreaterThan",(t,e)=>{ie.init(t,e);const r=Cl[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})}}),Qb=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):rb(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})}}),ev=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]=ib[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=Wb)}),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})}}),tv=p("$ZodCheckMaxLength",(t,e)=>{var r;ie.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Aa(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=Ia(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),rv=p("$ZodCheckMinLength",(t,e)=>{var r;ie.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Aa(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=Ia(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),nv=p("$ZodCheckLengthEquals",(t,e)=>{var r;ie.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Aa(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=Ia(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})}}),kn=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=()=>{})}),sv=p("$ZodCheckRegex",(t,e)=>{kn.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})}}),av=p("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Jb),kn.init(t,e)}),iv=p("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Xb),kn.init(t,e)}),ov=p("$ZodCheckIncludes",(t,e)=>{ie.init(t,e);const r=zn(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})}}),cv=p("$ZodCheckStartsWith",(t,e)=>{ie.init(t,e);const r=new RegExp(`^${zn(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})}}),lv=p("$ZodCheckEndsWith",(t,e)=>{ie.init(t,e);const r=new RegExp(`.*${zn(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})}}),uv=p("$ZodCheckOverwrite",(t,e)=>{ie.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class hv{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 dv={major:4,minor:1,patch:12},V=p("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=dv;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=$t(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,T=f._zod.check(o);if(T instanceof Promise&&l?.async===!1)throw new Zt;if(h||T instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await T,o.issues.length!==d&&(u||(u=$t(o,d)))});else{if(o.issues.length===d)continue;u||(u=$t(o,d))}}return h?h.then(()=>o):o},i=(o,c,l)=>{if($t(o))return o.aborted=!0,o;const u=s(c,n,l);if(u instanceof Promise){if(l.async===!1)throw new Zt;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 Zt;return l.then(u=>s(u,n,c))}return s(l,n,c)}}t["~standard"]={validate:s=>{try{const i=mb(t,s);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return gb(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Ma=p("$ZodString",(t,e)=>{V.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Hb(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}}),B=p("$ZodStringFormat",(t,e)=>{kn.init(t,e),Ma.init(t,e)}),fv=p("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Mb),B.init(t,e)}),pv=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=Ii(r))}else e.pattern??(e.pattern=Ii());B.init(t,e)}),yv=p("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=$b),B.init(t,e)}),mv=p("$ZodURL",(t,e)=>{B.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:Bb.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})}}}),gv=p("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=_b()),B.init(t,e)}),wv=p("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Cb),B.init(t,e)}),bv=p("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Nb),B.init(t,e)}),vv=p("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Eb),B.init(t,e)}),zv=p("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Ab),B.init(t,e)}),Ov=p("$ZodXID",(t,e)=>{e.pattern??(e.pattern=xb),B.init(t,e)}),Tv=p("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Ib),B.init(t,e)}),kv=p("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Vb(e)),B.init(t,e)}),Sv=p("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=qb),B.init(t,e)}),Nv=p("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Yb(e)),B.init(t,e)}),Ev=p("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=jb),B.init(t,e)}),Av=p("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Pb),B.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),xv=p("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Zb),B.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})}}}),Iv=p("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Rb),B.init(t,e)}),Cv=p("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Db),B.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 $l(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const jv=p("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Lb),B.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{$l(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Mv(t){if(!Al.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return $l(r)}const $v=p("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Al),B.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{Mv(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Uv=p("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Fb),B.init(t,e)});function _v(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 Pv=p("$ZodJWT",(t,e)=>{B.init(t,e),t._zod.check=r=>{_v(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),Ul=p("$ZodNumber",(t,e)=>{V.init(t,e),t._zod.pattern=t._zod.bag.pattern??Gb,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}}),Zv=p("$ZodNumber",(t,e)=>{ev.init(t,e),Ul.init(t,e)}),Rv=p("$ZodBoolean",(t,e)=>{V.init(t,e),t._zod.pattern=Kb,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}}),Dv=p("$ZodUnknown",(t,e)=>{V.init(t,e),t._zod.parse=r=>r}),Lv=p("$ZodNever",(t,e)=>{V.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Ci(t,e,r){t.issues.length&&e.issues.push(...kl(r,t.issues)),e.value[r]=t.value}const Bv=p("$ZodArray",(t,e)=>{V.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=>Ci(u,r,o))):Ci(l,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function un(t,e,r,n){t.issues.length&&e.issues.push(...kl(r,t.issues)),t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}function _l(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=ab(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function Pl(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 Fv=p("$ZodObject",(t,e)=>{if(V.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=Ea(()=>_l(e));R(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(T=>un(T,o,f,l))):un(d,o,f,l)}return s?Pl(u,l,o,c,r.value,t):u.length?Promise.all(u).then(()=>o):o}}),qv=p("$ZodObjectJIT",(t,e)=>{Fv.init(t,e);const r=t._zod.parse,n=Ea(()=>_l(e)),s=f=>{const d=new hv(["shape","payload","ctx"]),T=n.value,I=x=>{const G=xi(x);return`shape[${G}]._zod.run({ value: input[${G}], issues: [] }, ctx)`};d.write("const input = payload.value;");const $=Object.create(null);let b=0;for(const x of T.keys)$[x]=`key_${b++}`;d.write("const newResult = {};");for(const x of T.keys){const G=$[x],ne=xi(x);d.write(`const ${G} = ${I(x)};`),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 k=d.compile();return(x,G)=>k(f,x,G)};let i;const o=ln,c=!zl.jitless,l=c&&nb.value,u=e.catchall;let h;t._zod.parse=(f,d)=>{h??(h=n.value);const T=f.value;return o(T)?c&&l&&d?.async===!1&&d.jitless!==!0?(i||(i=s(e.shape)),f=i(f,d),u?Pl([],T,f,d,h,t):f):r(f,d):(f.issues.push({expected:"object",code:"invalid_type",input:T,inst:t}),f)}});function ji(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=>!$t(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=>zt(o,n,vt())))}),e)}const Yv=p("$ZodUnion",(t,e)=>{V.init(t,e),R(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),R(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),R(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),R(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=>xa(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=>ji(l,s,t,i)):ji(c,s,t,i)}}),Vv=p("$ZodIntersection",(t,e)=>{V.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])=>Mi(r,c,l)):Mi(r,i,o)}});function Ms(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(mr(t)&&mr(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=Ms(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=Ms(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 Mi(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),$t(t))return t;const n=Ms(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 Hv=p("$ZodEnum",(t,e)=>{V.init(t,e);const r=tb(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(s=>sb.has(typeof s)).map(s=>typeof s=="string"?zn(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}}),Wv=p("$ZodTransform",(t,e)=>{V.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vl(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 Zt;return r.value=s,r}});function $i(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const Gv=p("$ZodOptional",(t,e)=>{V.init(t,e),t._zod.optin="optional",t._zod.optout="optional",R(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),R(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${xa(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=>$i(i,r.value)):$i(s,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),Kv=p("$ZodNullable",(t,e)=>{V.init(t,e),R(t._zod,"optin",()=>e.innerType._zod.optin),R(t._zod,"optout",()=>e.innerType._zod.optout),R(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${xa(r.source)}|null)$`):void 0}),R(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)}),Jv=p("$ZodDefault",(t,e)=>{V.init(t,e),t._zod.optin="optional",R(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=>Ui(i,e)):Ui(s,e)}});function Ui(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const Xv=p("$ZodPrefault",(t,e)=>{V.init(t,e),t._zod.optin="optional",R(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))}),Qv=p("$ZodNonOptional",(t,e)=>{V.init(t,e),R(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=>_i(i,t)):_i(s,t)}});function _i(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 ez=p("$ZodCatch",(t,e)=>{V.init(t,e),R(t._zod,"optin",()=>e.innerType._zod.optin),R(t._zod,"optout",()=>e.innerType._zod.optout),R(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=>zt(o,n,vt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>zt(i,n,vt()))},input:r.value}),r.issues=[]),r)}}),tz=p("$ZodPipe",(t,e)=>{V.init(t,e),R(t._zod,"values",()=>e.in._zod.values),R(t._zod,"optin",()=>e.in._zod.optin),R(t._zod,"optout",()=>e.out._zod.optout),R(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=>Qr(o,e.in,n)):Qr(i,e.in,n)}const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(i=>Qr(i,e.out,n)):Qr(s,e.out,n)}});function Qr(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}const rz=p("$ZodReadonly",(t,e)=>{V.init(t,e),R(t._zod,"propValues",()=>e.innerType._zod.propValues),R(t._zod,"values",()=>e.innerType._zod.values),R(t._zod,"optin",()=>e.innerType._zod.optin),R(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(Pi):Pi(s)}});function Pi(t){return t.value=Object.freeze(t.value),t}const nz=p("$ZodCustom",(t,e)=>{ie.init(t,e),V.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=>Zi(i,r,n,t));Zi(s,r,n,t)}});function Zi(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(gr(s))}}class sz{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 az(){return new sz}const en=az();function iz(t,e){return new t({type:"string",...E(e)})}function oz(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...E(e)})}function Ri(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...E(e)})}function Zl(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...E(e)})}function cz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(e)})}function lz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(e)})}function uz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(e)})}function hz(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...E(e)})}function dz(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...E(e)})}function fz(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(e)})}function pz(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...E(e)})}function yz(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(e)})}function mz(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...E(e)})}function gz(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...E(e)})}function wz(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(e)})}function bz(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(e)})}function vz(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(e)})}function zz(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(e)})}function Oz(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(e)})}function Tz(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...E(e)})}function kz(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...E(e)})}function Sz(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...E(e)})}function Nz(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...E(e)})}function Ez(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(e)})}function Az(t,e){return new t({type:"string",format:"date",check:"string_format",...E(e)})}function xz(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...E(e)})}function Iz(t,e){return new t({type:"string",format:"duration",check:"string_format",...E(e)})}function Cz(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...E(e)})}function jz(t,e){return new t({type:"boolean",...E(e)})}function Mz(t){return new t({type:"unknown"})}function $z(t,e){return new t({type:"never",...E(e)})}function Di(t,e){return new jl({check:"less_than",...E(e),value:t,inclusive:!1})}function Hn(t,e){return new jl({check:"less_than",...E(e),value:t,inclusive:!0})}function Li(t,e){return new Ml({check:"greater_than",...E(e),value:t,inclusive:!1})}function Wn(t,e){return new Ml({check:"greater_than",...E(e),value:t,inclusive:!0})}function Bi(t,e){return new Qb({check:"multiple_of",...E(e),value:t})}function Rl(t,e){return new tv({check:"max_length",...E(e),maximum:t})}function hn(t,e){return new rv({check:"min_length",...E(e),minimum:t})}function Dl(t,e){return new nv({check:"length_equals",...E(e),length:t})}function Uz(t,e){return new sv({check:"string_format",format:"regex",...E(e),pattern:t})}function _z(t){return new av({check:"string_format",format:"lowercase",...E(t)})}function Pz(t){return new iv({check:"string_format",format:"uppercase",...E(t)})}function Zz(t,e){return new ov({check:"string_format",format:"includes",...E(e),includes:t})}function Rz(t,e){return new cv({check:"string_format",format:"starts_with",...E(e),prefix:t})}function Dz(t,e){return new lv({check:"string_format",format:"ends_with",...E(e),suffix:t})}function Ur(t){return new uv({check:"overwrite",tx:t})}function Lz(t){return Ur(e=>e.normalize(t))}function Bz(){return Ur(t=>t.trim())}function Fz(){return Ur(t=>t.toLowerCase())}function qz(){return Ur(t=>t.toUpperCase())}function Yz(t,e,r){return new t({type:"array",element:e,...E(r)})}function Vz(t,e,r){return new t({type:"custom",check:"custom",fn:e,...E(r)})}function Hz(t){const e=Wz(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(gr(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(gr(s))}},t(r.value,r)));return e}function Wz(t,e){const r=new ie({check:"custom",...E(e)});return r._zod.check=t,r}const Gz=p("ZodISODateTime",(t,e)=>{kv.init(t,e),q.init(t,e)});function Kz(t){return Ez(Gz,t)}const Jz=p("ZodISODate",(t,e)=>{Sv.init(t,e),q.init(t,e)});function Xz(t){return Az(Jz,t)}const Qz=p("ZodISOTime",(t,e)=>{Nv.init(t,e),q.init(t,e)});function eO(t){return xz(Qz,t)}const tO=p("ZodISODuration",(t,e)=>{Ev.init(t,e),q.init(t,e)});function rO(t){return Iz(tO,t)}const nO=(t,e)=>{Nl.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>yb(t,r)},flatten:{value:r=>pb(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,js,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,js,2)}},isEmpty:{get(){return t.issues.length===0}}})},we=p("ZodError",nO,{Parent:Error}),sO=Ca(we),aO=ja(we),iO=On(we),oO=Tn(we),cO=wb(we),lO=bb(we),uO=vb(we),hO=zb(we),dO=Ob(we),fO=Tb(we),pO=kb(we),yO=Sb(we),W=p("ZodType",(t,e)=>(V.init(t,e),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone(Et(e,{checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]})),t.clone=(r,n)=>at(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>sO(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>iO(t,r,n),t.parseAsync=async(r,n)=>aO(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>oO(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>cO(t,r,n),t.decode=(r,n)=>lO(t,r,n),t.encodeAsync=async(r,n)=>uO(t,r,n),t.decodeAsync=async(r,n)=>hO(t,r,n),t.safeEncode=(r,n)=>dO(t,r,n),t.safeDecode=(r,n)=>fO(t,r,n),t.safeEncodeAsync=async(r,n)=>pO(t,r,n),t.safeDecodeAsync=async(r,n)=>yO(t,r,n),t.refine=(r,n)=>t.check(cT(r,n)),t.superRefine=r=>t.check(lT(r)),t.overwrite=r=>t.check(Ur(r)),t.optional=()=>Yi(t),t.nullable=()=>Vi(t),t.nullish=()=>Yi(Vi(t)),t.nonoptional=r=>tT(t,r),t.array=()=>BO(t),t.or=r=>$a([t,r]),t.and=r=>VO(t,r),t.transform=r=>Hi(t,GO(r)),t.default=r=>XO(t,r),t.prefault=r=>eT(t,r),t.catch=r=>nT(t,r),t.pipe=r=>Hi(t,r),t.readonly=()=>iT(t),t.describe=r=>{const n=t.clone();return en.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return en.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return en.get(t);const n=t.clone();return en.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Ll=p("_ZodString",(t,e)=>{Ma.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(Uz(...n)),t.includes=(...n)=>t.check(Zz(...n)),t.startsWith=(...n)=>t.check(Rz(...n)),t.endsWith=(...n)=>t.check(Dz(...n)),t.min=(...n)=>t.check(hn(...n)),t.max=(...n)=>t.check(Rl(...n)),t.length=(...n)=>t.check(Dl(...n)),t.nonempty=(...n)=>t.check(hn(1,...n)),t.lowercase=n=>t.check(_z(n)),t.uppercase=n=>t.check(Pz(n)),t.trim=()=>t.check(Bz()),t.normalize=(...n)=>t.check(Lz(...n)),t.toLowerCase=()=>t.check(Fz()),t.toUpperCase=()=>t.check(qz())}),mO=p("ZodString",(t,e)=>{Ma.init(t,e),Ll.init(t,e),t.email=r=>t.check(oz(gO,r)),t.url=r=>t.check(hz(bO,r)),t.jwt=r=>t.check(Nz($O,r)),t.emoji=r=>t.check(dz(vO,r)),t.guid=r=>t.check(Ri(Fi,r)),t.uuid=r=>t.check(Zl(lr,r)),t.uuidv4=r=>t.check(cz(lr,r)),t.uuidv6=r=>t.check(lz(lr,r)),t.uuidv7=r=>t.check(uz(lr,r)),t.nanoid=r=>t.check(fz(zO,r)),t.guid=r=>t.check(Ri(Fi,r)),t.cuid=r=>t.check(pz(OO,r)),t.cuid2=r=>t.check(yz(TO,r)),t.ulid=r=>t.check(mz(kO,r)),t.base64=r=>t.check(Tz(CO,r)),t.base64url=r=>t.check(kz(jO,r)),t.xid=r=>t.check(gz(SO,r)),t.ksuid=r=>t.check(wz(NO,r)),t.ipv4=r=>t.check(bz(EO,r)),t.ipv6=r=>t.check(vz(AO,r)),t.cidrv4=r=>t.check(zz(xO,r)),t.cidrv6=r=>t.check(Oz(IO,r)),t.e164=r=>t.check(Sz(MO,r)),t.datetime=r=>t.check(Kz(r)),t.date=r=>t.check(Xz(r)),t.time=r=>t.check(eO(r)),t.duration=r=>t.check(rO(r))});function ge(t){return iz(mO,t)}const q=p("ZodStringFormat",(t,e)=>{B.init(t,e),Ll.init(t,e)}),gO=p("ZodEmail",(t,e)=>{yv.init(t,e),q.init(t,e)}),Fi=p("ZodGUID",(t,e)=>{fv.init(t,e),q.init(t,e)}),lr=p("ZodUUID",(t,e)=>{pv.init(t,e),q.init(t,e)});function wO(t){return Zl(lr,t)}const bO=p("ZodURL",(t,e)=>{mv.init(t,e),q.init(t,e)}),vO=p("ZodEmoji",(t,e)=>{gv.init(t,e),q.init(t,e)}),zO=p("ZodNanoID",(t,e)=>{wv.init(t,e),q.init(t,e)}),OO=p("ZodCUID",(t,e)=>{bv.init(t,e),q.init(t,e)}),TO=p("ZodCUID2",(t,e)=>{vv.init(t,e),q.init(t,e)}),kO=p("ZodULID",(t,e)=>{zv.init(t,e),q.init(t,e)}),SO=p("ZodXID",(t,e)=>{Ov.init(t,e),q.init(t,e)}),NO=p("ZodKSUID",(t,e)=>{Tv.init(t,e),q.init(t,e)}),EO=p("ZodIPv4",(t,e)=>{Av.init(t,e),q.init(t,e)}),AO=p("ZodIPv6",(t,e)=>{xv.init(t,e),q.init(t,e)}),xO=p("ZodCIDRv4",(t,e)=>{Iv.init(t,e),q.init(t,e)}),IO=p("ZodCIDRv6",(t,e)=>{Cv.init(t,e),q.init(t,e)}),CO=p("ZodBase64",(t,e)=>{jv.init(t,e),q.init(t,e)}),jO=p("ZodBase64URL",(t,e)=>{$v.init(t,e),q.init(t,e)}),MO=p("ZodE164",(t,e)=>{Uv.init(t,e),q.init(t,e)}),$O=p("ZodJWT",(t,e)=>{Pv.init(t,e),q.init(t,e)}),UO=p("ZodNumber",(t,e)=>{Ul.init(t,e),W.init(t,e),t.gt=(n,s)=>t.check(Li(n,s)),t.gte=(n,s)=>t.check(Wn(n,s)),t.min=(n,s)=>t.check(Wn(n,s)),t.lt=(n,s)=>t.check(Di(n,s)),t.lte=(n,s)=>t.check(Hn(n,s)),t.max=(n,s)=>t.check(Hn(n,s)),t.int=n=>t.check(dn(n)),t.safe=n=>t.check(dn(n)),t.positive=n=>t.check(Li(0,n)),t.nonnegative=n=>t.check(Wn(0,n)),t.negative=n=>t.check(Di(0,n)),t.nonpositive=n=>t.check(Hn(0,n)),t.multipleOf=(n,s)=>t.check(Bi(n,s)),t.step=(n,s)=>t.check(Bi(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}),_O=p("ZodNumberFormat",(t,e)=>{Zv.init(t,e),UO.init(t,e)});function dn(t){return Cz(_O,t)}const PO=p("ZodBoolean",(t,e)=>{Rv.init(t,e),W.init(t,e)});function _r(t){return jz(PO,t)}const ZO=p("ZodUnknown",(t,e)=>{Dv.init(t,e),W.init(t,e)});function qi(){return Mz(ZO)}const RO=p("ZodNever",(t,e)=>{Lv.init(t,e),W.init(t,e)});function DO(t){return $z(RO,t)}const LO=p("ZodArray",(t,e)=>{Bv.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(Rl(r,n)),t.length=(r,n)=>t.check(Dl(r,n)),t.unwrap=()=>t.element});function BO(t,e){return Yz(LO,t,e)}const FO=p("ZodObject",(t,e)=>{qv.init(t,e),W.init(t,e),R(t,"shape",()=>e.shape),t.keyof=()=>HO(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:qi()}),t.loose=()=>t.clone({...t._zod.def,catchall:qi()}),t.strict=()=>t.clone({...t._zod.def,catchall:DO()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>lb(t,r),t.safeExtend=r=>ub(t,r),t.merge=r=>hb(t,r),t.pick=r=>ob(t,r),t.omit=r=>cb(t,r),t.partial=(...r)=>db(Bl,t,r[0]),t.required=(...r)=>fb(Fl,t,r[0])});function ee(t,e){const r={type:"object",shape:t??{},...E(e)};return new FO(r)}const qO=p("ZodUnion",(t,e)=>{Yv.init(t,e),W.init(t,e),t.options=e.options});function $a(t,e){return new qO({type:"union",options:t,...E(e)})}const YO=p("ZodIntersection",(t,e)=>{Vv.init(t,e),W.init(t,e)});function VO(t,e){return new YO({type:"intersection",left:t,right:e})}const $s=p("ZodEnum",(t,e)=>{Hv.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 $s({...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 $s({...e,checks:[],...E(s),entries:i})}});function HO(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new $s({type:"enum",entries:r,...E(e)})}const WO=p("ZodTransform",(t,e)=>{Wv.init(t,e),W.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vl(t.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(gr(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(gr(o))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(i=>(r.value=i,r)):(r.value=s,r)}});function GO(t){return new WO({type:"transform",transform:t})}const Bl=p("ZodOptional",(t,e)=>{Gv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Yi(t){return new Bl({type:"optional",innerType:t})}const KO=p("ZodNullable",(t,e)=>{Kv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Vi(t){return new KO({type:"nullable",innerType:t})}const JO=p("ZodDefault",(t,e)=>{Jv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function XO(t,e){return new JO({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Tl(e)}})}const QO=p("ZodPrefault",(t,e)=>{Xv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function eT(t,e){return new QO({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Tl(e)}})}const Fl=p("ZodNonOptional",(t,e)=>{Qv.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function tT(t,e){return new Fl({type:"nonoptional",innerType:t,...E(e)})}const rT=p("ZodCatch",(t,e)=>{ez.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function nT(t,e){return new rT({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const sT=p("ZodPipe",(t,e)=>{tz.init(t,e),W.init(t,e),t.in=e.in,t.out=e.out});function Hi(t,e){return new sT({type:"pipe",in:t,out:e})}const aT=p("ZodReadonly",(t,e)=>{rz.init(t,e),W.init(t,e),t.unwrap=()=>t._zod.def.innerType});function iT(t){return new aT({type:"readonly",innerType:t})}const oT=p("ZodCustom",(t,e)=>{nz.init(t,e),W.init(t,e)});function cT(t,e={}){return Vz(oT,t,e)}function lT(t){return Hz(t)}const Sn=a.z.string(),Pr=t=>St.statusZ(t),ql=t=>Pr(t).omit({labels:!0}).partial({key:!0}),Us="sy_status_set",uT="sy_status_delete",Yl=H("status"),hT=Yl(""),$e=t=>t?JSON.parse(t):{},Ua=ee({key:ge(),type:ge(),config:Oe.unknownZ.or(ge().transform($e))}),Vl=Ua.extend({position:ya.xy}),_s=ee({param:ge(),node:ge()}),_a=ee({source:_s,target:_s}),dT=ee({nodes:Ua.array(),edges:_a.array()}),Hl=ee({nodes:Vl.array(),edges:_a.array()}),Wl=ee({raw:ge()}),Zr=wO(),Gl=ee({running:_r()}),Kl=Pr(Gl),Nn=ee({key:Zr,name:ge(),graph:Hl,text:Wl,deploy:_r(),version:ge(),status:Kl.optional().nullable()}),Jl=Nn.partial({key:!0}).omit({status:!0}),fT="arc",Xl=H("arc"),pT=Xl(""),yT=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let s=v.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}},he=(t,e,r,n)=>{if(n){if(r.length===0)throw new Bt(`${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}`)}},mT="sy_arc_set",gT="sy_arc_delete",wT=ee({keys:Zr.array().optional(),names:ge().array().optional(),searchTerm:ge().optional(),limit:dn().optional(),offset:dn().optional(),includeStatus:_r().optional()}),bT=ee({arcs:Jl.array()}),vT=ee({keys:Zr.array()}),zT=ee({arcs:v.nullableZ(Nn)}),OT=ee({arcs:Nn.array()}),TT=ee({}),Ps=ee({content:ge()}),kT=ee({key:Zr,includeStatus:_r().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),ST=ee({name:ge(),includeStatus:_r().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),Ql=$a([kT,ST]),NT=$a([Ql,wT]);let eu=class{client;streamClient;constructor(t,e){this.client=t,this.streamClient=e}async create(t){const e=Array.isArray(t),r=await w(this.client,"/arc/create",{arcs:v.toArray(t)},bT,OT);return e?r.arcs:r.arcs[0]}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,"/arc/retrieve",t,NT,zT);return he("Arc",t,r.arcs,e),e?r.arcs[0]:r.arcs}async delete(t){await w(this.client,"/arc/delete",{keys:v.toArray(t)},vT,TT)}async openLSP(){return await this.streamClient.stream("/arc/lsp",Ps,Ps)}};const ET=Object.freeze(Object.defineProperty({__proto__:null,Client:eu,DELETE_CHANNEL_NAME:gT,ONTOLOGY_TYPE:fT,SET_CHANNEL_NAME:mT,TYPE_ONTOLOGY_ID:pT,arcZ:Nn,edgeZ:_a,graphNodeZ:Vl,graphZ:Hl,handleZ:_s,irNodeZ:Ua,irZ:dT,keyZ:Zr,lspMessageZ:Ps,newZ:Jl,ontologyID:Xl,singleRetrieveArgsZ:Ql,statusDetailsZ:Gl,statusZ:Kl,textZ:Wl},Symbol.toStringTag,{value:"Module"})),Wi="Channel key must be a valid uint32.",Z=a.z.uint32().or(a.z.string().refine(t=>!isNaN(Number(t)),{message:Wi}).transform(Number).refine(t=>t<vs.MAX_UINT32,{message:Wi})),tu=/^[a-zA-Z_][a-zA-Z0-9_]*$/,De=a.z.string().min(1,"Name must not be empty").regex(tu,"Name can only contain letters, digits, and underscores, and cannot start with a digit"),ru=["min","max","avg","none"],nu=a.z.enum(ru),Pa=a.z.object({type:nu,resetChannel:Z.optional(),duration:N.z.optional()}),su=St.statusZ(),Gt=a.z.object({name:a.z.string(),key:Z,dataType:U.z,leaseholder:Ce.uint12,index:Z,isIndex:a.z.boolean(),internal:a.z.boolean(),virtual:a.z.boolean(),alias:a.z.string().optional(),expression:a.z.string().default(""),status:su.optional(),operations:v.nullableZ(Pa),requires:v.nullableZ(Z)}),au=Gt.extend({key:Z.optional(),name:De,leaseholder:Ce.uint12.optional(),index:Z.optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().default(!1),virtual:a.z.boolean().default(!1),expression:a.z.string().default(""),operations:v.nullableZ(Pa).optional(),requires:v.nullableZ(Z).optional()}),At=a.z.union([Ce.toArray(Z),Ce.toArray(De),Ce.toArray(Gt).transform(t=>t.map(e=>e.key))]),Za=H("channel"),AT=Za(0),xT=/[a-zA-Z0-9_]/,IT=(t,e=!1)=>{if(t==="")return e?"_":"";if(t.match(tu))return t;let r="";for(const n of t)n.match(xT)?r+=n:r+="_";return r[0].match(/^\d/)&&(r=`_${r}`),r},CT=new Error("request for lock canceled");var jT=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 MT{constructor(e,r=CT){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=iu(this._queue,c=>r<=c.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return jT(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]=[]),$T(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 $T(t,e){const r=iu(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function iu(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var UT=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 _T{constructor(e){this._semaphore=new MT(1,e)}acquire(){return UT(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 it=Gc.keyZ,Rr=Gc.labelZ,PT="labeled_by",ZT="sy_label_set",RT="sy_label_delete",ou=Rr.extend({key:it.optional()}),DT=a.object({labels:ou.array()}),LT=a.object({labels:Rr.array()}),BT=a.object({keys:it.array()}),cu=a.object({id:L,labels:it.array(),replace:a.boolean().optional()}),FT=cu.omit({replace:!0}),Gn=a.object({}),qT=a.object({keys:it.array().optional(),names:a.string().array().optional(),for:L.optional(),searchTerm:a.string().optional(),offset:a.int().optional(),limit:a.int().optional()}),YT=a.object({key:it}).transform(({key:t})=>({keys:[t]})),VT=a.union([YT,qT]),HT=a.object({labels:v.nullableZ(Rr)});let lu=class{type="label";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/label/retrieve",t,VT,HT);return he("Label",t,r.labels,e),e?r.labels[0]:r.labels}async label(t,e,r={}){await w(this.client,"/label/set",{id:t,labels:e,replace:r.replace},cu,Gn)}async remove(t,e){await w(this.client,"/label/remove",{id:t,labels:e},FT,Gn)}async create(t){const e=Array.isArray(t),r=await w(this.client,"/label/create",{labels:v.toArray(t)},DT,LT);return e?r.labels:r.labels[0]}async delete(t){await w(this.client,"/label/delete",{keys:v.toArray(t)},BT,Gn)}};const uu=H("label"),WT=uu(""),GT=Object.freeze(Object.defineProperty({__proto__:null,Client:lu,DELETE_CHANNEL_NAME:RT,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:PT,SET_CHANNEL_NAME:ZT,TYPE_ONTOLOGY_ID:WT,keyZ:it,labelZ:Rr,newZ:ou,ontologyID:uu},Symbol.toStringTag,{value:"Module"})),J=a.z.uuid(),Ra=a.z.string().min(1),Dr=a.z.object({key:J,name:Ra,timeRange:D.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()<=vs.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()>=vs.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:Rr.array().or(a.z.null().transform(()=>{})).optional(),get parent(){return Dr.optional().nullable().transform(t=>t===void 0?null:t)}}),hu=Dr.omit({parent:!0,labels:!0}).partial({key:!0}),KT=a.z.object({nodeKey:Ce.uint12.optional(),keys:Z.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),rangeKey:J.optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),dataTypes:U.z.array().optional(),notDataTypes:U.z.array().optional(),virtual:a.z.boolean().optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional(),legacyCalculated:a.z.boolean().optional()}),JT=a.z.object({channels:v.nullableZ(Gt)}),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]),yT(t,{number:"keys",string:"names"}));class Da{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){return(await w(this.client,"/channel/retrieve",e,KT,JT)).channels}}class La{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 du{mu=new _T;requests=new Map;wrapped;debouncedRun;constructor(e,r){this.wrapped=e,this.debouncedRun=_m(()=>{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 fu=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 nt(`Could not find channels: ${JSON.stringify(s)}`);return n},XT="sy_channel_set",QT="sy_channel_delete";class Zs{_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:T=[],requires:I=[]}){this.key=Z.parse(s),this.name=r,this.dataType=new U(e),this.leaseholder=n,this.index=Z.parse(o),this.isIndex=i,this.internal=c,this.alias=h,this.virtual=l,this.expression=d,this.operations=T,this.requires=I,f!=null&&(this.status=St.create(f)),this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new Y("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Gt.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 wr(this.payload)}get ontologyID(){return Za(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 ek="sy_calculation_status",tk=a.z.object({}),rk=a.z.object({group:bn});let pu=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=v.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 he("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(v.toArray(t),v.toArray(e))}createDebouncedBatchRetriever(t=10){return new La(new du(new Da(this.client),t))}sugar(t){const{frameClient:e}=this;return Array.isArray(t)?t.map(r=>new Zs({...r,frameClient:e})):new Zs({...t,frameClient:e})}async retrieveGroup(){return(await w(this.client,"/channel/retrieve-group",{},tk,rk)).group}};const wr=({virtual:t,expression:e})=>t&&e!=="",nk=t=>wr(t)&&t.requires.length>0,yu=async(t,e)=>{if(!wr(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(wr(n)){const s=await yu(t,n);if(s!=null)return s}}return null},sk=a.z.object({channels:au.array()}),ak=a.z.object({channels:Gt.array()}),ik=a.z.object({keys:Z.array().optional(),names:De.array().optional()}),ok=a.z.object({}),ck=a.z.object({keys:Z.array(),names:De.array()}),lk=a.z.object({});let mu=class{client;cache;constructor(t,e){this.client=t,this.cache=e}async create(t){const{channels:e}=await w(this.client,"/channel/create",{channels:t.map(r=>({...r,dataType:r.dataType}))},sk,ak);return this.cache.set(e),e}async delete(t){const e=Z.array().parse(t.keys??[]);await w(this.client,"/channel/delete",t,ik,ok),e.length>0&&this.cache.delete(e),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await w(this.client,"/channel/rename",{keys:t,names:e},ck,lk),this.cache.rename(t,e)}};const uk=Object.freeze(Object.defineProperty({__proto__:null,CALCULATION_STATUS_CHANNEL_NAME:ek,CacheRetriever:La,Channel:Zs,Client:pu,ClusterRetriever:Da,DELETE_CHANNEL_NAME:QT,DebouncedBatchRetriever:du,OPERATION_TYPES:ru,SET_CHANNEL_NAME:XT,TYPE_ONTOLOGY_ID:AT,Writer:mu,analyzeParams:ve,escapeInvalidName:IT,isCalculated:wr,isLegacyCalculated:nk,keyZ:Z,nameZ:De,newZ:au,ontologyID:Za,operationType:nu,operationZ:Pa,paramsZ:At,payloadZ:Gt,resolveLegacyCalculatedIndex:yu,retrieveRequired:fu,statusZ:su},Symbol.toStringTag,{value:"Module"})),hk=a.z.object({username:a.z.string(),password:a.z.string()}),dk=a.z.object({token:a.z.string(),user:$r}),Gi="/auth/login",fk=3,pk=a.z.object({username:a.z.string(),password:a.z.string(),newPassword:a.z.string().min(1)}),yk=a.z.object({}),mk=[xs,Is];let gk=class{client;credentials;authState={authenticated:!1};authenticating;retryCount;constructor(t,e){this.client=t,this.credentials=e,this.retryCount=0}get authenticated(){return this.authState.authenticated}get user(){return this.authState.authenticated?this.authState.user:void 0}get token(){return this.authState.authenticated?this.authState.token:void 0}async retrieveUser(){this.authState.authenticated||await this.authenticating;const{authState:t}=this;if(!t.authenticated)throw new Error("Authentication failed: user not available");return t.user}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,"/auth/change-password",{username:this.credentials.username,password:this.credentials.password,newPassword:t},pk,yk),this.credentials.password=t}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(Gi)){this.authenticating??=new Promise((o,c)=>{this.client.send(Gi,this.credentials,hk,dk).then(([l,u])=>{if(u!=null)return o(u);if(l==null)return o(new Error("No response from login"));this.authState={authenticated:!0,user:l.user,token:l.token},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 mk.some(i=>i.matches(s))&&this.retryCount<fk?(this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,s])};return t}};const wk=a.z.enum(["disconnected","connecting","connected","failed"]),bk=a.z.object({status:wk,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()}),vk=a.z.object({clusterKey:a.z.string(),nodeVersion:a.z.string().optional()}),zk=a.z.void(),Ki={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.49.0"},Ji=(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 Rs{static DEFAULT=Ki;_state;pollFrequency=N.seconds(30);client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=bk;versionWarned=!1;constructor(e,r=N.seconds(30),n,s){this._state={...Ki},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 w(this.client,"/connectivity/check",void 0,zk,vk),n=r.nodeVersion,s=this.clientVersion,i=this.versionWarned;n==null?(this._state.clientServerCompatible=!1,i||(console.warn(Ji(null,s,!0)),this.versionWarned=!0)):Ti.versionsEqual(s,n,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,i||(console.warn(Ji(n,s,Ti.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 Ok=a.z.object({keys:Z.array().optional(),bounds:D.z,names:De.array().optional()}),Tk=a.z.object({});class kk{client;constructor(e){this.client=e}async delete(e){await w(this.client,"/frame/delete",e,Ok,Tk)}}const Xi=t=>{const e=v.toArray(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Qi=(t,e)=>{const r=v.toArray(t);if(r.length===e.length)return;const n=Xi(t);throw Xi===null?new Y("[Frame] - channel keys or names must be provided when constructing a frame."):new Y(`[Frame] - ${n}s and series must be the same length.
43
- Got ${r.length} ${n}s and ${e.length} series.`)};let ce=class ut{columns=[];series=[];constructor(e=[],r=[]){if(e instanceof ut){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,s)=>this.push(s,...v.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=>gu(i));Qi(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,...v.toArray(s));this.push(n,...v.toArray(s))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=v.toArray(r),s=v.toArray(e);Qi(s,n),n.forEach((i,o)=>this.push(s[o],i));return}throw new Y(`[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 ue("colType is not key");return this.columns??[]}get uniqueKeys(){return gi.unique(this.keys)}get names(){if(this.colType==="key")throw new ue("colType is not name");return this.columns??[]}get uniqueNames(){return gi.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>wu(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 D.ZERO;const n=C.min(...this.series.map(i=>i.timeRange.start)),s=C.max(...this.series.map(i=>i.timeRange.end));return new D(n,s)}const r=this.get(e);return r==null?D.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 mm(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof ut){if(e.colType!=null&&this.colType!==null&&e.colType!==this.colType)throw new Y("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 Y("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new Y("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new ut([...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 ut;return this.forEach((n,s,i)=>r.push(...e(n,s,i))),r}mapFilter(e){const r=new ut;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)})}forEachUnique(e){this.uniqueColumns.forEach((r,n)=>e(r,this.get(r),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 ut;return this.columns.forEach((n,s)=>{const i=this.series[s];e(n,i,s)&&r.push(n,i)}),r}get byteLength(){return new Lt(this.series.reduce((e,r)=>e.add(r.byteLength),Lt.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 En=a.z.object({keys:a.z.union([a.z.null().transform(()=>[]),a.z.number().array().default([])]),series:a.z.union([a.z.null().transform(()=>[]),Qe.crudeZ.array().default([])])}),gu=t=>{const{dataType:e,data:r,timeRange:n,alignment:s}=t;return new Qe({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},wu=t=>({timeRange:t.timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});var Ie=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.SetAuthority=3]="SetAuthority",t))(Ie||{});const eo=t=>t.data.byteLength/t.dataType.density.valueOf(),Sk=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)},to=5,ro=4,no=3,so=2,ao=1,io=0,ke=U.TIMESTAMP.density.valueOf(),Ve=8,He=4,Kn=4,Jn=4,Nk=1;class bu{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 Y(`
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()),Sk(n);let s=-1,i,o,c,l=r+Nk+Jn,u=!this.currState?.hasVariableDataTypes,h=!0,f=!0,d=!0,T=!0,I=!0;n.keys.length!==this.currState?.keys.length&&(d=!1,l+=n.keys.length*Kn),n.series.forEach((x,G)=>{const ne=eo(x),Xt=n.keys[G],ct=this.currState?.keyDataTypes.get(Xt);if(ct==null)throw new Y(`Channel ${Xt} was not provided in the list of channels when opening the writer`);if(!ct.equals(x.dataType))throw new Y(`Series data type of ${x.dataType.toString()} does not match the data type of ${ct.toString()} for channel ${Xt}`);if(l+=x.data.byteLength,s===-1){s=ne,i=x.timeRange?.start,o=x.timeRange?.end,c=BigInt(x.alignment??0n);return}s!==ne&&(u=!1),(i?.valueOf()!==x.timeRange?.start.valueOf()||o?.valueOf()!==x.timeRange?.end.valueOf())&&(h=!1),c!==BigInt(x.alignment??0)&&(T=!1)}),f=h&&i==null&&o==null,I=T&&(c===void 0||c===0n),u?l+=He:l+=n.keys.length*He,f||(h?l+=ke*2:l+=n.keys.length*ke*2),I||(T?l+=Ve:l+=n.keys.length*Ve);const $=new Uint8Array(l),b=new DataView($.buffer);let k=r;return $[k]=Number(I)<<to|Number(T)<<ro|Number(u)<<no|Number(h)<<so|Number(f)<<ao|Number(d)<<io,k++,b.setUint32(k,this.seqNum,!0),k+=Jn,u&&(b.setUint32(k,s,!0),k+=He),h&&!f&&(b.setBigUint64(k,i?.valueOf()??0n,!0),b.setBigUint64(k,o?.valueOf()??0n,!0),k+=ke*2),T&&!I&&(b.setBigUint64(k,c??0n,!0),k+=Ve),n.series.forEach((x,G)=>{if(d||(b.setUint32(k,n.keys[G],!0),k+=Kn),!u){let ne=x.data.byteLength;x.dataType.isVariable||(ne=eo(x)),b.setUint32(k,ne,!0),k+=He}$.set(new Uint8Array(x.data),k),k+=x.data.byteLength,!h&&!f&&(b.setBigUint64(k,x.timeRange?.start.valueOf()??0n,!0),b.setBigUint64(k,x.timeRange?.end.valueOf()??0n,!0),k+=ke*2),!T&&!I&&(b.setBigUint64(k,x.alignment??0n,!0),k+=Ve)}),$}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]>>to&1),T=!!(n[i]>>ro&1),I=!!(n[i]>>no&1),$=!!(n[i]>>so&1),b=!!(n[i]>>ao&1),k=!!(n[i]>>io&1);i++;const x=f.getUint32(i,!0);i+=Jn;const G=this.states.get(x);if(G==null)return s;if(I){if(i+He>f.byteLength)return s;o=f.getUint32(i,!0),i+=He}if($&&!b){if(i+ke>f.byteLength)return s;l=new C(f.getBigUint64(i,!0)),i+=ke,u=new C(f.getBigUint64(i,!0)),i+=ke}if(T&&!d){if(i+Ve>f.byteLength)return s;h=f.getBigUint64(i,!0),i+=Ve}return k&&(s.keys=[...G.keys]),G.keys.forEach((ne,Xt)=>{if(!k){if(i>=f.byteLength||f.getUint32(i,!0)!==ne)return;i+=Kn,s.keys.push(ne)}const ct=G.keyDataTypes.get(ne);if(c=0,I)c=o;else{if(i+He>f.byteLength)return;c=f.getUint32(i,!0),i+=He}let qr=c;if(ct.isVariable||(qr*=ct.density.valueOf()),i+qr>f.byteLength){s.keys.splice(Xt,1);return}const lt={dataType:ct,data:n.slice(i,i+qr).buffer};if(i+=qr,!$&&!b){if(i+ke*2>f.byteLength)return;const sd=f.getBigUint64(i,!0);i+=ke;const ad=f.getBigUint64(i,!0);i+=ke,lt.timeRange=new D({start:sd,end:ad})}else b?lt.timeRange=new D({start:0n,end:0n}):lt.timeRange=new D({start:l?.valueOf()??0n,end:u?.valueOf()??0n});if(!T&&!d){if(i+Ve>f.byteLength)return;h=f.getBigUint64(i,!0),i+=Ve,lt.alignment=h}else d?lt.alignment=0n:lt.alignment=h;s.series.push(lt)}),s}}const Ba=254,Ek=new Uint8Array([Ba]),Ak=255,xk=new Uint8Array([Ak]),vu="application/sy-framer";class Ik{contentType=vu;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Ot.JSON_CODEC}encode(e){const r=e;if(r.type=="close"||r.payload?.command!=Ie.Write){const s=this.lowPerfCodec.encode(r),i=new Uint8Array({length:s.byteLength+1});return i.set(Ek,0),i.set(new Uint8Array(s),1),i}const n=this.base.encode(r.payload?.frame,1);return n.set(xk,0),n}decode(e,r){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Ba)return this.lowPerfCodec.decode(e.slice(1),r);const n={type:"data"},s=this.base.decode(e,1);return n.payload={command:Ie.Write,frame:s},n}}class Ck{contentType=vu;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Ot.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,r){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Ba?this.lowPerfCodec.decode(e.slice(1),r):{type:"data",payload:{frame:this.base.decode(e,1)}}}}class An{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=new Set,this.codec=new bu}static async open(e,r){const n=new An(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(wi.uniqueUnorderedPrimitiveArrays(Array.from(this.keys),i)===wi.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 Fa{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new bu}static async open(e,r){const n=new Fa(e);return await n.update(r),n}async adaptParams(e){const r=At.parse(e);return await Promise.all(r.map(async n=>await this.adaptToKey(n)))}async update(e){const r=await fu(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 Y(`
51
- Received a single channel name or key but no series.
52
- `);if(Array.isArray(r)){if(r.some(l=>l instanceof Qe||Array.isArray(l)))throw new Y(`
53
- Received a single channel name or key but multiple series.
54
- `);r=r}const o=await this.fetchChannel(e),c=new Qe({data:r,dataType:o.dataType});return new ce(o.key,c)}if(Array.isArray(e)){if(r==null)throw new Y(`
55
- Received an array of channel names or keys but no series.
56
- `);if(!Array.isArray(r))throw new Y(`
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 Y(`
59
- Received an array of channel names or keys but not enough series.
60
- `);const h=new Qe({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 Y(`
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 Qe({data:l,dataType:u.dataType});n.push(u.key),s.push(h)}return new ce(n,s)}}class zu{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 fn=new N(-1);var qa=(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))(qa||{}),Ou=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(Ou||{});const jk=a.z.object({command:a.z.enum(qa),span:N.z.optional(),bounds:D.z.optional(),stamp:C.z.optional(),keys:Z.array().optional(),chunkSize:a.z.number().optional()}),Mk=a.z.object({variant:a.z.enum(Ou),ack:a.z.boolean(),command:a.z.enum(qa),error:Le.payloadZ.optional().nullable(),frame:En.optional()});class xn{stream;adapter;value;constructor(e,r){this.stream=new zu("Iterator",e),this.value=new ce,this.adapter=r}static async _open(e,r,n,s,i={}){const o=await An.open(n,r),c=await s.stream("/frame/iterate",jk,Mk),l=new xn(c,o);return await l.execute({command:0,keys:Array.from(o.keys),bounds:new D(e),chunkSize:i.chunkSize??1e5}),l}async next(e=fn){return await this.execute({command:1,span:new N(e)})}async prev(e=fn){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 $k(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 $k{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 Uk=a.z.object({keys:a.z.number().array(),downsampleFactor:a.z.int(),throttleRate:gt.z.optional()}),_k=a.z.object({frame:En}),oo=a.z.object({channels:At,downsampleFactor:a.z.int().default(1),throttleRate:gt.z.default(new gt(0)),useHighPerformanceCodec:a.z.boolean().default(!0)}),Ya=oo.or(At.transform(t=>oo.parse({channels:t}))),Tu=(t,e)=>async r=>{const n=Ya.parse(r),s=await An.open(t,n.channels);n.useHighPerformanceCodec&&(e=e.withCodec(new Ck(s.codec)));const i=await e.stream("/frame/stream",Uk,_k),o=new Pk(i,s,n.downsampleFactor,n.throttleRate);i.send({keys:Array.from(s.keys),downsampleFactor:n.downsampleFactor,throttleRate:n.throttleRate});const[,c]=await i.receive();if(c!=null)throw c;return o},ku=async(t,e,r)=>await Tu(t,e)(r);class Pk{stream;adapter;downsampleFactor;throttleRate;constructor(e,r,n=1,s=new gt(0)){this.stream=new zu("Streamer",e),this.adapter=r,this.downsampleFactor=n,this.throttleRate=s}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,throttleRate:this.throttleRate})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class In{wrapped_=null;breaker;opener;config;constructor(e,r,n={}){this.opener=e,this.config=Ya.parse(r);const{maxRetries:s=5e3,baseInterval:i=N.seconds(1),scale:o=1}=n??{};this.breaker=new wa.Breaker({maxRetries:s,baseInterval:i,scale:o})}static async open(e,r,n){const s=new In(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=At.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 Su extends cg.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 br=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(br||{});const Zk=new N(-1);class Ds extends je.sub("writer_closed"){constructor(){super("WriterClosed")}}const Rk=a.z.enum(br).or(a.z.enum(["persist","stream","persistStream"]).transform(t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1}})),Nu=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:Rk.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)}),Dk=Nu.extend({keys:Z.array().optional()}),co=Nu.extend({channels:At}),Eu=co.or(At.transform(t=>co.parse({channels:t,start:C.now()}))),Lk=a.z.object({command:a.z.enum(Ie),config:Dk.optional(),frame:En.optional(),buffer:a.z.instanceof(Uint8Array).optional()}),Bk=a.z.object({command:a.z.enum(Ie),end:C.z,err:Le.payloadZ.optional()}),Fk=a.z.tuple([a.z.union([a.z.record(Z.or(De),me.authorityZ),Z.or(De),me.authorityZ]),me.authorityZ.optional()]).transform(([t,e])=>{if(me.authorityZ.safeParse(t).success)return{keys:[],authorities:[t]};if(Z.or(De).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 Au=class xu{stream;adapter;closeErr=null;constructor(e,r){this.stream=e,this.adapter=r}static async _open(e,r,n){const s=Eu.parse(n),i=await Fa.open(e,s.channels);s.useHighPerformanceCodec&&(r=r.withCodec(new Ik(i.codec)));const o=await r.stream("/frame/write",Lk,Bk),c=new xu(o,i);return await c.execute({command:Ie.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:Ie.Write,frame:n.toPayload()})}async setAuthority(e,r){if(this.closeErr!=null)throw this.closeErr;const n=Fk.parse([e,r]),s={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:Ie.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:Ie.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(Ds.matches(this.closeErr))return null;throw this.closeErr}const[r,n]=await this.stream.receive();n!=null?this.closeErr=ze.matches(n)?new Ds:n:this.closeErr=Le.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=Le.decode(n?.err);if(i!=null&&await this.closeInternal(i),n?.command==e.command)return n}}};const Iu=H("framer"),qk=Iu("");let Cu=class{streamClient;retriever;deleter;constructor(t,e,r){this.streamClient=t,this.retriever=r,this.deleter=new kk(e)}async openIterator(t,e,r){return await xn._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return await Au._open(this.retriever,this.streamClient,t)}async openStreamer(t){return await ku(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:br.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:N.MAX});return await i.write(s),await i.close()}const n=await this.openWriter({start:t,channels:e,mode:br.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(D.MAX,t,{chunkSize:e}),n=new ce;if(e>0)try{await r.seekLast(),await r.prev(fn),n.push(r.value)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=ve(t),s=new D(e);return n==="keys"?await this.deleter.delete({keys:r,bounds:s}):await this.deleter.delete({names:r,bounds:s})}};const Yk=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:Zk,AUTO_SPAN:fn,Client:Cu,Frame:ce,HardenedStreamer:In,Iterator:xn,ObservableStreamer:Su,TYPE_ONTOLOGY_ID:qk,Writer:Au,WriterClosedError:Ds,WriterCommand:Ie,WriterMode:br,createStreamOpener:Tu,frameZ:En,ontologyID:Iu,openStreamer:ku,seriesFromPayload:gu,seriesToPayload:wu,streamerConfigZ:Ya,writerConfigZ:Eu},Symbol.toStringTag,{value:"Module"})),Vk=me.ABSOLUTE_AUTHORITY,Hk=me.ZERO_AUTHORITY,Wk=me.stateZ(a.z.number()),Gk=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()})`,Kk=a.z.object({transfers:a.z.array(me.transferZ(Z))});class ju extends Su{states;codec;constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer,Kk);return this.merge(n),[n.transfers,!0]}),this.states=new Map,this.codec=new Ot.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 Mu="sy_node_1_control";let $u=class{framer;constructor(t){this.framer=t}async openStateTracker(){const t=await In.open(async e=>await this.framer.openStreamer(e),Mu);return new ju(t)}};const Jk=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:Vk,CONTROL_STATE_CHANNEL_NAME:Mu,Client:$u,StateTracker:ju,ZERO_AUTHORITY:Hk,stateZ:Wk,transferString:Gk},Symbol.toStringTag,{value:"Module"})),Te=a.z.uint32(),Uu=a.z.object({rack:Te}),_u=St.statusZ(Uu),Cn=a.z.object({key:Te,name:a.z.string(),status:Ce.nullToUndefined(_u)}),Pu=Cn.partial({key:!0}),Zu=t=>t?Ot.JSON_CODEC.decodeString(t,Oe.unknownZ):{},Kt=a.z.string(),Ru=a.z.object({rack:Te,device:Kt}),Du=St.statusZ(Ru),jn=a.z.object({key:Kt,rack:Te.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:Oe.unknownZ.or(a.z.string().transform(Zu)),status:Ce.nullToUndefined(Du)}),Lu=jn.extend({properties:a.z.unknown().transform(t=>Ot.JSON_CODEC.encodeString(t))}),Xk="sy_device_set",Qk="sy_device_delete",eS=a.z.object({devices:Lu.array()}),tS=a.z.object({devices:jn.array()}),rS=a.z.object({keys:Kt.array()}),nS=a.z.object({}),sS=a.z.object({keys:Kt.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:Te.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeStatus:a.z.boolean().optional()}),aS=a.z.object({devices:v.nullableZ(jn)}),iS=a.z.object({key:Kt,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),oS=a.z.union([iS,sS]);let Bu=class{client;constructor(t){this.client=t}async retrieve(t){const e=typeof t=="object"&&"key"in t,r=await w(this.client,"/device/retrieve",t,oS,aS);he("Device",t,r.devices,e);const n=r.devices;return e?n[0]:n}async create(t){const e=!Array.isArray(t),r=(await w(this.client,"/device/create",{devices:v.toArray(t)},eS,tS)).devices;return e?r[0]:r}async delete(t){await w(this.client,"/device/delete",{keys:v.toArray(t)},rS,nS)}};const Va=H("device"),cS=Va(""),lS=t=>Be(Va(t)),uS=Object.freeze(Object.defineProperty({__proto__:null,Client:Bu,DELETE_CHANNEL_NAME:Qk,SET_CHANNEL_NAME:Xk,TYPE_ONTOLOGY_ID:cS,deviceZ:jn,keyZ:Kt,newZ:Lu,ontologyID:Va,statusDetailsZ:Ru,statusKey:lS,statusZ:Du},Symbol.toStringTag,{value:"Module"})),hS="sy_rack_set",dS="sy_rack_delete",fS=a.z.object({keys:Te.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.int().optional(),offset:a.z.int().optional(),includeStatus:a.z.boolean().optional()}),pS=a.z.object({racks:v.nullableZ(Cn)}),yS=a.z.union([a.z.object({key:Te,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}))]),mS=fS,gS=a.z.union([yS,mS]),wS=a.z.object({racks:Pu.array()}),bS=a.z.object({racks:Cn.array()}),vS=a.z.object({keys:Te.array()}),zS=a.z.object({});let Fu=class{client;tasks;constructor(t,e){this.client=t,this.tasks=e}async delete(t){await w(this.client,"/rack/delete",{keys:v.toArray(t)},vS,zS)}async create(t){const e=!Array.isArray(t),r=await w(this.client,"/rack/create",{racks:v.toArray(t)},wS,bS),n=this.sugar(r.racks);return e?n[0]:n}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,"/rack/retrieve",t,gS,pS),n=this.sugar(r.racks);return he("Rack",t,n,e),e?n[0]:n}sugar(t){const e=!Array.isArray(t),r=v.toArray(t).map(({key:n,name:s,status:i})=>new qu(n,s,this.tasks,i));return e?r[0]:r}};class qu{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 Ha=H("rack"),OS=Ha(0),TS=t=>Be(Ha(t)),kS=Object.freeze(Object.defineProperty({__proto__:null,Client:Fu,DELETE_CHANNEL_NAME:dS,Rack:qu,SET_CHANNEL_NAME:hS,TYPE_ONTOLOGY_ID:OS,keyZ:Te,newZ:Pu,ontologyID:Ha,rackZ:Cn,statusDetailsZ:Uu,statusKey:TS,statusZ:_u},Symbol.toStringTag,{value:"Module"})),SS="sy_range_alias_set",NS="sy_range_alias_delete",ES=a.z.object({range:J,aliases:a.z.string().array()}),AS=a.z.object({aliases:a.z.record(a.z.string(),Z)}),xS=a.z.object({range:J,aliases:a.z.record(Z,a.z.string())}),IS=a.z.unknown(),CS=a.z.object({range:J,channels:Z.array()}),jS=a.z.unknown(),MS=a.z.object({range:J}),$S=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())}),US=a.z.object({range:J,channels:Z.array()}),_S=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())});class ht{cache=new Map;client;rangeKey;constructor(e,r){this.rangeKey=e,this.cache=new Map,this.client=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 w(this.client,"/range/alias/resolve",{range:this.rangeKey,aliases:r},ES,AS);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 w(this.client,"/range/alias/set",{range:this.rangeKey,aliases:e},xS,IS)}async list(){return(await w(this.client,"/range/alias/list",{range:this.rangeKey},MS,$S)).aliases}async retrieve(e){const r=typeof e=="number",n=await w(this.client,"/range/alias/retrieve",{range:this.rangeKey,channels:v.toArray(e)},US,_S);return r?n.aliases[e]:n.aliases}async delete(e){await w(this.client,"/range/alias/delete",{range:this.rangeKey,channels:v.toArray(e)},CS,jS)}}const PS=a.z.object({alias:a.z.string().optional(),channel:Z,range:J}),Yu="---",ZS=t=>`${t.range}${Yu}${t.channel}`,RS=t=>{const[e,r]=t.split(Yu);return{range:e,channel:Number(r)}},DS="sy_range_kv_set",LS="sy_range_kv_delete",Wa=a.z.object({range:J,key:a.z.string(),value:a.z.string()}),BS=({range:t,key:e})=>`${t}<--->${e}`,FS=a.z.object({range:J,keys:a.z.string().array()}),qS=a.z.object({pairs:v.nullableZ(Wa)}),YS=a.z.object({range:J,pairs:Wa.array()}),VS=a.z.object({range:J,keys:a.z.string().array()});class Ls{rangeKey;client;constructor(e,r){this.rangeKey=e,this.client=r}async get(e){const r=await w(this.client,"/range/kv/get",{range:this.rangeKey,keys:v.toArray(e)},FS,qS);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;typeof e=="string"?n=[{range:this.rangeKey,key:e,value:r}]:n=Object.entries(e).map(([s,i])=>({range:this.rangeKey,key:s,value:i})),await w(this.client,"/range/kv/set",{range:this.rangeKey,pairs:n},YS,a.z.unknown())}async delete(e){await w(this.client,"/range/kv/delete",{range:this.rangeKey,keys:v.toArray(e)},VS,a.z.unknown())}}const HS="sy_range_set",WS="sy_range_delete";class Vu{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:r=D.ZERO,key:n,color:s,parent:i,labels:o},{frameClient:c,kv:l,aliaser:u,channels:h,labelClient:f,ontologyClient:d,rangeClient:T}){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=T}get ontologyID(){return dt(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 nt(`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:dt(this.key)})}async addLabel(...e){await this.labelClient.label(dt(this.key),e)}async removeLabel(...e){await this.labelClient.remove(dt(this.key),e)}static sort(e,r){return D.sort(e.timeRange,r.timeRange)}}const GS=a.z.object({keys:J.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),overlapsWith:D.z.optional(),hasLabels:it.array().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeLabels:a.z.boolean().optional(),includeParent:a.z.boolean().optional()}),KS=GS.or(J.array().transform(t=>({keys:t}))).or(J.transform(t=>({keys:[t]}))).or(a.z.string().transform(t=>({names:[t]}))).or(a.z.string().array().transform(t=>({names:t}))).or(D.z.transform(t=>({overlapsWith:t}))),JS=a.z.object({ranges:v.nullableZ(Dr)});let Hu=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(v.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(v.toArray(t))}async retrieve(t){const e=typeof t=="string",{ranges:r}=await w(this.unaryClient,"/range/retrieve",t,KS,JS);return he("Range",t,r,e),e?this.sugarMany(r)[0]:this.sugarMany(r)}getKV(t){return new Ls(t,this.unaryClient)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents(dt(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(Wu(t))}async retrieveAlias(t,e){return await new ht(t,this.unaryClient).retrieve(e)}async retrieveAliases(t,e){return await new ht(t,this.unaryClient).retrieve(e)}async listAliases(t){return await new ht(t,this.unaryClient).list()}async setAlias(t,e,r){await new ht(t,this.unaryClient).set({[e]:r})}async deleteAlias(t,e){await new ht(t,this.unaryClient).delete(e)}sugarOne(t){return new Vu(t,{frameClient:this.frameClient,kv:new Ls(t.key,this.unaryClient),aliaser:new ht(t.key,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 D(t.data?.timeRange),color:t.data?.color,labels:[],parent:null})}};const dt=H("range"),XS=dt(""),QS=t=>({type:"range-alias",key:t}),Wu=({data:t,id:{key:e},name:r})=>{const n=D.z.parse(t?.timeRange);return{key:e,name:r,timeRange:n,color:typeof t?.color=="string"?t.color:void 0,labels:[],parent:null}},e0=a.z.object({ranges:Dr.array()}),t0=a.z.object({parent:L.optional(),ranges:hu.array()}),r0=a.z.object({keys:J.array()}),n0=a.z.object({}),s0=a.z.object({key:J,name:Ra}),a0=a.z.object({});class Gu{client;constructor(e){this.client=e}async rename(e,r){await w(this.client,"/range/rename",{key:e,name:r},s0,a0)}async create(e,r){return(await w(this.client,"/range/create",{ranges:e,...r},t0,e0)).ranges}async delete(e){await w(this.client,"/range/delete",{keys:e},r0,n0)}}const i0=Object.freeze(Object.defineProperty({__proto__:null,Aliaser:ht,Client:Hu,DELETE_ALIAS_CHANNEL_NAME:NS,DELETE_CHANNEL_NAME:WS,KV:Ls,KV_DELETE_CHANNEL:LS,KV_SET_CHANNEL:DS,Range:Vu,SET_ALIAS_CHANNEL_NAME:SS,SET_CHANNEL_NAME:HS,TYPE_ONTOLOGY_ID:XS,Writer:Gu,aliasKey:ZS,aliasOntologyID:QS,aliasZ:PS,convertOntologyResourceToPayload:Wu,decodeDeleteAliasChange:RS,keyZ:J,kvPairKey:BS,kvPairZ:Wa,nameZ:Ra,newZ:hu,ontologyID:dt,payloadZ:Dr},Symbol.toStringTag,{value:"Module"})),o0=t=>a.object({parent:L.optional(),statuses:ql(t).array()}),c0=t=>a.object({statuses:Pr(t).array()}),l0=a.object({keys:Sn.array()}),u0=a.object({}),h0=a.object({keys:Sn.array().optional(),searchTerm:a.string().optional(),offset:a.int().optional(),limit:a.int().optional(),includeLabels:a.boolean().optional(),hasLabels:it.array().optional()}),d0=a.object({key:Sn,includeLabels:a.boolean().optional()}).transform(({key:t,includeLabels:e})=>({keys:[t],includeLabels:e})),f0=a.union([d0,h0]),p0=t=>a.object({statuses:v.nullableZ(Pr(t))});let Ku=class{type="status";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/status/retrieve",t,f0,p0(t.detailsSchema));he("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 w(this.client,"/status/set",{statuses:v.toArray(t),parent:e.parent},o0(e.detailsSchema),c0(e.detailsSchema))).statuses;return r?n:n[0]}async delete(t){await w(this.client,"/status/delete",{keys:v.toArray(t)},l0,u0)}};const y0=Object.freeze(Object.defineProperty({__proto__:null,Client:Ku,DELETE_CHANNEL_NAME:uT,SET_CHANNEL_NAME:Us,TYPE_ONTOLOGY_ID:hT,keyZ:Sn,newZ:ql,ontologyID:Yl,statusZ:Pr},Symbol.toStringTag,{value:"Module"})),Fe=a.z.union([a.z.string(),a.z.bigint().transform(t=>t.toString()),a.z.number().transform(t=>t.toString())]),Ga=t=>a.z.object({task:Fe,running:a.z.boolean(),data:t,cmd:a.z.string().optional()}),Ka=t=>St.statusZ(Ga(t)),m0=t=>Ga(t).partial({task:!0}),Ju=t=>St.statusZ(m0(t)).partial({key:!0,name:!0}),Lr=(t={typeSchema:a.z.string(),configSchema:a.z.unknown(),statusDataSchema:a.z.unknown()})=>a.z.object({key:Fe,name:a.z.string(),type:t.typeSchema,internal:a.z.boolean().optional(),config:a.z.string().transform(Zu).or(t.configSchema),status:Ka(t.statusDataSchema).optional().nullable(),snapshot:a.z.boolean().optional()}),Xu=t=>Lr(t).omit({key:!0,status:!0}).extend({key:Fe.transform(e=>e.toString()).optional(),config:a.z.unknown().transform(e=>Ot.JSON_CODEC.encodeString(e)),status:Ju(t?.statusDataSchema??a.z.unknown()).optional().nullable()}),g0=a.z.object({task:Fe,type:a.z.string(),key:a.z.string(),args:Oe.unknownZ.or(a.z.string().transform($e)).or(a.z.array(a.z.unknown())).or(a.z.null()).optional()}),w0=t=>Number(BigInt(t)>>32n),Bs="sy_task_cmd",b0="sy_task_set",v0="sy_task_delete",ft=new Error("Task not created"),Qu=async(t,e)=>{const r=await e.retrieveParents(Br(t));return r.length===0?null:r[0]};class eh{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw ft;return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw ft;return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw ft;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 Br(this.key)}async executeCommand(e){return await nh({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await sh({...e,frameClient:this.frameClient,task:this.key,name:this.name,statusDataZ:this.schemas?.statusDataSchema})}async start(){await this.executeCommand({type:"start"})}async stop(){await this.executeCommand({type:"stop"})}async run(e){await this.start();try{return await e()}finally{await this.stop()}}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw ft;return this.snapshot?await Qu(this.key,this.ontologyClient):null}}const z0=a.z.object({rack:Te.optional(),keys:Fe.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.int().optional(),limit:a.z.int().optional()}),th=a.z.union([a.z.object({key:Fe,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:Te.optional()}).transform(({type:t,rack:e})=>({types:[t],rack:e}))]),O0=z0,T0=a.z.union([th,O0]),k0=t=>a.z.object({tasks:v.nullableZ(Lr(t))}),S0=t=>a.z.object({tasks:Xu(t).array()}),N0=t=>a.z.object({tasks:Lr(t).array()}),E0=a.z.object({keys:Fe.array()}),A0=a.z.object({}),x0=a.z.object({key:Fe,name:a.z.string(),snapshot:a.z.boolean()}),I0=t=>a.z.object({task:Lr(t)});let rh=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=S0(e),s=N0(e),i=await w(this.client,"/task/create",{tasks:v.toArray(t)},n,s),o=this.sugar(i.tasks,e);return r?o[0]:o}async delete(t){await w(this.client,"/task/delete",{keys:v.toArray(t)},E0,A0)}async retrieve({schemas:t,...e}){const r=th.safeParse(e).success,n=(await w(this.client,"/task/retrieve",e,T0,k0(t))).tasks,s=this.sugar(n,t);return he("Task",e,s,r),r?s[0]:s}async copy(t,e,r){const n=I0(),s=await w(this.client,"/task/copy",{key:t,name:e,snapshot:r},x0,n);return this.sugar(s.task)}async list(t){const e={internal:!1};return t!==void 0&&(e.rack=t),await this.retrieve(e)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw ft;return await Qu(t,this.ontologyClient)}sugar(t,e){const r=!Array.isArray(t),n=v.toArray(t).map(({key:s,name:i,type:o,config:c,status:l,internal:u,snapshot:h})=>new eh({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 Ja({...t,frameClient:this.frameClient}):await nh({...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 ah({...t,frameClient:this.frameClient,name:r})}const e=async()=>{const{task:r}=t;return(await this.retrieve({key:r})).name};return await sh({frameClient:this.frameClient,name:e,...t})}};const Br=H("task"),C0=Br(""),j0=t=>Be(Br(t)),nh=async({frameClient:t,task:e,type:r,args:n})=>(await Ja({frameClient:t,commands:[{args:n,task:e,type:r}]}))[0],Ja=async({frameClient:t,commands:e})=>{if(t==null)throw ft;const r=await t.openWriter(Bs),n=e.map(s=>({...s,key:Up.create()}));return await r.write(Bs,n),await r.close(),n.map(s=>s.key)},sh=async({frameClient:t,task:e,type:r,timeout:n,name:s,statusDataZ:i,args:o})=>(await ah({frameClient:t,commands:[{args:o,task:e,type:r}],timeout:n,statusDataZ:i,name:s}))[0],ah=async({frameClient:t,commands:e,timeout:r=N.seconds(10),statusDataZ:n,name:s})=>{if(t==null)throw ft;const i=await t.openStreamer(Us),o=await Ja({frameClient:t,commands:e}),c=new N(r);let l=[],u;const h=new Promise((f,d)=>{u=setTimeout(()=>{(async()=>{const T=e.map(I=>I.task);d(await M0("command",s,c,T))})()},c.milliseconds)});try{for(;;){const f=await Promise.race([i.read(),h]),d=Ka(n).safeParse(f.at(-1)[Us]);if(!d.success)continue;const T=d.data;if(!(T.details.cmd==null||!o.includes(T.details.cmd))&&(l=[...l.filter(I=>I.key!==T.key),T],l.length===o.length))return l}}finally{clearTimeout(u),i.close()}},M0=async(t,e,r,n)=>{const s=gp.capitalize(t),i=r.toString();try{let o;typeof e=="string"?o=[e]:Array.isArray(e)?o=e:o=v.toArray(await e());const c=As.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 ${As.naturalLanguageJoin(n)} timed out after ${i}`)}},$0=Object.freeze(Object.defineProperty({__proto__:null,COMMAND_CHANNEL_NAME:Bs,Client:rh,DELETE_CHANNEL_NAME:v0,SET_CHANNEL_NAME:b0,TYPE_ONTOLOGY_ID:C0,Task:eh,commandZ:g0,keyZ:Fe,newStatusZ:Ju,newZ:Xu,ontologyID:Br,rackKey:w0,statusDetailsZ:Ga,statusKey:j0,statusZ:Ka,taskZ:Lr},Symbol.toStringTag,{value:"Module"}));class ih{url;unary;stream;secure;constructor(e,r={},n=!1){this.secure=n,this.url=e.child("/api/v1/");const s=new Ot.JSONCodec;this.unary=ep(new Qf(this.url,s,this.secure),r),this.stream=new ap(this.url,s,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const xt=a.z.uuid(),Mn=a.z.object({key:xt,name:a.z.string(),data:Oe.unknownZ.or(a.z.string().transform($e))}),oh=Mn.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Ue=a.z.uuid(),$n=a.z.object({key:Ue,name:a.z.string().min(1,"Name is required"),layout:Oe.unknownZ.or(a.z.string().transform($e))}),ch=$n.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),lh=$n.omit({layout:!0}).extend({layout:a.z.string().transform($e)}),U0=a.z.object({key:xt,name:a.z.string()}),_0=a.z.object({key:xt,data:a.z.string()}),P0=a.z.object({keys:xt.array()}),Z0=a.z.object({keys:xt.array()}),uh=a.z.object({key:xt}).transform(({key:t})=>({keys:[t]})),hh=a.z.union([uh,Z0]),R0=a.z.object({linePlots:v.nullableZ(Mn)}),D0=a.z.object({workspace:Ue,linePlots:oh.array()}),L0=a.z.object({linePlots:Mn.array()}),Xn=a.z.object({});let dh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/lineplot/create",{workspace:t,linePlots:v.toArray(e)},D0,L0);return r?n.linePlots:n.linePlots[0]}async rename(t,e){await w(this.client,"/workspace/lineplot/rename",{key:t,name:e},U0,Xn)}async setData(t,e){await w(this.client,"/workspace/lineplot/set-data",{key:t,data:JSON.stringify(e)},_0,Xn)}async retrieve(t){const e=uh.safeParse(t).success,r=await w(this.client,"/workspace/lineplot/retrieve",t,hh,R0);return he("LinePlot",t,r.linePlots,e),e?r.linePlots[0]:r.linePlots}async delete(t){await w(this.client,"/workspace/lineplot/delete",{keys:v.toArray(t)},P0,Xn)}};const fh=H("lineplot"),B0=fh(""),F0=Object.freeze(Object.defineProperty({__proto__:null,Client:dh,TYPE_ONTOLOGY_ID:B0,keyZ:xt,linePlotZ:Mn,newZ:oh,ontologyID:fh,retrieveArgsZ:hh},Symbol.toStringTag,{value:"Module"})),It=a.z.uuid(),Un=a.z.object({key:It,name:a.z.string(),data:Oe.unknownZ.or(a.z.string().transform($e))}),ph=Un.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),q0=a.z.object({key:It,name:a.z.string()}),Y0=a.z.object({key:It,data:a.z.string()}),V0=a.z.object({keys:It.array()}),H0=a.z.object({keys:It.array()}),yh=a.z.object({key:It}).transform(({key:t})=>({keys:[t]})),mh=a.z.union([yh,H0]),W0=a.z.object({logs:v.nullableZ(Un)}),G0=a.z.object({workspace:Ue,logs:ph.array()}),K0=a.z.object({logs:Un.array()}),Qn=a.z.object({});let gh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/log/create",{workspace:t,logs:v.toArray(e)},G0,K0);return r?n.logs:n.logs[0]}async rename(t,e){await w(this.client,"/workspace/log/rename",{key:t,name:e},q0,Qn)}async setData(t,e){await w(this.client,"/workspace/log/set-data",{key:t,data:JSON.stringify(e)},Y0,Qn)}async retrieve(t){const e=yh.safeParse(t).success,r=await w(this.client,"/workspace/log/retrieve",t,mh,W0);return he("Log",t,r.logs,e),e?r.logs[0]:r.logs}async delete(t){await w(this.client,"/workspace/log/delete",{keys:v.toArray(t)},V0,Qn)}};const wh=H("log"),J0=wh(""),X0=Object.freeze(Object.defineProperty({__proto__:null,Client:gh,TYPE_ONTOLOGY_ID:J0,keyZ:It,logZ:Un,newZ:ph,ontologyID:wh,retrieveArgsZ:mh},Symbol.toStringTag,{value:"Module"})),ot=a.z.uuid(),_n=a.z.object({key:ot,name:a.z.string(),data:Oe.unknownZ.or(a.z.string().transform($e)),snapshot:a.z.boolean()}),bh=_n.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Xa=_n.extend({data:a.z.string().transform($e)}),Jt=a.z.uuid(),vh=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()}),zh=a.z.object({key:a.z.string(),name:a.z.string(),regions:vh.array()}),Oh=a.z.object({key:a.z.string(),position:ya.xy,orientation:xy.outer}),Q0=a.z.object({zoom:a.z.number().positive().default(1),position:ya.xy}),Th=a.z.object({svg:a.z.string().min(1,"SVG is required"),states:zh.array(),variant:a.z.string().min(1,"Variant is required"),handles:Oh.array(),scale:a.z.number().positive().default(1),scaleStroke:a.z.boolean().default(!1),previewViewport:Q0.default({zoom:1,position:{x:0,y:0}})}),Pn=a.z.object({key:Jt,version:a.z.literal(1).default(1),name:a.z.string().min(1,"Name is required"),data:Th}),kh=Pn.partial({key:!0}),eN=a.z.object({symbols:kh.array(),parent:L}),tN=a.z.object({key:Jt,name:a.z.string()}),rN=a.z.object({keys:Jt.array()}),nN=a.z.object({keys:Jt.array().optional(),searchTerm:a.z.string().optional()}),sN=a.z.object({key:Jt}).transform(({key:t})=>({keys:[t]})),aN=a.z.union([sN,nN]),iN=a.z.object({symbols:v.nullableZ(Pn)}),oN=a.z.object({symbols:Pn.array()}),lo=a.z.object({}),cN=a.z.object({}),lN=a.z.object({group:bn}),uN="sy_schematic_symbol_set",hN="sy_schematic_symbol_delete";let Sh=class{client;constructor(t){this.client=t}async create(t){const e="symbols"in t,r=e?t.symbols:[t],n=await w(this.client,"/workspace/schematic/symbol/create",{symbols:r,parent:t.parent},eN,oN);return e?n.symbols:n.symbols[0]}async rename(t,e){await w(this.client,"/workspace/schematic/symbol/rename",{key:t,name:e},tN,lo)}async retrieve(t){const e="key"in t,r=await w(this.client,"/workspace/schematic/symbol/retrieve",t,aN,iN);return he("Schematic Symbol",t,r.symbols,e),e?r.symbols[0]:r.symbols}async delete(t){await w(this.client,"/workspace/schematic/symbol/delete",{keys:v.toArray(t)},rN,lo)}async retrieveGroup(){return(await w(this.client,"/workspace/schematic/symbol/retrieve_group",{},cN,lN)).group}};const dN=H("schematic_symbol"),fN=Object.freeze(Object.defineProperty({__proto__:null,Client:Sh,DELETE_CHANNEL_NAME:hN,SET_CHANNEL_NAME:uN,handleZ:Oh,keyZ:Jt,newZ:kh,ontologyID:dN,regionZ:vh,specZ:Th,stateZ:zh,symbolZ:Pn},Symbol.toStringTag,{value:"Module"})),pN=a.z.object({key:ot,name:a.z.string()}),yN=a.z.object({key:ot,data:a.z.string()}),mN=a.z.object({keys:ot.array()}),gN=a.z.object({key:ot,name:a.z.string(),snapshot:a.z.boolean()}),wN=a.z.object({keys:ot.array()}),Nh=a.z.object({key:ot}).transform(({key:t})=>({keys:[t]})),Eh=a.z.union([Nh,wN]),bN=a.z.object({schematics:v.nullableZ(Xa)}),vN=a.z.object({workspace:Ue,schematics:bh.array()}),zN=a.z.object({schematics:Xa.array()}),ON=a.z.object({schematic:_n}),es=a.z.object({});let Ah=class{symbols;client;constructor(t){this.client=t,this.symbols=new Sh(t)}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/schematic/create",{workspace:t,schematics:v.toArray(e)},vN,zN);return r?n.schematics:n.schematics[0]}async rename(t,e){await w(this.client,"/workspace/schematic/rename",{key:t,name:e},pN,es)}async setData(t,e){await w(this.client,"/workspace/schematic/set-data",{key:t,data:JSON.stringify(e)},yN,es)}async retrieve(t){const e=Nh.safeParse(t).success,r=await w(this.client,"/workspace/schematic/retrieve",t,Eh,bN);return he("Schematic",t,r.schematics,e),e?r.schematics[0]:r.schematics}async delete(t){await w(this.client,"/workspace/schematic/delete",{keys:v.toArray(t)},mN,es)}async copy(t){return(await w(this.client,"/workspace/schematic/copy",t,gN,ON)).schematic}};const xh=H("schematic"),TN=xh(""),kN=Object.freeze(Object.defineProperty({__proto__:null,Client:Ah,TYPE_ONTOLOGY_ID:TN,keyZ:ot,newZ:bh,ontologyID:xh,remoteZ:Xa,retrieveArgsZ:Eh,schematicZ:_n,symbol:fN},Symbol.toStringTag,{value:"Module"})),Ct=a.z.uuid(),Qa=a.z.object({key:Ct,name:a.z.string(),data:Oe.unknownZ.or(a.z.string().transform($e))}),Ih=Qa.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ei=Qa.extend({data:a.z.string().transform($e)}),SN=a.z.object({key:Ct,name:a.z.string()}),NN=a.z.object({key:Ct,data:a.z.string()}),EN=a.z.object({keys:Ct.array()}),AN=a.z.object({keys:Ct.array()}),Ch=a.z.object({key:Ct}).transform(({key:t})=>({keys:[t]})),jh=a.z.union([Ch,AN]),xN=a.z.object({tables:v.nullableZ(ei)}),IN=a.z.object({workspace:Ue,tables:Ih.array()}),CN=a.z.object({tables:ei.array()}),ts=a.z.object({});let Mh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/table/create",{workspace:t,tables:v.toArray(e)},IN,CN);return r?n.tables:n.tables[0]}async rename(t,e){await w(this.client,"/workspace/table/rename",{key:t,name:e},SN,ts)}async setData(t,e){await w(this.client,"/workspace/table/set-data",{key:t,data:JSON.stringify(e)},NN,ts)}async retrieve(t){const e=Ch.safeParse(t).success,r=await w(this.client,"/workspace/table/retrieve",t,jh,xN);return he("Table",t,r.tables,e),e?r.tables[0]:r.tables}async delete(t){await w(this.client,"/workspace/table/delete",{keys:v.toArray(t)},EN,ts)}};const $h=H("table"),jN=$h(""),MN=Object.freeze(Object.defineProperty({__proto__:null,Client:Mh,TYPE_ONTOLOGY_ID:jN,keyZ:Ct,newZ:Ih,ontologyID:$h,remoteZ:ei,retrieveArgsZ:jh,tableZ:Qa},Symbol.toStringTag,{value:"Module"})),$N=a.z.object({keys:Ue.array().optional(),searchTerm:a.z.string().optional(),author:Me.optional(),offset:a.z.int().optional(),limit:a.z.int().optional()}),UN=a.z.object({workspaces:ch.array()}),_N=a.z.object({key:Ue,name:a.z.string()}),PN=a.z.object({key:Ue,layout:Oe.unknownZ.transform(t=>JSON.stringify(t))}),ZN=a.z.object({keys:Ue.array()}),RN=a.z.object({workspaces:v.nullableZ($n)}),DN=a.z.object({workspaces:lh.array()}),rs=a.z.object({}),LN="sy_workspace_set",BN="sy_workspace_delete";class Uh{schematics;lineplots;logs;tables;client;constructor(e){this.client=e,this.schematics=new Ah(e),this.lineplots=new dh(e),this.logs=new gh(e),this.tables=new Mh(e)}async create(e){const r=Array.isArray(e),n=await w(this.client,"/workspace/create",{workspaces:v.toArray(e)},UN,DN);return r?n.workspaces:n.workspaces[0]}async rename(e,r){await w(this.client,"/workspace/rename",{key:e,name:r},_N,rs)}async setLayout(e,r){await w(this.client,"/workspace/set-layout",{key:e,layout:r},PN,rs)}async retrieve(e){let r;const n=typeof e!="string";typeof e=="string"||Array.isArray(e)?r={keys:v.toArray(e)}:r=e;const s=await w(this.client,"/workspace/retrieve",r,$N,RN);return n?s.workspaces:s.workspaces[0]}async delete(e){await w(this.client,"/workspace/delete",{keys:v.toArray(e)},ZN,rs)}}const _h=H("workspace"),FN=_h(""),qN=Object.freeze(Object.defineProperty({__proto__:null,Client:Uh,DELETE_CHANNEL_NAME:BN,SET_CHANNEL_NAME:LN,TYPE_ONTOLOGY_ID:FN,keyZ:Ue,newZ:ch,ontologyID:_h,remoteZ:lh,workspaceZ:$n},Symbol.toStringTag,{value:"Module"})),Ph=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().default(!1),name:a.z.string().optional(),retry:wa.breakerConfigZ.optional()});class YN extends Cu{createdAt;params;ranges;channels;auth;users;access;connectivity;ontology;workspaces;labels;statuses;tasks;racks;devices;control;arcs;static connectivity=Rs;transport;clientVersion="0.49.0";constructor(e){const r=Ph.parse(e),{host:n,port:s,username:i,password:o,connectivityPollFrequency:c,secure:l,retry:u}=r,h=new ih(new Pt({host:n,port:Number(s)}),u,l);h.use(_g);const f=new La(new Da(h.unary));super(h.stream,h.unary,f),this.auth=new gk(h.unary,{username:i,password:o}),h.use(this.auth.middleware());const d=new mu(h.unary,f);this.createdAt=C.now(),this.params=r,this.transport=h,this.channels=new pu(this,f,h.unary,d),this.connectivity=new Rs(h.unary,c,this.clientVersion,r.name),this.control=new $u(this),this.ontology=new il(h.unary,this);const T=new Gu(this.transport.unary);this.labels=new lu(this.transport.unary),this.statuses=new Ku(this.transport.unary),this.ranges=new Hu(this,T,this.transport.unary,f,this.labels,this.ontology),this.access=new bl(this.transport.unary),this.users=new fl(this.transport.unary),this.workspaces=new Uh(this.transport.unary),this.tasks=new rh(this.transport.unary,this,this.ontology,this.ranges),this.racks=new Fu(this.transport.unary,this.tasks),this.devices=new Bu(this.transport.unary),this.arcs=new eu(this.transport.unary,this.transport.stream)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}}const VN=async t=>await Zh(t).check(),Zh=t=>{const{host:e,port:r,secure:n,name:s,retry:i}=t,o=wa.breakerConfigZ.optional().parse(i),c=new Pt({host:e,port:Number(r)}),l=new ih(c,o,n);return new Rs(l.unary,void 0,"0.49.0",s)};N.seconds(1);const Fs=(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}};class Ft{_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 Ft(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new Ft("","","")}const qs=["debug","info","warn","error"],Rh=t=>{const e=qs.indexOf(t);return({level:r})=>qs.indexOf(r)>=e},HN=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 qt{meta=Ft.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 qt({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,tn(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,tn(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,tn(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,tn(r)))}static NOOP=new qt}const tn=t=>typeof t=="function"?t():t;var WN=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},pt="1.9.0",uo=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function GN(t){var e=new Set([t]),r=new Set,n=t.match(uo);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(uo);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 KN=GN(pt),JN=pt.split(".")[0],vr=Symbol.for("opentelemetry.js.api."+JN),zr=WN;function ti(t,e,r,n){var s;n===void 0&&(n=!1);var i=zr[vr]=(s=zr[vr])!==null&&s!==void 0?s:{version:pt};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!==pt){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+pt);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+pt+"."),!0}function Or(t){var e,r,n=(e=zr[vr])===null||e===void 0?void 0:e.version;if(!(!n||!KN(n)))return(r=zr[vr])===null||r===void 0?void 0:r[t]}function ri(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+pt+".");var r=zr[vr];r&&delete r[t]}var XN=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},QN=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))},eE=(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=Or("diag");if(n)return r.unshift(e),n[t].apply(n,QN([],XN(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 tE(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 rE=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},nE=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))},sE="diag",Tr=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var c=Or("diag");if(c)return c[s].apply(c,nE([],rE(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=Or("diag"),f=tE((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 ti("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ri(sE,r)},r.createComponentLogger=function(s){return new eE(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})(),aE=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},iE=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.")},oE=(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=aE(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=iE(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})();Tr.instance();function cE(t){return t===void 0&&(t={}),new oE(new Map(Object.entries(t)))}function lE(t){return Symbol.for(t)}var uE=(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})(),hE=new uE,dE={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},fE={set:function(t,e,r){t!=null&&(t[e]=r)}},pE=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},yE=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))},mE=(function(){function t(){}return t.prototype.active=function(){return hE},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,yE([n],pE(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})(),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},wE=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))},ns="context",bE=new mE,Dh=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ti(ns,e,Tr.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,wE([e,r,n],gE(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Or(ns)||bE},t.prototype.disable=function(){this._getContextManager().disable(),ri(ns,Tr.instance())},t})(),Ys;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Ys||(Ys={}));var vE=Dh.getInstance(),zE=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})(),ni=lE("OpenTelemetry Baggage Key");function Lh(t){return t.getValue(ni)||void 0}function OE(){return Lh(Dh.getInstance().active())}function TE(t,e){return t.setValue(ni,e)}function kE(t){return t.deleteValue(ni)}var ss="propagation",SE=new zE,NE=(function(){function t(){this.createBaggage=cE,this.getBaggage=Lh,this.getActiveBaggage=OE,this.setBaggage=TE,this.deleteBaggage=kE}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ti(ss,e,Tr.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=fE),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=dE),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ri(ss,Tr.instance())},t.prototype._getGlobalPropagator=function(){return Or(ss)||SE},t})(),EE=NE.getInstance();const ho=["bench","debug","prod"],AE=t=>e=>ho.indexOf(e)>=ho.indexOf(t);class kr{meta=Ft.NOOP;otelTracer;filter;constructor(e,r=AE("debug")){this.otelTracer=e,this.filter=r}child(e){const r=new kr(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 Vs(e,this.otelTracer.startSpan(e));return i.start(),()=>i.end()}return s?n(new Bh(e)):this.otelTracer.startActiveSpan(e,i=>{const o=new Vs(e,i);return n(o)})}propagate(e){if(this.meta.noop)return;const r=vE.active();EE.inject(r,e,{set:(n,s,i)=>{n[s]=i}})}static NOOP=new kr}class Vs{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:Ys.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 Bh{key;constructor(e){this.key=e}set(){}recordError(e){}}class Yt{meta;T;L;constructor({key:e="",serviceName:r="",logger:n=qt.NOOP,tracer:s=kr.NOOP,noop:i=!1,__meta:o}){this.meta=o??new Ft(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 Yt({__meta:r,tracer:this.T,logger:this.L})}static NOOP=new Yt({noop:!0})}const xE=Yt.NOOP,Fh=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Yt,LOG_LEVELS:qs,Logger:qt,NOOP:xE,NoopSpan:Bh,Tracer:kr,_Span:Vs,logLevelKeyFiler:HN,logThresholdFilter:Rh},Symbol.toStringTag,{value:"Module"})),as=(t,e)=>t instanceof Error?(t.message=`[${e}] - ${t.message}`,t):new Error(e??"unknown error",{cause:t});class si{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 Y(`[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=We.executeSetter(e,this.state);this._prevState=A.nl.copy(this._state),this._state=Fs(this._schema,r,`${this.toString()}`),this.sender.send({variant:"update",key:this.key,state:this._state})}get state(){if(this._state==null)throw new ue(`[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 Bt(`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=Fs(this._schema,r,`${this.toString()}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:A.qu.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 as(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 as(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 as(r,`[${this.toString()}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new ue(`[Leaf.setState] - ${this.toString()} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new ue(`[Leaf.setState] - ${this.toString()} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new ue(`[Leaf.setState] - ${this.toString()} received a key ${r} but expected ${this.key}`)}}class Fr extends si{_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 ue(`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 ue(`[Composite.getRequiredKey] - ${this.toString()} received a key ${n} but expected ${this.key}`);return s}}const IE=a.z.object({}),CE=()=>{throw new Error("should not call create")};class et extends Fr{static TYPE="root";static KEY="root";comms;registry;schema=IE;constructor({comms:e,instrumentation:r=Fh.Instrumentation.NOOP,registry:n}){super({key:et.KEY,type:et.TYPE,sender:e,instrumentation:r,parentCtxValues:null}),this.comms=e,this.registry=n}static render(e){const r=new et(e);return r._updateState({path:[et.KEY],type:"",state:{},create:CE}),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 ue(`[Root.create] - ${r} not found in registry`);return new s({key:e,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:n})}}const qh=et.render.bind(et),jE=Object.freeze(Object.defineProperty({__proto__:null,Composite:Fr,Leaf:si,Root:et,render:qh},Symbol.toStringTag,{value:"Module"})),ME=(t,e)=>Array.isArray(e)?e.some(r=>r.matches(t)):e?.matches(t)??!1,$E=t=>{const e=[`${t.variant.toUpperCase()}: ${t.message}`];if(t.description)try{const r=JSON.parse(t.description);e.push(`Description:
73
- ${JSON.stringify(r,null,2)}`)}catch{e.push(`Description: ${t.description}`)}"details"in t&&A.hu.isObject(t.details)&&"stack"in t.details&&e.push(`Stack Trace:
74
- ${String(t.details.stack)}`),console.error(e.join(`
75
-
76
- `))},Yh=(t,e,r)=>{const n=A.rl.fromException(t,e);return $E(n),ME(t,r)?null:n},Vh=(t,e,r,n)=>{if(typeof t=="function")return!0;const s=Yh(t,r,n);return s!=null&&e(s),!1},Hh=async(t,e,r,n)=>{try{const s=t();s!=null&&await s}catch(s){const i=Yh(s,r,n);if(i!=null)return e(i)}},Wh=t=>(e,r,n)=>{Vh(e,t,r,n)&&Hh(e,t,r,n)},Gh=t=>async(e,r,n)=>{Vh(e,t,r,n)&&await Hh(e,t,r,n)},Kh=a.z.object({statuses:A.rl.statusZ().array()}),pn="status.aggregator";class Hs extends Fr{static TYPE="status.Aggregator";schema=Kh;afterUpdate(e){e.wasSetPreviously(pn)||e.set(pn,{add:this.add.bind(this),create:A.rl.create})}add(e){this.setState(r=>({...r,statuses:[...r.statuses,A.rl.create(e)]}))}}const ai=t=>t.get(pn).add,UE=t=>{const e=t.getOptional(pn);return e!=null?e.add:()=>{}},Jh=t=>Wh(ai(t)),_E=t=>Gh(ai(t)),PE={[Hs.TYPE]:Hs},ZE=a.z.object({l0:A.Pu.colorZ,l1:A.Pu.colorZ,l2:A.Pu.colorZ,l3:A.Pu.colorZ,l4:A.Pu.colorZ,l5:A.Pu.colorZ,l6:A.Pu.colorZ,l7:A.Pu.colorZ,l8:A.Pu.colorZ,l9:A.Pu.colorZ,l10:A.Pu.colorZ,l11:A.Pu.colorZ}),pe=(t,e)=>[t[0],t[1],e,t[3]],RE=a.z.object({m2:A.Pu.colorZ,m1:A.Pu.colorZ,z:A.Pu.colorZ,p1:A.Pu.colorZ,p2:A.Pu.colorZ}),rn=RE.or(A.Pu.colorZ.transform(t=>{const e=A.Pu.hsla(t);return{m2:A.Pu.fromHSLA(pe(e,40)),m1:A.Pu.fromHSLA(pe(e,45)),z:t,p1:A.Pu.fromHSLA(pe(e,55)),p2:A.Pu.fromHSLA(pe(e,65))}})),Xh=a.z.object({name:a.z.string(),key:a.z.string(),colors:a.z.object({border:A.Pu.colorZ,primary:rn,gray:ZE,error:rn,secondary:rn,warning:rn,palettes:a.z.record(a.z.string(),A.Pu.paletteZ),visualization:a.z.object({palettes:a.z.record(a.z.string(),a.z.array(A.Pu.colorZ))}).default({palettes:{}}),white:A.Pu.colorZ,black:A.Pu.colorZ,text:A.Pu.colorZ,textInverted:A.Pu.colorZ,textOnPrimary:A.Pu.colorZ.default(A.Pu.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:We.specZ,h2:We.specZ,h3:We.specZ,h4:We.specZ,h5:We.specZ,p:We.specZ,small:We.specZ})}).transform(t=>((t.colors.textOnPrimary==null||A.Pu.isZero(t.colors.textOnPrimary))&&(t.colors.textOnPrimary=A.Pu.pickByContrast(t.colors.primary.z,t.colors.text,t.colors.textInverted)),t)),DE='"Inter Variable", sans-serif',LE='"Geist Mono", monospace',BE=6,er=[357,91,55,1],tr=[48,90,55,1],FE=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],rr=Object.fromEntries(FE.map((t,e)=>[`l${e}`,t])),qE=()=>typeof window>"u"?!1:window.devicePixelRatio>1,YE=qE(),Ws={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:rr,border:rr.l4,error:{m2:A.Pu.fromHSLA(pe(er,30)),m1:A.Pu.fromHSLA(pe(er,40)),z:A.Pu.fromHSLA(er),p1:A.Pu.fromHSLA(pe(er,65)),p2:A.Pu.fromHSLA(pe(er,77))},warning:{m2:A.Pu.fromHSLA(pe(tr,30)),m1:A.Pu.fromHSLA(pe(tr,40)),z:A.Pu.fromHSLA(tr),p1:A.Pu.fromHSLA(pe(tr,65)),p2:A.Pu.fromHSLA(pe(tr,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:rr.l11,textInverted:rr.l0,textOnPrimary:rr.l0},sizes:{base:BE,border:{radius:3,width:YE?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:DE,codeFamily:LE,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}}},Qh=Object.freeze({...Ws,key:"synnaxLight",name:"Synnax Light"}),VE=["#020202","#080808","#151515","#202020","#272727","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],nr=Object.fromEntries(VE.map((t,e)=>[`l${e}`,t])),ed=Object.freeze({...Ws,key:"synnaxDark",name:"Synnax Dark",colors:{...Ws.colors,gray:nr,logo:"var(--pluto-text-color)",border:nr.l4,text:nr.l11,textInverted:nr.l0,textOnPrimary:nr.l11}}),HE={synnaxDark:ed,synnaxLight:Qh},td=["tiny","small","medium","large","huge"],rd=a.z.enum(td),WE=t=>rd.safeParse(t).success,Gs="pluto-theming-context",nd=a.z.object({name:a.z.string(),url:a.z.string()}),GE=a.z.object({theme:Xh,fontURLs:a.z.array(nd)});class Sr extends Fr{static TYPE="theming.Provider";static z=GE;schema=Sr.z;afterUpdate(e){if(e.getOptional(Gs)!=null&&this.state.theme.key===this.prevState.theme.key)return;e.set(Gs,this.state.theme),Jh(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 KE=t=>t.get(Gs),JE={[Sr.TYPE]:Sr};exports.Aggregator=Hs;exports.An=Bt;exports.Bk=uk;exports.Ck=Zw;exports.Composite=Fr;exports.Dk=GT;exports.Hk=Yk;exports.Ik=iw;exports.Kk=uS;exports.Leaf=si;exports.Mk=eb;exports.Nk=Mg;exports.O=Yt;exports.Provider=Sr;exports.REGISTRY=JE;exports.REGISTRY$1=PE;exports.SIZES=td;exports.SYNNAX_DARK=ed;exports.SYNNAX_LIGHT=Qh;exports.SYNNAX_THEMES=HE;exports.Uk=ET;exports.Ut=ue;exports.V=Y;exports.Vk=Jk;exports.Xk=kS;exports._=qt;exports.aA=F0;exports.aether=jE;exports.aggregatorStateZ=Kh;exports.ak=YN;exports.be=Rh;exports.cA=X0;exports.createAsyncErrorHandler=Gh;exports.createErrorHandler=Wh;exports.d=U;exports.dA=MN;exports.eA=i0;exports.fontSpecZ=nd;exports.g=Fh;exports.g$1=N;exports.hA=kN;exports.ik=Ph;exports.isSize=WE;exports.kk=Jg;exports.m=C;exports.nA=y0;exports.ok=Zh;exports.pA=qN;exports.prettyParse=Fs;exports.render=qh;exports.rt=nt;exports.sA=$0;exports.size=rd;exports.themeZ=Xh;exports.use=KE;exports.useAdder=ai;exports.useAsyncErrorHandler=_E;exports.useErrorHandler=Jh;exports.useOptionalAdder=UE;exports.yA=VN;