@synnaxlabs/pluto 0.42.3 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/{Center-D0JeI7Ta.js → Center-Bq5L7oy0.js} +2 -2
- package/dist/{Center-DuI3XH-Q.cjs → Center-DE_BtCCX.cjs} +1 -1
- package/dist/ContextMenu-BC5x7XR5.cjs +1 -0
- package/dist/{ContextMenu-BiNr7Gxv.js → ContextMenu-DLM5eLLG.js} +11 -11
- package/dist/DateTime-CdNKxVxT.js +17 -0
- package/dist/DateTime-DC19AIGq.cjs +1 -0
- package/dist/{Divider-DqEkzRIY.js → Divider-CDFHLK9U.js} +213 -215
- package/dist/Divider-D74_FAXn.cjs +22 -0
- package/dist/Dropdown-BpoU-xVd.cjs +1 -0
- package/dist/Dropdown-CQu3yo3v.js +327 -0
- package/dist/Haul-D6kpOYBa.js +124 -0
- package/dist/Haul-De8axVdi.cjs +1 -0
- package/dist/{Item-C5SQraZM.js → Item-BgUwEjzV.js} +6 -6
- package/dist/{Item-DSBs9VLu.cjs → Item-BrHZi6Fl.cjs} +1 -1
- package/dist/{Keyboard-Ca7TAAHK.cjs → Keyboard-CiNuYBa3.cjs} +1 -1
- package/dist/{Keyboard-Duo41pJL.js → Keyboard-DjeQa-Nx.js} +2 -2
- package/dist/{Link-B9ZGvoBU.cjs → Link-Bngd8rrL.cjs} +1 -1
- package/dist/{Link-C9GeoB0w.js → Link-y133HE5v.js} +1 -1
- package/dist/Pack-80N7XB5O.cjs +1 -0
- package/dist/Pack-BiS6QIuA.js +52 -0
- package/dist/Provider-B1j7nPL9.cjs +1 -0
- package/dist/Provider-CAR23fYq.js +464 -0
- package/dist/{Space-DvalhzRj.cjs → Space-ByFmfiTa.cjs} +1 -1
- package/dist/{Space-CyTH97CN.js → Space-DxHm2ok7.js} +1 -1
- package/dist/{Text-BR4FW9Hy.js → Text-B1uUpUKk.js} +125 -122
- package/dist/Text-CLsJyQGy.cjs +4 -0
- package/dist/{Text-8ps3Uw4T.js → Text-CacHYC7L.js} +4 -4
- package/dist/{Text-DkA06TeT.cjs → Text-DTPuORh0.cjs} +1 -1
- package/dist/Text-Ddc0C5JU.cjs +1 -0
- package/dist/{Text-sH_NOelc.js → Text-P0b041la.js} +17 -17
- package/dist/{Toggle-BRuUrO2N.js → Toggle-BC1o8qt5.js} +115 -109
- package/dist/Toggle-D-vvd8lz.cjs +1 -0
- package/dist/{Video-DWStbcmD.js → Video-Bq_WSdfc.js} +1 -1
- package/dist/{Video-DgjuFLiE.cjs → Video-BuzHLiXL.cjs} +1 -1
- package/dist/{WithIcon-BhR6nwRh.js → WithIcon-B7VPBqA2.js} +24 -27
- package/dist/WithIcon-CCnlO2LC.cjs +1 -0
- package/dist/align.cjs +1 -1
- package/dist/align.js +1 -1
- package/dist/array-CPtP5Oov.js +7 -0
- package/dist/array-CZHEGH95.cjs +1 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/css-C7rJrqRi.cjs +38 -0
- package/dist/css-DjQu2Qyf.js +12511 -0
- package/dist/css.cjs +1 -1
- package/dist/css.js +11 -5
- package/dist/deep-BRgXTyZn.cjs +1 -0
- package/dist/deep-D72Fid_q.js +193 -0
- package/dist/{dimensions-By-vgVks.cjs → dimensions-BmlCx5q4.cjs} +1 -1
- package/dist/{dimensions-B6qmnzv3.js → dimensions-FnMV2fyj.js} +1 -1
- package/dist/dropdown.cjs +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/eraser-C0Kv4_kL.cjs +11 -0
- package/dist/{eraser-CK8SwEJa.js → eraser-CupVBBBp.js} +246 -427
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +36 -37
- package/dist/{external-B1YsdhS4.js → external-8zJ3fvo2.js} +122 -123
- package/dist/{external-_8qdWaAg.js → external-BDh272rT.js} +2 -2
- package/dist/{external-BnK4UIFe.js → external-BYsOdgw5.js} +3 -3
- package/dist/{external-DmryCcwg.cjs → external-BgKH42un.cjs} +1 -1
- package/dist/external-BmeMUsxr.js +399 -0
- package/dist/{external-DissGp_3.js → external-CKag7gXR.js} +8 -8
- package/dist/{external-C0X4mXVG.js → external-CVHgvs0C.js} +6 -6
- package/dist/{external-B8uaUKhb.cjs → external-CjTwWT6m.cjs} +1 -1
- package/dist/{external-BDkqwq72.js → external-Cjnx793K.js} +7901 -7839
- package/dist/{external-CUgPP-JD.cjs → external-D1gwMWza.cjs} +1 -1
- package/dist/{external-BwUa_5Vs.cjs → external-D38Y0J6S.cjs} +1 -1
- package/dist/{external-zbKPQ9ls.cjs → external-D8mHEAIG.cjs} +2 -2
- package/dist/external-DC1RT1Js.cjs +1 -0
- package/dist/external-DHw0SdIj.cjs +1 -0
- package/dist/external-DOujCKRS.cjs +1 -0
- package/dist/external-DlyrUZhP.cjs +1 -0
- package/dist/external-Ds5GDIp9.cjs +1 -0
- package/dist/{external-BOMdfX8_.js → external-DuvwfKLw.js} +2 -2
- package/dist/external-GjPk23XZ.cjs +1 -0
- package/dist/{external-DQwznOyH.cjs → external-IsogMmdT.cjs} +38 -38
- package/dist/{external-C7yPkamb.js → external-ZV7pEm55.js} +8 -8
- package/dist/{external-Bl8q9UBF.js → external-firJ8w9n.js} +1837 -1838
- package/dist/{external-bSUra-q7.js → external-l7imNJRR.js} +26 -26
- package/dist/external-upR9Jz-8.js +60 -0
- package/dist/{font-XlUAG1-r.cjs → font-C5EV9fq1.cjs} +1 -1
- package/dist/{font-CjYcjBiv.js → font-Cy9UYjyY.js} +2 -2
- package/dist/fontString-CUy7T-OR.cjs +1 -0
- package/dist/{fontString-BN1kd1AP.js → fontString-CynarMI1.js} +6 -5
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hooks-B92WH57y.cjs +1 -0
- package/dist/{hooks-DjznxGgm.js → hooks-u_TgL0Xi.js} +79 -79
- package/dist/index.cjs +7 -7
- package/dist/index.js +7286 -7253
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/pluto.css +1 -1
- package/dist/provider-B8IM-N4g.cjs +154 -0
- package/dist/provider-CQqS-teQ.js +31994 -0
- package/dist/src/aether/aether/aether.d.ts +16 -16
- package/dist/src/aether/aether/aether.d.ts.map +1 -1
- package/dist/src/aether/aether/aether.spec.d.ts +5 -0
- package/dist/src/aether/aether/aether.spec.d.ts.map +1 -0
- package/dist/src/aether/main.d.ts +68 -19
- package/dist/src/aether/main.d.ts.map +1 -1
- package/dist/src/aether/main.spec.d.ts +2 -2
- package/dist/src/aether/main.spec.d.ts.map +1 -1
- package/dist/src/aether/message.d.ts +24 -14
- package/dist/src/aether/message.d.ts.map +1 -1
- package/dist/src/alamos/aether/alamos.d.ts +3 -3
- package/dist/src/alamos/aether/alamos.d.ts.map +1 -1
- package/dist/src/align/Pack.d.ts.map +1 -1
- package/dist/src/breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/src/button/Button.d.ts +1 -2
- package/dist/src/button/Button.d.ts.map +1 -1
- package/dist/src/button/color.d.ts +2 -2
- package/dist/src/button/color.d.ts.map +1 -1
- package/dist/src/channel/Select.d.ts.map +1 -1
- package/dist/src/color/Provider.d.ts +10 -10
- package/dist/src/color/Provider.d.ts.map +1 -1
- package/dist/src/css/color.d.ts +2 -2
- package/dist/src/css/color.d.ts.map +1 -1
- package/dist/src/divider/Divider.d.ts.map +1 -1
- package/dist/src/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/form/Field.d.ts +3 -3
- package/dist/src/form/Field.d.ts.map +1 -1
- package/dist/src/form/Form.d.ts +42 -28
- package/dist/src/form/Form.d.ts.map +1 -1
- package/dist/src/form/synced.d.ts +8 -8
- package/dist/src/form/synced.d.ts.map +1 -1
- package/dist/src/haul/Haul.d.ts +6 -6
- package/dist/src/haul/Haul.d.ts.map +1 -1
- package/dist/src/hooks/ref.d.ts +2 -2
- package/dist/src/hooks/ref.d.ts.map +1 -1
- package/dist/src/hooks/useResize.d.ts.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/input/HelpText.d.ts +4 -4
- package/dist/src/input/HelpText.d.ts.map +1 -1
- package/dist/src/input/Item.d.ts +1 -1
- package/dist/src/input/Item.d.ts.map +1 -1
- package/dist/src/input/Text.d.ts +2 -3
- package/dist/src/input/Text.d.ts.map +1 -1
- package/dist/src/label/Select.d.ts.map +1 -1
- package/dist/src/list/Selector.d.ts.map +1 -1
- package/dist/src/list/useSelect.d.ts.map +1 -1
- package/dist/src/memo/proxyMemo.d.ts.map +1 -1
- package/dist/src/memo/useMemoCompare.d.ts +3 -3
- package/dist/src/memo/useMemoCompare.d.ts.map +1 -1
- package/dist/src/mosaic/types.d.ts +9 -1
- package/dist/src/mosaic/types.d.ts.map +1 -1
- package/dist/src/note/Note.d.ts +2 -2
- package/dist/src/note/Note.d.ts.map +1 -1
- package/dist/src/observe/use.d.ts +2 -2
- package/dist/src/observe/use.d.ts.map +1 -1
- package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
- package/dist/src/ranger/Select.d.ts.map +1 -1
- package/dist/src/select/Button.d.ts +5 -3
- package/dist/src/select/Button.d.ts.map +1 -1
- package/dist/src/select/Multiple.d.ts.map +1 -1
- package/dist/src/select/Single.d.ts.map +1 -1
- package/dist/src/state/state.d.ts +2 -1
- package/dist/src/state/state.d.ts.map +1 -1
- package/dist/src/status/Indicator.d.ts +8 -0
- package/dist/src/status/Indicator.d.ts.map +1 -0
- package/dist/src/status/Text.d.ts +2 -2
- package/dist/src/status/Text.d.ts.map +1 -1
- package/dist/src/status/aether/aggregator.d.ts +14 -17
- package/dist/src/status/aether/aggregator.d.ts.map +1 -1
- package/dist/src/status/aether/types.d.ts +5 -17
- package/dist/src/status/aether/types.d.ts.map +1 -1
- package/dist/src/status/colors.d.ts +1 -1
- package/dist/src/status/colors.d.ts.map +1 -1
- package/dist/src/status/external.d.ts +1 -1
- package/dist/src/status/external.d.ts.map +1 -1
- package/dist/src/synnax/Provider.d.ts +2 -0
- package/dist/src/synnax/Provider.d.ts.map +1 -1
- package/dist/src/synnax/aether/provider.d.ts +28 -28
- package/dist/src/synnax/aether/provider.d.ts.map +1 -1
- package/dist/src/table/Table.d.ts +1 -1
- package/dist/src/table/Table.d.ts.map +1 -1
- package/dist/src/table/aether/Table.d.ts +28 -28
- package/dist/src/table/aether/Table.d.ts.map +1 -1
- package/dist/src/table/cells/Cells.d.ts +16 -16
- package/dist/src/table/cells/Cells.d.ts.map +1 -1
- package/dist/src/table/cells/registry.d.ts +2 -2
- package/dist/src/table/cells/registry.d.ts.map +1 -1
- package/dist/src/tabs/types.d.ts +3 -3
- package/dist/src/tabs/types.d.ts.map +1 -1
- package/dist/src/telem/aether/context.d.ts +1 -1
- package/dist/src/telem/aether/context.d.ts.map +1 -1
- package/dist/src/telem/aether/pipeline.d.ts +19 -19
- package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
- package/dist/src/telem/aether/provider.d.ts +4 -4
- package/dist/src/telem/aether/provider.d.ts.map +1 -1
- package/dist/src/telem/aether/remote.d.ts +27 -28
- package/dist/src/telem/aether/remote.d.ts.map +1 -1
- package/dist/src/telem/aether/static.d.ts +13 -13
- package/dist/src/telem/aether/static.d.ts.map +1 -1
- package/dist/src/telem/aether/telem.d.ts +44 -45
- package/dist/src/telem/aether/telem.d.ts.map +1 -1
- package/dist/src/telem/aether/transformers.d.ts +44 -47
- package/dist/src/telem/aether/transformers.d.ts.map +1 -1
- package/dist/src/telem/client/cache/cache.d.ts +1 -1
- package/dist/src/telem/client/cache/cache.d.ts.map +1 -1
- package/dist/src/telem/client/streamer.d.ts.map +1 -1
- package/dist/src/telem/control/Chip.d.ts +1 -1
- package/dist/src/telem/control/Chip.d.ts.map +1 -1
- package/dist/src/telem/control/Controller.d.ts +1 -1
- package/dist/src/telem/control/Controller.d.ts.map +1 -1
- package/dist/src/telem/control/Indicator.d.ts +1 -1
- package/dist/src/telem/control/Indicator.d.ts.map +1 -1
- package/dist/src/telem/control/StateProvider.d.ts +1 -3
- package/dist/src/telem/control/StateProvider.d.ts.map +1 -1
- package/dist/src/telem/control/aether/chip.d.ts +19 -21
- package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
- package/dist/src/telem/control/aether/controller.d.ts +17 -14
- package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
- package/dist/src/telem/control/aether/indicator.d.ts +25 -28
- package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
- package/dist/src/telem/control/aether/legend.d.ts +13 -13
- package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
- package/dist/src/telem/control/aether/state.d.ts +8 -8
- package/dist/src/telem/control/aether/state.d.ts.map +1 -1
- package/dist/src/text/Editable.d.ts.map +1 -1
- package/dist/src/text/Text.d.ts +2 -2
- package/dist/src/text/Text.d.ts.map +1 -1
- package/dist/src/text/WithIcon.d.ts.map +1 -1
- package/dist/src/text/core/dimensions.d.ts +24 -0
- package/dist/src/text/core/dimensions.d.ts.map +1 -0
- package/dist/src/text/core/dimensions.spec.d.ts +2 -0
- package/dist/src/text/core/dimensions.spec.d.ts.map +1 -0
- package/dist/src/text/core/external.d.ts +3 -0
- package/dist/src/text/core/external.d.ts.map +1 -0
- package/dist/src/text/core/index.d.ts +1 -1
- package/dist/src/text/core/index.d.ts.map +1 -1
- package/dist/src/text/core/types.d.ts +5 -5
- package/dist/src/text/core/types.d.ts.map +1 -1
- package/dist/src/text/external.d.ts +1 -1
- package/dist/src/text/external.d.ts.map +1 -1
- package/dist/src/theming/aether/provider.d.ts +809 -809
- package/dist/src/theming/aether/provider.d.ts.map +1 -1
- package/dist/src/theming/core/theme.d.ts +423 -424
- package/dist/src/theming/core/theme.d.ts.map +1 -1
- package/dist/src/tooltip/Dialog.d.ts.map +1 -1
- package/dist/src/tree/Tree.d.ts.map +1 -1
- package/dist/src/tree/core.d.ts.map +1 -1
- package/dist/src/triggers/triggers.d.ts +1 -1
- package/dist/src/triggers/triggers.d.ts.map +1 -1
- package/dist/src/util/component.d.ts +1 -1
- package/dist/src/util/component.d.ts.map +1 -1
- package/dist/src/util/zod.d.ts +2 -2
- package/dist/src/util/zod.d.ts.map +1 -1
- package/dist/src/viewport/use.d.ts +1 -1
- package/dist/src/viewport/use.d.ts.map +1 -1
- package/dist/src/vis/axis/axis.d.ts +10 -10
- package/dist/src/vis/axis/axis.d.ts.map +1 -1
- package/dist/src/vis/axis/ticks.d.ts +2 -2
- package/dist/src/vis/axis/ticks.d.ts.map +1 -1
- package/dist/src/vis/button/aether/button.d.ts +25 -7
- package/dist/src/vis/button/aether/button.d.ts.map +1 -1
- package/dist/src/vis/button/use.d.ts +5 -3
- package/dist/src/vis/button/use.d.ts.map +1 -1
- package/dist/src/vis/canvas/aether/canvas.d.ts +11 -11
- package/dist/src/vis/canvas/aether/canvas.d.ts.map +1 -1
- package/dist/src/vis/diagram/Diagram.d.ts +3 -2
- package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts +32 -32
- package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/types.d.ts +19 -45
- package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
- package/dist/src/vis/diagram/align.d.ts.map +1 -1
- package/dist/src/vis/diagram/edge/connector/connector.d.ts +2 -2
- package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
- package/dist/src/vis/draw2d/canvas.d.ts +1 -4
- package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
- package/dist/src/vis/draw2d/index.d.ts.map +1 -1
- package/dist/src/vis/eraser/aether/eraser.d.ts +11 -11
- package/dist/src/vis/eraser/aether/eraser.d.ts.map +1 -1
- package/dist/src/vis/eraser/use.d.ts +1 -1
- package/dist/src/vis/eraser/use.d.ts.map +1 -1
- package/dist/src/vis/grid/grid.d.ts +3 -3
- package/dist/src/vis/grid/grid.d.ts.map +1 -1
- package/dist/src/vis/legend/Container.d.ts +7 -7
- package/dist/src/vis/legend/Container.d.ts.map +1 -1
- package/dist/src/vis/light/aether/light.d.ts +7 -8
- package/dist/src/vis/light/aether/light.d.ts.map +1 -1
- package/dist/src/vis/light/use.d.ts +2 -2
- package/dist/src/vis/light/use.d.ts.map +1 -1
- package/dist/src/vis/line/Line.d.ts +1 -1
- package/dist/src/vis/line/Line.d.ts.map +1 -1
- package/dist/src/vis/line/aether/line.d.ts +10 -10
- package/dist/src/vis/line/aether/line.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Axis.d.ts +2 -2
- package/dist/src/vis/lineplot/Axis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/Line.d.ts +1 -1
- package/dist/src/vis/lineplot/Line.d.ts.map +1 -1
- package/dist/src/vis/lineplot/LinePlot.d.ts +2 -2
- package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts +7 -7
- package/dist/src/vis/lineplot/aether/BoundQuerier.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/LinePlot.d.ts +30 -30
- package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/XAxis.d.ts +64 -64
- package/dist/src/vis/lineplot/aether/XAxis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/YAxis.d.ts +64 -64
- package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/axis.d.ts +13 -13
- package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/Annotation.d.ts +2 -2
- package/dist/src/vis/lineplot/range/Annotation.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/Provider.d.ts +1 -1
- package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/aether/annotation.d.ts +11 -11
- package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/aether/provider.d.ts +31 -29
- package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
- package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts +2 -2
- package/dist/src/vis/lineplot/tooltip/Tooltip.d.ts.map +1 -1
- package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts +29 -29
- package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
- package/dist/src/vis/lineplot/useBoundQuerier.d.ts.map +1 -1
- package/dist/src/vis/log/Log.d.ts +2 -2
- package/dist/src/vis/log/Log.d.ts.map +1 -1
- package/dist/src/vis/log/aether/Log.d.ts +37 -37
- package/dist/src/vis/log/aether/Log.d.ts.map +1 -1
- package/dist/src/vis/measure/Measure.d.ts +1 -1
- package/dist/src/vis/measure/Measure.d.ts.map +1 -1
- package/dist/src/vis/measure/aether/measure.d.ts +36 -36
- package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
- package/dist/src/vis/render/context.d.ts.map +1 -1
- package/dist/src/vis/render/loop.d.ts +10 -15
- package/dist/src/vis/render/loop.d.ts.map +1 -1
- package/dist/src/vis/rule/Rule.d.ts +2 -2
- package/dist/src/vis/rule/Rule.d.ts.map +1 -1
- package/dist/src/vis/rule/aether/aether.d.ts +10 -10
- package/dist/src/vis/rule/aether/aether.d.ts.map +1 -1
- package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
- package/dist/src/vis/schematic/Grid.d.ts +6 -3
- package/dist/src/vis/schematic/Grid.d.ts.map +1 -1
- package/dist/src/vis/schematic/SelectOrientation.d.ts +3 -2
- package/dist/src/vis/schematic/SelectOrientation.d.ts.map +1 -1
- package/dist/src/vis/schematic/Symbols.d.ts +108 -99
- package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
- package/dist/src/vis/schematic/external.d.ts +1 -0
- package/dist/src/vis/schematic/external.d.ts.map +1 -1
- package/dist/src/vis/schematic/primitives/Primitives.d.ts +28 -28
- package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
- package/dist/src/vis/schematic/registry.d.ts +5 -5
- package/dist/src/vis/schematic/registry.d.ts.map +1 -1
- package/dist/src/vis/setpoint/aether/setpoint.d.ts +11 -11
- package/dist/src/vis/setpoint/aether/setpoint.d.ts.map +1 -1
- package/dist/src/vis/setpoint/use.d.ts +2 -2
- package/dist/src/vis/setpoint/use.d.ts.map +1 -1
- package/dist/src/vis/text/atlas.d.ts +0 -2
- package/dist/src/vis/text/atlas.d.ts.map +1 -1
- package/dist/src/vis/text/index.d.ts.map +1 -1
- package/dist/src/vis/toggle/aether/toggle.d.ts +11 -12
- package/dist/src/vis/toggle/aether/toggle.d.ts.map +1 -1
- package/dist/src/vis/toggle/use.d.ts +2 -2
- package/dist/src/vis/toggle/use.d.ts.map +1 -1
- package/dist/src/vis/value/aether/value.d.ts +43 -43
- package/dist/src/vis/value/aether/value.d.ts.map +1 -1
- package/dist/src/vis/value/use.d.ts +15 -15
- package/dist/src/vis/value/use.d.ts.map +1 -1
- package/dist/state-DAFH2z9y.js +4082 -0
- package/dist/state-DwM4WaEw.cjs +27 -0
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/dist/useClickOutside-CUa496t0.cjs +1 -0
- package/dist/{useClickOutside-DDCP7Fh-.js → useClickOutside-Dw3KdU3w.js} +22 -22
- package/dist/{useDebouncedCallback-DnwYZzjR.cjs → useDebouncedCallback-Bx-HX76R.cjs} +1 -1
- package/dist/{useDebouncedCallback-BG4I7mbT.js → useDebouncedCallback-Cvo_HNow.js} +1 -1
- package/dist/{useMemoCompare-BViQehyd.js → useMemoCompare-B5QPDK2p.js} +2 -2
- package/dist/{useMemoCompare-C2X7Mzx8.cjs → useMemoCompare-BDs2sKw5.cjs} +1 -1
- package/dist/useVirtualCursorDragWebKit-CUbBopD6.cjs +1 -0
- package/dist/{useVirtualCursorDragWebKit-DTU2tUmp.js → useVirtualCursorDragWebKit-CfxbToxm.js} +7 -7
- package/dist/value-BVL4mfhG.cjs +55 -0
- package/dist/value-DLy5XRhS.js +10797 -0
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +24 -23
- package/dist/ContextMenu-HpMLd1Ht.cjs +0 -1
- package/dist/DateTime-BsjSfOY-.cjs +0 -1
- package/dist/DateTime-r6hocEmI.js +0 -17
- package/dist/Divider-Dut8qPee.cjs +0 -22
- package/dist/Dropdown-BSSe1E1e.cjs +0 -1
- package/dist/Dropdown-BrFL1eSc.js +0 -327
- package/dist/Haul-C6i2oI7z.cjs +0 -1
- package/dist/Haul-CEFSvdy9.js +0 -124
- package/dist/Pack-BozAEHBp.js +0 -48
- package/dist/Pack-DeZUUdJM.cjs +0 -1
- package/dist/Provider-B86QO9NT.js +0 -461
- package/dist/Provider-Cw0mSr2D.cjs +0 -1
- package/dist/Text-C8GBHl-F.cjs +0 -1
- package/dist/Text-CMTkSEWx.cjs +0 -4
- package/dist/Toggle-C0lZDyeo.cjs +0 -1
- package/dist/WithIcon-BgS5shNZ.cjs +0 -1
- package/dist/css-9iEiTRNL.cjs +0 -15
- package/dist/css-Cnb9DQMD.js +0 -4747
- package/dist/deep-BNa3STCp.cjs +0 -1
- package/dist/deep-P35D0Sz7.js +0 -112
- package/dist/eraser-BkqFgBRY.cjs +0 -11
- package/dist/external-B7NxSklQ.js +0 -60
- package/dist/external-BA_VOnV-.js +0 -400
- package/dist/external-BGBgNbe2.cjs +0 -1
- package/dist/external-CTc1n-JC.cjs +0 -1
- package/dist/external-CzTBFiv_.cjs +0 -1
- package/dist/external-DGJ8YAe-.cjs +0 -1
- package/dist/external-DiLZ1dEk.cjs +0 -1
- package/dist/external-Dq8-cbf3.cjs +0 -1
- package/dist/fontString-Ddza50DF.cjs +0 -1
- package/dist/hooks-B5aLaWzS.cjs +0 -1
- package/dist/provider-aWtsGnV8.cjs +0 -58
- package/dist/provider-r5Ly36FI.js +0 -12854
- package/dist/src/aether/aether/aether.spec.spec.d.ts +0 -5
- package/dist/src/aether/aether/aether.spec.spec.d.ts.map +0 -1
- package/dist/src/select/Modal.d.ts +0 -1
- package/dist/src/select/Modal.d.ts.map +0 -1
- package/dist/src/status/Circle.d.ts +0 -8
- package/dist/src/status/Circle.d.ts.map +0 -1
- package/dist/src/text/dimensions.d.ts +0 -4
- package/dist/src/text/dimensions.d.ts.map +0 -1
- package/dist/src/vis/performance/Performance.d.ts +0 -2
- package/dist/src/vis/performance/Performance.d.ts.map +0 -1
- package/dist/src/vis/performance/aether/index.d.ts +0 -2
- package/dist/src/vis/performance/aether/index.d.ts.map +0 -1
- package/dist/src/vis/performance/aether/performance.d.ts +0 -15
- package/dist/src/vis/performance/aether/performance.d.ts.map +0 -1
- package/dist/src/vis/performance/index.d.ts +0 -2
- package/dist/src/vis/performance/index.d.ts.map +0 -1
- package/dist/state-CjGemC7S.js +0 -88
- package/dist/state-_FFrG5nH.cjs +0 -1
- package/dist/toArray-B7nD2CTw.js +0 -5
- package/dist/toArray-BvVYuN_b.cjs +0 -1
- package/dist/units-CX_coN92.cjs +0 -1
- package/dist/units-Ct3Xl5nK.js +0 -11
- package/dist/useClickOutside-CSff8yb-.cjs +0 -1
- package/dist/useVirtualCursorDragWebKit-DDmXE4RW.cjs +0 -1
- package/dist/value-B6OlPXe1.js +0 -5974
- package/dist/value-Bq1w9UY8.cjs +0 -57
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";var Rl=Object.defineProperty;var Dl=(s,e,t)=>e in s?Rl(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var L=(s,e,t)=>Dl(s,typeof e!="symbol"?e+"":e,t);const i=require("zod"),T=require("./css-9iEiTRNL.cjs"),Ml=require("./deep-BNa3STCp.cjs"),We=require("./state-_FFrG5nH.cjs");var Pl=Object.defineProperty,$l=(s,e,t)=>e in s?Pl(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ks=(s,e,t)=>$l(s,typeof e!="symbol"?e+"":e,t);let Ll=class{constructor(e){Ks(this,"sender"),Ks(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var t;const n=(t=this.handlers.get(e.type))==null?void 0:t.handler;n==null?console.warn(`No handler for ${e.type}`):n(e.payload)}route(e){const t=Fl(e,this.sender),n=new _l(t);return this.handlers.set(e,n),n}};const Fl=(s,e)=>(t,n)=>e({type:s,payload:t},n);class _l{constructor(e){Ks(this,"_send"),Ks(this,"handler"),this._send=e,this.handler=null}send(e,t=[]){this._send(e,t)}handle(e){this.handler=e}}const ql=i.z.object({l0:T.Dt.colorZ,l1:T.Dt.colorZ,l2:T.Dt.colorZ,l3:T.Dt.colorZ,l4:T.Dt.colorZ,l5:T.Dt.colorZ,l6:T.Dt.colorZ,l7:T.Dt.colorZ,l8:T.Dt.colorZ,l9:T.Dt.colorZ,l10:T.Dt.colorZ,l11:T.Dt.colorZ}),ye=(s,e)=>[s[0],s[1],e,s[3]],Wl=i.z.object({m2:T.Dt.colorZ,m1:T.Dt.colorZ,z:T.Dt.colorZ,p1:T.Dt.colorZ,p2:T.Dt.colorZ}),Es=Wl.or(T.Dt.colorZ.transform(s=>{const e=T.Dt.hsla(s);return{m2:T.Dt.fromHSLA(ye(e,40)),m1:T.Dt.fromHSLA(ye(e,45)),z:s,p1:T.Dt.fromHSLA(ye(e,55)),p2:T.Dt.fromHSLA(ye(e,65))}})),Ga=i.z.object({name:i.z.string(),key:i.z.string(),colors:i.z.object({border:T.Dt.colorZ,primary:Es,gray:ql,error:Es,secondary:Es,warning:Es,palettes:i.z.record(i.z.string(),T.Dt.paletteZ),visualization:i.z.object({palettes:i.z.record(i.z.string(),i.z.array(T.Dt.colorZ))}).optional().default({palettes:{}}),white:T.Dt.colorZ,black:T.Dt.colorZ,text:T.Dt.colorZ,textInverted:T.Dt.colorZ,textOnPrimary:T.Dt.colorZ.optional().default(T.Dt.ZERO),logo:i.z.string()}),sizes:i.z.object({base:i.z.number(),border:i.z.object({radius:i.z.number(),width:i.z.number(),thickWidth:i.z.number()}),schematic:i.z.object({elementStrokeWidth:i.z.number()})}),typography:i.z.object({family:i.z.string(),codeFamily:i.z.string(),h1:We.specZ,h2:We.specZ,h3:We.specZ,h4:We.specZ,h5:We.specZ,p:We.specZ,small:We.specZ})}).transform(s=>((s.colors.textOnPrimary==null||T.Dt.isZero(s.colors.textOnPrimary))&&(s.colors.textOnPrimary=T.Dt.pickByContrast(s.colors.primary.z,s.colors.text,s.colors.textInverted)),s)),Vl="'Inter Variable', sans-serif",Yl="'Geist Mono', monospace",Zl=6,Nt=[357,91,55,1],At=[58,100,50,1],Kl=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],Ut=Object.fromEntries(Kl.map((s,e)=>[`l${e}`,s])),Hl=()=>typeof window>"u"?!1:window.devicePixelRatio>1,Gl=Hl(),nr={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:Ut,border:Ut.l4,error:{m2:T.Dt.fromHSLA(ye(Nt,30)),m1:T.Dt.fromHSLA(ye(Nt,40)),z:T.Dt.fromHSLA(Nt),p1:T.Dt.fromHSLA(ye(Nt,65)),p2:T.Dt.fromHSLA(ye(Nt,77))},warning:{m2:T.Dt.fromHSLA(ye(At,30)),m1:T.Dt.fromHSLA(ye(At,40)),z:T.Dt.fromHSLA(At),p1:T.Dt.fromHSLA(ye(At,65)),p2:T.Dt.fromHSLA(ye(At,75))},palettes:{recent:{key:"recent",name:"Recent",swatches:[]}},visualization:{palettes:{default:["#DC136C","#20A4F3","#7AC74F","#FFC43D","#FE5F55","#8075FF","#D90429","#f7aef8","#f18f01","#791e94","#279af1","#d9fff5","#ff6b6b","#52ffb8"]}},logo:"url(#synnax-linear-gradient)",white:"#FFFFFF",black:"#000000",text:Ut.l11,textInverted:Ut.l0,textOnPrimary:Ut.l0},sizes:{base:Zl,border:{radius:3,width:Gl?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:Vl,codeFamily:Yl,h1:{size:6,weight:"500",lineHeight:6*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.6666,weight:"medium",lineHeight:2.6666*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:2.3333333}}},Ja=Object.freeze({...nr,key:"synnaxLight",name:"Synnax Light"}),Jl=["#020202","#080808","#151515","#242424","#2F2F2F","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],Ct=Object.fromEntries(Jl.map((s,e)=>[`l${e}`,s])),Xa=Object.freeze({...nr,key:"synnaxDark",name:"Synnax Dark",colors:{...nr.colors,gray:Ct,logo:"var(--pluto-text-color)",border:Ct.l3,text:Ct.l11,textInverted:Ct.l0,textOnPrimary:Ct.l11}}),Xl={synnaxDark:Xa,synnaxLight:Ja},Ql=["tiny","small","medium","large","huge"],eh=i.z.enum(Ql),th=s=>eh.safeParse(s).success;var sh=Object.defineProperty,nh=(s,e,t)=>e in s?sh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,l=(s,e,t)=>nh(s,typeof e!="symbol"?e+"":e,t);const b=s=>Array.isArray(s)?s:[s],rh="policy",Qa="allow_all";var ih=Object.defineProperty,ah=(s,e,t)=>e in s?ih(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,G=(s,e,t)=>ah(s,typeof e!="symbol"?e+"":e,t);const oh=s=>{const e=s.replace(/_[a-z]/g,t=>t[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)},eo=s=>{const e=(t,n=rr)=>{if(typeof t=="string")return s(t);if(Array.isArray(t))return t.map(o=>e(o,n));if(!kn(t))return t;n=lh(n);const r={},a=t;return Object.keys(a).forEach(o=>{let c=a[o];const h=s(o);n.recursive&&(kn(c)?Mi(c,n.keepTypesOnRecursion)||(c=e(c,n)):n.recursiveInArray&&Di(c)&&(c=[...c].map(d=>{let f=d;return kn(d)?Mi(f,n.keepTypesOnRecursion)||(f=e(d,n)):Di(d)&&(f=e({key:d},n).key),f}))),r[h]=c}),r};return e},Yr=eo(oh),ch=s=>s.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`),to=eo(ch),rr={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},lh=(s=rr)=>(s.recursive==null?s=rr:s.recursiveInArray??(s.recursiveInArray=!1),s),Di=s=>s!=null&&Array.isArray(s),kn=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),Mi=(s,e)=>(e||[]).some(t=>s instanceof t),Zr=s=>s!=null&&typeof s=="object"&&!Array.isArray(s);var hh=Object.defineProperty,uh=(s,e,t)=>e in s?hh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ft=(s,e,t)=>uh(s,typeof e!="symbol"?e+"":e,t);function dh(s){const e=s.length;let t=0,n=0;for(;n<e;){let r=s.charCodeAt(n++);if((r&4294967168)===0){t++;continue}else if((r&4294965248)===0)t+=2;else{if(r>=55296&&r<=56319&&n<e){const a=s.charCodeAt(n);(a&64512)===56320&&(++n,r=((r&1023)<<10)+(a&1023)+65536)}(r&4294901760)===0?t+=3:t+=4}}return t}function fh(s,e,t){const n=s.length;let r=t,a=0;for(;a<n;){let o=s.charCodeAt(a++);if((o&4294967168)===0){e[r++]=o;continue}else if((o&4294965248)===0)e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&a<n){const c=s.charCodeAt(a);(c&64512)===56320&&(++a,o=((o&1023)<<10)+(c&1023)+65536)}(o&4294901760)===0?(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128):(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128)}e[r++]=o&63|128}}const yh=new TextEncoder,ph=50;function gh(s,e,t){yh.encodeInto(s,e.subarray(t))}function mh(s,e,t){s.length>ph?gh(s,e,t):fh(s,e,t)}const wh=4096;function so(s,e,t){let n=e;const r=n+t,a=[];let o="";for(;n<r;){const c=s[n++];if((c&128)===0)a.push(c);else if((c&224)===192){const h=s[n++]&63;a.push((c&31)<<6|h)}else if((c&240)===224){const h=s[n++]&63,d=s[n++]&63;a.push((c&31)<<12|h<<6|d)}else if((c&248)===240){const h=s[n++]&63,d=s[n++]&63,f=s[n++]&63;let u=(c&7)<<18|h<<12|d<<6|f;u>65535&&(u-=65536,a.push(u>>>10&1023|55296),u=56320|u&1023),a.push(u)}else a.push(c);a.length>=wh&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}const bh=new TextDecoder,vh=200;function Sh(s,e,t){const n=s.subarray(e,e+t);return bh.decode(n)}function Th(s,e,t){return t>vh?Sh(s,e,t):so(s,e,t)}let Ns=class{constructor(s,e){this.type=s,this.data=e}},ze=class ir extends Error{constructor(e){super(e);const t=Object.create(ir.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:ir.name})}};const Bt=4294967295;function zh(s,e,t){const n=t/4294967296,r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function no(s,e,t){const n=Math.floor(t/4294967296),r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function ro(s,e){const t=s.getInt32(e),n=s.getUint32(e+4);return t*4294967296+n}function Oh(s,e){const t=s.getUint32(e),n=s.getUint32(e+4);return t*4294967296+n}const kh=-1,xh=4294967296-1,Ih=17179869184-1;function Eh({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=Ih)if(e===0&&s<=xh){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{const t=s/4294967296,n=s&4294967295,r=new Uint8Array(8),a=new DataView(r.buffer);return a.setUint32(0,e<<2|t&3),a.setUint32(4,n),r}else{const t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),no(n,4,s),t}}function Nh(s){const e=s.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,r=Math.floor(n/1e9);return{sec:t+r,nsec:n-r*1e9}}function Ah(s){if(s instanceof Date){const e=Nh(s);return Eh(e)}else return null}function Uh(s){const e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const t=e.getUint32(0),n=e.getUint32(4),r=(t&3)*4294967296+n,a=t>>>2;return{sec:r,nsec:a}}case 12:{const t=ro(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new ze(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function Ch(s){const e=Uh(s);return new Date(e.sec*1e3+e.nsec/1e6)}const Bh={type:kh,encode:Ah,decode:Ch};let cs=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Bh)}register({type:s,encode:e,decode:t}){if(s>=0)this.encoders[s]=e,this.decoders[s]=t;else{const n=-1-s;this.builtInEncoders[n]=e,this.builtInDecoders[n]=t}}tryToEncode(s,e){for(let t=0;t<this.builtInEncoders.length;t++){const n=this.builtInEncoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=-1-t;return new Ns(a,r)}}}for(let t=0;t<this.encoders.length;t++){const n=this.encoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=t;return new Ns(a,r)}}}return s instanceof Ns?s:null}decode(s,e,t){const n=e<0?this.builtInDecoders[-1-e]:this.decoders[e];return n?n(s,e,t):new Ns(e,s)}};cs.defaultCodec=new cs;function jh(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function ar(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):jh(s)?new Uint8Array(s):Uint8Array.from(s)}const Rh=100,Dh=2048;let Mh=class io{constructor(e){this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??cs.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Rh,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??Dh,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new io({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){const t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const t=dh(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),mh(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){const n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);const n=ar(e);this.writeU8a(n)}encodeArray(e,t){const n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(const r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let n=0;for(const r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){const n=Object.keys(e);this.sortKeys&&n.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(const a of n){const o=e[a];this.ignoreUndefined&&o===void 0||(this.encodeString(a),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){const n=e.data(this.pos+6),r=n.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(n);return}const t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),zh(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),no(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function $t(s,e){return new Mh(e).encodeSharedRef(s)}function xn(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}const Ph=16,$h=16;class Lh{constructor(e=Ph,t=$h){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){const r=this.caches[n-1];e:for(const a of r){const o=a.bytes;for(let c=0;c<n;c++)if(o[c]!==e[t+c])continue e;return a.str}return null}store(e,t){const n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){const r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;const a=so(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,a),a}}const or="array",ss="map_key",ao="map_value",Fh=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new ze("The type of key must be string or number but "+typeof s)};class _h{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const t=this.getUninitializedStateFromPool();t.type=or,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){const t=this.getUninitializedStateFromPool();t.type=ss,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===or){const t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===ss||e.type===ao){const t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const jt=-1,Kr=new DataView(new ArrayBuffer(0)),qh=new Uint8Array(Kr.buffer);try{Kr.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const Pi=new RangeError("Insufficient data"),Wh=new Lh;let Vh=class oo{constructor(e){this.totalPos=0,this.pos=0,this.view=Kr,this.bytes=qh,this.headByte=jt,this.stack=new _h,this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??cs.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??Bt,this.maxBinLength=(e==null?void 0:e.maxBinLength)??Bt,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??Bt,this.maxMapLength=(e==null?void 0:e.maxMapLength)??Bt,this.maxExtLength=(e==null?void 0:e.maxExtLength)??Bt,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:Wh,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??Fh}clone(){return new oo({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=jt,this.stack.reset()}setBuffer(e){const t=ar(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===jt&&!this.hasRemaining(1))this.setBuffer(e);else{const t=this.bytes.subarray(this.pos),n=ar(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(const c of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(c);try{n=this.doDecodeSync(),t=!0}catch(h){if(!(h instanceof RangeError))throw h}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}const{headByte:r,pos:a,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${xn(r)} at ${o} (${a} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(const a of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){const r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{const r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){const r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){const r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){const r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){const r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){const r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){const r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){const r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){const r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){const r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){const r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){const r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){const r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){const r=this.lookU32();t=this.decodeExtension(r,4)}else throw new ze(`Unrecognized type byte: ${xn(e)}`);this.complete();const n=this.stack;for(;n.length>0;){const r=n.top();if(r.type===or)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,n.release(r);else continue e;else if(r.type===ss){if(t==="__proto__")throw new ze("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=ao;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,n.release(r);else{r.key=null,r.type=ss;continue e}}return t}}readHeadByte(){return this.headByte===jt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=jt}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new ze(`Unrecognized array type byte: ${xn(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new ze(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new ze(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){var n;if(e>this.maxStrLength)throw new ze(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Pi;const r=this.pos+t;let a;return this.stateIsMapKey()&&(n=this.keyDecoder)!=null&&n.canBeCached(e)?a=this.keyDecoder.decode(this.bytes,r,e):a=Th(this.bytes,r,e),this.pos+=t+e,a}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===ss:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new ze(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Pi;const n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new ze(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Oh(this.view,this.pos);return this.pos+=8,e}readI64(){const e=ro(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function co(s,e){return new Vh(e).decode(s)}let Yh=class{constructor(){ft(this,"contentType","application/json"),ft(this,"decoder"),ft(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(s){return this.encoder.encode(this.encodeString(s))}decode(s,e){return this.decodeString(this.decoder.decode(s),e)}decodeString(s,e){const t=JSON.parse(s),n=Yr(t);return e!=null?e.parse(n):n}encodeString(s){const e=to(s);return JSON.stringify(e,(t,n)=>ArrayBuffer.isView(n)?Array.from(n):Zr(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},Zh=class{constructor(){ft(this,"contentType","text/csv")}encode(s){const e=this.encodeString(s);return new TextEncoder().encode(e)}decode(s,e){const t=new TextDecoder().decode(s);return this.decodeString(t,e)}encodeString(s){if(!Array.isArray(s)||s.length===0||!Zr(s[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(s[0]),t=[e.join(",")];return s.forEach(n=>{const r=e.map(a=>JSON.stringify(n[a]??""));t.push(r.join(","))}),t.join(`
|
|
2
|
-
`)}decodeString(s,e){const[t,...n]=s.trim().split(`
|
|
3
|
-
`).map(o=>o.trim());if(t.length===0)return e!=null?e.parse({}):{};const r=t.split(",").map(o=>o.trim()),a={};return r.forEach(o=>{a[o]=[]}),n.forEach(o=>{const c=o.split(",").map(h=>h.trim());r.forEach((h,d)=>{const f=this.parseValue(c[d]);f!=null&&a[h].push(f)})}),e!=null?e.parse(a):a}parseValue(s){if(s==null||s.length===0)return null;const e=Number(s);return isNaN(e)?s.startsWith('"')&&s.endsWith('"')?s.slice(1,-1):s:e}static registerCustomType(){}},Kh=class{constructor(){ft(this,"contentType","text/plain")}encode(s){return new TextEncoder().encode(s)}decode(s,e){const t=new TextDecoder().decode(s);return e!=null?e.parse(t):t}};const Ve=new cs;Ve.register({type:0,encode:s=>{if(ArrayBuffer.isView(s)){const e=Array.from(s);return $t(e,{extensionCodec:Ve})}return Zr(s)&&"encode_value"in s?typeof s.value=="bigint"?$t(s.value.toString(),{extensionCodec:Ve}):$t(s.value,{extensionCodec:Ve}):typeof s=="bigint"?$t(s.toString(),{extensionCodec:Ve}):null},decode:s=>co(s,{extensionCodec:Ve})});let Hh=class{constructor(){ft(this,"contentType","application/msgpack")}encode(s){const e=to(s);return $t(e,{extensionCodec:Ve}).slice()}decode(s,e){const t=co(s,{extensionCodec:Ve}),n=Yr(t);return e!=null?e.parse(n):n}static registerCustomType(){}};const Ls=new Yh;new Zh;new Kh;new Hh;const Gh=s=>s!=null&&typeof s=="object"&&"toString"in s,Jh=(s,e=!1)=>{const t=Gh(s)?"stringer":typeof s;let n;switch(t){case"string":n=(r,a)=>r.localeCompare(a);break;case"stringer":n=(r,a)=>r.toString().localeCompare(a.toString());break;case"number":n=(r,a)=>Number(r)-Number(a);break;case"bigint":n=(r,a)=>BigInt(r)-BigInt(a)>0n?1:-1;break;case"boolean":n=(r,a)=>Number(r)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Xh(n):n},Xh=s=>(e,t)=>s(t,e),sn=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const lo=i.z.object({width:i.z.number(),height:i.z.number()}),Qh=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),eu=["width","height"];i.z.enum(eu);const tu=["start","center","end"],su=["signedWidth","signedHeight"];i.z.enum(su);const Hs=i.z.object({x:i.z.number(),y:i.z.number()}),nu=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),ru=["x","y"],ho=i.z.enum(ru),uo=["top","right","bottom","left"];i.z.enum(uo);const iu=["left","right"],fo=i.z.enum(iu),au=["top","bottom"],yo=i.z.enum(au),po=["center"],$i=i.z.enum(po),ou=[...uo,...po],go=i.z.enum(ou);i.z.enum(tu);const cu=["first","last"];i.z.enum(cu);const lu=i.z.object({lower:i.z.number(),upper:i.z.number()}),hu=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([lu,sn]);i.z.union([hu,sn]);i.z.enum([...ho.options,...go.options]);i.z.union([ho,go,i.z.instanceof(String)]);const uu=s=>typeof s=="bigint"||s instanceof BigInt,ot=(s,e)=>uu(s)?s.valueOf()*BigInt(e.valueOf()):s.valueOf()*Number(e.valueOf()),Qe=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return Li(s);return Li(t)},Li=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s,Fi=(s,e)=>{const t=Qe(s);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e};i.z.object({x:fo.or($i),y:yo.or($i)});const du=i.z.object({x:fo,y:yo}),fu=Object.freeze({x:"left",y:"top"}),yu=(s,e)=>s.x===e.x&&s.y===e.y,_i=i.z.union([i.z.number(),Hs,sn,lo,Qh,nu]),pu=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},qi=Object.freeze({x:0,y:0}),As=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:As,left:As,width:As,height:As});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:Hs,two:Hs,root:du});const Hr=(s,e,t=0,n=0,r)=>{const a={one:{...qi},two:{...qi},root:r??fu};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},In=s=>{const e=Hr(s);return{lower:e.one.x,upper:e.two.x}},En=s=>{const e=Hr(s);return{lower:e.one.y,upper:e.two.y}},gu=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,mu=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([lo,mu,Hs,sn]);var wu=Object.defineProperty,bu=(s,e,t)=>e in s?wu(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Be=(s,e,t)=>bu(s,typeof e!="symbol"?e+"":e,t);const vu=(s,e,t)=>e!==void 0&&s<e?e:t!==void 0&&s>t?t:s;i.z.object({offset:_i,scale:_i});i.z.object({offset:i.z.number(),scale:i.z.number()});const Su=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],Tu=s=>(e,t,n,r)=>[e,r?n/s:n*s],zu=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:o,upper:c}=s,h=a-r,d=c-o;if(t==="dimension")return[s,n*(d/h)];const f=(n-r)*(d/h)+o;return[s,f]},Ou=s=>(e,t,n)=>[s,n],ku=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},xu=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=vu(n,r,a),[e,n]},cr=class Lt{constructor(){Be(this,"ops",[]),Be(this,"currBounds",null),Be(this,"currType",null),Be(this,"reversed",!1),this.ops=[]}static translate(e){return new Lt().translate(e)}static magnify(e){return new Lt().magnify(e)}static scale(e,t){return new Lt().scale(e,t)}translate(e){const t=this.new(),n=Su(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Tu(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Qe(e,t),r=this.new(),a=zu(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=Qe(e,t),r=this.new(),a=xu(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=Qe(e,t),r=this.new(),a=Ou(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=ku();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Lt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([o,c])=>r>=o&&r<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};Be(cr,"IDENTITY",new cr);let Wi=cr;const Vi=class Ue{constructor(e=new Wi,t=new Wi,n=null){Be(this,"x"),Be(this,"y"),Be(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Ue().translate(e,t)}static translateX(e){return new Ue().translateX(e)}static translateY(e){return new Ue().translateY(e)}static clamp(e){return new Ue().clamp(e)}static magnify(e){return new Ue().magnify(e)}static scale(e){return new Ue().scale(e)}static reBound(e){return new Ue().reBound(e)}translate(e,t){const n=pu(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(gu(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!yu(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(In(e)),t.y=t.y.scale(En(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(In(e)),t.y=this.y.reBound(En(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(In(e)),t.y=this.y.clamp(En(e)),t}copy(){const e=new Ue;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 Hr(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})}}};Be(Vi,"IDENTITY",new Vi);var Iu=Object.defineProperty,Eu=(s,e,t)=>e in s?Iu(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,p=(s,e,t)=>Eu(s,typeof e!="symbol"?e+"":e,t);let Nu=(s,e=21)=>(t=e)=>{let n="",r=t|0;for(;r--;)n+=s[Math.random()*s.length|0];return n};const Au="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Uu=Nu(Au,11),Cu=()=>Uu(),Bu=i.z.enum(["static","dynamic"]),mo=(s,e)=>{const t=new $(e);if(![C.DAY,C.HOUR,C.MINUTE,C.SECOND,C.MILLISECOND,C.MICROSECOND,C.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof $?new $(n):new C(n)},j=class v{constructor(e,t="UTC"){if(p(this,"value"),p(this,"encodeValue",!0),e==null)this.value=v.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*v.MILLISECOND.valueOf();else if(typeof e=="string")this.value=v.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=v.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new v(BigInt(r.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let h=v.hours(parseInt(n??"00")).add(v.minutes(parseInt(r??"00"))).add(v.seconds(parseInt(o??"00"))).add(v.milliseconds(parseInt(c??"00")));return t==="local"&&(h=h.add(v.utcOffset)),h.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new v(BigInt(n.getTime())*v.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(v.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new C(BigInt(new Date().getTimezoneOffset())*v.MINUTE.valueOf())}static since(e){return new v().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new v(e).valueOf()}span(e){return this.range(e).span}range(e){return new ns(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new v(e).valueOf()}afterEq(e){return this.valueOf()>=new v(e).valueOf()}before(e){return this.valueOf()<new v(e).valueOf()}beforeEq(e){return this.valueOf()<=new v(e).valueOf()}add(e){return new v(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new v(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(C.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(C.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(C.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(C.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(v.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new v(t)}get month(){return this.date().getUTCMonth()}setMonth(e){const t=this.date();return t.setUTCMonth(e),new v(t)}get day(){return this.date().getUTCDate()}setDay(e){const t=this.date();return t.setUTCDate(e),new v(t)}get hour(){return this.date().getUTCHours()}setHour(e){const t=this.date();return t.setUTCHours(e),new v(t,"UTC")}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setUTCMinutes(e),new v(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setUTCSeconds(e),new v(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new v(t)}toString(){return this.date().toISOString()}remainder(e){return mo(this,e)}get isToday(){return this.truncate(C.DAY).equals(v.now().truncate(C.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new v(new Date)}static max(...e){let t=v.MIN;for(const n of e){const r=new v(n);r.after(t)&&(t=r)}return t}static min(...e){let t=v.MAX;for(const n of e){const r=new v(n);r.before(t)&&(t=r)}return t}static nanoseconds(e,t="UTC"){return new v(e,t)}static microseconds(e,t="UTC"){return v.nanoseconds(e*1e3,t)}static milliseconds(e,t="UTC"){return v.microseconds(e*1e3,t)}static seconds(e,t="UTC"){return v.milliseconds(e*1e3,t)}static minutes(e,t="UTC"){return v.seconds(e*60,t)}static hours(e,t="UTC"){return v.minutes(e*60,t)}static days(e,t="UTC"){return v.hours(e*24,t)}};p(j,"NANOSECOND",j.nanoseconds(1)),p(j,"MICROSECOND",j.microseconds(1)),p(j,"MILLISECOND",j.milliseconds(1)),p(j,"SECOND",j.seconds(1)),p(j,"MINUTE",j.minutes(1)),p(j,"HOUR",j.hours(1)),p(j,"DAY",j.days(1)),p(j,"MAX",new j((1n<<63n)-1n)),p(j,"MIN",new j(0)),p(j,"ZERO",new j(0)),p(j,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new j(s.value)),i.z.string().transform(s=>new j(BigInt(s))),i.z.instanceof(Number).transform(s=>new j(s)),i.z.number().transform(s=>new j(s)),i.z.instanceof(j)]));let $=j;const R=class I{constructor(e){p(this,"value"),p(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof I?e:e instanceof Yi?e.period:e instanceof $?new I(e):["number","bigint"].includes(typeof e)?I.seconds(e):new I(e)}static fromMilliseconds(e){return e instanceof I?e:e instanceof Yi?e.period:e instanceof $?new I(e):["number","bigint"].includes(typeof e)?I.milliseconds(e):new I(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new I(e).valueOf()}greaterThan(e){return this.valueOf()>new I(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new I(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new I(e).valueOf()}remainder(e){return mo(this,e)}truncate(e){return new I(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(I.DAY),t=this.truncate(I.HOUR),n=this.truncate(I.MINUTE),r=this.truncate(I.SECOND),a=this.truncate(I.MILLISECOND),o=this.truncate(I.MICROSECOND),c=this.truncate(I.NANOSECOND),h=e,d=t.sub(e),f=n.sub(t),u=r.sub(n),z=a.sub(r),k=o.sub(a),Y=c.sub(o);let U="";return h.isZero||(U+=`${h.days}d `),d.isZero||(U+=`${d.hours}h `),f.isZero||(U+=`${f.minutes}m `),u.isZero||(U+=`${u.seconds}s `),z.isZero||(U+=`${z.milliseconds}ms `),k.isZero||(U+=`${k.microseconds}µs `),Y.isZero||(U+=`${Y.nanoseconds}ns`),U.trim()}mult(e){return new I(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(I.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(I.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(I.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(I.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(I.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(I.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new I(e).valueOf()}add(e){return new I(this.valueOf()+new I(e).valueOf())}sub(e){return new I(this.valueOf()-new I(e).valueOf())}static nanoseconds(e=1){return new I(e)}static microseconds(e=1){return I.nanoseconds(ot(e,1e3))}static milliseconds(e=1){return I.microseconds(ot(e,1e3))}static seconds(e=1){return I.milliseconds(ot(e,1e3))}static minutes(e=1){return I.seconds(ot(e,60))}static hours(e){return I.minutes(ot(e,60))}static days(e){return I.hours(ot(e,24))}};p(R,"NANOSECOND",R.nanoseconds(1)),p(R,"MICROSECOND",R.microseconds(1)),p(R,"MILLISECOND",R.milliseconds(1)),p(R,"SECOND",R.seconds(1)),p(R,"MINUTE",R.minutes(1)),p(R,"HOUR",R.hours(1)),p(R,"DAY",R.days(1)),p(R,"MAX",new R((1n<<63n)-1n)),p(R,"MIN",new R(0)),p(R,"ZERO",new R(0)),p(R,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new R(s.value)),i.z.string().transform(s=>new R(BigInt(s))),i.z.instanceof(Number).transform(s=>new R(s)),i.z.number().transform(s=>new R(s)),i.z.instanceof(R)]));let C=R;const Ft=class Fs extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Fs(e).valueOf()}get period(){return C.seconds(1/this.valueOf())}sampleCount(e){return new C(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ie(t).valueOf()}span(e){return C.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Fs(e)}static khz(e){return Fs.hz(e*1e3)}};p(Ft,"z",i.z.union([i.z.number().transform(s=>new Ft(s)),i.z.instanceof(Number).transform(s=>new Ft(s)),i.z.instanceof(Ft)]));let Yi=Ft;const X=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new lr(e*this.valueOf())}};p(X,"UNKNOWN",new X(0)),p(X,"BIT128",new X(16)),p(X,"BIT64",new X(8)),p(X,"BIT32",new X(4)),p(X,"BIT16",new X(2)),p(X,"BIT8",new X(1)),p(X,"z",i.z.union([i.z.number().transform(s=>new X(s)),i.z.instanceof(Number).transform(s=>new X(s)),i.z.instanceof(X)]));let ie=X;const be=class _t{constructor(e,t){p(this,"start"),p(this,"end"),typeof e=="object"&&"start"in e?(this.start=new $(e.start),this.end=new $(e.end)):(this.start=new $(e),this.end=new $(t))}get span(){return new C(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new _t(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=C.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=C.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 r=$.max(n.start,e.start),a=$.min(n.end,e.end);return a.before(r)?!1:new C(a.sub(r)).greaterThanOrEqual(t)}contains(e){return e instanceof _t?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new _t(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}static max(...e){return new _t($.min(...e.map(t=>t.start)),$.max(...e.map(t=>t.end)))}};p(be,"MAX",new be($.MIN,$.MAX)),p(be,"MIN",new be($.MAX,$.MIN)),p(be,"ZERO",new be($.ZERO,$.ZERO)),p(be,"z",i.z.union([i.z.object({start:$.z,end:$.z}).transform(s=>new be(s.start,s.end)),i.z.instanceof(be)]));let ns=be;const g=class _{constructor(e){if(p(this,"value"),p(this,"encodeValue",!0),e instanceof _||typeof e=="string"||typeof e.valueOf()=="string"){this.value=e.valueOf();return}const t=_.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){this.value=t.valueOf();return}throw this.value=_.UNKNOWN.valueOf(),new Error(`unable to find data type for ${e.toString()}`)}valueOf(){return this.value}get Array(){const e=_.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(_.JSON)||this.equals(_.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(_.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=_.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(_.UINT8)||this.equals(_.UINT16)||this.equals(_.UINT32)||this.equals(_.UINT64)}get isSigned(){return this.equals(_.INT8)||this.equals(_.INT16)||this.equals(_.INT32)||this.equals(_.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(_.INT32)&&e.equals(_.FLOAT64)||this.equals(_.INT8)&&e.equals(_.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}toJSON(){return this.toString()}get usesBigInt(){return _.BIG_INT_TYPES.some(e=>e.equals(this))}};p(g,"UNKNOWN",new g("unknown")),p(g,"FLOAT64",new g("float64")),p(g,"FLOAT32",new g("float32")),p(g,"INT64",new g("int64")),p(g,"INT32",new g("int32")),p(g,"INT16",new g("int16")),p(g,"INT8",new g("int8")),p(g,"UINT64",new g("uint64")),p(g,"UINT32",new g("uint32")),p(g,"UINT16",new g("uint16")),p(g,"UINT8",new g("uint8")),p(g,"BOOLEAN",g.UINT8),p(g,"TIMESTAMP",new g("timestamp")),p(g,"UUID",new g("uuid")),p(g,"STRING",new g("string")),p(g,"JSON",new g("json")),p(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),p(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),p(g,"DENSITIES",new Map([[g.UINT8.toString(),ie.BIT8],[g.UINT16.toString(),ie.BIT16],[g.UINT32.toString(),ie.BIT32],[g.UINT64.toString(),ie.BIT64],[g.FLOAT32.toString(),ie.BIT32],[g.FLOAT64.toString(),ie.BIT64],[g.INT8.toString(),ie.BIT8],[g.INT16.toString(),ie.BIT16],[g.INT32.toString(),ie.BIT32],[g.INT64.toString(),ie.BIT64],[g.TIMESTAMP.toString(),ie.BIT64],[g.STRING.toString(),ie.UNKNOWN],[g.JSON.toString(),ie.UNKNOWN],[g.UUID.toString(),ie.BIT128]])),p(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),p(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),p(g,"z",i.z.union([i.z.string().transform(s=>new g(s)),i.z.instanceof(g)]));let P=g;const ne=class Z extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Z.bytes(this.valueOf()+e.valueOf())}sub(e){return Z.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Z(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Z.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Z.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Z.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Z.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Z.TERABYTE.valueOf()}toString(){const e=this.truncate(Z.TERABYTE),t=this.truncate(Z.GIGABYTE),n=this.truncate(Z.MEGABYTE),r=this.truncate(Z.KILOBYTE),a=this.truncate(Z.BYTE),o=e,c=t.sub(e),h=n.sub(t),d=r.sub(n),f=a.sub(r);let u="";return o.isZero||(u+=`${o.terabytes}TB `),c.isZero||(u+=`${c.gigabytes}GB `),h.isZero||(u+=`${h.megabytes}MB `),d.isZero||(u+=`${d.kilobytes}KB `),(!f.isZero||u==="")&&(u+=`${f.valueOf()}B`),u.trim()}static bytes(e=1){return new Z(e)}static kilobytes(e=1){return Z.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Z.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Z.megabytes(e.valueOf()*1e3)}static terabytes(e){return Z.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};p(ne,"BYTE",new ne(1)),p(ne,"KILOBYTE",ne.kilobytes(1)),p(ne,"MEGABYTE",ne.megabytes(1)),p(ne,"GIGABYTE",ne.gigabytes(1)),p(ne,"TERABYTE",ne.terabytes(1)),p(ne,"ZERO",new ne(0)),p(ne,"z",i.z.union([i.z.number().transform(s=>new ne(s)),i.z.instanceof(ne)]));let lr=ne;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const wo=s=>{const e=typeof s;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||s instanceof $||s instanceof C||s instanceof Date},ju=(s,e,t,n=0)=>s.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!s.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(n.valueOf()):qt(t,-n).valueOf(),qt=(s,e)=>e==0?s:s==0?e:typeof s=="bigint"&&typeof e=="bigint"||typeof s=="number"&&typeof e=="number"?s+e:Number(s)+Number(e),Ru=s=>s==null?!1:Array.isArray(s)||s instanceof ArrayBuffer||ArrayBuffer.isView(s)&&!(s instanceof DataView)||s instanceof $u?!0:wo(s),$e=-1,Du=i.z.string().transform(s=>new Uint8Array(atob(s).split("").map(e=>e.charCodeAt(0))).buffer),Mu=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),hr=10,Pu=(s,e)=>{if(s==="string"&&!e.isVariable)throw new Error(`cannot convert series of type ${e.toString()} to string`);if(s==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(s==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Wt=class ve{constructor(e){p(this,"key",""),p(this,"isSynnaxSeries",!0),p(this,"dataType"),p(this,"sampleOffset"),p(this,"gl"),p(this,"_data"),p(this,"timeRange",ns.ZERO),p(this,"alignment",0n),p(this,"_cachedMin"),p(this,"_cachedMax"),p(this,"writePos",$e),p(this,"_refCount",0),p(this,"_cachedLength"),p(this,"_cachedIndexes"),Ru(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:a="static",alignment:o=0n,key:c=Cu()}=e,h=e.data??[];if(h instanceof ve||typeof h=="object"&&"isSynnaxSeries"in h&&h.isSynnaxSeries===!0){const u=h;this.key=u.key,this.dataType=u.dataType,this.sampleOffset=u.sampleOffset,this.gl=u.gl,this._data=u._data,this.timeRange=u.timeRange,this.alignment=u.alignment,this._cachedMin=u._cachedMin,this._cachedMax=u._cachedMax,this.writePos=u.writePos,this._refCount=u._refCount,this._cachedLength=u._cachedLength;return}const d=wo(h),f=Array.isArray(h);if(t!=null)this.dataType=new P(t);else{if(h instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||d){let u=h;if(!d){if(h.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");u=h[0]}if(typeof u=="string")this.dataType=P.STRING;else if(typeof u=="number")this.dataType=P.FLOAT64;else if(typeof u=="bigint")this.dataType=P.INT64;else if(typeof u=="boolean")this.dataType=P.BOOLEAN;else if(u instanceof $||u instanceof Date||u instanceof $)this.dataType=P.TIMESTAMP;else if(typeof u=="object")this.dataType=P.JSON;else throw new Error(`cannot infer data type of ${typeof u} when constructing a Series from a JS array`)}else this.dataType=new P(h)}if(!f&&!d)this._data=h;else{let u=d?[h]:h;const z=u[0];(z instanceof $||z instanceof Date||z instanceof C)&&(u=u.map(k=>new $(k).valueOf())),this.dataType.equals(P.STRING)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.join(`
|
|
4
|
-
`)}
|
|
5
|
-
`).buffer):this.dataType.equals(P.JSON)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.map(k=>Ls.encodeString(k)).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(u.map(k=>BigInt(Math.round(k)))).buffer:!this.dataType.usesBigInt&&typeof z=="bigint"?this._data=new this.dataType.Array(u.map(k=>Number(k))).buffer:this._data=new this.dataType.Array(u).buffer}this.key=c,this.alignment=o,this.sampleOffset=r??0,this.timeRange=n??ns.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const r=new new P(t).Array(e),a=new ve({data:r.buffer,dataType:t,...n});return a.writePos=0,a}static createTimestamps(e,t,n){const r=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(t.span(o)).valueOf());return new ve({data:a,dataType:P.TIMESTAMP,timeRange:r})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(`${e.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`);return new ve({data:n,dataType:P.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(`${e.map(r=>Ls.encodeString(r)).join(`
|
|
10
|
-
`)}
|
|
11
|
-
`);return new ve({data:n,dataType:P.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount<=0){console.warn("attempted to release a series with a negative reference count");return}this._refCount--,this._refCount===0&&this.gl.control!=null&&this.maybeGarbageCollectGLBuffer(this.gl.control)}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===$e)return 0;const t=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,t);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===$e)return 0;const t=this.capacity-this.writePos,n=e.sub(0,t);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===$e?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(P.STRING,P.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
12
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(P.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=P.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const r=this.underlyingData.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(r.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(P.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
|
|
13
|
-
`).slice(0,-1).map(t=>e.parse(Ls.decodeString(t)))}get byteCapacity(){return new lr(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===$e?this.byteCapacity:this.dataType.isVariable?new lr(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===$e?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((n,r)=>{n===hr&&(e++,t.push(r+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let r=0;r<this.length;r++)n[r]=ju(this.dataType,e,this.data[r],t);return new ve({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(P.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),qt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(P.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),qt(this._cachedMin,this.sampleOffset))}get bounds(){return Qe(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return qt(this.max,-this.min)}atAlignment(e,t){const n=Number(e-this.alignment);if(n<0||n>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return qt(n,this.sampleOffset)}atVariable(e,t){let n=0,r=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],r=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]===hr){if(e===0){r=o;break}n=o+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(n,r);return this.dataType.equals(P.STRING)?new TextDecoder().decode(a):Yr(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const r=Jh(e);for(;t<=n;){const a=Math.floor((t+n)/2),o=r(this.at(a,!0),e);if(o===0)return a;o<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(P.FLOAT32)&&!this.dataType.equals(P.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==$e){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(r).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=$e}as(e){return Pu(e,this.dataType),this}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Xi(this.alignmentBounds.lower),upper:Xi(this.alignmentBounds.upper)},timeRange:(e=this.timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return Qe(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Lu(this);return this.dataType.equals(P.JSON)?new Fu(e):e}return new _u(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Zi(this,e,t??this.length)}subAlignmentIterator(e,t){return new Zi(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,t);return new ve({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,n){if(t<=0&&(n==null||n>=this.length))return this;let r;return e?r=this.data.subarray(t,n):r=this.data.slice(t,n),new ve({data:r,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new ve({data:this.buffer,dataType:this.dataType,timeRange:ns.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){var e,t;let n=`${this.dataType.toString()} ${this.length} [`;if(this.length<=10)n+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)n+=`${(e=this.at(r))==null?void 0:e.toString()}`,r<4&&(n+=",");n+="...";for(let r=-5;r<0;r++)n+=(t=this.at(r))==null?void 0:t.toString(),r<-1&&(n+=",")}return n+="]",n}};p(Wt,"crudeZ",i.z.object({timeRange:ns.z.optional(),dataType:P.z,alignment:i.z.coerce.bigint().optional(),data:i.z.union([Du,Mu,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:Bu.optional().default("static").optional()})),p(Wt,"z",Wt.crudeZ.transform(s=>new Wt(s)));let $u=Wt,Zi=class{constructor(s,e,t){p(this,"series"),p(this,"end"),p(this,"index"),this.series=s;const n=Qe(0,s.length);this.end=Fi(n,t),this.index=Fi(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};class Lu{constructor(e){if(p(this,"series"),p(this,"index"),p(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==hr;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var Ki,Hi;const bo=class vo{constructor(e){p(this,"wrapped"),p(this,Ki,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Ls.decodeString(e.value,vo.SCHEMA)}}[(Hi=Symbol.iterator,Ki=Symbol.toStringTag,Hi)](){return this}};p(bo,"SCHEMA",i.z.record(i.z.string(),i.z.unknown()));let Fu=bo;var Gi,Ji;class _u{constructor(e){p(this,"series"),p(this,"index"),p(this,Gi,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(Ji=Symbol.iterator,Gi=Symbol.toStringTag,Ji)](){return this}}const Xi=s=>{const e=s>>32n,t=s&0xffffffffn;return{domain:e,sample:t}};i.z.object({key:i.z.string(),value:i.z.string()});i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown());const So=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",qu=So(),To=["macOS","Windows","Linux"],Wu=["macos","windows","linux"],Vu={macos:"macOS",windows:"Windows",linux:"Linux"},Yu=i.z.enum(To).or(i.z.enum(Wu).transform(s=>Vu[s])),Zu=()=>{if(typeof window>"u")return;const s=window.navigator.userAgent.toLowerCase();if(s.includes("mac"))return"macOS";if(s.includes("win"))return"Windows";if(s.includes("linux"))return"Linux"};let Nn;const Ku=(s={})=>{const{force:e,default:t}=s;return e??Nn??(Nn=Zu(),Nn??t)},zo=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:To,RUNTIME:qu,detect:So,getOS:Ku,osZ:Yu},Symbol.toStringTag,{value:"Module"}));var Hu=Object.defineProperty,Gu=(s,e,t)=>e in s?Hu(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vt=(s,e,t)=>Gu(s,typeof e!="symbol"?e+"":e,t);const Ju=(...s)=>s.map(Oo).join(""),Oo=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),Xu=s=>s.endsWith("/")?s.slice(0,-1):s,Qu=(s,e="")=>s===null?"":`?${Object.entries(s).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&")}`,ur=class dr{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){Vt(this,"protocol"),Vt(this,"host"),Vt(this,"port"),Vt(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Oo(r)}replace(e){return new dr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new dr({...this,pathPrefix:Ju(this.path,e)})}toString(){return Xu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Vt(ur,"UNKNOWN",new ur({host:"unknown",port:0}));let ed=ur;const td=-128,sd=127;i.z.number().int().min(td).max(sd);const nd=-32768,rd=32767;i.z.number().int().min(nd).max(rd);const id=-2147483648,ad=2147483647;i.z.number().int().min(id).max(ad);const od=-9223372036854775808n,cd=9223372036854775807n;i.z.bigint().min(od).max(cd);const ld=255;i.z.number().int().min(0).max(ld);const hd=65535;i.z.number().int().min(0).max(hd);const ud=4294967295;i.z.number().int().min(0).max(ud);const dd=18446744073709551615n;i.z.bigint().min(0n).max(dd);var fd=Object.defineProperty,yd=(s,e,t)=>e in s?fd(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ke=(s,e,t)=>yd(s,typeof e!="symbol"?e+"":e,t);const pd=async s=>await new Promise(e=>setTimeout(e,C.fromMilliseconds(s).milliseconds));class gd{constructor(e){ke(this,"config"),ke(this,"retries"),ke(this,"interval"),this.config={baseInterval:new C((e==null?void 0:e.baseInterval)??C.seconds(1)),maxRetries:(e==null?void 0:e.maxRetries)??5,scale:(e==null?void 0:e.scale)??1,sleepFn:(e==null?void 0:e.sleepFn)??pd},this.retries=0,this.interval=new C(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:t,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(t),this.retries++,!0)}reset(){this.retries=0,this.interval=this.config.baseInterval}}const md=i.z.object({baseInterval:C.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),wd=Object.freeze(Object.defineProperty({__proto__:null,Breaker:gd,breakerConfig:md},Symbol.toStringTag,{value:"Module"})),bd=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Gr=i.z.string().regex(bd),yt=i.z.number().min(0).max(255),vd=i.z.number().min(0).max(1),Jr=i.z.tuple([yt,yt,yt,vd]),ko=i.z.tuple([yt,yt,yt]),xo=i.z.object({rgba255:Jr}),Xr=(s,e=1)=>{if(typeof s=="string")return Td(s,e);if(Array.isArray(s)){if(s.length<3||s.length>4)throw new Error(`Invalid color: [${s.join(", ")}]`);return s.length===3?[...s,e]:s}if(typeof s=="object"&&"rgba255"in s)return s.rgba255;throw new Error(`Invalid color: ${JSON.stringify(s)}`)},Sd=i.z.union([Gr,Jr,ko,xo]).transform(s=>Xr(s)),Td=(s,e=1)=>{if(!Gr.safeParse(s).success)throw new Error(`Invalid hex color: ${s}`);return s=zd(s),[Us(s,0),Us(s,2),Us(s,4),s.length===8?Us(s,6)/255:e]},Us=(s,e)=>parseInt(s.slice(e,e+2),16),zd=s=>s.startsWith("#")?s.slice(1):s,Od=i.z.union([Gr,Jr,i.z.string(),ko,xo]);Xr("#000000");Xr("#ffffff");const kd=i.z.object({key:i.z.string(),color:Od,position:i.z.number(),switched:i.z.boolean().optional()});i.z.array(kd);const xd=i.z.object({key:i.z.string(),name:i.z.string(),color:Sd});i.z.object({key:i.z.string(),name:i.z.string(),swatches:i.z.array(xd)});const Id=i.z.number().int().min(0).max(255),Ed=i.z.object({name:i.z.string(),key:i.z.string()}),Gs=s=>i.z.object({subject:Ed,resource:s,authority:Id}),Nd=i.z.object({from:Gs(i.z.any()),to:i.z.null()}),Ad=i.z.object({from:i.z.null(),to:Gs(i.z.any())});i.z.union([Nd,Ad,i.z.object({from:Gs(i.z.any()),to:Gs(i.z.any())})]);const Ud=s=>Object.getOwnPropertySymbols(globalThis).includes(s),Cd=(s,e)=>{const t=Symbol.for(s);if(!Ud(t)){const n=e();Object.defineProperty(globalThis,t,{value:n})}return()=>globalThis[t]},Bd=s=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(s):e instanceof Error?e.message.startsWith(s):typeof e!="string"?!1:e.startsWith(s),nn=s=>{var e;return e=class extends Error{constructor(t,n){super(t,n),ke(this,"discriminator",e.discriminator),ke(this,"type",e.TYPE),ke(this,"matches",e.matches),this.name=e.TYPE}static sub(t){return nn(`${s}.${t}`)}},ke(e,"discriminator","FreighterError"),ke(e,"TYPE",s),ke(e,"matches",Bd(s)),e},Io=s=>{if(s==null||typeof s!="object")return!1;const e=s;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},lt="unknown",fr="nil";class jd{constructor(){ke(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:fr,data:""};if(Io(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:lt,data:e.message};if(typeof e=="string")return{type:lt,data:e};try{return{type:lt,data:JSON.stringify(e)}}catch{return{type:lt,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===fr)return null;if(e.type===lt)return new yr(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new yr(e.data)}}const Qr=Cd("synnax-error-registry",()=>new jd),Rd=({encode:s,decode:e})=>Qr().register({encode:s,decode:e}),Dd=s=>Qr().encode(s),Md=s=>s==null?null:Qr().decode(s);class yr extends nn("unknown"){}const Pd=i.z.object({type:i.z.string(),data:i.z.string()});class $d extends nn("canceled"){}const He=Object.freeze(Object.defineProperty({__proto__:null,Canceled:$d,NONE:fr,UNKNOWN:lt,Unknown:yr,createTyped:nn,decode:Md,encode:Dd,isTyped:Io,payloadZ:Pd,register:Rd},Symbol.toStringTag,{value:"Module"}));i.object({jsonrpc:i.string(),id:i.number().optional(),method:i.string().optional(),params:i.unknown().optional(),result:i.unknown().optional()});i.z.string().regex(/^\d+\.\d+\.\d+$/);const Ld=["standard","scientific","engineering"];i.z.enum(Ld);let ms=class extends He.createTyped("freighter"){},ge=class extends ms.sub("eof"){constructor(){super("EOF")}},mt=class extends ms.sub("stream_closed"){constructor(){super("StreamClosed")}},Ge=class extends ms.sub("unreachable"){constructor(s={}){const{message:e="Unreachable",url:t=ed.UNKNOWN}=s;super(e),G(this,"url"),this.url=t}};const Fd=s=>{if(!s.type.startsWith(ms.TYPE))return null;if(ge.matches(s))return{type:ge.TYPE,data:"EOF"};if(mt.matches(s))return{type:mt.TYPE,data:"StreamClosed"};if(Ge.matches(s))return{type:Ge.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${s.type}: ${s.message}`)},_d=s=>{if(!s.type.startsWith(ms.TYPE))return null;switch(s.type){case ge.TYPE:return new ge;case mt.TYPE:return new mt;case Ge.TYPE:return new Ge;default:throw new He.Unknown(`Unknown error type: ${s.data}`)}};He.register({encode:Fd,decode:_d});let Eo=class{constructor(){G(this,"middleware",[])}use(...s){this.middleware.push(...s)}async executeMiddleware(s,e){let t=0;const n=async r=>{if(t===this.middleware.length)return await e(r);const a=this.middleware[t];return t++,await a(r,n)};return await n(s)}};const No="Content-Type",Qi=s=>{if(zo.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(s==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(r,a)=>await e(r,{...a,agent:n})},qd=s=>"code"in s&&s.code==="ECONNREFUSED"||s.message.toLowerCase().includes("load failed"),Wd=400;class Vd extends Eo{constructor(e,t,n=!1){return super(),G(this,"endpoint"),G(this,"encoder"),G(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Qi(this.endpoint.protocol),new Proxy(this,{get:(r,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(r,a,o)})}get headers(){return{[No]:this.encoder.contentType}}async send(e,t,n,r){t=n==null?void 0:n.parse(t);let a=null;const o=this.endpoint.child(e),c={};c.method="POST",c.body=this.encoder.encode(t??{});const[,h]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async d=>{const f={...d,params:{}};c.headers={...this.headers,...d.params};let u;try{u=await Qi(d.protocol)(d.target,c)}catch(k){let Y=k;return qd(Y)&&(Y=new Ge({url:o})),[f,Y]}const z=new Uint8Array(await(await u.blob()).arrayBuffer());if(u!=null&&u.ok)return r!=null&&(a=this.encoder.decode(z,r)),[f,null];try{if(u.status!==Wd)return[f,new Error(u.statusText)];const k=this.encoder.decode(z,He.payloadZ),Y=He.decode(k);return[f,Y]}catch(k){return[f,new Error(`[freighter] - failed to decode error: ${u.statusText}: ${k.message}`)]}});return h!=null?[null,h]:[a,null]}}const Yd=(s,e)=>{class t{constructor(r){G(this,"wrapped"),this.wrapped=r}use(...r){this.wrapped.use(...r)}async send(r,a,o,c){const h=new wd.Breaker(e);do{const[d,f]=await this.wrapped.send(r,a,o,c);if(f==null)return[d,null];if(!Ge.matches(f))return[null,f];if(!await h.wait())return[d,f]}while(!0)}}return new t(s)},w=async(s,e,t,n,r)=>{const[a,o]=await s.send(e,t,n,r);if(o!=null)throw o;return a},Zd=()=>zo.RUNTIME!=="node"?s=>new WebSocket(s):s=>new(require("ws")).WebSocket(s,{rejectUnauthorized:!1}),Kd=i.z.object({type:i.z.enum(["data","close","open"]),payload:i.z.unknown(),error:i.z.optional(He.payloadZ)});class Hd{constructor(e,t,n,r){G(this,"codec"),G(this,"reqSchema"),G(this,"resSchema"),G(this,"ws"),G(this,"serverClosed"),G(this,"sendClosed"),G(this,"receiveDataQueue",[]),G(this,"receiveCallbacksQueue",[]),this.codec=t,this.reqSchema=n,this.resSchema=r,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const e=await this.receiveMsg();if(e.type!=="open"){if(e.error==null)throw new Error("Message error must be defined");return He.decode(e.error)}return null}send(e){if(this.serverClosed!=null)return new ge;if(this.sendClosed)throw new mt;return this.ws.send(this.codec.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=He.decode(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.codec.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,t)=>this.receiveCallbacksQueue.push({resolve:e,reject:t}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(e){this.addMessage(this.codec.decode(e.data,Kd))}onClose(e){this.addMessage({type:"close",error:{type:e.code===Jd?ge.TYPE:mt.TYPE,data:""}})}}const Gd="freighterctx",Jd=1e3,Ao=class pr extends Eo{constructor(e,t,n=!1){super(),G(this,"baseUrl"),G(this,"encoder"),G(this,"secure"),this.secure=n,this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}withCodec(e){const t=new pr(this.baseUrl,e,this.secure);return t.use(...this.middleware),t}async stream(e,t,n){const r=Zd();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async c=>{const h=r(this.buildURL(e,c)),d={...c,params:{}};h.binaryType=pr.MESSAGE_TYPE;const f=await this.wrapSocket(h,t,n);return f instanceof Error?[d,f]:(a=f,[d,null])});if(o!=null)throw o;return a}buildURL(e,t){const n=Qu({[No]:this.encoder.contentType,...t.params},Gd);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(r=>{e.onopen=()=>{const a=new Hd(e,this.encoder,t,n);a.receiveOpenAck().then(o=>{o!=null?r(o):r(a)}).catch(o=>r(o))},e.onerror=a=>{const o=a;r(new Error(o.message))}})}};G(Ao,"MESSAGE_TYPE","arraybuffer");let Xd=Ao;const Qd="all",ef="create",tf="delete",sf="retrieve",nf="update",gr=i.z.enum([Qd,ef,tf,sf,nf]),rf=s=>{const e=s.replace(/_[a-z]/g,t=>t[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)},Uo=s=>{const e=(t,n=mr)=>{if(typeof t=="string")return s(t);if(Array.isArray(t))return t.map(o=>e(o,n));if(!An(t))return t;n=of(n);const r={},a=t;return Object.keys(a).forEach(o=>{let c=a[o];const h=s(o);n.recursive&&(An(c)?ta(c,n.keepTypesOnRecursion)||(c=e(c,n)):n.recursiveInArray&&ea(c)&&(c=[...c].map(d=>{let f=d;return An(d)?ta(f,n.keepTypesOnRecursion)||(f=e(d,n)):ea(d)&&(f=e({key:d},n).key),f}))),r[h]=c}),r};return e},ei=Uo(rf),af=s=>s.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`),Co=Uo(af),mr={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},of=(s=mr)=>(s.recursive==null?s=mr:s.recursiveInArray??(s.recursiveInArray=!1),s),ea=s=>s!=null&&Array.isArray(s),An=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),ta=(s,e)=>(e||[]).some(t=>s instanceof t),rn=s=>s!=null&&typeof s=="object"&&!Array.isArray(s);var cf=Object.defineProperty,lf=(s,e,t)=>e in s?cf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,pt=(s,e,t)=>lf(s,typeof e!="symbol"?e+"":e,t);function hf(s){const e=s.length;let t=0,n=0;for(;n<e;){let r=s.charCodeAt(n++);if((r&4294967168)===0){t++;continue}else if((r&4294965248)===0)t+=2;else{if(r>=55296&&r<=56319&&n<e){const a=s.charCodeAt(n);(a&64512)===56320&&(++n,r=((r&1023)<<10)+(a&1023)+65536)}(r&4294901760)===0?t+=3:t+=4}}return t}function uf(s,e,t){const n=s.length;let r=t,a=0;for(;a<n;){let o=s.charCodeAt(a++);if((o&4294967168)===0){e[r++]=o;continue}else if((o&4294965248)===0)e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&a<n){const c=s.charCodeAt(a);(c&64512)===56320&&(++a,o=((o&1023)<<10)+(c&1023)+65536)}(o&4294901760)===0?(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128):(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128)}e[r++]=o&63|128}}const df=new TextEncoder,ff=50;function yf(s,e,t){df.encodeInto(s,e.subarray(t))}function pf(s,e,t){s.length>ff?yf(s,e,t):uf(s,e,t)}const gf=4096;function Bo(s,e,t){let n=e;const r=n+t,a=[];let o="";for(;n<r;){const c=s[n++];if((c&128)===0)a.push(c);else if((c&224)===192){const h=s[n++]&63;a.push((c&31)<<6|h)}else if((c&240)===224){const h=s[n++]&63,d=s[n++]&63;a.push((c&31)<<12|h<<6|d)}else if((c&248)===240){const h=s[n++]&63,d=s[n++]&63,f=s[n++]&63;let u=(c&7)<<18|h<<12|d<<6|f;u>65535&&(u-=65536,a.push(u>>>10&1023|55296),u=56320|u&1023),a.push(u)}else a.push(c);a.length>=gf&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}const mf=new TextDecoder,wf=200;function bf(s,e,t){const n=s.subarray(e,e+t);return mf.decode(n)}function vf(s,e,t){return t>wf?bf(s,e,t):Bo(s,e,t)}let Cs=class{constructor(s,e){this.type=s,this.data=e}},Oe=class wr extends Error{constructor(e){super(e);const t=Object.create(wr.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:wr.name})}};const Rt=4294967295;function Sf(s,e,t){const n=t/4294967296,r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function jo(s,e,t){const n=Math.floor(t/4294967296),r=t;s.setUint32(e,n),s.setUint32(e+4,r)}function Ro(s,e){const t=s.getInt32(e),n=s.getUint32(e+4);return t*4294967296+n}function Tf(s,e){const t=s.getUint32(e),n=s.getUint32(e+4);return t*4294967296+n}const zf=-1,Of=4294967296-1,kf=17179869184-1;function xf({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=kf)if(e===0&&s<=Of){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{const t=s/4294967296,n=s&4294967295,r=new Uint8Array(8),a=new DataView(r.buffer);return a.setUint32(0,e<<2|t&3),a.setUint32(4,n),r}else{const t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),jo(n,4,s),t}}function If(s){const e=s.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,r=Math.floor(n/1e9);return{sec:t+r,nsec:n-r*1e9}}function Ef(s){if(s instanceof Date){const e=If(s);return xf(e)}else return null}function Nf(s){const e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const t=e.getUint32(0),n=e.getUint32(4),r=(t&3)*4294967296+n,a=t>>>2;return{sec:r,nsec:a}}case 12:{const t=Ro(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new Oe(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function Af(s){const e=Nf(s);return new Date(e.sec*1e3+e.nsec/1e6)}const Uf={type:zf,encode:Ef,decode:Af};let ls=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Uf)}register({type:s,encode:e,decode:t}){if(s>=0)this.encoders[s]=e,this.decoders[s]=t;else{const n=-1-s;this.builtInEncoders[n]=e,this.builtInDecoders[n]=t}}tryToEncode(s,e){for(let t=0;t<this.builtInEncoders.length;t++){const n=this.builtInEncoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=-1-t;return new Cs(a,r)}}}for(let t=0;t<this.encoders.length;t++){const n=this.encoders[t];if(n!=null){const r=n(s,e);if(r!=null){const a=t;return new Cs(a,r)}}}return s instanceof Cs?s:null}decode(s,e,t){const n=e<0?this.builtInDecoders[-1-e]:this.decoders[e];return n?n(s,e,t):new Cs(e,s)}};ls.defaultCodec=new ls;function Cf(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function br(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Cf(s)?new Uint8Array(s):Uint8Array.from(s)}const Bf=100,jf=2048;let Rf=class Do{constructor(e){this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??ls.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Bf,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??jf,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new Do({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){const t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const t=hf(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),pf(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){const n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);const n=br(e);this.writeU8a(n)}encodeArray(e,t){const n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(const r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let n=0;for(const r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){const n=Object.keys(e);this.sortKeys&&n.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(const a of n){const o=e[a];this.ignoreUndefined&&o===void 0||(this.encodeString(a),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){const n=e.data(this.pos+6),r=n.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(n);return}const t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Sf(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),jo(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function Yt(s,e){return new Rf(e).encodeSharedRef(s)}function Un(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}const Df=16,Mf=16;class Pf{constructor(e=Df,t=Mf){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){const r=this.caches[n-1];e:for(const a of r){const o=a.bytes;for(let c=0;c<n;c++)if(o[c]!==e[t+c])continue e;return a.str}return null}store(e,t){const n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){const r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;const a=Bo(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,a),a}}const vr="array",rs="map_key",Mo="map_value",$f=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new Oe("The type of key must be string or number but "+typeof s)};class Lf{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const t=this.getUninitializedStateFromPool();t.type=vr,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){const t=this.getUninitializedStateFromPool();t.type=rs,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===vr){const t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===rs||e.type===Mo){const t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const Dt=-1,ti=new DataView(new ArrayBuffer(0)),Ff=new Uint8Array(ti.buffer);try{ti.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const sa=new RangeError("Insufficient data"),_f=new Pf;let qf=class Po{constructor(e){this.totalPos=0,this.pos=0,this.view=ti,this.bytes=Ff,this.headByte=Dt,this.stack=new Lf,this.entered=!1,this.extensionCodec=(e==null?void 0:e.extensionCodec)??ls.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??Rt,this.maxBinLength=(e==null?void 0:e.maxBinLength)??Rt,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??Rt,this.maxMapLength=(e==null?void 0:e.maxMapLength)??Rt,this.maxExtLength=(e==null?void 0:e.maxExtLength)??Rt,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:_f,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??$f}clone(){return new Po({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Dt,this.stack.reset()}setBuffer(e){const t=br(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Dt&&!this.hasRemaining(1))this.setBuffer(e);else{const t=this.bytes.subarray(this.pos),n=br(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(const c of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(c);try{n=this.doDecodeSync(),t=!0}catch(h){if(!(h instanceof RangeError))throw h}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}const{headByte:r,pos:a,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${Un(r)} at ${o} (${a} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(const a of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){const r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{const r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){const r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){const r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){const r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){const r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){const r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){const r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){const r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){const r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){const r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){const r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){const r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){const r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){const r=this.lookU32();t=this.decodeExtension(r,4)}else throw new Oe(`Unrecognized type byte: ${Un(e)}`);this.complete();const n=this.stack;for(;n.length>0;){const r=n.top();if(r.type===vr)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,n.release(r);else continue e;else if(r.type===rs){if(t==="__proto__")throw new Oe("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=Mo;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,n.release(r);else{r.key=null,r.type=rs;continue e}}return t}}readHeadByte(){return this.headByte===Dt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Dt}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new Oe(`Unrecognized array type byte: ${Un(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Oe(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Oe(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){var n;if(e>this.maxStrLength)throw new Oe(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw sa;const r=this.pos+t;let a;return this.stateIsMapKey()&&(n=this.keyDecoder)!=null&&n.canBeCached(e)?a=this.keyDecoder.decode(this.bytes,r,e):a=vf(this.bytes,r,e),this.pos+=t+e,a}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===rs:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Oe(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw sa;const n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new Oe(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Tf(this.view,this.pos);return this.pos+=8,e}readI64(){const e=Ro(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function $o(s,e){return new qf(e).decode(s)}let Lo=class{constructor(){pt(this,"contentType","application/json"),pt(this,"decoder"),pt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(s){return this.encoder.encode(this.encodeString(s))}decode(s,e){return this.decodeString(this.decoder.decode(s),e)}decodeString(s,e){const t=JSON.parse(s),n=ei(t);return e!=null?e.parse(n):n}encodeString(s){const e=Co(s);return JSON.stringify(e,(t,n)=>ArrayBuffer.isView(n)?Array.from(n):rn(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},Fo=class{constructor(){pt(this,"contentType","text/csv")}encode(s){const e=this.encodeString(s);return new TextEncoder().encode(e)}decode(s,e){const t=new TextDecoder().decode(s);return this.decodeString(t,e)}encodeString(s){if(!Array.isArray(s)||s.length===0||!rn(s[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(s[0]),t=[e.join(",")];return s.forEach(n=>{const r=e.map(a=>JSON.stringify(n[a]??""));t.push(r.join(","))}),t.join(`
|
|
14
|
-
`)}decodeString(s,e){const[t,...n]=s.trim().split(`
|
|
15
|
-
`).map(o=>o.trim());if(t.length===0)return e!=null?e.parse({}):{};const r=t.split(",").map(o=>o.trim()),a={};return r.forEach(o=>{a[o]=[]}),n.forEach(o=>{const c=o.split(",").map(h=>h.trim());r.forEach((h,d)=>{const f=this.parseValue(c[d]);f!=null&&a[h].push(f)})}),e!=null?e.parse(a):a}parseValue(s){if(s==null||s.length===0)return null;const e=Number(s);return isNaN(e)?s.startsWith('"')&&s.endsWith('"')?s.slice(1,-1):s:e}static registerCustomType(){}},_o=class{constructor(){pt(this,"contentType","text/plain")}encode(s){return new TextEncoder().encode(s)}decode(s,e){const t=new TextDecoder().decode(s);return e!=null?e.parse(t):t}};const Ye=new ls;Ye.register({type:0,encode:s=>{if(ArrayBuffer.isView(s)){const e=Array.from(s);return Yt(e,{extensionCodec:Ye})}return rn(s)&&"encode_value"in s?typeof s.value=="bigint"?Yt(s.value.toString(),{extensionCodec:Ye}):Yt(s.value,{extensionCodec:Ye}):typeof s=="bigint"?Yt(s.toString(),{extensionCodec:Ye}):null},decode:s=>$o(s,{extensionCodec:Ye})});let qo=class{constructor(){pt(this,"contentType","application/msgpack")}encode(s){const e=Co(s);return Yt(e,{extensionCodec:Ye}).slice()}decode(s,e){const t=$o(s,{extensionCodec:Ye}),n=ei(t);return e!=null?e.parse(n):n}static registerCustomType(){}};const is=new Lo,Wf=new Fo,Vf=new _o,Yf=new qo,rt=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:Fo,CSV_CODEC:Wf,JSONCodec:Lo,JSON_CODEC:is,MSGPACK_CODEC:Yf,MsgPackCodec:qo,TEXT_CODEC:Vf,TextCodec:_o},Symbol.toStringTag,{value:"Module"})),Zf=s=>[...new Set(s)],Kf=(s,e,t=!0)=>{const n=new Map;return s.forEach(r=>{const a=e(r);if(n.has(a)){if(t)return;n.delete(a)}n.set(a,r)}),Array.from(n.values())},na=Object.freeze(Object.defineProperty({__proto__:null,by:Kf,unique:Zf},Symbol.toStringTag,{value:"Module"})),Hf=s=>s!=null&&typeof s=="object"&&"toString"in s,Gf=(s,e=!1)=>{const t=Hf(s)?"stringer":typeof s;let n;switch(t){case"string":n=(r,a)=>r.localeCompare(a);break;case"stringer":n=(r,a)=>r.toString().localeCompare(a.toString());break;case"number":n=(r,a)=>Number(r)-Number(a);break;case"bigint":n=(r,a)=>BigInt(r)-BigInt(a)>0n?1:-1;break;case"boolean":n=(r,a)=>Number(r)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Jf(n):n},Jf=s=>(e,t)=>s(t,e),an=0,Cn=-1,Bn=1,Xf=s=>s<an,Qf=s=>s>an,ey=s=>s===an,on=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const Wo=i.z.object({width:i.z.number(),height:i.z.number()}),ty=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),sy=["width","height"];i.z.enum(sy);const ny=["start","center","end"],ry=["signedWidth","signedHeight"];i.z.enum(ry);const Js=i.z.object({x:i.z.number(),y:i.z.number()}),iy=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),ay=["x","y"],Vo=i.z.enum(ay),Yo=["top","right","bottom","left"];i.z.enum(Yo);const oy=["left","right"],Zo=i.z.enum(oy),cy=["top","bottom"],Ko=i.z.enum(cy),Ho=["center"],ra=i.z.enum(Ho),ly=[...Yo,...Ho],Go=i.z.enum(ly);i.z.enum(ny);const hy=["first","last"];i.z.enum(hy);const uy=i.z.object({lower:i.z.number(),upper:i.z.number()}),dy=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([uy,on]);i.z.union([dy,on]);i.z.enum([...Vo.options,...Go.options]);i.z.union([Vo,Go,i.z.instanceof(String)]);const zt=s=>typeof s=="bigint"||s instanceof BigInt,jn=(s,e)=>zt(s)?s.valueOf()-BigInt(e.valueOf().valueOf()):s.valueOf()-Number(e.valueOf()),fy=(s,e)=>zt(s)?s.valueOf()+BigInt(e.valueOf().valueOf()):s+Number(e.valueOf()),ia=(s,e)=>zt(s)?s===BigInt(e.valueOf().valueOf()):s===Number(e.valueOf()),yy=(s,e)=>zt(s)?s.valueOf()<BigInt(e.valueOf())?s:BigInt(e.valueOf()):s.valueOf()<Number(e.valueOf())?s:Number(e.valueOf()),py=s=>zt(s)||s instanceof BigInt?s.valueOf()<0n?-s:s:s.valueOf()<0?-s:s,ct=(s,e)=>zt(s)?s.valueOf()*BigInt(e.valueOf()):s.valueOf()*Number(e.valueOf()),ee=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return aa(s);return aa(t)},aa=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s,oa=(s,e)=>{const t=ee(s);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e},Bs=(s,e)=>{const t=ee(s);if(typeof e=="number"||typeof e=="bigint")return e>=t.lower&&e<t.upper;const n=ee(e);return n.lower>=t.lower&&n.upper<=t.upper},gy=s=>({lower:Math.min(...s.map(e=>ee(e).lower)),upper:Math.max(...s.map(e=>ee(e).upper))}),my=(s,e,t)=>{const n=s.map(c=>ee(c)),r=t>0?1:t<0?-1:0;if(r===0)return e;let a=t,o=e;for(;ia(a,0)===!1;){const c=n.findIndex(h=>r>0?o>=h.lower&&o<h.upper:o>h.lower&&o<=h.upper);if(c!==-1){const h=n[c];let d;if(r>0?d=jn(h.upper,o):d=jn(o,h.lower),d>0){const f=yy(py(a),d);if(o=fy(o,r>0?f:-f),a=jn(a,r>0?f:-f),ia(a,0))return o;continue}}if(r>0){const h=n.filter(d=>d.lower>o);if(h.length>0)o=h[0].lower;else return o}else{const h=n.filter(d=>d.upper<o);if(h.length>0)o=h[h.length-1].upper;else return o}}return o},wy=(s,e,t)=>{const n=s.map(o=>ee(o));if(e===t)return typeof e=="bigint"?0n:0;const r=e<t?ee([e,t]):ee([t,e]);let a=typeof e=="bigint"?0n:0;for(const o of n){const c=o.lower>r.lower?o.lower:r.lower,h=o.upper<r.upper?o.upper:r.upper;if(c<h){const d=h-c;a=a+d}}return a};i.z.object({x:Zo.or(ra),y:Ko.or(ra)});const by=i.z.object({x:Zo,y:Ko}),vy=Object.freeze({x:"left",y:"top"}),Sy=(s,e)=>s.x===e.x&&s.y===e.y,ca=i.z.union([i.z.number(),Js,on,Wo,ty,iy]),Ty=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},la=Object.freeze({x:0,y:0}),js=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:js,left:js,width:js,height:js});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:Js,two:Js,root:by});const si=(s,e,t=0,n=0,r)=>{const a={one:{...la},two:{...la},root:r??vy};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Rn=s=>{const e=si(s);return{lower:e.one.x,upper:e.two.x}},Dn=s=>{const e=si(s);return{lower:e.one.y,upper:e.two.y}},zy=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,Oy=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([Wo,Oy,Js,on]);var ky=Object.defineProperty,xy=(s,e,t)=>e in s?ky(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,je=(s,e,t)=>xy(s,typeof e!="symbol"?e+"":e,t);const Iy=(s,e,t)=>e!==void 0&&s<e?e:t!==void 0&&s>t?t:s;i.z.object({offset:ca,scale:ca});i.z.object({offset:i.z.number(),scale:i.z.number()});const Ey=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],Ny=s=>(e,t,n,r)=>[e,r?n/s:n*s],Ay=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:o,upper:c}=s,h=a-r,d=c-o;if(t==="dimension")return[s,n*(d/h)];const f=(n-r)*(d/h)+o;return[s,f]},Uy=s=>(e,t,n)=>[s,n],Cy=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},By=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=Iy(n,r,a),[e,n]},Sr=class Zt{constructor(){je(this,"ops",[]),je(this,"currBounds",null),je(this,"currType",null),je(this,"reversed",!1),this.ops=[]}static translate(e){return new Zt().translate(e)}static magnify(e){return new Zt().magnify(e)}static scale(e,t){return new Zt().scale(e,t)}translate(e){const t=this.new(),n=Ey(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Ny(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=ee(e,t),r=this.new(),a=Ay(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=ee(e,t),r=this.new(),a=By(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=ee(e,t),r=this.new(),a=Uy(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=Cy();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Zt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([o,c])=>r>=o&&r<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};je(Sr,"IDENTITY",new Sr);let ha=Sr;const ua=class Ce{constructor(e=new ha,t=new ha,n=null){je(this,"x"),je(this,"y"),je(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Ce().translate(e,t)}static translateX(e){return new Ce().translateX(e)}static translateY(e){return new Ce().translateY(e)}static clamp(e){return new Ce().clamp(e)}static magnify(e){return new Ce().magnify(e)}static scale(e){return new Ce().scale(e)}static reBound(e){return new Ce().reBound(e)}translate(e,t){const n=Ty(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(zy(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Sy(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Rn(e)),t.y=t.y.scale(Dn(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Rn(e)),t.y=this.y.reBound(Dn(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Rn(e)),t.y=this.y.clamp(Dn(e)),t}copy(){const e=new Ce;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 si(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})}}};je(ua,"IDENTITY",new ua);var jy=Object.defineProperty,Ry=(s,e,t)=>e in s?jy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,y=(s,e,t)=>Ry(s,typeof e!="symbol"?e+"":e,t);let Dy=(s,e=21)=>(t=e)=>{let n="",r=t|0;for(;r--;)n+=s[Math.random()*s.length|0];return n};const My="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Py=Dy(My,11),Jo=()=>Py(),$y=Object.freeze(Object.defineProperty({__proto__:null,create:Jo},Symbol.toStringTag,{value:"Module"})),Ly=i.z.enum(["static","dynamic"]),Xo=(s,e)=>{const t=new x(e);if(![O.DAY,O.HOUR,O.MINUTE,O.SECOND,O.MILLISECOND,O.MICROSECOND,O.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof x?new x(n):new O(n)},D=class S{constructor(e,t="UTC"){if(y(this,"value"),y(this,"encodeValue",!0),e==null)this.value=S.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*S.MILLISECOND.valueOf();else if(typeof e=="string")this.value=S.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=S.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=S.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=S.MAX:e=S.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new S(BigInt(r.getTime())*S.MILLISECOND.valueOf()).truncate(S.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let h=S.hours(parseInt(n??"00")).add(S.minutes(parseInt(r??"00"))).add(S.seconds(parseInt(o??"00"))).add(S.milliseconds(parseInt(c??"00")));return t==="local"&&(h=h.add(S.utcOffset)),h.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return S.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new S(BigInt(n.getTime())*S.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(S.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new O(BigInt(new Date().getTimezoneOffset())*S.MINUTE.valueOf())}static since(e){return new S().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new S(e).valueOf()}span(e){return this.range(e).span}range(e){return new V(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new S(e).valueOf()}afterEq(e){return this.valueOf()>=new S(e).valueOf()}before(e){return this.valueOf()<new S(e).valueOf()}beforeEq(e){return this.valueOf()<=new S(e).valueOf()}add(e){return new S(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new S(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(O.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(O.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(O.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(O.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 year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new S(t)}get month(){return this.date().getUTCMonth()}setMonth(e){const t=this.date();return t.setUTCMonth(e),new S(t)}get day(){return this.date().getUTCDate()}setDay(e){const t=this.date();return t.setUTCDate(e),new S(t)}get hour(){return this.date().getUTCHours()}setHour(e){const t=this.date();return t.setUTCHours(e),new S(t,"UTC")}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setUTCMinutes(e),new S(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setUTCSeconds(e),new S(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new S(t)}toString(){return this.date().toISOString()}remainder(e){return Xo(this,e)}get isToday(){return this.truncate(O.DAY).equals(S.now().truncate(O.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new S(new Date)}static max(...e){let t=S.MIN;for(const n of e){const r=new S(n);r.after(t)&&(t=r)}return t}static min(...e){let t=S.MAX;for(const n of e){const r=new S(n);r.before(t)&&(t=r)}return t}static nanoseconds(e,t="UTC"){return new S(e,t)}static microseconds(e,t="UTC"){return S.nanoseconds(e*1e3,t)}static milliseconds(e,t="UTC"){return S.microseconds(e*1e3,t)}static seconds(e,t="UTC"){return S.milliseconds(e*1e3,t)}static minutes(e,t="UTC"){return S.seconds(e*60,t)}static hours(e,t="UTC"){return S.minutes(e*60,t)}static days(e,t="UTC"){return S.hours(e*24,t)}};y(D,"NANOSECOND",D.nanoseconds(1)),y(D,"MICROSECOND",D.microseconds(1)),y(D,"MILLISECOND",D.milliseconds(1)),y(D,"SECOND",D.seconds(1)),y(D,"MINUTE",D.minutes(1)),y(D,"HOUR",D.hours(1)),y(D,"DAY",D.days(1)),y(D,"MAX",new D((1n<<63n)-1n)),y(D,"MIN",new D(0)),y(D,"ZERO",new D(0)),y(D,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new D(s.value)),i.z.string().transform(s=>new D(BigInt(s))),i.z.instanceof(Number).transform(s=>new D(s)),i.z.number().transform(s=>new D(s)),i.z.instanceof(D)]));let x=D;const M=class E{constructor(e){y(this,"value"),y(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof E?e:e instanceof da?e.period:e instanceof x?new E(e):["number","bigint"].includes(typeof e)?E.seconds(e):new E(e)}static fromMilliseconds(e){return e instanceof E?e:e instanceof da?e.period:e instanceof x?new E(e):["number","bigint"].includes(typeof e)?E.milliseconds(e):new E(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new E(e).valueOf()}greaterThan(e){return this.valueOf()>new E(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new E(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new E(e).valueOf()}remainder(e){return Xo(this,e)}truncate(e){return new E(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(E.DAY),t=this.truncate(E.HOUR),n=this.truncate(E.MINUTE),r=this.truncate(E.SECOND),a=this.truncate(E.MILLISECOND),o=this.truncate(E.MICROSECOND),c=this.truncate(E.NANOSECOND),h=e,d=t.sub(e),f=n.sub(t),u=r.sub(n),z=a.sub(r),k=o.sub(a),Y=c.sub(o);let U="";return h.isZero||(U+=`${h.days}d `),d.isZero||(U+=`${d.hours}h `),f.isZero||(U+=`${f.minutes}m `),u.isZero||(U+=`${u.seconds}s `),z.isZero||(U+=`${z.milliseconds}ms `),k.isZero||(U+=`${k.microseconds}µs `),Y.isZero||(U+=`${Y.nanoseconds}ns`),U.trim()}mult(e){return new E(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(E.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(E.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(E.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(E.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(E.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(E.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new E(e).valueOf()}add(e){return new E(this.valueOf()+new E(e).valueOf())}sub(e){return new E(this.valueOf()-new E(e).valueOf())}static nanoseconds(e=1){return new E(e)}static microseconds(e=1){return E.nanoseconds(ct(e,1e3))}static milliseconds(e=1){return E.microseconds(ct(e,1e3))}static seconds(e=1){return E.milliseconds(ct(e,1e3))}static minutes(e=1){return E.seconds(ct(e,60))}static hours(e){return E.minutes(ct(e,60))}static days(e){return E.hours(ct(e,24))}};y(M,"NANOSECOND",M.nanoseconds(1)),y(M,"MICROSECOND",M.microseconds(1)),y(M,"MILLISECOND",M.milliseconds(1)),y(M,"SECOND",M.seconds(1)),y(M,"MINUTE",M.minutes(1)),y(M,"HOUR",M.hours(1)),y(M,"DAY",M.days(1)),y(M,"MAX",new M((1n<<63n)-1n)),y(M,"MIN",new M(0)),y(M,"ZERO",new M(0)),y(M,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(s=>new M(s.value)),i.z.string().transform(s=>new M(BigInt(s))),i.z.instanceof(Number).transform(s=>new M(s)),i.z.number().transform(s=>new M(s)),i.z.instanceof(M)]));let O=M;const Kt=class _s extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new _s(e).valueOf()}get period(){return O.seconds(1/this.valueOf())}sampleCount(e){return new O(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ae(t).valueOf()}span(e){return O.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new _s(e)}static khz(e){return _s.hz(e*1e3)}};y(Kt,"z",i.z.union([i.z.number().transform(s=>new Kt(s)),i.z.instanceof(Number).transform(s=>new Kt(s)),i.z.instanceof(Kt)]));let da=Kt;const Q=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new wt(e*this.valueOf())}};y(Q,"UNKNOWN",new Q(0)),y(Q,"BIT128",new Q(16)),y(Q,"BIT64",new Q(8)),y(Q,"BIT32",new Q(4)),y(Q,"BIT16",new Q(2)),y(Q,"BIT8",new Q(1)),y(Q,"z",i.z.union([i.z.number().transform(s=>new Q(s)),i.z.instanceof(Number).transform(s=>new Q(s)),i.z.instanceof(Q)]));let ae=Q;const Se=class Ht{constructor(e,t){y(this,"start"),y(this,"end"),typeof e=="object"&&"start"in e?(this.start=new x(e.start),this.end=new x(e.end)):(this.start=new x(e),this.end=new x(t))}get span(){return new O(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Ht(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=O.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=O.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 r=x.max(n.start,e.start),a=x.min(n.end,e.end);return a.before(r)?!1:new O(a.sub(r)).greaterThanOrEqual(t)}contains(e){return e instanceof Ht?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Ht(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}static max(...e){return new Ht(x.min(...e.map(t=>t.start)),x.max(...e.map(t=>t.end)))}};y(Se,"MAX",new Se(x.MIN,x.MAX)),y(Se,"MIN",new Se(x.MAX,x.MIN)),y(Se,"ZERO",new Se(x.ZERO,x.ZERO)),y(Se,"z",i.z.union([i.z.object({start:x.z,end:x.z}).transform(s=>new Se(s.start,s.end)),i.z.instanceof(Se)]));let V=Se;const Fy=(s,e)=>s.start.before(e.start)?-1:s.start.after(e.start)?1:s.end.before(e.end)?-1:s.end.after(e.end)?1:0,m=class q{constructor(e){if(y(this,"value"),y(this,"encodeValue",!0),e instanceof q||typeof e=="string"||typeof e.valueOf()=="string"){this.value=e.valueOf();return}const t=q.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){this.value=t.valueOf();return}throw this.value=q.UNKNOWN.valueOf(),new Error(`unable to find data type for ${e.toString()}`)}valueOf(){return this.value}get Array(){const e=q.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(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(q.JSON)||this.equals(q.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(q.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=q.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(q.UINT8)||this.equals(q.UINT16)||this.equals(q.UINT32)||this.equals(q.UINT64)}get isSigned(){return this.equals(q.INT8)||this.equals(q.INT16)||this.equals(q.INT32)||this.equals(q.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(q.INT32)&&e.equals(q.FLOAT64)||this.equals(q.INT8)&&e.equals(q.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}toJSON(){return this.toString()}get usesBigInt(){return q.BIG_INT_TYPES.some(e=>e.equals(this))}};y(m,"UNKNOWN",new m("unknown")),y(m,"FLOAT64",new m("float64")),y(m,"FLOAT32",new m("float32")),y(m,"INT64",new m("int64")),y(m,"INT32",new m("int32")),y(m,"INT16",new m("int16")),y(m,"INT8",new m("int8")),y(m,"UINT64",new m("uint64")),y(m,"UINT32",new m("uint32")),y(m,"UINT16",new m("uint16")),y(m,"UINT8",new m("uint8")),y(m,"BOOLEAN",m.UINT8),y(m,"TIMESTAMP",new m("timestamp")),y(m,"UUID",new m("uuid")),y(m,"STRING",new m("string")),y(m,"JSON",new m("json")),y(m,"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]])),y(m,"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]])),y(m,"DENSITIES",new Map([[m.UINT8.toString(),ae.BIT8],[m.UINT16.toString(),ae.BIT16],[m.UINT32.toString(),ae.BIT32],[m.UINT64.toString(),ae.BIT64],[m.FLOAT32.toString(),ae.BIT32],[m.FLOAT64.toString(),ae.BIT64],[m.INT8.toString(),ae.BIT8],[m.INT16.toString(),ae.BIT16],[m.INT32.toString(),ae.BIT32],[m.INT64.toString(),ae.BIT64],[m.TIMESTAMP.toString(),ae.BIT64],[m.STRING.toString(),ae.UNKNOWN],[m.JSON.toString(),ae.UNKNOWN],[m.UUID.toString(),ae.BIT128]])),y(m,"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]),y(m,"BIG_INT_TYPES",[m.INT64,m.UINT64,m.TIMESTAMP]),y(m,"z",i.z.union([i.z.string().transform(s=>new m(s)),i.z.instanceof(m)]));let N=m;const re=class K extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return K.bytes(this.valueOf()+e.valueOf())}sub(e){return K.bytes(this.valueOf()-e.valueOf())}truncate(e){return new K(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return K.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/K.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/K.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/K.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/K.TERABYTE.valueOf()}toString(){const e=this.truncate(K.TERABYTE),t=this.truncate(K.GIGABYTE),n=this.truncate(K.MEGABYTE),r=this.truncate(K.KILOBYTE),a=this.truncate(K.BYTE),o=e,c=t.sub(e),h=n.sub(t),d=r.sub(n),f=a.sub(r);let u="";return o.isZero||(u+=`${o.terabytes}TB `),c.isZero||(u+=`${c.gigabytes}GB `),h.isZero||(u+=`${h.megabytes}MB `),d.isZero||(u+=`${d.kilobytes}KB `),(!f.isZero||u==="")&&(u+=`${f.valueOf()}B`),u.trim()}static bytes(e=1){return new K(e)}static kilobytes(e=1){return K.bytes(e.valueOf()*1e3)}static megabytes(e=1){return K.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return K.megabytes(e.valueOf()*1e3)}static terabytes(e){return K.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};y(re,"BYTE",new re(1)),y(re,"KILOBYTE",re.kilobytes(1)),y(re,"MEGABYTE",re.megabytes(1)),y(re,"GIGABYTE",re.gigabytes(1)),y(re,"TERABYTE",re.terabytes(1)),y(re,"ZERO",new re(0)),y(re,"z",i.z.union([i.z.number().transform(s=>new re(s)),i.z.instanceof(re)]));let wt=re;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const Qo=s=>{const e=typeof s;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||s instanceof x||s instanceof O||s instanceof Date},_y=(s,e,t,n=0)=>s.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!s.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(n.valueOf()):Gt(t,-n).valueOf(),Gt=(s,e)=>e==0?s:s==0?e:typeof s=="bigint"&&typeof e=="bigint"||typeof s=="number"&&typeof e=="number"?s+e:Number(s)+Number(e),qy=s=>s==null?!1:Array.isArray(s)||s instanceof ArrayBuffer||ArrayBuffer.isView(s)&&!(s instanceof DataView)||s instanceof Je?!0:Qo(s),Le=-1,Tr={[Symbol.iterator]:()=>Tr,next:()=>({done:!0,value:void 0})},Wy=i.z.string().transform(s=>new Uint8Array(atob(s).split("").map(e=>e.charCodeAt(0))).buffer),Vy=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),zr=10,ec=(s,e)=>{if(s==="string"&&!e.isVariable)throw new Error(`cannot convert series of type ${e.toString()} to string`);if(s==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(s==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Jt=class Te{constructor(e){y(this,"key",""),y(this,"isSynnaxSeries",!0),y(this,"dataType"),y(this,"sampleOffset"),y(this,"gl"),y(this,"_data"),y(this,"timeRange",V.ZERO),y(this,"alignment",0n),y(this,"_cachedMin"),y(this,"_cachedMax"),y(this,"writePos",Le),y(this,"_refCount",0),y(this,"_cachedLength"),y(this,"_cachedIndexes"),qy(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:a="static",alignment:o=0n,key:c=Jo()}=e,h=e.data??[];if(h instanceof Te||typeof h=="object"&&"isSynnaxSeries"in h&&h.isSynnaxSeries===!0){const u=h;this.key=u.key,this.dataType=u.dataType,this.sampleOffset=u.sampleOffset,this.gl=u.gl,this._data=u._data,this.timeRange=u.timeRange,this.alignment=u.alignment,this._cachedMin=u._cachedMin,this._cachedMax=u._cachedMax,this.writePos=u.writePos,this._refCount=u._refCount,this._cachedLength=u._cachedLength;return}const d=Qo(h),f=Array.isArray(h);if(t!=null)this.dataType=new N(t);else{if(h instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||d){let u=h;if(!d){if(h.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");u=h[0]}if(typeof u=="string")this.dataType=N.STRING;else if(typeof u=="number")this.dataType=N.FLOAT64;else if(typeof u=="bigint")this.dataType=N.INT64;else if(typeof u=="boolean")this.dataType=N.BOOLEAN;else if(u instanceof x||u instanceof Date||u instanceof x)this.dataType=N.TIMESTAMP;else if(typeof u=="object")this.dataType=N.JSON;else throw new Error(`cannot infer data type of ${typeof u} when constructing a Series from a JS array`)}else this.dataType=new N(h)}if(!f&&!d)this._data=h;else{let u=d?[h]:h;const z=u[0];(z instanceof x||z instanceof Date||z instanceof O)&&(u=u.map(k=>new x(k).valueOf())),this.dataType.equals(N.STRING)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.join(`
|
|
16
|
-
`)}
|
|
17
|
-
`).buffer):this.dataType.equals(N.JSON)?(this._cachedLength=u.length,this._data=new TextEncoder().encode(`${u.map(k=>is.encodeString(k)).join(`
|
|
18
|
-
`)}
|
|
19
|
-
`).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(u.map(k=>BigInt(Math.round(k)))).buffer:!this.dataType.usesBigInt&&typeof z=="bigint"?this._data=new this.dataType.Array(u.map(k=>Number(k))).buffer:this._data=new this.dataType.Array(u).buffer}this.key=c,this.alignment=o,this.sampleOffset=r??0,this.timeRange=n??V.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const r=new new N(t).Array(e),a=new Te({data:r.buffer,dataType:t,...n});return a.writePos=0,a}static createTimestamps(e,t,n){const r=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(t.span(o)).valueOf());return new Te({data:a,dataType:N.TIMESTAMP,timeRange:r})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(`${e.join(`
|
|
20
|
-
`)}
|
|
21
|
-
`);return new Te({data:n,dataType:N.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(`${e.map(r=>is.encodeString(r)).join(`
|
|
22
|
-
`)}
|
|
23
|
-
`);return new Te({data:n,dataType:N.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount<=0){console.warn("attempted to release a series with a negative reference count");return}this._refCount--,this._refCount===0&&this.gl.control!=null&&this.maybeGarbageCollectGLBuffer(this.gl.control)}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===Le)return 0;const t=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,t);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===Le)return 0;const t=this.capacity-this.writePos,n=e.sub(0,t);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===Le?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(N.STRING,N.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
24
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(N.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=N.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const r=this.underlyingData.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(r.buffer),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(N.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
|
|
25
|
-
`).slice(0,-1).map(t=>e.parse(is.decodeString(t)))}get byteCapacity(){return new wt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Le?this.byteCapacity:this.dataType.isVariable?new wt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Le?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((n,r)=>{n===zr&&(e++,t.push(r+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let r=0;r<this.length;r++)n[r]=_y(this.dataType,e,this.data[r],t);return new Te({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(N.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),Gt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(N.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),Gt(this._cachedMin,this.sampleOffset))}get bounds(){return ee(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return Gt(this.max,-this.min)}atAlignment(e,t){const n=Number(e-this.alignment);if(n<0||n>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return Gt(n,this.sampleOffset)}atVariable(e,t){let n=0,r=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],r=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]===zr){if(e===0){r=o;break}n=o+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(n,r);return this.dataType.equals(N.STRING)?new TextDecoder().decode(a):ei(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const r=Gf(e);for(;t<=n;){const a=Math.floor((t+n)/2),o=r(this.at(a,!0),e);if(o===0)return a;o<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(N.FLOAT32)&&!this.dataType.equals(N.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Le){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(r).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Le}as(e){return ec(e,this.dataType),this}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:va(this.alignmentBounds.lower),upper:va(this.alignmentBounds.upper)},timeRange:(e=this.timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return ee(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Yy(this);return this.dataType.equals(N.JSON)?new Zy(e):e}return new Ky(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new fa(this,e,t??this.length)}subAlignmentIterator(e,t){return new fa(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,t);return new Te({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,n){if(t<=0&&(n==null||n>=this.length))return this;let r;return e?r=this.data.subarray(t,n):r=this.data.slice(t,n),new Te({data:r,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new Te({data:this.buffer,dataType:this.dataType,timeRange:V.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){var e,t;let n=`${this.dataType.toString()} ${this.length} [`;if(this.length<=10)n+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)n+=`${(e=this.at(r))==null?void 0:e.toString()}`,r<4&&(n+=",");n+="...";for(let r=-5;r<0;r++)n+=(t=this.at(r))==null?void 0:t.toString(),r<-1&&(n+=",")}return n+="]",n}};y(Jt,"crudeZ",i.z.object({timeRange:V.z.optional(),dataType:N.z,alignment:i.z.coerce.bigint().optional(),data:i.z.union([Wy,Vy,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:Ly.optional().default("static").optional()})),y(Jt,"z",Jt.crudeZ.transform(s=>new Jt(s)));let Je=Jt,fa=class{constructor(s,e,t){y(this,"series"),y(this,"end"),y(this,"index"),this.series=s;const n=ee(0,s.length);this.end=oa(n,t),this.index=oa(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};class Yy{constructor(e){if(y(this,"series"),y(this,"index"),y(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==zr;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var ya,pa;const tc=class sc{constructor(e){y(this,"wrapped"),y(this,ya,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:is.decodeString(e.value,sc.SCHEMA)}}[(pa=Symbol.iterator,ya=Symbol.toStringTag,pa)](){return this}};y(tc,"SCHEMA",i.z.record(i.z.string(),i.z.unknown()));let Zy=tc;var ga,ma;class Ky{constructor(e){y(this,"series"),y(this,"index"),y(this,ga,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(ma=Symbol.iterator,ga=Symbol.toStringTag,ma)](){return this}}class Hy{constructor(e=[]){if(y(this,"series"),e.length!==0){const t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){return ec(e,this.dataType),this}get dataType(){return this.series.length===0?N.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?V.ZERO:new V(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?ee(0n,0n):ee(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){"isSynnaxSeries"in e&&e.isSynnaxSeries?this.series.push(e):this.series.push(...e.series)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}atAlignment(e,t){if(this.series.length===0){if(t)throw new Error(`[series] - no value at alignment ${e}`);return}for(const n of this.series)if(Bs(n.alignmentBounds,e))return n.atAlignment(e,t);if(t)throw new Error(`[series] - no value at alignment ${e}`)}at(e,t=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,t){return new Mn(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return Tr;let n=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)n+=o.length;else if(Bs(o.alignmentBounds,e)){n+=Number(e-o.alignment);break}}let r=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(t<o.alignment)break;if(t>=o.alignmentBounds.upper)r+=o.length;else if(Bs(o.alignmentBounds,t)){r+=Number(t-o.alignment);break}}return new Mn(this,n,r)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return Tr;let n=0;for(let r=0;r<this.series.length;r++){const a=this.series[r];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)n+=a.length;else if(Bs(a.alignmentBounds,e)){n+=Number(e-a.alignment);break}}return new Mn(this,n,n+t)}updateGLBuffer(e){this.series.forEach(t=>t.updateGLBuffer(e))}get bounds(){return gy(this.series.map(e=>e.bounds))}get byteLength(){return new wt(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,t){const n=this.series.map(r=>r.alignmentBounds);return my(n,e,t)}acquire(){this.series.forEach(e=>e.acquire())}release(){this.series.forEach(e=>e.release())}distance(e,t){const n=this.series.map(r=>r.alignmentBounds);return wy(n,e,t)}parseJSON(e){if(!this.dataType.equals(N.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(t=>t.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Gy(this.series)}}var wa,ba;class Gy{constructor(e){y(this,"series"),y(this,"seriesIndex"),y(this,"internal"),y(this,wa,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(ba=Symbol.iterator,wa=Symbol.toStringTag,ba)](){return this}}let Mn=class{constructor(s,e,t){y(this,"series"),y(this,"index"),y(this,"end"),this.series=s,this.end=t,this.index=e}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};const va=s=>{const e=s>>32n,t=s&0xffffffffn;return{domain:e,sample:t}},Jy=(s,e)=>{let t=null;return e===0?s:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>s(...n),e)}},Xy=(s,e,t=".")=>{const n=s.split(t);return n.map((r,a)=>{const o=e(r,a,n);return o==null?null:typeof o=="string"?o:o.join(t)}).filter(r=>r!=null).join(t)},Qy=(s,e,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:n,getter:r=(c,h)=>c[h]}=t,a=e.split(t.separator);if(a.length===1&&a[0]==="")return s;let o=s;for(const c of a){const h=r(o,c);if(h==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${c} is null`)}o=h}return o};i.z.object({key:i.z.string(),value:i.z.string()});var ep=Object.defineProperty,tp=(s,e,t)=>e in s?ep(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,qs=(s,e,t)=>tp(s,typeof e!="symbol"?e+"":e,t);let sp=class{constructor(s,e){qs(this,"handlers"),qs(this,"transform"),qs(this,"closer"),this.transform=s,this.handlers=e??new Map}onChange(s){return this.handlers.set(s,null),()=>this.handlers.delete(s)}notify(s){let e=s;if(this.transform!=null){const[t,n]=this.transform(s);if(!n)return;e=t}this.handlers.forEach((t,n)=>n(e))}setCloser(s){this.closer=s}async close(){var s;return await((s=this.closer)==null?void 0:s.call(this))}},np=class{constructor(s){qs(this,"handlers"),this.handlers=s??new Map}onChange(s){return this.handlers.set(s,null),()=>this.handlers.delete(s)}notify(s){this.handlers.forEach((e,t)=>t(s))}};const tt=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:np,Observer:sp},Symbol.toStringTag,{value:"Module"})),pe=i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown()),rp=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";rp();const ip=["macOS","Windows","Linux"],ap=["macos","windows","linux"],op={macos:"macOS",windows:"Windows",linux:"Linux"};i.z.enum(ip).or(i.z.enum(ap).transform(s=>op[s]));var cp=Object.defineProperty,lp=(s,e,t)=>e in s?cp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Xt=(s,e,t)=>lp(s,typeof e!="symbol"?e+"":e,t);const hp=(...s)=>s.map(nc).join(""),nc=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),up=s=>s.endsWith("/")?s.slice(0,-1):s,Or=class kr{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){Xt(this,"protocol"),Xt(this,"host"),Xt(this,"port"),Xt(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=nc(r)}replace(e){return new kr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new kr({...this,pathPrefix:hp(this.path,e)})}toString(){return up(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Xt(Or,"UNKNOWN",new Or({host:"unknown",port:0}));let dp=Or;const fp=-128,yp=127,pp=i.z.number().int().min(fp).max(yp),gp=-32768,mp=32767,wp=i.z.number().int().min(gp).max(mp),bp=-2147483648,vp=2147483647,Sp=i.z.number().int().min(bp).max(vp),Tp=-9223372036854775808n,zp=9223372036854775807n,Op=i.z.bigint().min(Tp).max(zp),kp=255,xp=i.z.number().int().min(0).max(kp),Ip=65535,Ep=i.z.number().int().min(0).max(Ip),Np=4294967295,Ap=i.z.number().int().min(0).max(Np),Up=18446744073709551615n,Cp=i.z.bigint().min(0n).max(Up),rc=s=>Xy(s,(e,t,n)=>{const r=t===n.length-1,a=!isNaN(parseInt(e)),o=!isNaN(parseInt(n[t+1]));return a&&(e="element"),r||o?e:[e,"shape"]}),Sa=(s,e)=>{if(s==null)return null;const t=s[e];return t==null&&typeof s=="object"&&"sourceType"in s?s.sourceType()[e]:t},Bp=(s,e,t)=>Qy(Sa(s,"shape"),rc(e),{...t,getter:Sa}),jp=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:Bp,getFieldSchemaPath:rc,int16:wp,int32:Sp,int64:Op,int8:pp,uint16:Ep,uint32:Ap,uint64:Cp,uint8:xp},Symbol.toStringTag,{value:"Module"}));var Rp=Object.defineProperty,Dp=(s,e,t)=>e in s?Rp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xe=(s,e,t)=>Dp(s,typeof e!="symbol"?e+"":e,t);const Mp=async s=>await new Promise(e=>setTimeout(e,O.fromMilliseconds(s).milliseconds));class Pp{constructor(e){xe(this,"config"),xe(this,"retries"),xe(this,"interval"),this.config={baseInterval:new O((e==null?void 0:e.baseInterval)??O.seconds(1)),maxRetries:(e==null?void 0:e.maxRetries)??5,scale:(e==null?void 0:e.scale)??1,sleepFn:(e==null?void 0:e.sleepFn)??Mp},this.retries=0,this.interval=new O(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:t,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(t),this.retries++,!0)}reset(){this.retries=0,this.interval=this.config.baseInterval}}const $p=i.z.object({baseInterval:O.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),ic=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Pp,breakerConfig:$p},Symbol.toStringTag,{value:"Module"})),Lp=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,ni=i.z.string().regex(Lp),gt=i.z.number().min(0).max(255),Fp=i.z.number().min(0).max(1),ri=i.z.tuple([gt,gt,gt,Fp]),ac=i.z.tuple([gt,gt,gt]),oc=i.z.object({rgba255:ri}),ii=(s,e=1)=>{if(typeof s=="string")return qp(s,e);if(Array.isArray(s)){if(s.length<3||s.length>4)throw new Error(`Invalid color: [${s.join(", ")}]`);return s.length===3?[...s,e]:s}if(typeof s=="object"&&"rgba255"in s)return s.rgba255;throw new Error(`Invalid color: ${JSON.stringify(s)}`)},_p=i.z.union([ni,ri,ac,oc]).transform(s=>ii(s)),qp=(s,e=1)=>{if(!ni.safeParse(s).success)throw new Error(`Invalid hex color: ${s}`);return s=Wp(s),[Rs(s,0),Rs(s,2),Rs(s,4),s.length===8?Rs(s,6)/255:e]},Rs=(s,e)=>parseInt(s.slice(e,e+2),16),Wp=s=>s.startsWith("#")?s.slice(1):s,Vp=i.z.union([ni,ri,i.z.string(),ac,oc]);ii("#000000");ii("#ffffff");const Yp=i.z.object({key:i.z.string(),color:Vp,position:i.z.number(),switched:i.z.boolean().optional()});i.z.array(Yp);const Zp=i.z.object({key:i.z.string(),name:i.z.string(),color:_p});i.z.object({key:i.z.string(),name:i.z.string(),swatches:i.z.array(Zp)});const cc=i.z.number().int().min(0).max(255),lc=255,hc=0,Kp={lower:hc,upper:lc+1},uc=i.z.object({name:i.z.string(),key:i.z.string()}),hs=s=>i.z.object({subject:uc,resource:s,authority:cc}),Hp=(...s)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=s.includes(t.to.resource)),t.from!=null&&!n&&(n=s.includes(t.from.resource)),n}),dc=i.z.object({from:hs(i.z.any()),to:i.z.null()}),fc=i.z.object({from:i.z.null(),to:hs(i.z.any())}),Gp=i.z.union([dc,fc,i.z.object({from:hs(i.z.any()),to:hs(i.z.any())})]),st=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:lc,AUTHORITY_BOUNDS:Kp,ZERO_AUTHORITY:hc,acquireZ:fc,authorityZ:cc,filterTransfersByChannelKey:Hp,releaseZ:dc,stateZ:hs,subjectZ:uc,transferZ:Gp},Symbol.toStringTag,{value:"Module"})),Jp=s=>Object.getOwnPropertySymbols(globalThis).includes(s),Xp=(s,e)=>{const t=Symbol.for(s);if(!Jp(t)){const n=e();Object.defineProperty(globalThis,t,{value:n})}return()=>globalThis[t]},Qp=s=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(s):e instanceof Error?e.message.startsWith(s):typeof e!="string"?!1:e.startsWith(s),cn=s=>{var e;return e=class extends Error{constructor(t,n){super(t,n),xe(this,"discriminator",e.discriminator),xe(this,"type",e.TYPE),xe(this,"matches",e.matches),this.name=e.TYPE}static sub(t){return cn(`${s}.${t}`)}},xe(e,"discriminator","FreighterError"),xe(e,"TYPE",s),xe(e,"matches",Qp(s)),e},yc=s=>{if(s==null||typeof s!="object")return!1;const e=s;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},ht="unknown",xr="nil";class eg{constructor(){xe(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:xr,data:""};if(yc(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:ht,data:e.message};if(typeof e=="string")return{type:ht,data:e};try{return{type:ht,data:JSON.stringify(e)}}catch{return{type:ht,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===xr)return null;if(e.type===ht)return new Ir(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Ir(e.data)}}const ai=Xp("synnax-error-registry",()=>new eg),tg=({encode:s,decode:e})=>ai().register({encode:s,decode:e}),sg=s=>ai().encode(s),ng=s=>s==null?null:ai().decode(s);class Ir extends cn("unknown"){}const rg=i.z.object({type:i.z.string(),data:i.z.string()});class ig extends cn("canceled"){}const bt=Object.freeze(Object.defineProperty({__proto__:null,Canceled:ig,NONE:xr,UNKNOWN:ht,Unknown:Ir,createTyped:cn,decode:ng,encode:sg,isTyped:yc,payloadZ:rg,register:tg},Symbol.toStringTag,{value:"Module"}));i.object({jsonrpc:i.string(),id:i.number().optional(),method:i.string().optional(),params:i.unknown().optional(),result:i.unknown().optional()});const Er=i.z.string().regex(/^\d+\.\d+\.\d+$/),ws=(s,e,t={})=>{t.checkMajor??(t.checkMajor=!0),t.checkMinor??(t.checkMinor=!0),t.checkPatch??(t.checkPatch=!0);const n=Er.parse(s),r=Er.parse(e),[a,o,c]=n.split(".").map(Number),[h,d,f]=r.split(".").map(Number);if(t.checkMajor){if(a<h)return Cn;if(a>h)return Bn}if(t.checkMinor){if(o<d)return Cn;if(o>d)return Bn}if(t.checkPatch){if(c<f)return Cn;if(c>f)return Bn}return an},ag=(s,e,t={})=>ey(ws(s,e,t)),pc=(s,e,t={})=>Qf(ws(s,e,t)),og=(s,e,t={})=>Xf(ws(s,e,t)),cg=({name:s,migrate:e})=>t=>{try{const n=e(t);return console.log(`${s} migrated: ${t.version} -> ${n.version}`),n}catch(n){throw console.log(`${s} failed to migrate from ${t.version}`),console.error(n),n}},lg=({name:s,migrations:e,targetSchema:t,defaultVersion:n,def:r})=>{const a=Object.keys(e).sort(ws).pop();if(a==null)return d=>{if(d.version??(d.version=n),d.version!==r.version)return console.log(`${s} version ${d.version} is newer than latest version of ${r.version}.
|
|
26
|
-
Returning default instead.
|
|
27
|
-
`),r;try{return t!=null?t.parse(d):d}catch(f){return console.log(`${s} failed to parse default. Exiting with default`),console.error(f),r}};const o=Object.keys(e).length;let c=!1;const h=d=>{try{if(o===0||pc(d.version,a))return console.log(c?`${s} ${d.version} now up to date`:`${s} version ${d.version} is up to date with target version ${r.version}`),d;const f=d.version,u=e[f],z=u(d);return c=!0,h(z)}catch(f){return console.log(`${s} failed to migrate from ${d.version} to ${a}`),console.error(f),r}};return d=>{try{if(d.version==null)if(n!=null)console.log(`${s} version is null. Setting version to default of ${n}`),d.version=n;else return console.log(`${s} version is null and no default version set. Exiting with default`),r;return h(d)}catch(f){return console.log(`${s} failed to parse final result. Exiting with default`),console.error(f),r}}},Ta=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:ws,createMigration:cg,migrator:lg,semVerNewer:pc,semVerOlder:og,semVerZ:Er,versionsEqual:ag},Symbol.toStringTag,{value:"Module"})),hg=["standard","scientific","engineering"];i.z.enum(hg);const ug=(s,e="")=>{const t=s.length;return t===0?e:t===1?s[0]:t===2?`${s[0]} and ${s[1]}`:`${s.slice(0,-1).join(", ")}, and ${s[t-1]}`},dg=s=>{const e=s.split(" "),t=new Set,n=e.map(o=>o.charAt(0).toLowerCase()).join("");t.add(n.replace(/-/g,"_")),t.add(n.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const r=/\d+/g;s.match(r)&&e.forEach((o,c)=>{if(r.test(o)){const h=e.map((d,f)=>f!==c?d.charAt(0).toLowerCase():d).join("");t.add(h.replace(/-/g,"_")),t.add(h.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const a=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return t.add(a.join("").replace(/-/g,"_")),t.add(a.join("_").replace(/-/g,"_")),Array.from(t).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},fg=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:dg,naturalLanguageJoin:ug},Symbol.toStringTag,{value:"Module"}));class Me extends bt.createTyped("sy"){}let W=class extends Me.sub("validation"){};class za extends W.sub("field"){constructor(e,t){super(`${e}: ${t}`),l(this,"field"),l(this,"message"),this.field=e,this.message=t}}class Xs extends Me.sub("auth"){}class Nr extends Xs.sub("invalid-token"){}class Ar extends Xs.sub("expired-token"){}class ue extends Me.sub("unexpected"){constructor(e){super(`
|
|
28
|
-
Unexpected error encountered:
|
|
29
|
-
|
|
30
|
-
${e}
|
|
31
|
-
|
|
32
|
-
Please report this to the Synnax team.
|
|
33
|
-
`)}}class Re extends Me.sub("query"){}class nt extends Re.sub("not_found"){}class vt extends Re.sub("multiple_results"){}class Oa extends Me.sub("route"){constructor(e,t){super(e),l(this,"path"),this.path=t}}class Ur extends Me.sub("control"){}class ka extends Ur.sub("unauthorized"){}class jS extends Me.sub("contiguity"){}const yg=s=>{if(!s.type.startsWith(Me.TYPE))return null;if(s.type.startsWith(W.TYPE)){if(s.type===za.TYPE){const e=s.data.split(": ");return e.length<2?new W(s.data):new za(e[0],e[1])}return new W(s.data)}return s.type.startsWith(Xs.TYPE)?s.type.startsWith(Nr.TYPE)?new Nr(s.data):s.type.startsWith(Ar.TYPE)?new Ar(s.data):new Xs(s.data):s.type.startsWith(ue.TYPE)?new ue(s.data):s.type.startsWith(Re.TYPE)?s.type.startsWith(nt.TYPE)?new nt(s.data):s.type.startsWith(vt.TYPE)?new vt(s.data):new Re(s.data):s.type.startsWith(Ur.TYPE)?s.type.startsWith(ka.TYPE)?new ka(s.data):new Ur(s.data):s.type.startsWith(Oa.TYPE)?new Oa(s.data,s.data):new ue(s.data)},pg=()=>{throw new Error("Not implemented")};bt.register({encode:pg,decode:yg});const gg=async(s,e)=>{const[t,n]=await e(s);return n==null?[t,n]:n instanceof Ge?[t,new Ge({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},ln=i.z.string().uuid(),oi=i.z.string(),gc=i.z.object({key:ln,name:oi}),mc="group",te=s=>i.z.union([i.z.union([i.z.null(),i.z.undefined()]).transform(()=>[]),s.array()]),se=i.z.number(),bs=i.z.string(),vs=i.z.object({name:bs,key:se,dataType:N.z,leaseholder:i.z.number(),index:se,isIndex:i.z.boolean(),internal:i.z.boolean(),virtual:i.z.boolean(),alias:i.z.string().optional(),expression:i.z.string().default(""),requires:te(se)}),wc=vs.extend({key:se.optional(),leaseholder:i.z.number().optional(),index:se.optional(),isIndex:i.z.boolean().optional(),internal:i.z.boolean().optional().default(!1),virtual:i.z.boolean().optional().default(!1),expression:i.z.string().optional().default(""),requires:te(se).optional().default([])}),hn="channel",ci="framer",xa=s=>{const e=b(s);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Ia=(s,e)=>{const t=b(s);if(t.length===e.length)return;const n=xa(s);throw xa===null?new W("[Frame] - channel keys or names must be provided when constructing a frame."):new W(`[Frame] - ${n}s and series must be the same length.
|
|
34
|
-
Got ${t.length} ${n}s and ${e.length} series.`)};class J{constructor(e=[],t=[]){if(l(this,"columns",[]),l(this,"series",[]),e instanceof J){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,r)=>this.push(r,...b(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e;n.series??(n.series=[]),n.keys??(n.keys=[]);const r=n.series.map(a=>bc(a));Ia(n.keys,r),n.keys.forEach((a,o)=>this.push(a,r[o]))}else Object.entries(e).forEach(([n,r])=>{const a=parseInt(n);if(!isNaN(a))return this.push(a,...b(r));this.push(n,...b(r))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=b(t),r=b(e);Ia(r,n),n.forEach((a,o)=>this.push(r[o],a));return}throw new W(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
35
|
-
payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
|
|
36
|
-
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new ue("colType is not key");return this.columns??[]}get uniqueKeys(){return na.unique(this.keys)}get names(){if(this.colType==="key")throw new ue("colType is not name");return this.columns??[]}get uniqueNames(){return na.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>vc(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(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return V.ZERO;const n=x.min(...this.series.map(a=>a.timeRange.start)),r=x.max(...this.series.map(a=>a.timeRange.end));return new V(n,r)}const t=this.get(e);return t==null?V.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Hy(this.series.filter((t,n)=>this.columns[n]===e))}push(e,...t){if(e instanceof J){if(this.colType!==null&&e.colType!==this.colType)throw new W("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new W("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new W("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new J([...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 t=new J;return this.forEach((n,r,a)=>t.push(...e(n,r,a))),t}forEach(e){this.columns.forEach((t,n)=>{const r=this.series[n];e(t,r,n)})}at(e,t=!1){const n={};return this.uniqueColumns.forEach(r=>{n[r]=this.get(r).at(e,t)}),n}filter(e){const t=new J;return this.columns.forEach((n,r)=>{const a=this.series[r];e(n,a,r)&&t.push(n,a)}),t}get byteLength(){return new wt(this.series.reduce((e,t)=>e.add(t.byteLength),wt.ZERO))}get digest(){const e={};return this.keys.forEach((t,n)=>{const r=this.series[n].digest;t in e?e[t].push(r):e[t]=[r]}),e}get length(){return this.series.reduce((e,t)=>e+t.length,0)}toString(){let e=`Frame{
|
|
37
|
-
`;return this.uniqueColumns.forEach(t=>{e+=` ${t}: ${this.get(t).series.map(n=>n.toString()).join(",")}
|
|
38
|
-
`}),e+="}",e}}const un=i.z.object({keys:i.z.union([i.z.null().transform(()=>[]),i.z.number().array().optional().default([])]),series:i.z.union([i.z.null().transform(()=>[]),Je.crudeZ.array().optional().default([])])}),bc=s=>{const{dataType:e,data:t,timeRange:n,alignment:r}=s;return new Je({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:r})},vc=s=>({timeRange:s.timeRange,dataType:s.dataType,data:new Uint8Array(s.data.buffer),alignment:s.alignment}),it=jp.uint32,Sc=i.z.object({key:it,variant:i.z.string(),message:i.z.string(),lastReceived:x.z.optional()}),li=i.z.object({key:it,name:i.z.string(),state:Sc.optional()}),mg=li.partial({key:!0}),Tc="rack",hi=s=>s?rt.JSON_CODEC.decodeString(s,pe):{},dn=i.z.string(),zc=i.z.object({key:dn,variant:i.z.string(),details:pe.or(i.z.string().transform(hi))}),fn=i.z.object({key:dn,rack:it,name:i.z.string(),make:i.z.string(),model:i.z.string(),location:i.z.string(),configured:i.z.boolean().optional(),properties:pe.or(i.z.string().transform(hi)),state:zc.optional()}),wg=fn.extend({properties:i.z.unknown().transform(s=>rt.JSON_CODEC.encodeString(s))}),Oc="device",Ee=s=>s?JSON.parse(s):{},at=i.z.union([i.z.string(),i.z.bigint().transform(s=>s.toString()),i.z.number().transform(s=>s.toString())]),bg=i.z.enum(["info","success","error","warning"]),Qs=i.z.object({task:at,variant:bg,key:i.z.string().optional(),details:pe.or(i.z.string().transform(Ee)).or(i.z.array(i.z.unknown())).or(i.z.null())}),yn=i.z.object({key:at,name:i.z.string(),type:i.z.string(),internal:i.z.boolean().optional(),config:pe.or(i.z.string().transform(hi)),state:Qs.optional().nullable(),snapshot:i.z.boolean().optional()}),vg=yn.omit({key:!0}).extend({key:at.transform(s=>s.toString()).optional(),config:i.z.unknown().transform(s=>rt.JSON_CODEC.encodeString(s))}),kc=i.z.object({task:at,type:i.z.string(),key:i.z.string(),args:pe.or(i.z.string().transform(Ee)).or(i.z.array(i.z.unknown())).or(i.z.null()).optional()}),ui="task",Ot=i.z.string().uuid(),pn=i.z.object({key:Ot,name:i.z.string().min(1),color:i.z.string()}),xc="label",oe=i.z.string().uuid(),di=i.z.string().min(1),Ss=i.z.object({key:oe,name:di,timeRange:V.z,color:i.z.string().optional()}),Ic=Ss.partial({key:!0}),Ec=s=>{const e=b(s),t=e.length===0;let n=!1;return t||(n=oe.safeParse(e[0]).success),{single:!Array.isArray(s),variant:n?"keys":"names",normalized:e,actual:s,empty:t}},fi="range",yi="range-alias",kt=i.z.string().uuid(),gn=i.z.object({key:kt,username:i.z.string().min(1),firstName:i.z.string().default(""),lastName:i.z.string().default(""),rootUser:i.z.boolean().default(!0)}),Sg=gn.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:i.z.string().min(1)}),Tg="user",Ts=i.z.string().uuid(),pi=i.z.object({key:Ts,name:i.z.string(),data:pe.or(i.z.string().transform(Ee))}),zg=pi.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Og="lineplot",zs=i.z.string().uuid(),gi=i.z.object({key:zs,name:i.z.string(),data:pe.or(i.z.string().transform(Ee))}),kg=gi.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),xg="log",Pe=i.z.string().uuid(),mi=i.z.object({key:Pe,name:i.z.string(),layout:pe.or(i.z.string().transform(Ee))}),Nc="workspace",Ig=mi.partial({key:!0}).transform(s=>({...s,layout:JSON.stringify(s.layout)})),Eg=mi.omit({layout:!0}).extend({layout:i.z.string().transform(Ee)}),xt=i.z.string().uuid(),wi=i.z.object({key:xt,name:i.z.string(),data:pe.or(i.z.string().transform(Ee)),snapshot:i.z.boolean()}),Ng=wi.partial({key:!0,snapshot:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Ac=wi.extend({data:i.z.string().transform(Ee)}),Ag="schematic",Os=i.z.string().uuid(),Uc=i.z.object({key:Os,name:i.z.string(),data:pe.or(i.z.string().transform(Ee))}),Ug=Uc.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Cc=Uc.extend({data:i.z.string().transform(Ee)}),Cg="table",Bc="builtin",Bg="cluster",jg="node",mn=i.z.enum([xc,xg,Qa,Bc,Bg,hn,jg,mc,fi,ci,yi,Tg,Nc,Ag,Og,Tc,Oc,ui,rh,Cg]),ce=i.z.object({type:mn,key:i.z.string()}),Rg=i.z.string().transform(s=>{const[e,t]=s.split(":");return{type:mn.parse(e),key:t??""}}),Qt=i.z.union([Rg,ce]),Ws=class jc{constructor(e){if(l(this,"type"),l(this,"key"),e instanceof jc){this.type=e.type,this.key=e.key;return}if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n??"";return}this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}isType(){return this.key===""}matchesType(e){return this.type===e&&this.isType()}get payload(){return{type:this.type,key:this.key}}};l(Ws,"z",i.z.union([i.z.instanceof(Ws),Qt.transform(s=>new Ws(s))]));let A=Ws;new A({type:Bc,key:"root"});const Dg=i.z.object({type:i.z.number()}),Mg=i.z.object({type:mn,fields:i.z.record(i.z.string(),Dg)}),Pg=i.z.object({id:A.z,name:i.z.string(),schema:Mg.optional().nullable(),data:pe.optional().nullable()}).transform(s=>({key:s.id.toString(),...s}));i.z.object({from:A.z,type:i.z.string(),to:A.z});const Ea=s=>{const[e,t,n]=s.split("->");return{from:new A(e),type:t,to:new A(n)}};class Rc{constructor(e,t){l(this,"key"),l(this,"name"),this.key=t,this.name=e}get ontologyID(){return $g(this.key)}}const $g=s=>new A({type:mc,key:s}),Lg=i.z.object({group:gc}),Fg=i.z.object({parent:ce,key:ln.optional(),name:oi}),_g=i.z.object({key:ln,name:oi}),qg=i.z.object({keys:i.z.array(ln)});var Fe;let Wg=(Fe=class{constructor(s){l(this,"client"),this.client=s}async create(s,e,t){return(await w(this.client,Fe.CREATE_ENDPOINT,{parent:s,name:e,key:t},Fg,Lg)).group}async rename(s,e){await w(this.client,Fe.RENAME_ENDPOINT,{key:s,name:e},_g,i.z.object({}))}async delete(s){await w(this.client,Fe.DELETE_ENDPOINT,{keys:s},qg,i.z.object({}))}},l(Fe,"CREATE_ENDPOINT","/ontology/create-group"),l(Fe,"RENAME_ENDPOINT","/ontology/rename-group"),l(Fe,"DELETE_ENDPOINT","/ontology/delete-group"),Fe),Vg=class{constructor(s){l(this,"creator"),this.creator=new Wg(s)}async create(s,e,t){return this.sugar(await this.creator.create(s,e,t))}async rename(s,e){return await this.creator.rename(s,e)}async delete(...s){return await this.creator.delete(s)}sugar(s){return new Rc(s.name,s.key)}};const Yg="/ontology/add-children",Zg="/ontology/remove-children",Kg="/ontology/move-children",Na=i.z.object({id:ce,children:ce.array()}),Hg=i.z.object({from:ce,to:ce,children:ce.array()}),Pn=i.z.object({});let Gg=class{constructor(s){l(this,"client"),this.client=s}async addChildren(s,...e){await w(this.client,Yg,{id:new A(s).payload,children:e.map(t=>new A(t).payload)},Na,Pn)}async removeChildren(s,...e){await w(this.client,Zg,{id:new A(s).payload,children:e.map(t=>new A(t).payload)},Na,Pn)}async moveChildren(s,e,...t){const n={from:new A(s).payload,to:new A(e).payload,children:t.map(r=>new A(r).payload)};await w(this.client,Kg,n,Hg,Pn)}};const Jg="/ontology/retrieve",Xg=i.z.object({ids:ce.array().optional(),children:i.z.boolean().optional(),parents:i.z.boolean().optional(),includeSchema:i.z.boolean().optional(),excludeFieldData:i.z.boolean().optional(),term:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),types:mn.array().optional()}),Qg=i.z.object({resources:Pg.array()}),$n=s=>b(s).map(e=>new A(e).payload);let em=class{constructor(s,e){l(this,"type","ontology"),l(this,"groups"),l(this,"client"),l(this,"writer"),l(this,"framer"),this.client=s,this.writer=new Gg(s),this.groups=new Vg(s),this.framer=e}async search(s,e){return await this.execRetrieve({term:s,...e})}async retrieve(s,e){const t=await this.execRetrieve({ids:$n(s),...e});if(Array.isArray(s))return t;if(t.length===0)throw new Re(`No resource found with ID ${fg.naturalLanguageJoin(b(s).map(n=>new A(n).toString()))}`);return t[0]}async page(s,e,t){return await this.execRetrieve({offset:s,limit:e,...t})}async retrieveChildren(s,e){return await this.execRetrieve({ids:$n(s),children:!0,...e})}async retrieveParents(s,e){return await this.execRetrieve({ids:$n(s),parents:!0,...e})}async addChildren(s,...e){return await this.writer.addChildren(s,...e)}async removeChildren(s,...e){return await this.writer.removeChildren(s,...e)}async moveChildren(s,e,...t){return await this.writer.moveChildren(s,e,...t)}async openChangeTracker(){return await wn.open(this.framer,this)}async openDependentTracker(s){return await bi.open(s,this.framer,this)}newSearcherWithOptions(s){return{type:this.type,search:e=>this.search(e,s),retrieve:e=>this.retrieve(e,s),page:(e,t)=>this.page(e,t,s)}}async execRetrieve(s){const{resources:e}=await w(this.client,Jg,s,Xg,Qg);return e}};const Aa="sy_ontology_resource_set",Ua="sy_ontology_resource_delete",Ca="sy_ontology_relationship_set",Ba="sy_ontology_relationship_delete";class wn{constructor(e,t){l(this,"relationships"),l(this,"resources"),l(this,"resourceObs"),l(this,"relationshipObs"),l(this,"streamer"),l(this,"client"),l(this,"closePromise"),this.relationshipObs=new tt.Observer,this.relationships=this.relationshipObs,this.resourceObs=new tt.Observer,this.resources=this.resourceObs,this.client=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const r=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);r.concat(a).length>0&&this.relationshipObs.notify(r.concat(a))}parseRelationshipSets(e){const t=e.get(Ca);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:Ea(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Ba);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:Ea(n)}))}async parseResourceSets(e){const t=e.get(Aa);if(t.length===0)return[];const n=Array.from(t.as("string")).map(r=>new A(r));try{return(await this.client.retrieve(n)).map(r=>({variant:"set",key:r.id,value:r}))}catch(r){if(r instanceof Re)return[];throw r}}parseResourceDeletes(e){const t=e.get(Ua);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new A(n)}))}static async open(e,t){const n=await e.openStreamer([Aa,Ua,Ca,Ba]);return new wn(n,t)}}const ja=s=>s==="from"?"to":"from";class bi extends tt.Observer{constructor({target:e,dependents:t,relationshipType:n="parent",relationshipDirection:r="from",resourceType:a},o,c){super(),l(this,"internal"),l(this,"target"),l(this,"relDir"),l(this,"resourceType"),l(this,"dependents"),l(this,"client"),l(this,"relType"),l(this,"handleResourceChange",h=>{this.dependents=this.dependents.map(d=>{const f=h.find(u=>u.key.toString()==d.id.toString());return f==null||f.variant==="delete"?d:f.value}),this.notify(this.dependents)}),l(this,"handleRelationshipChange",h=>{const d=h.filter(u=>u.variant==="delete"&&u.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||u.key[ja(this.relDir)].type===this.resourceType));this.dependents=this.dependents.filter(u=>!d.some(z=>z.key.to.toString()===u.id.toString()&&z.key.type===this.relType));const f=h.filter(u=>u.variant==="set"&&u.key.type===this.relType&&u.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||u.key[ja(this.relDir)].type===this.resourceType));if(f.length===0)return this.notify(this.dependents);this.client.retrieve(f.map(u=>u.key.to)).then(u=>{this.dependents=this.dependents.concat(u),this.notify(this.dependents)}).catch(console.error)}),this.resourceType=a,this.internal=o,this.target=e,this.dependents=t,this.resourceType!=null&&(this.dependents=this.dependents.filter(h=>h.id.type===this.resourceType)),this.client=c,this.relType=n,this.relDir=r,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,t,n){const r=await wn.open(t,n);return new bi(e,r,n)}async close(){await this.internal.close()}}const bn=i.z.string().uuid(),vi=i.z.object({key:bn,subjects:te(ce),objects:te(ce),actions:te(gr)}),tm=i.z.object({key:bn.optional(),subjects:Qt.array().or(Qt),objects:Qt.array().or(Qt),actions:gr.array().or(gr)}),sm=i.z.object({keys:bn.array().optional(),subjects:ce.array().optional()}),nm=i.z.object({policies:te(vi)}),rm="/access/policy/retrieve";let im=class{constructor(s){l(this,"client"),this.client=s}async retrieve(s){return(await w(this.client,rm,s,sm,nm)).policies}};const am=i.z.object({policies:vi.partial({key:!0}).array()}),om=i.z.object({policies:vi.array()}),cm=i.z.object({keys:bn.array()}),lm=i.z.object({}),hm="/access/policy/create",um="/access/policy/delete";let dm=class{constructor(s){l(this,"client"),this.client=s}async create(s){const e=tm.array().parse(b(s)).map(t=>({objects:b(t.objects),actions:b(t.actions),subjects:b(t.subjects)}));return(await w(this.client,hm,{policies:e},am,om)).policies}async delete(s){await w(this.client,um,{keys:b(s)},cm,lm)}},fm=class{constructor(s){l(this,"retriever"),l(this,"writer"),this.retriever=new im(s),this.writer=new dm(s)}async create(s){const e=Array.isArray(s),t=await this.writer.create(s);return e?t:t[0]}async retrieve(s){const e=Array.isArray(s),t=await this.retriever.retrieve({keys:b(s)});return e?t:t[0]}async retrieveFor(s){const e=b(s).map(t=>new A(t).payload);return await this.retriever.retrieve({subjects:e})}async delete(s){await this.writer.delete(s)}};new A({type:Qa,key:""});let ym=class{constructor(s){l(this,"policy"),this.policy=new fm(s)}};const pm=new Error("request for lock canceled");var gm=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function c(f){try{d(n.next(f))}catch(u){o(u)}}function h(f){try{d(n.throw(f))}catch(u){o(u)}}function d(f){f.done?a(f.value):r(f.value).then(c,h)}d((n=n.apply(s,e||[])).next())})};class mm{constructor(e,t=pm){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{const a={resolve:n,reject:r,weight:e,priority:t},o=Dc(this._queue,c=>t<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return gm(this,arguments,void 0,function*(t,n=1,r=0){const[a,o]=yield this.acquire(n,r);try{return yield t(a)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),wm(this._weightedWaiters[e-1],{resolve:n,priority:t})})}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 t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const r=n.findIndex(a=>a.priority<=e);(r===-1?n:n.splice(0,r)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function wm(s,e){const t=Dc(s,n=>e.priority<=n.priority);s.splice(t+1,0,e)}function Dc(s,e){for(let t=s.length-1;t>=0;t--)if(e(s[t]))return t;return-1}var bm=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function c(f){try{d(n.next(f))}catch(u){o(u)}}function h(f){try{d(n.throw(f))}catch(u){o(u)}}function d(f){f.done?a(f.value):r(f.value).then(c,h)}d((n=n.apply(s,e||[])).next())})};class vm{constructor(e){this._semaphore=new mm(1,e)}acquire(){return bm(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}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 Si=(s,e,{convertNumericStrings:t=!0}={})=>{const n=!Array.isArray(s);let r=b(s);const a=r[0],o=typeof a;let c;return o==="string"&&t&&!isNaN(parseInt(a))&&"number"in e?(c=e.number,r=r.map(h=>parseInt(h))):c=e[o],{single:n,variant:c,normalized:r,actual:s}},vn=(s,e,t,n)=>{if(n){if(t.length===0)throw new nt(`${s} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new vt(`Expected one ${s} matching ${JSON.stringify(e)}, but found ${t.length}`)}},Sm=i.z.object({leaseholder:i.z.number().optional(),keys:se.array().optional(),names:i.z.string().array().optional(),search:i.z.string().optional(),rangeKey:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),dataTypes:N.z.array().optional(),notDataTypes:N.z.array().optional(),virtual:i.z.boolean().optional(),isIndex:i.z.boolean().optional(),internal:i.z.boolean().optional()}),Tm=i.z.object({channels:te(vs)}),Ie=s=>(Array.isArray(s)&&s.length>0&&typeof s[0]=="object"?s=s.map(e=>e.key):typeof s=="object"&&"key"in s&&(s=[s.key]),Si(s,{number:"keys",string:"names"})),Mc=class Pc{constructor(e){l(this,"client"),this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){const n=Ie(e),{variant:r}=n;let{normalized:a}=n;return r==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[r]:a,...t})}async page(e,t,n){return await this.execute({offset:e,limit:t,...n})}async execute(e){const[t,n]=await this.client.send(Pc.ENDPOINT,e,Sm,Tm);if(n!=null)throw n;return t.channels}};l(Mc,"ENDPOINT","/channel/retrieve");let Ti=Mc;class zi{constructor(e){l(this,"cache"),l(this,"namesToKeys"),l(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e,t){const{normalized:n}=Ie(e),r=[],a=[];if(n.forEach(c=>{const h=this.get(c);h!=null?r.push(...h):a.push(c)}),a.length===0)return r;const o=await this.wrapped.retrieve(a,t);return this.set(o),r.concat(o)}delete(e){const{variant:t,normalized:n}=Ie(e);t==="names"?n.forEach(r=>{const a=this.namesToKeys.get(r);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(r))}):n.forEach(r=>{const a=this.cache.get(r);a!=null&&(this.cache.delete(r),this.namesToKeys.delete(a.name))})}rename(e,t){e.forEach((n,r)=>{const a=t[r],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=a,this.cache.set(n,o);const h=this.namesToKeys.get(a);h==null?this.namesToKeys.set(a,new Set([n])):h.add(n)})}set(e){e.forEach(t=>{this.cache.set(t.key,t);const n=this.namesToKeys.get(t.name);n==null?this.namesToKeys.set(t.name,new Set([t.key])):n.add(t.key)})}get(e){if(typeof e=="number"){const r=this.cache.get(e);return r==null?void 0:[r]}const t=this.namesToKeys.get(e);if(t==null)return;const n=[];if(t.forEach(r=>{const a=this.cache.get(r);a!=null&&n.push(a)}),n.length!==0)return n}}class $c{constructor(e,t){l(this,"mu",new vm),l(this,"requests",new Map),l(this,"wrapped"),l(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=Jy(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=Ie(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((r,a)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:r,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(r=>e.add(r)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,r)=>n.resolve(t.filter(a=>r.includes(a.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const Lc=async(s,e)=>{const{normalized:t}=Ie(e),n=await s.retrieve(t),r=[];if(t.forEach(a=>{n.find(o=>o.name===a||o.key===a)==null&&r.push(a)}),r.length>0)throw new Re(`Could not find channels: ${JSON.stringify(r)}`);return n};class Fc{constructor({dataType:e,name:t,leaseholder:n=0,key:r=0,isIndex:a=!1,index:o=0,internal:c=!1,virtual:h=!1,frameClient:d,alias:f,expression:u="",requires:z=[]}){l(this,"_frameClient"),l(this,"key"),l(this,"name"),l(this,"dataType"),l(this,"leaseholder"),l(this,"index"),l(this,"isIndex"),l(this,"internal"),l(this,"alias"),l(this,"virtual"),l(this,"expression"),l(this,"requires"),this.key=r,this.name=t,this.dataType=new N(e),this.leaseholder=n,this.index=o,this.isIndex=a,this.internal=c,this.alias=f,this.virtual=h,this.expression=u,this.requires=z??[],this._frameClient=d??null}get framer(){if(this._frameClient==null)throw new W("cannot read from a channel that has not been created");return this._frameClient}get payload(){return vs.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,expression:this.expression,requires:this.requires})}get isCalculated(){return en(this.payload)}get ontologyID(){return Wc(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}const zm="/channel/retrieve-group",Om=i.z.object({}),km=i.z.object({group:gc});let _c=class{constructor(s,e,t,n){l(this,"type",hn),l(this,"frameClient"),l(this,"client"),l(this,"retriever"),l(this,"writer"),this.frameClient=s,this.retriever=e,this.client=t,this.writer=n}async create(s,e={}){const{retrieveIfNameExists:t=!1}=e,n=!Array.isArray(s);let r=b(s),a=[];if(t){const o=await this.retriever.retrieve(r.map(h=>h.name)),c=new Set(o.map(h=>h.name));r=r.filter(h=>!c.has(h.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(r))),n?a[0]:a}async retrieve(s,e){const t=!Array.isArray(s),n=this.sugar(await this.retriever.retrieve(s,e));return vn("channel",s,n,t),t?n[0]:n}async search(s,e){return this.sugar(await this.retriever.search(s,e))}async delete(s){const{normalized:e,variant:t}=Ie(s);return t==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(s,e){return await this.writer.rename(b(s),b(e))}newSearcherWithOptions(s){return{type:this.type,search:async e=>await this.search(e,s),retrieve:async e=>await this.retrieve(e,s),page:async(e,t)=>await this.page(e,t,s)}}async page(s,e,t){return this.sugar(await this.retriever.page(s,e,t))}createDebouncedBatchRetriever(s=10){return new zi(new $c(new Ti(this.client),s))}sugar(s){const{frameClient:e}=this;return s.map(t=>new Fc({...t,frameClient:e}))}async retrieveGroup(){const s=await w(this.client,zm,{},Om,km);return new Rc(s.group.name,s.group.key)}};const en=({virtual:s,expression:e})=>s&&e!=="",qc=async(s,e)=>{if(!en(e))return e.index;for(const t of e.requires){const n=await s(t);if(n==null)return null;if(!n.virtual)return n.index}for(const t of e.requires){const n=await s(t);if(n==null)return null;if(en(n)){const r=await qc(s,n);if(r!=null)return r}}return null},Wc=s=>new A({type:hn,key:s.toString()}),xm=i.z.object({channels:wc.array()}),Im=i.z.object({channels:vs.array()}),Em=i.z.object({keys:se.array().optional(),names:bs.array().optional()}),Nm=i.z.object({}),Am=i.z.object({keys:se.array(),names:bs.array()}),Um=i.z.object({}),Cm="/channel/create",Bm="/channel/delete",jm="/channel/rename";let Vc=class{constructor(s,e){l(this,"client"),l(this,"cache"),this.client=s,this.cache=e}async create(s){const{channels:e}=await w(this.client,Cm,{channels:s},xm,Im);return this.cache.set(e),e}async delete(s){await w(this.client,Bm,s,Em,Nm),s.keys!=null&&this.cache.delete(s.keys),s.names!=null&&this.cache.delete(s.names)}async rename(s,e){await w(this.client,jm,{keys:s,names:e},Am,Um),this.cache.rename(s,e)}};const Rm=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:zi,Channel:Fc,Client:_c,ClusterRetriever:Ti,DebouncedBatchRetriever:$c,ONTOLOGY_TYPE:hn,Writer:Vc,analyzeParams:Ie,channelZ:vs,isCalculated:en,keyZ:se,nameZ:bs,newZ:wc,ontologyID:Wc,resolveCalculatedIndex:qc,retrieveRequired:Lc},Symbol.toStringTag,{value:"Module"})),Dm=i.z.object({keys:kt.array().optional(),usernames:i.z.string().array().optional()}),Mm=i.z.object({users:te(gn)}),Pm="/user/retrieve";let $m=class{constructor(s){l(this,"client"),this.client=s}async retrieve(s){return(await w(this.client,Pm,s,Dm,Mm)).users}};const Lm=i.z.object({users:Sg.array()}),Fm=i.z.object({users:gn.array()}),_m=i.z.object({key:kt,username:i.z.string().min(1)}),qm=i.z.object({}),Wm=i.z.object({key:kt,firstName:i.z.string().optional(),lastName:i.z.string().optional()}),Vm=i.z.object({}),Ym=i.z.object({keys:kt.array()}),Zm=i.z.object({}),Km="/user/create",Hm="/user/change-username",Gm="/user/rename",Jm="/user/delete";let Xm=class{constructor(s){l(this,"client"),this.client=s}async create(s){return(await w(this.client,Km,{users:b(s)},Lm,Fm)).users}async changeUsername(s,e){await w(this.client,Hm,{key:s,username:e},_m,qm)}async rename(s,e,t){await w(this.client,Gm,{key:s,firstName:e,lastName:t},Wm,Vm)}async delete(s){await w(this.client,Jm,{keys:b(s)},Ym,Zm)}},Qm=class{constructor(s){l(this,"reader"),l(this,"writer"),this.writer=new Xm(s),this.reader=new $m(s)}async create(s){const e=Array.isArray(s),t=await this.writer.create(s);return e?t:t[0]}async changeUsername(s,e){await this.writer.changeUsername(s,e)}async retrieve(s){const e=Array.isArray(s),t=await this.reader.retrieve({keys:b(s)});if(e)return t;if(t.length===0)throw new nt(`No user with key ${s} found`);if(t.length>1)throw new vt(`Multiple users found with key ${s}`);return t[0]}async retrieveByName(s){const e=Array.isArray(s),t=await this.reader.retrieve({usernames:b(s)});if(e)return t;if(t.length===0)throw new nt(`No user with username ${s} found`);if(t.length>1)throw new vt(`Multiple users found with username ${s}`);return t[0]}async rename(s,e,t){await this.writer.rename(s,e,t)}async delete(s){await this.writer.delete(s)}};const ew=i.z.object({username:i.z.string(),password:i.z.string()}),tw=i.z.object({token:i.z.string(),user:gn}),Ra="/auth/login",sw=3,nw="/auth/change-password",rw=i.z.object({username:i.z.string(),password:i.z.string(),newPassword:i.z.string().min(1)}),iw=i.z.object({}),aw=[Nr,Ar];let ow=class{constructor(s,e){l(this,"token"),l(this,"client"),l(this,"credentials"),l(this,"authenticating"),l(this,"authenticated"),l(this,"user"),l(this,"retryCount"),this.client=s,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(s){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,nw,{username:this.credentials.username,password:this.credentials.password,newPassword:s},rw,iw),this.credentials.password=s}middleware(){const s=async(e,t)=>{if(!this.authenticated&&!e.target.endsWith(Ra)){this.authenticating??(this.authenticating=new Promise((o,c)=>{this.client.send(Ra,this.credentials,ew,tw).then(([h,d])=>{if(d!=null)return o(d);this.token=h==null?void 0:h.token,this.user=h==null?void 0:h.user,this.authenticated=!0,o(null)}).catch(c)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[n,r]=await t(e);return aw.some(a=>a.matches(r))&&this.retryCount<sw?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,s(e,t)):(this.retryCount=0,[n,r])};return s}};const cw=i.z.enum(["disconnected","connecting","connected","failed"]),lw=i.z.object({status:cw,error:i.z.instanceof(Error).optional(),message:i.z.string().optional(),clusterKey:i.z.string(),clientVersion:i.z.string(),clientServerCompatible:i.z.boolean(),nodeVersion:i.z.string().optional()}),hw=i.z.object({clusterKey:i.z.string(),nodeVersion:i.z.string().optional()}),Yc={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.42.3"},Da=(s,e,t)=>{const n=t?"cluster":"client";return`Synnax cluster node version ${s!=null?`${s} `:""}is too ${t?"old":"new"} for client version ${e}.
|
|
39
|
-
This may cause compatibility issues. We recommend updating the ${n}. For more information, see
|
|
40
|
-
https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${n}-version`},Vs=class Zc{constructor(e,t=O.seconds(30),n,r){l(this,"_state"),l(this,"pollFrequency",O.seconds(30)),l(this,"client"),l(this,"name"),l(this,"interval"),l(this,"clientVersion"),l(this,"onChangeHandlers",[]),l(this,"versionWarned",!1),this._state={...Yc},this.client=e,this.pollFrequency=t,this.clientVersion=n,this.name=r,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const t=this._state.status;try{const[n,r]=await this.client.send(Zc.ENDPOINT,{},i.z.object({}),hw);if(r!=null)throw r;const a=n.nodeVersion,o=this.clientVersion,c=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,c||(console.warn(Da(null,o,!0)),this.versionWarned=!0)):Ta.versionsEqual(o,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,c||(console.warn(Da(a,o,Ta.semVerNewer(o,a))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey,this._state.nodeVersion=n.nodeVersion,this._state.clientVersion=this.clientVersion}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&t!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};l(Vs,"ENDPOINT","/connectivity/check"),l(Vs,"DEFAULT",Yc),l(Vs,"connectionStateZ",lw);let Kc=Vs;const uw=i.z.object({keys:se.array().optional(),bounds:V.z,names:bs.array().optional()}),dw=i.z.object({}),fw="/frame/delete";class yw{constructor(e){l(this,"client"),this.client=e}async delete(e){await w(this.client,fw,e,uw,dw)}}var St=(s=>(s[s.Open=0]="Open",s[s.Write=1]="Write",s[s.Commit=2]="Commit",s[s.SetAuthority=3]="SetAuthority",s))(St||{}),Tt=(s=>(s[s.PersistStream=1]="PersistStream",s[s.Persist=2]="Persist",s[s.Stream=3]="Stream",s))(Tt||{});const pw=s=>{switch(s){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof s=="number"&&s in Tt)return s;throw new Error(`invalid writer mode: ${s}`)}},gw=new O(-1);class Cr extends Me.sub("writer_closed"){constructor(){super("WriterClosed")}}const mw=i.z.object({start:x.z.optional(),controlSubject:st.subjectZ.optional(),keys:se.array().optional(),authorities:st.authorityZ.array().optional(),mode:i.z.enum(Tt).optional(),errOnUnauthorized:i.z.boolean().optional(),enableAutoCommit:i.z.boolean().optional(),autoIndexPersistInterval:O.z.optional()}),ww=i.z.object({command:i.z.enum(St),config:mw.optional(),frame:un.optional(),buffer:i.z.instanceof(Uint8Array).optional()}),bw=i.z.object({command:i.z.enum(St),end:x.z,err:bt.payloadZ.optional()});var Mt;let Hc=(Mt=class{constructor(s,e){l(this,"stream"),l(this,"adapter"),l(this,"closeErr",null),this.stream=s,this.adapter=e}static async _open(s,e,{channels:t,start:n=x.now(),authorities:r=st.ABSOLUTE_AUTHORITY,controlSubject:a,mode:o=1,errOnUnauthorized:c=!1,enableAutoCommit:h=!1,autoIndexPersistInterval:d=O.SECOND,useExperimentalCodec:f=!0}){const u=await ki.open(s,t);f&&(e=e.withCodec(new kw(u.codec)));const z=await e.stream(Mt.ENDPOINT,ww,bw),k=new Mt(z,u);return await k.execute({command:0,config:{start:new x(n),keys:u.keys,controlSubject:a,authorities:b(r),mode:pw(o),errOnUnauthorized:c,enableAutoCommit:h,autoIndexPersistInterval:d}}),k}async write(s,e){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();const t=await this.adapter.adapt(s,e);this.stream.send({command:1,frame:t.toPayload()})}async setAuthority(s,e){if(this.closeErr!=null)throw this.closeErr;let t;if(typeof s=="number"&&e==null)t={keys:[],authorities:[s]};else{let n;typeof s=="string"||typeof s=="number"?n={[s]:e}:n=s,n=await this.adapter.adaptObjectKeys(n),t={keys:Object.keys(n).map(r=>Number(r)),authorities:Object.values(n)}}await this.execute({command:3,config:t})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),x.ZERO):(await this.execute({command:2})).end}async close(){await this.closeInternal(null)}async closeInternal(s){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=s,this.stream.closeSend();;){if(this.closeErr!=null){if(Cr.matches(this.closeErr))return null;throw this.closeErr}const[e,t]=await this.stream.receive();t!=null?this.closeErr=ge.matches(t)?new Cr:t:this.closeErr=bt.decode(e==null?void 0:e.err)}}async execute(s){const e=this.stream.send(s);for(e!=null&&await this.closeInternal(e);;){const[t,n]=await this.stream.receive();n!=null&&await this.closeInternal(n);const r=bt.decode(t==null?void 0:t.err);if(r!=null&&await this.closeInternal(r),(t==null?void 0:t.command)==s.command)return t}}},l(Mt,"ENDPOINT","/frame/write"),Mt);const Ma=s=>s.data.byteLength/s.dataType.density.valueOf(),vw=s=>{const{keys:e,series:t}=s;e.forEach((n,r)=>{t[r].key=n}),t.sort((n,r)=>n.key-r.key),e.sort((n,r)=>n-r),t.forEach(n=>delete n.key)},Pa=5,$a=4,La=3,Fa=2,_a=1,qa=0,we=N.TIMESTAMP.density.valueOf(),_e=8,qe=4,Ln=4,Fn=4,Sw=1;class Gc{constructor(e=[],t=[]){l(this,"contentType","application/sy-framer"),l(this,"states",new Map),l(this,"currState"),l(this,"seqNum",0),(e.length>0||t.length>0)&&this.update(e,t)}update(e,t){this.seqNum++;const n={keys:e,keyDataTypes:new Map,hasVariableDataTypes:!1};e.forEach((r,a)=>{const o=t[a];n.keyDataTypes.set(r,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 W(`
|
|
41
|
-
The codec has not been updated with a list of channels and data types.
|
|
42
|
-
Please call the update method before calling ${e}.
|
|
43
|
-
`)}encode(e,t=0){var n,r;this.throwIfNotUpdated("encode");let a=e;e!=null&&typeof e=="object"&&"toPayload"in e&&(a=e.toPayload()),vw(a);let o=-1,c,h,d,f=t+Sw+Fn,u=!((n=this.currState)!=null&&n.hasVariableDataTypes),z=!0,k=!0,Y=!0,U=!0,de=!0;a.keys.length!==((r=this.currState)==null?void 0:r.keys.length)&&(Y=!1,f+=a.keys.length*Ln),a.series.forEach((F,Et)=>{var Ae,me,le,xs,Is;const Ri=Ma(F),zn=a.keys[Et],On=(Ae=this.currState)==null?void 0:Ae.keyDataTypes.get(zn);if(On==null)throw new W(`Channel ${zn} was not provided in the list of channels when opening the writer`);if(!On.equals(F.dataType))throw new W(`Series data type of ${F.dataType.toString()} does not match the data type of ${On.toString()} for channel ${zn}`);if(f+=F.data.byteLength,o===-1){o=Ri,c=(me=F.timeRange)==null?void 0:me.start,h=(le=F.timeRange)==null?void 0:le.end,d=BigInt(F.alignment??0n);return}o!==Ri&&(u=!1),((c==null?void 0:c.valueOf())!==((xs=F.timeRange)==null?void 0:xs.start.valueOf())||(h==null?void 0:h.valueOf())!==((Is=F.timeRange)==null?void 0:Is.end.valueOf()))&&(z=!1),d!==BigInt(F.alignment??0)&&(U=!1)}),k=z&&c==null&&h==null,de=U&&(d===void 0||d===0n),u?f+=qe:f+=a.keys.length*qe,k||(z?f+=we*2:f+=a.keys.length*we*2),de||(U?f+=_e:f+=a.keys.length*_e);const Ne=new Uint8Array(f),fe=new DataView(Ne.buffer);let B=t;return Ne[B]=Number(de)<<Pa|Number(U)<<$a|Number(u)<<La|Number(z)<<Fa|Number(k)<<_a|Number(Y)<<qa,B++,fe.setUint32(B,this.seqNum,!0),B+=Fn,u&&(fe.setUint32(B,o,!0),B+=qe),z&&!k&&(fe.setBigUint64(B,(c==null?void 0:c.valueOf())??0n,!0),fe.setBigUint64(B,(h==null?void 0:h.valueOf())??0n,!0),B+=we*2),U&&!de&&(fe.setBigUint64(B,d??0n,!0),B+=_e),a.series.forEach((F,Et)=>{var Ae,me;if(Y||(fe.setUint32(B,a.keys[Et],!0),B+=Ln),!u){let le=F.data.byteLength;F.dataType.isVariable||(le=Ma(F)),fe.setUint32(B,le,!0),B+=qe}Ne.set(new Uint8Array(F.data),B),B+=F.data.byteLength,!z&&!k&&(fe.setBigUint64(B,((Ae=F.timeRange)==null?void 0:Ae.start.valueOf())??0n,!0),fe.setBigUint64(B,((me=F.timeRange)==null?void 0:me.end.valueOf())??0n,!0),B+=we*2),!U&&!de&&(fe.setBigUint64(B,F.alignment??0n,!0),B+=_e)}),Ne}decode(e,t=0){this.throwIfNotUpdated("decode");const n=e instanceof Uint8Array?e:new Uint8Array(e),r={keys:[],series:[]};let a=t,o=0,c=0,h,d,f;const u=new DataView(n.buffer,n.byteOffset,n.byteLength),z=!!(n[a]>>Pa&1),k=!!(n[a]>>$a&1),Y=!!(n[a]>>La&1),U=!!(n[a]>>Fa&1),de=!!(n[a]>>_a&1),Ne=!!(n[a]>>qa&1);a++;const fe=u.getUint32(a,!0);a+=Fn;const B=this.states.get(fe);if(B==null)return r;if(Y){if(a+qe>u.byteLength)return r;o=u.getUint32(a,!0),a+=qe}if(U&&!de){if(a+we>u.byteLength)return r;h=new x(u.getBigUint64(a,!0)),a+=we,d=new x(u.getBigUint64(a,!0)),a+=we}if(k&&!z){if(a+_e>u.byteLength)return r;f=u.getBigUint64(a,!0),a+=_e}return Ne&&(r.keys=[...B.keys]),B.keys.forEach((F,Et)=>{if(!Ne){if(a>=u.byteLength||u.getUint32(a,!0)!==F)return;a+=Ln,r.keys.push(F)}const Ae=B.keyDataTypes.get(F);if(c=0,Y)c=o;else{if(a+qe>u.byteLength)return;c=u.getUint32(a,!0),a+=qe}let me=c;if(Ae.isVariable||(me*=Ae.density.valueOf()),a+me>u.byteLength){r.keys.splice(Et,1);return}const le={dataType:Ae,data:n.slice(a,a+me).buffer};if(a+=me,!U&&!de){if(a+we*2>u.byteLength)return;const xs=u.getBigUint64(a,!0);a+=we;const Is=u.getBigUint64(a,!0);a+=we,le.timeRange=new V({start:xs,end:Is})}else de?le.timeRange=new V({start:0n,end:0n}):le.timeRange=new V({start:(h==null?void 0:h.valueOf())??0n,end:(d==null?void 0:d.valueOf())??0n});if(!k&&!z){if(a+_e>u.byteLength)return;f=u.getBigUint64(a,!0),a+=_e,le.alignment=f}else z?le.alignment=0n:le.alignment=f;r.series.push(le)}),r}}const Oi=254,Tw=new Uint8Array([Oi]),zw=255,Ow=new Uint8Array([zw]),Jc="application/sy-framer";class kw{constructor(e){l(this,"contentType",Jc),l(this,"base"),l(this,"lowPerfCodec"),this.base=e,this.lowPerfCodec=rt.JSON_CODEC}encode(e){var t,n;const r=e;if(r.type=="close"||((t=r.payload)==null?void 0:t.command)!=St.Write){const o=this.lowPerfCodec.encode(r),c=new Uint8Array({length:o.byteLength+1});return c.set(Tw,0),c.set(new Uint8Array(o),1),c}const a=this.base.encode((n=r.payload)==null?void 0:n.frame,1);return a.set(Ow,0),a}decode(e,t){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Oi)return this.lowPerfCodec.decode(e.slice(1),t);const n={type:"data"},r=this.base.decode(e,1);return n.payload={command:St.Write,frame:r},n}}class xw{constructor(e){l(this,"contentType",Jc),l(this,"base"),l(this,"lowPerfCodec"),this.base=e,this.lowPerfCodec=rt.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,t){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===Oi?this.lowPerfCodec.decode(e.slice(1),t):{type:"data",payload:{frame:this.base.decode(e,1)}}}}class Sn{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),l(this,"codec"),this.retriever=e,this.adapter=null,this.keys=[],this.codec=new Gc}static async open(e,t){const n=new Sn(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=Ie(e),r=await this.retriever.retrieve(n);if(this.codec.update(r.map(o=>o.key),r.map(o=>o.dataType)),t==="keys"){this.adapter=null,this.keys=n;return}const a=new Map;this.adapter=a,n.forEach(o=>{const c=r.find(h=>h.name===o);if(c==null)throw new Error(`Channel ${o} not found`);a.set(c.key,c.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,r)=>{if(typeof n=="number"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,r]}return[n,r]})}}class ki{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),l(this,"codec"),this.retriever=e,this.adapter=null,this.keys=[],this.codec=new Gc}static async open(e,t){const n=new ki(e);return await n.update(t),n}async adaptObjectKeys(e){const t={};for(const[n,r]of Object.entries(e))t[await this.adaptToKey(n)]=r;return t}async update(e){const t=await Lc(this.retriever,e);this.adapter=new Map(t.map(n=>[n.name,n.key])),this.keys=t.map(n=>n.key),this.codec.update(this.keys,t.map(n=>n.dataType))}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${JSON.stringify(e)} not found`);return t[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,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new W(`
|
|
44
|
-
Received a single channel name or key but no series.
|
|
45
|
-
`);if(Array.isArray(t)){if(t.some(h=>h instanceof Je||Array.isArray(h)))throw new W(`
|
|
46
|
-
Received a single channel name or key but multiple series.
|
|
47
|
-
`);t=t}const o=await this.fetchChannel(e),c=new Je({data:t,dataType:o.dataType});return new J(o.key,c)}if(Array.isArray(e)){if(t==null)throw new W(`
|
|
48
|
-
Received an array of channel names or keys but no series.
|
|
49
|
-
`);if(!Array.isArray(t))throw new W(`
|
|
50
|
-
Received an array of channel names or keys but no array of series.
|
|
51
|
-
`);const o=[],c=[];for(let h=0;h<e.length;h++){const d=await this.fetchChannel(e[h]);if(h>=t.length)throw new W(`
|
|
52
|
-
Received an array of channel names or keys but not enough series.
|
|
53
|
-
`);const f=new Je({data:t[h],dataType:d.dataType});o.push(d.key),c.push(f)}return new J(o,c)}if(e instanceof J||e instanceof Map){const o=new J(e);if(this.adapter==null)return o;const c=o.columns.map(h=>{var d;const f=typeof h=="string"?(d=this.adapter)==null?void 0:d.get(h):h;if(f==null)throw new W(`
|
|
54
|
-
Channel ${h} was not provided in the list of channels when opening the writer
|
|
55
|
-
`);return f});return new J(c,o.series)}const n=[],r=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[c,h]=a[o],d=await this.fetchChannel(c),f=new Je({data:h,dataType:d.dataType});n.push(d.key),r.push(f)}return new J(n,r)}}class Xc{constructor(e,t){l(this,"name"),l(this,"stream"),this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,t]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
|
|
56
|
-
Please report this error to the Synnax team.`),t!=null){if(ge.matches(t))return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Br=new O(-1);var xi=(s=>(s[s.Open=0]="Open",s[s.Next=1]="Next",s[s.Prev=2]="Prev",s[s.SeekFirst=3]="SeekFirst",s[s.SeekLast=4]="SeekLast",s[s.SeekLE=5]="SeekLE",s[s.SeekGE=6]="SeekGE",s[s.Valid=7]="Valid",s[s.Error=8]="Error",s))(xi||{}),Qc=(s=>(s[s.None=0]="None",s[s.Ack=1]="Ack",s[s.Data=2]="Data",s))(Qc||{});const Iw=i.z.object({command:i.z.enum(xi),span:O.z.optional(),bounds:V.z.optional(),stamp:x.z.optional(),keys:se.array().optional(),chunkSize:i.z.number().optional()}),Ew=i.z.object({variant:i.z.enum(Qc),ack:i.z.boolean(),command:i.z.enum(xi),error:bt.payloadZ.optional().nullable(),frame:un.optional()}),el=class jr{constructor(e,t){l(this,"stream"),l(this,"adapter"),l(this,"value"),this.stream=new Xc("Iterator",e),this.value=new J,this.adapter=t}static async _open(e,t,n,r,a={}){const o=await Sn.open(n,t),c=await r.stream(jr.ENDPOINT,Iw,Ew),h=new jr(c,o);return await h.execute({command:0,keys:o.keys,bounds:new V(e),chunkSize:a.chunkSize??1e5}),h}async next(e=Br){return await this.execute({command:1,span:new O(e)})}async prev(e=Br){return await this.execute({command:2,span:new O(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 x(e)})}async seekGE(e){return await this.execute({command:6,stamp:new x(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Nw(this)}async execute(e){for(this.stream.send(e),this.value=new J;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new J(t.frame)))}}};l(el,"ENDPOINT","/frame/iterate");let tl=el;class Nw{constructor(e){l(this,"iter"),l(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Aw=i.z.object({keys:i.z.number().array(),downSampleFactor:i.z.number()}),Uw=i.z.object({frame:un}),Cw="/frame/stream",sl=(s,e)=>async t=>{let n;Array.isArray(t)||typeof t!="object"?n={channels:t,downSampleFactor:1}:n=t;const r=await Sn.open(s,n.channels);n.useExperimentalCodec&&(e=e.withCodec(new xw(r.codec)));const a=await e.stream(Cw,Aw,Uw),o=new Bw(a,r);a.send({keys:r.keys,downSampleFactor:n.downSampleFactor??1});const[,c]=await a.receive();if(c!=null)throw c;return o},nl=async(s,e,t)=>await sl(s,e)(t);class Bw{constructor(e,t){l(this,"stream"),l(this,"adapter"),l(this,"downsampleFactor"),this.stream=new Xc("Streamer",e),this.adapter=t,this.downsampleFactor=1}get keys(){return this.adapter.keys}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(ge.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new J((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys,downSampleFactor:this.downsampleFactor})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class Tn{constructor(e,t){l(this,"wrapped_",null),l(this,"breaker"),l(this,"opener"),l(this,"config"),this.opener=e,Array.isArray(t)||typeof t!="object"?this.config={channels:t,downSampleFactor:1}:this.config=t,this.breaker=new ic.Breaker({maxRetries:5e3,baseInterval:O.seconds(1),scale:1})}static async open(e,t){const n=new Tn(e,t);return await n.runStreamer(),n}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;continue}}get wrapped(){if(this.wrapped_==null)throw new Error("stream closed");return this.wrapped_}async update(e){this.config.channels=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(ge.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(ge.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 De extends tt.Observer{constructor(e,t){super(t),l(this,"streamer"),l(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}const jw=s=>new A({type:ci,key:s.toString()}),Wa=s=>Array.isArray(s)||typeof s!="object"||typeof s=="object"&&"key"in s?{channels:s}:s;let rl=class{constructor(s,e,t){l(this,"streamClient"),l(this,"retriever"),l(this,"deleter"),this.streamClient=s,this.retriever=t,this.deleter=new yw(e)}async openIterator(s,e,t){return await tl._open(s,e,this.retriever,this.streamClient,t)}async openWriter(s){return await Hc._open(this.retriever,this.streamClient,Wa(s))}async openStreamer(s){return await nl(this.retriever,this.streamClient,Wa(s))}async write(s,e,t){if(t==null){const r=e,a=await this.openWriter({start:s,channels:Object.keys(r),mode:Tt.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:O.MAX});await a.write(r),await a.commit(),await a.close();return}const n=await this.openWriter({start:s,channels:e,mode:Tt.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:O.MAX});await n.write(e,t),await n.close()}async read(s,e){const{single:t}=Ie(e),n=await this.readFrame(s,e);return t?n.get(e):n}async readFrame(s,e){const t=await this.openIterator(s,e),n=new J;try{for await(const r of t)n.push(r)}finally{await t.close()}return n}async delete(s,e){const{normalized:t,variant:n}=Ie(s);return n==="keys"?await this.deleter.delete({keys:t,bounds:e}):await this.deleter.delete({names:t,bounds:e})}};const Rw=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:gw,AUTO_SPAN:Br,Client:rl,Frame:J,HardenedStreamer:Tn,Iterator:tl,ONTOLOGY_TYPE:ci,ObservableStreamer:De,Writer:Hc,WriterClosedError:Cr,WriterCommand:St,WriterMode:Tt,createStreamOpener:sl,frameZ:un,ontologyID:jw,openStreamer:nl,seriesFromPayload:bc,seriesToPayload:vc},Symbol.toStringTag,{value:"Module"})),Dw=st.ABSOLUTE_AUTHORITY,Mw=st.ZERO_AUTHORITY,Pw=st.stateZ(i.z.number()),$w=s=>{var e,t;return s.to==null?`${(e=s.from)==null?void 0:e.resource} - ${(t=s.from)==null?void 0:t.subject.name} -> released`:s.from==null?`${s.to.resource} - released -> ${s.to.subject.name} (${s.to.authority.toString()})`:`${s.to.resource} - ${s.from.subject.name} -> ${s.to.subject.name} (${s.to.authority.toString()})`},Lw=i.z.object({transfers:i.z.array(st.transferZ)});class il extends De{constructor(e){super(e,t=>{const n=this.codec.decode(t.series[0].buffer,Lw);return this.merge(n),[n.transfers,!0]}),l(this,"states"),l(this,"codec"),this.states=new Map,this.codec=new rt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}const Va="sy_node_1_control";let al=class{constructor(s){l(this,"framer"),this.framer=s}async openStateTracker(){const s=await Tn.open(async()=>await this.framer.openStreamer(Va),Va);return new il(s)}};const Fw=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:Dw,Client:al,StateTracker:il,ZERO_AUTHORITY:Mw,stateZ:Pw,transferString:$w},Symbol.toStringTag,{value:"Module"}));let _w=class{constructor(s,e,t){l(this,"tasks"),l(this,"racks"),l(this,"devices"),this.tasks=s,this.racks=e,this.devices=t}};const It=async(s,e,t,n)=>{const r=await s.openStreamer([e,t]),a=o=>{const c=[];return t!=null&&c.push(...o.get(t).series.flatMap(h=>n("delete",h))),e!=null&&c.push(...o.get(e).series.flatMap(h=>n("set",h))),[c,c.length>0]};return new De(r,a)},qw="sy_device_set",Ww="sy_device_delete",Ya="sy_device_state",_n="/hardware/device/retrieve",Vw="/hardware/device/create",Yw="/hardware/device/delete",Zw=i.z.object({devices:wg.array()}),Kw=i.z.object({devices:fn.array()}),Hw=i.z.object({keys:dn.array()}),Gw=i.z.object({}),qn=i.z.object({keys:dn.array().optional(),names:i.z.string().array().optional(),makes:i.z.string().array().optional(),models:i.z.string().array().optional(),locations:i.z.string().array().optional(),racks:it.array().optional(),search:i.z.string().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),ignoreNotFound:i.z.boolean().optional(),includeState:i.z.boolean().optional()}),Wn=i.z.object({devices:te(fn)});let Jw=class{constructor(s,e){l(this,"type",Oc),l(this,"client"),l(this,"frameClient"),this.client=s,this.frameClient=e}async retrieve(s,e){const t=!Array.isArray(s),n=await w(this.client,_n,{keys:b(s),...e},qn,Wn);return vn("Device",s,n.devices,t),t?n.devices[0]:n.devices}async search(s,e){return(await w(this.client,_n,{search:s,...e},qn,Wn)).devices}async page(s,e,t){return(await w(this.client,_n,{offset:s,limit:e,...t},qn,Wn)).devices}async create(s){const e=!Array.isArray(s),t=await w(this.client,Vw,{devices:b(s)},Zw,Kw);return e?t.devices[0]:t.devices}async delete(s){await w(this.client,Yw,{keys:b(s)},Hw,Gw)}async openDeviceTracker(){return await It(this.frameClient,qw,Ww,Xw)}async openStateObserver(){return new De(await this.frameClient.openStreamer(Ya),s=>{const e=s.get(Ya);return e.length===0?[null,!1]:[e.parseJSON(zc),!0]})}newSearcherWithOptions(s){return{type:this.type,search:async e=>await this.search(e,s),retrieve:async e=>await this.retrieve(e,s),page:async(e,t)=>await this.page(e,t,s)}}};const Xw=(s,e)=>s==="delete"?e.toStrings().map(t=>({variant:s,key:t,value:void 0})):e.parseJSON(fn).map(t=>({variant:s,key:t.key,value:t})),Vn="/hardware/rack/retrieve",Qw="/hardware/rack/create",eb="/hardware/rack/delete",Za="sy_rack_state",Yn=i.z.object({keys:it.array().optional(),names:i.z.string().array().optional(),search:i.z.string().optional(),embedded:i.z.boolean().optional(),hostIsNode:i.z.boolean().optional(),limit:i.z.number().optional(),offset:i.z.number().optional(),includeState:i.z.boolean().optional()}),Zn=i.z.object({racks:te(li)}),tb=i.z.object({racks:mg.array()}),sb=i.z.object({racks:li.array()}),nb=i.z.object({keys:it.array()}),rb=i.z.object({});let ib=class{constructor(s,e,t){l(this,"type",Tc),l(this,"client"),l(this,"tasks"),l(this,"frameClient"),this.client=s,this.tasks=e,this.frameClient=t}async delete(s){await w(this.client,eb,{keys:b(s)},nb,rb)}async create(s){const e=!Array.isArray(s),t=await w(this.client,Qw,{racks:b(s)},tb,sb),n=this.sugar(t.racks);return e?n[0]:n}async search(s){const e=await w(this.client,Vn,{search:s},Yn,Zn);return this.sugar(e.racks)}async page(s,e){const t=await w(this.client,Vn,{offset:s,limit:e},Yn,Zn);return this.sugar(t.racks)}async retrieve(s,e){const{variant:t,normalized:n,single:r}=Si(s,{string:"names",number:"keys"}),a=await w(this.client,Vn,{[t]:n,includeState:e==null?void 0:e.includeState},Yn,Zn),o=this.sugar(a.racks);return vn("Rack",s,o,r),r?o[0]:o}async openStateObserver(){return new De(await this.frameClient.openStreamer(Za),s=>{const e=s.get(Za);return e.length===0?[[],!1]:[e.parseJSON(Sc),!0]})}sugar(s){return s.map(({key:e,name:t,state:n})=>new ab(e,t,this.tasks,n))}};class ab{constructor(e,t,n,r){l(this,"key"),l(this,"name"),l(this,"state"),l(this,"tasks"),this.key=e,this.name=t,this.tasks=n,this.state=r}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async retrieveTaskByType(e){return await this.tasks.retrieveByType(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const as="sy_task_state",dt="sy_task_cmd",ob="sy_task_set",cb="sy_task_delete",ut=new Error("Task not created"),ol=async(s,e)=>{const t=await e.retrieveParents(s);return t.length===0?null:t[0]};class lb{constructor(e,t,n,r,a=!1,o=!1,c,h=null,d=null,f=null){l(this,"key"),l(this,"name"),l(this,"internal"),l(this,"type"),l(this,"config"),l(this,"snapshot"),l(this,"state"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=e,this.name=t,this.type=n,this.config=r,this.internal=a,this.snapshot=o,c!==null&&(this.state=c),this.frameClient=h,this.ontologyClient=d,this.rangeClient=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}get ontologyID(){return zb(this.key)}async executeCommand(e,t){if(this.frameClient==null)throw ut;const n=await this.frameClient.openWriter(dt),r=$y.create();return await n.write(dt,[{task:this.key,type:e,key:r,args:t}]),await n.close(),r}async executeCommandSync(e,t,n){if(this.frameClient==null)throw ut;const r=await this.frameClient.openStreamer(as),a=await this.executeCommand(e,t);let o;const c=new Promise(h=>setTimeout(()=>h(!1),new O(n).milliseconds));for(;;){const h=await Promise.any([r.read(),c]);if(h===!1)throw new Error("Command timed out");const d=Qs.safeParse(h.at(-1).sy_task_state);if(d.success){if(o=d.data,o.key===a)break}else throw d.error}return r.close(),o}async openStateObserver(){if(this.frameClient==null)throw ut;return new De(await this.frameClient.openStreamer(as),e=>{const t=e.get(as);if(t.length===0)return[null,!1];const n=Qs.safeParse(t.at(-1));if(!n.success)return console.error(n.error),[null,!1];const r=n.data;return r.task!==this.key?[null,!1]:[r,!0]})}async openCommandObserver(){if(this.frameClient==null)throw ut;return new De(await this.frameClient.openStreamer(dt),e=>{const t=e.get(dt);if(t.length===0)return[null,!1];const n=kc.safeParse(t.at(-1));if(!n.success)return console.error(n.error),[null,!1];const r=n.data;return r.task!==this.key?[null,!1]:[r,!0]})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw ut;return this.snapshot?await ol(this.key,this.ontologyClient):null}}const hb=i.z.object({rack:it.optional(),keys:at.array().optional(),names:i.z.string().array().optional(),types:i.z.string().array().optional(),includeState:i.z.boolean().optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),ub=i.z.object({tasks:te(yn)}),db="/hardware/task/retrieve",fb="/hardware/task/create",yb="/hardware/task/delete",pb="/hardware/task/copy",gb=i.z.object({tasks:vg.array()}),mb=i.z.object({tasks:yn.array()}),wb=i.z.object({keys:at.array()}),bb=i.z.object({}),vb=i.z.object({key:at,name:i.z.string(),snapshot:i.z.boolean()}),Sb=i.z.object({task:yn});let Tb=class{constructor(s,e,t,n){l(this,"type",ui),l(this,"client"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.client=s,this.frameClient=e,this.ontologyClient=t,this.rangeClient=n}async create(s){const e=!Array.isArray(s),t=await w(this.client,fb,{tasks:b(s)},gb,mb),n=this.sugar(t.tasks);return e?n[0]:n}async delete(s){await w(this.client,yb,{keys:b(s)},wb,bb)}async search(s){return await this.execRetrieve({keys:[s]})}async page(s,e){return await this.execRetrieve({offset:s,limit:e})}async list(s={}){return this.sugar(await this.execRetrieve(s))}async retrieve(s,e){const{single:t,normalized:n,variant:r}=Si(s,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};r==="rack"?a.rack=s:a.keys=n;const o=await this.execRetrieve(a),c=this.sugar(o);return t&&r!=="rack"?c[0]:c}async copy(s,e,t){const n=await w(this.client,pb,{key:s,name:e,snapshot:t},vb,Sb);return this.sugar([n.task])[0]}async retrieveByName(s,e){const t=await this.execRetrieve({names:[s],rack:e});return vn("Task",s,t,!0),this.sugar(t)[0]}async retrieveByType(s,e){const t=await this.execRetrieve({types:[s],rack:e});return this.sugar(t)}async retrieveSnapshottedTo(s){if(this.ontologyClient==null)throw ut;return await ol(s,this.ontologyClient)}async execRetrieve(s){return(await w(this.client,db,s,hb,ub)).tasks}sugar(s){const e=!Array.isArray(s),t=b(s).map(({key:n,name:r,type:a,config:o,state:c,internal:h,snapshot:d})=>new lb(n,r,a,o,h,d,c,this.frameClient,this.ontologyClient,this.rangeClient));return e?t[0]:t}async openTracker(){return await It(this.frameClient,ob,cb,(s,e)=>Array.from(e).map(t=>({variant:s,key:t.toString(),value:t.toString()})))}async openStateObserver(){return new De(await this.frameClient.openStreamer(as),s=>{const e=s.get(as);if(e.length===0)return[null,!1];const t=Qs.safeParse(e.at(-1));return t.success?[t.data,!0]:(console.error(t.error),[null,!1])})}async openCommandObserver(){return new De(await this.frameClient.openStreamer(dt),s=>{const e=s.get(dt);if(e.length===0)return[null,!1];const t=kc.safeParse(e.at(-1));return t.success?[t.data,!0]:(console.error(t.error),[null,!1])})}};const zb=s=>new A({type:ui,key:s}),Ob=i.z.object({keys:Ot.array().optional(),for:ce.optional(),search:i.z.string().optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),kb=i.z.object({labels:te(pn)}),cl=class ll{constructor(e){l(this,"client"),this.client=e}async retrieve(e){return await this.execute({keys:b(e)})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(ll.ENDPOINT,e,Ob,kb);if(n!=null)throw n;return t.labels}};l(cl,"ENDPOINT","/label/retrieve");let xb=cl;const Ib=pn.extend({key:Ot.optional()}),Eb=i.z.object({labels:Ib.array()}),Nb=i.z.object({labels:pn.array()}),Ab=i.z.object({keys:Ot.array()}),hl=i.z.object({id:ce,labels:Ot.array(),replace:i.z.boolean().optional()}),Ub=hl.omit({replace:!0}),Kn=i.z.object({}),Cb="/label/create",Bb="/label/delete",jb="/label/set",Rb="/label/remove";let Db=class{constructor(s){l(this,"client"),this.client=s}async create(s){return(await w(this.client,Cb,{labels:b(s)},Eb,Nb)).labels}async delete(s){await w(this.client,Bb,{keys:b(s)},Ab,Kn)}async set(s,e,{replace:t}={}){await w(this.client,jb,{id:s,labels:e,replace:t},hl,Kn)}async remove(s,e){await w(this.client,Rb,{id:s,labels:e},Ub,Kn)}};const Mb="sy_label_set",Pb="sy_label_delete";let $b=class{constructor(s,e,t){l(this,"type","label"),l(this,"retriever"),l(this,"writer"),l(this,"frameClient"),l(this,"ontology"),this.writer=new Db(s),this.retriever=new xb(s),this.frameClient=e,this.ontology=t}async search(s){return await this.retriever.search(s)}async retrieve(s){const e=Array.isArray(s),t=await this.retriever.retrieve(s);return e?t:t[0]}async retrieveFor(s){return await this.retriever.retrieveFor(new A(s))}async label(s,e,t={}){await this.writer.set(new A(s),e,t)}async removeLabels(s,e){await this.writer.remove(new A(s),e)}async page(s,e){return await this.retriever.page(s,e)}async create(s){const e=Array.isArray(s),t=await this.writer.create(s);return e?t:t[0]}async delete(s){await this.writer.delete(s)}async openChangeTracker(){return await It(this.frameClient,Mb,Pb,Lb)}async trackLabelsOf(s){const e=new tt.Observer,t=(await this.retrieveFor(s)).map(n=>({id:Fb(n.key),key:n.key,name:n.name,data:n}));return(await this.ontology.openDependentTracker({target:new A(s),dependents:t,relationshipType:"labeled_by"})).onChange(n=>e.notify(n.map(r=>{var a,o;return{key:r.id.key,color:(a=r.data)==null?void 0:a.color,name:(o=r.data)==null?void 0:o.name}}))),e}};const Lb=(s,e)=>s==="delete"?e.toUUIDs().map(t=>({variant:s,key:t})):e.parseJSON(pn).map(t=>({variant:s,key:t.key,value:t})),Fb=s=>new A({type:xc,key:s}),_b="sy_range_alias_set",qb="sy_range_alias_delete",Wb=i.z.object({range:oe,aliases:i.z.string().array()}),Vb=i.z.object({aliases:i.z.record(i.z.string(),se)}),Yb=i.z.object({range:oe,aliases:i.z.record(se.or(i.z.string()),i.z.string())}),Zb=i.z.unknown(),Kb=i.z.object({range:oe,channels:se.array()}),Hb=i.z.unknown(),Gb=i.z.object({range:oe}),Jb=i.z.object({aliases:i.z.record(i.z.string(),i.z.string())}),es=class ts{constructor(e,t,n){l(this,"frameClient"),l(this,"cache",new Map),l(this,"client"),l(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",r={};if(n){const o=this.cache.get(e);if(o!=null)return o;t.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?r[o]=c:t.push(o)});if(t.length===0)return r;const a=await w(this.client,ts.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},Wb,Vb);return Object.entries(a.aliases).forEach(([o,c])=>this.cache.set(o,c)),n?a.aliases[t[0]]:{...r,...a.aliases}}async set(e){await w(this.client,ts.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Yb,Zb)}async list(){return(await w(this.client,ts.LIST_ENDPOINT,{range:this.rangeKey},Gb,Jb)).aliases}async delete(e){await w(this.client,ts.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Kb,Hb)}async openChangeTracker(){return await It(this.frameClient,_b,qb,tv(this.rangeKey))}};l(es,"SET_ENDPOINT","/range/alias/set"),l(es,"RESOLVE_ENDPOINT","/range/alias/resolve"),l(es,"LIST_ENDPOINT","/range/alias/list"),l(es,"DELETE_ENDPOINT","/range/alias/delete");let Xb=es;const Qb=i.z.object({range:oe,channel:se,alias:i.z.string()}),ev="---",tv=s=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(ev)[0]===s).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(Qb).map(n=>({variant:e,key:n.alias,value:n})),Ii=i.z.object({range:oe,key:i.z.string(),value:i.z.string()}),sv=i.z.object({range:oe,keys:i.z.string().array()}),nv=i.z.object({pairs:te(Ii)}),rv=i.z.object({range:oe,pairs:Ii.array()}),iv=i.z.object({range:oe,keys:i.z.string().array()}),Ys=class Zs{constructor(e,t,n){l(this,"rangeKey"),l(this,"client"),l(this,"frameClient"),this.rangeKey=e,this.client=t,this.frameClient=n}async get(e){const t=await w(this.client,Zs.GET_ENDPOINT,{range:this.rangeKey,keys:b(e)},sv,nv);return typeof e=="string"?t.pairs[0].value:Object.fromEntries(t.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,t=""){let n;rn(e)?n=Object.entries(e).map(([r,a])=>({range:this.rangeKey,key:r,value:a})):n=[{range:this.rangeKey,key:e,value:t}],await w(this.client,Zs.SET_ENDPOINT,{range:this.rangeKey,pairs:n},rv,i.z.unknown())}async delete(e){await w(this.client,Zs.DELETE_ENDPOINT,{range:this.rangeKey,keys:b(e)},iv,i.z.unknown())}async openTracker(){return await It(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,t)=>e==="delete"?t.toStrings().map(n=>{const[r,a]=n.split("<--->",2);return{variant:e,key:n,value:{range:r,key:a,value:""}}}):t.parseJSON(Ii).map(n=>({variant:e,key:`${n.range}${n.key}`,value:n})))}};l(Ys,"GET_ENDPOINT","/range/kv/get"),l(Ys,"SET_ENDPOINT","/range/kv/set"),l(Ys,"DELETE_ENDPOINT","/range/kv/delete");let Rr=Ys;class ul{constructor(e,t=V.ZERO,n,r,a,o,c,h,d,f,u){l(this,"key"),l(this,"name"),l(this,"kv"),l(this,"timeRange"),l(this,"color"),l(this,"channels"),l(this,"aliaser"),l(this,"frameClient"),l(this,"labelClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=n,this.name=e,this.timeRange=t,this.frameClient=a,this.color=r,this.kv=o,this.aliaser=c,this.channels=h,this.labelClient=d,this.ontologyClient=f,this.rangeClient=u}get ontologyID(){return Ze(this.key)}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new Re(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(t=>t.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ze(this.key))}async addLabel(...e){await this.labelClient.label(Ze(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ze(this.key),e)}async openChildRangeTracker(){const e=new tt.Observer,t=(await this.retrieveChildren()).map(r=>{const a=Ze(r.key);return{id:a,key:a.toString(),name:r.name,data:r.payload}}),n=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:t,resourceType:"range"});return n.onChange(r=>e.notify(this.rangeClient.resourcesToRanges(r))),e.setCloser(async()=>await n.close()),e}async openParentRangeTracker(){const e=new tt.Observer,t=await this.retrieveParent();if(t==null)return null;const n=Ze(t.key),r={id:n,key:n.toString(),name:t.name,data:t.payload},a=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:[r],relationshipDirection:"to"});return a.onChange(o=>{const c=this.rangeClient.resourcesToRanges(o);if(c.length===0)return;const h=c[0];e.notify(h)}),e.setCloser(async()=>await a.close()),e}}const av=(s,e)=>Fy(s.timeRange,e.timeRange),ov=i.z.object({keys:oe.array().optional(),names:i.z.array(i.z.string()).optional(),term:i.z.string().optional(),overlapsWith:V.z.optional(),limit:i.z.number().int().optional(),offset:i.z.number().int().optional(),hasLabels:Ot.array().optional()}),cv="/range/retrieve",lv=i.z.object({ranges:te(Ss)});let dl=class{constructor(s,e,t,n,r,a){l(this,"type","range"),l(this,"frameClient"),l(this,"writer"),l(this,"unaryClient"),l(this,"channels"),l(this,"labelClient"),l(this,"ontologyClient"),this.frameClient=s,this.writer=e,this.unaryClient=t,this.channels=n,this.labelClient=r,this.ontologyClient=a}async create(s,e){const t=!Array.isArray(s),n=this.sugarMany(await this.writer.create(b(s),e));return t?n[0]:n}async rename(s,e){await this.writer.rename(s,e)}async delete(s){await this.writer.delete(b(s))}async search(s){return this.sugarMany(await this.execRetrieve({term:s}))}async page(s,e){return this.sugarMany(await this.execRetrieve({offset:s,limit:e}))}async retrieve(s){if(typeof s=="object"&&"start"in s)return await this.execRetrieve({overlapsWith:new V(s)});const{single:e,actual:t,variant:n,normalized:r,empty:a}=Ec(s);if(a)return[];const o=await this.execRetrieve({[n]:r});if(!e)return o;if(o.length===0)throw new nt(`range matching ${t} not found`);if(o.length>1)throw new vt(`multiple ranges matching ${t} found`);return o[0]}getKV(s){return new Rr(s,this.unaryClient,this.frameClient)}async execRetrieve(s){const{ranges:e}=await w(this.unaryClient,cv,s,ov,lv);return this.sugarMany(e)}async retrieveParent(s){const e=await this.ontologyClient.retrieveParents(Ze(s));if(e.length===0)return null;const t=e[0];return t.id.type!=="range"?null:await this.retrieve(t.id.key)}sugarOne(s){return new ul(s.name,s.timeRange,s.key,s.color,this.frameClient,new Rr(s.key,this.unaryClient,this.frameClient),new Xb(s.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this)}sugarMany(s){return s.map(e=>this.sugarOne(e))}async openTracker(){return await It(this.frameClient,"sy_range_set","sy_range_delete",(s,e)=>s==="delete"?e.toUUIDs().map(t=>({variant:s,key:t,value:void 0})):this.sugarMany(e.parseJSON(Ss)).map(t=>({variant:s,key:t.key,value:t})))}resourcesToRanges(s){return s.map(e=>this.resourceToRange(e))}resourceToRange(s){var e,t,n;return this.sugarOne({key:s.id.key,name:(e=s.data)==null?void 0:e.name,timeRange:new V((t=s.data)==null?void 0:t.timeRange),color:(n=s.data)==null?void 0:n.color})}};const Ze=s=>new A({type:fi,key:s}),hv=s=>new A({type:yi,key:s}),uv=i.z.object({ranges:Ss.array()}),dv=i.z.object({parent:ce.optional(),ranges:Ic.array()}),fv=i.z.object({keys:oe.array()}),yv=i.z.object({}),pv=i.z.object({key:oe,name:di}),gv=i.z.object({}),mv="/range/create",wv="/range/delete",bv="/range/rename";class fl{constructor(e){l(this,"client"),this.client=e}async rename(e,t){await w(this.client,bv,{key:e,name:t},pv,gv)}async create(e,t){return(await w(this.client,mv,{ranges:e,...t},dv,uv)).ranges}async delete(e){await w(this.client,wv,{keys:e},fv,yv)}}const vv=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_ONTOLOGY_TYPE:yi,Client:dl,KV:Rr,ONTOLOGY_TYPE:fi,Range:ul,Writer:fl,aliasOntologyID:hv,analyzeParams:Ec,keyZ:oe,nameZ:di,newZ:Ic,ontologyID:Ze,payloadZ:Ss,sort:av},Symbol.toStringTag,{value:"Module"})),Sv="/api/v1/";class Tv{constructor(e,t={},n=!1){l(this,"url"),l(this,"unary"),l(this,"stream"),l(this,"secure"),this.secure=n,this.url=e.child(Sv);const r=new rt.JSONCodec;this.unary=Yd(new Vd(this.url,r,this.secure),t),this.stream=new Xd(this.url,r,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const zv="/workspace/lineplot/retrieve",Ov="/workspace/lineplot/create",kv="/workspace/lineplot/rename",xv="/workspace/lineplot/set-data",Iv="/workspace/lineplot/delete",Ev=i.z.object({keys:Ts.array()}),Nv=i.z.object({workspace:Pe,linePlots:zg.array()}),Av=i.z.object({key:Ts,name:i.z.string()}),Uv=i.z.object({key:Ts,data:i.z.string()}),Cv=i.z.object({keys:Ts.array()}),Bv=i.z.object({linePlots:te(pi)}),jv=i.z.object({linePlots:pi.array()}),Hn=i.z.object({});let Rv=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,Ov,{workspace:s,linePlots:b(e)},Nv,jv);return t?n.linePlots:n.linePlots[0]}async rename(s,e){await w(this.client,kv,{key:s,name:e},Av,Hn)}async setData(s,e){await w(this.client,xv,{key:s,data:JSON.stringify(e)},Uv,Hn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,zv,{keys:b(s)},Ev,Bv);return e?t.linePlots:t.linePlots[0]}async delete(s){await w(this.client,Iv,{keys:b(s)},Cv,Hn)}};const Dv="/workspace/log/retrieve",Mv="/workspace/log/create",Pv="/workspace/log/rename",$v="/workspace/log/set-data",Lv="/workspace/log/delete",Fv=i.z.object({keys:zs.array()}),_v=i.z.object({workspace:Pe,logs:kg.array()}),qv=i.z.object({key:zs,name:i.z.string()}),Wv=i.z.object({key:zs,data:i.z.string()}),Vv=i.z.object({keys:zs.array()}),Yv=i.z.object({logs:gi.array()}),Zv=i.z.object({logs:gi.array()}),Gn=i.z.object({});let Kv=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,Mv,{workspace:s,logs:b(e)},_v,Zv);return t?n.logs:n.logs[0]}async rename(s,e){await w(this.client,Pv,{key:s,name:e},qv,Gn)}async setData(s,e){await w(this.client,$v,{key:s,data:JSON.stringify(e)},Wv,Gn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,Dv,{keys:b(s)},Fv,Yv);return e?t.logs:t.logs[0]}async delete(s){await w(this.client,Lv,{keys:b(s)},Vv,Gn)}};const Hv="/workspace/schematic/retrieve",Gv="/workspace/schematic/create",Jv="/workspace/schematic/rename",Xv="/workspace/schematic/set-data",Qv="/workspace/schematic/delete",e0="/workspace/schematic/copy",t0=i.z.object({keys:xt.array()}),s0=i.z.object({workspace:Pe,schematics:Ng.array()}),n0=i.z.object({key:xt,name:i.z.string()}),r0=i.z.object({key:xt,data:i.z.string()}),i0=i.z.object({keys:xt.array()}),a0=i.z.object({key:xt,name:i.z.string(),snapshot:i.z.boolean()}),o0=i.z.object({schematics:te(Ac)}),c0=i.z.object({schematics:Ac.array()}),l0=i.z.object({schematic:wi}),Jn=i.z.object({});let h0=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,Gv,{workspace:s,schematics:b(e)},s0,c0);return t?n.schematics:n.schematics[0]}async rename(s,e){await w(this.client,Jv,{key:s,name:e},n0,Jn)}async setData(s,e){await w(this.client,Xv,{key:s,data:JSON.stringify(e)},r0,Jn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,Hv,{keys:b(s)},t0,o0);return e?t.schematics:t.schematics[0]}async delete(s){await w(this.client,Qv,{keys:b(s)},i0,Jn)}async copy(s,e,t){return(await w(this.client,e0,{key:s,name:e,snapshot:t},a0,l0)).schematic}};const u0="/workspace/table/retrieve",d0="/workspace/table/create",f0="/workspace/table/rename",y0="/workspace/table/set-data",p0="/workspace/table/delete",g0=i.z.object({keys:Os.array()}),m0=i.z.object({workspace:Pe,tables:Ug.array()}),w0=i.z.object({key:Os,name:i.z.string()}),b0=i.z.object({key:Os,data:i.z.string()}),v0=i.z.object({keys:Os.array()}),S0=i.z.object({tables:Cc.array()}),T0=i.z.object({tables:Cc.array()}),Xn=i.z.object({});let z0=class{constructor(s){l(this,"client"),this.client=s}async create(s,e){const t=Array.isArray(e),n=await w(this.client,d0,{workspace:s,tables:b(e)},m0,T0);return t?n.tables:n.tables[0]}async rename(s,e){await w(this.client,f0,{key:s,name:e},w0,Xn)}async setData(s,e){await w(this.client,y0,{key:s,data:JSON.stringify(e)},b0,Xn)}async retrieve(s){const e=Array.isArray(s),t=await w(this.client,u0,{keys:b(s)},g0,S0);return e?t.tables:t.tables[0]}async delete(s){await w(this.client,p0,{keys:b(s)},v0,Xn)}};const Ds="/workspace/retrieve",O0="/workspace/create",k0="/workspace/rename",x0="/workspace/set-layout",I0="/workspace/delete",Ms=i.z.object({keys:Pe.array().optional(),search:i.z.string().optional(),author:kt.optional(),offset:i.z.number().optional(),limit:i.z.number().optional()}),E0=i.z.object({workspaces:Ig.array()}),N0=i.z.object({key:Pe,name:i.z.string()}),A0=i.z.object({key:Pe,layout:i.z.string()}),U0=i.z.object({keys:Pe.array()}),Ps=i.z.object({workspaces:te(mi)}),C0=i.z.object({workspaces:Eg.array()}),Qn=i.z.object({});class B0{constructor(e){l(this,"type",Nc),l(this,"schematic"),l(this,"linePlot"),l(this,"log"),l(this,"table"),l(this,"client"),this.client=e,this.schematic=new h0(e),this.linePlot=new Rv(e),this.log=new Kv(e),this.table=new z0(e)}async create(e){const t=Array.isArray(e),n=await w(this.client,O0,{workspaces:b(e)},E0,C0);return t?n.workspaces:n.workspaces[0]}async rename(e,t){await w(this.client,k0,{key:e,name:t},N0,Qn)}async setLayout(e,t){await w(this.client,x0,{key:e,layout:JSON.stringify(t)},A0,Qn)}async retrieve(e){const t=Array.isArray(e),n=await w(this.client,Ds,{keys:b(e)},Ms,Ps);return t?n.workspaces:n.workspaces[0]}async retrieveByAuthor(e){return(await w(this.client,Ds,{author:e},Ms,Ps)).workspaces}async search(e){return(await w(this.client,Ds,{search:e},Ms,Ps)).workspaces}async page(e,t){return(await w(this.client,Ds,{offset:e,limit:t},Ms,Ps)).workspaces}async delete(e){await w(this.client,I0,{keys:b(e)},U0,Qn)}}const yl=i.z.object({host:i.z.string({error:"Host is required"}).min(1,"Host is required"),port:i.z.number({error:"Port is required"}).or(i.z.string({error:"Port is required"})),username:i.z.string().min(1,"Username is required"),password:i.z.string().min(1,"Password is required"),connectivityPollFrequency:O.z.default(O.seconds(30)),secure:i.z.boolean().optional().default(!1),name:i.z.string().optional(),retry:ic.breakerConfig.optional()});class pl extends rl{constructor(e){const t=yl.parse(e),{host:n,port:r,username:a,password:o,connectivityPollFrequency:c,secure:h,retry:d}=t,f=new Tv(new dp({host:n,port:Number(r)}),d,h);f.use(gg);let u;a!=null&&o!=null&&(u=new ow(f.unary,{username:a,password:o}),f.use(u.middleware()));const z=new zi(new Ti(f.unary)),k=new Vc(f.unary,z);super(f.stream,f.unary,z),l(this,"createdAt"),l(this,"props"),l(this,"ranges"),l(this,"channels"),l(this,"auth"),l(this,"user"),l(this,"access"),l(this,"connectivity"),l(this,"ontology"),l(this,"workspaces"),l(this,"labels"),l(this,"hardware"),l(this,"control"),l(this,"transport"),l(this,"clientVersion","0.42.3"),this.createdAt=x.now(),this.props=t,this.auth=u,this.transport=f,this.channels=new _c(this,z,f.unary,k),this.connectivity=new Kc(f.unary,c,this.clientVersion,t.name),this.control=new al(this),this.ontology=new em(f.unary,this);const Y=new fl(this.transport.unary);this.labels=new $b(this.transport.unary,this,this.ontology),this.ranges=new dl(this,Y,this.transport.unary,z,this.labels,this.ontology),this.access=new ym(this.transport.unary),this.user=new Qm(this.transport.unary),this.workspaces=new B0(this.transport.unary);const U=new Jw(this.transport.unary,this),de=new Tb(this.transport.unary,this,this.ontology,this.ranges),Ne=new ib(this.transport.unary,de,this);this.hardware=new _w(de,Ne,U)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}l(pl,"connectivity",Kc);const Dr=(s,e,t="")=>{try{return s.parse(e)}catch(n){if(n instanceof i.z.ZodError){const r=n.issues.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${t} - ${r.join(`
|
|
57
|
-
`)}`)}else throw n}};var j0=Object.defineProperty,R0=(s,e,t)=>e in s?j0(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,H=(s,e,t)=>R0(s,typeof e!="symbol"?e+"":e,t);const Mr=class gl{constructor(e,t,n="",r=!1){H(this,"_noop",!1),H(this,"key"),H(this,"path"),H(this,"serviceName"),this.key=e,this.path=t,this.serviceName=n,this._noop=r}child(e){return new gl(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};H(Mr,"NOOP",new Mr("","",""));let Ei=Mr;const Pr=["debug","info","warn","error"],ml=s=>{const e=Pr.indexOf(s);return({level:t})=>Pr.indexOf(t)>=e},D0=s=>{const{include:e,exclude:t}=s;return({path:n})=>!(e!=null&&!e.some(r=>n.startsWith(r))||t!=null&&t.some(r=>n.startsWith(r)))},$r=class wl{constructor(e={}){H(this,"meta",Ei.NOOP),H(this,"filters");const{filters:t=[]}=e;this.filters=t}filter(e){return!this.meta.noop&&this.filters.every(t=>t({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const t=new wl({filters:this.filters});return t.meta=e,t}debug(e,t,n=!1){!this.filter("debug")&&!n||(t==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,$s(t)))}info(e,t,n=!1){!this.filter("info")&&!n||(t==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,$s(t)))}warn(e,t,n=!1){!this.filter("warn")&&!n||(t==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,$s(t)))}error(e,t,n=!1){!this.filter("error")&&!n||(t==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,$s(t)))}};H($r,"NOOP",new $r);let Ni=$r;const $s=s=>typeof s=="function"?s():s;var M0=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Xe="1.9.0",Ka=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function P0(s){var e=new Set([s]),t=new Set,n=s.match(Ka);if(!n)return function(){return!1};var r={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(r.prerelease!=null)return function(c){return c===s};function a(c){return t.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(t.has(c))return!1;var h=c.match(Ka);if(!h)return a(c);var d={major:+h[1],minor:+h[2],patch:+h[3],prerelease:h[4]};return d.prerelease!=null||r.major!==d.major?a(c):r.major===0?r.minor===d.minor&&r.patch<=d.patch?o(c):a(c):r.minor<=d.minor?o(c):a(c)}}var $0=P0(Xe),L0=Xe.split(".")[0],us=Symbol.for("opentelemetry.js.api."+L0),ds=M0;function Ai(s,e,t,n){var r;n===void 0&&(n=!1);var a=ds[us]=(r=ds[us])!==null&&r!==void 0?r:{version:Xe};if(!n&&a[s]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+s);return t.error(o.stack||o.message),!1}if(a.version!==Xe){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+s+" does not match previously registered API v"+Xe);return t.error(o.stack||o.message),!1}return a[s]=e,t.debug("@opentelemetry/api: Registered a global for "+s+" v"+Xe+"."),!0}function fs(s){var e,t,n=(e=ds[us])===null||e===void 0?void 0:e.version;if(!(!n||!$0(n)))return(t=ds[us])===null||t===void 0?void 0:t[s]}function Ui(s,e){e.debug("@opentelemetry/api: Unregistering a global for "+s+" v"+Xe+".");var t=ds[us];t&&delete t[s]}var F0=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},_0=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},q0=function(){function s(e){this._namespace=e.namespace||"DiagComponentLogger"}return s.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Pt("debug",this._namespace,e)},s.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Pt("error",this._namespace,e)},s.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Pt("info",this._namespace,e)},s.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Pt("warn",this._namespace,e)},s.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Pt("verbose",this._namespace,e)},s}();function Pt(s,e,t){var n=fs("diag");if(n)return t.unshift(e),n[s].apply(n,_0([],F0(t),!1))}var he;(function(s){s[s.NONE=0]="NONE",s[s.ERROR=30]="ERROR",s[s.WARN=50]="WARN",s[s.INFO=60]="INFO",s[s.DEBUG=70]="DEBUG",s[s.VERBOSE=80]="VERBOSE",s[s.ALL=9999]="ALL"})(he||(he={}));function W0(s,e){s<he.NONE?s=he.NONE:s>he.ALL&&(s=he.ALL),e=e||{};function t(n,r){var a=e[n];return typeof a=="function"&&s>=r?a.bind(e):function(){}}return{error:t("error",he.ERROR),warn:t("warn",he.WARN),info:t("info",he.INFO),debug:t("debug",he.DEBUG),verbose:t("verbose",he.VERBOSE)}}var V0=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},Y0=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},Z0="diag",ys=function(){function s(){function e(r){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var c=fs("diag");if(c)return c[r].apply(c,Y0([],V0(a),!1))}}var t=this,n=function(r,a){var o,c,h;if(a===void 0&&(a={logLevel:he.INFO}),r===t){var d=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((o=d.stack)!==null&&o!==void 0?o:d.message),!1}typeof a=="number"&&(a={logLevel:a});var f=fs("diag"),u=W0((c=a.logLevel)!==null&&c!==void 0?c:he.INFO,r);if(f&&!a.suppressOverrideMessage){var z=(h=new Error().stack)!==null&&h!==void 0?h:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+z),u.warn("Current logger will overwrite one already registered from "+z)}return Ai("diag",u,t,!0)};t.setLogger=n,t.disable=function(){Ui(Z0,t)},t.createComponentLogger=function(r){return new q0(r)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return s.instance=function(){return this._instance||(this._instance=new s),this._instance},s}(),K0=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},H0=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],n=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&n>=s.length&&(s=void 0),{value:s&&s[n++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},G0=function(){function s(e){this._entries=e?new Map(e):new Map}return s.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},s.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=K0(e,2),n=t[0],r=t[1];return[n,r]})},s.prototype.setEntry=function(e,t){var n=new s(this._entries);return n._entries.set(e,t),n},s.prototype.removeEntry=function(e){var t=new s(this._entries);return t._entries.delete(e),t},s.prototype.removeEntries=function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var a=new s(this._entries);try{for(var o=H0(n),c=o.next();!c.done;c=o.next()){var h=c.value;a._entries.delete(h)}}catch(d){e={error:d}}finally{try{c&&!c.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return a},s.prototype.clear=function(){return new s},s}();ys.instance();function J0(s){return s===void 0&&(s={}),new G0(new Map(Object.entries(s)))}function X0(s){return Symbol.for(s)}var Q0=function(){function s(e){var t=this;t._currentContext=e?new Map(e):new Map,t.getValue=function(n){return t._currentContext.get(n)},t.setValue=function(n,r){var a=new s(t._currentContext);return a._currentContext.set(n,r),a},t.deleteValue=function(n){var r=new s(t._currentContext);return r._currentContext.delete(n),r}}return s}(),eS=new Q0,tS={get:function(s,e){if(s!=null)return s[e]},keys:function(s){return s==null?[]:Object.keys(s)}},sS={set:function(s,e,t){s!=null&&(s[e]=t)}},nS=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},rS=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},iS=function(){function s(){}return s.prototype.active=function(){return eS},s.prototype.with=function(e,t,n){for(var r=[],a=3;a<arguments.length;a++)r[a-3]=arguments[a];return t.call.apply(t,rS([n],nS(r),!1))},s.prototype.bind=function(e,t){return t},s.prototype.enable=function(){return this},s.prototype.disable=function(){return this},s}(),aS=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),r,a=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},oS=function(s,e,t){if(arguments.length===2)for(var n=0,r=e.length,a;n<r;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return s.concat(a||Array.prototype.slice.call(e))},er="context",cS=new iS,bl=function(){function s(){}return s.getInstance=function(){return this._instance||(this._instance=new s),this._instance},s.prototype.setGlobalContextManager=function(e){return Ai(er,e,ys.instance())},s.prototype.active=function(){return this._getContextManager().active()},s.prototype.with=function(e,t,n){for(var r,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(r=this._getContextManager()).with.apply(r,oS([e,t,n],aS(a),!1))},s.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},s.prototype._getContextManager=function(){return fs(er)||cS},s.prototype.disable=function(){this._getContextManager().disable(),Ui(er,ys.instance())},s}(),Lr;(function(s){s[s.UNSET=0]="UNSET",s[s.OK=1]="OK",s[s.ERROR=2]="ERROR"})(Lr||(Lr={}));var lS=bl.getInstance(),hS=function(){function s(){}return s.prototype.inject=function(e,t){},s.prototype.extract=function(e,t){return e},s.prototype.fields=function(){return[]},s}(),Ci=X0("OpenTelemetry Baggage Key");function vl(s){return s.getValue(Ci)||void 0}function uS(){return vl(bl.getInstance().active())}function dS(s,e){return s.setValue(Ci,e)}function fS(s){return s.deleteValue(Ci)}var tr="propagation",yS=new hS,pS=function(){function s(){this.createBaggage=J0,this.getBaggage=vl,this.getActiveBaggage=uS,this.setBaggage=dS,this.deleteBaggage=fS}return s.getInstance=function(){return this._instance||(this._instance=new s),this._instance},s.prototype.setGlobalPropagator=function(e){return Ai(tr,e,ys.instance())},s.prototype.inject=function(e,t,n){return n===void 0&&(n=sS),this._getGlobalPropagator().inject(e,t,n)},s.prototype.extract=function(e,t,n){return n===void 0&&(n=tS),this._getGlobalPropagator().extract(e,t,n)},s.prototype.fields=function(){return this._getGlobalPropagator().fields()},s.prototype.disable=function(){Ui(tr,ys.instance())},s.prototype._getGlobalPropagator=function(){return fs(tr)||yS},s}(),gS=pS.getInstance();const Ha=["bench","debug","prod"],mS=s=>e=>Ha.indexOf(e)>=Ha.indexOf(s),Fr=class Sl{constructor(e,t=mS("debug")){H(this,"meta",Ei.NOOP),H(this,"otelTracer"),H(this,"filter"),this.otelTracer=e,this.filter=t}child(e){const t=new Sl(this.otelTracer,this.filter);return t.meta=e,t}debug(e,t){return this.trace(e,"debug",t)}bench(e,t){return this.trace(e,"bench",t)}prod(e,t){return this.trace(e,"prod",t)}trace(e,t,n){if(n==null){if(this.meta.noop||!this.filter(t)||this.otelTracer==null)return()=>{};const r=new _r(e,this.otelTracer.startSpan(e));return r.start(),()=>r.end()}return this.meta.noop||!this.filter(t)||this.otelTracer==null?n(new zl(e)):this.otelTracer.startActiveSpan(e,r=>{const a=new _r(e,r);return n(a)})}propagate(e){if(this.meta.noop)return;const t=lS.active();gS.inject(t,e,{set:(n,r,a)=>{n[r]=a}})}};H(Fr,"NOOP",new Fr);let Tl=Fr;class _r{constructor(e,t){H(this,"key"),H(this,"otel"),this.key=e,this.otel=t}set(e,t){this.otel.setAttribute(e,t)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Lr.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.set("duration",e.duration),this.otel.end()}catch(e){console.error(e)}}}class zl{constructor(e){H(this,"key"),this.key=e}set(){}recordError(e){}}const qr=class Ol{constructor({key:e="",serviceName:t="",logger:n=Ni.NOOP,tracer:r=Tl.NOOP,noop:a=!1,__meta:o}){H(this,"meta"),H(this,"T"),H(this,"L"),this.meta=o??new Ei(e,e,t,a),this.T=r.child(this.meta),this.L=n.child(this.meta)}child(e){const t=this.meta.child(e);return new Ol({__meta:t,tracer:this.T,logger:this.L})}};H(qr,"NOOP",new qr({noop:!0}));let Bi=qr;const wS=Bi.NOOP,kl=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Bi,LOG_LEVELS:Pr,Logger:Ni,NOOP:wS,NoopSpan:zl,Tracer:Tl,_Span:_r,logLevelKeyFiler:D0,logThresholdFilter:ml},Symbol.toStringTag,{value:"Module"})),sr=(s,e)=>s instanceof Error?(s.message=`[${e}] - ${s.message}`,s):new Error(e??"unknown error",{cause:s});class ji{constructor({key:e,type:t,sender:n,instrumentation:r,parentCtxValues:a}){L(this,"type");L(this,"key");L(this,"sender");L(this,"_internalState");L(this,"_state");L(this,"_prevState");L(this,"_deleted",!1);L(this,"parentCtxValues");L(this,"childCtxValues");L(this,"childCtxChangedKeys");L(this,"instrumentation");L(this,"schema");this.type=t,this.key=e,this.sender=n,this._internalState={},this.instrumentation=r.child(`${this.type}(${this.key})`),this.parentCtxValues=new Map,a==null||a.forEach((o,c)=>this.parentCtxValues.set(c,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}get _schema(){if(this.schema==null)throw new W(`[AetherLeaf] - expected subclass to define component schema, but none was found.
|
|
58
|
-
Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const t=We.executeSetter(e,this._state);this._prevState=T.Qt(this._state),this._state=Dr(this._schema,t,`${this.type}:${this.key}`),this.sender.send({variant:"update",key:this.key,state:t})}get state(){if(this._state==null)throw new ue(`[AetherLeaf] - state not defined in ${this.type}:${this.key}`);return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>this.parentCtxValues.get(e),getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),wasSetPreviously:e=>this.childCtxValues.has(e),set:(e,t,n=!0)=>{this.childCtxValues.set(e,t),n&&this.childCtxChangedKeys.add(e)}}}_updateState(e,t,n){if(!this.deleted)try{const r=this.instrumentation.T.debug(`${this.type}:${this.key}:updateState`);this.validatePath(e);const a=Dr(this._schema,t,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:Ml.x.difference(this.state,a)})):this.instrumentation.L.debug("setting initial state",{state:t}),this._prevState=this._state??a,this._state=a,this.afterUpdate(this.ctx),r()}catch(r){throw sr(r,`${this.type}.${this.key}.updateState`)}}_updateContext(e){try{const t=this.instrumentation.T.debug(`${this.type}:${this.key}:updateContext`);e.forEach((n,r)=>this.parentCtxValues.set(r,n)),this.afterUpdate(this.ctx),t()}catch(t){throw sr(t,`${this.type}.${this.key}.updateContext`)}}_delete(e){try{const t=this.instrumentation.T.debug(`${this.type}:${this.key}:delete`);this.validatePath(e),this._deleted=!0,this.afterDelete(this.ctx),t()}catch(t){throw sr(t,`[${this.type}:${this.key}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new ue(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const t=e[e.length-1];if(e.length>1)throw new ue(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(t!==this.key)throw new ue(`[Leaf.setState] - ${this.type}:${this.key} received a key ${t} but expected ${this.key}`)}}class ks extends ji{constructor(){super(...arguments);L(this,"_children",new Map)}get children(){return Array.from(this._children.values())}getChild(t){return this._children.get(t)??null}childrenOfType(...t){return this.children.filter(n=>t.includes(n.type))}_updateState(t,n,r){if(this.deleted)return;const a=this.parsePath(t);if(a.length===0){if(this.childCtxChangedKeys.clear(),super._updateState(t,n,r),this.childCtxChangedKeys.size==0)return;this.updateChildContexts();return}const c=a[0],h=this.getChild(c);if(h!=null)return h._updateState(a,n,r);if(a.length>1)throw new ue(`[Composite.update] - ${this.type}:${this.key} received a subPath ${a.join(".")} but found now child with key ${c}`);const d=r(this.childCtx());d._updateState(a,n,r),this._children.set(c,d)}_updateContext(t){super._updateContext(t),this.updateChildContexts()}childCtx(){return{get:t=>this.childCtxValues.get(t)??this.parentCtxValues.get(t),forEach:t=>{this.childCtxValues.forEach((n,r)=>t(n,r,this.childCtxValues)),this.parentCtxValues.forEach((n,r)=>{this.childCtxValues.has(r)||t(n,r,this.parentCtxValues)})}}}updateChildContexts(){for(const t of this.children)t._updateContext(this.childCtx())}_delete(t){const n=this.parsePath(t);if(n.length===0){for(const a of this.children)a._delete([a.key]);this._children.clear(),super._delete([this.key])}const r=this.getChild(n[0]);if(r!=null){if(n.length>1)return r._delete(n);this._children.delete(r.key),r._delete(n)}}parsePath(t,n){const[r,...a]=t;if(r==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path${n!=null?` for ${n}`:""}`);if(r!==this.key)throw new ue(`[Composite.getRequiredKey] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`);return a}}const bS=i.z.object({}),vS=()=>{throw new Error("should not call create")},Ke=class Ke extends ks{constructor({comms:t,instrumentation:n=kl.Instrumentation.NOOP,registry:r}){super({key:Ke.KEY,type:Ke.TYPE,sender:t,instrumentation:n,parentCtxValues:null});L(this,"comms");L(this,"registry");L(this,"schema",bS);this.comms=t,this.registry=r}static render(t){const n=new Ke(t);return n._updateState([Ke.KEY],{},vS),n.comms.handle(r=>{try{n.handle(r)}catch(a){const o={name:"unknown",message:JSON.stringify(a),stack:"unknown"};a instanceof Error&&(o.name=a.name,o.message=a.message,o.stack=a.stack),n.comms.send({variant:"error",error:o})}}),n}handle(t){try{const{path:n,variant:r,type:a}=t;r==="delete"?this._delete(n):this._updateState(n,t.state,o=>{const c=n[n.length-1];return this.create({key:c,type:a,parentCtxValues:o})})}catch(n){console.error("failed to handle message",{error:n,msg:t})}}create({key:t,type:n,parentCtxValues:r}){const a=this.registry[n];if(a==null)throw new ue(`[Root.create] - ${n} not found in registry`);return new a({key:t,type:n,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:r})}};L(Ke,"TYPE","root"),L(Ke,"KEY","root");let ps=Ke;const xl=ps.render.bind(ps),SS=Object.freeze(Object.defineProperty({__proto__:null,Composite:ks,Leaf:ji,Root:ps,render:xl},Symbol.toStringTag,{value:"Module"})),Il=["success","error","warning","info","loading","disabled","secondary"],El=i.z.enum(Il),Nl=i.z.object({key:i.z.string(),variant:El,message:i.z.string(),description:i.z.string().optional(),time:T.m.z,data:T.m$1.optional()}),Al=i.z.object({statuses:Nl.array()}),et="status.aggregator";class tn extends ks{constructor(){super(...arguments);L(this,"schema",Al)}afterUpdate(t){t.wasSetPreviously(et)||t.set(et,{add:this.add.bind(this),parse:this.parse.bind(this)})}parse(t){return{time:T.m.now(),...t,key:T.Lt.create()}}add(t){this.setState(n=>({...n,statuses:[...n.statuses,this.parse(t)]}))}}L(tn,"TYPE","status.Aggregator");const Ul=s=>s.get(et).add,TS=s=>{const e=s.getOptional(et);return e!=null?e.add:()=>{}},Wr=(s,e)=>{if(!(s instanceof Error))throw s;return{variant:"error",message:e??s.message,description:e!=null?s.message:void 0}},Cl=s=>(e,t)=>{if(typeof e!="function")return s(Wr(e,t));(async()=>{try{await e()}catch(n){s(Wr(n,t))}})()},Bl=s=>Cl(Ul(s)),zS={[tn.TYPE]:tn},OS=(s,e)=>{if(s.wasSetPreviously(et))return;const t=s.get(et),n=r=>{const a=e(r,t.parse);a!=null&&t.add(a)};s.set(et,{add:n,parse:t.parse})},Vr="pluto-theming-context",jl=i.z.object({name:i.z.string(),url:i.z.string()}),kS=i.z.object({theme:Ga,fontURLs:i.z.array(jl)}),os=class os extends ks{constructor(){super(...arguments);L(this,"schema",os.z)}afterUpdate(t){if(t.getOptional(Vr)!=null&&this.state.theme.key===this.prevState.theme.key)return;t.set(Vr,this.state.theme),Bl(t)(async()=>{await this.loadFonts()})}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:t,url:n})=>{const r=new FontFace(t,`url(${n})`);try{await r.load(),self.fonts.add(r)}catch(a){console.error(a)}}))}};L(os,"TYPE","theming.Provider"),L(os,"z",kS);let gs=os;const xS=s=>s.get(Vr),IS={[gs.TYPE]:gs};exports.Aggregator=tn;exports.C=Bi;exports.Composite=ks;exports.F=W;exports.Fe=Re;exports.Gv=Fw;exports.Leaf=ji;exports.P=Ni;exports.Pe=ml;exports.Provider=gs;exports.Qt=ue;exports.REGISTRY=IS;exports.REGISTRY$1=zS;exports.S=O;exports.SYNNAX_DARK=Xa;exports.SYNNAX_LIGHT=Ja;exports.SYNNAX_THEMES=Xl;exports.VARIANTS=Il;exports.Wv=Rw;exports.aether=SS;exports.aggregatorStateZ=Al;exports.cT=vv;exports.createErrorHandler=Cl;exports.ev=yl;exports.fontSpecZ=jl;exports.fromException=Wr;exports.g=kl;exports.isComponentSize=th;exports.jv=Rm;exports.l=Ll;exports.prettyParse=Dr;exports.render=xl;exports.specZ=Nl;exports.themeZ=Ga;exports.tv=pl;exports.use=xS;exports.useAdder=Ul;exports.useErrorHandler=Bl;exports.useInterceptor=OS;exports.useOptionalAdder=TS;exports.variantZ=El;exports.vt=nt;exports.x=x;
|