@expresscsv/sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,205 @@
1
+ # ExpressCSV Importer
2
+
3
+ A TypeScript SDK for integrating the ExpressCSV widget into your web application.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Using pnpm
9
+ pnpm add @expresscsv/sdk
10
+
11
+ # Using npm
12
+ npm install @expresscsv/sdk
13
+
14
+ # Using yarn
15
+ yarn add @expresscsv/sdk
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### Basic Usage
21
+
22
+ ```typescript
23
+ import { CSVImporter } from "@expresscsv/sdk";
24
+
25
+ // Initialize the importer
26
+ const importer = new CSVImporter({
27
+ title: "CSV Import",
28
+ });
29
+
30
+ // Open the widget
31
+ await importer.open();
32
+
33
+ // Send a message to the widget
34
+ await importer.sendMessage({
35
+ type: "example",
36
+ payload: {
37
+ /* your data */
38
+ },
39
+ });
40
+
41
+ // Clean up when done
42
+ importer.close();
43
+ ```
44
+
45
+ ### Field Schema Validation
46
+
47
+ ExpressCSV SDK provides a Zod-like schema validation system for CSV imports. This allows you to define the expected structure of your CSV data and receive type-safe results.
48
+
49
+ ```typescript
50
+ import { CSVImporter, x } from "@expresscsv/sdk";
51
+
52
+ // Define your schema
53
+ const schema = x.row({
54
+ name: x.string().humanLabel("Full Name"),
55
+ email: x.email().humanLabel("Email Address"),
56
+ age: x.number().humanLabel("Age").min(18).max(100),
57
+ role: x.select(["admin", "user", "guest"]).humanLabel("User Role")
58
+ });
59
+
60
+ // Initialize with schema and results handler
61
+ const importer = new CSVImporter({
62
+ title: "User Import",
63
+ fields: schema,
64
+ onResults: (data) => {
65
+ // data is fully typed based on your schema
66
+ console.log(`Imported ${data.length} users`);
67
+
68
+ // Access properties with full type safety
69
+ data.forEach(user => {
70
+ console.log(`Name: ${user.name}, Email: ${user.email}`);
71
+ if (user.age) {
72
+ console.log(`Age: ${user.age + 1}`); // Numbers are typed correctly
73
+ }
74
+ });
75
+ }
76
+ });
77
+
78
+ // Or set the handler separately
79
+ importer.onResults = (data) => {
80
+ // Process the validated data
81
+ processUsers(data);
82
+ };
83
+
84
+ // Open the widget
85
+ await importer.open();
86
+ ```
87
+
88
+ ### Preload for Instant Display
89
+
90
+ By default, the SDK preloads the widget in the background for instant display when opened. This provides the best user experience with minimal perceived loading time.
91
+
92
+ ```typescript
93
+ import { CSVImporter, x } from "@expresscsv/sdk";
94
+
95
+ const schema = x.row({
96
+ name: x.string().humanLabel("Full Name"),
97
+ email: x.email().humanLabel("Email Address"),
98
+ });
99
+
100
+ // Preload is enabled by default - widget loads in background
101
+ const importer = new CSVImporter({
102
+ schema,
103
+ importIdentifier: "user-import",
104
+ title: "User Import",
105
+ });
106
+
107
+ // Later, when user clicks import button, widget displays instantly
108
+ await importer.open();
109
+ ```
110
+
111
+ To disable preload (not recommended for most use cases):
112
+
113
+ ```typescript
114
+ const importer = new CSVImporter({
115
+ schema,
116
+ importIdentifier: "user-import",
117
+ title: "User Import",
118
+ preload: false, // Opt-out of preload
119
+ });
120
+ ```
121
+
122
+ ## API Reference
123
+
124
+ ### Constructor Options
125
+
126
+ | Option | Type | Required | Default | Description |
127
+ |------------------|------------------------|----------|---------|--------------------------------------------|
128
+ | schema | ExType | Yes | - | Schema definition for CSV field validation |
129
+ | importIdentifier | string | Yes | - | Unique identifier for this import |
130
+ | title | string | No | - | Title to display in the widget |
131
+ | publishableKey | string | Yes | - | Publishable key for webhook authentication |
132
+ | debug | boolean | No | false | Enable debug logging |
133
+ | developerMode | boolean | No | false | Enable developer mode features |
134
+ | preload | boolean | No | true | Preload widget in background for instant display. Set to `false` to disable |
135
+
136
+ ### Methods
137
+
138
+ #### `open(): Promise<void>`
139
+
140
+ Opens the ExpressCSV widget as a modal and establishes communication using iframe-comm.
141
+
142
+ #### `sendMessage(message: Message): Promise<void>`
143
+
144
+ Sends a message to the ExpressCSV widget.
145
+
146
+ #### `close(): void`
147
+
148
+ Closes the widget and cleans up resources.
149
+
150
+ #### `getConnectionStatus(): boolean`
151
+
152
+ Returns whether the widget is currently connected.
153
+
154
+ #### `getVersion(): string`
155
+
156
+ Returns the current version of the SDK.
157
+
158
+ ### Event Handlers
159
+
160
+ | Handler | Type | Description |
161
+ |--------------|----------------------|------------------------------------------------|
162
+ | onConnected | () => void | Called when connection is established |
163
+ | onError | (error: Error) => void | Called when an error occurs |
164
+ | onClose | () => void | Called when the widget is closed |
165
+ | onResults | (data: T[]) => void | Called with schema-validated CSV data |
166
+
167
+ ### Schema Builder API
168
+
169
+ The SDK exports a Zod-like API for defining field validation schemas:
170
+
171
+ #### Field Types
172
+
173
+ - `x.string()` - String fields
174
+ - `x.number()` - Number fields
175
+ - `x.email()` - Email fields
176
+ - `x.select(['option1', 'option2'])` - Dropdown selection fields
177
+
178
+ #### Field Modifiers
179
+
180
+ - `.humanLabel(string)` - Sets a user-friendly label for the field
181
+ - `.required(boolean)` - Marks a field as required
182
+ - `.minLength(number)` - Sets minimum length for string fields
183
+ - `.maxLength(number)` - Sets maximum length for string fields
184
+ - `.min(number)` - Sets minimum value for number fields
185
+ - `.max(number)` - Sets maximum value for number fields
186
+
187
+ ## Development
188
+
189
+ ```bash
190
+ # Install dependencies
191
+ pnpm install
192
+
193
+ # Start development mode
194
+ pnpm dev
195
+
196
+ # Build the package
197
+ pnpm build
198
+
199
+ # Run linting
200
+ pnpm lint
201
+ ```
202
+
203
+ ## License
204
+
205
+ ISC
@@ -0,0 +1,214 @@
1
+ import { ExType, ExRow, ExRowShape, Infer } from '@expresscsv/fields';
2
+ export { ExType, Infer, x } from '@expresscsv/fields';
3
+ import { WidgetState, WidgetMode } from '@expresscsv/iframe-comm';
4
+ export { WidgetMode, WidgetState } from '@expresscsv/iframe-comm';
5
+ import { ExBaseDef } from '@expresscsv/fields/src/types';
6
+ export { ExBaseDef } from '@expresscsv/fields/src/types';
7
+ import { ECSVTheme, ColorModeConfig, ECSVFontSource } from '@expresscsv/theme';
8
+ export { ColorModeConfig, ColorModePref, ECSVFontSource, ECSVTheme, TailwindThemeVars } from '@expresscsv/theme';
9
+ import { TemplateDownloadConfig, DeepPartial, ExpressCSVLocaleInput, ExpressCSVStep } from '@expresscsv/core';
10
+ export { DeepPartial, ExpressCSVLocaleInput, ExpressCSVStep } from '@expresscsv/core';
11
+
12
+ /**
13
+ * Error thrown when the user cancels the import operation
14
+ */
15
+ declare class ImportCancelledError extends Error {
16
+ constructor(message?: string);
17
+ }
18
+
19
+ /**
20
+ * A chunk of records passed to the onData callback
21
+ */
22
+ interface RecordsChunk<T> {
23
+ /** The records in this chunk */
24
+ records: T[];
25
+ /** Total number of chunks */
26
+ totalChunks: number;
27
+ /** Current chunk index (0-based) */
28
+ currentChunkIndex: number;
29
+ /** Total number of records across all chunks */
30
+ totalRecords: number;
31
+ }
32
+ /**
33
+ * Webhook configuration for remote delivery of results
34
+ */
35
+ interface WebhookConfig {
36
+ /** The URL to send webhook requests to */
37
+ url: string;
38
+ /** Optional HTTP headers to include in the request */
39
+ headers?: Record<string, string>;
40
+ /** HTTP method to use (default: 'POST') */
41
+ method?: 'POST' | 'PUT' | 'PATCH';
42
+ /** Request timeout in milliseconds (default: 30000) */
43
+ timeout?: number;
44
+ /** Number of retry attempts on failure (default: 0) */
45
+ retries?: number;
46
+ /** Arbitrary developer-provided metadata */
47
+ metadata?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * Type helper that requires at least one of the specified keys to be present
51
+ */
52
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
53
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
54
+ }[Keys];
55
+ /**
56
+ * Base delivery options - at least one must be provided
57
+ */
58
+ interface DeliveryOptionsBase<T> {
59
+ /** Local callback for processing chunks */
60
+ onData?: (chunk: RecordsChunk<T>, next: () => void) => void | Promise<void>;
61
+ /** Webhook configuration for remote delivery */
62
+ webhook?: WebhookConfig;
63
+ }
64
+ /**
65
+ * Delivery options - requires at least one of onData or webhook
66
+ */
67
+ type DeliveryOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'>;
68
+ /**
69
+ * Options for the open() method
70
+ * Requires at least one of onData or webhook for delivery
71
+ */
72
+ type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'> & {
73
+ /** Number of records per chunk (default: 1000) */
74
+ chunkSize?: number;
75
+ /** Called when all chunks have been processed */
76
+ onComplete?: () => void;
77
+ /** Called when the user cancels the import */
78
+ onCancel?: () => void;
79
+ /** Called when an error occurs */
80
+ onError?: (error: Error) => void;
81
+ /** Called when the widget opens */
82
+ onWidgetOpen?: () => void;
83
+ /** Called when the step changes in the wizard */
84
+ onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
85
+ /** Called when the widget closes */
86
+ onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
87
+ };
88
+ type InferCSVImporter<TSchema extends ExType<unknown, ExBaseDef, unknown>> = CSVImporter<TSchema>;
89
+
90
+ interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
91
+ schema: TSchema;
92
+ publishableKey: string;
93
+ importIdentifier: string;
94
+ title?: string;
95
+ debug?: boolean;
96
+ developerMode?: boolean;
97
+ preload?: boolean;
98
+ theme?: ECSVTheme;
99
+ colorMode?: ColorModeConfig;
100
+ customCSS?: string;
101
+ fonts?: Record<string, ECSVFontSource>;
102
+ stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
103
+ previewSchemaBeforeUpload?: boolean;
104
+ templateDownload?: TemplateDownloadConfig;
105
+ saveSession?: boolean;
106
+ locale?: DeepPartial<ExpressCSVLocaleInput>;
107
+ }
108
+ declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unknown> = ExRow<ExRowShape>> {
109
+ private options;
110
+ private iframe;
111
+ private container;
112
+ private connection;
113
+ private connectionState;
114
+ private debug;
115
+ private developerMode;
116
+ private importIdentifier;
117
+ private sessionId;
118
+ private _destroyTimer;
119
+ private _beforeUnloadHandler;
120
+ private widgetUrl;
121
+ private widgetState;
122
+ private widgetMode;
123
+ private canRestart;
124
+ private lastError;
125
+ private openOptions;
126
+ private cachedSchemaJson;
127
+ private initCompletePromise;
128
+ private resolveInitComplete;
129
+ constructor(options: SDKOptions<TSchema>);
130
+ /**
131
+ * Enhanced state management
132
+ */
133
+ private setState;
134
+ private updateDerivedState;
135
+ private handleError;
136
+ private waitForEvent;
137
+ /**
138
+ * Open the import flow with chunk-based data processing.
139
+ * Automatically opens the widget if not already open.
140
+ *
141
+ * @param options Configuration including onData callback for processing chunks
142
+ */
143
+ open(options: OpenOptions<Infer<TSchema>>): void;
144
+ /**
145
+ * Create import session on backend with configuration
146
+ * Idempotent: safe to call multiple times with same sessionId
147
+ */
148
+ private createImportSession;
149
+ /**
150
+ * Deliver results to webhook endpoint via backend API
151
+ * Chunks data using SDK-determined chunk size (independent of customer's chunkSize)
152
+ */
153
+ private deliverToWebhook;
154
+ /**
155
+ * Send a single chunk to backend webhook API with retry logic
156
+ */
157
+ private sendChunkToBackend;
158
+ /**
159
+ * Process results in chunks, calling onData and/or webhook for each chunk with backpressure control
160
+ */
161
+ private processResultsInChunks;
162
+ /**
163
+ * Initialize the iframe and connection.
164
+ * @param hidden Whether to create the iframe hidden (for preload) or visible (for normal open)
165
+ */
166
+ private initializeIframe;
167
+ private log;
168
+ private error;
169
+ /**
170
+ * Add beforeunload event listener to warn users about losing progress
171
+ */
172
+ private addBeforeUnloadListener;
173
+ /**
174
+ * Remove beforeunload event listener
175
+ */
176
+ private removeBeforeUnloadListener;
177
+ private waitForIframeLoad;
178
+ private setupConnectionAndInit;
179
+ openWidget(options?: {
180
+ reset?: boolean;
181
+ }): Promise<void>;
182
+ /**
183
+ * Makes a hidden container visible for instant display of preloaded iframe
184
+ */
185
+ private makeContainerVisible;
186
+ private setupMessageHandlers;
187
+ private createAndAppendIframe;
188
+ private destroy;
189
+ close(reason?: 'user_close' | 'cancel' | 'complete' | 'error'): Promise<void>;
190
+ resetWidget(): Promise<void>;
191
+ restart(newOptions?: Partial<SDKOptions<TSchema>>): Promise<void>;
192
+ private handleWidgetClosed;
193
+ private hideContainer;
194
+ getConnectionStatus(): boolean;
195
+ getState(): WidgetState;
196
+ getMode(): WidgetMode;
197
+ getIsReady(): boolean;
198
+ getIsOpen(): boolean;
199
+ getCanRestart(): boolean;
200
+ getLastError(): Error | null;
201
+ getStatus(): {
202
+ state: WidgetState;
203
+ mode: WidgetMode;
204
+ isReady: boolean;
205
+ isOpen: boolean;
206
+ canRestart: boolean;
207
+ hasError: boolean;
208
+ lastError: Error | null;
209
+ connectionStatus: boolean;
210
+ };
211
+ getVersion(): string;
212
+ }
213
+
214
+ export { CSVImporter, type DeliveryOptions, ImportCancelledError, type InferCSVImporter, type OpenOptions, type RecordsChunk, type SDKOptions, type WebhookConfig };
@@ -0,0 +1,214 @@
1
+ import { ExType, ExRow, ExRowShape, Infer } from '@expresscsv/fields';
2
+ export { ExType, Infer, x } from '@expresscsv/fields';
3
+ import { WidgetState, WidgetMode } from '@expresscsv/iframe-comm';
4
+ export { WidgetMode, WidgetState } from '@expresscsv/iframe-comm';
5
+ import { ExBaseDef } from '@expresscsv/fields/src/types';
6
+ export { ExBaseDef } from '@expresscsv/fields/src/types';
7
+ import { ECSVTheme, ColorModeConfig, ECSVFontSource } from '@expresscsv/theme';
8
+ export { ColorModeConfig, ColorModePref, ECSVFontSource, ECSVTheme, TailwindThemeVars } from '@expresscsv/theme';
9
+ import { TemplateDownloadConfig, DeepPartial, ExpressCSVLocaleInput, ExpressCSVStep } from '@expresscsv/core';
10
+ export { DeepPartial, ExpressCSVLocaleInput, ExpressCSVStep } from '@expresscsv/core';
11
+
12
+ /**
13
+ * Error thrown when the user cancels the import operation
14
+ */
15
+ declare class ImportCancelledError extends Error {
16
+ constructor(message?: string);
17
+ }
18
+
19
+ /**
20
+ * A chunk of records passed to the onData callback
21
+ */
22
+ interface RecordsChunk<T> {
23
+ /** The records in this chunk */
24
+ records: T[];
25
+ /** Total number of chunks */
26
+ totalChunks: number;
27
+ /** Current chunk index (0-based) */
28
+ currentChunkIndex: number;
29
+ /** Total number of records across all chunks */
30
+ totalRecords: number;
31
+ }
32
+ /**
33
+ * Webhook configuration for remote delivery of results
34
+ */
35
+ interface WebhookConfig {
36
+ /** The URL to send webhook requests to */
37
+ url: string;
38
+ /** Optional HTTP headers to include in the request */
39
+ headers?: Record<string, string>;
40
+ /** HTTP method to use (default: 'POST') */
41
+ method?: 'POST' | 'PUT' | 'PATCH';
42
+ /** Request timeout in milliseconds (default: 30000) */
43
+ timeout?: number;
44
+ /** Number of retry attempts on failure (default: 0) */
45
+ retries?: number;
46
+ /** Arbitrary developer-provided metadata */
47
+ metadata?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * Type helper that requires at least one of the specified keys to be present
51
+ */
52
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
53
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
54
+ }[Keys];
55
+ /**
56
+ * Base delivery options - at least one must be provided
57
+ */
58
+ interface DeliveryOptionsBase<T> {
59
+ /** Local callback for processing chunks */
60
+ onData?: (chunk: RecordsChunk<T>, next: () => void) => void | Promise<void>;
61
+ /** Webhook configuration for remote delivery */
62
+ webhook?: WebhookConfig;
63
+ }
64
+ /**
65
+ * Delivery options - requires at least one of onData or webhook
66
+ */
67
+ type DeliveryOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'>;
68
+ /**
69
+ * Options for the open() method
70
+ * Requires at least one of onData or webhook for delivery
71
+ */
72
+ type OpenOptions<T> = RequireAtLeastOne<DeliveryOptionsBase<T>, 'onData' | 'webhook'> & {
73
+ /** Number of records per chunk (default: 1000) */
74
+ chunkSize?: number;
75
+ /** Called when all chunks have been processed */
76
+ onComplete?: () => void;
77
+ /** Called when the user cancels the import */
78
+ onCancel?: () => void;
79
+ /** Called when an error occurs */
80
+ onError?: (error: Error) => void;
81
+ /** Called when the widget opens */
82
+ onWidgetOpen?: () => void;
83
+ /** Called when the step changes in the wizard */
84
+ onStepChange?: (stepId: ExpressCSVStep, previousStepId?: ExpressCSVStep) => void;
85
+ /** Called when the widget closes */
86
+ onWidgetClose?: (reason: 'user_close' | 'cancel' | 'complete' | 'error') => void;
87
+ };
88
+ type InferCSVImporter<TSchema extends ExType<unknown, ExBaseDef, unknown>> = CSVImporter<TSchema>;
89
+
90
+ interface SDKOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
91
+ schema: TSchema;
92
+ publishableKey: string;
93
+ importIdentifier: string;
94
+ title?: string;
95
+ debug?: boolean;
96
+ developerMode?: boolean;
97
+ preload?: boolean;
98
+ theme?: ECSVTheme;
99
+ colorMode?: ColorModeConfig;
100
+ customCSS?: string;
101
+ fonts?: Record<string, ECSVFontSource>;
102
+ stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
103
+ previewSchemaBeforeUpload?: boolean;
104
+ templateDownload?: TemplateDownloadConfig;
105
+ saveSession?: boolean;
106
+ locale?: DeepPartial<ExpressCSVLocaleInput>;
107
+ }
108
+ declare class CSVImporter<TSchema extends ExType<unknown, ExBaseDef, unknown> = ExRow<ExRowShape>> {
109
+ private options;
110
+ private iframe;
111
+ private container;
112
+ private connection;
113
+ private connectionState;
114
+ private debug;
115
+ private developerMode;
116
+ private importIdentifier;
117
+ private sessionId;
118
+ private _destroyTimer;
119
+ private _beforeUnloadHandler;
120
+ private widgetUrl;
121
+ private widgetState;
122
+ private widgetMode;
123
+ private canRestart;
124
+ private lastError;
125
+ private openOptions;
126
+ private cachedSchemaJson;
127
+ private initCompletePromise;
128
+ private resolveInitComplete;
129
+ constructor(options: SDKOptions<TSchema>);
130
+ /**
131
+ * Enhanced state management
132
+ */
133
+ private setState;
134
+ private updateDerivedState;
135
+ private handleError;
136
+ private waitForEvent;
137
+ /**
138
+ * Open the import flow with chunk-based data processing.
139
+ * Automatically opens the widget if not already open.
140
+ *
141
+ * @param options Configuration including onData callback for processing chunks
142
+ */
143
+ open(options: OpenOptions<Infer<TSchema>>): void;
144
+ /**
145
+ * Create import session on backend with configuration
146
+ * Idempotent: safe to call multiple times with same sessionId
147
+ */
148
+ private createImportSession;
149
+ /**
150
+ * Deliver results to webhook endpoint via backend API
151
+ * Chunks data using SDK-determined chunk size (independent of customer's chunkSize)
152
+ */
153
+ private deliverToWebhook;
154
+ /**
155
+ * Send a single chunk to backend webhook API with retry logic
156
+ */
157
+ private sendChunkToBackend;
158
+ /**
159
+ * Process results in chunks, calling onData and/or webhook for each chunk with backpressure control
160
+ */
161
+ private processResultsInChunks;
162
+ /**
163
+ * Initialize the iframe and connection.
164
+ * @param hidden Whether to create the iframe hidden (for preload) or visible (for normal open)
165
+ */
166
+ private initializeIframe;
167
+ private log;
168
+ private error;
169
+ /**
170
+ * Add beforeunload event listener to warn users about losing progress
171
+ */
172
+ private addBeforeUnloadListener;
173
+ /**
174
+ * Remove beforeunload event listener
175
+ */
176
+ private removeBeforeUnloadListener;
177
+ private waitForIframeLoad;
178
+ private setupConnectionAndInit;
179
+ openWidget(options?: {
180
+ reset?: boolean;
181
+ }): Promise<void>;
182
+ /**
183
+ * Makes a hidden container visible for instant display of preloaded iframe
184
+ */
185
+ private makeContainerVisible;
186
+ private setupMessageHandlers;
187
+ private createAndAppendIframe;
188
+ private destroy;
189
+ close(reason?: 'user_close' | 'cancel' | 'complete' | 'error'): Promise<void>;
190
+ resetWidget(): Promise<void>;
191
+ restart(newOptions?: Partial<SDKOptions<TSchema>>): Promise<void>;
192
+ private handleWidgetClosed;
193
+ private hideContainer;
194
+ getConnectionStatus(): boolean;
195
+ getState(): WidgetState;
196
+ getMode(): WidgetMode;
197
+ getIsReady(): boolean;
198
+ getIsOpen(): boolean;
199
+ getCanRestart(): boolean;
200
+ getLastError(): Error | null;
201
+ getStatus(): {
202
+ state: WidgetState;
203
+ mode: WidgetMode;
204
+ isReady: boolean;
205
+ isOpen: boolean;
206
+ canRestart: boolean;
207
+ hasError: boolean;
208
+ lastError: Error | null;
209
+ connectionStatus: boolean;
210
+ };
211
+ getVersion(): string;
212
+ }
213
+
214
+ export { CSVImporter, type DeliveryOptions, ImportCancelledError, type InferCSVImporter, type OpenOptions, type RecordsChunk, type SDKOptions, type WebhookConfig };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var _=class{constructor(e){this._def=e;}_addCheck(e,t,n){return {type:e,params:t,message:n}}},b=class extends _{columnNameAliases(e){return this._def.columnNameAliases=e,this}description(e){return this._def.description=e,this}label(e){return this._def.label=e,this}example(e){return this._def.example=e,this}refine(e,t){let n=this._addCheck("refine",{validator:e,params:t});return this._def.checks||(this._def.checks=[]),this._def.checks.push(n),this}refineBatch(e,t){let n=this._addCheck("refineBatch",{validator:e,params:t});return this._def.checks||(this._def.checks=[]),this._def.checks.push(n),this}_findExistingCheck(e){if(!this._def.checks)return {check:void 0,index:-1,found:false};let t=this._def.checks.findIndex(r=>r.type===e),n=t!==-1;return {check:n?this._def.checks[t]:void 0,index:t,found:n}}_replaceOrAddCheck(e,t){this._def.checks||(this._def.checks=[]),t!==-1?this._def.checks[t]=e:this._def.checks.push(e);}};var be=[{name:"Afghanistan",alpha2:"AF",alpha3:"AFG",aliases:["Af\u0121\u0101nist\u0101n","\u0627\u0641\u063A\u0627\u0646\u0633\u062A\u0627\u0646"]},{name:"\xC5land Islands",alpha2:"AX",alpha3:"ALA",aliases:["Ahvenanmaa","\xC5land"]},{name:"Albania",alpha2:"AL",alpha3:"ALB",aliases:["Shqip\xEBri","Shqip\xEBria"]},{name:"Algeria",alpha2:"DZ",alpha3:"DZA",aliases:["\u0627\u0644\u062C\u0632\u0627\u0626\u0631","Alg\xE9rie"]},{name:"American Samoa",alpha2:"AS",alpha3:"ASM",aliases:["S\u0101moa Amelika","Amelika S\u0101moa"]},{name:"Andorra",alpha2:"AD",alpha3:"AND",aliases:["Principat d'Andorra"]},{name:"Angola",alpha2:"AO",alpha3:"AGO",aliases:["Rep\xFAblica de Angola"]},{name:"Anguilla",alpha2:"AI",alpha3:"AIA",aliases:[]},{name:"Antigua and Barbuda",alpha2:"AG",alpha3:"ATG",aliases:["Antigua","Barbuda"]},{name:"Argentina",alpha2:"AR",alpha3:"ARG",aliases:["Rep\xFAblica Argentina","Argentine Republic"]},{name:"Armenia",alpha2:"AM",alpha3:"ARM",aliases:["\u0540\u0561\u0575\u0561\u057D\u057F\u0561\u0576","Hayastan","Republic of Armenia"]},{name:"Aruba",alpha2:"AW",alpha3:"ABW",aliases:[]},{name:"Australia",alpha2:"AU",alpha3:"AUS",aliases:["Commonwealth of Australia","Oz"]},{name:"Austria",alpha2:"AT",alpha3:"AUT",aliases:["\xD6sterreich"]},{name:"Azerbaijan",alpha2:"AZ",alpha3:"AZE",aliases:["Az\u0259rbaycan","Republic of Azerbaijan"]},{name:"Bahamas",alpha2:"BS",alpha3:"BHS",aliases:["The Bahamas","Commonwealth of The Bahamas"]},{name:"Bahrain",alpha2:"BH",alpha3:"BHR",aliases:["\u0627\u0644\u0628\u062D\u0631\u064A\u0646","Kingdom of Bahrain"]},{name:"Bangladesh",alpha2:"BD",alpha3:"BGD",aliases:["\u09AC\u09BE\u0982\u09B2\u09BE\u09A6\u09C7\u09B6","People's Republic of Bangladesh"]},{name:"Barbados",alpha2:"BB",alpha3:"BRB",aliases:[]},{name:"Belarus",alpha2:"BY",alpha3:"BLR",aliases:["\u0411\u0435\u043B\u0430\u0440\u0443\u0441\u044C","Republic of Belarus","Belorussia"]},{name:"Belgium",alpha2:"BE",alpha3:"BEL",aliases:["Belgi\xEB","Belgique","Belgien"]},{name:"Belize",alpha2:"BZ",alpha3:"BLZ",aliases:[]},{name:"Benin",alpha2:"BJ",alpha3:"BEN",aliases:["Republic of Benin","R\xE9publique du B\xE9nin"]},{name:"Bermuda",alpha2:"BM",alpha3:"BMU",aliases:[]},{name:"Bhutan",alpha2:"BT",alpha3:"BTN",aliases:["\u0F60\u0F56\u0FB2\u0F74\u0F42\u0F0B\u0F61\u0F74\u0F63\u0F0B","Druk Yul","Kingdom of Bhutan"]},{name:"Bolivia",alpha2:"BO",alpha3:"BOL",aliases:["Bolivia","Estado Plurinacional de Bolivia"]},{name:"Bonaire, Sint Eustatius and Saba",alpha2:"BQ",alpha3:"BES",aliases:["Caribbean Netherlands"]},{name:"Bosnia and Herzegovina",alpha2:"BA",alpha3:"BIH",aliases:["Bosna i Hercegovina"]},{name:"Botswana",alpha2:"BW",alpha3:"BWA",aliases:["Republic of Botswana"]},{name:"Brazil",alpha2:"BR",alpha3:"BRA",aliases:["Brasil","Federative Republic of Brazil"]},{name:"British Indian Ocean Territory",alpha2:"IO",alpha3:"IOT",aliases:[]},{name:"Brunei Darussalam",alpha2:"BN",alpha3:"BRN",aliases:["Brunei"]},{name:"Bulgaria",alpha2:"BG",alpha3:"BGR",aliases:["\u0411\u044A\u043B\u0433\u0430\u0440\u0438\u044F","Republic of Bulgaria"]},{name:"Burkina Faso",alpha2:"BF",alpha3:"BFA",aliases:["Burkina"]},{name:"Burundi",alpha2:"BI",alpha3:"BDI",aliases:["Republic of Burundi","Republika y'Uburundi"]},{name:"Cabo Verde",alpha2:"CV",alpha3:"CPV",aliases:["Cape Verde"]},{name:"Cambodia",alpha2:"KH",alpha3:"KHM",aliases:["\u1780\u1798\u17D2\u1796\u17BB\u1787\u17B6","Kingdom of Cambodia"]},{name:"Cameroon",alpha2:"CM",alpha3:"CMR",aliases:["Cameroun","Republic of Cameroon"]},{name:"Canada",alpha2:"CA",alpha3:"CAN",aliases:["Kanada","Canada (French)"]},{name:"Cayman Islands",alpha2:"KY",alpha3:"CYM",aliases:[]},{name:"Central African Republic",alpha2:"CF",alpha3:"CAF",aliases:["R\xE9publique centrafricaine"]},{name:"Chad",alpha2:"TD",alpha3:"TCD",aliases:["Tchad","\u062C\u0645\u0647\u0648\u0631\u064A\u0629 \u062A\u0634\u0627\u062F"]},{name:"Chile",alpha2:"CL",alpha3:"CHL",aliases:["Rep\xFAblica de Chile"]},{name:"China",alpha2:"CN",alpha3:"CHN",aliases:["\u4E2D\u534E\u4EBA\u6C11\u5171\u548C\u56FD","\u4E2D\u56FD","Zh\u014Dnggu\xF3","People's Republic of China","PRC"]},{name:"Christmas Island",alpha2:"CX",alpha3:"CXR",aliases:[]},{name:"Cocos (Keeling) Islands",alpha2:"CC",alpha3:"CCK",aliases:[]},{name:"Colombia",alpha2:"CO",alpha3:"COL",aliases:["Rep\xFAblica de Colombia"]},{name:"Comoros",alpha2:"KM",alpha3:"COM",aliases:["\u062C\u0632\u0631 \u0627\u0644\u0642\u0645\u0631","Union of the Comoros"]},{name:"Congo",alpha2:"CG",alpha3:"COG",aliases:["Republic of the Congo","Congo-Brazzaville"]},{name:"Democratic Republic of the Congo",alpha2:"CD",alpha3:"COD",aliases:["Democratic Republic of the Congo","Congo-Kinshasa","DR Congo","DRC"]},{name:"Cook Islands",alpha2:"CK",alpha3:"COK",aliases:[]},{name:"Costa Rica",alpha2:"CR",alpha3:"CRI",aliases:["Rep\xFAblica de Costa Rica"]},{name:"C\xF4te d'Ivoire",alpha2:"CI",alpha3:"CIV",aliases:["Ivory Coast","R\xE9publique de C\xF4te d'Ivoire"]},{name:"Croatia",alpha2:"HR",alpha3:"HRV",aliases:["Hrvatska","Republic of Croatia"]},{name:"Cuba",alpha2:"CU",alpha3:"CUB",aliases:["Rep\xFAblica de Cuba"]},{name:"Cura\xE7ao",alpha2:"CW",alpha3:"CUW",aliases:[]},{name:"Cyprus",alpha2:"CY",alpha3:"CYP",aliases:["\u039A\u03CD\u03C0\u03C1\u03BF\u03C2","K\u0131br\u0131s"]},{name:"Czechia",alpha2:"CZ",alpha3:"CZE",aliases:["Czech Republic","\u010Cesko"]},{name:"Denmark",alpha2:"DK",alpha3:"DNK",aliases:["Danmark"]},{name:"Djibouti",alpha2:"DJ",alpha3:"DJI",aliases:["\u062C\u064A\u0628\u0648\u062A\u064A","Djibouti City-State"]},{name:"Dominica",alpha2:"DM",alpha3:"DMA",aliases:[]},{name:"Dominican Republic",alpha2:"DO",alpha3:"DOM",aliases:["Rep\xFAblica Dominicana"]},{name:"Ecuador",alpha2:"EC",alpha3:"ECU",aliases:["Rep\xFAblica del Ecuador"]},{name:"Egypt",alpha2:"EG",alpha3:"EGY",aliases:["\u0645\u0635\u0631","Arab Republic of Egypt"]},{name:"El Salvador",alpha2:"SV",alpha3:"SLV",aliases:["Rep\xFAblica de El Salvador"]},{name:"Equatorial Guinea",alpha2:"GQ",alpha3:"GNQ",aliases:["Rep\xFAblica de Guinea Ecuatorial","R\xE9publique de Guin\xE9e \xE9quatoriale","Rep\xFAblica da Guin\xE9 Equatorial"]},{name:"Eritrea",alpha2:"ER",alpha3:"ERI",aliases:["State of Eritrea","\u12A4\u122D\u1275\u122B","\u0625\u0631\u064A\u062A\u0631\u064A\u0627"]},{name:"Estonia",alpha2:"EE",alpha3:"EST",aliases:["Eesti"]},{name:"Eswatini",alpha2:"SZ",alpha3:"SWZ",aliases:["Swaziland","Kingdom of Eswatini"]},{name:"Ethiopia",alpha2:"ET",alpha3:"ETH",aliases:["\u12A2\u1275\u12EE\u1335\u12EB","Federal Democratic Republic of Ethiopia"]},{name:"Falkland Islands (Malvinas)",alpha2:"FK",alpha3:"FLK",aliases:["Islas Malvinas"]},{name:"Faroe Islands",alpha2:"FO",alpha3:"FRO",aliases:["F\xF8royar"]},{name:"Fiji",alpha2:"FJ",alpha3:"FJI",aliases:["Viti","Fiji Islands"]},{name:"Finland",alpha2:"FI",alpha3:"FIN",aliases:["Suomi"]},{name:"France",alpha2:"FR",alpha3:"FRA",aliases:["R\xE9publique fran\xE7aise"]},{name:"French Guiana",alpha2:"GF",alpha3:"GUF",aliases:["Guyane"]},{name:"French Polynesia",alpha2:"PF",alpha3:"PYF",aliases:["Polyn\xE9sie fran\xE7aise"]},{name:"Gabon",alpha2:"GA",alpha3:"GAB",aliases:["R\xE9publique gabonaise"]},{name:"Gambia",alpha2:"GM",alpha3:"GMB",aliases:["Republic of The Gambia"]},{name:"Georgia",alpha2:"GE",alpha3:"GEO",aliases:["\u10E1\u10D0\u10E5\u10D0\u10E0\u10D7\u10D5\u10D4\u10DA\u10DD","Sakartvelo"]},{name:"Germany",alpha2:"DE",alpha3:"DEU",aliases:["Deutschland","Federal Republic of Germany"]},{name:"Ghana",alpha2:"GH",alpha3:"GHA",aliases:["Republic of Ghana"]},{name:"Gibraltar",alpha2:"GI",alpha3:"GIB",aliases:[""]},{name:"Greece",alpha2:"GR",alpha3:"GRC",aliases:["\u0395\u03BB\u03BB\u03AC\u03B4\u03B1","Hellas","Hellenic Republic"]},{name:"Greenland",alpha2:"GL",alpha3:"GRL",aliases:["Kalaallit Nunaat"]},{name:"Grenada",alpha2:"GD",alpha3:"GRD",aliases:[]},{name:"Guadeloupe",alpha2:"GP",alpha3:"GLP",aliases:[]},{name:"Guam",alpha2:"GU",alpha3:"GUM",aliases:["Gu\xE5h\xE5n"]},{name:"Guatemala",alpha2:"GT",alpha3:"GTM",aliases:["Rep\xFAblica de Guatemala"]},{name:"Guernsey",alpha2:"GG",alpha3:"GGY",aliases:[]},{name:"Guinea",alpha2:"GN",alpha3:"GIN",aliases:["R\xE9publique de Guin\xE9e"]},{name:"Guinea-Bissau",alpha2:"GW",alpha3:"GNB",aliases:["Rep\xFAblica da Guin\xE9-Bissau"]},{name:"Guyana",alpha2:"GY",alpha3:"GUY",aliases:["Co-operative Republic of Guyana"]},{name:"Haiti",alpha2:"HT",alpha3:"HTI",aliases:["R\xE9publique d'Ha\xEFti","Repiblik d Ayiti"]},{name:"Holy See",alpha2:"VA",alpha3:"VAT",aliases:["Vatican City","Vatican City State","Santa Sede"]},{name:"Honduras",alpha2:"HN",alpha3:"HND",aliases:["Rep\xFAblica de Honduras"]},{name:"Hong Kong",alpha2:"HK",alpha3:"HKG",aliases:["\u9999\u6E2F","Xianggang","Hong Kong SAR"]},{name:"Hungary",alpha2:"HU",alpha3:"HUN",aliases:["Magyarorsz\xE1g"]},{name:"Iceland",alpha2:"IS",alpha3:"ISL",aliases:["\xCDsland"]},{name:"India",alpha2:"IN",alpha3:"IND",aliases:["\u092D\u093E\u0930\u0924","Republic of India","Bharat"]},{name:"Indonesia",alpha2:"ID",alpha3:"IDN",aliases:["Republik Indonesia"]},{name:"Iran, Islamic Republic of",alpha2:"IR",alpha3:"IRN",aliases:["\u0627\u06CC\u0631\u0627\u0646","Islamic Republic of Iran"]},{name:"Iraq",alpha2:"IQ",alpha3:"IRQ",aliases:["\u0627\u0644\u0639\u0631\u0627\u0642","Republic of Iraq"]},{name:"Ireland",alpha2:"IE",alpha3:"IRL",aliases:["\xC9ire","Republic of Ireland"]},{name:"Isle of Man",alpha2:"IM",alpha3:"IMN",aliases:["Mann","Ellan Vannin"]},{name:"Israel",alpha2:"IL",alpha3:"ISR",aliases:["\u05D9\u05B4\u05E9\u05B0\u05C2\u05E8\u05B8\u05D0\u05B5\u05DC","State of Israel","Med\u012Bnat Yisr\u0101'el"]},{name:"Italy",alpha2:"IT",alpha3:"ITA",aliases:["Italia","Repubblica Italiana"]},{name:"Jamaica",alpha2:"JM",alpha3:"JAM",aliases:[]},{name:"Japan",alpha2:"JP",alpha3:"JPN",aliases:["\u65E5\u672C","Nihon","Nippon"]},{name:"Jersey",alpha2:"JE",alpha3:"JEY",aliases:[]},{name:"Jordan",alpha2:"JO",alpha3:"JOR",aliases:["\u0627\u0644\u0623\u0631\u062F\u0646","Hashemite Kingdom of Jordan"]},{name:"Kazakhstan",alpha2:"KZ",alpha3:"KAZ",aliases:["\u049A\u0430\u0437\u0430\u049B\u0441\u0442\u0430\u043D","Republic of Kazakhstan"]},{name:"Kenya",alpha2:"KE",alpha3:"KEN",aliases:["Republic of Kenya"]},{name:"Kiribati",alpha2:"KI",alpha3:"KIR",aliases:[]},{name:"North Korea",alpha2:"KP",alpha3:"PRK",aliases:["North Korea","\uC870\uC120\uBBFC\uC8FC\uC8FC\uC758\uC778\uBBFC\uACF5\uD654\uAD6D","Democratic People's Republic of Korea"]},{name:"South Korea",alpha2:"KR",alpha3:"KOR",aliases:["South Korea","\uB300\uD55C\uBBFC\uAD6D","Republic of Korea"]},{name:"Kosovo",alpha2:"XK",alpha3:"XKS",aliases:["Kosova","\u041A\u043E\u0441\u043E\u0432\u043E","Republic of Kosovo","Republika e Kosov\xEBs"]},{name:"Kuwait",alpha2:"KW",alpha3:"KWT",aliases:["\u0627\u0644\u0643\u0648\u064A\u062A","State of Kuwait"]},{name:"Kyrgyzstan",alpha2:"KG",alpha3:"KGZ",aliases:["\u041A\u044B\u0440\u0433\u044B\u0437\u0441\u0442\u0430\u043D","Kyrgyz Republic"]},{name:"Lao People's Democratic Republic",alpha2:"LA",alpha3:"LAO",aliases:["Laos","\u0EAA\u0E9B\u0E9B\u0EA5\u0EB2\u0EA7"]},{name:"Latvia",alpha2:"LV",alpha3:"LVA",aliases:["Latvija"]},{name:"Lebanon",alpha2:"LB",alpha3:"LBN",aliases:["\u0644\u0628\u0646\u0627\u0646","Republic of Lebanon"]},{name:"Lesotho",alpha2:"LS",alpha3:"LSO",aliases:["Kingdom of Lesotho"]},{name:"Liberia",alpha2:"LR",alpha3:"LBR",aliases:["Republic of Liberia"]},{name:"Libya",alpha2:"LY",alpha3:"LBY",aliases:["Libyan Arab Jamahiriya"]},{name:"Liechtenstein",alpha2:"LI",alpha3:"LIE",aliases:["F\xFCrstentum Liechtenstein"]},{name:"Lithuania",alpha2:"LT",alpha3:"LTU",aliases:["Lietuva","Republic of Lithuania"]},{name:"Luxembourg",alpha2:"LU",alpha3:"LUX",aliases:["L\xEBtzebuerg","Luxembourg","Luxemburg"]},{name:"Macao",alpha2:"MO",alpha3:"MAC",aliases:["\u6FB3\u9580","Macao SAR","\xC0om\xE9n"]},{name:"Madagascar",alpha2:"MG",alpha3:"MDG",aliases:["Repoblikan'i Madagasikara","R\xE9publique de Madagascar"]},{name:"Malawi",alpha2:"MW",alpha3:"MWI",aliases:["Republic of Malawi"]},{name:"Malaysia",alpha2:"MY",alpha3:"MYS",aliases:["Malaysia","\u0645\u0627\u0644\u064A\u0632\u064A\u0627"]},{name:"Maldives",alpha2:"MV",alpha3:"MDV",aliases:["\u078B\u07A8\u0788\u07AC\u0780\u07A8\u0783\u07A7\u0787\u07B0\u0796\u07AD\u078E\u07AC","Dhivehi Raajje","Republic of Maldives"]},{name:"Mali",alpha2:"ML",alpha3:"MLI",aliases:["R\xE9publique du Mali"]},{name:"Malta",alpha2:"MT",alpha3:"MLT",aliases:["Repubblika ta' Malta","Republic of Malta"]},{name:"Marshall Islands",alpha2:"MH",alpha3:"MHL",aliases:["Aolep\u0101n Aor\u014Dkin M\u0327aje\u013C","Republic of the Marshall Islands"]},{name:"Martinique",alpha2:"MQ",alpha3:"MTQ",aliases:[]},{name:"Mauritania",alpha2:"MR",alpha3:"MRT",aliases:["\u0645\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u0627","Islamic Republic of Mauritania"]},{name:"Mauritius",alpha2:"MU",alpha3:"MUS",aliases:["Republic of Mauritius","R\xE9publique de Maurice"]},{name:"Mayotte",alpha2:"YT",alpha3:"MYT",aliases:[]},{name:"Mexico",alpha2:"MX",alpha3:"MEX",aliases:["M\xE9xico","Estados Unidos Mexicanos"]},{name:"Micronesia, Federated States of",alpha2:"FM",alpha3:"FSM",aliases:["Micronesia","Federated States of Micronesia"]},{name:"Moldova",alpha2:"MD",alpha3:"MDA",aliases:["Moldova","Republica Moldova"]},{name:"Monaco",alpha2:"MC",alpha3:"MCO",aliases:["Principaut\xE9 de Monaco"]},{name:"Mongolia",alpha2:"MN",alpha3:"MNG",aliases:["\u041C\u043E\u043D\u0433\u043E\u043B \u0443\u043B\u0441","Mongol Uls"]},{name:"Montenegro",alpha2:"ME",alpha3:"MNE",aliases:["\u0426\u0440\u043D\u0430 \u0413\u043E\u0440\u0430","Crna Gora"]},{name:"Montserrat",alpha2:"MS",alpha3:"MSR",aliases:[]},{name:"Morocco",alpha2:"MA",alpha3:"MAR",aliases:["\u0627\u0644\u0645\u063A\u0631\u0628","Maroc","Kingdom of Morocco"]},{name:"Mozambique",alpha2:"MZ",alpha3:"MOZ",aliases:["Mo\xE7ambique","Republic of Mozambique"]},{name:"Myanmar",alpha2:"MM",alpha3:"MMR",aliases:["Burma","\u1019\u103C\u1014\u103A\u1019\u102C","Myanma"]},{name:"Namibia",alpha2:"NA",alpha3:"NAM",aliases:["Republic of Namibia"]},{name:"Nauru",alpha2:"NR",alpha3:"NRU",aliases:["Naoero","Republic of Nauru"]},{name:"Nepal",alpha2:"NP",alpha3:"NPL",aliases:["\u0928\u0947\u092A\u093E\u0932","Federal Democratic Republic of Nepal"]},{name:"Netherlands",alpha2:"NL",alpha3:"NLD",aliases:["Nederland","Holland","Kingdom of the Netherlands"]},{name:"New Caledonia",alpha2:"NC",alpha3:"NCL",aliases:["Nouvelle-Cal\xE9donie"]},{name:"New Zealand",alpha2:"NZ",alpha3:"NZL",aliases:["Aotearoa"]},{name:"Nicaragua",alpha2:"NI",alpha3:"NIC",aliases:["Rep\xFAblica de Nicaragua"]},{name:"Niger",alpha2:"NE",alpha3:"NER",aliases:["R\xE9publique du Niger"]},{name:"Nigeria",alpha2:"NG",alpha3:"NGA",aliases:["Federal Republic of Nigeria"]},{name:"Niue",alpha2:"NU",alpha3:"NIU",aliases:[]},{name:"Norfolk Island",alpha2:"NF",alpha3:"NFK",aliases:[]},{name:"North Macedonia",alpha2:"MK",alpha3:"MKD",aliases:["Republic of North Macedonia","\u0421\u0435\u0432\u0435\u0440\u043D\u0430 \u041C\u0430\u043A\u0435\u0434\u043E\u043D\u0438\u0458\u0430"]},{name:"Northern Mariana Islands",alpha2:"MP",alpha3:"MNP",aliases:["Saipan","Commonwealth of the Northern Mariana Islands"]},{name:"Norway",alpha2:"NO",alpha3:"NOR",aliases:["Norge","Noreg","Norrige"]},{name:"Oman",alpha2:"OM",alpha3:"OMN",aliases:["\u0639\u0645\u0627\u0646","Sultanate of Oman"]},{name:"Pakistan",alpha2:"PK",alpha3:"PAK",aliases:["\u067E\u0627\u06A9\u0633\u062A\u0627\u0646","Islamic Republic of Pakistan"]},{name:"Palau",alpha2:"PW",alpha3:"PLW",aliases:["Beluu er a Belau","Republic of Palau"]},{name:"Palestine",alpha2:"PS",alpha3:"PSE",aliases:["\u0641\u0644\u0633\u0637\u064A\u0646","State of Palestine"]},{name:"Panama",alpha2:"PA",alpha3:"PAN",aliases:["Rep\xFAblica de Panam\xE1"]},{name:"Papua New Guinea",alpha2:"PG",alpha3:"PNG",aliases:["Papua Niugini"]},{name:"Paraguay",alpha2:"PY",alpha3:"PRY",aliases:["Rep\xFAblica del Paraguay"]},{name:"Peru",alpha2:"PE",alpha3:"PER",aliases:["Rep\xFAblica del Per\xFA"]},{name:"Philippines",alpha2:"PH",alpha3:"PHL",aliases:["Pilipinas","Republika ng Pilipinas"]},{name:"Poland",alpha2:"PL",alpha3:"POL",aliases:["Polska","Republic of Poland"]},{name:"Portugal",alpha2:"PT",alpha3:"PRT",aliases:["Rep\xFAblica Portuguesa"]},{name:"Puerto Rico",alpha2:"PR",alpha3:"PRI",aliases:[]},{name:"Qatar",alpha2:"QA",alpha3:"QAT",aliases:["\u0642\u0637\u0631","State of Qatar"]},{name:"R\xE9union",alpha2:"RE",alpha3:"REU",aliases:[]},{name:"Romania",alpha2:"RO",alpha3:"ROU",aliases:["Rom\xE2nia"]},{name:"Russian Federation",alpha2:"RU",alpha3:"RUS",aliases:["Russia","\u0420\u043E\u0441\u0441\u0438\u0439\u0441\u043A\u0430\u044F \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044F"]},{name:"Rwanda",alpha2:"RW",alpha3:"RWA",aliases:["Repubulika y'u Rwanda","R\xE9publique du Rwanda"]},{name:"Saint Barth\xE9lemy",alpha2:"BL",alpha3:"BLM",aliases:["Saint-Barth\xE9lemy"]},{name:"Saint Helena, Ascension and Tristan da Cunha",alpha2:"SH",alpha3:"SHN",aliases:[]},{name:"Saint Kitts and Nevis",alpha2:"KN",alpha3:"KNA",aliases:[]},{name:"Saint Lucia",alpha2:"LC",alpha3:"LCA",aliases:[]},{name:"Saint Martin (French part)",alpha2:"MF",alpha3:"MAF",aliases:[]},{name:"Saint Pierre and Miquelon",alpha2:"PM",alpha3:"SPM",aliases:[]},{name:"Saint Vincent and the Grenadines",alpha2:"VC",alpha3:"VCT",aliases:[]},{name:"Samoa",alpha2:"WS",alpha3:"WSM",aliases:["S\u0101moa","Independent State of Samoa"]},{name:"San Marino",alpha2:"SM",alpha3:"SMR",aliases:["Serenissima Repubblica di San Marino"]},{name:"Sao Tome and Principe",alpha2:"ST",alpha3:"STP",aliases:["S\xE3o Tom\xE9 e Pr\xEDncipe"]},{name:"Saudi Arabia",alpha2:"SA",alpha3:"SAU",aliases:["\u0627\u0644\u0645\u0645\u0644\u0643\u0629 \u0627\u0644\u0639\u0631\u0628\u064A\u0629 \u0627\u0644\u0633\u0639\u0648\u062F\u064A\u0629","Kingdom of Saudi Arabia","KSA"]},{name:"Senegal",alpha2:"SN",alpha3:"SEN",aliases:["R\xE9publique du S\xE9n\xE9gal"]},{name:"Serbia",alpha2:"RS",alpha3:"SRB",aliases:["\u0421\u0440\u0431\u0438\u0458\u0430","Srbija","Republic of Serbia"]},{name:"Seychelles",alpha2:"SC",alpha3:"SYC",aliases:["Repiblik Sesel","R\xE9publique des Seychelles"]},{name:"Sierra Leone",alpha2:"SL",alpha3:"SLE",aliases:["Republic of Sierra Leone"]},{name:"Singapore",alpha2:"SG",alpha3:"SGP",aliases:["\u65B0\u52A0\u5761","Singapura","Republic of Singapore"]},{name:"Sint Maarten (Dutch part)",alpha2:"SX",alpha3:"SXM",aliases:[]},{name:"Slovakia",alpha2:"SK",alpha3:"SVK",aliases:["Slovensko","Slovak Republic"]},{name:"Slovenia",alpha2:"SI",alpha3:"SVN",aliases:["Slovenija"]},{name:"Solomon Islands",alpha2:"SB",alpha3:"SLB",aliases:[]},{name:"Somalia",alpha2:"SO",alpha3:"SOM",aliases:["Soomaaliya","\u062C\u0645\u0647\u0648\u0631\u064A\u0629 \u0627\u0644\u0635\u0648\u0645\u0627\u0644","Federal Republic of Somalia"]},{name:"South Africa",alpha2:"ZA",alpha3:"ZAF",aliases:["RSA","Republic of South Africa"]},{name:"South Sudan",alpha2:"SS",alpha3:"SSD",aliases:["Republic of South Sudan"]},{name:"Spain",alpha2:"ES",alpha3:"ESP",aliases:["Espa\xF1a","Reino de Espa\xF1a"]},{name:"Sri Lanka",alpha2:"LK",alpha3:"LKA",aliases:["\u0DC1\u0DCA\u200D\u0DBB\u0DD3 \u0DBD\u0D82\u0D9A\u0DCF\u0DC0","\u0B87\u0BB2\u0B99\u0BCD\u0B95\u0BC8","Democratic Socialist Republic of Sri Lanka"]},{name:"Sudan",alpha2:"SD",alpha3:"SDN",aliases:["\u0627\u0644\u0633\u0648\u062F\u0627\u0646","Republic of the Sudan"]},{name:"Suriname",alpha2:"SR",alpha3:"SUR",aliases:["Republiek Suriname"]},{name:"Svalbard and Jan Mayen",alpha2:"SJ",alpha3:"SJM",aliases:[]},{name:"Sweden",alpha2:"SE",alpha3:"SWE",aliases:["Sverige","Kingdom of Sweden"]},{name:"Switzerland",alpha2:"CH",alpha3:"CHE",aliases:["Schweiz","Suisse","Svizzera","Svizra","Swiss Confederation"]},{name:"Syrian Arab Republic",alpha2:"SY",alpha3:"SYR",aliases:["\u0633\u0648\u0631\u064A\u0627","Syria"]},{name:"Taiwan, Province of China",alpha2:"TW",alpha3:"TWN",aliases:["\u53F0\u7063","\u81FA\u7063","Taiwan","Republic of China","ROC"]},{name:"Tajikistan",alpha2:"TJ",alpha3:"TJK",aliases:["\u0422\u043E\u04B7\u0438\u043A\u0438\u0441\u0442\u043E\u043D","Republic of Tajikistan"]},{name:"Tanzania, United Republic of",alpha2:"TZ",alpha3:"TZA",aliases:["Tanzania","Jamhuri ya Muungano wa Tanzania"]},{name:"Thailand",alpha2:"TH",alpha3:"THA",aliases:["\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28\u0E44\u0E17\u0E22","Prathet Thai","Kingdom of Thailand"]},{name:"Timor-Leste",alpha2:"TL",alpha3:"TLS",aliases:["East Timor","Rep\xFAblica Democr\xE1tica de Timor-Leste"]},{name:"Togo",alpha2:"TG",alpha3:"TGO",aliases:["R\xE9publique Togolaise"]},{name:"Tokelau",alpha2:"TK",alpha3:"TKL",aliases:[]},{name:"Tonga",alpha2:"TO",alpha3:"TON",aliases:["Pule\u02BBanga Fakatu\u02BBi \u02BBo Tonga","Kingdom of Tonga"]},{name:"Trinidad and Tobago",alpha2:"TT",alpha3:"TTO",aliases:[]},{name:"Tunisia",alpha2:"TN",alpha3:"TUN",aliases:["\u062A\u0648\u0646\u0633","Republic of Tunisia"]},{name:"T\xFCrkiye",alpha2:"TR",alpha3:"TUR",aliases:["Turkey","T\xFCrkiye Cumhuriyeti","Republic of T\xFCrkiye"]},{name:"Turkmenistan",alpha2:"TM",alpha3:"TKM",aliases:["T\xFCrkmenistan"]},{name:"Turks and Caicos Islands",alpha2:"TC",alpha3:"TCA",aliases:[]},{name:"Tuvalu",alpha2:"TV",alpha3:"TUV",aliases:[]},{name:"Uganda",alpha2:"UG",alpha3:"UGA",aliases:["Republic of Uganda"]},{name:"Ukraine",alpha2:"UA",alpha3:"UKR",aliases:["\u0423\u043A\u0440\u0430\u0457\u043D\u0430"]},{name:"United Arab Emirates",alpha2:"AE",alpha3:"ARE",aliases:["\u0627\u0644\u0625\u0645\u0627\u0631\u0627\u062A \u0627\u0644\u0639\u0631\u0628\u064A\u0629 \u0627\u0644\u0645\u062A\u062D\u062F\u0629","UAE"]},{name:"United Kingdom",alpha2:"GB",alpha3:"GBR",aliases:["United Kingdom","UK","Britain","Great Britain"]},{name:"United States of America",alpha2:"US",alpha3:"USA",aliases:["United States","USA","America","US"]},{name:"Uruguay",alpha2:"UY",alpha3:"URY",aliases:["Rep\xFAblica Oriental del Uruguay"]},{name:"Uzbekistan",alpha2:"UZ",alpha3:"UZB",aliases:["O\u02BBzbekiston","Republic of Uzbekistan"]},{name:"Vanuatu",alpha2:"VU",alpha3:"VUT",aliases:["Ripablik blong Vanuatu"]},{name:"Venezuela",alpha2:"VE",alpha3:"VEN",aliases:["Venezuela","Rep\xFAblica Bolivariana de Venezuela"]},{name:"Vietnam",alpha2:"VN",alpha3:"VNM",aliases:["Vi\u1EC7t Nam","Socialist Republic of Vietnam"]},{name:"Virgin Islands (British)",alpha2:"VG",alpha3:"VGB",aliases:["British Virgin Islands"]},{name:"Virgin Islands (U.S.)",alpha2:"VI",alpha3:"VIR",aliases:["U.S. Virgin Islands"]},{name:"Wallis and Futuna",alpha2:"WF",alpha3:"WLF",aliases:[]},{name:"Western Sahara",alpha2:"EH",alpha3:"ESH",aliases:["\u0627\u0644\u0635\u062D\u0631\u0627\u0621 \u0627\u0644\u063A\u0631\u0628\u064A\u0629","Sahara Occidental"]},{name:"Yemen",alpha2:"YE",alpha3:"YEM",aliases:["\u0627\u0644\u064A\u0645\u0646","Republic of Yemen"]},{name:"Zambia",alpha2:"ZM",alpha3:"ZMB",aliases:["Republic of Zambia"]},{name:"Zimbabwe",alpha2:"ZW",alpha3:"ZWE",aliases:["Republic of Zimbabwe"]}];var ue={byName:new Map,byAlpha2:new Map,byAlpha3:new Map,byAlias:new Map};for(let s of be){ue.byName.set(s.name.toLowerCase(),s),ue.byAlpha2.set(s.alpha2.toLowerCase(),s),ue.byAlpha3.set(s.alpha3.toLowerCase(),s);for(let e of s.aliases)ue.byAlias.set(e.toLowerCase(),s);}var Te=65,Ke=90;var Ge={A:"0-9A-Za-z",B:"0-9A-Z",C:"A-Za-z",F:"0-9",L:"a-z",U:"A-Z",W:"0-9a-z"};function Se(s){let e=s.toUpperCase();return (e.slice(4)+e.slice(0,4)).split("").map(n=>{let a=n.charCodeAt(0);return a>=Te&&a<=Ke?String(a-Te+10):n}).join("")}function Re(s){let e=s,t;for(;e.length>2;)t=e.slice(0,9),e=Number.parseInt(t,10)%97+e.slice(t.length);return Number.parseInt(e,10)%97}function We(s){let e=s.match(/(.{3})/g)?.map(t=>{let n=t.slice(0,1),a=Number.parseInt(t.slice(1),10);return `([${Ge[n]||""}]{${a}})`});return new RegExp(`^${e?.join("")||""}$`)}var i=class{constructor(e,t,n,a){this.countryCode=e,this.length=t,this.structure=n,this.example=a,this._cachedRegex=We(this.structure);}_regex(){return this._cachedRegex}isValid(e){return this.length===e.length&&this.countryCode===e.slice(0,2)&&this._regex().test(e.slice(4))&&Re(Se(e))===1}toBBAN(e,t=""){let n=this._regex().exec(e.slice(4));return n?n.slice(1).join(t):""}fromBBAN(e){if(!this.isValidBBAN(e))throw new Error("Invalid BBAN");let n=`0${98-Re(Se(`${this.countryCode}00${e}`))}`.slice(-2);return `${this.countryCode}${n}${e}`}isValidBBAN(e){return this.length-4===e.length&&this._regex().test(e)}},je={};function o(s){je[s.countryCode]=s;}o(new i("AD",24,"F04F04A12","AD1200012030200359100100"));o(new i("AE",23,"F03F16","AE070331234567890123456"));o(new i("AL",28,"F08A16","AL47212110090000000235698741"));o(new i("AT",20,"F05F11","AT611904300234573201"));o(new i("AZ",28,"U04A20","AZ21NABZ00000000137010001944"));o(new i("BA",20,"F03F03F08F02","BA391290079401028494"));o(new i("BE",16,"F03F07F02","BE68539007547034"));o(new i("BG",22,"U04F04F02A08","BG80BNBG96611020345678"));o(new i("BH",22,"U04A14","BH67BMAG00001299123456"));o(new i("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1"));o(new i("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00"));o(new i("CH",21,"F05A12","CH9300762011623852957"));o(new i("CR",22,"F04F14","CR72012300000171549015"));o(new i("CY",28,"F03F05A16","CY17002001280000001200527600"));o(new i("CZ",24,"F04F06F10","CZ6508000000192000145399"));o(new i("DE",22,"F08F10","DE89370400440532013000"));o(new i("DK",18,"F04F09F01","DK5000400440116243"));o(new i("DO",28,"U04F20","DO28BAGR00000001212453611324"));o(new i("EE",20,"F02F02F11F01","EE382200221020145685"));o(new i("EG",29,"F04F04F17","EG800002000156789012345180002"));o(new i("ES",24,"F04F04F01F01F10","ES9121000418450200051332"));o(new i("FI",18,"F06F07F01","FI2112345600000785"));o(new i("FO",18,"F04F09F01","FO6264600001631634"));o(new i("FR",27,"F05F05A11F02","FR1420041010050500013M02606"));o(new i("GB",22,"U04F06F08","GB29NWBK60161331926819"));o(new i("GE",22,"U02F16","GE29NB0000000101904917"));o(new i("GI",23,"U04A15","GI75NWBK000000007099453"));o(new i("GL",18,"F04F09F01","GL8964710001000206"));o(new i("GR",27,"F03F04A16","GR1601101250000000012300695"));o(new i("GT",28,"A04A20","GT82TRAJ01020000001210029690"));o(new i("HR",21,"F07F10","HR1210010051863000160"));o(new i("HU",28,"F03F04F01F15F01","HU42117730161111101800000000"));o(new i("IE",22,"U04F06F08","IE29AIBK93115212345678"));o(new i("IL",23,"F03F03F13","IL620108000000099999999"));o(new i("IS",26,"F04F02F06F10","IS140159260076545510730339"));o(new i("IT",27,"U01F05F05A12","IT60X0542811101000000123456"));o(new i("IQ",23,"U04F03A12","IQ98NBIQ850123456789012"));o(new i("JO",30,"A04F22","JO15AAAA1234567890123456789012"));o(new i("KW",30,"U04A22","KW81CBKU0000000000001234560101"));o(new i("KZ",20,"F03A13","KZ86125KZT5004100100"));o(new i("LB",28,"F04A20","LB62099900000001001901229114"));o(new i("LC",32,"U04F24","LC07HEMM000100010012001200013015"));o(new i("LI",21,"F05A12","LI21088100002324013AA"));o(new i("LT",20,"F05F11","LT121000011101001000"));o(new i("LU",20,"F03A13","LU280019400644750000"));o(new i("LV",21,"U04A13","LV80BANK0000435195001"));o(new i("MC",27,"F05F05A11F02","MC5811222000010123456789030"));o(new i("MD",24,"U02A18","MD24AG000225100013104168"));o(new i("ME",22,"F03F13F02","ME25505000012345678951"));o(new i("MK",19,"F03A10F02","MK07250120000058984"));o(new i("MR",27,"F05F05F11F02","MR1300020001010000123456753"));o(new i("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S"));o(new i("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR"));o(new i("NL",18,"U04F10","NL91ABNA0417164300"));o(new i("NO",15,"F04F06F01","NO9386011117947"));o(new i("PK",24,"U04A16","PK36SCBL0000001123456702"));o(new i("PL",28,"F08F16","PL61109010140000071219812874"));o(new i("PS",29,"U04A21","PS92PALS000000000400123456702"));o(new i("PT",25,"F04F04F11F02","PT50000201231234567890154"));o(new i("QA",29,"U04A21","QA30AAAA123456789012345678901"));o(new i("RO",24,"U04A16","RO49AAAA1B31007593840000"));o(new i("RS",22,"F03F13F02","RS35260005601001611379"));o(new i("SA",24,"F02A18","SA0380000000608010167519"));o(new i("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD"));o(new i("SE",24,"F03F16F01","SE4550000000058398257466"));o(new i("SI",19,"F05F08F02","SI56263300012039086"));o(new i("SK",24,"F04F06F10","SK3112000000198742637541"));o(new i("SM",27,"U01F05F05A12","SM86U0322509800000000270100"));o(new i("ST",25,"F08F11F02","ST68000100010051845310112"));o(new i("SV",28,"U04F20","SV62CENR00000000000000700025"));o(new i("TL",23,"F03F14F02","TL380080012345678910157"));o(new i("TN",24,"F02F03F13F02","TN5910006035183598478831"));o(new i("TR",26,"F05F01A16","TR330006100519786457841326"));o(new i("UA",29,"F25","UA511234567890123456789012345"));o(new i("VA",22,"F18","VA59001123000012345678"));o(new i("VG",24,"U04F16","VG96VPVG0000012345678901"));o(new i("XK",20,"F04F10F02","XK051212012345678906"));o(new i("AO",25,"F21","AO69123456789012345678901"));o(new i("BF",27,"F23","BF2312345678901234567890123"));o(new i("BI",16,"F12","BI41123456789012"));o(new i("BJ",28,"F24","BJ39123456789012345678901234"));o(new i("CI",28,"U02F22","CI70CI1234567890123456789012"));o(new i("CM",27,"F23","CM9012345678901234567890123"));o(new i("CV",25,"F21","CV30123456789012345678901"));o(new i("DZ",24,"F20","DZ8612345678901234567890"));o(new i("IR",26,"F22","IR861234568790123456789012"));o(new i("MG",27,"F23","MG1812345678901234567890123"));o(new i("ML",28,"U01F23","ML15A12345678901234567890123"));o(new i("MZ",25,"F21","MZ25123456789012345678901"));o(new i("SN",28,"U01F23","SN52A12345678901234567890123"));o(new i("GF",27,"F05F05A11F02","GF121234512345123456789AB13"));o(new i("GP",27,"F05F05A11F02","GP791234512345123456789AB13"));o(new i("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13"));o(new i("RE",27,"F05F05A11F02","RE131234512345123456789AB13"));o(new i("PF",27,"F05F05A11F02","PF281234512345123456789AB13"));o(new i("YT",27,"F05F05A11F02","YT021234512345123456789AB13"));o(new i("NC",27,"F05F05A11F02","NC551234512345123456789AB13"));o(new i("BL",27,"F05F05A11F02","BL391234512345123456789AB13"));o(new i("MF",27,"F05F05A11F02","MF551234512345123456789AB13"));o(new i("PM",27,"F05F05A11F02","PM071234512345123456789AB13"));o(new i("WF",27,"F05F05A11F02","WF621234512345123456789AB13"));var C=class s extends b{static create(e,t){if(!e||typeof e!="object")throw new Error("ExOptional.create: type must be a valid field");if(!("_def"in e)||!e._def||typeof e._def!="object")throw new Error("ExOptional.create: type is not a valid ExpressCSV field");if(!("typeName"in e._def)||typeof e._def.typeName!="string")throw new Error("ExOptional.create: type is missing a typeName");if(t!==void 0&&typeof t!="object")throw new Error("ExOptional.create: options must be an object");if(t?.when!==void 0&&typeof t.when!="function")throw new Error("ExOptional.create: options.when must be a function");return new s({typeName:"ExOptional",innerType:e,when:t?.when,checks:[]})}unwrap(){return this._def.innerType}optional(){return this}default(e){let t=this._def.innerType._def;return t.defaultValue=e,this}};var U=class extends C{};var L=class extends C{output(e){return this._def.innerType.output(e),this._def.outputFormat=e,this}};var z=class extends C{output(e){return this._def.innerType.output(e),this}};var $=class extends C{min(e,t){return this._def.innerType.min(e,t),this}max(e,t){return this._def.innerType.max(e,t),this}integer(e){return this._def.innerType.integer(e),this}multipleOf(e,t){return this._def.innerType.multipleOf(e,t),this}percentage(){return this._def.innerType.percentage(),this}currency(e){return this._def.innerType.currency(e),this}};var K=class extends C{caseSensitive(e=true){return this._def.innerType.caseSensitive(e),this}},G=class extends C{caseSensitive(e=true){return this._def.innerType.caseSensitive(e),this}min(e,t){return this._def.innerType.min(e,t),this}max(e,t){return this._def.innerType.max(e,t),this}};var W=class extends C{uuid(e){return this._def.innerType.uuid(e),this}ip(e){return this._def.innerType.ip(e),this}url(e){return this._def.innerType.url(e),this}email(e){return this._def.innerType.email(e),this}phone(e){return this._def.innerType.phone(e),this}country(e){return this._def.innerType.country(e),this}max(e,t){return this._def.innerType.max(e,t),this}min(e,t){return this._def.innerType.min(e,t),this}length(e,t){return this._def.innerType.length(e,t),this}includes(e,t){return this._def.innerType.includes(e,t),this}startsWith(e,t){return this._def.innerType.startsWith(e,t),this}endsWith(e,t){return this._def.innerType.endsWith(e,t),this}regex(e,t){return this._def.innerType.regex(e,t),this}alphabetical(e){return this._def.innerType.alphabetical(e),this}alphanumerical(e){return this._def.innerType.alphanumerical(e),this}numerical(e){return this._def.innerType.numerical(e),this}iban(e){return this._def.innerType.iban(e),this}bic(e){return this._def.innerType.bic(e),this}gtin(e){return this._def.innerType.gtin(e),this}currencyCode(e){return this._def.innerType.currencyCode(e),this}};var j=class extends C{precision(e,t){return this._def.innerType.precision(e,t),this}};var q=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.create: options.message must be a string");return new s({typeName:"ExString",checks:[],message:e?.message})}optional(){return new W({typeName:"ExOptional",innerType:this})}uuid(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.uuid: options must be an object");if(e?.version!==void 0&&!["v1","v4","v5","all"].includes(e.version))throw new Error("ExString.uuid: options.version must be 'v1', 'v4', 'v5', or 'all'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.uuid: options.message must be a string");let t=e?.version||"all",n=e?.message;if(this._def.checks.findIndex(u=>u.type==="uuid"&&u.params?.version===t)!==-1)return this;let r=this._addCheck("uuid",{version:t},n);return this._def.checks.push(r),this}ip(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.ip: options must be an object");if(e?.version!==void 0&&!["v4","v6","all"].includes(e.version))throw new Error("ExString.ip: options.version must be 'v4', 'v6', or 'all'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.ip: options.message must be a string");let t=e?.version||"all",n=e?.message;if(this._def.checks.findIndex(u=>u.type==="ipAddress"&&u.params?.version===t)!==-1)return this;let r=this._addCheck("ipAddress",{version:t},n);return this._def.checks.push(r),this}url(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.url: options must be an object");if(e?.allowedProtocols!==void 0&&!Array.isArray(e.allowedProtocols))throw new Error("ExString.url: options.allowedProtocols must be an array");if(e?.allowedDomains!==void 0&&!Array.isArray(e.allowedDomains))throw new Error("ExString.url: options.allowedDomains must be an array");if(e?.allowSubdomains!==void 0&&typeof e.allowSubdomains!="boolean")throw new Error("ExString.url: options.allowSubdomains must be a boolean");if(e?.allowPaths!==void 0&&typeof e.allowPaths!="boolean")throw new Error("ExString.url: options.allowPaths must be a boolean");if(e?.allowQueryParams!==void 0&&typeof e.allowQueryParams!="boolean")throw new Error("ExString.url: options.allowQueryParams must be a boolean");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.url: options.message must be a string");let t={allowedProtocols:e?.allowedProtocols,allowedDomains:e?.allowedDomains,allowSubdomains:e?.allowSubdomains!==void 0?e.allowSubdomains:true,allowPaths:e?.allowPaths!==void 0?e.allowPaths:true,allowQueryParams:e?.allowQueryParams!==void 0?e.allowQueryParams:true};if(this._def.checks.findIndex(r=>r.type!=="url"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("url",t,e?.message);return this._def.checks.push(a),this}email(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.email: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.email: options.message must be a string");if(this._findExistingCheck("email").found)return this;let n=e?.message,a=this._addCheck("email",{},n);return this._def.checks.push(a),this}phone(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.phone: options must be an object");if(e?.allowedCountries!==void 0&&!Array.isArray(e.allowedCountries))throw new Error("ExString.phone: options.allowedCountries must be an array");if(e?.format!==void 0&&!["international","national","both"].includes(e.format))throw new Error("ExString.phone: options.format must be 'international', 'national', or 'both'");if(e?.output!==void 0&&!["e164","formatted","digits"].includes(e.output))throw new Error("ExString.phone: options.output must be 'e164', 'formatted', or 'digits'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.phone: options.message must be a string");let t={allowedCountries:e?.allowedCountries,format:e?.format||"international",output:e?.output||"e164"};if(this._def.checks.findIndex(r=>r.type!=="phone"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("phone",t,e?.message);return this._def.checks.push(a),this}country(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.country: options must be an object");if(e?.output!==void 0&&!["name","2-letter","3-letter"].includes(e.output))throw new Error("ExString.country: options.output must be 'name', '2-letter', or '3-letter'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.country: options.message must be a string");let t={output:e?.output||"name"};if(this._def.checks.findIndex(r=>r.type==="country"&&r.params?.output===t.output)!==-1)return this;let a=this._addCheck("country",t,e?.message);return this._def.checks.push(a),this}max(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExString.max: maxLength must be a number");if(e<0||!Number.isInteger(e))throw new Error("ExString.max: maxLength must be a non-negative integer");if(t!==void 0&&typeof t!="object")throw new Error("ExString.max: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.max: options.message must be a string");let n=this._findExistingCheck("max");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e>=l)return this}let a=this._findExistingCheck("min");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&a.check.params.value>e)throw new Error("ExString.max: max cannot be less than min");let r=t?.message,u=this._addCheck("max",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}min(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExString.min: minLength must be a number");if(e<0||!Number.isInteger(e))throw new Error("ExString.min: minLength must be a non-negative integer");if(t!==void 0&&typeof t!="object")throw new Error("ExString.min: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.min: options.message must be a string");let n=this._findExistingCheck("min");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e<=l)return this}let a=this._findExistingCheck("max");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&e>a.check.params.value)throw new Error("ExString.min: min cannot be greater than max");let r=t?.message,u=this._addCheck("min",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}length(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExString.length: exactLength must be a number");if(e<0||!Number.isInteger(e))throw new Error("ExString.length: exactLength must be a non-negative integer");if(t!==void 0&&typeof t!="object")throw new Error("ExString.length: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.length: options.message must be a string");let n=this._findExistingCheck("length"),a=t?.message,r=this._addCheck("length",{value:e},a);return this._replaceOrAddCheck(r,n.index),this}includes(e,t){if(typeof e!="string")throw new Error("ExString.includes: substring must be a string");if(t!==void 0&&typeof t!="object")throw new Error("ExString.includes: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.includes: options.message must be a string");if(this._def.checks.findIndex(u=>u.type==="includes"&&u.params?.value===e)!==-1)return this;let a=t?.message,r=this._addCheck("includes",{value:e},a);return this._def.checks.push(r),this}startsWith(e,t){if(typeof e!="string")throw new Error("ExString.startsWith: prefix must be a string");if(t!==void 0&&typeof t!="object")throw new Error("ExString.startsWith: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.startsWith: options.message must be a string");if(this._def.checks.findIndex(u=>u.type==="startsWith"&&u.params?.value===e)!==-1)return this;let a=t?.message,r=this._addCheck("startsWith",{value:e},a);return this._def.checks.push(r),this}endsWith(e,t){if(typeof e!="string")throw new Error("ExString.endsWith: suffix must be a string");if(t!==void 0&&typeof t!="object")throw new Error("ExString.endsWith: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.endsWith: options.message must be a string");if(this._def.checks.findIndex(u=>u.type==="endsWith"&&u.params?.value===e)!==-1)return this;let a=t?.message,r=this._addCheck("endsWith",{value:e},a);return this._def.checks.push(r),this}regex(e,t){if(!(e instanceof RegExp))throw new Error("ExString.regex: pattern must be a RegExp");if(t!==void 0&&typeof t!="object")throw new Error("ExString.regex: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.regex: options.message must be a string");if(this._def.checks.findIndex(u=>{if(u.type!=="regex"||!u.params?.pattern)return false;let l=u.params.pattern;return l.source===e.source&&l.flags===e.flags})!==-1)return this;let a=t?.message,r=this._addCheck("regex",{pattern:e},a);return this._def.checks.push(r),this}alphabetical(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.alphabetical: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.alphabetical: options.message must be a string");if(this._findExistingCheck("alphabetical").found)return this;let n=e?.message,a=this._addCheck("alphabetical",{},n);return this._def.checks.push(a),this}alphanumerical(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.alphanumerical: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.alphanumerical: options.message must be a string");if(this._findExistingCheck("alphanumerical").found)return this;let n=e?.message,a=this._addCheck("alphanumerical",{},n);return this._def.checks.push(a),this}numerical(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.numerical: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.numerical: options.message must be a string");if(this._findExistingCheck("numerical").found)return this;let n=e?.message,a=this._addCheck("numerical",{},n);return this._def.checks.push(a),this}iban(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.iban: options must be an object");if(e?.allowedCountries!==void 0&&!Array.isArray(e.allowedCountries))throw new Error("ExString.iban: options.allowedCountries must be an array");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.iban: options.message must be a string");let t={allowedCountries:e?.allowedCountries};if(this._def.checks.findIndex(r=>r.type!=="iban"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("iban",t,e?.message);return this._def.checks.push(a),this}bic(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.bic: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.bic: options.message must be a string");if(this._findExistingCheck("bic").found)return this;let n=e?.message,a=this._addCheck("bic",{},n);return this._def.checks.push(a),this}gtin(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.gtin: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.gtin: options.message must be a string");if(this._findExistingCheck("gtin").found)return this;let n=e?.message,a=this._addCheck("gtin",{},n);return this._def.checks.push(a),this}currencyCode(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.currencyCode: options must be an object");if(e?.allowedCurrencies!==void 0&&!Array.isArray(e.allowedCurrencies))throw new Error("ExString.currencyCode: options.allowedCurrencies must be an array");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.currencyCode: options.message must be a string");let t={allowedCurrencies:e?.allowedCurrencies};if(this._def.checks.findIndex(r=>r.type!=="currencyCode"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("currencyCode",t,e?.message);return this._def.checks.push(a),this}};new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z"));function Oe(s){if(s){if(s==="defaultValue")return "default-value";if(s==="when")return "optional-when";if(s==="key")return "unique-index";if(s==="refine")return "refine"}throw new Error(`Invalid key: ${s}`)}function Z(s,e,t){if(!s||typeof s!="object")return s;if(s instanceof RegExp)return {__type:"RegExp",source:s.source,flags:s.flags};if(typeof s=="function"){let a=`func_${Math.random().toString(36).substring(2,15)}`,r=Oe(t),u;switch(r){case "default-value":u=s;break;case "refine":u=s;break;case "optional-when":u=s;break;case "unique-index":u=s;break;default:throw new Error(`Invalid function type: ${r}`)}return e.set(a,{function:u,functionType:r,id:a,functionSource:"local"}),{__type:"Function",id:a,functionType:r}}if(Array.isArray(s))return s.map(a=>Z(a,e));let n={};for(let[a,r]of Object.entries(s))n[a]=Z(r,e,a);return n}function H(s){let e={},t=s._def;return "description"in t&&typeof t.description=="string"&&(e.description=t.description),"label"in t&&typeof t.label=="string"&&(e.label=t.label),"example"in t&&typeof t.example=="string"&&(e.example=t.example),"defaultValue"in t&&t.defaultValue!==void 0&&(e.defaultValue=typeof t.defaultValue=="function"?"[[Function]]":t.defaultValue),"columnNameAliases"in t&&Array.isArray(t.columnNameAliases)&&(e.columnNameAliases=t.columnNameAliases),e}function Ae(s,e,t,n,a){if(typeof s.validator=="function"){let r=`func_${Math.random().toString(36).substring(2,15)}`,u=a==="refineBatch"?"refine":a;t.set(r,{id:r,functionType:u,function:s.validator}),n?e.set(r,{functionType:u,id:r,functionSource:"remote"}):e.set(r,{function:s.validator,functionType:u,id:r,functionSource:"local"}),s.validator={__type:"Function",id:r,functionType:a};}}function ce(s,e,t,n=false){return s.map(a=>{if(a.type==="refine"&&a.params){let r={...a.params};if(Ae(r,e,t,n,"refine"),typeof r.params=="function"){let l=`func_${Math.random().toString(36).substring(2,15)}`;t.set(l,{id:l,functionType:"refine",function:r.params}),n?e.set(l,{functionType:"refine",id:l,functionSource:"remote"}):e.set(l,{function:r.params,functionType:"refine",id:l,functionSource:"local"}),r.params={__type:"Function",id:l,functionType:"refine"};}let u=a.message;return !u&&r.params&&typeof r.params=="object"&&"message"in r.params&&(u=r.params.message),{...a,params:r,message:u}}if(a.type==="refineBatch"&&a.params){let r={...a.params};Ae(r,e,t,n,"refineBatch");let u=a.message;return !u&&r.params&&typeof r.params=="object"&&"message"in r.params&&(u=r.params.message),{...a,params:r,message:u}}return {...a,params:a.params}})}function me(s,e){let t={},n=s._def,a="message"in n&&typeof n.message=="string"?n.message:void 0;if(a&&(t.message=a),e==="ExNumber"&&("isPercentage"in n&&n.isPercentage===true&&(t.isPercentage=true),"currencyCode"in n&&typeof n.currencyCode=="string"&&(t.currencyCode=n.currencyCode)),e==="ExBoolean"&&"control"in n&&n.control!==void 0&&(t.control=n.control),(e==="ExSelect"||e==="ExMultiselect")&&("options"in n&&Array.isArray(n.options)&&(t.options=n.options),"config"in n&&n.config&&typeof n.config=="object")){let r=n.config;t.selectConfig={enforceCaseSensitiveMatch:!!r.enforceCaseSensitiveMatch,allowCustom:!!r.allowCustom};}if((e==="ExDate"||e==="ExDatetime"||e==="ExTime")&&"outputFormat"in n&&typeof n.outputFormat=="string"&&(t.outputFormat=n.outputFormat),e==="ExTime"&&"precision"in n&&(typeof n.precision=="number"||n.precision===null)&&(t.precision=n.precision),e==="ExDatetime"&&"checks"in n&&Array.isArray(n.checks)){let r=n.checks.find(u=>u.type==="datetime");r?.params&&r.params.offset===true&&(t.allowOffset=true);}return t}function Y(s,e=false){let t=new Map,n=new Map,a={typeName:"ExRow",shape:Object.entries(s._def.shape).reduce((l,[d,c])=>{let p=c._def.typeName,g={typeName:p,...H(c),...me(c,p)};if(c._def.checks&&Array.isArray(c._def.checks)&&(g.checks=ce(c._def.checks,t,n,e)),p==="ExOptional"&&"innerType"in c._def){let f=c._def.innerType,y=f._def.typeName,I=H(c),A=H(f),D=me(f,y),k={};for(let T of Object.keys(A))T!=="defaultValue"&&(k[T]=A[T]);let se={...k,...I};if(f._def.checks&&Array.isArray(f._def.checks)&&(D.checks=ce(f._def.checks,t,n,e)),g.innerType={typeName:y,...se,...D},!("defaultValue"in g)&&f._def&&"defaultValue"in f._def&&f._def.defaultValue!==void 0)if(typeof f._def.defaultValue=="function"){let T=`func_${Math.random().toString(36).substring(2,15)}`,B="default-value";n.set(T,{id:T,functionType:B,function:f._def.defaultValue}),e?t.set(T,{functionType:B,id:T,functionSource:"remote"}):t.set(T,{function:f._def.defaultValue,functionType:B,id:T,functionSource:"local"}),g.defaultValue={__type:"Function",id:T,functionType:B};}else g.defaultValue=f._def.defaultValue;}return l[d]=g,l},{})};if(s._def.optionalColumnConfig){a.optionalColumnConfig={columns:s._def.optionalColumnConfig.columns};let l=s._def.optionalColumnConfig.when,d=s._def.optionalColumnConfig.whenMap||{},c={},p;if(l){let g=`func_${Math.random().toString(36).substring(2,15)}`,f="optional-when";n.set(g,{id:g,functionType:f,function:l}),e?t.set(g,{functionType:f,id:g,functionSource:"remote"}):t.set(g,{function:l,functionType:f,id:g,functionSource:"local"}),p=g,a.optionalColumnConfig.when={__type:"Function",id:g,functionType:f};}if(Object.keys(d).length>0){for(let g of s._def.optionalColumnConfig.columns){let f=g.toString();if(d[f])if(l&&d[f]===l&&p)c[f]={__type:"Function",id:p,functionType:"optional-when"};else {let y=`func_${Math.random().toString(36).substring(2,15)}`;n.set(y,{id:y,functionType:"optional-when",function:d[f]}),e?t.set(y,{functionType:"optional-when",id:y,functionSource:"remote"}):t.set(y,{function:d[f],functionType:"optional-when",id:y,functionSource:"local"}),c[f]={__type:"Function",id:y,functionType:"optional-when"};}else c[f]=null;}a.optionalColumnConfig.whenMap=c;}else if(l){let g={};for(let f of s._def.optionalColumnConfig.columns){let y=f.toString();p?g[y]={__type:"Function",id:p,functionType:"optional-when"}:g[y]=null;}a.optionalColumnConfig.whenMap=g;}}s._def.uniqueColumnConfig&&(a.uniqueColumnConfig={uniqueConstraints:s._def.uniqueColumnConfig.uniqueConstraints.map(l=>{let d={id:l.id,columns:l.columns.map(c=>String(c))};if(l.key!==void 0){let c=`func_${Math.random().toString(36).substring(2,15)}`,p="unique-index";n.set(c,{id:c,functionType:p,function:l.key}),e?t.set(c,{functionType:p,id:c,functionSource:"remote"}):t.set(c,{function:l.key,functionType:p,id:c,functionSource:"local"}),d.hasKeyFn=true,d.keyFnId=c,d.key={__type:"Function",id:c,functionType:p};}return d})}),s._def.meta&&(a.meta=s._def.meta);let r=Z(a,t);return {json:JSON.stringify(r),functionMap:t,localFunctionMap:n}}var ye=class extends b{min(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExNumber.min: value must be a number");if(t!==void 0&&typeof t!="object")throw new Error("ExNumber.min: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExNumber.min: options.message must be a string");let n=this._findExistingCheck("min");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e<=l)return this}let a=this._findExistingCheck("max");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&e>a.check.params.value)throw new Error("ExNumber.min: min cannot be greater than max");let r=t?.message,u=this._addCheck("min",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}max(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExNumber.max: value must be a number");if(t!==void 0&&typeof t!="object")throw new Error("ExNumber.max: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExNumber.max: options.message must be a string");let n=this._findExistingCheck("max");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e>=l)return this}let a=this._findExistingCheck("min");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&a.check.params.value>e)throw new Error("ExNumber.max: max cannot be less than min");let r=t?.message,u=this._addCheck("max",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}integer(e){if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.integer: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.integer: options.message must be a string");let t=this._findExistingCheck("integer"),n=e?.message,a=this._addCheck("integer",{},n);return this._replaceOrAddCheck(a,t.index),this}multipleOf(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExNumber.multipleOf: value must be a number");if(e===0)throw new Error("ExNumber.multipleOf: value cannot be zero");if(t!==void 0&&typeof t!="object")throw new Error("ExNumber.multipleOf: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExNumber.multipleOf: options.message must be a string");let n=this._findExistingCheck("multipleOf");if(n.found&&n.check?.params){let u=n.check.params.value;if(typeof u=="number"&&e===u)return this}let a=t?.message,r=this._addCheck("multipleOf",{value:e},a);return this._def.checks.push(r),this}},J=class s extends ye{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.create: options.message must be a string");return new s({typeName:"ExNumber",checks:[],message:e?.message})}optional(){return new $({typeName:"ExOptional",innerType:this})}percentage(){if(this._def.currencyCode!==void 0)throw new Error("ExNumber.percentage: Cannot combine percentage with currency");return this._def.isPercentage=true,this}currency(e){if(typeof e!="string")throw new Error("ExNumber.currency: currencyCode must be a string");if(this._def.isPercentage)throw new Error("ExNumber.currency: Cannot combine currency with percentage");return this._def.currencyCode=e,this}};var X=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExBoolean.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExBoolean.create: options.message must be a string");if(e?.control!==void 0&&e.control!=="toggle"&&e.control!=="checkbox"&&e.control!=="dropdown")throw new Error('ExBoolean.create: options.control must be "toggle", "checkbox", or "dropdown"');return new s({typeName:"ExBoolean",control:e?.control,message:e?.message,checks:[]})}optional(){return new U({typeName:"ExOptional",innerType:this})}};var Q=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExDate.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExDate.create: options.message must be a string");let t=new s({typeName:"ExDate"});return e?.message&&(t._def.message=e.message),t}optional(){return new L({typeName:"ExOptional",innerType:this})}output(e){if(typeof e!="string")throw new Error("ExDate.output: template must be a string");if(e.trim()==="")throw new Error("ExDate.output: template cannot be empty");return this._def.outputFormat=e,this}};var ee=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExTime.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExTime.create: options.message must be a string");return new s({typeName:"ExTime",checks:[],message:e?.message})}optional(){return new j({typeName:"ExOptional",innerType:this})}precision(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExTime.precision: precision must be a number");if(e<0||e>9||!Number.isInteger(e))throw new Error("ExTime.precision: precision must be an integer between 0 and 9");if(t!==void 0&&typeof t!="object")throw new Error("ExTime.precision: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExTime.precision: options.message must be a string");return this._def.precision=e,t?.message&&(this._def.message=t.message),this}};var te=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExDatetime.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExDatetime.create: options.message must be a string");let t=new s({typeName:"ExDatetime",checks:[],message:e?.message});if(e?.message){let n=t._getDatetimeCheck();n&&(n.message=e.message);}return t}optional(){return new z({typeName:"ExOptional",innerType:this})}output(e){if(typeof e!="string")throw new Error("ExDatetime.output: template must be a string");if(e.trim()==="")throw new Error("ExDatetime.output: template cannot be empty");return this._def.outputFormat=e,this}allowOffset(e){if(e!==void 0&&typeof e!="object")throw new Error("ExDatetime.allowOffset: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExDatetime.allowOffset: options.message must be a string");let t=e?.message,n=this._getDatetimeCheck();return n?.params&&(n.params.offset=true,t&&(n.message=t)),this}_getDatetimeCheck(){let e=this._def.checks.find(t=>t.type==="datetime");if(!e){let t=this._addCheck("datetime",{allowOffset:false});return this._def.checks.push(t),t}return e}};var ne=class s extends b{static create(e,t={}){if(!Array.isArray(e))throw new Error("ExSelect.create: options must be an array");if(e.length===0)throw new Error("ExSelect.create: options array must not be empty");for(let a=0;a<e.length;a++){let r=e[a];if(!r||typeof r!="object")throw new Error(`ExSelect.create: option at index ${a} must be an object`);if(!("label"in r)||typeof r.label!="string")throw new Error(`ExSelect.create: option at index ${a} must have a string label`);if(!("value"in r))throw new Error(`ExSelect.create: option at index ${a} must have a value`);if(typeof r.value!="string"&&typeof r.value!="number")throw new Error(`ExSelect.create: option at index ${a} must have a string or number value`)}if(t!==void 0&&typeof t!="object")throw new Error("ExSelect.create: config must be an object");if(t.enforceCaseSensitiveMatch!==void 0&&typeof t.enforceCaseSensitiveMatch!="boolean")throw new Error("ExSelect.create: config.enforceCaseSensitiveMatch must be a boolean");if(t.allowCustom!==void 0&&typeof t.allowCustom!="boolean")throw new Error("ExSelect.create: config.allowCustom must be a boolean");if(t.message!==void 0&&typeof t.message!="string")throw new Error("ExSelect.create: config.message must be a string");return new s({typeName:"ExSelect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:!!t.allowCustom},checks:[],message:t.message})}optional(){return new K({typeName:"ExOptional",innerType:this})}caseSensitive(e=true){if(typeof e!="boolean")throw new Error("ExSelect.caseSensitive: enabled must be a boolean");return this._def.config.enforceCaseSensitiveMatch=e,this}};var ae=class s extends b{static create(e,t={}){if(!Array.isArray(e))throw new Error("ExMultiselect.create: options must be an array");if(e.length===0)throw new Error("ExMultiselect.create: options array must not be empty");for(let a=0;a<e.length;a++){let r=e[a];if(!r||typeof r!="object")throw new Error(`ExMultiselect.create: option at index ${a} must be an object`);if(!("label"in r)||typeof r.label!="string")throw new Error(`ExMultiselect.create: option at index ${a} must have a string label`);if(!("value"in r))throw new Error(`ExMultiselect.create: option at index ${a} must have a value`);if(typeof r.value!="string"&&typeof r.value!="number")throw new Error(`ExMultiselect.create: option at index ${a} must have a string or number value`)}if(t!==void 0&&typeof t!="object")throw new Error("ExMultiselect.create: config must be an object");if(t.enforceCaseSensitiveMatch!==void 0&&typeof t.enforceCaseSensitiveMatch!="boolean")throw new Error("ExMultiselect.create: config.enforceCaseSensitiveMatch must be a boolean");if(t.message!==void 0&&typeof t.message!="string")throw new Error("ExMultiselect.create: config.message must be a string");return new s({typeName:"ExMultiselect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:false},checks:[],message:t.message})}optional(){return new G({typeName:"ExOptional",innerType:this})}caseSensitive(e=true){if(typeof e!="boolean")throw new Error("ExMultiselect.caseSensitive: enabled must be a boolean");return this._def.config.enforceCaseSensitiveMatch=e,this}min(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExMultiselect.min: min must be a number");if(e<1||!Number.isInteger(e))throw new Error("ExMultiselect.min: min must be a positive integer (at least 1)");let n=this._findExistingCheck("min");if(n.found&&n.check?.params){let u=n.check.params.value;if(typeof u=="number"&&e<=u)return this}let a=this._findExistingCheck("max");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&e>a.check.params.value)throw new Error("ExMultiselect.min: min cannot be greater than max");let r=this._addCheck("min",{value:e},t);return this._replaceOrAddCheck(r,n.index),this}max(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExMultiselect.max: max must be a number");if(e<1||!Number.isInteger(e))throw new Error("ExMultiselect.max: max must be a positive integer");let n=this._findExistingCheck("max");if(n.found&&n.check?.params){let u=n.check.params.value;if(typeof u=="number"&&e>=u)return this}let a=this._findExistingCheck("min");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&a.check.params.value>e)throw new Error("ExMultiselect.max: max cannot be less than min");let r=this._addCheck("max",{value:e},t);return this._replaceOrAddCheck(r,n.index),this}};function It(){return `uc_${Math.random().toString(36).substring(2,15)}${Math.random().toString(36).substring(2,15)}`}var V=class s extends _{static create(e){if(!e||typeof e!="object")throw new Error("ExRow.create: shape must be a non-null object");for(let[t,n]of Object.entries(e)){if(!n||typeof n!="object")throw new Error(`ExRow.create: field "${t}" must be a valid field type`);if(!("_def"in n)||!n._def||typeof n._def!="object")throw new Error(`ExRow.create: field "${t}" is not a valid ExpressCSV field`);if(!("typeName"in n._def)||typeof n._def.typeName!="string")throw new Error(`ExRow.create: field "${t}" is missing a typeName`)}return new s({typeName:"ExRow",shape:e})}optionalColumns(e,t){if(!Array.isArray(e))throw new Error("ExRow.optionalColumns: columns must be an array");for(let l of e)if(!(l in this._def.shape))throw new Error(`ExRow.optionalColumns: column "${String(l)}" does not exist in the row shape`);if(t!==void 0&&typeof t!="object")throw new Error("ExRow.optionalColumns: options must be an object");if(t?.when!==void 0&&typeof t.when!="function")throw new Error("ExRow.optionalColumns: options.when must be a function");let n=e,a=t?.when;if(!this._def.optionalColumnConfig)return this._def.optionalColumnConfig={columns:n,when:a,whenMap:a?Object.fromEntries(n.map(l=>[l,a])):void 0},this;let u=[...this._def.optionalColumnConfig.columns];for(let l of n)u.includes(l)||u.push(l);if(this._def.optionalColumnConfig.columns=u,a){this._def.optionalColumnConfig.whenMap||(this._def.optionalColumnConfig.whenMap={});for(let l of n)this._def.optionalColumnConfig.whenMap[l]=a;}return this}unique(e,t){if(e===void 0)throw new Error("ExRow.unique: columns must be provided");let n=Array.isArray(e)?e:[e];for(let c of n)if(!(c in this._def.shape))throw new Error(`ExRow.unique: column "${String(c)}" does not exist in the row shape`);if(t!==void 0&&typeof t!="object")throw new Error("ExRow.unique: options must be an object");if(t?.key!==void 0&&typeof t.key!="function")throw new Error("ExRow.unique: options.key must be a function");let a=t?.key;this._def.uniqueColumnConfig||(this._def.uniqueColumnConfig={uniqueConstraints:[]});let r=a?c=>{let p=Object.fromEntries(n.map(g=>[g,c[g]]));return a(p)}:void 0,u=(c,p)=>{if(c.length!==p.length)return false;let g=[...c].sort(),f=[...p].sort();return g.every((y,I)=>y===f[I])},l=this._def.uniqueColumnConfig.uniqueConstraints.findIndex(c=>u(c.columns,n)),d={id:It(),columns:n,key:r};return l!==-1?this._def.uniqueColumnConfig.uniqueConstraints[l]=d:this._def.uniqueColumnConfig.uniqueConstraints.push(d),this}meta(e){if(e===void 0||typeof e!="object")throw new Error("ExRow.meta: metadata must be an object");if(e.description!==void 0&&typeof e.description!="string")throw new Error("ExRow.meta: metadata.description must be a string");return this._def.meta={...this._def.meta,...e},this}minRows(e){if(typeof e!="number")throw new Error("ExRow.minRows: count must be a number");if(!Number.isInteger(e))throw new Error("ExRow.minRows: count must be an integer");if(e<0)throw new Error("ExRow.minRows: count must be non-negative");return this._def.rowCountConfig||(this._def.rowCountConfig={}),this._def.rowCountConfig.minRows=e,this}maxRows(e){if(typeof e!="number")throw new Error("ExRow.maxRows: count must be a number");if(!Number.isInteger(e))throw new Error("ExRow.maxRows: count must be an integer");if(e<=0)throw new Error("ExRow.maxRows: count must be positive");return this._def.rowCountConfig||(this._def.rowCountConfig={}),this._def.rowCountConfig.maxRows=e,this}};var _e={string:q.create,number:J.create,boolean:X.create,date:Q.create,time:ee.create,datetime:te.create,row:V.create,select:ne.create,multiselect:ae.create,infer:s=>{}};var Dt=class{constructor(){this.items=[],this.processing=false;}enqueue(s){this.items.push(s);}dequeueUpTo(s){if(this.processing||this.items.length===0)return [];this.processing=true;let e=this.items.splice(0,s);return this.processing=false,e}size(){return this.items.length}isEmpty(){return this.items.length===0}dispose(){this.items=[];}};async function Mt(s,e){return Promise.all(s.map(t=>e(t)))}var x=(s=>(s.UNINITIALIZED="uninitialized",s.INITIALIZING="initializing",s.READY="ready",s.OPENING="opening",s.OPEN="open",s.CLOSING="closing",s.RESETTING="resetting",s.ERROR="error",s.DESTROYED="destroyed",s))(x||{}),S=(s=>(s.NORMAL="normal",s.PRELOAD="preload",s))(S||{}),pe={maxSize:200,maxDelay:50},Nt={maxRetries:3,retryDelay:500,acknowledgmentTimeout:2e3};function re(s="msg"){return `${s}_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Pt(s,e,t={}){let n=t.timeout||5e3,a={...Nt,...t.messagingConfig},r=new Map,u=[],l=null,d=new Dt,c=null,p=[],g=null,f=true,y=new Map,I=h=>{let m={kind:"singleton",type:"ack",id:h,retryCount:0,originalSentAt:Date.now()};s.postMessage(m,e);},A=h=>{let m=y.get(h);m&&(m.timeout&&clearTimeout(m.timeout),y.delete(h));},D=h=>{h.id||(h.id=re());try{s.postMessage(h,e);let m=0,w=setTimeout(()=>{k(h.id);},a.acknowledgmentTimeout);y.set(h.id,{message:h,retryCount:m,timeout:w});}catch(m){console.error("Error posting message:",m),f=false;}},k=h=>{let m=y.get(h);if(!m)return;if(m.retryCount>=a.maxRetries){if(y.delete(h),m.message.kind==="batch"&&m.message.type==="batch-rpc")for(let E of m.message.calls){let R=r.get(E.requestId);R&&(R.reject(new Error(`RPC call failed after ${a.maxRetries} retries`)),r.delete(E.requestId));}return}m.retryCount++,m.message.retryCount=m.retryCount,m.message.originalSentAt=m.message.originalSentAt||Date.now();try{s.postMessage(m.message,e);}catch(E){console.error("Error retrying message:",E),f=false;}let w=a.retryDelay*2**m.retryCount;m.timeout=setTimeout(()=>{k(h);},w),y.set(h,m);},se=h=>{if(e!=="*"&&h.origin!==e)return;let m=h.data;if(!(!m||typeof m!="object")){if(m.kind==="singleton"&&m.type==="ack"&&m.id){A(m.id);return}if(m.id&&I(m.id),m.kind==="singleton")if(m.type==="response"&&m.id){let w=r.get(m.id);w&&(m.error?w.reject(new Error(m.error)):w.resolve(m.data),r.delete(m.id));}else for(let w of u)try{w(m);}catch(E){console.error("Error in message handler:",E);}else if(m.kind==="batch"&&m.type==="batch-rpc-response")for(let w of m.responses){let E=r.get(w.requestId);E&&(w.status==="error"?E.reject(new Error(w.error.message||"RPC call failed")):E.resolve(w.result),r.delete(w.requestId));}else m.kind==="batch"&&m.type==="batch-rpc"&&T(m);}},T=async h=>{if(!l){for(let E of h.calls)B({requestId:E.requestId,functionId:E.functionId,status:"error",error:{code:"METHOD_NOT_FOUND",message:"No RPC handler registered"}});Ee();return}let m=l,w=await Mt(h.calls,async E=>{try{let R=await m({functionName:E.functionName,requestId:E.requestId,functionId:E.functionId,params:E.params});return {requestId:E.requestId,functionId:E.functionId,status:"success",result:R}}catch(R){return {requestId:E.requestId,functionId:E.functionId,status:"error",error:{code:"EXECUTION_ERROR",message:R instanceof Error?R.message:"Unknown error",details:R}}}});for(let E of w)p.push(E);p.length>0&&fe();},B=h=>{p.push(h),p.length>=pe.maxSize?fe():Ee();},fe=()=>{if(p.length===0)return;let h={kind:"batch",type:"batch-rpc-response",id:re("batch_resp"),responses:[...p],retryCount:0,originalSentAt:Date.now()};p=[],g&&(clearTimeout(g),g=null),D(h);},Ee=()=>{g||(g=setTimeout(()=>{fe();},pe.maxDelay));},we=()=>{if(d.isEmpty())return;let h=d.size(),m=d.dequeueUpTo(h);if(m.length===0)return;let w={kind:"batch",type:"batch-rpc",id:re("batch"),calls:[...m],retryCount:0,originalSentAt:Date.now()};c&&(clearTimeout(c),c=null),D(w);},Le=()=>{c||(c=setTimeout(()=>{we(),c=null;},pe.maxDelay));};return window.addEventListener("message",se),{callRPC:({functionName:h,functionId:m,params:w})=>new Promise((E,R)=>{let ie=re("rpc"),ze={requestId:ie,functionName:h,functionId:m,params:w};r.set(ie,{resolve:de=>{E(de);},reject:de=>{R(de);}}),setTimeout(()=>{r.has(ie)&&(r.delete(ie),R(new Error(`Call to ${h} timed out`)));},n),d.enqueue(ze),d.size()>=pe.maxSize?we():Le();}),registerRPCHandler:h=>{l=h;},sendMessage:h=>{let m={...h,kind:"singleton",id:re(),retryCount:0,originalSentAt:Date.now()};D(m);},registerMessageHandler:h=>{u.push(h);},disconnect:()=>{window.removeEventListener("message",se);for(let[,h]of r)h.reject(new Error("Connection closed"));for(let[,h]of y)h.timeout&&clearTimeout(h.timeout);c&&clearTimeout(c),g&&clearTimeout(g),r.clear(),y.clear(),d.dispose(),p=[],f=false;},getConnectionStatus:()=>f}}function Ve(s,e={}){let t=s.contentWindow;if(!t)throw new Error("Cannot connect to iframe: contentWindow is null");let n=e.targetOrigin||new URL(s.src).origin||"*";return Pt(t,n,e)}var xe=class s extends Error{constructor(e="Import was cancelled by the user"){super(e),this.name="ImportCancelledError",Error.captureStackTrace&&Error.captureStackTrace(this,s);}};var Ue=class{constructor(e){this.options=e;this.iframe=null;this.container=null;this.connection=null;this.connectionState=false;this.debug=false;this.developerMode=false;this.sessionId=null;this._destroyTimer=null;this._beforeUnloadHandler=null;this.widgetUrl=process.env.NODE_ENV==="development"?"http://localhost:3001":"https://widget.expresscsv.com";this.widgetState=x.UNINITIALIZED;this.canRestart=false;this.lastError=null;this.openOptions=null;this.cachedSchemaJson=null;this.initCompletePromise=null;this.resolveInitComplete=null;this.debug=e.debug||false,this.developerMode=e.developerMode||false,this.importIdentifier=e.importIdentifier,this.widgetMode=e.preload!==false?S.PRELOAD:S.NORMAL,this.log("Initializing CSVImporter with options:",e),e.preload!==false&&(this.setState(x.INITIALIZING,"Auto-preload initialization"),this.initCompletePromise=new Promise(t=>{this.resolveInitComplete=t;}),this.initializeIframe(true).catch(t=>{this.log("Auto-preload failed:",t),this.initCompletePromise=null,this.resolveInitComplete=null,this.handleError(t instanceof Error?t:new Error("Preload failed"));}));}setState(e,t){this.widgetState=e,this.log(`State change: \u2192 ${e}`,t),this.connection&&this.connection.sendMessage({type:"action:sync_state",data:{sdkState:e,mode:this.widgetMode}}),this.updateDerivedState();}updateDerivedState(){this.canRestart=this.widgetState===x.READY||this.widgetState===x.ERROR;}handleError(e){this.lastError=e,this.setState(x.ERROR,e.message),this.openOptions?.onError?.(e),this.openOptions=null;}async waitForEvent(e,t=5e3){return new Promise((n,a)=>{let r=setTimeout(()=>{a(new Error(`Timeout waiting for ${e}`));},t),u=l=>{l.type===e&&(clearTimeout(r),n(l.data));};this.connection?.registerMessageHandler(u);})}open(e){if(this.log("open() called",e),this.openOptions){this.log("open() called while already active, ignoring");return}if(this.sessionId=crypto.randomUUID(),this.connection&&this.widgetState===x.READY&&this.connection.sendMessage({type:"action:update_session_id",data:{sessionId:this.sessionId}}),this.openOptions=e,!this.cachedSchemaJson){let t=Y(this.options.schema,true);this.cachedSchemaJson=t.json;}this.openWidget().then(()=>{this.log("Widget opened successfully for open()"),this.createImportSession({chunkSize:e.chunkSize,webhook:e.webhook}).catch(t=>{if(this.log("Failed to create import session:",t),t.code==="NO_ACCESS"){this.connection&&this.connection.sendMessage({type:"action:set_error",data:{message:"Unable to start import. If you are the administrator of this account, please access your ExpressCSV dashboard for more information.",code:"NO_ACCESS"}});let a=new Error("Unable to start import. If you are the administrator of this account, please access your ExpressCSV dashboard for more information.");this.openOptions?.onError?.(a);}else {let a=t instanceof Error?t:new Error("Failed to create import session");this.openOptions?.onError?.(a);}});}).catch(t=>{this.log("Failed to open widget in open():",t);let n=t instanceof Error?t:new Error("Failed to open widget");this.openOptions?.onError?.(n),this.openOptions=null;});}async createImportSession({chunkSize:e,webhook:t}){if(!this.sessionId)throw new Error("Session ID not initialized");if(!this.cachedSchemaJson)throw new Error("Schema not serialized yet. Call open() after widget initialization.");let a=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/import-sessions`,r={schema:this.cachedSchemaJson,chunkSize:e,title:this.options.title,theme:this.options.theme,colorMode:this.options.colorMode,customCSS:this.options.customCSS,fonts:this.options.fonts,stepDisplay:this.options.stepDisplay,developerMode:this.options.developerMode,debug:this.options.debug,previewSchemaBeforeUpload:this.options.previewSchemaBeforeUpload??true};t&&(r.webhook={url:t.url,headers:t.headers,method:t.method,metadata:t.metadata});let u=await fetch(a,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,configuration:r})});if(!u.ok){let l,d="Unknown error";try{let p=await u.json();l=p.code,d=p.message||p.error||d;}catch{d=await u.text().catch(()=>"Unknown error");}let c=new Error(`Failed to create import session: ${u.status} ${u.statusText} - ${d}`);throw c.code=l,c}this.log("Import session created successfully",{sessionId:this.sessionId});}async deliverToWebhook(e,t,n,a){let u=e.length,l=Math.ceil(u/1e3);for(let d=0;d<l;d++){let c=d*1e3,p=Math.min(c+1e3,u),f={records:e.slice(c,p),totalChunks:l,currentChunkIndex:d,totalRecords:n.totalRecords};await this.sendChunkToBackend(f,t,a);}}async sendChunkToBackend(e,t,n){if(!this.sessionId)throw new Error("Session ID not initialized. Call open() first.");let r=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/webhooks/deliver`,u=3,l=3e4,d=null;for(let c=0;c<=u;c++){let p=new AbortController,g=setTimeout(()=>p.abort(),l);try{let f=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,webhook:{url:t.url,headers:t.headers,method:t.method,metadata:t.metadata,chunkSize:n},chunk:{records:e.records,totalChunks:e.totalChunks,currentChunkIndex:e.currentChunkIndex,totalRecords:e.totalRecords}}),signal:p.signal});if(clearTimeout(g),!f.ok){let y=f.status;if(y>=400&&y<500&&y!==429){let I=await f.text().catch(()=>"Unknown error");throw new Error(`Backend API error: ${y} ${f.statusText} - ${I}`)}throw new Error(`Backend API error: ${y} ${f.statusText}`)}this.log(`Chunk ${e.currentChunkIndex+1}/${e.totalChunks} sent to backend successfully (attempt ${c+1})`);return}catch(f){clearTimeout(g),d=f instanceof Error?f:new Error(String(f)),this.log(`Failed to send chunk to backend (attempt ${c+1}/${u+1}):`,d),c<u&&await new Promise(y=>setTimeout(y,2**c*1e3));}}throw d||new Error("Failed to send chunk to backend")}async processResultsInChunks(e){if(!this.openOptions){this.log("No open options available, skipping chunk processing");return}let{chunkSize:t=1e3,onData:n,webhook:a,onComplete:r,onError:u}=this.openOptions,l=e.length,d=t<=0?l:t,c=Math.ceil(l/d);this.log(`Processing ${l} records in ${c} chunks of ${d}`);try{for(let p=0;p<c;p++){let g=p*d,f=Math.min(g+d,l),I={records:e.slice(g,f),totalChunks:c,currentChunkIndex:p,totalRecords:l};n&&await new Promise((A,D)=>{try{let k=n(I,A);k instanceof Promise&&k.catch(D);}catch(k){D(k);}});}if(a){let p={records:[],totalChunks:c,currentChunkIndex:c-1,totalRecords:l};await this.deliverToWebhook(e,a,p,d);}this.log("All chunks processed successfully"),r?.();}catch(p){this.log("Error during chunk processing:",p);let g=p instanceof Error?p:new Error(String(p));u?.(g);}finally{this.openOptions=null;}}async initializeIframe(e=false){this.log(`Initializing iframe (hidden: ${e})`),(this.iframe||this.container||this.connection)&&(this.log("Cleaning up existing resources before initialization"),this.destroy(false));try{this.container=document.createElement("div"),e?(this.container.style.position="fixed",this.container.style.top="-9999px",this.container.style.left="-9999px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.pointerEvents="none",this.container.style.visibility="hidden",this.container.style.zIndex="-1"):(this.container.style.position="fixed",this.container.style.inset="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.zIndex="2147483647",this.container.style.visibility="visible"),document.body.appendChild(this.container),this.log(`Created ${e?"hidden":"visible"} container`),this.createAndAppendIframe(this.container),this.log("Created iframe"),await this.waitForIframeLoad(),await this.setupConnectionAndInit(),this.log(`Iframe initialization complete (hidden: ${e})`);}catch(t){throw this.log("Iframe initialization failed:",t),this.destroy(false),t}}log(...e){(this.debug||process.env.NODE_ENV==="development")&&console.log("[CSVImporter]",...e);}error(...e){console.error("[CSVImporter]",...e);}addBeforeUnloadListener(){if(this._beforeUnloadHandler){this.log("beforeunload listener already exists");return}this._beforeUnloadHandler=e=>{let t="You have an import in progress. Are you sure you want to leave? Your progress will be lost.";return e.preventDefault(),t},window.addEventListener("beforeunload",this._beforeUnloadHandler),this.log("Added beforeunload listener");}removeBeforeUnloadListener(){this._beforeUnloadHandler&&(window.removeEventListener("beforeunload",this._beforeUnloadHandler),this._beforeUnloadHandler=null,this.log("Removed beforeunload listener"));}async waitForIframeLoad(){return new Promise((e,t)=>{if(!this.iframe){this.log("No iframe available, rejecting promise"),t(new Error("No iframe available"));return}try{if(this.iframe.contentWindow&&this.iframe.contentDocument&&this.iframe.contentDocument.readyState==="complete"){this.log("Iframe already loaded (cached)"),e();return}}catch{this.log("Cannot check iframe load state (CORS), waiting for onload");}let n=false,a=()=>{this.iframe&&(this.iframe.onload=null,this.iframe.onerror=null);},r=()=>{n||(n=true,clearTimeout(l),a(),e());},u=d=>{n||(n=true,clearTimeout(l),a(),t(d));},l=setTimeout(()=>{this.log("Iframe load timeout reached"),u(new Error("Iframe load timeout"));},1e4);this.iframe.onload=()=>{this.log("Iframe loaded successfully"),r();},this.iframe.onerror=d=>{this.error("Iframe failed to load:",d),u(new Error("Failed to load iframe"));};})}async setupConnectionAndInit(){if(this.log("Creating connection to iframe"),this.connection=this.iframe?Ve(this.iframe):null,!this.connection||!this.iframe)throw this.log("Failed to create connection or iframe is missing"),new Error("Failed to create iframe or establish connection");this.log("Setting up message handlers"),this.setupMessageHandlers(),this.log("Sending init message",this.options);let e=Y(this.options.schema,true);this.cachedSchemaJson=e.json,this.initCompletePromise||(this.initCompletePromise=new Promise(t=>{this.resolveInitComplete=t;})),this.connection.sendMessage({type:"action:init",data:{schemaJson:e.json,functionMapJson:JSON.stringify([...e.functionMap]),title:this.options.title,publishableKey:this.options.publishableKey,importIdentifier:this.importIdentifier,developerMode:this.developerMode,theme:this.options.theme,colorMode:this.options.colorMode,customCSS:this.options.customCSS,fonts:this.options.fonts,stepDisplay:this.options.stepDisplay||"progressBar",previewSchemaBeforeUpload:this.options.previewSchemaBeforeUpload??true,templateDownload:this.options.templateDownload,saveSession:this.options.saveSession,locale:this.options.locale}}),this.connection.registerRPCHandler(async({functionName:t,functionId:n,params:a})=>{let r=e.localFunctionMap.get(n);if(!r)throw new Error(`Unknown function: ${t}`);let u=r.function;return await u(a)}),this.connectionState=true,this.log("Connection established and initialized");}async openWidget(e){if(this.log("openWidget() called",{currentState:this.widgetState,options:e}),this.widgetState===x.OPEN){this.log("Widget is already open, ignoring openWidget() call");return}let t=this.widgetState;this.setState(x.OPENING,"User requested open");try{e?.reset&&await this.resetWidget(),this.widgetMode===S.PRELOAD&&t===x.READY?(this.log("Using preloaded iframe - making visible instantly"),this.makeContainerVisible(),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:e?.reset,sessionId:this.sessionId??void 0}})):this.widgetMode===S.PRELOAD&&this.initCompletePromise?(this.log("Preload in progress, awaiting init_complete before opening"),await this.initCompletePromise,this.makeContainerVisible(),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:e?.reset,sessionId:this.sessionId??void 0}})):(this.log("Initializing iframe for immediate display"),await this.initializeIframe(!1),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:e?.reset,sessionId:this.sessionId??void 0}})),this.setState(x.OPEN,"Widget opened successfully"),this.openOptions?.onWidgetOpen?.(),this.addBeforeUnloadListener();}catch(n){throw this.log("Failed to open widget:",n),this.handleError(n instanceof Error?n:new Error("Failed to open widget")),n}}makeContainerVisible(){this.container&&(this.log("Making container visible"),this.container.style.position="fixed",this.container.style.inset="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.zIndex="2147483647",this.container.style.visibility="visible",this.container.style.pointerEvents="auto",this.container.style.top="0px",this.container.style.left="0px",this.iframe&&(this.iframe.style.pointerEvents="auto"));}setupMessageHandlers(){if(!this.connection){this.log("Cannot setup message handlers - no connection available");return}this.log("Registering onMessage handler"),this.connection.registerMessageHandler(async e=>{if(e.type==="event:results"){this.log("Processing results message");let t=e.data;this.openOptions?(await this.processResultsInChunks(t),this.connection&&this.connection.sendMessage({type:"event:results_processed"})):this.connection&&this.connection.sendMessage({type:"event:results_processed"});}else if(e.type==="event:init_complete")this.log("Widget initialized successfully"),this.resolveInitComplete&&(this.resolveInitComplete(),this.resolveInitComplete=null),this.setState(x.READY,"Widget initialization complete");else if(e.type==="event:widget_closed"){this.log("Processing widget closed message:",e.data);let t=e.data.reason;this.openOptions?.onWidgetClose?.(t),t==="cancel"&&this.openOptions&&(this.openOptions.onCancel?.(),this.openOptions=null),await this.handleWidgetClosed(t);}else if(e.type==="event:step_change"){this.log("Processing step change message:",e.data);let t=e.data.stepId,n=e.data.previousStepId;this.openOptions?.onStepChange?.(t,n);}else e.type==="event:state_change"?this.log("Widget state changed:",e.data):e.type==="event:widget_status"?this.log("Widget status update:",e.data):e.type==="event:reset_complete"?this.log("Widget reset complete:",e.data):e.type==="event:restart_complete"&&this.log("Widget restart complete:",e.data);});}createAndAppendIframe(e){this.log("Creating iframe"),this.iframe=document.createElement("iframe"),this.iframe.src=this.widgetUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none",this.iframe.style.overflow="hidden",e.appendChild(this.iframe),this.log("Iframe appended to container, URL:",this.widgetUrl);}destroy(e=true){if(this.log("destroy() called, resetReadyState:",e),this._destroyTimer!==null&&(this.log("Clearing existing destroy timer"),window.clearTimeout(this._destroyTimer),this._destroyTimer=null),this.widgetState===x.DESTROYED&&!this.iframe&&!this.container&&!this.connection){this.log("Already destroyed, nothing to do");return}this.removeBeforeUnloadListener(),this.initCompletePromise=null,this.resolveInitComplete=null;try{this.connection&&(this.log("Disconnecting connection"),this.connection.disconnect(),this.connection=null,this.connectionState=!1),this.iframe&&(this.log("Cleaning up iframe"),this.iframe.onload=null,this.iframe.onerror=null,this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.iframe=null),this.container&&(this.log("Cleaning up container"),this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=null),this.log("Destroy complete");}catch(t){this.error("Error during destroy:",t);}}async close(e="user_close"){if(this.log("close() called",{currentState:this.widgetState,reason:e}),this.widgetState===x.CLOSING||this.widgetState===x.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}if(this.widgetState!==x.OPEN){this.log("Not open, ignoring close call");return}this.setState(x.CLOSING,`Close requested: ${e}`);try{this.connection&&(this.log("Sending close message to widget"),this.connection.sendMessage({type:"action:close_widget",data:{reason:e}}));}catch(t){this.error("Error during close preparation:",t);}this.removeBeforeUnloadListener(),this.widgetMode===S.PRELOAD?(this.hideContainer(),this.setState(x.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(x.DESTROYED,"Normal mode widget destroyed"));}async resetWidget(){this.log("resetWidget() called",{currentState:this.widgetState}),this.setState(x.RESETTING,"Reset requested");try{this.connection&&(this.connection.sendMessage({type:"action:reset_widget",data:{preserveConnection:this.widgetMode===S.PRELOAD}}),await this.waitForEvent("event:reset_complete")),this.lastError=null,this.widgetMode===S.PRELOAD?this.setState(x.READY,"Reset complete - preload mode"):this.setState(x.UNINITIALIZED,"Reset complete - normal mode");}catch(e){throw this.handleError(e instanceof Error?e:new Error("Reset failed")),e}}async restart(e){if(this.log("restart() called",{currentState:this.widgetState,newOptions:e}),!this.canRestart)throw new Error("Widget cannot be restarted in current state");try{await this.resetWidget(),e&&(Object.assign(this.options,e),this.widgetMode=this.options.preload!==!1?S.PRELOAD:S.NORMAL,this.connection&&(this.connection.sendMessage({type:"action:restart_widget",data:{newOptions:e}}),await this.waitForEvent("event:restart_complete"))),await this.openWidget();}catch(t){throw this.handleError(t instanceof Error?t:new Error("Restart failed")),t}}async handleWidgetClosed(e){if(this.log("handleWidgetClosed() called",{currentState:this.widgetState,reason:e}),this.widgetState===x.CLOSING||this.widgetState===x.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}this.setState(x.CLOSING,`Widget closed: ${e}`),this.removeBeforeUnloadListener(),this.widgetMode===S.PRELOAD?(this.hideContainer(),this.setState(x.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(x.DESTROYED,"Normal mode widget destroyed"));}hideContainer(){this.container&&(this.log("Hiding container for reuse"),this.container.style.visibility="hidden",this.container.style.pointerEvents="none",this.container.style.zIndex="-1",this.container.style.top="-9999px",this.container.style.left="-9999px");}getConnectionStatus(){let e=this.connectionState&&this.connection?.getConnectionStatus();return this.log("getConnectionStatus() called, returning:",e),!!e}getState(){return this.widgetState}getMode(){return this.widgetMode}getIsReady(){let e=this.widgetState===x.READY||this.widgetState===x.OPEN;return this.log("getIsReady() called, returning:",e),e}getIsOpen(){let e=this.widgetState===x.OPEN;return this.log("getIsOpen() called, returning:",e),e}getCanRestart(){return this.log("getCanRestart() called, returning:",this.canRestart),this.canRestart}getLastError(){return this.lastError}getStatus(){return {state:this.widgetState,mode:this.widgetMode,isReady:this.getIsReady(),isOpen:this.getIsOpen(),canRestart:this.canRestart,hasError:!!this.lastError,lastError:this.lastError,connectionStatus:this.getConnectionStatus()}}getVersion(){let e="2.0.0";return this.log("getVersion() called, returning:",e),e}};
2
+ exports.CSVImporter=Ue;exports.ImportCancelledError=xe;exports.WidgetMode=S;exports.WidgetState=x;exports.x=_e;
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ var _=class{constructor(e){this._def=e;}_addCheck(e,t,n){return {type:e,params:t,message:n}}},b=class extends _{columnNameAliases(e){return this._def.columnNameAliases=e,this}description(e){return this._def.description=e,this}label(e){return this._def.label=e,this}example(e){return this._def.example=e,this}refine(e,t){let n=this._addCheck("refine",{validator:e,params:t});return this._def.checks||(this._def.checks=[]),this._def.checks.push(n),this}refineBatch(e,t){let n=this._addCheck("refineBatch",{validator:e,params:t});return this._def.checks||(this._def.checks=[]),this._def.checks.push(n),this}_findExistingCheck(e){if(!this._def.checks)return {check:void 0,index:-1,found:false};let t=this._def.checks.findIndex(r=>r.type===e),n=t!==-1;return {check:n?this._def.checks[t]:void 0,index:t,found:n}}_replaceOrAddCheck(e,t){this._def.checks||(this._def.checks=[]),t!==-1?this._def.checks[t]=e:this._def.checks.push(e);}};var be=[{name:"Afghanistan",alpha2:"AF",alpha3:"AFG",aliases:["Af\u0121\u0101nist\u0101n","\u0627\u0641\u063A\u0627\u0646\u0633\u062A\u0627\u0646"]},{name:"\xC5land Islands",alpha2:"AX",alpha3:"ALA",aliases:["Ahvenanmaa","\xC5land"]},{name:"Albania",alpha2:"AL",alpha3:"ALB",aliases:["Shqip\xEBri","Shqip\xEBria"]},{name:"Algeria",alpha2:"DZ",alpha3:"DZA",aliases:["\u0627\u0644\u062C\u0632\u0627\u0626\u0631","Alg\xE9rie"]},{name:"American Samoa",alpha2:"AS",alpha3:"ASM",aliases:["S\u0101moa Amelika","Amelika S\u0101moa"]},{name:"Andorra",alpha2:"AD",alpha3:"AND",aliases:["Principat d'Andorra"]},{name:"Angola",alpha2:"AO",alpha3:"AGO",aliases:["Rep\xFAblica de Angola"]},{name:"Anguilla",alpha2:"AI",alpha3:"AIA",aliases:[]},{name:"Antigua and Barbuda",alpha2:"AG",alpha3:"ATG",aliases:["Antigua","Barbuda"]},{name:"Argentina",alpha2:"AR",alpha3:"ARG",aliases:["Rep\xFAblica Argentina","Argentine Republic"]},{name:"Armenia",alpha2:"AM",alpha3:"ARM",aliases:["\u0540\u0561\u0575\u0561\u057D\u057F\u0561\u0576","Hayastan","Republic of Armenia"]},{name:"Aruba",alpha2:"AW",alpha3:"ABW",aliases:[]},{name:"Australia",alpha2:"AU",alpha3:"AUS",aliases:["Commonwealth of Australia","Oz"]},{name:"Austria",alpha2:"AT",alpha3:"AUT",aliases:["\xD6sterreich"]},{name:"Azerbaijan",alpha2:"AZ",alpha3:"AZE",aliases:["Az\u0259rbaycan","Republic of Azerbaijan"]},{name:"Bahamas",alpha2:"BS",alpha3:"BHS",aliases:["The Bahamas","Commonwealth of The Bahamas"]},{name:"Bahrain",alpha2:"BH",alpha3:"BHR",aliases:["\u0627\u0644\u0628\u062D\u0631\u064A\u0646","Kingdom of Bahrain"]},{name:"Bangladesh",alpha2:"BD",alpha3:"BGD",aliases:["\u09AC\u09BE\u0982\u09B2\u09BE\u09A6\u09C7\u09B6","People's Republic of Bangladesh"]},{name:"Barbados",alpha2:"BB",alpha3:"BRB",aliases:[]},{name:"Belarus",alpha2:"BY",alpha3:"BLR",aliases:["\u0411\u0435\u043B\u0430\u0440\u0443\u0441\u044C","Republic of Belarus","Belorussia"]},{name:"Belgium",alpha2:"BE",alpha3:"BEL",aliases:["Belgi\xEB","Belgique","Belgien"]},{name:"Belize",alpha2:"BZ",alpha3:"BLZ",aliases:[]},{name:"Benin",alpha2:"BJ",alpha3:"BEN",aliases:["Republic of Benin","R\xE9publique du B\xE9nin"]},{name:"Bermuda",alpha2:"BM",alpha3:"BMU",aliases:[]},{name:"Bhutan",alpha2:"BT",alpha3:"BTN",aliases:["\u0F60\u0F56\u0FB2\u0F74\u0F42\u0F0B\u0F61\u0F74\u0F63\u0F0B","Druk Yul","Kingdom of Bhutan"]},{name:"Bolivia",alpha2:"BO",alpha3:"BOL",aliases:["Bolivia","Estado Plurinacional de Bolivia"]},{name:"Bonaire, Sint Eustatius and Saba",alpha2:"BQ",alpha3:"BES",aliases:["Caribbean Netherlands"]},{name:"Bosnia and Herzegovina",alpha2:"BA",alpha3:"BIH",aliases:["Bosna i Hercegovina"]},{name:"Botswana",alpha2:"BW",alpha3:"BWA",aliases:["Republic of Botswana"]},{name:"Brazil",alpha2:"BR",alpha3:"BRA",aliases:["Brasil","Federative Republic of Brazil"]},{name:"British Indian Ocean Territory",alpha2:"IO",alpha3:"IOT",aliases:[]},{name:"Brunei Darussalam",alpha2:"BN",alpha3:"BRN",aliases:["Brunei"]},{name:"Bulgaria",alpha2:"BG",alpha3:"BGR",aliases:["\u0411\u044A\u043B\u0433\u0430\u0440\u0438\u044F","Republic of Bulgaria"]},{name:"Burkina Faso",alpha2:"BF",alpha3:"BFA",aliases:["Burkina"]},{name:"Burundi",alpha2:"BI",alpha3:"BDI",aliases:["Republic of Burundi","Republika y'Uburundi"]},{name:"Cabo Verde",alpha2:"CV",alpha3:"CPV",aliases:["Cape Verde"]},{name:"Cambodia",alpha2:"KH",alpha3:"KHM",aliases:["\u1780\u1798\u17D2\u1796\u17BB\u1787\u17B6","Kingdom of Cambodia"]},{name:"Cameroon",alpha2:"CM",alpha3:"CMR",aliases:["Cameroun","Republic of Cameroon"]},{name:"Canada",alpha2:"CA",alpha3:"CAN",aliases:["Kanada","Canada (French)"]},{name:"Cayman Islands",alpha2:"KY",alpha3:"CYM",aliases:[]},{name:"Central African Republic",alpha2:"CF",alpha3:"CAF",aliases:["R\xE9publique centrafricaine"]},{name:"Chad",alpha2:"TD",alpha3:"TCD",aliases:["Tchad","\u062C\u0645\u0647\u0648\u0631\u064A\u0629 \u062A\u0634\u0627\u062F"]},{name:"Chile",alpha2:"CL",alpha3:"CHL",aliases:["Rep\xFAblica de Chile"]},{name:"China",alpha2:"CN",alpha3:"CHN",aliases:["\u4E2D\u534E\u4EBA\u6C11\u5171\u548C\u56FD","\u4E2D\u56FD","Zh\u014Dnggu\xF3","People's Republic of China","PRC"]},{name:"Christmas Island",alpha2:"CX",alpha3:"CXR",aliases:[]},{name:"Cocos (Keeling) Islands",alpha2:"CC",alpha3:"CCK",aliases:[]},{name:"Colombia",alpha2:"CO",alpha3:"COL",aliases:["Rep\xFAblica de Colombia"]},{name:"Comoros",alpha2:"KM",alpha3:"COM",aliases:["\u062C\u0632\u0631 \u0627\u0644\u0642\u0645\u0631","Union of the Comoros"]},{name:"Congo",alpha2:"CG",alpha3:"COG",aliases:["Republic of the Congo","Congo-Brazzaville"]},{name:"Democratic Republic of the Congo",alpha2:"CD",alpha3:"COD",aliases:["Democratic Republic of the Congo","Congo-Kinshasa","DR Congo","DRC"]},{name:"Cook Islands",alpha2:"CK",alpha3:"COK",aliases:[]},{name:"Costa Rica",alpha2:"CR",alpha3:"CRI",aliases:["Rep\xFAblica de Costa Rica"]},{name:"C\xF4te d'Ivoire",alpha2:"CI",alpha3:"CIV",aliases:["Ivory Coast","R\xE9publique de C\xF4te d'Ivoire"]},{name:"Croatia",alpha2:"HR",alpha3:"HRV",aliases:["Hrvatska","Republic of Croatia"]},{name:"Cuba",alpha2:"CU",alpha3:"CUB",aliases:["Rep\xFAblica de Cuba"]},{name:"Cura\xE7ao",alpha2:"CW",alpha3:"CUW",aliases:[]},{name:"Cyprus",alpha2:"CY",alpha3:"CYP",aliases:["\u039A\u03CD\u03C0\u03C1\u03BF\u03C2","K\u0131br\u0131s"]},{name:"Czechia",alpha2:"CZ",alpha3:"CZE",aliases:["Czech Republic","\u010Cesko"]},{name:"Denmark",alpha2:"DK",alpha3:"DNK",aliases:["Danmark"]},{name:"Djibouti",alpha2:"DJ",alpha3:"DJI",aliases:["\u062C\u064A\u0628\u0648\u062A\u064A","Djibouti City-State"]},{name:"Dominica",alpha2:"DM",alpha3:"DMA",aliases:[]},{name:"Dominican Republic",alpha2:"DO",alpha3:"DOM",aliases:["Rep\xFAblica Dominicana"]},{name:"Ecuador",alpha2:"EC",alpha3:"ECU",aliases:["Rep\xFAblica del Ecuador"]},{name:"Egypt",alpha2:"EG",alpha3:"EGY",aliases:["\u0645\u0635\u0631","Arab Republic of Egypt"]},{name:"El Salvador",alpha2:"SV",alpha3:"SLV",aliases:["Rep\xFAblica de El Salvador"]},{name:"Equatorial Guinea",alpha2:"GQ",alpha3:"GNQ",aliases:["Rep\xFAblica de Guinea Ecuatorial","R\xE9publique de Guin\xE9e \xE9quatoriale","Rep\xFAblica da Guin\xE9 Equatorial"]},{name:"Eritrea",alpha2:"ER",alpha3:"ERI",aliases:["State of Eritrea","\u12A4\u122D\u1275\u122B","\u0625\u0631\u064A\u062A\u0631\u064A\u0627"]},{name:"Estonia",alpha2:"EE",alpha3:"EST",aliases:["Eesti"]},{name:"Eswatini",alpha2:"SZ",alpha3:"SWZ",aliases:["Swaziland","Kingdom of Eswatini"]},{name:"Ethiopia",alpha2:"ET",alpha3:"ETH",aliases:["\u12A2\u1275\u12EE\u1335\u12EB","Federal Democratic Republic of Ethiopia"]},{name:"Falkland Islands (Malvinas)",alpha2:"FK",alpha3:"FLK",aliases:["Islas Malvinas"]},{name:"Faroe Islands",alpha2:"FO",alpha3:"FRO",aliases:["F\xF8royar"]},{name:"Fiji",alpha2:"FJ",alpha3:"FJI",aliases:["Viti","Fiji Islands"]},{name:"Finland",alpha2:"FI",alpha3:"FIN",aliases:["Suomi"]},{name:"France",alpha2:"FR",alpha3:"FRA",aliases:["R\xE9publique fran\xE7aise"]},{name:"French Guiana",alpha2:"GF",alpha3:"GUF",aliases:["Guyane"]},{name:"French Polynesia",alpha2:"PF",alpha3:"PYF",aliases:["Polyn\xE9sie fran\xE7aise"]},{name:"Gabon",alpha2:"GA",alpha3:"GAB",aliases:["R\xE9publique gabonaise"]},{name:"Gambia",alpha2:"GM",alpha3:"GMB",aliases:["Republic of The Gambia"]},{name:"Georgia",alpha2:"GE",alpha3:"GEO",aliases:["\u10E1\u10D0\u10E5\u10D0\u10E0\u10D7\u10D5\u10D4\u10DA\u10DD","Sakartvelo"]},{name:"Germany",alpha2:"DE",alpha3:"DEU",aliases:["Deutschland","Federal Republic of Germany"]},{name:"Ghana",alpha2:"GH",alpha3:"GHA",aliases:["Republic of Ghana"]},{name:"Gibraltar",alpha2:"GI",alpha3:"GIB",aliases:[""]},{name:"Greece",alpha2:"GR",alpha3:"GRC",aliases:["\u0395\u03BB\u03BB\u03AC\u03B4\u03B1","Hellas","Hellenic Republic"]},{name:"Greenland",alpha2:"GL",alpha3:"GRL",aliases:["Kalaallit Nunaat"]},{name:"Grenada",alpha2:"GD",alpha3:"GRD",aliases:[]},{name:"Guadeloupe",alpha2:"GP",alpha3:"GLP",aliases:[]},{name:"Guam",alpha2:"GU",alpha3:"GUM",aliases:["Gu\xE5h\xE5n"]},{name:"Guatemala",alpha2:"GT",alpha3:"GTM",aliases:["Rep\xFAblica de Guatemala"]},{name:"Guernsey",alpha2:"GG",alpha3:"GGY",aliases:[]},{name:"Guinea",alpha2:"GN",alpha3:"GIN",aliases:["R\xE9publique de Guin\xE9e"]},{name:"Guinea-Bissau",alpha2:"GW",alpha3:"GNB",aliases:["Rep\xFAblica da Guin\xE9-Bissau"]},{name:"Guyana",alpha2:"GY",alpha3:"GUY",aliases:["Co-operative Republic of Guyana"]},{name:"Haiti",alpha2:"HT",alpha3:"HTI",aliases:["R\xE9publique d'Ha\xEFti","Repiblik d Ayiti"]},{name:"Holy See",alpha2:"VA",alpha3:"VAT",aliases:["Vatican City","Vatican City State","Santa Sede"]},{name:"Honduras",alpha2:"HN",alpha3:"HND",aliases:["Rep\xFAblica de Honduras"]},{name:"Hong Kong",alpha2:"HK",alpha3:"HKG",aliases:["\u9999\u6E2F","Xianggang","Hong Kong SAR"]},{name:"Hungary",alpha2:"HU",alpha3:"HUN",aliases:["Magyarorsz\xE1g"]},{name:"Iceland",alpha2:"IS",alpha3:"ISL",aliases:["\xCDsland"]},{name:"India",alpha2:"IN",alpha3:"IND",aliases:["\u092D\u093E\u0930\u0924","Republic of India","Bharat"]},{name:"Indonesia",alpha2:"ID",alpha3:"IDN",aliases:["Republik Indonesia"]},{name:"Iran, Islamic Republic of",alpha2:"IR",alpha3:"IRN",aliases:["\u0627\u06CC\u0631\u0627\u0646","Islamic Republic of Iran"]},{name:"Iraq",alpha2:"IQ",alpha3:"IRQ",aliases:["\u0627\u0644\u0639\u0631\u0627\u0642","Republic of Iraq"]},{name:"Ireland",alpha2:"IE",alpha3:"IRL",aliases:["\xC9ire","Republic of Ireland"]},{name:"Isle of Man",alpha2:"IM",alpha3:"IMN",aliases:["Mann","Ellan Vannin"]},{name:"Israel",alpha2:"IL",alpha3:"ISR",aliases:["\u05D9\u05B4\u05E9\u05B0\u05C2\u05E8\u05B8\u05D0\u05B5\u05DC","State of Israel","Med\u012Bnat Yisr\u0101'el"]},{name:"Italy",alpha2:"IT",alpha3:"ITA",aliases:["Italia","Repubblica Italiana"]},{name:"Jamaica",alpha2:"JM",alpha3:"JAM",aliases:[]},{name:"Japan",alpha2:"JP",alpha3:"JPN",aliases:["\u65E5\u672C","Nihon","Nippon"]},{name:"Jersey",alpha2:"JE",alpha3:"JEY",aliases:[]},{name:"Jordan",alpha2:"JO",alpha3:"JOR",aliases:["\u0627\u0644\u0623\u0631\u062F\u0646","Hashemite Kingdom of Jordan"]},{name:"Kazakhstan",alpha2:"KZ",alpha3:"KAZ",aliases:["\u049A\u0430\u0437\u0430\u049B\u0441\u0442\u0430\u043D","Republic of Kazakhstan"]},{name:"Kenya",alpha2:"KE",alpha3:"KEN",aliases:["Republic of Kenya"]},{name:"Kiribati",alpha2:"KI",alpha3:"KIR",aliases:[]},{name:"North Korea",alpha2:"KP",alpha3:"PRK",aliases:["North Korea","\uC870\uC120\uBBFC\uC8FC\uC8FC\uC758\uC778\uBBFC\uACF5\uD654\uAD6D","Democratic People's Republic of Korea"]},{name:"South Korea",alpha2:"KR",alpha3:"KOR",aliases:["South Korea","\uB300\uD55C\uBBFC\uAD6D","Republic of Korea"]},{name:"Kosovo",alpha2:"XK",alpha3:"XKS",aliases:["Kosova","\u041A\u043E\u0441\u043E\u0432\u043E","Republic of Kosovo","Republika e Kosov\xEBs"]},{name:"Kuwait",alpha2:"KW",alpha3:"KWT",aliases:["\u0627\u0644\u0643\u0648\u064A\u062A","State of Kuwait"]},{name:"Kyrgyzstan",alpha2:"KG",alpha3:"KGZ",aliases:["\u041A\u044B\u0440\u0433\u044B\u0437\u0441\u0442\u0430\u043D","Kyrgyz Republic"]},{name:"Lao People's Democratic Republic",alpha2:"LA",alpha3:"LAO",aliases:["Laos","\u0EAA\u0E9B\u0E9B\u0EA5\u0EB2\u0EA7"]},{name:"Latvia",alpha2:"LV",alpha3:"LVA",aliases:["Latvija"]},{name:"Lebanon",alpha2:"LB",alpha3:"LBN",aliases:["\u0644\u0628\u0646\u0627\u0646","Republic of Lebanon"]},{name:"Lesotho",alpha2:"LS",alpha3:"LSO",aliases:["Kingdom of Lesotho"]},{name:"Liberia",alpha2:"LR",alpha3:"LBR",aliases:["Republic of Liberia"]},{name:"Libya",alpha2:"LY",alpha3:"LBY",aliases:["Libyan Arab Jamahiriya"]},{name:"Liechtenstein",alpha2:"LI",alpha3:"LIE",aliases:["F\xFCrstentum Liechtenstein"]},{name:"Lithuania",alpha2:"LT",alpha3:"LTU",aliases:["Lietuva","Republic of Lithuania"]},{name:"Luxembourg",alpha2:"LU",alpha3:"LUX",aliases:["L\xEBtzebuerg","Luxembourg","Luxemburg"]},{name:"Macao",alpha2:"MO",alpha3:"MAC",aliases:["\u6FB3\u9580","Macao SAR","\xC0om\xE9n"]},{name:"Madagascar",alpha2:"MG",alpha3:"MDG",aliases:["Repoblikan'i Madagasikara","R\xE9publique de Madagascar"]},{name:"Malawi",alpha2:"MW",alpha3:"MWI",aliases:["Republic of Malawi"]},{name:"Malaysia",alpha2:"MY",alpha3:"MYS",aliases:["Malaysia","\u0645\u0627\u0644\u064A\u0632\u064A\u0627"]},{name:"Maldives",alpha2:"MV",alpha3:"MDV",aliases:["\u078B\u07A8\u0788\u07AC\u0780\u07A8\u0783\u07A7\u0787\u07B0\u0796\u07AD\u078E\u07AC","Dhivehi Raajje","Republic of Maldives"]},{name:"Mali",alpha2:"ML",alpha3:"MLI",aliases:["R\xE9publique du Mali"]},{name:"Malta",alpha2:"MT",alpha3:"MLT",aliases:["Repubblika ta' Malta","Republic of Malta"]},{name:"Marshall Islands",alpha2:"MH",alpha3:"MHL",aliases:["Aolep\u0101n Aor\u014Dkin M\u0327aje\u013C","Republic of the Marshall Islands"]},{name:"Martinique",alpha2:"MQ",alpha3:"MTQ",aliases:[]},{name:"Mauritania",alpha2:"MR",alpha3:"MRT",aliases:["\u0645\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u0627","Islamic Republic of Mauritania"]},{name:"Mauritius",alpha2:"MU",alpha3:"MUS",aliases:["Republic of Mauritius","R\xE9publique de Maurice"]},{name:"Mayotte",alpha2:"YT",alpha3:"MYT",aliases:[]},{name:"Mexico",alpha2:"MX",alpha3:"MEX",aliases:["M\xE9xico","Estados Unidos Mexicanos"]},{name:"Micronesia, Federated States of",alpha2:"FM",alpha3:"FSM",aliases:["Micronesia","Federated States of Micronesia"]},{name:"Moldova",alpha2:"MD",alpha3:"MDA",aliases:["Moldova","Republica Moldova"]},{name:"Monaco",alpha2:"MC",alpha3:"MCO",aliases:["Principaut\xE9 de Monaco"]},{name:"Mongolia",alpha2:"MN",alpha3:"MNG",aliases:["\u041C\u043E\u043D\u0433\u043E\u043B \u0443\u043B\u0441","Mongol Uls"]},{name:"Montenegro",alpha2:"ME",alpha3:"MNE",aliases:["\u0426\u0440\u043D\u0430 \u0413\u043E\u0440\u0430","Crna Gora"]},{name:"Montserrat",alpha2:"MS",alpha3:"MSR",aliases:[]},{name:"Morocco",alpha2:"MA",alpha3:"MAR",aliases:["\u0627\u0644\u0645\u063A\u0631\u0628","Maroc","Kingdom of Morocco"]},{name:"Mozambique",alpha2:"MZ",alpha3:"MOZ",aliases:["Mo\xE7ambique","Republic of Mozambique"]},{name:"Myanmar",alpha2:"MM",alpha3:"MMR",aliases:["Burma","\u1019\u103C\u1014\u103A\u1019\u102C","Myanma"]},{name:"Namibia",alpha2:"NA",alpha3:"NAM",aliases:["Republic of Namibia"]},{name:"Nauru",alpha2:"NR",alpha3:"NRU",aliases:["Naoero","Republic of Nauru"]},{name:"Nepal",alpha2:"NP",alpha3:"NPL",aliases:["\u0928\u0947\u092A\u093E\u0932","Federal Democratic Republic of Nepal"]},{name:"Netherlands",alpha2:"NL",alpha3:"NLD",aliases:["Nederland","Holland","Kingdom of the Netherlands"]},{name:"New Caledonia",alpha2:"NC",alpha3:"NCL",aliases:["Nouvelle-Cal\xE9donie"]},{name:"New Zealand",alpha2:"NZ",alpha3:"NZL",aliases:["Aotearoa"]},{name:"Nicaragua",alpha2:"NI",alpha3:"NIC",aliases:["Rep\xFAblica de Nicaragua"]},{name:"Niger",alpha2:"NE",alpha3:"NER",aliases:["R\xE9publique du Niger"]},{name:"Nigeria",alpha2:"NG",alpha3:"NGA",aliases:["Federal Republic of Nigeria"]},{name:"Niue",alpha2:"NU",alpha3:"NIU",aliases:[]},{name:"Norfolk Island",alpha2:"NF",alpha3:"NFK",aliases:[]},{name:"North Macedonia",alpha2:"MK",alpha3:"MKD",aliases:["Republic of North Macedonia","\u0421\u0435\u0432\u0435\u0440\u043D\u0430 \u041C\u0430\u043A\u0435\u0434\u043E\u043D\u0438\u0458\u0430"]},{name:"Northern Mariana Islands",alpha2:"MP",alpha3:"MNP",aliases:["Saipan","Commonwealth of the Northern Mariana Islands"]},{name:"Norway",alpha2:"NO",alpha3:"NOR",aliases:["Norge","Noreg","Norrige"]},{name:"Oman",alpha2:"OM",alpha3:"OMN",aliases:["\u0639\u0645\u0627\u0646","Sultanate of Oman"]},{name:"Pakistan",alpha2:"PK",alpha3:"PAK",aliases:["\u067E\u0627\u06A9\u0633\u062A\u0627\u0646","Islamic Republic of Pakistan"]},{name:"Palau",alpha2:"PW",alpha3:"PLW",aliases:["Beluu er a Belau","Republic of Palau"]},{name:"Palestine",alpha2:"PS",alpha3:"PSE",aliases:["\u0641\u0644\u0633\u0637\u064A\u0646","State of Palestine"]},{name:"Panama",alpha2:"PA",alpha3:"PAN",aliases:["Rep\xFAblica de Panam\xE1"]},{name:"Papua New Guinea",alpha2:"PG",alpha3:"PNG",aliases:["Papua Niugini"]},{name:"Paraguay",alpha2:"PY",alpha3:"PRY",aliases:["Rep\xFAblica del Paraguay"]},{name:"Peru",alpha2:"PE",alpha3:"PER",aliases:["Rep\xFAblica del Per\xFA"]},{name:"Philippines",alpha2:"PH",alpha3:"PHL",aliases:["Pilipinas","Republika ng Pilipinas"]},{name:"Poland",alpha2:"PL",alpha3:"POL",aliases:["Polska","Republic of Poland"]},{name:"Portugal",alpha2:"PT",alpha3:"PRT",aliases:["Rep\xFAblica Portuguesa"]},{name:"Puerto Rico",alpha2:"PR",alpha3:"PRI",aliases:[]},{name:"Qatar",alpha2:"QA",alpha3:"QAT",aliases:["\u0642\u0637\u0631","State of Qatar"]},{name:"R\xE9union",alpha2:"RE",alpha3:"REU",aliases:[]},{name:"Romania",alpha2:"RO",alpha3:"ROU",aliases:["Rom\xE2nia"]},{name:"Russian Federation",alpha2:"RU",alpha3:"RUS",aliases:["Russia","\u0420\u043E\u0441\u0441\u0438\u0439\u0441\u043A\u0430\u044F \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044F"]},{name:"Rwanda",alpha2:"RW",alpha3:"RWA",aliases:["Repubulika y'u Rwanda","R\xE9publique du Rwanda"]},{name:"Saint Barth\xE9lemy",alpha2:"BL",alpha3:"BLM",aliases:["Saint-Barth\xE9lemy"]},{name:"Saint Helena, Ascension and Tristan da Cunha",alpha2:"SH",alpha3:"SHN",aliases:[]},{name:"Saint Kitts and Nevis",alpha2:"KN",alpha3:"KNA",aliases:[]},{name:"Saint Lucia",alpha2:"LC",alpha3:"LCA",aliases:[]},{name:"Saint Martin (French part)",alpha2:"MF",alpha3:"MAF",aliases:[]},{name:"Saint Pierre and Miquelon",alpha2:"PM",alpha3:"SPM",aliases:[]},{name:"Saint Vincent and the Grenadines",alpha2:"VC",alpha3:"VCT",aliases:[]},{name:"Samoa",alpha2:"WS",alpha3:"WSM",aliases:["S\u0101moa","Independent State of Samoa"]},{name:"San Marino",alpha2:"SM",alpha3:"SMR",aliases:["Serenissima Repubblica di San Marino"]},{name:"Sao Tome and Principe",alpha2:"ST",alpha3:"STP",aliases:["S\xE3o Tom\xE9 e Pr\xEDncipe"]},{name:"Saudi Arabia",alpha2:"SA",alpha3:"SAU",aliases:["\u0627\u0644\u0645\u0645\u0644\u0643\u0629 \u0627\u0644\u0639\u0631\u0628\u064A\u0629 \u0627\u0644\u0633\u0639\u0648\u062F\u064A\u0629","Kingdom of Saudi Arabia","KSA"]},{name:"Senegal",alpha2:"SN",alpha3:"SEN",aliases:["R\xE9publique du S\xE9n\xE9gal"]},{name:"Serbia",alpha2:"RS",alpha3:"SRB",aliases:["\u0421\u0440\u0431\u0438\u0458\u0430","Srbija","Republic of Serbia"]},{name:"Seychelles",alpha2:"SC",alpha3:"SYC",aliases:["Repiblik Sesel","R\xE9publique des Seychelles"]},{name:"Sierra Leone",alpha2:"SL",alpha3:"SLE",aliases:["Republic of Sierra Leone"]},{name:"Singapore",alpha2:"SG",alpha3:"SGP",aliases:["\u65B0\u52A0\u5761","Singapura","Republic of Singapore"]},{name:"Sint Maarten (Dutch part)",alpha2:"SX",alpha3:"SXM",aliases:[]},{name:"Slovakia",alpha2:"SK",alpha3:"SVK",aliases:["Slovensko","Slovak Republic"]},{name:"Slovenia",alpha2:"SI",alpha3:"SVN",aliases:["Slovenija"]},{name:"Solomon Islands",alpha2:"SB",alpha3:"SLB",aliases:[]},{name:"Somalia",alpha2:"SO",alpha3:"SOM",aliases:["Soomaaliya","\u062C\u0645\u0647\u0648\u0631\u064A\u0629 \u0627\u0644\u0635\u0648\u0645\u0627\u0644","Federal Republic of Somalia"]},{name:"South Africa",alpha2:"ZA",alpha3:"ZAF",aliases:["RSA","Republic of South Africa"]},{name:"South Sudan",alpha2:"SS",alpha3:"SSD",aliases:["Republic of South Sudan"]},{name:"Spain",alpha2:"ES",alpha3:"ESP",aliases:["Espa\xF1a","Reino de Espa\xF1a"]},{name:"Sri Lanka",alpha2:"LK",alpha3:"LKA",aliases:["\u0DC1\u0DCA\u200D\u0DBB\u0DD3 \u0DBD\u0D82\u0D9A\u0DCF\u0DC0","\u0B87\u0BB2\u0B99\u0BCD\u0B95\u0BC8","Democratic Socialist Republic of Sri Lanka"]},{name:"Sudan",alpha2:"SD",alpha3:"SDN",aliases:["\u0627\u0644\u0633\u0648\u062F\u0627\u0646","Republic of the Sudan"]},{name:"Suriname",alpha2:"SR",alpha3:"SUR",aliases:["Republiek Suriname"]},{name:"Svalbard and Jan Mayen",alpha2:"SJ",alpha3:"SJM",aliases:[]},{name:"Sweden",alpha2:"SE",alpha3:"SWE",aliases:["Sverige","Kingdom of Sweden"]},{name:"Switzerland",alpha2:"CH",alpha3:"CHE",aliases:["Schweiz","Suisse","Svizzera","Svizra","Swiss Confederation"]},{name:"Syrian Arab Republic",alpha2:"SY",alpha3:"SYR",aliases:["\u0633\u0648\u0631\u064A\u0627","Syria"]},{name:"Taiwan, Province of China",alpha2:"TW",alpha3:"TWN",aliases:["\u53F0\u7063","\u81FA\u7063","Taiwan","Republic of China","ROC"]},{name:"Tajikistan",alpha2:"TJ",alpha3:"TJK",aliases:["\u0422\u043E\u04B7\u0438\u043A\u0438\u0441\u0442\u043E\u043D","Republic of Tajikistan"]},{name:"Tanzania, United Republic of",alpha2:"TZ",alpha3:"TZA",aliases:["Tanzania","Jamhuri ya Muungano wa Tanzania"]},{name:"Thailand",alpha2:"TH",alpha3:"THA",aliases:["\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28\u0E44\u0E17\u0E22","Prathet Thai","Kingdom of Thailand"]},{name:"Timor-Leste",alpha2:"TL",alpha3:"TLS",aliases:["East Timor","Rep\xFAblica Democr\xE1tica de Timor-Leste"]},{name:"Togo",alpha2:"TG",alpha3:"TGO",aliases:["R\xE9publique Togolaise"]},{name:"Tokelau",alpha2:"TK",alpha3:"TKL",aliases:[]},{name:"Tonga",alpha2:"TO",alpha3:"TON",aliases:["Pule\u02BBanga Fakatu\u02BBi \u02BBo Tonga","Kingdom of Tonga"]},{name:"Trinidad and Tobago",alpha2:"TT",alpha3:"TTO",aliases:[]},{name:"Tunisia",alpha2:"TN",alpha3:"TUN",aliases:["\u062A\u0648\u0646\u0633","Republic of Tunisia"]},{name:"T\xFCrkiye",alpha2:"TR",alpha3:"TUR",aliases:["Turkey","T\xFCrkiye Cumhuriyeti","Republic of T\xFCrkiye"]},{name:"Turkmenistan",alpha2:"TM",alpha3:"TKM",aliases:["T\xFCrkmenistan"]},{name:"Turks and Caicos Islands",alpha2:"TC",alpha3:"TCA",aliases:[]},{name:"Tuvalu",alpha2:"TV",alpha3:"TUV",aliases:[]},{name:"Uganda",alpha2:"UG",alpha3:"UGA",aliases:["Republic of Uganda"]},{name:"Ukraine",alpha2:"UA",alpha3:"UKR",aliases:["\u0423\u043A\u0440\u0430\u0457\u043D\u0430"]},{name:"United Arab Emirates",alpha2:"AE",alpha3:"ARE",aliases:["\u0627\u0644\u0625\u0645\u0627\u0631\u0627\u062A \u0627\u0644\u0639\u0631\u0628\u064A\u0629 \u0627\u0644\u0645\u062A\u062D\u062F\u0629","UAE"]},{name:"United Kingdom",alpha2:"GB",alpha3:"GBR",aliases:["United Kingdom","UK","Britain","Great Britain"]},{name:"United States of America",alpha2:"US",alpha3:"USA",aliases:["United States","USA","America","US"]},{name:"Uruguay",alpha2:"UY",alpha3:"URY",aliases:["Rep\xFAblica Oriental del Uruguay"]},{name:"Uzbekistan",alpha2:"UZ",alpha3:"UZB",aliases:["O\u02BBzbekiston","Republic of Uzbekistan"]},{name:"Vanuatu",alpha2:"VU",alpha3:"VUT",aliases:["Ripablik blong Vanuatu"]},{name:"Venezuela",alpha2:"VE",alpha3:"VEN",aliases:["Venezuela","Rep\xFAblica Bolivariana de Venezuela"]},{name:"Vietnam",alpha2:"VN",alpha3:"VNM",aliases:["Vi\u1EC7t Nam","Socialist Republic of Vietnam"]},{name:"Virgin Islands (British)",alpha2:"VG",alpha3:"VGB",aliases:["British Virgin Islands"]},{name:"Virgin Islands (U.S.)",alpha2:"VI",alpha3:"VIR",aliases:["U.S. Virgin Islands"]},{name:"Wallis and Futuna",alpha2:"WF",alpha3:"WLF",aliases:[]},{name:"Western Sahara",alpha2:"EH",alpha3:"ESH",aliases:["\u0627\u0644\u0635\u062D\u0631\u0627\u0621 \u0627\u0644\u063A\u0631\u0628\u064A\u0629","Sahara Occidental"]},{name:"Yemen",alpha2:"YE",alpha3:"YEM",aliases:["\u0627\u0644\u064A\u0645\u0646","Republic of Yemen"]},{name:"Zambia",alpha2:"ZM",alpha3:"ZMB",aliases:["Republic of Zambia"]},{name:"Zimbabwe",alpha2:"ZW",alpha3:"ZWE",aliases:["Republic of Zimbabwe"]}];var ue={byName:new Map,byAlpha2:new Map,byAlpha3:new Map,byAlias:new Map};for(let s of be){ue.byName.set(s.name.toLowerCase(),s),ue.byAlpha2.set(s.alpha2.toLowerCase(),s),ue.byAlpha3.set(s.alpha3.toLowerCase(),s);for(let e of s.aliases)ue.byAlias.set(e.toLowerCase(),s);}var Te=65,Ke=90;var Ge={A:"0-9A-Za-z",B:"0-9A-Z",C:"A-Za-z",F:"0-9",L:"a-z",U:"A-Z",W:"0-9a-z"};function Se(s){let e=s.toUpperCase();return (e.slice(4)+e.slice(0,4)).split("").map(n=>{let a=n.charCodeAt(0);return a>=Te&&a<=Ke?String(a-Te+10):n}).join("")}function Re(s){let e=s,t;for(;e.length>2;)t=e.slice(0,9),e=Number.parseInt(t,10)%97+e.slice(t.length);return Number.parseInt(e,10)%97}function We(s){let e=s.match(/(.{3})/g)?.map(t=>{let n=t.slice(0,1),a=Number.parseInt(t.slice(1),10);return `([${Ge[n]||""}]{${a}})`});return new RegExp(`^${e?.join("")||""}$`)}var i=class{constructor(e,t,n,a){this.countryCode=e,this.length=t,this.structure=n,this.example=a,this._cachedRegex=We(this.structure);}_regex(){return this._cachedRegex}isValid(e){return this.length===e.length&&this.countryCode===e.slice(0,2)&&this._regex().test(e.slice(4))&&Re(Se(e))===1}toBBAN(e,t=""){let n=this._regex().exec(e.slice(4));return n?n.slice(1).join(t):""}fromBBAN(e){if(!this.isValidBBAN(e))throw new Error("Invalid BBAN");let n=`0${98-Re(Se(`${this.countryCode}00${e}`))}`.slice(-2);return `${this.countryCode}${n}${e}`}isValidBBAN(e){return this.length-4===e.length&&this._regex().test(e)}},je={};function o(s){je[s.countryCode]=s;}o(new i("AD",24,"F04F04A12","AD1200012030200359100100"));o(new i("AE",23,"F03F16","AE070331234567890123456"));o(new i("AL",28,"F08A16","AL47212110090000000235698741"));o(new i("AT",20,"F05F11","AT611904300234573201"));o(new i("AZ",28,"U04A20","AZ21NABZ00000000137010001944"));o(new i("BA",20,"F03F03F08F02","BA391290079401028494"));o(new i("BE",16,"F03F07F02","BE68539007547034"));o(new i("BG",22,"U04F04F02A08","BG80BNBG96611020345678"));o(new i("BH",22,"U04A14","BH67BMAG00001299123456"));o(new i("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1"));o(new i("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00"));o(new i("CH",21,"F05A12","CH9300762011623852957"));o(new i("CR",22,"F04F14","CR72012300000171549015"));o(new i("CY",28,"F03F05A16","CY17002001280000001200527600"));o(new i("CZ",24,"F04F06F10","CZ6508000000192000145399"));o(new i("DE",22,"F08F10","DE89370400440532013000"));o(new i("DK",18,"F04F09F01","DK5000400440116243"));o(new i("DO",28,"U04F20","DO28BAGR00000001212453611324"));o(new i("EE",20,"F02F02F11F01","EE382200221020145685"));o(new i("EG",29,"F04F04F17","EG800002000156789012345180002"));o(new i("ES",24,"F04F04F01F01F10","ES9121000418450200051332"));o(new i("FI",18,"F06F07F01","FI2112345600000785"));o(new i("FO",18,"F04F09F01","FO6264600001631634"));o(new i("FR",27,"F05F05A11F02","FR1420041010050500013M02606"));o(new i("GB",22,"U04F06F08","GB29NWBK60161331926819"));o(new i("GE",22,"U02F16","GE29NB0000000101904917"));o(new i("GI",23,"U04A15","GI75NWBK000000007099453"));o(new i("GL",18,"F04F09F01","GL8964710001000206"));o(new i("GR",27,"F03F04A16","GR1601101250000000012300695"));o(new i("GT",28,"A04A20","GT82TRAJ01020000001210029690"));o(new i("HR",21,"F07F10","HR1210010051863000160"));o(new i("HU",28,"F03F04F01F15F01","HU42117730161111101800000000"));o(new i("IE",22,"U04F06F08","IE29AIBK93115212345678"));o(new i("IL",23,"F03F03F13","IL620108000000099999999"));o(new i("IS",26,"F04F02F06F10","IS140159260076545510730339"));o(new i("IT",27,"U01F05F05A12","IT60X0542811101000000123456"));o(new i("IQ",23,"U04F03A12","IQ98NBIQ850123456789012"));o(new i("JO",30,"A04F22","JO15AAAA1234567890123456789012"));o(new i("KW",30,"U04A22","KW81CBKU0000000000001234560101"));o(new i("KZ",20,"F03A13","KZ86125KZT5004100100"));o(new i("LB",28,"F04A20","LB62099900000001001901229114"));o(new i("LC",32,"U04F24","LC07HEMM000100010012001200013015"));o(new i("LI",21,"F05A12","LI21088100002324013AA"));o(new i("LT",20,"F05F11","LT121000011101001000"));o(new i("LU",20,"F03A13","LU280019400644750000"));o(new i("LV",21,"U04A13","LV80BANK0000435195001"));o(new i("MC",27,"F05F05A11F02","MC5811222000010123456789030"));o(new i("MD",24,"U02A18","MD24AG000225100013104168"));o(new i("ME",22,"F03F13F02","ME25505000012345678951"));o(new i("MK",19,"F03A10F02","MK07250120000058984"));o(new i("MR",27,"F05F05F11F02","MR1300020001010000123456753"));o(new i("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S"));o(new i("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR"));o(new i("NL",18,"U04F10","NL91ABNA0417164300"));o(new i("NO",15,"F04F06F01","NO9386011117947"));o(new i("PK",24,"U04A16","PK36SCBL0000001123456702"));o(new i("PL",28,"F08F16","PL61109010140000071219812874"));o(new i("PS",29,"U04A21","PS92PALS000000000400123456702"));o(new i("PT",25,"F04F04F11F02","PT50000201231234567890154"));o(new i("QA",29,"U04A21","QA30AAAA123456789012345678901"));o(new i("RO",24,"U04A16","RO49AAAA1B31007593840000"));o(new i("RS",22,"F03F13F02","RS35260005601001611379"));o(new i("SA",24,"F02A18","SA0380000000608010167519"));o(new i("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD"));o(new i("SE",24,"F03F16F01","SE4550000000058398257466"));o(new i("SI",19,"F05F08F02","SI56263300012039086"));o(new i("SK",24,"F04F06F10","SK3112000000198742637541"));o(new i("SM",27,"U01F05F05A12","SM86U0322509800000000270100"));o(new i("ST",25,"F08F11F02","ST68000100010051845310112"));o(new i("SV",28,"U04F20","SV62CENR00000000000000700025"));o(new i("TL",23,"F03F14F02","TL380080012345678910157"));o(new i("TN",24,"F02F03F13F02","TN5910006035183598478831"));o(new i("TR",26,"F05F01A16","TR330006100519786457841326"));o(new i("UA",29,"F25","UA511234567890123456789012345"));o(new i("VA",22,"F18","VA59001123000012345678"));o(new i("VG",24,"U04F16","VG96VPVG0000012345678901"));o(new i("XK",20,"F04F10F02","XK051212012345678906"));o(new i("AO",25,"F21","AO69123456789012345678901"));o(new i("BF",27,"F23","BF2312345678901234567890123"));o(new i("BI",16,"F12","BI41123456789012"));o(new i("BJ",28,"F24","BJ39123456789012345678901234"));o(new i("CI",28,"U02F22","CI70CI1234567890123456789012"));o(new i("CM",27,"F23","CM9012345678901234567890123"));o(new i("CV",25,"F21","CV30123456789012345678901"));o(new i("DZ",24,"F20","DZ8612345678901234567890"));o(new i("IR",26,"F22","IR861234568790123456789012"));o(new i("MG",27,"F23","MG1812345678901234567890123"));o(new i("ML",28,"U01F23","ML15A12345678901234567890123"));o(new i("MZ",25,"F21","MZ25123456789012345678901"));o(new i("SN",28,"U01F23","SN52A12345678901234567890123"));o(new i("GF",27,"F05F05A11F02","GF121234512345123456789AB13"));o(new i("GP",27,"F05F05A11F02","GP791234512345123456789AB13"));o(new i("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13"));o(new i("RE",27,"F05F05A11F02","RE131234512345123456789AB13"));o(new i("PF",27,"F05F05A11F02","PF281234512345123456789AB13"));o(new i("YT",27,"F05F05A11F02","YT021234512345123456789AB13"));o(new i("NC",27,"F05F05A11F02","NC551234512345123456789AB13"));o(new i("BL",27,"F05F05A11F02","BL391234512345123456789AB13"));o(new i("MF",27,"F05F05A11F02","MF551234512345123456789AB13"));o(new i("PM",27,"F05F05A11F02","PM071234512345123456789AB13"));o(new i("WF",27,"F05F05A11F02","WF621234512345123456789AB13"));var C=class s extends b{static create(e,t){if(!e||typeof e!="object")throw new Error("ExOptional.create: type must be a valid field");if(!("_def"in e)||!e._def||typeof e._def!="object")throw new Error("ExOptional.create: type is not a valid ExpressCSV field");if(!("typeName"in e._def)||typeof e._def.typeName!="string")throw new Error("ExOptional.create: type is missing a typeName");if(t!==void 0&&typeof t!="object")throw new Error("ExOptional.create: options must be an object");if(t?.when!==void 0&&typeof t.when!="function")throw new Error("ExOptional.create: options.when must be a function");return new s({typeName:"ExOptional",innerType:e,when:t?.when,checks:[]})}unwrap(){return this._def.innerType}optional(){return this}default(e){let t=this._def.innerType._def;return t.defaultValue=e,this}};var U=class extends C{};var L=class extends C{output(e){return this._def.innerType.output(e),this._def.outputFormat=e,this}};var z=class extends C{output(e){return this._def.innerType.output(e),this}};var $=class extends C{min(e,t){return this._def.innerType.min(e,t),this}max(e,t){return this._def.innerType.max(e,t),this}integer(e){return this._def.innerType.integer(e),this}multipleOf(e,t){return this._def.innerType.multipleOf(e,t),this}percentage(){return this._def.innerType.percentage(),this}currency(e){return this._def.innerType.currency(e),this}};var K=class extends C{caseSensitive(e=true){return this._def.innerType.caseSensitive(e),this}},G=class extends C{caseSensitive(e=true){return this._def.innerType.caseSensitive(e),this}min(e,t){return this._def.innerType.min(e,t),this}max(e,t){return this._def.innerType.max(e,t),this}};var W=class extends C{uuid(e){return this._def.innerType.uuid(e),this}ip(e){return this._def.innerType.ip(e),this}url(e){return this._def.innerType.url(e),this}email(e){return this._def.innerType.email(e),this}phone(e){return this._def.innerType.phone(e),this}country(e){return this._def.innerType.country(e),this}max(e,t){return this._def.innerType.max(e,t),this}min(e,t){return this._def.innerType.min(e,t),this}length(e,t){return this._def.innerType.length(e,t),this}includes(e,t){return this._def.innerType.includes(e,t),this}startsWith(e,t){return this._def.innerType.startsWith(e,t),this}endsWith(e,t){return this._def.innerType.endsWith(e,t),this}regex(e,t){return this._def.innerType.regex(e,t),this}alphabetical(e){return this._def.innerType.alphabetical(e),this}alphanumerical(e){return this._def.innerType.alphanumerical(e),this}numerical(e){return this._def.innerType.numerical(e),this}iban(e){return this._def.innerType.iban(e),this}bic(e){return this._def.innerType.bic(e),this}gtin(e){return this._def.innerType.gtin(e),this}currencyCode(e){return this._def.innerType.currencyCode(e),this}};var j=class extends C{precision(e,t){return this._def.innerType.precision(e,t),this}};var q=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.create: options.message must be a string");return new s({typeName:"ExString",checks:[],message:e?.message})}optional(){return new W({typeName:"ExOptional",innerType:this})}uuid(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.uuid: options must be an object");if(e?.version!==void 0&&!["v1","v4","v5","all"].includes(e.version))throw new Error("ExString.uuid: options.version must be 'v1', 'v4', 'v5', or 'all'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.uuid: options.message must be a string");let t=e?.version||"all",n=e?.message;if(this._def.checks.findIndex(u=>u.type==="uuid"&&u.params?.version===t)!==-1)return this;let r=this._addCheck("uuid",{version:t},n);return this._def.checks.push(r),this}ip(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.ip: options must be an object");if(e?.version!==void 0&&!["v4","v6","all"].includes(e.version))throw new Error("ExString.ip: options.version must be 'v4', 'v6', or 'all'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.ip: options.message must be a string");let t=e?.version||"all",n=e?.message;if(this._def.checks.findIndex(u=>u.type==="ipAddress"&&u.params?.version===t)!==-1)return this;let r=this._addCheck("ipAddress",{version:t},n);return this._def.checks.push(r),this}url(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.url: options must be an object");if(e?.allowedProtocols!==void 0&&!Array.isArray(e.allowedProtocols))throw new Error("ExString.url: options.allowedProtocols must be an array");if(e?.allowedDomains!==void 0&&!Array.isArray(e.allowedDomains))throw new Error("ExString.url: options.allowedDomains must be an array");if(e?.allowSubdomains!==void 0&&typeof e.allowSubdomains!="boolean")throw new Error("ExString.url: options.allowSubdomains must be a boolean");if(e?.allowPaths!==void 0&&typeof e.allowPaths!="boolean")throw new Error("ExString.url: options.allowPaths must be a boolean");if(e?.allowQueryParams!==void 0&&typeof e.allowQueryParams!="boolean")throw new Error("ExString.url: options.allowQueryParams must be a boolean");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.url: options.message must be a string");let t={allowedProtocols:e?.allowedProtocols,allowedDomains:e?.allowedDomains,allowSubdomains:e?.allowSubdomains!==void 0?e.allowSubdomains:true,allowPaths:e?.allowPaths!==void 0?e.allowPaths:true,allowQueryParams:e?.allowQueryParams!==void 0?e.allowQueryParams:true};if(this._def.checks.findIndex(r=>r.type!=="url"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("url",t,e?.message);return this._def.checks.push(a),this}email(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.email: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.email: options.message must be a string");if(this._findExistingCheck("email").found)return this;let n=e?.message,a=this._addCheck("email",{},n);return this._def.checks.push(a),this}phone(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.phone: options must be an object");if(e?.allowedCountries!==void 0&&!Array.isArray(e.allowedCountries))throw new Error("ExString.phone: options.allowedCountries must be an array");if(e?.format!==void 0&&!["international","national","both"].includes(e.format))throw new Error("ExString.phone: options.format must be 'international', 'national', or 'both'");if(e?.output!==void 0&&!["e164","formatted","digits"].includes(e.output))throw new Error("ExString.phone: options.output must be 'e164', 'formatted', or 'digits'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.phone: options.message must be a string");let t={allowedCountries:e?.allowedCountries,format:e?.format||"international",output:e?.output||"e164"};if(this._def.checks.findIndex(r=>r.type!=="phone"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("phone",t,e?.message);return this._def.checks.push(a),this}country(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.country: options must be an object");if(e?.output!==void 0&&!["name","2-letter","3-letter"].includes(e.output))throw new Error("ExString.country: options.output must be 'name', '2-letter', or '3-letter'");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.country: options.message must be a string");let t={output:e?.output||"name"};if(this._def.checks.findIndex(r=>r.type==="country"&&r.params?.output===t.output)!==-1)return this;let a=this._addCheck("country",t,e?.message);return this._def.checks.push(a),this}max(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExString.max: maxLength must be a number");if(e<0||!Number.isInteger(e))throw new Error("ExString.max: maxLength must be a non-negative integer");if(t!==void 0&&typeof t!="object")throw new Error("ExString.max: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.max: options.message must be a string");let n=this._findExistingCheck("max");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e>=l)return this}let a=this._findExistingCheck("min");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&a.check.params.value>e)throw new Error("ExString.max: max cannot be less than min");let r=t?.message,u=this._addCheck("max",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}min(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExString.min: minLength must be a number");if(e<0||!Number.isInteger(e))throw new Error("ExString.min: minLength must be a non-negative integer");if(t!==void 0&&typeof t!="object")throw new Error("ExString.min: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.min: options.message must be a string");let n=this._findExistingCheck("min");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e<=l)return this}let a=this._findExistingCheck("max");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&e>a.check.params.value)throw new Error("ExString.min: min cannot be greater than max");let r=t?.message,u=this._addCheck("min",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}length(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExString.length: exactLength must be a number");if(e<0||!Number.isInteger(e))throw new Error("ExString.length: exactLength must be a non-negative integer");if(t!==void 0&&typeof t!="object")throw new Error("ExString.length: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.length: options.message must be a string");let n=this._findExistingCheck("length"),a=t?.message,r=this._addCheck("length",{value:e},a);return this._replaceOrAddCheck(r,n.index),this}includes(e,t){if(typeof e!="string")throw new Error("ExString.includes: substring must be a string");if(t!==void 0&&typeof t!="object")throw new Error("ExString.includes: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.includes: options.message must be a string");if(this._def.checks.findIndex(u=>u.type==="includes"&&u.params?.value===e)!==-1)return this;let a=t?.message,r=this._addCheck("includes",{value:e},a);return this._def.checks.push(r),this}startsWith(e,t){if(typeof e!="string")throw new Error("ExString.startsWith: prefix must be a string");if(t!==void 0&&typeof t!="object")throw new Error("ExString.startsWith: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.startsWith: options.message must be a string");if(this._def.checks.findIndex(u=>u.type==="startsWith"&&u.params?.value===e)!==-1)return this;let a=t?.message,r=this._addCheck("startsWith",{value:e},a);return this._def.checks.push(r),this}endsWith(e,t){if(typeof e!="string")throw new Error("ExString.endsWith: suffix must be a string");if(t!==void 0&&typeof t!="object")throw new Error("ExString.endsWith: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.endsWith: options.message must be a string");if(this._def.checks.findIndex(u=>u.type==="endsWith"&&u.params?.value===e)!==-1)return this;let a=t?.message,r=this._addCheck("endsWith",{value:e},a);return this._def.checks.push(r),this}regex(e,t){if(!(e instanceof RegExp))throw new Error("ExString.regex: pattern must be a RegExp");if(t!==void 0&&typeof t!="object")throw new Error("ExString.regex: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExString.regex: options.message must be a string");if(this._def.checks.findIndex(u=>{if(u.type!=="regex"||!u.params?.pattern)return false;let l=u.params.pattern;return l.source===e.source&&l.flags===e.flags})!==-1)return this;let a=t?.message,r=this._addCheck("regex",{pattern:e},a);return this._def.checks.push(r),this}alphabetical(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.alphabetical: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.alphabetical: options.message must be a string");if(this._findExistingCheck("alphabetical").found)return this;let n=e?.message,a=this._addCheck("alphabetical",{},n);return this._def.checks.push(a),this}alphanumerical(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.alphanumerical: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.alphanumerical: options.message must be a string");if(this._findExistingCheck("alphanumerical").found)return this;let n=e?.message,a=this._addCheck("alphanumerical",{},n);return this._def.checks.push(a),this}numerical(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.numerical: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.numerical: options.message must be a string");if(this._findExistingCheck("numerical").found)return this;let n=e?.message,a=this._addCheck("numerical",{},n);return this._def.checks.push(a),this}iban(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.iban: options must be an object");if(e?.allowedCountries!==void 0&&!Array.isArray(e.allowedCountries))throw new Error("ExString.iban: options.allowedCountries must be an array");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.iban: options.message must be a string");let t={allowedCountries:e?.allowedCountries};if(this._def.checks.findIndex(r=>r.type!=="iban"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("iban",t,e?.message);return this._def.checks.push(a),this}bic(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.bic: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.bic: options.message must be a string");if(this._findExistingCheck("bic").found)return this;let n=e?.message,a=this._addCheck("bic",{},n);return this._def.checks.push(a),this}gtin(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.gtin: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.gtin: options.message must be a string");if(this._findExistingCheck("gtin").found)return this;let n=e?.message,a=this._addCheck("gtin",{},n);return this._def.checks.push(a),this}currencyCode(e){if(e!==void 0&&typeof e!="object")throw new Error("ExString.currencyCode: options must be an object");if(e?.allowedCurrencies!==void 0&&!Array.isArray(e.allowedCurrencies))throw new Error("ExString.currencyCode: options.allowedCurrencies must be an array");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExString.currencyCode: options.message must be a string");let t={allowedCurrencies:e?.allowedCurrencies};if(this._def.checks.findIndex(r=>r.type!=="currencyCode"||!r.params?false:JSON.stringify(r.params)===JSON.stringify(t))!==-1)return this;let a=this._addCheck("currencyCode",t,e?.message);return this._def.checks.push(a),this}};new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z"));function Oe(s){if(s){if(s==="defaultValue")return "default-value";if(s==="when")return "optional-when";if(s==="key")return "unique-index";if(s==="refine")return "refine"}throw new Error(`Invalid key: ${s}`)}function Z(s,e,t){if(!s||typeof s!="object")return s;if(s instanceof RegExp)return {__type:"RegExp",source:s.source,flags:s.flags};if(typeof s=="function"){let a=`func_${Math.random().toString(36).substring(2,15)}`,r=Oe(t),u;switch(r){case "default-value":u=s;break;case "refine":u=s;break;case "optional-when":u=s;break;case "unique-index":u=s;break;default:throw new Error(`Invalid function type: ${r}`)}return e.set(a,{function:u,functionType:r,id:a,functionSource:"local"}),{__type:"Function",id:a,functionType:r}}if(Array.isArray(s))return s.map(a=>Z(a,e));let n={};for(let[a,r]of Object.entries(s))n[a]=Z(r,e,a);return n}function H(s){let e={},t=s._def;return "description"in t&&typeof t.description=="string"&&(e.description=t.description),"label"in t&&typeof t.label=="string"&&(e.label=t.label),"example"in t&&typeof t.example=="string"&&(e.example=t.example),"defaultValue"in t&&t.defaultValue!==void 0&&(e.defaultValue=typeof t.defaultValue=="function"?"[[Function]]":t.defaultValue),"columnNameAliases"in t&&Array.isArray(t.columnNameAliases)&&(e.columnNameAliases=t.columnNameAliases),e}function Ae(s,e,t,n,a){if(typeof s.validator=="function"){let r=`func_${Math.random().toString(36).substring(2,15)}`,u=a==="refineBatch"?"refine":a;t.set(r,{id:r,functionType:u,function:s.validator}),n?e.set(r,{functionType:u,id:r,functionSource:"remote"}):e.set(r,{function:s.validator,functionType:u,id:r,functionSource:"local"}),s.validator={__type:"Function",id:r,functionType:a};}}function ce(s,e,t,n=false){return s.map(a=>{if(a.type==="refine"&&a.params){let r={...a.params};if(Ae(r,e,t,n,"refine"),typeof r.params=="function"){let l=`func_${Math.random().toString(36).substring(2,15)}`;t.set(l,{id:l,functionType:"refine",function:r.params}),n?e.set(l,{functionType:"refine",id:l,functionSource:"remote"}):e.set(l,{function:r.params,functionType:"refine",id:l,functionSource:"local"}),r.params={__type:"Function",id:l,functionType:"refine"};}let u=a.message;return !u&&r.params&&typeof r.params=="object"&&"message"in r.params&&(u=r.params.message),{...a,params:r,message:u}}if(a.type==="refineBatch"&&a.params){let r={...a.params};Ae(r,e,t,n,"refineBatch");let u=a.message;return !u&&r.params&&typeof r.params=="object"&&"message"in r.params&&(u=r.params.message),{...a,params:r,message:u}}return {...a,params:a.params}})}function me(s,e){let t={},n=s._def,a="message"in n&&typeof n.message=="string"?n.message:void 0;if(a&&(t.message=a),e==="ExNumber"&&("isPercentage"in n&&n.isPercentage===true&&(t.isPercentage=true),"currencyCode"in n&&typeof n.currencyCode=="string"&&(t.currencyCode=n.currencyCode)),e==="ExBoolean"&&"control"in n&&n.control!==void 0&&(t.control=n.control),(e==="ExSelect"||e==="ExMultiselect")&&("options"in n&&Array.isArray(n.options)&&(t.options=n.options),"config"in n&&n.config&&typeof n.config=="object")){let r=n.config;t.selectConfig={enforceCaseSensitiveMatch:!!r.enforceCaseSensitiveMatch,allowCustom:!!r.allowCustom};}if((e==="ExDate"||e==="ExDatetime"||e==="ExTime")&&"outputFormat"in n&&typeof n.outputFormat=="string"&&(t.outputFormat=n.outputFormat),e==="ExTime"&&"precision"in n&&(typeof n.precision=="number"||n.precision===null)&&(t.precision=n.precision),e==="ExDatetime"&&"checks"in n&&Array.isArray(n.checks)){let r=n.checks.find(u=>u.type==="datetime");r?.params&&r.params.offset===true&&(t.allowOffset=true);}return t}function Y(s,e=false){let t=new Map,n=new Map,a={typeName:"ExRow",shape:Object.entries(s._def.shape).reduce((l,[d,c])=>{let p=c._def.typeName,g={typeName:p,...H(c),...me(c,p)};if(c._def.checks&&Array.isArray(c._def.checks)&&(g.checks=ce(c._def.checks,t,n,e)),p==="ExOptional"&&"innerType"in c._def){let f=c._def.innerType,y=f._def.typeName,I=H(c),A=H(f),D=me(f,y),k={};for(let T of Object.keys(A))T!=="defaultValue"&&(k[T]=A[T]);let se={...k,...I};if(f._def.checks&&Array.isArray(f._def.checks)&&(D.checks=ce(f._def.checks,t,n,e)),g.innerType={typeName:y,...se,...D},!("defaultValue"in g)&&f._def&&"defaultValue"in f._def&&f._def.defaultValue!==void 0)if(typeof f._def.defaultValue=="function"){let T=`func_${Math.random().toString(36).substring(2,15)}`,B="default-value";n.set(T,{id:T,functionType:B,function:f._def.defaultValue}),e?t.set(T,{functionType:B,id:T,functionSource:"remote"}):t.set(T,{function:f._def.defaultValue,functionType:B,id:T,functionSource:"local"}),g.defaultValue={__type:"Function",id:T,functionType:B};}else g.defaultValue=f._def.defaultValue;}return l[d]=g,l},{})};if(s._def.optionalColumnConfig){a.optionalColumnConfig={columns:s._def.optionalColumnConfig.columns};let l=s._def.optionalColumnConfig.when,d=s._def.optionalColumnConfig.whenMap||{},c={},p;if(l){let g=`func_${Math.random().toString(36).substring(2,15)}`,f="optional-when";n.set(g,{id:g,functionType:f,function:l}),e?t.set(g,{functionType:f,id:g,functionSource:"remote"}):t.set(g,{function:l,functionType:f,id:g,functionSource:"local"}),p=g,a.optionalColumnConfig.when={__type:"Function",id:g,functionType:f};}if(Object.keys(d).length>0){for(let g of s._def.optionalColumnConfig.columns){let f=g.toString();if(d[f])if(l&&d[f]===l&&p)c[f]={__type:"Function",id:p,functionType:"optional-when"};else {let y=`func_${Math.random().toString(36).substring(2,15)}`;n.set(y,{id:y,functionType:"optional-when",function:d[f]}),e?t.set(y,{functionType:"optional-when",id:y,functionSource:"remote"}):t.set(y,{function:d[f],functionType:"optional-when",id:y,functionSource:"local"}),c[f]={__type:"Function",id:y,functionType:"optional-when"};}else c[f]=null;}a.optionalColumnConfig.whenMap=c;}else if(l){let g={};for(let f of s._def.optionalColumnConfig.columns){let y=f.toString();p?g[y]={__type:"Function",id:p,functionType:"optional-when"}:g[y]=null;}a.optionalColumnConfig.whenMap=g;}}s._def.uniqueColumnConfig&&(a.uniqueColumnConfig={uniqueConstraints:s._def.uniqueColumnConfig.uniqueConstraints.map(l=>{let d={id:l.id,columns:l.columns.map(c=>String(c))};if(l.key!==void 0){let c=`func_${Math.random().toString(36).substring(2,15)}`,p="unique-index";n.set(c,{id:c,functionType:p,function:l.key}),e?t.set(c,{functionType:p,id:c,functionSource:"remote"}):t.set(c,{function:l.key,functionType:p,id:c,functionSource:"local"}),d.hasKeyFn=true,d.keyFnId=c,d.key={__type:"Function",id:c,functionType:p};}return d})}),s._def.meta&&(a.meta=s._def.meta);let r=Z(a,t);return {json:JSON.stringify(r),functionMap:t,localFunctionMap:n}}var ye=class extends b{min(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExNumber.min: value must be a number");if(t!==void 0&&typeof t!="object")throw new Error("ExNumber.min: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExNumber.min: options.message must be a string");let n=this._findExistingCheck("min");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e<=l)return this}let a=this._findExistingCheck("max");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&e>a.check.params.value)throw new Error("ExNumber.min: min cannot be greater than max");let r=t?.message,u=this._addCheck("min",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}max(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExNumber.max: value must be a number");if(t!==void 0&&typeof t!="object")throw new Error("ExNumber.max: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExNumber.max: options.message must be a string");let n=this._findExistingCheck("max");if(n.found&&n.check?.params){let l=n.check.params.value;if(typeof l=="number"&&e>=l)return this}let a=this._findExistingCheck("min");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&a.check.params.value>e)throw new Error("ExNumber.max: max cannot be less than min");let r=t?.message,u=this._addCheck("max",{value:e},r);return this._replaceOrAddCheck(u,n.index),this}integer(e){if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.integer: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.integer: options.message must be a string");let t=this._findExistingCheck("integer"),n=e?.message,a=this._addCheck("integer",{},n);return this._replaceOrAddCheck(a,t.index),this}multipleOf(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExNumber.multipleOf: value must be a number");if(e===0)throw new Error("ExNumber.multipleOf: value cannot be zero");if(t!==void 0&&typeof t!="object")throw new Error("ExNumber.multipleOf: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExNumber.multipleOf: options.message must be a string");let n=this._findExistingCheck("multipleOf");if(n.found&&n.check?.params){let u=n.check.params.value;if(typeof u=="number"&&e===u)return this}let a=t?.message,r=this._addCheck("multipleOf",{value:e},a);return this._def.checks.push(r),this}},J=class s extends ye{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.create: options.message must be a string");return new s({typeName:"ExNumber",checks:[],message:e?.message})}optional(){return new $({typeName:"ExOptional",innerType:this})}percentage(){if(this._def.currencyCode!==void 0)throw new Error("ExNumber.percentage: Cannot combine percentage with currency");return this._def.isPercentage=true,this}currency(e){if(typeof e!="string")throw new Error("ExNumber.currency: currencyCode must be a string");if(this._def.isPercentage)throw new Error("ExNumber.currency: Cannot combine currency with percentage");return this._def.currencyCode=e,this}};var X=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExBoolean.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExBoolean.create: options.message must be a string");if(e?.control!==void 0&&e.control!=="toggle"&&e.control!=="checkbox"&&e.control!=="dropdown")throw new Error('ExBoolean.create: options.control must be "toggle", "checkbox", or "dropdown"');return new s({typeName:"ExBoolean",control:e?.control,message:e?.message,checks:[]})}optional(){return new U({typeName:"ExOptional",innerType:this})}};var Q=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExDate.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExDate.create: options.message must be a string");let t=new s({typeName:"ExDate"});return e?.message&&(t._def.message=e.message),t}optional(){return new L({typeName:"ExOptional",innerType:this})}output(e){if(typeof e!="string")throw new Error("ExDate.output: template must be a string");if(e.trim()==="")throw new Error("ExDate.output: template cannot be empty");return this._def.outputFormat=e,this}};var ee=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExTime.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExTime.create: options.message must be a string");return new s({typeName:"ExTime",checks:[],message:e?.message})}optional(){return new j({typeName:"ExOptional",innerType:this})}precision(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExTime.precision: precision must be a number");if(e<0||e>9||!Number.isInteger(e))throw new Error("ExTime.precision: precision must be an integer between 0 and 9");if(t!==void 0&&typeof t!="object")throw new Error("ExTime.precision: options must be an object");if(t?.message!==void 0&&typeof t.message!="string")throw new Error("ExTime.precision: options.message must be a string");return this._def.precision=e,t?.message&&(this._def.message=t.message),this}};var te=class s extends b{static create(e){if(e!==void 0&&typeof e!="object")throw new Error("ExDatetime.create: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExDatetime.create: options.message must be a string");let t=new s({typeName:"ExDatetime",checks:[],message:e?.message});if(e?.message){let n=t._getDatetimeCheck();n&&(n.message=e.message);}return t}optional(){return new z({typeName:"ExOptional",innerType:this})}output(e){if(typeof e!="string")throw new Error("ExDatetime.output: template must be a string");if(e.trim()==="")throw new Error("ExDatetime.output: template cannot be empty");return this._def.outputFormat=e,this}allowOffset(e){if(e!==void 0&&typeof e!="object")throw new Error("ExDatetime.allowOffset: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExDatetime.allowOffset: options.message must be a string");let t=e?.message,n=this._getDatetimeCheck();return n?.params&&(n.params.offset=true,t&&(n.message=t)),this}_getDatetimeCheck(){let e=this._def.checks.find(t=>t.type==="datetime");if(!e){let t=this._addCheck("datetime",{allowOffset:false});return this._def.checks.push(t),t}return e}};var ne=class s extends b{static create(e,t={}){if(!Array.isArray(e))throw new Error("ExSelect.create: options must be an array");if(e.length===0)throw new Error("ExSelect.create: options array must not be empty");for(let a=0;a<e.length;a++){let r=e[a];if(!r||typeof r!="object")throw new Error(`ExSelect.create: option at index ${a} must be an object`);if(!("label"in r)||typeof r.label!="string")throw new Error(`ExSelect.create: option at index ${a} must have a string label`);if(!("value"in r))throw new Error(`ExSelect.create: option at index ${a} must have a value`);if(typeof r.value!="string"&&typeof r.value!="number")throw new Error(`ExSelect.create: option at index ${a} must have a string or number value`)}if(t!==void 0&&typeof t!="object")throw new Error("ExSelect.create: config must be an object");if(t.enforceCaseSensitiveMatch!==void 0&&typeof t.enforceCaseSensitiveMatch!="boolean")throw new Error("ExSelect.create: config.enforceCaseSensitiveMatch must be a boolean");if(t.allowCustom!==void 0&&typeof t.allowCustom!="boolean")throw new Error("ExSelect.create: config.allowCustom must be a boolean");if(t.message!==void 0&&typeof t.message!="string")throw new Error("ExSelect.create: config.message must be a string");return new s({typeName:"ExSelect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:!!t.allowCustom},checks:[],message:t.message})}optional(){return new K({typeName:"ExOptional",innerType:this})}caseSensitive(e=true){if(typeof e!="boolean")throw new Error("ExSelect.caseSensitive: enabled must be a boolean");return this._def.config.enforceCaseSensitiveMatch=e,this}};var ae=class s extends b{static create(e,t={}){if(!Array.isArray(e))throw new Error("ExMultiselect.create: options must be an array");if(e.length===0)throw new Error("ExMultiselect.create: options array must not be empty");for(let a=0;a<e.length;a++){let r=e[a];if(!r||typeof r!="object")throw new Error(`ExMultiselect.create: option at index ${a} must be an object`);if(!("label"in r)||typeof r.label!="string")throw new Error(`ExMultiselect.create: option at index ${a} must have a string label`);if(!("value"in r))throw new Error(`ExMultiselect.create: option at index ${a} must have a value`);if(typeof r.value!="string"&&typeof r.value!="number")throw new Error(`ExMultiselect.create: option at index ${a} must have a string or number value`)}if(t!==void 0&&typeof t!="object")throw new Error("ExMultiselect.create: config must be an object");if(t.enforceCaseSensitiveMatch!==void 0&&typeof t.enforceCaseSensitiveMatch!="boolean")throw new Error("ExMultiselect.create: config.enforceCaseSensitiveMatch must be a boolean");if(t.message!==void 0&&typeof t.message!="string")throw new Error("ExMultiselect.create: config.message must be a string");return new s({typeName:"ExMultiselect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:false},checks:[],message:t.message})}optional(){return new G({typeName:"ExOptional",innerType:this})}caseSensitive(e=true){if(typeof e!="boolean")throw new Error("ExMultiselect.caseSensitive: enabled must be a boolean");return this._def.config.enforceCaseSensitiveMatch=e,this}min(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExMultiselect.min: min must be a number");if(e<1||!Number.isInteger(e))throw new Error("ExMultiselect.min: min must be a positive integer (at least 1)");let n=this._findExistingCheck("min");if(n.found&&n.check?.params){let u=n.check.params.value;if(typeof u=="number"&&e<=u)return this}let a=this._findExistingCheck("max");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&e>a.check.params.value)throw new Error("ExMultiselect.min: min cannot be greater than max");let r=this._addCheck("min",{value:e},t);return this._replaceOrAddCheck(r,n.index),this}max(e,t){if(typeof e!="number"||Number.isNaN(e))throw new Error("ExMultiselect.max: max must be a number");if(e<1||!Number.isInteger(e))throw new Error("ExMultiselect.max: max must be a positive integer");let n=this._findExistingCheck("max");if(n.found&&n.check?.params){let u=n.check.params.value;if(typeof u=="number"&&e>=u)return this}let a=this._findExistingCheck("min");if(a.found&&a.check?.params&&typeof a.check.params.value=="number"&&a.check.params.value>e)throw new Error("ExMultiselect.max: max cannot be less than min");let r=this._addCheck("max",{value:e},t);return this._replaceOrAddCheck(r,n.index),this}};function It(){return `uc_${Math.random().toString(36).substring(2,15)}${Math.random().toString(36).substring(2,15)}`}var V=class s extends _{static create(e){if(!e||typeof e!="object")throw new Error("ExRow.create: shape must be a non-null object");for(let[t,n]of Object.entries(e)){if(!n||typeof n!="object")throw new Error(`ExRow.create: field "${t}" must be a valid field type`);if(!("_def"in n)||!n._def||typeof n._def!="object")throw new Error(`ExRow.create: field "${t}" is not a valid ExpressCSV field`);if(!("typeName"in n._def)||typeof n._def.typeName!="string")throw new Error(`ExRow.create: field "${t}" is missing a typeName`)}return new s({typeName:"ExRow",shape:e})}optionalColumns(e,t){if(!Array.isArray(e))throw new Error("ExRow.optionalColumns: columns must be an array");for(let l of e)if(!(l in this._def.shape))throw new Error(`ExRow.optionalColumns: column "${String(l)}" does not exist in the row shape`);if(t!==void 0&&typeof t!="object")throw new Error("ExRow.optionalColumns: options must be an object");if(t?.when!==void 0&&typeof t.when!="function")throw new Error("ExRow.optionalColumns: options.when must be a function");let n=e,a=t?.when;if(!this._def.optionalColumnConfig)return this._def.optionalColumnConfig={columns:n,when:a,whenMap:a?Object.fromEntries(n.map(l=>[l,a])):void 0},this;let u=[...this._def.optionalColumnConfig.columns];for(let l of n)u.includes(l)||u.push(l);if(this._def.optionalColumnConfig.columns=u,a){this._def.optionalColumnConfig.whenMap||(this._def.optionalColumnConfig.whenMap={});for(let l of n)this._def.optionalColumnConfig.whenMap[l]=a;}return this}unique(e,t){if(e===void 0)throw new Error("ExRow.unique: columns must be provided");let n=Array.isArray(e)?e:[e];for(let c of n)if(!(c in this._def.shape))throw new Error(`ExRow.unique: column "${String(c)}" does not exist in the row shape`);if(t!==void 0&&typeof t!="object")throw new Error("ExRow.unique: options must be an object");if(t?.key!==void 0&&typeof t.key!="function")throw new Error("ExRow.unique: options.key must be a function");let a=t?.key;this._def.uniqueColumnConfig||(this._def.uniqueColumnConfig={uniqueConstraints:[]});let r=a?c=>{let p=Object.fromEntries(n.map(g=>[g,c[g]]));return a(p)}:void 0,u=(c,p)=>{if(c.length!==p.length)return false;let g=[...c].sort(),f=[...p].sort();return g.every((y,I)=>y===f[I])},l=this._def.uniqueColumnConfig.uniqueConstraints.findIndex(c=>u(c.columns,n)),d={id:It(),columns:n,key:r};return l!==-1?this._def.uniqueColumnConfig.uniqueConstraints[l]=d:this._def.uniqueColumnConfig.uniqueConstraints.push(d),this}meta(e){if(e===void 0||typeof e!="object")throw new Error("ExRow.meta: metadata must be an object");if(e.description!==void 0&&typeof e.description!="string")throw new Error("ExRow.meta: metadata.description must be a string");return this._def.meta={...this._def.meta,...e},this}minRows(e){if(typeof e!="number")throw new Error("ExRow.minRows: count must be a number");if(!Number.isInteger(e))throw new Error("ExRow.minRows: count must be an integer");if(e<0)throw new Error("ExRow.minRows: count must be non-negative");return this._def.rowCountConfig||(this._def.rowCountConfig={}),this._def.rowCountConfig.minRows=e,this}maxRows(e){if(typeof e!="number")throw new Error("ExRow.maxRows: count must be a number");if(!Number.isInteger(e))throw new Error("ExRow.maxRows: count must be an integer");if(e<=0)throw new Error("ExRow.maxRows: count must be positive");return this._def.rowCountConfig||(this._def.rowCountConfig={}),this._def.rowCountConfig.maxRows=e,this}};var _e={string:q.create,number:J.create,boolean:X.create,date:Q.create,time:ee.create,datetime:te.create,row:V.create,select:ne.create,multiselect:ae.create,infer:s=>{}};var Dt=class{constructor(){this.items=[],this.processing=false;}enqueue(s){this.items.push(s);}dequeueUpTo(s){if(this.processing||this.items.length===0)return [];this.processing=true;let e=this.items.splice(0,s);return this.processing=false,e}size(){return this.items.length}isEmpty(){return this.items.length===0}dispose(){this.items=[];}};async function Mt(s,e){return Promise.all(s.map(t=>e(t)))}var x=(s=>(s.UNINITIALIZED="uninitialized",s.INITIALIZING="initializing",s.READY="ready",s.OPENING="opening",s.OPEN="open",s.CLOSING="closing",s.RESETTING="resetting",s.ERROR="error",s.DESTROYED="destroyed",s))(x||{}),S=(s=>(s.NORMAL="normal",s.PRELOAD="preload",s))(S||{}),pe={maxSize:200,maxDelay:50},Nt={maxRetries:3,retryDelay:500,acknowledgmentTimeout:2e3};function re(s="msg"){return `${s}_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Pt(s,e,t={}){let n=t.timeout||5e3,a={...Nt,...t.messagingConfig},r=new Map,u=[],l=null,d=new Dt,c=null,p=[],g=null,f=true,y=new Map,I=h=>{let m={kind:"singleton",type:"ack",id:h,retryCount:0,originalSentAt:Date.now()};s.postMessage(m,e);},A=h=>{let m=y.get(h);m&&(m.timeout&&clearTimeout(m.timeout),y.delete(h));},D=h=>{h.id||(h.id=re());try{s.postMessage(h,e);let m=0,w=setTimeout(()=>{k(h.id);},a.acknowledgmentTimeout);y.set(h.id,{message:h,retryCount:m,timeout:w});}catch(m){console.error("Error posting message:",m),f=false;}},k=h=>{let m=y.get(h);if(!m)return;if(m.retryCount>=a.maxRetries){if(y.delete(h),m.message.kind==="batch"&&m.message.type==="batch-rpc")for(let E of m.message.calls){let R=r.get(E.requestId);R&&(R.reject(new Error(`RPC call failed after ${a.maxRetries} retries`)),r.delete(E.requestId));}return}m.retryCount++,m.message.retryCount=m.retryCount,m.message.originalSentAt=m.message.originalSentAt||Date.now();try{s.postMessage(m.message,e);}catch(E){console.error("Error retrying message:",E),f=false;}let w=a.retryDelay*2**m.retryCount;m.timeout=setTimeout(()=>{k(h);},w),y.set(h,m);},se=h=>{if(e!=="*"&&h.origin!==e)return;let m=h.data;if(!(!m||typeof m!="object")){if(m.kind==="singleton"&&m.type==="ack"&&m.id){A(m.id);return}if(m.id&&I(m.id),m.kind==="singleton")if(m.type==="response"&&m.id){let w=r.get(m.id);w&&(m.error?w.reject(new Error(m.error)):w.resolve(m.data),r.delete(m.id));}else for(let w of u)try{w(m);}catch(E){console.error("Error in message handler:",E);}else if(m.kind==="batch"&&m.type==="batch-rpc-response")for(let w of m.responses){let E=r.get(w.requestId);E&&(w.status==="error"?E.reject(new Error(w.error.message||"RPC call failed")):E.resolve(w.result),r.delete(w.requestId));}else m.kind==="batch"&&m.type==="batch-rpc"&&T(m);}},T=async h=>{if(!l){for(let E of h.calls)B({requestId:E.requestId,functionId:E.functionId,status:"error",error:{code:"METHOD_NOT_FOUND",message:"No RPC handler registered"}});Ee();return}let m=l,w=await Mt(h.calls,async E=>{try{let R=await m({functionName:E.functionName,requestId:E.requestId,functionId:E.functionId,params:E.params});return {requestId:E.requestId,functionId:E.functionId,status:"success",result:R}}catch(R){return {requestId:E.requestId,functionId:E.functionId,status:"error",error:{code:"EXECUTION_ERROR",message:R instanceof Error?R.message:"Unknown error",details:R}}}});for(let E of w)p.push(E);p.length>0&&fe();},B=h=>{p.push(h),p.length>=pe.maxSize?fe():Ee();},fe=()=>{if(p.length===0)return;let h={kind:"batch",type:"batch-rpc-response",id:re("batch_resp"),responses:[...p],retryCount:0,originalSentAt:Date.now()};p=[],g&&(clearTimeout(g),g=null),D(h);},Ee=()=>{g||(g=setTimeout(()=>{fe();},pe.maxDelay));},we=()=>{if(d.isEmpty())return;let h=d.size(),m=d.dequeueUpTo(h);if(m.length===0)return;let w={kind:"batch",type:"batch-rpc",id:re("batch"),calls:[...m],retryCount:0,originalSentAt:Date.now()};c&&(clearTimeout(c),c=null),D(w);},Le=()=>{c||(c=setTimeout(()=>{we(),c=null;},pe.maxDelay));};return window.addEventListener("message",se),{callRPC:({functionName:h,functionId:m,params:w})=>new Promise((E,R)=>{let ie=re("rpc"),ze={requestId:ie,functionName:h,functionId:m,params:w};r.set(ie,{resolve:de=>{E(de);},reject:de=>{R(de);}}),setTimeout(()=>{r.has(ie)&&(r.delete(ie),R(new Error(`Call to ${h} timed out`)));},n),d.enqueue(ze),d.size()>=pe.maxSize?we():Le();}),registerRPCHandler:h=>{l=h;},sendMessage:h=>{let m={...h,kind:"singleton",id:re(),retryCount:0,originalSentAt:Date.now()};D(m);},registerMessageHandler:h=>{u.push(h);},disconnect:()=>{window.removeEventListener("message",se);for(let[,h]of r)h.reject(new Error("Connection closed"));for(let[,h]of y)h.timeout&&clearTimeout(h.timeout);c&&clearTimeout(c),g&&clearTimeout(g),r.clear(),y.clear(),d.dispose(),p=[],f=false;},getConnectionStatus:()=>f}}function Ve(s,e={}){let t=s.contentWindow;if(!t)throw new Error("Cannot connect to iframe: contentWindow is null");let n=e.targetOrigin||new URL(s.src).origin||"*";return Pt(t,n,e)}var xe=class s extends Error{constructor(e="Import was cancelled by the user"){super(e),this.name="ImportCancelledError",Error.captureStackTrace&&Error.captureStackTrace(this,s);}};var Ue=class{constructor(e){this.options=e;this.iframe=null;this.container=null;this.connection=null;this.connectionState=false;this.debug=false;this.developerMode=false;this.sessionId=null;this._destroyTimer=null;this._beforeUnloadHandler=null;this.widgetUrl=process.env.NODE_ENV==="development"?"http://localhost:3001":"https://widget.expresscsv.com";this.widgetState=x.UNINITIALIZED;this.canRestart=false;this.lastError=null;this.openOptions=null;this.cachedSchemaJson=null;this.initCompletePromise=null;this.resolveInitComplete=null;this.debug=e.debug||false,this.developerMode=e.developerMode||false,this.importIdentifier=e.importIdentifier,this.widgetMode=e.preload!==false?S.PRELOAD:S.NORMAL,this.log("Initializing CSVImporter with options:",e),e.preload!==false&&(this.setState(x.INITIALIZING,"Auto-preload initialization"),this.initCompletePromise=new Promise(t=>{this.resolveInitComplete=t;}),this.initializeIframe(true).catch(t=>{this.log("Auto-preload failed:",t),this.initCompletePromise=null,this.resolveInitComplete=null,this.handleError(t instanceof Error?t:new Error("Preload failed"));}));}setState(e,t){this.widgetState=e,this.log(`State change: \u2192 ${e}`,t),this.connection&&this.connection.sendMessage({type:"action:sync_state",data:{sdkState:e,mode:this.widgetMode}}),this.updateDerivedState();}updateDerivedState(){this.canRestart=this.widgetState===x.READY||this.widgetState===x.ERROR;}handleError(e){this.lastError=e,this.setState(x.ERROR,e.message),this.openOptions?.onError?.(e),this.openOptions=null;}async waitForEvent(e,t=5e3){return new Promise((n,a)=>{let r=setTimeout(()=>{a(new Error(`Timeout waiting for ${e}`));},t),u=l=>{l.type===e&&(clearTimeout(r),n(l.data));};this.connection?.registerMessageHandler(u);})}open(e){if(this.log("open() called",e),this.openOptions){this.log("open() called while already active, ignoring");return}if(this.sessionId=crypto.randomUUID(),this.connection&&this.widgetState===x.READY&&this.connection.sendMessage({type:"action:update_session_id",data:{sessionId:this.sessionId}}),this.openOptions=e,!this.cachedSchemaJson){let t=Y(this.options.schema,true);this.cachedSchemaJson=t.json;}this.openWidget().then(()=>{this.log("Widget opened successfully for open()"),this.createImportSession({chunkSize:e.chunkSize,webhook:e.webhook}).catch(t=>{if(this.log("Failed to create import session:",t),t.code==="NO_ACCESS"){this.connection&&this.connection.sendMessage({type:"action:set_error",data:{message:"Unable to start import. If you are the administrator of this account, please access your ExpressCSV dashboard for more information.",code:"NO_ACCESS"}});let a=new Error("Unable to start import. If you are the administrator of this account, please access your ExpressCSV dashboard for more information.");this.openOptions?.onError?.(a);}else {let a=t instanceof Error?t:new Error("Failed to create import session");this.openOptions?.onError?.(a);}});}).catch(t=>{this.log("Failed to open widget in open():",t);let n=t instanceof Error?t:new Error("Failed to open widget");this.openOptions?.onError?.(n),this.openOptions=null;});}async createImportSession({chunkSize:e,webhook:t}){if(!this.sessionId)throw new Error("Session ID not initialized");if(!this.cachedSchemaJson)throw new Error("Schema not serialized yet. Call open() after widget initialization.");let a=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/import-sessions`,r={schema:this.cachedSchemaJson,chunkSize:e,title:this.options.title,theme:this.options.theme,colorMode:this.options.colorMode,customCSS:this.options.customCSS,fonts:this.options.fonts,stepDisplay:this.options.stepDisplay,developerMode:this.options.developerMode,debug:this.options.debug,previewSchemaBeforeUpload:this.options.previewSchemaBeforeUpload??true};t&&(r.webhook={url:t.url,headers:t.headers,method:t.method,metadata:t.metadata});let u=await fetch(a,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,configuration:r})});if(!u.ok){let l,d="Unknown error";try{let p=await u.json();l=p.code,d=p.message||p.error||d;}catch{d=await u.text().catch(()=>"Unknown error");}let c=new Error(`Failed to create import session: ${u.status} ${u.statusText} - ${d}`);throw c.code=l,c}this.log("Import session created successfully",{sessionId:this.sessionId});}async deliverToWebhook(e,t,n,a){let u=e.length,l=Math.ceil(u/1e3);for(let d=0;d<l;d++){let c=d*1e3,p=Math.min(c+1e3,u),f={records:e.slice(c,p),totalChunks:l,currentChunkIndex:d,totalRecords:n.totalRecords};await this.sendChunkToBackend(f,t,a);}}async sendChunkToBackend(e,t,n){if(!this.sessionId)throw new Error("Session ID not initialized. Call open() first.");let r=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/webhooks/deliver`,u=3,l=3e4,d=null;for(let c=0;c<=u;c++){let p=new AbortController,g=setTimeout(()=>p.abort(),l);try{let f=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,webhook:{url:t.url,headers:t.headers,method:t.method,metadata:t.metadata,chunkSize:n},chunk:{records:e.records,totalChunks:e.totalChunks,currentChunkIndex:e.currentChunkIndex,totalRecords:e.totalRecords}}),signal:p.signal});if(clearTimeout(g),!f.ok){let y=f.status;if(y>=400&&y<500&&y!==429){let I=await f.text().catch(()=>"Unknown error");throw new Error(`Backend API error: ${y} ${f.statusText} - ${I}`)}throw new Error(`Backend API error: ${y} ${f.statusText}`)}this.log(`Chunk ${e.currentChunkIndex+1}/${e.totalChunks} sent to backend successfully (attempt ${c+1})`);return}catch(f){clearTimeout(g),d=f instanceof Error?f:new Error(String(f)),this.log(`Failed to send chunk to backend (attempt ${c+1}/${u+1}):`,d),c<u&&await new Promise(y=>setTimeout(y,2**c*1e3));}}throw d||new Error("Failed to send chunk to backend")}async processResultsInChunks(e){if(!this.openOptions){this.log("No open options available, skipping chunk processing");return}let{chunkSize:t=1e3,onData:n,webhook:a,onComplete:r,onError:u}=this.openOptions,l=e.length,d=t<=0?l:t,c=Math.ceil(l/d);this.log(`Processing ${l} records in ${c} chunks of ${d}`);try{for(let p=0;p<c;p++){let g=p*d,f=Math.min(g+d,l),I={records:e.slice(g,f),totalChunks:c,currentChunkIndex:p,totalRecords:l};n&&await new Promise((A,D)=>{try{let k=n(I,A);k instanceof Promise&&k.catch(D);}catch(k){D(k);}});}if(a){let p={records:[],totalChunks:c,currentChunkIndex:c-1,totalRecords:l};await this.deliverToWebhook(e,a,p,d);}this.log("All chunks processed successfully"),r?.();}catch(p){this.log("Error during chunk processing:",p);let g=p instanceof Error?p:new Error(String(p));u?.(g);}finally{this.openOptions=null;}}async initializeIframe(e=false){this.log(`Initializing iframe (hidden: ${e})`),(this.iframe||this.container||this.connection)&&(this.log("Cleaning up existing resources before initialization"),this.destroy(false));try{this.container=document.createElement("div"),e?(this.container.style.position="fixed",this.container.style.top="-9999px",this.container.style.left="-9999px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.pointerEvents="none",this.container.style.visibility="hidden",this.container.style.zIndex="-1"):(this.container.style.position="fixed",this.container.style.inset="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.zIndex="2147483647",this.container.style.visibility="visible"),document.body.appendChild(this.container),this.log(`Created ${e?"hidden":"visible"} container`),this.createAndAppendIframe(this.container),this.log("Created iframe"),await this.waitForIframeLoad(),await this.setupConnectionAndInit(),this.log(`Iframe initialization complete (hidden: ${e})`);}catch(t){throw this.log("Iframe initialization failed:",t),this.destroy(false),t}}log(...e){(this.debug||process.env.NODE_ENV==="development")&&console.log("[CSVImporter]",...e);}error(...e){console.error("[CSVImporter]",...e);}addBeforeUnloadListener(){if(this._beforeUnloadHandler){this.log("beforeunload listener already exists");return}this._beforeUnloadHandler=e=>{let t="You have an import in progress. Are you sure you want to leave? Your progress will be lost.";return e.preventDefault(),t},window.addEventListener("beforeunload",this._beforeUnloadHandler),this.log("Added beforeunload listener");}removeBeforeUnloadListener(){this._beforeUnloadHandler&&(window.removeEventListener("beforeunload",this._beforeUnloadHandler),this._beforeUnloadHandler=null,this.log("Removed beforeunload listener"));}async waitForIframeLoad(){return new Promise((e,t)=>{if(!this.iframe){this.log("No iframe available, rejecting promise"),t(new Error("No iframe available"));return}try{if(this.iframe.contentWindow&&this.iframe.contentDocument&&this.iframe.contentDocument.readyState==="complete"){this.log("Iframe already loaded (cached)"),e();return}}catch{this.log("Cannot check iframe load state (CORS), waiting for onload");}let n=false,a=()=>{this.iframe&&(this.iframe.onload=null,this.iframe.onerror=null);},r=()=>{n||(n=true,clearTimeout(l),a(),e());},u=d=>{n||(n=true,clearTimeout(l),a(),t(d));},l=setTimeout(()=>{this.log("Iframe load timeout reached"),u(new Error("Iframe load timeout"));},1e4);this.iframe.onload=()=>{this.log("Iframe loaded successfully"),r();},this.iframe.onerror=d=>{this.error("Iframe failed to load:",d),u(new Error("Failed to load iframe"));};})}async setupConnectionAndInit(){if(this.log("Creating connection to iframe"),this.connection=this.iframe?Ve(this.iframe):null,!this.connection||!this.iframe)throw this.log("Failed to create connection or iframe is missing"),new Error("Failed to create iframe or establish connection");this.log("Setting up message handlers"),this.setupMessageHandlers(),this.log("Sending init message",this.options);let e=Y(this.options.schema,true);this.cachedSchemaJson=e.json,this.initCompletePromise||(this.initCompletePromise=new Promise(t=>{this.resolveInitComplete=t;})),this.connection.sendMessage({type:"action:init",data:{schemaJson:e.json,functionMapJson:JSON.stringify([...e.functionMap]),title:this.options.title,publishableKey:this.options.publishableKey,importIdentifier:this.importIdentifier,developerMode:this.developerMode,theme:this.options.theme,colorMode:this.options.colorMode,customCSS:this.options.customCSS,fonts:this.options.fonts,stepDisplay:this.options.stepDisplay||"progressBar",previewSchemaBeforeUpload:this.options.previewSchemaBeforeUpload??true,templateDownload:this.options.templateDownload,saveSession:this.options.saveSession,locale:this.options.locale}}),this.connection.registerRPCHandler(async({functionName:t,functionId:n,params:a})=>{let r=e.localFunctionMap.get(n);if(!r)throw new Error(`Unknown function: ${t}`);let u=r.function;return await u(a)}),this.connectionState=true,this.log("Connection established and initialized");}async openWidget(e){if(this.log("openWidget() called",{currentState:this.widgetState,options:e}),this.widgetState===x.OPEN){this.log("Widget is already open, ignoring openWidget() call");return}let t=this.widgetState;this.setState(x.OPENING,"User requested open");try{e?.reset&&await this.resetWidget(),this.widgetMode===S.PRELOAD&&t===x.READY?(this.log("Using preloaded iframe - making visible instantly"),this.makeContainerVisible(),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:e?.reset,sessionId:this.sessionId??void 0}})):this.widgetMode===S.PRELOAD&&this.initCompletePromise?(this.log("Preload in progress, awaiting init_complete before opening"),await this.initCompletePromise,this.makeContainerVisible(),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:e?.reset,sessionId:this.sessionId??void 0}})):(this.log("Initializing iframe for immediate display"),await this.initializeIframe(!1),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:e?.reset,sessionId:this.sessionId??void 0}})),this.setState(x.OPEN,"Widget opened successfully"),this.openOptions?.onWidgetOpen?.(),this.addBeforeUnloadListener();}catch(n){throw this.log("Failed to open widget:",n),this.handleError(n instanceof Error?n:new Error("Failed to open widget")),n}}makeContainerVisible(){this.container&&(this.log("Making container visible"),this.container.style.position="fixed",this.container.style.inset="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.zIndex="2147483647",this.container.style.visibility="visible",this.container.style.pointerEvents="auto",this.container.style.top="0px",this.container.style.left="0px",this.iframe&&(this.iframe.style.pointerEvents="auto"));}setupMessageHandlers(){if(!this.connection){this.log("Cannot setup message handlers - no connection available");return}this.log("Registering onMessage handler"),this.connection.registerMessageHandler(async e=>{if(e.type==="event:results"){this.log("Processing results message");let t=e.data;this.openOptions?(await this.processResultsInChunks(t),this.connection&&this.connection.sendMessage({type:"event:results_processed"})):this.connection&&this.connection.sendMessage({type:"event:results_processed"});}else if(e.type==="event:init_complete")this.log("Widget initialized successfully"),this.resolveInitComplete&&(this.resolveInitComplete(),this.resolveInitComplete=null),this.setState(x.READY,"Widget initialization complete");else if(e.type==="event:widget_closed"){this.log("Processing widget closed message:",e.data);let t=e.data.reason;this.openOptions?.onWidgetClose?.(t),t==="cancel"&&this.openOptions&&(this.openOptions.onCancel?.(),this.openOptions=null),await this.handleWidgetClosed(t);}else if(e.type==="event:step_change"){this.log("Processing step change message:",e.data);let t=e.data.stepId,n=e.data.previousStepId;this.openOptions?.onStepChange?.(t,n);}else e.type==="event:state_change"?this.log("Widget state changed:",e.data):e.type==="event:widget_status"?this.log("Widget status update:",e.data):e.type==="event:reset_complete"?this.log("Widget reset complete:",e.data):e.type==="event:restart_complete"&&this.log("Widget restart complete:",e.data);});}createAndAppendIframe(e){this.log("Creating iframe"),this.iframe=document.createElement("iframe"),this.iframe.src=this.widgetUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none",this.iframe.style.overflow="hidden",e.appendChild(this.iframe),this.log("Iframe appended to container, URL:",this.widgetUrl);}destroy(e=true){if(this.log("destroy() called, resetReadyState:",e),this._destroyTimer!==null&&(this.log("Clearing existing destroy timer"),window.clearTimeout(this._destroyTimer),this._destroyTimer=null),this.widgetState===x.DESTROYED&&!this.iframe&&!this.container&&!this.connection){this.log("Already destroyed, nothing to do");return}this.removeBeforeUnloadListener(),this.initCompletePromise=null,this.resolveInitComplete=null;try{this.connection&&(this.log("Disconnecting connection"),this.connection.disconnect(),this.connection=null,this.connectionState=!1),this.iframe&&(this.log("Cleaning up iframe"),this.iframe.onload=null,this.iframe.onerror=null,this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.iframe=null),this.container&&(this.log("Cleaning up container"),this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=null),this.log("Destroy complete");}catch(t){this.error("Error during destroy:",t);}}async close(e="user_close"){if(this.log("close() called",{currentState:this.widgetState,reason:e}),this.widgetState===x.CLOSING||this.widgetState===x.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}if(this.widgetState!==x.OPEN){this.log("Not open, ignoring close call");return}this.setState(x.CLOSING,`Close requested: ${e}`);try{this.connection&&(this.log("Sending close message to widget"),this.connection.sendMessage({type:"action:close_widget",data:{reason:e}}));}catch(t){this.error("Error during close preparation:",t);}this.removeBeforeUnloadListener(),this.widgetMode===S.PRELOAD?(this.hideContainer(),this.setState(x.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(x.DESTROYED,"Normal mode widget destroyed"));}async resetWidget(){this.log("resetWidget() called",{currentState:this.widgetState}),this.setState(x.RESETTING,"Reset requested");try{this.connection&&(this.connection.sendMessage({type:"action:reset_widget",data:{preserveConnection:this.widgetMode===S.PRELOAD}}),await this.waitForEvent("event:reset_complete")),this.lastError=null,this.widgetMode===S.PRELOAD?this.setState(x.READY,"Reset complete - preload mode"):this.setState(x.UNINITIALIZED,"Reset complete - normal mode");}catch(e){throw this.handleError(e instanceof Error?e:new Error("Reset failed")),e}}async restart(e){if(this.log("restart() called",{currentState:this.widgetState,newOptions:e}),!this.canRestart)throw new Error("Widget cannot be restarted in current state");try{await this.resetWidget(),e&&(Object.assign(this.options,e),this.widgetMode=this.options.preload!==!1?S.PRELOAD:S.NORMAL,this.connection&&(this.connection.sendMessage({type:"action:restart_widget",data:{newOptions:e}}),await this.waitForEvent("event:restart_complete"))),await this.openWidget();}catch(t){throw this.handleError(t instanceof Error?t:new Error("Restart failed")),t}}async handleWidgetClosed(e){if(this.log("handleWidgetClosed() called",{currentState:this.widgetState,reason:e}),this.widgetState===x.CLOSING||this.widgetState===x.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}this.setState(x.CLOSING,`Widget closed: ${e}`),this.removeBeforeUnloadListener(),this.widgetMode===S.PRELOAD?(this.hideContainer(),this.setState(x.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(x.DESTROYED,"Normal mode widget destroyed"));}hideContainer(){this.container&&(this.log("Hiding container for reuse"),this.container.style.visibility="hidden",this.container.style.pointerEvents="none",this.container.style.zIndex="-1",this.container.style.top="-9999px",this.container.style.left="-9999px");}getConnectionStatus(){let e=this.connectionState&&this.connection?.getConnectionStatus();return this.log("getConnectionStatus() called, returning:",e),!!e}getState(){return this.widgetState}getMode(){return this.widgetMode}getIsReady(){let e=this.widgetState===x.READY||this.widgetState===x.OPEN;return this.log("getIsReady() called, returning:",e),e}getIsOpen(){let e=this.widgetState===x.OPEN;return this.log("getIsOpen() called, returning:",e),e}getCanRestart(){return this.log("getCanRestart() called, returning:",this.canRestart),this.canRestart}getLastError(){return this.lastError}getStatus(){return {state:this.widgetState,mode:this.widgetMode,isReady:this.getIsReady(),isOpen:this.getIsOpen(),canRestart:this.canRestart,hasError:!!this.lastError,lastError:this.lastError,connectionStatus:this.getConnectionStatus()}}getVersion(){let e="2.0.0";return this.log("getVersion() called, returning:",e),e}};
2
+ export{Ue as CSVImporter,xe as ImportCancelledError,S as WidgetMode,x as WidgetState,_e as x};
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@expresscsv/sdk",
3
+ "version": "0.0.1",
4
+ "description": "SDK for integrating widget",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "dev": "tsup --config tsup.config.ts --watch",
13
+ "build": "tsup --config tsup.config.ts",
14
+ "typecheck": "tsc --noEmit",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest watch",
17
+ "test:coverage": "vitest run --coverage",
18
+ "clean": "rm -rf dist .turbo"
19
+ },
20
+ "keywords": [
21
+ "widget",
22
+ "iframe"
23
+ ],
24
+ "author": "",
25
+ "license": "ISC",
26
+ "devDependencies": {
27
+ "@expresscsv/tsconfig": "workspace:*",
28
+ "@types/node": "^20.0.0",
29
+ "@vitest/coverage-v8": "^3.1.1",
30
+ "happy-dom": "^14.12.3",
31
+ "tsup": "^8.0.0",
32
+ "typescript": "^5.0.0",
33
+ "vitest": "^1.6.1"
34
+ }
35
+ }