@mappa-ai/mappa-node 1.2.4 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -391
- package/dist/Mappa-BTrlzSaB.d.cts +621 -0
- package/dist/Mappa-BjTJceWa.d.mts +621 -0
- package/dist/index.cjs +5184 -1036
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1397
- package/dist/index.d.mts +3 -1397
- package/dist/index.mjs +5184 -1034
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +37 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +26 -0
- package/dist/node.d.mts +26 -0
- package/dist/node.mjs +34 -0
- package/dist/node.mjs.map +1 -0
- package/package.json +44 -28
- package/LICENSE +0 -21
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["jitter"],"sources":["../src/errors.ts","../src/resources/credits.ts","../src/resources/entities.ts","../src/resources/feedback.ts","../src/resources/files.ts","../src/resources/health.ts","../src/utils/index.ts","../src/resources/jobs.ts","../src/resources/reports.ts","../src/resources/transport.ts","../src/resources/webhooks.ts","../src/Mappa.ts","../src/types.ts","../src/index.ts"],"sourcesContent":["/**\n * Symbol for custom Node.js inspect formatting.\n * Ensures errors display nicely in console.log, REPL, and debuggers.\n */\nconst customInspect = Symbol.for(\"nodejs.util.inspect.custom\");\n\n/**\n * Formats error details for display.\n */\nfunction formatDetails(details: unknown, indent = \" \"): string {\n\tif (details === undefined || details === null) return \"\";\n\ttry {\n\t\tconst json = JSON.stringify(details, null, 2);\n\t\t// Indent each line for nested display\n\t\treturn json.split(\"\\n\").join(`\\n${indent}`);\n\t} catch {\n\t\treturn String(details);\n\t}\n}\n\n/**\n * Base error type for all SDK-raised errors.\n *\n * When available, {@link MappaError.requestId} can be used to correlate a failure\n * with server logs/support.\n */\nexport class MappaError extends Error {\n\toverride name = \"MappaError\";\n\trequestId?: string;\n\tcode?: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts?: { requestId?: string; code?: string; cause?: unknown },\n\t) {\n\t\tsuper(message);\n\t\tthis.requestId = opts?.requestId;\n\t\tthis.code = opts?.code;\n\t\tthis.cause = opts?.cause;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tif (this.code) lines.push(` Code: ${this.code}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\t[customInspect](): string {\n\t\treturn this.toString();\n\t}\n}\n\n/**\n * Error returned when the API responds with a non-2xx status.\n */\nexport class ApiError extends MappaError {\n\toverride name = \"ApiError\";\n\tstatus: number;\n\tdetails?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts: {\n\t\t\tstatus: number;\n\t\t\trequestId?: string;\n\t\t\tcode?: string;\n\t\t\tdetails?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message, { requestId: opts.requestId, code: opts.code });\n\t\tthis.status = opts.status;\n\t\tthis.details = opts.details;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tlines.push(` Status: ${this.status}`);\n\t\tif (this.code) lines.push(` Code: ${this.code}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\tif (this.details !== undefined && this.details !== null) {\n\t\t\tlines.push(` Details: ${formatDetails(this.details)}`);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\n/**\n * Error returned for HTTP 429 responses.\n *\n * If provided by the server, {@link RateLimitError.retryAfterMs} indicates when\n * it is safe to retry.\n */\nexport class RateLimitError extends ApiError {\n\toverride name = \"RateLimitError\";\n\tretryAfterMs?: number;\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tlines.push(` Status: ${this.status}`);\n\t\tif (this.retryAfterMs !== undefined) {\n\t\t\tlines.push(` Retry After: ${this.retryAfterMs}ms`);\n\t\t}\n\t\tif (this.code) lines.push(` Code: ${this.code}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\n/**\n * Error returned for authentication/authorization failures (typically 401/403).\n */\nexport class AuthError extends ApiError {\n\toverride name = \"AuthError\";\n}\n\n/**\n * Error returned when the server rejects a request as invalid (typically 422).\n */\nexport class ValidationError extends ApiError {\n\toverride name = \"ValidationError\";\n}\n\n/**\n * Error returned when the account lacks sufficient credits (HTTP 402).\n *\n * Use {@link InsufficientCreditsError.required} and {@link InsufficientCreditsError.available}\n * to inform users how many credits are needed.\n *\n * @example\n * ```typescript\n * try {\n * await mappa.reports.createJob({ ... });\n * } catch (err) {\n * if (err instanceof InsufficientCreditsError) {\n * console.log(`Need ${err.required} credits, have ${err.available}`);\n * }\n * }\n * ```\n */\nexport class InsufficientCreditsError extends ApiError {\n\toverride name = \"InsufficientCreditsError\";\n\t/** Credits required for the operation */\n\trequired: number;\n\t/** Credits currently available */\n\tavailable: number;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts: {\n\t\t\tstatus: number;\n\t\t\trequestId?: string;\n\t\t\tcode?: string;\n\t\t\tdetails?: { required?: number; available?: number };\n\t\t},\n\t) {\n\t\tsuper(message, opts);\n\t\tthis.required = opts.details?.required ?? 0;\n\t\tthis.available = opts.details?.available ?? 0;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tlines.push(` Status: ${this.status}`);\n\t\tlines.push(` Required: ${this.required} credits`);\n\t\tlines.push(` Available: ${this.available} credits`);\n\t\tif (this.code) lines.push(` Code: ${this.code}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\n/**\n * Error thrown by polling helpers when a job reaches the \"failed\" terminal state.\n */\nexport class JobFailedError extends MappaError {\n\toverride name = \"JobFailedError\";\n\tjobId: string;\n\n\tconstructor(\n\t\tjobId: string,\n\t\tmessage: string,\n\t\topts?: { requestId?: string; code?: string; cause?: unknown },\n\t) {\n\t\tsuper(message, opts);\n\t\tthis.jobId = jobId;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tlines.push(` Job ID: ${this.jobId}`);\n\t\tif (this.code) lines.push(` Code: ${this.code}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\n/**\n * Error thrown by polling helpers when a job reaches the \"canceled\" terminal state.\n */\nexport class JobCanceledError extends MappaError {\n\toverride name = \"JobCanceledError\";\n\tjobId: string;\n\n\tconstructor(\n\t\tjobId: string,\n\t\tmessage: string,\n\t\topts?: { requestId?: string; cause?: unknown },\n\t) {\n\t\tsuper(message, opts);\n\t\tthis.jobId = jobId;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tlines.push(` Job ID: ${this.jobId}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\n/**\n * Error thrown when SSE streaming fails after all retries.\n *\n * Includes recovery metadata to allow callers to resume or retry:\n * - `jobId`: The job being streamed (when known)\n * - `lastEventId`: Last successfully received event ID for resumption\n * - `url`: The stream URL that failed\n * - `retryCount`: Number of retries attempted\n *\n * @example\n * ```typescript\n * try {\n * for await (const event of mappa.jobs.stream(jobId)) { ... }\n * } catch (err) {\n * if (err instanceof StreamError) {\n * console.log(`Stream failed for job ${err.jobId}`);\n * console.log(`Last event ID: ${err.lastEventId}`);\n * // Can retry with: mappa.jobs.stream(err.jobId)\n * }\n * }\n * ```\n */\nexport class StreamError extends MappaError {\n\toverride name = \"StreamError\";\n\tjobId?: string;\n\tlastEventId?: string;\n\turl?: string;\n\tretryCount: number;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts: {\n\t\t\tjobId?: string;\n\t\t\tlastEventId?: string;\n\t\t\turl?: string;\n\t\t\tretryCount: number;\n\t\t\trequestId?: string;\n\t\t\tcause?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message, { requestId: opts.requestId, cause: opts.cause });\n\t\tthis.jobId = opts.jobId;\n\t\tthis.lastEventId = opts.lastEventId;\n\t\tthis.url = opts.url;\n\t\tthis.retryCount = opts.retryCount;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tif (this.jobId) lines.push(` Job ID: ${this.jobId}`);\n\t\tif (this.lastEventId) lines.push(` Last Event ID: ${this.lastEventId}`);\n\t\tif (this.url) lines.push(` URL: ${this.url}`);\n\t\tlines.push(` Retry Count: ${this.retryCount}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n","import { MappaError } from \"$/errors\";\nimport type { Transport } from \"$/resources/transport\";\nimport type { CreditBalance, CreditTransaction, CreditUsage } from \"$/types\";\n\nexport type ListTransactionsOptions = {\n\t/** Max transactions per page (1-100, default 50) */\n\tlimit?: number;\n\t/** Offset for pagination (default 0) */\n\toffset?: number;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport type ListTransactionsResponse = {\n\ttransactions: CreditTransaction[];\n\tpagination: {\n\t\tlimit: number;\n\t\toffset: number;\n\t\ttotal: number;\n\t};\n};\n\n/**\n * Credits API resource.\n *\n * Provides methods to manage and query credit balances, transaction history,\n * and job-specific credit usage.\n */\nexport class CreditsResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\t/**\n\t * Get the current credit balance for your team.\n\t *\n\t * @example\n\t * const balance = await mappa.credits.getBalance();\n\t * console.log(`Available: ${balance.available} credits`);\n\t */\n\tasync getBalance(opts?: {\n\t\trequestId?: string;\n\t\tsignal?: AbortSignal;\n\t}): Promise<CreditBalance> {\n\t\tconst res = await this.transport.request<CreditBalance>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/credits/balance\",\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * List credit transactions with offset pagination.\n\t *\n\t * @example\n\t * const { transactions, pagination } = await mappa.credits.listTransactions({ limit: 25 });\n\t * console.log(`Showing ${transactions.length} of ${pagination.total}`);\n\t */\n\tasync listTransactions(\n\t\topts?: ListTransactionsOptions,\n\t): Promise<ListTransactionsResponse> {\n\t\tconst query: Record<string, string> = {};\n\t\tif (opts?.limit !== undefined) query.limit = String(opts.limit);\n\t\tif (opts?.offset !== undefined) query.offset = String(opts.offset);\n\n\t\tconst res = await this.transport.request<ListTransactionsResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/credits/transactions\",\n\t\t\tquery,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Iterate over all transactions, automatically handling pagination.\n\t *\n\t * @example\n\t * for await (const tx of mappa.credits.listAllTransactions()) {\n\t * console.log(`${tx.type}: ${tx.amount}`);\n\t * }\n\t */\n\tasync *listAllTransactions(\n\t\topts?: Omit<ListTransactionsOptions, \"offset\">,\n\t): AsyncIterable<CreditTransaction> {\n\t\tlet offset = 0;\n\t\tconst limit = opts?.limit ?? 50;\n\n\t\twhile (true) {\n\t\t\tconst page = await this.listTransactions({ ...opts, limit, offset });\n\t\t\tfor (const tx of page.transactions) {\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\toffset += page.transactions.length;\n\t\t\tif (offset >= page.pagination.total) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get credit usage details for a completed job.\n\t *\n\t * @example\n\t * const usage = await mappa.credits.getJobUsage(\"job_xyz\");\n\t * console.log(`Net credits used: ${usage.creditsNetUsed}`);\n\t */\n\tasync getJobUsage(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<CreditUsage> {\n\t\tif (!jobId) throw new MappaError(\"jobId is required\");\n\n\t\tconst res = await this.transport.request<CreditUsage>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/credits/usage/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Check if the team has enough available credits for an operation.\n\t *\n\t * @example\n\t * if (await mappa.credits.hasEnough(100)) {\n\t * await mappa.reports.createJob(...);\n\t * }\n\t */\n\tasync hasEnough(\n\t\tcredits: number,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<boolean> {\n\t\tconst balance = await this.getBalance(opts);\n\t\treturn balance.available >= credits;\n\t}\n\n\t/**\n\t * Get the number of available credits (balance - reserved).\n\t *\n\t * @example\n\t * const available = await mappa.credits.getAvailable();\n\t * console.log(`You can spend ${available} credits`);\n\t */\n\tasync getAvailable(opts?: {\n\t\trequestId?: string;\n\t\tsignal?: AbortSignal;\n\t}): Promise<number> {\n\t\tconst balance = await this.getBalance(opts);\n\t\treturn balance.available;\n\t}\n}\n","import { MappaError } from \"$/errors\";\nimport type { Transport } from \"$/resources/transport\";\nimport type {\n\tEntity,\n\tEntityTagsResult,\n\tListEntitiesOptions,\n\tListEntitiesResponse,\n} from \"$/types\";\n\n/**\n * Tag validation regex: 1-64 chars, alphanumeric with underscores and hyphens.\n */\nconst TAG_REGEX = /^[a-zA-Z0-9_-]{1,64}$/;\n\n/**\n * Maximum number of tags per request.\n */\nconst MAX_TAGS_PER_REQUEST = 10;\n\n/**\n * Validates a single tag.\n * @throws {MappaError} if validation fails\n */\nfunction validateTag(tag: string): void {\n\tif (typeof tag !== \"string\") {\n\t\tthrow new MappaError(\"Tags must be strings\");\n\t}\n\tif (!TAG_REGEX.test(tag)) {\n\t\tthrow new MappaError(\n\t\t\t`Invalid tag \"${tag}\": must be 1-64 characters, alphanumeric with underscores and hyphens only`,\n\t\t);\n\t}\n}\n\n/**\n * Validates an array of tags.\n * @throws {MappaError} if validation fails\n */\nfunction validateTags(tags: string[]): void {\n\tif (!Array.isArray(tags)) {\n\t\tthrow new MappaError(\"tags must be an array\");\n\t}\n\tif (tags.length > MAX_TAGS_PER_REQUEST) {\n\t\tthrow new MappaError(\n\t\t\t`Too many tags: maximum ${MAX_TAGS_PER_REQUEST} per request`,\n\t\t);\n\t}\n\tfor (const tag of tags) {\n\t\tvalidateTag(tag);\n\t}\n}\n\n/**\n * Entities API resource.\n *\n * Responsibilities:\n * - List entities with optional tag filtering (`GET /v1/entities`)\n * - Get single entity details (`GET /v1/entities/:entityId`)\n * - Add tags to entities (`POST /v1/entities/:entityId/tags`)\n * - Remove tags from entities (`DELETE /v1/entities/:entityId/tags`)\n * - Replace all entity tags (`PUT /v1/entities/:entityId/tags`)\n *\n * Entities represent analyzed speakers identified by voice fingerprints.\n * Tags allow you to label entities (e.g., \"interviewer\", \"sales-rep\") for easier\n * filtering and identification across multiple reports.\n */\nexport class EntitiesResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\t/**\n\t * Get a single entity by ID.\n\t *\n\t * Returns entity metadata including tags, creation time, and usage statistics.\n\t *\n\t * @param entityId - The entity ID to retrieve\n\t * @param opts - Optional request options (requestId, signal)\n\t * @returns Entity details with tags and metadata\n\t *\n\t * @example\n\t * ```typescript\n\t * const entity = await mappa.entities.get(\"entity_abc123\");\n\t * console.log(entity.tags); // [\"interviewer\", \"john\"]\n\t * ```\n\t */\n\tasync get(\n\t\tentityId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Entity> {\n\t\tif (!entityId || typeof entityId !== \"string\") {\n\t\t\tthrow new MappaError(\"entityId must be a non-empty string\");\n\t\t}\n\n\t\tconst res = await this.transport.request<Entity>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * List entities with optional tag filtering.\n\t *\n\t * Supports cursor-based pagination. Use the returned `cursor` for fetching\n\t * subsequent pages, or use {@link listAll} for automatic pagination.\n\t *\n\t * When `tags` is provided, only entities with ALL specified tags are returned (AND logic).\n\t *\n\t * @param opts - List options: tags filter, cursor, limit\n\t * @returns Paginated list of entities\n\t *\n\t * @example\n\t * ```typescript\n\t * // List all entities\n\t * const page1 = await mappa.entities.list({ limit: 20 });\n\t *\n\t * // Filter by tags (must have both \"interviewer\" AND \"sales\")\n\t * const filtered = await mappa.entities.list({\n\t * tags: [\"interviewer\", \"sales\"],\n\t * limit: 50\n\t * });\n\t *\n\t * // Pagination\n\t * const page2 = await mappa.entities.list({\n\t * cursor: page1.cursor,\n\t * limit: 20\n\t * });\n\t * ```\n\t */\n\tasync list(\n\t\topts?: ListEntitiesOptions & { requestId?: string; signal?: AbortSignal },\n\t): Promise<ListEntitiesResponse> {\n\t\tconst query: Record<string, string> = {};\n\n\t\tif (opts?.tags) {\n\t\t\tvalidateTags(opts.tags);\n\t\t\t// Join tags with comma for API query parameter\n\t\t\tquery.tags = opts.tags.join(\",\");\n\t\t}\n\n\t\tif (opts?.cursor) {\n\t\t\tquery.cursor = opts.cursor;\n\t\t}\n\n\t\tif (opts?.limit !== undefined) {\n\t\t\tquery.limit = String(opts.limit);\n\t\t}\n\n\t\tconst res = await this.transport.request<ListEntitiesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/entities\",\n\t\t\tquery,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Async iterator that automatically paginates through all entities.\n\t *\n\t * Useful for processing large entity sets without manual pagination management.\n\t *\n\t * @param opts - List options: tags filter, limit per page\n\t * @yields Individual entities\n\t *\n\t * @example\n\t * ```typescript\n\t * // Process all entities with \"interviewer\" tag\n\t * for await (const entity of mappa.entities.listAll({ tags: [\"interviewer\"] })) {\n\t * console.log(`${entity.id}: ${entity.tags.join(\", \")}`);\n\t * }\n\t * ```\n\t */\n\tasync *listAll(\n\t\topts?: Omit<ListEntitiesOptions, \"cursor\"> & {\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): AsyncIterable<Entity> {\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore = true;\n\n\t\twhile (hasMore) {\n\t\t\tconst page = await this.list({ ...opts, cursor });\n\t\t\tfor (const entity of page.entities) {\n\t\t\t\tyield entity;\n\t\t\t}\n\t\t\tcursor = page.cursor;\n\t\t\thasMore = page.hasMore;\n\t\t}\n\t}\n\n\t/**\n\t * Get all entities with a specific tag.\n\t *\n\t * Convenience wrapper around {@link list} for single-tag filtering.\n\t *\n\t * @param tag - The tag to filter by\n\t * @param opts - Optional pagination and request options\n\t * @returns Paginated list of entities with the specified tag\n\t *\n\t * @example\n\t * ```typescript\n\t * const interviewers = await mappa.entities.getByTag(\"interviewer\");\n\t * ```\n\t */\n\tasync getByTag(\n\t\ttag: string,\n\t\topts?: Omit<ListEntitiesOptions, \"tags\"> & {\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<ListEntitiesResponse> {\n\t\tvalidateTag(tag);\n\t\treturn this.list({ ...opts, tags: [tag] });\n\t}\n\n\t/**\n\t * Add tags to an entity.\n\t *\n\t * Idempotent: existing tags are preserved, duplicates are ignored.\n\t *\n\t * @param entityId - The entity ID to tag\n\t * @param tags - Array of tags to add (1-10 tags, each 1-64 chars)\n\t * @param opts - Optional request options\n\t * @returns Updated tags for the entity\n\t *\n\t * @example\n\t * ```typescript\n\t * await mappa.entities.addTags(\"entity_abc123\", [\"interviewer\", \"john\"]);\n\t * ```\n\t */\n\tasync addTags(\n\t\tentityId: string,\n\t\ttags: string[],\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<EntityTagsResult> {\n\t\tif (!entityId || typeof entityId !== \"string\") {\n\t\t\tthrow new MappaError(\"entityId must be a non-empty string\");\n\t\t}\n\t\tif (tags.length === 0) {\n\t\t\tthrow new MappaError(\"At least one tag is required\");\n\t\t}\n\t\tvalidateTags(tags);\n\n\t\tconst res = await this.transport.request<EntityTagsResult>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}/tags`,\n\t\t\tbody: { tags },\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Remove tags from an entity.\n\t *\n\t * Idempotent: missing tags are silently ignored.\n\t *\n\t * @param entityId - The entity ID to update\n\t * @param tags - Array of tags to remove\n\t * @param opts - Optional request options\n\t * @returns Updated tags for the entity\n\t *\n\t * @example\n\t * ```typescript\n\t * await mappa.entities.removeTags(\"entity_abc123\", [\"interviewer\"]);\n\t * ```\n\t */\n\tasync removeTags(\n\t\tentityId: string,\n\t\ttags: string[],\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<EntityTagsResult> {\n\t\tif (!entityId || typeof entityId !== \"string\") {\n\t\t\tthrow new MappaError(\"entityId must be a non-empty string\");\n\t\t}\n\t\tif (tags.length === 0) {\n\t\t\tthrow new MappaError(\"At least one tag is required\");\n\t\t}\n\t\tvalidateTags(tags);\n\n\t\tconst res = await this.transport.request<EntityTagsResult>({\n\t\t\tmethod: \"DELETE\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}/tags`,\n\t\t\tbody: { tags },\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Replace all tags on an entity.\n\t *\n\t * Sets the complete tag list, removing any tags not in the provided array.\n\t * Pass an empty array to remove all tags.\n\t *\n\t * @param entityId - The entity ID to update\n\t * @param tags - New complete tag list (0-10 tags)\n\t * @param opts - Optional request options\n\t * @returns Updated tags for the entity\n\t *\n\t * @example\n\t * ```typescript\n\t * // Replace all tags\n\t * await mappa.entities.setTags(\"entity_abc123\", [\"sales-rep\", \"john\"]);\n\t *\n\t * // Remove all tags\n\t * await mappa.entities.setTags(\"entity_abc123\", []);\n\t * ```\n\t */\n\tasync setTags(\n\t\tentityId: string,\n\t\ttags: string[],\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<EntityTagsResult> {\n\t\tif (!entityId || typeof entityId !== \"string\") {\n\t\t\tthrow new MappaError(\"entityId must be a non-empty string\");\n\t\t}\n\t\tvalidateTags(tags);\n\n\t\tconst res = await this.transport.request<EntityTagsResult>({\n\t\t\tmethod: \"PUT\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}/tags`,\n\t\t\tbody: { tags },\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n}\n","import { MappaError } from \"$/errors\";\nimport type { Transport } from \"$/resources/transport\";\nimport type { FeedbackReceipt } from \"$/types\";\n\nexport type FeedbackCreateRequest = {\n\treportId?: string;\n\tjobId?: string;\n\trating: \"thumbs_up\" | \"thumbs_down\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\";\n\ttags?: string[];\n\tcomment?: string;\n\tcorrections?: Array<{ path: string; expected?: unknown; observed?: unknown }>;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport class FeedbackResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\t/**\n\t * Create feedback for a report or job. Provide exactly one of `reportId` or `jobId`.\n\t */\n\tasync create(req: FeedbackCreateRequest): Promise<FeedbackReceipt> {\n\t\tif (!!req.reportId === !!req.jobId)\n\t\t\tthrow new MappaError(\"Provide exactly one of reportId or jobId\");\n\n\t\tconst res = await this.transport.request<FeedbackReceipt>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/feedback\",\n\t\t\tbody: req,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\trequestId: req.requestId,\n\t\t\tsignal: req.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n}\n","import { MappaError } from \"$/errors\";\nimport type { Transport } from \"$/resources/transport\";\nimport type {\n\tFileDeleteReceipt,\n\tMediaFile,\n\tMediaObject,\n\tRetentionLockResult,\n} from \"$/types\";\n\nexport type UploadRequest = {\n\tfile: Blob | ArrayBuffer | Uint8Array | ReadableStream<Uint8Array>;\n\t/**\n\t * Optional override.\n\t * If omitted, the SDK will try to infer it from `file.type` (Blob) and then from `filename`.\n\t */\n\tcontentType?: string;\n\tfilename?: string;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport type ListFilesOptions = {\n\t/** Max files per page (1-100, default 20) */\n\tlimit?: number;\n\t/** Pagination cursor from previous response */\n\tcursor?: string;\n\t/** Include soft-deleted files (default false) */\n\tincludeDeleted?: boolean;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport type ListFilesResponse = {\n\tfiles: MediaFile[];\n\tcursor?: string;\n\thasMore: boolean;\n};\n\n/**\n * Uses multipart/form-data for uploads.\n *\n * If you need resumable uploads, add a dedicated resumable protocol.\n */\nexport class FilesResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync upload(req: UploadRequest): Promise<MediaObject> {\n\t\tif (typeof FormData === \"undefined\") {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"FormData is not available in this runtime; cannot perform multipart upload\",\n\t\t\t);\n\t\t}\n\n\t\tconst derivedContentType = inferContentType(req.file, req.filename);\n\t\tconst contentType = req.contentType ?? derivedContentType;\n\t\tif (!contentType) {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"contentType is required when it cannot be inferred from file.type or filename\",\n\t\t\t);\n\t\t}\n\n\t\tconst filename = req.filename ?? inferFilename(req.file) ?? \"upload\";\n\t\tconst filePart = await toFormDataPart(req.file, contentType);\n\n\t\tconst form = new FormData();\n\t\t// Server expects multipart fields:\n\t\t// - file: binary\n\t\t// - contentType: string (may be used for validation/normalization)\n\t\t// - filename: string (optional)\n\t\tform.append(\"file\", filePart, filename);\n\t\tform.append(\"contentType\", contentType);\n\t\tif (req.filename) form.append(\"filename\", req.filename);\n\n\t\tconst res = await this.transport.request<MediaObject>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/files\",\n\t\t\tbody: form,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\trequestId: req.requestId,\n\t\t\tsignal: req.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Retrieve metadata for a single uploaded file.\n\t *\n\t * @example\n\t * const file = await mappa.files.get(\"media_abc123\");\n\t * console.log(file.processingStatus); // \"COMPLETED\"\n\t */\n\tasync get(\n\t\tmediaId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MediaFile> {\n\t\tif (!mediaId) throw new MappaError(\"mediaId is required\");\n\n\t\tconst res = await this.transport.request<MediaFile>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * List uploaded files with cursor pagination.\n\t *\n\t * @example\n\t * const page1 = await mappa.files.list({ limit: 10 });\n\t * if (page1.hasMore) {\n\t * const page2 = await mappa.files.list({ limit: 10, cursor: page1.cursor });\n\t * }\n\t */\n\tasync list(opts?: ListFilesOptions): Promise<ListFilesResponse> {\n\t\tconst query: Record<string, string> = {};\n\t\tif (opts?.limit !== undefined) query.limit = String(opts.limit);\n\t\tif (opts?.cursor) query.cursor = opts.cursor;\n\t\tif (opts?.includeDeleted !== undefined)\n\t\t\tquery.includeDeleted = String(opts.includeDeleted);\n\n\t\tconst res = await this.transport.request<ListFilesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/files\",\n\t\t\tquery,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Iterate over all files, automatically handling pagination.\n\t *\n\t * @example\n\t * for await (const file of mappa.files.listAll()) {\n\t * console.log(file.mediaId);\n\t * }\n\t *\n\t * // Or collect all\n\t * const allFiles = [];\n\t * for await (const file of mappa.files.listAll({ limit: 50 })) {\n\t * allFiles.push(file);\n\t * }\n\t */\n\tasync *listAll(\n\t\topts?: Omit<ListFilesOptions, \"cursor\">,\n\t): AsyncIterable<MediaFile> {\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore = true;\n\n\t\twhile (hasMore) {\n\t\t\tconst page = await this.list({ ...opts, cursor });\n\t\t\tfor (const file of page.files) {\n\t\t\t\tyield file;\n\t\t\t}\n\t\t\tcursor = page.cursor;\n\t\t\thasMore = page.hasMore;\n\t\t}\n\t}\n\n\t/**\n\t * Lock or unlock a file's retention to prevent/allow automatic deletion.\n\t *\n\t * @example\n\t * // Prevent automatic deletion\n\t * await mappa.files.setRetentionLock(\"media_abc\", true);\n\t *\n\t * // Allow automatic deletion\n\t * await mappa.files.setRetentionLock(\"media_abc\", false);\n\t */\n\tasync setRetentionLock(\n\t\tmediaId: string,\n\t\tlocked: boolean,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<RetentionLockResult> {\n\t\tif (!mediaId) throw new MappaError(\"mediaId is required\");\n\n\t\tconst res = await this.transport.request<RetentionLockResult>({\n\t\t\tmethod: \"PATCH\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}/retention`,\n\t\t\tbody: { lock: locked },\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n\n\tasync delete(\n\t\tmediaId: string,\n\t\topts?: {\n\t\t\tidempotencyKey?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<FileDeleteReceipt> {\n\t\tif (!mediaId) throw new MappaError(\"mediaId is required\");\n\n\t\tconst res = await this.transport.request<FileDeleteReceipt>({\n\t\t\tmethod: \"DELETE\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}`,\n\t\t\tidempotencyKey: opts?.idempotencyKey,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn res.data;\n\t}\n}\n\nfunction inferContentType(\n\tfile: UploadRequest[\"file\"],\n\tfilename?: string,\n): string | undefined {\n\tif (typeof Blob !== \"undefined\" && file instanceof Blob) {\n\t\tif (file.type) return file.type;\n\t}\n\tif (filename) return contentTypeFromFilename(filename);\n\treturn undefined;\n}\n\nfunction inferFilename(file: UploadRequest[\"file\"]): string | undefined {\n\tif (typeof Blob !== \"undefined\" && file instanceof Blob) {\n\t\tconst anyBlob = file as unknown as { name?: unknown };\n\t\tif (typeof anyBlob.name === \"string\" && anyBlob.name) return anyBlob.name;\n\t}\n\treturn undefined;\n}\n\nfunction contentTypeFromFilename(filename: string): string | undefined {\n\tconst i = filename.lastIndexOf(\".\");\n\tif (i < 0) return undefined;\n\tconst ext = filename.slice(i + 1).toLowerCase();\n\n\t// Small built-in map to avoid an extra dependency.\n\t// Add more as needed.\n\tswitch (ext) {\n\t\tcase \"mp4\":\n\t\t\treturn \"video/mp4\";\n\t\tcase \"mov\":\n\t\t\treturn \"video/quicktime\";\n\t\tcase \"webm\":\n\t\t\treturn \"video/webm\";\n\t\tcase \"mp3\":\n\t\t\treturn \"audio/mpeg\";\n\t\tcase \"wav\":\n\t\t\treturn \"audio/wav\";\n\t\tcase \"m4a\":\n\t\t\treturn \"audio/mp4\";\n\t\tcase \"png\":\n\t\t\treturn \"image/png\";\n\t\tcase \"jpg\":\n\t\tcase \"jpeg\":\n\t\t\treturn \"image/jpeg\";\n\t\tcase \"gif\":\n\t\t\treturn \"image/gif\";\n\t\tcase \"webp\":\n\t\t\treturn \"image/webp\";\n\t\tcase \"pdf\":\n\t\t\treturn \"application/pdf\";\n\t\tcase \"json\":\n\t\t\treturn \"application/json\";\n\t\tcase \"txt\":\n\t\t\treturn \"text/plain\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nasync function toFormDataPart(\n\tfile: UploadRequest[\"file\"],\n\tcontentType: string,\n): Promise<Blob> {\n\t// Blob: ensure the part has the intended type.\n\tif (typeof Blob !== \"undefined\" && file instanceof Blob) {\n\t\tif (file.type === contentType) return file;\n\t\t// TS in this repo is configured without DOM lib, so `Blob#slice` isn't typed.\n\t\t// Most runtimes support it; we call it via an `any` cast.\n\t\tconst slicer = file as unknown as {\n\t\t\tslice?: (start?: number, end?: number, contentType?: string) => Blob;\n\t\t};\n\t\tif (typeof slicer.slice === \"function\") {\n\t\t\treturn slicer.slice(\n\t\t\t\t0,\n\t\t\t\t(file as unknown as { size?: number }).size,\n\t\t\t\tcontentType,\n\t\t\t);\n\t\t}\n\t\treturn file;\n\t}\n\n\t// ArrayBuffer / Uint8Array\n\tif (file instanceof ArrayBuffer)\n\t\treturn new Blob([file], { type: contentType });\n\tif (file instanceof Uint8Array)\n\t\treturn new Blob([file], { type: contentType });\n\n\t// ReadableStream<Uint8Array>\n\tif (typeof ReadableStream !== \"undefined\" && file instanceof ReadableStream) {\n\t\t// Most runtimes (Node 18+/Bun/modern browsers) can convert stream -> Blob via Response.\n\t\tif (typeof Response === \"undefined\") {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"ReadableStream upload requires Response to convert stream to Blob\",\n\t\t\t);\n\t\t}\n\n\t\tconst blob = await new Response(file).blob();\n\t\treturn blob.slice(0, blob.size, contentType);\n\t}\n\n\tthrow new MappaError(\"Unsupported file type for upload()\");\n}\n","import type { Transport } from \"$/resources/transport\";\n\nexport class HealthResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync ping(): Promise<{ ok: true; time: string }> {\n\t\tconst res = await this.transport.request<{ ok: true; time: string }>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/health/ping\",\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n}\n","import { init } from \"@paralleldrive/cuid2\";\n\nconst createId = init({\n\tlength: 32,\n});\n\nexport function assertNever(x: never): never {\n\tthrow new Error(`Unexpected object: ${String(x)}`);\n}\n\nexport function isObject(x: unknown): x is Record<string, unknown> {\n\treturn typeof x === \"object\" && x !== null;\n}\n\nexport function getHeader(headers: Headers, name: string): string | undefined {\n\tconst v = headers.get(name);\n\treturn v === null ? undefined : v;\n}\n\nexport function jitter(ms: number): number {\n\t// +/- 20%\n\tconst r = 0.8 + Math.random() * 0.4;\n\treturn Math.floor(ms * r);\n}\n\nexport function backoffMs(\n\tattempt: number,\n\tbaseMs: number,\n\tmaxMs: number,\n): number {\n\t// exponential: base * 2^(attempt-1)\n\tconst ms = baseMs * 2 ** Math.max(0, attempt - 1);\n\treturn Math.min(ms, maxMs);\n}\n\nexport function nowMs(): number {\n\treturn Date.now();\n}\n\nexport function hasAbortSignal(signal?: AbortSignal): boolean {\n\treturn !!signal && typeof signal.aborted === \"boolean\";\n}\n\nexport function makeAbortError(): Error {\n\tconst e = new Error(\"The operation was aborted\");\n\te.name = \"AbortError\";\n\treturn e;\n}\n\nexport function randomId(prefix = \"req\"): string {\n\treturn `${prefix}_${createId()}`;\n}\n","import {\n\tJobCanceledError,\n\tJobFailedError,\n\tMappaError,\n\tStreamError,\n} from \"$/errors\";\nimport type { SSEEvent, Transport } from \"$/resources/transport\";\nimport type { Job, JobEvent, JobStage, WaitOptions } from \"$/types\";\nimport { makeAbortError } from \"../utils\";\n\n/**\n * SSE event data shape from the server's job stream endpoint.\n */\ntype JobStreamEventData = {\n\tstatus?: string;\n\tstage?: string;\n\tprogress?: number;\n\tjob: Job;\n\treportId?: string;\n\terror?: { code: string; message: string };\n\ttimestamp?: string; // for heartbeat\n};\n\nexport class JobsResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync get(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Job> {\n\t\tconst res = await this.transport.request<Job>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/jobs/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n\n\tasync cancel(\n\t\tjobId: string,\n\t\topts?: {\n\t\t\tidempotencyKey?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<Job> {\n\t\tconst res = await this.transport.request<Job>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `/v1/jobs/${encodeURIComponent(jobId)}/cancel`,\n\t\t\tidempotencyKey: opts?.idempotencyKey,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Wait for a job to reach a terminal state.\n\t *\n\t * Uses SSE streaming internally for efficient real-time updates.\n\t */\n\tasync wait(jobId: string, opts?: WaitOptions): Promise<Job> {\n\t\tconst timeoutMs = opts?.timeoutMs ?? 5 * 60_000;\n\t\tconst controller = new AbortController();\n\n\t\t// Set up timeout\n\t\tconst timeoutId = setTimeout(() => controller.abort(), timeoutMs);\n\n\t\t// Combine signals if user provided one\n\t\tif (opts?.signal) {\n\t\t\tif (opts.signal.aborted) {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\tthrow makeAbortError();\n\t\t\t}\n\t\t\topts.signal.addEventListener(\"abort\", () => controller.abort(), {\n\t\t\t\tonce: true,\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tfor await (const event of this.stream(jobId, {\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tonEvent: opts?.onEvent,\n\t\t\t})) {\n\t\t\t\tif (event.type === \"terminal\") {\n\t\t\t\t\tconst job = event.job;\n\n\t\t\t\t\tif (job.status === \"succeeded\") {\n\t\t\t\t\t\treturn job;\n\t\t\t\t\t}\n\t\t\t\t\tif (job.status === \"failed\") {\n\t\t\t\t\t\tthrow new JobFailedError(\n\t\t\t\t\t\t\tjobId,\n\t\t\t\t\t\t\tjob.error?.message ?? \"Job failed\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trequestId: job.requestId,\n\t\t\t\t\t\t\t\tcode: job.error?.code,\n\t\t\t\t\t\t\t\tcause: job.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (job.status === \"canceled\") {\n\t\t\t\t\t\tthrow new JobCanceledError(jobId, \"Job canceled\", {\n\t\t\t\t\t\t\trequestId: job.requestId,\n\t\t\t\t\t\t\tcause: job.error,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Stream ended without terminal event (timeout or unexpected close)\n\t\t\tthrow new JobFailedError(\n\t\t\t\tjobId,\n\t\t\t\t`Timed out waiting for job ${jobId} after ${timeoutMs}ms`,\n\t\t\t\t{\n\t\t\t\t\tcause: { jobId, timeoutMs },\n\t\t\t\t},\n\t\t\t);\n\t\t} finally {\n\t\t\tclearTimeout(timeoutId);\n\t\t}\n\t}\n\n\t/**\n\t * Stream job events via SSE.\n\t *\n\t * Yields events as they arrive from the server. Use `AbortSignal` to cancel streaming.\n\t * Automatically handles reconnection with `Last-Event-ID` for up to 3 retries.\n\t */\n\tasync *stream(\n\t\tjobId: string,\n\t\topts?: { signal?: AbortSignal; onEvent?: (e: JobEvent) => void },\n\t): AsyncIterable<JobEvent> {\n\t\tconst maxRetries = 3;\n\t\tlet lastEventId: string | undefined;\n\t\tlet retries = 0;\n\n\t\twhile (retries < maxRetries) {\n\t\t\ttry {\n\t\t\t\tconst sseStream = this.transport.streamSSE<JobStreamEventData>(\n\t\t\t\t\t`/v1/jobs/${encodeURIComponent(jobId)}/stream`,\n\t\t\t\t\t{ signal: opts?.signal, lastEventId },\n\t\t\t\t);\n\n\t\t\t\tfor await (const sseEvent of sseStream) {\n\t\t\t\t\tlastEventId = sseEvent.id;\n\n\t\t\t\t\t// Handle error event (job not found, etc.)\n\t\t\t\t\tif (sseEvent.event === \"error\") {\n\t\t\t\t\t\tconst errorData = sseEvent.data;\n\t\t\t\t\t\tthrow new MappaError(\n\t\t\t\t\t\t\terrorData.error?.message ?? \"Unknown SSE error\",\n\t\t\t\t\t\t\t{ code: errorData.error?.code },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Skip heartbeat events (internal keep-alive)\n\t\t\t\t\tif (sseEvent.event === \"heartbeat\") {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Map SSE event to JobEvent\n\t\t\t\t\tconst jobEvent = this.mapSSEToJobEvent(sseEvent);\n\t\t\t\t\tif (jobEvent) {\n\t\t\t\t\t\topts?.onEvent?.(jobEvent);\n\t\t\t\t\t\tyield jobEvent;\n\n\t\t\t\t\t\t// Exit on terminal event\n\t\t\t\t\t\tif (sseEvent.event === \"terminal\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Reset retry counter on successful event\n\t\t\t\t\tretries = 0;\n\t\t\t\t}\n\n\t\t\t\t// Stream ended without terminal event (server timeout)\n\t\t\t\t// Reconnect with last event ID\n\t\t\t\tretries++;\n\t\t\t\tif (retries < maxRetries) {\n\t\t\t\t\tawait this.backoff(retries);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// If aborted, rethrow immediately\n\t\t\t\tif (opts?.signal?.aborted) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\tretries++;\n\t\t\t\tif (retries >= maxRetries) {\n\t\t\t\t\t// Wrap in StreamError with recovery metadata\n\t\t\t\t\tthrow new StreamError(\n\t\t\t\t\t\t`Stream connection failed for job ${jobId} after ${maxRetries} retries`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tjobId,\n\t\t\t\t\t\t\tlastEventId,\n\t\t\t\t\t\t\tretryCount: retries,\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tawait this.backoff(retries);\n\t\t\t}\n\t\t}\n\n\t\tthrow new StreamError(\n\t\t\t`Failed to get status for job ${jobId} after ${maxRetries} retries`,\n\t\t\t{\n\t\t\t\tjobId,\n\t\t\t\tlastEventId,\n\t\t\t\tretryCount: maxRetries,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Map an SSE event to a JobEvent.\n\t */\n\tprivate mapSSEToJobEvent(\n\t\tsseEvent: SSEEvent<JobStreamEventData>,\n\t): JobEvent | null {\n\t\tconst data = sseEvent.data;\n\n\t\tswitch (sseEvent.event) {\n\t\t\tcase \"status\":\n\t\t\t\treturn { type: \"status\", job: data.job };\n\t\t\tcase \"stage\":\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"stage\",\n\t\t\t\t\tstage: data.stage as JobStage,\n\t\t\t\t\tprogress: data.progress,\n\t\t\t\t\tjob: data.job,\n\t\t\t\t};\n\t\t\tcase \"terminal\":\n\t\t\t\treturn { type: \"terminal\", job: data.job };\n\t\t\tdefault:\n\t\t\t\t// Unknown event type, treat as status update\n\t\t\t\treturn { type: \"status\", job: data.job };\n\t\t}\n\t}\n\n\t/**\n\t * Exponential backoff with jitter for reconnection.\n\t */\n\tprivate async backoff(attempt: number): Promise<void> {\n\t\tconst delay = Math.min(1000 * 2 ** attempt, 10000);\n\t\tconst jitter = delay * 0.5 * Math.random();\n\t\tawait new Promise((r) => setTimeout(r, delay + jitter));\n\t}\n}\n","import { MappaError } from \"$/errors\";\nimport type { UploadRequest } from \"$/resources/files\";\nimport type { JobsResource } from \"$/resources/jobs\";\nimport type { Transport } from \"$/resources/transport\";\nimport type {\n\tJobEvent,\n\tMediaIdRef,\n\tMediaObject,\n\tReport,\n\tReportCreateJobRequest,\n\tReportForOutputType,\n\tReportJobReceipt,\n\tReportOutputType,\n\tReportRunHandle,\n\tWaitOptions,\n} from \"$/types\";\nimport { randomId } from \"$/utils\";\n\n/**\n * Runtime validation for the internal `MediaIdRef` requirement.\n *\n * The public API server expects a `mediaId` when creating a report job.\n * Use helpers like `createJobFromFile` / `createJobFromUrl` to start from bytes or a URL.\n */\nfunction validateMedia(media: MediaIdRef): void {\n\tconst m = media as unknown;\n\tconst isObj = (v: unknown): v is Record<string, unknown> =>\n\t\tv !== null && typeof v === \"object\";\n\n\tif (!isObj(m)) throw new MappaError(\"media must be an object\");\n\n\t// Report job creation only supports already-uploaded media references.\n\t// Use `createJobFromFile` / `createJobFromUrl` to start from bytes or a remote URL.\n\tif ((m as { url?: unknown }).url !== undefined) {\n\t\tthrow new MappaError(\n\t\t\t\"media.url is not supported; pass { mediaId } or use createJobFromUrl()\",\n\t\t);\n\t}\n\n\tconst mediaId = (m as { mediaId?: unknown }).mediaId;\n\tif (typeof mediaId !== \"string\" || !mediaId) {\n\t\tthrow new MappaError(\"media.mediaId must be a non-empty string\");\n\t}\n}\n\n/**\n * Request shape for {@link ReportsResource.createJobFromFile}.\n *\n * This helper performs two API calls as one logical operation:\n * 1) Upload bytes via `files.upload()` (multipart)\n * 2) Create a report job via {@link ReportsResource.createJob} using the returned `{ mediaId }`\n *\n * Differences vs {@link ReportCreateJobRequest}:\n * - `media` is derived from the upload result and therefore omitted.\n * - `idempotencyKey` applies to the *whole* upload + create-job sequence.\n * - `requestId` is forwarded to both requests for end-to-end correlation.\n *\n * Abort behavior:\n * - `signal` (from {@link UploadRequest}) is applied to the upload request.\n * Job creation only runs after a successful upload.\n */\nexport type ReportCreateJobFromFileRequest<\n\tT extends ReportOutputType = ReportOutputType,\n> = Omit<ReportCreateJobRequest<T>, \"media\" | \"idempotencyKey\" | \"requestId\"> &\n\tOmit<UploadRequest, \"filename\"> & {\n\t\t/**\n\t\t * Optional filename to attach to the upload.\n\t\t *\n\t\t * When omitted, the upload layer may infer it (e.g. from a `File` object).\n\t\t */\n\t\tfilename?: string;\n\t\t/**\n\t\t * Idempotency for the upload + job creation sequence.\n\t\t */\n\t\tidempotencyKey?: string;\n\t\t/**\n\t\t * Optional request correlation ID forwarded to both the upload and the job creation call.\n\t\t */\n\t\trequestId?: string;\n\t};\n\n/**\n * Request shape for {@link ReportsResource.createJobFromUrl}.\n *\n * This helper performs two API calls as one logical operation:\n * 1) Download bytes from a remote URL using `fetch()`\n * 2) Upload bytes via `files.upload()` and then create a report job via {@link ReportsResource.createJob}\n *\n * Differences vs {@link ReportCreateJobRequest}:\n * - `media` is derived from the upload result and therefore omitted.\n * - `idempotencyKey` applies to the *whole* download + upload + create-job sequence.\n * - `requestId` is forwarded to both upload and job creation calls.\n */\nexport type ReportCreateJobFromUrlRequest<\n\tT extends ReportOutputType = ReportOutputType,\n> = Omit<\n\tReportCreateJobRequest<T>,\n\t\"media\" | \"idempotencyKey\" | \"requestId\"\n> & {\n\turl: string;\n\tcontentType?: string;\n\tfilename?: string;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\n/**\n * Reports API resource.\n *\n * Responsibilities:\n * - Create report jobs (`POST /v1/reports/jobs`).\n * - Fetch reports by report ID (`GET /v1/reports/:reportId`).\n * - Fetch reports by job ID (`GET /v1/reports/by-job/:jobId`).\n *\n * Convenience helpers:\n * - {@link ReportsResource.createJobFromFile} orchestrates `files.upload()` + {@link ReportsResource.createJob}.\n * - {@link ReportsResource.createJobFromUrl} downloads a remote URL, uploads it, then calls {@link ReportsResource.createJob}.\n * - {@link ReportsResource.generate} / {@link ReportsResource.generateFromFile} are script-friendly wrappers that\n * create a job, wait for completion, and then fetch the final report.\n *\n * For production systems, prefer `createJob*()` plus webhooks or streaming job events rather than blocking waits.\n */\nexport class ReportsResource {\n\tconstructor(\n\t\tprivate readonly transport: Transport,\n\t\tprivate readonly jobs: JobsResource,\n\t\tprivate readonly files: {\n\t\t\tupload: (req: UploadRequest) => Promise<MediaObject>;\n\t\t},\n\t\tprivate readonly fetchImpl: typeof fetch,\n\t) {}\n\n\t/**\n\t * Create a new report job.\n\t *\n\t * Behavior:\n\t * - Validates {@link MediaIdRef} at runtime (must provide `{ mediaId }`).\n\t * - Defaults to `{ strategy: \"dominant\" }` when `target` is omitted.\n\t * - Applies an idempotency key: uses `req.idempotencyKey` when provided; otherwise generates a best-effort default.\n\t * - Forwards `req.requestId` to the transport for end-to-end correlation.\n\t *\n\t * The returned receipt includes a {@link ReportRunHandle} (`receipt.handle`) which can be used to:\n\t * - stream job events\n\t * - wait for completion and fetch the final report\n\t * - cancel the job, or fetch job/report metadata\n\t */\n\tasync createJob<T extends ReportOutputType = ReportOutputType>(\n\t\treq: ReportCreateJobRequest<T>,\n\t): Promise<ReportJobReceipt<T>> {\n\t\tvalidateMedia(req.media);\n\n\t\tconst idempotencyKey =\n\t\t\treq.idempotencyKey ?? this.defaultIdempotencyKey(req);\n\n\t\tconst res = await this.transport.request<\n\t\t\tOmit<ReportJobReceipt<T>, \"handle\">\n\t\t>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/reports/jobs\",\n\t\t\tbody: this.normalizeJobRequest(req),\n\t\t\tidempotencyKey,\n\t\t\trequestId: req.requestId,\n\t\t\tretryable: true,\n\t\t});\n\n\t\tconst receipt: ReportJobReceipt<T> = {\n\t\t\t...res.data,\n\t\t\trequestId: res.requestId ?? res.data.requestId,\n\t\t};\n\n\t\treceipt.handle = this.makeHandle<T>(receipt.jobId);\n\t\treturn receipt;\n\t}\n\n\t/**\n\t * Upload a file and create a report job in one call.\n\t *\n\t * Keeps `createJob()` strict about `media: { mediaId }` while offering a\n\t * convenient helper when you start from raw bytes.\n\t */\n\tasync createJobFromFile<T extends ReportOutputType = ReportOutputType>(\n\t\treq: ReportCreateJobFromFileRequest<T>,\n\t): Promise<ReportJobReceipt<T>> {\n\t\tconst {\n\t\t\tfile,\n\t\t\tcontentType,\n\t\t\tfilename,\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t\t...rest\n\t\t} = req;\n\n\t\tconst upload = await this.files.upload({\n\t\t\tfile,\n\t\t\tcontentType,\n\t\t\tfilename,\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t});\n\n\t\treturn this.createJob<T>({\n\t\t\t...(rest as Omit<ReportCreateJobRequest<T>, \"media\">),\n\t\t\tmedia: { mediaId: upload.mediaId },\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t});\n\t}\n\n\t/**\n\t * Download a file from a URL, upload it, and create a report job.\n\t *\n\t * Recommended when starting from a remote URL because report job creation\n\t * only accepts `media: { mediaId }`.\n\t *\n\t * Workflow:\n\t * 1) `fetch(url)`\n\t * 2) Validate the response (2xx) and derive `contentType`\n\t * 3) `files.upload({ file: Blob, ... })`\n\t * 4) `createJob({ media: { mediaId }, ... })`\n\t *\n\t * Verification / safety:\n\t * - Only allows `http:` and `https:` URLs.\n\t * - Requires a resolvable `contentType` (from `req.contentType` or response header).\n\t */\n\tasync createJobFromUrl<T extends ReportOutputType = ReportOutputType>(\n\t\treq: ReportCreateJobFromUrlRequest<T>,\n\t): Promise<ReportJobReceipt<T>> {\n\t\tconst {\n\t\t\turl,\n\t\t\tcontentType: contentTypeOverride,\n\t\t\tfilename,\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t\t...rest\n\t\t} = req;\n\n\t\tlet parsed: URL;\n\t\ttry {\n\t\t\tparsed = new URL(url);\n\t\t} catch {\n\t\t\tthrow new MappaError(\"url must be a valid URL\");\n\t\t}\n\t\tif (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n\t\t\tthrow new MappaError(\"url must use http: or https:\");\n\t\t}\n\n\t\tconst res = await this.fetchImpl(parsed.toString(), { signal });\n\t\tif (!res.ok) {\n\t\t\tthrow new MappaError(`Failed to download url (status ${res.status})`);\n\t\t}\n\n\t\tconst derivedContentType = res.headers.get(\"content-type\") ?? undefined;\n\t\tconst contentType = contentTypeOverride ?? derivedContentType;\n\t\tif (!contentType) {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"contentType is required when it cannot be inferred from the download response\",\n\t\t\t);\n\t\t}\n\n\t\tif (typeof Blob === \"undefined\") {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"Blob is not available in this runtime; cannot download and upload from url\",\n\t\t\t);\n\t\t}\n\n\t\tconst blob = await res.blob();\n\t\tconst upload = await this.files.upload({\n\t\t\tfile: blob,\n\t\t\tcontentType,\n\t\t\tfilename,\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t});\n\n\t\treturn this.createJob<T>({\n\t\t\t...(rest as Omit<ReportCreateJobRequest<T>, \"media\">),\n\t\t\tmedia: { mediaId: upload.mediaId },\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t});\n\t}\n\n\tasync get(\n\t\treportId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Report> {\n\t\tconst res = await this.transport.request<Report>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/reports/${encodeURIComponent(reportId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n\n\tasync getByJob(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Report | null> {\n\t\tconst res = await this.transport.request<Report | null>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/reports/by-job/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn res.data;\n\t}\n\n\t/**\n\t * Convenience wrapper: createJob + wait + get\n\t * Use for scripts; for production prefer createJob + webhooks/stream.\n\t */\n\tasync generate<T extends ReportOutputType = ReportOutputType>(\n\t\treq: ReportCreateJobRequest<T>,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<ReportForOutputType<T>> {\n\t\tconst receipt = await this.createJob<T>(req);\n\t\tif (!receipt.handle) {\n\t\t\tthrow new MappaError(\"Job receipt is missing handle\");\n\t\t}\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\t/**\n\t * Convenience wrapper: createJobFromFile + wait + get.\n\t * Use for scripts; for production prefer createJobFromFile + webhooks/stream.\n\t */\n\tasync generateFromFile<T extends ReportOutputType = ReportOutputType>(\n\t\treq: ReportCreateJobFromFileRequest<T>,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<ReportForOutputType<T>> {\n\t\tconst receipt = await this.createJobFromFile<T>(req);\n\t\tif (!receipt.handle) throw new MappaError(\"Job receipt is missing handle\");\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\t/**\n\t * Convenience wrapper: createJobFromUrl + wait + get.\n\t * Use for scripts; for production prefer createJobFromUrl + webhooks/stream.\n\t */\n\tasync generateFromUrl<T extends ReportOutputType = ReportOutputType>(\n\t\treq: ReportCreateJobFromUrlRequest<T>,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<ReportForOutputType<T>> {\n\t\tconst receipt = await this.createJobFromUrl<T>(req);\n\t\tif (!receipt.handle) throw new MappaError(\"Job receipt is missing handle\");\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\tmakeHandle<T extends ReportOutputType = ReportOutputType>(\n\t\tjobId: string,\n\t): ReportRunHandle<T> {\n\t\tconst self = this;\n\t\treturn {\n\t\t\tjobId,\n\t\t\tstream: (opts?: {\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t\tonEvent?: (e: JobEvent) => void;\n\t\t\t}) => self.jobs.stream(jobId, opts),\n\t\t\tasync wait(opts?: WaitOptions): Promise<ReportForOutputType<T>> {\n\t\t\t\tconst terminal = await self.jobs.wait(jobId, opts);\n\t\t\t\tif (!terminal.reportId)\n\t\t\t\t\tthrow new MappaError(\n\t\t\t\t\t\t`Job ${jobId} succeeded but no reportId was returned`,\n\t\t\t\t\t);\n\t\t\t\treturn self.get(terminal.reportId) as Promise<ReportForOutputType<T>>;\n\t\t\t},\n\t\t\tcancel: () => self.jobs.cancel(jobId),\n\t\t\tjob: () => self.jobs.get(jobId),\n\t\t\treport: () =>\n\t\t\t\tself.getByJob(jobId) as Promise<ReportForOutputType<T> | null>,\n\t\t};\n\t}\n\n\tprivate defaultIdempotencyKey(_req: ReportCreateJobRequest): string {\n\t\t// Deterministic keys can be added later; random avoids accidental duplicates on retries.\n\t\treturn randomId(\"idem\");\n\t}\n\n\tprivate normalizeJobRequest(\n\t\treq: ReportCreateJobRequest,\n\t): Record<string, unknown> {\n\t\tconst target = req.target;\n\n\t\t// Default to dominant strategy when target is not provided\n\t\tif (!target) {\n\t\t\treturn {\n\t\t\t\t...req,\n\t\t\t\ttarget: { strategy: \"dominant\" },\n\t\t\t};\n\t\t}\n\n\t\tconst baseTarget: Record<string, unknown> = {\n\t\t\tstrategy: target.strategy,\n\t\t};\n\n\t\tif (target.onMiss) {\n\t\t\tbaseTarget.on_miss = target.onMiss;\n\t\t}\n\n\t\t// Add tags and excludeTags to baseTarget (common to all strategies)\n\t\tif (target.tags && target.tags.length > 0) {\n\t\t\tbaseTarget.tags = target.tags;\n\t\t}\n\n\t\tif (target.excludeTags && target.excludeTags.length > 0) {\n\t\t\tbaseTarget.exclude_tags = target.excludeTags;\n\t\t}\n\n\t\tswitch (target.strategy) {\n\t\t\tcase \"dominant\": {\n\t\t\t\treturn { ...req, target: baseTarget };\n\t\t\t}\n\t\t\tcase \"timerange\": {\n\t\t\t\tconst timeRange = target.timeRange ?? {};\n\t\t\t\treturn {\n\t\t\t\t\t...req,\n\t\t\t\t\ttarget: {\n\t\t\t\t\t\t...baseTarget,\n\t\t\t\t\t\ttimerange: {\n\t\t\t\t\t\t\tstart_seconds: timeRange.startSeconds ?? null,\n\t\t\t\t\t\t\tend_seconds: timeRange.endSeconds ?? null,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\tcase \"entity_id\": {\n\t\t\t\treturn {\n\t\t\t\t\t...req,\n\t\t\t\t\ttarget: {\n\t\t\t\t\t\t...baseTarget,\n\t\t\t\t\t\tentity_id: target.entityId,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\tcase \"magic_hint\": {\n\t\t\t\treturn {\n\t\t\t\t\t...req,\n\t\t\t\t\ttarget: {\n\t\t\t\t\t\t...baseTarget,\n\t\t\t\t\t\thint: target.hint,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn req;\n\t\t\t}\n\t\t}\n\t}\n}\n","import {\n\tApiError,\n\tAuthError,\n\tInsufficientCreditsError,\n\tMappaError,\n\tRateLimitError,\n\tValidationError,\n} from \"$/errors\";\nimport {\n\tbackoffMs,\n\tgetHeader,\n\thasAbortSignal,\n\tjitter,\n\tmakeAbortError,\n\trandomId,\n} from \"$/utils\";\n\n/**\n * Options for SSE streaming.\n */\nexport type SSEStreamOptions = {\n\tsignal?: AbortSignal;\n\tlastEventId?: string;\n};\n\n/**\n * A parsed SSE event.\n */\nexport type SSEEvent<T = unknown> = {\n\tid?: string;\n\tevent: string;\n\tdata: T;\n};\n\nexport type Telemetry = {\n\tonRequest?: (ctx: {\n\t\tmethod: string;\n\t\turl: string;\n\t\trequestId?: string;\n\t}) => void;\n\tonResponse?: (ctx: {\n\t\tstatus: number;\n\t\turl: string;\n\t\trequestId?: string;\n\t\tdurationMs: number;\n\t}) => void;\n\tonError?: (ctx: {\n\t\turl: string;\n\t\trequestId?: string;\n\t\terror: unknown;\n\t\t/** Additional context for SSE streaming errors. */\n\t\tcontext?: Record<string, unknown>;\n\t}) => void;\n};\n\nexport type TransportOptions = {\n\tapiKey: string;\n\tbaseUrl: string;\n\ttimeoutMs: number;\n\tmaxRetries: number;\n\tdefaultHeaders?: Record<string, string>;\n\tfetch?: typeof fetch;\n\ttelemetry?: Telemetry;\n\tuserAgent?: string;\n};\n\nexport type RequestOptions = {\n\tmethod: \"GET\" | \"POST\" | \"DELETE\" | \"PUT\" | \"PATCH\";\n\tpath: string;\n\tquery?: Record<string, string | number | boolean | undefined>;\n\theaders?: Record<string, string | undefined>;\n\tbody?: unknown;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n\t// treat as safe to retry (typically true for GET and for idempotent POSTs)\n\tretryable?: boolean;\n};\n\nexport type TransportResponse<T> = {\n\tdata: T;\n\tstatus: number;\n\trequestId?: string;\n\theaders: Headers;\n};\n\nfunction buildUrl(\n\tbaseUrl: string,\n\tpath: string,\n\tquery?: RequestOptions[\"query\"],\n): string {\n\tconst u = new URL(\n\t\tpath.replace(/^\\//, \"\"),\n\t\tbaseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`,\n\t);\n\tif (query) {\n\t\tfor (const [k, v] of Object.entries(query)) {\n\t\t\tif (v === undefined) continue;\n\t\t\tu.searchParams.set(k, String(v));\n\t\t}\n\t}\n\treturn u.toString();\n}\n\nasync function readBody(\n\tres: Response,\n): Promise<{ parsed: unknown; text: string }> {\n\tconst text = await res.text();\n\tif (!text) return { parsed: null, text: \"\" };\n\ttry {\n\t\treturn { parsed: JSON.parse(text), text };\n\t} catch {\n\t\treturn { parsed: text, text };\n\t}\n}\n\nfunction coerceApiError(res: Response, parsed: unknown): ApiError {\n\tconst requestId = res.headers.get(\"x-request-id\") ?? undefined;\n\n\t// Expecting an error envelope like:\n\t// { error: { code, message, details } } OR { code, message, details }\n\tlet code: string | undefined;\n\tlet message = `Request failed with status ${res.status}`;\n\tlet details: unknown = parsed;\n\n\tif (typeof parsed === \"string\") {\n\t\tmessage = parsed;\n\t} else if (parsed && typeof parsed === \"object\") {\n\t\tconst p = parsed as Record<string, unknown>;\n\t\tconst err = (p.error ?? p) as unknown;\n\t\tif (err && typeof err === \"object\") {\n\t\t\tconst e = err as Record<string, unknown>;\n\t\t\tif (typeof e.message === \"string\") message = e.message;\n\t\t\tif (typeof e.code === \"string\") code = e.code;\n\t\t\tif (\"details\" in e) details = e.details;\n\t\t}\n\t}\n\n\tif (res.status === 401 || res.status === 403)\n\t\treturn new AuthError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails,\n\t\t});\n\tif (res.status === 422)\n\t\treturn new ValidationError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails,\n\t\t});\n\n\tif (res.status === 402 && code === \"insufficient_credits\") {\n\t\treturn new InsufficientCreditsError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails: details as { required?: number; available?: number },\n\t\t});\n\t}\n\n\tif (res.status === 429) {\n\t\tconst e = new RateLimitError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails,\n\t\t});\n\t\tconst ra = res.headers.get(\"retry-after\");\n\t\tif (ra) {\n\t\t\tconst sec = Number(ra);\n\t\t\tif (Number.isFinite(sec) && sec >= 0) e.retryAfterMs = sec * 1000;\n\t\t}\n\t\treturn e;\n\t}\n\n\treturn new ApiError(message, {\n\t\tstatus: res.status,\n\t\trequestId,\n\t\tcode,\n\t\tdetails,\n\t});\n}\n\nfunction shouldRetry(\n\topts: RequestOptions,\n\terr: unknown,\n): { retry: boolean; retryAfterMs?: number } {\n\tif (!opts.retryable) return { retry: false };\n\n\t// Retry on RateLimitError / 5xx / network failures\n\tif (err instanceof RateLimitError)\n\t\treturn { retry: true, retryAfterMs: err.retryAfterMs };\n\tif (err instanceof ApiError)\n\t\treturn { retry: err.status >= 500 && err.status <= 599 };\n\t// fetch throws TypeError on network failure in many runtimes\n\tif (err instanceof TypeError) return { retry: true };\n\treturn { retry: false };\n}\n\n/**\n * Checks if an error is a network-level failure that's safe to retry.\n * Includes socket failures, DNS errors, and fetch TypeErrors.\n */\nfunction isNetworkError(err: unknown): boolean {\n\t// Bun/Node fetch throws TypeError on network failure\n\tif (err instanceof TypeError) return true;\n\n\t// Check for common network error codes\n\tif (err && typeof err === \"object\") {\n\t\tconst e = err as Record<string, unknown>;\n\t\tconst code = e.code;\n\t\tif (typeof code === \"string\") {\n\t\t\t// Common network error codes\n\t\t\treturn [\n\t\t\t\t\"FailedToOpenSocket\",\n\t\t\t\t\"ECONNREFUSED\",\n\t\t\t\t\"ECONNRESET\",\n\t\t\t\t\"ETIMEDOUT\",\n\t\t\t\t\"ENOTFOUND\",\n\t\t\t\t\"EAI_AGAIN\",\n\t\t\t].includes(code);\n\t\t}\n\t}\n\treturn false;\n}\n\nexport class Transport {\n\tprivate readonly fetchImpl: typeof fetch;\n\n\tconstructor(private readonly opts: TransportOptions) {\n\t\tthis.fetchImpl = opts.fetch ?? fetch;\n\t}\n\n\t/**\n\t * Stream SSE events from a given path.\n\t *\n\t * Uses native `fetch` with streaming response body (not browser-only `EventSource`).\n\t * Parses SSE format manually from the `ReadableStream`.\n\t *\n\t * Automatically retries on network failures (socket errors, DNS failures, etc.)\n\t * up to `maxRetries` times with exponential backoff.\n\t */\n\tasync *streamSSE<T>(\n\t\tpath: string,\n\t\topts?: SSEStreamOptions,\n\t): AsyncGenerator<SSEEvent<T>> {\n\t\tconst url = buildUrl(this.opts.baseUrl, path);\n\t\tconst requestId = randomId(\"req\");\n\t\tconst maxRetries = Math.max(0, this.opts.maxRetries);\n\n\t\tconst headers: Record<string, string> = {\n\t\t\tAccept: \"text/event-stream\",\n\t\t\t\"Cache-Control\": \"no-cache\",\n\t\t\t\"Mappa-Api-Key\": this.opts.apiKey,\n\t\t\t\"X-Request-Id\": requestId,\n\t\t\t...(this.opts.userAgent ? { \"User-Agent\": this.opts.userAgent } : {}),\n\t\t\t...(this.opts.defaultHeaders ?? {}),\n\t\t};\n\n\t\tif (opts?.lastEventId) {\n\t\t\theaders[\"Last-Event-ID\"] = opts.lastEventId;\n\t\t}\n\n\t\tlet res: Response | undefined;\n\t\tlet lastError: unknown;\n\n\t\t// Retry loop for initial connection\n\t\tfor (let attempt = 0; attempt <= maxRetries; attempt++) {\n\t\t\tconst controller = new AbortController();\n\t\t\tconst timeout = setTimeout(\n\t\t\t\t() => controller.abort(makeAbortError()),\n\t\t\t\tthis.opts.timeoutMs,\n\t\t\t);\n\n\t\t\t// Combine signals: if caller aborts, abort our controller\n\t\t\tif (hasAbortSignal(opts?.signal)) {\n\t\t\t\tconst signal = opts?.signal;\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tthrow makeAbortError();\n\t\t\t\t}\n\t\t\t\tsignal?.addEventListener(\n\t\t\t\t\t\"abort\",\n\t\t\t\t\t() => controller.abort(makeAbortError()),\n\t\t\t\t\t{ once: true },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.opts.telemetry?.onRequest?.({ method: \"GET\", url, requestId });\n\n\t\t\ttry {\n\t\t\t\tres = await this.fetchImpl(url, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders,\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t});\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\t// Check for non-OK responses (5xx are retryable)\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\tconst { parsed } = await readBody(res);\n\t\t\t\t\tconst apiErr = coerceApiError(res, parsed);\n\n\t\t\t\t\tthis.opts.telemetry?.onError?.({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\terror: apiErr,\n\t\t\t\t\t\tcontext: { attempt, lastEventId: opts?.lastEventId },\n\t\t\t\t\t});\n\n\t\t\t\t\t// Retry on 5xx errors\n\t\t\t\t\tif (res.status >= 500 && res.status <= 599 && attempt < maxRetries) {\n\t\t\t\t\t\tconst delay = jitter(backoffMs(attempt + 1, 500, 4000));\n\t\t\t\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow apiErr;\n\t\t\t\t}\n\n\t\t\t\t// Success - exit retry loop\n\t\t\t\tbreak;\n\t\t\t} catch (err) {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tlastError = err;\n\n\t\t\t\tthis.opts.telemetry?.onError?.({\n\t\t\t\t\turl,\n\t\t\t\t\trequestId,\n\t\t\t\t\terror: err,\n\t\t\t\t\tcontext: { attempt, lastEventId: opts?.lastEventId },\n\t\t\t\t});\n\n\t\t\t\t// Check if retryable network error\n\t\t\t\tif (isNetworkError(err) && attempt < maxRetries) {\n\t\t\t\t\tconst delay = jitter(backoffMs(attempt + 1, 500, 4000));\n\t\t\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\n\t\tif (!res) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tif (!res.body) {\n\t\t\tthrow new MappaError(\"SSE response has no body\");\n\t\t}\n\n\t\tyield* this.parseSSEStream<T>(res.body);\n\t}\n\n\t/**\n\t * Parse SSE events from a ReadableStream.\n\t *\n\t * SSE format:\n\t * ```\n\t * id: <id>\n\t * event: <type>\n\t * data: <json>\n\t *\n\t * ```\n\t * Each event is terminated by an empty line.\n\t */\n\tprivate async *parseSSEStream<T>(\n\t\tbody: ReadableStream<Uint8Array>,\n\t): AsyncGenerator<SSEEvent<T>> {\n\t\tconst decoder = new TextDecoder();\n\t\tconst reader = body.getReader();\n\t\tlet buffer = \"\";\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) break;\n\n\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\n\t\t\t\t// Process complete events (separated by double newline)\n\t\t\t\tconst events = buffer.split(\"\\n\\n\");\n\t\t\t\t// Keep the last incomplete chunk in buffer\n\t\t\t\tbuffer = events.pop() ?? \"\";\n\n\t\t\t\tfor (const eventText of events) {\n\t\t\t\t\tif (!eventText.trim()) continue;\n\n\t\t\t\t\tconst event = this.parseSSEEvent<T>(eventText);\n\t\t\t\t\tif (event) {\n\t\t\t\t\t\tyield event;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Process any remaining data in buffer\n\t\t\tif (buffer.trim()) {\n\t\t\t\tconst event = this.parseSSEEvent<T>(buffer);\n\t\t\t\tif (event) {\n\t\t\t\t\tyield event;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\treader.releaseLock();\n\t\t}\n\t}\n\n\t/**\n\t * Parse a single SSE event from text.\n\t */\n\tprivate parseSSEEvent<T>(text: string): SSEEvent<T> | null {\n\t\tconst lines = text.split(\"\\n\");\n\t\tlet id: string | undefined;\n\t\tlet event = \"message\"; // default event type per SSE spec\n\t\tlet data = \"\";\n\n\t\tfor (const line of lines) {\n\t\t\tif (line.startsWith(\"id:\")) {\n\t\t\t\tid = line.slice(3).trim();\n\t\t\t} else if (line.startsWith(\"event:\")) {\n\t\t\t\tevent = line.slice(6).trim();\n\t\t\t} else if (line.startsWith(\"data:\")) {\n\t\t\t\t// Append to data (SSE allows multiple data lines)\n\t\t\t\tif (data) data += \"\\n\";\n\t\t\t\tdata += line.slice(5).trim();\n\t\t\t}\n\t\t\t// Ignore retry: and comments (lines starting with :)\n\t\t}\n\n\t\tif (!data) return null;\n\n\t\tlet parsedData: T;\n\t\ttry {\n\t\t\tparsedData = JSON.parse(data) as T;\n\t\t} catch {\n\t\t\t// If data is not valid JSON, return it as-is (cast to T)\n\t\t\tparsedData = data as unknown as T;\n\t\t}\n\n\t\treturn { id, event, data: parsedData };\n\t}\n\n\tasync request<T>(req: RequestOptions): Promise<TransportResponse<T>> {\n\t\tconst url = buildUrl(this.opts.baseUrl, req.path, req.query);\n\n\t\tconst requestId = req.requestId ?? randomId(\"req\");\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Mappa-Api-Key\": this.opts.apiKey,\n\t\t\t\"X-Request-Id\": requestId,\n\t\t\t...(this.opts.userAgent ? { \"User-Agent\": this.opts.userAgent } : {}),\n\t\t\t...(this.opts.defaultHeaders ?? {}),\n\t\t};\n\n\t\tif (req.idempotencyKey) headers[\"Idempotency-Key\"] = req.idempotencyKey;\n\t\tif (req.headers) {\n\t\t\tfor (const [k, v] of Object.entries(req.headers)) {\n\t\t\t\tif (v !== undefined) headers[k] = v;\n\t\t\t}\n\t\t}\n\n\t\tconst isFormData =\n\t\t\ttypeof FormData !== \"undefined\" && req.body instanceof FormData;\n\t\tconst hasBody = req.body !== undefined;\n\n\t\tif (hasBody && !isFormData) headers[\"Content-Type\"] = \"application/json\";\n\n\t\tconst body =\n\t\t\treq.body === undefined\n\t\t\t\t? undefined\n\t\t\t\t: isFormData\n\t\t\t\t\t? (req.body as FormData)\n\t\t\t\t\t: JSON.stringify(req.body);\n\n\t\tconst maxRetries = Math.max(0, this.opts.maxRetries);\n\t\tconst startedAt = Date.now();\n\n\t\tfor (let attempt = 1; attempt <= 1 + maxRetries; attempt++) {\n\t\t\tconst controller = new AbortController();\n\t\t\tconst timeout = setTimeout(\n\t\t\t\t() => controller.abort(makeAbortError()),\n\t\t\t\tthis.opts.timeoutMs,\n\t\t\t);\n\n\t\t\t// Combine signals: if caller aborts, abort our controller\n\t\t\tif (hasAbortSignal(req.signal)) {\n\t\t\t\tconst signal = req.signal;\n\t\t\t\tif (!signal) {\n\t\t\t\t\t// Type guard safety: hasAbortSignal should imply this is defined.\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tthrow new Error(\"Unexpected: abort signal missing\");\n\t\t\t\t}\n\t\t\t\tif (signal.aborted) {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tthrow makeAbortError();\n\t\t\t\t}\n\t\t\t\tsignal.addEventListener(\n\t\t\t\t\t\"abort\",\n\t\t\t\t\t() => controller.abort(makeAbortError()),\n\t\t\t\t\t{ once: true },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.opts.telemetry?.onRequest?.({ method: req.method, url, requestId });\n\n\t\t\ttry {\n\t\t\t\tconst res = await this.fetchImpl(url, {\n\t\t\t\t\tmethod: req.method,\n\t\t\t\t\theaders,\n\t\t\t\t\tbody,\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t});\n\n\t\t\t\tconst durationMs = Date.now() - startedAt;\n\t\t\t\tconst serverRequestId =\n\t\t\t\t\tgetHeader(res.headers, \"x-request-id\") ?? requestId;\n\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\tconst { parsed } = await readBody(res);\n\t\t\t\t\tconst apiErr = coerceApiError(res, parsed);\n\n\t\t\t\t\tthis.opts.telemetry?.onError?.({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\trequestId: serverRequestId,\n\t\t\t\t\t\terror: apiErr,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst decision = shouldRetry(req, apiErr);\n\t\t\t\t\tif (\n\t\t\t\t\t\tattempt <= maxRetries + 1 &&\n\t\t\t\t\t\tdecision.retry &&\n\t\t\t\t\t\tattempt <= maxRetries\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst base =\n\t\t\t\t\t\t\tdecision.retryAfterMs ?? jitter(backoffMs(attempt, 500, 4000));\n\t\t\t\t\t\tawait new Promise((r) => setTimeout(r, base));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow apiErr;\n\t\t\t\t}\n\n\t\t\t\tconst ct = res.headers.get(\"content-type\") ?? \"\";\n\t\t\t\tlet data: unknown;\n\t\t\t\tif (ct.includes(\"application/json\")) {\n\t\t\t\t\tdata = (await res.json()) as unknown;\n\t\t\t\t} else {\n\t\t\t\t\tdata = await res.text();\n\t\t\t\t}\n\n\t\t\t\tthis.opts.telemetry?.onResponse?.({\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\turl,\n\t\t\t\t\trequestId: serverRequestId,\n\t\t\t\t\tdurationMs,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tdata: data as T,\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\trequestId: serverRequestId,\n\t\t\t\t\theaders: res.headers,\n\t\t\t\t};\n\t\t\t} catch (err) {\n\t\t\t\tthis.opts.telemetry?.onError?.({ url, requestId, error: err });\n\n\t\t\t\tconst decision = shouldRetry(req, err);\n\t\t\t\tif (attempt <= maxRetries && decision.retry) {\n\t\t\t\t\tconst sleep =\n\t\t\t\t\t\tdecision.retryAfterMs ?? jitter(backoffMs(attempt, 500, 4000));\n\t\t\t\t\tawait new Promise((r) => setTimeout(r, sleep));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t}\n\t\t}\n\n\t\t// unreachable\n\t\tthrow new Error(\"Unexpected transport exit\");\n\t}\n}\n","function isObject(v: unknown): v is Record<string, unknown> {\n\treturn v !== null && typeof v === \"object\";\n}\n\n/**\n * Webhook event types supported by the API.\n */\nexport type WebhookEventType = \"report.completed\" | \"report.failed\";\n\n/**\n * Base webhook event structure.\n */\nexport interface WebhookEvent<T = unknown> {\n\ttype: string;\n\ttimestamp: string;\n\tdata: T;\n}\n\n/**\n * Payload for successful report completion.\n */\nexport interface ReportCompletedData {\n\tjobId: string;\n\treportId: string;\n\tstatus: \"succeeded\";\n}\n\n/**\n * Payload for failed report processing.\n */\nexport interface ReportFailedData {\n\tjobId: string;\n\tstatus: \"failed\";\n\terror: {\n\t\tcode: string;\n\t\tmessage: string;\n\t};\n}\n\n/**\n * Event emitted when a report completes successfully.\n */\nexport type ReportCompletedEvent = WebhookEvent<ReportCompletedData> & {\n\ttype: \"report.completed\";\n};\n\n/**\n * Event emitted when a report fails.\n */\nexport type ReportFailedEvent = WebhookEvent<ReportFailedData> & {\n\ttype: \"report.failed\";\n};\n\n/**\n * Async signature verification using WebCrypto (works in modern Node and browsers).\n * Signature scheme:\n * headers[\"mappa-signature\"] = \"t=1700000000,v1=<hex_hmac_sha256>\"\n * Signed payload: `${t}.${rawBody}`\n */\n\nexport class WebhooksResource {\n\tasync verifySignature(params: {\n\t\tpayload: string; // raw body\n\t\theaders: Record<string, string | string[] | undefined>;\n\t\tsecret: string;\n\t\ttoleranceSec?: number;\n\t}): Promise<{ ok: true }> {\n\t\tconst tolerance = params.toleranceSec ?? 300;\n\n\t\tconst sigHeader = headerValue(params.headers, \"mappa-signature\");\n\t\tif (!sigHeader) throw new Error(\"Missing mappa-signature header\");\n\n\t\tconst parts = parseSig(sigHeader);\n\t\tconst ts = Number(parts.t);\n\t\tif (!Number.isFinite(ts)) throw new Error(\"Invalid signature timestamp\");\n\n\t\tconst nowSec = Math.floor(Date.now() / 1000);\n\t\tif (Math.abs(nowSec - ts) > tolerance)\n\t\t\tthrow new Error(\"Signature timestamp outside tolerance\");\n\n\t\tconst signed = `${parts.t}.${params.payload}`;\n\t\tconst expected = await hmacHex(params.secret, signed);\n\n\t\tif (!timingSafeEqualHex(expected, parts.v1))\n\t\t\tthrow new Error(\"Invalid signature\");\n\n\t\treturn { ok: true };\n\t}\n\n\t/**\n\t * Parse and validate a webhook event payload.\n\t *\n\t * @param payload - Raw JSON string from the webhook request body\n\t * @returns Parsed and validated webhook event\n\t * @throws Error if payload is invalid or missing required fields\n\t */\n\tparseEvent<T = unknown>(payload: string): WebhookEvent<T> {\n\t\tconst raw: unknown = JSON.parse(payload);\n\t\tif (!isObject(raw))\n\t\t\tthrow new Error(\"Invalid webhook payload: not an object\");\n\t\tconst obj = raw;\n\n\t\tconst type = obj.type;\n\t\tconst timestamp = obj.timestamp;\n\n\t\tif (typeof type !== \"string\")\n\t\t\tthrow new Error(\"Invalid webhook payload: type must be a string\");\n\t\tif (typeof timestamp !== \"string\")\n\t\t\tthrow new Error(\"Invalid webhook payload: timestamp must be a string\");\n\n\t\treturn {\n\t\t\ttype,\n\t\t\ttimestamp,\n\t\t\tdata: \"data\" in obj ? (obj.data as T) : (undefined as unknown as T),\n\t\t};\n\t}\n}\n\nfunction headerValue(\n\theaders: Record<string, string | string[] | undefined>,\n\tname: string,\n): string | undefined {\n\tconst key = Object.keys(headers).find(\n\t\t(k) => k.toLowerCase() === name.toLowerCase(),\n\t);\n\tconst v = key ? headers[key] : undefined;\n\tif (!v) return undefined;\n\treturn Array.isArray(v) ? v[0] : v;\n}\n\nfunction parseSig(h: string): { t: string; v1: string } {\n\tconst out: Record<string, string> = {};\n\tfor (const part of h.split(\",\")) {\n\t\tconst [k, v] = part.split(\"=\");\n\t\tif (k && v) out[k.trim()] = v.trim();\n\t}\n\tif (!out.t || !out.v1) throw new Error(\"Invalid signature format\");\n\treturn { t: out.t, v1: out.v1 };\n}\n\nasync function hmacHex(secret: string, message: string): Promise<string> {\n\tconst enc = new TextEncoder();\n\tconst key = await crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tenc.encode(secret),\n\t\t{ name: \"HMAC\", hash: \"SHA-256\" },\n\t\tfalse,\n\t\t[\"sign\"],\n\t);\n\tconst sig = await crypto.subtle.sign(\"HMAC\", key, enc.encode(message));\n\treturn bufToHex(sig);\n}\n\nfunction bufToHex(buf: ArrayBuffer): string {\n\tconst b = new Uint8Array(buf);\n\tlet s = \"\";\n\tfor (const x of b) s += x.toString(16).padStart(2, \"0\");\n\treturn s;\n}\n\nfunction timingSafeEqualHex(a: string, b: string): boolean {\n\tif (a.length !== b.length) return false;\n\tlet r = 0;\n\tfor (let i = 0; i < a.length; i++) r |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\treturn r === 0;\n}\n","import { MappaError } from \"$/errors\";\nimport { CreditsResource } from \"$/resources/credits\";\nimport { EntitiesResource } from \"$/resources/entities\";\nimport { FeedbackResource } from \"$/resources/feedback\";\nimport { FilesResource } from \"$/resources/files\";\nimport { HealthResource } from \"$/resources/health\";\nimport { JobsResource } from \"$/resources/jobs\";\nimport { ReportsResource } from \"$/resources/reports\";\nimport { type Telemetry, Transport } from \"$/resources/transport\";\nimport { WebhooksResource } from \"$/resources/webhooks\";\n\n/**\n * Options for constructing a {@link Mappa} client.\n */\nexport type MappaClientOptions = {\n\t/**\n\t * API key used for authenticating requests.\n\t */\n\tapiKey: string;\n\n\t/**\n\t * Base URL for the Mappa API.\n\t *\n\t * @defaultValue \"https://api.mappa.ai\"\n\t */\n\tbaseUrl?: string;\n\n\t/**\n\t * Per-request timeout, in milliseconds.\n\t *\n\t * Note: this timeout applies to individual HTTP attempts (including retries).\n\t * Long-running workflows should use {@link JobsResource.wait} through\n\t * {@link ReportsResource.makeHandle} instead.\n\t *\n\t * @defaultValue 30000\n\t */\n\ttimeoutMs?: number;\n\n\t/**\n\t * Maximum number of retries performed by the transport for retryable requests.\n\t *\n\t * @defaultValue 2\n\t */\n\tmaxRetries?: number;\n\n\t/**\n\t * Headers that will be sent with every request.\n\t */\n\tdefaultHeaders?: Record<string, string>;\n\n\t/**\n\t * Custom fetch implementation (useful for polyfills, instrumentation, or tests).\n\t */\n\tfetch?: typeof fetch;\n\n\t/**\n\t * Overrides the User-Agent header.\n\t */\n\tuserAgent?: string;\n\n\t/**\n\t * Telemetry hooks called on request/response/error.\n\t */\n\ttelemetry?: Telemetry;\n};\n\n/**\n * Main SDK client.\n *\n * Exposes resource namespaces ({@link Mappa.files}, {@link Mappa.reports}, etc.)\n * and configures a shared HTTP transport.\n */\nexport class Mappa {\n\tpublic readonly files: FilesResource;\n\tpublic readonly jobs: JobsResource;\n\tpublic readonly reports: ReportsResource;\n\tpublic readonly feedback: FeedbackResource;\n\tpublic readonly credits: CreditsResource;\n\tpublic readonly entities: EntitiesResource;\n\tpublic readonly webhooks: WebhooksResource;\n\tpublic readonly health: HealthResource;\n\n\tprivate readonly transport: Transport;\n\tprivate readonly opts: Required<\n\t\tPick<MappaClientOptions, \"apiKey\" | \"baseUrl\" | \"timeoutMs\" | \"maxRetries\">\n\t> &\n\t\tOmit<MappaClientOptions, \"apiKey\" | \"baseUrl\" | \"timeoutMs\" | \"maxRetries\">;\n\n\tconstructor(options: MappaClientOptions) {\n\t\tif (!options.apiKey) {\n\t\t\tthrow new MappaError(\"apiKey is required\");\n\t\t}\n\n\t\tconst baseUrl = options.baseUrl ?? \"https://api.mappa.ai\";\n\t\tconst timeoutMs = options.timeoutMs ?? 30_000;\n\t\tconst maxRetries = options.maxRetries ?? 2;\n\n\t\tthis.opts = {\n\t\t\t...options,\n\t\t\tapiKey: options.apiKey,\n\t\t\tbaseUrl,\n\t\t\ttimeoutMs,\n\t\t\tmaxRetries,\n\t\t};\n\n\t\tthis.transport = new Transport({\n\t\t\tapiKey: options.apiKey,\n\t\t\tbaseUrl,\n\t\t\ttimeoutMs,\n\t\t\tmaxRetries,\n\t\t\tdefaultHeaders: options.defaultHeaders,\n\t\t\tfetch: options.fetch,\n\t\t\ttelemetry: options.telemetry,\n\t\t\tuserAgent: options.userAgent,\n\t\t});\n\n\t\tthis.files = new FilesResource(this.transport);\n\t\tthis.jobs = new JobsResource(this.transport);\n\t\tthis.reports = new ReportsResource(\n\t\t\tthis.transport,\n\t\t\tthis.jobs,\n\t\t\tthis.files,\n\t\t\tthis.opts.fetch ?? fetch,\n\t\t);\n\t\tthis.feedback = new FeedbackResource(this.transport);\n\t\tthis.credits = new CreditsResource(this.transport);\n\t\tthis.entities = new EntitiesResource(this.transport);\n\t\tthis.webhooks = new WebhooksResource();\n\t\tthis.health = new HealthResource(this.transport);\n\t}\n\n\twithOptions(overrides: Partial<MappaClientOptions>): Mappa {\n\t\treturn new Mappa({\n\t\t\t...this.opts,\n\t\t\t...overrides,\n\t\t\tapiKey: overrides.apiKey ?? this.opts.apiKey,\n\t\t});\n\t}\n\n\tclose(): void {\n\t\t// No-op today; reserved for future transport cleanup (keep-alive, SSE, etc.).\n\t}\n}\n","/**\n * JSON-serializable value.\n *\n * Used throughout the SDK for message payloads, webhook data, and server-provided\n * metadata where the exact shape is not known at compile time.\n */\nexport type JsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| { [k: string]: JsonValue }\n\t| JsonValue[];\n\nexport type MediaRef =\n\t| { url: string; contentType?: string; filename?: string }\n\t| { mediaId: string };\n\n/**\n * A reference to an already-uploaded media object.\n */\nexport type MediaIdRef = { mediaId: string };\n\nexport type ReportTemplateId =\n\t| \"sales_playbook\"\n\t| \"general_report\"\n\t| \"hiring_report\"\n\t| \"profile_alignment\";\n\nexport type ReportTemplateParamsMap = {\n\tsales_playbook: Record<string, never>;\n\tgeneral_report: Record<string, never>;\n\thiring_report: {\n\t\troleTitle: string;\n\t\troleDescription: string;\n\t\tcompanyCulture: string;\n\t};\n\tprofile_alignment: {\n\t\tidealProfile: string;\n\t};\n};\n\nexport type ReportOutputType = \"markdown\" | \"json\" | \"pdf\" | \"url\";\n\ntype ReportOutputEntry<\n\tOutputType extends ReportOutputType,\n\tTemplate extends ReportTemplateId,\n> = ReportTemplateParamsMap[Template] extends Record<string, never>\n\t? {\n\t\t\ttype: OutputType;\n\t\t\ttemplate: Template;\n\t\t\ttemplateParams?: ReportTemplateParamsMap[Template];\n\t\t}\n\t: {\n\t\t\ttype: OutputType;\n\t\t\ttemplate: Template;\n\t\t\ttemplateParams: ReportTemplateParamsMap[Template];\n\t\t};\n\ntype ReportOutputForType<OutputType extends ReportOutputType> =\n\t| ReportOutputEntry<OutputType, \"sales_playbook\">\n\t| ReportOutputEntry<OutputType, \"general_report\">\n\t| ReportOutputEntry<OutputType, \"hiring_report\">\n\t| ReportOutputEntry<OutputType, \"profile_alignment\">;\n\nexport type ReportOutput =\n\t| ReportOutputForType<\"markdown\">\n\t| ReportOutputForType<\"json\">\n\t| ReportOutputForType<\"pdf\">\n\t| ReportOutputForType<\"url\">;\n\n/**\n * Report output configuration constrained to a specific output type.\n * When T is a specific literal like \"markdown\", only markdown output configs are allowed.\n * When T is the full union (ReportOutputType), all output configs are allowed.\n *\n * @example\n * ```typescript\n * type MarkdownOutput = ReportOutputFor<\"markdown\">; // Only markdown configs\n * type AnyOutput = ReportOutputFor<ReportOutputType>; // All configs (same as ReportOutput)\n * ```\n */\nexport type ReportOutputFor<T extends ReportOutputType> = T extends \"markdown\"\n\t? ReportOutputForType<\"markdown\">\n\t: T extends \"json\"\n\t\t? ReportOutputForType<\"json\">\n\t\t: T extends \"pdf\"\n\t\t\t? ReportOutputForType<\"pdf\">\n\t\t\t: T extends \"url\"\n\t\t\t\t? ReportOutputForType<\"url\">\n\t\t\t\t: ReportOutput;\n\nexport type TargetStrategy =\n\t| \"dominant\"\n\t| \"timerange\"\n\t| \"entity_id\"\n\t| \"magic_hint\";\n\nexport type TargetOnMiss = \"fallback_dominant\" | \"error\";\n\nexport type TargetTimeRange = {\n\t/**\n\t * Start time in seconds.\n\t * When omitted, starts from the beginning.\n\t */\n\tstartSeconds?: number;\n\t/**\n\t * End time in seconds.\n\t * When omitted, goes until the end.\n\t */\n\tendSeconds?: number;\n};\n\ntype TargetBase = {\n\t/**\n\t * Behavior when the entity is not found.\n\t */\n\tonMiss?: TargetOnMiss;\n\t/**\n\t * Tags to apply to the selected entity after job completion.\n\t *\n\t * Tags must be 1-64 characters, alphanumeric with underscores and hyphens only.\n\t * Maximum 10 tags per request.\n\t *\n\t * @example [\"interviewer\", \"sales-rep\", \"round-1\"]\n\t */\n\ttags?: string[];\n\t/**\n\t * Exclude speakers whose entities have ANY of these tags from selection.\n\t *\n\t * Useful for filtering out known interviewers, hosts, etc.\n\t *\n\t * @example [\"interviewer\", \"host\"]\n\t */\n\texcludeTags?: string[];\n};\n\nexport type TargetDominant = TargetBase & {\n\tstrategy: \"dominant\";\n};\n\nexport type TargetTimeRangeStrategy = TargetBase & {\n\tstrategy: \"timerange\";\n\ttimeRange: TargetTimeRange;\n};\n\nexport type TargetEntityId = TargetBase & {\n\tstrategy: \"entity_id\";\n\tentityId: string;\n};\n\nexport type TargetMagicHint = TargetBase & {\n\tstrategy: \"magic_hint\";\n\thint: string;\n};\n\nexport type TargetSelector =\n\t| TargetDominant\n\t| TargetTimeRangeStrategy\n\t| TargetEntityId\n\t| TargetMagicHint;\n\nexport type TargetStrategyMap = {\n\tdominant: TargetDominant;\n\ttimerange: TargetTimeRangeStrategy;\n\tentity_id: TargetEntityId;\n\tmagic_hint: TargetMagicHint;\n};\n\nexport type TargetFor<Strategy extends TargetStrategy> =\n\tTargetStrategyMap[Strategy];\n\nexport type Usage = {\n\tcreditsUsed: number;\n\tcreditsDiscounted?: number;\n\tcreditsNetUsed: number;\n\tdurationMs?: number;\n\tmodelVersion?: string;\n};\n\nexport type JobStage =\n\t| \"uploaded\"\n\t| \"queued\"\n\t| \"transcoding\"\n\t| \"extracting\"\n\t| \"scoring\"\n\t| \"rendering\"\n\t| \"finalizing\";\n\nexport type JobStatus =\n\t| \"queued\"\n\t| \"running\"\n\t| \"succeeded\"\n\t| \"failed\"\n\t| \"canceled\";\n\nexport type JobCreditReservation = {\n\treservedCredits: number | null;\n\treservationStatus: \"active\" | \"released\" | \"applied\" | null;\n};\n\nexport type Job = {\n\tid: string;\n\ttype: \"report.generate\";\n\tstatus: JobStatus;\n\tstage?: JobStage;\n\tprogress?: number; // 0..1\n\tcreatedAt: string;\n\tupdatedAt: string;\n\treportId?: string;\n\tusage?: Usage;\n\tcredits?: JobCreditReservation;\n\treleasedCredits?: number | null;\n\terror?: {\n\t\tcode: string;\n\t\tmessage: string;\n\t\tdetails?: JsonValue;\n\t\tretryable?: boolean;\n\t};\n\trequestId?: string;\n};\n\nexport type JobEvent =\n\t| { type: \"status\"; job: Job }\n\t| { type: \"stage\"; stage: JobStage; progress?: number; job: Job }\n\t| { type: \"log\"; message: string; ts: string }\n\t| { type: \"terminal\"; job: Job };\n\nexport type Subject = {\n\tid?: string;\n\texternalRef?: string;\n\tmetadata?: Record<string, JsonValue>;\n};\n\nexport type WebhookConfig = {\n\turl: string;\n\theaders?: Record<string, string>;\n};\n\nexport type ReportCreateJobRequest<\n\tT extends ReportOutputType = ReportOutputType,\n> = {\n\tsubject?: Subject;\n\t/**\n\t * Reference to already-uploaded media.\n\t *\n\t * Note: Report job creation requires a `mediaId`. To start from a remote URL or local bytes,\n\t * use helper methods like `reports.createJobFromUrl()` / `reports.createJobFromFile()`.\n\t */\n\tmedia: MediaIdRef;\n\toutput: ReportOutputFor<T>;\n\t/**\n\t * Select the target entity for analysis.\n\t *\n\t * @defaultValue `{ strategy: \"dominant\" }` - analyzes the dominant speaker\n\t */\n\ttarget?: TargetSelector;\n\toptions?: {\n\t\tlanguage?: string;\n\t\ttimezone?: string;\n\t\tincludeMetrics?: boolean;\n\t\tincludeRawModelOutput?: boolean;\n\t};\n\t/**\n\t * Webhook to call when the job completes or fails.\n\t *\n\t * @example\n\t * webhook: {\n\t * url: \"https://example.com/webhooks/mappa\",\n\t * headers: { \"X-Custom-Header\": \"value\" }\n\t * }\n\t */\n\twebhook?: WebhookConfig;\n\tidempotencyKey?: string;\n\trequestId?: string;\n};\n\nexport type ReportBase = {\n\tid: string;\n\tcreatedAt: string;\n\tjobId?: string;\n\tsubject?: Subject;\n\tmedia: { url?: string; mediaId?: string };\n\tentity: {\n\t\tid: string;\n\t\ttags: string[];\n\t};\n\tusage?: Usage;\n\tmetrics?: Record<string, JsonValue>;\n\traw?: JsonValue;\n};\n\nexport type MarkdownReport = ReportBase & {\n\toutput: { type: \"markdown\"; template: ReportTemplateId };\n\tmarkdown: string;\n};\n\nexport type JsonReport = ReportBase & {\n\toutput: { type: \"json\"; template: ReportTemplateId };\n\tsections: Array<{\n\t\tsection_title: string;\n\t\tsection_content: JsonValue;\n\t}>;\n};\n\nexport type PdfReport = ReportBase & {\n\toutput: { type: \"pdf\"; template: ReportTemplateId };\n\tmarkdown: string;\n\tpdfUrl: string;\n};\n\nexport type UrlReport = ReportBase & {\n\toutput: { type: \"url\"; template: ReportTemplateId };\n\tmarkdown: string;\n\tsections: Array<{\n\t\tsection_title: string;\n\t\tsection_content: JsonValue;\n\t}>;\n\treportUrl: string;\n};\n\nexport type Report = MarkdownReport | JsonReport | PdfReport | UrlReport;\n\n/**\n * Maps an output type to its corresponding report type.\n * Used for type-safe inference in generate methods.\n *\n * @example\n * ```typescript\n * type R = ReportForOutputType<\"markdown\">; // MarkdownReport\n * type R = ReportForOutputType<\"json\">; // JsonReport\n * type R = ReportForOutputType<ReportOutputType>; // Report (union)\n * ```\n */\nexport type ReportForOutputType<T extends ReportOutputType> =\n\tT extends \"markdown\"\n\t\t? MarkdownReport\n\t\t: T extends \"json\"\n\t\t\t? JsonReport\n\t\t\t: T extends \"pdf\"\n\t\t\t\t? PdfReport\n\t\t\t\t: T extends \"url\"\n\t\t\t\t\t? UrlReport\n\t\t\t\t\t: Report;\n\nexport type ReportJobReceipt<T extends ReportOutputType = ReportOutputType> = {\n\tjobId: string;\n\tstatus: \"queued\" | \"running\";\n\tstage?: JobStage;\n\testimatedWaitSec?: number;\n\trequestId?: string;\n\thandle?: ReportRunHandle<T>;\n};\n\nexport type FeedbackReceipt = {\n\tid: string;\n\tcreatedAt: string;\n\ttarget: { reportId?: string; jobId?: string };\n\trating: \"thumbs_up\" | \"thumbs_down\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\";\n\ttags?: string[];\n\tcomment?: string;\n\tcredits: {\n\t\teligible: boolean;\n\t\treason?: string;\n\t\tdiscountApplied: number;\n\t\tnetUsed: number;\n\t};\n};\n\nexport type MediaObject = {\n\tmediaId: string;\n\tcreatedAt: string;\n\tcontentType: string;\n\tfilename?: string;\n\tsizeBytes?: number;\n};\n\nexport type MediaProcessingStatus =\n\t| \"PENDING\"\n\t| \"PROCESSING\"\n\t| \"COMPLETED\"\n\t| \"FAILED\";\n\nexport type MediaRetention = {\n\texpiresAt: string | null;\n\tdaysRemaining: number | null;\n\tlocked: boolean;\n};\n\nexport type MediaFile = {\n\tmediaId: string;\n\tcreatedAt: string;\n\tcontentType: string;\n\tfilename: string | null;\n\tsizeBytes: number | null;\n\tdurationSeconds: number | null;\n\tprocessingStatus: MediaProcessingStatus;\n\tlastUsedAt: string | null;\n\tretention: MediaRetention;\n};\n\nexport type FileDeleteReceipt = {\n\tmediaId: string;\n\tdeleted: true;\n};\n\nexport type RetentionLockResult = {\n\tmediaId: string;\n\tretentionLock: boolean;\n\tmessage: string;\n};\n\nexport type CursorPaginationParams = {\n\tlimit?: number;\n\tcursor?: string;\n};\n\nexport type OffsetPaginationParams = {\n\tlimit?: number;\n\toffset?: number;\n};\n\nexport type CursorPage<T> = {\n\tdata: T[];\n\tcursor?: string;\n\thasMore: boolean;\n};\n\nexport type OffsetPage<T> = {\n\tdata: T[];\n\tpagination: {\n\t\tlimit: number;\n\t\toffset: number;\n\t\ttotal: number;\n\t};\n};\n\nexport type CreditBalance = {\n\tbalance: number;\n\treserved: number;\n\tavailable: number;\n};\n\nexport type CreditTransactionType =\n\t| \"PURCHASE\"\n\t| \"SUBSCRIPTION_GRANT\"\n\t| \"PROMO_GRANT\"\n\t| \"USAGE\"\n\t| \"REFUND\"\n\t| \"FEEDBACK_DISCOUNT\"\n\t| \"ADJUSTMENT\"\n\t| \"EXPIRATION\";\n\nexport type CreditTransaction = {\n\tid: string;\n\ttype: CreditTransactionType;\n\tamount: number;\n\tcreatedAt: string;\n\teffectiveAt: string;\n\texpiresAt: string | null;\n\tjobId: string | null;\n\tjob?: {\n\t\tid: string;\n\t\tstatus: string;\n\t\tcreatedAt: string;\n\t};\n};\n\nexport type CreditUsage = {\n\tjobId: string;\n\tcreditsUsed: number;\n\tcreditsDiscounted?: number;\n\tcreditsNetUsed: number;\n\tdurationMs?: number;\n\tmodelVersion?: string;\n};\n\n/**\n * Options for waiting on job completion.\n */\nexport type WaitOptions = {\n\t/**\n\t * Maximum time to wait before failing.\n\t *\n\t * @defaultValue 300000\n\t */\n\ttimeoutMs?: number;\n\n\t/**\n\t * Optional callback invoked on meaningful job state transitions.\n\t */\n\tonEvent?: (event: JobEvent) => void;\n\n\t/**\n\t * Abort signal used to cancel waiting.\n\t */\n\tsignal?: AbortSignal;\n};\n\n// Forward decl to avoid circular imports; implemented in reports resource.\nexport type ReportRunHandle<T extends ReportOutputType = ReportOutputType> = {\n\tjobId: string;\n\tstream(opts?: {\n\t\tsignal?: AbortSignal;\n\t\tonEvent?: (e: JobEvent) => void;\n\t}): AsyncIterable<JobEvent>;\n\twait(opts?: WaitOptions): Promise<ReportForOutputType<T>>;\n\tcancel(): Promise<Job>;\n\tjob(): Promise<Job>;\n\treport(): Promise<ReportForOutputType<T> | null>;\n};\n\n/**\n * Type guard for MarkdownReport.\n */\nexport function isMarkdownReport(report: Report): report is MarkdownReport {\n\treturn report.output.type === \"markdown\";\n}\n\n/**\n * Type guard for JsonReport.\n */\nexport function isJsonReport(report: Report): report is JsonReport {\n\treturn report.output.type === \"json\";\n}\n\n/**\n * Type guard for PdfReport.\n */\nexport function isPdfReport(report: Report): report is PdfReport {\n\treturn report.output.type === \"pdf\";\n}\n\n/**\n * Type guard for UrlReport.\n */\nexport function isUrlReport(report: Report): report is UrlReport {\n\treturn report.output.type === \"url\";\n}\n\nexport type Entity = {\n\tid: string;\n\ttags: string[];\n\tcreatedAt: string;\n\tmediaCount: number;\n\tlastSeenAt: string | null;\n};\n\nexport type EntityTagsResult = {\n\tentityId: string;\n\ttags: string[];\n};\n\nexport type ListEntitiesOptions = CursorPaginationParams & {\n\t/**\n\t * Filter entities by tags.\n\t * Entities must have ALL specified tags (AND logic).\n\t */\n\ttags?: string[];\n};\n\nexport type ListEntitiesResponse = {\n\tentities: Entity[];\n\tcursor?: string;\n\thasMore: boolean;\n};\n\n/**\n * Type guard to check if a report has entity information.\n * Always returns true since entity is always present in reports.\n */\nexport function hasEntity(report: Report): report is Report & {\n\tentity: { id: string; tags: string[] };\n} {\n\treturn report.entity !== undefined && report.entity !== null;\n}\n","/**\n * Mappa Node SDK\n *\n * This module is the public entrypoint for the package. It re-exports:\n * - {@link Mappa} (the main client)\n * - Error types from {@link \"$/errors\"}\n * - Public TypeScript types from {@link \"$/types\"}\n */\nexport * from \"$/errors\";\nexport { Mappa } from \"$/Mappa\";\nexport type {\n\tReportCompletedData,\n\tReportCompletedEvent,\n\tReportFailedData,\n\tReportFailedEvent,\n\tWebhookEvent,\n\tWebhookEventType,\n} from \"$/resources/webhooks\";\nexport type * from \"$/types\";\nexport {\n\thasEntity,\n\tisJsonReport,\n\tisMarkdownReport,\n\tisPdfReport,\n\tisUrlReport,\n} from \"$/types\";\n\nimport { InsufficientCreditsError, MappaError, StreamError } from \"$/errors\";\n\n/**\n * Type guard for catching SDK errors.\n */\nexport function isMappaError(err: unknown): err is MappaError {\n\treturn err instanceof MappaError;\n}\n\n/**\n * Type guard for insufficient credits errors.\n *\n * @example\n * ```typescript\n * try {\n * await mappa.reports.createJob({ ... });\n * } catch (err) {\n * if (isInsufficientCreditsError(err)) {\n * console.log(`Need ${err.required} credits, have ${err.available}`);\n * }\n * }\n * ```\n */\nexport function isInsufficientCreditsError(\n\terr: unknown,\n): err is InsufficientCreditsError {\n\treturn err instanceof InsufficientCreditsError;\n}\n\n/**\n * Type guard for stream connection errors.\n *\n * Use this to detect streaming failures and access recovery metadata\n * like `jobId`, `lastEventId`, and `retryCount`.\n *\n * @example\n * ```typescript\n * try {\n * await mappa.reports.generate({ ... });\n * } catch (err) {\n * if (isStreamError(err)) {\n * console.log(`Stream failed for job ${err.jobId}`);\n * console.log(`Last event ID: ${err.lastEventId}`);\n * console.log(`Retries attempted: ${err.retryCount}`);\n * }\n * }\n * ```\n */\nexport function isStreamError(err: unknown): err is StreamError {\n\treturn err instanceof StreamError;\n}\n"],"mappings":";;;;;;;AAIA,MAAM,gBAAgB,OAAO,IAAI,6BAA6B;;;;AAK9D,SAAS,cAAc,SAAkB,SAAS,MAAc;AAC/D,KAAI,YAAY,UAAa,YAAY,KAAM,QAAO;AACtD,KAAI;AAGH,SAFa,KAAK,UAAU,SAAS,MAAM,EAAE,CAEjC,MAA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;;;;;AAiBvB,SAAgB,2BACf,KACkC;AAClC,QAAO,eAAe;;;;;;;;;;;;;;;;;;;;;AAsBvB,SAAgB,cAAc,KAAkC;AAC/D,QAAO,eAAe"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isObject","initializer","util.jsonStringifyReplacer","core.$ZodAsyncError","util.finalizeIssue","core.config","parse","errors.$ZodRealError","parseAsync","errors.$ZodError","safeParse","safeParseAsync","encode","decode","encodeAsync","decodeAsync","safeEncode","safeDecode","safeEncodeAsync","safeDecodeAsync","duration","_emoji","date","time","datetime","string","number","boolean","util.floatSafeRemainder","util.NUMBER_FORMAT_RANGES","regexes.integer","util.nullish","util.getLengthableOrigin","regexes.lowercase","regexes.uppercase","util.escapeRegex","util.aborted","core.$ZodAsyncError","safeParse","safeParseAsync","regexes.string","regexes.guid","regexes.uuid","regexes.email","regexes.emoji","regexes.nanoid","regexes.cuid","regexes.cuid2","regexes.ulid","regexes.xid","regexes.ksuid","regexes.datetime","regexes.date","regexes.time","regexes.duration","regexes.ipv4","regexes.ipv6","regexes.cidrv4","regexes.cidrv6","regexes.base64","regexes.base64url","regexes.e164","regexes.number","regexes.boolean","util.prefixIssues","util.optionalKeys","util.cached","util.isObject","util.esc","allowsEval","util.allowsEval","util.finalizeIssue","core.config","util.cleanRegex","util.isPlainObject","util.getEnumValues","util.escapeRegex","core.$ZodEncodeError","util.issue","util.normalizeParams","checks.$ZodCheckLessThan","checks.$ZodCheckGreaterThan","checks.$ZodCheckMultipleOf","checks.$ZodCheckMaxLength","checks.$ZodCheckMinLength","checks.$ZodCheckLengthEquals","checks.$ZodCheckRegex","checks.$ZodCheckLowerCase","checks.$ZodCheckUpperCase","checks.$ZodCheckIncludes","checks.$ZodCheckStartsWith","checks.$ZodCheckEndsWith","checks.$ZodCheckOverwrite","util.slugify","issue","util.issue","checks.$ZodCheck","describe","meta","core._isoDateTime","core._isoDate","core._isoTime","core._isoDuration","core.formatError","core.flattenError","util.jsonStringifyReplacer","core.$constructor","util.mergeDefs","core.clone","parse.parse","parse.safeParse","parse.parseAsync","parse.safeParseAsync","parse.encode","parse.decode","parse.encodeAsync","parse.decodeAsync","parse.safeEncode","parse.safeDecode","parse.safeEncodeAsync","parse.safeDecodeAsync","checks.overwrite","processors.stringProcessor","checks.regex","checks.includes","checks.startsWith","checks.endsWith","checks.minLength","checks.maxLength","checks.length","checks.lowercase","checks.uppercase","checks.trim","checks.normalize","checks.toLowerCase","checks.toUpperCase","checks.slugify","core._email","core._url","core._jwt","core._emoji","core._guid","core._uuid","core._uuidv4","core._uuidv6","core._uuidv7","core._nanoid","core._cuid","core._cuid2","core._ulid","core._base64","core._base64url","core._xid","core._ksuid","core._ipv4","core._ipv6","core._cidrv4","core._cidrv6","core._e164","iso.datetime","iso.date","iso.time","iso.duration","core._string","processors.numberProcessor","checks.gt","checks.gte","checks.lt","checks.lte","checks.multipleOf","number","core._number","core._int","processors.booleanProcessor","boolean","core._boolean","processors.unknownProcessor","core._unknown","processors.neverProcessor","core._never","processors.arrayProcessor","core._array","processors.objectProcessor","util.extend","util.safeExtend","util.merge","util.pick","util.omit","util.partial","util.required","util.normalizeParams","processors.unionProcessor","processors.intersectionProcessor","processors.recordProcessor","processors.enumProcessor","processors.literalProcessor","processors.transformProcessor","core.$ZodEncodeError","issue","util.issue","processors.optionalProcessor","processors.nullableProcessor","processors.defaultProcessor","util.shallowClone","processors.prefaultProcessor","processors.nonoptionalProcessor","processors.catchProcessor","processors.pipeProcessor","processors.readonlyProcessor","processors.customProcessor","core._refine","core._superRefine","core.describe","core.meta","core._coercedNumber","schemas.ZodNumber","core._coercedBoolean","schemas.ZodBoolean","z.string","z.object","z.coerce.number","z.iso.datetime","z.number","z.array","z.boolean","z.object","z.string","z.unknown","z.enum","z.array","z.boolean","z.number","z.object","z.iso.datetime","z.number","z.boolean","z.string","z.enum","z.coerce.number","z.coerce.boolean","z.array","z.literal","z.object","z.literal","z.string","z.enum","z.object","z.string","z.literal","z.number","z.unknown","z.boolean","z.discriminatedUnion","z.coerce.number","getHeader","targetSelector","z.object","z.enum","z.number","z.string","z.record","z.unknown","webhookConfig","z.url","jobReceipt","z.coerce.number","z.iso.datetime","z.array","z.literal","z.union","z.discriminatedUnion","sharingStatus","z.boolean","toggleSharingBody","sharingQuery","z.discriminatedUnion","z.object","z.literal","z.string","z.record","z.unknown","z.url","z.enum","z.number","z.array","z.boolean","jobReceipt","getHeader"],"sources":["../src/errors.ts","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/util.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/errors.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/parse.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/regexes.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/checks.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/doc.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/versions.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/schemas.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/registries.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/api.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/iso.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/errors.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/parse.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/schemas.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/coerce.js","../../contracts/dist/v1/entities.mjs","../src/resources/validate.ts","../src/resources/entities.ts","../../contracts/dist/v1/feedback.mjs","../src/resources/feedback.ts","../../contracts/dist/v1/files.mjs","../src/resources/files.ts","../../contracts/dist/v1/health.mjs","../src/resources/health.ts","../../contracts/dist/v1/jobs.mjs","../src/utils/index.ts","../src/resources/jobs.ts","../../contracts/dist/v1/reports.mjs","../../contracts/dist/v1/matching-analysis.mjs","../src/resources/matching-analysis.ts","../src/resources/reports.ts","../src/resources/transport.ts","../src/resources/webhooks.ts","../src/Mappa.ts","../src/types.ts","../src/index.ts"],"sourcesContent":["const customInspect = Symbol.for(\"nodejs.util.inspect.custom\");\n\nfunction formatDetails(details: unknown, indent = \" \"): string {\n\tif (details === undefined || details === null) return \"\";\n\ttry {\n\t\tconst json = JSON.stringify(details, null, 2);\n\t\treturn json.split(\"\\n\").join(`\\n${indent}`);\n\t} catch {\n\t\treturn String(details);\n\t}\n}\n\nexport class MappaError extends Error {\n\toverride name = \"MappaError\";\n\trequestId?: string;\n\tcode?: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts?: { requestId?: string; code?: string; cause?: unknown },\n\t) {\n\t\tsuper(message);\n\t\tthis.requestId = opts?.requestId;\n\t\tthis.code = opts?.code;\n\t\tthis.cause = opts?.cause;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`];\n\t\tif (this.code) lines.push(` Code: ${this.code}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\t[customInspect](): string {\n\t\treturn this.toString();\n\t}\n}\n\nexport class ApiError extends MappaError {\n\toverride name = \"ApiError\";\n\tstatus: number;\n\tdetails?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts: {\n\t\t\tstatus: number;\n\t\t\trequestId?: string;\n\t\t\tcode?: string;\n\t\t\tdetails?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message, { requestId: opts.requestId, code: opts.code });\n\t\tthis.status = opts.status;\n\t\tthis.details = opts.details;\n\t}\n\n\toverride toString(): string {\n\t\tconst lines = [`${this.name}: ${this.message}`, ` Status: ${this.status}`];\n\t\tif (this.code) lines.push(` Code: ${this.code}`);\n\t\tif (this.requestId) lines.push(` Request ID: ${this.requestId}`);\n\t\tif (this.details !== undefined && this.details !== null) {\n\t\t\tlines.push(` Details: ${formatDetails(this.details)}`);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\nexport class RateLimitError extends ApiError {\n\toverride name = \"RateLimitError\";\n\tretryAfterMs?: number;\n}\n\nexport class AuthError extends ApiError {\n\toverride name = \"AuthError\";\n}\n\nexport class ValidationError extends ApiError {\n\toverride name = \"ValidationError\";\n}\n\nexport class InsufficientCreditsError extends ApiError {\n\toverride name = \"InsufficientCreditsError\";\n\trequired: number;\n\tavailable: number;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts: {\n\t\t\tstatus: number;\n\t\t\trequestId?: string;\n\t\t\tcode?: string;\n\t\t\tdetails?: { required?: number; available?: number };\n\t\t},\n\t) {\n\t\tsuper(message, opts);\n\t\tthis.required = opts.details?.required ?? 0;\n\t\tthis.available = opts.details?.available ?? 0;\n\t}\n}\n\nexport class JobFailedError extends MappaError {\n\toverride name = \"JobFailedError\";\n\tjobId: string;\n\n\tconstructor(\n\t\tjobId: string,\n\t\tmessage: string,\n\t\topts?: { requestId?: string; code?: string; cause?: unknown },\n\t) {\n\t\tsuper(message, opts);\n\t\tthis.jobId = jobId;\n\t}\n}\n\nexport class JobCanceledError extends MappaError {\n\toverride name = \"JobCanceledError\";\n\tjobId: string;\n\n\tconstructor(\n\t\tjobId: string,\n\t\tmessage: string,\n\t\topts?: { requestId?: string; cause?: unknown },\n\t) {\n\t\tsuper(message, opts);\n\t\tthis.jobId = jobId;\n\t}\n}\n\nexport class StreamError extends MappaError {\n\toverride name = \"StreamError\";\n\tjobId?: string;\n\tlastEventId?: string;\n\turl?: string;\n\tretryCount: number;\n\n\tconstructor(\n\t\tmessage: string,\n\t\topts: {\n\t\t\tjobId?: string;\n\t\t\tlastEventId?: string;\n\t\t\turl?: string;\n\t\t\tretryCount: number;\n\t\t\trequestId?: string;\n\t\t\tcause?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message, { requestId: opts.requestId, cause: opts.cause });\n\t\tthis.jobId = opts.jobId;\n\t\tthis.lastEventId = opts.lastEventId;\n\t\tthis.url = opts.url;\n\t\tthis.retryCount = opts.retryCount;\n\t}\n}\n","/** A special constant with type `never` */\nexport const NEVER = Object.freeze({\n status: \"aborted\",\n});\nexport /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {\n function init(inst, def) {\n if (!inst._zod) {\n Object.defineProperty(inst, \"_zod\", {\n value: {\n def,\n constr: _,\n traits: new Set(),\n },\n enumerable: false,\n });\n }\n if (inst._zod.traits.has(name)) {\n return;\n }\n inst._zod.traits.add(name);\n initializer(inst, def);\n // support prototype modifications\n const proto = _.prototype;\n const keys = Object.keys(proto);\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i];\n if (!(k in inst)) {\n inst[k] = proto[k].bind(inst);\n }\n }\n }\n // doesn't work if Parent has a constructor with arguments\n const Parent = params?.Parent ?? Object;\n class Definition extends Parent {\n }\n Object.defineProperty(Definition, \"name\", { value: name });\n function _(def) {\n var _a;\n const inst = params?.Parent ? new Definition() : this;\n init(inst, def);\n (_a = inst._zod).deferred ?? (_a.deferred = []);\n for (const fn of inst._zod.deferred) {\n fn();\n }\n return inst;\n }\n Object.defineProperty(_, \"init\", { value: init });\n Object.defineProperty(_, Symbol.hasInstance, {\n value: (inst) => {\n if (params?.Parent && inst instanceof params.Parent)\n return true;\n return inst?._zod?.traits?.has(name);\n },\n });\n Object.defineProperty(_, \"name\", { value: name });\n return _;\n}\n////////////////////////////// UTILITIES ///////////////////////////////////////\nexport const $brand = Symbol(\"zod_brand\");\nexport class $ZodAsyncError extends Error {\n constructor() {\n super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);\n }\n}\nexport class $ZodEncodeError extends Error {\n constructor(name) {\n super(`Encountered unidirectional transform during encode: ${name}`);\n this.name = \"ZodEncodeError\";\n }\n}\nexport const globalConfig = {};\nexport function config(newConfig) {\n if (newConfig)\n Object.assign(globalConfig, newConfig);\n return globalConfig;\n}\n","// functions\nexport function assertEqual(val) {\n return val;\n}\nexport function assertNotEqual(val) {\n return val;\n}\nexport function assertIs(_arg) { }\nexport function assertNever(_x) {\n throw new Error(\"Unexpected value in exhaustive check\");\n}\nexport function assert(_) { }\nexport function getEnumValues(entries) {\n const numericValues = Object.values(entries).filter((v) => typeof v === \"number\");\n const values = Object.entries(entries)\n .filter(([k, _]) => numericValues.indexOf(+k) === -1)\n .map(([_, v]) => v);\n return values;\n}\nexport function joinValues(array, separator = \"|\") {\n return array.map((val) => stringifyPrimitive(val)).join(separator);\n}\nexport function jsonStringifyReplacer(_, value) {\n if (typeof value === \"bigint\")\n return value.toString();\n return value;\n}\nexport function cached(getter) {\n const set = false;\n return {\n get value() {\n if (!set) {\n const value = getter();\n Object.defineProperty(this, \"value\", { value });\n return value;\n }\n throw new Error(\"cached value already set\");\n },\n };\n}\nexport function nullish(input) {\n return input === null || input === undefined;\n}\nexport function cleanRegex(source) {\n const start = source.startsWith(\"^\") ? 1 : 0;\n const end = source.endsWith(\"$\") ? source.length - 1 : source.length;\n return source.slice(start, end);\n}\nexport function floatSafeRemainder(val, step) {\n const valDecCount = (val.toString().split(\".\")[1] || \"\").length;\n const stepString = step.toString();\n let stepDecCount = (stepString.split(\".\")[1] || \"\").length;\n if (stepDecCount === 0 && /\\d?e-\\d?/.test(stepString)) {\n const match = stepString.match(/\\d?e-(\\d?)/);\n if (match?.[1]) {\n stepDecCount = Number.parseInt(match[1]);\n }\n }\n const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;\n const valInt = Number.parseInt(val.toFixed(decCount).replace(\".\", \"\"));\n const stepInt = Number.parseInt(step.toFixed(decCount).replace(\".\", \"\"));\n return (valInt % stepInt) / 10 ** decCount;\n}\nconst EVALUATING = Symbol(\"evaluating\");\nexport function defineLazy(object, key, getter) {\n let value = undefined;\n Object.defineProperty(object, key, {\n get() {\n if (value === EVALUATING) {\n // Circular reference detected, return undefined to break the cycle\n return undefined;\n }\n if (value === undefined) {\n value = EVALUATING;\n value = getter();\n }\n return value;\n },\n set(v) {\n Object.defineProperty(object, key, {\n value: v,\n // configurable: true,\n });\n // object[key] = v;\n },\n configurable: true,\n });\n}\nexport function objectClone(obj) {\n return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));\n}\nexport function assignProp(target, prop, value) {\n Object.defineProperty(target, prop, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n}\nexport function mergeDefs(...defs) {\n const mergedDescriptors = {};\n for (const def of defs) {\n const descriptors = Object.getOwnPropertyDescriptors(def);\n Object.assign(mergedDescriptors, descriptors);\n }\n return Object.defineProperties({}, mergedDescriptors);\n}\nexport function cloneDef(schema) {\n return mergeDefs(schema._zod.def);\n}\nexport function getElementAtPath(obj, path) {\n if (!path)\n return obj;\n return path.reduce((acc, key) => acc?.[key], obj);\n}\nexport function promiseAllObject(promisesObj) {\n const keys = Object.keys(promisesObj);\n const promises = keys.map((key) => promisesObj[key]);\n return Promise.all(promises).then((results) => {\n const resolvedObj = {};\n for (let i = 0; i < keys.length; i++) {\n resolvedObj[keys[i]] = results[i];\n }\n return resolvedObj;\n });\n}\nexport function randomString(length = 10) {\n const chars = \"abcdefghijklmnopqrstuvwxyz\";\n let str = \"\";\n for (let i = 0; i < length; i++) {\n str += chars[Math.floor(Math.random() * chars.length)];\n }\n return str;\n}\nexport function esc(str) {\n return JSON.stringify(str);\n}\nexport function slugify(input) {\n return input\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\nexport const captureStackTrace = (\"captureStackTrace\" in Error ? Error.captureStackTrace : (..._args) => { });\nexport function isObject(data) {\n return typeof data === \"object\" && data !== null && !Array.isArray(data);\n}\nexport const allowsEval = cached(() => {\n // @ts-ignore\n if (typeof navigator !== \"undefined\" && navigator?.userAgent?.includes(\"Cloudflare\")) {\n return false;\n }\n try {\n const F = Function;\n new F(\"\");\n return true;\n }\n catch (_) {\n return false;\n }\n});\nexport function isPlainObject(o) {\n if (isObject(o) === false)\n return false;\n // modified constructor\n const ctor = o.constructor;\n if (ctor === undefined)\n return true;\n if (typeof ctor !== \"function\")\n return true;\n // modified prototype\n const prot = ctor.prototype;\n if (isObject(prot) === false)\n return false;\n // ctor doesn't have static `isPrototypeOf`\n if (Object.prototype.hasOwnProperty.call(prot, \"isPrototypeOf\") === false) {\n return false;\n }\n return true;\n}\nexport function shallowClone(o) {\n if (isPlainObject(o))\n return { ...o };\n if (Array.isArray(o))\n return [...o];\n return o;\n}\nexport function numKeys(data) {\n let keyCount = 0;\n for (const key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n keyCount++;\n }\n }\n return keyCount;\n}\nexport const getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case \"undefined\":\n return \"undefined\";\n case \"string\":\n return \"string\";\n case \"number\":\n return Number.isNaN(data) ? \"nan\" : \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"function\":\n return \"function\";\n case \"bigint\":\n return \"bigint\";\n case \"symbol\":\n return \"symbol\";\n case \"object\":\n if (Array.isArray(data)) {\n return \"array\";\n }\n if (data === null) {\n return \"null\";\n }\n if (data.then && typeof data.then === \"function\" && data.catch && typeof data.catch === \"function\") {\n return \"promise\";\n }\n if (typeof Map !== \"undefined\" && data instanceof Map) {\n return \"map\";\n }\n if (typeof Set !== \"undefined\" && data instanceof Set) {\n return \"set\";\n }\n if (typeof Date !== \"undefined\" && data instanceof Date) {\n return \"date\";\n }\n // @ts-ignore\n if (typeof File !== \"undefined\" && data instanceof File) {\n return \"file\";\n }\n return \"object\";\n default:\n throw new Error(`Unknown data type: ${t}`);\n }\n};\nexport const propertyKeyTypes = new Set([\"string\", \"number\", \"symbol\"]);\nexport const primitiveTypes = new Set([\"string\", \"number\", \"bigint\", \"boolean\", \"symbol\", \"undefined\"]);\nexport function escapeRegex(str) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n// zod-specific utils\nexport function clone(inst, def, params) {\n const cl = new inst._zod.constr(def ?? inst._zod.def);\n if (!def || params?.parent)\n cl._zod.parent = inst;\n return cl;\n}\nexport function normalizeParams(_params) {\n const params = _params;\n if (!params)\n return {};\n if (typeof params === \"string\")\n return { error: () => params };\n if (params?.message !== undefined) {\n if (params?.error !== undefined)\n throw new Error(\"Cannot specify both `message` and `error` params\");\n params.error = params.message;\n }\n delete params.message;\n if (typeof params.error === \"string\")\n return { ...params, error: () => params.error };\n return params;\n}\nexport function createTransparentProxy(getter) {\n let target;\n return new Proxy({}, {\n get(_, prop, receiver) {\n target ?? (target = getter());\n return Reflect.get(target, prop, receiver);\n },\n set(_, prop, value, receiver) {\n target ?? (target = getter());\n return Reflect.set(target, prop, value, receiver);\n },\n has(_, prop) {\n target ?? (target = getter());\n return Reflect.has(target, prop);\n },\n deleteProperty(_, prop) {\n target ?? (target = getter());\n return Reflect.deleteProperty(target, prop);\n },\n ownKeys(_) {\n target ?? (target = getter());\n return Reflect.ownKeys(target);\n },\n getOwnPropertyDescriptor(_, prop) {\n target ?? (target = getter());\n return Reflect.getOwnPropertyDescriptor(target, prop);\n },\n defineProperty(_, prop, descriptor) {\n target ?? (target = getter());\n return Reflect.defineProperty(target, prop, descriptor);\n },\n });\n}\nexport function stringifyPrimitive(value) {\n if (typeof value === \"bigint\")\n return value.toString() + \"n\";\n if (typeof value === \"string\")\n return `\"${value}\"`;\n return `${value}`;\n}\nexport function optionalKeys(shape) {\n return Object.keys(shape).filter((k) => {\n return shape[k]._zod.optin === \"optional\" && shape[k]._zod.optout === \"optional\";\n });\n}\nexport const NUMBER_FORMAT_RANGES = {\n safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],\n int32: [-2147483648, 2147483647],\n uint32: [0, 4294967295],\n float32: [-3.4028234663852886e38, 3.4028234663852886e38],\n float64: [-Number.MAX_VALUE, Number.MAX_VALUE],\n};\nexport const BIGINT_FORMAT_RANGES = {\n int64: [/* @__PURE__*/ BigInt(\"-9223372036854775808\"), /* @__PURE__*/ BigInt(\"9223372036854775807\")],\n uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt(\"18446744073709551615\")],\n};\nexport function pick(schema, mask) {\n const currDef = schema._zod.def;\n const checks = currDef.checks;\n const hasChecks = checks && checks.length > 0;\n if (hasChecks) {\n throw new Error(\".pick() cannot be used on object schemas containing refinements\");\n }\n const def = mergeDefs(schema._zod.def, {\n get shape() {\n const newShape = {};\n for (const key in mask) {\n if (!(key in currDef.shape)) {\n throw new Error(`Unrecognized key: \"${key}\"`);\n }\n if (!mask[key])\n continue;\n newShape[key] = currDef.shape[key];\n }\n assignProp(this, \"shape\", newShape); // self-caching\n return newShape;\n },\n checks: [],\n });\n return clone(schema, def);\n}\nexport function omit(schema, mask) {\n const currDef = schema._zod.def;\n const checks = currDef.checks;\n const hasChecks = checks && checks.length > 0;\n if (hasChecks) {\n throw new Error(\".omit() cannot be used on object schemas containing refinements\");\n }\n const def = mergeDefs(schema._zod.def, {\n get shape() {\n const newShape = { ...schema._zod.def.shape };\n for (const key in mask) {\n if (!(key in currDef.shape)) {\n throw new Error(`Unrecognized key: \"${key}\"`);\n }\n if (!mask[key])\n continue;\n delete newShape[key];\n }\n assignProp(this, \"shape\", newShape); // self-caching\n return newShape;\n },\n checks: [],\n });\n return clone(schema, def);\n}\nexport function extend(schema, shape) {\n if (!isPlainObject(shape)) {\n throw new Error(\"Invalid input to extend: expected a plain object\");\n }\n const checks = schema._zod.def.checks;\n const hasChecks = checks && checks.length > 0;\n if (hasChecks) {\n // Only throw if new shape overlaps with existing shape\n // Use getOwnPropertyDescriptor to check key existence without accessing values\n const existingShape = schema._zod.def.shape;\n for (const key in shape) {\n if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {\n throw new Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\");\n }\n }\n }\n const def = mergeDefs(schema._zod.def, {\n get shape() {\n const _shape = { ...schema._zod.def.shape, ...shape };\n assignProp(this, \"shape\", _shape); // self-caching\n return _shape;\n },\n });\n return clone(schema, def);\n}\nexport function safeExtend(schema, shape) {\n if (!isPlainObject(shape)) {\n throw new Error(\"Invalid input to safeExtend: expected a plain object\");\n }\n const def = mergeDefs(schema._zod.def, {\n get shape() {\n const _shape = { ...schema._zod.def.shape, ...shape };\n assignProp(this, \"shape\", _shape); // self-caching\n return _shape;\n },\n });\n return clone(schema, def);\n}\nexport function merge(a, b) {\n const def = mergeDefs(a._zod.def, {\n get shape() {\n const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };\n assignProp(this, \"shape\", _shape); // self-caching\n return _shape;\n },\n get catchall() {\n return b._zod.def.catchall;\n },\n checks: [], // delete existing checks\n });\n return clone(a, def);\n}\nexport function partial(Class, schema, mask) {\n const currDef = schema._zod.def;\n const checks = currDef.checks;\n const hasChecks = checks && checks.length > 0;\n if (hasChecks) {\n throw new Error(\".partial() cannot be used on object schemas containing refinements\");\n }\n const def = mergeDefs(schema._zod.def, {\n get shape() {\n const oldShape = schema._zod.def.shape;\n const shape = { ...oldShape };\n if (mask) {\n for (const key in mask) {\n if (!(key in oldShape)) {\n throw new Error(`Unrecognized key: \"${key}\"`);\n }\n if (!mask[key])\n continue;\n // if (oldShape[key]!._zod.optin === \"optional\") continue;\n shape[key] = Class\n ? new Class({\n type: \"optional\",\n innerType: oldShape[key],\n })\n : oldShape[key];\n }\n }\n else {\n for (const key in oldShape) {\n // if (oldShape[key]!._zod.optin === \"optional\") continue;\n shape[key] = Class\n ? new Class({\n type: \"optional\",\n innerType: oldShape[key],\n })\n : oldShape[key];\n }\n }\n assignProp(this, \"shape\", shape); // self-caching\n return shape;\n },\n checks: [],\n });\n return clone(schema, def);\n}\nexport function required(Class, schema, mask) {\n const def = mergeDefs(schema._zod.def, {\n get shape() {\n const oldShape = schema._zod.def.shape;\n const shape = { ...oldShape };\n if (mask) {\n for (const key in mask) {\n if (!(key in shape)) {\n throw new Error(`Unrecognized key: \"${key}\"`);\n }\n if (!mask[key])\n continue;\n // overwrite with non-optional\n shape[key] = new Class({\n type: \"nonoptional\",\n innerType: oldShape[key],\n });\n }\n }\n else {\n for (const key in oldShape) {\n // overwrite with non-optional\n shape[key] = new Class({\n type: \"nonoptional\",\n innerType: oldShape[key],\n });\n }\n }\n assignProp(this, \"shape\", shape); // self-caching\n return shape;\n },\n });\n return clone(schema, def);\n}\n// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom\nexport function aborted(x, startIndex = 0) {\n if (x.aborted === true)\n return true;\n for (let i = startIndex; i < x.issues.length; i++) {\n if (x.issues[i]?.continue !== true) {\n return true;\n }\n }\n return false;\n}\nexport function prefixIssues(path, issues) {\n return issues.map((iss) => {\n var _a;\n (_a = iss).path ?? (_a.path = []);\n iss.path.unshift(path);\n return iss;\n });\n}\nexport function unwrapMessage(message) {\n return typeof message === \"string\" ? message : message?.message;\n}\nexport function finalizeIssue(iss, ctx, config) {\n const full = { ...iss, path: iss.path ?? [] };\n // for backwards compatibility\n if (!iss.message) {\n const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??\n unwrapMessage(ctx?.error?.(iss)) ??\n unwrapMessage(config.customError?.(iss)) ??\n unwrapMessage(config.localeError?.(iss)) ??\n \"Invalid input\";\n full.message = message;\n }\n // delete (full as any).def;\n delete full.inst;\n delete full.continue;\n if (!ctx?.reportInput) {\n delete full.input;\n }\n return full;\n}\nexport function getSizableOrigin(input) {\n if (input instanceof Set)\n return \"set\";\n if (input instanceof Map)\n return \"map\";\n // @ts-ignore\n if (input instanceof File)\n return \"file\";\n return \"unknown\";\n}\nexport function getLengthableOrigin(input) {\n if (Array.isArray(input))\n return \"array\";\n if (typeof input === \"string\")\n return \"string\";\n return \"unknown\";\n}\nexport function parsedType(data) {\n const t = typeof data;\n switch (t) {\n case \"number\": {\n return Number.isNaN(data) ? \"nan\" : \"number\";\n }\n case \"object\": {\n if (data === null) {\n return \"null\";\n }\n if (Array.isArray(data)) {\n return \"array\";\n }\n const obj = data;\n if (obj && Object.getPrototypeOf(obj) !== Object.prototype && \"constructor\" in obj && obj.constructor) {\n return obj.constructor.name;\n }\n }\n }\n return t;\n}\nexport function issue(...args) {\n const [iss, input, inst] = args;\n if (typeof iss === \"string\") {\n return {\n message: iss,\n code: \"custom\",\n input,\n inst,\n };\n }\n return { ...iss };\n}\nexport function cleanEnum(obj) {\n return Object.entries(obj)\n .filter(([k, _]) => {\n // return true if NaN, meaning it's not a number, thus a string key\n return Number.isNaN(Number.parseInt(k, 10));\n })\n .map((el) => el[1]);\n}\n// Codec utility functions\nexport function base64ToUint8Array(base64) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes;\n}\nexport function uint8ArrayToBase64(bytes) {\n let binaryString = \"\";\n for (let i = 0; i < bytes.length; i++) {\n binaryString += String.fromCharCode(bytes[i]);\n }\n return btoa(binaryString);\n}\nexport function base64urlToUint8Array(base64url) {\n const base64 = base64url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padding = \"=\".repeat((4 - (base64.length % 4)) % 4);\n return base64ToUint8Array(base64 + padding);\n}\nexport function uint8ArrayToBase64url(bytes) {\n return uint8ArrayToBase64(bytes).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=/g, \"\");\n}\nexport function hexToUint8Array(hex) {\n const cleanHex = hex.replace(/^0x/, \"\");\n if (cleanHex.length % 2 !== 0) {\n throw new Error(\"Invalid hex string length\");\n }\n const bytes = new Uint8Array(cleanHex.length / 2);\n for (let i = 0; i < cleanHex.length; i += 2) {\n bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);\n }\n return bytes;\n}\nexport function uint8ArrayToHex(bytes) {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n// instanceof\nexport class Class {\n constructor(..._args) { }\n}\n","import { $constructor } from \"./core.js\";\nimport * as util from \"./util.js\";\nconst initializer = (inst, def) => {\n inst.name = \"$ZodError\";\n Object.defineProperty(inst, \"_zod\", {\n value: inst._zod,\n enumerable: false,\n });\n Object.defineProperty(inst, \"issues\", {\n value: def,\n enumerable: false,\n });\n inst.message = JSON.stringify(def, util.jsonStringifyReplacer, 2);\n Object.defineProperty(inst, \"toString\", {\n value: () => inst.message,\n enumerable: false,\n });\n};\nexport const $ZodError = $constructor(\"$ZodError\", initializer);\nexport const $ZodRealError = $constructor(\"$ZodError\", initializer, { Parent: Error });\nexport function flattenError(error, mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of error.issues) {\n if (sub.path.length > 0) {\n fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];\n fieldErrors[sub.path[0]].push(mapper(sub));\n }\n else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n}\nexport function formatError(error, mapper = (issue) => issue.message) {\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\" && issue.errors.length) {\n issue.errors.map((issues) => processError({ issues }));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues });\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues });\n }\n else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < issue.path.length) {\n const el = issue.path[i];\n const terminal = i === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n }\n else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i++;\n }\n }\n }\n };\n processError(error);\n return fieldErrors;\n}\nexport function treeifyError(error, mapper = (issue) => issue.message) {\n const result = { errors: [] };\n const processError = (error, path = []) => {\n var _a, _b;\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\" && issue.errors.length) {\n // regular union error\n issue.errors.map((issues) => processError({ issues }, issue.path));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues }, issue.path);\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues }, issue.path);\n }\n else {\n const fullpath = [...path, ...issue.path];\n if (fullpath.length === 0) {\n result.errors.push(mapper(issue));\n continue;\n }\n let curr = result;\n let i = 0;\n while (i < fullpath.length) {\n const el = fullpath[i];\n const terminal = i === fullpath.length - 1;\n if (typeof el === \"string\") {\n curr.properties ?? (curr.properties = {});\n (_a = curr.properties)[el] ?? (_a[el] = { errors: [] });\n curr = curr.properties[el];\n }\n else {\n curr.items ?? (curr.items = []);\n (_b = curr.items)[el] ?? (_b[el] = { errors: [] });\n curr = curr.items[el];\n }\n if (terminal) {\n curr.errors.push(mapper(issue));\n }\n i++;\n }\n }\n }\n };\n processError(error);\n return result;\n}\n/** Format a ZodError as a human-readable string in the following form.\n *\n * From\n *\n * ```ts\n * ZodError {\n * issues: [\n * {\n * expected: 'string',\n * code: 'invalid_type',\n * path: [ 'username' ],\n * message: 'Invalid input: expected string'\n * },\n * {\n * expected: 'number',\n * code: 'invalid_type',\n * path: [ 'favoriteNumbers', 1 ],\n * message: 'Invalid input: expected number'\n * }\n * ];\n * }\n * ```\n *\n * to\n *\n * ```\n * username\n * ✖ Expected number, received string at \"username\n * favoriteNumbers[0]\n * ✖ Invalid input: expected number\n * ```\n */\nexport function toDotPath(_path) {\n const segs = [];\n const path = _path.map((seg) => (typeof seg === \"object\" ? seg.key : seg));\n for (const seg of path) {\n if (typeof seg === \"number\")\n segs.push(`[${seg}]`);\n else if (typeof seg === \"symbol\")\n segs.push(`[${JSON.stringify(String(seg))}]`);\n else if (/[^\\w$]/.test(seg))\n segs.push(`[${JSON.stringify(seg)}]`);\n else {\n if (segs.length)\n segs.push(\".\");\n segs.push(seg);\n }\n }\n return segs.join(\"\");\n}\nexport function prettifyError(error) {\n const lines = [];\n // sort by path length\n const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);\n // Process each issue\n for (const issue of issues) {\n lines.push(`✖ ${issue.message}`);\n if (issue.path?.length)\n lines.push(` → at ${toDotPath(issue.path)}`);\n }\n // Convert Map to formatted string\n return lines.join(\"\\n\");\n}\n","import * as core from \"./core.js\";\nimport * as errors from \"./errors.js\";\nimport * as util from \"./util.js\";\nexport const _parse = (_Err) => (schema, value, _ctx, _params) => {\n const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };\n const result = schema._zod.run({ value, issues: [] }, ctx);\n if (result instanceof Promise) {\n throw new core.$ZodAsyncError();\n }\n if (result.issues.length) {\n const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));\n util.captureStackTrace(e, _params?.callee);\n throw e;\n }\n return result.value;\n};\nexport const parse = /* @__PURE__*/ _parse(errors.$ZodRealError);\nexport const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {\n const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };\n let result = schema._zod.run({ value, issues: [] }, ctx);\n if (result instanceof Promise)\n result = await result;\n if (result.issues.length) {\n const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));\n util.captureStackTrace(e, params?.callee);\n throw e;\n }\n return result.value;\n};\nexport const parseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError);\nexport const _safeParse = (_Err) => (schema, value, _ctx) => {\n const ctx = _ctx ? { ..._ctx, async: false } : { async: false };\n const result = schema._zod.run({ value, issues: [] }, ctx);\n if (result instanceof Promise) {\n throw new core.$ZodAsyncError();\n }\n return result.issues.length\n ? {\n success: false,\n error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),\n }\n : { success: true, data: result.value };\n};\nexport const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);\nexport const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {\n const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };\n let result = schema._zod.run({ value, issues: [] }, ctx);\n if (result instanceof Promise)\n result = await result;\n return result.issues.length\n ? {\n success: false,\n error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),\n }\n : { success: true, data: result.value };\n};\nexport const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);\nexport const _encode = (_Err) => (schema, value, _ctx) => {\n const ctx = _ctx ? Object.assign(_ctx, { direction: \"backward\" }) : { direction: \"backward\" };\n return _parse(_Err)(schema, value, ctx);\n};\nexport const encode = /* @__PURE__*/ _encode(errors.$ZodRealError);\nexport const _decode = (_Err) => (schema, value, _ctx) => {\n return _parse(_Err)(schema, value, _ctx);\n};\nexport const decode = /* @__PURE__*/ _decode(errors.$ZodRealError);\nexport const _encodeAsync = (_Err) => async (schema, value, _ctx) => {\n const ctx = _ctx ? Object.assign(_ctx, { direction: \"backward\" }) : { direction: \"backward\" };\n return _parseAsync(_Err)(schema, value, ctx);\n};\nexport const encodeAsync = /* @__PURE__*/ _encodeAsync(errors.$ZodRealError);\nexport const _decodeAsync = (_Err) => async (schema, value, _ctx) => {\n return _parseAsync(_Err)(schema, value, _ctx);\n};\nexport const decodeAsync = /* @__PURE__*/ _decodeAsync(errors.$ZodRealError);\nexport const _safeEncode = (_Err) => (schema, value, _ctx) => {\n const ctx = _ctx ? Object.assign(_ctx, { direction: \"backward\" }) : { direction: \"backward\" };\n return _safeParse(_Err)(schema, value, ctx);\n};\nexport const safeEncode = /* @__PURE__*/ _safeEncode(errors.$ZodRealError);\nexport const _safeDecode = (_Err) => (schema, value, _ctx) => {\n return _safeParse(_Err)(schema, value, _ctx);\n};\nexport const safeDecode = /* @__PURE__*/ _safeDecode(errors.$ZodRealError);\nexport const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {\n const ctx = _ctx ? Object.assign(_ctx, { direction: \"backward\" }) : { direction: \"backward\" };\n return _safeParseAsync(_Err)(schema, value, ctx);\n};\nexport const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync(errors.$ZodRealError);\nexport const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {\n return _safeParseAsync(_Err)(schema, value, _ctx);\n};\nexport const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync(errors.$ZodRealError);\n","import * as util from \"./util.js\";\nexport const cuid = /^[cC][^\\s-]{8,}$/;\nexport const cuid2 = /^[0-9a-z]+$/;\nexport const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;\nexport const xid = /^[0-9a-vA-V]{20}$/;\nexport const ksuid = /^[A-Za-z0-9]{27}$/;\nexport const nanoid = /^[a-zA-Z0-9_-]{21}$/;\n/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */\nexport const duration = /^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;\n/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */\nexport const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\\d+Y)|(?:[-+]?\\d+[.,]\\d+Y$))?(?:(?:[-+]?\\d+M)|(?:[-+]?\\d+[.,]\\d+M$))?(?:(?:[-+]?\\d+W)|(?:[-+]?\\d+[.,]\\d+W$))?(?:(?:[-+]?\\d+D)|(?:[-+]?\\d+[.,]\\d+D$))?(?:T(?=[\\d+-])(?:(?:[-+]?\\d+H)|(?:[-+]?\\d+[.,]\\d+H$))?(?:(?:[-+]?\\d+M)|(?:[-+]?\\d+[.,]\\d+M$))?(?:[-+]?\\d+(?:[.,]\\d+)?S)?)??$/;\n/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */\nexport const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;\n/** Returns a regex for validating an RFC 9562/4122 UUID.\n *\n * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */\nexport const uuid = (version) => {\n if (!version)\n return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;\n return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);\n};\nexport const uuid4 = /*@__PURE__*/ uuid(4);\nexport const uuid6 = /*@__PURE__*/ uuid(6);\nexport const uuid7 = /*@__PURE__*/ uuid(7);\n/** Practical email validation */\nexport const email = /^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;\n/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */\nexport const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n/** The classic emailregex.com regex for RFC 5322-compliant emails */\nexport const rfc5322Email = /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */\nexport const unicodeEmail = /^[^\\s@\"]{1,64}@[^\\s@]{1,255}$/u;\nexport const idnEmail = unicodeEmail;\nexport const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression\nconst _emoji = `^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$`;\nexport function emoji() {\n return new RegExp(_emoji, \"u\");\n}\nexport const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;\nexport const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;\nexport const mac = (delimiter) => {\n const escapedDelim = util.escapeRegex(delimiter ?? \":\");\n return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);\n};\nexport const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/;\nexport const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;\n// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript\nexport const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;\nexport const base64url = /^[A-Za-z0-9_-]*$/;\n// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address\n// export const hostname: RegExp = /^([a-zA-Z0-9-]+\\.)*[a-zA-Z0-9-]+$/;\nexport const hostname = /^(?=.{1,253}\\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\\.?$/;\nexport const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}$/;\n// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)\n// E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15\nexport const e164 = /^\\+[1-9]\\d{6,14}$/;\n// const dateSource = `((\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\\\d|30)|(02)-(0[1-9]|1\\\\d|2[0-8])))`;\nconst dateSource = `(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))`;\nexport const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);\nfunction timeSource(args) {\n const hhmm = `(?:[01]\\\\d|2[0-3]):[0-5]\\\\d`;\n const regex = typeof args.precision === \"number\"\n ? args.precision === -1\n ? `${hhmm}`\n : args.precision === 0\n ? `${hhmm}:[0-5]\\\\d`\n : `${hhmm}:[0-5]\\\\d\\\\.\\\\d{${args.precision}}`\n : `${hhmm}(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?`;\n return regex;\n}\nexport function time(args) {\n return new RegExp(`^${timeSource(args)}$`);\n}\n// Adapted from https://stackoverflow.com/a/3143231\nexport function datetime(args) {\n const time = timeSource({ precision: args.precision });\n const opts = [\"Z\"];\n if (args.local)\n opts.push(\"\");\n // if (args.offset) opts.push(`([+-]\\\\d{2}:\\\\d{2})`);\n if (args.offset)\n opts.push(`([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)`);\n const timeRegex = `${time}(?:${opts.join(\"|\")})`;\n return new RegExp(`^${dateSource}T(?:${timeRegex})$`);\n}\nexport const string = (params) => {\n const regex = params ? `[\\\\s\\\\S]{${params?.minimum ?? 0},${params?.maximum ?? \"\"}}` : `[\\\\s\\\\S]*`;\n return new RegExp(`^${regex}$`);\n};\nexport const bigint = /^-?\\d+n?$/;\nexport const integer = /^-?\\d+$/;\nexport const number = /^-?\\d+(?:\\.\\d+)?$/;\nexport const boolean = /^(?:true|false)$/i;\nconst _null = /^null$/i;\nexport { _null as null };\nconst _undefined = /^undefined$/i;\nexport { _undefined as undefined };\n// regex for string with no uppercase letters\nexport const lowercase = /^[^A-Z]*$/;\n// regex for string with no lowercase letters\nexport const uppercase = /^[^a-z]*$/;\n// regex for hexadecimal strings (any length)\nexport const hex = /^[0-9a-fA-F]*$/;\n// Hash regexes for different algorithms and encodings\n// Helper function to create base64 regex with exact length and padding\nfunction fixedBase64(bodyLength, padding) {\n return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);\n}\n// Helper function to create base64url regex with exact length (no padding)\nfunction fixedBase64url(length) {\n return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);\n}\n// MD5 (16 bytes): base64 = 24 chars total (22 + \"==\")\nexport const md5_hex = /^[0-9a-fA-F]{32}$/;\nexport const md5_base64 = /*@__PURE__*/ fixedBase64(22, \"==\");\nexport const md5_base64url = /*@__PURE__*/ fixedBase64url(22);\n// SHA1 (20 bytes): base64 = 28 chars total (27 + \"=\")\nexport const sha1_hex = /^[0-9a-fA-F]{40}$/;\nexport const sha1_base64 = /*@__PURE__*/ fixedBase64(27, \"=\");\nexport const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);\n// SHA256 (32 bytes): base64 = 44 chars total (43 + \"=\")\nexport const sha256_hex = /^[0-9a-fA-F]{64}$/;\nexport const sha256_base64 = /*@__PURE__*/ fixedBase64(43, \"=\");\nexport const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);\n// SHA384 (48 bytes): base64 = 64 chars total (no padding)\nexport const sha384_hex = /^[0-9a-fA-F]{96}$/;\nexport const sha384_base64 = /*@__PURE__*/ fixedBase64(64, \"\");\nexport const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);\n// SHA512 (64 bytes): base64 = 88 chars total (86 + \"==\")\nexport const sha512_hex = /^[0-9a-fA-F]{128}$/;\nexport const sha512_base64 = /*@__PURE__*/ fixedBase64(86, \"==\");\nexport const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);\n","// import { $ZodType } from \"./schemas.js\";\nimport * as core from \"./core.js\";\nimport * as regexes from \"./regexes.js\";\nimport * as util from \"./util.js\";\nexport const $ZodCheck = /*@__PURE__*/ core.$constructor(\"$ZodCheck\", (inst, def) => {\n var _a;\n inst._zod ?? (inst._zod = {});\n inst._zod.def = def;\n (_a = inst._zod).onattach ?? (_a.onattach = []);\n});\nconst numericOriginMap = {\n number: \"number\",\n bigint: \"bigint\",\n object: \"date\",\n};\nexport const $ZodCheckLessThan = /*@__PURE__*/ core.$constructor(\"$ZodCheckLessThan\", (inst, def) => {\n $ZodCheck.init(inst, def);\n const origin = numericOriginMap[typeof def.value];\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;\n if (def.value < curr) {\n if (def.inclusive)\n bag.maximum = def.value;\n else\n bag.exclusiveMaximum = def.value;\n }\n });\n inst._zod.check = (payload) => {\n if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {\n return;\n }\n payload.issues.push({\n origin,\n code: \"too_big\",\n maximum: typeof def.value === \"object\" ? def.value.getTime() : def.value,\n input: payload.value,\n inclusive: def.inclusive,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckGreaterThan = /*@__PURE__*/ core.$constructor(\"$ZodCheckGreaterThan\", (inst, def) => {\n $ZodCheck.init(inst, def);\n const origin = numericOriginMap[typeof def.value];\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;\n if (def.value > curr) {\n if (def.inclusive)\n bag.minimum = def.value;\n else\n bag.exclusiveMinimum = def.value;\n }\n });\n inst._zod.check = (payload) => {\n if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {\n return;\n }\n payload.issues.push({\n origin,\n code: \"too_small\",\n minimum: typeof def.value === \"object\" ? def.value.getTime() : def.value,\n input: payload.value,\n inclusive: def.inclusive,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckMultipleOf = \n/*@__PURE__*/ core.$constructor(\"$ZodCheckMultipleOf\", (inst, def) => {\n $ZodCheck.init(inst, def);\n inst._zod.onattach.push((inst) => {\n var _a;\n (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);\n });\n inst._zod.check = (payload) => {\n if (typeof payload.value !== typeof def.value)\n throw new Error(\"Cannot mix number and bigint in multiple_of check.\");\n const isMultiple = typeof payload.value === \"bigint\"\n ? payload.value % def.value === BigInt(0)\n : util.floatSafeRemainder(payload.value, def.value) === 0;\n if (isMultiple)\n return;\n payload.issues.push({\n origin: typeof payload.value,\n code: \"not_multiple_of\",\n divisor: def.value,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckNumberFormat = /*@__PURE__*/ core.$constructor(\"$ZodCheckNumberFormat\", (inst, def) => {\n $ZodCheck.init(inst, def); // no format checks\n def.format = def.format || \"float64\";\n const isInt = def.format?.includes(\"int\");\n const origin = isInt ? \"int\" : \"number\";\n const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.format = def.format;\n bag.minimum = minimum;\n bag.maximum = maximum;\n if (isInt)\n bag.pattern = regexes.integer;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n if (isInt) {\n if (!Number.isInteger(input)) {\n // invalid_format issue\n // payload.issues.push({\n // expected: def.format,\n // format: def.format,\n // code: \"invalid_format\",\n // input,\n // inst,\n // });\n // invalid_type issue\n payload.issues.push({\n expected: origin,\n format: def.format,\n code: \"invalid_type\",\n continue: false,\n input,\n inst,\n });\n return;\n // not_multiple_of issue\n // payload.issues.push({\n // code: \"not_multiple_of\",\n // origin: \"number\",\n // input,\n // inst,\n // divisor: 1,\n // });\n }\n if (!Number.isSafeInteger(input)) {\n if (input > 0) {\n // too_big\n payload.issues.push({\n input,\n code: \"too_big\",\n maximum: Number.MAX_SAFE_INTEGER,\n note: \"Integers must be within the safe integer range.\",\n inst,\n origin,\n inclusive: true,\n continue: !def.abort,\n });\n }\n else {\n // too_small\n payload.issues.push({\n input,\n code: \"too_small\",\n minimum: Number.MIN_SAFE_INTEGER,\n note: \"Integers must be within the safe integer range.\",\n inst,\n origin,\n inclusive: true,\n continue: !def.abort,\n });\n }\n return;\n }\n }\n if (input < minimum) {\n payload.issues.push({\n origin: \"number\",\n input,\n code: \"too_small\",\n minimum,\n inclusive: true,\n inst,\n continue: !def.abort,\n });\n }\n if (input > maximum) {\n payload.issues.push({\n origin: \"number\",\n input,\n code: \"too_big\",\n maximum,\n inclusive: true,\n inst,\n continue: !def.abort,\n });\n }\n };\n});\nexport const $ZodCheckBigIntFormat = /*@__PURE__*/ core.$constructor(\"$ZodCheckBigIntFormat\", (inst, def) => {\n $ZodCheck.init(inst, def); // no format checks\n const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.format = def.format;\n bag.minimum = minimum;\n bag.maximum = maximum;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n if (input < minimum) {\n payload.issues.push({\n origin: \"bigint\",\n input,\n code: \"too_small\",\n minimum: minimum,\n inclusive: true,\n inst,\n continue: !def.abort,\n });\n }\n if (input > maximum) {\n payload.issues.push({\n origin: \"bigint\",\n input,\n code: \"too_big\",\n maximum,\n inclusive: true,\n inst,\n continue: !def.abort,\n });\n }\n };\n});\nexport const $ZodCheckMaxSize = /*@__PURE__*/ core.$constructor(\"$ZodCheckMaxSize\", (inst, def) => {\n var _a;\n $ZodCheck.init(inst, def);\n (_a = inst._zod.def).when ?? (_a.when = (payload) => {\n const val = payload.value;\n return !util.nullish(val) && val.size !== undefined;\n });\n inst._zod.onattach.push((inst) => {\n const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);\n if (def.maximum < curr)\n inst._zod.bag.maximum = def.maximum;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n const size = input.size;\n if (size <= def.maximum)\n return;\n payload.issues.push({\n origin: util.getSizableOrigin(input),\n code: \"too_big\",\n maximum: def.maximum,\n inclusive: true,\n input,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckMinSize = /*@__PURE__*/ core.$constructor(\"$ZodCheckMinSize\", (inst, def) => {\n var _a;\n $ZodCheck.init(inst, def);\n (_a = inst._zod.def).when ?? (_a.when = (payload) => {\n const val = payload.value;\n return !util.nullish(val) && val.size !== undefined;\n });\n inst._zod.onattach.push((inst) => {\n const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);\n if (def.minimum > curr)\n inst._zod.bag.minimum = def.minimum;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n const size = input.size;\n if (size >= def.minimum)\n return;\n payload.issues.push({\n origin: util.getSizableOrigin(input),\n code: \"too_small\",\n minimum: def.minimum,\n inclusive: true,\n input,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckSizeEquals = /*@__PURE__*/ core.$constructor(\"$ZodCheckSizeEquals\", (inst, def) => {\n var _a;\n $ZodCheck.init(inst, def);\n (_a = inst._zod.def).when ?? (_a.when = (payload) => {\n const val = payload.value;\n return !util.nullish(val) && val.size !== undefined;\n });\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.minimum = def.size;\n bag.maximum = def.size;\n bag.size = def.size;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n const size = input.size;\n if (size === def.size)\n return;\n const tooBig = size > def.size;\n payload.issues.push({\n origin: util.getSizableOrigin(input),\n ...(tooBig ? { code: \"too_big\", maximum: def.size } : { code: \"too_small\", minimum: def.size }),\n inclusive: true,\n exact: true,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckMaxLength = /*@__PURE__*/ core.$constructor(\"$ZodCheckMaxLength\", (inst, def) => {\n var _a;\n $ZodCheck.init(inst, def);\n (_a = inst._zod.def).when ?? (_a.when = (payload) => {\n const val = payload.value;\n return !util.nullish(val) && val.length !== undefined;\n });\n inst._zod.onattach.push((inst) => {\n const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);\n if (def.maximum < curr)\n inst._zod.bag.maximum = def.maximum;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n const length = input.length;\n if (length <= def.maximum)\n return;\n const origin = util.getLengthableOrigin(input);\n payload.issues.push({\n origin,\n code: \"too_big\",\n maximum: def.maximum,\n inclusive: true,\n input,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckMinLength = /*@__PURE__*/ core.$constructor(\"$ZodCheckMinLength\", (inst, def) => {\n var _a;\n $ZodCheck.init(inst, def);\n (_a = inst._zod.def).when ?? (_a.when = (payload) => {\n const val = payload.value;\n return !util.nullish(val) && val.length !== undefined;\n });\n inst._zod.onattach.push((inst) => {\n const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);\n if (def.minimum > curr)\n inst._zod.bag.minimum = def.minimum;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n const length = input.length;\n if (length >= def.minimum)\n return;\n const origin = util.getLengthableOrigin(input);\n payload.issues.push({\n origin,\n code: \"too_small\",\n minimum: def.minimum,\n inclusive: true,\n input,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckLengthEquals = /*@__PURE__*/ core.$constructor(\"$ZodCheckLengthEquals\", (inst, def) => {\n var _a;\n $ZodCheck.init(inst, def);\n (_a = inst._zod.def).when ?? (_a.when = (payload) => {\n const val = payload.value;\n return !util.nullish(val) && val.length !== undefined;\n });\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.minimum = def.length;\n bag.maximum = def.length;\n bag.length = def.length;\n });\n inst._zod.check = (payload) => {\n const input = payload.value;\n const length = input.length;\n if (length === def.length)\n return;\n const origin = util.getLengthableOrigin(input);\n const tooBig = length > def.length;\n payload.issues.push({\n origin,\n ...(tooBig ? { code: \"too_big\", maximum: def.length } : { code: \"too_small\", minimum: def.length }),\n inclusive: true,\n exact: true,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckStringFormat = /*@__PURE__*/ core.$constructor(\"$ZodCheckStringFormat\", (inst, def) => {\n var _a, _b;\n $ZodCheck.init(inst, def);\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.format = def.format;\n if (def.pattern) {\n bag.patterns ?? (bag.patterns = new Set());\n bag.patterns.add(def.pattern);\n }\n });\n if (def.pattern)\n (_a = inst._zod).check ?? (_a.check = (payload) => {\n def.pattern.lastIndex = 0;\n if (def.pattern.test(payload.value))\n return;\n payload.issues.push({\n origin: \"string\",\n code: \"invalid_format\",\n format: def.format,\n input: payload.value,\n ...(def.pattern ? { pattern: def.pattern.toString() } : {}),\n inst,\n continue: !def.abort,\n });\n });\n else\n (_b = inst._zod).check ?? (_b.check = () => { });\n});\nexport const $ZodCheckRegex = /*@__PURE__*/ core.$constructor(\"$ZodCheckRegex\", (inst, def) => {\n $ZodCheckStringFormat.init(inst, def);\n inst._zod.check = (payload) => {\n def.pattern.lastIndex = 0;\n if (def.pattern.test(payload.value))\n return;\n payload.issues.push({\n origin: \"string\",\n code: \"invalid_format\",\n format: \"regex\",\n input: payload.value,\n pattern: def.pattern.toString(),\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckLowerCase = /*@__PURE__*/ core.$constructor(\"$ZodCheckLowerCase\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.lowercase);\n $ZodCheckStringFormat.init(inst, def);\n});\nexport const $ZodCheckUpperCase = /*@__PURE__*/ core.$constructor(\"$ZodCheckUpperCase\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.uppercase);\n $ZodCheckStringFormat.init(inst, def);\n});\nexport const $ZodCheckIncludes = /*@__PURE__*/ core.$constructor(\"$ZodCheckIncludes\", (inst, def) => {\n $ZodCheck.init(inst, def);\n const escapedRegex = util.escapeRegex(def.includes);\n const pattern = new RegExp(typeof def.position === \"number\" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);\n def.pattern = pattern;\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.patterns ?? (bag.patterns = new Set());\n bag.patterns.add(pattern);\n });\n inst._zod.check = (payload) => {\n if (payload.value.includes(def.includes, def.position))\n return;\n payload.issues.push({\n origin: \"string\",\n code: \"invalid_format\",\n format: \"includes\",\n includes: def.includes,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckStartsWith = /*@__PURE__*/ core.$constructor(\"$ZodCheckStartsWith\", (inst, def) => {\n $ZodCheck.init(inst, def);\n const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);\n def.pattern ?? (def.pattern = pattern);\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.patterns ?? (bag.patterns = new Set());\n bag.patterns.add(pattern);\n });\n inst._zod.check = (payload) => {\n if (payload.value.startsWith(def.prefix))\n return;\n payload.issues.push({\n origin: \"string\",\n code: \"invalid_format\",\n format: \"starts_with\",\n prefix: def.prefix,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckEndsWith = /*@__PURE__*/ core.$constructor(\"$ZodCheckEndsWith\", (inst, def) => {\n $ZodCheck.init(inst, def);\n const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);\n def.pattern ?? (def.pattern = pattern);\n inst._zod.onattach.push((inst) => {\n const bag = inst._zod.bag;\n bag.patterns ?? (bag.patterns = new Set());\n bag.patterns.add(pattern);\n });\n inst._zod.check = (payload) => {\n if (payload.value.endsWith(def.suffix))\n return;\n payload.issues.push({\n origin: \"string\",\n code: \"invalid_format\",\n format: \"ends_with\",\n suffix: def.suffix,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\n///////////////////////////////////\n///// $ZodCheckProperty /////\n///////////////////////////////////\nfunction handleCheckPropertyResult(result, payload, property) {\n if (result.issues.length) {\n payload.issues.push(...util.prefixIssues(property, result.issues));\n }\n}\nexport const $ZodCheckProperty = /*@__PURE__*/ core.$constructor(\"$ZodCheckProperty\", (inst, def) => {\n $ZodCheck.init(inst, def);\n inst._zod.check = (payload) => {\n const result = def.schema._zod.run({\n value: payload.value[def.property],\n issues: [],\n }, {});\n if (result instanceof Promise) {\n return result.then((result) => handleCheckPropertyResult(result, payload, def.property));\n }\n handleCheckPropertyResult(result, payload, def.property);\n return;\n };\n});\nexport const $ZodCheckMimeType = /*@__PURE__*/ core.$constructor(\"$ZodCheckMimeType\", (inst, def) => {\n $ZodCheck.init(inst, def);\n const mimeSet = new Set(def.mime);\n inst._zod.onattach.push((inst) => {\n inst._zod.bag.mime = def.mime;\n });\n inst._zod.check = (payload) => {\n if (mimeSet.has(payload.value.type))\n return;\n payload.issues.push({\n code: \"invalid_value\",\n values: def.mime,\n input: payload.value.type,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCheckOverwrite = /*@__PURE__*/ core.$constructor(\"$ZodCheckOverwrite\", (inst, def) => {\n $ZodCheck.init(inst, def);\n inst._zod.check = (payload) => {\n payload.value = def.tx(payload.value);\n };\n});\n","export class Doc {\n constructor(args = []) {\n this.content = [];\n this.indent = 0;\n if (this)\n this.args = args;\n }\n indented(fn) {\n this.indent += 1;\n fn(this);\n this.indent -= 1;\n }\n write(arg) {\n if (typeof arg === \"function\") {\n arg(this, { execution: \"sync\" });\n arg(this, { execution: \"async\" });\n return;\n }\n const content = arg;\n const lines = content.split(\"\\n\").filter((x) => x);\n const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));\n const dedented = lines.map((x) => x.slice(minIndent)).map((x) => \" \".repeat(this.indent * 2) + x);\n for (const line of dedented) {\n this.content.push(line);\n }\n }\n compile() {\n const F = Function;\n const args = this?.args;\n const content = this?.content ?? [``];\n const lines = [...content.map((x) => ` ${x}`)];\n // console.log(lines.join(\"\\n\"));\n return new F(...args, lines.join(\"\\n\"));\n }\n}\n","export const version = {\n major: 4,\n minor: 3,\n patch: 6,\n};\n","import * as checks from \"./checks.js\";\nimport * as core from \"./core.js\";\nimport { Doc } from \"./doc.js\";\nimport { parse, parseAsync, safeParse, safeParseAsync } from \"./parse.js\";\nimport * as regexes from \"./regexes.js\";\nimport * as util from \"./util.js\";\nimport { version } from \"./versions.js\";\nexport const $ZodType = /*@__PURE__*/ core.$constructor(\"$ZodType\", (inst, def) => {\n var _a;\n inst ?? (inst = {});\n inst._zod.def = def; // set _def property\n inst._zod.bag = inst._zod.bag || {}; // initialize _bag object\n inst._zod.version = version;\n const checks = [...(inst._zod.def.checks ?? [])];\n // if inst is itself a checks.$ZodCheck, run it as a check\n if (inst._zod.traits.has(\"$ZodCheck\")) {\n checks.unshift(inst);\n }\n for (const ch of checks) {\n for (const fn of ch._zod.onattach) {\n fn(inst);\n }\n }\n if (checks.length === 0) {\n // deferred initializer\n // inst._zod.parse is not yet defined\n (_a = inst._zod).deferred ?? (_a.deferred = []);\n inst._zod.deferred?.push(() => {\n inst._zod.run = inst._zod.parse;\n });\n }\n else {\n const runChecks = (payload, checks, ctx) => {\n let isAborted = util.aborted(payload);\n let asyncResult;\n for (const ch of checks) {\n if (ch._zod.def.when) {\n const shouldRun = ch._zod.def.when(payload);\n if (!shouldRun)\n continue;\n }\n else if (isAborted) {\n continue;\n }\n const currLen = payload.issues.length;\n const _ = ch._zod.check(payload);\n if (_ instanceof Promise && ctx?.async === false) {\n throw new core.$ZodAsyncError();\n }\n if (asyncResult || _ instanceof Promise) {\n asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {\n await _;\n const nextLen = payload.issues.length;\n if (nextLen === currLen)\n return;\n if (!isAborted)\n isAborted = util.aborted(payload, currLen);\n });\n }\n else {\n const nextLen = payload.issues.length;\n if (nextLen === currLen)\n continue;\n if (!isAborted)\n isAborted = util.aborted(payload, currLen);\n }\n }\n if (asyncResult) {\n return asyncResult.then(() => {\n return payload;\n });\n }\n return payload;\n };\n const handleCanaryResult = (canary, payload, ctx) => {\n // abort if the canary is aborted\n if (util.aborted(canary)) {\n canary.aborted = true;\n return canary;\n }\n // run checks first, then\n const checkResult = runChecks(payload, checks, ctx);\n if (checkResult instanceof Promise) {\n if (ctx.async === false)\n throw new core.$ZodAsyncError();\n return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));\n }\n return inst._zod.parse(checkResult, ctx);\n };\n inst._zod.run = (payload, ctx) => {\n if (ctx.skipChecks) {\n return inst._zod.parse(payload, ctx);\n }\n if (ctx.direction === \"backward\") {\n // run canary\n // initial pass (no checks)\n const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });\n if (canary instanceof Promise) {\n return canary.then((canary) => {\n return handleCanaryResult(canary, payload, ctx);\n });\n }\n return handleCanaryResult(canary, payload, ctx);\n }\n // forward\n const result = inst._zod.parse(payload, ctx);\n if (result instanceof Promise) {\n if (ctx.async === false)\n throw new core.$ZodAsyncError();\n return result.then((result) => runChecks(result, checks, ctx));\n }\n return runChecks(result, checks, ctx);\n };\n }\n // Lazy initialize ~standard to avoid creating objects for every schema\n util.defineLazy(inst, \"~standard\", () => ({\n validate: (value) => {\n try {\n const r = safeParse(inst, value);\n return r.success ? { value: r.data } : { issues: r.error?.issues };\n }\n catch (_) {\n return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));\n }\n },\n vendor: \"zod\",\n version: 1,\n }));\n});\nexport { clone } from \"./util.js\";\nexport const $ZodString = /*@__PURE__*/ core.$constructor(\"$ZodString\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);\n inst._zod.parse = (payload, _) => {\n if (def.coerce)\n try {\n payload.value = String(payload.value);\n }\n catch (_) { }\n if (typeof payload.value === \"string\")\n return payload;\n payload.issues.push({\n expected: \"string\",\n code: \"invalid_type\",\n input: payload.value,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodStringFormat = /*@__PURE__*/ core.$constructor(\"$ZodStringFormat\", (inst, def) => {\n // check initialization must come first\n checks.$ZodCheckStringFormat.init(inst, def);\n $ZodString.init(inst, def);\n});\nexport const $ZodGUID = /*@__PURE__*/ core.$constructor(\"$ZodGUID\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.guid);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodUUID = /*@__PURE__*/ core.$constructor(\"$ZodUUID\", (inst, def) => {\n if (def.version) {\n const versionMap = {\n v1: 1,\n v2: 2,\n v3: 3,\n v4: 4,\n v5: 5,\n v6: 6,\n v7: 7,\n v8: 8,\n };\n const v = versionMap[def.version];\n if (v === undefined)\n throw new Error(`Invalid UUID version: \"${def.version}\"`);\n def.pattern ?? (def.pattern = regexes.uuid(v));\n }\n else\n def.pattern ?? (def.pattern = regexes.uuid());\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodEmail = /*@__PURE__*/ core.$constructor(\"$ZodEmail\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.email);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodURL = /*@__PURE__*/ core.$constructor(\"$ZodURL\", (inst, def) => {\n $ZodStringFormat.init(inst, def);\n inst._zod.check = (payload) => {\n try {\n // Trim whitespace from input\n const trimmed = payload.value.trim();\n // @ts-ignore\n const url = new URL(trimmed);\n if (def.hostname) {\n def.hostname.lastIndex = 0;\n if (!def.hostname.test(url.hostname)) {\n payload.issues.push({\n code: \"invalid_format\",\n format: \"url\",\n note: \"Invalid hostname\",\n pattern: def.hostname.source,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n }\n }\n if (def.protocol) {\n def.protocol.lastIndex = 0;\n if (!def.protocol.test(url.protocol.endsWith(\":\") ? url.protocol.slice(0, -1) : url.protocol)) {\n payload.issues.push({\n code: \"invalid_format\",\n format: \"url\",\n note: \"Invalid protocol\",\n pattern: def.protocol.source,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n }\n }\n // Set the output value based on normalize flag\n if (def.normalize) {\n // Use normalized URL\n payload.value = url.href;\n }\n else {\n // Preserve the original input (trimmed)\n payload.value = trimmed;\n }\n return;\n }\n catch (_) {\n payload.issues.push({\n code: \"invalid_format\",\n format: \"url\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n }\n };\n});\nexport const $ZodEmoji = /*@__PURE__*/ core.$constructor(\"$ZodEmoji\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.emoji());\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodNanoID = /*@__PURE__*/ core.$constructor(\"$ZodNanoID\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.nanoid);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodCUID = /*@__PURE__*/ core.$constructor(\"$ZodCUID\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.cuid);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodCUID2 = /*@__PURE__*/ core.$constructor(\"$ZodCUID2\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.cuid2);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodULID = /*@__PURE__*/ core.$constructor(\"$ZodULID\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.ulid);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodXID = /*@__PURE__*/ core.$constructor(\"$ZodXID\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.xid);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodKSUID = /*@__PURE__*/ core.$constructor(\"$ZodKSUID\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.ksuid);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodISODateTime = /*@__PURE__*/ core.$constructor(\"$ZodISODateTime\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.datetime(def));\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodISODate = /*@__PURE__*/ core.$constructor(\"$ZodISODate\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.date);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodISOTime = /*@__PURE__*/ core.$constructor(\"$ZodISOTime\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.time(def));\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodISODuration = /*@__PURE__*/ core.$constructor(\"$ZodISODuration\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.duration);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodIPv4 = /*@__PURE__*/ core.$constructor(\"$ZodIPv4\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.ipv4);\n $ZodStringFormat.init(inst, def);\n inst._zod.bag.format = `ipv4`;\n});\nexport const $ZodIPv6 = /*@__PURE__*/ core.$constructor(\"$ZodIPv6\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.ipv6);\n $ZodStringFormat.init(inst, def);\n inst._zod.bag.format = `ipv6`;\n inst._zod.check = (payload) => {\n try {\n // @ts-ignore\n new URL(`http://[${payload.value}]`);\n // return;\n }\n catch {\n payload.issues.push({\n code: \"invalid_format\",\n format: \"ipv6\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n }\n };\n});\nexport const $ZodMAC = /*@__PURE__*/ core.$constructor(\"$ZodMAC\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.mac(def.delimiter));\n $ZodStringFormat.init(inst, def);\n inst._zod.bag.format = `mac`;\n});\nexport const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor(\"$ZodCIDRv4\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.cidrv4);\n $ZodStringFormat.init(inst, def);\n});\nexport const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor(\"$ZodCIDRv6\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation\n $ZodStringFormat.init(inst, def);\n inst._zod.check = (payload) => {\n const parts = payload.value.split(\"/\");\n try {\n if (parts.length !== 2)\n throw new Error();\n const [address, prefix] = parts;\n if (!prefix)\n throw new Error();\n const prefixNum = Number(prefix);\n if (`${prefixNum}` !== prefix)\n throw new Error();\n if (prefixNum < 0 || prefixNum > 128)\n throw new Error();\n // @ts-ignore\n new URL(`http://[${address}]`);\n }\n catch {\n payload.issues.push({\n code: \"invalid_format\",\n format: \"cidrv6\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n }\n };\n});\n////////////////////////////// ZodBase64 //////////////////////////////\nexport function isValidBase64(data) {\n if (data === \"\")\n return true;\n if (data.length % 4 !== 0)\n return false;\n try {\n // @ts-ignore\n atob(data);\n return true;\n }\n catch {\n return false;\n }\n}\nexport const $ZodBase64 = /*@__PURE__*/ core.$constructor(\"$ZodBase64\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.base64);\n $ZodStringFormat.init(inst, def);\n inst._zod.bag.contentEncoding = \"base64\";\n inst._zod.check = (payload) => {\n if (isValidBase64(payload.value))\n return;\n payload.issues.push({\n code: \"invalid_format\",\n format: \"base64\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\n////////////////////////////// ZodBase64 //////////////////////////////\nexport function isValidBase64URL(data) {\n if (!regexes.base64url.test(data))\n return false;\n const base64 = data.replace(/[-_]/g, (c) => (c === \"-\" ? \"+\" : \"/\"));\n const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, \"=\");\n return isValidBase64(padded);\n}\nexport const $ZodBase64URL = /*@__PURE__*/ core.$constructor(\"$ZodBase64URL\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.base64url);\n $ZodStringFormat.init(inst, def);\n inst._zod.bag.contentEncoding = \"base64url\";\n inst._zod.check = (payload) => {\n if (isValidBase64URL(payload.value))\n return;\n payload.issues.push({\n code: \"invalid_format\",\n format: \"base64url\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodE164 = /*@__PURE__*/ core.$constructor(\"$ZodE164\", (inst, def) => {\n def.pattern ?? (def.pattern = regexes.e164);\n $ZodStringFormat.init(inst, def);\n});\n////////////////////////////// ZodJWT //////////////////////////////\nexport function isValidJWT(token, algorithm = null) {\n try {\n const tokensParts = token.split(\".\");\n if (tokensParts.length !== 3)\n return false;\n const [header] = tokensParts;\n if (!header)\n return false;\n // @ts-ignore\n const parsedHeader = JSON.parse(atob(header));\n if (\"typ\" in parsedHeader && parsedHeader?.typ !== \"JWT\")\n return false;\n if (!parsedHeader.alg)\n return false;\n if (algorithm && (!(\"alg\" in parsedHeader) || parsedHeader.alg !== algorithm))\n return false;\n return true;\n }\n catch {\n return false;\n }\n}\nexport const $ZodJWT = /*@__PURE__*/ core.$constructor(\"$ZodJWT\", (inst, def) => {\n $ZodStringFormat.init(inst, def);\n inst._zod.check = (payload) => {\n if (isValidJWT(payload.value, def.alg))\n return;\n payload.issues.push({\n code: \"invalid_format\",\n format: \"jwt\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor(\"$ZodCustomStringFormat\", (inst, def) => {\n $ZodStringFormat.init(inst, def);\n inst._zod.check = (payload) => {\n if (def.fn(payload.value))\n return;\n payload.issues.push({\n code: \"invalid_format\",\n format: def.format,\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n };\n});\nexport const $ZodNumber = /*@__PURE__*/ core.$constructor(\"$ZodNumber\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;\n inst._zod.parse = (payload, _ctx) => {\n if (def.coerce)\n try {\n payload.value = Number(payload.value);\n }\n catch (_) { }\n const input = payload.value;\n if (typeof input === \"number\" && !Number.isNaN(input) && Number.isFinite(input)) {\n return payload;\n }\n const received = typeof input === \"number\"\n ? Number.isNaN(input)\n ? \"NaN\"\n : !Number.isFinite(input)\n ? \"Infinity\"\n : undefined\n : undefined;\n payload.issues.push({\n expected: \"number\",\n code: \"invalid_type\",\n input,\n inst,\n ...(received ? { received } : {}),\n });\n return payload;\n };\n});\nexport const $ZodNumberFormat = /*@__PURE__*/ core.$constructor(\"$ZodNumberFormat\", (inst, def) => {\n checks.$ZodCheckNumberFormat.init(inst, def);\n $ZodNumber.init(inst, def); // no format checks\n});\nexport const $ZodBoolean = /*@__PURE__*/ core.$constructor(\"$ZodBoolean\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.pattern = regexes.boolean;\n inst._zod.parse = (payload, _ctx) => {\n if (def.coerce)\n try {\n payload.value = Boolean(payload.value);\n }\n catch (_) { }\n const input = payload.value;\n if (typeof input === \"boolean\")\n return payload;\n payload.issues.push({\n expected: \"boolean\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodBigInt = /*@__PURE__*/ core.$constructor(\"$ZodBigInt\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.pattern = regexes.bigint;\n inst._zod.parse = (payload, _ctx) => {\n if (def.coerce)\n try {\n payload.value = BigInt(payload.value);\n }\n catch (_) { }\n if (typeof payload.value === \"bigint\")\n return payload;\n payload.issues.push({\n expected: \"bigint\",\n code: \"invalid_type\",\n input: payload.value,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor(\"$ZodBigIntFormat\", (inst, def) => {\n checks.$ZodCheckBigIntFormat.init(inst, def);\n $ZodBigInt.init(inst, def); // no format checks\n});\nexport const $ZodSymbol = /*@__PURE__*/ core.$constructor(\"$ZodSymbol\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, _ctx) => {\n const input = payload.value;\n if (typeof input === \"symbol\")\n return payload;\n payload.issues.push({\n expected: \"symbol\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodUndefined = /*@__PURE__*/ core.$constructor(\"$ZodUndefined\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.pattern = regexes.undefined;\n inst._zod.values = new Set([undefined]);\n inst._zod.optin = \"optional\";\n inst._zod.optout = \"optional\";\n inst._zod.parse = (payload, _ctx) => {\n const input = payload.value;\n if (typeof input === \"undefined\")\n return payload;\n payload.issues.push({\n expected: \"undefined\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodNull = /*@__PURE__*/ core.$constructor(\"$ZodNull\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.pattern = regexes.null;\n inst._zod.values = new Set([null]);\n inst._zod.parse = (payload, _ctx) => {\n const input = payload.value;\n if (input === null)\n return payload;\n payload.issues.push({\n expected: \"null\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodAny = /*@__PURE__*/ core.$constructor(\"$ZodAny\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload) => payload;\n});\nexport const $ZodUnknown = /*@__PURE__*/ core.$constructor(\"$ZodUnknown\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload) => payload;\n});\nexport const $ZodNever = /*@__PURE__*/ core.$constructor(\"$ZodNever\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, _ctx) => {\n payload.issues.push({\n expected: \"never\",\n code: \"invalid_type\",\n input: payload.value,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodVoid = /*@__PURE__*/ core.$constructor(\"$ZodVoid\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, _ctx) => {\n const input = payload.value;\n if (typeof input === \"undefined\")\n return payload;\n payload.issues.push({\n expected: \"void\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodDate = /*@__PURE__*/ core.$constructor(\"$ZodDate\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, _ctx) => {\n if (def.coerce) {\n try {\n payload.value = new Date(payload.value);\n }\n catch (_err) { }\n }\n const input = payload.value;\n const isDate = input instanceof Date;\n const isValidDate = isDate && !Number.isNaN(input.getTime());\n if (isValidDate)\n return payload;\n payload.issues.push({\n expected: \"date\",\n code: \"invalid_type\",\n input,\n ...(isDate ? { received: \"Invalid Date\" } : {}),\n inst,\n });\n return payload;\n };\n});\nfunction handleArrayResult(result, final, index) {\n if (result.issues.length) {\n final.issues.push(...util.prefixIssues(index, result.issues));\n }\n final.value[index] = result.value;\n}\nexport const $ZodArray = /*@__PURE__*/ core.$constructor(\"$ZodArray\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n const input = payload.value;\n if (!Array.isArray(input)) {\n payload.issues.push({\n expected: \"array\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n }\n payload.value = Array(input.length);\n const proms = [];\n for (let i = 0; i < input.length; i++) {\n const item = input[i];\n const result = def.element._zod.run({\n value: item,\n issues: [],\n }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((result) => handleArrayResult(result, payload, i)));\n }\n else {\n handleArrayResult(result, payload, i);\n }\n }\n if (proms.length) {\n return Promise.all(proms).then(() => payload);\n }\n return payload; //handleArrayResultsAsync(parseResults, final);\n };\n});\nfunction handlePropertyResult(result, final, key, input, isOptionalOut) {\n if (result.issues.length) {\n // For optional-out schemas, ignore errors on absent keys\n if (isOptionalOut && !(key in input)) {\n return;\n }\n final.issues.push(...util.prefixIssues(key, result.issues));\n }\n if (result.value === undefined) {\n if (key in input) {\n final.value[key] = undefined;\n }\n }\n else {\n final.value[key] = result.value;\n }\n}\nfunction normalizeDef(def) {\n const keys = Object.keys(def.shape);\n for (const k of keys) {\n if (!def.shape?.[k]?._zod?.traits?.has(\"$ZodType\")) {\n throw new Error(`Invalid element at key \"${k}\": expected a Zod schema`);\n }\n }\n const okeys = util.optionalKeys(def.shape);\n return {\n ...def,\n keys,\n keySet: new Set(keys),\n numKeys: keys.length,\n optionalKeys: new Set(okeys),\n };\n}\nfunction handleCatchall(proms, input, payload, ctx, def, inst) {\n const unrecognized = [];\n // iterate over input keys\n const keySet = def.keySet;\n const _catchall = def.catchall._zod;\n const t = _catchall.def.type;\n const isOptionalOut = _catchall.optout === \"optional\";\n for (const key in input) {\n if (keySet.has(key))\n continue;\n if (t === \"never\") {\n unrecognized.push(key);\n continue;\n }\n const r = _catchall.run({ value: input[key], issues: [] }, ctx);\n if (r instanceof Promise) {\n proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));\n }\n else {\n handlePropertyResult(r, payload, key, input, isOptionalOut);\n }\n }\n if (unrecognized.length) {\n payload.issues.push({\n code: \"unrecognized_keys\",\n keys: unrecognized,\n input,\n inst,\n });\n }\n if (!proms.length)\n return payload;\n return Promise.all(proms).then(() => {\n return payload;\n });\n}\nexport const $ZodObject = /*@__PURE__*/ core.$constructor(\"$ZodObject\", (inst, def) => {\n // requires cast because technically $ZodObject doesn't extend\n $ZodType.init(inst, def);\n // const sh = def.shape;\n const desc = Object.getOwnPropertyDescriptor(def, \"shape\");\n if (!desc?.get) {\n const sh = def.shape;\n Object.defineProperty(def, \"shape\", {\n get: () => {\n const newSh = { ...sh };\n Object.defineProperty(def, \"shape\", {\n value: newSh,\n });\n return newSh;\n },\n });\n }\n const _normalized = util.cached(() => normalizeDef(def));\n util.defineLazy(inst._zod, \"propValues\", () => {\n const shape = def.shape;\n const propValues = {};\n for (const key in shape) {\n const field = shape[key]._zod;\n if (field.values) {\n propValues[key] ?? (propValues[key] = new Set());\n for (const v of field.values)\n propValues[key].add(v);\n }\n }\n return propValues;\n });\n const isObject = util.isObject;\n const catchall = def.catchall;\n let value;\n inst._zod.parse = (payload, ctx) => {\n value ?? (value = _normalized.value);\n const input = payload.value;\n if (!isObject(input)) {\n payload.issues.push({\n expected: \"object\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n }\n payload.value = {};\n const proms = [];\n const shape = value.shape;\n for (const key of value.keys) {\n const el = shape[key];\n const isOptionalOut = el._zod.optout === \"optional\";\n const r = el._zod.run({ value: input[key], issues: [] }, ctx);\n if (r instanceof Promise) {\n proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));\n }\n else {\n handlePropertyResult(r, payload, key, input, isOptionalOut);\n }\n }\n if (!catchall) {\n return proms.length ? Promise.all(proms).then(() => payload) : payload;\n }\n return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);\n };\n});\nexport const $ZodObjectJIT = /*@__PURE__*/ core.$constructor(\"$ZodObjectJIT\", (inst, def) => {\n // requires cast because technically $ZodObject doesn't extend\n $ZodObject.init(inst, def);\n const superParse = inst._zod.parse;\n const _normalized = util.cached(() => normalizeDef(def));\n const generateFastpass = (shape) => {\n const doc = new Doc([\"shape\", \"payload\", \"ctx\"]);\n const normalized = _normalized.value;\n const parseStr = (key) => {\n const k = util.esc(key);\n return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;\n };\n doc.write(`const input = payload.value;`);\n const ids = Object.create(null);\n let counter = 0;\n for (const key of normalized.keys) {\n ids[key] = `key_${counter++}`;\n }\n // A: preserve key order {\n doc.write(`const newResult = {};`);\n for (const key of normalized.keys) {\n const id = ids[key];\n const k = util.esc(key);\n const schema = shape[key];\n const isOptionalOut = schema?._zod?.optout === \"optional\";\n doc.write(`const ${id} = ${parseStr(key)};`);\n if (isOptionalOut) {\n // For optional-out schemas, ignore errors on absent keys\n doc.write(`\n if (${id}.issues.length) {\n if (${k} in input) {\n payload.issues = payload.issues.concat(${id}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${k}, ...iss.path] : [${k}]\n })));\n }\n }\n \n if (${id}.value === undefined) {\n if (${k} in input) {\n newResult[${k}] = undefined;\n }\n } else {\n newResult[${k}] = ${id}.value;\n }\n \n `);\n }\n else {\n doc.write(`\n if (${id}.issues.length) {\n payload.issues = payload.issues.concat(${id}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${k}, ...iss.path] : [${k}]\n })));\n }\n \n if (${id}.value === undefined) {\n if (${k} in input) {\n newResult[${k}] = undefined;\n }\n } else {\n newResult[${k}] = ${id}.value;\n }\n \n `);\n }\n }\n doc.write(`payload.value = newResult;`);\n doc.write(`return payload;`);\n const fn = doc.compile();\n return (payload, ctx) => fn(shape, payload, ctx);\n };\n let fastpass;\n const isObject = util.isObject;\n const jit = !core.globalConfig.jitless;\n const allowsEval = util.allowsEval;\n const fastEnabled = jit && allowsEval.value; // && !def.catchall;\n const catchall = def.catchall;\n let value;\n inst._zod.parse = (payload, ctx) => {\n value ?? (value = _normalized.value);\n const input = payload.value;\n if (!isObject(input)) {\n payload.issues.push({\n expected: \"object\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n }\n if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {\n // always synchronous\n if (!fastpass)\n fastpass = generateFastpass(def.shape);\n payload = fastpass(payload, ctx);\n if (!catchall)\n return payload;\n return handleCatchall([], input, payload, ctx, value, inst);\n }\n return superParse(payload, ctx);\n };\n});\nfunction handleUnionResults(results, final, inst, ctx) {\n for (const result of results) {\n if (result.issues.length === 0) {\n final.value = result.value;\n return final;\n }\n }\n const nonaborted = results.filter((r) => !util.aborted(r));\n if (nonaborted.length === 1) {\n final.value = nonaborted[0].value;\n return nonaborted[0];\n }\n final.issues.push({\n code: \"invalid_union\",\n input: final.value,\n inst,\n errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),\n });\n return final;\n}\nexport const $ZodUnion = /*@__PURE__*/ core.$constructor(\"$ZodUnion\", (inst, def) => {\n $ZodType.init(inst, def);\n util.defineLazy(inst._zod, \"optin\", () => def.options.some((o) => o._zod.optin === \"optional\") ? \"optional\" : undefined);\n util.defineLazy(inst._zod, \"optout\", () => def.options.some((o) => o._zod.optout === \"optional\") ? \"optional\" : undefined);\n util.defineLazy(inst._zod, \"values\", () => {\n if (def.options.every((o) => o._zod.values)) {\n return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));\n }\n return undefined;\n });\n util.defineLazy(inst._zod, \"pattern\", () => {\n if (def.options.every((o) => o._zod.pattern)) {\n const patterns = def.options.map((o) => o._zod.pattern);\n return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join(\"|\")})$`);\n }\n return undefined;\n });\n const single = def.options.length === 1;\n const first = def.options[0]._zod.run;\n inst._zod.parse = (payload, ctx) => {\n if (single) {\n return first(payload, ctx);\n }\n let async = false;\n const results = [];\n for (const option of def.options) {\n const result = option._zod.run({\n value: payload.value,\n issues: [],\n }, ctx);\n if (result instanceof Promise) {\n results.push(result);\n async = true;\n }\n else {\n if (result.issues.length === 0)\n return result;\n results.push(result);\n }\n }\n if (!async)\n return handleUnionResults(results, payload, inst, ctx);\n return Promise.all(results).then((results) => {\n return handleUnionResults(results, payload, inst, ctx);\n });\n };\n});\nfunction handleExclusiveUnionResults(results, final, inst, ctx) {\n const successes = results.filter((r) => r.issues.length === 0);\n if (successes.length === 1) {\n final.value = successes[0].value;\n return final;\n }\n if (successes.length === 0) {\n // No matches - same as regular union\n final.issues.push({\n code: \"invalid_union\",\n input: final.value,\n inst,\n errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),\n });\n }\n else {\n // Multiple matches - exclusive union failure\n final.issues.push({\n code: \"invalid_union\",\n input: final.value,\n inst,\n errors: [],\n inclusive: false,\n });\n }\n return final;\n}\nexport const $ZodXor = /*@__PURE__*/ core.$constructor(\"$ZodXor\", (inst, def) => {\n $ZodUnion.init(inst, def);\n def.inclusive = false;\n const single = def.options.length === 1;\n const first = def.options[0]._zod.run;\n inst._zod.parse = (payload, ctx) => {\n if (single) {\n return first(payload, ctx);\n }\n let async = false;\n const results = [];\n for (const option of def.options) {\n const result = option._zod.run({\n value: payload.value,\n issues: [],\n }, ctx);\n if (result instanceof Promise) {\n results.push(result);\n async = true;\n }\n else {\n results.push(result);\n }\n }\n if (!async)\n return handleExclusiveUnionResults(results, payload, inst, ctx);\n return Promise.all(results).then((results) => {\n return handleExclusiveUnionResults(results, payload, inst, ctx);\n });\n };\n});\nexport const $ZodDiscriminatedUnion = \n/*@__PURE__*/\ncore.$constructor(\"$ZodDiscriminatedUnion\", (inst, def) => {\n def.inclusive = false;\n $ZodUnion.init(inst, def);\n const _super = inst._zod.parse;\n util.defineLazy(inst._zod, \"propValues\", () => {\n const propValues = {};\n for (const option of def.options) {\n const pv = option._zod.propValues;\n if (!pv || Object.keys(pv).length === 0)\n throw new Error(`Invalid discriminated union option at index \"${def.options.indexOf(option)}\"`);\n for (const [k, v] of Object.entries(pv)) {\n if (!propValues[k])\n propValues[k] = new Set();\n for (const val of v) {\n propValues[k].add(val);\n }\n }\n }\n return propValues;\n });\n const disc = util.cached(() => {\n const opts = def.options;\n const map = new Map();\n for (const o of opts) {\n const values = o._zod.propValues?.[def.discriminator];\n if (!values || values.size === 0)\n throw new Error(`Invalid discriminated union option at index \"${def.options.indexOf(o)}\"`);\n for (const v of values) {\n if (map.has(v)) {\n throw new Error(`Duplicate discriminator value \"${String(v)}\"`);\n }\n map.set(v, o);\n }\n }\n return map;\n });\n inst._zod.parse = (payload, ctx) => {\n const input = payload.value;\n if (!util.isObject(input)) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"object\",\n input,\n inst,\n });\n return payload;\n }\n const opt = disc.value.get(input?.[def.discriminator]);\n if (opt) {\n return opt._zod.run(payload, ctx);\n }\n if (def.unionFallback) {\n return _super(payload, ctx);\n }\n // no matching discriminator\n payload.issues.push({\n code: \"invalid_union\",\n errors: [],\n note: \"No matching discriminator\",\n discriminator: def.discriminator,\n input,\n path: [def.discriminator],\n inst,\n });\n return payload;\n };\n});\nexport const $ZodIntersection = /*@__PURE__*/ core.$constructor(\"$ZodIntersection\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n const input = payload.value;\n const left = def.left._zod.run({ value: input, issues: [] }, ctx);\n const right = def.right._zod.run({ value: input, issues: [] }, ctx);\n const async = left instanceof Promise || right instanceof Promise;\n if (async) {\n return Promise.all([left, right]).then(([left, right]) => {\n return handleIntersectionResults(payload, left, right);\n });\n }\n return handleIntersectionResults(payload, left, right);\n };\n});\nfunction mergeValues(a, b) {\n // const aType = parse.t(a);\n // const bType = parse.t(b);\n if (a === b) {\n return { valid: true, data: a };\n }\n if (a instanceof Date && b instanceof Date && +a === +b) {\n return { valid: true, data: a };\n }\n if (util.isPlainObject(a) && util.isPlainObject(b)) {\n const bKeys = Object.keys(b);\n const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);\n const newObj = { ...a, ...b };\n for (const key of sharedKeys) {\n const sharedValue = mergeValues(a[key], b[key]);\n if (!sharedValue.valid) {\n return {\n valid: false,\n mergeErrorPath: [key, ...sharedValue.mergeErrorPath],\n };\n }\n newObj[key] = sharedValue.data;\n }\n return { valid: true, data: newObj };\n }\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) {\n return { valid: false, mergeErrorPath: [] };\n }\n const newArray = [];\n for (let index = 0; index < a.length; index++) {\n const itemA = a[index];\n const itemB = b[index];\n const sharedValue = mergeValues(itemA, itemB);\n if (!sharedValue.valid) {\n return {\n valid: false,\n mergeErrorPath: [index, ...sharedValue.mergeErrorPath],\n };\n }\n newArray.push(sharedValue.data);\n }\n return { valid: true, data: newArray };\n }\n return { valid: false, mergeErrorPath: [] };\n}\nfunction handleIntersectionResults(result, left, right) {\n // Track which side(s) report each key as unrecognized\n const unrecKeys = new Map();\n let unrecIssue;\n for (const iss of left.issues) {\n if (iss.code === \"unrecognized_keys\") {\n unrecIssue ?? (unrecIssue = iss);\n for (const k of iss.keys) {\n if (!unrecKeys.has(k))\n unrecKeys.set(k, {});\n unrecKeys.get(k).l = true;\n }\n }\n else {\n result.issues.push(iss);\n }\n }\n for (const iss of right.issues) {\n if (iss.code === \"unrecognized_keys\") {\n for (const k of iss.keys) {\n if (!unrecKeys.has(k))\n unrecKeys.set(k, {});\n unrecKeys.get(k).r = true;\n }\n }\n else {\n result.issues.push(iss);\n }\n }\n // Report only keys unrecognized by BOTH sides\n const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);\n if (bothKeys.length && unrecIssue) {\n result.issues.push({ ...unrecIssue, keys: bothKeys });\n }\n if (util.aborted(result))\n return result;\n const merged = mergeValues(left.value, right.value);\n if (!merged.valid) {\n throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);\n }\n result.value = merged.data;\n return result;\n}\nexport const $ZodTuple = /*@__PURE__*/ core.$constructor(\"$ZodTuple\", (inst, def) => {\n $ZodType.init(inst, def);\n const items = def.items;\n inst._zod.parse = (payload, ctx) => {\n const input = payload.value;\n if (!Array.isArray(input)) {\n payload.issues.push({\n input,\n inst,\n expected: \"tuple\",\n code: \"invalid_type\",\n });\n return payload;\n }\n payload.value = [];\n const proms = [];\n const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== \"optional\");\n const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;\n if (!def.rest) {\n const tooBig = input.length > items.length;\n const tooSmall = input.length < optStart - 1;\n if (tooBig || tooSmall) {\n payload.issues.push({\n ...(tooBig\n ? { code: \"too_big\", maximum: items.length, inclusive: true }\n : { code: \"too_small\", minimum: items.length }),\n input,\n inst,\n origin: \"array\",\n });\n return payload;\n }\n }\n let i = -1;\n for (const item of items) {\n i++;\n if (i >= input.length)\n if (i >= optStart)\n continue;\n const result = item._zod.run({\n value: input[i],\n issues: [],\n }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((result) => handleTupleResult(result, payload, i)));\n }\n else {\n handleTupleResult(result, payload, i);\n }\n }\n if (def.rest) {\n const rest = input.slice(items.length);\n for (const el of rest) {\n i++;\n const result = def.rest._zod.run({\n value: el,\n issues: [],\n }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((result) => handleTupleResult(result, payload, i)));\n }\n else {\n handleTupleResult(result, payload, i);\n }\n }\n }\n if (proms.length)\n return Promise.all(proms).then(() => payload);\n return payload;\n };\n});\nfunction handleTupleResult(result, final, index) {\n if (result.issues.length) {\n final.issues.push(...util.prefixIssues(index, result.issues));\n }\n final.value[index] = result.value;\n}\nexport const $ZodRecord = /*@__PURE__*/ core.$constructor(\"$ZodRecord\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n const input = payload.value;\n if (!util.isPlainObject(input)) {\n payload.issues.push({\n expected: \"record\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n }\n const proms = [];\n const values = def.keyType._zod.values;\n if (values) {\n payload.value = {};\n const recordKeys = new Set();\n for (const key of values) {\n if (typeof key === \"string\" || typeof key === \"number\" || typeof key === \"symbol\") {\n recordKeys.add(typeof key === \"number\" ? key.toString() : key);\n const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((result) => {\n if (result.issues.length) {\n payload.issues.push(...util.prefixIssues(key, result.issues));\n }\n payload.value[key] = result.value;\n }));\n }\n else {\n if (result.issues.length) {\n payload.issues.push(...util.prefixIssues(key, result.issues));\n }\n payload.value[key] = result.value;\n }\n }\n }\n let unrecognized;\n for (const key in input) {\n if (!recordKeys.has(key)) {\n unrecognized = unrecognized ?? [];\n unrecognized.push(key);\n }\n }\n if (unrecognized && unrecognized.length > 0) {\n payload.issues.push({\n code: \"unrecognized_keys\",\n input,\n inst,\n keys: unrecognized,\n });\n }\n }\n else {\n payload.value = {};\n for (const key of Reflect.ownKeys(input)) {\n if (key === \"__proto__\")\n continue;\n let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);\n if (keyResult instanceof Promise) {\n throw new Error(\"Async schemas not supported in object keys currently\");\n }\n // Numeric string fallback: if key is a numeric string and failed, retry with Number(key)\n // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals\n const checkNumericKey = typeof key === \"string\" && regexes.number.test(key) && keyResult.issues.length;\n if (checkNumericKey) {\n const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);\n if (retryResult instanceof Promise) {\n throw new Error(\"Async schemas not supported in object keys currently\");\n }\n if (retryResult.issues.length === 0) {\n keyResult = retryResult;\n }\n }\n if (keyResult.issues.length) {\n if (def.mode === \"loose\") {\n // Pass through unchanged\n payload.value[key] = input[key];\n }\n else {\n // Default \"strict\" behavior: error on invalid key\n payload.issues.push({\n code: \"invalid_key\",\n origin: \"record\",\n issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),\n input: key,\n path: [key],\n inst,\n });\n }\n continue;\n }\n const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((result) => {\n if (result.issues.length) {\n payload.issues.push(...util.prefixIssues(key, result.issues));\n }\n payload.value[keyResult.value] = result.value;\n }));\n }\n else {\n if (result.issues.length) {\n payload.issues.push(...util.prefixIssues(key, result.issues));\n }\n payload.value[keyResult.value] = result.value;\n }\n }\n }\n if (proms.length) {\n return Promise.all(proms).then(() => payload);\n }\n return payload;\n };\n});\nexport const $ZodMap = /*@__PURE__*/ core.$constructor(\"$ZodMap\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n const input = payload.value;\n if (!(input instanceof Map)) {\n payload.issues.push({\n expected: \"map\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n }\n const proms = [];\n payload.value = new Map();\n for (const [key, value] of input) {\n const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);\n const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);\n if (keyResult instanceof Promise || valueResult instanceof Promise) {\n proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {\n handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);\n }));\n }\n else {\n handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);\n }\n }\n if (proms.length)\n return Promise.all(proms).then(() => payload);\n return payload;\n };\n});\nfunction handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {\n if (keyResult.issues.length) {\n if (util.propertyKeyTypes.has(typeof key)) {\n final.issues.push(...util.prefixIssues(key, keyResult.issues));\n }\n else {\n final.issues.push({\n code: \"invalid_key\",\n origin: \"map\",\n input,\n inst,\n issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),\n });\n }\n }\n if (valueResult.issues.length) {\n if (util.propertyKeyTypes.has(typeof key)) {\n final.issues.push(...util.prefixIssues(key, valueResult.issues));\n }\n else {\n final.issues.push({\n origin: \"map\",\n code: \"invalid_element\",\n input,\n inst,\n key: key,\n issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),\n });\n }\n }\n final.value.set(keyResult.value, valueResult.value);\n}\nexport const $ZodSet = /*@__PURE__*/ core.$constructor(\"$ZodSet\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n const input = payload.value;\n if (!(input instanceof Set)) {\n payload.issues.push({\n input,\n inst,\n expected: \"set\",\n code: \"invalid_type\",\n });\n return payload;\n }\n const proms = [];\n payload.value = new Set();\n for (const item of input) {\n const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((result) => handleSetResult(result, payload)));\n }\n else\n handleSetResult(result, payload);\n }\n if (proms.length)\n return Promise.all(proms).then(() => payload);\n return payload;\n };\n});\nfunction handleSetResult(result, final) {\n if (result.issues.length) {\n final.issues.push(...result.issues);\n }\n final.value.add(result.value);\n}\nexport const $ZodEnum = /*@__PURE__*/ core.$constructor(\"$ZodEnum\", (inst, def) => {\n $ZodType.init(inst, def);\n const values = util.getEnumValues(def.entries);\n const valuesSet = new Set(values);\n inst._zod.values = valuesSet;\n inst._zod.pattern = new RegExp(`^(${values\n .filter((k) => util.propertyKeyTypes.has(typeof k))\n .map((o) => (typeof o === \"string\" ? util.escapeRegex(o) : o.toString()))\n .join(\"|\")})$`);\n inst._zod.parse = (payload, _ctx) => {\n const input = payload.value;\n if (valuesSet.has(input)) {\n return payload;\n }\n payload.issues.push({\n code: \"invalid_value\",\n values,\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodLiteral = /*@__PURE__*/ core.$constructor(\"$ZodLiteral\", (inst, def) => {\n $ZodType.init(inst, def);\n if (def.values.length === 0) {\n throw new Error(\"Cannot create literal schema with no valid values\");\n }\n const values = new Set(def.values);\n inst._zod.values = values;\n inst._zod.pattern = new RegExp(`^(${def.values\n .map((o) => (typeof o === \"string\" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))\n .join(\"|\")})$`);\n inst._zod.parse = (payload, _ctx) => {\n const input = payload.value;\n if (values.has(input)) {\n return payload;\n }\n payload.issues.push({\n code: \"invalid_value\",\n values: def.values,\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodFile = /*@__PURE__*/ core.$constructor(\"$ZodFile\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, _ctx) => {\n const input = payload.value;\n // @ts-ignore\n if (input instanceof File)\n return payload;\n payload.issues.push({\n expected: \"file\",\n code: \"invalid_type\",\n input,\n inst,\n });\n return payload;\n };\n});\nexport const $ZodTransform = /*@__PURE__*/ core.$constructor(\"$ZodTransform\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n if (ctx.direction === \"backward\") {\n throw new core.$ZodEncodeError(inst.constructor.name);\n }\n const _out = def.transform(payload.value, payload);\n if (ctx.async) {\n const output = _out instanceof Promise ? _out : Promise.resolve(_out);\n return output.then((output) => {\n payload.value = output;\n return payload;\n });\n }\n if (_out instanceof Promise) {\n throw new core.$ZodAsyncError();\n }\n payload.value = _out;\n return payload;\n };\n});\nfunction handleOptionalResult(result, input) {\n if (result.issues.length && input === undefined) {\n return { issues: [], value: undefined };\n }\n return result;\n}\nexport const $ZodOptional = /*@__PURE__*/ core.$constructor(\"$ZodOptional\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.optin = \"optional\";\n inst._zod.optout = \"optional\";\n util.defineLazy(inst._zod, \"values\", () => {\n return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;\n });\n util.defineLazy(inst._zod, \"pattern\", () => {\n const pattern = def.innerType._zod.pattern;\n return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;\n });\n inst._zod.parse = (payload, ctx) => {\n if (def.innerType._zod.optin === \"optional\") {\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise)\n return result.then((r) => handleOptionalResult(r, payload.value));\n return handleOptionalResult(result, payload.value);\n }\n if (payload.value === undefined) {\n return payload;\n }\n return def.innerType._zod.run(payload, ctx);\n };\n});\nexport const $ZodExactOptional = /*@__PURE__*/ core.$constructor(\"$ZodExactOptional\", (inst, def) => {\n // Call parent init - inherits optin/optout = \"optional\"\n $ZodOptional.init(inst, def);\n // Override values/pattern to NOT add undefined\n util.defineLazy(inst._zod, \"values\", () => def.innerType._zod.values);\n util.defineLazy(inst._zod, \"pattern\", () => def.innerType._zod.pattern);\n // Override parse to just delegate (no undefined handling)\n inst._zod.parse = (payload, ctx) => {\n return def.innerType._zod.run(payload, ctx);\n };\n});\nexport const $ZodNullable = /*@__PURE__*/ core.$constructor(\"$ZodNullable\", (inst, def) => {\n $ZodType.init(inst, def);\n util.defineLazy(inst._zod, \"optin\", () => def.innerType._zod.optin);\n util.defineLazy(inst._zod, \"optout\", () => def.innerType._zod.optout);\n util.defineLazy(inst._zod, \"pattern\", () => {\n const pattern = def.innerType._zod.pattern;\n return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;\n });\n util.defineLazy(inst._zod, \"values\", () => {\n return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;\n });\n inst._zod.parse = (payload, ctx) => {\n // Forward direction (decode): allow null to pass through\n if (payload.value === null)\n return payload;\n return def.innerType._zod.run(payload, ctx);\n };\n});\nexport const $ZodDefault = /*@__PURE__*/ core.$constructor(\"$ZodDefault\", (inst, def) => {\n $ZodType.init(inst, def);\n // inst._zod.qin = \"true\";\n inst._zod.optin = \"optional\";\n util.defineLazy(inst._zod, \"values\", () => def.innerType._zod.values);\n inst._zod.parse = (payload, ctx) => {\n if (ctx.direction === \"backward\") {\n return def.innerType._zod.run(payload, ctx);\n }\n // Forward direction (decode): apply defaults for undefined input\n if (payload.value === undefined) {\n payload.value = def.defaultValue;\n /**\n * $ZodDefault returns the default value immediately in forward direction.\n * It doesn't pass the default value into the validator (\"prefault\"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a \"prefault\" for the pipe. */\n return payload;\n }\n // Forward direction: continue with default handling\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise) {\n return result.then((result) => handleDefaultResult(result, def));\n }\n return handleDefaultResult(result, def);\n };\n});\nfunction handleDefaultResult(payload, def) {\n if (payload.value === undefined) {\n payload.value = def.defaultValue;\n }\n return payload;\n}\nexport const $ZodPrefault = /*@__PURE__*/ core.$constructor(\"$ZodPrefault\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.optin = \"optional\";\n util.defineLazy(inst._zod, \"values\", () => def.innerType._zod.values);\n inst._zod.parse = (payload, ctx) => {\n if (ctx.direction === \"backward\") {\n return def.innerType._zod.run(payload, ctx);\n }\n // Forward direction (decode): apply prefault for undefined input\n if (payload.value === undefined) {\n payload.value = def.defaultValue;\n }\n return def.innerType._zod.run(payload, ctx);\n };\n});\nexport const $ZodNonOptional = /*@__PURE__*/ core.$constructor(\"$ZodNonOptional\", (inst, def) => {\n $ZodType.init(inst, def);\n util.defineLazy(inst._zod, \"values\", () => {\n const v = def.innerType._zod.values;\n return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;\n });\n inst._zod.parse = (payload, ctx) => {\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise) {\n return result.then((result) => handleNonOptionalResult(result, inst));\n }\n return handleNonOptionalResult(result, inst);\n };\n});\nfunction handleNonOptionalResult(payload, inst) {\n if (!payload.issues.length && payload.value === undefined) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: payload.value,\n inst,\n });\n }\n return payload;\n}\nexport const $ZodSuccess = /*@__PURE__*/ core.$constructor(\"$ZodSuccess\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n if (ctx.direction === \"backward\") {\n throw new core.$ZodEncodeError(\"ZodSuccess\");\n }\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise) {\n return result.then((result) => {\n payload.value = result.issues.length === 0;\n return payload;\n });\n }\n payload.value = result.issues.length === 0;\n return payload;\n };\n});\nexport const $ZodCatch = /*@__PURE__*/ core.$constructor(\"$ZodCatch\", (inst, def) => {\n $ZodType.init(inst, def);\n util.defineLazy(inst._zod, \"optin\", () => def.innerType._zod.optin);\n util.defineLazy(inst._zod, \"optout\", () => def.innerType._zod.optout);\n util.defineLazy(inst._zod, \"values\", () => def.innerType._zod.values);\n inst._zod.parse = (payload, ctx) => {\n if (ctx.direction === \"backward\") {\n return def.innerType._zod.run(payload, ctx);\n }\n // Forward direction (decode): apply catch logic\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise) {\n return result.then((result) => {\n payload.value = result.value;\n if (result.issues.length) {\n payload.value = def.catchValue({\n ...payload,\n error: {\n issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),\n },\n input: payload.value,\n });\n payload.issues = [];\n }\n return payload;\n });\n }\n payload.value = result.value;\n if (result.issues.length) {\n payload.value = def.catchValue({\n ...payload,\n error: {\n issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),\n },\n input: payload.value,\n });\n payload.issues = [];\n }\n return payload;\n };\n});\nexport const $ZodNaN = /*@__PURE__*/ core.$constructor(\"$ZodNaN\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, _ctx) => {\n if (typeof payload.value !== \"number\" || !Number.isNaN(payload.value)) {\n payload.issues.push({\n input: payload.value,\n inst,\n expected: \"nan\",\n code: \"invalid_type\",\n });\n return payload;\n }\n return payload;\n };\n});\nexport const $ZodPipe = /*@__PURE__*/ core.$constructor(\"$ZodPipe\", (inst, def) => {\n $ZodType.init(inst, def);\n util.defineLazy(inst._zod, \"values\", () => def.in._zod.values);\n util.defineLazy(inst._zod, \"optin\", () => def.in._zod.optin);\n util.defineLazy(inst._zod, \"optout\", () => def.out._zod.optout);\n util.defineLazy(inst._zod, \"propValues\", () => def.in._zod.propValues);\n inst._zod.parse = (payload, ctx) => {\n if (ctx.direction === \"backward\") {\n const right = def.out._zod.run(payload, ctx);\n if (right instanceof Promise) {\n return right.then((right) => handlePipeResult(right, def.in, ctx));\n }\n return handlePipeResult(right, def.in, ctx);\n }\n const left = def.in._zod.run(payload, ctx);\n if (left instanceof Promise) {\n return left.then((left) => handlePipeResult(left, def.out, ctx));\n }\n return handlePipeResult(left, def.out, ctx);\n };\n});\nfunction handlePipeResult(left, next, ctx) {\n if (left.issues.length) {\n // prevent further checks\n left.aborted = true;\n return left;\n }\n return next._zod.run({ value: left.value, issues: left.issues }, ctx);\n}\nexport const $ZodCodec = /*@__PURE__*/ core.$constructor(\"$ZodCodec\", (inst, def) => {\n $ZodType.init(inst, def);\n util.defineLazy(inst._zod, \"values\", () => def.in._zod.values);\n util.defineLazy(inst._zod, \"optin\", () => def.in._zod.optin);\n util.defineLazy(inst._zod, \"optout\", () => def.out._zod.optout);\n util.defineLazy(inst._zod, \"propValues\", () => def.in._zod.propValues);\n inst._zod.parse = (payload, ctx) => {\n const direction = ctx.direction || \"forward\";\n if (direction === \"forward\") {\n const left = def.in._zod.run(payload, ctx);\n if (left instanceof Promise) {\n return left.then((left) => handleCodecAResult(left, def, ctx));\n }\n return handleCodecAResult(left, def, ctx);\n }\n else {\n const right = def.out._zod.run(payload, ctx);\n if (right instanceof Promise) {\n return right.then((right) => handleCodecAResult(right, def, ctx));\n }\n return handleCodecAResult(right, def, ctx);\n }\n };\n});\nfunction handleCodecAResult(result, def, ctx) {\n if (result.issues.length) {\n // prevent further checks\n result.aborted = true;\n return result;\n }\n const direction = ctx.direction || \"forward\";\n if (direction === \"forward\") {\n const transformed = def.transform(result.value, result);\n if (transformed instanceof Promise) {\n return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));\n }\n return handleCodecTxResult(result, transformed, def.out, ctx);\n }\n else {\n const transformed = def.reverseTransform(result.value, result);\n if (transformed instanceof Promise) {\n return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));\n }\n return handleCodecTxResult(result, transformed, def.in, ctx);\n }\n}\nfunction handleCodecTxResult(left, value, nextSchema, ctx) {\n // Check if transform added any issues\n if (left.issues.length) {\n left.aborted = true;\n return left;\n }\n return nextSchema._zod.run({ value, issues: left.issues }, ctx);\n}\nexport const $ZodReadonly = /*@__PURE__*/ core.$constructor(\"$ZodReadonly\", (inst, def) => {\n $ZodType.init(inst, def);\n util.defineLazy(inst._zod, \"propValues\", () => def.innerType._zod.propValues);\n util.defineLazy(inst._zod, \"values\", () => def.innerType._zod.values);\n util.defineLazy(inst._zod, \"optin\", () => def.innerType?._zod?.optin);\n util.defineLazy(inst._zod, \"optout\", () => def.innerType?._zod?.optout);\n inst._zod.parse = (payload, ctx) => {\n if (ctx.direction === \"backward\") {\n return def.innerType._zod.run(payload, ctx);\n }\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise) {\n return result.then(handleReadonlyResult);\n }\n return handleReadonlyResult(result);\n };\n});\nfunction handleReadonlyResult(payload) {\n payload.value = Object.freeze(payload.value);\n return payload;\n}\nexport const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor(\"$ZodTemplateLiteral\", (inst, def) => {\n $ZodType.init(inst, def);\n const regexParts = [];\n for (const part of def.parts) {\n if (typeof part === \"object\" && part !== null) {\n // is Zod schema\n if (!part._zod.pattern) {\n // if (!source)\n throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);\n }\n const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;\n if (!source)\n throw new Error(`Invalid template literal part: ${part._zod.traits}`);\n const start = source.startsWith(\"^\") ? 1 : 0;\n const end = source.endsWith(\"$\") ? source.length - 1 : source.length;\n regexParts.push(source.slice(start, end));\n }\n else if (part === null || util.primitiveTypes.has(typeof part)) {\n regexParts.push(util.escapeRegex(`${part}`));\n }\n else {\n throw new Error(`Invalid template literal part: ${part}`);\n }\n }\n inst._zod.pattern = new RegExp(`^${regexParts.join(\"\")}$`);\n inst._zod.parse = (payload, _ctx) => {\n if (typeof payload.value !== \"string\") {\n payload.issues.push({\n input: payload.value,\n inst,\n expected: \"string\",\n code: \"invalid_type\",\n });\n return payload;\n }\n inst._zod.pattern.lastIndex = 0;\n if (!inst._zod.pattern.test(payload.value)) {\n payload.issues.push({\n input: payload.value,\n inst,\n code: \"invalid_format\",\n format: def.format ?? \"template_literal\",\n pattern: inst._zod.pattern.source,\n });\n return payload;\n }\n return payload;\n };\n});\nexport const $ZodFunction = /*@__PURE__*/ core.$constructor(\"$ZodFunction\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._def = def;\n inst._zod.def = def;\n inst.implement = (func) => {\n if (typeof func !== \"function\") {\n throw new Error(\"implement() must be called with a function\");\n }\n return function (...args) {\n const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;\n const result = Reflect.apply(func, this, parsedArgs);\n if (inst._def.output) {\n return parse(inst._def.output, result);\n }\n return result;\n };\n };\n inst.implementAsync = (func) => {\n if (typeof func !== \"function\") {\n throw new Error(\"implementAsync() must be called with a function\");\n }\n return async function (...args) {\n const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;\n const result = await Reflect.apply(func, this, parsedArgs);\n if (inst._def.output) {\n return await parseAsync(inst._def.output, result);\n }\n return result;\n };\n };\n inst._zod.parse = (payload, _ctx) => {\n if (typeof payload.value !== \"function\") {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"function\",\n input: payload.value,\n inst,\n });\n return payload;\n }\n // Check if output is a promise type to determine if we should use async implementation\n const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === \"promise\";\n if (hasPromiseOutput) {\n payload.value = inst.implementAsync(payload.value);\n }\n else {\n payload.value = inst.implement(payload.value);\n }\n return payload;\n };\n inst.input = (...args) => {\n const F = inst.constructor;\n if (Array.isArray(args[0])) {\n return new F({\n type: \"function\",\n input: new $ZodTuple({\n type: \"tuple\",\n items: args[0],\n rest: args[1],\n }),\n output: inst._def.output,\n });\n }\n return new F({\n type: \"function\",\n input: args[0],\n output: inst._def.output,\n });\n };\n inst.output = (output) => {\n const F = inst.constructor;\n return new F({\n type: \"function\",\n input: inst._def.input,\n output,\n });\n };\n return inst;\n});\nexport const $ZodPromise = /*@__PURE__*/ core.$constructor(\"$ZodPromise\", (inst, def) => {\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, ctx) => {\n return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));\n };\n});\nexport const $ZodLazy = /*@__PURE__*/ core.$constructor(\"$ZodLazy\", (inst, def) => {\n $ZodType.init(inst, def);\n // let _innerType!: any;\n // util.defineLazy(def, \"getter\", () => {\n // if (!_innerType) {\n // _innerType = def.getter();\n // }\n // return () => _innerType;\n // });\n util.defineLazy(inst._zod, \"innerType\", () => def.getter());\n util.defineLazy(inst._zod, \"pattern\", () => inst._zod.innerType?._zod?.pattern);\n util.defineLazy(inst._zod, \"propValues\", () => inst._zod.innerType?._zod?.propValues);\n util.defineLazy(inst._zod, \"optin\", () => inst._zod.innerType?._zod?.optin ?? undefined);\n util.defineLazy(inst._zod, \"optout\", () => inst._zod.innerType?._zod?.optout ?? undefined);\n inst._zod.parse = (payload, ctx) => {\n const inner = inst._zod.innerType;\n return inner._zod.run(payload, ctx);\n };\n});\nexport const $ZodCustom = /*@__PURE__*/ core.$constructor(\"$ZodCustom\", (inst, def) => {\n checks.$ZodCheck.init(inst, def);\n $ZodType.init(inst, def);\n inst._zod.parse = (payload, _) => {\n return payload;\n };\n inst._zod.check = (payload) => {\n const input = payload.value;\n const r = def.fn(input);\n if (r instanceof Promise) {\n return r.then((r) => handleRefineResult(r, payload, input, inst));\n }\n handleRefineResult(r, payload, input, inst);\n return;\n };\n});\nfunction handleRefineResult(result, payload, input, inst) {\n if (!result) {\n const _iss = {\n code: \"custom\",\n input,\n inst, // incorporates params.error into issue reporting\n path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting\n continue: !inst._zod.def.abort,\n // params: inst._zod.def.params,\n };\n if (inst._zod.def.params)\n _iss.params = inst._zod.def.params;\n payload.issues.push(util.issue(_iss));\n }\n}\n","var _a;\nexport const $output = Symbol(\"ZodOutput\");\nexport const $input = Symbol(\"ZodInput\");\nexport class $ZodRegistry {\n constructor() {\n this._map = new WeakMap();\n this._idmap = new Map();\n }\n add(schema, ..._meta) {\n const meta = _meta[0];\n this._map.set(schema, meta);\n if (meta && typeof meta === \"object\" && \"id\" in meta) {\n this._idmap.set(meta.id, schema);\n }\n return this;\n }\n clear() {\n this._map = new WeakMap();\n this._idmap = new Map();\n return this;\n }\n remove(schema) {\n const meta = this._map.get(schema);\n if (meta && typeof meta === \"object\" && \"id\" in meta) {\n this._idmap.delete(meta.id);\n }\n this._map.delete(schema);\n return this;\n }\n get(schema) {\n // return this._map.get(schema) as any;\n // inherit metadata\n const p = schema._zod.parent;\n if (p) {\n const pm = { ...(this.get(p) ?? {}) };\n delete pm.id; // do not inherit id\n const f = { ...pm, ...this._map.get(schema) };\n return Object.keys(f).length ? f : undefined;\n }\n return this._map.get(schema);\n }\n has(schema) {\n return this._map.has(schema);\n }\n}\n// registries\nexport function registry() {\n return new $ZodRegistry();\n}\n(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());\nexport const globalRegistry = globalThis.__zod_globalRegistry;\n","import * as checks from \"./checks.js\";\nimport * as registries from \"./registries.js\";\nimport * as schemas from \"./schemas.js\";\nimport * as util from \"./util.js\";\n// @__NO_SIDE_EFFECTS__\nexport function _string(Class, params) {\n return new Class({\n type: \"string\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedString(Class, params) {\n return new Class({\n type: \"string\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _email(Class, params) {\n return new Class({\n type: \"string\",\n format: \"email\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _guid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"guid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuidv4(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n version: \"v4\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuidv6(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n version: \"v6\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuidv7(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n version: \"v7\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _url(Class, params) {\n return new Class({\n type: \"string\",\n format: \"url\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _emoji(Class, params) {\n return new Class({\n type: \"string\",\n format: \"emoji\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nanoid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"nanoid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cuid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cuid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cuid2(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cuid2\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ulid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ulid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _xid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"xid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ksuid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ksuid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ipv4(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ipv4\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ipv6(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ipv6\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _mac(Class, params) {\n return new Class({\n type: \"string\",\n format: \"mac\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cidrv4(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cidrv4\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cidrv6(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cidrv6\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _base64(Class, params) {\n return new Class({\n type: \"string\",\n format: \"base64\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _base64url(Class, params) {\n return new Class({\n type: \"string\",\n format: \"base64url\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _e164(Class, params) {\n return new Class({\n type: \"string\",\n format: \"e164\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _jwt(Class, params) {\n return new Class({\n type: \"string\",\n format: \"jwt\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\nexport const TimePrecision = {\n Any: null,\n Minute: -1,\n Second: 0,\n Millisecond: 3,\n Microsecond: 6,\n};\n// @__NO_SIDE_EFFECTS__\nexport function _isoDateTime(Class, params) {\n return new Class({\n type: \"string\",\n format: \"datetime\",\n check: \"string_format\",\n offset: false,\n local: false,\n precision: null,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _isoDate(Class, params) {\n return new Class({\n type: \"string\",\n format: \"date\",\n check: \"string_format\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _isoTime(Class, params) {\n return new Class({\n type: \"string\",\n format: \"time\",\n check: \"string_format\",\n precision: null,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _isoDuration(Class, params) {\n return new Class({\n type: \"string\",\n format: \"duration\",\n check: \"string_format\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _number(Class, params) {\n return new Class({\n type: \"number\",\n checks: [],\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedNumber(Class, params) {\n return new Class({\n type: \"number\",\n coerce: true,\n checks: [],\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _int(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"safeint\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _float32(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"float32\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _float64(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"float64\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _int32(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"int32\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uint32(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"uint32\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _boolean(Class, params) {\n return new Class({\n type: \"boolean\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedBoolean(Class, params) {\n return new Class({\n type: \"boolean\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _bigint(Class, params) {\n return new Class({\n type: \"bigint\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedBigint(Class, params) {\n return new Class({\n type: \"bigint\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _int64(Class, params) {\n return new Class({\n type: \"bigint\",\n check: \"bigint_format\",\n abort: false,\n format: \"int64\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uint64(Class, params) {\n return new Class({\n type: \"bigint\",\n check: \"bigint_format\",\n abort: false,\n format: \"uint64\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _symbol(Class, params) {\n return new Class({\n type: \"symbol\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _undefined(Class, params) {\n return new Class({\n type: \"undefined\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _null(Class, params) {\n return new Class({\n type: \"null\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _any(Class) {\n return new Class({\n type: \"any\",\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _unknown(Class) {\n return new Class({\n type: \"unknown\",\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _never(Class, params) {\n return new Class({\n type: \"never\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _void(Class, params) {\n return new Class({\n type: \"void\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _date(Class, params) {\n return new Class({\n type: \"date\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedDate(Class, params) {\n return new Class({\n type: \"date\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nan(Class, params) {\n return new Class({\n type: \"nan\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lt(value, params) {\n return new checks.$ZodCheckLessThan({\n check: \"less_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: false,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lte(value, params) {\n return new checks.$ZodCheckLessThan({\n check: \"less_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: true,\n });\n}\nexport { \n/** @deprecated Use `z.lte()` instead. */\n_lte as _max, };\n// @__NO_SIDE_EFFECTS__\nexport function _gt(value, params) {\n return new checks.$ZodCheckGreaterThan({\n check: \"greater_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: false,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _gte(value, params) {\n return new checks.$ZodCheckGreaterThan({\n check: \"greater_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: true,\n });\n}\nexport { \n/** @deprecated Use `z.gte()` instead. */\n_gte as _min, };\n// @__NO_SIDE_EFFECTS__\nexport function _positive(params) {\n return _gt(0, params);\n}\n// negative\n// @__NO_SIDE_EFFECTS__\nexport function _negative(params) {\n return _lt(0, params);\n}\n// nonpositive\n// @__NO_SIDE_EFFECTS__\nexport function _nonpositive(params) {\n return _lte(0, params);\n}\n// nonnegative\n// @__NO_SIDE_EFFECTS__\nexport function _nonnegative(params) {\n return _gte(0, params);\n}\n// @__NO_SIDE_EFFECTS__\nexport function _multipleOf(value, params) {\n return new checks.$ZodCheckMultipleOf({\n check: \"multiple_of\",\n ...util.normalizeParams(params),\n value,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _maxSize(maximum, params) {\n return new checks.$ZodCheckMaxSize({\n check: \"max_size\",\n ...util.normalizeParams(params),\n maximum,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _minSize(minimum, params) {\n return new checks.$ZodCheckMinSize({\n check: \"min_size\",\n ...util.normalizeParams(params),\n minimum,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _size(size, params) {\n return new checks.$ZodCheckSizeEquals({\n check: \"size_equals\",\n ...util.normalizeParams(params),\n size,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _maxLength(maximum, params) {\n const ch = new checks.$ZodCheckMaxLength({\n check: \"max_length\",\n ...util.normalizeParams(params),\n maximum,\n });\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _minLength(minimum, params) {\n return new checks.$ZodCheckMinLength({\n check: \"min_length\",\n ...util.normalizeParams(params),\n minimum,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _length(length, params) {\n return new checks.$ZodCheckLengthEquals({\n check: \"length_equals\",\n ...util.normalizeParams(params),\n length,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _regex(pattern, params) {\n return new checks.$ZodCheckRegex({\n check: \"string_format\",\n format: \"regex\",\n ...util.normalizeParams(params),\n pattern,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lowercase(params) {\n return new checks.$ZodCheckLowerCase({\n check: \"string_format\",\n format: \"lowercase\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uppercase(params) {\n return new checks.$ZodCheckUpperCase({\n check: \"string_format\",\n format: \"uppercase\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _includes(includes, params) {\n return new checks.$ZodCheckIncludes({\n check: \"string_format\",\n format: \"includes\",\n ...util.normalizeParams(params),\n includes,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _startsWith(prefix, params) {\n return new checks.$ZodCheckStartsWith({\n check: \"string_format\",\n format: \"starts_with\",\n ...util.normalizeParams(params),\n prefix,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _endsWith(suffix, params) {\n return new checks.$ZodCheckEndsWith({\n check: \"string_format\",\n format: \"ends_with\",\n ...util.normalizeParams(params),\n suffix,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _property(property, schema, params) {\n return new checks.$ZodCheckProperty({\n check: \"property\",\n property,\n schema,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _mime(types, params) {\n return new checks.$ZodCheckMimeType({\n check: \"mime_type\",\n mime: types,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _overwrite(tx) {\n return new checks.$ZodCheckOverwrite({\n check: \"overwrite\",\n tx,\n });\n}\n// normalize\n// @__NO_SIDE_EFFECTS__\nexport function _normalize(form) {\n return _overwrite((input) => input.normalize(form));\n}\n// trim\n// @__NO_SIDE_EFFECTS__\nexport function _trim() {\n return _overwrite((input) => input.trim());\n}\n// toLowerCase\n// @__NO_SIDE_EFFECTS__\nexport function _toLowerCase() {\n return _overwrite((input) => input.toLowerCase());\n}\n// toUpperCase\n// @__NO_SIDE_EFFECTS__\nexport function _toUpperCase() {\n return _overwrite((input) => input.toUpperCase());\n}\n// slugify\n// @__NO_SIDE_EFFECTS__\nexport function _slugify() {\n return _overwrite((input) => util.slugify(input));\n}\n// @__NO_SIDE_EFFECTS__\nexport function _array(Class, element, params) {\n return new Class({\n type: \"array\",\n element,\n // get element() {\n // return element;\n // },\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _union(Class, options, params) {\n return new Class({\n type: \"union\",\n options,\n ...util.normalizeParams(params),\n });\n}\nexport function _xor(Class, options, params) {\n return new Class({\n type: \"union\",\n options,\n inclusive: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _discriminatedUnion(Class, discriminator, options, params) {\n return new Class({\n type: \"union\",\n options,\n discriminator,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _intersection(Class, left, right) {\n return new Class({\n type: \"intersection\",\n left,\n right,\n });\n}\n// export function _tuple(\n// Class: util.SchemaClass<schemas.$ZodTuple>,\n// items: [],\n// params?: string | $ZodTupleParams\n// ): schemas.$ZodTuple<[], null>;\n// @__NO_SIDE_EFFECTS__\nexport function _tuple(Class, items, _paramsOrRest, _params) {\n const hasRest = _paramsOrRest instanceof schemas.$ZodType;\n const params = hasRest ? _params : _paramsOrRest;\n const rest = hasRest ? _paramsOrRest : null;\n return new Class({\n type: \"tuple\",\n items,\n rest,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _record(Class, keyType, valueType, params) {\n return new Class({\n type: \"record\",\n keyType,\n valueType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _map(Class, keyType, valueType, params) {\n return new Class({\n type: \"map\",\n keyType,\n valueType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _set(Class, valueType, params) {\n return new Class({\n type: \"set\",\n valueType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _enum(Class, values, params) {\n const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;\n // if (Array.isArray(values)) {\n // for (const value of values) {\n // entries[value] = value;\n // }\n // } else {\n // Object.assign(entries, values);\n // }\n // const entries: util.EnumLike = {};\n // for (const val of values) {\n // entries[val] = val;\n // }\n return new Class({\n type: \"enum\",\n entries,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\n/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.\n *\n * ```ts\n * enum Colors { red, green, blue }\n * z.enum(Colors);\n * ```\n */\nexport function _nativeEnum(Class, entries, params) {\n return new Class({\n type: \"enum\",\n entries,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _literal(Class, value, params) {\n return new Class({\n type: \"literal\",\n values: Array.isArray(value) ? value : [value],\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _file(Class, params) {\n return new Class({\n type: \"file\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _transform(Class, fn) {\n return new Class({\n type: \"transform\",\n transform: fn,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _optional(Class, innerType) {\n return new Class({\n type: \"optional\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nullable(Class, innerType) {\n return new Class({\n type: \"nullable\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _default(Class, innerType, defaultValue) {\n return new Class({\n type: \"default\",\n innerType,\n get defaultValue() {\n return typeof defaultValue === \"function\" ? defaultValue() : util.shallowClone(defaultValue);\n },\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nonoptional(Class, innerType, params) {\n return new Class({\n type: \"nonoptional\",\n innerType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _success(Class, innerType) {\n return new Class({\n type: \"success\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _catch(Class, innerType, catchValue) {\n return new Class({\n type: \"catch\",\n innerType,\n catchValue: (typeof catchValue === \"function\" ? catchValue : () => catchValue),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _pipe(Class, in_, out) {\n return new Class({\n type: \"pipe\",\n in: in_,\n out,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _readonly(Class, innerType) {\n return new Class({\n type: \"readonly\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _templateLiteral(Class, parts, params) {\n return new Class({\n type: \"template_literal\",\n parts,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lazy(Class, getter) {\n return new Class({\n type: \"lazy\",\n getter,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _promise(Class, innerType) {\n return new Class({\n type: \"promise\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _custom(Class, fn, _params) {\n const norm = util.normalizeParams(_params);\n norm.abort ?? (norm.abort = true); // default to abort:false\n const schema = new Class({\n type: \"custom\",\n check: \"custom\",\n fn: fn,\n ...norm,\n });\n return schema;\n}\n// same as _custom but defaults to abort:false\n// @__NO_SIDE_EFFECTS__\nexport function _refine(Class, fn, _params) {\n const schema = new Class({\n type: \"custom\",\n check: \"custom\",\n fn: fn,\n ...util.normalizeParams(_params),\n });\n return schema;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _superRefine(fn) {\n const ch = _check((payload) => {\n payload.addIssue = (issue) => {\n if (typeof issue === \"string\") {\n payload.issues.push(util.issue(issue, payload.value, ch._zod.def));\n }\n else {\n // for Zod 3 backwards compatibility\n const _issue = issue;\n if (_issue.fatal)\n _issue.continue = false;\n _issue.code ?? (_issue.code = \"custom\");\n _issue.input ?? (_issue.input = payload.value);\n _issue.inst ?? (_issue.inst = ch);\n _issue.continue ?? (_issue.continue = !ch._zod.def.abort); // abort is always undefined, so this is always true...\n payload.issues.push(util.issue(_issue));\n }\n };\n return fn(payload.value, payload);\n });\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _check(fn, params) {\n const ch = new checks.$ZodCheck({\n check: \"custom\",\n ...util.normalizeParams(params),\n });\n ch._zod.check = fn;\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function describe(description) {\n const ch = new checks.$ZodCheck({ check: \"describe\" });\n ch._zod.onattach = [\n (inst) => {\n const existing = registries.globalRegistry.get(inst) ?? {};\n registries.globalRegistry.add(inst, { ...existing, description });\n },\n ];\n ch._zod.check = () => { }; // no-op check\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function meta(metadata) {\n const ch = new checks.$ZodCheck({ check: \"meta\" });\n ch._zod.onattach = [\n (inst) => {\n const existing = registries.globalRegistry.get(inst) ?? {};\n registries.globalRegistry.add(inst, { ...existing, ...metadata });\n },\n ];\n ch._zod.check = () => { }; // no-op check\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _stringbool(Classes, _params) {\n const params = util.normalizeParams(_params);\n let truthyArray = params.truthy ?? [\"true\", \"1\", \"yes\", \"on\", \"y\", \"enabled\"];\n let falsyArray = params.falsy ?? [\"false\", \"0\", \"no\", \"off\", \"n\", \"disabled\"];\n if (params.case !== \"sensitive\") {\n truthyArray = truthyArray.map((v) => (typeof v === \"string\" ? v.toLowerCase() : v));\n falsyArray = falsyArray.map((v) => (typeof v === \"string\" ? v.toLowerCase() : v));\n }\n const truthySet = new Set(truthyArray);\n const falsySet = new Set(falsyArray);\n const _Codec = Classes.Codec ?? schemas.$ZodCodec;\n const _Boolean = Classes.Boolean ?? schemas.$ZodBoolean;\n const _String = Classes.String ?? schemas.$ZodString;\n const stringSchema = new _String({ type: \"string\", error: params.error });\n const booleanSchema = new _Boolean({ type: \"boolean\", error: params.error });\n const codec = new _Codec({\n type: \"pipe\",\n in: stringSchema,\n out: booleanSchema,\n transform: ((input, payload) => {\n let data = input;\n if (params.case !== \"sensitive\")\n data = data.toLowerCase();\n if (truthySet.has(data)) {\n return true;\n }\n else if (falsySet.has(data)) {\n return false;\n }\n else {\n payload.issues.push({\n code: \"invalid_value\",\n expected: \"stringbool\",\n values: [...truthySet, ...falsySet],\n input: payload.value,\n inst: codec,\n continue: false,\n });\n return {};\n }\n }),\n reverseTransform: ((input, _payload) => {\n if (input === true) {\n return truthyArray[0] || \"true\";\n }\n else {\n return falsyArray[0] || \"false\";\n }\n }),\n error: params.error,\n });\n return codec;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _stringFormat(Class, format, fnOrRegex, _params = {}) {\n const params = util.normalizeParams(_params);\n const def = {\n ...util.normalizeParams(_params),\n check: \"string_format\",\n type: \"string\",\n format,\n fn: typeof fnOrRegex === \"function\" ? fnOrRegex : (val) => fnOrRegex.test(val),\n ...params,\n };\n if (fnOrRegex instanceof RegExp) {\n def.pattern = fnOrRegex;\n }\n const inst = new Class(def);\n return inst;\n}\n","import { globalRegistry } from \"./registries.js\";\n// function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {\n// return {\n// processor: inputs.processor,\n// metadataRegistry: inputs.metadata ?? globalRegistry,\n// target: inputs.target ?? \"draft-2020-12\",\n// unrepresentable: inputs.unrepresentable ?? \"throw\",\n// };\n// }\nexport function initializeContext(params) {\n // Normalize target: convert old non-hyphenated versions to hyphenated versions\n let target = params?.target ?? \"draft-2020-12\";\n if (target === \"draft-4\")\n target = \"draft-04\";\n if (target === \"draft-7\")\n target = \"draft-07\";\n return {\n processors: params.processors ?? {},\n metadataRegistry: params?.metadata ?? globalRegistry,\n target,\n unrepresentable: params?.unrepresentable ?? \"throw\",\n override: params?.override ?? (() => { }),\n io: params?.io ?? \"output\",\n counter: 0,\n seen: new Map(),\n cycles: params?.cycles ?? \"ref\",\n reused: params?.reused ?? \"inline\",\n external: params?.external ?? undefined,\n };\n}\nexport function process(schema, ctx, _params = { path: [], schemaPath: [] }) {\n var _a;\n const def = schema._zod.def;\n // check for schema in seens\n const seen = ctx.seen.get(schema);\n if (seen) {\n seen.count++;\n // check if cycle\n const isCycle = _params.schemaPath.includes(schema);\n if (isCycle) {\n seen.cycle = _params.path;\n }\n return seen.schema;\n }\n // initialize\n const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };\n ctx.seen.set(schema, result);\n // custom method overrides default behavior\n const overrideSchema = schema._zod.toJSONSchema?.();\n if (overrideSchema) {\n result.schema = overrideSchema;\n }\n else {\n const params = {\n ..._params,\n schemaPath: [..._params.schemaPath, schema],\n path: _params.path,\n };\n if (schema._zod.processJSONSchema) {\n schema._zod.processJSONSchema(ctx, result.schema, params);\n }\n else {\n const _json = result.schema;\n const processor = ctx.processors[def.type];\n if (!processor) {\n throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);\n }\n processor(schema, ctx, _json, params);\n }\n const parent = schema._zod.parent;\n if (parent) {\n // Also set ref if processor didn't (for inheritance)\n if (!result.ref)\n result.ref = parent;\n process(parent, ctx, params);\n ctx.seen.get(parent).isParent = true;\n }\n }\n // metadata\n const meta = ctx.metadataRegistry.get(schema);\n if (meta)\n Object.assign(result.schema, meta);\n if (ctx.io === \"input\" && isTransforming(schema)) {\n // examples/defaults only apply to output type of pipe\n delete result.schema.examples;\n delete result.schema.default;\n }\n // set prefault as default\n if (ctx.io === \"input\" && result.schema._prefault)\n (_a = result.schema).default ?? (_a.default = result.schema._prefault);\n delete result.schema._prefault;\n // pulling fresh from ctx.seen in case it was overwritten\n const _result = ctx.seen.get(schema);\n return _result.schema;\n}\nexport function extractDefs(ctx, schema\n// params: EmitParams\n) {\n // iterate over seen map;\n const root = ctx.seen.get(schema);\n if (!root)\n throw new Error(\"Unprocessed schema. This is a bug in Zod.\");\n // Track ids to detect duplicates across different schemas\n const idToSchema = new Map();\n for (const entry of ctx.seen.entries()) {\n const id = ctx.metadataRegistry.get(entry[0])?.id;\n if (id) {\n const existing = idToSchema.get(id);\n if (existing && existing !== entry[0]) {\n throw new Error(`Duplicate schema id \"${id}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);\n }\n idToSchema.set(id, entry[0]);\n }\n }\n // returns a ref to the schema\n // defId will be empty if the ref points to an external schema (or #)\n const makeURI = (entry) => {\n // comparing the seen objects because sometimes\n // multiple schemas map to the same seen object.\n // e.g. lazy\n // external is configured\n const defsSegment = ctx.target === \"draft-2020-12\" ? \"$defs\" : \"definitions\";\n if (ctx.external) {\n const externalId = ctx.external.registry.get(entry[0])?.id; // ?? \"__shared\";// `__schema${ctx.counter++}`;\n // check if schema is in the external registry\n const uriGenerator = ctx.external.uri ?? ((id) => id);\n if (externalId) {\n return { ref: uriGenerator(externalId) };\n }\n // otherwise, add to __shared\n const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;\n entry[1].defId = id; // set defId so it will be reused if needed\n return { defId: id, ref: `${uriGenerator(\"__shared\")}#/${defsSegment}/${id}` };\n }\n if (entry[1] === root) {\n return { ref: \"#\" };\n }\n // self-contained schema\n const uriPrefix = `#`;\n const defUriPrefix = `${uriPrefix}/${defsSegment}/`;\n const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;\n return { defId, ref: defUriPrefix + defId };\n };\n // stored cached version in `def` property\n // remove all properties, set $ref\n const extractToDef = (entry) => {\n // if the schema is already a reference, do not extract it\n if (entry[1].schema.$ref) {\n return;\n }\n const seen = entry[1];\n const { ref, defId } = makeURI(entry);\n seen.def = { ...seen.schema };\n // defId won't be set if the schema is a reference to an external schema\n // or if the schema is the root schema\n if (defId)\n seen.defId = defId;\n // wipe away all properties except $ref\n const schema = seen.schema;\n for (const key in schema) {\n delete schema[key];\n }\n schema.$ref = ref;\n };\n // throw on cycles\n // break cycles\n if (ctx.cycles === \"throw\") {\n for (const entry of ctx.seen.entries()) {\n const seen = entry[1];\n if (seen.cycle) {\n throw new Error(\"Cycle detected: \" +\n `#/${seen.cycle?.join(\"/\")}/<root>` +\n '\\n\\nSet the `cycles` parameter to `\"ref\"` to resolve cyclical schemas with defs.');\n }\n }\n }\n // extract schemas into $defs\n for (const entry of ctx.seen.entries()) {\n const seen = entry[1];\n // convert root schema to # $ref\n if (schema === entry[0]) {\n extractToDef(entry); // this has special handling for the root schema\n continue;\n }\n // extract schemas that are in the external registry\n if (ctx.external) {\n const ext = ctx.external.registry.get(entry[0])?.id;\n if (schema !== entry[0] && ext) {\n extractToDef(entry);\n continue;\n }\n }\n // extract schemas with `id` meta\n const id = ctx.metadataRegistry.get(entry[0])?.id;\n if (id) {\n extractToDef(entry);\n continue;\n }\n // break cycles\n if (seen.cycle) {\n // any\n extractToDef(entry);\n continue;\n }\n // extract reused schemas\n if (seen.count > 1) {\n if (ctx.reused === \"ref\") {\n extractToDef(entry);\n // biome-ignore lint:\n continue;\n }\n }\n }\n}\nexport function finalize(ctx, schema) {\n const root = ctx.seen.get(schema);\n if (!root)\n throw new Error(\"Unprocessed schema. This is a bug in Zod.\");\n // flatten refs - inherit properties from parent schemas\n const flattenRef = (zodSchema) => {\n const seen = ctx.seen.get(zodSchema);\n // already processed\n if (seen.ref === null)\n return;\n const schema = seen.def ?? seen.schema;\n const _cached = { ...schema };\n const ref = seen.ref;\n seen.ref = null; // prevent infinite recursion\n if (ref) {\n flattenRef(ref);\n const refSeen = ctx.seen.get(ref);\n const refSchema = refSeen.schema;\n // merge referenced schema into current\n if (refSchema.$ref && (ctx.target === \"draft-07\" || ctx.target === \"draft-04\" || ctx.target === \"openapi-3.0\")) {\n // older drafts can't combine $ref with other properties\n schema.allOf = schema.allOf ?? [];\n schema.allOf.push(refSchema);\n }\n else {\n Object.assign(schema, refSchema);\n }\n // restore child's own properties (child wins)\n Object.assign(schema, _cached);\n const isParentRef = zodSchema._zod.parent === ref;\n // For parent chain, child is a refinement - remove parent-only properties\n if (isParentRef) {\n for (const key in schema) {\n if (key === \"$ref\" || key === \"allOf\")\n continue;\n if (!(key in _cached)) {\n delete schema[key];\n }\n }\n }\n // When ref was extracted to $defs, remove properties that match the definition\n if (refSchema.$ref && refSeen.def) {\n for (const key in schema) {\n if (key === \"$ref\" || key === \"allOf\")\n continue;\n if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {\n delete schema[key];\n }\n }\n }\n }\n // If parent was extracted (has $ref), propagate $ref to this schema\n // This handles cases like: readonly().meta({id}).describe()\n // where processor sets ref to innerType but parent should be referenced\n const parent = zodSchema._zod.parent;\n if (parent && parent !== ref) {\n // Ensure parent is processed first so its def has inherited properties\n flattenRef(parent);\n const parentSeen = ctx.seen.get(parent);\n if (parentSeen?.schema.$ref) {\n schema.$ref = parentSeen.schema.$ref;\n // De-duplicate with parent's definition\n if (parentSeen.def) {\n for (const key in schema) {\n if (key === \"$ref\" || key === \"allOf\")\n continue;\n if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {\n delete schema[key];\n }\n }\n }\n }\n }\n // execute overrides\n ctx.override({\n zodSchema: zodSchema,\n jsonSchema: schema,\n path: seen.path ?? [],\n });\n };\n for (const entry of [...ctx.seen.entries()].reverse()) {\n flattenRef(entry[0]);\n }\n const result = {};\n if (ctx.target === \"draft-2020-12\") {\n result.$schema = \"https://json-schema.org/draft/2020-12/schema\";\n }\n else if (ctx.target === \"draft-07\") {\n result.$schema = \"http://json-schema.org/draft-07/schema#\";\n }\n else if (ctx.target === \"draft-04\") {\n result.$schema = \"http://json-schema.org/draft-04/schema#\";\n }\n else if (ctx.target === \"openapi-3.0\") {\n // OpenAPI 3.0 schema objects should not include a $schema property\n }\n else {\n // Arbitrary string values are allowed but won't have a $schema property set\n }\n if (ctx.external?.uri) {\n const id = ctx.external.registry.get(schema)?.id;\n if (!id)\n throw new Error(\"Schema is missing an `id` property\");\n result.$id = ctx.external.uri(id);\n }\n Object.assign(result, root.def ?? root.schema);\n // build defs object\n const defs = ctx.external?.defs ?? {};\n for (const entry of ctx.seen.entries()) {\n const seen = entry[1];\n if (seen.def && seen.defId) {\n defs[seen.defId] = seen.def;\n }\n }\n // set definitions in result\n if (ctx.external) {\n }\n else {\n if (Object.keys(defs).length > 0) {\n if (ctx.target === \"draft-2020-12\") {\n result.$defs = defs;\n }\n else {\n result.definitions = defs;\n }\n }\n }\n try {\n // this \"finalizes\" this schema and ensures all cycles are removed\n // each call to finalize() is functionally independent\n // though the seen map is shared\n const finalized = JSON.parse(JSON.stringify(result));\n Object.defineProperty(finalized, \"~standard\", {\n value: {\n ...schema[\"~standard\"],\n jsonSchema: {\n input: createStandardJSONSchemaMethod(schema, \"input\", ctx.processors),\n output: createStandardJSONSchemaMethod(schema, \"output\", ctx.processors),\n },\n },\n enumerable: false,\n writable: false,\n });\n return finalized;\n }\n catch (_err) {\n throw new Error(\"Error converting schema to JSON.\");\n }\n}\nfunction isTransforming(_schema, _ctx) {\n const ctx = _ctx ?? { seen: new Set() };\n if (ctx.seen.has(_schema))\n return false;\n ctx.seen.add(_schema);\n const def = _schema._zod.def;\n if (def.type === \"transform\")\n return true;\n if (def.type === \"array\")\n return isTransforming(def.element, ctx);\n if (def.type === \"set\")\n return isTransforming(def.valueType, ctx);\n if (def.type === \"lazy\")\n return isTransforming(def.getter(), ctx);\n if (def.type === \"promise\" ||\n def.type === \"optional\" ||\n def.type === \"nonoptional\" ||\n def.type === \"nullable\" ||\n def.type === \"readonly\" ||\n def.type === \"default\" ||\n def.type === \"prefault\") {\n return isTransforming(def.innerType, ctx);\n }\n if (def.type === \"intersection\") {\n return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);\n }\n if (def.type === \"record\" || def.type === \"map\") {\n return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);\n }\n if (def.type === \"pipe\") {\n return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);\n }\n if (def.type === \"object\") {\n for (const key in def.shape) {\n if (isTransforming(def.shape[key], ctx))\n return true;\n }\n return false;\n }\n if (def.type === \"union\") {\n for (const option of def.options) {\n if (isTransforming(option, ctx))\n return true;\n }\n return false;\n }\n if (def.type === \"tuple\") {\n for (const item of def.items) {\n if (isTransforming(item, ctx))\n return true;\n }\n if (def.rest && isTransforming(def.rest, ctx))\n return true;\n return false;\n }\n return false;\n}\n/**\n * Creates a toJSONSchema method for a schema instance.\n * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.\n */\nexport const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {\n const ctx = initializeContext({ ...params, processors });\n process(schema, ctx);\n extractDefs(ctx, schema);\n return finalize(ctx, schema);\n};\nexport const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {\n const { libraryOptions, target } = params ?? {};\n const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });\n process(schema, ctx);\n extractDefs(ctx, schema);\n return finalize(ctx, schema);\n};\n","import { extractDefs, finalize, initializeContext, process, } from \"./to-json-schema.js\";\nimport { getEnumValues } from \"./util.js\";\nconst formatMap = {\n guid: \"uuid\",\n url: \"uri\",\n datetime: \"date-time\",\n json_string: \"json-string\",\n regex: \"\", // do not set\n};\n// ==================== SIMPLE TYPE PROCESSORS ====================\nexport const stringProcessor = (schema, ctx, _json, _params) => {\n const json = _json;\n json.type = \"string\";\n const { minimum, maximum, format, patterns, contentEncoding } = schema._zod\n .bag;\n if (typeof minimum === \"number\")\n json.minLength = minimum;\n if (typeof maximum === \"number\")\n json.maxLength = maximum;\n // custom pattern overrides format\n if (format) {\n json.format = formatMap[format] ?? format;\n if (json.format === \"\")\n delete json.format; // empty format is not valid\n // JSON Schema format: \"time\" requires a full time with offset or Z\n // z.iso.time() does not include timezone information, so format: \"time\" should never be used\n if (format === \"time\") {\n delete json.format;\n }\n }\n if (contentEncoding)\n json.contentEncoding = contentEncoding;\n if (patterns && patterns.size > 0) {\n const regexes = [...patterns];\n if (regexes.length === 1)\n json.pattern = regexes[0].source;\n else if (regexes.length > 1) {\n json.allOf = [\n ...regexes.map((regex) => ({\n ...(ctx.target === \"draft-07\" || ctx.target === \"draft-04\" || ctx.target === \"openapi-3.0\"\n ? { type: \"string\" }\n : {}),\n pattern: regex.source,\n })),\n ];\n }\n }\n};\nexport const numberProcessor = (schema, ctx, _json, _params) => {\n const json = _json;\n const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;\n if (typeof format === \"string\" && format.includes(\"int\"))\n json.type = \"integer\";\n else\n json.type = \"number\";\n if (typeof exclusiveMinimum === \"number\") {\n if (ctx.target === \"draft-04\" || ctx.target === \"openapi-3.0\") {\n json.minimum = exclusiveMinimum;\n json.exclusiveMinimum = true;\n }\n else {\n json.exclusiveMinimum = exclusiveMinimum;\n }\n }\n if (typeof minimum === \"number\") {\n json.minimum = minimum;\n if (typeof exclusiveMinimum === \"number\" && ctx.target !== \"draft-04\") {\n if (exclusiveMinimum >= minimum)\n delete json.minimum;\n else\n delete json.exclusiveMinimum;\n }\n }\n if (typeof exclusiveMaximum === \"number\") {\n if (ctx.target === \"draft-04\" || ctx.target === \"openapi-3.0\") {\n json.maximum = exclusiveMaximum;\n json.exclusiveMaximum = true;\n }\n else {\n json.exclusiveMaximum = exclusiveMaximum;\n }\n }\n if (typeof maximum === \"number\") {\n json.maximum = maximum;\n if (typeof exclusiveMaximum === \"number\" && ctx.target !== \"draft-04\") {\n if (exclusiveMaximum <= maximum)\n delete json.maximum;\n else\n delete json.exclusiveMaximum;\n }\n }\n if (typeof multipleOf === \"number\")\n json.multipleOf = multipleOf;\n};\nexport const booleanProcessor = (_schema, _ctx, json, _params) => {\n json.type = \"boolean\";\n};\nexport const bigintProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"BigInt cannot be represented in JSON Schema\");\n }\n};\nexport const symbolProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Symbols cannot be represented in JSON Schema\");\n }\n};\nexport const nullProcessor = (_schema, ctx, json, _params) => {\n if (ctx.target === \"openapi-3.0\") {\n json.type = \"string\";\n json.nullable = true;\n json.enum = [null];\n }\n else {\n json.type = \"null\";\n }\n};\nexport const undefinedProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Undefined cannot be represented in JSON Schema\");\n }\n};\nexport const voidProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Void cannot be represented in JSON Schema\");\n }\n};\nexport const neverProcessor = (_schema, _ctx, json, _params) => {\n json.not = {};\n};\nexport const anyProcessor = (_schema, _ctx, _json, _params) => {\n // empty schema accepts anything\n};\nexport const unknownProcessor = (_schema, _ctx, _json, _params) => {\n // empty schema accepts anything\n};\nexport const dateProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Date cannot be represented in JSON Schema\");\n }\n};\nexport const enumProcessor = (schema, _ctx, json, _params) => {\n const def = schema._zod.def;\n const values = getEnumValues(def.entries);\n // Number enums can have both string and number values\n if (values.every((v) => typeof v === \"number\"))\n json.type = \"number\";\n if (values.every((v) => typeof v === \"string\"))\n json.type = \"string\";\n json.enum = values;\n};\nexport const literalProcessor = (schema, ctx, json, _params) => {\n const def = schema._zod.def;\n const vals = [];\n for (const val of def.values) {\n if (val === undefined) {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Literal `undefined` cannot be represented in JSON Schema\");\n }\n else {\n // do not add to vals\n }\n }\n else if (typeof val === \"bigint\") {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"BigInt literals cannot be represented in JSON Schema\");\n }\n else {\n vals.push(Number(val));\n }\n }\n else {\n vals.push(val);\n }\n }\n if (vals.length === 0) {\n // do nothing (an undefined literal was stripped)\n }\n else if (vals.length === 1) {\n const val = vals[0];\n json.type = val === null ? \"null\" : typeof val;\n if (ctx.target === \"draft-04\" || ctx.target === \"openapi-3.0\") {\n json.enum = [val];\n }\n else {\n json.const = val;\n }\n }\n else {\n if (vals.every((v) => typeof v === \"number\"))\n json.type = \"number\";\n if (vals.every((v) => typeof v === \"string\"))\n json.type = \"string\";\n if (vals.every((v) => typeof v === \"boolean\"))\n json.type = \"boolean\";\n if (vals.every((v) => v === null))\n json.type = \"null\";\n json.enum = vals;\n }\n};\nexport const nanProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"NaN cannot be represented in JSON Schema\");\n }\n};\nexport const templateLiteralProcessor = (schema, _ctx, json, _params) => {\n const _json = json;\n const pattern = schema._zod.pattern;\n if (!pattern)\n throw new Error(\"Pattern not found in template literal\");\n _json.type = \"string\";\n _json.pattern = pattern.source;\n};\nexport const fileProcessor = (schema, _ctx, json, _params) => {\n const _json = json;\n const file = {\n type: \"string\",\n format: \"binary\",\n contentEncoding: \"binary\",\n };\n const { minimum, maximum, mime } = schema._zod.bag;\n if (minimum !== undefined)\n file.minLength = minimum;\n if (maximum !== undefined)\n file.maxLength = maximum;\n if (mime) {\n if (mime.length === 1) {\n file.contentMediaType = mime[0];\n Object.assign(_json, file);\n }\n else {\n Object.assign(_json, file); // shared props at root\n _json.anyOf = mime.map((m) => ({ contentMediaType: m })); // only contentMediaType differs\n }\n }\n else {\n Object.assign(_json, file);\n }\n};\nexport const successProcessor = (_schema, _ctx, json, _params) => {\n json.type = \"boolean\";\n};\nexport const customProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Custom types cannot be represented in JSON Schema\");\n }\n};\nexport const functionProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Function types cannot be represented in JSON Schema\");\n }\n};\nexport const transformProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Transforms cannot be represented in JSON Schema\");\n }\n};\nexport const mapProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Map cannot be represented in JSON Schema\");\n }\n};\nexport const setProcessor = (_schema, ctx, _json, _params) => {\n if (ctx.unrepresentable === \"throw\") {\n throw new Error(\"Set cannot be represented in JSON Schema\");\n }\n};\n// ==================== COMPOSITE TYPE PROCESSORS ====================\nexport const arrayProcessor = (schema, ctx, _json, params) => {\n const json = _json;\n const def = schema._zod.def;\n const { minimum, maximum } = schema._zod.bag;\n if (typeof minimum === \"number\")\n json.minItems = minimum;\n if (typeof maximum === \"number\")\n json.maxItems = maximum;\n json.type = \"array\";\n json.items = process(def.element, ctx, { ...params, path: [...params.path, \"items\"] });\n};\nexport const objectProcessor = (schema, ctx, _json, params) => {\n const json = _json;\n const def = schema._zod.def;\n json.type = \"object\";\n json.properties = {};\n const shape = def.shape;\n for (const key in shape) {\n json.properties[key] = process(shape[key], ctx, {\n ...params,\n path: [...params.path, \"properties\", key],\n });\n }\n // required keys\n const allKeys = new Set(Object.keys(shape));\n const requiredKeys = new Set([...allKeys].filter((key) => {\n const v = def.shape[key]._zod;\n if (ctx.io === \"input\") {\n return v.optin === undefined;\n }\n else {\n return v.optout === undefined;\n }\n }));\n if (requiredKeys.size > 0) {\n json.required = Array.from(requiredKeys);\n }\n // catchall\n if (def.catchall?._zod.def.type === \"never\") {\n // strict\n json.additionalProperties = false;\n }\n else if (!def.catchall) {\n // regular\n if (ctx.io === \"output\")\n json.additionalProperties = false;\n }\n else if (def.catchall) {\n json.additionalProperties = process(def.catchall, ctx, {\n ...params,\n path: [...params.path, \"additionalProperties\"],\n });\n }\n};\nexport const unionProcessor = (schema, ctx, json, params) => {\n const def = schema._zod.def;\n // Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches)\n // This includes both z.xor() and discriminated unions\n const isExclusive = def.inclusive === false;\n const options = def.options.map((x, i) => process(x, ctx, {\n ...params,\n path: [...params.path, isExclusive ? \"oneOf\" : \"anyOf\", i],\n }));\n if (isExclusive) {\n json.oneOf = options;\n }\n else {\n json.anyOf = options;\n }\n};\nexport const intersectionProcessor = (schema, ctx, json, params) => {\n const def = schema._zod.def;\n const a = process(def.left, ctx, {\n ...params,\n path: [...params.path, \"allOf\", 0],\n });\n const b = process(def.right, ctx, {\n ...params,\n path: [...params.path, \"allOf\", 1],\n });\n const isSimpleIntersection = (val) => \"allOf\" in val && Object.keys(val).length === 1;\n const allOf = [\n ...(isSimpleIntersection(a) ? a.allOf : [a]),\n ...(isSimpleIntersection(b) ? b.allOf : [b]),\n ];\n json.allOf = allOf;\n};\nexport const tupleProcessor = (schema, ctx, _json, params) => {\n const json = _json;\n const def = schema._zod.def;\n json.type = \"array\";\n const prefixPath = ctx.target === \"draft-2020-12\" ? \"prefixItems\" : \"items\";\n const restPath = ctx.target === \"draft-2020-12\" ? \"items\" : ctx.target === \"openapi-3.0\" ? \"items\" : \"additionalItems\";\n const prefixItems = def.items.map((x, i) => process(x, ctx, {\n ...params,\n path: [...params.path, prefixPath, i],\n }));\n const rest = def.rest\n ? process(def.rest, ctx, {\n ...params,\n path: [...params.path, restPath, ...(ctx.target === \"openapi-3.0\" ? [def.items.length] : [])],\n })\n : null;\n if (ctx.target === \"draft-2020-12\") {\n json.prefixItems = prefixItems;\n if (rest) {\n json.items = rest;\n }\n }\n else if (ctx.target === \"openapi-3.0\") {\n json.items = {\n anyOf: prefixItems,\n };\n if (rest) {\n json.items.anyOf.push(rest);\n }\n json.minItems = prefixItems.length;\n if (!rest) {\n json.maxItems = prefixItems.length;\n }\n }\n else {\n json.items = prefixItems;\n if (rest) {\n json.additionalItems = rest;\n }\n }\n // length\n const { minimum, maximum } = schema._zod.bag;\n if (typeof minimum === \"number\")\n json.minItems = minimum;\n if (typeof maximum === \"number\")\n json.maxItems = maximum;\n};\nexport const recordProcessor = (schema, ctx, _json, params) => {\n const json = _json;\n const def = schema._zod.def;\n json.type = \"object\";\n // For looseRecord with regex patterns, use patternProperties\n // This correctly represents \"only validate keys matching the pattern\" semantics\n // and composes well with allOf (intersections)\n const keyType = def.keyType;\n const keyBag = keyType._zod.bag;\n const patterns = keyBag?.patterns;\n if (def.mode === \"loose\" && patterns && patterns.size > 0) {\n // Use patternProperties for looseRecord with regex patterns\n const valueSchema = process(def.valueType, ctx, {\n ...params,\n path: [...params.path, \"patternProperties\", \"*\"],\n });\n json.patternProperties = {};\n for (const pattern of patterns) {\n json.patternProperties[pattern.source] = valueSchema;\n }\n }\n else {\n // Default behavior: use propertyNames + additionalProperties\n if (ctx.target === \"draft-07\" || ctx.target === \"draft-2020-12\") {\n json.propertyNames = process(def.keyType, ctx, {\n ...params,\n path: [...params.path, \"propertyNames\"],\n });\n }\n json.additionalProperties = process(def.valueType, ctx, {\n ...params,\n path: [...params.path, \"additionalProperties\"],\n });\n }\n // Add required for keys with discrete values (enum, literal, etc.)\n const keyValues = keyType._zod.values;\n if (keyValues) {\n const validKeyValues = [...keyValues].filter((v) => typeof v === \"string\" || typeof v === \"number\");\n if (validKeyValues.length > 0) {\n json.required = validKeyValues;\n }\n }\n};\nexport const nullableProcessor = (schema, ctx, json, params) => {\n const def = schema._zod.def;\n const inner = process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n if (ctx.target === \"openapi-3.0\") {\n seen.ref = def.innerType;\n json.nullable = true;\n }\n else {\n json.anyOf = [inner, { type: \"null\" }];\n }\n};\nexport const nonoptionalProcessor = (schema, ctx, _json, params) => {\n const def = schema._zod.def;\n process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = def.innerType;\n};\nexport const defaultProcessor = (schema, ctx, json, params) => {\n const def = schema._zod.def;\n process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = def.innerType;\n json.default = JSON.parse(JSON.stringify(def.defaultValue));\n};\nexport const prefaultProcessor = (schema, ctx, json, params) => {\n const def = schema._zod.def;\n process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = def.innerType;\n if (ctx.io === \"input\")\n json._prefault = JSON.parse(JSON.stringify(def.defaultValue));\n};\nexport const catchProcessor = (schema, ctx, json, params) => {\n const def = schema._zod.def;\n process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = def.innerType;\n let catchValue;\n try {\n catchValue = def.catchValue(undefined);\n }\n catch {\n throw new Error(\"Dynamic catch values are not supported in JSON Schema\");\n }\n json.default = catchValue;\n};\nexport const pipeProcessor = (schema, ctx, _json, params) => {\n const def = schema._zod.def;\n const innerType = ctx.io === \"input\" ? (def.in._zod.def.type === \"transform\" ? def.out : def.in) : def.out;\n process(innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = innerType;\n};\nexport const readonlyProcessor = (schema, ctx, json, params) => {\n const def = schema._zod.def;\n process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = def.innerType;\n json.readOnly = true;\n};\nexport const promiseProcessor = (schema, ctx, _json, params) => {\n const def = schema._zod.def;\n process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = def.innerType;\n};\nexport const optionalProcessor = (schema, ctx, _json, params) => {\n const def = schema._zod.def;\n process(def.innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = def.innerType;\n};\nexport const lazyProcessor = (schema, ctx, _json, params) => {\n const innerType = schema._zod.innerType;\n process(innerType, ctx, params);\n const seen = ctx.seen.get(schema);\n seen.ref = innerType;\n};\n// ==================== ALL PROCESSORS ====================\nexport const allProcessors = {\n string: stringProcessor,\n number: numberProcessor,\n boolean: booleanProcessor,\n bigint: bigintProcessor,\n symbol: symbolProcessor,\n null: nullProcessor,\n undefined: undefinedProcessor,\n void: voidProcessor,\n never: neverProcessor,\n any: anyProcessor,\n unknown: unknownProcessor,\n date: dateProcessor,\n enum: enumProcessor,\n literal: literalProcessor,\n nan: nanProcessor,\n template_literal: templateLiteralProcessor,\n file: fileProcessor,\n success: successProcessor,\n custom: customProcessor,\n function: functionProcessor,\n transform: transformProcessor,\n map: mapProcessor,\n set: setProcessor,\n array: arrayProcessor,\n object: objectProcessor,\n union: unionProcessor,\n intersection: intersectionProcessor,\n tuple: tupleProcessor,\n record: recordProcessor,\n nullable: nullableProcessor,\n nonoptional: nonoptionalProcessor,\n default: defaultProcessor,\n prefault: prefaultProcessor,\n catch: catchProcessor,\n pipe: pipeProcessor,\n readonly: readonlyProcessor,\n promise: promiseProcessor,\n optional: optionalProcessor,\n lazy: lazyProcessor,\n};\nexport function toJSONSchema(input, params) {\n if (\"_idmap\" in input) {\n // Registry case\n const registry = input;\n const ctx = initializeContext({ ...params, processors: allProcessors });\n const defs = {};\n // First pass: process all schemas to build the seen map\n for (const entry of registry._idmap.entries()) {\n const [_, schema] = entry;\n process(schema, ctx);\n }\n const schemas = {};\n const external = {\n registry,\n uri: params?.uri,\n defs,\n };\n // Update the context with external configuration\n ctx.external = external;\n // Second pass: emit each schema\n for (const entry of registry._idmap.entries()) {\n const [key, schema] = entry;\n extractDefs(ctx, schema);\n schemas[key] = finalize(ctx, schema);\n }\n if (Object.keys(defs).length > 0) {\n const defsSegment = ctx.target === \"draft-2020-12\" ? \"$defs\" : \"definitions\";\n schemas.__shared = {\n [defsSegment]: defs,\n };\n }\n return { schemas };\n }\n // Single schema case\n const ctx = initializeContext({ ...params, processors: allProcessors });\n process(input, ctx);\n extractDefs(ctx, input);\n return finalize(ctx, input);\n}\n","import * as core from \"../core/index.js\";\nimport * as schemas from \"./schemas.js\";\nexport const ZodISODateTime = /*@__PURE__*/ core.$constructor(\"ZodISODateTime\", (inst, def) => {\n core.$ZodISODateTime.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function datetime(params) {\n return core._isoDateTime(ZodISODateTime, params);\n}\nexport const ZodISODate = /*@__PURE__*/ core.$constructor(\"ZodISODate\", (inst, def) => {\n core.$ZodISODate.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function date(params) {\n return core._isoDate(ZodISODate, params);\n}\nexport const ZodISOTime = /*@__PURE__*/ core.$constructor(\"ZodISOTime\", (inst, def) => {\n core.$ZodISOTime.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function time(params) {\n return core._isoTime(ZodISOTime, params);\n}\nexport const ZodISODuration = /*@__PURE__*/ core.$constructor(\"ZodISODuration\", (inst, def) => {\n core.$ZodISODuration.init(inst, def);\n schemas.ZodStringFormat.init(inst, def);\n});\nexport function duration(params) {\n return core._isoDuration(ZodISODuration, params);\n}\n","import * as core from \"../core/index.js\";\nimport { $ZodError } from \"../core/index.js\";\nimport * as util from \"../core/util.js\";\nconst initializer = (inst, issues) => {\n $ZodError.init(inst, issues);\n inst.name = \"ZodError\";\n Object.defineProperties(inst, {\n format: {\n value: (mapper) => core.formatError(inst, mapper),\n // enumerable: false,\n },\n flatten: {\n value: (mapper) => core.flattenError(inst, mapper),\n // enumerable: false,\n },\n addIssue: {\n value: (issue) => {\n inst.issues.push(issue);\n inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);\n },\n // enumerable: false,\n },\n addIssues: {\n value: (issues) => {\n inst.issues.push(...issues);\n inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);\n },\n // enumerable: false,\n },\n isEmpty: {\n get() {\n return inst.issues.length === 0;\n },\n // enumerable: false,\n },\n });\n // Object.defineProperty(inst, \"isEmpty\", {\n // get() {\n // return inst.issues.length === 0;\n // },\n // });\n};\nexport const ZodError = core.$constructor(\"ZodError\", initializer);\nexport const ZodRealError = core.$constructor(\"ZodError\", initializer, {\n Parent: Error,\n});\n// /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */\n// export type ErrorMapCtx = core.$ZodErrorMapCtx;\n","import * as core from \"../core/index.js\";\nimport { ZodRealError } from \"./errors.js\";\nexport const parse = /* @__PURE__ */ core._parse(ZodRealError);\nexport const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);\nexport const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);\nexport const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);\n// Codec functions\nexport const encode = /* @__PURE__ */ core._encode(ZodRealError);\nexport const decode = /* @__PURE__ */ core._decode(ZodRealError);\nexport const encodeAsync = /* @__PURE__ */ core._encodeAsync(ZodRealError);\nexport const decodeAsync = /* @__PURE__ */ core._decodeAsync(ZodRealError);\nexport const safeEncode = /* @__PURE__ */ core._safeEncode(ZodRealError);\nexport const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);\nexport const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);\nexport const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);\n","import * as core from \"../core/index.js\";\nimport { util } from \"../core/index.js\";\nimport * as processors from \"../core/json-schema-processors.js\";\nimport { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from \"../core/to-json-schema.js\";\nimport * as checks from \"./checks.js\";\nimport * as iso from \"./iso.js\";\nimport * as parse from \"./parse.js\";\nexport const ZodType = /*@__PURE__*/ core.$constructor(\"ZodType\", (inst, def) => {\n core.$ZodType.init(inst, def);\n Object.assign(inst[\"~standard\"], {\n jsonSchema: {\n input: createStandardJSONSchemaMethod(inst, \"input\"),\n output: createStandardJSONSchemaMethod(inst, \"output\"),\n },\n });\n inst.toJSONSchema = createToJSONSchemaMethod(inst, {});\n inst.def = def;\n inst.type = def.type;\n Object.defineProperty(inst, \"_def\", { value: def });\n // base methods\n inst.check = (...checks) => {\n return inst.clone(util.mergeDefs(def, {\n checks: [\n ...(def.checks ?? []),\n ...checks.map((ch) => typeof ch === \"function\" ? { _zod: { check: ch, def: { check: \"custom\" }, onattach: [] } } : ch),\n ],\n }), {\n parent: true,\n });\n };\n inst.with = inst.check;\n inst.clone = (def, params) => core.clone(inst, def, params);\n inst.brand = () => inst;\n inst.register = ((reg, meta) => {\n reg.add(inst, meta);\n return inst;\n });\n // parsing\n inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });\n inst.safeParse = (data, params) => parse.safeParse(inst, data, params);\n inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });\n inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);\n inst.spa = inst.safeParseAsync;\n // encoding/decoding\n inst.encode = (data, params) => parse.encode(inst, data, params);\n inst.decode = (data, params) => parse.decode(inst, data, params);\n inst.encodeAsync = async (data, params) => parse.encodeAsync(inst, data, params);\n inst.decodeAsync = async (data, params) => parse.decodeAsync(inst, data, params);\n inst.safeEncode = (data, params) => parse.safeEncode(inst, data, params);\n inst.safeDecode = (data, params) => parse.safeDecode(inst, data, params);\n inst.safeEncodeAsync = async (data, params) => parse.safeEncodeAsync(inst, data, params);\n inst.safeDecodeAsync = async (data, params) => parse.safeDecodeAsync(inst, data, params);\n // refinements\n inst.refine = (check, params) => inst.check(refine(check, params));\n inst.superRefine = (refinement) => inst.check(superRefine(refinement));\n inst.overwrite = (fn) => inst.check(checks.overwrite(fn));\n // wrappers\n inst.optional = () => optional(inst);\n inst.exactOptional = () => exactOptional(inst);\n inst.nullable = () => nullable(inst);\n inst.nullish = () => optional(nullable(inst));\n inst.nonoptional = (params) => nonoptional(inst, params);\n inst.array = () => array(inst);\n inst.or = (arg) => union([inst, arg]);\n inst.and = (arg) => intersection(inst, arg);\n inst.transform = (tx) => pipe(inst, transform(tx));\n inst.default = (def) => _default(inst, def);\n inst.prefault = (def) => prefault(inst, def);\n // inst.coalesce = (def, params) => coalesce(inst, def, params);\n inst.catch = (params) => _catch(inst, params);\n inst.pipe = (target) => pipe(inst, target);\n inst.readonly = () => readonly(inst);\n // meta\n inst.describe = (description) => {\n const cl = inst.clone();\n core.globalRegistry.add(cl, { description });\n return cl;\n };\n Object.defineProperty(inst, \"description\", {\n get() {\n return core.globalRegistry.get(inst)?.description;\n },\n configurable: true,\n });\n inst.meta = (...args) => {\n if (args.length === 0) {\n return core.globalRegistry.get(inst);\n }\n const cl = inst.clone();\n core.globalRegistry.add(cl, args[0]);\n return cl;\n };\n // helpers\n inst.isOptional = () => inst.safeParse(undefined).success;\n inst.isNullable = () => inst.safeParse(null).success;\n inst.apply = (fn) => fn(inst);\n return inst;\n});\n/** @internal */\nexport const _ZodString = /*@__PURE__*/ core.$constructor(\"_ZodString\", (inst, def) => {\n core.$ZodString.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.stringProcessor(inst, ctx, json, params);\n const bag = inst._zod.bag;\n inst.format = bag.format ?? null;\n inst.minLength = bag.minimum ?? null;\n inst.maxLength = bag.maximum ?? null;\n // validations\n inst.regex = (...args) => inst.check(checks.regex(...args));\n inst.includes = (...args) => inst.check(checks.includes(...args));\n inst.startsWith = (...args) => inst.check(checks.startsWith(...args));\n inst.endsWith = (...args) => inst.check(checks.endsWith(...args));\n inst.min = (...args) => inst.check(checks.minLength(...args));\n inst.max = (...args) => inst.check(checks.maxLength(...args));\n inst.length = (...args) => inst.check(checks.length(...args));\n inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));\n inst.lowercase = (params) => inst.check(checks.lowercase(params));\n inst.uppercase = (params) => inst.check(checks.uppercase(params));\n // transforms\n inst.trim = () => inst.check(checks.trim());\n inst.normalize = (...args) => inst.check(checks.normalize(...args));\n inst.toLowerCase = () => inst.check(checks.toLowerCase());\n inst.toUpperCase = () => inst.check(checks.toUpperCase());\n inst.slugify = () => inst.check(checks.slugify());\n});\nexport const ZodString = /*@__PURE__*/ core.$constructor(\"ZodString\", (inst, def) => {\n core.$ZodString.init(inst, def);\n _ZodString.init(inst, def);\n inst.email = (params) => inst.check(core._email(ZodEmail, params));\n inst.url = (params) => inst.check(core._url(ZodURL, params));\n inst.jwt = (params) => inst.check(core._jwt(ZodJWT, params));\n inst.emoji = (params) => inst.check(core._emoji(ZodEmoji, params));\n inst.guid = (params) => inst.check(core._guid(ZodGUID, params));\n inst.uuid = (params) => inst.check(core._uuid(ZodUUID, params));\n inst.uuidv4 = (params) => inst.check(core._uuidv4(ZodUUID, params));\n inst.uuidv6 = (params) => inst.check(core._uuidv6(ZodUUID, params));\n inst.uuidv7 = (params) => inst.check(core._uuidv7(ZodUUID, params));\n inst.nanoid = (params) => inst.check(core._nanoid(ZodNanoID, params));\n inst.guid = (params) => inst.check(core._guid(ZodGUID, params));\n inst.cuid = (params) => inst.check(core._cuid(ZodCUID, params));\n inst.cuid2 = (params) => inst.check(core._cuid2(ZodCUID2, params));\n inst.ulid = (params) => inst.check(core._ulid(ZodULID, params));\n inst.base64 = (params) => inst.check(core._base64(ZodBase64, params));\n inst.base64url = (params) => inst.check(core._base64url(ZodBase64URL, params));\n inst.xid = (params) => inst.check(core._xid(ZodXID, params));\n inst.ksuid = (params) => inst.check(core._ksuid(ZodKSUID, params));\n inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));\n inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));\n inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));\n inst.cidrv6 = (params) => inst.check(core._cidrv6(ZodCIDRv6, params));\n inst.e164 = (params) => inst.check(core._e164(ZodE164, params));\n // iso\n inst.datetime = (params) => inst.check(iso.datetime(params));\n inst.date = (params) => inst.check(iso.date(params));\n inst.time = (params) => inst.check(iso.time(params));\n inst.duration = (params) => inst.check(iso.duration(params));\n});\nexport function string(params) {\n return core._string(ZodString, params);\n}\nexport const ZodStringFormat = /*@__PURE__*/ core.$constructor(\"ZodStringFormat\", (inst, def) => {\n core.$ZodStringFormat.init(inst, def);\n _ZodString.init(inst, def);\n});\nexport const ZodEmail = /*@__PURE__*/ core.$constructor(\"ZodEmail\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodEmail.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function email(params) {\n return core._email(ZodEmail, params);\n}\nexport const ZodGUID = /*@__PURE__*/ core.$constructor(\"ZodGUID\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodGUID.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function guid(params) {\n return core._guid(ZodGUID, params);\n}\nexport const ZodUUID = /*@__PURE__*/ core.$constructor(\"ZodUUID\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodUUID.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function uuid(params) {\n return core._uuid(ZodUUID, params);\n}\nexport function uuidv4(params) {\n return core._uuidv4(ZodUUID, params);\n}\n// ZodUUIDv6\nexport function uuidv6(params) {\n return core._uuidv6(ZodUUID, params);\n}\n// ZodUUIDv7\nexport function uuidv7(params) {\n return core._uuidv7(ZodUUID, params);\n}\nexport const ZodURL = /*@__PURE__*/ core.$constructor(\"ZodURL\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodURL.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function url(params) {\n return core._url(ZodURL, params);\n}\nexport function httpUrl(params) {\n return core._url(ZodURL, {\n protocol: /^https?$/,\n hostname: core.regexes.domain,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodEmoji = /*@__PURE__*/ core.$constructor(\"ZodEmoji\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodEmoji.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function emoji(params) {\n return core._emoji(ZodEmoji, params);\n}\nexport const ZodNanoID = /*@__PURE__*/ core.$constructor(\"ZodNanoID\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodNanoID.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function nanoid(params) {\n return core._nanoid(ZodNanoID, params);\n}\nexport const ZodCUID = /*@__PURE__*/ core.$constructor(\"ZodCUID\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodCUID.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function cuid(params) {\n return core._cuid(ZodCUID, params);\n}\nexport const ZodCUID2 = /*@__PURE__*/ core.$constructor(\"ZodCUID2\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodCUID2.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function cuid2(params) {\n return core._cuid2(ZodCUID2, params);\n}\nexport const ZodULID = /*@__PURE__*/ core.$constructor(\"ZodULID\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodULID.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function ulid(params) {\n return core._ulid(ZodULID, params);\n}\nexport const ZodXID = /*@__PURE__*/ core.$constructor(\"ZodXID\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodXID.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function xid(params) {\n return core._xid(ZodXID, params);\n}\nexport const ZodKSUID = /*@__PURE__*/ core.$constructor(\"ZodKSUID\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodKSUID.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function ksuid(params) {\n return core._ksuid(ZodKSUID, params);\n}\nexport const ZodIPv4 = /*@__PURE__*/ core.$constructor(\"ZodIPv4\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodIPv4.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function ipv4(params) {\n return core._ipv4(ZodIPv4, params);\n}\nexport const ZodMAC = /*@__PURE__*/ core.$constructor(\"ZodMAC\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodMAC.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function mac(params) {\n return core._mac(ZodMAC, params);\n}\nexport const ZodIPv6 = /*@__PURE__*/ core.$constructor(\"ZodIPv6\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodIPv6.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function ipv6(params) {\n return core._ipv6(ZodIPv6, params);\n}\nexport const ZodCIDRv4 = /*@__PURE__*/ core.$constructor(\"ZodCIDRv4\", (inst, def) => {\n core.$ZodCIDRv4.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function cidrv4(params) {\n return core._cidrv4(ZodCIDRv4, params);\n}\nexport const ZodCIDRv6 = /*@__PURE__*/ core.$constructor(\"ZodCIDRv6\", (inst, def) => {\n core.$ZodCIDRv6.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function cidrv6(params) {\n return core._cidrv6(ZodCIDRv6, params);\n}\nexport const ZodBase64 = /*@__PURE__*/ core.$constructor(\"ZodBase64\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodBase64.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function base64(params) {\n return core._base64(ZodBase64, params);\n}\nexport const ZodBase64URL = /*@__PURE__*/ core.$constructor(\"ZodBase64URL\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodBase64URL.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function base64url(params) {\n return core._base64url(ZodBase64URL, params);\n}\nexport const ZodE164 = /*@__PURE__*/ core.$constructor(\"ZodE164\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodE164.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function e164(params) {\n return core._e164(ZodE164, params);\n}\nexport const ZodJWT = /*@__PURE__*/ core.$constructor(\"ZodJWT\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodJWT.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function jwt(params) {\n return core._jwt(ZodJWT, params);\n}\nexport const ZodCustomStringFormat = /*@__PURE__*/ core.$constructor(\"ZodCustomStringFormat\", (inst, def) => {\n // ZodStringFormat.init(inst, def);\n core.$ZodCustomStringFormat.init(inst, def);\n ZodStringFormat.init(inst, def);\n});\nexport function stringFormat(format, fnOrRegex, _params = {}) {\n return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);\n}\nexport function hostname(_params) {\n return core._stringFormat(ZodCustomStringFormat, \"hostname\", core.regexes.hostname, _params);\n}\nexport function hex(_params) {\n return core._stringFormat(ZodCustomStringFormat, \"hex\", core.regexes.hex, _params);\n}\nexport function hash(alg, params) {\n const enc = params?.enc ?? \"hex\";\n const format = `${alg}_${enc}`;\n const regex = core.regexes[format];\n if (!regex)\n throw new Error(`Unrecognized hash format: ${format}`);\n return core._stringFormat(ZodCustomStringFormat, format, regex, params);\n}\nexport const ZodNumber = /*@__PURE__*/ core.$constructor(\"ZodNumber\", (inst, def) => {\n core.$ZodNumber.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);\n inst.gt = (value, params) => inst.check(checks.gt(value, params));\n inst.gte = (value, params) => inst.check(checks.gte(value, params));\n inst.min = (value, params) => inst.check(checks.gte(value, params));\n inst.lt = (value, params) => inst.check(checks.lt(value, params));\n inst.lte = (value, params) => inst.check(checks.lte(value, params));\n inst.max = (value, params) => inst.check(checks.lte(value, params));\n inst.int = (params) => inst.check(int(params));\n inst.safe = (params) => inst.check(int(params));\n inst.positive = (params) => inst.check(checks.gt(0, params));\n inst.nonnegative = (params) => inst.check(checks.gte(0, params));\n inst.negative = (params) => inst.check(checks.lt(0, params));\n inst.nonpositive = (params) => inst.check(checks.lte(0, params));\n inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));\n inst.step = (value, params) => inst.check(checks.multipleOf(value, params));\n // inst.finite = (params) => inst.check(core.finite(params));\n inst.finite = () => inst;\n const bag = inst._zod.bag;\n inst.minValue =\n Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;\n inst.maxValue =\n Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;\n inst.isInt = (bag.format ?? \"\").includes(\"int\") || Number.isSafeInteger(bag.multipleOf ?? 0.5);\n inst.isFinite = true;\n inst.format = bag.format ?? null;\n});\nexport function number(params) {\n return core._number(ZodNumber, params);\n}\nexport const ZodNumberFormat = /*@__PURE__*/ core.$constructor(\"ZodNumberFormat\", (inst, def) => {\n core.$ZodNumberFormat.init(inst, def);\n ZodNumber.init(inst, def);\n});\nexport function int(params) {\n return core._int(ZodNumberFormat, params);\n}\nexport function float32(params) {\n return core._float32(ZodNumberFormat, params);\n}\nexport function float64(params) {\n return core._float64(ZodNumberFormat, params);\n}\nexport function int32(params) {\n return core._int32(ZodNumberFormat, params);\n}\nexport function uint32(params) {\n return core._uint32(ZodNumberFormat, params);\n}\nexport const ZodBoolean = /*@__PURE__*/ core.$constructor(\"ZodBoolean\", (inst, def) => {\n core.$ZodBoolean.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.booleanProcessor(inst, ctx, json, params);\n});\nexport function boolean(params) {\n return core._boolean(ZodBoolean, params);\n}\nexport const ZodBigInt = /*@__PURE__*/ core.$constructor(\"ZodBigInt\", (inst, def) => {\n core.$ZodBigInt.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);\n inst.gte = (value, params) => inst.check(checks.gte(value, params));\n inst.min = (value, params) => inst.check(checks.gte(value, params));\n inst.gt = (value, params) => inst.check(checks.gt(value, params));\n inst.gte = (value, params) => inst.check(checks.gte(value, params));\n inst.min = (value, params) => inst.check(checks.gte(value, params));\n inst.lt = (value, params) => inst.check(checks.lt(value, params));\n inst.lte = (value, params) => inst.check(checks.lte(value, params));\n inst.max = (value, params) => inst.check(checks.lte(value, params));\n inst.positive = (params) => inst.check(checks.gt(BigInt(0), params));\n inst.negative = (params) => inst.check(checks.lt(BigInt(0), params));\n inst.nonpositive = (params) => inst.check(checks.lte(BigInt(0), params));\n inst.nonnegative = (params) => inst.check(checks.gte(BigInt(0), params));\n inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));\n const bag = inst._zod.bag;\n inst.minValue = bag.minimum ?? null;\n inst.maxValue = bag.maximum ?? null;\n inst.format = bag.format ?? null;\n});\nexport function bigint(params) {\n return core._bigint(ZodBigInt, params);\n}\nexport const ZodBigIntFormat = /*@__PURE__*/ core.$constructor(\"ZodBigIntFormat\", (inst, def) => {\n core.$ZodBigIntFormat.init(inst, def);\n ZodBigInt.init(inst, def);\n});\n// int64\nexport function int64(params) {\n return core._int64(ZodBigIntFormat, params);\n}\n// uint64\nexport function uint64(params) {\n return core._uint64(ZodBigIntFormat, params);\n}\nexport const ZodSymbol = /*@__PURE__*/ core.$constructor(\"ZodSymbol\", (inst, def) => {\n core.$ZodSymbol.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.symbolProcessor(inst, ctx, json, params);\n});\nexport function symbol(params) {\n return core._symbol(ZodSymbol, params);\n}\nexport const ZodUndefined = /*@__PURE__*/ core.$constructor(\"ZodUndefined\", (inst, def) => {\n core.$ZodUndefined.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.undefinedProcessor(inst, ctx, json, params);\n});\nfunction _undefined(params) {\n return core._undefined(ZodUndefined, params);\n}\nexport { _undefined as undefined };\nexport const ZodNull = /*@__PURE__*/ core.$constructor(\"ZodNull\", (inst, def) => {\n core.$ZodNull.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.nullProcessor(inst, ctx, json, params);\n});\nfunction _null(params) {\n return core._null(ZodNull, params);\n}\nexport { _null as null };\nexport const ZodAny = /*@__PURE__*/ core.$constructor(\"ZodAny\", (inst, def) => {\n core.$ZodAny.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.anyProcessor(inst, ctx, json, params);\n});\nexport function any() {\n return core._any(ZodAny);\n}\nexport const ZodUnknown = /*@__PURE__*/ core.$constructor(\"ZodUnknown\", (inst, def) => {\n core.$ZodUnknown.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.unknownProcessor(inst, ctx, json, params);\n});\nexport function unknown() {\n return core._unknown(ZodUnknown);\n}\nexport const ZodNever = /*@__PURE__*/ core.$constructor(\"ZodNever\", (inst, def) => {\n core.$ZodNever.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.neverProcessor(inst, ctx, json, params);\n});\nexport function never(params) {\n return core._never(ZodNever, params);\n}\nexport const ZodVoid = /*@__PURE__*/ core.$constructor(\"ZodVoid\", (inst, def) => {\n core.$ZodVoid.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.voidProcessor(inst, ctx, json, params);\n});\nfunction _void(params) {\n return core._void(ZodVoid, params);\n}\nexport { _void as void };\nexport const ZodDate = /*@__PURE__*/ core.$constructor(\"ZodDate\", (inst, def) => {\n core.$ZodDate.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);\n inst.min = (value, params) => inst.check(checks.gte(value, params));\n inst.max = (value, params) => inst.check(checks.lte(value, params));\n const c = inst._zod.bag;\n inst.minDate = c.minimum ? new Date(c.minimum) : null;\n inst.maxDate = c.maximum ? new Date(c.maximum) : null;\n});\nexport function date(params) {\n return core._date(ZodDate, params);\n}\nexport const ZodArray = /*@__PURE__*/ core.$constructor(\"ZodArray\", (inst, def) => {\n core.$ZodArray.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.arrayProcessor(inst, ctx, json, params);\n inst.element = def.element;\n inst.min = (minLength, params) => inst.check(checks.minLength(minLength, params));\n inst.nonempty = (params) => inst.check(checks.minLength(1, params));\n inst.max = (maxLength, params) => inst.check(checks.maxLength(maxLength, params));\n inst.length = (len, params) => inst.check(checks.length(len, params));\n inst.unwrap = () => inst.element;\n});\nexport function array(element, params) {\n return core._array(ZodArray, element, params);\n}\n// .keyof\nexport function keyof(schema) {\n const shape = schema._zod.def.shape;\n return _enum(Object.keys(shape));\n}\nexport const ZodObject = /*@__PURE__*/ core.$constructor(\"ZodObject\", (inst, def) => {\n core.$ZodObjectJIT.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.objectProcessor(inst, ctx, json, params);\n util.defineLazy(inst, \"shape\", () => {\n return def.shape;\n });\n inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));\n inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });\n inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });\n inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });\n inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });\n inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });\n inst.extend = (incoming) => {\n return util.extend(inst, incoming);\n };\n inst.safeExtend = (incoming) => {\n return util.safeExtend(inst, incoming);\n };\n inst.merge = (other) => util.merge(inst, other);\n inst.pick = (mask) => util.pick(inst, mask);\n inst.omit = (mask) => util.omit(inst, mask);\n inst.partial = (...args) => util.partial(ZodOptional, inst, args[0]);\n inst.required = (...args) => util.required(ZodNonOptional, inst, args[0]);\n});\nexport function object(shape, params) {\n const def = {\n type: \"object\",\n shape: shape ?? {},\n ...util.normalizeParams(params),\n };\n return new ZodObject(def);\n}\n// strictObject\nexport function strictObject(shape, params) {\n return new ZodObject({\n type: \"object\",\n shape,\n catchall: never(),\n ...util.normalizeParams(params),\n });\n}\n// looseObject\nexport function looseObject(shape, params) {\n return new ZodObject({\n type: \"object\",\n shape,\n catchall: unknown(),\n ...util.normalizeParams(params),\n });\n}\nexport const ZodUnion = /*@__PURE__*/ core.$constructor(\"ZodUnion\", (inst, def) => {\n core.$ZodUnion.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.unionProcessor(inst, ctx, json, params);\n inst.options = def.options;\n});\nexport function union(options, params) {\n return new ZodUnion({\n type: \"union\",\n options: options,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodXor = /*@__PURE__*/ core.$constructor(\"ZodXor\", (inst, def) => {\n ZodUnion.init(inst, def);\n core.$ZodXor.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.unionProcessor(inst, ctx, json, params);\n inst.options = def.options;\n});\n/** Creates an exclusive union (XOR) where exactly one option must match.\n * Unlike regular unions that succeed when any option matches, xor fails if\n * zero or more than one option matches the input. */\nexport function xor(options, params) {\n return new ZodXor({\n type: \"union\",\n options: options,\n inclusive: false,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodDiscriminatedUnion = /*@__PURE__*/ core.$constructor(\"ZodDiscriminatedUnion\", (inst, def) => {\n ZodUnion.init(inst, def);\n core.$ZodDiscriminatedUnion.init(inst, def);\n});\nexport function discriminatedUnion(discriminator, options, params) {\n // const [options, params] = args;\n return new ZodDiscriminatedUnion({\n type: \"union\",\n options,\n discriminator,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodIntersection = /*@__PURE__*/ core.$constructor(\"ZodIntersection\", (inst, def) => {\n core.$ZodIntersection.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.intersectionProcessor(inst, ctx, json, params);\n});\nexport function intersection(left, right) {\n return new ZodIntersection({\n type: \"intersection\",\n left: left,\n right: right,\n });\n}\nexport const ZodTuple = /*@__PURE__*/ core.$constructor(\"ZodTuple\", (inst, def) => {\n core.$ZodTuple.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.tupleProcessor(inst, ctx, json, params);\n inst.rest = (rest) => inst.clone({\n ...inst._zod.def,\n rest: rest,\n });\n});\nexport function tuple(items, _paramsOrRest, _params) {\n const hasRest = _paramsOrRest instanceof core.$ZodType;\n const params = hasRest ? _params : _paramsOrRest;\n const rest = hasRest ? _paramsOrRest : null;\n return new ZodTuple({\n type: \"tuple\",\n items: items,\n rest,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodRecord = /*@__PURE__*/ core.$constructor(\"ZodRecord\", (inst, def) => {\n core.$ZodRecord.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.recordProcessor(inst, ctx, json, params);\n inst.keyType = def.keyType;\n inst.valueType = def.valueType;\n});\nexport function record(keyType, valueType, params) {\n return new ZodRecord({\n type: \"record\",\n keyType,\n valueType: valueType,\n ...util.normalizeParams(params),\n });\n}\n// type alksjf = core.output<core.$ZodRecordKey>;\nexport function partialRecord(keyType, valueType, params) {\n const k = core.clone(keyType);\n k._zod.values = undefined;\n return new ZodRecord({\n type: \"record\",\n keyType: k,\n valueType: valueType,\n ...util.normalizeParams(params),\n });\n}\nexport function looseRecord(keyType, valueType, params) {\n return new ZodRecord({\n type: \"record\",\n keyType,\n valueType: valueType,\n mode: \"loose\",\n ...util.normalizeParams(params),\n });\n}\nexport const ZodMap = /*@__PURE__*/ core.$constructor(\"ZodMap\", (inst, def) => {\n core.$ZodMap.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.mapProcessor(inst, ctx, json, params);\n inst.keyType = def.keyType;\n inst.valueType = def.valueType;\n inst.min = (...args) => inst.check(core._minSize(...args));\n inst.nonempty = (params) => inst.check(core._minSize(1, params));\n inst.max = (...args) => inst.check(core._maxSize(...args));\n inst.size = (...args) => inst.check(core._size(...args));\n});\nexport function map(keyType, valueType, params) {\n return new ZodMap({\n type: \"map\",\n keyType: keyType,\n valueType: valueType,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodSet = /*@__PURE__*/ core.$constructor(\"ZodSet\", (inst, def) => {\n core.$ZodSet.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.setProcessor(inst, ctx, json, params);\n inst.min = (...args) => inst.check(core._minSize(...args));\n inst.nonempty = (params) => inst.check(core._minSize(1, params));\n inst.max = (...args) => inst.check(core._maxSize(...args));\n inst.size = (...args) => inst.check(core._size(...args));\n});\nexport function set(valueType, params) {\n return new ZodSet({\n type: \"set\",\n valueType: valueType,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodEnum = /*@__PURE__*/ core.$constructor(\"ZodEnum\", (inst, def) => {\n core.$ZodEnum.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.enumProcessor(inst, ctx, json, params);\n inst.enum = def.entries;\n inst.options = Object.values(def.entries);\n const keys = new Set(Object.keys(def.entries));\n inst.extract = (values, params) => {\n const newEntries = {};\n for (const value of values) {\n if (keys.has(value)) {\n newEntries[value] = def.entries[value];\n }\n else\n throw new Error(`Key ${value} not found in enum`);\n }\n return new ZodEnum({\n ...def,\n checks: [],\n ...util.normalizeParams(params),\n entries: newEntries,\n });\n };\n inst.exclude = (values, params) => {\n const newEntries = { ...def.entries };\n for (const value of values) {\n if (keys.has(value)) {\n delete newEntries[value];\n }\n else\n throw new Error(`Key ${value} not found in enum`);\n }\n return new ZodEnum({\n ...def,\n checks: [],\n ...util.normalizeParams(params),\n entries: newEntries,\n });\n };\n});\nfunction _enum(values, params) {\n const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;\n return new ZodEnum({\n type: \"enum\",\n entries,\n ...util.normalizeParams(params),\n });\n}\nexport { _enum as enum };\n/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.\n *\n * ```ts\n * enum Colors { red, green, blue }\n * z.enum(Colors);\n * ```\n */\nexport function nativeEnum(entries, params) {\n return new ZodEnum({\n type: \"enum\",\n entries,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodLiteral = /*@__PURE__*/ core.$constructor(\"ZodLiteral\", (inst, def) => {\n core.$ZodLiteral.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.literalProcessor(inst, ctx, json, params);\n inst.values = new Set(def.values);\n Object.defineProperty(inst, \"value\", {\n get() {\n if (def.values.length > 1) {\n throw new Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");\n }\n return def.values[0];\n },\n });\n});\nexport function literal(value, params) {\n return new ZodLiteral({\n type: \"literal\",\n values: Array.isArray(value) ? value : [value],\n ...util.normalizeParams(params),\n });\n}\nexport const ZodFile = /*@__PURE__*/ core.$constructor(\"ZodFile\", (inst, def) => {\n core.$ZodFile.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.fileProcessor(inst, ctx, json, params);\n inst.min = (size, params) => inst.check(core._minSize(size, params));\n inst.max = (size, params) => inst.check(core._maxSize(size, params));\n inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));\n});\nexport function file(params) {\n return core._file(ZodFile, params);\n}\nexport const ZodTransform = /*@__PURE__*/ core.$constructor(\"ZodTransform\", (inst, def) => {\n core.$ZodTransform.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.transformProcessor(inst, ctx, json, params);\n inst._zod.parse = (payload, _ctx) => {\n if (_ctx.direction === \"backward\") {\n throw new core.$ZodEncodeError(inst.constructor.name);\n }\n payload.addIssue = (issue) => {\n if (typeof issue === \"string\") {\n payload.issues.push(util.issue(issue, payload.value, def));\n }\n else {\n // for Zod 3 backwards compatibility\n const _issue = issue;\n if (_issue.fatal)\n _issue.continue = false;\n _issue.code ?? (_issue.code = \"custom\");\n _issue.input ?? (_issue.input = payload.value);\n _issue.inst ?? (_issue.inst = inst);\n // _issue.continue ??= true;\n payload.issues.push(util.issue(_issue));\n }\n };\n const output = def.transform(payload.value, payload);\n if (output instanceof Promise) {\n return output.then((output) => {\n payload.value = output;\n return payload;\n });\n }\n payload.value = output;\n return payload;\n };\n});\nexport function transform(fn) {\n return new ZodTransform({\n type: \"transform\",\n transform: fn,\n });\n}\nexport const ZodOptional = /*@__PURE__*/ core.$constructor(\"ZodOptional\", (inst, def) => {\n core.$ZodOptional.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function optional(innerType) {\n return new ZodOptional({\n type: \"optional\",\n innerType: innerType,\n });\n}\nexport const ZodExactOptional = /*@__PURE__*/ core.$constructor(\"ZodExactOptional\", (inst, def) => {\n core.$ZodExactOptional.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function exactOptional(innerType) {\n return new ZodExactOptional({\n type: \"optional\",\n innerType: innerType,\n });\n}\nexport const ZodNullable = /*@__PURE__*/ core.$constructor(\"ZodNullable\", (inst, def) => {\n core.$ZodNullable.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.nullableProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function nullable(innerType) {\n return new ZodNullable({\n type: \"nullable\",\n innerType: innerType,\n });\n}\n// nullish\nexport function nullish(innerType) {\n return optional(nullable(innerType));\n}\nexport const ZodDefault = /*@__PURE__*/ core.$constructor(\"ZodDefault\", (inst, def) => {\n core.$ZodDefault.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.defaultProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n inst.removeDefault = inst.unwrap;\n});\nexport function _default(innerType, defaultValue) {\n return new ZodDefault({\n type: \"default\",\n innerType: innerType,\n get defaultValue() {\n return typeof defaultValue === \"function\" ? defaultValue() : util.shallowClone(defaultValue);\n },\n });\n}\nexport const ZodPrefault = /*@__PURE__*/ core.$constructor(\"ZodPrefault\", (inst, def) => {\n core.$ZodPrefault.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.prefaultProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function prefault(innerType, defaultValue) {\n return new ZodPrefault({\n type: \"prefault\",\n innerType: innerType,\n get defaultValue() {\n return typeof defaultValue === \"function\" ? defaultValue() : util.shallowClone(defaultValue);\n },\n });\n}\nexport const ZodNonOptional = /*@__PURE__*/ core.$constructor(\"ZodNonOptional\", (inst, def) => {\n core.$ZodNonOptional.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.nonoptionalProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function nonoptional(innerType, params) {\n return new ZodNonOptional({\n type: \"nonoptional\",\n innerType: innerType,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodSuccess = /*@__PURE__*/ core.$constructor(\"ZodSuccess\", (inst, def) => {\n core.$ZodSuccess.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.successProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function success(innerType) {\n return new ZodSuccess({\n type: \"success\",\n innerType: innerType,\n });\n}\nexport const ZodCatch = /*@__PURE__*/ core.$constructor(\"ZodCatch\", (inst, def) => {\n core.$ZodCatch.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.catchProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n inst.removeCatch = inst.unwrap;\n});\nfunction _catch(innerType, catchValue) {\n return new ZodCatch({\n type: \"catch\",\n innerType: innerType,\n catchValue: (typeof catchValue === \"function\" ? catchValue : () => catchValue),\n });\n}\nexport { _catch as catch };\nexport const ZodNaN = /*@__PURE__*/ core.$constructor(\"ZodNaN\", (inst, def) => {\n core.$ZodNaN.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.nanProcessor(inst, ctx, json, params);\n});\nexport function nan(params) {\n return core._nan(ZodNaN, params);\n}\nexport const ZodPipe = /*@__PURE__*/ core.$constructor(\"ZodPipe\", (inst, def) => {\n core.$ZodPipe.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.pipeProcessor(inst, ctx, json, params);\n inst.in = def.in;\n inst.out = def.out;\n});\nexport function pipe(in_, out) {\n return new ZodPipe({\n type: \"pipe\",\n in: in_,\n out: out,\n // ...util.normalizeParams(params),\n });\n}\nexport const ZodCodec = /*@__PURE__*/ core.$constructor(\"ZodCodec\", (inst, def) => {\n ZodPipe.init(inst, def);\n core.$ZodCodec.init(inst, def);\n});\nexport function codec(in_, out, params) {\n return new ZodCodec({\n type: \"pipe\",\n in: in_,\n out: out,\n transform: params.decode,\n reverseTransform: params.encode,\n });\n}\nexport const ZodReadonly = /*@__PURE__*/ core.$constructor(\"ZodReadonly\", (inst, def) => {\n core.$ZodReadonly.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.readonlyProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function readonly(innerType) {\n return new ZodReadonly({\n type: \"readonly\",\n innerType: innerType,\n });\n}\nexport const ZodTemplateLiteral = /*@__PURE__*/ core.$constructor(\"ZodTemplateLiteral\", (inst, def) => {\n core.$ZodTemplateLiteral.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.templateLiteralProcessor(inst, ctx, json, params);\n});\nexport function templateLiteral(parts, params) {\n return new ZodTemplateLiteral({\n type: \"template_literal\",\n parts,\n ...util.normalizeParams(params),\n });\n}\nexport const ZodLazy = /*@__PURE__*/ core.$constructor(\"ZodLazy\", (inst, def) => {\n core.$ZodLazy.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.lazyProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.getter();\n});\nexport function lazy(getter) {\n return new ZodLazy({\n type: \"lazy\",\n getter: getter,\n });\n}\nexport const ZodPromise = /*@__PURE__*/ core.$constructor(\"ZodPromise\", (inst, def) => {\n core.$ZodPromise.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.promiseProcessor(inst, ctx, json, params);\n inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function promise(innerType) {\n return new ZodPromise({\n type: \"promise\",\n innerType: innerType,\n });\n}\nexport const ZodFunction = /*@__PURE__*/ core.$constructor(\"ZodFunction\", (inst, def) => {\n core.$ZodFunction.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.functionProcessor(inst, ctx, json, params);\n});\nexport function _function(params) {\n return new ZodFunction({\n type: \"function\",\n input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),\n output: params?.output ?? unknown(),\n });\n}\nexport { _function as function };\nexport const ZodCustom = /*@__PURE__*/ core.$constructor(\"ZodCustom\", (inst, def) => {\n core.$ZodCustom.init(inst, def);\n ZodType.init(inst, def);\n inst._zod.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);\n});\n// custom checks\nexport function check(fn) {\n const ch = new core.$ZodCheck({\n check: \"custom\",\n // ...util.normalizeParams(params),\n });\n ch._zod.check = fn;\n return ch;\n}\nexport function custom(fn, _params) {\n return core._custom(ZodCustom, fn ?? (() => true), _params);\n}\nexport function refine(fn, _params = {}) {\n return core._refine(ZodCustom, fn, _params);\n}\n// superRefine\nexport function superRefine(fn) {\n return core._superRefine(fn);\n}\n// Re-export describe and meta from core\nexport const describe = core.describe;\nexport const meta = core.meta;\nfunction _instanceof(cls, params = {}) {\n const inst = new ZodCustom({\n type: \"custom\",\n check: \"custom\",\n fn: (data) => data instanceof cls,\n abort: true,\n ...util.normalizeParams(params),\n });\n inst._zod.bag.Class = cls;\n // Override check to emit invalid_type instead of custom\n inst._zod.check = (payload) => {\n if (!(payload.value instanceof cls)) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: cls.name,\n input: payload.value,\n inst,\n path: [...(inst._zod.def.path ?? [])],\n });\n }\n };\n return inst;\n}\nexport { _instanceof as instanceof };\n// stringbool\nexport const stringbool = (...args) => core._stringbool({\n Codec: ZodCodec,\n Boolean: ZodBoolean,\n String: ZodString,\n}, ...args);\nexport function json(params) {\n const jsonSchema = lazy(() => {\n return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);\n });\n return jsonSchema;\n}\n// preprocess\n// /** @deprecated Use `z.pipe()` and `z.transform()` instead. */\nexport function preprocess(fn, schema) {\n return pipe(transform(fn), schema);\n}\n","import * as core from \"../core/index.js\";\nimport * as schemas from \"./schemas.js\";\nexport function string(params) {\n return core._coercedString(schemas.ZodString, params);\n}\nexport function number(params) {\n return core._coercedNumber(schemas.ZodNumber, params);\n}\nexport function boolean(params) {\n return core._coercedBoolean(schemas.ZodBoolean, params);\n}\nexport function bigint(params) {\n return core._coercedBigint(schemas.ZodBigInt, params);\n}\nexport function date(params) {\n return core._coercedDate(schemas.ZodDate, params);\n}\n","import { t as __exportAll } from \"../chunk-DQk6qfdC.mjs\";\nimport { z } from \"zod\";\n\n//#region src/v1/entities.ts\nvar entities_exports = /* @__PURE__ */ __exportAll({\n\tentityResponse: () => entityResponse,\n\tlabel: () => label,\n\tlistEntitiesQuery: () => listEntitiesQuery,\n\tlistEntitiesResponse: () => listEntitiesResponse,\n\tupdateEntityBody: () => updateEntityBody\n});\n/**\n* Entities module Zod schemas and types.\n*\n* Provides team-scoped labels for entities (speaker fingerprints).\n* Labels allow teams to identify analyzed speakers with human-readable names.\n*/\n/**\n* Label validation schema.\n* - Max 64 characters\n* - Trimmed whitespace\n* - Free-form text (allows spaces, special characters)\n*/\nconst label = z.string().trim().min(1, \"Label must be at least 1 character\").max(64, \"Label must be at most 64 characters\");\n/**\n* Query parameters for listing entities.\n*/\nconst listEntitiesQuery = z.object({\n\tcursor: z.string().optional(),\n\tlimit: z.coerce.number().min(1).max(100).default(20)\n});\n/**\n* Request body for updating an entity (PATCH).\n*/\nconst updateEntityBody = z.object({ label: label.nullable().optional() });\n/**\n* Single entity response with label and metadata.\n*/\nconst entityResponse = z.object({\n\tid: z.string(),\n\tlabel: z.string().nullable(),\n\tcreatedAt: z.iso.datetime(),\n\tmediaCount: z.number(),\n\tlastSeenAt: z.iso.datetime().nullable()\n});\n/**\n* Paginated list of entities response.\n*/\nconst listEntitiesResponse = z.object({\n\tentities: z.array(entityResponse),\n\tcursor: z.string().nullable(),\n\thasMore: z.boolean()\n});\n\n//#endregion\nexport { entityResponse, label, listEntitiesQuery, listEntitiesResponse, entities_exports as t, updateEntityBody };\n//# sourceMappingURL=entities.mjs.map","import { MappaError } from \"../errors\";\n\ntype ParseResult<T> =\n\t| { success: true; data: T }\n\t| { success: false; error: unknown };\n\ntype Schema<T> = {\n\tsafeParse: (input: unknown) => ParseResult<T>;\n};\n\nfunction summarize(err: unknown): string {\n\tif (!err || typeof err !== \"object\") return \"unknown validation error\";\n\tif (!(\"issues\" in err) || !Array.isArray(err.issues)) {\n\t\treturn \"unknown validation error\";\n\t}\n\tconst items = err.issues\n\t\t.slice(0, 3)\n\t\t.map((issue) => {\n\t\t\tif (!issue || typeof issue !== \"object\") return \"invalid value\";\n\t\t\tconst path =\n\t\t\t\t\"path\" in issue && Array.isArray(issue.path) && issue.path.length > 0\n\t\t\t\t\t? issue.path.join(\".\")\n\t\t\t\t\t: \"root\";\n\t\t\tconst msg =\n\t\t\t\t\"message\" in issue && typeof issue.message === \"string\"\n\t\t\t\t\t? issue.message\n\t\t\t\t\t: \"invalid value\";\n\t\t\treturn `${path}: ${msg}`;\n\t\t})\n\t\t.join(\"; \");\n\treturn items || \"unknown validation error\";\n}\n\nexport function parseReq<T>(\n\tschema: Schema<T>,\n\tinput: unknown,\n\tname: string,\n): T {\n\tconst out = schema.safeParse(input);\n\tif (out.success) return out.data;\n\tthrow new MappaError(`Invalid ${name}: ${summarize(out.error)}`, {\n\t\tcause: out.error,\n\t});\n}\n\nexport function parseRes<T>(\n\tschema: Schema<T>,\n\tinput: unknown,\n\tname: string,\n): T {\n\tconst out = schema.safeParse(input);\n\tif (out.success) return out.data;\n\tthrow new MappaError(`Invalid ${name} response: ${summarize(out.error)}`, {\n\t\tcause: out.error,\n\t});\n}\n","import {\n\tentityResponse,\n\tlistEntitiesQuery,\n\tlistEntitiesResponse,\n\tupdateEntityBody,\n} from \"@mappa-ai/contracts/v1/entities\";\nimport { MappaError } from \"../errors\";\nimport type { Entity, ListEntitiesResponse } from \"../types\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nexport type ListEntitiesOptions = {\n\tlimit?: number;\n\tcursor?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport class EntitiesResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync get(\n\t\tentityId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Entity> {\n\t\tif (!entityId) throw new MappaError(\"entityId must be a non-empty string\");\n\t\tconst res = await this.transport.request<Entity>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(entityResponse, res.data, \"entities.get\");\n\t}\n\n\tasync list(opts?: ListEntitiesOptions): Promise<ListEntitiesResponse> {\n\t\tconst query = parseReq(\n\t\t\tlistEntitiesQuery,\n\t\t\t{ limit: opts?.limit, cursor: opts?.cursor },\n\t\t\t\"entities.list query\",\n\t\t);\n\n\t\tconst res = await this.transport.request<ListEntitiesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/entities\",\n\t\t\tquery: {\n\t\t\t\tlimit: String(query.limit),\n\t\t\t\t...(query.cursor ? { cursor: query.cursor } : {}),\n\t\t\t},\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(listEntitiesResponse, res.data, \"entities.list\");\n\t}\n\n\tasync *listAll(\n\t\topts?: Omit<ListEntitiesOptions, \"cursor\">,\n\t): AsyncIterable<Entity> {\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore = true;\n\t\twhile (hasMore) {\n\t\t\tconst page = await this.list({ ...opts, cursor });\n\t\t\tfor (const entity of page.entities) {\n\t\t\t\tyield entity;\n\t\t\t}\n\t\t\tcursor = page.cursor ?? undefined;\n\t\t\thasMore = page.hasMore;\n\t\t}\n\t}\n\n\tasync update(\n\t\tentityId: string,\n\t\tbody: { label?: string | null },\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Entity> {\n\t\tif (!entityId) throw new MappaError(\"entityId must be a non-empty string\");\n\t\tconst payload = parseReq(updateEntityBody, body, \"entities.update body\");\n\t\tconst res = await this.transport.request<Entity>({\n\t\t\tmethod: \"PATCH\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}`,\n\t\t\tbody: payload,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(entityResponse, res.data, \"entities.update\");\n\t}\n}\n","import { t as __exportAll } from \"../chunk-DQk6qfdC.mjs\";\nimport { z } from \"zod\";\n\n//#region src/v1/feedback.ts\nvar feedback_exports = /* @__PURE__ */ __exportAll({\n\tcorrectionItem: () => correctionItem,\n\tcreditDiscountInfo: () => creditDiscountInfo,\n\tfeedbackCreateBody: () => feedbackCreateBody,\n\tfeedbackReceipt: () => feedbackReceipt,\n\trating: () => rating\n});\n/**\n* Feedback module Zod schemas and types.\n*\n*/\n/**\n* Correction item for structured feedback\n*/\nconst correctionItem = z.object({\n\tpath: z.string(),\n\texpected: z.unknown().optional(),\n\tobserved: z.unknown().optional()\n});\n/**\n* Rating values - thumbs only for v1\n*/\nconst rating = z.enum([\"thumbs_up\", \"thumbs_down\"]);\n/**\n* Request body for POST /v1/feedback\n*/\nconst feedbackCreateBody = z.object({\n\treportId: z.string().optional(),\n\tjobId: z.string().optional(),\n\tmatchingAnalysisId: z.string().optional(),\n\trating,\n\tcomment: z.string().optional(),\n\tcorrections: z.array(correctionItem).optional(),\n\tidempotencyKey: z.string().optional()\n}).strict().refine((data) => [\n\tdata.reportId,\n\tdata.jobId,\n\tdata.matchingAnalysisId\n].filter(Boolean).length === 1, { message: \"Provide exactly one of reportId or jobId or matchingAnalysisId\" });\n/**\n* Credit discount info in feedback receipt\n*/\nconst creditDiscountInfo = z.object({\n\teligible: z.boolean(),\n\treason: z.string().optional(),\n\tdiscountApplied: z.number(),\n\tnetUsed: z.number()\n});\n/**\n* Response for POST /v1/feedback\n*/\nconst feedbackReceipt = z.object({\n\tid: z.string(),\n\tcreatedAt: z.string(),\n\ttarget: z.object({\n\t\treportId: z.string().optional(),\n\t\tjobId: z.string().optional(),\n\t\tmatchingAnalysisId: z.string().optional()\n\t}),\n\trating,\n\tcomment: z.string().optional(),\n\tcredits: creditDiscountInfo\n});\n\n//#endregion\nexport { correctionItem, creditDiscountInfo, feedbackCreateBody, feedbackReceipt, rating, feedback_exports as t };\n//# sourceMappingURL=feedback.mjs.map","import {\n\tfeedbackCreateBody,\n\tfeedbackReceipt,\n} from \"@mappa-ai/contracts/v1/feedback\";\nimport type { FeedbackCreateRequest, FeedbackReceipt } from \"../types\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nexport class FeedbackResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync create(req: FeedbackCreateRequest): Promise<FeedbackReceipt> {\n\t\tconst body = parseReq(\n\t\t\tfeedbackCreateBody,\n\t\t\t{\n\t\t\t\treportId: req.reportId,\n\t\t\t\tjobId: req.jobId,\n\t\t\t\tmatchingAnalysisId: req.matchingAnalysisId,\n\t\t\t\trating: req.rating,\n\t\t\t\tcomment: req.comment,\n\t\t\t\tcorrections: req.corrections,\n\t\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\t},\n\t\t\t\"feedback.create body\",\n\t\t);\n\n\t\tconst idempotencyKey = req.idempotencyKey;\n\t\tconst res = await this.transport.request<FeedbackReceipt>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/feedback\",\n\t\t\tbody,\n\t\t\tidempotencyKey,\n\t\t\trequestId: req.requestId,\n\t\t\tsignal: req.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\treturn parseRes(feedbackReceipt, res.data, \"feedback.create\");\n\t}\n}\n","import { t as __exportAll } from \"../chunk-DQk6qfdC.mjs\";\nimport { z } from \"zod\";\n\n//#region src/v1/files.ts\nvar files_exports = /* @__PURE__ */ __exportAll({\n\tdeleteResponse: () => deleteResponse,\n\tfileResponse: () => fileResponse,\n\tgoneError: () => goneError,\n\tlistFilesQuery: () => listFilesQuery,\n\tlistFilesResponse: () => listFilesResponse,\n\tnotFoundError: () => notFoundError,\n\tretentionInfo: () => retentionInfo,\n\tretentionUpdateBody: () => retentionUpdateBody,\n\tretentionUpdateResponse: () => retentionUpdateResponse,\n\tunsupportedMediaTypeError: () => unsupportedMediaTypeError,\n\tuploadResponse: () => uploadResponse\n});\nconst retentionInfo = z.object({\n\texpiresAt: z.iso.datetime().nullable().describe(\"When the file will expire (null if locked)\"),\n\tdaysRemaining: z.number().int().nullable().describe(\"Days until expiry (null if locked or deleted)\"),\n\tlocked: z.boolean().describe(\"Whether the file is locked from automatic deletion\")\n});\nconst retentionUpdateBody = z.object({ lock: z.boolean().describe(\"Set to true to lock, false to unlock\") });\nconst retentionUpdateResponse = z.object({\n\tmediaId: z.string(),\n\tretentionLock: z.boolean(),\n\tmessage: z.string()\n});\nconst uploadResponse = z.object({\n\tmediaId: z.string(),\n\tcreatedAt: z.string(),\n\tcontentType: z.string(),\n\tlabel: z.string().nullish(),\n\tsizeBytes: z.number().int().nullish(),\n\tdurationSeconds: z.number().nullish()\n});\nconst fileResponse = z.object({\n\tmediaId: z.string(),\n\tcreatedAt: z.iso.datetime(),\n\tcontentType: z.string(),\n\tlabel: z.string().nullish(),\n\tsizeBytes: z.number().int().nullish(),\n\tdurationSeconds: z.number().nullish(),\n\tprocessingStatus: z.enum([\n\t\t\"PENDING\",\n\t\t\"PROCESSING\",\n\t\t\"COMPLETED\",\n\t\t\"FAILED\"\n\t]),\n\tlastUsedAt: z.iso.datetime().nullable(),\n\tretention: retentionInfo\n});\nconst listFilesQuery = z.object({\n\tlimit: z.coerce.number().int().min(1).max(100).default(20),\n\tcursor: z.string().optional(),\n\tincludeDeleted: z.coerce.boolean().default(false)\n});\nconst listFilesResponse = z.object({\n\tfiles: z.array(fileResponse),\n\tnextCursor: z.string().nullable(),\n\thasMore: z.boolean()\n});\nconst deleteResponse = z.object({\n\tmediaId: z.string(),\n\tdeleted: z.literal(true)\n});\nconst goneError = z.object({\n\terror: z.literal(\"gone\"),\n\tmessage: z.string(),\n\tdeletedAt: z.iso.datetime(),\n\thardDeleteAt: z.iso.datetime()\n});\nconst notFoundError = z.object({ error: z.object({\n\tcode: z.literal(\"not_found\"),\n\tmessage: z.string()\n}) });\nconst unsupportedMediaTypeError = z.object({ error: z.object({\n\tcode: z.literal(\"unsupported_media_type\"),\n\tmessage: z.string()\n}) });\n\n//#endregion\nexport { deleteResponse, fileResponse, goneError, listFilesQuery, listFilesResponse, notFoundError, retentionInfo, retentionUpdateBody, retentionUpdateResponse, files_exports as t, unsupportedMediaTypeError, uploadResponse };\n//# sourceMappingURL=files.mjs.map","import {\n\tdeleteResponse,\n\tfileResponse,\n\tlistFilesQuery,\n\tlistFilesResponse,\n\tretentionUpdateResponse,\n\tuploadResponse,\n} from \"@mappa-ai/contracts/v1/files\";\nimport { MappaError } from \"../errors\";\nimport type {\n\tFileDeleteReceipt,\n\tListFilesResponse,\n\tMediaFile,\n\tMediaObject,\n\tRetentionLockResult,\n} from \"../types\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nexport type UploadRequest = {\n\tfile: Blob | ArrayBuffer | Uint8Array | ReadableStream<Uint8Array>;\n\tlabel?: string;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport type ListFilesOptions = {\n\tlimit?: number;\n\tcursor?: string;\n\tincludeDeleted?: boolean;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport class FilesResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync upload(req: UploadRequest): Promise<MediaObject> {\n\t\tif (typeof FormData === \"undefined\") {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"FormData is not available in this runtime; cannot perform multipart upload\",\n\t\t\t);\n\t\t}\n\n\t\tconst file = await toFormDataPart(req.file);\n\n\t\tconst form = new FormData();\n\t\tform.append(\"file\", file);\n\t\tif (req.label) form.append(\"label\", req.label);\n\n\t\tconst res = await this.transport.request<MediaObject>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/files\",\n\t\t\tbody: form,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\trequestId: req.requestId,\n\t\t\tsignal: req.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(uploadResponse, res.data, \"files.upload\");\n\t}\n\n\tasync get(\n\t\tmediaId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MediaFile> {\n\t\tif (!mediaId) throw new MappaError(\"mediaId is required\");\n\t\tconst res = await this.transport.request<MediaFile>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(fileResponse, res.data, \"files.get\");\n\t}\n\n\tasync list(opts?: ListFilesOptions): Promise<ListFilesResponse> {\n\t\tconst query = parseReq(\n\t\t\tlistFilesQuery,\n\t\t\t{\n\t\t\t\tlimit: opts?.limit,\n\t\t\t\tcursor: opts?.cursor,\n\t\t\t\tincludeDeleted: opts?.includeDeleted,\n\t\t\t},\n\t\t\t\"files.list query\",\n\t\t);\n\n\t\tconst res = await this.transport.request<ListFilesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/files\",\n\t\t\tquery: {\n\t\t\t\tlimit: String(query.limit),\n\t\t\t\t...(query.cursor ? { cursor: query.cursor } : {}),\n\t\t\t\tincludeDeleted: String(query.includeDeleted),\n\t\t\t},\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(listFilesResponse, res.data, \"files.list\");\n\t}\n\n\tasync *listAll(\n\t\topts?: Omit<ListFilesOptions, \"cursor\">,\n\t): AsyncIterable<MediaFile> {\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore = true;\n\t\twhile (hasMore) {\n\t\t\tconst page = await this.list({ ...opts, cursor });\n\t\t\tfor (const file of page.files) {\n\t\t\t\tyield file;\n\t\t\t}\n\t\t\tcursor = page.nextCursor ?? undefined;\n\t\t\thasMore = page.hasMore;\n\t\t}\n\t}\n\n\tasync setRetentionLock(\n\t\tmediaId: string,\n\t\tlocked: boolean,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<RetentionLockResult> {\n\t\tif (!mediaId) throw new MappaError(\"mediaId is required\");\n\t\tconst res = await this.transport.request<RetentionLockResult>({\n\t\t\tmethod: \"PATCH\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}/retention`,\n\t\t\tbody: { lock: locked },\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(\n\t\t\tretentionUpdateResponse,\n\t\t\tres.data,\n\t\t\t\"files.setRetentionLock\",\n\t\t);\n\t}\n\n\tasync delete(\n\t\tmediaId: string,\n\t\topts?: {\n\t\t\tidempotencyKey?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<FileDeleteReceipt> {\n\t\tif (!mediaId) throw new MappaError(\"mediaId is required\");\n\t\tconst res = await this.transport.request<FileDeleteReceipt>({\n\t\t\tmethod: \"DELETE\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}`,\n\t\t\tidempotencyKey: opts?.idempotencyKey,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(deleteResponse, res.data, \"files.delete\");\n\t}\n}\n\nasync function toFormDataPart(file: UploadRequest[\"file\"]): Promise<Blob> {\n\tif (typeof Blob !== \"undefined\" && file instanceof Blob) {\n\t\treturn file;\n\t}\n\n\tif (file instanceof ArrayBuffer) return new Blob([file]);\n\tif (file instanceof Uint8Array) {\n\t\tconst copy = new Uint8Array(file.byteLength);\n\t\tcopy.set(file);\n\t\treturn new Blob([copy]);\n\t}\n\n\tif (typeof ReadableStream !== \"undefined\" && file instanceof ReadableStream) {\n\t\tif (typeof Response === \"undefined\") {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"ReadableStream upload requires Response to convert stream to Blob\",\n\t\t\t);\n\t\t}\n\t\treturn new Response(file).blob();\n\t}\n\n\tthrow new MappaError(\"Unsupported file type for upload()\");\n}\n","import { t as __exportAll } from \"../chunk-DQk6qfdC.mjs\";\nimport { z } from \"zod\";\n\n//#region src/v1/health.ts\nvar health_exports = /* @__PURE__ */ __exportAll({ pingResponse: () => pingResponse });\n/**\n* Response schema for GET /v1/health/ping.\n*\n* Matches the SDK's expected `{ ok: true, time: string }` shape.\n*/\nconst pingResponse = z.object({\n\tok: z.literal(true),\n\ttime: z.string().describe(\"ISO 8601 timestamp of the server's current time\")\n});\n\n//#endregion\nexport { pingResponse, health_exports as t };\n//# sourceMappingURL=health.mjs.map","import { pingResponse } from \"@mappa-ai/contracts/v1/health\";\nimport type { Transport } from \"./transport\";\nimport { parseRes } from \"./validate\";\n\nexport class HealthResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync ping(): Promise<{ ok: true; time: string }> {\n\t\tconst res = await this.transport.request<{ ok: true; time: string }>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/health/ping\",\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(pingResponse, res.data, \"health.ping\");\n\t}\n}\n","import { t as __exportAll } from \"../chunk-DQk6qfdC.mjs\";\nimport { z } from \"zod\";\n\n//#region src/v1/jobs.ts\nvar jobs_exports = /* @__PURE__ */ __exportAll({\n\theartbeatStreamEvent: () => heartbeatStreamEvent,\n\tjobResponse: () => jobResponse,\n\tjobStage: () => jobStage,\n\tjobStatus: () => jobStatus,\n\tjobStreamEvent: () => jobStreamEvent,\n\tstageStreamEvent: () => stageStreamEvent,\n\tstatusStreamEvent: () => statusStreamEvent,\n\tstreamEventType: () => streamEventType,\n\tstreamQueryParams: () => streamQueryParams,\n\tterminalStreamEvent: () => terminalStreamEvent\n});\n/**\n* Job status values returned by the API.\n*/\nconst jobStatus = z.enum([\n\t\"queued\",\n\t\"running\",\n\t\"succeeded\",\n\t\"failed\",\n\t\"canceled\"\n]);\n/**\n* Job processing stages.\n*/\nconst jobStage = z.enum([\n\t\"uploaded\",\n\t\"queued\",\n\t\"transcoding\",\n\t\"extracting\",\n\t\"scoring\",\n\t\"rendering\",\n\t\"finalizing\"\n]);\nconst jobResponse = z.object({\n\tid: z.string(),\n\ttype: z.literal(\"report.generate\"),\n\tstatus: z.enum([\n\t\t\"queued\",\n\t\t\"running\",\n\t\t\"succeeded\",\n\t\t\"failed\",\n\t\t\"canceled\"\n\t]),\n\tstage: z.enum([\n\t\t\"uploaded\",\n\t\t\"queued\",\n\t\t\"transcoding\",\n\t\t\"extracting\",\n\t\t\"scoring\",\n\t\t\"rendering\",\n\t\t\"finalizing\"\n\t]).optional(),\n\tprogress: z.number().optional(),\n\tcreatedAt: z.string(),\n\tupdatedAt: z.string(),\n\treportId: z.string().optional(),\n\tusage: z.object({\n\t\tcreditsUsed: z.number(),\n\t\tcreditsDiscounted: z.number().optional(),\n\t\tcreditsNetUsed: z.number(),\n\t\tdurationMs: z.number().optional(),\n\t\tmodelVersion: z.string().optional()\n\t}).optional(),\n\tcredits: z.object({\n\t\treservedCredits: z.number().nullable(),\n\t\treservationStatus: z.enum([\n\t\t\t\"active\",\n\t\t\t\"released\",\n\t\t\t\"applied\"\n\t\t]).nullable()\n\t}).optional(),\n\treleasedCredits: z.number().nullable().optional(),\n\terror: z.object({\n\t\tcode: z.string(),\n\t\tmessage: z.string(),\n\t\tdetails: z.unknown().optional(),\n\t\tretryable: z.boolean().optional()\n\t}).optional()\n});\n/**\n* SSE stream event types for job status streaming.\n*/\nconst streamEventType = z.enum([\n\t\"status\",\n\t\"stage\",\n\t\"terminal\",\n\t\"heartbeat\"\n]);\n/**\n* Base SSE event structure with event ID for Last-Event-ID support.\n*/\nconst baseStreamEvent = z.object({ id: z.string().describe(\"Monotonically increasing event ID for resumption\") });\n/**\n* Status change event - emitted when job status changes.\n*/\nconst statusStreamEvent = baseStreamEvent.extend({\n\tevent: z.literal(\"status\"),\n\tdata: z.object({\n\t\tstatus: jobStatus,\n\t\tstage: jobStage.optional(),\n\t\tprogress: z.number().optional(),\n\t\tjob: jobResponse\n\t})\n});\n/**\n* Stage change event - emitted when job processing stage changes.\n*/\nconst stageStreamEvent = baseStreamEvent.extend({\n\tevent: z.literal(\"stage\"),\n\tdata: z.object({\n\t\tstage: jobStage,\n\t\tprogress: z.number().optional(),\n\t\tjob: jobResponse\n\t})\n});\n/**\n* Terminal event - emitted when job reaches final state (succeeded/failed/canceled).\n*/\nconst terminalStreamEvent = baseStreamEvent.extend({\n\tevent: z.literal(\"terminal\"),\n\tdata: z.object({\n\t\tstatus: z.enum([\n\t\t\t\"succeeded\",\n\t\t\t\"failed\",\n\t\t\t\"canceled\"\n\t\t]),\n\t\treportId: z.string().optional(),\n\t\terror: z.object({\n\t\t\tcode: z.string(),\n\t\t\tmessage: z.string()\n\t\t}).optional(),\n\t\tjob: jobResponse\n\t})\n});\n/**\n* Heartbeat event - emitted periodically to keep connection alive.\n*/\nconst heartbeatStreamEvent = baseStreamEvent.extend({\n\tevent: z.literal(\"heartbeat\"),\n\tdata: z.object({ timestamp: z.string() })\n});\n/**\n* Union of all SSE stream events.\n*/\nconst jobStreamEvent = z.discriminatedUnion(\"event\", [\n\tstatusStreamEvent,\n\tstageStreamEvent,\n\tterminalStreamEvent,\n\theartbeatStreamEvent\n]);\n/**\n* Query parameters for the stream endpoint.\n*/\nconst streamQueryParams = z.object({ timeout: z.coerce.number().min(1e3).max(3e5).default(3e5).describe(\"Stream timeout in milliseconds (default: 300000, max: 300000)\") });\n\n//#endregion\nexport { heartbeatStreamEvent, jobResponse, jobStage, jobStatus, jobStreamEvent, stageStreamEvent, statusStreamEvent, streamEventType, streamQueryParams, jobs_exports as t, terminalStreamEvent };\n//# sourceMappingURL=jobs.mjs.map","export function getHeader(headers: Headers, name: string): string | undefined {\n\tconst value = headers.get(name);\n\tif (value === null) return undefined;\n\treturn value;\n}\n\nexport function jitter(ms: number): number {\n\tconst ratio = 0.8 + Math.random() * 0.4;\n\treturn Math.floor(ms * ratio);\n}\n\nexport function backoffMs(\n\tattempt: number,\n\tbaseMs: number,\n\tmaxMs: number,\n): number {\n\tconst ms = baseMs * 2 ** Math.max(0, attempt - 1);\n\tif (ms > maxMs) return maxMs;\n\treturn ms;\n}\n\nexport function hasAbortSignal(signal?: AbortSignal): boolean {\n\treturn !!signal && typeof signal.aborted === \"boolean\";\n}\n\nexport function makeAbortError(): Error {\n\tconst err = new Error(\"The operation was aborted\");\n\terr.name = \"AbortError\";\n\treturn err;\n}\n\nexport function randomId(prefix = \"req\"): string {\n\tif (\n\t\ttypeof crypto !== \"undefined\" &&\n\t\ttypeof crypto.randomUUID === \"function\"\n\t) {\n\t\treturn `${prefix}_${crypto.randomUUID().replace(/-/g, \"\")}`;\n\t}\n\treturn `${prefix}_${Math.random().toString(16).slice(2)}${Date.now().toString(16)}`;\n}\n","import { jobResponse, jobStreamEvent } from \"@mappa-ai/contracts/v1/jobs\";\nimport {\n\tJobCanceledError,\n\tJobFailedError,\n\tMappaError,\n\tStreamError,\n} from \"../errors\";\nimport type { Job, JobEvent, WaitOptions } from \"../types\";\nimport { makeAbortError } from \"../utils\";\nimport type { SSEEvent, Transport } from \"./transport\";\nimport { parseRes } from \"./validate\";\n\nexport class JobsResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync get(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Job> {\n\t\tconst res = await this.transport.request<Job>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/jobs/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(jobResponse, res.data, \"jobs.get\");\n\t}\n\n\tasync cancel(\n\t\tjobId: string,\n\t\topts?: {\n\t\t\tidempotencyKey?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<Job> {\n\t\tconst res = await this.transport.request<Job>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `/v1/jobs/${encodeURIComponent(jobId)}/cancel`,\n\t\t\tidempotencyKey: opts?.idempotencyKey,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(jobResponse, res.data, \"jobs.cancel\");\n\t}\n\n\tasync wait(jobId: string, opts?: WaitOptions): Promise<Job> {\n\t\tconst timeoutMs = opts?.timeoutMs ?? 300000;\n\t\tconst ctrl = new AbortController();\n\t\tconst timeout = setTimeout(() => ctrl.abort(), timeoutMs);\n\n\t\tif (opts?.signal?.aborted) {\n\t\t\tclearTimeout(timeout);\n\t\t\tthrow makeAbortError();\n\t\t}\n\n\t\topts?.signal?.addEventListener(\"abort\", () => ctrl.abort(), { once: true });\n\n\t\ttry {\n\t\t\tfor await (const event of this.stream(jobId, {\n\t\t\t\tsignal: ctrl.signal,\n\t\t\t\tonEvent: opts?.onEvent,\n\t\t\t})) {\n\t\t\t\tif (event.type !== \"terminal\") continue;\n\t\t\t\tconst job = event.job;\n\t\t\t\tif (job.status === \"succeeded\") return job;\n\t\t\t\tif (job.status === \"failed\") {\n\t\t\t\t\tthrow new JobFailedError(jobId, job.error?.message ?? \"Job failed\", {\n\t\t\t\t\t\trequestId: job.requestId,\n\t\t\t\t\t\tcode: job.error?.code,\n\t\t\t\t\t\tcause: job.error,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (job.status === \"canceled\") {\n\t\t\t\t\tthrow new JobCanceledError(jobId, \"Job canceled\", {\n\t\t\t\t\t\trequestId: job.requestId,\n\t\t\t\t\t\tcause: job.error,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new JobFailedError(\n\t\t\t\tjobId,\n\t\t\t\t`Timed out waiting for job ${jobId} after ${timeoutMs}ms`,\n\t\t\t\t{ cause: { jobId, timeoutMs } },\n\t\t\t);\n\t\t} finally {\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync *stream(\n\t\tjobId: string,\n\t\topts?: { signal?: AbortSignal; onEvent?: (e: JobEvent) => void },\n\t): AsyncIterable<JobEvent> {\n\t\tconst maxRetries = 3;\n\t\tlet lastEventId: string | undefined;\n\t\tlet retries = 0;\n\n\t\twhile (retries < maxRetries) {\n\t\t\ttry {\n\t\t\t\tconst stream = this.transport.streamSSE<unknown>(\n\t\t\t\t\t`/v1/jobs/${encodeURIComponent(jobId)}/stream`,\n\t\t\t\t\t{ signal: opts?.signal, lastEventId },\n\t\t\t\t);\n\n\t\t\t\tfor await (const sse of stream) {\n\t\t\t\t\tlastEventId = sse.id;\n\t\t\t\t\tif (sse.event === \"error\") {\n\t\t\t\t\t\tconst err = readSSEError(sse.data);\n\t\t\t\t\t\tthrow new MappaError(err.message ?? \"Unknown SSE error\", {\n\t\t\t\t\t\t\tcode: err.code,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (sse.event === \"heartbeat\") continue;\n\n\t\t\t\t\tconst event = this.mapSSEToJobEvent(sse);\n\t\t\t\t\tif (!event) continue;\n\t\t\t\t\topts?.onEvent?.(event);\n\t\t\t\t\tyield event;\n\t\t\t\t\tif (sse.event === \"terminal\") return;\n\t\t\t\t\tretries = 0;\n\t\t\t\t}\n\n\t\t\t\tretries += 1;\n\t\t\t\tif (retries < maxRetries) await this.backoff(retries);\n\t\t\t} catch (err) {\n\t\t\t\tif (opts?.signal?.aborted) throw err;\n\t\t\t\tretries += 1;\n\t\t\t\tif (retries >= maxRetries) {\n\t\t\t\t\tthrow new StreamError(\n\t\t\t\t\t\t`Stream connection failed for job ${jobId} after ${maxRetries} retries`,\n\t\t\t\t\t\t{ jobId, lastEventId, retryCount: retries, cause: err },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait this.backoff(retries);\n\t\t\t}\n\t\t}\n\n\t\tthrow new StreamError(\n\t\t\t`Failed to get status for job ${jobId} after ${maxRetries} retries`,\n\t\t\t{\n\t\t\t\tjobId,\n\t\t\t\tlastEventId,\n\t\t\t\tretryCount: maxRetries,\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate mapSSEToJobEvent(sse: SSEEvent<unknown>): JobEvent | null {\n\t\tconst parsed = parseRes(\n\t\t\tjobStreamEvent,\n\t\t\t{\n\t\t\t\tid: sse.id ?? \"\",\n\t\t\t\tevent: sse.event,\n\t\t\t\tdata: sse.data,\n\t\t\t},\n\t\t\t\"jobs.stream event\",\n\t\t);\n\t\tif (parsed.event === \"status\")\n\t\t\treturn { type: \"status\", job: parsed.data.job };\n\t\tif (parsed.event === \"stage\") {\n\t\t\treturn {\n\t\t\t\ttype: \"stage\",\n\t\t\t\tstage: parsed.data.stage,\n\t\t\t\tprogress: parsed.data.progress,\n\t\t\t\tjob: parsed.data.job,\n\t\t\t};\n\t\t}\n\t\tif (parsed.event === \"terminal\")\n\t\t\treturn { type: \"terminal\", job: parsed.data.job };\n\t\treturn null;\n\t}\n\n\tprivate async backoff(attempt: number): Promise<void> {\n\t\tconst base = Math.min(1000 * 2 ** attempt, 10000);\n\t\tconst offset = base * 0.5 * Math.random();\n\t\tawait new Promise((r) => setTimeout(r, base + offset));\n\t}\n}\n\nfunction readSSEError(data: unknown): { code?: string; message?: string } {\n\tif (!data || typeof data !== \"object\") return {};\n\tconst err = data as Record<string, unknown>;\n\treturn {\n\t\tcode: typeof err.code === \"string\" ? err.code : undefined,\n\t\tmessage: typeof err.message === \"string\" ? err.message : undefined,\n\t};\n}\n","import { t as __exportAll } from \"../chunk-DQk6qfdC.mjs\";\nimport { z } from \"zod\";\n\n//#region src/v1/reports.ts\nvar reports_exports = /* @__PURE__ */ __exportAll({\n\tcardContent: () => cardContent,\n\tgenerateDefaultLabel: () => generateDefaultLabel,\n\tgridContent: () => gridContent,\n\tillustrationContent: () => illustrationContent,\n\tjobReceipt: () => jobReceipt,\n\tlistDateRange: () => listDateRange,\n\tlistOutputFormat: () => listOutputFormat,\n\tlistReportItem: () => listReportItem,\n\tlistReportsQuery: () => listReportsQuery,\n\tlistReportsResponse: () => listReportsResponse,\n\tlistStatus: () => listStatus,\n\treportCreateJobBody: () => reportCreateJobBody,\n\treportOutput: () => reportOutput,\n\treportResponse: () => reportResponse,\n\treportSection: () => reportSection,\n\treportViewQuery: () => reportViewQuery,\n\tsectionContent: () => sectionContent,\n\tsharingQuery: () => sharingQuery,\n\tsharingStatus: () => sharingStatus,\n\ttargetSelector: () => targetSelector,\n\ttextContent: () => textContent,\n\ttoggleSharingBody: () => toggleSharingBody,\n\twebhookConfig: () => webhookConfig\n});\n/**\n* Target selector for identifying which speaker to analyze.\n* Strategy is REQUIRED - we always need to know which speaker to target.\n*/\nconst targetSelector = z.object({\n\tstrategy: z.enum([\n\t\t\"dominant\",\n\t\t\"timerange\",\n\t\t\"entity_id\",\n\t\t\"magic_hint\"\n\t]),\n\ton_miss: z.enum([\"fallback_dominant\", \"error\"]).default(\"error\"),\n\ttimerange: z.object({\n\t\tstart_seconds: z.number().min(0).nullish(),\n\t\tend_seconds: z.number().min(0).nullish()\n\t}).nullish(),\n\thint: z.string().min(1).max(1024).trim().nullish(),\n\tentity_id: z.string().min(1).max(256).trim().nullish()\n}).refine((data) => {\n\tif (data.strategy === \"entity_id\" && !data.entity_id) return false;\n\tif (data.strategy === \"magic_hint\" && (!data.hint || data.hint.trim() === \"\")) return false;\n\treturn true;\n}, { message: \"entity_id is required for entity_id strategy, hint is required for magic_hint strategy\" });\n/**\n* Available report templates.\n* All templates analyze the same behavioral map (LayeredLenses) but apply\n* different lenses optimized for specific use cases.\n*/\nconst reportTemplates = z.enum([\n\t\"sales_playbook\",\n\t\"general_report\",\n\t\"hiring_report\",\n\t\"profile_alignment\"\n]);\n/**\n* Report output configuration.\n*\n* Reports are always generated in all supported formats:\n* - `markdown`: Human-readable formatted text\n* - `json`: Structured data for programmatic use\n* - `pdf`: Rendered PDF document (via external service)\n* - `url`: Hosted web report at console.mappa.ai/reports/[id]\n*/\nconst reportOutput = z.object({\n\ttemplate: reportTemplates,\n\ttemplateParams: z.record(z.string(), z.unknown()).optional()\n}).strict();\n/**\n* Webhook configuration for async job notifications.\n*/\nconst webhookConfig = z.object({\n\turl: z.url(),\n\theaders: z.record(z.string(), z.string()).optional()\n}).optional();\n/**\n* Human-readable template labels for auto-generating report names.\n*/\nconst templateLabels = {\n\tsales_playbook: \"Sales Playbook\",\n\tgeneral_report: \"General Report\",\n\thiring_report: \"Hiring Report\",\n\tprofile_alignment: \"Profile Alignment\"\n};\n/**\n* Generates a default label from template and current date.\n* Format: \"Template Name - Feb 3, 2026\"\n*/\nfunction generateDefaultLabel(template) {\n\treturn `${templateLabels[template] ?? template} - ${(/* @__PURE__ */ new Date()).toLocaleDateString(\"en-US\", {\n\t\tmonth: \"short\",\n\t\tday: \"numeric\",\n\t\tyear: \"numeric\"\n\t})}`;\n}\n/**\n* Request body for creating a report job.\n* Note: target is NOW REQUIRED (not optional).\n*/\nconst reportCreateJobBody = z.object({\n\tmedia: z.object({ mediaId: z.string() }),\n\toutput: reportOutput,\n\ttarget: targetSelector,\n\tlabel: z.string().trim().min(1).max(64).optional(),\n\tentityLabel: z.string().trim().min(1).max(64).optional(),\n\twebhook: webhookConfig,\n\tidempotencyKey: z.string().optional()\n});\nconst jobReceipt = z.object({\n\tjobId: z.string(),\n\tstatus: z.enum([\"queued\", \"running\"]),\n\tstage: z.string().optional(),\n\testimatedWaitSec: z.number().optional()\n});\nconst listStatus = z.enum([\n\t\"completed\",\n\t\"processing\",\n\t\"failed\"\n]);\nconst listDateRange = z.enum([\n\t\"all\",\n\t\"last_7_days\",\n\t\"last_30_days\",\n\t\"last_90_days\"\n]);\nconst listOutputFormat = z.enum([\n\t\"markdown\",\n\t\"json\",\n\t\"pdf\",\n\t\"url\"\n]);\nconst listReportsQuery = z.object({\n\tteamId: z.string(),\n\tpage: z.coerce.number().int().min(1).default(1),\n\tlimit: z.coerce.number().int().min(1).max(50).default(5),\n\tsearch: z.string().trim().min(1).max(128).optional(),\n\tstatus: listStatus.optional(),\n\ttemplate: reportTemplates.optional(),\n\tdateRange: listDateRange.default(\"all\")\n});\nconst listReportItem = z.object({\n\tid: z.string(),\n\tlabel: z.string().nullable(),\n\tentity: z.object({\n\t\tid: z.string(),\n\t\tlabel: z.string().nullable()\n\t}).nullable(),\n\ttemplate: reportTemplates,\n\tstatus: listStatus,\n\tcreatedAt: z.iso.datetime(),\n\toutput: z.object({ availableFormats: z.array(listOutputFormat) })\n});\nconst listReportsResponse = z.object({\n\titems: z.array(listReportItem),\n\tpagination: z.object({\n\t\tpage: z.number().int().min(1),\n\t\tlimit: z.number().int().min(1),\n\t\ttotalItems: z.number().int().min(0),\n\t\ttotalPages: z.number().int().min(0)\n\t})\n});\nconst reportViewQuery = z.object({ teamId: z.string() });\n/**\n* Card content for displaying titled content blocks with icons.\n* Icons use PascalCase Lucide icon names (e.g., \"Sparkles\", \"Brain\").\n*/\nconst cardContent = z.object({\n\ttype: z.literal(\"card\"),\n\ticon: z.string(),\n\ttitle: z.string(),\n\tcontent: z.string()\n});\n/**\n* Text content for simple paragraphs or prose sections.\n*/\nconst textContent = z.object({\n\ttype: z.literal(\"text\"),\n\ttitle: z.string().optional(),\n\tcontent: z.string()\n});\n/**\n* Grid content for displaying multiple cards in a grid layout.\n*/\nconst gridContent = z.object({\n\ttype: z.literal(\"grid\"),\n\tcolumns: z.union([\n\t\tz.literal(2),\n\t\tz.literal(3),\n\t\tz.literal(4)\n\t]),\n\titems: z.array(cardContent)\n});\n/**\n* Illustration content for decorative visual elements.\n*/\nconst illustrationContent = z.object({\n\ttype: z.literal(\"illustration\"),\n\tvariant: z.enum([\n\t\t\"conversation\",\n\t\t\"growth\",\n\t\t\"connection\",\n\t\t\"analysis\"\n\t])\n});\n/**\n* Discriminated union of all section content types.\n*/\nconst sectionContent = z.discriminatedUnion(\"type\", [\n\tcardContent,\n\ttextContent,\n\tgridContent,\n\tillustrationContent\n]);\n/**\n* Report section with typed content.\n* Content can be a single item, an array of items, or legacy untyped content.\n*\n* Note: Legacy reports may have arbitrary section_content. New reports\n* should use the typed sectionContent schema for proper frontend rendering.\n*/\nconst reportSection = z.object({\n\tsection_title: z.string(),\n\tsection_content: z.union([\n\t\tsectionContent,\n\t\tz.array(sectionContent),\n\t\tz.unknown()\n\t])\n});\n/**\n* Report response structure.\n*\n* Reports always include all available render outputs.\n*/\nconst reportResponse = z.object({\n\tid: z.string(),\n\tcreatedAt: z.string(),\n\tjobId: z.string().optional(),\n\tlabel: z.string().optional(),\n\tsummary: z.string().optional(),\n\tmedia: z.object({\n\t\turl: z.string().optional(),\n\t\tmediaId: z.string().optional()\n\t}),\n\toutput: z.object({ template: z.enum([\n\t\t\"sales_playbook\",\n\t\t\"general_report\",\n\t\t\"hiring_report\",\n\t\t\"profile_alignment\"\n\t]) }),\n\tentity: z.object({\n\t\tid: z.string(),\n\t\tlabel: z.string().nullable()\n\t}).optional(),\n\tmarkdown: z.string().nullish(),\n\tsections: z.array(reportSection).nullish(),\n\tmetrics: z.record(z.string(), z.unknown()).nullish(),\n\traw: z.unknown().nullish(),\n\tpdfUrl: z.url().optional(),\n\treportUrl: z.url().optional()\n});\n/**\n* Response for sharing status queries.\n*/\nconst sharingStatus = z.object({\n\tactive: z.boolean(),\n\tshareUrl: z.url().nullable()\n});\n/**\n* Request body for toggling report sharing.\n*/\nconst toggleSharingBody = z.object({\n\tteamId: z.string(),\n\tactive: z.boolean()\n});\n/**\n* Query params for sharing status.\n*/\nconst sharingQuery = z.object({ teamId: z.string() });\n\n//#endregion\nexport { cardContent, generateDefaultLabel, gridContent, illustrationContent, jobReceipt, listDateRange, listOutputFormat, listReportItem, listReportsQuery, listReportsResponse, listStatus, reportCreateJobBody, reportOutput, reportResponse, reportSection, reportViewQuery, sectionContent, sharingQuery, sharingStatus, reports_exports as t, targetSelector, textContent, toggleSharingBody, webhookConfig };\n//# sourceMappingURL=reports.mjs.map","import { t as __exportAll } from \"../chunk-DQk6qfdC.mjs\";\nimport { reportSection, targetSelector as targetSelector$1 } from \"./reports.mjs\";\nimport { z } from \"zod\";\n\n//#region src/v1/matching-analysis.ts\nvar matching_analysis_exports = /* @__PURE__ */ __exportAll({\n\tcreateJobBody: () => createJobBody,\n\tentitySource: () => entitySource,\n\tgenerateDefaultLabel: () => generateDefaultLabel,\n\tjobReceipt: () => jobReceipt,\n\tmatchingAnalysisResponse: () => matchingAnalysisResponse,\n\tmatchingEntity: () => matchingEntity,\n\toutput: () => output,\n\tsharingQuery: () => sharingQuery,\n\tsharingStatus: () => sharingStatus,\n\ttargetSelector: () => targetSelector,\n\ttoggleSharingBody: () => toggleSharingBody,\n\twebhookConfig: () => webhookConfig\n});\nconst targetSelector = targetSelector$1;\nconst entitySource = z.discriminatedUnion(\"type\", [z.object({\n\ttype: z.literal(\"entity_id\"),\n\tentityId: z.string().min(1).max(256).trim()\n}), z.object({\n\ttype: z.literal(\"media_target\"),\n\tmediaId: z.string().min(1).max(256).trim(),\n\ttarget: targetSelector\n})]);\nconst output = z.object({\n\ttemplate: z.literal(\"matching_analysis\"),\n\ttemplateParams: z.record(z.string(), z.unknown()).optional()\n}).strict();\nconst webhookConfig = z.object({\n\turl: z.url(),\n\theaders: z.record(z.string(), z.string()).optional()\n}).optional();\nconst createJobBody = z.object({\n\tentityA: entitySource,\n\tentityB: entitySource,\n\tcontext: z.string().trim().min(1).max(2048),\n\toutput,\n\tlabel: z.string().trim().min(1).max(64).optional(),\n\tentityALabel: z.string().trim().min(1).max(64).optional(),\n\tentityBLabel: z.string().trim().min(1).max(64).optional(),\n\twebhook: webhookConfig,\n\tidempotencyKey: z.string().optional()\n}).refine((data) => {\n\tif (data.entityA.type !== \"entity_id\" || data.entityB.type !== \"entity_id\") return true;\n\treturn data.entityA.entityId !== data.entityB.entityId;\n}, {\n\tmessage: \"entityA and entityB must reference different entity IDs\",\n\tpath: [\"entityB\"]\n});\nconst jobReceipt = z.object({\n\tjobId: z.string(),\n\tstatus: z.enum([\"queued\", \"running\"]),\n\tstage: z.string().optional(),\n\testimatedWaitSec: z.number().optional()\n});\nconst matchingEntity = z.object({\n\tid: z.string(),\n\tlabel: z.string().nullable()\n});\nconst matchingAnalysisResponse = z.object({\n\tid: z.string(),\n\tcreatedAt: z.string(),\n\tjobId: z.string().optional(),\n\tlabel: z.string().optional(),\n\tcontext: z.string(),\n\toutput: z.object({ template: z.literal(\"matching_analysis\") }),\n\tentityA: matchingEntity.optional(),\n\tentityB: matchingEntity.optional(),\n\tmarkdown: z.string().nullish(),\n\tsections: z.array(reportSection).nullish(),\n\tmetrics: z.record(z.string(), z.unknown()).nullish(),\n\traw: z.unknown().nullish(),\n\tpdfUrl: z.url().optional(),\n\treportUrl: z.url().optional()\n});\nconst sharingStatus = z.object({\n\tactive: z.boolean(),\n\tshareUrl: z.url().nullable()\n});\nconst toggleSharingBody = z.object({\n\tteamId: z.string(),\n\tactive: z.boolean()\n});\nconst sharingQuery = z.object({ teamId: z.string() });\nfunction generateDefaultLabel() {\n\treturn `Matching Analysis - ${(/* @__PURE__ */ new Date()).toLocaleDateString(\"en-US\", {\n\t\tmonth: \"short\",\n\t\tday: \"numeric\",\n\t\tyear: \"numeric\"\n\t})}`;\n}\n\n//#endregion\nexport { createJobBody, entitySource, generateDefaultLabel, jobReceipt, matchingAnalysisResponse, matchingEntity, output, sharingQuery, sharingStatus, matching_analysis_exports as t, targetSelector, toggleSharingBody, webhookConfig };\n//# sourceMappingURL=matching-analysis.mjs.map","import {\n\tcreateJobBody,\n\tjobReceipt,\n\tmatchingAnalysisResponse,\n} from \"@mappa-ai/contracts/v1/matching-analysis\";\nimport { MappaError } from \"../errors\";\nimport type {\n\tJob,\n\tJobEvent,\n\tMatchingAnalysisCreateJobRequest,\n\tMatchingAnalysisEntitySource,\n\tMatchingAnalysisForOutputType,\n\tMatchingAnalysisJobReceipt,\n\tMatchingAnalysisResponse,\n\tMatchingAnalysisRunHandle,\n\tTargetSelector,\n\tWaitOptions,\n} from \"../types\";\nimport { randomId } from \"../utils\";\nimport type { JobsResource } from \"./jobs\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nexport class MatchingAnalysisResource {\n\tconstructor(\n\t\tprivate readonly transport: Transport,\n\t\tprivate readonly jobs: JobsResource,\n\t) {}\n\n\tasync createJob(\n\t\treq: MatchingAnalysisCreateJobRequest,\n\t): Promise<MatchingAnalysisJobReceipt> {\n\t\tconst idempotencyKey = req.idempotencyKey ?? randomId(\"idem\");\n\t\tconst body = parseReq(\n\t\t\tcreateJobBody,\n\t\t\tthis.normalizeBody(req),\n\t\t\t\"matchingAnalysis.createJob body\",\n\t\t);\n\t\tconst res = await this.transport.request<\n\t\t\tOmit<MatchingAnalysisJobReceipt, \"handle\">\n\t\t>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/matching-analysis/jobs\",\n\t\t\tbody,\n\t\t\tidempotencyKey,\n\t\t\trequestId: req.requestId,\n\t\t\tsignal: req.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\tconst receiptData = parseRes(\n\t\t\tjobReceipt,\n\t\t\tres.data,\n\t\t\t\"matchingAnalysis.createJob\",\n\t\t);\n\t\tconst receipt: MatchingAnalysisJobReceipt = {\n\t\t\t...receiptData,\n\t\t\trequestId: res.requestId ?? res.data.requestId,\n\t\t};\n\t\treceipt.handle = this.makeHandle(receipt.jobId);\n\t\treturn receipt;\n\t}\n\n\tasync get(\n\t\tmatchingAnalysisId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MatchingAnalysisResponse> {\n\t\tconst res = await this.transport.request<MatchingAnalysisResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/matching-analysis/${encodeURIComponent(matchingAnalysisId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(matchingAnalysisResponse, res.data, \"matchingAnalysis.get\");\n\t}\n\n\tasync getByJob(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MatchingAnalysisResponse | null> {\n\t\tconst res = await this.transport.request<MatchingAnalysisResponse | null>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/matching-analysis/by-job/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\tif (res.data === null) return null;\n\t\treturn parseRes(\n\t\t\tmatchingAnalysisResponse,\n\t\t\tres.data,\n\t\t\t\"matchingAnalysis.getByJob\",\n\t\t);\n\t}\n\n\tasync generate(\n\t\treq: MatchingAnalysisCreateJobRequest,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<MatchingAnalysisForOutputType> {\n\t\tconst receipt = await this.createJob(req);\n\t\tif (!receipt.handle) throw new MappaError(\"Job receipt is missing handle\");\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\tmakeHandle(jobId: string): MatchingAnalysisRunHandle {\n\t\treturn {\n\t\t\tjobId,\n\t\t\tstream: (opts?: {\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t\tonEvent?: (e: JobEvent) => void;\n\t\t\t}) => this.jobs.stream(jobId, opts),\n\t\t\twait: async (\n\t\t\t\topts?: WaitOptions,\n\t\t\t): Promise<MatchingAnalysisForOutputType> => {\n\t\t\t\tconst terminal = await this.jobs.wait(jobId, opts);\n\t\t\t\tconst analysisId = terminal.reportId;\n\t\t\t\tif (!analysisId) {\n\t\t\t\t\tthrow new MappaError(\n\t\t\t\t\t\t`Job ${jobId} succeeded but no matching analysis id was returned`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.get(analysisId) as Promise<MatchingAnalysisForOutputType>;\n\t\t\t},\n\t\t\tcancel: (): Promise<Job> => this.jobs.cancel(jobId),\n\t\t\tjob: (): Promise<Job> => this.jobs.get(jobId),\n\t\t\tanalysis: () =>\n\t\t\t\tthis.getByJob(jobId) as Promise<MatchingAnalysisForOutputType | null>,\n\t\t};\n\t}\n\n\tprivate normalizeBody(\n\t\treq: MatchingAnalysisCreateJobRequest,\n\t): Record<string, unknown> {\n\t\treturn {\n\t\t\tentityA: this.normalizeEntitySource(req.entityA),\n\t\t\tentityB: this.normalizeEntitySource(req.entityB),\n\t\t\tcontext: req.context,\n\t\t\toutput: req.output,\n\t\t\tlabel: req.label,\n\t\t\tentityALabel: req.entityALabel,\n\t\t\tentityBLabel: req.entityBLabel,\n\t\t\twebhook: req.webhook,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t};\n\t}\n\n\tprivate normalizeEntitySource(\n\t\tsource: MatchingAnalysisEntitySource,\n\t): Record<string, unknown> {\n\t\tif (source.type === \"entity_id\") return source;\n\t\treturn {\n\t\t\ttype: source.type,\n\t\t\tmediaId: source.mediaId,\n\t\t\ttarget: this.normalizeTarget(source.target),\n\t\t};\n\t}\n\n\tprivate normalizeTarget(target: TargetSelector): Record<string, unknown> {\n\t\tif (target.strategy === \"dominant\") {\n\t\t\treturn {\n\t\t\t\tstrategy: target.strategy,\n\t\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\t};\n\t\t}\n\n\t\tif (target.strategy === \"timerange\") {\n\t\t\treturn {\n\t\t\t\tstrategy: target.strategy,\n\t\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\t\ttimerange: {\n\t\t\t\t\tstart_seconds: target.timeRange?.startSeconds ?? null,\n\t\t\t\t\tend_seconds: target.timeRange?.endSeconds ?? null,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (target.strategy === \"entity_id\") {\n\t\t\treturn {\n\t\t\t\tstrategy: target.strategy,\n\t\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\t\tentity_id: target.entityId,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\thint: target.hint,\n\t\t};\n\t}\n}\n","import {\n\tjobReceipt,\n\treportCreateJobBody,\n\treportResponse,\n} from \"@mappa-ai/contracts/v1/reports\";\nimport { MappaError } from \"../errors\";\nimport type {\n\tJobEvent,\n\tReport,\n\tReportCreateJobRequest,\n\tReportForOutputType,\n\tReportJobReceipt,\n\tReportRunHandle,\n\tWaitOptions,\n} from \"../types\";\nimport { randomId } from \"../utils\";\nimport type { UploadRequest } from \"./files\";\nimport type { JobsResource } from \"./jobs\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nexport type ReportCreateJobFromFileRequest = Omit<\n\tReportCreateJobRequest,\n\t\"media\" | \"idempotencyKey\" | \"requestId\"\n> &\n\tOmit<UploadRequest, \"label\"> & {\n\t\tlabel?: string;\n\t\tidempotencyKey?: string;\n\t\trequestId?: string;\n\t};\n\nexport type ReportCreateJobFromUrlRequest = Omit<\n\tReportCreateJobRequest,\n\t\"media\" | \"idempotencyKey\" | \"requestId\"\n> & {\n\turl: string;\n\tlabel?: string;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport class ReportsResource {\n\tconstructor(\n\t\tprivate readonly transport: Transport,\n\t\tprivate readonly jobs: JobsResource,\n\t\tprivate readonly files: {\n\t\t\tupload: (req: UploadRequest) => Promise<{ mediaId: string }>;\n\t\t},\n\t\tprivate readonly fetchImpl: typeof fetch,\n\t) {}\n\n\tasync createJob(req: ReportCreateJobRequest): Promise<ReportJobReceipt> {\n\t\tvalidateMedia(req.media);\n\n\t\tconst idem = req.idempotencyKey ?? this.defaultIdempotencyKey();\n\t\tconst body = parseReq(\n\t\t\treportCreateJobBody,\n\t\t\tthis.normalizeJobRequest(req),\n\t\t\t\"reports.createJob body\",\n\t\t);\n\n\t\tconst res = await this.transport.request<Omit<ReportJobReceipt, \"handle\">>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/reports/jobs\",\n\t\t\tbody,\n\t\t\tidempotencyKey: idem,\n\t\t\trequestId: req.requestId,\n\t\t\tsignal: req.signal,\n\t\t\tretryable: true,\n\t\t});\n\n\t\tconst receiptData = parseRes(jobReceipt, res.data, \"reports.createJob\");\n\t\tconst receipt: ReportJobReceipt = {\n\t\t\t...receiptData,\n\t\t\trequestId: res.requestId ?? res.data.requestId,\n\t\t};\n\t\treceipt.handle = this.makeHandle(receipt.jobId);\n\t\treturn receipt;\n\t}\n\n\tasync createJobFromFile(\n\t\treq: ReportCreateJobFromFileRequest,\n\t): Promise<ReportJobReceipt> {\n\t\tconst { file, label, idempotencyKey, requestId, signal, ...rest } = req;\n\n\t\tconst upload = await this.files.upload({\n\t\t\tfile,\n\t\t\tlabel,\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t});\n\n\t\treturn this.createJob({\n\t\t\toutput: rest.output,\n\t\t\ttarget: rest.target,\n\t\t\tentityLabel: rest.entityLabel,\n\t\t\twebhook: rest.webhook,\n\t\t\tmedia: { mediaId: upload.mediaId },\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tasync createJobFromUrl(\n\t\treq: ReportCreateJobFromUrlRequest,\n\t): Promise<ReportJobReceipt> {\n\t\tconst { url, label, idempotencyKey, requestId, signal, ...rest } = req;\n\n\t\tlet parsed: URL;\n\t\ttry {\n\t\t\tparsed = new URL(url);\n\t\t} catch {\n\t\t\tthrow new MappaError(\"url must be a valid URL\");\n\t\t}\n\n\t\tif (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n\t\t\tthrow new MappaError(\"url must use http: or https:\");\n\t\t}\n\n\t\tconst response = await this.fetchImpl(parsed.toString(), { signal });\n\t\tif (!response.ok) {\n\t\t\tthrow new MappaError(\n\t\t\t\t`Failed to download url (status ${response.status})`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof Blob === \"undefined\") {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"Blob is not available in this runtime; cannot download and upload from url\",\n\t\t\t);\n\t\t}\n\n\t\tconst blob = await response.blob();\n\t\tconst upload = await this.files.upload({\n\t\t\tfile: blob,\n\t\t\tlabel,\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t});\n\n\t\treturn this.createJob({\n\t\t\toutput: rest.output,\n\t\t\ttarget: rest.target,\n\t\t\tentityLabel: rest.entityLabel,\n\t\t\twebhook: rest.webhook,\n\t\t\tmedia: { mediaId: upload.mediaId },\n\t\t\tidempotencyKey,\n\t\t\trequestId,\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tasync get(\n\t\treportId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Report> {\n\t\tconst res = await this.transport.request<Report>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/reports/${encodeURIComponent(reportId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\treturn parseRes(reportResponse, res.data, \"reports.get\");\n\t}\n\n\tasync getByJob(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Report | null> {\n\t\tconst res = await this.transport.request<Report | null>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/reports/by-job/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tsignal: opts?.signal,\n\t\t\tretryable: true,\n\t\t});\n\t\tif (res.data === null) return null;\n\t\treturn parseRes(reportResponse, res.data, \"reports.getByJob\");\n\t}\n\n\tasync generate(\n\t\treq: ReportCreateJobRequest,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<ReportForOutputType> {\n\t\tconst receipt = await this.createJob(req);\n\t\tif (!receipt.handle) throw new MappaError(\"Job receipt is missing handle\");\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\tasync generateFromFile(\n\t\treq: ReportCreateJobFromFileRequest,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<ReportForOutputType> {\n\t\tconst receipt = await this.createJobFromFile(req);\n\t\tif (!receipt.handle) throw new MappaError(\"Job receipt is missing handle\");\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\tasync generateFromUrl(\n\t\treq: ReportCreateJobFromUrlRequest,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<ReportForOutputType> {\n\t\tconst receipt = await this.createJobFromUrl(req);\n\t\tif (!receipt.handle) throw new MappaError(\"Job receipt is missing handle\");\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\tmakeHandle(jobId: string): ReportRunHandle {\n\t\treturn {\n\t\t\tjobId,\n\t\t\tstream: (opts?: {\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t\tonEvent?: (e: JobEvent) => void;\n\t\t\t}) => this.jobs.stream(jobId, opts),\n\t\t\twait: async (opts?: WaitOptions): Promise<ReportForOutputType> => {\n\t\t\t\tconst terminal = await this.jobs.wait(jobId, opts);\n\t\t\t\tif (!terminal.reportId) {\n\t\t\t\t\tthrow new MappaError(\n\t\t\t\t\t\t`Job ${jobId} succeeded but no reportId was returned`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.get(terminal.reportId) as Promise<ReportForOutputType>;\n\t\t\t},\n\t\t\tcancel: () => this.jobs.cancel(jobId),\n\t\t\tjob: () => this.jobs.get(jobId),\n\t\t\treport: () => this.getByJob(jobId) as Promise<ReportForOutputType | null>,\n\t\t};\n\t}\n\n\tprivate defaultIdempotencyKey(): string {\n\t\treturn randomId(\"idem\");\n\t}\n\n\tprivate normalizeJobRequest(\n\t\treq: ReportCreateJobRequest,\n\t): Record<string, unknown> {\n\t\treturn {\n\t\t\tmedia: req.media,\n\t\t\toutput: req.output,\n\t\t\tlabel: req.label,\n\t\t\ttarget: normalizeTarget(req.target),\n\t\t\tentityLabel: req.entityLabel,\n\t\t\twebhook: req.webhook,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t};\n\t}\n}\n\nfunction validateMedia(media: { mediaId: string }): void {\n\tif (!media || typeof media !== \"object\") {\n\t\tthrow new MappaError(\"media must be an object\");\n\t}\n\tif (typeof media.mediaId !== \"string\" || !media.mediaId) {\n\t\tthrow new MappaError(\"media.mediaId must be a non-empty string\");\n\t}\n}\n\nfunction normalizeTarget(\n\ttarget: ReportCreateJobRequest[\"target\"],\n): Record<string, unknown> {\n\tif (target.strategy === \"dominant\") {\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t};\n\t}\n\n\tif (target.strategy === \"timerange\") {\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\ttimerange: {\n\t\t\t\tstart_seconds: target.timeRange?.startSeconds ?? null,\n\t\t\t\tend_seconds: target.timeRange?.endSeconds ?? null,\n\t\t\t},\n\t\t};\n\t}\n\n\tif (target.strategy === \"entity_id\") {\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\tentity_id: target.entityId,\n\t\t};\n\t}\n\n\treturn {\n\t\tstrategy: target.strategy,\n\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\thint: target.hint,\n\t};\n}\n","import {\n\tApiError,\n\tAuthError,\n\tInsufficientCreditsError,\n\tMappaError,\n\tRateLimitError,\n\tValidationError,\n} from \"../errors\";\nimport {\n\tbackoffMs,\n\tgetHeader,\n\thasAbortSignal,\n\tjitter,\n\tmakeAbortError,\n\trandomId,\n} from \"../utils\";\n\nexport type SSEStreamOptions = {\n\tsignal?: AbortSignal;\n\tlastEventId?: string;\n};\n\nexport type SSEEvent<T = unknown> = {\n\tid?: string;\n\tevent: string;\n\tdata: T;\n};\n\nexport type Telemetry = {\n\tonRequest?: (ctx: {\n\t\tmethod: string;\n\t\turl: string;\n\t\trequestId?: string;\n\t}) => void;\n\tonResponse?: (ctx: {\n\t\tstatus: number;\n\t\turl: string;\n\t\trequestId?: string;\n\t\tdurationMs: number;\n\t}) => void;\n\tonError?: (ctx: {\n\t\turl: string;\n\t\trequestId?: string;\n\t\terror: unknown;\n\t\tcontext?: Record<string, unknown>;\n\t}) => void;\n};\n\nexport type TransportOptions = {\n\tapiKey: string;\n\tbaseUrl: string;\n\ttimeoutMs: number;\n\tmaxRetries: number;\n\tdefaultHeaders?: Record<string, string>;\n\tfetch?: typeof fetch;\n\ttelemetry?: Telemetry;\n\tuserAgent?: string;\n};\n\nexport type RequestOptions = {\n\tmethod: \"GET\" | \"POST\" | \"DELETE\" | \"PUT\" | \"PATCH\";\n\tpath: string;\n\tquery?: Record<string, string | number | boolean | undefined>;\n\theaders?: Record<string, string | undefined>;\n\tbody?: unknown;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n\tretryable?: boolean;\n};\n\nexport type TransportResponse<T> = {\n\tdata: T;\n\tstatus: number;\n\trequestId?: string;\n\theaders: Headers;\n};\n\nfunction buildUrl(\n\tbaseUrl: string,\n\tpath: string,\n\tquery?: RequestOptions[\"query\"],\n): string {\n\tconst url = new URL(\n\t\tpath.replace(/^\\//, \"\"),\n\t\tbaseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`,\n\t);\n\tif (!query) return url.toString();\n\tfor (const [k, v] of Object.entries(query)) {\n\t\tif (v === undefined) continue;\n\t\turl.searchParams.set(k, String(v));\n\t}\n\treturn url.toString();\n}\n\nasync function readBody(\n\tres: Response,\n): Promise<{ parsed: unknown; text: string }> {\n\tconst text = await res.text();\n\tif (!text) return { parsed: null, text: \"\" };\n\ttry {\n\t\treturn { parsed: JSON.parse(text), text };\n\t} catch {\n\t\treturn { parsed: text, text };\n\t}\n}\n\nfunction coerceApiError(res: Response, parsed: unknown): ApiError {\n\tconst requestId = res.headers.get(\"x-request-id\") ?? undefined;\n\tlet code: string | undefined;\n\tlet message = `Request failed with status ${res.status}`;\n\tlet details: unknown = parsed;\n\n\tif (typeof parsed === \"string\") {\n\t\tmessage = parsed;\n\t}\n\n\tif (parsed && typeof parsed === \"object\") {\n\t\tconst obj = parsed as Record<string, unknown>;\n\t\tconst err = (obj.error ?? obj) as Record<string, unknown>;\n\t\tif (typeof err.message === \"string\") message = err.message;\n\t\tif (typeof err.code === \"string\") code = err.code;\n\t\tif (\"details\" in err) details = err.details;\n\t}\n\n\tif (res.status === 401 || res.status === 403) {\n\t\treturn new AuthError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails,\n\t\t});\n\t}\n\n\tif (res.status === 422) {\n\t\treturn new ValidationError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails,\n\t\t});\n\t}\n\n\tif (res.status === 402 && code === \"insufficient_credits\") {\n\t\treturn new InsufficientCreditsError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails: details as { required?: number; available?: number },\n\t\t});\n\t}\n\n\tif (res.status === 429) {\n\t\tconst err = new RateLimitError(message, {\n\t\t\tstatus: res.status,\n\t\t\trequestId,\n\t\t\tcode,\n\t\t\tdetails,\n\t\t});\n\t\tconst retryAfter = res.headers.get(\"retry-after\");\n\t\tif (retryAfter) {\n\t\t\tconst sec = Number(retryAfter);\n\t\t\tif (Number.isFinite(sec) && sec >= 0) {\n\t\t\t\terr.retryAfterMs = sec * 1000;\n\t\t\t}\n\t\t}\n\t\treturn err;\n\t}\n\n\treturn new ApiError(message, {\n\t\tstatus: res.status,\n\t\trequestId,\n\t\tcode,\n\t\tdetails,\n\t});\n}\n\nfunction shouldRetry(\n\treq: RequestOptions,\n\terr: unknown,\n): { retry: boolean; retryAfterMs?: number } {\n\tif (!req.retryable) return { retry: false };\n\tif (err instanceof RateLimitError) {\n\t\treturn { retry: true, retryAfterMs: err.retryAfterMs };\n\t}\n\tif (err instanceof ApiError) {\n\t\treturn { retry: err.status >= 500 && err.status <= 599 };\n\t}\n\tif (err instanceof TypeError) return { retry: true };\n\treturn { retry: false };\n}\n\nfunction isNetworkError(err: unknown): boolean {\n\tif (err instanceof TypeError) return true;\n\tif (!err || typeof err !== \"object\") return false;\n\tif (!(\"code\" in err)) return false;\n\tif (typeof err.code !== \"string\") return false;\n\treturn [\n\t\t\"FailedToOpenSocket\",\n\t\t\"ECONNREFUSED\",\n\t\t\"ECONNRESET\",\n\t\t\"ETIMEDOUT\",\n\t\t\"ENOTFOUND\",\n\t\t\"EAI_AGAIN\",\n\t].includes(err.code);\n}\n\nexport class Transport {\n\tprivate readonly fetchImpl: typeof fetch;\n\n\tconstructor(private readonly opts: TransportOptions) {\n\t\tthis.fetchImpl = opts.fetch ?? fetch;\n\t}\n\n\tasync *streamSSE<T>(\n\t\tpath: string,\n\t\topts?: SSEStreamOptions,\n\t): AsyncGenerator<SSEEvent<T>> {\n\t\tconst url = buildUrl(this.opts.baseUrl, path);\n\t\tconst requestId = randomId(\"req\");\n\t\tconst maxRetries = Math.max(0, this.opts.maxRetries);\n\t\tconst headers: Record<string, string> = {\n\t\t\tAccept: \"text/event-stream\",\n\t\t\t\"Cache-Control\": \"no-cache\",\n\t\t\t\"Mappa-Api-Key\": this.opts.apiKey,\n\t\t\t\"X-Request-Id\": requestId,\n\t\t\t...(this.opts.userAgent ? { \"User-Agent\": this.opts.userAgent } : {}),\n\t\t\t...(this.opts.defaultHeaders ?? {}),\n\t\t};\n\n\t\tif (opts?.lastEventId) headers[\"Last-Event-ID\"] = opts.lastEventId;\n\n\t\tlet res: Response | undefined;\n\t\tlet lastError: unknown;\n\n\t\tfor (const attempt of Array.from({ length: maxRetries + 1 }, (_, i) => i)) {\n\t\t\tconst ctrl = new AbortController();\n\t\t\tconst timeout = setTimeout(\n\t\t\t\t() => ctrl.abort(makeAbortError()),\n\t\t\t\tthis.opts.timeoutMs,\n\t\t\t);\n\n\t\t\tif (hasAbortSignal(opts?.signal)) {\n\t\t\t\tif (opts?.signal?.aborted) {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tthrow makeAbortError();\n\t\t\t\t}\n\t\t\t\topts?.signal?.addEventListener(\n\t\t\t\t\t\"abort\",\n\t\t\t\t\t() => ctrl.abort(makeAbortError()),\n\t\t\t\t\t{ once: true },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.opts.telemetry?.onRequest?.({ method: \"GET\", url, requestId });\n\n\t\t\ttry {\n\t\t\t\tres = await this.fetchImpl(url, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders,\n\t\t\t\t\tsignal: ctrl.signal,\n\t\t\t\t});\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\tconst { parsed } = await readBody(res);\n\t\t\t\t\tconst err = coerceApiError(res, parsed);\n\t\t\t\t\tthis.opts.telemetry?.onError?.({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\terror: err,\n\t\t\t\t\t\tcontext: { attempt, lastEventId: opts?.lastEventId },\n\t\t\t\t\t});\n\t\t\t\t\tif (res.status >= 500 && res.status <= 599 && attempt < maxRetries) {\n\t\t\t\t\t\tconst delay = jitter(backoffMs(attempt + 1, 500, 4000));\n\t\t\t\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t} catch (err) {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tlastError = err;\n\t\t\t\tthis.opts.telemetry?.onError?.({\n\t\t\t\t\turl,\n\t\t\t\t\trequestId,\n\t\t\t\t\terror: err,\n\t\t\t\t\tcontext: { attempt, lastEventId: opts?.lastEventId },\n\t\t\t\t});\n\t\t\t\tif (isNetworkError(err) && attempt < maxRetries) {\n\t\t\t\t\tconst delay = jitter(backoffMs(attempt + 1, 500, 4000));\n\t\t\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\n\t\tif (!res) throw lastError;\n\t\tif (!res.body) throw new MappaError(\"SSE response has no body\");\n\t\tyield* this.parseSSEStream<T>(res.body);\n\t}\n\n\tprivate async *parseSSEStream<T>(\n\t\tbody: ReadableStream<Uint8Array>,\n\t): AsyncGenerator<SSEEvent<T>> {\n\t\tconst decoder = new TextDecoder();\n\t\tconst reader = body.getReader();\n\t\tlet buf = \"\";\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) break;\n\t\t\t\tbuf += decoder.decode(value, { stream: true });\n\t\t\t\tconst parts = buf.split(\"\\n\\n\");\n\t\t\t\tbuf = parts.pop() ?? \"\";\n\t\t\t\tfor (const part of parts) {\n\t\t\t\t\tif (!part.trim()) continue;\n\t\t\t\t\tconst event = this.parseSSEEvent<T>(part);\n\t\t\t\t\tif (event) yield event;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (buf.trim()) {\n\t\t\t\tconst event = this.parseSSEEvent<T>(buf);\n\t\t\t\tif (event) yield event;\n\t\t\t}\n\t\t} finally {\n\t\t\treader.releaseLock();\n\t\t}\n\t}\n\n\tprivate parseSSEEvent<T>(text: string): SSEEvent<T> | null {\n\t\tconst lines = text.split(\"\\n\");\n\t\tlet id: string | undefined;\n\t\tlet event = \"message\";\n\t\tlet data = \"\";\n\n\t\tfor (const line of lines) {\n\t\t\tif (line.startsWith(\"id:\")) id = line.slice(3).trim();\n\t\t\tif (line.startsWith(\"event:\")) event = line.slice(6).trim();\n\t\t\tif (!line.startsWith(\"data:\")) continue;\n\t\t\tif (data) data += \"\\n\";\n\t\t\tdata += line.slice(5).trim();\n\t\t}\n\n\t\tif (!data) return null;\n\t\ttry {\n\t\t\treturn { id, event, data: JSON.parse(data) as T };\n\t\t} catch {\n\t\t\treturn { id, event, data: data as T };\n\t\t}\n\t}\n\n\tasync request<T>(req: RequestOptions): Promise<TransportResponse<T>> {\n\t\tconst url = buildUrl(this.opts.baseUrl, req.path, req.query);\n\t\tconst requestId = req.requestId ?? randomId(\"req\");\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Mappa-Api-Key\": this.opts.apiKey,\n\t\t\t\"X-Request-Id\": requestId,\n\t\t\t...(this.opts.userAgent ? { \"User-Agent\": this.opts.userAgent } : {}),\n\t\t\t...(this.opts.defaultHeaders ?? {}),\n\t\t};\n\n\t\tif (req.idempotencyKey) headers[\"Idempotency-Key\"] = req.idempotencyKey;\n\t\tif (req.headers) {\n\t\t\tfor (const [k, v] of Object.entries(req.headers)) {\n\t\t\t\tif (v === undefined) continue;\n\t\t\t\theaders[k] = v;\n\t\t\t}\n\t\t}\n\n\t\tconst isFormData =\n\t\t\ttypeof FormData !== \"undefined\" && req.body instanceof FormData;\n\t\tconst hasBody = req.body !== undefined;\n\t\tif (hasBody && !isFormData) headers[\"Content-Type\"] = \"application/json\";\n\n\t\tconst body =\n\t\t\treq.body === undefined\n\t\t\t\t? undefined\n\t\t\t\t: isFormData\n\t\t\t\t\t? (req.body as FormData)\n\t\t\t\t\t: JSON.stringify(req.body);\n\n\t\tconst maxRetries = Math.max(0, this.opts.maxRetries);\n\t\tconst start = Date.now();\n\n\t\tfor (const attempt of Array.from(\n\t\t\t{ length: maxRetries + 1 },\n\t\t\t(_, i) => i + 1,\n\t\t)) {\n\t\t\tconst ctrl = new AbortController();\n\t\t\tconst timeout = setTimeout(\n\t\t\t\t() => ctrl.abort(makeAbortError()),\n\t\t\t\tthis.opts.timeoutMs,\n\t\t\t);\n\n\t\t\tif (hasAbortSignal(req.signal)) {\n\t\t\t\tif (req.signal?.aborted) {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tthrow makeAbortError();\n\t\t\t\t}\n\t\t\t\treq.signal?.addEventListener(\n\t\t\t\t\t\"abort\",\n\t\t\t\t\t() => ctrl.abort(makeAbortError()),\n\t\t\t\t\t{\n\t\t\t\t\t\tonce: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.opts.telemetry?.onRequest?.({ method: req.method, url, requestId });\n\n\t\t\ttry {\n\t\t\t\tconst res = await this.fetchImpl(url, {\n\t\t\t\t\tmethod: req.method,\n\t\t\t\t\theaders,\n\t\t\t\t\tbody,\n\t\t\t\t\tsignal: ctrl.signal,\n\t\t\t\t});\n\n\t\t\t\tconst serverRequestId =\n\t\t\t\t\tgetHeader(res.headers, \"x-request-id\") ?? requestId;\n\t\t\t\tconst durationMs = Date.now() - start;\n\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\tconst { parsed } = await readBody(res);\n\t\t\t\t\tconst err = coerceApiError(res, parsed);\n\t\t\t\t\tthis.opts.telemetry?.onError?.({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\trequestId: serverRequestId,\n\t\t\t\t\t\terror: err,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst decision = shouldRetry(req, err);\n\t\t\t\t\tif (attempt <= maxRetries && decision.retry) {\n\t\t\t\t\t\tconst sleep =\n\t\t\t\t\t\t\tdecision.retryAfterMs ?? jitter(backoffMs(attempt, 500, 4000));\n\t\t\t\t\t\tawait new Promise((r) => setTimeout(r, sleep));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\n\t\t\t\tconst ct = res.headers.get(\"content-type\") ?? \"\";\n\t\t\t\tconst data = ct.includes(\"application/json\")\n\t\t\t\t\t? ((await res.json()) as unknown)\n\t\t\t\t\t: ((await res.text()) as unknown);\n\n\t\t\t\tthis.opts.telemetry?.onResponse?.({\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\turl,\n\t\t\t\t\trequestId: serverRequestId,\n\t\t\t\t\tdurationMs,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tdata: data as T,\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\trequestId: serverRequestId,\n\t\t\t\t\theaders: res.headers,\n\t\t\t\t};\n\t\t\t} catch (err) {\n\t\t\t\tthis.opts.telemetry?.onError?.({ url, requestId, error: err });\n\t\t\t\tconst decision = shouldRetry(req, err);\n\t\t\t\tif (attempt <= maxRetries && decision.retry) {\n\t\t\t\t\tconst sleep =\n\t\t\t\t\t\tdecision.retryAfterMs ?? jitter(backoffMs(attempt, 500, 4000));\n\t\t\t\t\tawait new Promise((r) => setTimeout(r, sleep));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\"Unexpected transport exit\");\n\t}\n}\n","function isObject(v: unknown): v is Record<string, unknown> {\n\treturn v !== null && typeof v === \"object\";\n}\n\nexport type WebhookEventType = \"report.completed\" | \"report.failed\";\n\nexport interface WebhookEvent<T = unknown> {\n\ttype: string;\n\ttimestamp: string;\n\tdata: T;\n}\n\nexport interface ReportCompletedData {\n\tjobId: string;\n\treportId: string;\n\tstatus: \"succeeded\";\n}\n\nexport interface ReportFailedData {\n\tjobId: string;\n\tstatus: \"failed\";\n\terror: {\n\t\tcode: string;\n\t\tmessage: string;\n\t};\n}\n\nexport type ReportCompletedEvent = WebhookEvent<ReportCompletedData> & {\n\ttype: \"report.completed\";\n};\n\nexport type ReportFailedEvent = WebhookEvent<ReportFailedData> & {\n\ttype: \"report.failed\";\n};\n\nexport class WebhooksResource {\n\tasync verifySignature(params: {\n\t\tpayload: string;\n\t\theaders: Record<string, string | string[] | undefined>;\n\t\tsecret: string;\n\t\ttoleranceSec?: number;\n\t}): Promise<{ ok: true }> {\n\t\tconst tolerance = params.toleranceSec ?? 300;\n\t\tconst sigHeader = getHeader(params.headers, \"mappa-signature\");\n\t\tif (!sigHeader) throw new Error(\"Missing mappa-signature header\");\n\n\t\tconst sig = parseSignature(sigHeader);\n\t\tconst ts = Number(sig.t);\n\t\tif (!Number.isFinite(ts)) throw new Error(\"Invalid signature timestamp\");\n\n\t\tconst now = Math.floor(Date.now() / 1000);\n\t\tif (Math.abs(now - ts) > tolerance) {\n\t\t\tthrow new Error(\"Signature timestamp outside tolerance\");\n\t\t}\n\n\t\tconst payload = `${sig.t}.${params.payload}`;\n\t\tconst expected = await hmacHex(params.secret, payload);\n\t\tif (!timingSafeEqualHex(expected, sig.v1)) {\n\t\t\tthrow new Error(\"Invalid signature\");\n\t\t}\n\n\t\treturn { ok: true };\n\t}\n\n\tparseEvent<T = unknown>(payload: string): WebhookEvent<T>;\n\tparseEvent(\n\t\tpayload: string,\n\t): ReportCompletedEvent | ReportFailedEvent | WebhookEvent<unknown>;\n\tparseEvent<T = unknown>(payload: string): WebhookEvent<T> {\n\t\tconst raw = JSON.parse(payload) as unknown;\n\t\tif (!isObject(raw)) {\n\t\t\tthrow new Error(\"Invalid webhook payload: not an object\");\n\t\t}\n\t\tif (typeof raw.type !== \"string\") {\n\t\t\tthrow new Error(\"Invalid webhook payload: type must be a string\");\n\t\t}\n\t\tif (typeof raw.timestamp !== \"string\") {\n\t\t\tthrow new Error(\"Invalid webhook payload: timestamp must be a string\");\n\t\t}\n\n\t\tconst data = \"data\" in raw ? raw.data : undefined;\n\t\tif (raw.type === \"report.completed\") {\n\t\t\treturn {\n\t\t\t\ttype: raw.type,\n\t\t\t\ttimestamp: raw.timestamp,\n\t\t\t\tdata: parseReportCompletedData(data) as T,\n\t\t\t};\n\t\t}\n\n\t\tif (raw.type === \"report.failed\") {\n\t\t\treturn {\n\t\t\t\ttype: raw.type,\n\t\t\t\ttimestamp: raw.timestamp,\n\t\t\t\tdata: parseReportFailedData(data) as T,\n\t\t\t};\n\t\t}\n\n\t\treturn { type: raw.type, timestamp: raw.timestamp, data: data as T };\n\t}\n}\n\nfunction parseReportCompletedData(data: unknown): ReportCompletedData {\n\tif (!isObject(data))\n\t\tthrow new Error(\"Invalid report.completed data: not an object\");\n\tif (typeof data.jobId !== \"string\") {\n\t\tthrow new Error(\"Invalid report.completed data: jobId must be a string\");\n\t}\n\tif (typeof data.reportId !== \"string\") {\n\t\tthrow new Error(\"Invalid report.completed data: reportId must be a string\");\n\t}\n\tif (data.status !== \"succeeded\") {\n\t\tthrow new Error(\"Invalid report.completed data: status must be succeeded\");\n\t}\n\treturn { jobId: data.jobId, reportId: data.reportId, status: data.status };\n}\n\nfunction parseReportFailedData(data: unknown): ReportFailedData {\n\tif (!isObject(data))\n\t\tthrow new Error(\"Invalid report.failed data: not an object\");\n\tif (typeof data.jobId !== \"string\") {\n\t\tthrow new Error(\"Invalid report.failed data: jobId must be a string\");\n\t}\n\tif (data.status !== \"failed\") {\n\t\tthrow new Error(\"Invalid report.failed data: status must be failed\");\n\t}\n\tif (!isObject(data.error)) {\n\t\tthrow new Error(\"Invalid report.failed data: error must be an object\");\n\t}\n\tif (typeof data.error.code !== \"string\") {\n\t\tthrow new Error(\"Invalid report.failed data: error.code must be a string\");\n\t}\n\tif (typeof data.error.message !== \"string\") {\n\t\tthrow new Error(\n\t\t\t\"Invalid report.failed data: error.message must be a string\",\n\t\t);\n\t}\n\treturn {\n\t\tjobId: data.jobId,\n\t\tstatus: data.status,\n\t\terror: {\n\t\t\tcode: data.error.code,\n\t\t\tmessage: data.error.message,\n\t\t},\n\t};\n}\n\nfunction getHeader(\n\theaders: Record<string, string | string[] | undefined>,\n\tname: string,\n): string | undefined {\n\tconst key = Object.keys(headers).find(\n\t\t(k) => k.toLowerCase() === name.toLowerCase(),\n\t);\n\tif (!key) return undefined;\n\tconst value = headers[key];\n\tif (!value) return undefined;\n\tif (Array.isArray(value)) return value[0];\n\treturn value;\n}\n\nfunction parseSignature(value: string): { t: string; v1: string } {\n\tconst out: Record<string, string> = {};\n\tfor (const part of value.split(\",\")) {\n\t\tconst [k, v] = part.split(\"=\");\n\t\tif (!k || !v) continue;\n\t\tout[k.trim()] = v.trim();\n\t}\n\tif (!out.t || !out.v1) throw new Error(\"Invalid signature format\");\n\treturn { t: out.t, v1: out.v1 };\n}\n\nasync function hmacHex(secret: string, message: string): Promise<string> {\n\tconst enc = new TextEncoder();\n\tconst key = await crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tenc.encode(secret),\n\t\t{ name: \"HMAC\", hash: \"SHA-256\" },\n\t\tfalse,\n\t\t[\"sign\"],\n\t);\n\tconst sig = await crypto.subtle.sign(\"HMAC\", key, enc.encode(message));\n\tconst bytes = new Uint8Array(sig);\n\tlet out = \"\";\n\tfor (const b of bytes) out += b.toString(16).padStart(2, \"0\");\n\treturn out;\n}\n\nfunction timingSafeEqualHex(a: string, b: string): boolean {\n\tif (a.length !== b.length) return false;\n\tlet diff = 0;\n\tfor (let i = 0; i < a.length; i++) {\n\t\tdiff |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t}\n\treturn diff === 0;\n}\n","import { MappaError } from \"./errors\";\nimport { EntitiesResource } from \"./resources/entities\";\nimport { FeedbackResource } from \"./resources/feedback\";\nimport { FilesResource } from \"./resources/files\";\nimport { HealthResource } from \"./resources/health\";\nimport { JobsResource } from \"./resources/jobs\";\nimport { MatchingAnalysisResource } from \"./resources/matching-analysis\";\nimport { ReportsResource } from \"./resources/reports\";\nimport { type Telemetry, Transport } from \"./resources/transport\";\nimport { WebhooksResource } from \"./resources/webhooks\";\n\nexport type MappaClientOptions = {\n\t/** API key used for Mappa authenticated requests. */\n\tapiKey: string;\n\t/** Base API URL. Defaults to https://api.mappa.ai. */\n\tbaseUrl?: string;\n\t/** Per-request timeout in milliseconds. Defaults to 30000. */\n\ttimeoutMs?: number;\n\t/** Number of retry attempts for retryable requests. Defaults to 2. */\n\tmaxRetries?: number;\n\t/** Headers included on every request. */\n\tdefaultHeaders?: Record<string, string>;\n\t/** Custom fetch implementation. */\n\tfetch?: typeof fetch;\n\t/** User-Agent header value sent on requests. */\n\tuserAgent?: string;\n\t/** Request/response/error instrumentation hooks. */\n\ttelemetry?: Telemetry;\n\t/**\n\t * Allow use from browser-like runtimes.\n\t *\n\t * This is unsafe for secret API keys and should only be used when\n\t * credentials are intentionally exposed.\n\t */\n\tdangerouslyAllowBrowser?: boolean;\n};\n\n/**\n * Mappa API client for server and worker runtimes.\n */\nexport class Mappa {\n\tpublic readonly files: FilesResource;\n\tpublic readonly jobs: JobsResource;\n\tpublic readonly reports: ReportsResource;\n\tpublic readonly matchingAnalysis: MatchingAnalysisResource;\n\tpublic readonly feedback: FeedbackResource;\n\tpublic readonly entities: EntitiesResource;\n\tpublic readonly webhooks: WebhooksResource;\n\tpublic readonly health: HealthResource;\n\n\tprivate readonly transport: Transport;\n\tprivate readonly opts: Required<\n\t\tPick<MappaClientOptions, \"apiKey\" | \"baseUrl\" | \"timeoutMs\" | \"maxRetries\">\n\t> &\n\t\tOmit<MappaClientOptions, \"apiKey\" | \"baseUrl\" | \"timeoutMs\" | \"maxRetries\">;\n\n\t/** Create a new client instance. */\n\tconstructor(options: MappaClientOptions) {\n\t\tif (!options.apiKey) throw new MappaError(\"apiKey is required\");\n\t\tif (isBrowserRuntime() && !options.dangerouslyAllowBrowser) {\n\t\t\tthrow new MappaError(\n\t\t\t\t\"Mappa SDK cannot run in browser environments by default because API keys are secret. Use a server/edge proxy or pass dangerouslyAllowBrowser: true only if you understand the risk.\",\n\t\t\t);\n\t\t}\n\n\t\tconst baseUrl = options.baseUrl ?? \"https://api.mappa.ai\";\n\t\tconst timeoutMs = options.timeoutMs ?? 30000;\n\t\tconst maxRetries = options.maxRetries ?? 2;\n\n\t\tthis.opts = {\n\t\t\t...options,\n\t\t\tapiKey: options.apiKey,\n\t\t\tbaseUrl,\n\t\t\ttimeoutMs,\n\t\t\tmaxRetries,\n\t\t};\n\n\t\tthis.transport = new Transport({\n\t\t\tapiKey: options.apiKey,\n\t\t\tbaseUrl,\n\t\t\ttimeoutMs,\n\t\t\tmaxRetries,\n\t\t\tdefaultHeaders: options.defaultHeaders,\n\t\t\tfetch: options.fetch,\n\t\t\ttelemetry: options.telemetry,\n\t\t\tuserAgent: options.userAgent,\n\t\t});\n\n\t\tthis.files = new FilesResource(this.transport);\n\t\tthis.jobs = new JobsResource(this.transport);\n\t\tthis.reports = new ReportsResource(\n\t\t\tthis.transport,\n\t\t\tthis.jobs,\n\t\t\tthis.files,\n\t\t\tthis.opts.fetch ?? fetch,\n\t\t);\n\t\tthis.matchingAnalysis = new MatchingAnalysisResource(\n\t\t\tthis.transport,\n\t\t\tthis.jobs,\n\t\t);\n\t\tthis.feedback = new FeedbackResource(this.transport);\n\t\tthis.entities = new EntitiesResource(this.transport);\n\t\tthis.webhooks = new WebhooksResource();\n\t\tthis.health = new HealthResource(this.transport);\n\t}\n\n\t/** Clone the client with option overrides. */\n\twithOptions(overrides: Partial<MappaClientOptions>): Mappa {\n\t\treturn new Mappa({\n\t\t\t...this.opts,\n\t\t\t...overrides,\n\t\t\tapiKey: overrides.apiKey ?? this.opts.apiKey,\n\t\t});\n\t}\n\n\tclose(): void {}\n}\n\nfunction isBrowserRuntime(): boolean {\n\tif (typeof window === \"undefined\") return false;\n\tif (typeof document === \"undefined\") return false;\n\treturn true;\n}\n","export type JsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| { [k: string]: JsonValue }\n\t| JsonValue[];\n\nexport type ReportTemplateId =\n\t| \"sales_playbook\"\n\t| \"general_report\"\n\t| \"hiring_report\"\n\t| \"profile_alignment\";\n\nexport type ReportOutputType = \"markdown\" | \"json\" | \"pdf\" | \"url\";\n\nexport type ReportOutput = {\n\ttemplate: ReportTemplateId;\n\ttemplateParams?: Record<string, unknown>;\n};\n\nexport type TargetSelector =\n\t| {\n\t\t\tstrategy: \"dominant\";\n\t\t\tonMiss?: \"fallback_dominant\" | \"error\";\n\t }\n\t| {\n\t\t\tstrategy: \"timerange\";\n\t\t\tonMiss?: \"fallback_dominant\" | \"error\";\n\t\t\ttimeRange?: { startSeconds?: number; endSeconds?: number };\n\t }\n\t| {\n\t\t\tstrategy: \"entity_id\";\n\t\t\tonMiss?: \"fallback_dominant\" | \"error\";\n\t\t\tentityId: string;\n\t }\n\t| {\n\t\t\tstrategy: \"magic_hint\";\n\t\t\tonMiss?: \"fallback_dominant\" | \"error\";\n\t\t\thint: string;\n\t };\n\nexport type WebhookConfig = {\n\turl: string;\n\theaders?: Record<string, string>;\n};\n\nexport type ReportCreateJobRequest = {\n\tmedia: { mediaId: string };\n\toutput: ReportOutput;\n\ttarget: TargetSelector;\n\tlabel?: string;\n\tentityLabel?: string;\n\twebhook?: WebhookConfig;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport type JobStage =\n\t| \"uploaded\"\n\t| \"queued\"\n\t| \"transcoding\"\n\t| \"extracting\"\n\t| \"scoring\"\n\t| \"rendering\"\n\t| \"finalizing\";\n\nexport type JobStatus =\n\t| \"queued\"\n\t| \"running\"\n\t| \"succeeded\"\n\t| \"failed\"\n\t| \"canceled\";\n\nexport type Usage = {\n\tcreditsUsed: number;\n\tcreditsDiscounted?: number;\n\tcreditsNetUsed: number;\n\tdurationMs?: number;\n\tmodelVersion?: string;\n};\n\nexport type JobCreditReservation = {\n\treservedCredits: number | null;\n\treservationStatus: \"active\" | \"released\" | \"applied\" | null;\n};\n\nexport type Job = {\n\tid: string;\n\ttype: \"report.generate\";\n\tstatus: JobStatus;\n\tstage?: JobStage;\n\tprogress?: number;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\treportId?: string;\n\tusage?: Usage;\n\tcredits?: JobCreditReservation;\n\treleasedCredits?: number | null;\n\terror?: {\n\t\tcode: string;\n\t\tmessage: string;\n\t\tdetails?: unknown;\n\t\tretryable?: boolean;\n\t};\n\trequestId?: string;\n};\n\nexport type JobEvent =\n\t| { type: \"status\"; job: Job }\n\t| { type: \"stage\"; stage: JobStage; progress?: number; job: Job }\n\t| { type: \"terminal\"; job: Job };\n\nexport type WaitOptions = {\n\ttimeoutMs?: number;\n\tonEvent?: (event: JobEvent) => void;\n\tsignal?: AbortSignal;\n};\n\nexport type Report = {\n\tid: string;\n\tcreatedAt: string;\n\tjobId?: string;\n\tlabel?: string;\n\tsummary?: string;\n\tmedia: { url?: string; mediaId?: string };\n\toutput: {\n\t\ttemplate: ReportTemplateId;\n\t};\n\tentity?: { id: string; label: string | null };\n\tmarkdown?: string | null;\n\tsections?: Array<{\n\t\tsection_title: string;\n\t\tsection_content: unknown;\n\t}> | null;\n\tmetrics?: Record<string, unknown> | null;\n\traw?: unknown;\n\tpdfUrl?: string;\n\treportUrl?: string;\n};\n\nexport type ReportForOutputType = Report;\n\nexport type ReportRunHandle = {\n\tjobId: string;\n\tstream(opts?: {\n\t\tsignal?: AbortSignal;\n\t\tonEvent?: (e: JobEvent) => void;\n\t}): AsyncIterable<JobEvent>;\n\twait(opts?: WaitOptions): Promise<ReportForOutputType>;\n\tcancel(): Promise<Job>;\n\tjob(): Promise<Job>;\n\treport(): Promise<ReportForOutputType | null>;\n};\n\nexport type MatchingAnalysisOutputType = \"markdown\" | \"json\" | \"pdf\" | \"url\";\n\nexport type MatchingAnalysisOutput = {\n\ttemplate: \"matching_analysis\";\n\ttemplateParams?: Record<string, unknown>;\n};\n\nexport type MatchingAnalysisEntitySource =\n\t| {\n\t\t\ttype: \"entity_id\";\n\t\t\tentityId: string;\n\t }\n\t| {\n\t\t\ttype: \"media_target\";\n\t\t\tmediaId: string;\n\t\t\ttarget: TargetSelector;\n\t };\n\nexport type MatchingAnalysisCreateJobRequest = {\n\tentityA: MatchingAnalysisEntitySource;\n\tentityB: MatchingAnalysisEntitySource;\n\tcontext: string;\n\toutput: MatchingAnalysisOutput;\n\tlabel?: string;\n\tentityALabel?: string;\n\tentityBLabel?: string;\n\twebhook?: WebhookConfig;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport type MatchingAnalysisResponse = {\n\tid: string;\n\tcreatedAt: string;\n\tjobId?: string;\n\tlabel?: string;\n\tcontext: string;\n\toutput: {\n\t\ttemplate: \"matching_analysis\";\n\t};\n\tentityA?: { id: string; label: string | null };\n\tentityB?: { id: string; label: string | null };\n\tmarkdown?: string | null;\n\tsections?: Array<{\n\t\tsection_title: string;\n\t\tsection_content: unknown;\n\t}> | null;\n\tmetrics?: Record<string, unknown> | null;\n\traw?: unknown;\n\tpdfUrl?: string;\n\treportUrl?: string;\n};\n\nexport type MatchingAnalysisForOutputType = MatchingAnalysisResponse;\n\nexport type MatchingAnalysisRunHandle = {\n\tjobId: string;\n\tstream(opts?: {\n\t\tsignal?: AbortSignal;\n\t\tonEvent?: (e: JobEvent) => void;\n\t}): AsyncIterable<JobEvent>;\n\twait(opts?: WaitOptions): Promise<MatchingAnalysisForOutputType>;\n\tcancel(): Promise<Job>;\n\tjob(): Promise<Job>;\n\tanalysis(): Promise<MatchingAnalysisForOutputType | null>;\n};\n\nexport type MatchingAnalysisJobReceipt = {\n\tjobId: string;\n\tstatus: \"queued\" | \"running\";\n\tstage?: string;\n\testimatedWaitSec?: number;\n\trequestId?: string;\n\thandle?: MatchingAnalysisRunHandle;\n};\n\nexport type ReportJobReceipt = {\n\tjobId: string;\n\tstatus: \"queued\" | \"running\";\n\tstage?: string;\n\testimatedWaitSec?: number;\n\trequestId?: string;\n\thandle?: ReportRunHandle;\n};\n\nexport type FeedbackCreateRequest = {\n\treportId?: string;\n\tjobId?: string;\n\tmatchingAnalysisId?: string;\n\trating: \"thumbs_up\" | \"thumbs_down\";\n\tcomment?: string;\n\tcorrections?: Array<{ path: string; expected?: unknown; observed?: unknown }>;\n\tidempotencyKey?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport type FeedbackReceipt = {\n\tid: string;\n\tcreatedAt: string;\n\ttarget: {\n\t\treportId?: string;\n\t\tjobId?: string;\n\t\tmatchingAnalysisId?: string;\n\t};\n\trating: \"thumbs_up\" | \"thumbs_down\";\n\tcomment?: string;\n\tcredits: {\n\t\teligible: boolean;\n\t\treason?: string;\n\t\tdiscountApplied: number;\n\t\tnetUsed: number;\n\t};\n};\n\nexport type MediaObject = {\n\tmediaId: string;\n\tcreatedAt: string;\n\tcontentType: string;\n\tlabel?: string | null;\n\tsizeBytes?: number | null;\n\tdurationSeconds?: number | null;\n};\n\nexport type MediaRetention = {\n\texpiresAt: string | null;\n\tdaysRemaining: number | null;\n\tlocked: boolean;\n};\n\nexport type MediaFile = {\n\tmediaId: string;\n\tcreatedAt: string;\n\tcontentType: string;\n\tlabel?: string | null;\n\tsizeBytes?: number | null;\n\tdurationSeconds?: number | null;\n\tprocessingStatus: \"PENDING\" | \"PROCESSING\" | \"COMPLETED\" | \"FAILED\";\n\tlastUsedAt: string | null;\n\tretention: MediaRetention;\n};\n\nexport type FileDeleteReceipt = {\n\tmediaId: string;\n\tdeleted: true;\n};\n\nexport type RetentionLockResult = {\n\tmediaId: string;\n\tretentionLock: boolean;\n\tmessage: string;\n};\n\nexport type ListFilesResponse = {\n\tfiles: MediaFile[];\n\tnextCursor: string | null;\n\thasMore: boolean;\n};\n\nexport type Entity = {\n\tid: string;\n\tlabel: string | null;\n\tcreatedAt: string;\n\tmediaCount: number;\n\tlastSeenAt: string | null;\n};\n\nexport type ListEntitiesResponse = {\n\tentities: Entity[];\n\tcursor: string | null;\n\thasMore: boolean;\n};\n\nexport function hasEntity(\n\treport: Report,\n): report is Report & { entity: { id: string; label: string | null } } {\n\treturn report.entity !== undefined && report.entity !== null;\n}\n","export * from \"./errors\";\nexport { Mappa } from \"./Mappa\";\nexport type {\n\tReportCompletedData,\n\tReportCompletedEvent,\n\tReportFailedData,\n\tReportFailedEvent,\n\tWebhookEvent,\n\tWebhookEventType,\n} from \"./resources/webhooks\";\nexport type * from \"./types\";\nexport { hasEntity } from \"./types\";\n\nimport { InsufficientCreditsError, MappaError, StreamError } from \"./errors\";\n\nexport function isMappaError(err: unknown): err is MappaError {\n\treturn err instanceof MappaError;\n}\n\nexport function isInsufficientCreditsError(\n\terr: unknown,\n): err is InsufficientCreditsError {\n\treturn err instanceof InsufficientCreditsError;\n}\n\nexport function isStreamError(err: unknown): err is StreamError {\n\treturn err instanceof StreamError;\n}\n"],"x_google_ignoreList":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],"mappings":";;;AAAA,MAAM,gBAAgB,OAAO,IAAI,6BAA6B;AAE9D,SAAS,cAAc,SAAkB,SAAS,MAAc;AAC/D,KAAI,YAAY,UAAa,YAAY,KAAM,QAAO;AACtD,KAAI;AAEH,SADa,KAAK,UAAU,SAAS,MAAM,EAAE,CACjC,MAAM,KAAK,CAAC,KAAK,KAAK,SAAS;SACpC;AACP,SAAO,OAAO,QAAQ;;;AAIxB,IAAa,aAAb,cAAgC,MAAM;CACrC,AAAS,OAAO;CAChB;CACA;CAEA,YACC,SACA,MACC;AACD,QAAM,QAAQ;AACd,OAAK,YAAY,MAAM;AACvB,OAAK,OAAO,MAAM;AAClB,OAAK,QAAQ,MAAM;;CAGpB,AAAS,WAAmB;EAC3B,MAAM,QAAQ,CAAC,GAAG,KAAK,KAAK,IAAI,KAAK,UAAU;AAC/C,MAAI,KAAK,KAAM,OAAM,KAAK,WAAW,KAAK,OAAO;AACjD,MAAI,KAAK,UAAW,OAAM,KAAK,iBAAiB,KAAK,YAAY;AACjE,SAAO,MAAM,KAAK,KAAK;;CAGxB,CAAC,iBAAyB;AACzB,SAAO,KAAK,UAAU;;;AAIxB,IAAa,WAAb,cAA8B,WAAW;CAC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