@spfn/notification 0.1.0-beta.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/dist/server.js ADDED
@@ -0,0 +1,3807 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/config/index.ts
8
+ import { createEnvRegistry } from "@spfn/core/env";
9
+
10
+ // src/config/schema.ts
11
+ import { defineEnvSchema, envString } from "@spfn/core/env";
12
+ var notificationEnvSchema = defineEnvSchema({
13
+ // Email
14
+ SPFN_NOTIFICATION_EMAIL_PROVIDER: {
15
+ ...envString({
16
+ description: "Email provider (aws-ses, sendgrid, smtp)",
17
+ default: "aws-ses",
18
+ required: false,
19
+ examples: ["aws-ses", "sendgrid", "smtp"]
20
+ })
21
+ },
22
+ SPFN_NOTIFICATION_EMAIL_FROM: {
23
+ ...envString({
24
+ description: "Default sender email address",
25
+ required: false,
26
+ examples: ["noreply@example.com"]
27
+ })
28
+ },
29
+ // SMS
30
+ SPFN_NOTIFICATION_SMS_PROVIDER: {
31
+ ...envString({
32
+ description: "SMS provider (aws-sns, twilio)",
33
+ default: "aws-sns",
34
+ required: false,
35
+ examples: ["aws-sns", "twilio"]
36
+ })
37
+ },
38
+ // Slack
39
+ SPFN_NOTIFICATION_SLACK_WEBHOOK_URL: {
40
+ ...envString({
41
+ description: "Slack webhook URL",
42
+ required: false,
43
+ examples: ["https://hooks.slack.com/services/xxx/xxx/xxx"]
44
+ })
45
+ },
46
+ // AWS (shared with other AWS services)
47
+ AWS_REGION: {
48
+ ...envString({
49
+ description: "AWS region",
50
+ default: "ap-northeast-2",
51
+ required: false,
52
+ examples: ["ap-northeast-2", "us-east-1"]
53
+ })
54
+ },
55
+ AWS_ACCESS_KEY_ID: {
56
+ ...envString({
57
+ description: "AWS access key ID",
58
+ required: false,
59
+ sensitive: true
60
+ })
61
+ },
62
+ AWS_SECRET_ACCESS_KEY: {
63
+ ...envString({
64
+ description: "AWS secret access key",
65
+ required: false,
66
+ sensitive: true
67
+ })
68
+ }
69
+ });
70
+
71
+ // src/config/index.ts
72
+ var registry = createEnvRegistry(notificationEnvSchema);
73
+ var env = registry.validate();
74
+ var globalConfig = {};
75
+ function configureNotification(config) {
76
+ globalConfig = { ...globalConfig, ...config };
77
+ }
78
+ function getNotificationConfig() {
79
+ return { ...globalConfig };
80
+ }
81
+ function getEmailFrom() {
82
+ return globalConfig.email?.from || env.SPFN_NOTIFICATION_EMAIL_FROM || "noreply@example.com";
83
+ }
84
+ function getEmailReplyTo() {
85
+ return globalConfig.email?.replyTo;
86
+ }
87
+ function getSmsDefaultCountryCode() {
88
+ return globalConfig.sms?.defaultCountryCode || "+82";
89
+ }
90
+ function getAppName() {
91
+ return globalConfig.defaults?.appName || "SPFN";
92
+ }
93
+ function isHistoryEnabled() {
94
+ return globalConfig.enableHistory ?? false;
95
+ }
96
+
97
+ // src/channels/email/providers/aws-ses.ts
98
+ var sesClient = null;
99
+ async function getSESClient() {
100
+ if (sesClient) {
101
+ return sesClient;
102
+ }
103
+ try {
104
+ const { SESClient } = await import("@aws-sdk/client-ses");
105
+ sesClient = new SESClient({
106
+ region: env.AWS_REGION,
107
+ credentials: env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY ? {
108
+ accessKeyId: env.AWS_ACCESS_KEY_ID,
109
+ secretAccessKey: env.AWS_SECRET_ACCESS_KEY
110
+ } : void 0
111
+ });
112
+ return sesClient;
113
+ } catch {
114
+ throw new Error(
115
+ "@aws-sdk/client-ses is not installed. Please install it: pnpm add @aws-sdk/client-ses"
116
+ );
117
+ }
118
+ }
119
+ var awsSesProvider = {
120
+ name: "aws-ses",
121
+ async send(params) {
122
+ try {
123
+ const client = await getSESClient();
124
+ const { SendEmailCommand } = await import("@aws-sdk/client-ses");
125
+ const command = new SendEmailCommand({
126
+ Source: params.from,
127
+ Destination: {
128
+ ToAddresses: params.to
129
+ },
130
+ ReplyToAddresses: params.replyTo ? [params.replyTo] : void 0,
131
+ Message: {
132
+ Subject: {
133
+ Charset: "UTF-8",
134
+ Data: params.subject
135
+ },
136
+ Body: {
137
+ ...params.html && {
138
+ Html: {
139
+ Charset: "UTF-8",
140
+ Data: params.html
141
+ }
142
+ },
143
+ ...params.text && {
144
+ Text: {
145
+ Charset: "UTF-8",
146
+ Data: params.text
147
+ }
148
+ }
149
+ }
150
+ }
151
+ });
152
+ const response = await client.send(command);
153
+ return {
154
+ success: true,
155
+ messageId: response.MessageId
156
+ };
157
+ } catch (error) {
158
+ const err = error;
159
+ return {
160
+ success: false,
161
+ error: err.message
162
+ };
163
+ }
164
+ }
165
+ };
166
+
167
+ // src/templates/renderer.ts
168
+ var filters = {
169
+ /**
170
+ * Convert to uppercase
171
+ */
172
+ uppercase: (value) => String(value).toUpperCase(),
173
+ /**
174
+ * Convert to lowercase
175
+ */
176
+ lowercase: (value) => String(value).toLowerCase(),
177
+ /**
178
+ * Format as currency (Korean Won style: 1,000)
179
+ */
180
+ currency: (value) => {
181
+ const num = typeof value === "number" ? value : parseFloat(String(value));
182
+ if (isNaN(num)) return String(value);
183
+ return num.toLocaleString("ko-KR");
184
+ },
185
+ /**
186
+ * Format date
187
+ * Usage: {{date | date}} or {{date | date:YYYY-MM-DD}}
188
+ */
189
+ date: (value, format) => {
190
+ const date = value instanceof Date ? value : new Date(String(value));
191
+ if (isNaN(date.getTime())) return String(value);
192
+ if (!format || format === "default") {
193
+ return date.toLocaleDateString("ko-KR");
194
+ }
195
+ return format.replace("YYYY", String(date.getFullYear())).replace("MM", String(date.getMonth() + 1).padStart(2, "0")).replace("DD", String(date.getDate()).padStart(2, "0")).replace("HH", String(date.getHours()).padStart(2, "0")).replace("mm", String(date.getMinutes()).padStart(2, "0")).replace("ss", String(date.getSeconds()).padStart(2, "0"));
196
+ },
197
+ /**
198
+ * Truncate string
199
+ * Usage: {{text | truncate:20}}
200
+ */
201
+ truncate: (value, arg) => {
202
+ const str = String(value);
203
+ const length = arg ? parseInt(arg, 10) : 50;
204
+ if (str.length <= length) return str;
205
+ return str.slice(0, length) + "...";
206
+ },
207
+ /**
208
+ * Default value if empty
209
+ * Usage: {{name | default:Guest}}
210
+ */
211
+ default: (value, arg) => {
212
+ if (value === null || value === void 0 || value === "") {
213
+ return arg || "";
214
+ }
215
+ return String(value);
216
+ }
217
+ };
218
+ function parseExpression(expr) {
219
+ const parts = expr.split("|").map((p) => p.trim());
220
+ const variable = parts[0];
221
+ if (parts.length === 1) {
222
+ return { variable };
223
+ }
224
+ const filterPart = parts[1];
225
+ const colonIndex = filterPart.indexOf(":");
226
+ if (colonIndex === -1) {
227
+ return { variable, filter: filterPart };
228
+ }
229
+ return {
230
+ variable,
231
+ filter: filterPart.slice(0, colonIndex),
232
+ arg: filterPart.slice(colonIndex + 1)
233
+ };
234
+ }
235
+ function getValue(data, path) {
236
+ const parts = path.split(".");
237
+ let value = data;
238
+ for (const part of parts) {
239
+ if (value === null || value === void 0) {
240
+ return void 0;
241
+ }
242
+ value = value[part];
243
+ }
244
+ return value;
245
+ }
246
+ function render(template, data) {
247
+ return template.replace(/\{\{([^}]+)\}\}/g, (match, expr) => {
248
+ const { variable, filter, arg } = parseExpression(expr.trim());
249
+ let value = getValue(data, variable);
250
+ if (value === void 0) {
251
+ return match;
252
+ }
253
+ if (filter && filters[filter]) {
254
+ return filters[filter](value, arg);
255
+ }
256
+ return String(value);
257
+ });
258
+ }
259
+ function registerFilter(name, fn) {
260
+ filters[name] = fn;
261
+ }
262
+
263
+ // src/templates/registry.ts
264
+ var templates = /* @__PURE__ */ new Map();
265
+ function registerTemplate(template) {
266
+ templates.set(template.name, template);
267
+ }
268
+ function getTemplate(name) {
269
+ return templates.get(name);
270
+ }
271
+ function hasTemplate(name) {
272
+ return templates.has(name);
273
+ }
274
+ function renderTemplate(name, data, channel) {
275
+ const template = templates.get(name);
276
+ if (!template) {
277
+ throw new Error(`Template not found: ${name}`);
278
+ }
279
+ const fullData = {
280
+ appName: getAppName(),
281
+ ...data
282
+ };
283
+ const result = {};
284
+ if ((!channel || channel === "email") && template.email) {
285
+ result.email = renderEmailTemplate(template.email, fullData);
286
+ }
287
+ if ((!channel || channel === "sms") && template.sms) {
288
+ result.sms = renderSmsTemplate(template.sms, fullData);
289
+ }
290
+ if ((!channel || channel === "slack") && template.slack) {
291
+ result.slack = renderSlackTemplate(template.slack, fullData);
292
+ }
293
+ return result;
294
+ }
295
+ function renderEmailTemplate(template, data) {
296
+ return {
297
+ subject: render(template.subject, data),
298
+ html: template.html ? render(template.html, data) : void 0,
299
+ text: template.text ? render(template.text, data) : void 0
300
+ };
301
+ }
302
+ function renderSmsTemplate(template, data) {
303
+ return {
304
+ message: render(template.message, data)
305
+ };
306
+ }
307
+ function renderSlackTemplate(template, data) {
308
+ return {
309
+ text: template.text ? render(template.text, data) : void 0,
310
+ blocks: template.blocks
311
+ // Blocks are not rendered (complex structure)
312
+ };
313
+ }
314
+ function getTemplateNames() {
315
+ return Array.from(templates.keys());
316
+ }
317
+
318
+ // src/templates/builtin/verification-code.ts
319
+ var verificationCodeTemplate = {
320
+ name: "verification-code",
321
+ channels: ["email", "sms"],
322
+ email: {
323
+ subject: "[{{appName}}] \uC778\uC99D \uCF54\uB4DC: {{code}}",
324
+ html: `<!DOCTYPE html>
325
+ <html>
326
+ <head>
327
+ <meta charset="utf-8">
328
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
329
+ </head>
330
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f5f5f5;">
331
+ <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 30px; border-radius: 10px 10px 0 0; text-align: center;">
332
+ <h1 style="color: white; margin: 0; font-size: 24px;">{{appName}}</h1>
333
+ </div>
334
+ <div style="background: #ffffff; padding: 30px; border: 1px solid #e0e0e0; border-top: none; border-radius: 0 0 10px 10px;">
335
+ <p style="margin-bottom: 20px; font-size: 16px;">
336
+ \uC778\uC99D \uCF54\uB4DC\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694:
337
+ </p>
338
+ <div style="background: #f8f9fa; padding: 25px; border-radius: 8px; text-align: center; margin: 25px 0; border: 2px dashed #dee2e6;">
339
+ <span style="font-size: 36px; font-weight: bold; letter-spacing: 10px; color: #333; font-family: 'Courier New', monospace;">{{code}}</span>
340
+ </div>
341
+ <p style="color: #666; font-size: 14px; margin-top: 20px; text-align: center;">
342
+ <strong>\uC774 \uCF54\uB4DC\uB294 {{expiresInMinutes | default:5}}\uBD84 \uD6C4 \uB9CC\uB8CC\uB429\uB2C8\uB2E4.</strong>
343
+ </p>
344
+ <hr style="border: none; border-top: 1px solid #eee; margin: 30px 0;">
345
+ <p style="color: #999; font-size: 12px; text-align: center; margin: 0;">
346
+ \uBCF8\uC778\uC774 \uC694\uCCAD\uD558\uC9C0 \uC54A\uC558\uB2E4\uBA74 \uC774 \uC774\uBA54\uC77C\uC744 \uBB34\uC2DC\uD574\uC8FC\uC138\uC694.
347
+ </p>
348
+ </div>
349
+ </body>
350
+ </html>`,
351
+ text: `[{{appName}}] \uC778\uC99D \uCF54\uB4DC: {{code}}
352
+
353
+ \uC774 \uCF54\uB4DC\uB294 {{expiresInMinutes | default:5}}\uBD84 \uD6C4 \uB9CC\uB8CC\uB429\uB2C8\uB2E4.
354
+
355
+ \uBCF8\uC778\uC774 \uC694\uCCAD\uD558\uC9C0 \uC54A\uC558\uB2E4\uBA74 \uC774 \uBA54\uC2DC\uC9C0\uB97C \uBB34\uC2DC\uD574\uC8FC\uC138\uC694.`
356
+ },
357
+ sms: {
358
+ message: "[{{appName}}] \uC778\uC99D \uCF54\uB4DC: {{code}} ({{expiresInMinutes | default:5}}\uBD84 \uB0B4 \uC785\uB825)"
359
+ }
360
+ };
361
+
362
+ // src/templates/builtin/welcome.ts
363
+ var welcomeTemplate = {
364
+ name: "welcome",
365
+ channels: ["email"],
366
+ email: {
367
+ subject: "[{{appName}}] \uAC00\uC785\uC744 \uD658\uC601\uD569\uB2C8\uB2E4!",
368
+ html: `<!DOCTYPE html>
369
+ <html>
370
+ <head>
371
+ <meta charset="utf-8">
372
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
373
+ </head>
374
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f5f5f5;">
375
+ <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 30px; border-radius: 10px 10px 0 0; text-align: center;">
376
+ <h1 style="color: white; margin: 0; font-size: 24px;">{{appName}}</h1>
377
+ </div>
378
+ <div style="background: #ffffff; padding: 30px; border: 1px solid #e0e0e0; border-top: none; border-radius: 0 0 10px 10px;">
379
+ <h2 style="color: #333; margin-top: 0;">\uD658\uC601\uD569\uB2C8\uB2E4, {{name | default:\uD68C\uC6D0}}\uB2D8!</h2>
380
+ <p style="font-size: 16px; color: #555;">
381
+ {{appName}}\uC5D0 \uAC00\uC785\uD574 \uC8FC\uC154\uC11C \uAC10\uC0AC\uD569\uB2C8\uB2E4.
382
+ </p>
383
+ <p style="font-size: 16px; color: #555;">
384
+ \uC774\uC81C \uBAA8\uB4E0 \uC11C\uBE44\uC2A4\uB97C \uC774\uC6A9\uD558\uC2E4 \uC218 \uC788\uC2B5\uB2C8\uB2E4.
385
+ </p>
386
+ <hr style="border: none; border-top: 1px solid #eee; margin: 30px 0;">
387
+ <p style="color: #999; font-size: 12px; text-align: center; margin: 0;">
388
+ \uBB38\uC758\uC0AC\uD56D\uC774 \uC788\uC73C\uC2DC\uBA74 \uC5B8\uC81C\uB4E0\uC9C0 \uC5F0\uB77D\uD574 \uC8FC\uC138\uC694.
389
+ </p>
390
+ </div>
391
+ </body>
392
+ </html>`,
393
+ text: `[{{appName}}] \uAC00\uC785\uC744 \uD658\uC601\uD569\uB2C8\uB2E4!
394
+
395
+ {{name | default:\uD68C\uC6D0}}\uB2D8, {{appName}}\uC5D0 \uAC00\uC785\uD574 \uC8FC\uC154\uC11C \uAC10\uC0AC\uD569\uB2C8\uB2E4.
396
+ \uC774\uC81C \uBAA8\uB4E0 \uC11C\uBE44\uC2A4\uB97C \uC774\uC6A9\uD558\uC2E4 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`
397
+ }
398
+ };
399
+
400
+ // src/templates/index.ts
401
+ function registerBuiltinTemplates() {
402
+ registerTemplate(verificationCodeTemplate);
403
+ registerTemplate(welcomeTemplate);
404
+ }
405
+
406
+ // src/services/notification.service.ts
407
+ import { create, findOne, findMany, updateOne, count } from "@spfn/core/db";
408
+ import { desc, eq, and, gte, lte } from "drizzle-orm";
409
+
410
+ // src/entities/schema.ts
411
+ import { createSchema } from "@spfn/core/db";
412
+ var notificationSchema = createSchema("@spfn/notification");
413
+
414
+ // src/entities/notifications.ts
415
+ import { text, jsonb, index } from "drizzle-orm/pg-core";
416
+ import { id, timestamps, utcTimestamp } from "@spfn/core/db";
417
+ var NOTIFICATION_CHANNELS = ["email", "sms", "slack", "push"];
418
+ var NOTIFICATION_STATUSES = ["scheduled", "pending", "sent", "failed", "cancelled"];
419
+ var notifications = notificationSchema.table(
420
+ "history",
421
+ {
422
+ id: id(),
423
+ /**
424
+ * Channel used for sending (email, sms, slack, push)
425
+ */
426
+ channel: text("channel", {
427
+ enum: NOTIFICATION_CHANNELS
428
+ }).notNull(),
429
+ /**
430
+ * Recipient identifier (email, phone, channel, device token)
431
+ */
432
+ recipient: text("recipient").notNull(),
433
+ /**
434
+ * Template name used (if any)
435
+ */
436
+ templateName: text("template_name"),
437
+ /**
438
+ * Template data used for rendering (JSON)
439
+ */
440
+ templateData: jsonb("template_data"),
441
+ /**
442
+ * Subject (for email) or title
443
+ */
444
+ subject: text("subject"),
445
+ /**
446
+ * Rendered content (text version)
447
+ */
448
+ content: text("content"),
449
+ /**
450
+ * Current status
451
+ */
452
+ status: text("status", {
453
+ enum: NOTIFICATION_STATUSES
454
+ }).notNull().default("pending"),
455
+ /**
456
+ * Provider message ID (for tracking delivery)
457
+ */
458
+ providerMessageId: text("provider_message_id"),
459
+ /**
460
+ * Provider name used (aws-ses, aws-sns, etc.)
461
+ */
462
+ providerName: text("provider_name"),
463
+ /**
464
+ * Error message if failed
465
+ */
466
+ errorMessage: text("error_message"),
467
+ /**
468
+ * Scheduled send time (for delayed notifications)
469
+ */
470
+ scheduledAt: utcTimestamp("scheduled_at"),
471
+ /**
472
+ * Actual send time
473
+ */
474
+ sentAt: utcTimestamp("sent_at"),
475
+ /**
476
+ * pg-boss job ID (for scheduled notifications, enables cancellation)
477
+ */
478
+ jobId: text("job_id"),
479
+ /**
480
+ * Batch ID (for bulk operations)
481
+ */
482
+ batchId: text("batch_id"),
483
+ /**
484
+ * Reference to related entity (e.g., user_id, order_id)
485
+ */
486
+ referenceType: text("reference_type"),
487
+ referenceId: text("reference_id"),
488
+ ...timestamps()
489
+ },
490
+ (table) => [
491
+ index("noti_channel_idx").on(table.channel),
492
+ index("noti_status_idx").on(table.status),
493
+ index("noti_recipient_idx").on(table.recipient),
494
+ index("noti_created_at_idx").on(table.createdAt),
495
+ index("noti_scheduled_at_idx").on(table.scheduledAt),
496
+ index("noti_job_id_idx").on(table.jobId),
497
+ index("noti_batch_id_idx").on(table.batchId),
498
+ index("noti_reference_idx").on(table.referenceType, table.referenceId)
499
+ ]
500
+ );
501
+
502
+ // src/services/notification.service.ts
503
+ async function createNotificationRecord(data) {
504
+ return await create(notifications, {
505
+ ...data,
506
+ status: "pending"
507
+ });
508
+ }
509
+ async function createScheduledNotification(data) {
510
+ return await create(notifications, {
511
+ ...data,
512
+ status: "scheduled"
513
+ });
514
+ }
515
+ async function updateNotificationJobId(id2, jobId) {
516
+ return await updateOne(notifications, { id: id2 }, { jobId });
517
+ }
518
+ async function markNotificationSent(id2, providerMessageId) {
519
+ return await updateOne(
520
+ notifications,
521
+ { id: id2 },
522
+ {
523
+ status: "sent",
524
+ sentAt: /* @__PURE__ */ new Date(),
525
+ providerMessageId
526
+ }
527
+ );
528
+ }
529
+ async function markNotificationFailed(id2, errorMessage) {
530
+ return await updateOne(
531
+ notifications,
532
+ { id: id2 },
533
+ {
534
+ status: "failed",
535
+ errorMessage
536
+ }
537
+ );
538
+ }
539
+ async function markNotificationPending(id2) {
540
+ return await updateOne(
541
+ notifications,
542
+ { id: id2 },
543
+ { status: "pending" }
544
+ );
545
+ }
546
+ async function cancelScheduledNotification(id2) {
547
+ return await updateOne(
548
+ notifications,
549
+ { id: id2 },
550
+ { status: "cancelled" }
551
+ );
552
+ }
553
+ async function findNotificationByJobId(jobId) {
554
+ return await findOne(notifications, { jobId });
555
+ }
556
+ async function findNotifications(options = {}) {
557
+ const conditions = [];
558
+ if (options.channel) {
559
+ conditions.push(eq(notifications.channel, options.channel));
560
+ }
561
+ if (options.status) {
562
+ conditions.push(eq(notifications.status, options.status));
563
+ }
564
+ if (options.recipient) {
565
+ conditions.push(eq(notifications.recipient, options.recipient));
566
+ }
567
+ if (options.referenceType) {
568
+ conditions.push(eq(notifications.referenceType, options.referenceType));
569
+ }
570
+ if (options.referenceId) {
571
+ conditions.push(eq(notifications.referenceId, options.referenceId));
572
+ }
573
+ if (options.from) {
574
+ conditions.push(gte(notifications.createdAt, options.from));
575
+ }
576
+ if (options.to) {
577
+ conditions.push(lte(notifications.createdAt, options.to));
578
+ }
579
+ return await findMany(notifications, {
580
+ where: conditions.length > 0 ? and(...conditions) : void 0,
581
+ orderBy: desc(notifications.createdAt),
582
+ limit: options.limit,
583
+ offset: options.offset
584
+ });
585
+ }
586
+ async function countNotifications(options = {}) {
587
+ const conditions = [];
588
+ if (options.channel) {
589
+ conditions.push(eq(notifications.channel, options.channel));
590
+ }
591
+ if (options.status) {
592
+ conditions.push(eq(notifications.status, options.status));
593
+ }
594
+ if (options.recipient) {
595
+ conditions.push(eq(notifications.recipient, options.recipient));
596
+ }
597
+ if (conditions.length > 0) {
598
+ return await count(notifications, and(...conditions));
599
+ }
600
+ return await count(notifications);
601
+ }
602
+ async function getNotificationStats(options = {}) {
603
+ const [total, scheduled, pending, sent, failed, cancelled] = await Promise.all([
604
+ countNotifications(options),
605
+ countNotifications({ ...options, status: "scheduled" }),
606
+ countNotifications({ ...options, status: "pending" }),
607
+ countNotifications({ ...options, status: "sent" }),
608
+ countNotifications({ ...options, status: "failed" }),
609
+ countNotifications({ ...options, status: "cancelled" })
610
+ ]);
611
+ return { total, scheduled, pending, sent, failed, cancelled };
612
+ }
613
+ async function findScheduledNotifications(options = {}) {
614
+ const conditions = [eq(notifications.status, "scheduled")];
615
+ if (options.channel) {
616
+ conditions.push(eq(notifications.channel, options.channel));
617
+ }
618
+ if (options.from) {
619
+ conditions.push(gte(notifications.scheduledAt, options.from));
620
+ }
621
+ if (options.to) {
622
+ conditions.push(lte(notifications.scheduledAt, options.to));
623
+ }
624
+ return await findMany(notifications, {
625
+ where: and(...conditions),
626
+ orderBy: desc(notifications.scheduledAt),
627
+ limit: options.limit,
628
+ offset: options.offset
629
+ });
630
+ }
631
+
632
+ // src/channels/email/index.ts
633
+ var providers = {
634
+ "aws-ses": awsSesProvider
635
+ };
636
+ function registerEmailProvider(provider) {
637
+ providers[provider.name] = provider;
638
+ }
639
+ function getProvider() {
640
+ const providerName = env.SPFN_NOTIFICATION_EMAIL_PROVIDER || "aws-ses";
641
+ const provider = providers[providerName];
642
+ if (!provider) {
643
+ throw new Error(`Email provider not found: ${providerName}`);
644
+ }
645
+ return provider;
646
+ }
647
+ async function sendEmail(params) {
648
+ const recipients = Array.isArray(params.to) ? params.to : [params.to];
649
+ let subject = params.subject;
650
+ let text2 = params.text;
651
+ let html = params.html;
652
+ if (params.template) {
653
+ if (!hasTemplate(params.template)) {
654
+ return {
655
+ success: false,
656
+ error: `Template not found: ${params.template}`
657
+ };
658
+ }
659
+ const rendered = renderTemplate(params.template, params.data || {}, "email");
660
+ if (rendered.email) {
661
+ subject = rendered.email.subject;
662
+ text2 = rendered.email.text;
663
+ html = rendered.email.html;
664
+ }
665
+ }
666
+ if (!subject) {
667
+ return {
668
+ success: false,
669
+ error: "Email subject is required"
670
+ };
671
+ }
672
+ if (!text2 && !html) {
673
+ return {
674
+ success: false,
675
+ error: "Email content (text or html) is required"
676
+ };
677
+ }
678
+ const internalParams = {
679
+ to: recipients,
680
+ from: params.from || getEmailFrom(),
681
+ replyTo: params.replyTo || getEmailReplyTo(),
682
+ subject,
683
+ text: text2,
684
+ html
685
+ };
686
+ const provider = getProvider();
687
+ let historyId;
688
+ if (isHistoryEnabled()) {
689
+ try {
690
+ const record = await createNotificationRecord({
691
+ channel: "email",
692
+ recipient: recipients.join(","),
693
+ templateName: params.template,
694
+ templateData: params.data,
695
+ subject,
696
+ content: text2,
697
+ providerName: provider.name
698
+ });
699
+ historyId = record.id;
700
+ } catch {
701
+ }
702
+ }
703
+ const result = await provider.send(internalParams);
704
+ if (historyId && isHistoryEnabled()) {
705
+ try {
706
+ if (result.success) {
707
+ await markNotificationSent(historyId, result.messageId);
708
+ } else {
709
+ await markNotificationFailed(historyId, result.error || "Unknown error");
710
+ }
711
+ } catch {
712
+ }
713
+ }
714
+ return result;
715
+ }
716
+ async function sendEmailBulk(items) {
717
+ const results = [];
718
+ let successCount = 0;
719
+ let failureCount = 0;
720
+ for (const item of items) {
721
+ const result = await sendEmail(item);
722
+ results.push(result);
723
+ if (result.success) {
724
+ successCount++;
725
+ } else {
726
+ failureCount++;
727
+ }
728
+ }
729
+ return { results, successCount, failureCount };
730
+ }
731
+
732
+ // src/channels/sms/providers/aws-sns.ts
733
+ var snsClient = null;
734
+ async function getSNSClient() {
735
+ if (snsClient) {
736
+ return snsClient;
737
+ }
738
+ try {
739
+ const { SNSClient } = await import("@aws-sdk/client-sns");
740
+ snsClient = new SNSClient({
741
+ region: env.AWS_REGION,
742
+ credentials: env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY ? {
743
+ accessKeyId: env.AWS_ACCESS_KEY_ID,
744
+ secretAccessKey: env.AWS_SECRET_ACCESS_KEY
745
+ } : void 0
746
+ });
747
+ return snsClient;
748
+ } catch {
749
+ throw new Error(
750
+ "@aws-sdk/client-sns is not installed. Please install it: pnpm add @aws-sdk/client-sns"
751
+ );
752
+ }
753
+ }
754
+ var awsSnsProvider = {
755
+ name: "aws-sns",
756
+ async send(params) {
757
+ try {
758
+ const client = await getSNSClient();
759
+ const { PublishCommand } = await import("@aws-sdk/client-sns");
760
+ const command = new PublishCommand({
761
+ PhoneNumber: params.to,
762
+ Message: params.message,
763
+ MessageAttributes: {
764
+ "AWS.SNS.SMS.SMSType": {
765
+ DataType: "String",
766
+ StringValue: "Transactional"
767
+ }
768
+ }
769
+ });
770
+ const response = await client.send(command);
771
+ return {
772
+ success: true,
773
+ messageId: response.MessageId
774
+ };
775
+ } catch (error) {
776
+ const err = error;
777
+ return {
778
+ success: false,
779
+ error: err.message
780
+ };
781
+ }
782
+ }
783
+ };
784
+
785
+ // src/channels/sms/utils.ts
786
+ function normalizePhoneNumber(phone, defaultCountryCode) {
787
+ let normalized = phone.replace(/[^\d+]/g, "");
788
+ if (!normalized.startsWith("+")) {
789
+ const countryCode = defaultCountryCode ?? getSmsDefaultCountryCode();
790
+ if (normalized.startsWith("0")) {
791
+ normalized = normalized.slice(1);
792
+ }
793
+ normalized = countryCode + normalized;
794
+ }
795
+ return normalized;
796
+ }
797
+
798
+ // src/channels/sms/index.ts
799
+ var providers2 = {
800
+ "aws-sns": awsSnsProvider
801
+ };
802
+ function registerSMSProvider(provider) {
803
+ providers2[provider.name] = provider;
804
+ }
805
+ function getProvider2() {
806
+ const providerName = env.SPFN_NOTIFICATION_SMS_PROVIDER || "aws-sns";
807
+ const provider = providers2[providerName];
808
+ if (!provider) {
809
+ throw new Error(`SMS provider not found: ${providerName}`);
810
+ }
811
+ return provider;
812
+ }
813
+ async function sendSMS(params) {
814
+ const recipients = Array.isArray(params.to) ? params.to : [params.to];
815
+ let message = params.message;
816
+ if (params.template) {
817
+ if (!hasTemplate(params.template)) {
818
+ return {
819
+ success: false,
820
+ error: `Template not found: ${params.template}`
821
+ };
822
+ }
823
+ const rendered = renderTemplate(params.template, params.data || {}, "sms");
824
+ if (rendered.sms) {
825
+ message = rendered.sms.message;
826
+ }
827
+ }
828
+ if (!message) {
829
+ return {
830
+ success: false,
831
+ error: "SMS message is required"
832
+ };
833
+ }
834
+ const provider = getProvider2();
835
+ const results = [];
836
+ for (const recipient of recipients) {
837
+ const normalizedPhone = normalizePhoneNumber(recipient);
838
+ const internalParams = {
839
+ to: normalizedPhone,
840
+ message
841
+ };
842
+ let historyId;
843
+ if (isHistoryEnabled()) {
844
+ try {
845
+ const record = await createNotificationRecord({
846
+ channel: "sms",
847
+ recipient: normalizedPhone,
848
+ templateName: params.template,
849
+ templateData: params.data,
850
+ content: message,
851
+ providerName: provider.name
852
+ });
853
+ historyId = record.id;
854
+ } catch {
855
+ }
856
+ }
857
+ const result = await provider.send(internalParams);
858
+ if (historyId && isHistoryEnabled()) {
859
+ try {
860
+ if (result.success) {
861
+ await markNotificationSent(historyId, result.messageId);
862
+ } else {
863
+ await markNotificationFailed(historyId, result.error || "Unknown error");
864
+ }
865
+ } catch {
866
+ }
867
+ }
868
+ results.push(result);
869
+ }
870
+ const allSuccess = results.every((r) => r.success);
871
+ const messageIds = results.filter((r) => r.messageId).map((r) => r.messageId).join(",");
872
+ const errors = results.filter((r) => r.error).map((r) => r.error).join("; ");
873
+ return {
874
+ success: allSuccess,
875
+ messageId: messageIds || void 0,
876
+ error: errors || void 0
877
+ };
878
+ }
879
+ async function sendSMSBulk(items) {
880
+ const results = [];
881
+ let successCount = 0;
882
+ let failureCount = 0;
883
+ for (const item of items) {
884
+ const result = await sendSMS(item);
885
+ results.push(result);
886
+ if (result.success) {
887
+ successCount++;
888
+ } else {
889
+ failureCount++;
890
+ }
891
+ }
892
+ return { results, successCount, failureCount };
893
+ }
894
+
895
+ // src/jobs/send-scheduled-email.ts
896
+ import { job } from "@spfn/core/job";
897
+
898
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
899
+ var value_exports = {};
900
+ __export(value_exports, {
901
+ HasPropertyKey: () => HasPropertyKey,
902
+ IsArray: () => IsArray,
903
+ IsAsyncIterator: () => IsAsyncIterator,
904
+ IsBigInt: () => IsBigInt,
905
+ IsBoolean: () => IsBoolean,
906
+ IsDate: () => IsDate,
907
+ IsFunction: () => IsFunction,
908
+ IsIterator: () => IsIterator,
909
+ IsNull: () => IsNull,
910
+ IsNumber: () => IsNumber,
911
+ IsObject: () => IsObject,
912
+ IsRegExp: () => IsRegExp,
913
+ IsString: () => IsString,
914
+ IsSymbol: () => IsSymbol,
915
+ IsUint8Array: () => IsUint8Array,
916
+ IsUndefined: () => IsUndefined
917
+ });
918
+ function HasPropertyKey(value, key) {
919
+ return key in value;
920
+ }
921
+ function IsAsyncIterator(value) {
922
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
923
+ }
924
+ function IsArray(value) {
925
+ return Array.isArray(value);
926
+ }
927
+ function IsBigInt(value) {
928
+ return typeof value === "bigint";
929
+ }
930
+ function IsBoolean(value) {
931
+ return typeof value === "boolean";
932
+ }
933
+ function IsDate(value) {
934
+ return value instanceof globalThis.Date;
935
+ }
936
+ function IsFunction(value) {
937
+ return typeof value === "function";
938
+ }
939
+ function IsIterator(value) {
940
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
941
+ }
942
+ function IsNull(value) {
943
+ return value === null;
944
+ }
945
+ function IsNumber(value) {
946
+ return typeof value === "number";
947
+ }
948
+ function IsObject(value) {
949
+ return typeof value === "object" && value !== null;
950
+ }
951
+ function IsRegExp(value) {
952
+ return value instanceof globalThis.RegExp;
953
+ }
954
+ function IsString(value) {
955
+ return typeof value === "string";
956
+ }
957
+ function IsSymbol(value) {
958
+ return typeof value === "symbol";
959
+ }
960
+ function IsUint8Array(value) {
961
+ return value instanceof globalThis.Uint8Array;
962
+ }
963
+ function IsUndefined(value) {
964
+ return value === void 0;
965
+ }
966
+
967
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
968
+ function ArrayType(value) {
969
+ return value.map((value2) => Visit(value2));
970
+ }
971
+ function DateType(value) {
972
+ return new Date(value.getTime());
973
+ }
974
+ function Uint8ArrayType(value) {
975
+ return new Uint8Array(value);
976
+ }
977
+ function RegExpType(value) {
978
+ return new RegExp(value.source, value.flags);
979
+ }
980
+ function ObjectType(value) {
981
+ const result = {};
982
+ for (const key of Object.getOwnPropertyNames(value)) {
983
+ result[key] = Visit(value[key]);
984
+ }
985
+ for (const key of Object.getOwnPropertySymbols(value)) {
986
+ result[key] = Visit(value[key]);
987
+ }
988
+ return result;
989
+ }
990
+ function Visit(value) {
991
+ return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
992
+ }
993
+ function Clone(value) {
994
+ return Visit(value);
995
+ }
996
+
997
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
998
+ function CloneType(schema, options) {
999
+ return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
1000
+ }
1001
+
1002
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
1003
+ function IsObject2(value) {
1004
+ return value !== null && typeof value === "object";
1005
+ }
1006
+ function IsArray2(value) {
1007
+ return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
1008
+ }
1009
+ function IsUndefined2(value) {
1010
+ return value === void 0;
1011
+ }
1012
+ function IsNumber2(value) {
1013
+ return typeof value === "number";
1014
+ }
1015
+
1016
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/system/policy.mjs
1017
+ var TypeSystemPolicy;
1018
+ (function(TypeSystemPolicy2) {
1019
+ TypeSystemPolicy2.InstanceMode = "default";
1020
+ TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
1021
+ TypeSystemPolicy2.AllowArrayObject = false;
1022
+ TypeSystemPolicy2.AllowNaN = false;
1023
+ TypeSystemPolicy2.AllowNullVoid = false;
1024
+ function IsExactOptionalProperty(value, key) {
1025
+ return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
1026
+ }
1027
+ TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
1028
+ function IsObjectLike(value) {
1029
+ const isObject = IsObject2(value);
1030
+ return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
1031
+ }
1032
+ TypeSystemPolicy2.IsObjectLike = IsObjectLike;
1033
+ function IsRecordLike(value) {
1034
+ return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
1035
+ }
1036
+ TypeSystemPolicy2.IsRecordLike = IsRecordLike;
1037
+ function IsNumberLike(value) {
1038
+ return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
1039
+ }
1040
+ TypeSystemPolicy2.IsNumberLike = IsNumberLike;
1041
+ function IsVoidLike(value) {
1042
+ const isUndefined = IsUndefined2(value);
1043
+ return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
1044
+ }
1045
+ TypeSystemPolicy2.IsVoidLike = IsVoidLike;
1046
+ })(TypeSystemPolicy || (TypeSystemPolicy = {}));
1047
+
1048
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
1049
+ function ImmutableArray(value) {
1050
+ return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
1051
+ }
1052
+ function ImmutableDate(value) {
1053
+ return value;
1054
+ }
1055
+ function ImmutableUint8Array(value) {
1056
+ return value;
1057
+ }
1058
+ function ImmutableRegExp(value) {
1059
+ return value;
1060
+ }
1061
+ function ImmutableObject(value) {
1062
+ const result = {};
1063
+ for (const key of Object.getOwnPropertyNames(value)) {
1064
+ result[key] = Immutable(value[key]);
1065
+ }
1066
+ for (const key of Object.getOwnPropertySymbols(value)) {
1067
+ result[key] = Immutable(value[key]);
1068
+ }
1069
+ return globalThis.Object.freeze(result);
1070
+ }
1071
+ function Immutable(value) {
1072
+ return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
1073
+ }
1074
+
1075
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
1076
+ function CreateType(schema, options) {
1077
+ const result = options !== void 0 ? { ...options, ...schema } : schema;
1078
+ switch (TypeSystemPolicy.InstanceMode) {
1079
+ case "freeze":
1080
+ return Immutable(result);
1081
+ case "clone":
1082
+ return Clone(result);
1083
+ default:
1084
+ return result;
1085
+ }
1086
+ }
1087
+
1088
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
1089
+ var TypeBoxError = class extends Error {
1090
+ constructor(message) {
1091
+ super(message);
1092
+ }
1093
+ };
1094
+
1095
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
1096
+ var TransformKind = Symbol.for("TypeBox.Transform");
1097
+ var ReadonlyKind = Symbol.for("TypeBox.Readonly");
1098
+ var OptionalKind = Symbol.for("TypeBox.Optional");
1099
+ var Hint = Symbol.for("TypeBox.Hint");
1100
+ var Kind = Symbol.for("TypeBox.Kind");
1101
+
1102
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
1103
+ function IsReadonly(value) {
1104
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
1105
+ }
1106
+ function IsOptional(value) {
1107
+ return IsObject(value) && value[OptionalKind] === "Optional";
1108
+ }
1109
+ function IsAny(value) {
1110
+ return IsKindOf(value, "Any");
1111
+ }
1112
+ function IsArgument(value) {
1113
+ return IsKindOf(value, "Argument");
1114
+ }
1115
+ function IsArray3(value) {
1116
+ return IsKindOf(value, "Array");
1117
+ }
1118
+ function IsAsyncIterator2(value) {
1119
+ return IsKindOf(value, "AsyncIterator");
1120
+ }
1121
+ function IsBigInt2(value) {
1122
+ return IsKindOf(value, "BigInt");
1123
+ }
1124
+ function IsBoolean2(value) {
1125
+ return IsKindOf(value, "Boolean");
1126
+ }
1127
+ function IsComputed(value) {
1128
+ return IsKindOf(value, "Computed");
1129
+ }
1130
+ function IsConstructor(value) {
1131
+ return IsKindOf(value, "Constructor");
1132
+ }
1133
+ function IsDate2(value) {
1134
+ return IsKindOf(value, "Date");
1135
+ }
1136
+ function IsFunction2(value) {
1137
+ return IsKindOf(value, "Function");
1138
+ }
1139
+ function IsInteger(value) {
1140
+ return IsKindOf(value, "Integer");
1141
+ }
1142
+ function IsIntersect(value) {
1143
+ return IsKindOf(value, "Intersect");
1144
+ }
1145
+ function IsIterator2(value) {
1146
+ return IsKindOf(value, "Iterator");
1147
+ }
1148
+ function IsKindOf(value, kind) {
1149
+ return IsObject(value) && Kind in value && value[Kind] === kind;
1150
+ }
1151
+ function IsLiteralValue(value) {
1152
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
1153
+ }
1154
+ function IsLiteral(value) {
1155
+ return IsKindOf(value, "Literal");
1156
+ }
1157
+ function IsMappedKey(value) {
1158
+ return IsKindOf(value, "MappedKey");
1159
+ }
1160
+ function IsMappedResult(value) {
1161
+ return IsKindOf(value, "MappedResult");
1162
+ }
1163
+ function IsNever(value) {
1164
+ return IsKindOf(value, "Never");
1165
+ }
1166
+ function IsNot(value) {
1167
+ return IsKindOf(value, "Not");
1168
+ }
1169
+ function IsNull2(value) {
1170
+ return IsKindOf(value, "Null");
1171
+ }
1172
+ function IsNumber3(value) {
1173
+ return IsKindOf(value, "Number");
1174
+ }
1175
+ function IsObject3(value) {
1176
+ return IsKindOf(value, "Object");
1177
+ }
1178
+ function IsPromise(value) {
1179
+ return IsKindOf(value, "Promise");
1180
+ }
1181
+ function IsRecord(value) {
1182
+ return IsKindOf(value, "Record");
1183
+ }
1184
+ function IsRef(value) {
1185
+ return IsKindOf(value, "Ref");
1186
+ }
1187
+ function IsRegExp2(value) {
1188
+ return IsKindOf(value, "RegExp");
1189
+ }
1190
+ function IsString2(value) {
1191
+ return IsKindOf(value, "String");
1192
+ }
1193
+ function IsSymbol2(value) {
1194
+ return IsKindOf(value, "Symbol");
1195
+ }
1196
+ function IsTemplateLiteral(value) {
1197
+ return IsKindOf(value, "TemplateLiteral");
1198
+ }
1199
+ function IsThis(value) {
1200
+ return IsKindOf(value, "This");
1201
+ }
1202
+ function IsTransform(value) {
1203
+ return IsObject(value) && TransformKind in value;
1204
+ }
1205
+ function IsTuple(value) {
1206
+ return IsKindOf(value, "Tuple");
1207
+ }
1208
+ function IsUndefined3(value) {
1209
+ return IsKindOf(value, "Undefined");
1210
+ }
1211
+ function IsUnion(value) {
1212
+ return IsKindOf(value, "Union");
1213
+ }
1214
+ function IsUint8Array2(value) {
1215
+ return IsKindOf(value, "Uint8Array");
1216
+ }
1217
+ function IsUnknown(value) {
1218
+ return IsKindOf(value, "Unknown");
1219
+ }
1220
+ function IsUnsafe(value) {
1221
+ return IsKindOf(value, "Unsafe");
1222
+ }
1223
+ function IsVoid(value) {
1224
+ return IsKindOf(value, "Void");
1225
+ }
1226
+ function IsKind(value) {
1227
+ return IsObject(value) && Kind in value && IsString(value[Kind]);
1228
+ }
1229
+ function IsSchema(value) {
1230
+ return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean2(value) || IsBigInt2(value) || IsAsyncIterator2(value) || IsComputed(value) || IsConstructor(value) || IsDate2(value) || IsFunction2(value) || IsInteger(value) || IsIntersect(value) || IsIterator2(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull2(value) || IsNumber3(value) || IsObject3(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString2(value) || IsSymbol2(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array2(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
1231
+ }
1232
+
1233
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
1234
+ var type_exports = {};
1235
+ __export(type_exports, {
1236
+ IsAny: () => IsAny2,
1237
+ IsArgument: () => IsArgument2,
1238
+ IsArray: () => IsArray4,
1239
+ IsAsyncIterator: () => IsAsyncIterator3,
1240
+ IsBigInt: () => IsBigInt3,
1241
+ IsBoolean: () => IsBoolean3,
1242
+ IsComputed: () => IsComputed2,
1243
+ IsConstructor: () => IsConstructor2,
1244
+ IsDate: () => IsDate3,
1245
+ IsFunction: () => IsFunction3,
1246
+ IsImport: () => IsImport,
1247
+ IsInteger: () => IsInteger2,
1248
+ IsIntersect: () => IsIntersect2,
1249
+ IsIterator: () => IsIterator3,
1250
+ IsKind: () => IsKind2,
1251
+ IsKindOf: () => IsKindOf2,
1252
+ IsLiteral: () => IsLiteral2,
1253
+ IsLiteralBoolean: () => IsLiteralBoolean,
1254
+ IsLiteralNumber: () => IsLiteralNumber,
1255
+ IsLiteralString: () => IsLiteralString,
1256
+ IsLiteralValue: () => IsLiteralValue2,
1257
+ IsMappedKey: () => IsMappedKey2,
1258
+ IsMappedResult: () => IsMappedResult2,
1259
+ IsNever: () => IsNever2,
1260
+ IsNot: () => IsNot2,
1261
+ IsNull: () => IsNull3,
1262
+ IsNumber: () => IsNumber4,
1263
+ IsObject: () => IsObject4,
1264
+ IsOptional: () => IsOptional2,
1265
+ IsPromise: () => IsPromise2,
1266
+ IsProperties: () => IsProperties,
1267
+ IsReadonly: () => IsReadonly2,
1268
+ IsRecord: () => IsRecord2,
1269
+ IsRecursive: () => IsRecursive,
1270
+ IsRef: () => IsRef2,
1271
+ IsRegExp: () => IsRegExp3,
1272
+ IsSchema: () => IsSchema2,
1273
+ IsString: () => IsString3,
1274
+ IsSymbol: () => IsSymbol3,
1275
+ IsTemplateLiteral: () => IsTemplateLiteral2,
1276
+ IsThis: () => IsThis2,
1277
+ IsTransform: () => IsTransform2,
1278
+ IsTuple: () => IsTuple2,
1279
+ IsUint8Array: () => IsUint8Array3,
1280
+ IsUndefined: () => IsUndefined4,
1281
+ IsUnion: () => IsUnion2,
1282
+ IsUnionLiteral: () => IsUnionLiteral,
1283
+ IsUnknown: () => IsUnknown2,
1284
+ IsUnsafe: () => IsUnsafe2,
1285
+ IsVoid: () => IsVoid2,
1286
+ TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
1287
+ });
1288
+ var TypeGuardUnknownTypeError = class extends TypeBoxError {
1289
+ };
1290
+ var KnownTypes = [
1291
+ "Argument",
1292
+ "Any",
1293
+ "Array",
1294
+ "AsyncIterator",
1295
+ "BigInt",
1296
+ "Boolean",
1297
+ "Computed",
1298
+ "Constructor",
1299
+ "Date",
1300
+ "Enum",
1301
+ "Function",
1302
+ "Integer",
1303
+ "Intersect",
1304
+ "Iterator",
1305
+ "Literal",
1306
+ "MappedKey",
1307
+ "MappedResult",
1308
+ "Not",
1309
+ "Null",
1310
+ "Number",
1311
+ "Object",
1312
+ "Promise",
1313
+ "Record",
1314
+ "Ref",
1315
+ "RegExp",
1316
+ "String",
1317
+ "Symbol",
1318
+ "TemplateLiteral",
1319
+ "This",
1320
+ "Tuple",
1321
+ "Undefined",
1322
+ "Union",
1323
+ "Uint8Array",
1324
+ "Unknown",
1325
+ "Void"
1326
+ ];
1327
+ function IsPattern(value) {
1328
+ try {
1329
+ new RegExp(value);
1330
+ return true;
1331
+ } catch {
1332
+ return false;
1333
+ }
1334
+ }
1335
+ function IsControlCharacterFree(value) {
1336
+ if (!IsString(value))
1337
+ return false;
1338
+ for (let i = 0; i < value.length; i++) {
1339
+ const code = value.charCodeAt(i);
1340
+ if (code >= 7 && code <= 13 || code === 27 || code === 127) {
1341
+ return false;
1342
+ }
1343
+ }
1344
+ return true;
1345
+ }
1346
+ function IsAdditionalProperties(value) {
1347
+ return IsOptionalBoolean(value) || IsSchema2(value);
1348
+ }
1349
+ function IsOptionalBigInt(value) {
1350
+ return IsUndefined(value) || IsBigInt(value);
1351
+ }
1352
+ function IsOptionalNumber(value) {
1353
+ return IsUndefined(value) || IsNumber(value);
1354
+ }
1355
+ function IsOptionalBoolean(value) {
1356
+ return IsUndefined(value) || IsBoolean(value);
1357
+ }
1358
+ function IsOptionalString(value) {
1359
+ return IsUndefined(value) || IsString(value);
1360
+ }
1361
+ function IsOptionalPattern(value) {
1362
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
1363
+ }
1364
+ function IsOptionalFormat(value) {
1365
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
1366
+ }
1367
+ function IsOptionalSchema(value) {
1368
+ return IsUndefined(value) || IsSchema2(value);
1369
+ }
1370
+ function IsReadonly2(value) {
1371
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
1372
+ }
1373
+ function IsOptional2(value) {
1374
+ return IsObject(value) && value[OptionalKind] === "Optional";
1375
+ }
1376
+ function IsAny2(value) {
1377
+ return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
1378
+ }
1379
+ function IsArgument2(value) {
1380
+ return IsKindOf2(value, "Argument") && IsNumber(value.index);
1381
+ }
1382
+ function IsArray4(value) {
1383
+ return IsKindOf2(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema2(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
1384
+ }
1385
+ function IsAsyncIterator3(value) {
1386
+ return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
1387
+ }
1388
+ function IsBigInt3(value) {
1389
+ return IsKindOf2(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
1390
+ }
1391
+ function IsBoolean3(value) {
1392
+ return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
1393
+ }
1394
+ function IsComputed2(value) {
1395
+ return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
1396
+ }
1397
+ function IsConstructor2(value) {
1398
+ return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
1399
+ }
1400
+ function IsDate3(value) {
1401
+ return IsKindOf2(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
1402
+ }
1403
+ function IsFunction3(value) {
1404
+ return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
1405
+ }
1406
+ function IsImport(value) {
1407
+ return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
1408
+ }
1409
+ function IsInteger2(value) {
1410
+ return IsKindOf2(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
1411
+ }
1412
+ function IsProperties(value) {
1413
+ return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
1414
+ }
1415
+ function IsIntersect2(value) {
1416
+ return IsKindOf2(value, "Intersect") && (IsString(value.type) && value.type !== "object" ? false : true) && IsArray(value.allOf) && value.allOf.every((schema) => IsSchema2(schema) && !IsTransform2(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
1417
+ }
1418
+ function IsIterator3(value) {
1419
+ return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
1420
+ }
1421
+ function IsKindOf2(value, kind) {
1422
+ return IsObject(value) && Kind in value && value[Kind] === kind;
1423
+ }
1424
+ function IsLiteralString(value) {
1425
+ return IsLiteral2(value) && IsString(value.const);
1426
+ }
1427
+ function IsLiteralNumber(value) {
1428
+ return IsLiteral2(value) && IsNumber(value.const);
1429
+ }
1430
+ function IsLiteralBoolean(value) {
1431
+ return IsLiteral2(value) && IsBoolean(value.const);
1432
+ }
1433
+ function IsLiteral2(value) {
1434
+ return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
1435
+ }
1436
+ function IsLiteralValue2(value) {
1437
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
1438
+ }
1439
+ function IsMappedKey2(value) {
1440
+ return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
1441
+ }
1442
+ function IsMappedResult2(value) {
1443
+ return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
1444
+ }
1445
+ function IsNever2(value) {
1446
+ return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
1447
+ }
1448
+ function IsNot2(value) {
1449
+ return IsKindOf2(value, "Not") && IsSchema2(value.not);
1450
+ }
1451
+ function IsNull3(value) {
1452
+ return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
1453
+ }
1454
+ function IsNumber4(value) {
1455
+ return IsKindOf2(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
1456
+ }
1457
+ function IsObject4(value) {
1458
+ return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
1459
+ }
1460
+ function IsPromise2(value) {
1461
+ return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
1462
+ }
1463
+ function IsRecord2(value) {
1464
+ return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
1465
+ const keys = Object.getOwnPropertyNames(schema.patternProperties);
1466
+ return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
1467
+ })(value);
1468
+ }
1469
+ function IsRecursive(value) {
1470
+ return IsObject(value) && Hint in value && value[Hint] === "Recursive";
1471
+ }
1472
+ function IsRef2(value) {
1473
+ return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
1474
+ }
1475
+ function IsRegExp3(value) {
1476
+ return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
1477
+ }
1478
+ function IsString3(value) {
1479
+ return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
1480
+ }
1481
+ function IsSymbol3(value) {
1482
+ return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
1483
+ }
1484
+ function IsTemplateLiteral2(value) {
1485
+ return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
1486
+ }
1487
+ function IsThis2(value) {
1488
+ return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
1489
+ }
1490
+ function IsTransform2(value) {
1491
+ return IsObject(value) && TransformKind in value;
1492
+ }
1493
+ function IsTuple2(value) {
1494
+ return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
1495
+ (IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
1496
+ }
1497
+ function IsUndefined4(value) {
1498
+ return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
1499
+ }
1500
+ function IsUnionLiteral(value) {
1501
+ return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
1502
+ }
1503
+ function IsUnion2(value) {
1504
+ return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
1505
+ }
1506
+ function IsUint8Array3(value) {
1507
+ return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
1508
+ }
1509
+ function IsUnknown2(value) {
1510
+ return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
1511
+ }
1512
+ function IsUnsafe2(value) {
1513
+ return IsKindOf2(value, "Unsafe");
1514
+ }
1515
+ function IsVoid2(value) {
1516
+ return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
1517
+ }
1518
+ function IsKind2(value) {
1519
+ return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
1520
+ }
1521
+ function IsSchema2(value) {
1522
+ return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed2(value) || IsConstructor2(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect2(value) || IsIterator3(value) || IsLiteral2(value) || IsMappedKey2(value) || IsMappedResult2(value) || IsNever2(value) || IsNot2(value) || IsNull3(value) || IsNumber4(value) || IsObject4(value) || IsPromise2(value) || IsRecord2(value) || IsRef2(value) || IsRegExp3(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral2(value) || IsThis2(value) || IsTuple2(value) || IsUndefined4(value) || IsUnion2(value) || IsUint8Array3(value) || IsUnknown2(value) || IsUnsafe2(value) || IsVoid2(value) || IsKind2(value));
1523
+ }
1524
+
1525
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
1526
+ var PatternBoolean = "(true|false)";
1527
+ var PatternNumber = "(0|[1-9][0-9]*)";
1528
+ var PatternString = "(.*)";
1529
+ var PatternNever = "(?!.*)";
1530
+ var PatternBooleanExact = `^${PatternBoolean}$`;
1531
+ var PatternNumberExact = `^${PatternNumber}$`;
1532
+ var PatternStringExact = `^${PatternString}$`;
1533
+ var PatternNeverExact = `^${PatternNever}$`;
1534
+
1535
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
1536
+ function SetIncludes(T, S) {
1537
+ return T.includes(S);
1538
+ }
1539
+ function SetDistinct(T) {
1540
+ return [...new Set(T)];
1541
+ }
1542
+ function SetIntersect(T, S) {
1543
+ return T.filter((L) => S.includes(L));
1544
+ }
1545
+ function SetIntersectManyResolve(T, Init) {
1546
+ return T.reduce((Acc, L) => {
1547
+ return SetIntersect(Acc, L);
1548
+ }, Init);
1549
+ }
1550
+ function SetIntersectMany(T) {
1551
+ return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
1552
+ }
1553
+ function SetUnionMany(T) {
1554
+ const Acc = [];
1555
+ for (const L of T)
1556
+ Acc.push(...L);
1557
+ return Acc;
1558
+ }
1559
+
1560
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
1561
+ function Any(options) {
1562
+ return CreateType({ [Kind]: "Any" }, options);
1563
+ }
1564
+
1565
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
1566
+ function Array2(items, options) {
1567
+ return CreateType({ [Kind]: "Array", type: "array", items }, options);
1568
+ }
1569
+
1570
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
1571
+ function Argument(index2) {
1572
+ return CreateType({ [Kind]: "Argument", index: index2 });
1573
+ }
1574
+
1575
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
1576
+ function AsyncIterator(items, options) {
1577
+ return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
1578
+ }
1579
+
1580
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
1581
+ function Computed(target, parameters, options) {
1582
+ return CreateType({ [Kind]: "Computed", target, parameters }, options);
1583
+ }
1584
+
1585
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
1586
+ function DiscardKey(value, key) {
1587
+ const { [key]: _, ...rest } = value;
1588
+ return rest;
1589
+ }
1590
+ function Discard(value, keys) {
1591
+ return keys.reduce((acc, key) => DiscardKey(acc, key), value);
1592
+ }
1593
+
1594
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
1595
+ function Never(options) {
1596
+ return CreateType({ [Kind]: "Never", not: {} }, options);
1597
+ }
1598
+
1599
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
1600
+ function MappedResult(properties) {
1601
+ return CreateType({
1602
+ [Kind]: "MappedResult",
1603
+ properties
1604
+ });
1605
+ }
1606
+
1607
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
1608
+ function Constructor(parameters, returns, options) {
1609
+ return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
1610
+ }
1611
+
1612
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
1613
+ function Function(parameters, returns, options) {
1614
+ return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
1615
+ }
1616
+
1617
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
1618
+ function UnionCreate(T, options) {
1619
+ return CreateType({ [Kind]: "Union", anyOf: T }, options);
1620
+ }
1621
+
1622
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
1623
+ function IsUnionOptional(types) {
1624
+ return types.some((type) => IsOptional(type));
1625
+ }
1626
+ function RemoveOptionalFromRest(types) {
1627
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
1628
+ }
1629
+ function RemoveOptionalFromType(T) {
1630
+ return Discard(T, [OptionalKind]);
1631
+ }
1632
+ function ResolveUnion(types, options) {
1633
+ const isOptional = IsUnionOptional(types);
1634
+ return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
1635
+ }
1636
+ function UnionEvaluated(T, options) {
1637
+ return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
1638
+ }
1639
+
1640
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
1641
+ function Union(types, options) {
1642
+ return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
1643
+ }
1644
+
1645
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
1646
+ var TemplateLiteralParserError = class extends TypeBoxError {
1647
+ };
1648
+ function Unescape(pattern) {
1649
+ return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
1650
+ }
1651
+ function IsNonEscaped(pattern, index2, char) {
1652
+ return pattern[index2] === char && pattern.charCodeAt(index2 - 1) !== 92;
1653
+ }
1654
+ function IsOpenParen(pattern, index2) {
1655
+ return IsNonEscaped(pattern, index2, "(");
1656
+ }
1657
+ function IsCloseParen(pattern, index2) {
1658
+ return IsNonEscaped(pattern, index2, ")");
1659
+ }
1660
+ function IsSeparator(pattern, index2) {
1661
+ return IsNonEscaped(pattern, index2, "|");
1662
+ }
1663
+ function IsGroup(pattern) {
1664
+ if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
1665
+ return false;
1666
+ let count2 = 0;
1667
+ for (let index2 = 0; index2 < pattern.length; index2++) {
1668
+ if (IsOpenParen(pattern, index2))
1669
+ count2 += 1;
1670
+ if (IsCloseParen(pattern, index2))
1671
+ count2 -= 1;
1672
+ if (count2 === 0 && index2 !== pattern.length - 1)
1673
+ return false;
1674
+ }
1675
+ return true;
1676
+ }
1677
+ function InGroup(pattern) {
1678
+ return pattern.slice(1, pattern.length - 1);
1679
+ }
1680
+ function IsPrecedenceOr(pattern) {
1681
+ let count2 = 0;
1682
+ for (let index2 = 0; index2 < pattern.length; index2++) {
1683
+ if (IsOpenParen(pattern, index2))
1684
+ count2 += 1;
1685
+ if (IsCloseParen(pattern, index2))
1686
+ count2 -= 1;
1687
+ if (IsSeparator(pattern, index2) && count2 === 0)
1688
+ return true;
1689
+ }
1690
+ return false;
1691
+ }
1692
+ function IsPrecedenceAnd(pattern) {
1693
+ for (let index2 = 0; index2 < pattern.length; index2++) {
1694
+ if (IsOpenParen(pattern, index2))
1695
+ return true;
1696
+ }
1697
+ return false;
1698
+ }
1699
+ function Or(pattern) {
1700
+ let [count2, start] = [0, 0];
1701
+ const expressions = [];
1702
+ for (let index2 = 0; index2 < pattern.length; index2++) {
1703
+ if (IsOpenParen(pattern, index2))
1704
+ count2 += 1;
1705
+ if (IsCloseParen(pattern, index2))
1706
+ count2 -= 1;
1707
+ if (IsSeparator(pattern, index2) && count2 === 0) {
1708
+ const range2 = pattern.slice(start, index2);
1709
+ if (range2.length > 0)
1710
+ expressions.push(TemplateLiteralParse(range2));
1711
+ start = index2 + 1;
1712
+ }
1713
+ }
1714
+ const range = pattern.slice(start);
1715
+ if (range.length > 0)
1716
+ expressions.push(TemplateLiteralParse(range));
1717
+ if (expressions.length === 0)
1718
+ return { type: "const", const: "" };
1719
+ if (expressions.length === 1)
1720
+ return expressions[0];
1721
+ return { type: "or", expr: expressions };
1722
+ }
1723
+ function And(pattern) {
1724
+ function Group(value, index2) {
1725
+ if (!IsOpenParen(value, index2))
1726
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
1727
+ let count2 = 0;
1728
+ for (let scan = index2; scan < value.length; scan++) {
1729
+ if (IsOpenParen(value, scan))
1730
+ count2 += 1;
1731
+ if (IsCloseParen(value, scan))
1732
+ count2 -= 1;
1733
+ if (count2 === 0)
1734
+ return [index2, scan];
1735
+ }
1736
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
1737
+ }
1738
+ function Range(pattern2, index2) {
1739
+ for (let scan = index2; scan < pattern2.length; scan++) {
1740
+ if (IsOpenParen(pattern2, scan))
1741
+ return [index2, scan];
1742
+ }
1743
+ return [index2, pattern2.length];
1744
+ }
1745
+ const expressions = [];
1746
+ for (let index2 = 0; index2 < pattern.length; index2++) {
1747
+ if (IsOpenParen(pattern, index2)) {
1748
+ const [start, end] = Group(pattern, index2);
1749
+ const range = pattern.slice(start, end + 1);
1750
+ expressions.push(TemplateLiteralParse(range));
1751
+ index2 = end;
1752
+ } else {
1753
+ const [start, end] = Range(pattern, index2);
1754
+ const range = pattern.slice(start, end);
1755
+ if (range.length > 0)
1756
+ expressions.push(TemplateLiteralParse(range));
1757
+ index2 = end - 1;
1758
+ }
1759
+ }
1760
+ return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
1761
+ }
1762
+ function TemplateLiteralParse(pattern) {
1763
+ return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
1764
+ }
1765
+ function TemplateLiteralParseExact(pattern) {
1766
+ return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
1767
+ }
1768
+
1769
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
1770
+ var TemplateLiteralFiniteError = class extends TypeBoxError {
1771
+ };
1772
+ function IsNumberExpression(expression) {
1773
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "0" && expression.expr[1].type === "const" && expression.expr[1].const === "[1-9][0-9]*";
1774
+ }
1775
+ function IsBooleanExpression(expression) {
1776
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "true" && expression.expr[1].type === "const" && expression.expr[1].const === "false";
1777
+ }
1778
+ function IsStringExpression(expression) {
1779
+ return expression.type === "const" && expression.const === ".*";
1780
+ }
1781
+ function IsTemplateLiteralExpressionFinite(expression) {
1782
+ return IsNumberExpression(expression) || IsStringExpression(expression) ? false : IsBooleanExpression(expression) ? true : expression.type === "and" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "or" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "const" ? true : (() => {
1783
+ throw new TemplateLiteralFiniteError(`Unknown expression type`);
1784
+ })();
1785
+ }
1786
+ function IsTemplateLiteralFinite(schema) {
1787
+ const expression = TemplateLiteralParseExact(schema.pattern);
1788
+ return IsTemplateLiteralExpressionFinite(expression);
1789
+ }
1790
+
1791
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
1792
+ var TemplateLiteralGenerateError = class extends TypeBoxError {
1793
+ };
1794
+ function* GenerateReduce(buffer) {
1795
+ if (buffer.length === 1)
1796
+ return yield* buffer[0];
1797
+ for (const left of buffer[0]) {
1798
+ for (const right of GenerateReduce(buffer.slice(1))) {
1799
+ yield `${left}${right}`;
1800
+ }
1801
+ }
1802
+ }
1803
+ function* GenerateAnd(expression) {
1804
+ return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
1805
+ }
1806
+ function* GenerateOr(expression) {
1807
+ for (const expr of expression.expr)
1808
+ yield* TemplateLiteralExpressionGenerate(expr);
1809
+ }
1810
+ function* GenerateConst(expression) {
1811
+ return yield expression.const;
1812
+ }
1813
+ function* TemplateLiteralExpressionGenerate(expression) {
1814
+ return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
1815
+ throw new TemplateLiteralGenerateError("Unknown expression");
1816
+ })();
1817
+ }
1818
+ function TemplateLiteralGenerate(schema) {
1819
+ const expression = TemplateLiteralParseExact(schema.pattern);
1820
+ return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
1821
+ }
1822
+
1823
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
1824
+ function Literal(value, options) {
1825
+ return CreateType({
1826
+ [Kind]: "Literal",
1827
+ const: value,
1828
+ type: typeof value
1829
+ }, options);
1830
+ }
1831
+
1832
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
1833
+ function Boolean(options) {
1834
+ return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
1835
+ }
1836
+
1837
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
1838
+ function BigInt(options) {
1839
+ return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
1840
+ }
1841
+
1842
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
1843
+ function Number2(options) {
1844
+ return CreateType({ [Kind]: "Number", type: "number" }, options);
1845
+ }
1846
+
1847
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
1848
+ function String2(options) {
1849
+ return CreateType({ [Kind]: "String", type: "string" }, options);
1850
+ }
1851
+
1852
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
1853
+ function* FromUnion(syntax) {
1854
+ const trim = syntax.trim().replace(/"|'/g, "");
1855
+ return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
1856
+ const literals = trim.split("|").map((literal) => Literal(literal.trim()));
1857
+ return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
1858
+ })();
1859
+ }
1860
+ function* FromTerminal(syntax) {
1861
+ if (syntax[1] !== "{") {
1862
+ const L = Literal("$");
1863
+ const R = FromSyntax(syntax.slice(1));
1864
+ return yield* [L, ...R];
1865
+ }
1866
+ for (let i = 2; i < syntax.length; i++) {
1867
+ if (syntax[i] === "}") {
1868
+ const L = FromUnion(syntax.slice(2, i));
1869
+ const R = FromSyntax(syntax.slice(i + 1));
1870
+ return yield* [...L, ...R];
1871
+ }
1872
+ }
1873
+ yield Literal(syntax);
1874
+ }
1875
+ function* FromSyntax(syntax) {
1876
+ for (let i = 0; i < syntax.length; i++) {
1877
+ if (syntax[i] === "$") {
1878
+ const L = Literal(syntax.slice(0, i));
1879
+ const R = FromTerminal(syntax.slice(i));
1880
+ return yield* [L, ...R];
1881
+ }
1882
+ }
1883
+ yield Literal(syntax);
1884
+ }
1885
+ function TemplateLiteralSyntax(syntax) {
1886
+ return [...FromSyntax(syntax)];
1887
+ }
1888
+
1889
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
1890
+ var TemplateLiteralPatternError = class extends TypeBoxError {
1891
+ };
1892
+ function Escape(value) {
1893
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1894
+ }
1895
+ function Visit2(schema, acc) {
1896
+ return IsTemplateLiteral(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion(schema) ? `(${schema.anyOf.map((schema2) => Visit2(schema2, acc)).join("|")})` : IsNumber3(schema) ? `${acc}${PatternNumber}` : IsInteger(schema) ? `${acc}${PatternNumber}` : IsBigInt2(schema) ? `${acc}${PatternNumber}` : IsString2(schema) ? `${acc}${PatternString}` : IsLiteral(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean2(schema) ? `${acc}${PatternBoolean}` : (() => {
1897
+ throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
1898
+ })();
1899
+ }
1900
+ function TemplateLiteralPattern(kinds) {
1901
+ return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
1902
+ }
1903
+
1904
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
1905
+ function TemplateLiteralToUnion(schema) {
1906
+ const R = TemplateLiteralGenerate(schema);
1907
+ const L = R.map((S) => Literal(S));
1908
+ return UnionEvaluated(L);
1909
+ }
1910
+
1911
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
1912
+ function TemplateLiteral(unresolved, options) {
1913
+ const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
1914
+ return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
1915
+ }
1916
+
1917
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
1918
+ function FromTemplateLiteral(templateLiteral) {
1919
+ const keys = TemplateLiteralGenerate(templateLiteral);
1920
+ return keys.map((key) => key.toString());
1921
+ }
1922
+ function FromUnion2(types) {
1923
+ const result = [];
1924
+ for (const type of types)
1925
+ result.push(...IndexPropertyKeys(type));
1926
+ return result;
1927
+ }
1928
+ function FromLiteral(literalValue) {
1929
+ return [literalValue.toString()];
1930
+ }
1931
+ function IndexPropertyKeys(type) {
1932
+ return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
1933
+ }
1934
+
1935
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
1936
+ function FromProperties(type, properties, options) {
1937
+ const result = {};
1938
+ for (const K2 of Object.getOwnPropertyNames(properties)) {
1939
+ result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
1940
+ }
1941
+ return result;
1942
+ }
1943
+ function FromMappedResult(type, mappedResult, options) {
1944
+ return FromProperties(type, mappedResult.properties, options);
1945
+ }
1946
+ function IndexFromMappedResult(type, mappedResult, options) {
1947
+ const properties = FromMappedResult(type, mappedResult, options);
1948
+ return MappedResult(properties);
1949
+ }
1950
+
1951
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
1952
+ function FromRest(types, key) {
1953
+ return types.map((type) => IndexFromPropertyKey(type, key));
1954
+ }
1955
+ function FromIntersectRest(types) {
1956
+ return types.filter((type) => !IsNever(type));
1957
+ }
1958
+ function FromIntersect(types, key) {
1959
+ return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
1960
+ }
1961
+ function FromUnionRest(types) {
1962
+ return types.some((L) => IsNever(L)) ? [] : types;
1963
+ }
1964
+ function FromUnion3(types, key) {
1965
+ return UnionEvaluated(FromUnionRest(FromRest(types, key)));
1966
+ }
1967
+ function FromTuple(types, key) {
1968
+ return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
1969
+ }
1970
+ function FromArray(type, key) {
1971
+ return key === "[number]" ? type : Never();
1972
+ }
1973
+ function FromProperty(properties, propertyKey) {
1974
+ return propertyKey in properties ? properties[propertyKey] : Never();
1975
+ }
1976
+ function IndexFromPropertyKey(type, propertyKey) {
1977
+ return IsIntersect(type) ? FromIntersect(type.allOf, propertyKey) : IsUnion(type) ? FromUnion3(type.anyOf, propertyKey) : IsTuple(type) ? FromTuple(type.items ?? [], propertyKey) : IsArray3(type) ? FromArray(type.items, propertyKey) : IsObject3(type) ? FromProperty(type.properties, propertyKey) : Never();
1978
+ }
1979
+ function IndexFromPropertyKeys(type, propertyKeys) {
1980
+ return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
1981
+ }
1982
+ function FromSchema(type, propertyKeys) {
1983
+ return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
1984
+ }
1985
+ function Index(type, key, options) {
1986
+ if (IsRef(type) || IsRef(key)) {
1987
+ const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
1988
+ if (!IsSchema(type) || !IsSchema(key))
1989
+ throw new TypeBoxError(error);
1990
+ return Computed("Index", [type, key]);
1991
+ }
1992
+ if (IsMappedResult(key))
1993
+ return IndexFromMappedResult(type, key, options);
1994
+ if (IsMappedKey(key))
1995
+ return IndexFromMappedKey(type, key, options);
1996
+ return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
1997
+ }
1998
+
1999
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
2000
+ function MappedIndexPropertyKey(type, key, options) {
2001
+ return { [key]: Index(type, [key], Clone(options)) };
2002
+ }
2003
+ function MappedIndexPropertyKeys(type, propertyKeys, options) {
2004
+ return propertyKeys.reduce((result, left) => {
2005
+ return { ...result, ...MappedIndexPropertyKey(type, left, options) };
2006
+ }, {});
2007
+ }
2008
+ function MappedIndexProperties(type, mappedKey, options) {
2009
+ return MappedIndexPropertyKeys(type, mappedKey.keys, options);
2010
+ }
2011
+ function IndexFromMappedKey(type, mappedKey, options) {
2012
+ const properties = MappedIndexProperties(type, mappedKey, options);
2013
+ return MappedResult(properties);
2014
+ }
2015
+
2016
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
2017
+ function Iterator(items, options) {
2018
+ return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
2019
+ }
2020
+
2021
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
2022
+ function RequiredKeys(properties) {
2023
+ const keys = [];
2024
+ for (let key in properties) {
2025
+ if (!IsOptional(properties[key]))
2026
+ keys.push(key);
2027
+ }
2028
+ return keys;
2029
+ }
2030
+ function _Object(properties, options) {
2031
+ const required = RequiredKeys(properties);
2032
+ const schematic = required.length > 0 ? { [Kind]: "Object", type: "object", properties, required } : { [Kind]: "Object", type: "object", properties };
2033
+ return CreateType(schematic, options);
2034
+ }
2035
+ var Object2 = _Object;
2036
+
2037
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
2038
+ function Promise2(item, options) {
2039
+ return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
2040
+ }
2041
+
2042
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
2043
+ function RemoveReadonly(schema) {
2044
+ return CreateType(Discard(schema, [ReadonlyKind]));
2045
+ }
2046
+ function AddReadonly(schema) {
2047
+ return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
2048
+ }
2049
+ function ReadonlyWithFlag(schema, F) {
2050
+ return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
2051
+ }
2052
+ function Readonly(schema, enable) {
2053
+ const F = enable ?? true;
2054
+ return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
2055
+ }
2056
+
2057
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
2058
+ function FromProperties2(K, F) {
2059
+ const Acc = {};
2060
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
2061
+ Acc[K2] = Readonly(K[K2], F);
2062
+ return Acc;
2063
+ }
2064
+ function FromMappedResult2(R, F) {
2065
+ return FromProperties2(R.properties, F);
2066
+ }
2067
+ function ReadonlyFromMappedResult(R, F) {
2068
+ const P = FromMappedResult2(R, F);
2069
+ return MappedResult(P);
2070
+ }
2071
+
2072
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
2073
+ function Tuple(types, options) {
2074
+ return CreateType(types.length > 0 ? { [Kind]: "Tuple", type: "array", items: types, additionalItems: false, minItems: types.length, maxItems: types.length } : { [Kind]: "Tuple", type: "array", minItems: types.length, maxItems: types.length }, options);
2075
+ }
2076
+
2077
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
2078
+ function FromMappedResult3(K, P) {
2079
+ return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
2080
+ }
2081
+ function MappedKeyToKnownMappedResultProperties(K) {
2082
+ return { [K]: Literal(K) };
2083
+ }
2084
+ function MappedKeyToUnknownMappedResultProperties(P) {
2085
+ const Acc = {};
2086
+ for (const L of P)
2087
+ Acc[L] = Literal(L);
2088
+ return Acc;
2089
+ }
2090
+ function MappedKeyToMappedResultProperties(K, P) {
2091
+ return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
2092
+ }
2093
+ function FromMappedKey(K, P) {
2094
+ const R = MappedKeyToMappedResultProperties(K, P);
2095
+ return FromMappedResult3(K, R);
2096
+ }
2097
+ function FromRest2(K, T) {
2098
+ return T.map((L) => FromSchemaType(K, L));
2099
+ }
2100
+ function FromProperties3(K, T) {
2101
+ const Acc = {};
2102
+ for (const K2 of globalThis.Object.getOwnPropertyNames(T))
2103
+ Acc[K2] = FromSchemaType(K, T[K2]);
2104
+ return Acc;
2105
+ }
2106
+ function FromSchemaType(K, T) {
2107
+ const options = { ...T };
2108
+ return (
2109
+ // unevaluated modifier types
2110
+ IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
2111
+ // unevaluated mapped types
2112
+ IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
2113
+ // unevaluated types
2114
+ IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction2(T) ? Function(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator2(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator2(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect(T) ? Intersect(FromRest2(K, T.allOf), options) : IsUnion(T) ? Union(FromRest2(K, T.anyOf), options) : IsTuple(T) ? Tuple(FromRest2(K, T.items ?? []), options) : IsObject3(T) ? Object2(FromProperties3(K, T.properties), options) : IsArray3(T) ? Array2(FromSchemaType(K, T.items), options) : IsPromise(T) ? Promise2(FromSchemaType(K, T.item), options) : T
2115
+ )
2116
+ )
2117
+ );
2118
+ }
2119
+ function MappedFunctionReturnType(K, T) {
2120
+ const Acc = {};
2121
+ for (const L of K)
2122
+ Acc[L] = FromSchemaType(L, T);
2123
+ return Acc;
2124
+ }
2125
+ function Mapped(key, map, options) {
2126
+ const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
2127
+ const RT = map({ [Kind]: "MappedKey", keys: K });
2128
+ const R = MappedFunctionReturnType(K, RT);
2129
+ return Object2(R, options);
2130
+ }
2131
+
2132
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
2133
+ function RemoveOptional(schema) {
2134
+ return CreateType(Discard(schema, [OptionalKind]));
2135
+ }
2136
+ function AddOptional(schema) {
2137
+ return CreateType({ ...schema, [OptionalKind]: "Optional" });
2138
+ }
2139
+ function OptionalWithFlag(schema, F) {
2140
+ return F === false ? RemoveOptional(schema) : AddOptional(schema);
2141
+ }
2142
+ function Optional(schema, enable) {
2143
+ const F = enable ?? true;
2144
+ return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
2145
+ }
2146
+
2147
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
2148
+ function FromProperties4(P, F) {
2149
+ const Acc = {};
2150
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
2151
+ Acc[K2] = Optional(P[K2], F);
2152
+ return Acc;
2153
+ }
2154
+ function FromMappedResult4(R, F) {
2155
+ return FromProperties4(R.properties, F);
2156
+ }
2157
+ function OptionalFromMappedResult(R, F) {
2158
+ const P = FromMappedResult4(R, F);
2159
+ return MappedResult(P);
2160
+ }
2161
+
2162
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
2163
+ function IntersectCreate(T, options = {}) {
2164
+ const allObjects = T.every((schema) => IsObject3(schema));
2165
+ const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
2166
+ return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
2167
+ }
2168
+
2169
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
2170
+ function IsIntersectOptional(types) {
2171
+ return types.every((left) => IsOptional(left));
2172
+ }
2173
+ function RemoveOptionalFromType2(type) {
2174
+ return Discard(type, [OptionalKind]);
2175
+ }
2176
+ function RemoveOptionalFromRest2(types) {
2177
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
2178
+ }
2179
+ function ResolveIntersect(types, options) {
2180
+ return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
2181
+ }
2182
+ function IntersectEvaluated(types, options = {}) {
2183
+ if (types.length === 1)
2184
+ return CreateType(types[0], options);
2185
+ if (types.length === 0)
2186
+ return Never(options);
2187
+ if (types.some((schema) => IsTransform(schema)))
2188
+ throw new Error("Cannot intersect transform types");
2189
+ return ResolveIntersect(types, options);
2190
+ }
2191
+
2192
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
2193
+ function Intersect(types, options) {
2194
+ if (types.length === 1)
2195
+ return CreateType(types[0], options);
2196
+ if (types.length === 0)
2197
+ return Never(options);
2198
+ if (types.some((schema) => IsTransform(schema)))
2199
+ throw new Error("Cannot intersect transform types");
2200
+ return IntersectCreate(types, options);
2201
+ }
2202
+
2203
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
2204
+ function Ref(...args) {
2205
+ const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
2206
+ if (typeof $ref !== "string")
2207
+ throw new TypeBoxError("Ref: $ref must be a string");
2208
+ return CreateType({ [Kind]: "Ref", $ref }, options);
2209
+ }
2210
+
2211
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
2212
+ function FromComputed(target, parameters) {
2213
+ return Computed("Awaited", [Computed(target, parameters)]);
2214
+ }
2215
+ function FromRef($ref) {
2216
+ return Computed("Awaited", [Ref($ref)]);
2217
+ }
2218
+ function FromIntersect2(types) {
2219
+ return Intersect(FromRest3(types));
2220
+ }
2221
+ function FromUnion4(types) {
2222
+ return Union(FromRest3(types));
2223
+ }
2224
+ function FromPromise(type) {
2225
+ return Awaited(type);
2226
+ }
2227
+ function FromRest3(types) {
2228
+ return types.map((type) => Awaited(type));
2229
+ }
2230
+ function Awaited(type, options) {
2231
+ return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) : IsPromise(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
2232
+ }
2233
+
2234
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
2235
+ function FromRest4(types) {
2236
+ const result = [];
2237
+ for (const L of types)
2238
+ result.push(KeyOfPropertyKeys(L));
2239
+ return result;
2240
+ }
2241
+ function FromIntersect3(types) {
2242
+ const propertyKeysArray = FromRest4(types);
2243
+ const propertyKeys = SetUnionMany(propertyKeysArray);
2244
+ return propertyKeys;
2245
+ }
2246
+ function FromUnion5(types) {
2247
+ const propertyKeysArray = FromRest4(types);
2248
+ const propertyKeys = SetIntersectMany(propertyKeysArray);
2249
+ return propertyKeys;
2250
+ }
2251
+ function FromTuple2(types) {
2252
+ return types.map((_, indexer) => indexer.toString());
2253
+ }
2254
+ function FromArray2(_) {
2255
+ return ["[number]"];
2256
+ }
2257
+ function FromProperties5(T) {
2258
+ return globalThis.Object.getOwnPropertyNames(T);
2259
+ }
2260
+ function FromPatternProperties(patternProperties) {
2261
+ if (!includePatternProperties)
2262
+ return [];
2263
+ const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
2264
+ return patternPropertyKeys.map((key) => {
2265
+ return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
2266
+ });
2267
+ }
2268
+ function KeyOfPropertyKeys(type) {
2269
+ return IsIntersect(type) ? FromIntersect3(type.allOf) : IsUnion(type) ? FromUnion5(type.anyOf) : IsTuple(type) ? FromTuple2(type.items ?? []) : IsArray3(type) ? FromArray2(type.items) : IsObject3(type) ? FromProperties5(type.properties) : IsRecord(type) ? FromPatternProperties(type.patternProperties) : [];
2270
+ }
2271
+ var includePatternProperties = false;
2272
+
2273
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
2274
+ function FromComputed2(target, parameters) {
2275
+ return Computed("KeyOf", [Computed(target, parameters)]);
2276
+ }
2277
+ function FromRef2($ref) {
2278
+ return Computed("KeyOf", [Ref($ref)]);
2279
+ }
2280
+ function KeyOfFromType(type, options) {
2281
+ const propertyKeys = KeyOfPropertyKeys(type);
2282
+ const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
2283
+ const result = UnionEvaluated(propertyKeyTypes);
2284
+ return CreateType(result, options);
2285
+ }
2286
+ function KeyOfPropertyKeysToRest(propertyKeys) {
2287
+ return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
2288
+ }
2289
+ function KeyOf(type, options) {
2290
+ return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
2291
+ }
2292
+
2293
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
2294
+ function FromProperties6(properties, options) {
2295
+ const result = {};
2296
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
2297
+ result[K2] = KeyOf(properties[K2], Clone(options));
2298
+ return result;
2299
+ }
2300
+ function FromMappedResult5(mappedResult, options) {
2301
+ return FromProperties6(mappedResult.properties, options);
2302
+ }
2303
+ function KeyOfFromMappedResult(mappedResult, options) {
2304
+ const properties = FromMappedResult5(mappedResult, options);
2305
+ return MappedResult(properties);
2306
+ }
2307
+
2308
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
2309
+ function CompositeKeys(T) {
2310
+ const Acc = [];
2311
+ for (const L of T)
2312
+ Acc.push(...KeyOfPropertyKeys(L));
2313
+ return SetDistinct(Acc);
2314
+ }
2315
+ function FilterNever(T) {
2316
+ return T.filter((L) => !IsNever(L));
2317
+ }
2318
+ function CompositeProperty(T, K) {
2319
+ const Acc = [];
2320
+ for (const L of T)
2321
+ Acc.push(...IndexFromPropertyKeys(L, [K]));
2322
+ return FilterNever(Acc);
2323
+ }
2324
+ function CompositeProperties(T, K) {
2325
+ const Acc = {};
2326
+ for (const L of K) {
2327
+ Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
2328
+ }
2329
+ return Acc;
2330
+ }
2331
+ function Composite(T, options) {
2332
+ const K = CompositeKeys(T);
2333
+ const P = CompositeProperties(T, K);
2334
+ const R = Object2(P, options);
2335
+ return R;
2336
+ }
2337
+
2338
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
2339
+ function Date2(options) {
2340
+ return CreateType({ [Kind]: "Date", type: "Date" }, options);
2341
+ }
2342
+
2343
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
2344
+ function Null(options) {
2345
+ return CreateType({ [Kind]: "Null", type: "null" }, options);
2346
+ }
2347
+
2348
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
2349
+ function Symbol2(options) {
2350
+ return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
2351
+ }
2352
+
2353
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
2354
+ function Undefined(options) {
2355
+ return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
2356
+ }
2357
+
2358
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
2359
+ function Uint8Array2(options) {
2360
+ return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
2361
+ }
2362
+
2363
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
2364
+ function Unknown(options) {
2365
+ return CreateType({ [Kind]: "Unknown" }, options);
2366
+ }
2367
+
2368
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
2369
+ function FromArray3(T) {
2370
+ return T.map((L) => FromValue(L, false));
2371
+ }
2372
+ function FromProperties7(value) {
2373
+ const Acc = {};
2374
+ for (const K of globalThis.Object.getOwnPropertyNames(value))
2375
+ Acc[K] = Readonly(FromValue(value[K], false));
2376
+ return Acc;
2377
+ }
2378
+ function ConditionalReadonly(T, root) {
2379
+ return root === true ? T : Readonly(T);
2380
+ }
2381
+ function FromValue(value, root) {
2382
+ return IsAsyncIterator(value) ? ConditionalReadonly(Any(), root) : IsIterator(value) ? ConditionalReadonly(Any(), root) : IsArray(value) ? Readonly(Tuple(FromArray3(value))) : IsUint8Array(value) ? Uint8Array2() : IsDate(value) ? Date2() : IsObject(value) ? ConditionalReadonly(Object2(FromProperties7(value)), root) : IsFunction(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined(value) ? Undefined() : IsNull(value) ? Null() : IsSymbol(value) ? Symbol2() : IsBigInt(value) ? BigInt() : IsNumber(value) ? Literal(value) : IsBoolean(value) ? Literal(value) : IsString(value) ? Literal(value) : Object2({});
2383
+ }
2384
+ function Const(T, options) {
2385
+ return CreateType(FromValue(T, true), options);
2386
+ }
2387
+
2388
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
2389
+ function ConstructorParameters(schema, options) {
2390
+ return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
2391
+ }
2392
+
2393
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
2394
+ function Enum(item, options) {
2395
+ if (IsUndefined(item))
2396
+ throw new Error("Enum undefined or empty");
2397
+ const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
2398
+ const values2 = [...new Set(values1)];
2399
+ const anyOf = values2.map((value) => Literal(value));
2400
+ return Union(anyOf, { ...options, [Hint]: "Enum" });
2401
+ }
2402
+
2403
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
2404
+ var ExtendsResolverError = class extends TypeBoxError {
2405
+ };
2406
+ var ExtendsResult;
2407
+ (function(ExtendsResult2) {
2408
+ ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
2409
+ ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
2410
+ ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
2411
+ })(ExtendsResult || (ExtendsResult = {}));
2412
+ function IntoBooleanResult(result) {
2413
+ return result === ExtendsResult.False ? result : ExtendsResult.True;
2414
+ }
2415
+ function Throw(message) {
2416
+ throw new ExtendsResolverError(message);
2417
+ }
2418
+ function IsStructuralRight(right) {
2419
+ return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
2420
+ }
2421
+ function StructuralRight(left, right) {
2422
+ return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
2423
+ }
2424
+ function FromAnyRight(left, right) {
2425
+ return ExtendsResult.True;
2426
+ }
2427
+ function FromAny(left, right) {
2428
+ return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) && right.anyOf.some((schema) => type_exports.IsAny(schema) || type_exports.IsUnknown(schema)) ? ExtendsResult.True : type_exports.IsUnion(right) ? ExtendsResult.Union : type_exports.IsUnknown(right) ? ExtendsResult.True : type_exports.IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
2429
+ }
2430
+ function FromArrayRight(left, right) {
2431
+ return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
2432
+ }
2433
+ function FromArray4(left, right) {
2434
+ return type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
2435
+ }
2436
+ function FromAsyncIterator(left, right) {
2437
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
2438
+ }
2439
+ function FromBigInt(left, right) {
2440
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
2441
+ }
2442
+ function FromBooleanRight(left, right) {
2443
+ return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
2444
+ }
2445
+ function FromBoolean(left, right) {
2446
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
2447
+ }
2448
+ function FromConstructor(left, right) {
2449
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index2) => IntoBooleanResult(Visit3(right.parameters[index2], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
2450
+ }
2451
+ function FromDate(left, right) {
2452
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
2453
+ }
2454
+ function FromFunction(left, right) {
2455
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index2) => IntoBooleanResult(Visit3(right.parameters[index2], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
2456
+ }
2457
+ function FromIntegerRight(left, right) {
2458
+ return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
2459
+ }
2460
+ function FromInteger(left, right) {
2461
+ return type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
2462
+ }
2463
+ function FromIntersectRight(left, right) {
2464
+ return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
2465
+ }
2466
+ function FromIntersect4(left, right) {
2467
+ return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
2468
+ }
2469
+ function FromIterator(left, right) {
2470
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
2471
+ }
2472
+ function FromLiteral2(left, right) {
2473
+ return type_exports.IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
2474
+ }
2475
+ function FromNeverRight(left, right) {
2476
+ return ExtendsResult.False;
2477
+ }
2478
+ function FromNever(left, right) {
2479
+ return ExtendsResult.True;
2480
+ }
2481
+ function UnwrapTNot(schema) {
2482
+ let [current, depth] = [schema, 0];
2483
+ while (true) {
2484
+ if (!type_exports.IsNot(current))
2485
+ break;
2486
+ current = current.not;
2487
+ depth += 1;
2488
+ }
2489
+ return depth % 2 === 0 ? current : Unknown();
2490
+ }
2491
+ function FromNot(left, right) {
2492
+ return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
2493
+ }
2494
+ function FromNull(left, right) {
2495
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
2496
+ }
2497
+ function FromNumberRight(left, right) {
2498
+ return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
2499
+ }
2500
+ function FromNumber(left, right) {
2501
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
2502
+ }
2503
+ function IsObjectPropertyCount(schema, count2) {
2504
+ return Object.getOwnPropertyNames(schema.properties).length === count2;
2505
+ }
2506
+ function IsObjectStringLike(schema) {
2507
+ return IsObjectArrayLike(schema);
2508
+ }
2509
+ function IsObjectSymbolLike(schema) {
2510
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && type_exports.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (type_exports.IsString(schema.properties.description.anyOf[0]) && type_exports.IsUndefined(schema.properties.description.anyOf[1]) || type_exports.IsString(schema.properties.description.anyOf[1]) && type_exports.IsUndefined(schema.properties.description.anyOf[0]));
2511
+ }
2512
+ function IsObjectNumberLike(schema) {
2513
+ return IsObjectPropertyCount(schema, 0);
2514
+ }
2515
+ function IsObjectBooleanLike(schema) {
2516
+ return IsObjectPropertyCount(schema, 0);
2517
+ }
2518
+ function IsObjectBigIntLike(schema) {
2519
+ return IsObjectPropertyCount(schema, 0);
2520
+ }
2521
+ function IsObjectDateLike(schema) {
2522
+ return IsObjectPropertyCount(schema, 0);
2523
+ }
2524
+ function IsObjectUint8ArrayLike(schema) {
2525
+ return IsObjectArrayLike(schema);
2526
+ }
2527
+ function IsObjectFunctionLike(schema) {
2528
+ const length = Number2();
2529
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
2530
+ }
2531
+ function IsObjectConstructorLike(schema) {
2532
+ return IsObjectPropertyCount(schema, 0);
2533
+ }
2534
+ function IsObjectArrayLike(schema) {
2535
+ const length = Number2();
2536
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
2537
+ }
2538
+ function IsObjectPromiseLike(schema) {
2539
+ const then = Function([Any()], Any());
2540
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
2541
+ }
2542
+ function Property(left, right) {
2543
+ return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
2544
+ }
2545
+ function FromObjectRight(left, right) {
2546
+ return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) || type_exports.IsLiteralString(left) && IsObjectStringLike(right) || type_exports.IsLiteralNumber(left) && IsObjectNumberLike(right) || type_exports.IsLiteralBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsBigInt(left) && IsObjectBigIntLike(right) || type_exports.IsString(left) && IsObjectStringLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsNumber(left) && IsObjectNumberLike(right) || type_exports.IsInteger(left) && IsObjectNumberLike(right) || type_exports.IsBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsUint8Array(left) && IsObjectUint8ArrayLike(right) || type_exports.IsDate(left) && IsObjectDateLike(right) || type_exports.IsConstructor(left) && IsObjectConstructorLike(right) || type_exports.IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : type_exports.IsRecord(left) && type_exports.IsString(RecordKey(left)) ? (() => {
2547
+ return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
2548
+ })() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
2549
+ return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
2550
+ })() : ExtendsResult.False;
2551
+ }
2552
+ function FromObject(left, right) {
2553
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
2554
+ for (const key of Object.getOwnPropertyNames(right.properties)) {
2555
+ if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
2556
+ return ExtendsResult.False;
2557
+ }
2558
+ if (type_exports.IsOptional(right.properties[key])) {
2559
+ return ExtendsResult.True;
2560
+ }
2561
+ if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
2562
+ return ExtendsResult.False;
2563
+ }
2564
+ }
2565
+ return ExtendsResult.True;
2566
+ })();
2567
+ }
2568
+ function FromPromise2(left, right) {
2569
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !type_exports.IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.item, right.item));
2570
+ }
2571
+ function RecordKey(schema) {
2572
+ return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
2573
+ }
2574
+ function RecordValue(schema) {
2575
+ return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
2576
+ }
2577
+ function FromRecordRight(left, right) {
2578
+ const [Key, Value] = [RecordKey(right), RecordValue(right)];
2579
+ return type_exports.IsLiteralString(left) && type_exports.IsNumber(Key) && IntoBooleanResult(Visit3(left, Value)) === ExtendsResult.True ? ExtendsResult.True : type_exports.IsUint8Array(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsString(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsArray(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsObject(left) ? (() => {
2580
+ for (const key of Object.getOwnPropertyNames(left.properties)) {
2581
+ if (Property(Value, left.properties[key]) === ExtendsResult.False) {
2582
+ return ExtendsResult.False;
2583
+ }
2584
+ }
2585
+ return ExtendsResult.True;
2586
+ })() : ExtendsResult.False;
2587
+ }
2588
+ function FromRecord(left, right) {
2589
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
2590
+ }
2591
+ function FromRegExp(left, right) {
2592
+ const L = type_exports.IsRegExp(left) ? String2() : left;
2593
+ const R = type_exports.IsRegExp(right) ? String2() : right;
2594
+ return Visit3(L, R);
2595
+ }
2596
+ function FromStringRight(left, right) {
2597
+ return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
2598
+ }
2599
+ function FromString(left, right) {
2600
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? ExtendsResult.True : ExtendsResult.False;
2601
+ }
2602
+ function FromSymbol(left, right) {
2603
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
2604
+ }
2605
+ function FromTemplateLiteral2(left, right) {
2606
+ return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
2607
+ }
2608
+ function IsArrayOfTuple(left, right) {
2609
+ return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
2610
+ }
2611
+ function FromTupleRight(left, right) {
2612
+ return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
2613
+ }
2614
+ function FromTuple3(left, right) {
2615
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : type_exports.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !type_exports.IsTuple(right) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) || !value_exports.IsUndefined(left.items) && value_exports.IsUndefined(right.items) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) ? ExtendsResult.True : left.items.every((schema, index2) => Visit3(schema, right.items[index2]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
2616
+ }
2617
+ function FromUint8Array(left, right) {
2618
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
2619
+ }
2620
+ function FromUndefined(left, right) {
2621
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsVoid(right) ? FromVoidRight(left, right) : type_exports.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
2622
+ }
2623
+ function FromUnionRight(left, right) {
2624
+ return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
2625
+ }
2626
+ function FromUnion6(left, right) {
2627
+ return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
2628
+ }
2629
+ function FromUnknownRight(left, right) {
2630
+ return ExtendsResult.True;
2631
+ }
2632
+ function FromUnknown(left, right) {
2633
+ return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : type_exports.IsArray(right) ? FromArrayRight(left, right) : type_exports.IsTuple(right) ? FromTupleRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
2634
+ }
2635
+ function FromVoidRight(left, right) {
2636
+ return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
2637
+ }
2638
+ function FromVoid(left, right) {
2639
+ return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
2640
+ }
2641
+ function Visit3(left, right) {
2642
+ return (
2643
+ // resolvable
2644
+ type_exports.IsTemplateLiteral(left) || type_exports.IsTemplateLiteral(right) ? FromTemplateLiteral2(left, right) : type_exports.IsRegExp(left) || type_exports.IsRegExp(right) ? FromRegExp(left, right) : type_exports.IsNot(left) || type_exports.IsNot(right) ? FromNot(left, right) : (
2645
+ // standard
2646
+ type_exports.IsAny(left) ? FromAny(left, right) : type_exports.IsArray(left) ? FromArray4(left, right) : type_exports.IsBigInt(left) ? FromBigInt(left, right) : type_exports.IsBoolean(left) ? FromBoolean(left, right) : type_exports.IsAsyncIterator(left) ? FromAsyncIterator(left, right) : type_exports.IsConstructor(left) ? FromConstructor(left, right) : type_exports.IsDate(left) ? FromDate(left, right) : type_exports.IsFunction(left) ? FromFunction(left, right) : type_exports.IsInteger(left) ? FromInteger(left, right) : type_exports.IsIntersect(left) ? FromIntersect4(left, right) : type_exports.IsIterator(left) ? FromIterator(left, right) : type_exports.IsLiteral(left) ? FromLiteral2(left, right) : type_exports.IsNever(left) ? FromNever(left, right) : type_exports.IsNull(left) ? FromNull(left, right) : type_exports.IsNumber(left) ? FromNumber(left, right) : type_exports.IsObject(left) ? FromObject(left, right) : type_exports.IsRecord(left) ? FromRecord(left, right) : type_exports.IsString(left) ? FromString(left, right) : type_exports.IsSymbol(left) ? FromSymbol(left, right) : type_exports.IsTuple(left) ? FromTuple3(left, right) : type_exports.IsPromise(left) ? FromPromise2(left, right) : type_exports.IsUint8Array(left) ? FromUint8Array(left, right) : type_exports.IsUndefined(left) ? FromUndefined(left, right) : type_exports.IsUnion(left) ? FromUnion6(left, right) : type_exports.IsUnknown(left) ? FromUnknown(left, right) : type_exports.IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`)
2647
+ )
2648
+ );
2649
+ }
2650
+ function ExtendsCheck(left, right) {
2651
+ return Visit3(left, right);
2652
+ }
2653
+
2654
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
2655
+ function FromProperties8(P, Right, True, False, options) {
2656
+ const Acc = {};
2657
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
2658
+ Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
2659
+ return Acc;
2660
+ }
2661
+ function FromMappedResult6(Left, Right, True, False, options) {
2662
+ return FromProperties8(Left.properties, Right, True, False, options);
2663
+ }
2664
+ function ExtendsFromMappedResult(Left, Right, True, False, options) {
2665
+ const P = FromMappedResult6(Left, Right, True, False, options);
2666
+ return MappedResult(P);
2667
+ }
2668
+
2669
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
2670
+ function ExtendsResolve(left, right, trueType, falseType) {
2671
+ const R = ExtendsCheck(left, right);
2672
+ return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
2673
+ }
2674
+ function Extends(L, R, T, F, options) {
2675
+ return IsMappedResult(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
2676
+ }
2677
+
2678
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
2679
+ function FromPropertyKey(K, U, L, R, options) {
2680
+ return {
2681
+ [K]: Extends(Literal(K), U, L, R, Clone(options))
2682
+ };
2683
+ }
2684
+ function FromPropertyKeys(K, U, L, R, options) {
2685
+ return K.reduce((Acc, LK) => {
2686
+ return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
2687
+ }, {});
2688
+ }
2689
+ function FromMappedKey2(K, U, L, R, options) {
2690
+ return FromPropertyKeys(K.keys, U, L, R, options);
2691
+ }
2692
+ function ExtendsFromMappedKey(T, U, L, R, options) {
2693
+ const P = FromMappedKey2(T, U, L, R, options);
2694
+ return MappedResult(P);
2695
+ }
2696
+
2697
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
2698
+ function ExcludeFromTemplateLiteral(L, R) {
2699
+ return Exclude(TemplateLiteralToUnion(L), R);
2700
+ }
2701
+
2702
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
2703
+ function ExcludeRest(L, R) {
2704
+ const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
2705
+ return excluded.length === 1 ? excluded[0] : Union(excluded);
2706
+ }
2707
+ function Exclude(L, R, options = {}) {
2708
+ if (IsTemplateLiteral(L))
2709
+ return CreateType(ExcludeFromTemplateLiteral(L, R), options);
2710
+ if (IsMappedResult(L))
2711
+ return CreateType(ExcludeFromMappedResult(L, R), options);
2712
+ return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
2713
+ }
2714
+
2715
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
2716
+ function FromProperties9(P, U) {
2717
+ const Acc = {};
2718
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
2719
+ Acc[K2] = Exclude(P[K2], U);
2720
+ return Acc;
2721
+ }
2722
+ function FromMappedResult7(R, T) {
2723
+ return FromProperties9(R.properties, T);
2724
+ }
2725
+ function ExcludeFromMappedResult(R, T) {
2726
+ const P = FromMappedResult7(R, T);
2727
+ return MappedResult(P);
2728
+ }
2729
+
2730
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
2731
+ function ExtractFromTemplateLiteral(L, R) {
2732
+ return Extract(TemplateLiteralToUnion(L), R);
2733
+ }
2734
+
2735
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
2736
+ function ExtractRest(L, R) {
2737
+ const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
2738
+ return extracted.length === 1 ? extracted[0] : Union(extracted);
2739
+ }
2740
+ function Extract(L, R, options) {
2741
+ if (IsTemplateLiteral(L))
2742
+ return CreateType(ExtractFromTemplateLiteral(L, R), options);
2743
+ if (IsMappedResult(L))
2744
+ return CreateType(ExtractFromMappedResult(L, R), options);
2745
+ return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
2746
+ }
2747
+
2748
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
2749
+ function FromProperties10(P, T) {
2750
+ const Acc = {};
2751
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
2752
+ Acc[K2] = Extract(P[K2], T);
2753
+ return Acc;
2754
+ }
2755
+ function FromMappedResult8(R, T) {
2756
+ return FromProperties10(R.properties, T);
2757
+ }
2758
+ function ExtractFromMappedResult(R, T) {
2759
+ const P = FromMappedResult8(R, T);
2760
+ return MappedResult(P);
2761
+ }
2762
+
2763
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
2764
+ function InstanceType(schema, options) {
2765
+ return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
2766
+ }
2767
+
2768
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
2769
+ function ReadonlyOptional(schema) {
2770
+ return Readonly(Optional(schema));
2771
+ }
2772
+
2773
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
2774
+ function RecordCreateFromPattern(pattern, T, options) {
2775
+ return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
2776
+ }
2777
+ function RecordCreateFromKeys(K, T, options) {
2778
+ const result = {};
2779
+ for (const K2 of K)
2780
+ result[K2] = T;
2781
+ return Object2(result, { ...options, [Hint]: "Record" });
2782
+ }
2783
+ function FromTemplateLiteralKey(K, T, options) {
2784
+ return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
2785
+ }
2786
+ function FromUnionKey(key, type, options) {
2787
+ return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
2788
+ }
2789
+ function FromLiteralKey(key, type, options) {
2790
+ return RecordCreateFromKeys([key.toString()], type, options);
2791
+ }
2792
+ function FromRegExpKey(key, type, options) {
2793
+ return RecordCreateFromPattern(key.source, type, options);
2794
+ }
2795
+ function FromStringKey(key, type, options) {
2796
+ const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
2797
+ return RecordCreateFromPattern(pattern, type, options);
2798
+ }
2799
+ function FromAnyKey(_, type, options) {
2800
+ return RecordCreateFromPattern(PatternStringExact, type, options);
2801
+ }
2802
+ function FromNeverKey(_key, type, options) {
2803
+ return RecordCreateFromPattern(PatternNeverExact, type, options);
2804
+ }
2805
+ function FromBooleanKey(_key, type, options) {
2806
+ return Object2({ true: type, false: type }, options);
2807
+ }
2808
+ function FromIntegerKey(_key, type, options) {
2809
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
2810
+ }
2811
+ function FromNumberKey(_, type, options) {
2812
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
2813
+ }
2814
+ function Record(key, type, options = {}) {
2815
+ return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) : IsBoolean2(key) ? FromBooleanKey(key, type, options) : IsInteger(key) ? FromIntegerKey(key, type, options) : IsNumber3(key) ? FromNumberKey(key, type, options) : IsRegExp2(key) ? FromRegExpKey(key, type, options) : IsString2(key) ? FromStringKey(key, type, options) : IsAny(key) ? FromAnyKey(key, type, options) : IsNever(key) ? FromNeverKey(key, type, options) : Never(options);
2816
+ }
2817
+ function RecordPattern(record) {
2818
+ return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
2819
+ }
2820
+ function RecordKey2(type) {
2821
+ const pattern = RecordPattern(type);
2822
+ return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
2823
+ }
2824
+ function RecordValue2(type) {
2825
+ return type.patternProperties[RecordPattern(type)];
2826
+ }
2827
+
2828
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
2829
+ function FromConstructor2(args, type) {
2830
+ type.parameters = FromTypes(args, type.parameters);
2831
+ type.returns = FromType(args, type.returns);
2832
+ return type;
2833
+ }
2834
+ function FromFunction2(args, type) {
2835
+ type.parameters = FromTypes(args, type.parameters);
2836
+ type.returns = FromType(args, type.returns);
2837
+ return type;
2838
+ }
2839
+ function FromIntersect5(args, type) {
2840
+ type.allOf = FromTypes(args, type.allOf);
2841
+ return type;
2842
+ }
2843
+ function FromUnion7(args, type) {
2844
+ type.anyOf = FromTypes(args, type.anyOf);
2845
+ return type;
2846
+ }
2847
+ function FromTuple4(args, type) {
2848
+ if (IsUndefined(type.items))
2849
+ return type;
2850
+ type.items = FromTypes(args, type.items);
2851
+ return type;
2852
+ }
2853
+ function FromArray5(args, type) {
2854
+ type.items = FromType(args, type.items);
2855
+ return type;
2856
+ }
2857
+ function FromAsyncIterator2(args, type) {
2858
+ type.items = FromType(args, type.items);
2859
+ return type;
2860
+ }
2861
+ function FromIterator2(args, type) {
2862
+ type.items = FromType(args, type.items);
2863
+ return type;
2864
+ }
2865
+ function FromPromise3(args, type) {
2866
+ type.item = FromType(args, type.item);
2867
+ return type;
2868
+ }
2869
+ function FromObject2(args, type) {
2870
+ const mappedProperties = FromProperties11(args, type.properties);
2871
+ return { ...type, ...Object2(mappedProperties) };
2872
+ }
2873
+ function FromRecord2(args, type) {
2874
+ const mappedKey = FromType(args, RecordKey2(type));
2875
+ const mappedValue = FromType(args, RecordValue2(type));
2876
+ const result = Record(mappedKey, mappedValue);
2877
+ return { ...type, ...result };
2878
+ }
2879
+ function FromArgument(args, argument) {
2880
+ return argument.index in args ? args[argument.index] : Unknown();
2881
+ }
2882
+ function FromProperty2(args, type) {
2883
+ const isReadonly = IsReadonly(type);
2884
+ const isOptional = IsOptional(type);
2885
+ const mapped = FromType(args, type);
2886
+ return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
2887
+ }
2888
+ function FromProperties11(args, properties) {
2889
+ return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
2890
+ return { ...result, [key]: FromProperty2(args, properties[key]) };
2891
+ }, {});
2892
+ }
2893
+ function FromTypes(args, types) {
2894
+ return types.map((type) => FromType(args, type));
2895
+ }
2896
+ function FromType(args, type) {
2897
+ return IsConstructor(type) ? FromConstructor2(args, type) : IsFunction2(type) ? FromFunction2(args, type) : IsIntersect(type) ? FromIntersect5(args, type) : IsUnion(type) ? FromUnion7(args, type) : IsTuple(type) ? FromTuple4(args, type) : IsArray3(type) ? FromArray5(args, type) : IsAsyncIterator2(type) ? FromAsyncIterator2(args, type) : IsIterator2(type) ? FromIterator2(args, type) : IsPromise(type) ? FromPromise3(args, type) : IsObject3(type) ? FromObject2(args, type) : IsRecord(type) ? FromRecord2(args, type) : IsArgument(type) ? FromArgument(args, type) : type;
2898
+ }
2899
+ function Instantiate(type, args) {
2900
+ return FromType(args, CloneType(type));
2901
+ }
2902
+
2903
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
2904
+ function Integer(options) {
2905
+ return CreateType({ [Kind]: "Integer", type: "integer" }, options);
2906
+ }
2907
+
2908
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
2909
+ function MappedIntrinsicPropertyKey(K, M, options) {
2910
+ return {
2911
+ [K]: Intrinsic(Literal(K), M, Clone(options))
2912
+ };
2913
+ }
2914
+ function MappedIntrinsicPropertyKeys(K, M, options) {
2915
+ const result = K.reduce((Acc, L) => {
2916
+ return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
2917
+ }, {});
2918
+ return result;
2919
+ }
2920
+ function MappedIntrinsicProperties(T, M, options) {
2921
+ return MappedIntrinsicPropertyKeys(T["keys"], M, options);
2922
+ }
2923
+ function IntrinsicFromMappedKey(T, M, options) {
2924
+ const P = MappedIntrinsicProperties(T, M, options);
2925
+ return MappedResult(P);
2926
+ }
2927
+
2928
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
2929
+ function ApplyUncapitalize(value) {
2930
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2931
+ return [first.toLowerCase(), rest].join("");
2932
+ }
2933
+ function ApplyCapitalize(value) {
2934
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2935
+ return [first.toUpperCase(), rest].join("");
2936
+ }
2937
+ function ApplyUppercase(value) {
2938
+ return value.toUpperCase();
2939
+ }
2940
+ function ApplyLowercase(value) {
2941
+ return value.toLowerCase();
2942
+ }
2943
+ function FromTemplateLiteral3(schema, mode, options) {
2944
+ const expression = TemplateLiteralParseExact(schema.pattern);
2945
+ const finite = IsTemplateLiteralExpressionFinite(expression);
2946
+ if (!finite)
2947
+ return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
2948
+ const strings = [...TemplateLiteralExpressionGenerate(expression)];
2949
+ const literals = strings.map((value) => Literal(value));
2950
+ const mapped = FromRest5(literals, mode);
2951
+ const union = Union(mapped);
2952
+ return TemplateLiteral([union], options);
2953
+ }
2954
+ function FromLiteralValue(value, mode) {
2955
+ return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
2956
+ }
2957
+ function FromRest5(T, M) {
2958
+ return T.map((L) => Intrinsic(L, M));
2959
+ }
2960
+ function Intrinsic(schema, mode, options = {}) {
2961
+ return (
2962
+ // Intrinsic-Mapped-Inference
2963
+ IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
2964
+ // Standard-Inference
2965
+ IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
2966
+ // Default Type
2967
+ CreateType(schema, options)
2968
+ )
2969
+ )
2970
+ );
2971
+ }
2972
+
2973
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
2974
+ function Capitalize(T, options = {}) {
2975
+ return Intrinsic(T, "Capitalize", options);
2976
+ }
2977
+
2978
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
2979
+ function Lowercase(T, options = {}) {
2980
+ return Intrinsic(T, "Lowercase", options);
2981
+ }
2982
+
2983
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
2984
+ function Uncapitalize(T, options = {}) {
2985
+ return Intrinsic(T, "Uncapitalize", options);
2986
+ }
2987
+
2988
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
2989
+ function Uppercase(T, options = {}) {
2990
+ return Intrinsic(T, "Uppercase", options);
2991
+ }
2992
+
2993
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
2994
+ function FromProperties12(properties, propertyKeys, options) {
2995
+ const result = {};
2996
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
2997
+ result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
2998
+ return result;
2999
+ }
3000
+ function FromMappedResult9(mappedResult, propertyKeys, options) {
3001
+ return FromProperties12(mappedResult.properties, propertyKeys, options);
3002
+ }
3003
+ function OmitFromMappedResult(mappedResult, propertyKeys, options) {
3004
+ const properties = FromMappedResult9(mappedResult, propertyKeys, options);
3005
+ return MappedResult(properties);
3006
+ }
3007
+
3008
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
3009
+ function FromIntersect6(types, propertyKeys) {
3010
+ return types.map((type) => OmitResolve(type, propertyKeys));
3011
+ }
3012
+ function FromUnion8(types, propertyKeys) {
3013
+ return types.map((type) => OmitResolve(type, propertyKeys));
3014
+ }
3015
+ function FromProperty3(properties, key) {
3016
+ const { [key]: _, ...R } = properties;
3017
+ return R;
3018
+ }
3019
+ function FromProperties13(properties, propertyKeys) {
3020
+ return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
3021
+ }
3022
+ function FromObject3(properties, propertyKeys) {
3023
+ const options = Discard(properties, [TransformKind, "$id", "required", "properties"]);
3024
+ const omittedProperties = FromProperties13(properties["properties"], propertyKeys);
3025
+ return Object2(omittedProperties, options);
3026
+ }
3027
+ function UnionFromPropertyKeys(propertyKeys) {
3028
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
3029
+ return Union(result);
3030
+ }
3031
+ function OmitResolve(properties, propertyKeys) {
3032
+ return IsIntersect(properties) ? Intersect(FromIntersect6(properties.allOf, propertyKeys)) : IsUnion(properties) ? Union(FromUnion8(properties.anyOf, propertyKeys)) : IsObject3(properties) ? FromObject3(properties, propertyKeys) : Object2({});
3033
+ }
3034
+ function Omit(type, key, options) {
3035
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
3036
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
3037
+ const isTypeRef = IsRef(type);
3038
+ const isKeyRef = IsRef(key);
3039
+ return IsMappedResult(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? OmitFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Omit", [type, typeKey], options) : CreateType({ ...OmitResolve(type, propertyKeys), ...options });
3040
+ }
3041
+
3042
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
3043
+ function FromPropertyKey2(type, key, options) {
3044
+ return { [key]: Omit(type, [key], Clone(options)) };
3045
+ }
3046
+ function FromPropertyKeys2(type, propertyKeys, options) {
3047
+ return propertyKeys.reduce((Acc, LK) => {
3048
+ return { ...Acc, ...FromPropertyKey2(type, LK, options) };
3049
+ }, {});
3050
+ }
3051
+ function FromMappedKey3(type, mappedKey, options) {
3052
+ return FromPropertyKeys2(type, mappedKey.keys, options);
3053
+ }
3054
+ function OmitFromMappedKey(type, mappedKey, options) {
3055
+ const properties = FromMappedKey3(type, mappedKey, options);
3056
+ return MappedResult(properties);
3057
+ }
3058
+
3059
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
3060
+ function FromProperties14(properties, propertyKeys, options) {
3061
+ const result = {};
3062
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
3063
+ result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
3064
+ return result;
3065
+ }
3066
+ function FromMappedResult10(mappedResult, propertyKeys, options) {
3067
+ return FromProperties14(mappedResult.properties, propertyKeys, options);
3068
+ }
3069
+ function PickFromMappedResult(mappedResult, propertyKeys, options) {
3070
+ const properties = FromMappedResult10(mappedResult, propertyKeys, options);
3071
+ return MappedResult(properties);
3072
+ }
3073
+
3074
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
3075
+ function FromIntersect7(types, propertyKeys) {
3076
+ return types.map((type) => PickResolve(type, propertyKeys));
3077
+ }
3078
+ function FromUnion9(types, propertyKeys) {
3079
+ return types.map((type) => PickResolve(type, propertyKeys));
3080
+ }
3081
+ function FromProperties15(properties, propertyKeys) {
3082
+ const result = {};
3083
+ for (const K2 of propertyKeys)
3084
+ if (K2 in properties)
3085
+ result[K2] = properties[K2];
3086
+ return result;
3087
+ }
3088
+ function FromObject4(T, K) {
3089
+ const options = Discard(T, [TransformKind, "$id", "required", "properties"]);
3090
+ const properties = FromProperties15(T["properties"], K);
3091
+ return Object2(properties, options);
3092
+ }
3093
+ function UnionFromPropertyKeys2(propertyKeys) {
3094
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
3095
+ return Union(result);
3096
+ }
3097
+ function PickResolve(properties, propertyKeys) {
3098
+ return IsIntersect(properties) ? Intersect(FromIntersect7(properties.allOf, propertyKeys)) : IsUnion(properties) ? Union(FromUnion9(properties.anyOf, propertyKeys)) : IsObject3(properties) ? FromObject4(properties, propertyKeys) : Object2({});
3099
+ }
3100
+ function Pick(type, key, options) {
3101
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
3102
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
3103
+ const isTypeRef = IsRef(type);
3104
+ const isKeyRef = IsRef(key);
3105
+ return IsMappedResult(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? PickFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Pick", [type, typeKey], options) : CreateType({ ...PickResolve(type, propertyKeys), ...options });
3106
+ }
3107
+
3108
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
3109
+ function FromPropertyKey3(type, key, options) {
3110
+ return {
3111
+ [key]: Pick(type, [key], Clone(options))
3112
+ };
3113
+ }
3114
+ function FromPropertyKeys3(type, propertyKeys, options) {
3115
+ return propertyKeys.reduce((result, leftKey) => {
3116
+ return { ...result, ...FromPropertyKey3(type, leftKey, options) };
3117
+ }, {});
3118
+ }
3119
+ function FromMappedKey4(type, mappedKey, options) {
3120
+ return FromPropertyKeys3(type, mappedKey.keys, options);
3121
+ }
3122
+ function PickFromMappedKey(type, mappedKey, options) {
3123
+ const properties = FromMappedKey4(type, mappedKey, options);
3124
+ return MappedResult(properties);
3125
+ }
3126
+
3127
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
3128
+ function FromComputed3(target, parameters) {
3129
+ return Computed("Partial", [Computed(target, parameters)]);
3130
+ }
3131
+ function FromRef3($ref) {
3132
+ return Computed("Partial", [Ref($ref)]);
3133
+ }
3134
+ function FromProperties16(properties) {
3135
+ const partialProperties = {};
3136
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
3137
+ partialProperties[K] = Optional(properties[K]);
3138
+ return partialProperties;
3139
+ }
3140
+ function FromObject5(type) {
3141
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
3142
+ const properties = FromProperties16(type["properties"]);
3143
+ return Object2(properties, options);
3144
+ }
3145
+ function FromRest6(types) {
3146
+ return types.map((type) => PartialResolve(type));
3147
+ }
3148
+ function PartialResolve(type) {
3149
+ return (
3150
+ // Mappable
3151
+ IsComputed(type) ? FromComputed3(type.target, type.parameters) : IsRef(type) ? FromRef3(type.$ref) : IsIntersect(type) ? Intersect(FromRest6(type.allOf)) : IsUnion(type) ? Union(FromRest6(type.anyOf)) : IsObject3(type) ? FromObject5(type) : (
3152
+ // Intrinsic
3153
+ IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
3154
+ // Passthrough
3155
+ Object2({})
3156
+ )
3157
+ )
3158
+ );
3159
+ }
3160
+ function Partial(type, options) {
3161
+ if (IsMappedResult(type)) {
3162
+ return PartialFromMappedResult(type, options);
3163
+ } else {
3164
+ return CreateType({ ...PartialResolve(type), ...options });
3165
+ }
3166
+ }
3167
+
3168
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
3169
+ function FromProperties17(K, options) {
3170
+ const Acc = {};
3171
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
3172
+ Acc[K2] = Partial(K[K2], Clone(options));
3173
+ return Acc;
3174
+ }
3175
+ function FromMappedResult11(R, options) {
3176
+ return FromProperties17(R.properties, options);
3177
+ }
3178
+ function PartialFromMappedResult(R, options) {
3179
+ const P = FromMappedResult11(R, options);
3180
+ return MappedResult(P);
3181
+ }
3182
+
3183
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
3184
+ function FromComputed4(target, parameters) {
3185
+ return Computed("Required", [Computed(target, parameters)]);
3186
+ }
3187
+ function FromRef4($ref) {
3188
+ return Computed("Required", [Ref($ref)]);
3189
+ }
3190
+ function FromProperties18(properties) {
3191
+ const requiredProperties = {};
3192
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
3193
+ requiredProperties[K] = Discard(properties[K], [OptionalKind]);
3194
+ return requiredProperties;
3195
+ }
3196
+ function FromObject6(type) {
3197
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
3198
+ const properties = FromProperties18(type["properties"]);
3199
+ return Object2(properties, options);
3200
+ }
3201
+ function FromRest7(types) {
3202
+ return types.map((type) => RequiredResolve(type));
3203
+ }
3204
+ function RequiredResolve(type) {
3205
+ return (
3206
+ // Mappable
3207
+ IsComputed(type) ? FromComputed4(type.target, type.parameters) : IsRef(type) ? FromRef4(type.$ref) : IsIntersect(type) ? Intersect(FromRest7(type.allOf)) : IsUnion(type) ? Union(FromRest7(type.anyOf)) : IsObject3(type) ? FromObject6(type) : (
3208
+ // Intrinsic
3209
+ IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
3210
+ // Passthrough
3211
+ Object2({})
3212
+ )
3213
+ )
3214
+ );
3215
+ }
3216
+ function Required(type, options) {
3217
+ if (IsMappedResult(type)) {
3218
+ return RequiredFromMappedResult(type, options);
3219
+ } else {
3220
+ return CreateType({ ...RequiredResolve(type), ...options });
3221
+ }
3222
+ }
3223
+
3224
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
3225
+ function FromProperties19(P, options) {
3226
+ const Acc = {};
3227
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3228
+ Acc[K2] = Required(P[K2], options);
3229
+ return Acc;
3230
+ }
3231
+ function FromMappedResult12(R, options) {
3232
+ return FromProperties19(R.properties, options);
3233
+ }
3234
+ function RequiredFromMappedResult(R, options) {
3235
+ const P = FromMappedResult12(R, options);
3236
+ return MappedResult(P);
3237
+ }
3238
+
3239
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
3240
+ function DereferenceParameters(moduleProperties, types) {
3241
+ return types.map((type) => {
3242
+ return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
3243
+ });
3244
+ }
3245
+ function Dereference(moduleProperties, ref) {
3246
+ return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
3247
+ }
3248
+ function FromAwaited(parameters) {
3249
+ return Awaited(parameters[0]);
3250
+ }
3251
+ function FromIndex(parameters) {
3252
+ return Index(parameters[0], parameters[1]);
3253
+ }
3254
+ function FromKeyOf(parameters) {
3255
+ return KeyOf(parameters[0]);
3256
+ }
3257
+ function FromPartial(parameters) {
3258
+ return Partial(parameters[0]);
3259
+ }
3260
+ function FromOmit(parameters) {
3261
+ return Omit(parameters[0], parameters[1]);
3262
+ }
3263
+ function FromPick(parameters) {
3264
+ return Pick(parameters[0], parameters[1]);
3265
+ }
3266
+ function FromRequired(parameters) {
3267
+ return Required(parameters[0]);
3268
+ }
3269
+ function FromComputed5(moduleProperties, target, parameters) {
3270
+ const dereferenced = DereferenceParameters(moduleProperties, parameters);
3271
+ return target === "Awaited" ? FromAwaited(dereferenced) : target === "Index" ? FromIndex(dereferenced) : target === "KeyOf" ? FromKeyOf(dereferenced) : target === "Partial" ? FromPartial(dereferenced) : target === "Omit" ? FromOmit(dereferenced) : target === "Pick" ? FromPick(dereferenced) : target === "Required" ? FromRequired(dereferenced) : Never();
3272
+ }
3273
+ function FromArray6(moduleProperties, type) {
3274
+ return Array2(FromType2(moduleProperties, type));
3275
+ }
3276
+ function FromAsyncIterator3(moduleProperties, type) {
3277
+ return AsyncIterator(FromType2(moduleProperties, type));
3278
+ }
3279
+ function FromConstructor3(moduleProperties, parameters, instanceType) {
3280
+ return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
3281
+ }
3282
+ function FromFunction3(moduleProperties, parameters, returnType) {
3283
+ return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
3284
+ }
3285
+ function FromIntersect8(moduleProperties, types) {
3286
+ return Intersect(FromTypes2(moduleProperties, types));
3287
+ }
3288
+ function FromIterator3(moduleProperties, type) {
3289
+ return Iterator(FromType2(moduleProperties, type));
3290
+ }
3291
+ function FromObject7(moduleProperties, properties) {
3292
+ return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
3293
+ return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
3294
+ }, {}));
3295
+ }
3296
+ function FromRecord3(moduleProperties, type) {
3297
+ const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
3298
+ const result = CloneType(type);
3299
+ result.patternProperties[pattern] = value;
3300
+ return result;
3301
+ }
3302
+ function FromTransform(moduleProperties, transform) {
3303
+ return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
3304
+ }
3305
+ function FromTuple5(moduleProperties, types) {
3306
+ return Tuple(FromTypes2(moduleProperties, types));
3307
+ }
3308
+ function FromUnion10(moduleProperties, types) {
3309
+ return Union(FromTypes2(moduleProperties, types));
3310
+ }
3311
+ function FromTypes2(moduleProperties, types) {
3312
+ return types.map((type) => FromType2(moduleProperties, type));
3313
+ }
3314
+ function FromType2(moduleProperties, type) {
3315
+ return (
3316
+ // Modifiers
3317
+ IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
3318
+ // Transform
3319
+ IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
3320
+ // Types
3321
+ IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) : IsAsyncIterator2(type) ? CreateType(FromAsyncIterator3(moduleProperties, type.items), type) : IsComputed(type) ? CreateType(FromComputed5(moduleProperties, type.target, type.parameters)) : IsConstructor(type) ? CreateType(FromConstructor3(moduleProperties, type.parameters, type.returns), type) : IsFunction2(type) ? CreateType(FromFunction3(moduleProperties, type.parameters, type.returns), type) : IsIntersect(type) ? CreateType(FromIntersect8(moduleProperties, type.allOf), type) : IsIterator2(type) ? CreateType(FromIterator3(moduleProperties, type.items), type) : IsObject3(type) ? CreateType(FromObject7(moduleProperties, type.properties), type) : IsRecord(type) ? CreateType(FromRecord3(moduleProperties, type)) : IsTuple(type) ? CreateType(FromTuple5(moduleProperties, type.items || []), type) : IsUnion(type) ? CreateType(FromUnion10(moduleProperties, type.anyOf), type) : type
3322
+ )
3323
+ )
3324
+ );
3325
+ }
3326
+ function ComputeType(moduleProperties, key) {
3327
+ return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
3328
+ }
3329
+ function ComputeModuleProperties(moduleProperties) {
3330
+ return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
3331
+ return { ...result, [key]: ComputeType(moduleProperties, key) };
3332
+ }, {});
3333
+ }
3334
+
3335
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
3336
+ var TModule = class {
3337
+ constructor($defs) {
3338
+ const computed = ComputeModuleProperties($defs);
3339
+ const identified = this.WithIdentifiers(computed);
3340
+ this.$defs = identified;
3341
+ }
3342
+ /** `[Json]` Imports a Type by Key. */
3343
+ Import(key, options) {
3344
+ const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
3345
+ return CreateType({ [Kind]: "Import", $defs, $ref: key });
3346
+ }
3347
+ // prettier-ignore
3348
+ WithIdentifiers($defs) {
3349
+ return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
3350
+ return { ...result, [key]: { ...$defs[key], $id: key } };
3351
+ }, {});
3352
+ }
3353
+ };
3354
+ function Module(properties) {
3355
+ return new TModule(properties);
3356
+ }
3357
+
3358
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
3359
+ function Not(type, options) {
3360
+ return CreateType({ [Kind]: "Not", not: type }, options);
3361
+ }
3362
+
3363
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
3364
+ function Parameters(schema, options) {
3365
+ return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
3366
+ }
3367
+
3368
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
3369
+ var Ordinal = 0;
3370
+ function Recursive(callback, options = {}) {
3371
+ if (IsUndefined(options.$id))
3372
+ options.$id = `T${Ordinal++}`;
3373
+ const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
3374
+ thisType.$id = options.$id;
3375
+ return CreateType({ [Hint]: "Recursive", ...thisType }, options);
3376
+ }
3377
+
3378
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
3379
+ function RegExp2(unresolved, options) {
3380
+ const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
3381
+ return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
3382
+ }
3383
+
3384
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
3385
+ function RestResolve(T) {
3386
+ return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
3387
+ }
3388
+ function Rest(T) {
3389
+ return RestResolve(T);
3390
+ }
3391
+
3392
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
3393
+ function ReturnType(schema, options) {
3394
+ return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
3395
+ }
3396
+
3397
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
3398
+ var TransformDecodeBuilder = class {
3399
+ constructor(schema) {
3400
+ this.schema = schema;
3401
+ }
3402
+ Decode(decode) {
3403
+ return new TransformEncodeBuilder(this.schema, decode);
3404
+ }
3405
+ };
3406
+ var TransformEncodeBuilder = class {
3407
+ constructor(schema, decode) {
3408
+ this.schema = schema;
3409
+ this.decode = decode;
3410
+ }
3411
+ EncodeTransform(encode, schema) {
3412
+ const Encode = (value) => schema[TransformKind].Encode(encode(value));
3413
+ const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
3414
+ const Codec = { Encode, Decode };
3415
+ return { ...schema, [TransformKind]: Codec };
3416
+ }
3417
+ EncodeSchema(encode, schema) {
3418
+ const Codec = { Decode: this.decode, Encode: encode };
3419
+ return { ...schema, [TransformKind]: Codec };
3420
+ }
3421
+ Encode(encode) {
3422
+ return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
3423
+ }
3424
+ };
3425
+ function Transform(schema) {
3426
+ return new TransformDecodeBuilder(schema);
3427
+ }
3428
+
3429
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
3430
+ function Unsafe(options = {}) {
3431
+ return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
3432
+ }
3433
+
3434
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
3435
+ function Void(options) {
3436
+ return CreateType({ [Kind]: "Void", type: "void" }, options);
3437
+ }
3438
+
3439
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
3440
+ var type_exports2 = {};
3441
+ __export(type_exports2, {
3442
+ Any: () => Any,
3443
+ Argument: () => Argument,
3444
+ Array: () => Array2,
3445
+ AsyncIterator: () => AsyncIterator,
3446
+ Awaited: () => Awaited,
3447
+ BigInt: () => BigInt,
3448
+ Boolean: () => Boolean,
3449
+ Capitalize: () => Capitalize,
3450
+ Composite: () => Composite,
3451
+ Const: () => Const,
3452
+ Constructor: () => Constructor,
3453
+ ConstructorParameters: () => ConstructorParameters,
3454
+ Date: () => Date2,
3455
+ Enum: () => Enum,
3456
+ Exclude: () => Exclude,
3457
+ Extends: () => Extends,
3458
+ Extract: () => Extract,
3459
+ Function: () => Function,
3460
+ Index: () => Index,
3461
+ InstanceType: () => InstanceType,
3462
+ Instantiate: () => Instantiate,
3463
+ Integer: () => Integer,
3464
+ Intersect: () => Intersect,
3465
+ Iterator: () => Iterator,
3466
+ KeyOf: () => KeyOf,
3467
+ Literal: () => Literal,
3468
+ Lowercase: () => Lowercase,
3469
+ Mapped: () => Mapped,
3470
+ Module: () => Module,
3471
+ Never: () => Never,
3472
+ Not: () => Not,
3473
+ Null: () => Null,
3474
+ Number: () => Number2,
3475
+ Object: () => Object2,
3476
+ Omit: () => Omit,
3477
+ Optional: () => Optional,
3478
+ Parameters: () => Parameters,
3479
+ Partial: () => Partial,
3480
+ Pick: () => Pick,
3481
+ Promise: () => Promise2,
3482
+ Readonly: () => Readonly,
3483
+ ReadonlyOptional: () => ReadonlyOptional,
3484
+ Record: () => Record,
3485
+ Recursive: () => Recursive,
3486
+ Ref: () => Ref,
3487
+ RegExp: () => RegExp2,
3488
+ Required: () => Required,
3489
+ Rest: () => Rest,
3490
+ ReturnType: () => ReturnType,
3491
+ String: () => String2,
3492
+ Symbol: () => Symbol2,
3493
+ TemplateLiteral: () => TemplateLiteral,
3494
+ Transform: () => Transform,
3495
+ Tuple: () => Tuple,
3496
+ Uint8Array: () => Uint8Array2,
3497
+ Uncapitalize: () => Uncapitalize,
3498
+ Undefined: () => Undefined,
3499
+ Union: () => Union,
3500
+ Unknown: () => Unknown,
3501
+ Unsafe: () => Unsafe,
3502
+ Uppercase: () => Uppercase,
3503
+ Void: () => Void
3504
+ });
3505
+
3506
+ // ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
3507
+ var Type = type_exports2;
3508
+
3509
+ // src/jobs/send-scheduled-email.ts
3510
+ var SendScheduledEmailInput = Type.Object({
3511
+ notificationId: Type.Number(),
3512
+ to: Type.Union([Type.String(), Type.Array(Type.String())]),
3513
+ subject: Type.Optional(Type.String()),
3514
+ template: Type.Optional(Type.String()),
3515
+ data: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
3516
+ text: Type.Optional(Type.String()),
3517
+ html: Type.Optional(Type.String()),
3518
+ from: Type.Optional(Type.String()),
3519
+ replyTo: Type.Optional(Type.String())
3520
+ });
3521
+ var sendScheduledEmailJob = job("notification.send-scheduled-email").input(SendScheduledEmailInput).options({
3522
+ retryLimit: 3,
3523
+ retryDelay: 5e3
3524
+ }).handler(async (input) => {
3525
+ const { notificationId, ...emailParams } = input;
3526
+ await markNotificationPending(notificationId);
3527
+ const result = await sendEmail(emailParams);
3528
+ if (result.success) {
3529
+ await markNotificationSent(notificationId, result.messageId);
3530
+ } else {
3531
+ await markNotificationFailed(notificationId, result.error || "Unknown error");
3532
+ throw new Error(result.error || "Failed to send email");
3533
+ }
3534
+ });
3535
+
3536
+ // src/jobs/send-scheduled-sms.ts
3537
+ import { job as job2 } from "@spfn/core/job";
3538
+ var SendScheduledSmsInput = Type.Object({
3539
+ notificationId: Type.Number(),
3540
+ to: Type.Union([Type.String(), Type.Array(Type.String())]),
3541
+ message: Type.Optional(Type.String()),
3542
+ template: Type.Optional(Type.String()),
3543
+ data: Type.Optional(Type.Record(Type.String(), Type.Unknown()))
3544
+ });
3545
+ var sendScheduledSmsJob = job2("notification.send-scheduled-sms").input(SendScheduledSmsInput).options({
3546
+ retryLimit: 3,
3547
+ retryDelay: 5e3
3548
+ }).handler(async (input) => {
3549
+ const { notificationId, ...smsParams } = input;
3550
+ await markNotificationPending(notificationId);
3551
+ const result = await sendSMS(smsParams);
3552
+ if (result.success) {
3553
+ await markNotificationSent(notificationId, result.messageId);
3554
+ } else {
3555
+ await markNotificationFailed(notificationId, result.error || "Unknown error");
3556
+ throw new Error(result.error || "Failed to send SMS");
3557
+ }
3558
+ });
3559
+
3560
+ // src/services/schedule.service.ts
3561
+ async function scheduleEmail(params, options) {
3562
+ const recipients = Array.isArray(params.to) ? params.to : [params.to];
3563
+ let subject = params.subject;
3564
+ let text2 = params.text;
3565
+ let html = params.html;
3566
+ if (params.template) {
3567
+ if (!hasTemplate(params.template)) {
3568
+ return {
3569
+ success: false,
3570
+ error: `Template not found: ${params.template}`
3571
+ };
3572
+ }
3573
+ const rendered = renderTemplate(params.template, params.data || {}, "email");
3574
+ if (rendered.email) {
3575
+ subject = rendered.email.subject;
3576
+ text2 = rendered.email.text;
3577
+ html = rendered.email.html;
3578
+ }
3579
+ }
3580
+ if (!subject) {
3581
+ return {
3582
+ success: false,
3583
+ error: "Email subject is required"
3584
+ };
3585
+ }
3586
+ if (!text2 && !html) {
3587
+ return {
3588
+ success: false,
3589
+ error: "Email content (text or html) is required"
3590
+ };
3591
+ }
3592
+ try {
3593
+ const notification = await createScheduledNotification({
3594
+ channel: "email",
3595
+ recipient: recipients.join(","),
3596
+ templateName: params.template,
3597
+ templateData: params.data,
3598
+ subject,
3599
+ content: text2,
3600
+ providerName: "pending",
3601
+ // Will be set when job runs
3602
+ scheduledAt: options.scheduledAt,
3603
+ referenceType: options.referenceType,
3604
+ referenceId: options.referenceId
3605
+ });
3606
+ const jobId = await sendScheduledEmailJob.send(
3607
+ {
3608
+ notificationId: notification.id,
3609
+ to: params.to,
3610
+ subject: params.subject,
3611
+ template: params.template,
3612
+ data: params.data,
3613
+ text: params.text,
3614
+ html: params.html,
3615
+ from: params.from,
3616
+ replyTo: params.replyTo
3617
+ },
3618
+ { startAfter: options.scheduledAt }
3619
+ );
3620
+ if (jobId) {
3621
+ await updateNotificationJobId(notification.id, jobId);
3622
+ }
3623
+ return {
3624
+ success: true,
3625
+ notificationId: notification.id,
3626
+ jobId: jobId || void 0
3627
+ };
3628
+ } catch (error) {
3629
+ return {
3630
+ success: false,
3631
+ error: error instanceof Error ? error.message : "Failed to schedule email"
3632
+ };
3633
+ }
3634
+ }
3635
+ async function scheduleSMS(params, options) {
3636
+ const recipients = Array.isArray(params.to) ? params.to : [params.to];
3637
+ let message = params.message;
3638
+ if (params.template) {
3639
+ if (!hasTemplate(params.template)) {
3640
+ return {
3641
+ success: false,
3642
+ error: `Template not found: ${params.template}`
3643
+ };
3644
+ }
3645
+ const rendered = renderTemplate(params.template, params.data || {}, "sms");
3646
+ if (rendered.sms) {
3647
+ message = rendered.sms.message;
3648
+ }
3649
+ }
3650
+ if (!message) {
3651
+ return {
3652
+ success: false,
3653
+ error: "SMS message is required"
3654
+ };
3655
+ }
3656
+ try {
3657
+ const normalizedRecipients = recipients.map((r) => normalizePhoneNumber(r));
3658
+ const notification = await createScheduledNotification({
3659
+ channel: "sms",
3660
+ recipient: normalizedRecipients.join(","),
3661
+ templateName: params.template,
3662
+ templateData: params.data,
3663
+ content: message,
3664
+ providerName: "pending",
3665
+ // Will be set when job runs
3666
+ scheduledAt: options.scheduledAt,
3667
+ referenceType: options.referenceType,
3668
+ referenceId: options.referenceId
3669
+ });
3670
+ const jobId = await sendScheduledSmsJob.send(
3671
+ {
3672
+ notificationId: notification.id,
3673
+ to: params.to,
3674
+ message: params.message,
3675
+ template: params.template,
3676
+ data: params.data
3677
+ },
3678
+ { startAfter: options.scheduledAt }
3679
+ );
3680
+ if (jobId) {
3681
+ await updateNotificationJobId(notification.id, jobId);
3682
+ }
3683
+ return {
3684
+ success: true,
3685
+ notificationId: notification.id,
3686
+ jobId: jobId || void 0
3687
+ };
3688
+ } catch (error) {
3689
+ return {
3690
+ success: false,
3691
+ error: error instanceof Error ? error.message : "Failed to schedule SMS"
3692
+ };
3693
+ }
3694
+ }
3695
+
3696
+ // src/services/cancel.service.ts
3697
+ import { getBoss } from "@spfn/core/job";
3698
+ import { findOne as findOne2 } from "@spfn/core/db";
3699
+ async function cancelNotification(notificationId) {
3700
+ const notification = await findOne2(notifications, { id: notificationId });
3701
+ if (!notification) {
3702
+ return {
3703
+ success: false,
3704
+ error: "Notification not found"
3705
+ };
3706
+ }
3707
+ if (notification.status !== "scheduled") {
3708
+ return {
3709
+ success: false,
3710
+ error: `Cannot cancel notification with status: ${notification.status}`
3711
+ };
3712
+ }
3713
+ try {
3714
+ if (notification.jobId) {
3715
+ const boss = getBoss();
3716
+ if (boss) {
3717
+ const queueName = notification.channel === "email" ? "notification.send-scheduled-email" : notification.channel === "sms" ? "notification.send-scheduled-sms" : null;
3718
+ if (queueName) {
3719
+ await boss.cancel(queueName, notification.jobId);
3720
+ }
3721
+ }
3722
+ }
3723
+ await cancelScheduledNotification(notificationId);
3724
+ return { success: true };
3725
+ } catch (error) {
3726
+ return {
3727
+ success: false,
3728
+ error: error instanceof Error ? error.message : "Failed to cancel notification"
3729
+ };
3730
+ }
3731
+ }
3732
+ async function cancelNotificationsByReference(referenceType, referenceId) {
3733
+ const { findMany: findMany2 } = await import("@spfn/core/db");
3734
+ const { eq: eq2, and: and2 } = await import("drizzle-orm");
3735
+ const scheduledNotifications = await findMany2(notifications, {
3736
+ where: and2(
3737
+ eq2(notifications.referenceType, referenceType),
3738
+ eq2(notifications.referenceId, referenceId),
3739
+ eq2(notifications.status, "scheduled")
3740
+ )
3741
+ });
3742
+ let cancelled = 0;
3743
+ let errors = 0;
3744
+ for (const notification of scheduledNotifications) {
3745
+ const result = await cancelNotification(notification.id);
3746
+ if (result.success) {
3747
+ cancelled++;
3748
+ } else {
3749
+ errors++;
3750
+ }
3751
+ }
3752
+ return { cancelled, errors };
3753
+ }
3754
+
3755
+ // src/jobs/router.ts
3756
+ import { defineJobRouter } from "@spfn/core/job";
3757
+ var notificationJobRouter = defineJobRouter({
3758
+ sendScheduledEmail: sendScheduledEmailJob,
3759
+ sendScheduledSms: sendScheduledSmsJob
3760
+ });
3761
+
3762
+ // src/server.ts
3763
+ registerBuiltinTemplates();
3764
+ export {
3765
+ NOTIFICATION_CHANNELS,
3766
+ NOTIFICATION_STATUSES,
3767
+ cancelNotification,
3768
+ cancelNotificationsByReference,
3769
+ cancelScheduledNotification,
3770
+ configureNotification,
3771
+ countNotifications,
3772
+ createNotificationRecord,
3773
+ createScheduledNotification,
3774
+ findNotificationByJobId,
3775
+ findNotifications,
3776
+ findScheduledNotifications,
3777
+ getAppName,
3778
+ getEmailFrom,
3779
+ getEmailReplyTo,
3780
+ getNotificationConfig,
3781
+ getNotificationStats,
3782
+ getSmsDefaultCountryCode,
3783
+ getTemplate,
3784
+ getTemplateNames,
3785
+ hasTemplate,
3786
+ markNotificationFailed,
3787
+ markNotificationPending,
3788
+ markNotificationSent,
3789
+ notificationJobRouter,
3790
+ notifications,
3791
+ registerBuiltinTemplates,
3792
+ registerEmailProvider,
3793
+ registerFilter,
3794
+ registerSMSProvider,
3795
+ registerTemplate,
3796
+ renderTemplate,
3797
+ scheduleEmail,
3798
+ scheduleSMS,
3799
+ sendEmail,
3800
+ sendEmailBulk,
3801
+ sendSMS,
3802
+ sendSMSBulk,
3803
+ sendScheduledEmailJob,
3804
+ sendScheduledSmsJob,
3805
+ updateNotificationJobId
3806
+ };
3807
+ //# sourceMappingURL=server.js.map