@synnaxlabs/drift 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/debounce-BUAIXXZt.cjs +1 -0
  2. package/dist/debounce-DOZKRZa9.js +9 -0
  3. package/dist/electron.cjs +1 -0
  4. package/dist/electron.js +256 -0
  5. package/dist/index.cjs +1 -0
  6. package/dist/index.js +491 -0
  7. package/dist/react.cjs +1 -0
  8. package/dist/react.js +70 -0
  9. package/dist/selectors-CDBV8JlK.js +25 -0
  10. package/dist/selectors-DSYdcjUd.cjs +1 -0
  11. package/dist/src/configureStore.d.ts +43 -0
  12. package/dist/src/configureStore.d.ts.map +1 -0
  13. package/dist/src/debug.d.ts +4 -0
  14. package/dist/src/debug.d.ts.map +1 -0
  15. package/dist/src/electron/index.d.ts +49 -0
  16. package/dist/src/electron/index.d.ts.map +1 -0
  17. package/dist/src/external.d.ts +8 -0
  18. package/dist/src/external.d.ts.map +1 -0
  19. package/dist/src/index.d.ts +3 -0
  20. package/dist/src/index.d.ts.map +1 -0
  21. package/dist/src/middleware.d.ts +27 -0
  22. package/dist/src/middleware.d.ts.map +1 -0
  23. package/dist/src/middleware.spec.d.ts +2 -0
  24. package/dist/src/middleware.spec.d.ts.map +1 -0
  25. package/dist/src/mock/index.d.ts +2 -0
  26. package/dist/src/mock/index.d.ts.map +1 -0
  27. package/dist/src/mock/runtime.d.ts +44 -0
  28. package/dist/src/mock/runtime.d.ts.map +1 -0
  29. package/dist/src/react/Provider.d.ts +23 -0
  30. package/dist/src/react/Provider.d.ts.map +1 -0
  31. package/dist/src/react/hooks.d.ts +15 -0
  32. package/dist/src/react/hooks.d.ts.map +1 -0
  33. package/dist/src/react/index.d.ts +4 -0
  34. package/dist/src/react/index.d.ts.map +1 -0
  35. package/dist/src/react/selectors.d.ts +13 -0
  36. package/dist/src/react/selectors.d.ts.map +1 -0
  37. package/dist/src/runtime.d.ts +99 -0
  38. package/dist/src/runtime.d.ts.map +1 -0
  39. package/dist/src/selectors.d.ts +9 -0
  40. package/dist/src/selectors.d.ts.map +1 -0
  41. package/dist/src/serialization/index.d.ts +6 -0
  42. package/dist/src/serialization/index.d.ts.map +1 -0
  43. package/dist/src/state.d.ts +100 -0
  44. package/dist/src/state.d.ts.map +1 -0
  45. package/dist/src/sugar.d.ts +24 -0
  46. package/dist/src/sugar.d.ts.map +1 -0
  47. package/dist/src/sugar.spec.d.ts +2 -0
  48. package/dist/src/sugar.spec.d.ts.map +1 -0
  49. package/dist/src/sync.d.ts +11 -0
  50. package/dist/src/sync.d.ts.map +1 -0
  51. package/dist/src/sync.spec.d.ts +2 -0
  52. package/dist/src/sync.spec.d.ts.map +1 -0
  53. package/dist/src/tauri/index.d.ts +47 -0
  54. package/dist/src/tauri/index.d.ts.map +1 -0
  55. package/dist/src/validate.d.ts +11 -0
  56. package/dist/src/validate.d.ts.map +1 -0
  57. package/dist/src/validate.spec.d.ts +2 -0
  58. package/dist/src/validate.spec.d.ts.map +1 -0
  59. package/dist/src/window.d.ts +177 -0
  60. package/dist/src/window.d.ts.map +1 -0
  61. package/dist/state--TjGqMVk.cjs +13 -0
  62. package/dist/state-B6yPmERI.js +5918 -0
  63. package/dist/tauri.cjs +1 -0
  64. package/dist/tauri.js +2712 -0
  65. package/package.json +11 -12
@@ -0,0 +1,47 @@
1
+ import { Action, UnknownAction } from '@reduxjs/toolkit';
2
+ import { dimensions, xy } from '@synnaxlabs/x';
3
+ import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
4
+ import { Event, Runtime } from '../runtime';
5
+ import { StoreState } from '../state';
6
+ import { WindowProps } from '../window';
7
+ /**
8
+ * A Tauri backed implementation of the drift Runtime.
9
+ */
10
+ export declare class TauriRuntime<S extends StoreState, A extends Action = UnknownAction> implements Runtime<S, A> {
11
+ private readonly win;
12
+ private unsubscribe;
13
+ private fullscreenPoll;
14
+ /**
15
+ * @param window - The WebviewWindow to use as the underlying engine for this runtime.
16
+ * This should not be set in 99% of cases. Only use this if you know what you're doing.
17
+ */
18
+ constructor(window?: WebviewWindow);
19
+ configure(): Promise<void>;
20
+ private startFullscreenPoll;
21
+ label(): string;
22
+ isMain(): boolean;
23
+ release(): void;
24
+ emit(event_: Omit<Event<S, A>, "emitter">, to?: string, emitter?: string): Promise<void>;
25
+ subscribe(lis: (action: Event<S, A>) => void): Promise<void>;
26
+ onCloseRequested(cb: () => void): void;
27
+ create(label: string, props: Omit<WindowProps, "key">): Promise<void>;
28
+ close(label: string): Promise<void>;
29
+ listLabels(): Promise<string[]>;
30
+ focus(): Promise<void>;
31
+ setMinimized(value: boolean): Promise<void>;
32
+ setMaximized(value: boolean): Promise<void>;
33
+ setVisible(value: boolean): Promise<void>;
34
+ setFullscreen(value: boolean): Promise<void>;
35
+ center(): Promise<void>;
36
+ setPosition(xy: xy.XY): Promise<void>;
37
+ setSize(dims: dimensions.Dimensions): Promise<void>;
38
+ setMinSize(dims: dimensions.Dimensions): Promise<void>;
39
+ setMaxSize(dims: dimensions.Dimensions): Promise<void>;
40
+ setResizable(value: boolean): Promise<void>;
41
+ setSkipTaskbar(value: boolean): Promise<void>;
42
+ setAlwaysOnTop(value: boolean): Promise<void>;
43
+ setTitle(title: string): Promise<void>;
44
+ setDecorations(value: boolean): Promise<void>;
45
+ getProps(): Promise<Omit<WindowProps, "key">>;
46
+ }
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tauri/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAIL,UAAU,EAGV,EAAE,EACH,MAAM,eAAe,CAAC;AAQvB,OAAO,EAGL,aAAa,EACd,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAgDzD;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,MAAM,GAAG,aAAa,CAC9E,YAAW,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IACpC,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,cAAc,CAA+B;IAErD;;;OAGG;gBACS,MAAM,CAAC,EAAE,aAAa;IAK5B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;YAMlB,mBAAmB;IAyBjC,KAAK,IAAI,MAAM;IAIf,MAAM,IAAI,OAAO;IAIjB,OAAO,IAAI,IAAI;IAOT,IAAI,CACR,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,EACpC,EAAE,CAAC,EAAE,MAAM,EACX,OAAO,GAAE,MAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAQV,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBlE,gBAAgB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAOhC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCrE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBnC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAK/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnD,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3C,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;CAWpD"}
@@ -0,0 +1,11 @@
1
+ import { UnknownAction } from '@reduxjs/toolkit';
2
+ /**
3
+ * Ensures an action is valid, and throws an error if it is not.
4
+ * @param a - The action to validate.
5
+ */
6
+ export declare const validateAction: (meta: {
7
+ emitted?: boolean;
8
+ action?: UnknownAction;
9
+ emitter?: string;
10
+ }) => void;
11
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKtD;;;GAGG;AACH,eAAO,MAAM,cAAc,SAAU;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,IAUH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=validate.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.spec.d.ts","sourceRoot":"","sources":["../../src/validate.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,177 @@
1
+ import { dimensions, xy } from '@synnaxlabs/x';
2
+ import { z } from 'zod';
3
+ /** Represents the state of a window in it's lifecycle */
4
+ export type WindowStage = "creating" | "created" | "closing" | "closed" | "reloading";
5
+ export declare const MAIN_WINDOW = "main";
6
+ export declare const PRERENDER_WINDOW = "prerender";
7
+ export interface WindowStateExtensionProps {
8
+ /** Lifecycle stage */
9
+ stage: WindowStage;
10
+ /** Number of active processes */
11
+ processCount: number;
12
+ /**
13
+ * Whether the window has been reserved for use. If this value is false,
14
+ * the window is a pre-forked window that is not currently in use.
15
+ */
16
+ reserved: boolean;
17
+ /**
18
+ * If something went wrong while making changes to the window, the error
19
+ * will be stored here.
20
+ */
21
+ error?: string;
22
+ /** Incremented to focus the window */
23
+ focusCount: number;
24
+ /** Incremented to center the window */
25
+ centerCount: number;
26
+ }
27
+ export declare const INITIAL_WINDOW_STATE: WindowStateExtensionProps;
28
+ export declare const INITIAL_PRERENDER_WINDOW_STATE: WindowState;
29
+ /** State of a window managed by drift */
30
+ export interface WindowState extends WindowProps, WindowStateExtensionProps {
31
+ }
32
+ /**
33
+ * The properties to provide when creating a window.
34
+ */
35
+ export interface WindowProps {
36
+ key: string;
37
+ url?: string;
38
+ title?: string;
39
+ center?: boolean;
40
+ position?: xy.XY;
41
+ size?: dimensions.Dimensions;
42
+ minSize?: dimensions.Dimensions;
43
+ maxSize?: dimensions.Dimensions;
44
+ resizable?: boolean;
45
+ fullscreen?: boolean;
46
+ focus?: boolean;
47
+ maximized?: boolean;
48
+ visible?: boolean;
49
+ minimized?: boolean;
50
+ decorations?: boolean;
51
+ skipTaskbar?: boolean;
52
+ fileDropEnabled?: boolean;
53
+ transparent?: boolean;
54
+ alwaysOnTop?: boolean;
55
+ }
56
+ export declare const windowPropsZ: z.ZodObject<{
57
+ key: z.ZodString;
58
+ url: z.ZodOptional<z.ZodString>;
59
+ title: z.ZodOptional<z.ZodString>;
60
+ center: z.ZodOptional<z.ZodBoolean>;
61
+ position: z.ZodOptional<z.ZodObject<{
62
+ x: z.ZodNumber;
63
+ y: z.ZodNumber;
64
+ }, "strip", z.ZodTypeAny, {
65
+ x: number;
66
+ y: number;
67
+ }, {
68
+ x: number;
69
+ y: number;
70
+ }>>;
71
+ size: z.ZodOptional<z.ZodObject<{
72
+ width: z.ZodNumber;
73
+ height: z.ZodNumber;
74
+ }, "strip", z.ZodTypeAny, {
75
+ width: number;
76
+ height: number;
77
+ }, {
78
+ width: number;
79
+ height: number;
80
+ }>>;
81
+ minSize: z.ZodOptional<z.ZodObject<{
82
+ width: z.ZodNumber;
83
+ height: z.ZodNumber;
84
+ }, "strip", z.ZodTypeAny, {
85
+ width: number;
86
+ height: number;
87
+ }, {
88
+ width: number;
89
+ height: number;
90
+ }>>;
91
+ maxSize: z.ZodOptional<z.ZodObject<{
92
+ width: z.ZodNumber;
93
+ height: z.ZodNumber;
94
+ }, "strip", z.ZodTypeAny, {
95
+ width: number;
96
+ height: number;
97
+ }, {
98
+ width: number;
99
+ height: number;
100
+ }>>;
101
+ resizable: z.ZodOptional<z.ZodBoolean>;
102
+ fullscreen: z.ZodOptional<z.ZodBoolean>;
103
+ focus: z.ZodOptional<z.ZodBoolean>;
104
+ maximized: z.ZodOptional<z.ZodBoolean>;
105
+ visible: z.ZodOptional<z.ZodBoolean>;
106
+ minimized: z.ZodOptional<z.ZodBoolean>;
107
+ decorations: z.ZodOptional<z.ZodBoolean>;
108
+ skipTaskbar: z.ZodOptional<z.ZodBoolean>;
109
+ fileDropEnabled: z.ZodOptional<z.ZodBoolean>;
110
+ transparent: z.ZodOptional<z.ZodBoolean>;
111
+ alwaysOnTop: z.ZodOptional<z.ZodBoolean>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ key: string;
114
+ url?: string | undefined;
115
+ title?: string | undefined;
116
+ center?: boolean | undefined;
117
+ position?: {
118
+ x: number;
119
+ y: number;
120
+ } | undefined;
121
+ size?: {
122
+ width: number;
123
+ height: number;
124
+ } | undefined;
125
+ minSize?: {
126
+ width: number;
127
+ height: number;
128
+ } | undefined;
129
+ maxSize?: {
130
+ width: number;
131
+ height: number;
132
+ } | undefined;
133
+ resizable?: boolean | undefined;
134
+ fullscreen?: boolean | undefined;
135
+ focus?: boolean | undefined;
136
+ maximized?: boolean | undefined;
137
+ visible?: boolean | undefined;
138
+ minimized?: boolean | undefined;
139
+ decorations?: boolean | undefined;
140
+ skipTaskbar?: boolean | undefined;
141
+ fileDropEnabled?: boolean | undefined;
142
+ transparent?: boolean | undefined;
143
+ alwaysOnTop?: boolean | undefined;
144
+ }, {
145
+ key: string;
146
+ url?: string | undefined;
147
+ title?: string | undefined;
148
+ center?: boolean | undefined;
149
+ position?: {
150
+ x: number;
151
+ y: number;
152
+ } | undefined;
153
+ size?: {
154
+ width: number;
155
+ height: number;
156
+ } | undefined;
157
+ minSize?: {
158
+ width: number;
159
+ height: number;
160
+ } | undefined;
161
+ maxSize?: {
162
+ width: number;
163
+ height: number;
164
+ } | undefined;
165
+ resizable?: boolean | undefined;
166
+ fullscreen?: boolean | undefined;
167
+ focus?: boolean | undefined;
168
+ maximized?: boolean | undefined;
169
+ visible?: boolean | undefined;
170
+ minimized?: boolean | undefined;
171
+ decorations?: boolean | undefined;
172
+ skipTaskbar?: boolean | undefined;
173
+ fileDropEnabled?: boolean | undefined;
174
+ transparent?: boolean | undefined;
175
+ alwaysOnTop?: boolean | undefined;
176
+ }>;
177
+ //# sourceMappingURL=window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../src/window.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEtF,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,MAAM,WAAW,yBAAyB;IACxC,sBAAsB;IACtB,KAAK,EAAE,WAAW,CAAC;IACnB,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,oBAAoB,EAAE,yBAMlC,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,WAI5C,CAAC;AAEF,0CAA0C;AAC1C,MAAM,WAAW,WAAY,SAAQ,WAAW,EAAE,yBAAyB;CAAG;AAE9E;;GAEG;AACH,MAAM,WAAW,WAAW;IAE1B,GAAG,EAAE,MAAM,CAAC;IAEZ,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,QAAQ,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IAEjB,IAAI,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC;IAE7B,OAAO,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC;IAEhC,OAAO,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC;IAEhC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,YAAY;;;;;;WA7DiB,EAAG,SAAS;WAAS,EAC7D,SAAO;;;;;;;;;eAlCsE,EAAG,SAC7E;gBAAc,EAAE,SAAS;;;;;;;;;eADiD,EAAG,SAC7E;gBAAc,EAAE,SAAS;;;;;;;;;eADiD,EAAG,SAC7E;gBAAc,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiH5B,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";const Ur=require("@reduxjs/toolkit"),Ze=(n=!1,...e)=>{n&&console.log(...e)},Fn=(n=!1,...e)=>{n&&console.group(...e)},qt=n=>{n&&console.groupEnd()},Pr=n=>{const e=n.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)},Yn=n=>{const e=(t,r=Ft)=>{if(typeof t=="string")return n(t);if(Array.isArray(t))return t.map(a=>e(a,r));if(!Wt(t))return t;r=qr(r);const s={},i=t;return Object.keys(i).forEach(a=>{let o=i[a];const c=n(a);r.recursive&&(Wt(o)?En(o,r.keepTypesOnRecursion)||(o=e(o,r)):r.recursiveInArray&&An(o)&&(o=[...o].map(l=>{let m=l;return Wt(l)?En(m,r.keepTypesOnRecursion)||(m=e(l,r)):An(l)&&(m=e({key:l},r).key),m}))),s[c]=o}),s};return e},Gn=Yn(Pr),Wr=n=>n.replace(/([a-z0-9])([A-Z])/g,(e,t,r)=>`${t}_${r.toLowerCase()}`),zr=Yn(Wr),Vr=n=>n.length===0?n:n[0].toUpperCase()+n.slice(1),Ft={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},qr=(n=Ft)=>(n.recursive==null?n=Ft:n.recursiveInArray??(n.recursiveInArray=!1),n),An=n=>n!=null&&Array.isArray(n),Wt=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),En=(n,e)=>(e||[]).some(t=>n instanceof t),Ge=n=>n!=null&&typeof n=="object"&&!Array.isArray(n);var Fr=Object.defineProperty,Yr=(n,e,t)=>e in n?Fr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Je=(n,e,t)=>Yr(n,typeof e!="symbol"?e+"":e,t);let Gr=class{constructor(){Je(this,"contentType","application/json"),Je(this,"decoder"),Je(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const r=JSON.parse(e),s=Gn(r);return t!=null?t.parse(s):s}encodeString(e){const t=zr(e);return JSON.stringify(t,(r,s)=>ArrayBuffer.isView(s)?Array.from(s):Ge(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s)}static registerCustomType(){}},Jr=class{constructor(){Je(this,"contentType","text/csv")}encode(e){const t=this.encodeString(e);return new TextEncoder().encode(t).buffer}decode(e,t){const r=new TextDecoder().decode(e);return this.decodeString(r,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Ge(e[0]))throw new Error("Payload must be an array of objects");const t=Object.keys(e[0]),r=[t.join(",")];return e.forEach(s=>{const i=t.map(a=>JSON.stringify(s[a]??""));r.push(i.join(","))}),r.join(`
2
+ `)}decodeString(e,t){const[r,...s]=e.trim().split(`
3
+ `).map(o=>o.trim());if(r.length===0)return t!=null?t.parse({}):{};const i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),s.forEach(o=>{const c=o.split(",").map(l=>l.trim());i.forEach((l,m)=>{const g=this.parseValue(c[m]);g!=null&&a[l].push(g)})}),t!=null?t.parse(a):a}parseValue(e){if(e==null||e.length===0)return null;const t=Number(e);return isNaN(t)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:t}static registerCustomType(){}},Hr=class{constructor(){Je(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,t){const r=new TextDecoder().decode(e);return t!=null?t.parse(r):r}};const yt=new Gr;new Jr;new Hr;var S;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},n.getValidEnumValues=s=>{const i=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return n.objectValues(a)},n.objectValues=s=>n.objectKeys(s).map(function(i){return s[i]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},n.find=(s,i)=>{for(const a of s)if(i(a))return a},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}n.joinValues=r,n.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var Yt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Yt||(Yt={}));const y=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),re=n=>{switch(typeof n){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(n)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(n)?y.array:n===null?y.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?y.promise:typeof Map<"u"&&n instanceof Map?y.map:typeof Set<"u"&&n instanceof Set?y.set:typeof Date<"u"&&n instanceof Date?y.date:y.object;default:return y.unknown}},h=S.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Xr=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class W extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(t(a));else{let o=r,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof W))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}W.create=n=>new W(n);const Ce=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===y.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,S.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${S.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${S.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${S.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:S.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,S.assertNever(n)}return{message:t}};let Jn=Ce;function Kr(n){Jn=n}function Ot(){return Jn}const St=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},Qr=[];function p(n,e){const t=Ot(),r=St({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Ce?void 0:Ce].filter(s=>!!s)});n.common.issues.push(r)}class D{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return D.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return x;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}}const x=Object.freeze({status:"aborted"}),Ee=n=>({status:"dirty",value:n}),P=n=>({status:"valid",value:n}),Gt=n=>n.status==="aborted",Jt=n=>n.status==="dirty",Te=n=>n.status==="valid",He=n=>typeof Promise<"u"&&n instanceof Promise;function Nt(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Hn(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var w;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Be,De;class K{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const $n=(n,e)=>{if(Te(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new W(n.common.issues);return this._error=t,this._error}}};function _(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,l;const{message:m}=n;return a.code==="invalid_enum_value"?{message:m??o.defaultError}:typeof o.data>"u"?{message:(c=m??r)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(l=m??t)!==null&&l!==void 0?l:o.defaultError}},description:s}}class O{get description(){return this._def.description}_getType(e){return re(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(He(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)},i=this._parseSync({data:e,path:s.path,parent:s});return $n(s,i)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:s});return Te(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(t=i==null?void 0:i.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(i=>Te(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(He(s)?s:Promise.resolve(s));return $n(r,i)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new Y({schema:this,typeName:b.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return X.create(this,this._def)}nullable(){return he.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return F.create(this)}promise(){return Me.create(this,this._def)}or(e){return et.create([this,e],this._def)}and(e){return tt.create(this,e,this._def)}transform(e){return new Y({..._(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new at({..._(this._def),innerType:this,defaultValue:t,typeName:b.ZodDefault})}brand(){return new cn({typeName:b.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ot({..._(this._def),innerType:this,catchValue:t,typeName:b.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ft.create(this,e)}readonly(){return ut.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const es=/^c[^\s-]{8,}$/i,ts=/^[0-9a-z]+$/,ns=/^[0-9A-HJKMNP-TV-Z]{26}$/i,rs=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ss=/^[a-z0-9_-]{21}$/i,is=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,as=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,os=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,us="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let zt;const cs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ls=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ds=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,fs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ps=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ms=new RegExp(`^${Xn}$`);function Kn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function ys(n){return new RegExp(`^${Kn(n)}$`)}function Qn(n){let e=`${Xn}T${Kn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function gs(n,e){return!!((e==="v4"||!e)&&cs.test(n)||(e==="v6"||!e)&&ds.test(n))}function ws(n,e){if(!is.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function vs(n,e){return!!((e==="v4"||!e)&&ls.test(n)||(e==="v6"||!e)&&fs.test(n))}class q extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_type,expected:y.string,received:i.parsedType}),x}const r=new D;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?p(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&p(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")os.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")zt||(zt=new RegExp(us,"u")),zt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")rs.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")ss.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")es.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")ts.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")ns.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:h.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:h.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Qn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?ms.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?ys(i).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?as.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"duration",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?gs(e.data,i.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?ws(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"jwt",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?vs(e.data,i.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cidr",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?hs.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ps.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64url",code:h.invalid_string,message:i.message}),r.dirty()):S.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...w.errToObj(r)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...w.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=n=>{var e;return new q({checks:[],typeName:b.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,..._(n)})};function bs(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,i=parseInt(n.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class le extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_type,expected:y.number,received:i.parsedType}),x}let r;const s=new D;for(const i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?bs(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new le({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}le.create=n=>new le({checks:[],typeName:b.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,..._(n)});class de extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let r;const s=new D;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return p(t,{code:h.invalid_type,expected:y.bigint,received:t.parsedType}),x}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new de({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}de.create=n=>{var e;return new de({checks:[],typeName:b.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,..._(n)})};class Xe extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.boolean,received:r.parsedType}),x}return P(e.data)}}Xe.create=n=>new Xe({typeName:b.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,..._(n)});class Oe extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_type,expected:y.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_date}),x}const r=new D;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):S.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Oe.create=n=>new Oe({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:b.ZodDate,..._(n)});class It extends O{_parse(e){if(this._getType(e)!==y.symbol){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.symbol,received:r.parsedType}),x}return P(e.data)}}It.create=n=>new It({typeName:b.ZodSymbol,..._(n)});class Ke extends O{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.undefined,received:r.parsedType}),x}return P(e.data)}}Ke.create=n=>new Ke({typeName:b.ZodUndefined,..._(n)});class Qe extends O{_parse(e){if(this._getType(e)!==y.null){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.null,received:r.parsedType}),x}return P(e.data)}}Qe.create=n=>new Qe({typeName:b.ZodNull,..._(n)});class Re extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}Re.create=n=>new Re({typeName:b.ZodAny,..._(n)});class ve extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}ve.create=n=>new ve({typeName:b.ZodUnknown,..._(n)});class ie extends O{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:h.invalid_type,expected:y.never,received:t.parsedType}),x}}ie.create=n=>new ie({typeName:b.ZodNever,..._(n)});class kt extends O{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.void,received:r.parsedType}),x}return P(e.data)}}kt.create=n=>new kt({typeName:b.ZodVoid,..._(n)});class F extends O{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==y.array)return p(t,{code:h.invalid_type,expected:y.array,received:t.parsedType}),x;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(p(t,{code:a?h.too_big:h.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(p(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(p(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new K(t,a,t.path,o)))).then(a=>D.mergeArray(r,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new K(t,a,t.path,o)));return D.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new F({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new F({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new F({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}F.create=(n,e)=>new F({type:n,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,..._(e)});function Ae(n){if(n instanceof R){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=X.create(Ae(r))}return new R({...n._def,shape:()=>e})}else return n instanceof F?new F({...n._def,type:Ae(n.element)}):n instanceof X?X.create(Ae(n.unwrap())):n instanceof he?he.create(Ae(n.unwrap())):n instanceof Q?Q.create(n.items.map(e=>Ae(e))):n}class R extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=S.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==y.object){const l=this._getOrReturnCtx(e);return p(l,{code:h.invalid_type,expected:y.object,received:l.parsedType}),x}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const l in s.data)a.includes(l)||o.push(l);const c=[];for(const l of a){const m=i[l],g=s.data[l];c.push({key:{status:"valid",value:l},value:m._parse(new K(s,g,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof ie){const l=this._def.unknownKeys;if(l==="passthrough")for(const m of o)c.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(l==="strict")o.length>0&&(p(s,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const m of o){const g=s.data[m];c.push({key:{status:"valid",value:m},value:l._parse(new K(s,g,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const m of c){const g=await m.key,L=await m.value;l.push({key:g,value:L,alwaysSet:m.alwaysSet})}return l}).then(l=>D.mergeObjectSync(r,l)):D.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new R({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,r).message)!==null&&a!==void 0?a:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=w.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(e){return new R({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new R({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:b.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new R({...this._def,catchall:e})}pick(e){const t={};return S.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new R({...this._def,shape:()=>t})}omit(e){const t={};return S.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new R({...this._def,shape:()=>t})}deepPartial(){return Ae(this)}partial(e){const t={};return S.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new R({...this._def,shape:()=>t})}required(e){const t={};return S.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof X;)i=i._def.innerType;t[r]=i}}),new R({...this._def,shape:()=>t})}keyof(){return er(S.objectKeys(this.shape))}}R.create=(n,e)=>new R({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:b.ZodObject,..._(e)});R.strictCreate=(n,e)=>new R({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:b.ZodObject,..._(e)});R.lazycreate=(n,e)=>new R({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:b.ZodObject,..._(e)});class et extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new W(o.ctx.common.issues));return p(t,{code:h.invalid_union,unionErrors:a}),x}if(t.common.async)return Promise.all(r.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of r){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new W(c));return p(t,{code:h.invalid_union,unionErrors:o}),x}}get options(){return this._def.options}}et.create=(n,e)=>new et({options:n,typeName:b.ZodUnion,..._(e)});const te=n=>n instanceof rt?te(n.schema):n instanceof Y?te(n.innerType()):n instanceof st?[n.value]:n instanceof fe?n.options:n instanceof it?S.objectValues(n.enum):n instanceof at?te(n._def.innerType):n instanceof Ke?[void 0]:n instanceof Qe?[null]:n instanceof X?[void 0,...te(n.unwrap())]:n instanceof he?[null,...te(n.unwrap())]:n instanceof cn||n instanceof ut?te(n.unwrap()):n instanceof ot?te(n._def.innerType):[];class Rt extends O{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.object)return p(t,{code:h.invalid_type,expected:y.object,received:t.parsedType}),x;const r=this.discriminator,s=t.data[r],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const i of t){const a=te(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Rt({typeName:b.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._(r)})}}function Ht(n,e){const t=re(n),r=re(e);if(n===e)return{valid:!0,data:n};if(t===y.object&&r===y.object){const s=S.objectKeys(e),i=S.objectKeys(n).filter(o=>s.indexOf(o)!==-1),a={...n,...e};for(const o of i){const c=Ht(n[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===y.array&&r===y.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<n.length;i++){const a=n[i],o=e[i],c=Ht(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===y.date&&r===y.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class tt extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(i,a)=>{if(Gt(i)||Gt(a))return x;const o=Ht(i.value,a.value);return o.valid?((Jt(i)||Jt(a))&&t.dirty(),{status:t.value,value:o.data}):(p(r,{code:h.invalid_intersection_types}),x)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}tt.create=(n,e,t)=>new tt({left:n,right:e,typeName:b.ZodIntersection,..._(t)});class Q extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return p(r,{code:h.invalid_type,expected:y.array,received:r.parsedType}),x;if(r.data.length<this._def.items.length)return p(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&r.data.length>this._def.items.length&&(p(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new K(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>D.mergeArray(t,a)):D.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Q({...this._def,rest:e})}}Q.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:n,typeName:b.ZodTuple,rest:null,..._(e)})};class nt extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return p(r,{code:h.invalid_type,expected:y.object,received:r.parsedType}),x;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in r.data)s.push({key:i._parse(new K(r,o,r.path,o)),value:a._parse(new K(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?D.mergeObjectAsync(t,s):D.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof O?new nt({keyType:e,valueType:t,typeName:b.ZodRecord,..._(r)}):new nt({keyType:q.create(),valueType:e,typeName:b.ZodRecord,..._(t)})}}class At extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return p(r,{code:h.invalid_type,expected:y.map,received:r.parsedType}),x;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([o,c],l)=>({key:s._parse(new K(r,o,r.path,[l,"key"])),value:i._parse(new K(r,c,r.path,[l,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return x;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return x;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}}At.create=(n,e,t)=>new At({valueType:e,keyType:n,typeName:b.ZodMap,..._(t)});class Se extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return p(r,{code:h.invalid_type,expected:y.set,received:r.parsedType}),x;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(p(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(p(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const l=new Set;for(const m of c){if(m.status==="aborted")return x;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...r.data.values()].map((c,l)=>i._parse(new K(r,c,r.path,l)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Se({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Se({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Se.create=(n,e)=>new Se({valueType:n,minSize:null,maxSize:null,typeName:b.ZodSet,..._(e)});class $e extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.function)return p(t,{code:h.invalid_type,expected:y.function,received:t.parsedType}),x;function r(o,c){return St({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ot(),Ce].filter(l=>!!l),issueData:{code:h.invalid_arguments,argumentsError:c}})}function s(o,c){return St({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ot(),Ce].filter(l=>!!l),issueData:{code:h.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Me){const o=this;return P(async function(...c){const l=new W([]),m=await o._def.args.parseAsync(c,i).catch(V=>{throw l.addIssue(r(c,V)),l}),g=await Reflect.apply(a,this,m);return await o._def.returns._def.type.parseAsync(g,i).catch(V=>{throw l.addIssue(s(g,V)),l})})}else{const o=this;return P(function(...c){const l=o._def.args.safeParse(c,i);if(!l.success)throw new W([r(c,l.error)]);const m=Reflect.apply(a,this,l.data),g=o._def.returns.safeParse(m,i);if(!g.success)throw new W([s(m,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $e({...this._def,args:Q.create(e).rest(ve.create())})}returns(e){return new $e({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new $e({args:e||Q.create([]).rest(ve.create()),returns:t||ve.create(),typeName:b.ZodFunction,..._(r)})}}class rt extends O{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}rt.create=(n,e)=>new rt({getter:n,typeName:b.ZodLazy,..._(e)});class st extends O{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}st.create=(n,e)=>new st({value:n,typeName:b.ZodLiteral,..._(e)});function er(n,e){return new fe({values:n,typeName:b.ZodEnum,..._(e)})}class fe extends O{constructor(){super(...arguments),Be.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return p(t,{expected:S.joinValues(r),received:t.parsedType,code:h.invalid_type}),x}if(Nt(this,Be)||Hn(this,Be,new Set(this._def.values)),!Nt(this,Be).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return p(t,{received:t.data,code:h.invalid_enum_value,options:r}),x}return P(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return fe.create(e,{...this._def,...t})}exclude(e,t=this._def){return fe.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Be=new WeakMap;fe.create=er;class it extends O{constructor(){super(...arguments),De.set(this,void 0)}_parse(e){const t=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const s=S.objectValues(t);return p(r,{expected:S.joinValues(s),received:r.parsedType,code:h.invalid_type}),x}if(Nt(this,De)||Hn(this,De,new Set(S.getValidEnumValues(this._def.values))),!Nt(this,De).has(e.data)){const s=S.objectValues(t);return p(r,{received:r.data,code:h.invalid_enum_value,options:s}),x}return P(e.data)}get enum(){return this._def.values}}De=new WeakMap;it.create=(n,e)=>new it({values:n,typeName:b.ZodNativeEnum,..._(e)});class Me extends O{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&t.common.async===!1)return p(t,{code:h.invalid_type,expected:y.promise,received:t.parsedType}),x;const r=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return P(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Me.create=(n,e)=>new Me({type:n,typeName:b.ZodPromise,..._(e)});class Y extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{p(r,a),a.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return x;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Ee(c.value):c});{if(t.value==="aborted")return x;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?x:o.status==="dirty"||t.value==="dirty"?Ee(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Te(a))return a;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Te(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);S.assertNever(s)}}Y.create=(n,e,t)=>new Y({schema:n,typeName:b.ZodEffects,effect:e,..._(t)});Y.createWithPreprocess=(n,e,t)=>new Y({schema:e,effect:{type:"preprocess",transform:n},typeName:b.ZodEffects,..._(t)});class X extends O{_parse(e){return this._getType(e)===y.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(n,e)=>new X({innerType:n,typeName:b.ZodOptional,..._(e)});class he extends O{_parse(e){return this._getType(e)===y.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:b.ZodNullable,..._(e)});class at extends O{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}at.create=(n,e)=>new at({innerType:n,typeName:b.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class ot extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return He(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new W(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new W(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ot.create=(n,e)=>new ot({innerType:n,typeName:b.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class Et extends O{_parse(e){if(this._getType(e)!==y.nan){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.nan,received:r.parsedType}),x}return{status:"valid",value:e.data}}}Et.create=n=>new Et({typeName:b.ZodNaN,..._(n)});const xs=Symbol("zod_brand");class cn extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ft extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?x:i.status==="dirty"?(t.dirty(),Ee(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?x:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ft({in:e,out:t,typeName:b.ZodPipeline})}}class ut extends O{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Te(s)&&(s.value=Object.freeze(s.value)),s);return He(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}ut.create=(n,e)=>new ut({innerType:n,typeName:b.ZodReadonly,..._(e)});function tr(n,e={},t){return n?Re.create().superRefine((r,s)=>{var i,a;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Re.create()}const _s={object:R.lazycreate};var b;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(b||(b={}));const Ts=(n,e={message:`Input not instance of ${n.name}`})=>tr(t=>t instanceof n,e),nr=q.create,rr=le.create,Os=Et.create,Ss=de.create,sr=Xe.create,Ns=Oe.create,Is=It.create,ks=Ke.create,As=Qe.create,Es=Re.create,$s=ve.create,Cs=ie.create,Rs=kt.create,Ms=F.create,js=R.create,Zs=R.strictCreate,Bs=et.create,Ds=Rt.create,Ls=tt.create,Us=Q.create,Ps=nt.create,Ws=At.create,zs=Se.create,Vs=$e.create,qs=rt.create,Fs=st.create,Ys=fe.create,Gs=it.create,Js=Me.create,Cn=Y.create,Hs=X.create,Xs=he.create,Ks=Y.createWithPreprocess,Qs=ft.create,ei=()=>nr().optional(),ti=()=>rr().optional(),ni=()=>sr().optional(),ri={string:n=>q.create({...n,coerce:!0}),number:n=>le.create({...n,coerce:!0}),boolean:n=>Xe.create({...n,coerce:!0}),bigint:n=>de.create({...n,coerce:!0}),date:n=>Oe.create({...n,coerce:!0})},si=x;var u=Object.freeze({__proto__:null,defaultErrorMap:Ce,setErrorMap:Kr,getErrorMap:Ot,makeIssue:St,EMPTY_PATH:Qr,addIssueToContext:p,ParseStatus:D,INVALID:x,DIRTY:Ee,OK:P,isAborted:Gt,isDirty:Jt,isValid:Te,isAsync:He,get util(){return S},get objectUtil(){return Yt},ZodParsedType:y,getParsedType:re,ZodType:O,datetimeRegex:Qn,ZodString:q,ZodNumber:le,ZodBigInt:de,ZodBoolean:Xe,ZodDate:Oe,ZodSymbol:It,ZodUndefined:Ke,ZodNull:Qe,ZodAny:Re,ZodUnknown:ve,ZodNever:ie,ZodVoid:kt,ZodArray:F,ZodObject:R,ZodUnion:et,ZodDiscriminatedUnion:Rt,ZodIntersection:tt,ZodTuple:Q,ZodRecord:nt,ZodMap:At,ZodSet:Se,ZodFunction:$e,ZodLazy:rt,ZodLiteral:st,ZodEnum:fe,ZodNativeEnum:it,ZodPromise:Me,ZodEffects:Y,ZodTransformer:Y,ZodOptional:X,ZodNullable:he,ZodDefault:at,ZodCatch:ot,ZodNaN:Et,BRAND:xs,ZodBranded:cn,ZodPipeline:ft,ZodReadonly:ut,custom:tr,Schema:O,ZodSchema:O,late:_s,get ZodFirstPartyTypeKind(){return b},coerce:ri,any:Es,array:Ms,bigint:Ss,boolean:sr,date:Ns,discriminatedUnion:Ds,effect:Cn,enum:Ys,function:Vs,instanceof:Ts,intersection:Ls,lazy:qs,literal:Fs,map:Ws,nan:Os,nativeEnum:Gs,never:Cs,null:As,nullable:Xs,number:rr,object:js,oboolean:ni,onumber:ti,optional:Hs,ostring:ei,pipeline:Qs,preprocess:Ks,promise:Js,record:Ps,set:zs,strictObject:Zs,string:nr,symbol:Is,transformer:Cn,tuple:Us,undefined:ks,union:Bs,unknown:$s,void:Rs,NEVER:si,ZodIssueCode:h,quotelessJson:Xr,ZodError:W});const ii=n=>n!=null&&typeof n=="object"&&"toString"in n,ai=(n,e=!1)=>{const t=ii(n)?"stringer":typeof n;let r;switch(t){case"string":r=(s,i)=>s.localeCompare(i);break;case"stringer":r=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":r=(s,i)=>Number(s)-Number(i);break;case"bigint":r=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":r=(s,i)=>Number(s)-Number(i);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?oi(r):r},oi=n=>(e,t)=>n(t,e),Mt=u.tuple([u.number(),u.number()]);u.tuple([u.bigint(),u.bigint()]);const ln=u.object({width:u.number(),height:u.number()}),ui=u.object({signedWidth:u.number(),signedHeight:u.number()}),ci=["width","height"];u.enum(ci);const li=["start","center","end"],di=["signedWidth","signedHeight"];u.enum(di);const ct=u.object({x:u.number(),y:u.number()}),ir=u.object({clientX:u.number(),clientY:u.number()}),dn=["x","y"],ar=u.enum(dn),or=["top","right","bottom","left"],fi=u.enum(or),jt=["left","right"],fn=u.enum(jt),Zt=["top","bottom"],hn=u.enum(Zt),pn=["center"],Xt=u.enum(pn),hi=[...or,...pn],mn=u.enum(hi);u.enum(li);const pi=["first","last"];u.enum(pi);const mi=u.object({lower:u.number(),upper:u.number()}),yi=u.object({lower:u.bigint(),upper:u.bigint()});u.union([mi,Mt]);u.union([yi,Mt]);u.union([ar,mn]);const gi=u.union([ar,mn,u.instanceof(String)]),wi=n=>typeof n=="bigint"||n instanceof BigInt,Ie=(n,e)=>wi(n)?n.valueOf()*BigInt(e.valueOf()):n.valueOf()*Number(e.valueOf()),be=(n,e)=>{const t={};if(typeof n=="number"||typeof n=="bigint")e!=null?(t.lower=n,t.upper=e):(t.lower=typeof n=="bigint"?0n:0,t.upper=n);else if(Array.isArray(n)){if(n.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=n}else return Rn(n);return Rn(t)},Rn=n=>n.lower>n.upper?{lower:n.upper,upper:n.lower}:n,Mn=(n,e)=>{const t=be(n);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e},yn=n=>dn.includes(n)?n:Zt.includes(n)?"y":"x",vi=fn,bi=hn,xi=Xt,_i={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},Ti={top:"left",right:"top",bottom:"right",left:"bottom",center:"center"},Oi=gi,pe=n=>n instanceof String||!dn.includes(n)?n:n==="x"?"left":"top",Si=n=>_i[pe(n)],Ni=n=>Ti[pe(n)],lt=n=>{const e=pe(n);return e==="top"||e==="bottom"?"y":"x"},Ii=u.object({x:fn.or(Xt),y:hn.or(Xt)}),ur=u.object({x:fn,y:hn}),ht=Object.freeze({x:"left",y:"top"}),gn=Object.freeze({x:"right",y:"top"}),Bt=Object.freeze({x:"left",y:"bottom"}),wn=Object.freeze({x:"right",y:"bottom"}),vn=Object.freeze({x:"center",y:"center"}),cr=Object.freeze({x:"center",y:"top"}),lr=Object.freeze({x:"center",y:"bottom"}),dr=Object.freeze({x:"right",y:"center"}),fr=Object.freeze({x:"left",y:"center"}),ki=Object.freeze([fr,dr,cr,lr,ht,gn,Bt,wn,vn]),bn=(n,e)=>n.x===e.x&&n.y===e.y,Ai=(n,e)=>{if(typeof e=="object"){let t=!0;return"x"in e&&(n.x===e.x||(t=!1)),"y"in e&&(n.y===e.y||(t=!1)),t}return n.x===e||n.y===e},hr=n=>[n.x,n.y],gt=n=>lt(pe(n))==="x",Ei=n=>lt(pe(n))==="y",$i=n=>`${n.x}${Vr(n.y)}`,Ci=(n,e)=>{let t,r;if(typeof n=="object"&&"x"in n?(t=n.x,r=n.y):(t=pe(n),r=pe(e??n)),lt(t)===lt(r)&&t!=="center"&&r!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${t.toString()} - ${r.toString()}`);const s={...vn};return t==="center"?gt(r)?[s.x,s.y]=[r,t]:[s.x,s.y]=[t,r]:r==="center"?gt(t)?[s.x,s.y]=[t,r]:[s.x,s.y]=[r,t]:gt(t)?[s.x,s.y]=[t,r]:[s.x,s.y]=[r,t],s},Ri=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:lr,BOTTOM_LEFT:Bt,BOTTOM_RIGHT:wn,CENTER:vn,CENTER_LOCATIONS:pn,LEFT_CENTER:fr,RIGHT_CENTER:dr,TOP_CENTER:cr,TOP_LEFT:ht,TOP_RIGHT:gn,XY_LOCATIONS:ki,X_LOCATIONS:jt,Y_LOCATIONS:Zt,center:xi,construct:pe,constructXY:Ci,corner:ur,crude:Oi,direction:lt,isX:gt,isY:Ei,location:mn,outer:fi,rotate90:Ni,swap:Si,x:vi,xy:Ii,xyCouple:hr,xyEquals:bn,xyMatches:Ai,xyToString:$i,y:bi},Symbol.toStringTag,{value:"Module"})),Kt=u.union([u.number(),ct,Mt,ln,ui,ir]),C=(n,e)=>{if(typeof n=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return n==="x"?{x:e,y:0}:{x:0,y:e}}return typeof n=="number"?{x:n,y:e??n}:Array.isArray(n)?{x:n[0],y:n[1]}:"signedWidth"in n?{x:n.signedWidth,y:n.signedHeight}:"clientX"in n?{x:n.clientX,y:n.clientY}:"width"in n?{x:n.width,y:n.height}:{x:n.x,y:n.y}},ee=Object.freeze({x:0,y:0}),pr=Object.freeze({x:1,y:1}),Mi=Object.freeze({x:1/0,y:1/0}),ji=Object.freeze({x:NaN,y:NaN}),$t=(n,e,t=0)=>{const r=C(n),s=C(e);return t===0?r.x===s.x&&r.y===s.y:Math.abs(r.x-s.x)<=t&&Math.abs(r.y-s.y)<=t},Zi=n=>$t(n,ee),xn=(n,e,t)=>{const r=C(n),s=C(e,t);return{x:r.x*s.x,y:r.y*s.y}},mr=(n,e)=>{const t=C(n);return{x:t.x+e,y:t.y}},yr=(n,e)=>{const t=C(n);return{x:t.x,y:t.y+e}},dt=(n,e,t,...r)=>typeof e=="string"&&typeof t=="number"?e==="x"?mr(n,t):yr(n,t):[n,e,t??ee,...r].reduce((s,i)=>{const a=C(i);return{x:s.x+a.x,y:s.y+a.y}},ee),Bi=(n,e,t)=>{const r=C(n);return e==="x"?{x:t,y:r.y}:{x:r.x,y:t}},Di=(n,e)=>{const t=C(n),r=C(e);return Math.sqrt((t.x-r.x)**2+(t.y-r.y)**2)},Li=(n,e)=>{const t=C(n),r=C(e);return{x:r.x-t.x,y:r.y-t.y}},Ui=n=>{const e=C(n);return Number.isNaN(e.x)||Number.isNaN(e.y)},Pi=n=>{const e=C(n);return Number.isFinite(e.x)&&Number.isFinite(e.y)},Wi=n=>{const e=C(n);return[e.x,e.y]},zi=n=>{const e=C(n);return{left:e.x,top:e.y}},Qt=(n,e=0)=>{const t=C(n);return{x:Number(t.x.toFixed(e)),y:Number(t.y.toFixed(e))}},Le=(n,e)=>{const t=C(n),r=C(e);return{x:t.x-r.x,y:t.y-r.y}},Ue=n=>{const e=C(n),t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:-e.y/t,y:e.x/t}},gr=n=>{const e=C(n),t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},wr=(...n)=>{const e=n.reduce((t,r)=>dt(t,r),ee);return xn(e,1/n.length)},Vi=(n,e)=>{const t=[];for(let r=0;r<n.length;r++){const s=n[r];let i,a,o,c;if(r===0){const l=n[r+1],m=Le(l,s);a=Ue(m),o=a,c=e}else if(r===n.length-1){const l=n[r-1],m=Le(s,l);i=Ue(m),o=i,c=e}else{const l=n[r-1],m=n[r+1],g=Le(s,l),L=Le(m,s);i=Ue(g),a=Ue(L);const V=Math.acos((g.x*L.x+g.y*L.y)/(Math.hypot(g.x,g.y)*Math.hypot(L.x,L.y))),je=Math.sin(V/2);je===0?c=e:c=e/je,o=gr(wr(i,a))}t.push(xn(o,c))}return t},Ct=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Mi,NAN:ji,ONE:pr,ZERO:ee,average:wr,calculateMiters:Vi,clientXY:ir,construct:C,couple:Wi,crudeZ:Kt,css:zi,distance:Di,equals:$t,isFinite:Pi,isNan:Ui,isZero:Zi,normal:Ue,normalize:gr,scale:xn,set:Bi,sub:Le,translate:dt,translateX:mr,translateY:yr,translation:Li,truncate:Qt,xy:ct},Symbol.toStringTag,{value:"Module"})),mt=u.union([u.number(),u.string()]),qi=u.object({top:mt,left:mt,width:mt,height:mt}),Fi=u.object({left:u.number(),top:u.number(),right:u.number(),bottom:u.number()}),Yi=u.object({one:ct,two:ct,root:ur}),vr={one:ee,two:ee,root:ht},Gi={one:ee,two:pr,root:Bt},br=(n,e)=>({one:n.one,two:n.two,root:e??n.root}),$=(n,e,t=0,r=0,s)=>{const i={one:{...ee},two:{...ee},root:s??ht};if(typeof n=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:n,y:e},i.two={x:i.one.x+t,y:i.one.y+r},i}return"one"in n&&"two"in n&&"root"in n?{...n,root:s??n.root}:("getBoundingClientRect"in n&&(n=n.getBoundingClientRect()),"left"in n?(i.one={x:n.left,y:n.top},i.two={x:n.right,y:n.bottom},i):(i.one=n,e==null?i.two={x:i.one.x+t,y:i.one.y+r}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+t}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Ji=(n,e,t)=>{const r=$(n);if(typeof e=="string"){if(t==null)throw new Error("Invalid arguments for resize");const s=yn(e);return $(r.one,void 0,s==="x"?t:me(r),s==="y"?t:ye(r),r.root)}return $(r.one,e,void 0,void 0,r.root)},Hi=(n,e,t=!0)=>{const r=$(n);let s=(i,a)=>i<a;return t&&(s=(i,a)=>i<=a),"one"in e?s(ue(r),ue(e))&&s(xe(e),xe(r))&&s(ce(r),ce(e))&&s(_e(e),_e(r)):s(ue(r),e.x)&&s(e.x,xe(r))&&s(ce(r),e.y)&&s(e.y,_e(r))},Xi=(n,e)=>$t(n.one,e.one)&&$t(n.two,e.two)&&bn(n.root,e.root),xr=n=>({width:me(n),height:ye(n)}),Ki=n=>({signedWidth:Dt(n),signedHeight:Lt(n)}),Qi=n=>({top:ce(n),left:ue(n),width:me(n),height:ye(n)}),_n=(n,e,t=!1)=>{const r=yn(e)==="y"?Lt(n):Dt(n);return t?r:Math.abs(r)},pt=(n,e)=>{const t=$(n);return{x:e.x==="center"?en(t).x:Ne(t,e.x),y:e.y==="center"?en(t).y:Ne(t,e.y)}},Ne=(n,e)=>{const t=$(n),r=hr(t.root).includes(e)?Math.min:Math.max;return jt.includes(e)?r(t.one.x,t.two.x):r(t.one.y,t.two.y)},ea=n=>n.one.x===n.two.x&&n.one.y===n.two.y,me=n=>_n(n,"x"),ye=n=>_n(n,"y"),Dt=n=>{const e=$(n);return e.two.x-e.one.x},Lt=n=>{const e=$(n);return e.two.y-e.one.y},_r=n=>pt(n,ht),ta=n=>pt(n,gn),na=n=>pt(n,Bt),ra=n=>pt(n,wn),xe=n=>Ne(n,"right"),_e=n=>Ne(n,"bottom"),ue=n=>Ne(n,"left"),ce=n=>Ne(n,"top"),en=n=>dt(_r(n),{x:Dt(n)/2,y:Lt(n)/2}),Tn=n=>{const e=$(n);return e.root.x==="left"?ue(e):xe(e)},On=n=>{const e=$(n);return e.root.y==="top"?ce(e):_e(e)},sa=n=>({x:Tn(n),y:On(n)}),wt=n=>{const e=$(n);return{lower:e.one.x,upper:e.two.x}},vt=n=>{const e=$(n);return{lower:e.one.y,upper:e.two.y}},ia=(n,e)=>br(n,e),aa=(n,e)=>{const t=$(n),r=jt.includes(e)?"x":Zt.includes(e)?"y":null;if(r===null)throw new Error(`Invalid location: ${Ri}`);const s=e==="top"||e==="left"?Math.min:Math.max,i={...t.one},a={...t.two};return i[r]=s(t.one[r],t.two[r]),a[r]=s(t.one[r],t.two[r]),[i,a]},oa=(n,e)=>{const t=$(n),r=$(e),s=Tn(r)+(me(r)-me(t))/2,i=On(r)+(ye(r)-ye(t))/2;return $({x:s,y:i},xr(t))},Tr=n=>typeof n!="object"||n==null?!1:"one"in n&&"two"in n&&"root"in n,ua=n=>me(n)/ye(n),ca=(n,e,t)=>{if(typeof e=="string"){if(t==null)throw new Error("Undefined amount passed into box.translate");const s=yn(e);e=C(s,t)}const r=$(n);return $(dt(r.one,e),dt(r.two,e),void 0,void 0,r.root)},la=(n,e)=>{const t=Math.max(ue(n),ue(e)),r=Math.max(ce(n),ce(e)),s=Math.min(xe(n),xe(e)),i=Math.min(_e(n),_e(e));return t>s||r>i?vr:$({x:t,y:r},{x:s,y:i},void 0,void 0,n.root)},da=n=>me(n)*ye(n),fa=(n,e)=>{const t=$(n);return $(Qt(t.one,e),Qt(t.two,e),void 0,void 0,t.root)},ha=(n,e,t,r,s,i)=>{const a={x:n,y:e},o={x:n+t,y:e+r};return s.x!==i.x&&(s.x==="center"?(a.x-=t/2,o.x-=t/2):(a.x-=t,o.x-=t)),s.y!==i.y&&(s.y==="center"?(a.y-=r/2,o.y-=r/2):(a.y-=r,o.y-=r)),$(a,o,void 0,void 0,i)},Pe=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:Gi,ZERO:vr,area:da,areaIsZero:ea,aspect:ua,bottom:_e,bottomLeft:na,bottomRight:ra,box:Yi,center:en,construct:$,constructWithAlternateRoot:ha,contains:Hi,copy:br,css:Qi,cssBox:qi,dim:_n,dims:xr,domRect:Fi,edgePoints:aa,equals:Xi,height:ye,intersection:la,isBox:Tr,left:ue,loc:Ne,positionInCenter:oa,reRoot:ia,resize:Ji,right:xe,root:sa,signedDims:Ki,signedHeight:Lt,signedWidth:Dt,top:ce,topLeft:_r,topRight:ta,translate:ca,truncate:fa,width:me,x:Tn,xBounds:wt,xyLoc:pt,y:On,yBounds:vt},Symbol.toStringTag,{value:"Module"})),Or=u.object({signedWidth:u.number(),signedHeight:u.number()}),pa=u.union([ln,Or,ct,Mt]),ma={width:0,height:0},ya={width:1,height:1},G=(n,e)=>typeof n=="number"?{width:n,height:e??n}:Array.isArray(n)?{width:n[0],height:n[1]}:"x"in n?{width:n.x,height:n.y}:"signedWidth"in n?{width:n.signedWidth,height:n.signedHeight}:{...n},ga=(n,e)=>{if(e==null)return!1;const t=G(n),r=G(e);return t.width===r.width&&t.height===r.height},wa=n=>{const e=G(n);return{width:e.height,height:e.width}},va=n=>{const e=G(n);return`0 0 ${e.width} ${e.height}`},ba=n=>{const e=G(n);return[e.width,e.height]},xa=n=>({width:Math.max(...n.map(e=>G(e).width)),height:Math.max(...n.map(e=>G(e).height))}),_a=n=>({width:Math.min(...n.map(e=>G(e).width)),height:Math.min(...n.map(e=>G(e).height))}),Ta=(n,e)=>{const t=G(n);return{width:t.width*e,height:t.height*e}},bt=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:ya,ZERO:ma,construct:G,couple:ba,crude:pa,dimensions:ln,equals:ga,max:xa,min:_a,scale:Ta,signed:Or,svgViewBox:va,swap:wa},Symbol.toStringTag,{value:"Module"}));var Oa=Object.defineProperty,Sa=(n,e,t)=>e in n?Oa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,se=(n,e,t)=>Sa(n,typeof e!="symbol"?e+"":e,t);const Na=(n,e,t)=>e!==void 0&&n<e?e:t!==void 0&&n>t?t:n;u.object({offset:Kt,scale:Kt});u.object({offset:u.number(),scale:u.number()});const Ia=n=>(e,t,r,s)=>t==="dimension"?[e,r]:[e,s?r-n:r+n],ka=n=>(e,t,r,s)=>[e,s?r/n:r*n],Aa=n=>(e,t,r)=>{if(e===null)return[n,r];const{lower:s,upper:i}=e,{lower:a,upper:o}=n,c=i-s,l=o-a;if(t==="dimension")return[n,r*(l/c)];const m=(r-s)*(l/c)+a;return[n,m]},Ea=n=>(e,t,r)=>[n,r],$a=()=>(n,e,t)=>{if(n===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[n,t];const{lower:r,upper:s}=n;return[n,s-(t-r)]},Ca=n=>(e,t,r)=>{const{lower:s,upper:i}=n;return r=Na(r,s,i),[e,r]},tn=class We{constructor(){se(this,"ops",[]),se(this,"currBounds",null),se(this,"currType",null),se(this,"reversed",!1),this.ops=[]}static translate(e){return new We().translate(e)}static magnify(e){return new We().magnify(e)}static scale(e,t){return new We().scale(e,t)}translate(e){const t=this.new(),r=Ia(e);return r.type="translate",t.ops.push(r),t}magnify(e){const t=this.new(),r=ka(e);return r.type="magnify",t.ops.push(r),t}scale(e,t){const r=be(e,t),s=this.new(),i=Aa(r);return i.type="scale",s.ops.push(i),s}clamp(e,t){const r=be(e,t),s=this.new(),i=Ca(r);return i.type="clamp",s.ops.push(i),s}reBound(e,t){const r=be(e,t),s=this.new(),i=Ea(r);return i.type="re-bound",s.ops.push(i),s}invert(){const e=$a();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 We;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([r,s],i)=>i(r,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((r,s)=>{if(r.type==="scale"||t.some(([a,o])=>s>=a&&s<=o))return;const i=e.ops.findIndex((a,o)=>a.type==="scale"&&o>s);i!==-1&&t.push([s,i])}),t.forEach(([r,s])=>{const i=e.ops.slice(r,s);i.unshift(e.ops[s]),e.ops.splice(r,s-r+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};se(tn,"IDENTITY",new tn);let jn=tn;const Zn=class ne{constructor(e=new jn,t=new jn,r=null){se(this,"x"),se(this,"y"),se(this,"currRoot"),this.x=e,this.y=t,this.currRoot=r}static translate(e,t){return new ne().translate(e,t)}static translateX(e){return new ne().translateX(e)}static translateY(e){return new ne().translateY(e)}static clamp(e){return new ne().clamp(e)}static magnify(e){return new ne().magnify(e)}static scale(e){return new ne().scale(e)}static reBound(e){return new ne().reBound(e)}translate(e,t){const r=C(e,t),s=this.copy();return s.x=this.x.translate(r.x),s.y=this.y.translate(r.y),s}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(Tr(e)){const r=this.currRoot;return t.currRoot=e.root,r!=null&&!bn(r,e.root)&&(r.x!==e.root.x&&(t.x=t.x.invert()),r.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(wt(e)),t.y=t.y.scale(vt(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(wt(e)),t.y=this.y.reBound(vt(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(wt(e)),t.y=this.y.clamp(vt(e)),t}copy(){const e=new ne;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 $(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})}}};se(Zn,"IDENTITY",new Zn);const Ra=(n,e,t=".")=>{const r=n.split(t);return r.map((s,i)=>{const a=e(s,i,r);return a==null?null:typeof a=="string"?a:a.join(t)}).filter(s=>s!=null).join(t)},Sr=(n,e,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:r,getter:s=(o,c)=>o[c]}=t,i=e.split(t.separator);if(i.length===1&&i[0]==="")return n;let a=n;for(const o of i){const c=s(a,o);if(c==null){if(r)return null;throw new Error(`Path ${e} does not exist. ${o} is null`)}a=c}return a},Ma=(n,e,t)=>{const r=e.split(".");let s=n;for(let i=0;i<r.length-1;i++){const a=r[i];s[a]??(s[a]={}),s=s[a]}try{s[r[r.length-1]]=t}catch(i){throw console.error("failed to set value",t,"at path",e,"on object",n),i}},ja=(n,e)=>{const t=e.split(".");let r=n;for(let s=0;s<t.length-1;s++){const i=t[s];if(r[i]==null)return;r=r[i]}if(Array.isArray(r)){const s=parseInt(t[t.length-1]);if(isNaN(s))return;r.splice(s,1);return}delete r[t[t.length-1]]},Za=(n,e)=>{const t=n.split(".");return e<0?t[t.length+e]:t[e]},Ba=(n,e)=>{try{return Sr(n,e),!0}catch{return!1}},Da=(n,e)=>{if(e.length===0)return!0;const t=n.split("."),r=e.split(".");if(r.length>t.length)return!1;for(let s=0;s<r.length;s++){const i=t[s],a=r[s];if(a!=="*"&&i!==a)return!1}return!0},La=u.bigint().or(u.string().transform(BigInt));var Ua=Object.defineProperty,Pa=(n,e,t)=>e in n?Ua(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,f=(n,e,t)=>Pa(n,typeof e!="symbol"?e+"":e,t);let Wa=(n,e=21)=>(t=e)=>{let r="",s=t|0;for(;s--;)r+=n[Math.random()*n.length|0];return r};const za="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Nr=Wa(za,11),nn=Object.freeze(Object.defineProperty({__proto__:null,id:Nr},Symbol.toStringTag,{value:"Module"})),Va=u.enum(["static","dynamic"]),Ir=(n,e)=>{const t=new E(e);if(![A.DAY,A.HOUR,A.MINUTE,A.SECOND,A.MILLISECOND,A.MICROSECOND,A.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=n.valueOf()%t.valueOf();return n instanceof E?new E(r):new A(r)},I=class v{constructor(e,t="UTC"){if(f(this,"value"),f(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 r=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(r=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,t=1,r=1]){const s=new Date(e,t-1,r,0,0,0,0);return new v(BigInt(s.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[r,s,i]=e.split(":");let a="00",o="00";i!=null&&([a,o]=i.split("."));let c=v.hours(parseInt(r??"00")).add(v.minutes(parseInt(s??"00"))).add(v.seconds(parseInt(a??"00"))).add(v.milliseconds(parseInt(o??"00")));return t==="local"&&(c=c.add(v.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,t);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new v(BigInt(r.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 r=this.toISOString(t);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${t} ${r}`}static get utcOffset(){return new A(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 Sn(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(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.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().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new v(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new v(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new v(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new v(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(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 Ir(this,e)}get isToday(){return this.truncate(A.DAY).equals(v.now().truncate(A.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 r of e){const s=new v(r);s.after(t)&&(t=s)}return t}static min(...e){let t=v.MAX;for(const r of e){const s=new v(r);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new v(e)}static microseconds(e){return v.nanoseconds(e*1e3)}static milliseconds(e){return v.microseconds(e*1e3)}static seconds(e){return v.milliseconds(e*1e3)}static minutes(e){return v.seconds(e*60)}static hours(e){return v.minutes(e*60)}static days(e){return v.hours(e*24)}};f(I,"NANOSECOND",I.nanoseconds(1)),f(I,"MICROSECOND",I.microseconds(1)),f(I,"MILLISECOND",I.milliseconds(1)),f(I,"SECOND",I.seconds(1)),f(I,"MINUTE",I.minutes(1)),f(I,"HOUR",I.hours(1)),f(I,"DAY",I.days(1)),f(I,"MAX",new I((1n<<63n)-1n)),f(I,"MIN",new I(0)),f(I,"ZERO",new I(0)),f(I,"z",u.union([u.object({value:u.bigint()}).transform(n=>new I(n.value)),u.string().transform(n=>new I(BigInt(n))),u.instanceof(Number).transform(n=>new I(n)),u.number().transform(n=>new I(n)),u.instanceof(I)]));let E=I;const k=class T{constructor(e){f(this,"value"),f(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof T?e:e instanceof Bn?e.period:e instanceof E?new T(e):["number","bigint"].includes(typeof e)?T.seconds(e):new T(e)}static fromMilliseconds(e){return e instanceof T?e:e instanceof Bn?e.period:e instanceof E?new T(e):["number","bigint"].includes(typeof e)?T.milliseconds(e):new T(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new T(e).valueOf()}greaterThan(e){return this.valueOf()>new T(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new T(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new T(e).valueOf()}remainder(e){return Ir(this,e)}truncate(e){return new T(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(T.DAY),t=this.truncate(T.HOUR),r=this.truncate(T.MINUTE),s=this.truncate(T.SECOND),i=this.truncate(T.MILLISECOND),a=this.truncate(T.MICROSECOND),o=this.truncate(T.NANOSECOND),c=e,l=t.sub(e),m=r.sub(t),g=s.sub(r),L=i.sub(s),V=a.sub(i),je=o.sub(a);let ae="";return c.isZero||(ae+=`${c.days}d `),l.isZero||(ae+=`${l.hours}h `),m.isZero||(ae+=`${m.minutes}m `),g.isZero||(ae+=`${g.seconds}s `),L.isZero||(ae+=`${L.milliseconds}ms `),V.isZero||(ae+=`${V.microseconds}µs `),je.isZero||(ae+=`${je.nanoseconds}ns`),ae.trim()}mult(e){return new T(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(T.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(T.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(T.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(T.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new T(e).valueOf()}add(e){return new T(this.valueOf()+new T(e).valueOf())}sub(e){return new T(this.valueOf()-new T(e).valueOf())}static nanoseconds(e=1){return new T(e)}static microseconds(e=1){return T.nanoseconds(Ie(e,1e3))}static milliseconds(e=1){return T.microseconds(Ie(e,1e3))}static seconds(e=1){return T.milliseconds(Ie(e,1e3))}static minutes(e=1){return T.seconds(Ie(e,60))}static hours(e){return T.minutes(Ie(e,60))}static days(e){return T.hours(Ie(e,24))}};f(k,"NANOSECOND",k.nanoseconds(1)),f(k,"MICROSECOND",k.microseconds(1)),f(k,"MILLISECOND",k.milliseconds(1)),f(k,"SECOND",k.seconds(1)),f(k,"MINUTE",k.minutes(1)),f(k,"HOUR",k.hours(1)),f(k,"DAY",k.days(1)),f(k,"MAX",new k((1n<<63n)-1n)),f(k,"MIN",new k(0)),f(k,"ZERO",new k(0)),f(k,"z",u.union([u.object({value:u.bigint()}).transform(n=>new k(n.value)),u.string().transform(n=>new k(BigInt(n))),u.instanceof(Number).transform(n=>new k(n)),u.number().transform(n=>new k(n)),u.instanceof(k)]));let A=k;const ze=class xt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new xt(e).valueOf()}get period(){return A.seconds(1/this.valueOf())}sampleCount(e){return new A(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new U(t).valueOf()}span(e){return A.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new xt(e)}static khz(e){return xt.hz(e*1e3)}};f(ze,"z",u.union([u.number().transform(n=>new ze(n)),u.instanceof(Number).transform(n=>new ze(n)),u.instanceof(ze)]));let Bn=ze;const Z=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new rn(e*this.valueOf())}};f(Z,"UNKNOWN",new Z(0)),f(Z,"BIT128",new Z(16)),f(Z,"BIT64",new Z(8)),f(Z,"BIT32",new Z(4)),f(Z,"BIT16",new Z(2)),f(Z,"BIT8",new Z(1)),f(Z,"z",u.union([u.number().transform(n=>new Z(n)),u.instanceof(Number).transform(n=>new Z(n)),u.instanceof(Z)]));let U=Z;const J=class _t{constructor(e,t){f(this,"start"),f(this,"end"),typeof e=="object"&&"start"in e?(this.start=new E(e.start),this.end=new E(e.end)):(this.start=new E(e),this.end=new E(t))}get span(){return new A(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new _t(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=A.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const s=E.max(r.start,e.start),i=E.min(r.end,e.end);return i.before(s)?!1:new A(i.sub(s)).greaterThanOrEqual(t)}roughlyEquals(e,t){let r=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return r<0&&(r=-r),s<0&&(s=-s),r<=t.valueOf()&&s<=t.valueOf()}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}};f(J,"MAX",new J(E.MIN,E.MAX)),f(J,"MIN",new J(E.MAX,E.MIN)),f(J,"ZERO",new J(E.ZERO,E.ZERO)),f(J,"z",u.union([u.object({start:E.z,end:E.z}).transform(n=>new J(n.start,n.end)),u.instanceof(J)]));let Sn=J;const d=class M extends String{constructor(e){if(e instanceof M||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=M.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(M.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=M.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(M.JSON)||this.equals(M.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(M.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=M.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(M.UINT8)||this.equals(M.UINT16)||this.equals(M.UINT32)||this.equals(M.UINT64)}get isSigned(){return this.equals(M.INT8)||this.equals(M.INT16)||this.equals(M.INT32)||this.equals(M.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(M.INT32)&&e.equals(M.FLOAT64)||this.equals(M.INT8)&&e.equals(M.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return M.BIG_INT_TYPES.some(e=>e.equals(this))}};f(d,"UNKNOWN",new d("unknown")),f(d,"FLOAT64",new d("float64")),f(d,"FLOAT32",new d("float32")),f(d,"INT64",new d("int64")),f(d,"INT32",new d("int32")),f(d,"INT16",new d("int16")),f(d,"INT8",new d("int8")),f(d,"UINT64",new d("uint64")),f(d,"UINT32",new d("uint32")),f(d,"UINT16",new d("uint16")),f(d,"UINT8",new d("uint8")),f(d,"BOOLEAN",d.UINT8),f(d,"TIMESTAMP",new d("timestamp")),f(d,"UUID",new d("uuid")),f(d,"STRING",new d("string")),f(d,"JSON",new d("json")),f(d,"ARRAY_CONSTRUCTORS",new Map([[d.UINT8.toString(),Uint8Array],[d.UINT16.toString(),Uint16Array],[d.UINT32.toString(),Uint32Array],[d.UINT64.toString(),BigUint64Array],[d.FLOAT32.toString(),Float32Array],[d.FLOAT64.toString(),Float64Array],[d.INT8.toString(),Int8Array],[d.INT16.toString(),Int16Array],[d.INT32.toString(),Int32Array],[d.INT64.toString(),BigInt64Array],[d.TIMESTAMP.toString(),BigInt64Array],[d.STRING.toString(),Uint8Array],[d.JSON.toString(),Uint8Array],[d.UUID.toString(),Uint8Array]])),f(d,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,d.UINT8],[Uint16Array.name,d.UINT16],[Uint32Array.name,d.UINT32],[BigUint64Array.name,d.UINT64],[Float32Array.name,d.FLOAT32],[Float64Array.name,d.FLOAT64],[Int8Array.name,d.INT8],[Int16Array.name,d.INT16],[Int32Array.name,d.INT32],[BigInt64Array.name,d.INT64]])),f(d,"DENSITIES",new Map([[d.UINT8.toString(),U.BIT8],[d.UINT16.toString(),U.BIT16],[d.UINT32.toString(),U.BIT32],[d.UINT64.toString(),U.BIT64],[d.FLOAT32.toString(),U.BIT32],[d.FLOAT64.toString(),U.BIT64],[d.INT8.toString(),U.BIT8],[d.INT16.toString(),U.BIT16],[d.INT32.toString(),U.BIT32],[d.INT64.toString(),U.BIT64],[d.TIMESTAMP.toString(),U.BIT64],[d.STRING.toString(),U.UNKNOWN],[d.JSON.toString(),U.UNKNOWN],[d.UUID.toString(),U.BIT128]])),f(d,"ALL",[d.UNKNOWN,d.FLOAT64,d.FLOAT32,d.INT64,d.INT32,d.INT16,d.INT8,d.UINT64,d.UINT32,d.UINT16,d.UINT8,d.TIMESTAMP,d.UUID,d.STRING,d.JSON]),f(d,"BIG_INT_TYPES",[d.INT64,d.UINT64,d.TIMESTAMP]),f(d,"z",u.union([u.string().transform(n=>new d(n)),u.instanceof(d)]));let N=d;const B=class j extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return j.bytes(this.valueOf()+e.valueOf())}sub(e){return j.bytes(this.valueOf()-e.valueOf())}truncate(e){return new j(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return j.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/j.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/j.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/j.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/j.TERABYTE.valueOf()}toString(){const e=this.truncate(j.TERABYTE),t=this.truncate(j.GIGABYTE),r=this.truncate(j.MEGABYTE),s=this.truncate(j.KILOBYTE),i=this.truncate(j.BYTE),a=e,o=t.sub(e),c=r.sub(t),l=s.sub(r),m=i.sub(s);let g="";return a.isZero||(g+=`${a.terabytes}TB `),o.isZero||(g+=`${o.gigabytes}GB `),c.isZero||(g+=`${c.megabytes}MB `),l.isZero||(g+=`${l.kilobytes}KB `),(!m.isZero||g==="")&&(g+=`${m.valueOf()}B`),g.trim()}static bytes(e=1){return new j(e)}static kilobytes(e=1){return j.bytes(e.valueOf()*1e3)}static megabytes(e=1){return j.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return j.megabytes(e.valueOf()*1e3)}static terabytes(e){return j.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};f(B,"BYTE",new B(1)),f(B,"KILOBYTE",B.kilobytes(1)),f(B,"MEGABYTE",B.megabytes(1)),f(B,"GIGABYTE",B.gigabytes(1)),f(B,"TERABYTE",B.terabytes(1)),f(B,"ZERO",new B(0)),f(B,"z",u.union([u.number().transform(n=>new B(n)),u.instanceof(B)]));let rn=B;u.union([u.instanceof(Uint8Array),u.instanceof(Uint16Array),u.instanceof(Uint32Array),u.instanceof(BigUint64Array),u.instanceof(Float32Array),u.instanceof(Float64Array),u.instanceof(Int8Array),u.instanceof(Int16Array),u.instanceof(Int32Array),u.instanceof(BigInt64Array)]);const kr=n=>{const e=typeof n;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||n instanceof E||n instanceof A||n instanceof Date},qa=(n,e,t,r=0)=>n.usesBigInt&&!e.usesBigInt?Number(t)-Number(r):!n.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(r.valueOf()):qe(t,-r).valueOf(),Fa=n=>n==null?!1:Array.isArray(n)||n instanceof ArrayBuffer||ArrayBuffer.isView(n)&&!(n instanceof DataView)||n instanceof Ja?!0:kr(n),oe=-1,Ya=u.string().transform(n=>new Uint8Array(atob(n).split("").map(e=>e.charCodeAt(0))).buffer),Ga=u.union([u.null(),u.undefined()]).transform(()=>new Uint8Array().buffer),sn=10,Ve=class H{constructor(e){f(this,"key",""),f(this,"isSynnaxSeries",!0),f(this,"dataType"),f(this,"sampleOffset"),f(this,"gl"),f(this,"_data"),f(this,"_timeRange"),f(this,"alignment",0n),f(this,"_cachedMin"),f(this,"_cachedMax"),f(this,"writePos",oe),f(this,"_refCount",0),f(this,"_cachedLength"),f(this,"_cachedIndexes"),Fa(e)&&(e={data:e});const{dataType:t,timeRange:r,sampleOffset:s=0,glBufferUsage:i="static",alignment:a=0n,key:o=Nr()}=e,c=e.data??[];if(c instanceof H||typeof c=="object"&&"isSynnaxSeries"in c&&c.isSynnaxSeries===!0){const g=c;this.key=g.key,this.dataType=g.dataType,this.sampleOffset=g.sampleOffset,this.gl=g.gl,this._data=g._data,this._timeRange=g._timeRange,this.alignment=g.alignment,this._cachedMin=g._cachedMin,this._cachedMax=g._cachedMax,this.writePos=g.writePos,this._refCount=g._refCount,this._cachedLength=g._cachedLength;return}const l=kr(c),m=Array.isArray(c);if(t!=null)this.dataType=new N(t);else{if(c instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(m||l){let g=c;if(!l){if(c.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");g=c[0]}if(typeof g=="string")this.dataType=N.STRING;else if(typeof g=="number")this.dataType=N.FLOAT64;else if(typeof g=="bigint")this.dataType=N.INT64;else if(typeof g=="boolean")this.dataType=N.BOOLEAN;else if(g instanceof E||g instanceof Date||g instanceof E)this.dataType=N.TIMESTAMP;else if(typeof g=="object")this.dataType=N.JSON;else throw new Error(`cannot infer data type of ${typeof g} when constructing a Series from a JS array`)}else this.dataType=new N(c)}if(!m&&!l)this._data=c;else{let g=l?[c]:c;const L=g[0];(L instanceof E||L instanceof Date||L instanceof A)&&(g=g.map(V=>new E(V).valueOf())),this.dataType.equals(N.STRING)?(this._cachedLength=g.length,this._data=new TextEncoder().encode(`${g.join(`
4
+ `)}
5
+ `).buffer):this.dataType.equals(N.JSON)?(this._cachedLength=g.length,this._data=new TextEncoder().encode(`${g.map(V=>yt.encodeString(V)).join(`
6
+ `)}
7
+ `).buffer):this._data=new this.dataType.Array(g).buffer}this.key=o,this.alignment=a,this.sampleOffset=s??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:t,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new N(t).Array(e),i=new H({data:s.buffer,dataType:t,...r});return i.writePos=0,i}static generateTimestamps(e,t,r){const s=r.spanRange(t.span(e)),i=new BigInt64Array(e);for(let a=0;a<e;a++)i[a]=BigInt(r.add(t.span(a)).valueOf());return new H({data:i,dataType:N.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const r=new TextEncoder().encode(`${e.join(`
8
+ `)}
9
+ `);return new H({data:r,dataType:N.STRING,timeRange:t})}static fromJSON(e,t){const r=new TextEncoder().encode(`${e.map(s=>yt.encodeString(s)).join(`
10
+ `)}
11
+ `);return new H({data:r,dataType:N.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===oe)return 0;const t=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,t);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===oe)return 0;const t=this.capacity-this.writePos,r=e.sub(0,t);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===oe?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(`
12
+ `).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 r=0;r<this.length;r++){const s=this.underlyingData.slice(r*e,(r+1)*e),i=Array.from(new Uint8Array(s.buffer),a=>a.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[r]=i}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(`
13
+ `).slice(0,-1).map(t=>e.parse(yt.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new rn(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===oe?this.byteCapacity:this.dataType.isVariable?new rn(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===oe?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((r,s)=>{r===sn&&(e++,t.push(s+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let s=0;s<this.length;s++)r[s]=qa(this.dataType,e,this.data[s],t);return new H({data:r.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,r)=>t>r?t:r)}else{const e=this.data;this._cachedMax=e.reduce((t,r)=>t>r?t:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),qe(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,r)=>t<r?t:r)}else{const e=this.data;this._cachedMin=e.reduce((t,r)=>t<r?t:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),qe(this._cachedMin,this.sampleOffset))}get bounds(){return be(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 qe(this.max,-this.min)}atAlignment(e,t){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return qe(r,this.sampleOffset)}atVariable(e,t){let r=0,s=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let a=0;a<this.data.length;a++)if(this.data[a]===sn){if(e===0){s=a;break}r=a+1,e--}if(s===0&&(s=this.data.length),r>=s||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(r,s);return this.dataType.equals(N.STRING)?new TextDecoder().decode(i):Gn(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,r=this.length-1;const s=ai(e);for(;t<=r;){const i=Math.floor((t+r)/2),a=s(this.at(i,!0),e);if(a===0)return i;a<0?t=i+1:r=i-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:r,prevBuffer:s}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==oe){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),a=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,a.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=oe}as(e){if(e==="string"){if(!this.dataType.equals(N.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(N.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:zn(this.alignmentBounds.lower),upper:zn(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 be(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 Ha(this);return this.dataType.equals(N.JSON)?new Xa(e):e}return new Ka(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Dn(this,e,t??this.length)}subAlignmentIterator(e,t){return new Dn(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,t);return new H({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,r){if(t<=0&&(r==null||r>=this.length))return this;let s;return e?s=this.data.subarray(t,r):s=this.data.slice(t,r),new H({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new H({data:this.buffer,dataType:this.dataType,timeRange:Sn.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};f(Ve,"crudeZ",u.object({timeRange:Sn.z.optional(),dataType:N.z,alignment:La.optional(),data:u.union([Ya,Ga,u.instanceof(ArrayBuffer),u.instanceof(Uint8Array)]),glBufferUsage:Va.optional().default("static").optional()})),f(Ve,"z",Ve.crudeZ.transform(n=>new Ve(n)));let Ja=Ve;class Dn{constructor(e,t,r){f(this,"series"),f(this,"end"),f(this,"index"),this.series=e;const s=be(0,e.length);this.end=Mn(s,r),this.index=Mn(s,t)}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 Ha{constructor(e){if(f(this,"series"),f(this,"index"),f(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]!==sn;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var Ln,Un;class Xa{constructor(e){f(this,"wrapped"),f(this,Ln,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:yt.decodeString(e.value)}}[(Un=Symbol.iterator,Ln=Symbol.toStringTag,Un)](){return this}}var Pn,Wn;class Ka{constructor(e){f(this,"series"),f(this,"index"),f(this,Pn,"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)}}[(Wn=Symbol.iterator,Pn=Symbol.toStringTag,Wn)](){return this}}const qe=(n,e)=>typeof n=="bigint"&&typeof e=="bigint"||typeof n=="number"&&typeof e=="number"?n+e:e===0?n:n===0?e:Number(n)+Number(e),zn=n=>{const e=n>>32n,t=n&0xffffffffn;return{domain:e,sample:t}},Qa=n=>JSON.parse(JSON.stringify(n)),eo=(n,...e)=>(e.forEach(t=>{let r=n;const s=t.split(".");s.forEach((i,a)=>{a===s.length-1?delete r[i]:i in r&&(r=r[i])})}),n),to=(n,e,t="")=>{const r={},s=(i,a,o)=>{if(typeof i!=typeof a||i===null||a===null){r[o]=[i,a];return}if(typeof i=="object"&&typeof a=="object")if(Array.isArray(i)&&Array.isArray(a)){if(i.length!==a.length){r[o]=[i,a];return}for(let c=0;c<i.length;c++)s(i[c],a[c],`${o}[${c}]`)}else new Set([...Object.keys(i),...Object.keys(a)]).forEach(c=>{s(i[c],a[c],o!==""?`${o}.${c}`:c)});else i!==a&&(r[o]=[i,a])};return s(n,e,t),r},an=(n,e)=>{const t=Array.isArray(n),r=Array.isArray(e);if(t!==r)return!1;if(t&&r){const a=n,o=e;if(a.length!==o.length)return!1;for(let c=0;c<a.length;c++)if(!an(a[c],o[c]))return!1;return!0}if(n==null||e==null||typeof n!="object"||typeof e!="object")return n===e;if("equals"in n)return n.equals(e);const s=Object.keys(n),i=Object.keys(e);if(s.length!==i.length)return!1;for(const a of s){const o=n[a],c=e[a];if(typeof o=="object"&&typeof c=="object"){if(!an(o,c))return!1}else if(o!==c)return!1}return!0},Ar=(n,e)=>{if(typeof n!="object"||n==null)return n===e;const t=Object.keys(n),r=Object.keys(e);if(r.length>t.length)return!1;for(const s of r){const i=n[s],a=e[s];if(typeof i=="object"&&typeof a=="object"){if(!Ar(i,a))return!1}else if(i!==a)return!1}return!0},on=(n,...e)=>{if(e.length===0)return n;const t=e.shift();if(Ge(n)&&Ge(t))for(const r in t)try{Ge(t[r])?(r in n||Object.assign(n,{[r]:{}}),on(n[r],t[r])):Object.assign(n,{[r]:t[r]})}catch(s){throw s instanceof TypeError?new TypeError(`.${r}: ${s.message}`):s}return on(n,...e)},no=(n,e,t)=>{const r=(s,i,a)=>{for(const o in i){const c=i[o];if(a!=null&&a.shape[o]){const l=a.shape[o].safeParse(c);l.success&&(s[o]=l.data)}else typeof c=="object"&&!Array.isArray(c)&&c!==null&&a&&a.shape&&a.shape[o]&&(s[o]||(s[o]={}),r(s[o],c,a.shape[o]))}return s};return r({...n},e,t)},Nn=Object.freeze(Object.defineProperty({__proto__:null,copy:Qa,deleteD:eo,difference:to,element:Za,equal:an,get:Sr,has:Ba,override:on,overrideValidItems:no,partialEqual:Ar,pathsMatch:Da,remove:ja,set:Ma,transformPath:Ra},Symbol.toStringTag,{value:"Module"}));u.object({key:u.string(),value:u.string()});u.record(u.union([u.number(),u.string(),u.symbol()]),u.unknown());const Er=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",ro=Er(),$r=["MacOS","Windows","Linux","Docker"],so=["macos","windows","linux","docker"],io={macos:"MacOS",windows:"Windows",linux:"Linux",docker:"Docker"},ao=u.enum($r).or(u.enum(so).transform(n=>io[n]));let Vt;const oo=()=>{if(typeof window>"u")return;const n=window.navigator.userAgent.toLowerCase();if(n.includes("mac"))return"MacOS";if(n.includes("win"))return"Windows";if(n.includes("linux"))return"Linux"},uo=(n={})=>{const{force:e,default:t}=n;return e??Vt??(Vt=oo(),Vt??t)},co=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:$r,RUNTIME:ro,detect:Er,getOS:uo,osZ:ao},Symbol.toStringTag,{value:"Module"}));var lo=Object.defineProperty,fo=(n,e,t)=>e in n?lo(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Fe=(n,e,t)=>fo(n,typeof e!="symbol"?e+"":e,t);const ho=(...n)=>n.map(Cr).join(""),Cr=n=>(n.endsWith("/")||(n+="/"),n.startsWith("/")&&(n=n.slice(1)),n),po=n=>n.endsWith("/")?n.slice(0,-1):n,Vn=class un{constructor({host:e,port:t,protocol:r="",pathPrefix:s=""}){Fe(this,"protocol"),Fe(this,"host"),Fe(this,"port"),Fe(this,"path"),this.protocol=r,this.host=e,this.port=t,this.path=Cr(s)}replace(e){return new un({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new un({...this,pathPrefix:ho(this.path,e)})}toString(){return po(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Fe(Vn,"UNKNOWN",new Vn({host:"unknown",port:0}));var mo=Object.defineProperty,yo=(n,e,t)=>e in n?mo(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Tt=(n,e,t)=>yo(n,typeof e!="symbol"?e+"":e,t);u.object({interval:A.z.optional(),maxRetries:u.number().optional(),scale:u.number().optional()});const ke=class extends Number{};Tt(ke,"Absolute",255),Tt(ke,"Default",1),Tt(ke,"z",u.union([u.instanceof(ke),u.number().int().min(0).max(255).transform(n=>new ke(n)),u.instanceof(Number).transform(n=>new ke(n))]));u.object({name:u.string(),key:u.string()});const Rr=class Ye extends Error{constructor(){super(Ye.MESSAGE)}matches(e){return typeof e=="string"?e.includes(Ye.MESSAGE):e instanceof Ye||e.message.includes(Ye.MESSAGE)}};Tt(Rr,"MESSAGE","canceled");let go=Rr;new go;u.string().regex(/^\d+\.\d+\.\d+$/);const we="main",In="prerender",Ut={stage:"creating",processCount:0,reserved:!1,focusCount:0,centerCount:0},Mr={...Ut,key:In,visible:!1},wo=u.object({key:u.string(),url:u.string().optional(),title:u.string().optional(),center:u.boolean().optional(),position:Ct.xy.optional(),size:bt.dimensions.optional(),minSize:bt.dimensions.optional(),maxSize:bt.dimensions.optional(),resizable:u.boolean().optional(),fullscreen:u.boolean().optional(),focus:u.boolean().optional(),maximized:u.boolean().optional(),visible:u.boolean().optional(),minimized:u.boolean().optional(),decorations:u.boolean().optional(),skipTaskbar:u.boolean().optional(),fileDropEnabled:u.boolean().optional(),transparent:u.boolean().optional(),alwaysOnTop:u.boolean().optional()}),vo=A.milliseconds(50),jr=()=>setTimeout(()=>window.location.reload(),vo.milliseconds),Zr={label:we,config:{enablePrerender:!0,debug:!1,defaultWindowProps:{}},windows:{main:{...Ut,key:we,reserved:!0}},labelKeys:{main:we},keyLabels:{main:we}},bo=(n,e)=>{if(n.type===Dr.type)return e.label!==we||(n.payload.label=nn.id(),n.payload.prerenderLabel=nn.id()),n;if("label"in n.payload)return n;let t=e.label;const r=n.payload;return r.key!=null&&(r.key in e.windows?t=r.key:t=e.keyLabels[r.key]),n.payload={...n.payload,label:t},n},z=n=>(e,t)=>{if(!("label"in t.payload))throw new Error("Missing label");n(e,t)},ge=(n,e=!1)=>z((t,r)=>{let s=e;const i=t.windows[r.payload.label];if(i!=null){if(r.payload.value!=null)s=r.payload.value;else{const a=i[n];a!=null&&(s=!a)}t.windows[r.payload.label]={...i,[n]:s}}}),Pt=(n,e=!1)=>(t,r)=>{const s=t.windows[r.payload.label];s!=null&&(t.windows[r.payload.label]={...s,[n]:s[n]+(e?-1:1)})},xo=n=>Object.values(n.windows).some(e=>e.key===In&&!e.reserved),kn="drift",_o=(n,e,t)=>n.position!=null&&n.size!=null&&e==null?Pe.topLeft(Pe.positionInCenter(Pe.construct(Ct.ZERO,t??Ct.ZERO),Pe.construct(n.position,n.size))):e,To=(n,{payload:e})=>{if(e.key===In)return;const{key:t,label:r,prerenderLabel:s}=e;if(r==null||s==null)throw new Error("[drift] - bug - missing label and prerender label");console.log(n.config.debug),Fn(n.config.debug,"reducer create window");const i=n.windows.main;if(e.position=_o(i,e.position,e.size),t in n.keyLabels){Ze(n.config.debug,"window already exists, un-minimize and focus it");const c=n.keyLabels[e.key];n.windows[c].visible=!0,n.windows[c].focusCount+=1,n.windows[c].minimized=!1,n.windows[c].position=e.position,qt(n.config.debug);return}const[a,o]=Object.entries(n.windows).find(([,c])=>!c.reserved)??[null,null];a!=null?(Ze(n.config.debug,"using available pre-rendered window"),n.windows[a]={...o,visible:!0,reserved:!0,focusCount:1,focus:!0,...e},n.labelKeys[a]=e.key,n.keyLabels[e.key]=a):(Ze(n.config.debug,"creating new window"),n.windows[r]={...n.config.defaultWindowProps,...Ut,...e,reserved:!0},n.labelKeys[r]=t,n.keyLabels[t]=r),n.config.enablePrerender&&!xo(n)&&(Ze(n.config.debug,"creating pre-render window"),n.windows[s]=Nn.copy({...n.config.defaultWindowProps,...Mr})),qt(n.config.debug)},Oo=z((n,e)=>{const t=n.windows[e.payload.label];t!=null&&(t.stage=e.payload.stage)}),So=z((n,{payload:{label:e}})=>{const t=n.windows[e];t==null||t.processCount>0||(t.stage="closing",delete n.windows[e],delete n.labelKeys[e],delete n.keyLabels[t.key])}),No=z((n,e)=>{const t=n.windows[e.payload.label];t==null||t.processCount>0||(t.stage="reloading",jr())}),Io=z(Pt("processCount")),ko=z((n,e)=>{Pt("processCount",!0)(n,e);const t=n.windows[e.payload.label];t!=null&&t.processCount===0&&(t.stage==="reloading"?jr():(n.windows[e.payload.label].visible=!1,delete n.windows[e.payload.label],delete n.labelKeys[e.payload.label],delete n.keyLabels[t.key]))}),Ao=(n,e)=>{const t=n.windows[e.payload.key];t!=null&&(t.error=e.payload.message)},Eo=z((n,e)=>{const t=n.windows[e.payload.label];t!=null&&(t.visible!==!0&&(t.visible=!0),Pt("focusCount")(n,e))}),$o=ge("minimized"),Co=ge("maximized"),Ro=ge("visible",!0),Mo=ge("fullscreen",!0),jo=z(Pt("centerCount")),Zo=z((n,e)=>{n.windows[e.payload.label].position=e.payload.position}),Bo=z((n,e)=>{n.windows[e.payload.label].size=e.payload.size}),Do=z((n,e)=>{n.windows[e.payload.label].minSize=e.payload.size}),Lo=z((n,e)=>{n.windows[e.payload.label].maxSize=e.payload.size}),Uo=ge("resizable"),Po=ge("skipTaskbar"),Wo=ge("alwaysOnTop"),zo=z((n,e)=>{n.windows[e.payload.label].title=e.payload.title}),Vo=ge("decorations"),qn=(n,e)=>{const t=n.windows[e.payload.label];Nn.partialEqual(t,e.payload)||(n.windows[e.payload.label]={...t,...e.payload})},qo=(n,e)=>{if(n.config={...n.config,...e.payload},n.label=e.payload.label,n.label===we&&n.config.enablePrerender){const t=nn.id();n.windows[t]={...n.config.defaultWindowProps,...Mr}}},Br=Ur.createSlice({name:kn,initialState:Zr,reducers:{internalSetInitial:qo,createWindow:To,setWindowStage:Oo,closeWindow:So,registerProcess:Io,completeProcess:ko,setWindowError:Ao,focusWindow:Eo,reloadWindow:No,setWindowMinimized:$o,setWindowMaximized:Co,setWindowVisible:Ro,setWindowFullscreen:Mo,centerWindow:jo,setWindowPosition:Zo,setWindowSize:Bo,setWindowMinSize:Do,setWindowMaxSize:Lo,setWindowResizable:Uo,setWindowSkipTaskbar:Po,setWindowAlwaysOnTop:Wo,setWindowTitle:zo,setWindowDecorations:Vo,runtimeSetWindowProps:qn,setWindowProps:qn}}),{actions:{runtimeSetWindowProps:Fo,setWindowProps:Yo,createWindow:Dr,internalSetInitial:Lr,setWindowStage:Go,closeWindow:Jo,registerProcess:Ho,completeProcess:Xo,setWindowError:Ko,focusWindow:Qo,reloadWindow:eu,setWindowMinimized:tu,setWindowMaximized:nu,setWindowVisible:ru,setWindowFullscreen:su,centerWindow:Tu,setWindowPosition:iu,setWindowSize:au,setWindowMinSize:ou,setWindowMaxSize:uu,setWindowResizable:cu,setWindowSkipTaskbar:lu,setWindowAlwaysOnTop:du,setWindowTitle:fu,setWindowDecorations:hu}}=Br,pu=Br.reducer,mu=n=>n.startsWith(kn),yu=[Lr.type],gu=(n,e)=>!n&&!yu.includes(e);exports.G=Ct;exports.INITIAL_WINDOW_STATE=Ut;exports.MAIN_WINDOW=we;exports.Mt=Pe;exports.S=co;exports.SLICE_NAME=kn;exports.ZERO_SLICE_STATE=Zr;exports._=bt;exports._$1=Nn;exports.assignLabel=bo;exports.closeWindow=Jo;exports.completeProcess=Xo;exports.createWindow=Dr;exports.focusWindow=Qo;exports.group=Fn;exports.groupEnd=qt;exports.internalSetInitial=Lr;exports.isDriftAction=mu;exports.log=Ze;exports.reducer=pu;exports.registerProcess=Ho;exports.reloadWindow=eu;exports.runtimeSetWindowProps=Fo;exports.setWindowAlwaysOnTop=du;exports.setWindowDecorations=hu;exports.setWindowError=Ko;exports.setWindowFullscreen=su;exports.setWindowMaxSize=uu;exports.setWindowMaximized=nu;exports.setWindowMinSize=ou;exports.setWindowMinimized=tu;exports.setWindowPosition=iu;exports.setWindowProps=Yo;exports.setWindowResizable=cu;exports.setWindowSize=au;exports.setWindowSkipTaskbar=lu;exports.setWindowStage=Go;exports.setWindowTitle=fu;exports.setWindowVisible=ru;exports.shouldEmit=gu;exports.w=A;exports.windowPropsZ=wo;