@expresscsv/react 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 +420 -0
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
# ExpressCSV React SDK
|
|
2
|
+
|
|
3
|
+
A React component wrapper for the ExpressCSV SDK that provides a simple, declarative way to integrate CSV import functionality into your React applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using pnpm
|
|
9
|
+
pnpm add @expresscsv/react
|
|
10
|
+
|
|
11
|
+
# Using npm
|
|
12
|
+
npm install @expresscsv/react
|
|
13
|
+
|
|
14
|
+
# Using yarn
|
|
15
|
+
yarn add @expresscsv/react
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
The React SDK provides a `useExpressCSV` hook for easy integration into your React components.
|
|
21
|
+
|
|
22
|
+
### Basic Usage
|
|
23
|
+
|
|
24
|
+
The React SDK provides a `useExpressCSV` hook for easy integration:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { useExpressCSV, x, type Infer } from '@expresscsv/react';
|
|
28
|
+
|
|
29
|
+
const schema = x.row({
|
|
30
|
+
name: x.string().label('Full Name'),
|
|
31
|
+
email: x.string().email().label('Email Address'),
|
|
32
|
+
age: x.number().label('Age').min(18),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function App() {
|
|
36
|
+
const { open, isOpen, widgetState } = useExpressCSV({
|
|
37
|
+
schema,
|
|
38
|
+
title: "Import Users",
|
|
39
|
+
importIdentifier: "user-import",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const handleImport = () => {
|
|
43
|
+
open({
|
|
44
|
+
chunkSize: 100,
|
|
45
|
+
onData: async (chunk, next) => {
|
|
46
|
+
console.log(`Processing chunk ${chunk.currentChunkIndex + 1}/${chunk.totalChunks}`);
|
|
47
|
+
console.log('CSV data:', chunk.records);
|
|
48
|
+
// Process your validated data here
|
|
49
|
+
next();
|
|
50
|
+
},
|
|
51
|
+
onComplete: () => {
|
|
52
|
+
console.log('All chunks processed');
|
|
53
|
+
},
|
|
54
|
+
onCancel: () => {
|
|
55
|
+
console.log('User cancelled import');
|
|
56
|
+
},
|
|
57
|
+
onError: (error) => {
|
|
58
|
+
console.error('Import error:', error);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<button onClick={handleImport} disabled={isOpen}>
|
|
65
|
+
Import CSV
|
|
66
|
+
</button>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Preload for Instant Display
|
|
72
|
+
|
|
73
|
+
By default, the widget preloads in the background for instant display. This provides the best user experience with minimal perceived loading time.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { useExpressCSV, x } from '@expresscsv/react';
|
|
77
|
+
|
|
78
|
+
const schema = x.row({
|
|
79
|
+
name: x.string().label('Full Name'),
|
|
80
|
+
email: x.string().email().label('Email Address'),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
function App() {
|
|
84
|
+
// Preload is enabled by default
|
|
85
|
+
const { open } = useExpressCSV({
|
|
86
|
+
schema,
|
|
87
|
+
title: "Import Users",
|
|
88
|
+
importIdentifier: "user-import",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const handleImport = () => {
|
|
92
|
+
open({
|
|
93
|
+
onData: async (chunk, next) => {
|
|
94
|
+
console.log('CSV data:', chunk.records);
|
|
95
|
+
next();
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<button onClick={handleImport}>
|
|
102
|
+
Import CSV
|
|
103
|
+
</button>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
To disable preload for specific use cases (not recommended for most scenarios):
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
const { open } = useExpressCSV({
|
|
112
|
+
schema,
|
|
113
|
+
title: "Import Users",
|
|
114
|
+
importIdentifier: "user-import",
|
|
115
|
+
preload: false, // Disable preload
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Webhook Delivery
|
|
120
|
+
|
|
121
|
+
You can deliver CSV data to a webhook endpoint instead of (or in addition to) using local callbacks. The backend will handle retries, exponential backoff, and deliver data in chunks:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { useExpressCSV, x, type Infer, type WebhookConfig } from '@expresscsv/react';
|
|
125
|
+
|
|
126
|
+
const schema = x.row({
|
|
127
|
+
name: x.string().label('Full Name'),
|
|
128
|
+
email: x.string().email().label('Email Address'),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
function App() {
|
|
132
|
+
const { open } = useExpressCSV({
|
|
133
|
+
schema,
|
|
134
|
+
title: "Import Users",
|
|
135
|
+
importIdentifier: "user-import",
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const handleImport = () => {
|
|
139
|
+
open({
|
|
140
|
+
chunkSize: 500, // Optional: chunk size for webhook delivery (default: 1000)
|
|
141
|
+
webhook: {
|
|
142
|
+
url: 'https://api.example.com/webhooks/csv-import',
|
|
143
|
+
method: 'POST',
|
|
144
|
+
headers: {
|
|
145
|
+
'Authorization': 'Bearer your-api-token',
|
|
146
|
+
'X-Custom-Header': 'custom-value',
|
|
147
|
+
},
|
|
148
|
+
metadata: {
|
|
149
|
+
// Optional: arbitrary metadata to include in webhook payload
|
|
150
|
+
source: 'react-app',
|
|
151
|
+
userId: 'user-123',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
onComplete: () => {
|
|
155
|
+
console.log('Webhook delivery initiated');
|
|
156
|
+
},
|
|
157
|
+
onError: (error) => {
|
|
158
|
+
console.error('Webhook delivery error:', error);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<button onClick={handleImport}>
|
|
165
|
+
Import CSV via Webhook
|
|
166
|
+
</button>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Combined Local Callback and Webhook
|
|
172
|
+
|
|
173
|
+
You can use both `onData` callback and webhook delivery simultaneously:
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
import { useExpressCSV, x, type Infer } from '@expresscsv/react';
|
|
177
|
+
|
|
178
|
+
const schema = x.row({
|
|
179
|
+
name: x.string().label('Full Name'),
|
|
180
|
+
email: x.string().email().label('Email Address'),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
function App() {
|
|
184
|
+
const { open } = useExpressCSV({
|
|
185
|
+
schema,
|
|
186
|
+
title: "Import Users",
|
|
187
|
+
importIdentifier: "user-import",
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const handleImport = () => {
|
|
191
|
+
open({
|
|
192
|
+
chunkSize: 100,
|
|
193
|
+
// Process locally
|
|
194
|
+
onData: async (chunk, next) => {
|
|
195
|
+
console.log(`Processing chunk ${chunk.currentChunkIndex + 1}/${chunk.totalChunks}`);
|
|
196
|
+
// Your local processing logic
|
|
197
|
+
await processChunkLocally(chunk.records);
|
|
198
|
+
next();
|
|
199
|
+
},
|
|
200
|
+
// Also deliver to webhook
|
|
201
|
+
webhook: {
|
|
202
|
+
url: 'https://api.example.com/webhooks/csv-import',
|
|
203
|
+
headers: {
|
|
204
|
+
'Authorization': 'Bearer your-api-token',
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
onComplete: () => {
|
|
208
|
+
console.log('All chunks processed and webhook delivery initiated');
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<button onClick={handleImport}>
|
|
215
|
+
Import CSV
|
|
216
|
+
</button>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Advanced Example with Error Handling
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { useExpressCSV, x, type Infer } from '@expresscsv/react';
|
|
225
|
+
import { useState } from 'react';
|
|
226
|
+
|
|
227
|
+
const candidateSchema = x.row({
|
|
228
|
+
firstName: x.string().label('First Name'),
|
|
229
|
+
lastName: x.string().label('Last Name'),
|
|
230
|
+
email: x.string().email().label('Email'),
|
|
231
|
+
experienceLevel: x.select([
|
|
232
|
+
{ label: 'Entry Level', value: 'entry' },
|
|
233
|
+
{ label: 'Mid Level', value: 'mid' },
|
|
234
|
+
{ label: 'Senior Level', value: 'senior' },
|
|
235
|
+
]).label('Experience Level'),
|
|
236
|
+
salary: x.number().currency('USD').min(30000).label('Expected Salary'),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
function CandidateImporter() {
|
|
240
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
241
|
+
const [error, setError] = useState<string | null>(null);
|
|
242
|
+
|
|
243
|
+
const { open } = useExpressCSV({
|
|
244
|
+
schema: candidateSchema,
|
|
245
|
+
title: "Import Candidates",
|
|
246
|
+
importIdentifier: "candidate-import",
|
|
247
|
+
developerMode: process.env.NODE_ENV === 'development',
|
|
248
|
+
debug: process.env.NODE_ENV === 'development',
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const handleImport = () => {
|
|
252
|
+
setIsLoading(true);
|
|
253
|
+
setError(null);
|
|
254
|
+
|
|
255
|
+
open({
|
|
256
|
+
onData: async (chunk, next) => {
|
|
257
|
+
try {
|
|
258
|
+
// Process the candidates chunk
|
|
259
|
+
await importCandidates(chunk.records);
|
|
260
|
+
next();
|
|
261
|
+
} catch (err) {
|
|
262
|
+
setError('Failed to import candidates. Please try again.');
|
|
263
|
+
throw err;
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
onComplete: () => {
|
|
267
|
+
setIsLoading(false);
|
|
268
|
+
alert('Successfully imported all candidates!');
|
|
269
|
+
},
|
|
270
|
+
onError: (error) => {
|
|
271
|
+
setIsLoading(false);
|
|
272
|
+
setError(`Import failed: ${error.message}`);
|
|
273
|
+
},
|
|
274
|
+
onCancel: () => {
|
|
275
|
+
setIsLoading(false);
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<div>
|
|
282
|
+
{error && <div className="error">{error}</div>}
|
|
283
|
+
|
|
284
|
+
<button
|
|
285
|
+
onClick={handleImport}
|
|
286
|
+
disabled={isLoading}
|
|
287
|
+
className="import-button"
|
|
288
|
+
>
|
|
289
|
+
{isLoading ? 'Processing...' : 'Import Candidates'}
|
|
290
|
+
</button>
|
|
291
|
+
</div>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## API Reference
|
|
297
|
+
|
|
298
|
+
### useExpressCSV Hook
|
|
299
|
+
|
|
300
|
+
A custom hook that provides access to the CSV importer functionality.
|
|
301
|
+
|
|
302
|
+
#### Parameters
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
interface UseExpressCSVOptions<TSchema> {
|
|
306
|
+
schema: TSchema;
|
|
307
|
+
title?: string;
|
|
308
|
+
importIdentifier: string;
|
|
309
|
+
publishableKey: string;
|
|
310
|
+
debug?: boolean;
|
|
311
|
+
developerMode?: boolean;
|
|
312
|
+
preload?: boolean; // Defaults to true
|
|
313
|
+
theme?: ECSVTheme;
|
|
314
|
+
colorMode?: ColorModeConfig;
|
|
315
|
+
customCSS?: string;
|
|
316
|
+
fonts?: Record<string, ECSVFontSource>;
|
|
317
|
+
stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### Returns
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
{
|
|
325
|
+
open: (options: OpenOptions<Infer<TSchema>>) => void;
|
|
326
|
+
widgetState: WidgetState;
|
|
327
|
+
isInitialising: boolean;
|
|
328
|
+
isOpen: boolean;
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### OpenOptions
|
|
333
|
+
|
|
334
|
+
Options passed to the `open` method:
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
interface OpenOptions<T> {
|
|
338
|
+
// At least one of onData or webhook must be provided
|
|
339
|
+
onData?: (chunk: RecordsChunk<T>, next: () => void) => void | Promise<void>;
|
|
340
|
+
webhook?: WebhookConfig;
|
|
341
|
+
|
|
342
|
+
// Optional configuration
|
|
343
|
+
chunkSize?: number; // Default: 1000
|
|
344
|
+
onComplete?: () => void;
|
|
345
|
+
onCancel?: () => void;
|
|
346
|
+
onError?: (error: Error) => void;
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### WebhookConfig
|
|
351
|
+
|
|
352
|
+
Configuration for webhook delivery:
|
|
353
|
+
|
|
354
|
+
```tsx
|
|
355
|
+
interface WebhookConfig {
|
|
356
|
+
url: string; // Required: Webhook endpoint URL
|
|
357
|
+
headers?: Record<string, string>; // Optional HTTP headers
|
|
358
|
+
method?: 'POST' | 'PUT' | 'PATCH'; // Default: 'POST'
|
|
359
|
+
timeout?: number; // Request timeout in milliseconds (default: 30000)
|
|
360
|
+
retries?: number; // Number of retry attempts (default: 0)
|
|
361
|
+
metadata?: Record<string, unknown>; // Optional metadata to include in webhook payload
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**Note:** The `chunkSize` option in `OpenOptions` controls the chunk size for both `onData` callbacks and webhook delivery. The backend will deliver webhooks in chunks of this size (or default 1000 if not specified).
|
|
366
|
+
|
|
367
|
+
### Schema Builder
|
|
368
|
+
|
|
369
|
+
The schema builder (`x`) provides a fluent API for defining field validation:
|
|
370
|
+
|
|
371
|
+
```tsx
|
|
372
|
+
const schema = x.row({
|
|
373
|
+
// String fields
|
|
374
|
+
name: x.string().label('Name').minLength(2).maxLength(50),
|
|
375
|
+
|
|
376
|
+
// Email validation
|
|
377
|
+
email: x.string().email().label('Email Address'),
|
|
378
|
+
|
|
379
|
+
// Number fields with constraints
|
|
380
|
+
age: x.number().label('Age').min(18).max(100),
|
|
381
|
+
|
|
382
|
+
// Currency fields
|
|
383
|
+
salary: x.number().currency('USD').min(30000),
|
|
384
|
+
|
|
385
|
+
// Select dropdowns
|
|
386
|
+
role: x.select([
|
|
387
|
+
{ label: 'Admin', value: 'admin' },
|
|
388
|
+
{ label: 'User', value: 'user' },
|
|
389
|
+
]).label('Role'),
|
|
390
|
+
|
|
391
|
+
// Date fields
|
|
392
|
+
startDate: x.date().label('Start Date'),
|
|
393
|
+
|
|
394
|
+
// Boolean fields
|
|
395
|
+
isActive: x.boolean().label('Active Status'),
|
|
396
|
+
});
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
## TypeScript Support
|
|
400
|
+
|
|
401
|
+
The component provides full TypeScript support with automatic type inference:
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
const schema = x.row({
|
|
405
|
+
name: x.string(),
|
|
406
|
+
age: x.number(),
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// results is automatically typed as { name: string; age: number }[]
|
|
410
|
+
const handleResults = (results: Infer<typeof schema>[]) => {
|
|
411
|
+
results.forEach(row => {
|
|
412
|
+
console.log(row.name); // string
|
|
413
|
+
console.log(row.age); // number
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## License
|
|
419
|
+
|
|
420
|
+
ISC
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TemplateDownloadConfig, DeepPartial, ExpressCSVLocaleInput } from '@expresscsv/core';
|
|
2
|
+
export { DeepPartial, ExpressCSVLocaleInput, TemplateDownloadConfig, TemplateDownloadFormat } from '@expresscsv/core';
|
|
3
|
+
import { ExType, ExBaseDef, ECSVTheme, ColorModeConfig, ECSVFontSource, OpenOptions, Infer, WidgetState } from '@expresscsv/sdk';
|
|
4
|
+
export { ColorModeConfig, ColorModePref, DeliveryOptions, ECSVFontSource, ECSVTheme, ExpressCSVStep, ImportCancelledError, Infer, OpenOptions, RecordsChunk, TailwindThemeVars, WebhookConfig, WidgetMode, WidgetState, x } from '@expresscsv/sdk';
|
|
5
|
+
|
|
6
|
+
interface UseExpressCSVOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
|
|
7
|
+
schema: TSchema;
|
|
8
|
+
title?: string;
|
|
9
|
+
importIdentifier: string;
|
|
10
|
+
publishableKey: string;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
developerMode?: boolean;
|
|
13
|
+
preload?: boolean;
|
|
14
|
+
theme?: ECSVTheme;
|
|
15
|
+
colorMode?: ColorModeConfig;
|
|
16
|
+
customCSS?: string;
|
|
17
|
+
fonts?: Record<string, ECSVFontSource>;
|
|
18
|
+
stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
|
|
19
|
+
previewSchemaBeforeUpload?: boolean;
|
|
20
|
+
templateDownload?: TemplateDownloadConfig;
|
|
21
|
+
saveSession?: boolean;
|
|
22
|
+
locale?: DeepPartial<ExpressCSVLocaleInput>;
|
|
23
|
+
}
|
|
24
|
+
declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, publishableKey, debug, developerMode, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, }: UseExpressCSVOptions<TSchema>): {
|
|
25
|
+
open: (options: OpenOptions<Infer<TSchema>>) => void;
|
|
26
|
+
widgetState: WidgetState;
|
|
27
|
+
isInitialising: boolean;
|
|
28
|
+
isOpen: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { type UseExpressCSVOptions, useExpressCSV };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TemplateDownloadConfig, DeepPartial, ExpressCSVLocaleInput } from '@expresscsv/core';
|
|
2
|
+
export { DeepPartial, ExpressCSVLocaleInput, TemplateDownloadConfig, TemplateDownloadFormat } from '@expresscsv/core';
|
|
3
|
+
import { ExType, ExBaseDef, ECSVTheme, ColorModeConfig, ECSVFontSource, OpenOptions, Infer, WidgetState } from '@expresscsv/sdk';
|
|
4
|
+
export { ColorModeConfig, ColorModePref, DeliveryOptions, ECSVFontSource, ECSVTheme, ExpressCSVStep, ImportCancelledError, Infer, OpenOptions, RecordsChunk, TailwindThemeVars, WebhookConfig, WidgetMode, WidgetState, x } from '@expresscsv/sdk';
|
|
5
|
+
|
|
6
|
+
interface UseExpressCSVOptions<TSchema extends ExType<unknown, ExBaseDef, unknown>> {
|
|
7
|
+
schema: TSchema;
|
|
8
|
+
title?: string;
|
|
9
|
+
importIdentifier: string;
|
|
10
|
+
publishableKey: string;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
developerMode?: boolean;
|
|
13
|
+
preload?: boolean;
|
|
14
|
+
theme?: ECSVTheme;
|
|
15
|
+
colorMode?: ColorModeConfig;
|
|
16
|
+
customCSS?: string;
|
|
17
|
+
fonts?: Record<string, ECSVFontSource>;
|
|
18
|
+
stepDisplay?: 'progressBar' | 'segmented' | 'numbered';
|
|
19
|
+
previewSchemaBeforeUpload?: boolean;
|
|
20
|
+
templateDownload?: TemplateDownloadConfig;
|
|
21
|
+
saveSession?: boolean;
|
|
22
|
+
locale?: DeepPartial<ExpressCSVLocaleInput>;
|
|
23
|
+
}
|
|
24
|
+
declare function useExpressCSV<TSchema extends ExType<unknown, ExBaseDef, unknown>>({ schema, title, importIdentifier, publishableKey, debug, developerMode, preload, theme, colorMode, customCSS, fonts, stepDisplay, previewSchemaBeforeUpload, templateDownload, saveSession, locale, }: UseExpressCSVOptions<TSchema>): {
|
|
25
|
+
open: (options: OpenOptions<Infer<TSchema>>) => void;
|
|
26
|
+
widgetState: WidgetState;
|
|
27
|
+
isInitialising: boolean;
|
|
28
|
+
isOpen: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { type UseExpressCSVOptions, useExpressCSV };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var react=require('react');var Y=class{constructor(a){this._def=a;}_addCheck(a,e,t){return {type:a,params:e,message:t}}},I=class extends Y{columnNameAliases(a){return this._def.columnNameAliases=a,this}description(a){return this._def.description=a,this}label(a){return this._def.label=a,this}example(a){return this._def.example=a,this}refine(a,e){let t=this._addCheck("refine",{validator:a,params:e});return this._def.checks||(this._def.checks=[]),this._def.checks.push(t),this}refineBatch(a,e){let t=this._addCheck("refineBatch",{validator:a,params:e});return this._def.checks||(this._def.checks=[]),this._def.checks.push(t),this}_findExistingCheck(a){if(!this._def.checks)return {check:void 0,index:-1,found:false};let e=this._def.checks.findIndex(i=>i.type===a),t=e!==-1;return {check:t?this._def.checks[e]:void 0,index:e,found:t}}_replaceOrAddCheck(a,e){this._def.checks||(this._def.checks=[]),e!==-1?this._def.checks[e]=a:this._def.checks.push(a);}},pe=[{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"]}],P={byName:new Map,byAlpha2:new Map,byAlpha3:new Map,byAlias:new Map};for(let a of pe){P.byName.set(a.name.toLowerCase(),a),P.byAlpha2.set(a.alpha2.toLowerCase(),a),P.byAlpha3.set(a.alpha3.toLowerCase(),a);for(let e of a.aliases)P.byAlias.set(e.toLowerCase(),a);}var K=65,ce=90,me={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 W(a){let e=a.toUpperCase();return (e.slice(4)+e.slice(0,4)).split("").map(t=>{let i=t.charCodeAt(0);return i>=K&&i<=ce?String(i-K+10):t}).join("")}function z(a){let e=a,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 de(a){let e=a.match(/(.{3})/g)?.map(t=>{let i=t.slice(0,1),n=Number.parseInt(t.slice(1),10);return `([${me[i]||""}]{${n}})`});return new RegExp(`^${e?.join("")||""}$`)}var r=class{constructor(a,e,t,i){this.countryCode=a,this.length=e,this.structure=t,this.example=i,this._cachedRegex=de(this.structure);}_regex(){return this._cachedRegex}isValid(a){return this.length===a.length&&this.countryCode===a.slice(0,2)&&this._regex().test(a.slice(4))&&z(W(a))===1}toBBAN(a,e=""){let t=this._regex().exec(a.slice(4));return t?t.slice(1).join(e):""}fromBBAN(a){if(!this.isValidBBAN(a))throw new Error("Invalid BBAN");let e=`0${98-z(W(`${this.countryCode}00${a}`))}`.slice(-2);return `${this.countryCode}${e}${a}`}isValidBBAN(a){return this.length-4===a.length&&this._regex().test(a)}},fe={};function o(a){fe[a.countryCode]=a;}o(new r("AD",24,"F04F04A12","AD1200012030200359100100"));o(new r("AE",23,"F03F16","AE070331234567890123456"));o(new r("AL",28,"F08A16","AL47212110090000000235698741"));o(new r("AT",20,"F05F11","AT611904300234573201"));o(new r("AZ",28,"U04A20","AZ21NABZ00000000137010001944"));o(new r("BA",20,"F03F03F08F02","BA391290079401028494"));o(new r("BE",16,"F03F07F02","BE68539007547034"));o(new r("BG",22,"U04F04F02A08","BG80BNBG96611020345678"));o(new r("BH",22,"U04A14","BH67BMAG00001299123456"));o(new r("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1"));o(new r("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00"));o(new r("CH",21,"F05A12","CH9300762011623852957"));o(new r("CR",22,"F04F14","CR72012300000171549015"));o(new r("CY",28,"F03F05A16","CY17002001280000001200527600"));o(new r("CZ",24,"F04F06F10","CZ6508000000192000145399"));o(new r("DE",22,"F08F10","DE89370400440532013000"));o(new r("DK",18,"F04F09F01","DK5000400440116243"));o(new r("DO",28,"U04F20","DO28BAGR00000001212453611324"));o(new r("EE",20,"F02F02F11F01","EE382200221020145685"));o(new r("EG",29,"F04F04F17","EG800002000156789012345180002"));o(new r("ES",24,"F04F04F01F01F10","ES9121000418450200051332"));o(new r("FI",18,"F06F07F01","FI2112345600000785"));o(new r("FO",18,"F04F09F01","FO6264600001631634"));o(new r("FR",27,"F05F05A11F02","FR1420041010050500013M02606"));o(new r("GB",22,"U04F06F08","GB29NWBK60161331926819"));o(new r("GE",22,"U02F16","GE29NB0000000101904917"));o(new r("GI",23,"U04A15","GI75NWBK000000007099453"));o(new r("GL",18,"F04F09F01","GL8964710001000206"));o(new r("GR",27,"F03F04A16","GR1601101250000000012300695"));o(new r("GT",28,"A04A20","GT82TRAJ01020000001210029690"));o(new r("HR",21,"F07F10","HR1210010051863000160"));o(new r("HU",28,"F03F04F01F15F01","HU42117730161111101800000000"));o(new r("IE",22,"U04F06F08","IE29AIBK93115212345678"));o(new r("IL",23,"F03F03F13","IL620108000000099999999"));o(new r("IS",26,"F04F02F06F10","IS140159260076545510730339"));o(new r("IT",27,"U01F05F05A12","IT60X0542811101000000123456"));o(new r("IQ",23,"U04F03A12","IQ98NBIQ850123456789012"));o(new r("JO",30,"A04F22","JO15AAAA1234567890123456789012"));o(new r("KW",30,"U04A22","KW81CBKU0000000000001234560101"));o(new r("KZ",20,"F03A13","KZ86125KZT5004100100"));o(new r("LB",28,"F04A20","LB62099900000001001901229114"));o(new r("LC",32,"U04F24","LC07HEMM000100010012001200013015"));o(new r("LI",21,"F05A12","LI21088100002324013AA"));o(new r("LT",20,"F05F11","LT121000011101001000"));o(new r("LU",20,"F03A13","LU280019400644750000"));o(new r("LV",21,"U04A13","LV80BANK0000435195001"));o(new r("MC",27,"F05F05A11F02","MC5811222000010123456789030"));o(new r("MD",24,"U02A18","MD24AG000225100013104168"));o(new r("ME",22,"F03F13F02","ME25505000012345678951"));o(new r("MK",19,"F03A10F02","MK07250120000058984"));o(new r("MR",27,"F05F05F11F02","MR1300020001010000123456753"));o(new r("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S"));o(new r("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR"));o(new r("NL",18,"U04F10","NL91ABNA0417164300"));o(new r("NO",15,"F04F06F01","NO9386011117947"));o(new r("PK",24,"U04A16","PK36SCBL0000001123456702"));o(new r("PL",28,"F08F16","PL61109010140000071219812874"));o(new r("PS",29,"U04A21","PS92PALS000000000400123456702"));o(new r("PT",25,"F04F04F11F02","PT50000201231234567890154"));o(new r("QA",29,"U04A21","QA30AAAA123456789012345678901"));o(new r("RO",24,"U04A16","RO49AAAA1B31007593840000"));o(new r("RS",22,"F03F13F02","RS35260005601001611379"));o(new r("SA",24,"F02A18","SA0380000000608010167519"));o(new r("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD"));o(new r("SE",24,"F03F16F01","SE4550000000058398257466"));o(new r("SI",19,"F05F08F02","SI56263300012039086"));o(new r("SK",24,"F04F06F10","SK3112000000198742637541"));o(new r("SM",27,"U01F05F05A12","SM86U0322509800000000270100"));o(new r("ST",25,"F08F11F02","ST68000100010051845310112"));o(new r("SV",28,"U04F20","SV62CENR00000000000000700025"));o(new r("TL",23,"F03F14F02","TL380080012345678910157"));o(new r("TN",24,"F02F03F13F02","TN5910006035183598478831"));o(new r("TR",26,"F05F01A16","TR330006100519786457841326"));o(new r("UA",29,"F25","UA511234567890123456789012345"));o(new r("VA",22,"F18","VA59001123000012345678"));o(new r("VG",24,"U04F16","VG96VPVG0000012345678901"));o(new r("XK",20,"F04F10F02","XK051212012345678906"));o(new r("AO",25,"F21","AO69123456789012345678901"));o(new r("BF",27,"F23","BF2312345678901234567890123"));o(new r("BI",16,"F12","BI41123456789012"));o(new r("BJ",28,"F24","BJ39123456789012345678901234"));o(new r("CI",28,"U02F22","CI70CI1234567890123456789012"));o(new r("CM",27,"F23","CM9012345678901234567890123"));o(new r("CV",25,"F21","CV30123456789012345678901"));o(new r("DZ",24,"F20","DZ8612345678901234567890"));o(new r("IR",26,"F22","IR861234568790123456789012"));o(new r("MG",27,"F23","MG1812345678901234567890123"));o(new r("ML",28,"U01F23","ML15A12345678901234567890123"));o(new r("MZ",25,"F21","MZ25123456789012345678901"));o(new r("SN",28,"U01F23","SN52A12345678901234567890123"));o(new r("GF",27,"F05F05A11F02","GF121234512345123456789AB13"));o(new r("GP",27,"F05F05A11F02","GP791234512345123456789AB13"));o(new r("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13"));o(new r("RE",27,"F05F05A11F02","RE131234512345123456789AB13"));o(new r("PF",27,"F05F05A11F02","PF281234512345123456789AB13"));o(new r("YT",27,"F05F05A11F02","YT021234512345123456789AB13"));o(new r("NC",27,"F05F05A11F02","NC551234512345123456789AB13"));o(new r("BL",27,"F05F05A11F02","BL391234512345123456789AB13"));o(new r("MF",27,"F05F05A11F02","MF551234512345123456789AB13"));o(new r("PM",27,"F05F05A11F02","PM071234512345123456789AB13"));o(new r("WF",27,"F05F05A11F02","WF621234512345123456789AB13"));var N=class J extends I{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 J({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}},ge=class extends N{},we=class extends N{output(a){return this._def.innerType.output(a),this._def.outputFormat=a,this}},Ee=class extends N{output(a){return this._def.innerType.output(a),this}},be=class extends N{min(a,e){return this._def.innerType.min(a,e),this}max(a,e){return this._def.innerType.max(a,e),this}integer(a){return this._def.innerType.integer(a),this}multipleOf(a,e){return this._def.innerType.multipleOf(a,e),this}percentage(){return this._def.innerType.percentage(),this}currency(a){return this._def.innerType.currency(a),this}},ye=class extends N{caseSensitive(a=true){return this._def.innerType.caseSensitive(a),this}},Ce=class extends N{caseSensitive(a=true){return this._def.innerType.caseSensitive(a),this}min(a,e){return this._def.innerType.min(a,e),this}max(a,e){return this._def.innerType.max(a,e),this}},Se=class extends N{uuid(a){return this._def.innerType.uuid(a),this}ip(a){return this._def.innerType.ip(a),this}url(a){return this._def.innerType.url(a),this}email(a){return this._def.innerType.email(a),this}phone(a){return this._def.innerType.phone(a),this}country(a){return this._def.innerType.country(a),this}max(a,e){return this._def.innerType.max(a,e),this}min(a,e){return this._def.innerType.min(a,e),this}length(a,e){return this._def.innerType.length(a,e),this}includes(a,e){return this._def.innerType.includes(a,e),this}startsWith(a,e){return this._def.innerType.startsWith(a,e),this}endsWith(a,e){return this._def.innerType.endsWith(a,e),this}regex(a,e){return this._def.innerType.regex(a,e),this}alphabetical(a){return this._def.innerType.alphabetical(a),this}alphanumerical(a){return this._def.innerType.alphanumerical(a),this}numerical(a){return this._def.innerType.numerical(a),this}iban(a){return this._def.innerType.iban(a),this}bic(a){return this._def.innerType.bic(a),this}gtin(a){return this._def.innerType.gtin(a),this}currencyCode(a){return this._def.innerType.currencyCode(a),this}},xe=class extends N{precision(a,e){return this._def.innerType.precision(a,e),this}},Ae=class Q extends I{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 Q({typeName:"ExString",checks:[],message:e?.message})}optional(){return new Se({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",i=e?.message;if(this._def.checks.findIndex(s=>s.type==="uuid"&&s.params?.version===t)!==-1)return this;let n=this._addCheck("uuid",{version:t},i);return this._def.checks.push(n),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",i=e?.message;if(this._def.checks.findIndex(s=>s.type==="ipAddress"&&s.params?.version===t)!==-1)return this;let n=this._addCheck("ipAddress",{version:t},i);return this._def.checks.push(n),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(n=>n.type!=="url"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("url",t,e?.message);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("email",{},t);return this._def.checks.push(i),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(n=>n.type!=="phone"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("phone",t,e?.message);return this._def.checks.push(i),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(n=>n.type==="country"&&n.params?.output===t.output)!==-1)return this;let i=this._addCheck("country",t,e?.message);return this._def.checks.push(i),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 i=this._findExistingCheck("max");if(i.found&&i.check?.params){let h=i.check.params.value;if(typeof h=="number"&&e>=h)return this}let n=this._findExistingCheck("min");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&n.check.params.value>e)throw new Error("ExString.max: max cannot be less than min");let s=t?.message,l=this._addCheck("max",{value:e},s);return this._replaceOrAddCheck(l,i.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 i=this._findExistingCheck("min");if(i.found&&i.check?.params){let h=i.check.params.value;if(typeof h=="number"&&e<=h)return this}let n=this._findExistingCheck("max");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&e>n.check.params.value)throw new Error("ExString.min: min cannot be greater than max");let s=t?.message,l=this._addCheck("min",{value:e},s);return this._replaceOrAddCheck(l,i.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 i=this._findExistingCheck("length"),n=t?.message,s=this._addCheck("length",{value:e},n);return this._replaceOrAddCheck(s,i.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(s=>s.type==="includes"&&s.params?.value===e)!==-1)return this;let i=t?.message,n=this._addCheck("includes",{value:e},i);return this._def.checks.push(n),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(s=>s.type==="startsWith"&&s.params?.value===e)!==-1)return this;let i=t?.message,n=this._addCheck("startsWith",{value:e},i);return this._def.checks.push(n),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(s=>s.type==="endsWith"&&s.params?.value===e)!==-1)return this;let i=t?.message,n=this._addCheck("endsWith",{value:e},i);return this._def.checks.push(n),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(s=>{if(s.type!=="regex"||!s.params?.pattern)return false;let l=s.params.pattern;return l.source===e.source&&l.flags===e.flags})!==-1)return this;let i=t?.message,n=this._addCheck("regex",{pattern:e},i);return this._def.checks.push(n),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 t=e?.message,i=this._addCheck("alphabetical",{},t);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("alphanumerical",{},t);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("numerical",{},t);return this._def.checks.push(i),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(n=>n.type!=="iban"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("iban",t,e?.message);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("bic",{},t);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("gtin",{},t);return this._def.checks.push(i),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(n=>n.type!=="currencyCode"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("currencyCode",t,e?.message);return this._def.checks.push(i),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 ve(a){if(a){if(a==="defaultValue")return "default-value";if(a==="when")return "optional-when";if(a==="key")return "unique-index";if(a==="refine")return "refine"}throw new Error(`Invalid key: ${a}`)}function V(a,e,t){if(!a||typeof a!="object")return a;if(a instanceof RegExp)return {__type:"RegExp",source:a.source,flags:a.flags};if(typeof a=="function"){let n=`func_${Math.random().toString(36).substring(2,15)}`,s=ve(t),l;switch(s){case "default-value":l=a;break;case "refine":l=a;break;case "optional-when":l=a;break;case "unique-index":l=a;break;default:throw new Error(`Invalid function type: ${s}`)}return e.set(n,{function:l,functionType:s,id:n,functionSource:"local"}),{__type:"Function",id:n,functionType:s}}if(Array.isArray(a))return a.map(n=>V(n,e));let i={};for(let[n,s]of Object.entries(a))i[n]=V(s,e,n);return i}function j(a){let e={},t=a._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 H(a,e,t,i,n){if(typeof a.validator=="function"){let s=`func_${Math.random().toString(36).substring(2,15)}`,l=n==="refineBatch"?"refine":n;t.set(s,{id:s,functionType:l,function:a.validator}),i?e.set(s,{functionType:l,id:s,functionSource:"remote"}):e.set(s,{function:a.validator,functionType:l,id:s,functionSource:"local"}),a.validator={__type:"Function",id:s,functionType:n};}}function q(a,e,t,i=false){return a.map(n=>{if(n.type==="refine"&&n.params){let s={...n.params};if(H(s,e,t,i,"refine"),typeof s.params=="function"){let h=`func_${Math.random().toString(36).substring(2,15)}`;t.set(h,{id:h,functionType:"refine",function:s.params}),i?e.set(h,{functionType:"refine",id:h,functionSource:"remote"}):e.set(h,{function:s.params,functionType:"refine",id:h,functionSource:"local"}),s.params={__type:"Function",id:h,functionType:"refine"};}let l=n.message;return !l&&s.params&&typeof s.params=="object"&&"message"in s.params&&(l=s.params.message),{...n,params:s,message:l}}if(n.type==="refineBatch"&&n.params){let s={...n.params};H(s,e,t,i,"refineBatch");let l=n.message;return !l&&s.params&&typeof s.params=="object"&&"message"in s.params&&(l=s.params.message),{...n,params:s,message:l}}return {...n,params:n.params}})}function $(a,e){let t={},i=a._def,n="message"in i&&typeof i.message=="string"?i.message:void 0;if(n&&(t.message=n),e==="ExNumber"&&("isPercentage"in i&&i.isPercentage===true&&(t.isPercentage=true),"currencyCode"in i&&typeof i.currencyCode=="string"&&(t.currencyCode=i.currencyCode)),e==="ExBoolean"&&"control"in i&&i.control!==void 0&&(t.control=i.control),(e==="ExSelect"||e==="ExMultiselect")&&("options"in i&&Array.isArray(i.options)&&(t.options=i.options),"config"in i&&i.config&&typeof i.config=="object")){let s=i.config;t.selectConfig={enforceCaseSensitiveMatch:!!s.enforceCaseSensitiveMatch,allowCustom:!!s.allowCustom};}if((e==="ExDate"||e==="ExDatetime"||e==="ExTime")&&"outputFormat"in i&&typeof i.outputFormat=="string"&&(t.outputFormat=i.outputFormat),e==="ExTime"&&"precision"in i&&(typeof i.precision=="number"||i.precision===null)&&(t.precision=i.precision),e==="ExDatetime"&&"checks"in i&&Array.isArray(i.checks)){let s=i.checks.find(l=>l.type==="datetime");s?.params&&s.params.offset===true&&(t.allowOffset=true);}return t}function Z(a,e=false){let t=new Map,i=new Map,n={typeName:"ExRow",shape:Object.entries(a._def.shape).reduce((l,[h,c])=>{let m=c._def.typeName,d={typeName:m,...j(c),...$(c,m)};if(c._def.checks&&Array.isArray(c._def.checks)&&(d.checks=q(c._def.checks,t,i,e)),m==="ExOptional"&&"innerType"in c._def){let p=c._def.innerType,E=p._def.typeName,y=j(c),x=j(p),A=$(p,E),k={};for(let C of Object.keys(x))C!=="defaultValue"&&(k[C]=x[C]);let T={...k,...y};if(p._def.checks&&Array.isArray(p._def.checks)&&(A.checks=q(p._def.checks,t,i,e)),d.innerType={typeName:E,...T,...A},!("defaultValue"in d)&&p._def&&"defaultValue"in p._def&&p._def.defaultValue!==void 0)if(typeof p._def.defaultValue=="function"){let C=`func_${Math.random().toString(36).substring(2,15)}`,R="default-value";i.set(C,{id:C,functionType:R,function:p._def.defaultValue}),e?t.set(C,{functionType:R,id:C,functionSource:"remote"}):t.set(C,{function:p._def.defaultValue,functionType:R,id:C,functionSource:"local"}),d.defaultValue={__type:"Function",id:C,functionType:R};}else d.defaultValue=p._def.defaultValue;}return l[h]=d,l},{})};if(a._def.optionalColumnConfig){n.optionalColumnConfig={columns:a._def.optionalColumnConfig.columns};let l=a._def.optionalColumnConfig.when,h=a._def.optionalColumnConfig.whenMap||{},c={},m;if(l){let d=`func_${Math.random().toString(36).substring(2,15)}`,p="optional-when";i.set(d,{id:d,functionType:p,function:l}),e?t.set(d,{functionType:p,id:d,functionSource:"remote"}):t.set(d,{function:l,functionType:p,id:d,functionSource:"local"}),m=d,n.optionalColumnConfig.when={__type:"Function",id:d,functionType:p};}if(Object.keys(h).length>0){for(let d of a._def.optionalColumnConfig.columns){let p=d.toString();if(h[p])if(l&&h[p]===l&&m)c[p]={__type:"Function",id:m,functionType:"optional-when"};else {let E=`func_${Math.random().toString(36).substring(2,15)}`;i.set(E,{id:E,functionType:"optional-when",function:h[p]}),e?t.set(E,{functionType:"optional-when",id:E,functionSource:"remote"}):t.set(E,{function:h[p],functionType:"optional-when",id:E,functionSource:"local"}),c[p]={__type:"Function",id:E,functionType:"optional-when"};}else c[p]=null;}n.optionalColumnConfig.whenMap=c;}else if(l){let d={};for(let p of a._def.optionalColumnConfig.columns){let E=p.toString();m?d[E]={__type:"Function",id:m,functionType:"optional-when"}:d[E]=null;}n.optionalColumnConfig.whenMap=d;}}a._def.uniqueColumnConfig&&(n.uniqueColumnConfig={uniqueConstraints:a._def.uniqueColumnConfig.uniqueConstraints.map(l=>{let h={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)}`,m="unique-index";i.set(c,{id:c,functionType:m,function:l.key}),e?t.set(c,{functionType:m,id:c,functionSource:"remote"}):t.set(c,{function:l.key,functionType:m,id:c,functionSource:"local"}),h.hasKeyFn=true,h.keyFnId=c,h.key={__type:"Function",id:c,functionType:m};}return h})}),a._def.meta&&(n.meta=a._def.meta);let s=V(n,t);return {json:JSON.stringify(s),functionMap:t,localFunctionMap:i}}var Fe=class extends I{min(a,e){if(typeof a!="number"||Number.isNaN(a))throw new Error("ExNumber.min: value must be a number");if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.min: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.min: options.message must be a string");let t=this._findExistingCheck("min");if(t.found&&t.check?.params){let l=t.check.params.value;if(typeof l=="number"&&a<=l)return this}let i=this._findExistingCheck("max");if(i.found&&i.check?.params&&typeof i.check.params.value=="number"&&a>i.check.params.value)throw new Error("ExNumber.min: min cannot be greater than max");let n=e?.message,s=this._addCheck("min",{value:a},n);return this._replaceOrAddCheck(s,t.index),this}max(a,e){if(typeof a!="number"||Number.isNaN(a))throw new Error("ExNumber.max: value must be a number");if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.max: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.max: options.message must be a string");let t=this._findExistingCheck("max");if(t.found&&t.check?.params){let l=t.check.params.value;if(typeof l=="number"&&a>=l)return this}let i=this._findExistingCheck("min");if(i.found&&i.check?.params&&typeof i.check.params.value=="number"&&i.check.params.value>a)throw new Error("ExNumber.max: max cannot be less than min");let n=e?.message,s=this._addCheck("max",{value:a},n);return this._replaceOrAddCheck(s,t.index),this}integer(a){if(a!==void 0&&typeof a!="object")throw new Error("ExNumber.integer: options must be an object");if(a?.message!==void 0&&typeof a.message!="string")throw new Error("ExNumber.integer: options.message must be a string");let e=this._findExistingCheck("integer"),t=a?.message,i=this._addCheck("integer",{},t);return this._replaceOrAddCheck(i,e.index),this}multipleOf(a,e){if(typeof a!="number"||Number.isNaN(a))throw new Error("ExNumber.multipleOf: value must be a number");if(a===0)throw new Error("ExNumber.multipleOf: value cannot be zero");if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.multipleOf: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.multipleOf: options.message must be a string");let t=this._findExistingCheck("multipleOf");if(t.found&&t.check?.params){let s=t.check.params.value;if(typeof s=="number"&&a===s)return this}let i=e?.message,n=this._addCheck("multipleOf",{value:a},i);return this._def.checks.push(n),this}},Re=class X extends Fe{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 X({typeName:"ExNumber",checks:[],message:e?.message})}optional(){return new be({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}},Ie=class ee extends I{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 ee({typeName:"ExBoolean",control:e?.control,message:e?.message,checks:[]})}optional(){return new ge({typeName:"ExOptional",innerType:this})}},ke=class ae extends I{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 ae({typeName:"ExDate"});return e?.message&&(t._def.message=e.message),t}optional(){return new we({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}},Me=class te extends I{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 te({typeName:"ExTime",checks:[],message:e?.message})}optional(){return new xe({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}},Ne=class ie extends I{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 ie({typeName:"ExDatetime",checks:[],message:e?.message});if(e?.message){let i=t._getDatetimeCheck();i&&(i.message=e.message);}return t}optional(){return new Ee({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,i=this._getDatetimeCheck();return i?.params&&(i.params.offset=true,t&&(i.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}},Te=class ne extends I{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 i=0;i<e.length;i++){let n=e[i];if(!n||typeof n!="object")throw new Error(`ExSelect.create: option at index ${i} must be an object`);if(!("label"in n)||typeof n.label!="string")throw new Error(`ExSelect.create: option at index ${i} must have a string label`);if(!("value"in n))throw new Error(`ExSelect.create: option at index ${i} must have a value`);if(typeof n.value!="string"&&typeof n.value!="number")throw new Error(`ExSelect.create: option at index ${i} 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 ne({typeName:"ExSelect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:!!t.allowCustom},checks:[],message:t.message})}optional(){return new ye({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}},_e=class se extends I{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 i=0;i<e.length;i++){let n=e[i];if(!n||typeof n!="object")throw new Error(`ExMultiselect.create: option at index ${i} must be an object`);if(!("label"in n)||typeof n.label!="string")throw new Error(`ExMultiselect.create: option at index ${i} must have a string label`);if(!("value"in n))throw new Error(`ExMultiselect.create: option at index ${i} must have a value`);if(typeof n.value!="string"&&typeof n.value!="number")throw new Error(`ExMultiselect.create: option at index ${i} 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 se({typeName:"ExMultiselect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:false},checks:[],message:t.message})}optional(){return new Ce({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 i=this._findExistingCheck("min");if(i.found&&i.check?.params){let l=i.check.params.value;if(typeof l=="number"&&e<=l)return this}let n=this._findExistingCheck("max");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&e>n.check.params.value)throw new Error("ExMultiselect.min: min cannot be greater than max");let s=this._addCheck("min",{value:e},t);return this._replaceOrAddCheck(s,i.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 i=this._findExistingCheck("max");if(i.found&&i.check?.params){let l=i.check.params.value;if(typeof l=="number"&&e>=l)return this}let n=this._findExistingCheck("min");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&n.check.params.value>e)throw new Error("ExMultiselect.max: max cannot be less than min");let s=this._addCheck("max",{value:e},t);return this._replaceOrAddCheck(s,i.index),this}};function Be(){return `uc_${Math.random().toString(36).substring(2,15)}${Math.random().toString(36).substring(2,15)}`}var De=class re extends Y{static create(e){if(!e||typeof e!="object")throw new Error("ExRow.create: shape must be a non-null object");for(let[t,i]of Object.entries(e)){if(!i||typeof i!="object")throw new Error(`ExRow.create: field "${t}" must be a valid field type`);if(!("_def"in i)||!i._def||typeof i._def!="object")throw new Error(`ExRow.create: field "${t}" is not a valid ExpressCSV field`);if(!("typeName"in i._def)||typeof i._def.typeName!="string")throw new Error(`ExRow.create: field "${t}" is missing a typeName`)}return new re({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 i=e,n=t?.when;if(!this._def.optionalColumnConfig)return this._def.optionalColumnConfig={columns:i,when:n,whenMap:n?Object.fromEntries(i.map(l=>[l,n])):void 0},this;let s=[...this._def.optionalColumnConfig.columns];for(let l of i)s.includes(l)||s.push(l);if(this._def.optionalColumnConfig.columns=s,n){this._def.optionalColumnConfig.whenMap||(this._def.optionalColumnConfig.whenMap={});for(let l of i)this._def.optionalColumnConfig.whenMap[l]=n;}return this}unique(e,t){if(e===void 0)throw new Error("ExRow.unique: columns must be provided");let i=Array.isArray(e)?e:[e];for(let m of i)if(!(m in this._def.shape))throw new Error(`ExRow.unique: column "${String(m)}" 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 n=t?.key;this._def.uniqueColumnConfig||(this._def.uniqueColumnConfig={uniqueConstraints:[]});let s=n?m=>{let d=Object.fromEntries(i.map(p=>[p,m[p]]));return n(d)}:void 0,l=(m,d)=>{if(m.length!==d.length)return false;let p=[...m].sort(),E=[...d].sort();return p.every((y,x)=>y===E[x])},h=this._def.uniqueColumnConfig.uniqueConstraints.findIndex(m=>l(m.columns,i)),c={id:Be(),columns:i,key:s};return h!==-1?this._def.uniqueColumnConfig.uniqueConstraints[h]=c:this._def.uniqueColumnConfig.uniqueConstraints.push(c),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}},Oe={string:Ae.create,number:Re.create,boolean:Ie.create,date:ke.create,time:Me.create,datetime:Ne.create,row:De.create,select:Te.create,multiselect:_e.create,infer:a=>{}},Pe=class{constructor(){this.items=[],this.processing=false;}enqueue(a){this.items.push(a);}dequeueUpTo(a){if(this.processing||this.items.length===0)return [];this.processing=true;let e=this.items.splice(0,a);return this.processing=false,e}size(){return this.items.length}isEmpty(){return this.items.length===0}dispose(){this.items=[];}};async function Le(a,e){return Promise.all(a.map(t=>e(t)))}var g=(a=>(a.UNINITIALIZED="uninitialized",a.INITIALIZING="initializing",a.READY="ready",a.OPENING="opening",a.OPEN="open",a.CLOSING="closing",a.RESETTING="resetting",a.ERROR="error",a.DESTROYED="destroyed",a))(g||{}),v=(a=>(a.NORMAL="normal",a.PRELOAD="preload",a))(v||{}),L={maxSize:200,maxDelay:50},Ue={maxRetries:3,retryDelay:500,acknowledgmentTimeout:2e3};function _(a="msg"){return `${a}_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Ge(a,e,t={}){let i=t.timeout||5e3,n={...Ue,...t.messagingConfig},s=new Map,l=[],h=null,c=new Pe,m=null,d=[],p=null,E=true,y=new Map,x=f=>{let u={kind:"singleton",type:"ack",id:f,retryCount:0,originalSentAt:Date.now()};a.postMessage(u,e);},A=f=>{let u=y.get(f);u&&(u.timeout&&clearTimeout(u.timeout),y.delete(f));},k=f=>{f.id||(f.id=_());try{a.postMessage(f,e);let u=0,b=setTimeout(()=>{T(f.id);},n.acknowledgmentTimeout);y.set(f.id,{message:f,retryCount:u,timeout:b});}catch(u){console.error("Error posting message:",u),E=false;}},T=f=>{let u=y.get(f);if(!u)return;if(u.retryCount>=n.maxRetries){if(y.delete(f),u.message.kind==="batch"&&u.message.type==="batch-rpc")for(let w of u.message.calls){let S=s.get(w.requestId);S&&(S.reject(new Error(`RPC call failed after ${n.maxRetries} retries`)),s.delete(w.requestId));}return}u.retryCount++,u.message.retryCount=u.retryCount,u.message.originalSentAt=u.message.originalSentAt||Date.now();try{a.postMessage(u.message,e);}catch(w){console.error("Error retrying message:",w),E=false;}let b=n.retryDelay*2**u.retryCount;u.timeout=setTimeout(()=>{T(f);},b),y.set(f,u);},C=f=>{if(e!=="*"&&f.origin!==e)return;let u=f.data;if(!(!u||typeof u!="object")){if(u.kind==="singleton"&&u.type==="ack"&&u.id){A(u.id);return}if(u.id&&x(u.id),u.kind==="singleton")if(u.type==="response"&&u.id){let b=s.get(u.id);b&&(u.error?b.reject(new Error(u.error)):b.resolve(u.data),s.delete(u.id));}else for(let b of l)try{b(u);}catch(w){console.error("Error in message handler:",w);}else if(u.kind==="batch"&&u.type==="batch-rpc-response")for(let b of u.responses){let w=s.get(b.requestId);w&&(b.status==="error"?w.reject(new Error(b.error.message||"RPC call failed")):w.resolve(b.result),s.delete(b.requestId));}else u.kind==="batch"&&u.type==="batch-rpc"&&R(u);}},R=async f=>{if(!h){for(let w of f.calls)F({requestId:w.requestId,functionId:w.functionId,status:"error",error:{code:"METHOD_NOT_FOUND",message:"No RPC handler registered"}});B();return}let u=h,b=await Le(f.calls,async w=>{try{let S=await u({functionName:w.functionName,requestId:w.requestId,functionId:w.functionId,params:w.params});return {requestId:w.requestId,functionId:w.functionId,status:"success",result:S}}catch(S){return {requestId:w.requestId,functionId:w.functionId,status:"error",error:{code:"EXECUTION_ERROR",message:S instanceof Error?S.message:"Unknown error",details:S}}}});for(let w of b)d.push(w);d.length>0&&M();},F=f=>{d.push(f),d.length>=L.maxSize?M():B();},M=()=>{if(d.length===0)return;let f={kind:"batch",type:"batch-rpc-response",id:_("batch_resp"),responses:[...d],retryCount:0,originalSentAt:Date.now()};d=[],p&&(clearTimeout(p),p=null),k(f);},B=()=>{p||(p=setTimeout(()=>{M();},L.maxDelay));},D=()=>{if(c.isEmpty())return;let f=c.size(),u=c.dequeueUpTo(f);if(u.length===0)return;let b={kind:"batch",type:"batch-rpc",id:_("batch"),calls:[...u],retryCount:0,originalSentAt:Date.now()};m&&(clearTimeout(m),m=null),k(b);},U=()=>{m||(m=setTimeout(()=>{D(),m=null;},L.maxDelay));};return window.addEventListener("message",C),{callRPC:({functionName:f,functionId:u,params:b})=>new Promise((w,S)=>{let O=_("rpc"),he={requestId:O,functionName:f,functionId:u,params:b};s.set(O,{resolve:G=>{w(G);},reject:G=>{S(G);}}),setTimeout(()=>{s.has(O)&&(s.delete(O),S(new Error(`Call to ${f} timed out`)));},i),c.enqueue(he),c.size()>=L.maxSize?D():U();}),registerRPCHandler:f=>{h=f;},sendMessage:f=>{let u={...f,kind:"singleton",id:_(),retryCount:0,originalSentAt:Date.now()};k(u);},registerMessageHandler:f=>{l.push(f);},disconnect:()=>{window.removeEventListener("message",C);for(let[,f]of s)f.reject(new Error("Connection closed"));for(let[,f]of y)f.timeout&&clearTimeout(f.timeout);m&&clearTimeout(m),p&&clearTimeout(p),s.clear(),y.clear(),c.dispose(),d=[],E=false;},getConnectionStatus:()=>E}}function je(a,e={}){let t=a.contentWindow;if(!t)throw new Error("Cannot connect to iframe: contentWindow is null");let i=e.targetOrigin||new URL(a.src).origin||"*";return Ge(t,i,e)}var Ve=class oe extends Error{constructor(e="Import was cancelled by the user"){super(e),this.name="ImportCancelledError",Error.captureStackTrace&&Error.captureStackTrace(this,oe);}},le=class{constructor(a){this.options=a,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=g.UNINITIALIZED,this.canRestart=false,this.lastError=null,this.openOptions=null,this.cachedSchemaJson=null,this.initCompletePromise=null,this.resolveInitComplete=null,this.debug=a.debug||false,this.developerMode=a.developerMode||false,this.importIdentifier=a.importIdentifier,this.widgetMode=a.preload!==false?v.PRELOAD:v.NORMAL,this.log("Initializing CSVImporter with options:",a),a.preload!==false&&(this.setState(g.INITIALIZING,"Auto-preload initialization"),this.initCompletePromise=new Promise(e=>{this.resolveInitComplete=e;}),this.initializeIframe(true).catch(e=>{this.log("Auto-preload failed:",e),this.initCompletePromise=null,this.resolveInitComplete=null,this.handleError(e instanceof Error?e:new Error("Preload failed"));}));}setState(a,e){this.widgetState=a,this.log(`State change: \u2192 ${a}`,e),this.connection&&this.connection.sendMessage({type:"action:sync_state",data:{sdkState:a,mode:this.widgetMode}}),this.updateDerivedState();}updateDerivedState(){this.canRestart=this.widgetState===g.READY||this.widgetState===g.ERROR;}handleError(a){this.lastError=a,this.setState(g.ERROR,a.message),this.openOptions?.onError?.(a),this.openOptions=null;}async waitForEvent(a,e=5e3){return new Promise((t,i)=>{let n=setTimeout(()=>{i(new Error(`Timeout waiting for ${a}`));},e),s=l=>{l.type===a&&(clearTimeout(n),t(l.data));};this.connection?.registerMessageHandler(s);})}open(a){if(this.log("open() called",a),this.openOptions){this.log("open() called while already active, ignoring");return}if(this.sessionId=crypto.randomUUID(),this.connection&&this.widgetState===g.READY&&this.connection.sendMessage({type:"action:update_session_id",data:{sessionId:this.sessionId}}),this.openOptions=a,!this.cachedSchemaJson){let e=Z(this.options.schema,true);this.cachedSchemaJson=e.json;}this.openWidget().then(()=>{this.log("Widget opened successfully for open()"),this.createImportSession({chunkSize:a.chunkSize,webhook:a.webhook}).catch(e=>{if(this.log("Failed to create import session:",e),e.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 t=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?.(t);}else {let t=e instanceof Error?e:new Error("Failed to create import session");this.openOptions?.onError?.(t);}});}).catch(e=>{this.log("Failed to open widget in open():",e);let t=e instanceof Error?e:new Error("Failed to open widget");this.openOptions?.onError?.(t),this.openOptions=null;});}async createImportSession({chunkSize:a,webhook:e}){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 t=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/import-sessions`,i={schema:this.cachedSchemaJson,chunkSize:a,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};e&&(i.webhook={url:e.url,headers:e.headers,method:e.method,metadata:e.metadata});let n=await fetch(t,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,configuration:i})});if(!n.ok){let s,l="Unknown error";try{let c=await n.json();s=c.code,l=c.message||c.error||l;}catch{l=await n.text().catch(()=>"Unknown error");}let h=new Error(`Failed to create import session: ${n.status} ${n.statusText} - ${l}`);throw h.code=s,h}this.log("Import session created successfully",{sessionId:this.sessionId});}async deliverToWebhook(a,e,t,i){let n=a.length,s=Math.ceil(n/1e3);for(let l=0;l<s;l++){let h=l*1e3,c=Math.min(h+1e3,n),m={records:a.slice(h,c),totalChunks:s,currentChunkIndex:l,totalRecords:t.totalRecords};await this.sendChunkToBackend(m,e,i);}}async sendChunkToBackend(a,e,t){if(!this.sessionId)throw new Error("Session ID not initialized. Call open() first.");let i=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/webhooks/deliver`,n=3,s=3e4,l=null;for(let h=0;h<=n;h++){let c=new AbortController,m=setTimeout(()=>c.abort(),s);try{let d=await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,webhook:{url:e.url,headers:e.headers,method:e.method,metadata:e.metadata,chunkSize:t},chunk:{records:a.records,totalChunks:a.totalChunks,currentChunkIndex:a.currentChunkIndex,totalRecords:a.totalRecords}}),signal:c.signal});if(clearTimeout(m),!d.ok){let p=d.status;if(p>=400&&p<500&&p!==429){let E=await d.text().catch(()=>"Unknown error");throw new Error(`Backend API error: ${p} ${d.statusText} - ${E}`)}throw new Error(`Backend API error: ${p} ${d.statusText}`)}this.log(`Chunk ${a.currentChunkIndex+1}/${a.totalChunks} sent to backend successfully (attempt ${h+1})`);return}catch(d){clearTimeout(m),l=d instanceof Error?d:new Error(String(d)),this.log(`Failed to send chunk to backend (attempt ${h+1}/${n+1}):`,l),h<n&&await new Promise(p=>setTimeout(p,2**h*1e3));}}throw l||new Error("Failed to send chunk to backend")}async processResultsInChunks(a){if(!this.openOptions){this.log("No open options available, skipping chunk processing");return}let{chunkSize:e=1e3,onData:t,webhook:i,onComplete:n,onError:s}=this.openOptions,l=a.length,h=e<=0?l:e,c=Math.ceil(l/h);this.log(`Processing ${l} records in ${c} chunks of ${h}`);try{for(let m=0;m<c;m++){let d=m*h,p=Math.min(d+h,l),E={records:a.slice(d,p),totalChunks:c,currentChunkIndex:m,totalRecords:l};t&&await new Promise((y,x)=>{try{let A=t(E,y);A instanceof Promise&&A.catch(x);}catch(A){x(A);}});}if(i){let m={records:[],totalChunks:c,currentChunkIndex:c-1,totalRecords:l};await this.deliverToWebhook(a,i,m,h);}this.log("All chunks processed successfully"),n?.();}catch(m){this.log("Error during chunk processing:",m);let d=m instanceof Error?m:new Error(String(m));s?.(d);}finally{this.openOptions=null;}}async initializeIframe(a=false){this.log(`Initializing iframe (hidden: ${a})`),(this.iframe||this.container||this.connection)&&(this.log("Cleaning up existing resources before initialization"),this.destroy(false));try{this.container=document.createElement("div"),a?(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 ${a?"hidden":"visible"} container`),this.createAndAppendIframe(this.container),this.log("Created iframe"),await this.waitForIframeLoad(),await this.setupConnectionAndInit(),this.log(`Iframe initialization complete (hidden: ${a})`);}catch(e){throw this.log("Iframe initialization failed:",e),this.destroy(false),e}}log(...a){(this.debug||process.env.NODE_ENV==="development")&&console.log("[CSVImporter]",...a);}error(...a){console.error("[CSVImporter]",...a);}addBeforeUnloadListener(){if(this._beforeUnloadHandler){this.log("beforeunload listener already exists");return}this._beforeUnloadHandler=a=>(a.preventDefault(),"You have an import in progress. Are you sure you want to leave? Your progress will be lost."),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((a,e)=>{if(!this.iframe){this.log("No iframe available, rejecting promise"),e(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)"),a();return}}catch{this.log("Cannot check iframe load state (CORS), waiting for onload");}let t=false,i=()=>{this.iframe&&(this.iframe.onload=null,this.iframe.onerror=null);},n=()=>{t||(t=true,clearTimeout(l),i(),a());},s=h=>{t||(t=true,clearTimeout(l),i(),e(h));},l=setTimeout(()=>{this.log("Iframe load timeout reached"),s(new Error("Iframe load timeout"));},1e4);this.iframe.onload=()=>{this.log("Iframe loaded successfully"),n();},this.iframe.onerror=h=>{this.error("Iframe failed to load:",h),s(new Error("Failed to load iframe"));};})}async setupConnectionAndInit(){if(this.log("Creating connection to iframe"),this.connection=this.iframe?je(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 a=Z(this.options.schema,true);this.cachedSchemaJson=a.json,this.initCompletePromise||(this.initCompletePromise=new Promise(e=>{this.resolveInitComplete=e;})),this.connection.sendMessage({type:"action:init",data:{schemaJson:a.json,functionMapJson:JSON.stringify([...a.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:e,functionId:t,params:i})=>{let n=a.localFunctionMap.get(t);if(!n)throw new Error(`Unknown function: ${e}`);let s=n.function;return await s(i)}),this.connectionState=true,this.log("Connection established and initialized");}async openWidget(a){if(this.log("openWidget() called",{currentState:this.widgetState,options:a}),this.widgetState===g.OPEN){this.log("Widget is already open, ignoring openWidget() call");return}let e=this.widgetState;this.setState(g.OPENING,"User requested open");try{a?.reset&&await this.resetWidget(),this.widgetMode===v.PRELOAD&&e===g.READY?(this.log("Using preloaded iframe - making visible instantly"),this.makeContainerVisible(),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:a?.reset,sessionId:this.sessionId??void 0}})):this.widgetMode===v.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:a?.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:a?.reset,sessionId:this.sessionId??void 0}})),this.setState(g.OPEN,"Widget opened successfully"),this.openOptions?.onWidgetOpen?.(),this.addBeforeUnloadListener();}catch(t){throw this.log("Failed to open widget:",t),this.handleError(t instanceof Error?t:new Error("Failed to open widget")),t}}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 a=>{if(a.type==="event:results"){this.log("Processing results message");let e=a.data;this.openOptions?(await this.processResultsInChunks(e),this.connection&&this.connection.sendMessage({type:"event:results_processed"})):this.connection&&this.connection.sendMessage({type:"event:results_processed"});}else if(a.type==="event:init_complete")this.log("Widget initialized successfully"),this.resolveInitComplete&&(this.resolveInitComplete(),this.resolveInitComplete=null),this.setState(g.READY,"Widget initialization complete");else if(a.type==="event:widget_closed"){this.log("Processing widget closed message:",a.data);let e=a.data.reason;this.openOptions?.onWidgetClose?.(e),e==="cancel"&&this.openOptions&&(this.openOptions.onCancel?.(),this.openOptions=null),await this.handleWidgetClosed(e);}else if(a.type==="event:step_change"){this.log("Processing step change message:",a.data);let e=a.data.stepId,t=a.data.previousStepId;this.openOptions?.onStepChange?.(e,t);}else a.type==="event:state_change"?this.log("Widget state changed:",a.data):a.type==="event:widget_status"?this.log("Widget status update:",a.data):a.type==="event:reset_complete"?this.log("Widget reset complete:",a.data):a.type==="event:restart_complete"&&this.log("Widget restart complete:",a.data);});}createAndAppendIframe(a){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",a.appendChild(this.iframe),this.log("Iframe appended to container, URL:",this.widgetUrl);}destroy(a=true){if(this.log("destroy() called, resetReadyState:",a),this._destroyTimer!==null&&(this.log("Clearing existing destroy timer"),window.clearTimeout(this._destroyTimer),this._destroyTimer=null),this.widgetState===g.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(e){this.error("Error during destroy:",e);}}async close(a="user_close"){if(this.log("close() called",{currentState:this.widgetState,reason:a}),this.widgetState===g.CLOSING||this.widgetState===g.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}if(this.widgetState!==g.OPEN){this.log("Not open, ignoring close call");return}this.setState(g.CLOSING,`Close requested: ${a}`);try{this.connection&&(this.log("Sending close message to widget"),this.connection.sendMessage({type:"action:close_widget",data:{reason:a}}));}catch(e){this.error("Error during close preparation:",e);}this.removeBeforeUnloadListener(),this.widgetMode===v.PRELOAD?(this.hideContainer(),this.setState(g.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(g.DESTROYED,"Normal mode widget destroyed"));}async resetWidget(){this.log("resetWidget() called",{currentState:this.widgetState}),this.setState(g.RESETTING,"Reset requested");try{this.connection&&(this.connection.sendMessage({type:"action:reset_widget",data:{preserveConnection:this.widgetMode===v.PRELOAD}}),await this.waitForEvent("event:reset_complete")),this.lastError=null,this.widgetMode===v.PRELOAD?this.setState(g.READY,"Reset complete - preload mode"):this.setState(g.UNINITIALIZED,"Reset complete - normal mode");}catch(a){throw this.handleError(a instanceof Error?a:new Error("Reset failed")),a}}async restart(a){if(this.log("restart() called",{currentState:this.widgetState,newOptions:a}),!this.canRestart)throw new Error("Widget cannot be restarted in current state");try{await this.resetWidget(),a&&(Object.assign(this.options,a),this.widgetMode=this.options.preload!==!1?v.PRELOAD:v.NORMAL,this.connection&&(this.connection.sendMessage({type:"action:restart_widget",data:{newOptions:a}}),await this.waitForEvent("event:restart_complete"))),await this.openWidget();}catch(e){throw this.handleError(e instanceof Error?e:new Error("Restart failed")),e}}async handleWidgetClosed(a){if(this.log("handleWidgetClosed() called",{currentState:this.widgetState,reason:a}),this.widgetState===g.CLOSING||this.widgetState===g.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}this.setState(g.CLOSING,`Widget closed: ${a}`),this.removeBeforeUnloadListener(),this.widgetMode===v.PRELOAD?(this.hideContainer(),this.setState(g.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(g.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 a=this.connectionState&&this.connection?.getConnectionStatus();return this.log("getConnectionStatus() called, returning:",a),!!a}getState(){return this.widgetState}getMode(){return this.widgetMode}getIsReady(){let a=this.widgetState===g.READY||this.widgetState===g.OPEN;return this.log("getIsReady() called, returning:",a),a}getIsOpen(){let a=this.widgetState===g.OPEN;return this.log("getIsOpen() called, returning:",a),a}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 a="2.0.0";return this.log("getVersion() called, returning:",a),a}};function qe({schema:a,title:e,importIdentifier:t,publishableKey:i,debug:n,developerMode:s,preload:l,theme:h,colorMode:c,customCSS:m,fonts:d,stepDisplay:p,previewSchemaBeforeUpload:E=true,templateDownload:y,saveSession:x,locale:A}){let k=JSON.stringify(y),T=react.useMemo(()=>y,[k]),C=JSON.stringify(A),R=react.useMemo(()=>A,[C]),F=react.useRef(null),[M,B]=react.useState(g.UNINITIALIZED),D=M===g.INITIALIZING||M===g.OPENING,U=M===g.OPEN;return react.useEffect(()=>{let u=new le({schema:a,title:e,importIdentifier:t,publishableKey:i,debug:n,developerMode:s,preload:l,theme:h,colorMode:c,customCSS:m,fonts:d,stepDisplay:p,previewSchemaBeforeUpload:E,templateDownload:T,saveSession:x,locale:R});F.current=u;let w=setInterval(()=>{if(F.current){let S=F.current.getState();B(S);}},100);return ()=>{clearInterval(w),F.current&&(F.current.close(),F.current=null);}},[a,e,t,i,n,s,l,h,c,m,d,p,E,T,x,R]),{open:react.useCallback(u=>{if(!F.current)throw new Error("CSVImporter not initialized");F.current.open(u);},[]),widgetState:M,isInitialising:D,isOpen:U}}
|
|
2
|
+
exports.ImportCancelledError=Ve;exports.WidgetMode=v;exports.WidgetState=g;exports.useExpressCSV=qe;exports.x=Oe;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {useMemo,useRef,useState,useCallback,useEffect}from'react';var Y=class{constructor(a){this._def=a;}_addCheck(a,e,t){return {type:a,params:e,message:t}}},I=class extends Y{columnNameAliases(a){return this._def.columnNameAliases=a,this}description(a){return this._def.description=a,this}label(a){return this._def.label=a,this}example(a){return this._def.example=a,this}refine(a,e){let t=this._addCheck("refine",{validator:a,params:e});return this._def.checks||(this._def.checks=[]),this._def.checks.push(t),this}refineBatch(a,e){let t=this._addCheck("refineBatch",{validator:a,params:e});return this._def.checks||(this._def.checks=[]),this._def.checks.push(t),this}_findExistingCheck(a){if(!this._def.checks)return {check:void 0,index:-1,found:false};let e=this._def.checks.findIndex(i=>i.type===a),t=e!==-1;return {check:t?this._def.checks[e]:void 0,index:e,found:t}}_replaceOrAddCheck(a,e){this._def.checks||(this._def.checks=[]),e!==-1?this._def.checks[e]=a:this._def.checks.push(a);}},pe=[{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"]}],P={byName:new Map,byAlpha2:new Map,byAlpha3:new Map,byAlias:new Map};for(let a of pe){P.byName.set(a.name.toLowerCase(),a),P.byAlpha2.set(a.alpha2.toLowerCase(),a),P.byAlpha3.set(a.alpha3.toLowerCase(),a);for(let e of a.aliases)P.byAlias.set(e.toLowerCase(),a);}var K=65,ce=90,me={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 W(a){let e=a.toUpperCase();return (e.slice(4)+e.slice(0,4)).split("").map(t=>{let i=t.charCodeAt(0);return i>=K&&i<=ce?String(i-K+10):t}).join("")}function z(a){let e=a,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 de(a){let e=a.match(/(.{3})/g)?.map(t=>{let i=t.slice(0,1),n=Number.parseInt(t.slice(1),10);return `([${me[i]||""}]{${n}})`});return new RegExp(`^${e?.join("")||""}$`)}var r=class{constructor(a,e,t,i){this.countryCode=a,this.length=e,this.structure=t,this.example=i,this._cachedRegex=de(this.structure);}_regex(){return this._cachedRegex}isValid(a){return this.length===a.length&&this.countryCode===a.slice(0,2)&&this._regex().test(a.slice(4))&&z(W(a))===1}toBBAN(a,e=""){let t=this._regex().exec(a.slice(4));return t?t.slice(1).join(e):""}fromBBAN(a){if(!this.isValidBBAN(a))throw new Error("Invalid BBAN");let e=`0${98-z(W(`${this.countryCode}00${a}`))}`.slice(-2);return `${this.countryCode}${e}${a}`}isValidBBAN(a){return this.length-4===a.length&&this._regex().test(a)}},fe={};function o(a){fe[a.countryCode]=a;}o(new r("AD",24,"F04F04A12","AD1200012030200359100100"));o(new r("AE",23,"F03F16","AE070331234567890123456"));o(new r("AL",28,"F08A16","AL47212110090000000235698741"));o(new r("AT",20,"F05F11","AT611904300234573201"));o(new r("AZ",28,"U04A20","AZ21NABZ00000000137010001944"));o(new r("BA",20,"F03F03F08F02","BA391290079401028494"));o(new r("BE",16,"F03F07F02","BE68539007547034"));o(new r("BG",22,"U04F04F02A08","BG80BNBG96611020345678"));o(new r("BH",22,"U04A14","BH67BMAG00001299123456"));o(new r("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1"));o(new r("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00"));o(new r("CH",21,"F05A12","CH9300762011623852957"));o(new r("CR",22,"F04F14","CR72012300000171549015"));o(new r("CY",28,"F03F05A16","CY17002001280000001200527600"));o(new r("CZ",24,"F04F06F10","CZ6508000000192000145399"));o(new r("DE",22,"F08F10","DE89370400440532013000"));o(new r("DK",18,"F04F09F01","DK5000400440116243"));o(new r("DO",28,"U04F20","DO28BAGR00000001212453611324"));o(new r("EE",20,"F02F02F11F01","EE382200221020145685"));o(new r("EG",29,"F04F04F17","EG800002000156789012345180002"));o(new r("ES",24,"F04F04F01F01F10","ES9121000418450200051332"));o(new r("FI",18,"F06F07F01","FI2112345600000785"));o(new r("FO",18,"F04F09F01","FO6264600001631634"));o(new r("FR",27,"F05F05A11F02","FR1420041010050500013M02606"));o(new r("GB",22,"U04F06F08","GB29NWBK60161331926819"));o(new r("GE",22,"U02F16","GE29NB0000000101904917"));o(new r("GI",23,"U04A15","GI75NWBK000000007099453"));o(new r("GL",18,"F04F09F01","GL8964710001000206"));o(new r("GR",27,"F03F04A16","GR1601101250000000012300695"));o(new r("GT",28,"A04A20","GT82TRAJ01020000001210029690"));o(new r("HR",21,"F07F10","HR1210010051863000160"));o(new r("HU",28,"F03F04F01F15F01","HU42117730161111101800000000"));o(new r("IE",22,"U04F06F08","IE29AIBK93115212345678"));o(new r("IL",23,"F03F03F13","IL620108000000099999999"));o(new r("IS",26,"F04F02F06F10","IS140159260076545510730339"));o(new r("IT",27,"U01F05F05A12","IT60X0542811101000000123456"));o(new r("IQ",23,"U04F03A12","IQ98NBIQ850123456789012"));o(new r("JO",30,"A04F22","JO15AAAA1234567890123456789012"));o(new r("KW",30,"U04A22","KW81CBKU0000000000001234560101"));o(new r("KZ",20,"F03A13","KZ86125KZT5004100100"));o(new r("LB",28,"F04A20","LB62099900000001001901229114"));o(new r("LC",32,"U04F24","LC07HEMM000100010012001200013015"));o(new r("LI",21,"F05A12","LI21088100002324013AA"));o(new r("LT",20,"F05F11","LT121000011101001000"));o(new r("LU",20,"F03A13","LU280019400644750000"));o(new r("LV",21,"U04A13","LV80BANK0000435195001"));o(new r("MC",27,"F05F05A11F02","MC5811222000010123456789030"));o(new r("MD",24,"U02A18","MD24AG000225100013104168"));o(new r("ME",22,"F03F13F02","ME25505000012345678951"));o(new r("MK",19,"F03A10F02","MK07250120000058984"));o(new r("MR",27,"F05F05F11F02","MR1300020001010000123456753"));o(new r("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S"));o(new r("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR"));o(new r("NL",18,"U04F10","NL91ABNA0417164300"));o(new r("NO",15,"F04F06F01","NO9386011117947"));o(new r("PK",24,"U04A16","PK36SCBL0000001123456702"));o(new r("PL",28,"F08F16","PL61109010140000071219812874"));o(new r("PS",29,"U04A21","PS92PALS000000000400123456702"));o(new r("PT",25,"F04F04F11F02","PT50000201231234567890154"));o(new r("QA",29,"U04A21","QA30AAAA123456789012345678901"));o(new r("RO",24,"U04A16","RO49AAAA1B31007593840000"));o(new r("RS",22,"F03F13F02","RS35260005601001611379"));o(new r("SA",24,"F02A18","SA0380000000608010167519"));o(new r("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD"));o(new r("SE",24,"F03F16F01","SE4550000000058398257466"));o(new r("SI",19,"F05F08F02","SI56263300012039086"));o(new r("SK",24,"F04F06F10","SK3112000000198742637541"));o(new r("SM",27,"U01F05F05A12","SM86U0322509800000000270100"));o(new r("ST",25,"F08F11F02","ST68000100010051845310112"));o(new r("SV",28,"U04F20","SV62CENR00000000000000700025"));o(new r("TL",23,"F03F14F02","TL380080012345678910157"));o(new r("TN",24,"F02F03F13F02","TN5910006035183598478831"));o(new r("TR",26,"F05F01A16","TR330006100519786457841326"));o(new r("UA",29,"F25","UA511234567890123456789012345"));o(new r("VA",22,"F18","VA59001123000012345678"));o(new r("VG",24,"U04F16","VG96VPVG0000012345678901"));o(new r("XK",20,"F04F10F02","XK051212012345678906"));o(new r("AO",25,"F21","AO69123456789012345678901"));o(new r("BF",27,"F23","BF2312345678901234567890123"));o(new r("BI",16,"F12","BI41123456789012"));o(new r("BJ",28,"F24","BJ39123456789012345678901234"));o(new r("CI",28,"U02F22","CI70CI1234567890123456789012"));o(new r("CM",27,"F23","CM9012345678901234567890123"));o(new r("CV",25,"F21","CV30123456789012345678901"));o(new r("DZ",24,"F20","DZ8612345678901234567890"));o(new r("IR",26,"F22","IR861234568790123456789012"));o(new r("MG",27,"F23","MG1812345678901234567890123"));o(new r("ML",28,"U01F23","ML15A12345678901234567890123"));o(new r("MZ",25,"F21","MZ25123456789012345678901"));o(new r("SN",28,"U01F23","SN52A12345678901234567890123"));o(new r("GF",27,"F05F05A11F02","GF121234512345123456789AB13"));o(new r("GP",27,"F05F05A11F02","GP791234512345123456789AB13"));o(new r("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13"));o(new r("RE",27,"F05F05A11F02","RE131234512345123456789AB13"));o(new r("PF",27,"F05F05A11F02","PF281234512345123456789AB13"));o(new r("YT",27,"F05F05A11F02","YT021234512345123456789AB13"));o(new r("NC",27,"F05F05A11F02","NC551234512345123456789AB13"));o(new r("BL",27,"F05F05A11F02","BL391234512345123456789AB13"));o(new r("MF",27,"F05F05A11F02","MF551234512345123456789AB13"));o(new r("PM",27,"F05F05A11F02","PM071234512345123456789AB13"));o(new r("WF",27,"F05F05A11F02","WF621234512345123456789AB13"));var N=class J extends I{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 J({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}},ge=class extends N{},we=class extends N{output(a){return this._def.innerType.output(a),this._def.outputFormat=a,this}},Ee=class extends N{output(a){return this._def.innerType.output(a),this}},be=class extends N{min(a,e){return this._def.innerType.min(a,e),this}max(a,e){return this._def.innerType.max(a,e),this}integer(a){return this._def.innerType.integer(a),this}multipleOf(a,e){return this._def.innerType.multipleOf(a,e),this}percentage(){return this._def.innerType.percentage(),this}currency(a){return this._def.innerType.currency(a),this}},ye=class extends N{caseSensitive(a=true){return this._def.innerType.caseSensitive(a),this}},Ce=class extends N{caseSensitive(a=true){return this._def.innerType.caseSensitive(a),this}min(a,e){return this._def.innerType.min(a,e),this}max(a,e){return this._def.innerType.max(a,e),this}},Se=class extends N{uuid(a){return this._def.innerType.uuid(a),this}ip(a){return this._def.innerType.ip(a),this}url(a){return this._def.innerType.url(a),this}email(a){return this._def.innerType.email(a),this}phone(a){return this._def.innerType.phone(a),this}country(a){return this._def.innerType.country(a),this}max(a,e){return this._def.innerType.max(a,e),this}min(a,e){return this._def.innerType.min(a,e),this}length(a,e){return this._def.innerType.length(a,e),this}includes(a,e){return this._def.innerType.includes(a,e),this}startsWith(a,e){return this._def.innerType.startsWith(a,e),this}endsWith(a,e){return this._def.innerType.endsWith(a,e),this}regex(a,e){return this._def.innerType.regex(a,e),this}alphabetical(a){return this._def.innerType.alphabetical(a),this}alphanumerical(a){return this._def.innerType.alphanumerical(a),this}numerical(a){return this._def.innerType.numerical(a),this}iban(a){return this._def.innerType.iban(a),this}bic(a){return this._def.innerType.bic(a),this}gtin(a){return this._def.innerType.gtin(a),this}currencyCode(a){return this._def.innerType.currencyCode(a),this}},xe=class extends N{precision(a,e){return this._def.innerType.precision(a,e),this}},Ae=class Q extends I{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 Q({typeName:"ExString",checks:[],message:e?.message})}optional(){return new Se({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",i=e?.message;if(this._def.checks.findIndex(s=>s.type==="uuid"&&s.params?.version===t)!==-1)return this;let n=this._addCheck("uuid",{version:t},i);return this._def.checks.push(n),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",i=e?.message;if(this._def.checks.findIndex(s=>s.type==="ipAddress"&&s.params?.version===t)!==-1)return this;let n=this._addCheck("ipAddress",{version:t},i);return this._def.checks.push(n),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(n=>n.type!=="url"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("url",t,e?.message);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("email",{},t);return this._def.checks.push(i),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(n=>n.type!=="phone"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("phone",t,e?.message);return this._def.checks.push(i),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(n=>n.type==="country"&&n.params?.output===t.output)!==-1)return this;let i=this._addCheck("country",t,e?.message);return this._def.checks.push(i),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 i=this._findExistingCheck("max");if(i.found&&i.check?.params){let h=i.check.params.value;if(typeof h=="number"&&e>=h)return this}let n=this._findExistingCheck("min");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&n.check.params.value>e)throw new Error("ExString.max: max cannot be less than min");let s=t?.message,l=this._addCheck("max",{value:e},s);return this._replaceOrAddCheck(l,i.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 i=this._findExistingCheck("min");if(i.found&&i.check?.params){let h=i.check.params.value;if(typeof h=="number"&&e<=h)return this}let n=this._findExistingCheck("max");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&e>n.check.params.value)throw new Error("ExString.min: min cannot be greater than max");let s=t?.message,l=this._addCheck("min",{value:e},s);return this._replaceOrAddCheck(l,i.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 i=this._findExistingCheck("length"),n=t?.message,s=this._addCheck("length",{value:e},n);return this._replaceOrAddCheck(s,i.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(s=>s.type==="includes"&&s.params?.value===e)!==-1)return this;let i=t?.message,n=this._addCheck("includes",{value:e},i);return this._def.checks.push(n),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(s=>s.type==="startsWith"&&s.params?.value===e)!==-1)return this;let i=t?.message,n=this._addCheck("startsWith",{value:e},i);return this._def.checks.push(n),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(s=>s.type==="endsWith"&&s.params?.value===e)!==-1)return this;let i=t?.message,n=this._addCheck("endsWith",{value:e},i);return this._def.checks.push(n),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(s=>{if(s.type!=="regex"||!s.params?.pattern)return false;let l=s.params.pattern;return l.source===e.source&&l.flags===e.flags})!==-1)return this;let i=t?.message,n=this._addCheck("regex",{pattern:e},i);return this._def.checks.push(n),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 t=e?.message,i=this._addCheck("alphabetical",{},t);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("alphanumerical",{},t);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("numerical",{},t);return this._def.checks.push(i),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(n=>n.type!=="iban"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("iban",t,e?.message);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("bic",{},t);return this._def.checks.push(i),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 t=e?.message,i=this._addCheck("gtin",{},t);return this._def.checks.push(i),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(n=>n.type!=="currencyCode"||!n.params?false:JSON.stringify(n.params)===JSON.stringify(t))!==-1)return this;let i=this._addCheck("currencyCode",t,e?.message);return this._def.checks.push(i),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 ve(a){if(a){if(a==="defaultValue")return "default-value";if(a==="when")return "optional-when";if(a==="key")return "unique-index";if(a==="refine")return "refine"}throw new Error(`Invalid key: ${a}`)}function V(a,e,t){if(!a||typeof a!="object")return a;if(a instanceof RegExp)return {__type:"RegExp",source:a.source,flags:a.flags};if(typeof a=="function"){let n=`func_${Math.random().toString(36).substring(2,15)}`,s=ve(t),l;switch(s){case "default-value":l=a;break;case "refine":l=a;break;case "optional-when":l=a;break;case "unique-index":l=a;break;default:throw new Error(`Invalid function type: ${s}`)}return e.set(n,{function:l,functionType:s,id:n,functionSource:"local"}),{__type:"Function",id:n,functionType:s}}if(Array.isArray(a))return a.map(n=>V(n,e));let i={};for(let[n,s]of Object.entries(a))i[n]=V(s,e,n);return i}function j(a){let e={},t=a._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 H(a,e,t,i,n){if(typeof a.validator=="function"){let s=`func_${Math.random().toString(36).substring(2,15)}`,l=n==="refineBatch"?"refine":n;t.set(s,{id:s,functionType:l,function:a.validator}),i?e.set(s,{functionType:l,id:s,functionSource:"remote"}):e.set(s,{function:a.validator,functionType:l,id:s,functionSource:"local"}),a.validator={__type:"Function",id:s,functionType:n};}}function q(a,e,t,i=false){return a.map(n=>{if(n.type==="refine"&&n.params){let s={...n.params};if(H(s,e,t,i,"refine"),typeof s.params=="function"){let h=`func_${Math.random().toString(36).substring(2,15)}`;t.set(h,{id:h,functionType:"refine",function:s.params}),i?e.set(h,{functionType:"refine",id:h,functionSource:"remote"}):e.set(h,{function:s.params,functionType:"refine",id:h,functionSource:"local"}),s.params={__type:"Function",id:h,functionType:"refine"};}let l=n.message;return !l&&s.params&&typeof s.params=="object"&&"message"in s.params&&(l=s.params.message),{...n,params:s,message:l}}if(n.type==="refineBatch"&&n.params){let s={...n.params};H(s,e,t,i,"refineBatch");let l=n.message;return !l&&s.params&&typeof s.params=="object"&&"message"in s.params&&(l=s.params.message),{...n,params:s,message:l}}return {...n,params:n.params}})}function $(a,e){let t={},i=a._def,n="message"in i&&typeof i.message=="string"?i.message:void 0;if(n&&(t.message=n),e==="ExNumber"&&("isPercentage"in i&&i.isPercentage===true&&(t.isPercentage=true),"currencyCode"in i&&typeof i.currencyCode=="string"&&(t.currencyCode=i.currencyCode)),e==="ExBoolean"&&"control"in i&&i.control!==void 0&&(t.control=i.control),(e==="ExSelect"||e==="ExMultiselect")&&("options"in i&&Array.isArray(i.options)&&(t.options=i.options),"config"in i&&i.config&&typeof i.config=="object")){let s=i.config;t.selectConfig={enforceCaseSensitiveMatch:!!s.enforceCaseSensitiveMatch,allowCustom:!!s.allowCustom};}if((e==="ExDate"||e==="ExDatetime"||e==="ExTime")&&"outputFormat"in i&&typeof i.outputFormat=="string"&&(t.outputFormat=i.outputFormat),e==="ExTime"&&"precision"in i&&(typeof i.precision=="number"||i.precision===null)&&(t.precision=i.precision),e==="ExDatetime"&&"checks"in i&&Array.isArray(i.checks)){let s=i.checks.find(l=>l.type==="datetime");s?.params&&s.params.offset===true&&(t.allowOffset=true);}return t}function Z(a,e=false){let t=new Map,i=new Map,n={typeName:"ExRow",shape:Object.entries(a._def.shape).reduce((l,[h,c])=>{let m=c._def.typeName,d={typeName:m,...j(c),...$(c,m)};if(c._def.checks&&Array.isArray(c._def.checks)&&(d.checks=q(c._def.checks,t,i,e)),m==="ExOptional"&&"innerType"in c._def){let p=c._def.innerType,E=p._def.typeName,y=j(c),x=j(p),A=$(p,E),k={};for(let C of Object.keys(x))C!=="defaultValue"&&(k[C]=x[C]);let T={...k,...y};if(p._def.checks&&Array.isArray(p._def.checks)&&(A.checks=q(p._def.checks,t,i,e)),d.innerType={typeName:E,...T,...A},!("defaultValue"in d)&&p._def&&"defaultValue"in p._def&&p._def.defaultValue!==void 0)if(typeof p._def.defaultValue=="function"){let C=`func_${Math.random().toString(36).substring(2,15)}`,R="default-value";i.set(C,{id:C,functionType:R,function:p._def.defaultValue}),e?t.set(C,{functionType:R,id:C,functionSource:"remote"}):t.set(C,{function:p._def.defaultValue,functionType:R,id:C,functionSource:"local"}),d.defaultValue={__type:"Function",id:C,functionType:R};}else d.defaultValue=p._def.defaultValue;}return l[h]=d,l},{})};if(a._def.optionalColumnConfig){n.optionalColumnConfig={columns:a._def.optionalColumnConfig.columns};let l=a._def.optionalColumnConfig.when,h=a._def.optionalColumnConfig.whenMap||{},c={},m;if(l){let d=`func_${Math.random().toString(36).substring(2,15)}`,p="optional-when";i.set(d,{id:d,functionType:p,function:l}),e?t.set(d,{functionType:p,id:d,functionSource:"remote"}):t.set(d,{function:l,functionType:p,id:d,functionSource:"local"}),m=d,n.optionalColumnConfig.when={__type:"Function",id:d,functionType:p};}if(Object.keys(h).length>0){for(let d of a._def.optionalColumnConfig.columns){let p=d.toString();if(h[p])if(l&&h[p]===l&&m)c[p]={__type:"Function",id:m,functionType:"optional-when"};else {let E=`func_${Math.random().toString(36).substring(2,15)}`;i.set(E,{id:E,functionType:"optional-when",function:h[p]}),e?t.set(E,{functionType:"optional-when",id:E,functionSource:"remote"}):t.set(E,{function:h[p],functionType:"optional-when",id:E,functionSource:"local"}),c[p]={__type:"Function",id:E,functionType:"optional-when"};}else c[p]=null;}n.optionalColumnConfig.whenMap=c;}else if(l){let d={};for(let p of a._def.optionalColumnConfig.columns){let E=p.toString();m?d[E]={__type:"Function",id:m,functionType:"optional-when"}:d[E]=null;}n.optionalColumnConfig.whenMap=d;}}a._def.uniqueColumnConfig&&(n.uniqueColumnConfig={uniqueConstraints:a._def.uniqueColumnConfig.uniqueConstraints.map(l=>{let h={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)}`,m="unique-index";i.set(c,{id:c,functionType:m,function:l.key}),e?t.set(c,{functionType:m,id:c,functionSource:"remote"}):t.set(c,{function:l.key,functionType:m,id:c,functionSource:"local"}),h.hasKeyFn=true,h.keyFnId=c,h.key={__type:"Function",id:c,functionType:m};}return h})}),a._def.meta&&(n.meta=a._def.meta);let s=V(n,t);return {json:JSON.stringify(s),functionMap:t,localFunctionMap:i}}var Fe=class extends I{min(a,e){if(typeof a!="number"||Number.isNaN(a))throw new Error("ExNumber.min: value must be a number");if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.min: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.min: options.message must be a string");let t=this._findExistingCheck("min");if(t.found&&t.check?.params){let l=t.check.params.value;if(typeof l=="number"&&a<=l)return this}let i=this._findExistingCheck("max");if(i.found&&i.check?.params&&typeof i.check.params.value=="number"&&a>i.check.params.value)throw new Error("ExNumber.min: min cannot be greater than max");let n=e?.message,s=this._addCheck("min",{value:a},n);return this._replaceOrAddCheck(s,t.index),this}max(a,e){if(typeof a!="number"||Number.isNaN(a))throw new Error("ExNumber.max: value must be a number");if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.max: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.max: options.message must be a string");let t=this._findExistingCheck("max");if(t.found&&t.check?.params){let l=t.check.params.value;if(typeof l=="number"&&a>=l)return this}let i=this._findExistingCheck("min");if(i.found&&i.check?.params&&typeof i.check.params.value=="number"&&i.check.params.value>a)throw new Error("ExNumber.max: max cannot be less than min");let n=e?.message,s=this._addCheck("max",{value:a},n);return this._replaceOrAddCheck(s,t.index),this}integer(a){if(a!==void 0&&typeof a!="object")throw new Error("ExNumber.integer: options must be an object");if(a?.message!==void 0&&typeof a.message!="string")throw new Error("ExNumber.integer: options.message must be a string");let e=this._findExistingCheck("integer"),t=a?.message,i=this._addCheck("integer",{},t);return this._replaceOrAddCheck(i,e.index),this}multipleOf(a,e){if(typeof a!="number"||Number.isNaN(a))throw new Error("ExNumber.multipleOf: value must be a number");if(a===0)throw new Error("ExNumber.multipleOf: value cannot be zero");if(e!==void 0&&typeof e!="object")throw new Error("ExNumber.multipleOf: options must be an object");if(e?.message!==void 0&&typeof e.message!="string")throw new Error("ExNumber.multipleOf: options.message must be a string");let t=this._findExistingCheck("multipleOf");if(t.found&&t.check?.params){let s=t.check.params.value;if(typeof s=="number"&&a===s)return this}let i=e?.message,n=this._addCheck("multipleOf",{value:a},i);return this._def.checks.push(n),this}},Re=class X extends Fe{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 X({typeName:"ExNumber",checks:[],message:e?.message})}optional(){return new be({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}},Ie=class ee extends I{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 ee({typeName:"ExBoolean",control:e?.control,message:e?.message,checks:[]})}optional(){return new ge({typeName:"ExOptional",innerType:this})}},ke=class ae extends I{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 ae({typeName:"ExDate"});return e?.message&&(t._def.message=e.message),t}optional(){return new we({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}},Me=class te extends I{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 te({typeName:"ExTime",checks:[],message:e?.message})}optional(){return new xe({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}},Ne=class ie extends I{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 ie({typeName:"ExDatetime",checks:[],message:e?.message});if(e?.message){let i=t._getDatetimeCheck();i&&(i.message=e.message);}return t}optional(){return new Ee({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,i=this._getDatetimeCheck();return i?.params&&(i.params.offset=true,t&&(i.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}},Te=class ne extends I{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 i=0;i<e.length;i++){let n=e[i];if(!n||typeof n!="object")throw new Error(`ExSelect.create: option at index ${i} must be an object`);if(!("label"in n)||typeof n.label!="string")throw new Error(`ExSelect.create: option at index ${i} must have a string label`);if(!("value"in n))throw new Error(`ExSelect.create: option at index ${i} must have a value`);if(typeof n.value!="string"&&typeof n.value!="number")throw new Error(`ExSelect.create: option at index ${i} 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 ne({typeName:"ExSelect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:!!t.allowCustom},checks:[],message:t.message})}optional(){return new ye({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}},_e=class se extends I{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 i=0;i<e.length;i++){let n=e[i];if(!n||typeof n!="object")throw new Error(`ExMultiselect.create: option at index ${i} must be an object`);if(!("label"in n)||typeof n.label!="string")throw new Error(`ExMultiselect.create: option at index ${i} must have a string label`);if(!("value"in n))throw new Error(`ExMultiselect.create: option at index ${i} must have a value`);if(typeof n.value!="string"&&typeof n.value!="number")throw new Error(`ExMultiselect.create: option at index ${i} 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 se({typeName:"ExMultiselect",options:[...e],config:{enforceCaseSensitiveMatch:!!t.enforceCaseSensitiveMatch,allowCustom:false},checks:[],message:t.message})}optional(){return new Ce({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 i=this._findExistingCheck("min");if(i.found&&i.check?.params){let l=i.check.params.value;if(typeof l=="number"&&e<=l)return this}let n=this._findExistingCheck("max");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&e>n.check.params.value)throw new Error("ExMultiselect.min: min cannot be greater than max");let s=this._addCheck("min",{value:e},t);return this._replaceOrAddCheck(s,i.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 i=this._findExistingCheck("max");if(i.found&&i.check?.params){let l=i.check.params.value;if(typeof l=="number"&&e>=l)return this}let n=this._findExistingCheck("min");if(n.found&&n.check?.params&&typeof n.check.params.value=="number"&&n.check.params.value>e)throw new Error("ExMultiselect.max: max cannot be less than min");let s=this._addCheck("max",{value:e},t);return this._replaceOrAddCheck(s,i.index),this}};function Be(){return `uc_${Math.random().toString(36).substring(2,15)}${Math.random().toString(36).substring(2,15)}`}var De=class re extends Y{static create(e){if(!e||typeof e!="object")throw new Error("ExRow.create: shape must be a non-null object");for(let[t,i]of Object.entries(e)){if(!i||typeof i!="object")throw new Error(`ExRow.create: field "${t}" must be a valid field type`);if(!("_def"in i)||!i._def||typeof i._def!="object")throw new Error(`ExRow.create: field "${t}" is not a valid ExpressCSV field`);if(!("typeName"in i._def)||typeof i._def.typeName!="string")throw new Error(`ExRow.create: field "${t}" is missing a typeName`)}return new re({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 i=e,n=t?.when;if(!this._def.optionalColumnConfig)return this._def.optionalColumnConfig={columns:i,when:n,whenMap:n?Object.fromEntries(i.map(l=>[l,n])):void 0},this;let s=[...this._def.optionalColumnConfig.columns];for(let l of i)s.includes(l)||s.push(l);if(this._def.optionalColumnConfig.columns=s,n){this._def.optionalColumnConfig.whenMap||(this._def.optionalColumnConfig.whenMap={});for(let l of i)this._def.optionalColumnConfig.whenMap[l]=n;}return this}unique(e,t){if(e===void 0)throw new Error("ExRow.unique: columns must be provided");let i=Array.isArray(e)?e:[e];for(let m of i)if(!(m in this._def.shape))throw new Error(`ExRow.unique: column "${String(m)}" 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 n=t?.key;this._def.uniqueColumnConfig||(this._def.uniqueColumnConfig={uniqueConstraints:[]});let s=n?m=>{let d=Object.fromEntries(i.map(p=>[p,m[p]]));return n(d)}:void 0,l=(m,d)=>{if(m.length!==d.length)return false;let p=[...m].sort(),E=[...d].sort();return p.every((y,x)=>y===E[x])},h=this._def.uniqueColumnConfig.uniqueConstraints.findIndex(m=>l(m.columns,i)),c={id:Be(),columns:i,key:s};return h!==-1?this._def.uniqueColumnConfig.uniqueConstraints[h]=c:this._def.uniqueColumnConfig.uniqueConstraints.push(c),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}},Oe={string:Ae.create,number:Re.create,boolean:Ie.create,date:ke.create,time:Me.create,datetime:Ne.create,row:De.create,select:Te.create,multiselect:_e.create,infer:a=>{}},Pe=class{constructor(){this.items=[],this.processing=false;}enqueue(a){this.items.push(a);}dequeueUpTo(a){if(this.processing||this.items.length===0)return [];this.processing=true;let e=this.items.splice(0,a);return this.processing=false,e}size(){return this.items.length}isEmpty(){return this.items.length===0}dispose(){this.items=[];}};async function Le(a,e){return Promise.all(a.map(t=>e(t)))}var g=(a=>(a.UNINITIALIZED="uninitialized",a.INITIALIZING="initializing",a.READY="ready",a.OPENING="opening",a.OPEN="open",a.CLOSING="closing",a.RESETTING="resetting",a.ERROR="error",a.DESTROYED="destroyed",a))(g||{}),v=(a=>(a.NORMAL="normal",a.PRELOAD="preload",a))(v||{}),L={maxSize:200,maxDelay:50},Ue={maxRetries:3,retryDelay:500,acknowledgmentTimeout:2e3};function _(a="msg"){return `${a}_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Ge(a,e,t={}){let i=t.timeout||5e3,n={...Ue,...t.messagingConfig},s=new Map,l=[],h=null,c=new Pe,m=null,d=[],p=null,E=true,y=new Map,x=f=>{let u={kind:"singleton",type:"ack",id:f,retryCount:0,originalSentAt:Date.now()};a.postMessage(u,e);},A=f=>{let u=y.get(f);u&&(u.timeout&&clearTimeout(u.timeout),y.delete(f));},k=f=>{f.id||(f.id=_());try{a.postMessage(f,e);let u=0,b=setTimeout(()=>{T(f.id);},n.acknowledgmentTimeout);y.set(f.id,{message:f,retryCount:u,timeout:b});}catch(u){console.error("Error posting message:",u),E=false;}},T=f=>{let u=y.get(f);if(!u)return;if(u.retryCount>=n.maxRetries){if(y.delete(f),u.message.kind==="batch"&&u.message.type==="batch-rpc")for(let w of u.message.calls){let S=s.get(w.requestId);S&&(S.reject(new Error(`RPC call failed after ${n.maxRetries} retries`)),s.delete(w.requestId));}return}u.retryCount++,u.message.retryCount=u.retryCount,u.message.originalSentAt=u.message.originalSentAt||Date.now();try{a.postMessage(u.message,e);}catch(w){console.error("Error retrying message:",w),E=false;}let b=n.retryDelay*2**u.retryCount;u.timeout=setTimeout(()=>{T(f);},b),y.set(f,u);},C=f=>{if(e!=="*"&&f.origin!==e)return;let u=f.data;if(!(!u||typeof u!="object")){if(u.kind==="singleton"&&u.type==="ack"&&u.id){A(u.id);return}if(u.id&&x(u.id),u.kind==="singleton")if(u.type==="response"&&u.id){let b=s.get(u.id);b&&(u.error?b.reject(new Error(u.error)):b.resolve(u.data),s.delete(u.id));}else for(let b of l)try{b(u);}catch(w){console.error("Error in message handler:",w);}else if(u.kind==="batch"&&u.type==="batch-rpc-response")for(let b of u.responses){let w=s.get(b.requestId);w&&(b.status==="error"?w.reject(new Error(b.error.message||"RPC call failed")):w.resolve(b.result),s.delete(b.requestId));}else u.kind==="batch"&&u.type==="batch-rpc"&&R(u);}},R=async f=>{if(!h){for(let w of f.calls)F({requestId:w.requestId,functionId:w.functionId,status:"error",error:{code:"METHOD_NOT_FOUND",message:"No RPC handler registered"}});B();return}let u=h,b=await Le(f.calls,async w=>{try{let S=await u({functionName:w.functionName,requestId:w.requestId,functionId:w.functionId,params:w.params});return {requestId:w.requestId,functionId:w.functionId,status:"success",result:S}}catch(S){return {requestId:w.requestId,functionId:w.functionId,status:"error",error:{code:"EXECUTION_ERROR",message:S instanceof Error?S.message:"Unknown error",details:S}}}});for(let w of b)d.push(w);d.length>0&&M();},F=f=>{d.push(f),d.length>=L.maxSize?M():B();},M=()=>{if(d.length===0)return;let f={kind:"batch",type:"batch-rpc-response",id:_("batch_resp"),responses:[...d],retryCount:0,originalSentAt:Date.now()};d=[],p&&(clearTimeout(p),p=null),k(f);},B=()=>{p||(p=setTimeout(()=>{M();},L.maxDelay));},D=()=>{if(c.isEmpty())return;let f=c.size(),u=c.dequeueUpTo(f);if(u.length===0)return;let b={kind:"batch",type:"batch-rpc",id:_("batch"),calls:[...u],retryCount:0,originalSentAt:Date.now()};m&&(clearTimeout(m),m=null),k(b);},U=()=>{m||(m=setTimeout(()=>{D(),m=null;},L.maxDelay));};return window.addEventListener("message",C),{callRPC:({functionName:f,functionId:u,params:b})=>new Promise((w,S)=>{let O=_("rpc"),he={requestId:O,functionName:f,functionId:u,params:b};s.set(O,{resolve:G=>{w(G);},reject:G=>{S(G);}}),setTimeout(()=>{s.has(O)&&(s.delete(O),S(new Error(`Call to ${f} timed out`)));},i),c.enqueue(he),c.size()>=L.maxSize?D():U();}),registerRPCHandler:f=>{h=f;},sendMessage:f=>{let u={...f,kind:"singleton",id:_(),retryCount:0,originalSentAt:Date.now()};k(u);},registerMessageHandler:f=>{l.push(f);},disconnect:()=>{window.removeEventListener("message",C);for(let[,f]of s)f.reject(new Error("Connection closed"));for(let[,f]of y)f.timeout&&clearTimeout(f.timeout);m&&clearTimeout(m),p&&clearTimeout(p),s.clear(),y.clear(),c.dispose(),d=[],E=false;},getConnectionStatus:()=>E}}function je(a,e={}){let t=a.contentWindow;if(!t)throw new Error("Cannot connect to iframe: contentWindow is null");let i=e.targetOrigin||new URL(a.src).origin||"*";return Ge(t,i,e)}var Ve=class oe extends Error{constructor(e="Import was cancelled by the user"){super(e),this.name="ImportCancelledError",Error.captureStackTrace&&Error.captureStackTrace(this,oe);}},le=class{constructor(a){this.options=a,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=g.UNINITIALIZED,this.canRestart=false,this.lastError=null,this.openOptions=null,this.cachedSchemaJson=null,this.initCompletePromise=null,this.resolveInitComplete=null,this.debug=a.debug||false,this.developerMode=a.developerMode||false,this.importIdentifier=a.importIdentifier,this.widgetMode=a.preload!==false?v.PRELOAD:v.NORMAL,this.log("Initializing CSVImporter with options:",a),a.preload!==false&&(this.setState(g.INITIALIZING,"Auto-preload initialization"),this.initCompletePromise=new Promise(e=>{this.resolveInitComplete=e;}),this.initializeIframe(true).catch(e=>{this.log("Auto-preload failed:",e),this.initCompletePromise=null,this.resolveInitComplete=null,this.handleError(e instanceof Error?e:new Error("Preload failed"));}));}setState(a,e){this.widgetState=a,this.log(`State change: \u2192 ${a}`,e),this.connection&&this.connection.sendMessage({type:"action:sync_state",data:{sdkState:a,mode:this.widgetMode}}),this.updateDerivedState();}updateDerivedState(){this.canRestart=this.widgetState===g.READY||this.widgetState===g.ERROR;}handleError(a){this.lastError=a,this.setState(g.ERROR,a.message),this.openOptions?.onError?.(a),this.openOptions=null;}async waitForEvent(a,e=5e3){return new Promise((t,i)=>{let n=setTimeout(()=>{i(new Error(`Timeout waiting for ${a}`));},e),s=l=>{l.type===a&&(clearTimeout(n),t(l.data));};this.connection?.registerMessageHandler(s);})}open(a){if(this.log("open() called",a),this.openOptions){this.log("open() called while already active, ignoring");return}if(this.sessionId=crypto.randomUUID(),this.connection&&this.widgetState===g.READY&&this.connection.sendMessage({type:"action:update_session_id",data:{sessionId:this.sessionId}}),this.openOptions=a,!this.cachedSchemaJson){let e=Z(this.options.schema,true);this.cachedSchemaJson=e.json;}this.openWidget().then(()=>{this.log("Widget opened successfully for open()"),this.createImportSession({chunkSize:a.chunkSize,webhook:a.webhook}).catch(e=>{if(this.log("Failed to create import session:",e),e.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 t=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?.(t);}else {let t=e instanceof Error?e:new Error("Failed to create import session");this.openOptions?.onError?.(t);}});}).catch(e=>{this.log("Failed to open widget in open():",e);let t=e instanceof Error?e:new Error("Failed to open widget");this.openOptions?.onError?.(t),this.openOptions=null;});}async createImportSession({chunkSize:a,webhook:e}){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 t=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/import-sessions`,i={schema:this.cachedSchemaJson,chunkSize:a,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};e&&(i.webhook={url:e.url,headers:e.headers,method:e.method,metadata:e.metadata});let n=await fetch(t,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,configuration:i})});if(!n.ok){let s,l="Unknown error";try{let c=await n.json();s=c.code,l=c.message||c.error||l;}catch{l=await n.text().catch(()=>"Unknown error");}let h=new Error(`Failed to create import session: ${n.status} ${n.statusText} - ${l}`);throw h.code=s,h}this.log("Import session created successfully",{sessionId:this.sessionId});}async deliverToWebhook(a,e,t,i){let n=a.length,s=Math.ceil(n/1e3);for(let l=0;l<s;l++){let h=l*1e3,c=Math.min(h+1e3,n),m={records:a.slice(h,c),totalChunks:s,currentChunkIndex:l,totalRecords:t.totalRecords};await this.sendChunkToBackend(m,e,i);}}async sendChunkToBackend(a,e,t){if(!this.sessionId)throw new Error("Session ID not initialized. Call open() first.");let i=`${process.env.NODE_ENV==="development"?"http://localhost:3000":"https://www.expresscsv.com"}/api/webhooks/deliver`,n=3,s=3e4,l=null;for(let h=0;h<=n;h++){let c=new AbortController,m=setTimeout(()=>c.abort(),s);try{let d=await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${this.options.publishableKey}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:this.sessionId,importIdentifier:this.importIdentifier,webhook:{url:e.url,headers:e.headers,method:e.method,metadata:e.metadata,chunkSize:t},chunk:{records:a.records,totalChunks:a.totalChunks,currentChunkIndex:a.currentChunkIndex,totalRecords:a.totalRecords}}),signal:c.signal});if(clearTimeout(m),!d.ok){let p=d.status;if(p>=400&&p<500&&p!==429){let E=await d.text().catch(()=>"Unknown error");throw new Error(`Backend API error: ${p} ${d.statusText} - ${E}`)}throw new Error(`Backend API error: ${p} ${d.statusText}`)}this.log(`Chunk ${a.currentChunkIndex+1}/${a.totalChunks} sent to backend successfully (attempt ${h+1})`);return}catch(d){clearTimeout(m),l=d instanceof Error?d:new Error(String(d)),this.log(`Failed to send chunk to backend (attempt ${h+1}/${n+1}):`,l),h<n&&await new Promise(p=>setTimeout(p,2**h*1e3));}}throw l||new Error("Failed to send chunk to backend")}async processResultsInChunks(a){if(!this.openOptions){this.log("No open options available, skipping chunk processing");return}let{chunkSize:e=1e3,onData:t,webhook:i,onComplete:n,onError:s}=this.openOptions,l=a.length,h=e<=0?l:e,c=Math.ceil(l/h);this.log(`Processing ${l} records in ${c} chunks of ${h}`);try{for(let m=0;m<c;m++){let d=m*h,p=Math.min(d+h,l),E={records:a.slice(d,p),totalChunks:c,currentChunkIndex:m,totalRecords:l};t&&await new Promise((y,x)=>{try{let A=t(E,y);A instanceof Promise&&A.catch(x);}catch(A){x(A);}});}if(i){let m={records:[],totalChunks:c,currentChunkIndex:c-1,totalRecords:l};await this.deliverToWebhook(a,i,m,h);}this.log("All chunks processed successfully"),n?.();}catch(m){this.log("Error during chunk processing:",m);let d=m instanceof Error?m:new Error(String(m));s?.(d);}finally{this.openOptions=null;}}async initializeIframe(a=false){this.log(`Initializing iframe (hidden: ${a})`),(this.iframe||this.container||this.connection)&&(this.log("Cleaning up existing resources before initialization"),this.destroy(false));try{this.container=document.createElement("div"),a?(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 ${a?"hidden":"visible"} container`),this.createAndAppendIframe(this.container),this.log("Created iframe"),await this.waitForIframeLoad(),await this.setupConnectionAndInit(),this.log(`Iframe initialization complete (hidden: ${a})`);}catch(e){throw this.log("Iframe initialization failed:",e),this.destroy(false),e}}log(...a){(this.debug||process.env.NODE_ENV==="development")&&console.log("[CSVImporter]",...a);}error(...a){console.error("[CSVImporter]",...a);}addBeforeUnloadListener(){if(this._beforeUnloadHandler){this.log("beforeunload listener already exists");return}this._beforeUnloadHandler=a=>(a.preventDefault(),"You have an import in progress. Are you sure you want to leave? Your progress will be lost."),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((a,e)=>{if(!this.iframe){this.log("No iframe available, rejecting promise"),e(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)"),a();return}}catch{this.log("Cannot check iframe load state (CORS), waiting for onload");}let t=false,i=()=>{this.iframe&&(this.iframe.onload=null,this.iframe.onerror=null);},n=()=>{t||(t=true,clearTimeout(l),i(),a());},s=h=>{t||(t=true,clearTimeout(l),i(),e(h));},l=setTimeout(()=>{this.log("Iframe load timeout reached"),s(new Error("Iframe load timeout"));},1e4);this.iframe.onload=()=>{this.log("Iframe loaded successfully"),n();},this.iframe.onerror=h=>{this.error("Iframe failed to load:",h),s(new Error("Failed to load iframe"));};})}async setupConnectionAndInit(){if(this.log("Creating connection to iframe"),this.connection=this.iframe?je(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 a=Z(this.options.schema,true);this.cachedSchemaJson=a.json,this.initCompletePromise||(this.initCompletePromise=new Promise(e=>{this.resolveInitComplete=e;})),this.connection.sendMessage({type:"action:init",data:{schemaJson:a.json,functionMapJson:JSON.stringify([...a.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:e,functionId:t,params:i})=>{let n=a.localFunctionMap.get(t);if(!n)throw new Error(`Unknown function: ${e}`);let s=n.function;return await s(i)}),this.connectionState=true,this.log("Connection established and initialized");}async openWidget(a){if(this.log("openWidget() called",{currentState:this.widgetState,options:a}),this.widgetState===g.OPEN){this.log("Widget is already open, ignoring openWidget() call");return}let e=this.widgetState;this.setState(g.OPENING,"User requested open");try{a?.reset&&await this.resetWidget(),this.widgetMode===v.PRELOAD&&e===g.READY?(this.log("Using preloaded iframe - making visible instantly"),this.makeContainerVisible(),this.connection?.sendMessage({type:"action:open_widget",data:{resetState:a?.reset,sessionId:this.sessionId??void 0}})):this.widgetMode===v.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:a?.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:a?.reset,sessionId:this.sessionId??void 0}})),this.setState(g.OPEN,"Widget opened successfully"),this.openOptions?.onWidgetOpen?.(),this.addBeforeUnloadListener();}catch(t){throw this.log("Failed to open widget:",t),this.handleError(t instanceof Error?t:new Error("Failed to open widget")),t}}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 a=>{if(a.type==="event:results"){this.log("Processing results message");let e=a.data;this.openOptions?(await this.processResultsInChunks(e),this.connection&&this.connection.sendMessage({type:"event:results_processed"})):this.connection&&this.connection.sendMessage({type:"event:results_processed"});}else if(a.type==="event:init_complete")this.log("Widget initialized successfully"),this.resolveInitComplete&&(this.resolveInitComplete(),this.resolveInitComplete=null),this.setState(g.READY,"Widget initialization complete");else if(a.type==="event:widget_closed"){this.log("Processing widget closed message:",a.data);let e=a.data.reason;this.openOptions?.onWidgetClose?.(e),e==="cancel"&&this.openOptions&&(this.openOptions.onCancel?.(),this.openOptions=null),await this.handleWidgetClosed(e);}else if(a.type==="event:step_change"){this.log("Processing step change message:",a.data);let e=a.data.stepId,t=a.data.previousStepId;this.openOptions?.onStepChange?.(e,t);}else a.type==="event:state_change"?this.log("Widget state changed:",a.data):a.type==="event:widget_status"?this.log("Widget status update:",a.data):a.type==="event:reset_complete"?this.log("Widget reset complete:",a.data):a.type==="event:restart_complete"&&this.log("Widget restart complete:",a.data);});}createAndAppendIframe(a){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",a.appendChild(this.iframe),this.log("Iframe appended to container, URL:",this.widgetUrl);}destroy(a=true){if(this.log("destroy() called, resetReadyState:",a),this._destroyTimer!==null&&(this.log("Clearing existing destroy timer"),window.clearTimeout(this._destroyTimer),this._destroyTimer=null),this.widgetState===g.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(e){this.error("Error during destroy:",e);}}async close(a="user_close"){if(this.log("close() called",{currentState:this.widgetState,reason:a}),this.widgetState===g.CLOSING||this.widgetState===g.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}if(this.widgetState!==g.OPEN){this.log("Not open, ignoring close call");return}this.setState(g.CLOSING,`Close requested: ${a}`);try{this.connection&&(this.log("Sending close message to widget"),this.connection.sendMessage({type:"action:close_widget",data:{reason:a}}));}catch(e){this.error("Error during close preparation:",e);}this.removeBeforeUnloadListener(),this.widgetMode===v.PRELOAD?(this.hideContainer(),this.setState(g.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(g.DESTROYED,"Normal mode widget destroyed"));}async resetWidget(){this.log("resetWidget() called",{currentState:this.widgetState}),this.setState(g.RESETTING,"Reset requested");try{this.connection&&(this.connection.sendMessage({type:"action:reset_widget",data:{preserveConnection:this.widgetMode===v.PRELOAD}}),await this.waitForEvent("event:reset_complete")),this.lastError=null,this.widgetMode===v.PRELOAD?this.setState(g.READY,"Reset complete - preload mode"):this.setState(g.UNINITIALIZED,"Reset complete - normal mode");}catch(a){throw this.handleError(a instanceof Error?a:new Error("Reset failed")),a}}async restart(a){if(this.log("restart() called",{currentState:this.widgetState,newOptions:a}),!this.canRestart)throw new Error("Widget cannot be restarted in current state");try{await this.resetWidget(),a&&(Object.assign(this.options,a),this.widgetMode=this.options.preload!==!1?v.PRELOAD:v.NORMAL,this.connection&&(this.connection.sendMessage({type:"action:restart_widget",data:{newOptions:a}}),await this.waitForEvent("event:restart_complete"))),await this.openWidget();}catch(e){throw this.handleError(e instanceof Error?e:new Error("Restart failed")),e}}async handleWidgetClosed(a){if(this.log("handleWidgetClosed() called",{currentState:this.widgetState,reason:a}),this.widgetState===g.CLOSING||this.widgetState===g.DESTROYED){this.log("Already closing or destroyed, ignoring close call");return}this.setState(g.CLOSING,`Widget closed: ${a}`),this.removeBeforeUnloadListener(),this.widgetMode===v.PRELOAD?(this.hideContainer(),this.setState(g.READY,"Preloaded widget hidden for reuse"),this.canRestart=true):(this.destroy(),this.setState(g.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 a=this.connectionState&&this.connection?.getConnectionStatus();return this.log("getConnectionStatus() called, returning:",a),!!a}getState(){return this.widgetState}getMode(){return this.widgetMode}getIsReady(){let a=this.widgetState===g.READY||this.widgetState===g.OPEN;return this.log("getIsReady() called, returning:",a),a}getIsOpen(){let a=this.widgetState===g.OPEN;return this.log("getIsOpen() called, returning:",a),a}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 a="2.0.0";return this.log("getVersion() called, returning:",a),a}};function qe({schema:a,title:e,importIdentifier:t,publishableKey:i,debug:n,developerMode:s,preload:l,theme:h,colorMode:c,customCSS:m,fonts:d,stepDisplay:p,previewSchemaBeforeUpload:E=true,templateDownload:y,saveSession:x,locale:A}){let k=JSON.stringify(y),T=useMemo(()=>y,[k]),C=JSON.stringify(A),R=useMemo(()=>A,[C]),F=useRef(null),[M,B]=useState(g.UNINITIALIZED),D=M===g.INITIALIZING||M===g.OPENING,U=M===g.OPEN;return useEffect(()=>{let u=new le({schema:a,title:e,importIdentifier:t,publishableKey:i,debug:n,developerMode:s,preload:l,theme:h,colorMode:c,customCSS:m,fonts:d,stepDisplay:p,previewSchemaBeforeUpload:E,templateDownload:T,saveSession:x,locale:R});F.current=u;let w=setInterval(()=>{if(F.current){let S=F.current.getState();B(S);}},100);return ()=>{clearInterval(w),F.current&&(F.current.close(),F.current=null);}},[a,e,t,i,n,s,l,h,c,m,d,p,E,T,x,R]),{open:useCallback(u=>{if(!F.current)throw new Error("CSVImporter not initialized");F.current.open(u);},[]),widgetState:M,isInitialising:D,isOpen:U}}
|
|
2
|
+
export{Ve as ImportCancelledError,v as WidgetMode,g as WidgetState,qe as useExpressCSV,Oe as x};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expresscsv/react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "React component wrapper for ExpressCSV SDK",
|
|
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
|
+
"react",
|
|
23
|
+
"csv",
|
|
24
|
+
"upload"
|
|
25
|
+
],
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@expresscsv/tsconfig": "workspace:*",
|
|
33
|
+
"@testing-library/react": "^14.2.1",
|
|
34
|
+
"@types/node": "^20.0.0",
|
|
35
|
+
"@types/react": "^18.2.55",
|
|
36
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
37
|
+
"happy-dom": "^14.12.3",
|
|
38
|
+
"react": "^18.2.0",
|
|
39
|
+
"react-dom": "^18.2.0",
|
|
40
|
+
"tsup": "^8.0.0",
|
|
41
|
+
"typescript": "^5.0.0",
|
|
42
|
+
"vitest": "^1.6.1"
|
|
43
|
+
}
|
|
44
|
+
}
|